@engenty/wizards-runtime 0.9.8 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/apps/runtime/dist/app.js +18 -1
  2. package/apps/runtime/dist/auth/index.js +10 -1
  3. package/apps/runtime/dist/db/client.js +9 -1
  4. package/apps/runtime/dist/db/migrations/tenant/0022_sync.sql +247 -0
  5. package/apps/runtime/dist/db/migrations/tenant/meta/0022_snapshot.json +3792 -0
  6. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  7. package/apps/runtime/dist/db/schema.js +60 -0
  8. package/apps/runtime/dist/docs/user-guide/cloud-sync.md +85 -0
  9. package/apps/runtime/dist/docs/user-guide/data.md +4 -4
  10. package/apps/runtime/dist/docs/user-guide/meta.json +1 -0
  11. package/apps/runtime/dist/docs/user-guide/test-and-share.md +4 -14
  12. package/apps/runtime/dist/files/blobs.js +13 -0
  13. package/apps/runtime/dist/index.js +7 -1
  14. package/apps/runtime/dist/plugins/jobs.js +7 -0
  15. package/apps/runtime/dist/routes/api.js +107 -0
  16. package/apps/runtime/dist/routes/studio.js +62 -0
  17. package/apps/runtime/dist/services/cloud.js +39 -5
  18. package/apps/runtime/dist/services/projects.js +11 -0
  19. package/apps/runtime/dist/sync/apply.js +39 -0
  20. package/apps/runtime/dist/sync/client.js +828 -0
  21. package/apps/runtime/dist/sync/hub.js +324 -0
  22. package/apps/runtime/dist/sync/log.js +74 -0
  23. package/apps/runtime/dist/sync/records.js +943 -0
  24. package/apps/runtime/dist/sync/state.js +17 -0
  25. package/apps/web/dist/assets/{AboutDialog-B_Ixp_Tb.js → AboutDialog-D1YHT0jc.js} +1 -1
  26. package/apps/web/dist/assets/{ChangelogDialog-BpEIbAZ8.js → ChangelogDialog-Bv02g8av.js} +1 -1
  27. package/apps/web/dist/assets/{EditorPage-CKHY4hn4.js → EditorPage-BThoZwqO.js} +4 -4
  28. package/apps/web/dist/assets/{FlowPreview-APXdRflR.js → FlowPreview-dc5C92kK.js} +1 -1
  29. package/apps/web/dist/assets/{Harness-BsGXMlLg.js → Harness-D0nFOIVx.js} +1 -1
  30. package/apps/web/dist/assets/{Marketplace-Dr-Qnb-F.js → Marketplace-Cnd8BF3q.js} +2 -2
  31. package/apps/web/dist/assets/{NewWizardChannels-0JrRdUFd.js → NewWizardChannels-i62Y_2DZ.js} +1 -1
  32. package/apps/web/dist/assets/{NewWizardPage-9igFL5O8.js → NewWizardPage-BcpRA1fx.js} +1 -1
  33. package/apps/web/dist/assets/{OnboardingPage-BcK9FUnU.js → OnboardingPage-BcMDEXNq.js} +1 -1
  34. package/apps/web/dist/assets/PreviewPane-GHcVV2Hu.js +4 -0
  35. package/apps/web/dist/assets/ProjectPage-TDywzUOd.js +1 -0
  36. package/apps/web/dist/assets/{PublicRunner-CZR1ziQ4.js → PublicRunner-B6JINLpR.js} +1 -1
  37. package/apps/web/dist/assets/{ReadOnly-BraZbEG_.js → ReadOnly-Mv5M2OV9.js} +1 -1
  38. package/apps/web/dist/assets/SettingsPage-B-F1dLgt.js +2 -0
  39. package/apps/web/dist/assets/{SetupPage-CvkE2aKx.js → SetupPage-CVdsdVBW.js} +1 -1
  40. package/apps/web/dist/assets/{SharePage-Dk7zC5Zo.js → SharePage-CBSRK0wF.js} +1 -1
  41. package/apps/web/dist/assets/changelog-BR1lxaWv.js +1 -0
  42. package/apps/web/dist/assets/{coins-391m1e4_.js → coins-BGZKYmu6.js} +1 -1
  43. package/apps/web/dist/assets/index-D3-kv1WF.js +14 -0
  44. package/apps/web/dist/assets/{phone-DvgrtyNO.js → phone-BzHhwehj.js} +1 -1
  45. package/apps/web/dist/assets/{runners-4OBelIgF.js → runners-C1-zIlry.js} +1 -1
  46. package/apps/web/dist/assets/{session-DvnGHbDz.js → session-B_JeZnJ0.js} +1 -1
  47. package/apps/web/dist/assets/{settings-menu-xK9A-gaP.js → settings-menu-BZRGhsIO.js} +1 -1
  48. package/apps/web/dist/assets/{theme-D3yDT4QT.js → theme-HcCfZDzS.js} +2 -2
  49. package/apps/web/dist/assets/{ui-BVQk2DtW.js → ui-BI1RPFWT.js} +1 -1
  50. package/apps/web/dist/assets/{upload-BgXbzG6C.js → upload-CwT8oMz0.js} +1 -1
  51. package/apps/web/dist/assets/{useMutation-DkwSQWoD.js → useMutation-byk81dDj.js} +1 -1
  52. package/apps/web/dist/assets/{volume-2-DHGoe3Cg.js → volume-2-B1Pz6Iwt.js} +1 -1
  53. package/apps/web/dist/assets/{wrench-Cf_aE3O0.js → wrench-CvzXRbWN.js} +1 -1
  54. package/apps/web/dist/index.html +7 -7
  55. package/apps/web/dist/mcp/flow.html +1 -1
  56. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +6 -0
  57. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +6 -0
  58. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +6 -0
  59. package/node_modules/@engenty/wizards-shared/dist/run.js +12 -0
  60. package/node_modules/@engenty/wizards-shared/dist/sync-merge.d.ts +55 -0
  61. package/node_modules/@engenty/wizards-shared/dist/sync-merge.js +214 -0
  62. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +166 -0
  63. package/node_modules/@engenty/wizards-shared/dist/sync.js +40 -0
  64. package/node_modules/@engenty/wizards-shared/dist/text-merge.d.ts +14 -0
  65. package/node_modules/@engenty/wizards-shared/dist/text-merge.js +137 -0
  66. package/package.json +1 -1
  67. package/plugin/.claude-plugin/plugin.json +1 -1
  68. package/plugin/plugin.json +1 -1
  69. package/apps/web/dist/assets/PreviewPane-X4LBqA0D.js +0 -4
  70. package/apps/web/dist/assets/ProjectPage-CG0i-KhR.js +0 -1
  71. package/apps/web/dist/assets/SettingsPage-Bw4tdoV7.js +0 -2
  72. package/apps/web/dist/assets/changelog-DDXnAaHm.js +0 -1
  73. package/apps/web/dist/assets/index-BTUtot4r.js +0 -14
@@ -1 +1 @@
1
- import{Jr as e}from"./ui-BVQk2DtW.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{Jr as e}from"./ui-BI1RPFWT.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{vn as e}from"./ui-BVQk2DtW.js";var t=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`film`,`surface`];[...e],[...t];var n={default:`steps`,enabled:[`steps`,`chat`]};export{n as t};
1
+ import{vn as e}from"./ui-BI1RPFWT.js";var t=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`film`,`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,Ai as i,At as a,Ht as o,Jr as s,W as c,Y as l,ai as u,an as ee,on as te,rn as d,wn as ne}from"./ui-BVQk2DtW.js";import{t as re}from"./preload-helper-DpV6A1kQ.js";import{c as ie,s as ae,t as f}from"./engenty-CNjaZCVM.js";import"./logo-CGNoptDg.js";var p={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`}]]};p.node;var m=s(p),h={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`}]]};h.node;var g=s(h),_=e(t(),1),v=`wizards.theme`,y=new Set,b=window.matchMedia(`(prefers-color-scheme: dark)`),x=`engenty_theme`;function S(){let e=document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`${x}=`))?.slice(14);return e===`light`||e===`dark`||e===`system`?e:null}function C(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=`${x}=${e}; Path=/; Max-Age=31536000; SameSite=Lax${r?`; Domain=${r}`:``}${i}`}function w(){try{let e=S()??localStorage.getItem(v);return e===`system`?null:e===`light`?`light`:`dark`}catch{return`dark`}}var T=0,E=null,D=null;function O(){try{return S()!==null||localStorage.getItem(v)!==null}catch{return!1}}function k(){return T>0?`dark`:E||(D&&!O()?D:w()??(b.matches?`dark`:`light`))}function A(){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 j(){let e=k()===`dark`;document.documentElement.classList.toggle(`dark`,e),A();for(let e of y)e()}b.addEventListener(`change`,j),S()||C(w()??`system`),j();function M(e){C(e??`system`);try{localStorage.setItem(v,e??`system`)}catch{document.documentElement.classList.toggle(`dark`,(e??k())===`dark`);return}j()}function N(){return(0,_.useSyncExternalStore)(e=>(y.add(e),()=>y.delete(e)),w)}function oe(){return(0,_.useSyncExternalStore)(e=>(y.add(e),()=>y.delete(e)),()=>w()??(b.matches?`dark`:`light`))}function P(){return(0,_.useSyncExternalStore)(e=>(y.add(e),()=>y.delete(e)),()=>document.documentElement.classList.contains(`dark`)?`dark`:`light`)}var F=e=>`oklch(from ${ae[ie[e]??`cobalt`]} 0.34 calc(c * 0.6) h)`;function se(e){(0,_.useEffect)(()=>{if(!e)return;let t=document.documentElement;return T+=1,t.style.setProperty(`--stage`,e),j(),()=>{--T,t.style.removeProperty(`--stage`),j()}},[e])}function I(e){(0,_.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--engenty-stage`,F(e)),A(),()=>{t.style.removeProperty(`--engenty-stage`),A()}},[e])}function L(e){(0,_.useEffect)(()=>{if(e)return D=e,j(),()=>{D=null,j()}},[e])}function R(e){(0,_.useEffect)(()=>{if(e)return E=e,j(),()=>{E=null,j()}},[e])}function z(){return(0,_.useSyncExternalStore)(e=>(y.add(e),()=>y.delete(e)),()=>E!==null)}var B=e(n(),1),V={name:`engenty wizards`,short:`wizards`},H=(0,_.lazy)(()=>re(()=>import(`./fluffy-engenty-o_lu9icd.js`).then(e=>({default:e.FluffyEngenty})),__vite__mapDeps([0,1,2,3])));function U({kind:e,size:t=64,fluffy:n,coat:r,costume:i,helmet:a=!1,interactive:o=!0}){let s=e||`round`,c=P(),l=r??(c===`dark`?`jelly`:`fur`);if(n&&t>=120&&(l===`fur`||c===`dark`))return(0,B.jsx)(_.Suspense,{fallback:(0,B.jsx)(f,{costume:i,helmet:a,kind:s,size:Math.round(t*.62)}),children:(0,B.jsx)(H,{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,B.jsxs)(`div`,{"aria-hidden":`true`,className:`relative flex items-center justify-center overflow-hidden`,style:{background:F(s),borderRadius:t*.28,height:t,width:t},children:[(0,B.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,B.jsx)(`div`,{className:`relative`,style:{marginTop:t*.04},children:(0,B.jsx)(_.Suspense,{fallback:(0,B.jsx)(f,{costume:i,helmet:a,kind:s,size:Math.round(e*.62)}),children:(0,B.jsx)(H,{costume:i,gooseHelmet:a,coat:`jelly`,kind:s,size:e,quality:`medium`,interactive:o})})})]})}return(0,B.jsx)(f,{costume:i,helmet:a,kind:s,size:t,animated:o})}function W(){let e=P(),t=z(),n=e===`dark`?`light`:`dark`;return t?null:(0,B.jsx)(o,{label:te(n===`dark`?`theme.dark`:`theme.light`),onClick:()=>M(n),children:e===`dark`?(0,B.jsx)(g,{className:`size-4`}):(0,B.jsx)(m,{className:`size-4`})})}function G(e){return Object.fromEntries(ne.filter(t=>e[t]?.startsWith(`apple:`)).map(e=>[e,``]))}function K(e){return e.split(/\s+/).map(e=>e[0]??``).join(``).slice(0,2).toUpperCase()}function ce(){let e=q().data?.limits.projects;return e===null||(e??1)>1}function le(){return q().data?.limits.build??!0}function ue(){return q().data?.limits.create??!0}function de(){let e=q().data;return!e||e.mode===`local`||e.tenant.role!==`member`}function fe(e){return e.mode===`managed`?e.credits:e.models?.source===`account`?e.account?.credits??null:null}function pe(){let e=i();return t=>{d(t),e.setQueryData([`me`],e=>e&&{...e,lang:t}),c.put(`/api/studio/lang`,{lang:t}).catch(()=>void 0)}}function me(e){let t=i();(0,_.useEffect)(()=>{if(!e)return;if(e.lang){d(e.lang);return}let n=ee();n&&(t.setQueryData([`me`],e=>e&&{...e,lang:n}),c.put(`/api/studio/lang`,{lang:n}).catch(()=>void 0))},[e,t])}function q(){return u({queryKey:[`me`],queryFn:async()=>{try{return await c.get(`/api/studio/me`)}catch(e){if(e instanceof a&&e.status===401)return null;throw e}},staleTime:3e4})}function J(e=!0){return u({queryKey:[`projects`],queryFn:()=>c.get(`/api/studio/projects`),enabled:e})}var Y=`wz.project`;function he(){try{return localStorage.getItem(Y)}catch{return null}}var X=he(),Z=new Set;function ge(e){X=e;try{localStorage.setItem(Y,e)}catch{}for(let e of Z)e()}function _e(){let e=J(),t=(0,_.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:ge,loading:e.isLoading}}function ve(e,t){return u({queryKey:[`cloud`,e],queryFn:()=>c.get(`/api/studio/wizards/${e}/cloud`),enabled:t})}function Q(e){return e instanceof a&&e.body?.code===`read_only`?e.message:null}async function ye(){let{account:e}=await(await fetch(r(`/api/auth/sign-out`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:`{}`})).json().catch(()=>({}));if(!e){window.location.href=`${l}/`;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}${l}/`,t.append(n),document.body.append(t),t.submit()}function be(e=window.location.pathname,t){let n=new URLSearchParams({return:e});t?.trim()&&n.set(`wish`,t.trim()),window.location.href=r(`/api/auth/login?${n}`)}var $=`wizards.wish`,xe=1;function Se(e){try{localStorage.setItem($,JSON.stringify({text:e,at:Date.now()}))}catch{}}function Ce(){try{let e=JSON.parse(localStorage.getItem($)??`null`);if(typeof e?.text==`string`&&typeof e.at==`number`&&Date.now()-e.at<xe*864e5)return e.text}catch{}return null}function we(){try{localStorage.removeItem($)}catch{}}export{N as A,M as C,oe as D,L as E,m as M,I as O,W as S,R as T,pe as _,Q as a,V as b,fe as c,_e as d,de as f,q as g,ue as h,Ce as i,g as j,P as k,me as l,le as m,K as n,be as o,ce as p,Se as r,ye as s,we as t,ve as u,J as v,se as w,U as x,G 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,Ai as i,At as a,Ht as o,Jr as s,W as c,Y as l,ai as u,an as ee,on as te,rn as d,wn as ne}from"./ui-BI1RPFWT.js";import{t as re}from"./preload-helper-DpV6A1kQ.js";import{c as ie,s as ae,t as f}from"./engenty-CNjaZCVM.js";import"./logo-CGNoptDg.js";var p={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`}]]};p.node;var m=s(p),h={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`}]]};h.node;var g=s(h),_=e(t(),1),v=`wizards.theme`,y=new Set,b=window.matchMedia(`(prefers-color-scheme: dark)`),x=`engenty_theme`;function S(){let e=document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`${x}=`))?.slice(14);return e===`light`||e===`dark`||e===`system`?e:null}function C(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=`${x}=${e}; Path=/; Max-Age=31536000; SameSite=Lax${r?`; Domain=${r}`:``}${i}`}function w(){try{let e=S()??localStorage.getItem(v);return e===`system`?null:e===`light`?`light`:`dark`}catch{return`dark`}}var T=0,E=null,D=null;function O(){try{return S()!==null||localStorage.getItem(v)!==null}catch{return!1}}function k(){return T>0?`dark`:E||(D&&!O()?D:w()??(b.matches?`dark`:`light`))}function A(){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 j(){let e=k()===`dark`;document.documentElement.classList.toggle(`dark`,e),A();for(let e of y)e()}b.addEventListener(`change`,j),S()||C(w()??`system`),j();function M(e){C(e??`system`);try{localStorage.setItem(v,e??`system`)}catch{document.documentElement.classList.toggle(`dark`,(e??k())===`dark`);return}j()}function N(){return(0,_.useSyncExternalStore)(e=>(y.add(e),()=>y.delete(e)),w)}function oe(){return(0,_.useSyncExternalStore)(e=>(y.add(e),()=>y.delete(e)),()=>w()??(b.matches?`dark`:`light`))}function P(){return(0,_.useSyncExternalStore)(e=>(y.add(e),()=>y.delete(e)),()=>document.documentElement.classList.contains(`dark`)?`dark`:`light`)}var F=e=>`oklch(from ${ae[ie[e]??`cobalt`]} 0.34 calc(c * 0.6) h)`;function se(e){(0,_.useEffect)(()=>{if(!e)return;let t=document.documentElement;return T+=1,t.style.setProperty(`--stage`,e),j(),()=>{--T,t.style.removeProperty(`--stage`),j()}},[e])}function I(e){(0,_.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--engenty-stage`,F(e)),A(),()=>{t.style.removeProperty(`--engenty-stage`),A()}},[e])}function L(e){(0,_.useEffect)(()=>{if(e)return D=e,j(),()=>{D=null,j()}},[e])}function R(e){(0,_.useEffect)(()=>{if(e)return E=e,j(),()=>{E=null,j()}},[e])}function z(){return(0,_.useSyncExternalStore)(e=>(y.add(e),()=>y.delete(e)),()=>E!==null)}var B=e(n(),1),V={name:`engenty wizards`,short:`wizards`},H=(0,_.lazy)(()=>re(()=>import(`./fluffy-engenty-o_lu9icd.js`).then(e=>({default:e.FluffyEngenty})),__vite__mapDeps([0,1,2,3])));function U({kind:e,size:t=64,fluffy:n,coat:r,costume:i,helmet:a=!1,interactive:o=!0}){let s=e||`round`,c=P(),l=r??(c===`dark`?`jelly`:`fur`);if(n&&t>=120&&(l===`fur`||c===`dark`))return(0,B.jsx)(_.Suspense,{fallback:(0,B.jsx)(f,{costume:i,helmet:a,kind:s,size:Math.round(t*.62)}),children:(0,B.jsx)(H,{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,B.jsxs)(`div`,{"aria-hidden":`true`,className:`relative flex items-center justify-center overflow-hidden`,style:{background:F(s),borderRadius:t*.28,height:t,width:t},children:[(0,B.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,B.jsx)(`div`,{className:`relative`,style:{marginTop:t*.04},children:(0,B.jsx)(_.Suspense,{fallback:(0,B.jsx)(f,{costume:i,helmet:a,kind:s,size:Math.round(e*.62)}),children:(0,B.jsx)(H,{costume:i,gooseHelmet:a,coat:`jelly`,kind:s,size:e,quality:`medium`,interactive:o})})})]})}return(0,B.jsx)(f,{costume:i,helmet:a,kind:s,size:t,animated:o})}function W(){let e=P(),t=z(),n=e===`dark`?`light`:`dark`;return t?null:(0,B.jsx)(o,{label:te(n===`dark`?`theme.dark`:`theme.light`),onClick:()=>M(n),children:e===`dark`?(0,B.jsx)(g,{className:`size-4`}):(0,B.jsx)(m,{className:`size-4`})})}function G(e){return Object.fromEntries(ne.filter(t=>e[t]?.startsWith(`apple:`)).map(e=>[e,``]))}function K(e){return e.split(/\s+/).map(e=>e[0]??``).join(``).slice(0,2).toUpperCase()}function ce(){let e=q().data?.limits.projects;return e===null||(e??1)>1}function le(){return q().data?.limits.build??!0}function ue(){return q().data?.limits.create??!0}function de(){let e=q().data;return!e||e.mode===`local`||e.tenant.role!==`member`}function fe(e){return e.mode===`managed`?e.credits:e.models?.source===`account`?e.account?.credits??null:null}function pe(){let e=i();return t=>{d(t),e.setQueryData([`me`],e=>e&&{...e,lang:t}),c.put(`/api/studio/lang`,{lang:t}).catch(()=>void 0)}}function me(e){let t=i();(0,_.useEffect)(()=>{if(!e)return;if(e.lang){d(e.lang);return}let n=ee();n&&(t.setQueryData([`me`],e=>e&&{...e,lang:n}),c.put(`/api/studio/lang`,{lang:n}).catch(()=>void 0))},[e,t])}function q(){return u({queryKey:[`me`],queryFn:async()=>{try{return await c.get(`/api/studio/me`)}catch(e){if(e instanceof a&&e.status===401)return null;throw e}},staleTime:3e4})}function J(e=!0){return u({queryKey:[`projects`],queryFn:()=>c.get(`/api/studio/projects`),enabled:e})}var Y=`wz.project`;function he(){try{return localStorage.getItem(Y)}catch{return null}}var X=he(),Z=new Set;function ge(e){X=e;try{localStorage.setItem(Y,e)}catch{}for(let e of Z)e()}function _e(){let e=J(),t=(0,_.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:ge,loading:e.isLoading}}function ve(e,t){return u({queryKey:[`cloud`,e],queryFn:()=>c.get(`/api/studio/wizards/${e}/cloud`),enabled:t})}function Q(e){return e instanceof a&&e.body?.code===`read_only`?e.message:null}async function ye(){let{account:e}=await(await fetch(r(`/api/auth/sign-out`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:`{}`})).json().catch(()=>({}));if(!e){window.location.href=`${l}/`;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}${l}/`,t.append(n),document.body.append(t),t.submit()}function be(e=window.location.pathname,t){let n=new URLSearchParams({return:e});t?.trim()&&n.set(`wish`,t.trim()),window.location.href=r(`/api/auth/login?${n}`)}var $=`wizards.wish`,xe=1;function Se(e){try{localStorage.setItem($,JSON.stringify({text:e,at:Date.now()}))}catch{}}function Ce(){try{let e=JSON.parse(localStorage.getItem($)??`null`);if(typeof e?.text==`string`&&typeof e.at==`number`&&Date.now()-e.at<xe*864e5)return e.text}catch{}return null}function we(){try{localStorage.removeItem($)}catch{}}export{N as A,M as C,oe as D,L as E,m as M,I as O,W as S,R as T,pe as _,Q as a,V as b,fe as c,_e as d,de as f,q as g,ue as h,Ce as i,g as j,P as k,me as l,le as m,K as n,be as o,ce as p,Se as r,ye as s,we as t,ve as u,J as v,se as w,U as x,G 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{$t as r,Br as i,Kr as a,Rr as o,Xr as s,zr as c}from"./ui-BVQk2DtW.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:i}){let o=t??i??null,s=t?n:i?.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:r(`shrink-0 overflow-hidden transition-[width,margin,opacity] duration-200 ease-out`,o&&s?`-ml-1.5 mr-0.5 w-8 opacity-100`:`w-0 opacity-0`),children:(0,p.jsx)(`button`,{type:`button`,onClick:s,"aria-hidden":!(o&&s),tabIndex:o&&s?void 0:-1,"aria-label":t?e:i?.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`})})}),o?(0,p.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-medium text-[0.875rem]`,children:[(0,p.jsx)(o.icon,{className:`size-4 shrink-0 text-ember-strong`}),(0,p.jsx)(`span`,{className:`truncate`,children:o.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(e=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(s,{to:e.to,onClick:r=>{e.id===t?.id&&(r.preventDefault(),n(e))},"aria-current":e.id===t?.id?`page`:void 0,className:r(`group flex items-center gap-2 rounded-lg px-2 py-1 text-[0.875rem] transition max-md:py-2`,e.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)(e.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:e.label}),(0,p.jsx)(o,{className:`size-4 text-ink-4 md:hidden`})]})},e.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)(c,{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:a,children:o}){let[s,c]=(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:()=>c(!s),"aria-expanded":s,className:r(`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}),s?null:(0,p.jsx)(`span`,{className:`tabular-nums tracking-normal`,children:a}),(0,p.jsx)(i,{className:r(`size-3.5 transition-transform`,s?null:`-rotate-90`)})]}):(0,p.jsx)(`p`,{className:r(`mb-1 px-2`,l),children:e}),s?(0,p.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:o}):null]})}function T({icon:e,label:t,badge:n,tone:i,toneLabel:a,selected:s,disabled:c,onPick:l}){return(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{type:`button`,onClick:l,disabled:c,"aria-current":s?`page`:void 0,className:r(`group flex w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-[0.875rem] transition max-md:py-2`,s?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`,c&&`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:r(`size-4 transition-transform duration-200 ease-out`,!c&&`group-hover:scale-110`,s?`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:r(`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,c?null:(0,p.jsx)(o,{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{$t as r,Br as i,Kr as a,Rr as o,Xr as s,zr as c}from"./ui-BI1RPFWT.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:i}){let o=t??i??null,s=t?n:i?.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:r(`shrink-0 overflow-hidden transition-[width,margin,opacity] duration-200 ease-out`,o&&s?`-ml-1.5 mr-0.5 w-8 opacity-100`:`w-0 opacity-0`),children:(0,p.jsx)(`button`,{type:`button`,onClick:s,"aria-hidden":!(o&&s),tabIndex:o&&s?void 0:-1,"aria-label":t?e:i?.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`})})}),o?(0,p.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-medium text-[0.875rem]`,children:[(0,p.jsx)(o.icon,{className:`size-4 shrink-0 text-ember-strong`}),(0,p.jsx)(`span`,{className:`truncate`,children:o.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(e=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(s,{to:e.to,onClick:r=>{e.id===t?.id&&(r.preventDefault(),n(e))},"aria-current":e.id===t?.id?`page`:void 0,className:r(`group flex items-center gap-2 rounded-lg px-2 py-1 text-[0.875rem] transition max-md:py-2`,e.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)(e.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:e.label}),(0,p.jsx)(o,{className:`size-4 text-ink-4 md:hidden`})]})},e.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)(c,{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:a,children:o}){let[s,c]=(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:()=>c(!s),"aria-expanded":s,className:r(`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}),s?null:(0,p.jsx)(`span`,{className:`tabular-nums tracking-normal`,children:a}),(0,p.jsx)(i,{className:r(`size-3.5 transition-transform`,s?null:`-rotate-90`)})]}):(0,p.jsx)(`p`,{className:r(`mb-1 px-2`,l),children:e}),s?(0,p.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:o}):null]})}function T({icon:e,label:t,badge:n,tone:i,toneLabel:a,selected:s,disabled:c,onPick:l}){return(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{type:`button`,onClick:l,disabled:c,"aria-current":s?`page`:void 0,className:r(`group flex w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-[0.875rem] transition max-md:py-2`,s?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`,c&&`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:r(`size-4 transition-transform duration-200 ease-out`,!c&&`group-hover:scale-110`,s?`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:r(`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,c?null:(0,p.jsx)(o,{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{$ as r,$n as i,$t as a,At as o,Cr as s,Dt as c,Et as l,Gt as u,Ht as d,Jr as f,Jt as p,Ot as m,Pn as h,Qn as g,Qt as _,Tn as v,Tr as y,Tt as b,Vr as x,W as S,Wn as C,Wr as w,Zn as T,ar as E,br as D,bt as O,cr as k,ct as A,dr as ee,en as j,er as M,fr as N,gr as P,gt as F,ht as te,ir as I,l as L,ln as R,lt as ne,nr as z,nt as re,on as B,ot as ie,pr as ae,pt as oe,st as se,tn as ce,tr as le,tt as ue,un as de,vt as fe,xt as pe,yn as me,yt as he}from"./ui-BVQk2DtW.js";import{t as ge}from"./react-dom-hf6EcyAr.js";import{t as V}from"./preload-helper-DpV6A1kQ.js";import{t as _e}from"./volume-2-DHGoe3Cg.js";import{E as ve,T as ye,k as be,x as xe}from"./session-DvnGHbDz.js";import{t as Se}from"./phone-DvgrtyNO.js";import{t as Ce}from"./engenty-CNjaZCVM.js";import{$ as we,et as Te,gt as Ee,pt as De,t as Oe,tt as ke}from"./index-BTUtot4r.js";var Ae={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`}]]};Ae.node;var je=f(Ae),Me={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`}]]};Me.node;var Ne=f(Me),Pe={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Pe.node;var Fe=f(Pe),Ie={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`}]]};Ie.node;var Le=f(Ie),Re={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`}]]};Re.node;var ze=f(Re),Be=3e3,Ve=new Set;function He(e,t,n){let r=`${e.family}\n${e.url}`;if(Ve.has(r))return;Ve.add(r);let i=!1,a=setTimeout(()=>i||n(),Be),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 Ue=ge(),H=e(t(),1),U=e(n(),1),We=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function Ge({since:e}){let[t,n]=(0,H.useState)(Date.now());if((0,H.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,U.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function W({label:e,on:t,danger:n,busy:r,onClick:i,children:o}){return(0,U.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:a(`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,U.jsx)(p,{className:`size-5`}):o})}function Ke({voice:e}){let t=(0,H.useRef)(null),{captions:n}=e;return(0,H.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,U.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,U.jsx)(`li`,{className:a(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,U.jsx)(`div`,{ref:t})]})}):null}function qe({voice:e,view:t,video:n,className:r}){let i=e.state===`live`,o=e.state===`connecting`,[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1);(0,H.useEffect)(()=>{c(i?Date.now():null)},[i]);let d=async()=>{u(!1),await e.start(),n&&await e.startCamera()},f=()=>{e.stop(),u(!0)},m=n||e.camera,h=[...e.captions].reverse().find(e=>e.who===`bot`),g=[...e.captions].reverse().find(e=>e.who===`me`),_=e.speaking?B(`talk.speaking`):e.listening?B(`talk.listening`):i?B(`talk.live`):o?B(`talk.connecting`):l?B(`video.ended`):``;return(0,U.jsxs)(`section`,{className:a(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,U.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,U.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),_?(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,U.jsx)(`span`,{className:a(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,_]}):null,(0,U.jsx)(Ge,{since:s})]}),(0,U.jsxs)(`div`,{className:a(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,m?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!m&&i&&e.captions.length?`h-[38%]`:m?``:`flex-1`),children:[(0,U.jsxs)(`div`,{className:a(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!m&&`hidden`),children:[(0,U.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:a(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,U.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,U.jsx)(Le,{className:`size-8`}),(0,U.jsx)(`span`,{className:`text-[0.8125rem]`,children:B(`video.cameraOff`)})]}),(0,U.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[B(`video.you`),e.muted?(0,U.jsx)(Ee,{className:`ml-1.5 inline size-3`}):null]})]}),(0,U.jsxs)(`div`,{className:a(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,m?`bg-neutral-900`:`bg-transparent`,m&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,U.jsx)(`div`,{className:a(`rounded-full transition-shadow duration-500`,!m&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!m&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,U.jsx)(xe,{kind:t?.wizard.avatar??`round`,costume:t?.wizard.costume,size:m?140:200,fluffy:!0,interactive:!1})}),m?(0,U.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&&!m?(0,U.jsx)(Ke,{voice:e}):i&&(h||g)?(0,U.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[g?(0,U.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:g.text}):null,h?(0,U.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:h.text}):null]})}):null,e.error?(0,U.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,U.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(W,{label:B(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,U.jsx)(Ee,{className:`size-5`}):(0,U.jsx)(y,{className:`size-5`})}),(0,U.jsx)(W,{label:B(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,U.jsx)(k,{className:`size-5`}):(0,U.jsx)(Le,{className:`size-5`})}),e.camera&&We?(0,U.jsx)(W,{label:B(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,U.jsx)(ee,{className:`size-5`})}):null,(0,U.jsx)(W,{label:B(`video.leave`),danger:!0,onClick:f,children:(0,U.jsx)(De,{className:`size-5`})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:o||!t?.talk,onClick:()=>void d(),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:[o?(0,U.jsx)(p,{className:`size-4`}):n?(0,U.jsx)(k,{className:`size-5`}):(0,U.jsx)(y,{className:`size-5`}),B(l?`video.rejoin`:n?`video.join`:`talk.start`)]}),!l&&!e.error?(0,U.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:B(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Je=e=>me[e.kind]!==`device`,Ye=1024,Xe=4e3;function Ze(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function Qe(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{$ as r,$n as i,$t as a,At as o,Cr as s,Dt as c,Et as l,Gt as u,Ht as d,Jr as f,Jt as p,Ot as m,Pn as h,Qn as g,Qt as _,Tn as v,Tr as y,Tt as b,Vr as x,W as S,Wn as C,Wr as w,Zn as T,ar as E,br as D,bt as O,cr as k,ct as A,dr as ee,en as j,er as M,fr as N,gr as P,gt as F,ht as te,ir as I,l as L,ln as R,lt as ne,nr as z,nt as re,on as B,ot as ie,pr as ae,pt as oe,st as se,tn as ce,tr as le,tt as ue,un as de,vt as fe,xt as pe,yn as me,yt as he}from"./ui-BI1RPFWT.js";import{t as ge}from"./react-dom-hf6EcyAr.js";import{t as V}from"./preload-helper-DpV6A1kQ.js";import{t as _e}from"./volume-2-B1Pz6Iwt.js";import{E as ve,T as ye,k as be,x as xe}from"./session-B_JeZnJ0.js";import{t as Se}from"./phone-BzHhwehj.js";import{t as Ce}from"./engenty-CNjaZCVM.js";import{ht as we,nt as Te,rt as Ee,t as De,tt as Oe,vt as ke}from"./index-D3-kv1WF.js";var Ae={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`}]]};Ae.node;var je=f(Ae),Me={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`}]]};Me.node;var Ne=f(Me),Pe={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Pe.node;var Fe=f(Pe),Ie={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`}]]};Ie.node;var Le=f(Ie),Re={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`}]]};Re.node;var ze=f(Re),Be=3e3,Ve=new Set;function He(e,t,n){let r=`${e.family}\n${e.url}`;if(Ve.has(r))return;Ve.add(r);let i=!1,a=setTimeout(()=>i||n(),Be),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 Ue=ge(),H=e(t(),1),U=e(n(),1),We=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function Ge({since:e}){let[t,n]=(0,H.useState)(Date.now());if((0,H.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,U.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function W({label:e,on:t,danger:n,busy:r,onClick:i,children:o}){return(0,U.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:a(`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,U.jsx)(p,{className:`size-5`}):o})}function Ke({voice:e}){let t=(0,H.useRef)(null),{captions:n}=e;return(0,H.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,U.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,U.jsx)(`li`,{className:a(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,U.jsx)(`div`,{ref:t})]})}):null}function qe({voice:e,view:t,video:n,className:r}){let i=e.state===`live`,o=e.state===`connecting`,[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1);(0,H.useEffect)(()=>{c(i?Date.now():null)},[i]);let d=async()=>{u(!1),await e.start(),n&&await e.startCamera()},f=()=>{e.stop(),u(!0)},m=n||e.camera,h=[...e.captions].reverse().find(e=>e.who===`bot`),g=[...e.captions].reverse().find(e=>e.who===`me`),_=e.speaking?B(`talk.speaking`):e.listening?B(`talk.listening`):i?B(`talk.live`):o?B(`talk.connecting`):l?B(`video.ended`):``;return(0,U.jsxs)(`section`,{className:a(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,U.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,U.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),_?(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,U.jsx)(`span`,{className:a(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,_]}):null,(0,U.jsx)(Ge,{since:s})]}),(0,U.jsxs)(`div`,{className:a(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,m?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!m&&i&&e.captions.length?`h-[38%]`:m?``:`flex-1`),children:[(0,U.jsxs)(`div`,{className:a(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!m&&`hidden`),children:[(0,U.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:a(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,U.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,U.jsx)(Le,{className:`size-8`}),(0,U.jsx)(`span`,{className:`text-[0.8125rem]`,children:B(`video.cameraOff`)})]}),(0,U.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[B(`video.you`),e.muted?(0,U.jsx)(ke,{className:`ml-1.5 inline size-3`}):null]})]}),(0,U.jsxs)(`div`,{className:a(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,m?`bg-neutral-900`:`bg-transparent`,m&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,U.jsx)(`div`,{className:a(`rounded-full transition-shadow duration-500`,!m&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!m&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,U.jsx)(xe,{kind:t?.wizard.avatar??`round`,costume:t?.wizard.costume,size:m?140:200,fluffy:!0,interactive:!1})}),m?(0,U.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&&!m?(0,U.jsx)(Ke,{voice:e}):i&&(h||g)?(0,U.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[g?(0,U.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:g.text}):null,h?(0,U.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:h.text}):null]})}):null,e.error?(0,U.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,U.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(W,{label:B(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,U.jsx)(ke,{className:`size-5`}):(0,U.jsx)(y,{className:`size-5`})}),(0,U.jsx)(W,{label:B(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,U.jsx)(k,{className:`size-5`}):(0,U.jsx)(Le,{className:`size-5`})}),e.camera&&We?(0,U.jsx)(W,{label:B(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,U.jsx)(ee,{className:`size-5`})}):null,(0,U.jsx)(W,{label:B(`video.leave`),danger:!0,onClick:f,children:(0,U.jsx)(we,{className:`size-5`})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:o||!t?.talk,onClick:()=>void d(),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:[o?(0,U.jsx)(p,{className:`size-4`}):n?(0,U.jsx)(k,{className:`size-5`}):(0,U.jsx)(y,{className:`size-5`}),B(l?`video.rejoin`:n?`video.join`:`talk.start`)]}),!l&&!e.error?(0,U.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:B(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Je=e=>me[e.kind]!==`device`,Ye=1024,Xe=4e3;function Ze(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function Qe(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: ${j(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}: ${Ze(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 $e(e,t,n,r){let[i,a]=(0,H.useState)(`off`),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(`environment`),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)([]),b=(0,H.useRef)(null),x=(0,H.useRef)(null),C=(0,H.useRef)(0),w=(0,H.useRef)(!1);w.current=f;let T=(0,H.useRef)(null),E=(0,H.useRef)(null),D=(0,H.useRef)(null),O=(0,H.useRef)(null),k=(0,H.useRef)(t);k.current=t;let A=(0,H.useRef)(r);A.current=r;let ee=(0,H.useRef)(n);ee.current=n;let j=(0,H.useRef)(``),M=(0,H.useCallback)(e=>{let t=E.current;t&&t.readyState===`open`&&t.send(JSON.stringify(e))},[]),N=(0,H.useCallback)(()=>{let e=b.current;if(!w.current||!e||e.videoWidth===0)return null;let t=Math.min(1,Ye/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,H.useCallback)(()=>{for(let e of x.current?.getTracks()??[])e.stop();x.current=null,b.current&&(b.current.srcObject=null),p(!1)},[]),F=(0,H.useCallback)(async e=>{if(x.current)return;let t=e??`environment`;try{let e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:t},width:{ideal:1280}},audio:!1});x.current=e;let n=e.getVideoTracks()[0]?.getSettings().facingMode;h(n===`user`||n===`environment`?n:t),b.current&&(b.current.srcObject=e,await b.current.play().catch(()=>void 0)),p(!0)}catch(e){s(e.name===`NotAllowedError`?B(`talk.cameraDenied`):e.message)}},[]),te=(0,H.useCallback)(async()=>{let e=m===`user`?`environment`:`user`;P(),await F(e)},[m,P,F]),I=(0,H.useCallback)(()=>{_(e=>{for(let t of O.current?.getAudioTracks()??[])t.enabled=e;return!e})},[]),L=(0,H.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=``,l(!1),d(!1),_(!1),a(`off`)},[P]);(0,H.useEffect)(()=>()=>L(),[L]);let R=(0,H.useCallback)(async(t,n)=>{let r=k.current,i=A.current,a=ee.current;switch(t){case`get_state`:return r?Qe(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 S.upload(`/api/runs/${e}/uploads`,a),s=i.values[t.id],c=t.multiple?[...Array.isArray(s)?s:s?[s]:[],o.id]:o.id,l=i.setField(t.id,c);return l?`refused: ${l}`:`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&&Je(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 S.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]),ne=(0,H.useCallback)(async()=>{if(!T.current){s(null),y([]),a(`connecting`);try{let t=await S.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`:l(!0);break;case`output_audio_buffer.stopped`:case`output_audio_buffer.cleared`:l(!1);break;case`input_audio_buffer.speech_started`:{d(!0);let e=Date.now()-C.current>Xe?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`:d(!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`;y(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{}R(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=Qe(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&&L()};let c=await r.createOffer();await r.setLocalDescription(c);let u=await fetch(t.endpoint,{method:`POST`,headers:{authorization:`Bearer ${t.clientSecret}`,"content-type":`application/sdp`},body:c.sdp});if(!u.ok)throw Error(`${B(`talk.failed`)} (${u.status})`);await r.setRemoteDescription({type:`answer`,sdp:await u.text()})}catch(e){L(),s(e.name===`NotAllowedError`?B(`chat.micDenied`):e.message),a(`error`)}}},[e,R,N,M,L]);return(0,H.useEffect)(()=>{if(i!==`live`||!t)return;let e=Qe(t,r,f);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,f,M]),{state:i,error:o,speaking:c,listening:u,start:ne,stop:L,camera:f,facing:m,startCamera:F,stopCamera:P,flipCamera:te,muted:g,toggleMute:I,captions:v,video:b}}var et=[`classifier`,`low`],tt=12e3;function nt(e){re(`think`)&&S.post(`/api/runs/${e}/device`,{think:{classes:et,maxChars:tt}}).catch(()=>void 0)}async function rt(e,t){if(t.kind!==`think`)return;let n;try{let e=await ue(`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 S.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var it=45e3;function at(e){let[t,n]=(0,H.useState)(null),[i,a]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)({});(0,H.useEffect)(()=>{if(n(null),c(!1),!e)return;let t=!1,i=0,a,s=null,l=Date.now(),u=()=>{t=!0,s?.close(),c(!0)},d=async()=>{try{let r=await S.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof o&&e.status===404&&u()}},f=()=>{if(clearTimeout(a),s?.close(),t)return;let o=new EventSource(r(`/api/runs/${e}/stream`),{withCredentials:!0});s=o,l=Date.now(),nt(e),o.addEventListener(`device`,t=>{l=Date.now(),rt(e,JSON.parse(t.data))}),o.addEventListener(`view`,e=>{i=0,l=Date.now(),n(JSON.parse(e.data))}),o.addEventListener(`ping`,()=>{l=Date.now()}),o.onerror=()=>{o.close(),!(t||s!==o)&&(s=null,d(),i=Math.min(i+1,6),a=setTimeout(f,500*2**i))}},p=()=>{t||document.visibilityState!==`visible`||(!s||s.readyState===EventSource.CLOSED||Date.now()-l>it?(i=0,f()):d())},m=setInterval(()=>{!t&&s&&Date.now()-l>it&&(i=0,f())},15e3);return f(),document.addEventListener(`visibilitychange`,p),window.addEventListener(`pageshow`,p),window.addEventListener(`online`,p),()=>{t=!0,clearTimeout(a),clearInterval(m),document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`pageshow`,p),window.removeEventListener(`online`,p),s?.close()}},[e]);let p=(0,H.useCallback)(async(t,n)=>{if(!e)return!1;u(!0),a(null),f({});try{return await S.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof o&&e.status===422&&Array.isArray(e.body?.fields)&&f(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),a(e.message),!1}finally{u(!1)}},[e]);return de(t?.translation?.labels),{view:t,notFound:s,error:i,busy:l,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 G=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),K=(e,t,n)=>({key:e,who:`me`,node:t,...n}),ot=(0,H.createContext)(null),q=(0,H.createContext)(null);function st(){return(0,H.useContext)(q)?.voice??null}function ct({children:e}){let t=(0,H.useContext)(ot);return t?(0,Ue.createPortal)(e,t):null}function lt({header:e,footer:t,children:n}){let[r,i]=(0,H.useState)(null),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(!0);return(0,H.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,U.jsx)(ot.Provider,{value:r,children:(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,U.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,U.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,U.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,U.jsx)(`div`,{ref:i,className:`mx-auto w-full max-w-[760px] px-3 pt-3 sm:px-6`}),t]})]})})}function J({avatar:e,costume:t,lines:n}){let r=(0,H.useContext)(q),i=(0,H.useMemo)(()=>n.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[n]),o=(0,H.useCallback)(e=>{let t=document.querySelector(`[data-say="${CSS.escape(e)}"]`);return t?.querySelector(`[data-say-text]`)?.getAttribute(`data-say-text`)??t?.innerText??null},[]);ke(!!r?.readAloud,r?.lang??ce,i,o);let s=[];for(let e of n){let t=s.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):s.push({who:e.who,lines:[e]})}return s.map((n,r)=>n.who===`bot`?(0,U.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,U.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,U.jsx)(xe,{kind:e,costume:t,size:30,interactive:r>=s.length-2})}),(0,U.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:n.lines.map(e=>(0,U.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:a(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?a(`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,U.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,U.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,U.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,U.jsx)(D,{className:`size-3`}),` `,B(`chat.change`)]}):null]},e.key)))}function ut(){return(0,U.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":B(`run.working`),children:[0,1,2].map(e=>(0,U.jsx)(`span`,{className:`size-1.5 animate-typing rounded-full bg-ink-3`,style:{animationDelay:`${e*160}ms`}},e))})}function Y({children:e}){return(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var X=(e,t)=>G(e,(0,U.jsx)(Y,{children:t}),{bare:!0});function Z({onClick:e,children:t,primary:n,on:r,disabled:i,busy:o}){return(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||o,onClick:e,className:a(`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:[o?(0,U.jsx)(p,{className:`size-4`}):null,t]})}function dt({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:o,inputRef:s,onSend:c}){let[l,u]=(0,H.useState)(e),f=(0,H.useRef)(null),m=s??f,h=(0,H.useContext)(q),g=L(l,u,{endpoint:h?`/api/runs/${h.runId}/transcribe`:void 0}),v=!!h&&g.supported&&!o;(0,H.useEffect)(()=>{if(!v)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),g.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v,g.toggle]),(0,H.useEffect)(()=>{!b&&!o&&m.current?.focus()},[o,m]);let x=()=>{i||o||(g.listening&&g.toggle(),c(l)!==!1&&u(``))},S=g.listening?B(`chat.listening`):g.processing?B(`chat.transcribing`):t,C=h?.voice??null,T=!!h?.call,E=h&&!T&&(we||v||C)?(0,U.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[C?(0,U.jsx)(d,{label:B(C.state===`live`?`talk.stop`:C.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":C.state===`live`,disabled:C.state===`connecting`,onClick:()=>C.state===`live`?C.stop():void C.start(),className:a(`size-9`,C.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,C.state===`off`&&h.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:C.state===`connecting`?(0,U.jsx)(p,{className:`size-4`}):C.state===`live`?(0,U.jsx)(De,{className:`size-4`}):(0,U.jsx)(Se,{className:`size-4`})}):null,C?.state===`live`?(0,U.jsx)(d,{label:B(C.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":C.camera,onClick:()=>C.camera?C.stopCamera():void C.startCamera(),className:a(`size-9`,C.camera&&`text-ink`),children:C.camera?(0,U.jsx)(k,{className:`size-4`}):(0,U.jsx)(Le,{className:`size-4`})}):null,we?(0,U.jsx)(d,{label:B(h.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":h.readAloud,onClick:()=>h.setReadAloud(!h.readAloud),className:a(`size-9`,h.readAloud&&`text-ink`),children:h.readAloud?(0,U.jsx)(_e,{className:`size-4`}):(0,U.jsx)(ze,{className:`size-4`})}):null,v?(0,U.jsx)(d,{label:B(g.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":g.listening,disabled:g.processing,onClick:g.toggle,className:a(`size-9`,g.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:g.processing?(0,U.jsx)(p,{className:`size-4`}):g.listening?(0,U.jsx)(N,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,U.jsx)(y,{className:`size-4`})}):null]}):null;return(0,U.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),x()},children:[C&&!T?(0,U.jsx)(`video`,{ref:C.video,muted:!0,playsInline:!0,autoPlay:!0,className:a(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,C.camera?`block`:`hidden`)}):null,(0,U.jsxs)(`div`,{className:a(`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`,o&&`opacity-60`),children:[E,n?(0,U.jsx)(_,{ref:m,minRows:1,maxRows:6,value:l,disabled:o,placeholder:S,autoCapitalize:`sentences`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!b&&!e.nativeEvent.isComposing&&(e.preventDefault(),x())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,U.jsx)(`input`,{ref:m,...r,value:l,disabled:o,placeholder:S,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,U.jsx)(`button`,{type:`submit`,"aria-label":B(`chat.send`),title:B(`chat.send`),disabled:i||o,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,U.jsx)(p,{className:`size-4`}):(0,U.jsx)(w,{className:`size-4`})})]}),g.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:g.error===`denied`?B(`chat.micDenied`):g.error}):T?null:C?.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:C.error}):C?.state===`live`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:C.speaking?B(`talk.speaking`):C.listening?B(`talk.listening`):B(`talk.live`)}):h?.talk&&C?.state===`off`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:B(`talk.hint`)}):null]})}function Q({placeholder:e=B(`chat.above`)}){return(0,U.jsx)(ct,{children:(0,U.jsx)(dt,{disabled:!0,placeholder:e,onSend:()=>!1})})}function ft(e){let t=me[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var pt=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function mt(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(pt(t))return e.required&&!n?B(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return B(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return B(`chat.badUrl`)}return e.kind===`number`&&T(r)===null?B(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?B(`run.filesMin`,{n:t.length,min:e.min}):null}function ht(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 gt({field:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,U.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function _t({step:e,only:t}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,U.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,U.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function vt({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,U.jsx)(U.Fragment,{children:typeof t==`string`&&t?t:B(`chat.connected`)});if(e.kind===`list`)return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(x,{className:`size-4`}),` `,B(`chat.checked`)]});if(e.kind===`toggle`)return(0,U.jsx)(U.Fragment,{children:B(t===!0?`run.yes`:`run.no`)});if(pt(t))return(0,U.jsx)(`span`,{className:`italic opacity-80`,children:B(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,U.jsx)(U.Fragment,{children:t.map(R).join(`, `)});case`select`:return(0,U.jsx)(U.Fragment,{children:R(String(t))});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,U.jsx)(U.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(ce,{dateStyle:`long`}).format(e)})}case`color`:return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,U.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,U.jsx)(`img`,{src:r(`/api/runs/${n}/assets/${t}`),alt:``,className:a(`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,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(s,{className:`size-4`}),` `,B(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(y,{className:`size-4`}),` `,B(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,U.jsx)(U.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,U.jsx)(U.Fragment,{children:B(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,U.jsx)(U.Fragment,{children:String(t)})}}function yt(e,t,n,r,i,a){let o=[G(t,(0,U.jsx)(_t,{step:e,only:a}))];for(let e of i)a||o.push(G(`${t}:${e.id}`,(0,U.jsx)(gt,{field:e}))),o.push(K(`${t}:${e.id}:a`,(0,U.jsx)(vt,{field:e,value:n[e.id],runId:r})));return o}var bt=(e,t)=>e.fields.filter(e=>!e.when&&!h(e)||t[e.id]!==void 0&&t[e.id]!==null);function xt(e,t){let n=[];e.wizard.description&&n.push(G(`hello`,e.wizard.description)),e.wizard.intro&&n.push(G(`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(...yt(r,i,e.values,e.id,bt(r,e.values),t))}else r.type===`review`&&(n.push(G(i,(0,U.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(K(`${i}:a`,B(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function St(e,t){return e.fields.filter(e=>!h(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function Ct({view:e,run:t,step:n,before:r}){let i=(0,H.useMemo)(()=>St(n,e),[n,e]),a=e.known??{},[o,s]=(0,H.useState)(()=>se(n,e)),[c,l]=(0,H.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?C(St(n,e),e.known??{},se(n,e)).slice(0,-1).map(e=>e.id):[]),[u,d]=(0,H.useState)({}),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),g=C(i,a,o),_=g.filter(e=>c.includes(e.id)),v=g.find(e=>!c.includes(e.id)),y=i.length===1?i[0]:void 0,b=_.at(-1),x=b?()=>l(e=>e.filter(e=>e!==b.id)):void 0;(0,H.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=C(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 S=e=>{t.submitPage(n.id,e).then(h)},w=(0,H.useContext)(q),T=(0,H.useRef)(o);T.current=o;let E=w?.bindPage,D=(0,H.useRef)(S);D.current=S,(0,H.useEffect)(()=>{if(!E)return;let e=C(i,a,o);return E({step:n,fields:e,values:o,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?mt(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(!v)return!1;let t=mt(v,e);if(t)return d({[v.id]:t}),!1;let n={...o,[v.id]:e},r=[...c,v.id];return s(n),l(r),d({}),C(i,a,n).some(e=>!r.includes(e.id))||S(n),!0},k=[...r.map(e=>c.length?{...e,onEdit:void 0}:e),...yt(n,`now:${n.id}`,o,e.id,_,y).map((e,t,n)=>t===n.length-1&&e.who===`me`&&v?{...e,onEdit:x}:e)];v?(ft(v)===`control`?k.push(G(`now:${n.id}:${v.id}:control`,(0,U.jsx)(te,{field:v,value:o[v.id],values:o,runId:e.id,view:e,closed:e.closed?.[v.id],onChange:e=>s(t=>({...t,[v.id]:e})),onBusy:p}),{wide:!0})):y||k.push(G(`now:${n.id}:${v.id}`,(0,U.jsx)(gt,{field:v}))),u[v.id]&&k.push(G(`now:${n.id}:${v.id}:error`,u[v.id],{tone:`error`}))):t.busy||m?k.push(G(`sending`,(0,U.jsx)(ut,{}))):t.error&&k.push(G(`send-error`,t.error,{tone:`error`}));let A=(0,U.jsx)(Q,{});if(m||!v&&c.length>0&&t.busy)A=(0,U.jsx)(Q,{placeholder:B(`run.working`)});else if(!v)k.push(X(`now:${n.id}:go`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>S(o),children:n.cta||B(`run.next`)}),x?(0,U.jsx)(Z,{onClick:x,disabled:t.busy,children:B(`run.back`)}):null]})));else{let r=ft(v),i=!v.required&&v.kind!==`connection`&&v.kind!==`list`?(0,U.jsx)(Z,{onClick:()=>O(void 0),children:B(`chat.skip`)}):null;if(r===`typed`){i&&k.push(X(`now:${n.id}:${v.id}:replies`,i));let e=o[v.id];A=(0,U.jsx)(ct,{children:(0,U.jsx)(dt,{initial:pt(e)?``:String(e),multiline:v.kind===`textarea`,placeholder:v.placeholder||(y?v.label:B(`chat.placeholder`)),inputProps:wt(v),busy:t.busy,onSend:e=>O(ht(v,e))},v.id)})}else if(r===`tapped`)k.push(G(`now:${n.id}:${v.id}:replies`,(0,U.jsx)(Tt,{field:v,view:e,value:o[v.id],onAnswer:O}),{bare:!0}));else{let e=g.filter(e=>!c.includes(e.id)).length===1;k.push(X(`now:${n.id}:${v.id}:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z,{primary:!0,disabled:f,onClick:()=>O(o[v.id]),children:e&&n.cta?n.cta:B(`chat.send`)}),i]})))}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:k}),A]})}function wt(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 F(e)}}function Tt({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,H.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,U.jsxs)(Y,{children:[(0,U.jsx)(Z,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:B(`run.no`)}),(0,U.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:B(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,U.jsxs)(Y,{children:[s.map(e=>(0,U.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:R(e)},e)),(0,U.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?B(`chat.send`):B(`chat.skip`)})]}):(0,U.jsxs)(Y,{children:[s.map(e=>(0,U.jsx)(Z,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:R(e)},e)),e.required?null:(0,U.jsx)(Z,{onClick:()=>r(void 0),children:B(`chat.skip`)})]})}function Et({view:e}){let t=(0,H.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(),[i,o]=(0,H.useState)(Date.now());(0,H.useEffect)(()=>{let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[]);let s=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),c=s.at(-1),l=[...s].reverse().find(Ot),u=[...new Set(s.map(e=>e.asset).filter(e=>!!e))];return(0,U.jsxs)(`div`,{className:a(`flex max-w-full flex-col gap-1`,l?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??B(`run.working`),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(ut,{}),(0,U.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??B(`run.working`)}),(0,U.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:B(`run.elapsed`,{s:Math.max(0,Math.round((i-n)/1e3))})})]}),c&&c!==l?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,U.jsx)(ae,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,U.jsx)(`span`,{className:`truncate`,children:j(c)})]}):null,l&&e.status===`running`?(0,U.jsx)(At,{runId:e.id,event:l}):null,u.length?(0,U.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:u.slice(-6).map(t=>(0,U.jsx)(`img`,{src:r(`/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 Dt=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function Ot(e){return!!e.note&&Dt.has(e.note.code)}var kt=1e4;function At({runId:e,event:t}){let[n,r]=(0,H.useState)(null),[i,o]=(0,H.useState)(`agent`),[s,c]=(0,H.useState)(!1),l=t.note?.code;if((0,H.useEffect)(()=>{l===`personDrives`?o(`person`):l===`agentDrives`&&o(`agent`)},[l]),(0,H.useEffect)(()=>{let t=()=>S.get(`/api/runs/${e}/browser/seat`).then(e=>o(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,kt);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let u=i===`person`,d=async()=>{c(!0);try{let t=await S.post(`/api/runs/${e}/browser/seat`,{to:u?`agent`:`person`});o(t.seat)}catch{}finally{c(!1)}};return(0,U.jsx)(m,{runId:e,driving:u,caption:j(t),hint:B(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,U.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>void d(),className:a(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,u?`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:[u?(0,U.jsx)(Fe,{className:`size-3.5`}):(0,U.jsx)(je,{className:`size-3.5`}),B(u?`browser.handBack`:`browser.takeOver`)]})},n??0)}function jt({children:e,end:t}){return(0,U.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function Mt({view:e,run:t,step:n,before:r,asked:i,onNote:a}){let o=e.shown.filter(e=>e.output),[s,c]=(0,H.useState)(o.length===1?o[0].step.id:null),l=(0,H.useRef)(null),u=[...r,...i.map((e,t)=>K(`review:${n.id}:asked:${t}`,e)),G(`review:${n.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,U.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.description}):null]}),{anchor:!0}),...o.map(({step:t,output:r})=>G(`review:${n.id}:${t.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jt,{children:t.title}),(0,U.jsx)(oe,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{c(t.id),l.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>G(`review:${n.id}:list:${t.def.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jt,{children:t.def.title}),t.def.check?(0,U.jsx)(fe,{runId:e.id,list:t}):(0,U.jsx)(O,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&u.push(G(`review-error`,t.error,{tone:`error`}));let d=n.regenerate&&o.length>0;return u.push(X(`review:${n.id}:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,U.jsx)(x,{className:`size-4`}),` `,B(`run.accept`)]}),d&&o.length>1?o.map(({step:e})=>(0,U.jsx)(Z,{on:s===e.id,onClick:()=>c(e.id),children:e.title},e.id)):null]}))),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:u}),d?(0,U.jsx)(ct,{children:(0,U.jsx)(dt,{multiline:!0,inputRef:l,busy:t.busy,placeholder:o.length>1&&!s?B(`run.feedbackPick`):B(`run.feedbackPlaceholder`),disabled:!s,onSend:e=>{let r=e.trim();return!r||!s?!1:(a(r),t.regenerate(n.id,s,r),!0)}})}):(0,U.jsx)(Q,{})]})}function Nt({view:e,run:t,step:n,before:r,onRestart:i}){let a=e.shown.filter(e=>e.output),o=`/api/runs/${e.id}`,s=[...r,G(`result:${n.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,U.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.message}):null]}),{anchor:!0}),...a.map(({step:e,output:t,formats:n,label:r})=>G(`result:${e.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jt,{end:(0,U.jsx)(ne,{base:o,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,U.jsx)(oe,{base:o,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,U.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:B(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>G(`result:list:${t.def.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jt,{end:(0,U.jsx)(he,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,U.jsx)(O,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return s.push(X(`result:replies`,(0,U.jsxs)(U.Fragment,{children:[a.length?(0,U.jsx)(Oe,{view:e,title:`${n.title} · ${e.wizard.title}`}):null,i?(0,U.jsxs)(Z,{onClick:i,children:[(0,U.jsx)(P,{className:`size-4`}),` `,B(`run.again`)]}):null,e.canBack?(0,U.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:B(`run.back`)}):null,e.keeps?(0,U.jsx)(`span`,{className:`ml-1`,children:(0,U.jsx)(pe,{runId:e.id})}):null]}))),(0,U.jsx)(J,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:s})}function Pt({runId:e,onRestart:t,onView:n,header:r,footer:i,talk:a=!1,call:o=!1}){let s=at(e),{view:d}=s,[f,m]=(0,H.useState)(null),h=$e(e,d,s,f);(0,H.useEffect)(()=>{n?.(d)},[d,n]);let[g,_]=Te(),v=(0,H.useMemo)(()=>({runId:e,lang:d?.lang??ce,readAloud:g,setReadAloud:_,voice:d?.talk?h:null,talk:a,call:!!o,bindPage:m}),[e,d?.lang,d?.talk,g,_,h,a,o]);l(d?.status===`running`&&!d.ask),A(d);let[y,b]=(0,H.useState)({}),[x,S]=(0,H.useState)(null);(0,H.useEffect)(()=>{d&&d.status!==`running`&&S(null)},[d]);let C;if(s.notFound)C=(0,U.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:B(`run.notFound`)});else if(!d)C=(0,U.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,U.jsx)(p,{})});else{let e=d.step,n=d.status===`waiting_input`,r=xt(d,d.canBack&&n&&!s.busy?()=>void s.back():void 0);if(d.status===`running`&&d.ask)C=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:[...r,G(`ask:${d.ask.id}`,(0,U.jsx)(c,{runId:d.id,ask:d.ask}),{wide:!0})]}),(0,U.jsx)(Q,{})]});else if(d.status===`running`)C=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:[...r,...x?[K(`note`,x)]:[],G(`working:${e?.id}`,(0,U.jsx)(Et,{view:d}),{wide:d.events.some(t=>t.stepId===e?.id&&Ot(t))?`most`:void 0})]}),(0,U.jsx)(Q,{placeholder:B(`run.working`)})]});else if(d.status===`failed`)C=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:[...r,G(`failed`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:B(`run.failed`)}),d.error?(0,U.jsx)(`span`,{className:`mt-0.5 block`,children:(0,U.jsx)(u,{text:d.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{primary:!0,busy:s.busy,onClick:()=>void s.retry(),children:[(0,U.jsx)(P,{className:`size-4`}),` `,B(`run.retry`)]}),d.canBack?(0,U.jsx)(Z,{onClick:()=>void s.back(),disabled:s.busy,children:B(`run.back`)}):null]}))]}),(0,U.jsx)(Q,{})]});else if(d.status===`cancelled`)C=(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:[...r,G(`cancelled`,B(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,U.jsxs)(Z,{primary:!0,onClick:t,children:[(0,U.jsx)(P,{className:`size-4`}),` `,B(`run.again`)]}))]:[]]});else if(e?.type===`page`)C=(0,U.jsx)(Ct,{view:d,run:s,step:e,before:r},e.id);else if(e?.type===`review`){let t=d.shown.map(e=>e.output?.at??``).join(`|`);C=(0,U.jsx)(Mt,{view:d,run:s,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,U.jsx)(Nt,{view:d,run:s,step:e,before:r,onRestart:t}):(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:r})}return o?(0,U.jsx)(q.Provider,{value:v,children:(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,U.jsx)(qe,{voice:h,view:d,video:o===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,U.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,U.jsx)(lt,{footer:i,children:C})})]})}):(0,U.jsx)(q.Provider,{value:v,children:(0,U.jsx)(lt,{header:r,footer:i,children:C})})}function Ft({runId:e,...t}){let n=at(e);return(0,U.jsx)(ie,{run:n,...t})}function $(e){let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)}function It(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 Lt={left:It(1),right:It(9)};function Rt({side:e,className:t}){return(0,U.jsx)(`svg`,{className:t??`wizard-web wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:Lt[e],fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function zt(){return(0,U.jsxs)(`div`,{className:`wizard-spider`,children:[(0,U.jsx)(`div`,{className:`wizard-spider-thread`}),(0,U.jsxs)(`svg`,{viewBox:`-30 -10 60 60`,"aria-hidden":`true`,children:[(0,U.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`2.6`,strokeLinecap:`round`,fill:`none`,children:[0,1,2,3].map(e=>(0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{d:`M0 ${8+e*5} Q-16 ${-2+e*6} -24 ${14+e*6}`}),(0,U.jsx)(`path`,{d:`M0 ${8+e*5} Q16 ${-2+e*6} 24 ${14+e*6}`})]},e))}),(0,U.jsx)(`ellipse`,{cx:`0`,cy:`22`,rx:`11`,ry:`14`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`0`,cy:`6`,r:`7`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`-2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`}),(0,U.jsx)(`circle`,{cx:`2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`})]})]})}function Bt({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,U.jsx)(`svg`,{className:`wizard-frost wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:t,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function Vt({kind:e}){let t=e===`stars`?28:22;return(0,U.jsx)(`div`,{className:`wizard-particles wizard-particles-${e}`,children:Array.from({length:t},(t,n)=>(0,U.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 Ht=[{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}],Ut=[{kind:`flame`,side:`right`,seconds:14,delay:2},{kind:`sprout`,side:`left`,seconds:16,delay:9}];function Wt({costume:e,motion:t}){return t===`peek`?(0,U.jsx)(U.Fragment,{children:Ut.map(t=>(0,U.jsx)(`div`,{className:`wizard-peek wizard-peek-${t.side}`,style:{animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,U.jsx)(Ce,{kind:t.kind,costume:e,size:96})},t.kind))}):(0,U.jsx)(U.Fragment,{children:Ht.map(t=>(0,U.jsx)(`div`,{className:`wizard-bat`,style:{top:`${t.top}%`,animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,U.jsx)(`div`,{className:`wizard-bat-bob`,children:(0,U.jsx)(Ce,{kind:t.kind,costume:e,size:t.size})})},t.kind))})}var Gt=[`witch`,`devil`,`bat`,`pumpkin`];function Kt({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,U.jsxs)(U.Fragment,{children:[n.some(e=>e.id===`fog`)?(0,U.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fog wizard-fx-contained`:`wizard-fog`}):null,(0,U.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,U.jsxs)(`div`,{children:[(0,U.jsx)(Bt,{side:`left`}),(0,U.jsx)(Bt,{side:`right`})]},n):t===`webs`?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(Rt,{side:`left`}),(0,U.jsx)(Rt,{side:`right`}),(0,U.jsx)(zt,{})]},n):null}if(e.id===`particles`){let t=r(e,`kind`)||`embers`;return[`embers`,`snow`,`confetti`,`stars`].includes(t)?(0,U.jsx)(Vt,{kind:t},n):null}if(e.id===`figures`){let t=r(e,`costume`);return(0,U.jsx)(Wt,{costume:Gt.includes(t)?t:void 0,motion:r(e,`motion`)||`fly`},n)}return null})})]})}var qt=[`brand`,`host`,`default`],Jt=[...qt,`engenty`,`wizard`,`wizards`],Yt=[`Inter`,`Figtree`,`DM Sans`,`Nunito`,`Fredoka`,`Bricolage Grotesque`,`Fraunces`,`Playfair Display`,`Lora`,`Young Serif`,`Caveat`,`Creepster`,`Nosifer`],Xt=I().regex(/^#[0-9a-fA-F]{6}$/,`a colour as #rrggbb`),Zt=z({accent:Xt.optional(),background:Xt.optional(),text:Xt.optional()}).extend({scheme:g([`light`,`dark`])}),Qt=z({radius:g([`sharp`,`soft`,`round`]).optional(),cards:g([`solid`,`outline`,`glass`]).optional(),headings:g([`normal`,`uppercase`]).optional()}),$t=z({id:I().min(1).max(40)}).catchall(E([I().max(40),le(),M()])),en=I().min(1).max(60).regex(/^[A-Za-z0-9 -]+$/,`a font by its family name, or brand`);z({id:I().regex(v,`a theme id: lowercase letters, digits and dashes`),name:I().min(1).max(80),version:I().regex(/^\d+\.\d+\.\d+$/).default(`1.0.0`),base:g(qt).default(`brand`),colors:i(Zt).min(1).max(2).refine(e=>new Set(e.map(e=>e.scheme)).size===e.length,{message:`Each scheme once: light, dark.`}).optional(),fonts:z({heading:en.optional(),text:en.optional()}).optional(),shape:Qt.optional(),effects:i($t).max(8).optional()});function tn(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 nn(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48);return t&&!Jt.includes(t)?t:`look`}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?.colors?.find(e=>e.scheme===t);if(!n)return;let{scheme:r,...i}=n;return i}function dn(e,t){let n=e.modes?.[t];return{accent:n?.accent??e.accent,background:n?.background??e.background,text:n?.text??null}}var fn={Inter:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([0])),V(()=>Promise.resolve({}),__vite__mapDeps([1])),V(()=>Promise.resolve({}),__vite__mapDeps([2])),V(()=>Promise.resolve({}),__vite__mapDeps([3]))],Figtree:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([4])),V(()=>Promise.resolve({}),__vite__mapDeps([5])),V(()=>Promise.resolve({}),__vite__mapDeps([6])),V(()=>Promise.resolve({}),__vite__mapDeps([7]))],"DM Sans":()=>[V(()=>Promise.resolve({}),__vite__mapDeps([8])),V(()=>Promise.resolve({}),__vite__mapDeps([9])),V(()=>Promise.resolve({}),__vite__mapDeps([10])),V(()=>Promise.resolve({}),__vite__mapDeps([11]))],Nunito:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([12])),V(()=>Promise.resolve({}),__vite__mapDeps([13])),V(()=>Promise.resolve({}),__vite__mapDeps([14])),V(()=>Promise.resolve({}),__vite__mapDeps([15]))],Fredoka:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([16])),V(()=>Promise.resolve({}),__vite__mapDeps([17])),V(()=>Promise.resolve({}),__vite__mapDeps([18])),V(()=>Promise.resolve({}),__vite__mapDeps([19]))],"Bricolage Grotesque":()=>[V(()=>Promise.resolve({}),__vite__mapDeps([20])),V(()=>Promise.resolve({}),__vite__mapDeps([21])),V(()=>Promise.resolve({}),__vite__mapDeps([22])),V(()=>Promise.resolve({}),__vite__mapDeps([23]))],Fraunces:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([24])),V(()=>Promise.resolve({}),__vite__mapDeps([25])),V(()=>Promise.resolve({}),__vite__mapDeps([26])),V(()=>Promise.resolve({}),__vite__mapDeps([27]))],"Playfair Display":()=>[V(()=>Promise.resolve({}),__vite__mapDeps([28])),V(()=>Promise.resolve({}),__vite__mapDeps([29])),V(()=>Promise.resolve({}),__vite__mapDeps([30])),V(()=>Promise.resolve({}),__vite__mapDeps([31]))],Lora:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([32])),V(()=>Promise.resolve({}),__vite__mapDeps([33])),V(()=>Promise.resolve({}),__vite__mapDeps([34])),V(()=>Promise.resolve({}),__vite__mapDeps([35]))],"Young Serif":()=>[V(()=>Promise.resolve({}),__vite__mapDeps([36]))],Caveat:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([37])),V(()=>Promise.resolve({}),__vite__mapDeps([38])),V(()=>Promise.resolve({}),__vite__mapDeps([39])),V(()=>Promise.resolve({}),__vite__mapDeps([40]))],Creepster:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([41]))],Nosifer:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([42]))]},pn=new Set;function mn(e){e&&!pn.has(e)&&e in fn&&(pn.add(e),Promise.all(fn[e]()).catch(()=>pn.delete(e)))}function hn(e){He(e,e.url.startsWith(`/`)?r(e.url):e.url,()=>mn(cn(e.family)))}function gn(e,t){let n=e.faces??[],r=!!e.modes,i=dn({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 _n(e){return!!(e&&!e.pinned&&e.modes?.light&&e.modes.dark)}function vn(e){for(let t of e.faces??[])hn(t);mn(e.display),mn(e.body)}function yn(e){ye(e?.pinned?e.dark?`dark`:`light`:null),ve(e?.prefer??null);let t=be(),n=JSON.stringify(e??{});(0,H.useEffect)(()=>{let e=JSON.parse(n),r=document.documentElement;vn(e);let{props:i,marks:a,themed:o}=gn(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 bn(e,t){let n=JSON.stringify(e??{});if((0,H.useEffect)(()=>{vn(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}=gn(e,t&&_n(e)?t:r);return{className:[`wizard-themed`,...a,o?`dark`:``].filter(Boolean).join(` `),style:Object.fromEntries(i)}}export{J as _,mn as a,Ne as b,un as c,Kt as d,Ft as f,Z as g,Q as h,hn as i,nn as l,lt as m,yn as n,Yt as o,Pt as p,bn as r,tn as s,_n as t,Rt as u,X as v,st as y};
11
+ `)[1])&&M({type:`response.create`})},[i,t,r,f,M]),{state:i,error:o,speaking:c,listening:u,start:ne,stop:L,camera:f,facing:m,startCamera:F,stopCamera:P,flipCamera:te,muted:g,toggleMute:I,captions:v,video:b}}var et=[`classifier`,`low`],tt=12e3;function nt(e){re(`think`)&&S.post(`/api/runs/${e}/device`,{think:{classes:et,maxChars:tt}}).catch(()=>void 0)}async function rt(e,t){if(t.kind!==`think`)return;let n;try{let e=await ue(`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 S.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var it=45e3;function at(e){let[t,n]=(0,H.useState)(null),[i,a]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)({});(0,H.useEffect)(()=>{if(n(null),c(!1),!e)return;let t=!1,i=0,a,s=null,l=Date.now(),u=()=>{t=!0,s?.close(),c(!0)},d=async()=>{try{let r=await S.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof o&&e.status===404&&u()}},f=()=>{if(clearTimeout(a),s?.close(),t)return;let o=new EventSource(r(`/api/runs/${e}/stream`),{withCredentials:!0});s=o,l=Date.now(),nt(e),o.addEventListener(`device`,t=>{l=Date.now(),rt(e,JSON.parse(t.data))}),o.addEventListener(`view`,e=>{i=0,l=Date.now(),n(JSON.parse(e.data))}),o.addEventListener(`ping`,()=>{l=Date.now()}),o.onerror=()=>{o.close(),!(t||s!==o)&&(s=null,d(),i=Math.min(i+1,6),a=setTimeout(f,500*2**i))}},p=()=>{t||document.visibilityState!==`visible`||(!s||s.readyState===EventSource.CLOSED||Date.now()-l>it?(i=0,f()):d())},m=setInterval(()=>{!t&&s&&Date.now()-l>it&&(i=0,f())},15e3);return f(),document.addEventListener(`visibilitychange`,p),window.addEventListener(`pageshow`,p),window.addEventListener(`online`,p),()=>{t=!0,clearTimeout(a),clearInterval(m),document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`pageshow`,p),window.removeEventListener(`online`,p),s?.close()}},[e]);let p=(0,H.useCallback)(async(t,n)=>{if(!e)return!1;u(!0),a(null),f({});try{return await S.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof o&&e.status===422&&Array.isArray(e.body?.fields)&&f(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),a(e.message),!1}finally{u(!1)}},[e]);return de(t?.translation?.labels),{view:t,notFound:s,error:i,busy:l,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 G=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),K=(e,t,n)=>({key:e,who:`me`,node:t,...n}),ot=(0,H.createContext)(null),q=(0,H.createContext)(null);function st(){return(0,H.useContext)(q)?.voice??null}function ct({children:e}){let t=(0,H.useContext)(ot);return t?(0,Ue.createPortal)(e,t):null}function lt({header:e,footer:t,children:n}){let[r,i]=(0,H.useState)(null),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(!0);return(0,H.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,U.jsx)(ot.Provider,{value:r,children:(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,U.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,U.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,U.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,U.jsx)(`div`,{ref:i,className:`mx-auto w-full max-w-[760px] px-3 pt-3 sm:px-6`}),t]})]})})}function J({avatar:e,costume:t,lines:n}){let r=(0,H.useContext)(q),i=(0,H.useMemo)(()=>n.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[n]),o=(0,H.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??ce,i,o);let s=[];for(let e of n){let t=s.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):s.push({who:e.who,lines:[e]})}return s.map((n,r)=>n.who===`bot`?(0,U.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,U.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,U.jsx)(xe,{kind:e,costume:t,size:30,interactive:r>=s.length-2})}),(0,U.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:n.lines.map(e=>(0,U.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:a(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?a(`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,U.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,U.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,U.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,U.jsx)(D,{className:`size-3`}),` `,B(`chat.change`)]}):null]},e.key)))}function ut(){return(0,U.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":B(`run.working`),children:[0,1,2].map(e=>(0,U.jsx)(`span`,{className:`size-1.5 animate-typing rounded-full bg-ink-3`,style:{animationDelay:`${e*160}ms`}},e))})}function Y({children:e}){return(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var X=(e,t)=>G(e,(0,U.jsx)(Y,{children:t}),{bare:!0});function Z({onClick:e,children:t,primary:n,on:r,disabled:i,busy:o}){return(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||o,onClick:e,className:a(`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:[o?(0,U.jsx)(p,{className:`size-4`}):null,t]})}function dt({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:o,inputRef:s,onSend:c}){let[l,u]=(0,H.useState)(e),f=(0,H.useRef)(null),m=s??f,h=(0,H.useContext)(q),g=L(l,u,{endpoint:h?`/api/runs/${h.runId}/transcribe`:void 0}),v=!!h&&g.supported&&!o;(0,H.useEffect)(()=>{if(!v)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),g.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v,g.toggle]),(0,H.useEffect)(()=>{!b&&!o&&m.current?.focus()},[o,m]);let x=()=>{i||o||(g.listening&&g.toggle(),c(l)!==!1&&u(``))},S=g.listening?B(`chat.listening`):g.processing?B(`chat.transcribing`):t,C=h?.voice??null,T=!!h?.call,E=h&&!T&&(Oe||v||C)?(0,U.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[C?(0,U.jsx)(d,{label:B(C.state===`live`?`talk.stop`:C.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":C.state===`live`,disabled:C.state===`connecting`,onClick:()=>C.state===`live`?C.stop():void C.start(),className:a(`size-9`,C.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,C.state===`off`&&h.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:C.state===`connecting`?(0,U.jsx)(p,{className:`size-4`}):C.state===`live`?(0,U.jsx)(we,{className:`size-4`}):(0,U.jsx)(Se,{className:`size-4`})}):null,C?.state===`live`?(0,U.jsx)(d,{label:B(C.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":C.camera,onClick:()=>C.camera?C.stopCamera():void C.startCamera(),className:a(`size-9`,C.camera&&`text-ink`),children:C.camera?(0,U.jsx)(k,{className:`size-4`}):(0,U.jsx)(Le,{className:`size-4`})}):null,Oe?(0,U.jsx)(d,{label:B(h.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":h.readAloud,onClick:()=>h.setReadAloud(!h.readAloud),className:a(`size-9`,h.readAloud&&`text-ink`),children:h.readAloud?(0,U.jsx)(_e,{className:`size-4`}):(0,U.jsx)(ze,{className:`size-4`})}):null,v?(0,U.jsx)(d,{label:B(g.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":g.listening,disabled:g.processing,onClick:g.toggle,className:a(`size-9`,g.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:g.processing?(0,U.jsx)(p,{className:`size-4`}):g.listening?(0,U.jsx)(N,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,U.jsx)(y,{className:`size-4`})}):null]}):null;return(0,U.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),x()},children:[C&&!T?(0,U.jsx)(`video`,{ref:C.video,muted:!0,playsInline:!0,autoPlay:!0,className:a(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,C.camera?`block`:`hidden`)}):null,(0,U.jsxs)(`div`,{className:a(`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`,o&&`opacity-60`),children:[E,n?(0,U.jsx)(_,{ref:m,minRows:1,maxRows:6,value:l,disabled:o,placeholder:S,autoCapitalize:`sentences`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!b&&!e.nativeEvent.isComposing&&(e.preventDefault(),x())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,U.jsx)(`input`,{ref:m,...r,value:l,disabled:o,placeholder:S,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,U.jsx)(`button`,{type:`submit`,"aria-label":B(`chat.send`),title:B(`chat.send`),disabled:i||o,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,U.jsx)(p,{className:`size-4`}):(0,U.jsx)(w,{className:`size-4`})})]}),g.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:g.error===`denied`?B(`chat.micDenied`):g.error}):T?null:C?.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:C.error}):C?.state===`live`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:C.speaking?B(`talk.speaking`):C.listening?B(`talk.listening`):B(`talk.live`)}):h?.talk&&C?.state===`off`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:B(`talk.hint`)}):null]})}function Q({placeholder:e=B(`chat.above`)}){return(0,U.jsx)(ct,{children:(0,U.jsx)(dt,{disabled:!0,placeholder:e,onSend:()=>!1})})}function ft(e){let t=me[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var pt=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function mt(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(pt(t))return e.required&&!n?B(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return B(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return B(`chat.badUrl`)}return e.kind===`number`&&T(r)===null?B(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?B(`run.filesMin`,{n:t.length,min:e.min}):null}function ht(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 gt({field:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,U.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function _t({step:e,only:t}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,U.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,U.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function vt({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,U.jsx)(U.Fragment,{children:typeof t==`string`&&t?t:B(`chat.connected`)});if(e.kind===`list`)return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(x,{className:`size-4`}),` `,B(`chat.checked`)]});if(e.kind===`toggle`)return(0,U.jsx)(U.Fragment,{children:B(t===!0?`run.yes`:`run.no`)});if(pt(t))return(0,U.jsx)(`span`,{className:`italic opacity-80`,children:B(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,U.jsx)(U.Fragment,{children:t.map(R).join(`, `)});case`select`:return(0,U.jsx)(U.Fragment,{children:R(String(t))});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,U.jsx)(U.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(ce,{dateStyle:`long`}).format(e)})}case`color`:return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,U.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,U.jsx)(`img`,{src:r(`/api/runs/${n}/assets/${t}`),alt:``,className:a(`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,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(s,{className:`size-4`}),` `,B(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(y,{className:`size-4`}),` `,B(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,U.jsx)(U.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,U.jsx)(U.Fragment,{children:B(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,U.jsx)(U.Fragment,{children:String(t)})}}function yt(e,t,n,r,i,a){let o=[G(t,(0,U.jsx)(_t,{step:e,only:a}))];for(let e of i)a||o.push(G(`${t}:${e.id}`,(0,U.jsx)(gt,{field:e}))),o.push(K(`${t}:${e.id}:a`,(0,U.jsx)(vt,{field:e,value:n[e.id],runId:r})));return o}var bt=(e,t)=>e.fields.filter(e=>!e.when&&!h(e)||t[e.id]!==void 0&&t[e.id]!==null);function xt(e,t){let n=[];e.wizard.description&&n.push(G(`hello`,e.wizard.description)),e.wizard.intro&&n.push(G(`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(...yt(r,i,e.values,e.id,bt(r,e.values),t))}else r.type===`review`&&(n.push(G(i,(0,U.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(K(`${i}:a`,B(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function St(e,t){return e.fields.filter(e=>!h(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function Ct({view:e,run:t,step:n,before:r}){let i=(0,H.useMemo)(()=>St(n,e),[n,e]),a=e.known??{},[o,s]=(0,H.useState)(()=>se(n,e)),[c,l]=(0,H.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?C(St(n,e),e.known??{},se(n,e)).slice(0,-1).map(e=>e.id):[]),[u,d]=(0,H.useState)({}),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),g=C(i,a,o),_=g.filter(e=>c.includes(e.id)),v=g.find(e=>!c.includes(e.id)),y=i.length===1?i[0]:void 0,b=_.at(-1),x=b?()=>l(e=>e.filter(e=>e!==b.id)):void 0;(0,H.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=C(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 S=e=>{t.submitPage(n.id,e).then(h)},w=(0,H.useContext)(q),T=(0,H.useRef)(o);T.current=o;let E=w?.bindPage,D=(0,H.useRef)(S);D.current=S,(0,H.useEffect)(()=>{if(!E)return;let e=C(i,a,o);return E({step:n,fields:e,values:o,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?mt(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(!v)return!1;let t=mt(v,e);if(t)return d({[v.id]:t}),!1;let n={...o,[v.id]:e},r=[...c,v.id];return s(n),l(r),d({}),C(i,a,n).some(e=>!r.includes(e.id))||S(n),!0},k=[...r.map(e=>c.length?{...e,onEdit:void 0}:e),...yt(n,`now:${n.id}`,o,e.id,_,y).map((e,t,n)=>t===n.length-1&&e.who===`me`&&v?{...e,onEdit:x}:e)];v?(ft(v)===`control`?k.push(G(`now:${n.id}:${v.id}:control`,(0,U.jsx)(te,{field:v,value:o[v.id],values:o,runId:e.id,view:e,closed:e.closed?.[v.id],onChange:e=>s(t=>({...t,[v.id]:e})),onBusy:p}),{wide:!0})):y||k.push(G(`now:${n.id}:${v.id}`,(0,U.jsx)(gt,{field:v}))),u[v.id]&&k.push(G(`now:${n.id}:${v.id}:error`,u[v.id],{tone:`error`}))):t.busy||m?k.push(G(`sending`,(0,U.jsx)(ut,{}))):t.error&&k.push(G(`send-error`,t.error,{tone:`error`}));let A=(0,U.jsx)(Q,{});if(m||!v&&c.length>0&&t.busy)A=(0,U.jsx)(Q,{placeholder:B(`run.working`)});else if(!v)k.push(X(`now:${n.id}:go`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>S(o),children:n.cta||B(`run.next`)}),x?(0,U.jsx)(Z,{onClick:x,disabled:t.busy,children:B(`run.back`)}):null]})));else{let r=ft(v),i=!v.required&&v.kind!==`connection`&&v.kind!==`list`?(0,U.jsx)(Z,{onClick:()=>O(void 0),children:B(`chat.skip`)}):null;if(r===`typed`){i&&k.push(X(`now:${n.id}:${v.id}:replies`,i));let e=o[v.id];A=(0,U.jsx)(ct,{children:(0,U.jsx)(dt,{initial:pt(e)?``:String(e),multiline:v.kind===`textarea`,placeholder:v.placeholder||(y?v.label:B(`chat.placeholder`)),inputProps:wt(v),busy:t.busy,onSend:e=>O(ht(v,e))},v.id)})}else if(r===`tapped`)k.push(G(`now:${n.id}:${v.id}:replies`,(0,U.jsx)(Tt,{field:v,view:e,value:o[v.id],onAnswer:O}),{bare:!0}));else{let e=g.filter(e=>!c.includes(e.id)).length===1;k.push(X(`now:${n.id}:${v.id}:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z,{primary:!0,disabled:f,onClick:()=>O(o[v.id]),children:e&&n.cta?n.cta:B(`chat.send`)}),i]})))}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:k}),A]})}function wt(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 F(e)}}function Tt({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,H.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,U.jsxs)(Y,{children:[(0,U.jsx)(Z,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:B(`run.no`)}),(0,U.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:B(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,U.jsxs)(Y,{children:[s.map(e=>(0,U.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:R(e)},e)),(0,U.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?B(`chat.send`):B(`chat.skip`)})]}):(0,U.jsxs)(Y,{children:[s.map(e=>(0,U.jsx)(Z,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:R(e)},e)),e.required?null:(0,U.jsx)(Z,{onClick:()=>r(void 0),children:B(`chat.skip`)})]})}function Et({view:e}){let t=(0,H.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(),[i,o]=(0,H.useState)(Date.now());(0,H.useEffect)(()=>{let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[]);let s=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),c=s.at(-1),l=[...s].reverse().find(Ot),u=[...new Set(s.map(e=>e.asset).filter(e=>!!e))];return(0,U.jsxs)(`div`,{className:a(`flex max-w-full flex-col gap-1`,l?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??B(`run.working`),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(ut,{}),(0,U.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??B(`run.working`)}),(0,U.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:B(`run.elapsed`,{s:Math.max(0,Math.round((i-n)/1e3))})})]}),c&&c!==l?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,U.jsx)(ae,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,U.jsx)(`span`,{className:`truncate`,children:j(c)})]}):null,l&&e.status===`running`?(0,U.jsx)(At,{runId:e.id,event:l}):null,u.length?(0,U.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:u.slice(-6).map(t=>(0,U.jsx)(`img`,{src:r(`/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 Dt=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function Ot(e){return!!e.note&&Dt.has(e.note.code)}var kt=1e4;function At({runId:e,event:t}){let[n,r]=(0,H.useState)(null),[i,o]=(0,H.useState)(`agent`),[s,c]=(0,H.useState)(!1),l=t.note?.code;if((0,H.useEffect)(()=>{l===`personDrives`?o(`person`):l===`agentDrives`&&o(`agent`)},[l]),(0,H.useEffect)(()=>{let t=()=>S.get(`/api/runs/${e}/browser/seat`).then(e=>o(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,kt);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let u=i===`person`,d=async()=>{c(!0);try{let t=await S.post(`/api/runs/${e}/browser/seat`,{to:u?`agent`:`person`});o(t.seat)}catch{}finally{c(!1)}};return(0,U.jsx)(m,{runId:e,driving:u,caption:j(t),hint:B(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,U.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>void d(),className:a(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,u?`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:[u?(0,U.jsx)(Fe,{className:`size-3.5`}):(0,U.jsx)(je,{className:`size-3.5`}),B(u?`browser.handBack`:`browser.takeOver`)]})},n??0)}function jt({children:e,end:t}){return(0,U.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function Mt({view:e,run:t,step:n,before:r,asked:i,onNote:a}){let o=e.shown.filter(e=>e.output),[s,c]=(0,H.useState)(o.length===1?o[0].step.id:null),l=(0,H.useRef)(null),u=[...r,...i.map((e,t)=>K(`review:${n.id}:asked:${t}`,e)),G(`review:${n.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,U.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.description}):null]}),{anchor:!0}),...o.map(({step:t,output:r})=>G(`review:${n.id}:${t.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jt,{children:t.title}),(0,U.jsx)(oe,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{c(t.id),l.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>G(`review:${n.id}:list:${t.def.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jt,{children:t.def.title}),t.def.check?(0,U.jsx)(fe,{runId:e.id,list:t}):(0,U.jsx)(O,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&u.push(G(`review-error`,t.error,{tone:`error`}));let d=n.regenerate&&o.length>0;return u.push(X(`review:${n.id}:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,U.jsx)(x,{className:`size-4`}),` `,B(`run.accept`)]}),d&&o.length>1?o.map(({step:e})=>(0,U.jsx)(Z,{on:s===e.id,onClick:()=>c(e.id),children:e.title},e.id)):null]}))),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:u}),d?(0,U.jsx)(ct,{children:(0,U.jsx)(dt,{multiline:!0,inputRef:l,busy:t.busy,placeholder:o.length>1&&!s?B(`run.feedbackPick`):B(`run.feedbackPlaceholder`),disabled:!s,onSend:e=>{let r=e.trim();return!r||!s?!1:(a(r),t.regenerate(n.id,s,r),!0)}})}):(0,U.jsx)(Q,{})]})}function Nt({view:e,run:t,step:n,before:r,onRestart:i}){let a=e.shown.filter(e=>e.output),o=`/api/runs/${e.id}`,s=[...r,G(`result:${n.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,U.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.message}):null]}),{anchor:!0}),...a.map(({step:e,output:t,formats:n,label:r})=>G(`result:${e.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jt,{end:(0,U.jsx)(ne,{base:o,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,U.jsx)(oe,{base:o,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,U.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:B(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>G(`result:list:${t.def.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jt,{end:(0,U.jsx)(he,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,U.jsx)(O,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return s.push(X(`result:replies`,(0,U.jsxs)(U.Fragment,{children:[a.length?(0,U.jsx)(De,{view:e,title:`${n.title} · ${e.wizard.title}`}):null,i?(0,U.jsxs)(Z,{onClick:i,children:[(0,U.jsx)(P,{className:`size-4`}),` `,B(`run.again`)]}):null,e.canBack?(0,U.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:B(`run.back`)}):null,e.keeps?(0,U.jsx)(`span`,{className:`ml-1`,children:(0,U.jsx)(pe,{runId:e.id})}):null]}))),(0,U.jsx)(J,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:s})}function Pt({runId:e,onRestart:t,onView:n,header:r,footer:i,talk:a=!1,call:o=!1}){let s=at(e),{view:d}=s,[f,m]=(0,H.useState)(null),h=$e(e,d,s,f);(0,H.useEffect)(()=>{n?.(d)},[d,n]);let[g,_]=Te(),v=(0,H.useMemo)(()=>({runId:e,lang:d?.lang??ce,readAloud:g,setReadAloud:_,voice:d?.talk?h:null,talk:a,call:!!o,bindPage:m}),[e,d?.lang,d?.talk,g,_,h,a,o]);l(d?.status===`running`&&!d.ask),A(d);let[y,b]=(0,H.useState)({}),[x,S]=(0,H.useState)(null);(0,H.useEffect)(()=>{d&&d.status!==`running`&&S(null)},[d]);let C;if(s.notFound)C=(0,U.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:B(`run.notFound`)});else if(!d)C=(0,U.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,U.jsx)(p,{})});else{let e=d.step,n=d.status===`waiting_input`,r=xt(d,d.canBack&&n&&!s.busy?()=>void s.back():void 0);if(d.status===`running`&&d.ask)C=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:[...r,G(`ask:${d.ask.id}`,(0,U.jsx)(c,{runId:d.id,ask:d.ask}),{wide:!0})]}),(0,U.jsx)(Q,{})]});else if(d.status===`running`)C=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:[...r,...x?[K(`note`,x)]:[],G(`working:${e?.id}`,(0,U.jsx)(Et,{view:d}),{wide:d.events.some(t=>t.stepId===e?.id&&Ot(t))?`most`:void 0})]}),(0,U.jsx)(Q,{placeholder:B(`run.working`)})]});else if(d.status===`failed`)C=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:[...r,G(`failed`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:B(`run.failed`)}),d.error?(0,U.jsx)(`span`,{className:`mt-0.5 block`,children:(0,U.jsx)(u,{text:d.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{primary:!0,busy:s.busy,onClick:()=>void s.retry(),children:[(0,U.jsx)(P,{className:`size-4`}),` `,B(`run.retry`)]}),d.canBack?(0,U.jsx)(Z,{onClick:()=>void s.back(),disabled:s.busy,children:B(`run.back`)}):null]}))]}),(0,U.jsx)(Q,{})]});else if(d.status===`cancelled`)C=(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:[...r,G(`cancelled`,B(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,U.jsxs)(Z,{primary:!0,onClick:t,children:[(0,U.jsx)(P,{className:`size-4`}),` `,B(`run.again`)]}))]:[]]});else if(e?.type===`page`)C=(0,U.jsx)(Ct,{view:d,run:s,step:e,before:r},e.id);else if(e?.type===`review`){let t=d.shown.map(e=>e.output?.at??``).join(`|`);C=(0,U.jsx)(Mt,{view:d,run:s,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,U.jsx)(Nt,{view:d,run:s,step:e,before:r,onRestart:t}):(0,U.jsx)(J,{avatar:d.wizard.avatar,costume:d.wizard.costume,lines:r})}return o?(0,U.jsx)(q.Provider,{value:v,children:(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,U.jsx)(qe,{voice:h,view:d,video:o===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,U.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,U.jsx)(lt,{footer:i,children:C})})]})}):(0,U.jsx)(q.Provider,{value:v,children:(0,U.jsx)(lt,{header:r,footer:i,children:C})})}function Ft({runId:e,...t}){let n=at(e);return(0,U.jsx)(ie,{run:n,...t})}function $(e){let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)}function It(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 Lt={left:It(1),right:It(9)};function Rt({side:e,className:t}){return(0,U.jsx)(`svg`,{className:t??`wizard-web wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:Lt[e],fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function zt(){return(0,U.jsxs)(`div`,{className:`wizard-spider`,children:[(0,U.jsx)(`div`,{className:`wizard-spider-thread`}),(0,U.jsxs)(`svg`,{viewBox:`-30 -10 60 60`,"aria-hidden":`true`,children:[(0,U.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`2.6`,strokeLinecap:`round`,fill:`none`,children:[0,1,2,3].map(e=>(0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{d:`M0 ${8+e*5} Q-16 ${-2+e*6} -24 ${14+e*6}`}),(0,U.jsx)(`path`,{d:`M0 ${8+e*5} Q16 ${-2+e*6} 24 ${14+e*6}`})]},e))}),(0,U.jsx)(`ellipse`,{cx:`0`,cy:`22`,rx:`11`,ry:`14`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`0`,cy:`6`,r:`7`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`-2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`}),(0,U.jsx)(`circle`,{cx:`2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`})]})]})}function Bt({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,U.jsx)(`svg`,{className:`wizard-frost wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:t,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function Vt({kind:e}){let t=e===`stars`?28:22;return(0,U.jsx)(`div`,{className:`wizard-particles wizard-particles-${e}`,children:Array.from({length:t},(t,n)=>(0,U.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 Ht=[{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}],Ut=[{kind:`flame`,side:`right`,seconds:14,delay:2},{kind:`sprout`,side:`left`,seconds:16,delay:9}];function Wt({costume:e,motion:t}){return t===`peek`?(0,U.jsx)(U.Fragment,{children:Ut.map(t=>(0,U.jsx)(`div`,{className:`wizard-peek wizard-peek-${t.side}`,style:{animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,U.jsx)(Ce,{kind:t.kind,costume:e,size:96})},t.kind))}):(0,U.jsx)(U.Fragment,{children:Ht.map(t=>(0,U.jsx)(`div`,{className:`wizard-bat`,style:{top:`${t.top}%`,animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,U.jsx)(`div`,{className:`wizard-bat-bob`,children:(0,U.jsx)(Ce,{kind:t.kind,costume:e,size:t.size})})},t.kind))})}var Gt=[`witch`,`devil`,`bat`,`pumpkin`];function Kt({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,U.jsxs)(U.Fragment,{children:[n.some(e=>e.id===`fog`)?(0,U.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fog wizard-fx-contained`:`wizard-fog`}):null,(0,U.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,U.jsxs)(`div`,{children:[(0,U.jsx)(Bt,{side:`left`}),(0,U.jsx)(Bt,{side:`right`})]},n):t===`webs`?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(Rt,{side:`left`}),(0,U.jsx)(Rt,{side:`right`}),(0,U.jsx)(zt,{})]},n):null}if(e.id===`particles`){let t=r(e,`kind`)||`embers`;return[`embers`,`snow`,`confetti`,`stars`].includes(t)?(0,U.jsx)(Vt,{kind:t},n):null}if(e.id===`figures`){let t=r(e,`costume`);return(0,U.jsx)(Wt,{costume:Gt.includes(t)?t:void 0,motion:r(e,`motion`)||`fly`},n)}return null})})]})}var qt=[`brand`,`host`,`default`],Jt=[...qt,`engenty`,`wizard`,`wizards`],Yt=[`Inter`,`Figtree`,`DM Sans`,`Nunito`,`Fredoka`,`Bricolage Grotesque`,`Fraunces`,`Playfair Display`,`Lora`,`Young Serif`,`Caveat`,`Creepster`,`Nosifer`],Xt=I().regex(/^#[0-9a-fA-F]{6}$/,`a colour as #rrggbb`),Zt=z({accent:Xt.optional(),background:Xt.optional(),text:Xt.optional()}).extend({scheme:g([`light`,`dark`])}),Qt=z({radius:g([`sharp`,`soft`,`round`]).optional(),cards:g([`solid`,`outline`,`glass`]).optional(),headings:g([`normal`,`uppercase`]).optional()}),$t=z({id:I().min(1).max(40)}).catchall(E([I().max(40),le(),M()])),en=I().min(1).max(60).regex(/^[A-Za-z0-9 -]+$/,`a font by its family name, or brand`);z({id:I().regex(v,`a theme id: lowercase letters, digits and dashes`),name:I().min(1).max(80),version:I().regex(/^\d+\.\d+\.\d+$/).default(`1.0.0`),base:g(qt).default(`brand`),colors:i(Zt).min(1).max(2).refine(e=>new Set(e.map(e=>e.scheme)).size===e.length,{message:`Each scheme once: light, dark.`}).optional(),fonts:z({heading:en.optional(),text:en.optional()}).optional(),shape:Qt.optional(),effects:i($t).max(8).optional()});function tn(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 nn(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48);return t&&!Jt.includes(t)?t:`look`}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?.colors?.find(e=>e.scheme===t);if(!n)return;let{scheme:r,...i}=n;return i}function dn(e,t){let n=e.modes?.[t];return{accent:n?.accent??e.accent,background:n?.background??e.background,text:n?.text??null}}var fn={Inter:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([0])),V(()=>Promise.resolve({}),__vite__mapDeps([1])),V(()=>Promise.resolve({}),__vite__mapDeps([2])),V(()=>Promise.resolve({}),__vite__mapDeps([3]))],Figtree:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([4])),V(()=>Promise.resolve({}),__vite__mapDeps([5])),V(()=>Promise.resolve({}),__vite__mapDeps([6])),V(()=>Promise.resolve({}),__vite__mapDeps([7]))],"DM Sans":()=>[V(()=>Promise.resolve({}),__vite__mapDeps([8])),V(()=>Promise.resolve({}),__vite__mapDeps([9])),V(()=>Promise.resolve({}),__vite__mapDeps([10])),V(()=>Promise.resolve({}),__vite__mapDeps([11]))],Nunito:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([12])),V(()=>Promise.resolve({}),__vite__mapDeps([13])),V(()=>Promise.resolve({}),__vite__mapDeps([14])),V(()=>Promise.resolve({}),__vite__mapDeps([15]))],Fredoka:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([16])),V(()=>Promise.resolve({}),__vite__mapDeps([17])),V(()=>Promise.resolve({}),__vite__mapDeps([18])),V(()=>Promise.resolve({}),__vite__mapDeps([19]))],"Bricolage Grotesque":()=>[V(()=>Promise.resolve({}),__vite__mapDeps([20])),V(()=>Promise.resolve({}),__vite__mapDeps([21])),V(()=>Promise.resolve({}),__vite__mapDeps([22])),V(()=>Promise.resolve({}),__vite__mapDeps([23]))],Fraunces:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([24])),V(()=>Promise.resolve({}),__vite__mapDeps([25])),V(()=>Promise.resolve({}),__vite__mapDeps([26])),V(()=>Promise.resolve({}),__vite__mapDeps([27]))],"Playfair Display":()=>[V(()=>Promise.resolve({}),__vite__mapDeps([28])),V(()=>Promise.resolve({}),__vite__mapDeps([29])),V(()=>Promise.resolve({}),__vite__mapDeps([30])),V(()=>Promise.resolve({}),__vite__mapDeps([31]))],Lora:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([32])),V(()=>Promise.resolve({}),__vite__mapDeps([33])),V(()=>Promise.resolve({}),__vite__mapDeps([34])),V(()=>Promise.resolve({}),__vite__mapDeps([35]))],"Young Serif":()=>[V(()=>Promise.resolve({}),__vite__mapDeps([36]))],Caveat:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([37])),V(()=>Promise.resolve({}),__vite__mapDeps([38])),V(()=>Promise.resolve({}),__vite__mapDeps([39])),V(()=>Promise.resolve({}),__vite__mapDeps([40]))],Creepster:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([41]))],Nosifer:()=>[V(()=>Promise.resolve({}),__vite__mapDeps([42]))]},pn=new Set;function mn(e){e&&!pn.has(e)&&e in fn&&(pn.add(e),Promise.all(fn[e]()).catch(()=>pn.delete(e)))}function hn(e){He(e,e.url.startsWith(`/`)?r(e.url):e.url,()=>mn(cn(e.family)))}function gn(e,t){let n=e.faces??[],r=!!e.modes,i=dn({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 _n(e){return!!(e&&!e.pinned&&e.modes?.light&&e.modes.dark)}function vn(e){for(let t of e.faces??[])hn(t);mn(e.display),mn(e.body)}function yn(e){ye(e?.pinned?e.dark?`dark`:`light`:null),ve(e?.prefer??null);let t=be(),n=JSON.stringify(e??{});(0,H.useEffect)(()=>{let e=JSON.parse(n),r=document.documentElement;vn(e);let{props:i,marks:a,themed:o}=gn(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 bn(e,t){let n=JSON.stringify(e??{});if((0,H.useEffect)(()=>{vn(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}=gn(e,t&&_n(e)?t:r);return{className:[`wizard-themed`,...a,o?`dark`:``].filter(Boolean).join(` `),style:Object.fromEntries(i)}}export{J as _,mn as a,Ne as b,un as c,Kt as d,Ft as f,Z as g,Q as h,hn as i,nn as l,lt as m,yn as n,Yt as o,Pt as p,bn as r,tn as s,_n as t,Rt as u,X as v,st as y};