@engenty/wizards-runtime 0.11.12 → 0.11.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/auth/index.js +14 -2
- package/apps/web/dist/assets/{AboutDialog-DKGBCS3o.js → AboutDialog-pMHleH_y.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-Dc66LqBg.js → ChangelogDialog-Cxwkcjdy.js} +1 -1
- package/apps/web/dist/assets/{EditorPage-CWtOGKs7.js → EditorPage-v7cpENx3.js} +1 -1
- package/apps/web/dist/assets/{Harness-CdmCoeEZ.js → Harness-TUpGhGX5.js} +1 -1
- package/apps/web/dist/assets/{NewWizardChannels-g3CJzwr5.js → NewWizardChannels-CelW1MGq.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-DGHwvXLf.js → NewWizardPage-Coswm2WX.js} +1 -1
- package/apps/web/dist/assets/{OnboardingPage-CoCBYKvL.js → OnboardingPage-C9XM_VXs.js} +1 -1
- package/apps/web/dist/assets/{PreviewPane-BgIEsVjy.js → PreviewPane-BUwlltqA.js} +1 -1
- package/apps/web/dist/assets/{ProjectPage-Cmhm9qh1.js → ProjectPage-Cw7hdXO6.js} +1 -1
- package/apps/web/dist/assets/{PublicRunner-C7i0QdlT.js → PublicRunner-B5RGNs07.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-C3SYrBNk.js → ReadOnly-DZMZPM-W.js} +1 -1
- package/apps/web/dist/assets/{SettingsPage-Ctul7RLy.js → SettingsPage-CfL1e3Vs.js} +2 -2
- package/apps/web/dist/assets/{SetupPage-CuuQVDH2.js → SetupPage-BRPenYa-.js} +1 -1
- package/apps/web/dist/assets/{SharePage-BDeYhYRB.js → SharePage-DF8LO8-K.js} +1 -1
- package/apps/web/dist/assets/changelog-CO6ysfQg.js +1 -0
- package/apps/web/dist/assets/{index-C0yASttP.js → index-Bl7qOZv0.js} +3 -3
- package/apps/web/dist/assets/{theme-DftQJmEW.js → theme-D6QLPvJL.js} +1 -1
- package/apps/web/dist/index.html +1 -1
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/changelog-BXyvVCpB.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-pMHleH_y.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-Bhp_a_44.js","assets/preload-helper-DpV6A1kQ.js","assets/i18n-BYeH2Dmi.js","assets/logo-CGNoptDg.js","assets/engenty-CNjaZCVM.js","assets/settings-menu-C0yo5q3t.js","assets/react-dom-hf6EcyAr.js","assets/media-Cej-H610.js","assets/ChangelogDialog-Cxwkcjdy.js","assets/Marketplace-CpjRqTvn.js","assets/useMutation-Cmn8b7tT.js","assets/volume-2-DGqbhyPO.js","assets/session-CngLvd02.js","assets/PublicRunner-B5RGNs07.js","assets/theme-D6QLPvJL.js","assets/phone-JGS60FQU.js","assets/theme-CbR9-ayl.css","assets/SharePage-DF8LO8-K.js","assets/EditorPage-v7cpENx3.js","assets/PreviewPane-BUwlltqA.js","assets/upload-DPLDQsRT.js","assets/runners-CwTP03YR.js","assets/wrench-Dr19y-10.js","assets/esm-BdxDT9Km.js","assets/NewWizardChannels-CelW1MGq.js","assets/OnboardingPage-C9XM_VXs.js","assets/NewWizardPage-Coswm2WX.js","assets/SettingsPage-CfL1e3Vs.js","assets/ReadOnly-DZMZPM-W.js","assets/Harness-TUpGhGX5.js","assets/Harness-BrP-ENHg.css","assets/ProjectPage-Cw7hdXO6.js","assets/SetupPage-BRPenYa-.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{n as r,t as i}from"./jsx-runtime-BNakU3Ej.js";import{$ as a,$n as o,An as s,Ar as c,B as l,Bn as u,Cn as d,Cr as f,Dn as p,Dr as m,Er as h,Fn as g,G as _,Gn as v,Gt as y,Hn as b,In as x,It as S,J as C,Jn as ee,Jt as w,K as te,Kt as T,Ln as E,Lt as ne,Mn as re,Mr as D,Nn as ie,Pn as ae,Pt as oe,Q as se,Qn as ce,Rn as le,Tn as ue,Tr as de,Un as fe,W as O,Wt as k,X as pe,Xn as A,Xt as me,Y as he,Yt as ge,Z as _e,Zn as j,Zt as M,_n as ve,_r as ye,_t as be,a as xe,an as Se,ar as N,at as Ce,bn as we,br as Te,cn as Ee,ct as De,en as Oe,er as ke,et as Ae,fn as je,ft as Me,gr as Ne,hn as Pe,hr as Fe,i as Ie,in as Le,ir as Re,it as ze,jr as Be,l as Ve,ln as He,lt as Ue,mn as We,nr as Ge,nt as Ke,on as P,or as qe,ot as Je,pn as Ye,q as Xe,qn as Ze,qt as Qe,r as $e,rn as et,rr as tt,rt as nt,s as rt,sn as it,sr as at,t as ot,tn as st,tr as F,tt as ct,un as lt,ur as ut,ut as dt,vr as ft,wr as pt,wt as mt,xn as ht,xr as gt,y as _t,yn as vt,yr as yt,yt as bt,zn as xt}from"./ui-Bhp_a_44.js";import{A as St,D as Ct,O as wt,S as Tt,T as Et,_ as Dt,i as Ot,j as kt,n as At,v as jt,x as Mt}from"./Marketplace-CpjRqTvn.js";import{n as Nt,t as Pt}from"./useMutation-Cmn8b7tT.js";import{t as Ft}from"./react-dom-hf6EcyAr.js";import{t as It}from"./preload-helper-DpV6A1kQ.js";import{i as Lt,n as Rt,r as zt,t as Bt}from"./volume-2-DGqbhyPO.js";import{A as Vt,C as Ht,D as Ut,M as Wt,_ as Gt,b as Kt,c as qt,d as I,f as Jt,g as Yt,h as Xt,i as Zt,j as Qt,k as $t,l as en,m as tn,n as nn,o as rn,r as an,s as on,x as sn}from"./session-CngLvd02.js";import{n as cn,t as ln}from"./logo-CGNoptDg.js";import{D as un,K as dn,T as fn,V as pn,_t as mn,bt as hn,c as gn,et as _n,g as vn,gt as yn,mt as bn,n as L,pt as xn,r as Sn,s as R,vt as Cn,w as wn}from"./i18n-BYeH2Dmi.js";import{t as Tn}from"./media-Cej-H610.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var En=class extends ft{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new Nt({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Dn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Dn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Dn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Dn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Ne.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>f(t,e))}findAll(e={}){return this.getAll().filter(t=>f(e,t))}notify(e){Ne.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Ne.batch(()=>Promise.all(e.map(e=>e.continue().catch(de))))}};function Dn(e){return e.options.scope?.id}var On=class extends ft{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??gt(r,t),a=this.get(i);return a||(a=new ut({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Ne.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>pt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>pt(e,t)):t}notify(e){Ne.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Ne.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ne.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},kn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new On,this.#t=e.mutationCache||new En,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ye.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(m(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=yt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Ne.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Ne.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Ne.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=Ne.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(de).catch(de)}invalidateQueries(e,t={}){return Ne.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ne.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(de)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(de)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(m(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(m(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(de).catch(de)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(de).catch(de)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Fe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Te(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{h(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Te(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{h(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=gt(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===c&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},An=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,E());else{var t=n(l);t!==null&&D(x,t.startTime-e)}}}var S=!1,C=-1,ee=5,w=-1;function te(){return g?!0:!(e.unstable_now()-w<ee)}function T(){if(g=!1,S){var t=e.unstable_now();w=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&te());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&D(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?E():S=!1}}}var E;if(typeof y==`function`)E=function(){y(T)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=T,E=function(){re.postMessage(null)}}else E=function(){_(T,0)};function D(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):ee=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,D(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,E()))),r},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),jn=n(((e,t)=>{t.exports=An()})),Mn=n((e=>{var t=jn(),n=r(),i=Ft();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(a(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return u(i),e;if(o===r)return u(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,l=i.child;l;){if(l===n){c=!0,n=i,r=o;break}if(l===r){c=!0,r=i,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=i;break}if(l===r){c=!0,r=o,n=i;break}l=l.sibling}if(!c)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}function p(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&p(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function m(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function h(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function g(e){var t=[null,null],n=m(e);return n===null||_(t,e,n.child,{foundSelf:!1}),t}function _(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&_(e,t,n.child,r))return!0;n=n.sibling}return!1}function v(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(a(559))}}var y=null,b=null;function x(e,t,n){return e===n||e===t&&(y=e,!0)}function S(e,t,n){return e===n?(b=e,!1):e===t&&(b!==null&&(y=e),!0)}function C(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function ee(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,te=Symbol.for(`react.element`),T=Symbol.for(`react.transitional.element`),E=Symbol.for(`react.portal`),ne=Symbol.for(`react.fragment`),re=Symbol.for(`react.strict_mode`),D=Symbol.for(`react.profiler`),ie=Symbol.for(`react.consumer`),ae=Symbol.for(`react.context`),oe=Symbol.for(`react.forward_ref`),se=Symbol.for(`react.suspense`),ce=Symbol.for(`react.suspense_list`),le=Symbol.for(`react.memo`),ue=Symbol.for(`react.lazy`),de=Symbol.for(`react.activity`),fe=Symbol.for(`react.legacy_hidden`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.for(`react.view_transition`),pe=Symbol.for(`react.recoverable`),A=Symbol.iterator;function me(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var he=Symbol.for(`react.client.reference`);function ge(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===he?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case ne:return`Fragment`;case D:return`Profiler`;case re:return`StrictMode`;case se:return`Suspense`;case ce:return`SuspenseList`;case de:return`Activity`;case k:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case E:return`Portal`;case ae:return e.displayName||`Context`;case ie:return(e._context.displayName||`Context`)+`.Consumer`;case oe:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case le:return t=e.displayName||null,t===null?ge(e.type)||`Memo`:t;case ue:t=e._payload,e=e._init;try{return ge(e(t))}catch{}}return null}var _e=Array.isArray,j=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ye=[],be=-1;function xe(e){return{current:e}}function Se(e){0>be||(e.current=ye[be],ye[be]=null,be--)}function N(e,t){be++,ye[be]=e.current,e.current=t}var Ce=xe(null),we=xe(null),Te=xe(null),Ee=xe(null);function De(e,t){switch(N(Te,t),N(we,e),N(Ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?dp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=dp(t),e=fp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Se(Ce),N(Ce,e)}function Oe(){Se(Ce),Se(we),Se(Te)}function ke(e){var t=e.memoizedState;t!==null&&(ch._currentValue=t.memoizedState,N(Ee,e)),t=Ce.current;var n=fp(t,e.type);t!==n&&(N(we,e),N(Ce,n))}function Ae(e){we.current===e&&(Se(Ce),Se(we)),Ee.current===e&&(Se(Ee),ch._currentValue=ve)}var je,Me;function Ne(e){if(je===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);je=t&&t[1]||``,Me=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+je+e+Me}var Pe=!1;function Fe(e,t){if(!e||Pe)return``;Pe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -21,7 +21,7 @@ Error generating stack: `+e.message+`
|
|
|
21
21
|
${n}
|
|
22
22
|
}
|
|
23
23
|
`}),o.appendChild(r.createTextNode(e))}i.timeEnd(`clone node`),await f?.(h),l!==!1&&eo(h)&&(i.time(`embed web font`),await xs(h,n),i.timeEnd(`embed web font`)),i.time(`embed node`),bs(h,n);let g=a.length,_=0,v=async()=>{for(;;){let e=a.pop();if(!e)break;try{await e}catch(e){n.log.warn(`Failed to run task`,e)}u?.(++_,g)}};u?.(_,g),await Promise.all([...Array.from({length:4})].map(v)),i.timeEnd(`embed node`),await p?.(h);let y=Ms(h,n);return s&&y.insertBefore(s,y.children[0]),o&&y.insertBefore(o,y.children[0]),d&&cs(n),await m?.(y),y}function Ms(e,t){let{width:n,height:r}=t,i=wo(n,r,e.ownerDocument),a=i.ownerDocument.createElementNS(i.namespaceURI,`foreignObject`);return a.setAttributeNS(null,`x`,`0%`),a.setAttributeNS(null,`y`,`0%`),a.setAttributeNS(null,`width`,`100%`),a.setAttributeNS(null,`height`,`100%`),a.append(e),i.appendChild(a),i}async function Ns(e,t){let n=await Io(e,t),r=await js(n),i=To(r,n.isEnable(`removeControlCharacter`));return n.autoDestruct||(n.svgStyleElement=Ro(n.ownerDocument),n.svgDefsElement=n.ownerDocument?.createElementNS(Co,`defs`),n.svgStyles.clear()),await Bo(Oo(i,r.ownerDocument),n)}async function Ps(e,t){let n=await Io(e,t),{log:r,quality:i,type:a,dpi:o}=n,s=await Ns(n);r.time(`canvas to data url`);let c=s.toDataURL(a,i);if([`image/png`,`image/jpeg`].includes(a)&&o&&Wa&&Ga){let[e,t]=c.split(`,`),n=0,r=!1;if(a===`image/png`){let e=Ba(t);e>=0?(n=Math.ceil((e+28)/3)*4,r=!0):n=44}else a===`image/jpeg`&&(n=24);let i=t.substring(0,n),s=t.substring(n),l=window.atob(i),u=new Uint8Array(l.length);for(let e=0;e<u.length;e++)u[e]=l.charCodeAt(e);let d=a===`image/png`?Ia(u,o,r):Da(u,o);c=[e,`,`,window.btoa(String.fromCharCode(...d)),s].join(``)}return r.timeEnd(`canvas to data url`),c}async function Fs(e,t){return Ps(await Io(e,{...t,type:`image/png`}))}var Is=null,Ls=!1,Rs=0,zs=new Set,Bs=()=>{for(let e of zs)e()};async function Vs(e){if(Ls)return;Ls=!0,Bs();let t=await qs();Ls=!1,Rs+=1,Is={context:e,shot:t,n:Rs},Bs()}var Hs=()=>{Is=null,Bs()},Us=e=>(zs.add(e),()=>{zs.delete(e)}),Ws=()=>(0,z.useSyncExternalStore)(Us,()=>Is),Gs=()=>(0,z.useSyncExternalStore)(Us,()=>Ls);function Ks(e){if(e instanceof HTMLInputElement){if(![`button`,`submit`,`checkbox`,`radio`,`range`,`color`,`hidden`].includes(e.type)){let t=e.value?`•`.repeat(Math.min(12,e.value.length)):``;e.setAttribute(`value`,t),e.value=t}}else if(e instanceof HTMLTextAreaElement){let t=e.value?`•`.repeat(Math.min(24,e.value.length)):``;e.textContent=t,e.value=t}else e instanceof HTMLElement&&(e.isContentEditable||e.dataset.private!==void 0)&&(e.style.filter=`blur(6px)`)}async function qs(){try{return await Fs(document.body,{scale:Math.min(2,window.devicePixelRatio||1),width:window.innerWidth,height:window.innerHeight,style:{transform:`translateY(-${window.scrollY}px)`},backgroundColor:getComputedStyle(document.body).backgroundColor||`#fff`,onCloneEachNode:Ks,filter:e=>!(e instanceof HTMLElement&&e.dataset.reportSkip!==void 0)})}catch(e){return console.warn(`[report] no screenshot:`,e.message),null}}function Js(e,t,n){if(!e||!t)return;let r=e.getContext(`2d`);if(r){r.drawImage(t,0,0,e.width,e.height);for(let t of n)if(t.tool===`pen`){r.strokeStyle=`#e11d48`,r.lineWidth=Math.max(3,e.width/300),r.lineCap=`round`,r.lineJoin=`round`,r.beginPath();for(let[e,[n,i]]of t.points.entries())e?r.lineTo(n,i):r.moveTo(n,i);r.stroke()}else{r.fillStyle=`#000`;let[e,n]=t.from,[i,a]=t.to;r.fillRect(Math.min(e,i),Math.min(n,a),Math.abs(i-e),Math.abs(a-n))}}}function Ys({src:e,onChange:t}){let n=(0,z.useRef)(null),r=(0,z.useRef)(null),[i,a]=(0,z.useState)(`pen`),[o,s]=(0,z.useState)([]),c=(0,z.useRef)(null),l=e=>Js(n.current,r.current,e);(0,z.useEffect)(()=>{let t=new Image;t.onload=()=>{r.current=t;let e=n.current;e&&(e.width=t.naturalWidth,e.height=t.naturalHeight,Js(e,t,[]))},t.src=e},[e]);let u=e=>{let t=n.current,r=t.getBoundingClientRect();return[(e.clientX-r.left)/r.width*t.width,(e.clientY-r.top)/r.height*t.height]},d=e=>{s(e),l(e),t(n.current.toDataURL(`image/png`))};return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:[(0,B.jsxs)(k,{size:`sm`,variant:i===`pen`?`quiet`:`ghost`,onClick:()=>a(`pen`),children:[(0,B.jsx)(Cr,{className:`size-4`}),` `,R(`report.pen`)]}),(0,B.jsxs)(k,{size:`sm`,variant:i===`cover`?`quiet`:`ghost`,onClick:()=>a(`cover`),children:[(0,B.jsx)(je,{className:`size-4 fill-current`}),` `,R(`report.cover`)]}),(0,B.jsxs)(k,{size:`sm`,variant:`ghost`,disabled:!o.length,onClick:()=>d(o.slice(0,-1)),children:[(0,B.jsx)(Ui,{className:`size-4`}),` `,R(`report.undo`)]}),o.length?(0,B.jsx)(k,{size:`sm`,variant:`ghost`,onClick:()=>d([]),"aria-label":`Clear`,children:(0,B.jsx)(ae,{className:`size-4`})}):null]}),(0,B.jsx)(`canvas`,{ref:n,className:`w-full cursor-crosshair touch-none rounded-lg border border-border`,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId);let t=u(e);c.current=i===`pen`?{tool:i,points:[t]}:{tool:i,from:t,to:t}},onPointerMove:e=>{let t=c.current;if(!t)return;let n=u(e);t.tool===`pen`?t.points.push(n):t.to=n,l([...o,t])},onPointerUp:()=>{let e=c.current;c.current=null,e&&d([...o,e])}})]})}function Xs(){let e=Ws();return Gs()?(0,B.jsx)(`div`,{"data-report-skip":!0,className:`pointer-events-none fixed inset-x-0 bottom-6 z-50 flex justify-center`,children:(0,B.jsxs)(`span`,{className:`flex items-center gap-2 rounded-full bg-ink px-4 py-2 text-paper text-sm`,children:[(0,B.jsx)(st,{className:`size-4`}),` `,R(`report.capturing`)]})}):e?(0,B.jsx)(Zs,{context:e.context,shot:e.shot},e.n):null}function Zs({context:e,shot:t}){let[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(!!t),[o,s]=(0,z.useState)(!0),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(`idle`),m=pe().map(_e),h=_e(window.location.href),g=async()=>{p(`sending`);try{let r=await fetch(Je(`/api/bug-reports`),{method:`POST`,headers:{"content-type":`application/json`},credentials:`include`,body:JSON.stringify({where:e.where,url:window.location.href.split(`?`)[0],runId:e.runId??null,comment:c.trim()||null,error:e.error?{message:_e(e.error.message),stack:e.error.stack?_e(e.error.stack):void 0}:null,logs:o?m:[],screenshot:i?n??t:null,contact:u.trim()||null})});p(r.ok?`sent`:`failed`)}catch{p(`failed`)}};return(0,B.jsx)(Qe,{open:!0,onClose:Hs,title:R(`report.title`),wide:!0,height:`tall`,children:(0,B.jsx)(`div`,{className:`grid gap-5`,"data-report-skip":!0,children:f===`sent`?(0,B.jsxs)(`div`,{className:`py-10 text-center`,children:[(0,B.jsx)(`p`,{className:`font-display font-semibold text-lg`,children:R(`report.sent`)}),(0,B.jsx)(k,{className:`mt-6`,onClick:Hs,children:`OK`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-ink-3 text-sm`,children:R(`report.lead`)}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{hint:R(`report.whatHint`),children:R(`report.what`)}),(0,B.jsx)(Se,{"data-autofocus":!0,value:c,onChange:e=>l(e.target.value),rows:3})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,B.jsx)(M,{hint:R(`report.screenshotHint`),children:R(`report.screenshot`)}),(0,B.jsx)(et,{checked:i,disabled:!t,onChange:a,label:R(`report.screenshot`)})]}),t?i?(0,B.jsx)(Ys,{src:t,onChange:r}):null:(0,B.jsx)(`p`,{className:`text-ink-3 text-sm`,children:R(`report.noShot`)})]}),e.error?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{children:R(`report.error`)}),(0,B.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-lg bg-paper-2 p-3 text-xs`,children:_e(e.error.message)})]}):null,(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,B.jsx)(M,{hint:R(`report.logsHint`),children:R(`report.logs`,{count:m.length})}),(0,B.jsx)(et,{checked:o,disabled:!m.length,onChange:s,label:R(`report.logs`,{count:m.length})})]}),o&&m.length?(0,B.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded-lg bg-paper-2 p-3 text-xs`,children:m.join(`
|
|
24
|
-
`)}):null]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{children:R(`report.page`)}),(0,B.jsxs)(`p`,{className:`break-all font-mono text-ink-3 text-xs`,children:[h,(0,B.jsx)(`br`,{}),navigator.userAgent]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{children:R(`report.contact`)}),(0,B.jsx)(me,{type:`email`,value:u,onChange:e=>d(e.target.value)})]}),f===`failed`?(0,B.jsx)(`p`,{className:`text-rose text-sm`,children:R(`report.failed`)}):null,(0,B.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,B.jsx)(k,{variant:`ghost`,onClick:Hs,children:R(`report.cancel`)}),(0,B.jsx)(k,{onClick:()=>void g(),busy:f===`sending`,children:R(f===`sending`?`report.sending`:`report.send`)})]})]})})})}var Qs=(0,z.lazy)(()=>It(()=>import(`./AboutDialog-DKGBCS3o.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),$s=`0.11.12`;function ec({me:e}){let[t,n]=(0,z.useState)(!1);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:`tabular-nums transition hover:text-ink-2`,onClick:()=>n(!0),children:R(`about.version`,{v:$s})}),t?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(Qs,{open:!0,me:e,onClose:()=>n(!1)})}):null]})}var tc=[`update`],nc=36e5;function rc(e=!0){let t=D(),[n,r]=(0,z.useState)(null),i=at({queryKey:tc,queryFn:()=>_.get(`/api/studio/update`),staleTime:nc,refetchInterval:nc,retry:!1,enabled:e}),a=Pt({mutationFn:()=>_.get(`/api/studio/update?fresh=1`),onSuccess:e=>t.setQueryData(tc,e)}),o=Pt({mutationFn:()=>_.post(`/api/studio/update`),onSuccess:e=>t.setQueryData(tc,e)}),s=i.data,c=s?.latest??null,l=s?.restarts&&(s.applying===`running`||s.applying===`done`),u=s?.current;return(0,z.useEffect)(()=>{if(!(l||s?.applying===`running`)||!c)return;let e=setInterval(async()=>{try{let e=await _.get(`/api/studio/update`);if(e.current!==u){window.location.reload();return}t.setQueryData(tc,e),e.applying===`done`&&e.restarts&&r(c)}catch{r(c)}},2e3);return()=>clearInterval(e)},[l,s?.applying,c,u,t]),{status:i,data:s,latest:c,check:a,apply:o,busy:s?.applying===`running`||n!==null,progress:!s||!c?null:n===null?s.applying===`running`?R(`about.update.installing`,{v:c}):s.applying===`done`?R(`about.update.done`,{v:c}):s.applying===`failed`?R(`about.update.failed`):null:R(`about.update.restarting`,{v:c})}}var ic=`wizards.install-banner`,ac=`wizards.first-day`,oc=()=>window.matchMedia(`(pointer: coarse)`).matches;function sc({open:e,onClose:t}){let n=Ta(),r=wa(n),i=R(r===`prompt`?`install.app.offer`:r===`none`?`install.app.browser`:`install.app.how.${r}`);return(0,B.jsxs)(Qe,{open:e,onClose:t,title:R(`install.app.action`),children:[(0,B.jsx)(`p`,{className:`text-[0.9375rem] text-ink-2 leading-relaxed`,children:i}),(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,B.jsx)(k,{variant:`ghost`,onClick:t,children:R(`install.app.close`)}),n?(0,B.jsx)(k,{onClick:()=>{Ea(n),t()},children:R(`install.app.action`)}):null]})]})}function cc(){try{return localStorage.getItem(ic)===`1`}catch{return!1}}var lc=()=>new Date().toLocaleDateString(`sv`);function uc(){try{let e=localStorage.getItem(ac);return e?e!==lc():(localStorage.setItem(ac,lc()),!1)}catch{return!1}}function dc({me:e}){let t=Ta(),[n,r]=(0,z.useState)(cc),[i]=(0,z.useState)(uc);return!(t&&e.hasWizards&&i)||n||ya()||oc()?null:(0,B.jsxs)(`div`,{className:`flex items-center gap-3 border-border-soft border-b bg-paper-2 px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,B.jsx)(kt,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1`,children:R(`install.app.offer`)}),(0,B.jsx)(k,{size:`sm`,onClick:()=>void Ea(t),children:R(`install.app.action`)}),(0,B.jsx)(ge,{label:R(`install.app.close`),onClick:()=>{try{localStorage.setItem(ic,`1`)}catch{}r(!0)},className:`size-8`,children:(0,B.jsx)(it,{className:`size-4`})})]})}function fc(e){return e.mode===`managed`&&(e.organizations.length>1||e.mayCreateOrganization)}function pc(e){if(e.slug){window.location.href=`${a}/${e.slug}/`;return}let t=new URLSearchParams({organization:e.id,return:`${a}/`});window.location.href=Je(`/api/auth/login?${t}`)}function mc(e){return e.organizations.find(t=>t.id===e.tenant.id)??(e.tenant.name?{id:e.tenant.id,name:e.tenant.name,slug:null,role:e.tenant.role,personal:!1,plan:e.tenant.plan}:null)}function hc({org:e,size:t=`sm`}){return(0,B.jsx)(`span`,{"aria-hidden":`true`,className:P(`grid shrink-0 place-items-center font-semibold tracking-wide`,t===`md`?`size-10 text-[0.8125rem]`:t===`sm`?`size-9 text-[0.75rem]`:`size-7 text-[0.625rem]`,e.personal?`rounded-full bg-ember-tint text-ember-strong ring-1 ring-border-soft`:`rounded-lg bg-card text-ink-2 ring-1 ring-border`),children:nn(e.name)})}function gc(e){let t=Re();return()=>{na(e.features,`teamPlans`)?t(`/settings/organization`):e.manageUrl&&window.open(`${e.manageUrl}/account`,`_blank`,`noreferrer`)}}function _c({me:e,roomy:t,onDone:n}){let r=gc(e),[i,a]=(0,z.useState)(null),o=P(`flex w-full items-center gap-3 rounded-lg px-3 text-left text-ink-2 transition hover:bg-accent hover:text-ink`,t?`py-3 text-[0.9375rem]`:`py-2 text-[0.875rem]`);return(0,B.jsxs)(B.Fragment,{children:[e.organizations.map(r=>{let o=r.id===e.tenant.id;return(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:i!==null,"aria-current":o?`true`:void 0,className:P(`flex w-full items-center gap-3 rounded-lg px-2 text-left transition hover:bg-accent disabled:cursor-default`,t?`py-2.5`:`py-1.5`),onClick:()=>{if(o){n();return}a(r.id),pc(r)},children:[(0,B.jsx)(hc,{org:r,size:t?`md`:`sm`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,B.jsx)(`span`,{className:P(`truncate`,t?`text-[0.9375rem]`:`text-[0.875rem]`,o?`font-semibold text-ink`:`font-medium text-ink-2`),children:r.name}),(0,B.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:i===r.id?R(`organizations.switching`,{name:r.name}):r.personal?R(`organizations.own`):R(`organization.role.${r.role}`)})]}),r.plan?(0,B.jsx)(`span`,{className:`shrink-0 whitespace-nowrap rounded-full px-2 py-0.5 font-medium text-[0.6875rem] text-ink-3 ring-1 ring-border`,children:r.plan.name}):null,(0,B.jsx)(`span`,{className:`grid w-4 shrink-0 place-items-center`,children:i===r.id?(0,B.jsx)(Vr,{className:`size-4 animate-spin text-ink-3`}):o?(0,B.jsx)(fe,{className:`size-4 text-ember-strong`}):null})]},r.id)}),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:o,onClick:()=>{n(),r()},children:[(0,B.jsx)(ji,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:R(`organizations.manage`)})]}),e.mayCreateOrganization&&e.manageUrl?(0,B.jsxs)(`a`,{role:`menuitem`,className:o,href:`${e.manageUrl}/account`,target:`_blank`,rel:`noreferrer`,onClick:n,children:[(0,B.jsx)(vt,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`flex-1 truncate`,children:R(`organizations.create`)}),(0,B.jsx)(Vn,{className:`size-3.5 shrink-0 text-ink-4`})]}):null]})}function vc({me:e,className:t}){let[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)({top:0,left:0}),o=(0,z.useRef)(null);Jm(o,n,()=>r(!1));let s=mc(e);return s?fc(e)?(0,B.jsxs)(`div`,{ref:o,className:P(`relative min-w-0 shrink`,t),children:[(0,B.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":n,title:R(`organizations.switch`),onClick:e=>{let t=e.currentTarget.getBoundingClientRect();a({top:t.bottom+6,left:t.left}),r(e=>!e)},className:P(`-ml-2 flex max-w-[13rem] items-center gap-1 rounded-md py-0.5 pr-1.5 pl-2 text-[0.9375rem] text-ink-2 transition hover:bg-accent hover:text-ink`,n&&`bg-accent text-ink`),children:[(0,B.jsx)(`span`,{className:`truncate`,children:s.name}),(0,B.jsx)($n,{className:`size-3.5 shrink-0 text-ink-4`})]}),n?(0,B.jsxs)(`div`,{role:`menu`,style:{position:`fixed`,...i},className:`z-50 w-80 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,B.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:R(`organizations.mine`)}),(0,B.jsx)(_c,{me:e,onDone:()=>r(!1)})]}):null]}):(0,B.jsx)(`span`,{className:P(`max-w-[12rem] truncate text-[0.9375rem] text-ink-3`,t),title:s.name,children:s.name}):null}function yc({me:e,open:t,onClose:n}){let r=(0,z.useRef)(null);return(0,z.useEffect)(()=>{let e=r.current;t&&e&&!e.open?e.showModal():!t&&e?.open&&e.close()},[t]),(0,B.jsx)(`dialog`,{ref:r,onClose:n,onClick:e=>{e.target===r.current&&n()},"aria-label":R(`organizations.switch`),className:P(`max-h-[85dvh] overflow-y-auto overscroll-contain bg-card p-0 text-ink shadow-overlay backdrop:bg-[oklch(20%_0.01_60/0.28)]`,`max-sm:mx-0 max-sm:mt-auto max-sm:mb-0 max-sm:w-full max-sm:max-w-none max-sm:rounded-t-3xl`,`sm:m-auto sm:w-[calc(100%-32px)] sm:max-w-sm sm:rounded-2xl`),children:t?(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-[max(1rem,env(safe-area-inset-bottom))] sm:pt-3`,children:[(0,B.jsx)(`div`,{className:`mx-auto mb-2 h-1.5 w-9 rounded-full bg-border sm:hidden`}),(0,B.jsx)(bc,{onClose:n,children:R(`organizations.switch`)}),(0,B.jsx)(_c,{me:e,roomy:!0,onDone:n})]}):null})}function bc({children:e,onClose:t}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-2 pt-1 pb-2.5`,children:[(0,B.jsx)(`h2`,{className:`font-semibold text-[1.0625rem]`,children:e}),(0,B.jsx)(`button`,{type:`button`,onClick:t,"aria-label":R(`common.close`),className:`grid size-8 place-items-center rounded-full bg-paper-2 text-ink-3 transition hover:text-ink`,children:(0,B.jsx)(it,{className:`size-4`})})]})}var xc=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);function Sc({me:e,position:t,horizontal:n,labels:r}){let i=Re(),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(!1),[l,d]=(0,z.useState)(!1),f=e.mode===`managed`?mc(e):null,p=fc(e),m=gc(e),h=Ta(),g=(0,z.useRef)(null);Jm(g,a,()=>o(!1)),(0,z.useEffect)(()=>{a||d(!1)},[a]);let _=e.mode===`local`,{data:v,check:y}=rc(_);(0,z.useEffect)(()=>{let e=e=>{e.key===`,`&&(xc?e.metaKey:e.ctrlKey)&&!e.altKey&&!e.shiftKey&&(e.preventDefault(),i(`/settings`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let b=e=>{o(!1),i(e)},x=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 transition hover:bg-accent hover:text-ink`,S=`ml-auto shrink-0 text-[0.75rem] text-ink-4`,C=(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),ee=y.isPending?{text:R(`about.update.checking`),tone:S}:v?.newer&&v.latest?{text:v.latest,tone:`ml-auto shrink-0 text-[0.75rem] font-medium text-ember-strong`}:v?{text:R(`about.update.upToDateShort`),tone:`ml-auto shrink-0 text-[0.75rem] text-moss`}:null;return(0,B.jsxs)(`div`,{ref:g,className:P(`relative shrink-0`,r&&`w-full`),children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-haspopup":`menu`,title:R(`about.title`),"aria-label":R(`about.title`),className:P(`shrink-0 rounded-lg transition hover:bg-ink/10`,a&&`bg-ink/10`,r?`flex h-12 w-full items-center gap-2 px-1.5`:P(`grid place-items-center`,n?`size-11`:`h-12 w-11`)),children:[(0,B.jsx)(ln,{size:32}),r?(0,B.jsxs)(`span`,{className:`truncate font-display font-semibold text-[1rem] tracking-tight`,children:[`engenty`,(0,B.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,B.jsx)(`span`,{className:`ml-1 font-normal text-ink-3`,children:`wizards`})]}):null]}),a?(0,B.jsxs)(`div`,{role:`menu`,className:P(`absolute z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,ha(t,`start`)),children:[(0,B.jsxs)(`div`,{className:`flex items-baseline gap-2 px-3 pt-2 pb-2.5`,children:[(0,B.jsxs)(`span`,{className:`font-display font-semibold text-[1rem] tracking-tight`,children:[`engenty`,(0,B.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,B.jsx)(`span`,{className:`ml-1 font-normal text-ink-3`,children:`wizards`})]}),(0,B.jsx)(`span`,{className:P(S,`tabular-nums`),children:$s})]}),f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":p?`menu`:void 0,"aria-expanded":p?l:void 0,className:P(`flex w-full items-center gap-3 rounded-lg px-2.5 py-1.5 text-left transition hover:bg-accent`,l&&`bg-accent`),onClick:()=>{p?d(e=>!e):(o(!1),m())},children:[(0,B.jsx)(hc,{org:f,size:`xs`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,B.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:f.name}),(0,B.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:f.plan?`${R(`organization.title`)} · ${f.plan.name}`:R(`organization.title`)})]}),p?(0,B.jsx)(u,{className:`size-4 shrink-0 text-ink-4`}):null]}),l?(0,B.jsxs)(`div`,{role:`menu`,className:P(`absolute top-12 z-50 w-80 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,t===`right`?`right-full mr-1.5`:`left-full ml-1.5`),children:[(0,B.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:R(`organizations.switch`)}),(0,B.jsx)(_c,{me:e,onDone:()=>o(!1)})]}):null,C]}):null,(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>b(`/settings/about`),children:R(`about.title`)}),_?(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>v?.newer?b(`/settings/about`):y.mutate(),children:[R(`about.update.check`),ee?(0,B.jsx)(`span`,{className:ee.tone,children:ee.text}):null]}):null,(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>b(`/settings/about?tab=new`),children:R(`about.tab.new`)}),C,(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>b(`/settings`),children:[R(`nav.settings`),` …`,(0,B.jsx)(`span`,{className:S,children:xc?`⌘ ,`:`Ctrl ,`})]}),ya()?null:(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>{o(!1),h?Ea(h):c(!0)},children:R(`install.app.action`)}),C,(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>b(`/settings/about?tab=credits`),children:R(`about.creditsMenu`)})]}):null,(0,B.jsx)(sc,{open:s,onClose:()=>c(!1)})]})}var Cc=[],wc=0,Tc=new Set;function Ec(){for(let e of Tc)e()}function Dc(e){let t=(0,z.useRef)(e);t.current=e;let n=e!==null,r=e?.icon,i=e?.label;(0,z.useEffect)(()=>{if(!n||!r||i===void 0)return;let e=++wc;return Cc=[...Cc,{id:e,action:{icon:r,label:i,run:()=>t.current?.run()}}],Ec(),()=>{Cc=Cc.filter(t=>t.id!==e),Ec()}},[n,r,i])}function Oc(){return(0,z.useSyncExternalStore)(e=>(Tc.add(e),()=>Tc.delete(e)),()=>Cc.at(-1)?.action??null,()=>null)}var kc=(0,z.lazy)(()=>It(()=>import(`./AboutDialog-DKGBCS3o.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])));function Ac(e,t=!1){return P(`shrink-0 rounded-lg transition`,t?`flex h-10 w-full items-center gap-3 px-2.5 font-medium text-[0.875rem]`:`grid size-10 place-items-center`,e?`bg-paper text-ink shadow-soft dark:ring-1 dark:ring-border-soft`:`text-ink-3 hover:bg-ink/10 hover:text-ink`)}function jc({children:e}){return(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})}function Mc({me:e,labels:t}){let{project:n}=I(),r=Qm(e),i=r?e.tenant.name??void 0:void 0;return(0,B.jsxs)($m,{me:e,placement:`bar-start`,label:n?.name??R(`nav.space`),className:e=>t?P(`flex w-full items-center gap-3 rounded-lg p-0.5 pr-2 text-left transition hover:bg-ink/10`,e&&`bg-ink/10`):P(`block rounded-lg transition`,e?`ring-2 ring-ink/80 ring-offset-2 ring-offset-sidebar`:`hover:shadow-soft`),children:[(0,B.jsx)(Zm,{project:n,name:i}),t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-semibold text-[0.875rem] text-ink`,children:i??n?.name??R(`nav.space`)}),r?null:(0,B.jsx)($n,{className:`size-4 shrink-0 text-ink-4`})]}):null]})}var Nc={left:di,top:hi,right:pi,bottom:si},Pc=[{pick:`light`,icon:Qt,label:`appbar.light`},{pick:`dark`,icon:Wt,label:`appbar.dark`},{pick:null,icon:ri,label:`appbar.system`}];function Fc({at:e,room:t,onClose:n}){let{position:r,labels:i}=fa(),a=Vt(),o=V,s=(0,z.useRef)(null);Jm(s,!0,n);let[c,l]=(0,z.useState)({x:0,y:0});(0,z.useLayoutEffect)(()=>{let e=s.current?.getBoundingClientRect();e&&l({x:Math.min(0,window.innerWidth-8-e.right),y:Math.min(0,window.innerHeight-8-e.bottom)})},[]);let u=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink disabled:pointer-events-none disabled:opacity-50`,d=`px-3 pt-2 pb-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.07em]`;return(0,B.jsxs)(`div`,{ref:s,role:`menu`,className:`fixed z-[60] w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,style:{left:Math.max(8,e.x+c.x),top:Math.max(8,e.y+c.y)},onContextMenu:e=>e.preventDefault(),children:[(0,B.jsx)(`div`,{className:d,children:R(`appbar.position`)}),o.map(e=>{let t=Nc[e];return(0,B.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===r,className:P(u,e===r&&`text-ink`),onClick:()=>{ua({position:e}),n()},children:[(0,B.jsx)(t,{className:`size-4`}),(0,B.jsx)(`span`,{className:`flex-1`,children:R(`appbar.${e}`)}),e===r?(0,B.jsx)(fe,{className:`size-4 text-ember-strong`}):null]},e)}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":i,disabled:!(i||t),className:P(u,i&&`text-ink`),onClick:()=>{ua({labels:!i}),n()},children:[(0,B.jsx)(li,{className:`size-4`}),(0,B.jsx)(`span`,{className:`flex-1`,children:R(`appbar.labels`)}),i?(0,B.jsx)(fe,{className:`size-4 text-ember-strong`}):null]}),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsx)(`div`,{className:d,children:R(`appbar.theme`)}),Pc.map(({pick:e,icon:t,label:r})=>(0,B.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===a,className:P(u,e===a&&`text-ink`),onClick:()=>{Ht(e),n()},children:[(0,B.jsx)(t,{className:`size-4`}),(0,B.jsx)(`span`,{className:`flex-1`,children:R(r)}),e===a?(0,B.jsx)(fe,{className:`size-4 text-ember-strong`}):null]},r))]})}function Ic(){let{pathname:e}=tt();return e===`/new`?`new`:e===`/`||e.startsWith(`/edit/`)?`home`:e===`/space/results`||e.startsWith(`/space/results/`)?`results`:e===`/settings`||e.startsWith(`/settings/`)?`settings`:e===`/space`||e.startsWith(`/space/`)?`space`:null}function Lc({me:e,labels:t,room:n}){let r=bh(),{position:i}=fa(),a=pa(i),s=Ic(),[c,l]=(0,z.useState)(null),u=e=>{e.preventDefault(),l({x:e.clientX,y:e.clientY})},d=(0,z.useRef)(null),f=(0,z.useRef)(!1),p=()=>{d.current&&=(window.clearTimeout(d.current.timer),null)};return(0,B.jsxs)(`aside`,{"aria-label":Kt.name,onContextMenu:u,onPointerDown:e=>{if(e.pointerType===`mouse`)return;p();let{clientX:t,clientY:n}=e;d.current={x:t,y:n,timer:window.setTimeout(()=>{d.current=null,f.current=!0,window.setTimeout(()=>{f.current=!1},700),l({x:t,y:n})},500)}},onPointerMove:e=>{d.current&&Math.hypot(e.clientX-d.current.x,e.clientY-d.current.y)>10&&p()},onPointerUp:p,onPointerCancel:p,onPointerLeave:p,onClickCapture:e=>{f.current&&(f.current=!1,e.preventDefault(),e.stopPropagation())},className:P(`flex shrink-0 select-none bg-sidebar [-webkit-touch-callout:none]`,a?`w-full flex-row items-center gap-1.5 px-2`:P(`h-full flex-col pt-2 pb-3 transition-[width] duration-200 ease-out`,t?`w-56 items-stretch px-2.5`:`w-16 items-center`),i===`bottom`&&`pt-1.5 pb-[calc(0.375rem+env(safe-area-inset-bottom))]`,i===`top`&&`pt-[calc(0.375rem+env(safe-area-inset-top))] pb-1.5`),children:[(0,B.jsx)(Sc,{me:e,position:i,horizontal:a,labels:t}),(0,B.jsx)(`div`,{className:a?`ml-1`:`mt-2`,children:(0,B.jsx)(Mc,{me:e,labels:t})}),(0,B.jsxs)(ce,{to:`/`,title:R(`nav.home`),"aria-label":R(`nav.home`),"aria-current":s===`home`||s===`new`?`page`:void 0,className:P(Ac(s===`home`||s===`new`,t),a?`ml-1.5`:`mt-2`),children:[(0,B.jsx)(Tr,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:R(`nav.home`)}):null]}),(0,B.jsxs)(ce,{to:`/space`,title:R(`nav.sources`),"aria-label":R(`nav.sources`),"aria-current":s===`space`?`page`:void 0,className:P(Ac(s===`space`,t),a?`ml-1.5`:`mt-2`),children:[(0,B.jsx)(Lr,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:R(`nav.sources`)}):null]}),(0,B.jsxs)(ce,{to:`/space/results`,title:R(`space.results`),"aria-label":R(`space.results`),"aria-current":s===`results`?`page`:void 0,className:P(Ac(s===`results`,t),a?`ml-1.5`:`mt-2`),children:[(0,B.jsx)(kr,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:R(`space.results`)}):null]}),r.nav.length?(0,B.jsx)(`div`,{className:P(`shrink-0 bg-border`,a?`mx-2 h-7 w-px`:P(`my-3 h-px`,t?`mx-2.5`:`w-7`))}):null,(0,B.jsx)(`nav`,{className:P(`flex min-h-0 min-w-0 flex-1 gap-1.5`,t?`items-stretch`:`items-center`,a?`flex-row overflow-x-auto`:`flex-col overflow-y-auto`),children:r.nav.map(e=>(0,B.jsx)(Wh,{of:e,children:(0,B.jsxs)(o,{to:e.to,title:e.label(),"aria-label":e.label(),className:({isActive:e})=>Ac(e,t),children:[(0,B.jsx)(e.icon,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:e.label()}):null]})},e.serial))}),(0,B.jsxs)(`div`,{className:P(`flex shrink-0 gap-2`,a?`flex-row pl-3`:`flex-col pt-3`,t?`items-stretch`:`items-center`),children:[(0,B.jsxs)(o,{to:`/settings`,title:R(`nav.settings`),"aria-label":R(`nav.settings`),className:({isActive:e})=>Ac(e,t),children:[(0,B.jsx)(ji,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:R(`nav.settings`)}):null]}),(0,B.jsx)(rh,{me:e,placement:`bar-end`,named:t})]}),c?(0,B.jsx)(Fc,{at:c,room:n,onClose:()=>l(null)}):null]})}function Rc(e){return P(`glass-press relative grid h-12 w-16 place-items-center rounded-full transition-colors`,e?`text-ink`:`text-ink-3`)}var zc=68;function Bc({index:e}){let t=(0,z.useRef)(null),n=(0,z.useRef)(e);return(0,z.useEffect)(()=>{let r=n.current;n.current=e;let i=t.current;if(!i||r===null||e===null||r===e||matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let a=r*zc,o=e*zc;i.animate([{transform:`translateX(${a}px)`},{transform:`translateX(${(a+o)/2}px) scaleX(1.35) scaleY(0.92)`,offset:.45},{transform:`translateX(${o}px)`}],{duration:420,easing:`cubic-bezier(0.34, 1.3, 0.64, 1)`})},[e]),(0,B.jsx)(`span`,{ref:t,"aria-hidden":`true`,className:`pointer-events-none absolute top-1 left-1 h-12 w-16 rounded-full bg-ink/12 transition-opacity`,style:{transform:`translateX(${(e??0)*zc}px)`,opacity:e===null?0:1}})}function Vc({me:e}){let t=bh(),n=Ic(),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(!1),s=Re(),c=(0,z.useRef)(null),l=Oc(),u=Xt(),{project:d}=I(),f=l??(u&&!d?.readOnly&&n!==`new`?{icon:vt,label:R(`home.new`),run:()=>s(`/new`)}:null);Jm(c,r,()=>i(!1));let{pathname:p}=tt();(0,z.useEffect)(()=>i(!1),[p]);let m=e=>!r&&n===e,h=r?2:n===`home`||n===`new`?0:n===`space`?1:n===`results`||n===`settings`?2:null,g=e=>{i(!1),s(e)},_=e=>P(`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-[0.9375rem] transition`,e?`bg-accent text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`);return(0,B.jsxs)(`div`,{className:`fixed inset-x-0 bottom-[calc(0.5rem+env(safe-area-inset-bottom))] z-40 flex select-none justify-center gap-2.5 [-webkit-touch-callout:none]`,children:[(0,B.jsxs)(`nav`,{ref:c,"aria-label":Kt.name,className:`liquid-glass relative flex gap-1 rounded-full p-1`,children:[(0,B.jsx)(Bc,{index:h}),(0,B.jsx)(ce,{to:`/`,"aria-label":R(`nav.home`),"aria-current":n===`home`?`page`:void 0,onClick:()=>i(!1),className:Rc(m(`home`)),children:(0,B.jsx)(Tr,{className:`size-[1.375rem]`})}),(0,B.jsx)(ce,{to:`/space`,"aria-label":R(`nav.sources`),"aria-current":n===`space`?`page`:void 0,onClick:()=>i(!1),className:Rc(m(`space`)),children:(0,B.jsx)(Lr,{className:`size-[1.375rem]`})}),(0,B.jsx)(`button`,{type:`button`,"aria-label":R(`nav.more`),"aria-expanded":r,"aria-haspopup":`menu`,onClick:()=>i(e=>!e),className:Rc(r||n===`results`||n===`settings`),children:(0,B.jsx)(dr,{className:`size-[1.375rem]`})}),r?(0,B.jsxs)(`div`,{role:`menu`,className:`absolute right-0 bottom-full mb-3 flex w-60 animate-rise flex-col rounded-2xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:_(n===`results`),onClick:()=>g(`/space/results`),children:[(0,B.jsx)(kr,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R(`space.results`)})]}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:_(n===`settings`),onClick:()=>g(`/settings`),children:[(0,B.jsx)(ji,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R(`nav.settings`)})]}),t.nav.map(e=>(0,B.jsx)(Wh,{of:e,children:(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:_(!1),onClick:()=>g(e.to),children:[(0,B.jsx)(e.icon,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label()})]})},e.serial)),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:_(!1),onClick:()=>{i(!1),o(!0)},children:[(0,B.jsx)(jr,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R(`about.nav`)})]})]}):null,a?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(kc,{open:!0,me:e,onClose:()=>o(!1)})}):null]}),f?(0,B.jsx)(`button`,{type:`button`,"aria-label":f.label,title:f.label,onClick:f.run,className:`liquid-glass glass-press relative grid size-14 shrink-0 place-items-center rounded-full text-ink`,children:(0,B.jsx)(f.icon,{className:`size-6`})}):null]})}var Hc=yn({route:Cn().max(400),title:Cn().max(200).optional(),view:Cn().max(200).optional(),open:yn({kind:Cn().max(60),id:Cn().max(120).optional(),label:Cn().max(200)}).optional(),selection:xn(Cn().max(120)).max(100).optional(),summary:Cn().max(2e3).optional(),fields:xn(yn({id:Cn().max(120),label:Cn().max(200),value:hn()})).max(60).optional(),plugin:Cn().max(60).optional()}),Uc=yn({name:Cn().regex(/^[a-z][a-z0-9_]{1,62}$/),description:Cn().max(2e3),parameters:mn(Cn(),hn())});yn({message:Cn().min(1).max(8e3),projectId:Cn().max(80).optional(),page:Hc.optional(),tools:xn(Uc).max(40).default([]),debug:bn().optional(),extra:bn().optional()}),yn({ref:Cn().min(1).max(40),message:Cn().min(1).max(8e3)});var Wc={initial:400,min:320,max:720},Gc=`wz.readAloud`,Kc=typeof window<`u`&&`speechSynthesis`in window&&`SpeechSynthesisUtterance`in window;function qc(){try{return localStorage.getItem(Gc)===`1`}catch{return!1}}function Jc(e){try{localStorage.setItem(Gc,e?`1`:`0`)}catch{}}function Yc(e){let t=window.speechSynthesis.getVoices(),n=e.slice(0,2);return t.find(t=>t.lang===e&&t.default)??t.find(t=>t.lang===e)??t.find(e=>e.lang.startsWith(n)&&e.default)??t.find(e=>e.lang.startsWith(n))??null}function Xc(e,t=L,n=!1){if(!Kc||!e.trim())return;let r=window.speechSynthesis;n&&r.cancel();let i=_n(t),a=new SpeechSynthesisUtterance(e.trim().slice(0,2e3));a.lang=i;let o=Yc(i);o&&(a.voice=o),r.speak(a)}function Zc(e,t=L){if(!Kc||!e.trim())return Promise.resolve();let n=window.speechSynthesis;n.cancel();let r=_n(t),i=new SpeechSynthesisUtterance(e.trim().slice(0,4e3));i.lang=r;let a=Yc(r);return a&&(i.voice=a),new Promise(e=>{i.onend=()=>e(),i.onerror=()=>e(),n.speak(i)})}function Qc(e){return e.replace(/```[\s\S]*?```/g,``).replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/https?:\/\/\S+/g,``).replace(/^#+\s*/gm,``).replace(/^\s*[-*]\s+/gm,``).replace(/[*_`>|]/g,``).replace(/\n{2,}/g,`. `).replace(/\s+/g,` `).trim()}function $c(){Kc&&window.speechSynthesis.cancel()}function el(){let[e,t]=(0,z.useState)(()=>Kc&&qc()),n=(0,z.useCallback)(e=>{t(e),Jc(e),e||$c()},[]);return(0,z.useEffect)(()=>{Kc&&window.speechSynthesis.getVoices()},[]),(0,z.useEffect)(()=>()=>$c(),[]),[e,n]}function tl(e,t,n,r){let i=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!e){i.current=null;return}let a=n.map(e=>e.key);if(!i.current){i.current=new Set(a);let e=[...n].reverse().find(e=>e.who===`bot`&&e.spoken!==!1);if(e){let n=r(e.key);n&&Xc(n,t,!0)}return}let o=n.filter(e=>!i.current?.has(e.key));for(let e of a)i.current.add(e);o.some(e=>e.who===`me`)&&$c();for(let e of o)if(e.who===`bot`&&e.spoken!==!1){let n=r(e.key);n&&Xc(n,t)}},[e,t,n,r])}var nl=/\.(png|jpe?g|gif|webp|avif|svg)$/i;function rl(e){let t=e.filter(e=>e.type.startsWith(`image/`));return t.length?Object.fromEntries(t.map(e=>[e.name,URL.createObjectURL(e)])):void 0}function il(e){let t=e.match(/(?:^|\n\n)(?:Angehängt|Attached): ([^\n]+)$/);return t?{text:e.slice(0,t.index).trim(),names:t[1].split(`, `).filter(Boolean)}:{text:e,names:[]}}function al({names:e,previews:t,fileUrl:n}){let r=e.filter(e=>t?.[e]||n&&nl.test(e)),i=e.filter(e=>!r.includes(e));return(0,B.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5`,children:[r.map(e=>{let r=t?.[e]??n?.(e)??``;return(0,B.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,title:e,children:(0,B.jsx)(`img`,{src:r,alt:e,className:`max-h-60 w-auto max-w-full rounded-xl bg-paper-2 object-contain ring-1 ring-border`})},e)}),i.length?(0,B.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:i.map(e=>(0,B.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 px-2.5 py-1 text-[0.75rem] text-ink-2`,children:[(0,B.jsx)(d,{className:`size-3 shrink-0 text-ink-4`}),(0,B.jsx)(`span`,{className:`truncate`,children:e})]},e))}):null]})}function ol(e,t){let n=D(),[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)(`idle`),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(!0),_=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(e){if(_.current!==e.id){_.current=e.id,i(e.messages);return}a===`idle`&&i(t=>e.messages.length>=t.length?e.messages:t)}},[e,a]),{messages:r,phase:a,activity:l,thought:d,startedAt:p,error:s,send:async(r,s=[])=>{if(!e||!(r.trim()||s.length)||a!==`idle`)return!1;if(c(null),m(Date.now()),f(null),s.length){o(`thinking`);try{for(let t of s){let n=await fetch(Je(`/api/studio/wizards/${e.id}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`,"accept-language":L},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}}catch(t){return c(t.message),o(`idle`),m(null),await n.invalidateQueries({queryKey:O.wizard(e.id)}),!1}let t=`${R(`editor.attached`)}: ${s.map(e=>e.name).join(`, `)}`;r=r.trim()?`${r}\n\n${t}`:t}let l=`p-${Date.now()}`;i(e=>[...e,{id:`u-${Date.now()}`,role:`user`,content:r,previews:rl(s)},{id:l,role:`assistant`,content:``,pending:!0}]),o(`thinking`),u(null);let d=!1;try{await te(`/api/studio/wizards/${e.id}/chat`,{message:r,extra:h},(e,n)=>{if(e===`text`){let e=JSON.parse(n);i(t=>t.map(t=>t.id===l?{...t,content:t.content+e}:t))}else if(e===`activity`)u(JSON.parse(n));else if(e===`thought`)f(JSON.parse(n));else if(e===`building`)o(`building`);else if(e===`done`){d=!0;let e=JSON.parse(n);i(t=>t.map(t=>t.id===l?{...t,content:e.reply,changed:e.changed,pending:!1}:t)),e.changed&&t(e.draft,e.revision)}else e===`error`&&(d=!0,c(JSON.parse(n).message))}),d||c(R(`editor.chatBroken`))}catch(e){c(e.message)}finally{u(null),f(null),m(null),i(e=>e.filter(e=>!(e.id===l&&!e.content)).map(e=>({...e,pending:!1}))),o(`idle`),await n.invalidateQueries({queryKey:O.wizard(e.id)}),await n.invalidateQueries({queryKey:[`me`]})}return!0},fileUrl:t=>Je(`/api/studio/wizards/${e?.id}/files/${encodeURIComponent(t)}`),extra:h,setExtra:g}}function sl(e){let[t,n]=(0,z.useState)(()=>Date.now());return(0,z.useEffect)(()=>{if(e===null)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e===null?null:Math.max(0,Math.floor((t-e)/1e3))}function cl(e){return e<60?`${e} s`:`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)} min`}function ll({chat:e,thought:t,className:n,spinner:r=`size-3.5`}){let i=sl(e.startedAt);return(0,B.jsxs)(`div`,{className:P(`min-w-0`,n),children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(st,{className:P(`shrink-0`,r)}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:e.activity??(e.phase===`building`?R(`editor.building`):R(`editor.thinking`))}),i===null?null:(0,B.jsx)(`span`,{className:`shrink-0 text-ink-4 tabular-nums`,children:cl(i)})]}),t&&e.thought?(0,B.jsx)(`p`,{className:`mt-0.5 truncate pl-5.5 text-[0.75rem] text-ink-4`,children:e.thought}):null]})}function ul({message:e,fileUrl:t}){let{text:n,names:r}=il(e.content);return(0,B.jsxs)(`div`,{className:`ml-8 flex flex-col items-end gap-1.5 self-end`,children:[e.signal?(0,B.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4`,children:R(`assistant.signalled`)}):null,r.length?(0,B.jsx)(al,{names:r,previews:e.previews,fileUrl:t}):null,n?(0,B.jsx)(`div`,{className:`rounded-xl rounded-br-md bg-paper-2 px-4 py-2.5 text-[0.875rem] leading-relaxed`,children:(0,B.jsx)(`span`,{className:`whitespace-pre-wrap`,children:n})}):null]})}function dl({chat:e,avatar:t,costume:n,changedLabel:r,card:i,calls:a,foot:o}){return(0,B.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.messages.map(s=>s.role===`user`?(0,B.jsx)(ul,{message:s,fileUrl:e.fileUrl},s.id):(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`div`,{className:`shrink-0`,children:(0,B.jsx)(sn,{kind:t,costume:n,size:28,interactive:!1})}),(0,B.jsxs)(`div`,{className:`min-w-0 pt-0.5 text-[0.875rem]`,children:[s.source===`mcp`?(0,B.jsxs)(`div`,{className:`mb-1 inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,B.jsx)(Rt,{className:`size-3`}),` `,R(`editor.viaClient`,{client:s.client??`MCP`})]}):null,a?a(s):null,s.content?(0,B.jsx)(bt,{text:s.content,className:`text-[0.875rem]`}):null,i&&s.cards?.length?(0,B.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:s.cards.map(e=>(0,B.jsx)(z.Fragment,{children:i(e)},e.id))}):null,s.pending?(0,B.jsx)(ll,{chat:e,thought:!0,className:`mt-1 text-[0.8125rem] text-ink-3`}):null,s.changed?(0,B.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-full bg-ember-tint px-2.5 py-0.5 text-[0.75rem] text-ember-strong`,children:[(0,B.jsx)(Ye,{className:`size-3`}),` `,r]}):null,o?o(s):null]})]},s.id))})}var fl=`wizards.editorThread.height`,pl=320,ml=120,hl=()=>Math.max(ml,window.innerHeight-260);function gl(){let[e,t]=(0,z.useState)(()=>{try{let e=Number(localStorage.getItem(fl));return e?Math.min(Math.max(e,ml),hl()):pl}catch{return pl}});return{height:e,set:e=>{let n=Math.round(Math.min(Math.max(e,ml),hl()));t(n);try{localStorage.setItem(fl,String(n))}catch{}}}}function _l({open:e,height:t,onHeight:n,onToggle:r}){let i=(0,z.useRef)(null);return(0,B.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`horizontal`,"aria-valuenow":t,"aria-valuemin":ml,"aria-label":R(`editor.threadGrip`),title:R(`editor.threadGrip`),onPointerDown:n=>{n.button===0&&(n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId),i.current={y:n.clientY,height:e?t:0,moved:!1})},onPointerMove:t=>{let a=i.current;!a||!a.moved&&Math.abs(t.clientY-a.y)<4||!(e||a.moved)&&t.clientY>a.y||(e||a.moved||r(!0),a.moved=!0,n(a.height+(a.y-t.clientY)))},onPointerUp:()=>{let t=i.current&&!i.current.moved;i.current=null,t&&r(!e)},onPointerCancel:()=>{i.current=null},onKeyDown:i=>{if(i.key===`ArrowUp`||i.key===`ArrowDown`){if(i.preventDefault(),!e){i.key===`ArrowUp`&&r(!0);return}n(t+(i.key===`ArrowUp`?32:-32))}else(i.key===`Enter`||i.key===` `)&&(i.preventDefault(),r(!e))},className:`group flex h-3.5 shrink-0 cursor-row-resize touch-none items-center justify-center outline-none`,children:(0,B.jsx)(`span`,{className:`h-1 w-10 rounded-full bg-ink-4/40 transition group-hover:bg-ink-4 group-focus-visible:bg-ember`})})}function vl({chat:e,avatar:t,costume:n,hello:r=R(`editor.chatHello`),placeholder:i=R(`editor.composer`),changedLabel:a=R(`editor.flowChanged`),compact:o,intro:s,closed:c,card:l,foldOn:u}){let[f,p]=(0,z.useState)(!1);(0,z.useEffect)(()=>{u&&p(!1)},[u]);let m=gl(),h=(0,z.useRef)(null),g=(0,z.useRef)(null);(0,z.useEffect)(()=>{h.current?.scrollTo({top:h.current.scrollHeight,behavior:`smooth`})},[e.messages,e.phase]);let _=!o||f,v=e.messages.at(-1),[y,x]=(0,z.useState)(!1),S=(0,z.useRef)(0),C=e=>!c&&e.dataTransfer.types.includes(`Files`);return(0,B.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,onDragEnter:e=>{C(e)&&(e.preventDefault(),S.current+=1,x(!0))},onDragOver:e=>{C(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:()=>{S.current=Math.max(0,S.current-1),S.current===0&&x(!1)},onDrop:e=>{C(e)&&(e.preventDefault(),S.current=0,x(!1),g.current?.add(Array.from(e.dataTransfer.files).map(rt)),g.current?.focus())},children:[y?(0,B.jsxs)(`div`,{className:`pointer-events-none absolute inset-3 z-20 flex flex-col items-center justify-center gap-2 rounded-2xl border-2 border-ember border-dashed bg-ember-veil text-[0.875rem] text-ember-strong`,children:[(0,B.jsx)(d,{className:`size-6`}),R(`editor.dropToAttach`)]}):null,(0,B.jsxs)(`div`,{className:o?P(`mb-2 flex min-h-0 flex-col overflow-hidden rounded-2xl bg-card shadow-overlay ring-1 ring-border`,!(v||e.error)&&`hidden`):`contents`,children:[o&&(v||e.error)?(0,B.jsx)(_l,{open:f,height:m.height,onHeight:m.set,onToggle:p}):null,o&&(v||e.error)?(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":f,"aria-label":R(`editor.thread`),onClick:()=>p(e=>!e),className:`flex items-center gap-2 px-4 pb-0.5 text-left text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[!(e.error||f)&&v?.pending?(0,B.jsx)(ll,{chat:e,className:`flex-1`}):(0,B.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate`,e.error&&`text-rose`),children:e.error??(f?R(`editor.thread`):v?.content)}),f?(0,B.jsx)(b,{className:`size-4 shrink-0`}):(0,B.jsx)(Zn,{className:`size-4 shrink-0`})]}):null,(0,B.jsxs)(`div`,{ref:h,className:P(`min-h-0 flex-1 overflow-y-auto px-5 py-5`,!_&&`hidden`),style:o?{height:m.height,flex:`none`}:void 0,children:[e.messages.length===0&&!c?s??(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(sn,{kind:t,costume:n,size:32,interactive:!1}),(0,B.jsx)(`p`,{className:`pt-1 text-[0.875rem] text-ink-2 leading-relaxed`,children:r})]}):null,(0,B.jsx)(dl,{chat:e,avatar:t,costume:n,changedLabel:a,card:l}),e.error?(0,B.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-3 py-2 text-[0.8125rem] text-rose`,children:e.error}):null]})]}),c?(0,B.jsx)(`p`,{className:`m-3 rounded-xl bg-paper-2 px-4 py-3 text-[0.8125rem] text-ink-2 leading-relaxed`,children:c}):(0,B.jsx)($e,{ref:g,floating:o,className:o?void 0:`p-3`,placeholder:i,disabled:e.phase!==`idle`,onSend:(t,n)=>e.send(t,n),effort:e.setExtra?{on:!!e.extra,onChange:e.setExtra}:void 0})]})}var yl=O.cloudSync();function bl(e){return e?.mode===`local`&&!!e.account&&na(e.features,`twoWaySync`)}function xl(){let e=Yt(),t=bl(e.data),n=na(e.data?.features??{},`liveChanges`);return at({queryKey:yl,queryFn:()=>_.get(`/api/studio/sync`),enabled:t,refetchInterval:t?n?12e4:2e4:!1})}function Sl(e){let t=D(),n=na(Yt().data?.features??{},`liveChanges`);return Pt({mutationFn:e,onSuccess:e=>{e&&typeof e==`object`&&`spaces`in e?t.setQueryData(yl,e):t.invalidateQueries({queryKey:yl}),!n&&(t.invalidateQueries({queryKey:[`wizard`]}),t.invalidateQueries({queryKey:[`space-page`]}),t.invalidateQueries({queryKey:[`space-table`]}))}})}var Cl=e=>new Date(e).toLocaleString(L===`de`?`de-AT`:`en-GB`,{day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`}),wl={update_here:`cloudSync.error.updateHere`,update_cloud:`cloudSync.error.updateCloud`,unreachable:`cloudSync.error.unreachable`,signed_out:`cloudSync.error.signedOut`,refused:`cloudSync.error.refused`};function Tl(e){let t=e.reason?wl[e.reason]:void 0;return t?R(t):e.message}var El={space:`cloudSync.kind.space`,wizard:`cloudSync.kind.wizard`,translation:`cloudSync.kind.translation`,message:`cloudSync.kind.message`,page:`cloudSync.kind.page`,table:`cloudSync.kind.table`,row:`cloudSync.kind.row`,category:`cloudSync.kind.category`,file:`cloudSync.kind.file`,connector:`cloudSync.kind.connector`},Dl={title:`cloudSync.word.title`,markdown:`cloudSync.word.text`,description:`cloudSync.word.description`,steps:`cloudSync.word.steps`,fields:`cloudSync.word.fields`,instructions:`cloudSync.word.instructions`,prompt:`cloudSync.word.prompt`,label:`cloudSync.word.label`,cells:`cloudSync.word.cells`,columns:`cloudSync.word.columns`,name:`cloudSync.word.name`,brand:`cloudSync.word.brand`,facts:`cloudSync.word.facts`,themes:`cloudSync.word.themes`,files:`cloudSync.word.files`,options:`cloudSync.word.options`,categories:`cloudSync.word.categories`,values:`cloudSync.word.values`,texts:`cloudSync.word.texts`,page:`cloudSync.word.page`};function Ol(e){return e.split(` › `).map(e=>e.startsWith(`“`)||!Dl[e]?e:R(Dl[e])).join(` › `)}var kl=new Map,Al=new Set;function jl(e){(0,z.useEffect)(()=>{if(e){kl.set(e,(kl.get(e)??0)+1);for(let e of Al)e();return()=>{kl.set(e,(kl.get(e)??1)-1),kl.get(e)||kl.delete(e);for(let e of Al)e()}}},[e])}function Ml(){let[,e]=(0,z.useState)(0);return(0,z.useEffect)(()=>{let t=()=>e(e=>e+1);return Al.add(t),()=>{Al.delete(t)}},[]),[...kl.keys()]}function Nl(){let e=xl(),t=Sl(()=>_.post(`/api/studio/sync/now`,{})),n=Sl(e=>_.put(`/api/studio/sync/spaces/${e.id}`,{on:e.on})),r=e.data;return r?(0,B.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,B.jsx)(_t,{title:R(`cloudSync.title`),hint:R(`cloudSync.hint`),action:(0,B.jsxs)(k,{variant:`secondary`,size:`sm`,busy:t.isPending,onClick:()=>t.mutate(void 0),children:[(0,B.jsx)(ve,{className:`size-3.5`}),` `,R(`cloudSync.now`)]}),children:(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:r.spaces.map(e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-4 py-3 first:pt-0 last:pb-0`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:e.name}),(0,B.jsx)(Pl,{space:e,refusals:r.refusals[e.spaceId]})]}),e.organization?null:(0,B.jsx)(et,{checked:e.on,label:R(`cloudSync.spaceOn`),disabled:n.isPending,onChange:t=>n.mutate({id:e.spaceId,on:t})})]},e.spaceId))})}),r.conflicts.length?(0,B.jsx)(Fl,{view:r}):null,r.merges.length?(0,B.jsx)(Rl,{merges:r.merges}):null]}):e.isLoading?(0,B.jsx)(st,{className:`size-5`}):null}function Pl({space:e,refusals:t}){let n=`mt-0.5 text-[0.8125rem] text-ink-3`;return e.organization?(0,B.jsx)(`p`,{className:n,children:R(`cloudSync.state.otherOrganization`,{name:e.organization})}):e.on?(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:[e.error?(0,B.jsxs)(`p`,{className:`text-[0.8125rem] text-rose`,children:[Tl(e.error),e.error.reason===`refused`&&t?.length?` ${t.join(` · `)}`:``]}):e.waiting?(0,B.jsx)(T,{tone:`warn`,children:R(`cloudSync.state.waiting`,{count:e.waiting})}):e.conflicts?null:(0,B.jsx)(T,{tone:`live`,children:R(`cloudSync.state.ok`)}),e.conflicts?(0,B.jsx)(T,{tone:`ember`,children:R(`cloudSync.state.conflicts`,{count:e.conflicts})}):null,e.syncedAt?(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:R(`cloudSync.state.at`,{when:Cl(e.syncedAt)})}):null]}):(0,B.jsx)(`p`,{className:n,children:R(e.here?`cloudSync.state.hereOnly`:`cloudSync.state.cloudOnly`)})}function Fl({view:e}){let t=Sl(e=>_.post(`/api/studio/sync/spaces/${e}/keep-cloud`,{})),n=[...new Set(e.conflicts.map(e=>e.spaceId))];return(0,B.jsx)(_t,{title:R(`cloudSync.conflicts`),hint:R(`cloudSync.conflictsHint`),action:e.conflicts.length>1&&n.length===1?(0,B.jsx)(k,{variant:`secondary`,size:`sm`,busy:t.isPending,onClick:()=>t.mutate(n[0]),children:R(`cloudSync.keepCloudAll`)}):null,children:(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:e.conflicts.map(e=>(0,B.jsx)(`li`,{className:`py-4 first:pt-0 last:pb-0`,children:(0,B.jsx)(Ll,{conflict:e})},e.id))})})}var Il=e=>e===void 0?R(`cloudSync.removed`):typeof e==`string`?e:JSON.stringify(e,null,1);function Ll({conflict:e}){let[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(()=>e.conflicts.map(()=>`local`)),[a,o]=(0,z.useState)(null),s=Sl(t=>_.post(`/api/studio/sync/conflicts/${e.id}/resolve`,t)),c=Pt({mutationFn:()=>_.post(`/api/studio/sync/conflicts/${e.id}/propose`,{}),onSuccess:e=>o(e.record)}),l=e.deleted===`remote`?R(`cloudSync.conflict.deletedRemote`):e.deleted===`local`?R(`cloudSync.conflict.deletedLocal`):R(`cloudSync.conflict.both`);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`p`,{className:`font-medium text-[0.9375rem]`,children:[(0,B.jsxs)(`span`,{className:`text-ink-3`,children:[R(El[e.kind]),` · `]}),e.title]}),(0,B.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:l})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(k,{size:`sm`,variant:`secondary`,busy:s.isPending,onClick:()=>s.mutate({take:`remote`}),children:R(`cloudSync.keepCloud`)}),(0,B.jsx)(k,{size:`sm`,variant:`secondary`,busy:s.isPending,onClick:()=>s.mutate({take:`local`}),children:R(`cloudSync.keepLocal`)}),e.conflicts.length?(0,B.jsx)(k,{size:`sm`,variant:`ghost`,onClick:()=>n(e=>!e),children:R(`cloudSync.pick`)}):null,e.deleted?null:(0,B.jsx)(k,{size:`sm`,variant:`ghost`,busy:c.isPending,onClick:()=>c.mutate(),children:R(`cloudSync.ai`)})]}),t?(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-paper-2 p-3`,children:[e.conflicts.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,B.jsx)(`p`,{className:`font-medium text-[0.8125rem]`,children:Ol(e.label)}),[`local`,`remote`].map(n=>(0,B.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[0.8125rem]`,children:[(0,B.jsx)(`input`,{type:`radio`,className:`mt-1`,checked:r[t]===n,onChange:()=>i(e=>e.map((e,r)=>r===t?n:e))}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsxs)(`span`,{className:`text-ink-3`,children:[R(n===`local`?`cloudSync.here`:`cloudSync.cloud`),`:`,` `]}),(0,B.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:Il(e[n])})]})]},n))]},e.label)),(0,B.jsx)(`div`,{children:(0,B.jsx)(k,{size:`sm`,busy:s.isPending,onClick:()=>s.mutate({choices:r.map(e=>({take:e}))}),children:R(`cloudSync.apply`)})})]}):null,c.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:R(`cloudSync.aiFailed`,{error:c.error.message})}):null,a?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-paper-2 p-3`,children:[(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:R(`cloudSync.aiProposal`)}),(0,B.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-[0.75rem] text-ink-2`,children:JSON.stringify(a,null,2)}),(0,B.jsx)(`div`,{children:(0,B.jsx)(k,{size:`sm`,busy:s.isPending,onClick:()=>s.mutate({record:a}),children:R(`cloudSync.aiTake`)})})]}):null,s.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:s.error.message}):null]})}function Rl({merges:e}){return(0,B.jsx)(_t,{title:R(`cloudSync.merges`),hint:R(`cloudSync.mergesHint`),children:(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:e.map(e=>(0,B.jsx)(`li`,{className:`py-4 first:pt-0 last:pb-0`,children:(0,B.jsx)(zl,{merge:e})},e.id))})})}function zl({merge:e,compact:t}){let n=Sl(()=>_.post(`/api/studio/sync/merges/seen`,{ids:[e.id]})),r=Sl(t=>_.post(`/api/studio/sync/merges/${e.id}/undo`,{take:t}));return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`text-[0.8125rem]`,children:[(0,B.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:t?R(`cloudSync.merged`):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`text-ink-3`,children:[R(El[e.kind]),` · `]}),e.title]})}),e.local.length?(0,B.jsx)(`p`,{className:`mt-0.5 text-ink-3`,children:R(`cloudSync.mergedHere`,{places:e.local.map(Ol).join(`, `)})}):null,e.remote.length?(0,B.jsx)(`p`,{className:`mt-0.5 text-ink-3`,children:R(`cloudSync.mergedThere`,{places:e.remote.map(Ol).join(`, `)})}):null]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(k,{size:`sm`,variant:`secondary`,busy:n.isPending,onClick:()=>n.mutate(void 0),children:R(`cloudSync.ok`)}),(0,B.jsx)(k,{size:`sm`,variant:`ghost`,busy:r.isPending,onClick:()=>r.mutate(`local`),children:R(`cloudSync.undoLocal`)}),(0,B.jsx)(k,{size:`sm`,variant:`ghost`,busy:r.isPending,onClick:()=>r.mutate(`remote`),children:R(`cloudSync.undoRemote`)})]})]})}function Bl({kind:e,item:t}){let n=xl(),r=n.data?.conflicts.find(n=>n.kind===e&&n.item===t),i=n.data?.merges.find(n=>n.kind===e&&n.item===t);return jl(r?r.id:null),r?(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-border-soft border-b bg-amber-tint px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,B.jsx)(tr,{className:`size-4 shrink-0 text-amber`}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1`,children:R(`cloudSync.conflict.both`)}),(0,B.jsx)(ce,{to:`/settings/cloud`,className:`shrink-0 underline transition hover:text-ink`,children:R(`cloudSync.settle`)})]}):i?(0,B.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-border-soft border-b bg-moss-tint px-4 py-2 sm:px-6`,children:[(0,B.jsx)(yr,{className:`mt-1 size-4 shrink-0 text-moss`}),(0,B.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,B.jsx)(zl,{merge:i,compact:!0})})]}):null}function Vl({me:e}){let t=xl(),n=Ml(),r=(t.data?.conflicts??[]).filter(e=>!n.includes(e.id)).length;return!bl(e)||!r?null:(0,B.jsxs)(`div`,{className:`flex items-center gap-3 border-border-soft border-b bg-amber-tint px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,B.jsx)(tr,{className:`size-4 shrink-0 text-amber`}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1`,children:R(`cloudSync.bar`,{count:r})}),(0,B.jsx)(ce,{to:`/settings/cloud`,className:`shrink-0 underline transition hover:text-ink`,children:R(`cloudSync.settle`)})]})}function Hl(e,t){let n=e?.mode===`managed`&&na(e.features,`organizationSettings`),r=R(`settings.groupOrganization`),i=n?R(`settings.groupStudio`):void 0,a=e=>i?{...e,group:i}:e;return[...n?[]:[{id:`account`,label:R(`account.title`),icon:Gi,menu:!0}],...n?[{id:`general`,label:R(`orgSettings.general`),icon:qn,menu:!1,group:r},{id:`members`,label:R(`orgSettings.members`),icon:qi,menu:!0,group:r},{id:`credits`,label:R(`credits.title`),icon:Ct,menu:!1,group:r},{id:`usage`,label:R(`credits.usage`),icon:St,menu:!1,group:r},{id:`invoices`,label:R(`credits.invoices`),icon:Ci,menu:!1,group:r},{id:`keys`,label:R(`orgSettings.keys`),icon:Nr,menu:!1,group:r}]:e?.mode===`managed`&&na(e.features,`teamPlans`)?[{id:`organization`,label:R(`organization.title`),icon:qi,menu:!0}]:[],...bl(e)?[a({id:`cloud`,label:R(`cloudSync.title`),icon:rr,menu:!1})]:[],a({id:`connectors`,label:R(`connectors.title`),icon:Rt,menu:!0}),a({id:`models`,label:R(`local.title`),icon:sr,menu:!0}),a({id:`integrate`,label:R(`integrate.nav`),icon:Yn,menu:!0}),...t.sections.map(e=>a({id:e.id,label:e.label(),icon:e.icon,menu:e.menu??!1,plugin:e})),...t.plugins.length||t.problems.length||t.canReload&&e?.account?[a({id:`plugins`,label:R(`plugins.title`),icon:Un,menu:!1})]:[],{id:`about`,label:R(`about.nav`),icon:jr,menu:!1}]}function Ul(){return[{id:`profile`,label:R(`konto.profile`),icon:Gi,menu:!0},{id:`orgs`,label:R(`konto.organizations`),icon:qn,menu:!1},{id:`apps`,label:R(`konto.apps`),icon:Rt,menu:!1}]}var Wl=`wizards.assistant`,Gl={place:`center`,height:null,dev:!1};function Kl(){try{let e=JSON.parse(localStorage.getItem(Wl)??`null`);return{place:e?.place===`right`?`right`:`center`,height:typeof e?.height==`number`?e.height:null,dev:e?.dev===!0}}catch{return Gl}}var ql=Kl(),Jl=new Set,Yl=()=>{for(let e of Jl)e()},Xl=e=>(Jl.add(e),()=>Jl.delete(e));function Zl(e){ql={...ql,...e};try{localStorage.setItem(Wl,JSON.stringify(ql))}catch{}Yl()}function Ql(){return(0,z.useSyncExternalStore)(Xl,()=>ql)}var $l=64,eu=12,tu=null,nu=new Set;function ru(e){tu=e;for(let e of nu)e()}function iu(){return(0,z.useSyncExternalStore)(e=>(nu.add(e),()=>nu.delete(e)),()=>tu)}var au=e=>Math.min(600,e-24);function W(e,t,n){let r=au(e.width),i=e.height-eu-t;return{center:{left:(e.width-r)/2,top:i,width:r,height:t},right:e.width>=r+24+240?{left:e.width-eu-r,top:i,width:r,height:t}:null,sidebar:n?{left:e.width-400+8,top:8,width:384,height:e.height-16}:null}}var ou=e=>e>=au(e)+24+240;function su(e,t){if(e.button!==0)return;e.preventDefault();let n={x:e.clientX,y:e.clientY},r=t.frame()?.getBoundingClientRect(),i=r?{x:n.x-r.left,y:n.y-r.top}:{x:28,y:24},a=!1,o=null,s=r=>{if(r.pointerId!==e.pointerId||!a&&Math.hypot(r.clientX-n.x,r.clientY-n.y)<5)return;a||(a=!0,document.body.style.userSelect=`none`,t.onLeave?.());let s=t.column()?.getBoundingClientRect();if(!s)return;let c=t.frame()?.getBoundingClientRect(),l=au(s.width),u=c?.height??160,d=Math.min(Math.max(r.clientX-s.left-i.x,8),Math.max(8,s.width-120)),f=Math.min(Math.max(r.clientY-s.top-i.y,8),Math.max(8,s.height-u-8)),p=W(s,u,t.sidebar),m=s.height-(f+u)<$l,h=s.width-(d+l)<$l||window.innerWidth-r.clientX<$l,g;if(p.sidebar&&h&&(!m||window.innerWidth-r.clientX<$l))g=`sidebar`;else{let e=d+l/2;g=p.right&&Math.abs(e-(p.right.left+l/2))<Math.abs(e-(p.center.left+l/2))?`right`:`center`}o={left:d,top:f,width:l,zone:g,spot:p[g]??o?.spot??null},ru(o)},c=n=>{if(n.pointerId!==e.pointerId)return;window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),document.body.style.userSelect=``;let r=o;if(ru(null),!a){t.onClick?.();return}r?.zone&&t.onDrop(r.zone)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)}var cu=null,lu=new Set;function uu(e){cu=e;for(let e of lu)e()}function du(){return(0,z.useSyncExternalStore)(e=>(lu.add(e),()=>lu.delete(e)),()=>cu)}var fu=null,pu=new Set;function mu(e){fu=e;for(let e of pu)e()}function hu(){return(0,z.useSyncExternalStore)(e=>(pu.add(e),()=>pu.delete(e)),()=>fu)}var gu=1300,_u=3e3;function vu(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}var yu=typeof window<`u`&&(!!vu()||!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`);function bu(e){return e.toLowerCase().split(/[\s\-–—/]+/).map(e=>e.replace(/[^\p{L}\p{N}]/gu,``)).filter(Boolean)}function xu(e,t){let n=new Set(bu(t)),r=bu(e);return r.length<2||r.filter(e=>n.has(e)).length/r.length>=.75}function Su(e){let[t,n]=(0,z.useState)(`off`),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(0),[d,f]=(0,z.useState)(``),[p,m]=(0,z.useState)(null),h=(0,z.useRef)(`off`),g=(0,z.useRef)(!1),v=(0,z.useRef)(null),y=(0,z.useRef)(null),b=(0,z.useRef)(null),x=(0,z.useRef)(``),S=(0,z.useRef)({text:``,until:0}),C=(0,z.useRef)(``),ee=(0,z.useRef)(null),w=(0,z.useRef)(null),te=(0,z.useRef)(e);te.current=e;let T=(0,z.useRef)(p);T.current=p;let E=(0,z.useCallback)(e=>{h.current=e,n(e)},[]),ne=(0,z.useCallback)(()=>{$c(),b.current&&=(b.current.pause(),null),x.current=``},[]),re=(0,z.useCallback)(()=>{ee.current&&=(clearTimeout(ee.current),null);let e=C.current.trim();C.current=``,f(``),e&&h.current!==`off`&&(E(`thinking`),w.current=te.current.messages.at(-1)?.id??null,te.current.send(e).then(e=>{!e&&h.current===`thinking`&&E(`listening`)}))},[E]),D=(0,z.useCallback)((e,t)=>{if(!(g.current||h.current===`off`||h.current===`thinking`)){if(h.current===`speaking`){if(xu(e,x.current))return;ne(),E(`listening`)}else if(Date.now()<S.current.until&&xu(e,S.current.text))return;f(e),t&&(C.current=`${C.current} ${e}`.trim(),f(C.current)),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(re,gu)}},[re,ne,E]),ie=(0,z.useCallback)(()=>{let e=vu();if(!e||v.current)return;let t=new e;t.continuous=!0,t.interimResults=!0,t.lang=un[L],t.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n];r.isFinal?D(r[0].transcript,!0):t+=r[0].transcript}t.trim()&&D(`${C.current} ${t}`.trim(),!1)},t.onerror=e=>{(e.error===`not-allowed`||e.error===`service-not-allowed`)&&c(`denied`)},t.onend=()=>{v.current=null,h.current!==`off`&&!g.current&&setTimeout(ie,200)},v.current=t;try{t.start()}catch{v.current=null}},[D]),ae=(0,z.useCallback)((e,t)=>{let n=null,r=[],i=0,a=new Uint8Array(t.fftSize),o=()=>{if(h.current===`off`){n?.stop();return}t.getByteTimeDomainData(a);let s=0;for(let e of a)s=Math.max(s,Math.abs(e-128)/128);if(s>.08&&!g.current&&h.current===`listening`){if(i=Date.now(),!n){let t=Date.now()<S.current.until?S.current.text:``;r=[],n=new MediaRecorder(e),n.ondataavailable=e=>e.data.size&&r.push(e.data),n.onstop=async()=>{let e=new File(r,`live`,{type:(n?.mimeType||`audio/webm`).split(`;`)[0]});if(n=null,e.size&&h.current!==`off`){E(`thinking`);try{let{text:n}=await _.upload(`/api/studio/transcribe`,e);if(t&&xu(n,t)){E(`listening`);return}C.current=n,re()}catch(e){c(e.message),E(`listening`)}}},n.start()}}else n&&Date.now()-i>gu&&n.stop();setTimeout(o,100)};o()},[re,E]),oe=(0,z.useCallback)(async()=>{if(h.current!==`off`)return;c(null);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch{c(`denied`);return}y.current=e,w.current=te.current.messages.at(-1)?.id??null,E(`listening`),o(Date.now());let t=new AudioContext,n=t.createAnalyser();n.fftSize=512,t.createMediaStreamSource(e).connect(n);let r=new Uint8Array(n.fftSize),i=()=>{if(h.current===`off`){t.close();return}n.getByteTimeDomainData(r);let e=0;for(let t of r)e=Math.max(e,Math.abs(t-128)/128);u(g.current?0:Math.min(1,e*3)),setTimeout(i,90)};i(),vu()?ie():ae(e,n),T.current||_.get(`/api/studio/assistant/voice`).then(({way:e})=>m({way:e,natural:e===`key`||e===`local`})).catch(()=>m({way:`none`,natural:!1}))},[ie,ae,E]),se=(0,z.useCallback)(()=>{E(`off`),o(null),f(``),u(0),C.current=``,ee.current&&clearTimeout(ee.current),v.current?.abort(),v.current=null,ne();for(let e of y.current?.getTracks()??[])e.stop();y.current=null},[ne,E]),ce=(0,z.useCallback)(()=>{let e=!g.current;g.current=e,i(e);for(let t of y.current?.getAudioTracks()??[])t.enabled=!e;e?(v.current?.abort(),v.current=null):h.current!==`off`&&ie()},[ie]),le=(0,z.useCallback)(async e=>{let t=Qc(e);if(!t){E(`listening`);return}E(`speaking`),x.current=t;let n=T.current?.natural&&T.current.way!==`none`,r=!1;if(n)try{let e=await fetch(Je(`/api/studio/assistant/speak`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t.slice(0,4e3)})});if(e.ok&&h.current===`speaking`){let t=URL.createObjectURL(await e.blob()),n=new Audio(t);b.current=n,await new Promise(e=>{n.onended=()=>e(),n.onerror=()=>e(),n.onpause=()=>e(),n.play().catch(()=>e())}),URL.revokeObjectURL(t),r=!0}}catch{}!r&&h.current===`speaking`&&await Zc(t,L),b.current=null,x.current=``,h.current===`speaking`&&(S.current={text:t,until:Date.now()+_u},C.current=``,f(``),v.current?.abort(),E(`listening`))},[E]);return(0,z.useEffect)(()=>{if(t!==`thinking`||e.phase!==`idle`)return;let n=e.messages.at(-1);n?.role===`assistant`&&n.id!==w.current&&!n.pending?(w.current=n.id,le(n.content)):e.error&&E(`listening`)},[t,e.phase,e.messages,e.error,le,E]),(0,z.useEffect)(()=>()=>se(),[se]),{state:t,muted:r,since:a,error:s,level:l,heard:d,voice:p,setNatural:e=>m(t=>t&&{...t,natural:e}),start:oe,end:se,toggleMute:ce}}var Cu=new Map,wu={},Tu=new Set;function Eu(){wu=Object.assign({},...Cu.values());for(let e of Tu)e()}function Du(){return(0,z.useSyncExternalStore)(e=>(Tu.add(e),()=>Tu.delete(e)),()=>wu)}function Ou(){for(let e of Cu.values())e.onChanged?.()}function ku(e){let t=(0,z.useId)(),n=(0,z.useRef)(e);n.current=e;let{onChanged:r,...i}=e,a=JSON.stringify(i);(0,z.useEffect)(()=>{Cu.set(t,{...JSON.parse(a),onChanged:()=>n.current.onChanged?.()}),Eu()},[t,a]),(0,z.useEffect)(()=>()=>{Cu.delete(t),Eu()},[t])}function Au(){let e=document.getElementById(ah);if(!e)return;let t=e.getBoundingClientRect().top;for(let n of e.querySelectorAll(`[data-assist-section]`)){let e=n.getBoundingClientRect();if(e.bottom>t+40&&e.top<window.innerHeight*.6)return n.dataset.assistSection||void 0}}function ju(){let{title:e,hello:t,about:n,placeholder:r,suggestions:i,compact:a,onChanged:o,...s}=wu,c=Vm().map(e=>e.label),l=window.location.pathname,u=l.startsWith(ct)?l.slice(ct.length)||`/`:l,d=Au(),f=(e,t)=>e&&e.length>t?`${e.slice(0,t-1)}…`:e;return{route:`${u}${window.location.search}`.slice(0,400),...c.length?{title:f(c.join(` / `),200)}:{},...d?{view:f(d,200)}:{},...s.open?{open:{kind:s.open.kind.slice(0,60),...s.open.id?{id:s.open.id.slice(0,120)}:{},label:f(s.open.label,200)??``}}:{},...s.selection?{selection:s.selection.slice(0,100).map(e=>e.slice(0,120))}:{},...s.summary?{summary:f(s.summary,2e3)}:{},...s.fields?{fields:s.fields.slice(0,60).map(e=>({id:e.id.slice(0,120),label:f(e.label,200)??``,value:e.value}))}:{},...s.plugin?{plugin:s.plugin}:{}}}var Mu=()=>document.getElementById(`studio-scroll`)??document.body,Nu=`[data-assist],h1,h2,h3,h4,button,a[href],input,textarea,select,[role=switch],[role=checkbox],[role=tab],[contenteditable=true]`,Pu=150,Fu=0;function Iu(e){return e.dataset.assist?e.dataset.assist:(e.dataset.assistRef||(Fu+=1,e.dataset.assistRef=`e${Fu}`),e.dataset.assistRef)}var Lu=(e,t=120)=>(e??``).replace(/\s+/g,` `).trim().slice(0,t);function Ru(e){if(e.dataset.assistLabel)return Lu(e.dataset.assistLabel);let t=e.getAttribute(`aria-label`);if(t)return Lu(t);if(e.dataset.assist&&!e.matches(`input,textarea,select,button,a`)){let t=e.querySelector(`h1,h2,h3,h4,[data-assist-section]`);if(t)return Lu(t.getAttribute(`data-assist-section`)||t.textContent)}if(e.id){let t=document.querySelector(`label[for="${CSS.escape(e.id)}"]`);if(t)return Lu(t.textContent)}let n=e.closest(`label`);if(n&&n!==e)return Lu(n.textContent);let r=e.parentElement?.querySelector(`label`);return r&&(e.matches(`input,textarea,select`)||e.getAttribute(`role`)===`switch`)?Lu(r.textContent):Lu(e.textContent||e.placeholder||e.getAttribute(`title`)||``)}function zu(e){if(e instanceof HTMLInputElement)return e.type===`password`?e.value?`••••`:``:e.type===`checkbox`||e.type===`radio`?e.checked:e.value.slice(0,300);if(e instanceof HTMLTextAreaElement)return e.value.slice(0,600);if(e instanceof HTMLSelectElement)return Lu(e.selectedOptions[0]?.textContent??e.value);let t=e.getAttribute(`role`);if(t===`switch`||t===`checkbox`)return e.getAttribute(`aria-checked`)===`true`;if(e.isContentEditable)return Lu(e.textContent,600)}function Bu(e){return e.dataset.assist&&!e.matches(`input,textarea,select,button,a`)?`area`:/^H[1-4]$/.test(e.tagName)?`heading`:e.matches(`input,textarea,select,[role=switch],[role=checkbox],[contenteditable=true]`)?`field`:e.getAttribute(`role`)===`tab`?`tab`:e.tagName===`A`?`link`:`button`}function Vu(e){if(e.closest(`[data-assistant-ui],[aria-hidden=true]`))return!1;let t=getComputedStyle(e);if(t.display===`none`||t.visibility===`hidden`)return!1;let n=e.getBoundingClientRect();return n.width>0||n.height>0}function Hu(e){let t=e.getBoundingClientRect();return t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth}function Uu(e,t){let n=[];for(let r of e.querySelectorAll(Nu)){if(n.length>=Pu)break;if(!Vu(r)||t&&!Hu(r))continue;let e=Bu(r),i=Ru(r);if(!i&&e!==`field`)continue;let a=e===`field`?zu(r):void 0,o=r.disabled||r.getAttribute(`aria-disabled`)===`true`;n.push({ref:Iu(r),kind:e,label:i,...a===void 0?{}:{value:a},...o?{disabled:!0}:{},...r.getAttribute(`aria-current`)||r.getAttribute(`aria-selected`)===`true`?{current:!0}:{}})}return n}function Wu(e){let t=Mu(),n=e.trim(),r=document.querySelector(`[data-assist="${CSS.escape(n)}"]`)??document.querySelector(`[data-assist-ref="${CSS.escape(n)}"]`)??(/^[A-Za-z][\w-]*$/.test(n)?document.getElementById(n):null);if(r)return r;let i=n.toLowerCase(),a=null;for(let e of t.querySelectorAll(Nu)){if(!Vu(e))continue;let t=Ru(e).toLowerCase();if(t===i)return e;!a&&t.includes(i)&&(a=e)}return a}var Gu=e=>({error:`Nothing on the page is "${e}". look_at_page lists what is there.`}),Ku=null,qu=0,Ju=new Set;function Yu(e){Ku=e;for(let e of Ju)e()}function Xu(){return(0,z.useSyncExternalStore)(e=>(Ju.add(e),()=>Ju.delete(e)),()=>Ku)}var Zu=null,Qu=()=>[];function $u(e,t){Zu=e,Qu=t}function ed(e){let t=e.split(/[?#]/)[0]||`/`;return Qu().some(e=>RegExp(`^${e.split(`/`).map(e=>e.startsWith(`:`)?e.endsWith(`?`)?`(?:[^/]+)?`:`[^/]+`:e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`/`)}/?$`).test(t))}var G=()=>new Promise(e=>setTimeout(e,450));function K(e){return!e.startsWith(`/`)||e.startsWith(`//`)||/^\/(api|w|s)\//.test(e)||!(Zu&&ed(e))?!1:(Zu(e),!0)}var q={type:`string`,description:`A ref or area from look_at_page, or the label`},J=new Map;function Y(){return[...J.values()].map(({name:e,description:t,parameters:n})=>({name:e,description:t,parameters:n}))}var td=[{name:`navigate`,description:`Open a page of the studio by its address (/settings/models, /space/knowledge, /space/data, a plugin's page). The chat stays open.`,parameters:{type:`object`,properties:{to:{type:`string`,description:`The studio address, starting with /`}},required:[`to`]},run:async({to:e})=>{let t=String(e??``);return t.startsWith(`/`)&&ed(t)?(Zu?.(t),await G(),{opened:t,pageTools:Y()}):{error:`The studio has no page "${t}".`,pages:Qu()}}},{name:`highlight`,description:"Point at one element: `spotlight` dims the page except it, `ring` only rings it. A small card beside it shows a title, a text and buttons; a button the person presses comes back as their next message. Scrolls it into view.",parameters:{type:`object`,properties:{target:q,mode:{type:`string`,enum:[`spotlight`,`ring`]},title:{type:`string`,maxLength:80},text:{type:`string`,maxLength:400},buttons:{type:`array`,items:{type:`string`,maxLength:40},maxItems:3,description:`Answers the person can give with one click`}},required:[`target`]},run:async({target:e,mode:t,title:n,text:r,buttons:i})=>{let a=Wu(String(e??``));return a?(a.scrollIntoView({behavior:`smooth`,block:`center`}),await G(),qu+=1,Yu({id:qu,el:a,mode:t===`ring`?`ring`:`spotlight`,title:n?String(n):void 0,text:r?String(r):void 0,buttons:Array.isArray(i)?i.map(String).slice(0,3):[]}),{shown:Ru(a)}):Gu(String(e))}},{name:`look_at_page`,description:`What is on the screen now, as a list: headings, areas, buttons, links, tabs and fields with their values, each with a ref to point at (at most 150). Not a picture.`,parameters:{type:`object`,properties:{}},run:()=>({route:window.location.pathname,scrolled:Math.round(Mu().scrollTop),items:Uu(Mu(),!0),pageTools:Y()})},{name:`read_section`,description:`Everything in one area of the page, also what is scrolled away: its elements with values, and its text.`,parameters:{type:`object`,properties:{target:q},required:[`target`]},run:({target:e})=>{let t=Wu(String(e??``));return t?{area:Ru(t),items:Uu(t,!1),text:Lu(t.innerText,4e3)}:Gu(String(e))}},{name:`fill_field`,description:`Put a value into a field of the page, as if typed: text, a choice by its label, yes/no for a switch. Not saved by you: the person checks and saves.`,parameters:{type:`object`,properties:{target:q,value:{type:[`string`,`number`,`boolean`]}},required:[`target`,`value`]},run:async({target:e,value:t})=>{let n=Wu(String(e??``));if(!n)return Gu(String(e));if(n.scrollIntoView({behavior:`smooth`,block:`center`}),n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`))n.checked!==!!t&&n.click();else if(n.getAttribute(`role`)===`switch`||n.getAttribute(`role`)===`checkbox`)n.getAttribute(`aria-checked`)===`true`!=!!t&&n.click();else if(n instanceof HTMLSelectElement){let e=[...n.options].find(e=>e.value===String(t)||Lu(e.textContent).toLowerCase()===String(t).toLowerCase());if(!e)return{error:`No such choice.`,choices:[...n.options].map(e=>Lu(e.textContent))};n.value=e.value,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}else if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){if(n.disabled||n.readOnly)return{error:`The field takes nothing here.`};let e=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(e,`value`)?.set?.call(n,String(t)),n.dispatchEvent(new Event(`input`,{bubbles:!0})),n.dispatchEvent(new Event(`change`,{bubbles:!0}))}else return{error:`That is not a field.`};return n.focus({preventScroll:!0}),{filled:Ru(n),value:zu(n)}}},{name:`page_tool`,description:`Runs a tool the page shown now offers, by its name, with its arguments: a page opened during this answer brings tools that are not among yours (navigate and look_at_page list them with their parameters).`,parameters:{type:`object`,properties:{name:{type:`string`},args:{type:`object`,description:`The tool's arguments, as its parameters say`}},required:[`name`]},run:async({name:e,args:t})=>{let n=J.get(String(e??``));return n?n.run(t??{}):{error:`The page offers no tool "${String(e)}".`,pageTools:Y()}}},{name:`scroll_to`,description:`Scroll an element of the page into view.`,parameters:{type:`object`,properties:{target:q},required:[`target`]},run:async({target:e})=>{let t=Wu(String(e??``));return t?(t.scrollIntoView({behavior:`smooth`,block:`start`}),await G(),{at:Ru(t)}):Gu(String(e))}}];function nd(e,t,n){let r=(0,z.useRef)(n);r.current=n;let i=JSON.stringify(t);(0,z.useEffect)(()=>{if(td.some(t=>t.name===e))throw Error(`"${e}" is a tool of the assistant itself.`);if(!/^[a-z][a-z0-9_]{1,62}$/.test(e))throw Error(`"${e}": a tool's name is lower case letters, digits and _.`);let{description:t,parameters:n}=JSON.parse(i);return J.set(e,{name:e,description:t,parameters:n??{type:`object`,properties:{}},run:e=>r.current(e)}),()=>{J.delete(e)}},[e,i])}function rd(){return[...td,...J.values()].map(({name:e,description:t,parameters:n})=>({name:e,description:t,parameters:n}))}async function id(e,t){let n=td.find(t=>t.name===e)??J.get(e);if(!n)return null;try{return{result:await n.run(t??{})}}catch(e){return{result:{error:e.message}}}}var ad=e=>({id:e.id,role:e.role,content:e.content,cards:e.cards.map((t,n)=>({...t,id:`${e.id}-${n}`})),toolCalls:e.toolCalls,changed:e.changed});function od(e){return e.type.startsWith(`image/`)&&/logo/i.test(e.name)?`logo`:/^(image|video|audio)\//.test(e.type)?`asset`:`document`}var sd=0,cd=e=>`${e}-${Date.now()}-${++sd}`,ld=(0,z.createContext)(null);function ud(){return(0,z.useContext)(ld)}function dd(){let e=bh(),t=Yt(),n=(0,z.useRef)([]);return n.current=[`/`,`/new`,`/edit/:id`,`/space`,`/space/:group`,`/settings`,...Hl(t.data,e).map(e=>`/settings/${e.id}`),...e.pages.map(e=>e.path)],(0,z.useCallback)(()=>n.current,[])}function fd({children:e}){let t=D(),n=Yt(),r=!!n.data,{project:i}=I(),a=Re(),o=dd();(0,z.useEffect)(()=>{$u(e=>a(e),o)},[a,o]);let s=at({queryKey:[`assistant-chat`],queryFn:()=>_.get(`/api/studio/assistant/chat`),enabled:r,staleTime:1/0}),c=at({queryKey:[`assistant-layout`],queryFn:()=>_.get(`/api/studio/assistant/layout`),enabled:r,staleTime:1/0}),[l,u]=(0,z.useState)([]),[d,f]=(0,z.useState)(`idle`),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(null),[v,y]=(0,z.useState)(null),[b,x]=(0,z.useState)(!1),[S,C]=(0,z.useState)(!1),[ee,w]=(0,z.useState)({kind:`chat`}),[T,E]=(0,z.useState)(null),[ne,re]=(0,z.useState)(void 0),[ie,ae]=(0,z.useState)([]),[oe,se]=(0,z.useState)([]),ce=(0,z.useRef)(null),le=Ql(),ue=!!n.data?.assistantDev,de=ue&&le.dev,fe=(0,z.useRef)(de);fe.current=de;let[k,pe]=(0,z.useState)(!1),A=(0,z.useRef)(k);A.current=k,(0,z.useEffect)(()=>{s.data&&ce.current!==s.data.id&&(ce.current=s.data.id,u(s.data.messages.map(ad)))},[s.data]);let me=(0,z.useCallback)(e=>{E(e),t.setQueryData([`assistant-layout`],t=>({...t,layout:e})),_.put(`/api/studio/assistant/layout`,{layout:e}).catch(()=>null)},[t]),he=(0,z.useCallback)((e,n=!0)=>{re(e),n&&(t.setQueryData([`assistant-layout`],t=>({...t,width:e})),_.put(`/api/studio/assistant/layout`,{width:e}).catch(()=>null))},[t]),ge=(0,z.useRef)(null),_e=(0,z.useCallback)(()=>(ge.current??=(async()=>{await Promise.all([t.invalidateQueries({queryKey:O.spaces()}),i?t.invalidateQueries({queryKey:O.files(i.id)}):null,i?t.invalidateQueries({queryKey:O.knowledge(i.id)}):null]),Ou(),ge.current=null})(),ge.current),[t,i]),j=(0,z.useRef)([]),M=(0,z.useCallback)(e=>{j.current=e(j.current),ae(j.current)},[]),ve=(0,z.useRef)(!1),ye=(0,z.useRef)(null),be=(0,z.useRef)(null),xe=(0,z.useRef)(()=>void 0),Se=(0,z.useRef)(new Set),N=(0,z.useCallback)(()=>{let e=ye.current?.runId;if(e)for(let t of j.current)t.way!==`signal`||Se.current.has(t.id)||(Se.current.add(t.id),_.post(`/api/studio/assistant/run/${e}/signal`,{ref:t.id,message:t.text}).catch(()=>{}))},[]),Ce=(0,z.useCallback)(async(e,t)=>{if(!t.length)return e;if(!i||i.readOnly)return m(R(`assistant.filesNeedSpace`)),null;try{for(let e of t)await _.upload(`/api/studio/projects/${i.id}/files?kind=${od(e)}`,e)}catch(e){return m(e.message),await _e(),null}await _e();let n=`${R(`editor.attached`)}: ${t.map(e=>e.name).join(`, `)}`;return e.trim()?`${e}\n\n${n}`:n},[i,_e]),we=(0,z.useCallback)(async(e,n)=>{ve.current=!0,m(null),f(`thinking`),y(Date.now()),Yu(null),w({kind:`chat`});let r=cd(`p`),a=cd(`u`);u(t=>[...t,{id:a,role:`user`,content:e,previews:n},{id:r,role:`assistant`,content:``,pending:!0}]),g(null);let o=e=>{let t=r;u(n=>n.map(n=>n.id===t?e(n):n))},s=fe.current?{id:cd(`t`),message:e,startedAt:Date.now(),endedAt:null,prompt:null,events:[]}:null;s&&se(e=>[...e,s]);let c=(e,t)=>{s&&(s.events.push({at:Date.now(),event:e,data:t}),e===`prompt`&&(s.prompt=t),se(e=>e.map(e=>e.id===s.id?{...s}:e)))},l=new AbortController,d={runId:null,abort:l,stopped:!1};ye.current=d;let p=!1;try{await te(`/api/studio/assistant/turn`,{message:e,projectId:i?.id,page:ju(),tools:rd(),lang:L,...fe.current?{debug:!0}:{},...A.current?{extra:!0}:{}},(e,t)=>{let n=JSON.parse(t);switch(c(e,n),e){case`run_started`:{let e=n;d.runId=e.runId,u(t=>t.map(t=>t.id===a?{...t,id:e.messageId}:t)),N();break}case`text`:o(e=>({...e,content:e.content+n.delta}));break;case`activity`:g(n.label);break;case`tool_call`:{let e=n;o(t=>({...t,toolCalls:[...t.toolCalls??[],e]})),id(e.toolCallName,e.args).then(t=>{t&&_.post(`/api/studio/assistant/tool/${e.toolCallId}`,{result:t.result??null}).catch(()=>null)});break}case`tool_result`:{let e=n;o(t=>({...t,toolCalls:t.toolCalls?.map(t=>t.toolCallId===e.toolCallId?{...t,result:e.content}:t)}));break}case`card`:{let e=n;o(t=>({...t,cards:[...t.cards??[],{...e,id:`${t.id}-${t.cards?.length??0}`}]}));break}case`changed`:_e();break;case`step`:o(e=>({...e,steps:[...e.steps??[],n]}));break;case`signal`:{let e=n,t=r;r=cd(`p`),M(t=>t.filter(t=>t.id!==e.ref)),u(n=>[...n.flatMap(n=>n.id===t?n.content||n.toolCalls?.length||n.cards?.length||n.steps?.length?[{...n,id:e.answerId??n.id,pending:!1}]:[]:[n]),{id:e.messageId,role:`user`,content:e.content,signal:!0},{id:r,role:`assistant`,content:``,pending:!0}]);break}case`done`:{p=!0;let e=n;o(t=>({...t,id:e.messageId,content:e.reply,changed:e.changed,pending:!1}));break}case`error`:p=!0,m(n.message)}},l.signal),p||m(R(`editor.chatBroken`))}catch(e){d.stopped||m(e.message)}finally{s&&(s.endedAt=Date.now(),se(e=>e.map(e=>e.id===s.id?{...s}:e))),ye.current=null,g(null),y(null),u(e=>e.filter(e=>!(e.pending&&!e.content&&!e.cards?.length&&!e.toolCalls?.length&&!e.steps?.length)).map(e=>({...e,pending:!1}))),f(`idle`),ve.current=!1,await ge.current,t.invalidateQueries({queryKey:[`me`]})}let h=be.current;if(be.current=null,!(h||d.stopped)){let e=j.current.filter(e=>e.way===`signal`),t=e.length?e:j.current.filter(e=>e.way===`queue`).slice(0,1);t.length&&(M(e=>e.filter(e=>!t.includes(e))),h=t.map(e=>e.text).join(`
|
|
24
|
+
`)}):null]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{children:R(`report.page`)}),(0,B.jsxs)(`p`,{className:`break-all font-mono text-ink-3 text-xs`,children:[h,(0,B.jsx)(`br`,{}),navigator.userAgent]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{children:R(`report.contact`)}),(0,B.jsx)(me,{type:`email`,value:u,onChange:e=>d(e.target.value)})]}),f===`failed`?(0,B.jsx)(`p`,{className:`text-rose text-sm`,children:R(`report.failed`)}):null,(0,B.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,B.jsx)(k,{variant:`ghost`,onClick:Hs,children:R(`report.cancel`)}),(0,B.jsx)(k,{onClick:()=>void g(),busy:f===`sending`,children:R(f===`sending`?`report.sending`:`report.send`)})]})]})})})}var Qs=(0,z.lazy)(()=>It(()=>import(`./AboutDialog-pMHleH_y.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),$s=`0.11.13`;function ec({me:e}){let[t,n]=(0,z.useState)(!1);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:`tabular-nums transition hover:text-ink-2`,onClick:()=>n(!0),children:R(`about.version`,{v:$s})}),t?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(Qs,{open:!0,me:e,onClose:()=>n(!1)})}):null]})}var tc=[`update`],nc=36e5;function rc(e=!0){let t=D(),[n,r]=(0,z.useState)(null),i=at({queryKey:tc,queryFn:()=>_.get(`/api/studio/update`),staleTime:nc,refetchInterval:nc,retry:!1,enabled:e}),a=Pt({mutationFn:()=>_.get(`/api/studio/update?fresh=1`),onSuccess:e=>t.setQueryData(tc,e)}),o=Pt({mutationFn:()=>_.post(`/api/studio/update`),onSuccess:e=>t.setQueryData(tc,e)}),s=i.data,c=s?.latest??null,l=s?.restarts&&(s.applying===`running`||s.applying===`done`),u=s?.current;return(0,z.useEffect)(()=>{if(!(l||s?.applying===`running`)||!c)return;let e=setInterval(async()=>{try{let e=await _.get(`/api/studio/update`);if(e.current!==u){window.location.reload();return}t.setQueryData(tc,e),e.applying===`done`&&e.restarts&&r(c)}catch{r(c)}},2e3);return()=>clearInterval(e)},[l,s?.applying,c,u,t]),{status:i,data:s,latest:c,check:a,apply:o,busy:s?.applying===`running`||n!==null,progress:!s||!c?null:n===null?s.applying===`running`?R(`about.update.installing`,{v:c}):s.applying===`done`?R(`about.update.done`,{v:c}):s.applying===`failed`?R(`about.update.failed`):null:R(`about.update.restarting`,{v:c})}}var ic=`wizards.install-banner`,ac=`wizards.first-day`,oc=()=>window.matchMedia(`(pointer: coarse)`).matches;function sc({open:e,onClose:t}){let n=Ta(),r=wa(n),i=R(r===`prompt`?`install.app.offer`:r===`none`?`install.app.browser`:`install.app.how.${r}`);return(0,B.jsxs)(Qe,{open:e,onClose:t,title:R(`install.app.action`),children:[(0,B.jsx)(`p`,{className:`text-[0.9375rem] text-ink-2 leading-relaxed`,children:i}),(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,B.jsx)(k,{variant:`ghost`,onClick:t,children:R(`install.app.close`)}),n?(0,B.jsx)(k,{onClick:()=>{Ea(n),t()},children:R(`install.app.action`)}):null]})]})}function cc(){try{return localStorage.getItem(ic)===`1`}catch{return!1}}var lc=()=>new Date().toLocaleDateString(`sv`);function uc(){try{let e=localStorage.getItem(ac);return e?e!==lc():(localStorage.setItem(ac,lc()),!1)}catch{return!1}}function dc({me:e}){let t=Ta(),[n,r]=(0,z.useState)(cc),[i]=(0,z.useState)(uc);return!(t&&e.hasWizards&&i)||n||ya()||oc()?null:(0,B.jsxs)(`div`,{className:`flex items-center gap-3 border-border-soft border-b bg-paper-2 px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,B.jsx)(kt,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1`,children:R(`install.app.offer`)}),(0,B.jsx)(k,{size:`sm`,onClick:()=>void Ea(t),children:R(`install.app.action`)}),(0,B.jsx)(ge,{label:R(`install.app.close`),onClick:()=>{try{localStorage.setItem(ic,`1`)}catch{}r(!0)},className:`size-8`,children:(0,B.jsx)(it,{className:`size-4`})})]})}function fc(e){return e.mode===`managed`&&(e.organizations.length>1||e.mayCreateOrganization)}function pc(e){if(e.slug){window.location.href=`${a}/${e.slug}/`;return}let t=new URLSearchParams({organization:e.id,return:`${a}/`});window.location.href=Je(`/api/auth/login?${t}`)}function mc(e){return e.organizations.find(t=>t.id===e.tenant.id)??(e.tenant.name?{id:e.tenant.id,name:e.tenant.name,slug:null,role:e.tenant.role,personal:!1,plan:e.tenant.plan}:null)}function hc({org:e,size:t=`sm`}){return(0,B.jsx)(`span`,{"aria-hidden":`true`,className:P(`grid shrink-0 place-items-center font-semibold tracking-wide`,t===`md`?`size-10 text-[0.8125rem]`:t===`sm`?`size-9 text-[0.75rem]`:`size-7 text-[0.625rem]`,e.personal?`rounded-full bg-ember-tint text-ember-strong ring-1 ring-border-soft`:`rounded-lg bg-card text-ink-2 ring-1 ring-border`),children:nn(e.name)})}function gc(e){let t=Re();return()=>{na(e.features,`teamPlans`)?t(`/settings/organization`):e.manageUrl&&window.open(`${e.manageUrl}/account`,`_blank`,`noreferrer`)}}function _c({me:e,roomy:t,onDone:n}){let r=gc(e),[i,a]=(0,z.useState)(null),o=P(`flex w-full items-center gap-3 rounded-lg px-3 text-left text-ink-2 transition hover:bg-accent hover:text-ink`,t?`py-3 text-[0.9375rem]`:`py-2 text-[0.875rem]`);return(0,B.jsxs)(B.Fragment,{children:[e.organizations.map(r=>{let o=r.id===e.tenant.id;return(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:i!==null,"aria-current":o?`true`:void 0,className:P(`flex w-full items-center gap-3 rounded-lg px-2 text-left transition hover:bg-accent disabled:cursor-default`,t?`py-2.5`:`py-1.5`),onClick:()=>{if(o){n();return}a(r.id),pc(r)},children:[(0,B.jsx)(hc,{org:r,size:t?`md`:`sm`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,B.jsx)(`span`,{className:P(`truncate`,t?`text-[0.9375rem]`:`text-[0.875rem]`,o?`font-semibold text-ink`:`font-medium text-ink-2`),children:r.name}),(0,B.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:i===r.id?R(`organizations.switching`,{name:r.name}):r.personal?R(`organizations.own`):R(`organization.role.${r.role}`)})]}),r.plan?(0,B.jsx)(`span`,{className:`shrink-0 whitespace-nowrap rounded-full px-2 py-0.5 font-medium text-[0.6875rem] text-ink-3 ring-1 ring-border`,children:r.plan.name}):null,(0,B.jsx)(`span`,{className:`grid w-4 shrink-0 place-items-center`,children:i===r.id?(0,B.jsx)(Vr,{className:`size-4 animate-spin text-ink-3`}):o?(0,B.jsx)(fe,{className:`size-4 text-ember-strong`}):null})]},r.id)}),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:o,onClick:()=>{n(),r()},children:[(0,B.jsx)(ji,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:R(`organizations.manage`)})]}),e.mayCreateOrganization&&e.manageUrl?(0,B.jsxs)(`a`,{role:`menuitem`,className:o,href:`${e.manageUrl}/account`,target:`_blank`,rel:`noreferrer`,onClick:n,children:[(0,B.jsx)(vt,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`flex-1 truncate`,children:R(`organizations.create`)}),(0,B.jsx)(Vn,{className:`size-3.5 shrink-0 text-ink-4`})]}):null]})}function vc({me:e,className:t}){let[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)({top:0,left:0}),o=(0,z.useRef)(null);Jm(o,n,()=>r(!1));let s=mc(e);return s?fc(e)?(0,B.jsxs)(`div`,{ref:o,className:P(`relative min-w-0 shrink`,t),children:[(0,B.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":n,title:R(`organizations.switch`),onClick:e=>{let t=e.currentTarget.getBoundingClientRect();a({top:t.bottom+6,left:t.left}),r(e=>!e)},className:P(`-ml-2 flex max-w-[13rem] items-center gap-1 rounded-md py-0.5 pr-1.5 pl-2 text-[0.9375rem] text-ink-2 transition hover:bg-accent hover:text-ink`,n&&`bg-accent text-ink`),children:[(0,B.jsx)(`span`,{className:`truncate`,children:s.name}),(0,B.jsx)($n,{className:`size-3.5 shrink-0 text-ink-4`})]}),n?(0,B.jsxs)(`div`,{role:`menu`,style:{position:`fixed`,...i},className:`z-50 w-80 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,B.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:R(`organizations.mine`)}),(0,B.jsx)(_c,{me:e,onDone:()=>r(!1)})]}):null]}):(0,B.jsx)(`span`,{className:P(`max-w-[12rem] truncate text-[0.9375rem] text-ink-3`,t),title:s.name,children:s.name}):null}function yc({me:e,open:t,onClose:n}){let r=(0,z.useRef)(null);return(0,z.useEffect)(()=>{let e=r.current;t&&e&&!e.open?e.showModal():!t&&e?.open&&e.close()},[t]),(0,B.jsx)(`dialog`,{ref:r,onClose:n,onClick:e=>{e.target===r.current&&n()},"aria-label":R(`organizations.switch`),className:P(`max-h-[85dvh] overflow-y-auto overscroll-contain bg-card p-0 text-ink shadow-overlay backdrop:bg-[oklch(20%_0.01_60/0.28)]`,`max-sm:mx-0 max-sm:mt-auto max-sm:mb-0 max-sm:w-full max-sm:max-w-none max-sm:rounded-t-3xl`,`sm:m-auto sm:w-[calc(100%-32px)] sm:max-w-sm sm:rounded-2xl`),children:t?(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-[max(1rem,env(safe-area-inset-bottom))] sm:pt-3`,children:[(0,B.jsx)(`div`,{className:`mx-auto mb-2 h-1.5 w-9 rounded-full bg-border sm:hidden`}),(0,B.jsx)(bc,{onClose:n,children:R(`organizations.switch`)}),(0,B.jsx)(_c,{me:e,roomy:!0,onDone:n})]}):null})}function bc({children:e,onClose:t}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-2 pt-1 pb-2.5`,children:[(0,B.jsx)(`h2`,{className:`font-semibold text-[1.0625rem]`,children:e}),(0,B.jsx)(`button`,{type:`button`,onClick:t,"aria-label":R(`common.close`),className:`grid size-8 place-items-center rounded-full bg-paper-2 text-ink-3 transition hover:text-ink`,children:(0,B.jsx)(it,{className:`size-4`})})]})}var xc=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);function Sc({me:e,position:t,horizontal:n,labels:r}){let i=Re(),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(!1),[l,d]=(0,z.useState)(!1),f=e.mode===`managed`?mc(e):null,p=fc(e),m=gc(e),h=Ta(),g=(0,z.useRef)(null);Jm(g,a,()=>o(!1)),(0,z.useEffect)(()=>{a||d(!1)},[a]);let _=e.mode===`local`,{data:v,check:y}=rc(_);(0,z.useEffect)(()=>{let e=e=>{e.key===`,`&&(xc?e.metaKey:e.ctrlKey)&&!e.altKey&&!e.shiftKey&&(e.preventDefault(),i(`/settings`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let b=e=>{o(!1),i(e)},x=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 transition hover:bg-accent hover:text-ink`,S=`ml-auto shrink-0 text-[0.75rem] text-ink-4`,C=(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),ee=y.isPending?{text:R(`about.update.checking`),tone:S}:v?.newer&&v.latest?{text:v.latest,tone:`ml-auto shrink-0 text-[0.75rem] font-medium text-ember-strong`}:v?{text:R(`about.update.upToDateShort`),tone:`ml-auto shrink-0 text-[0.75rem] text-moss`}:null;return(0,B.jsxs)(`div`,{ref:g,className:P(`relative shrink-0`,r&&`w-full`),children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-haspopup":`menu`,title:R(`about.title`),"aria-label":R(`about.title`),className:P(`shrink-0 rounded-lg transition hover:bg-ink/10`,a&&`bg-ink/10`,r?`flex h-12 w-full items-center gap-2 px-1.5`:P(`grid place-items-center`,n?`size-11`:`h-12 w-11`)),children:[(0,B.jsx)(ln,{size:32}),r?(0,B.jsxs)(`span`,{className:`truncate font-display font-semibold text-[1rem] tracking-tight`,children:[`engenty`,(0,B.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,B.jsx)(`span`,{className:`ml-1 font-normal text-ink-3`,children:`wizards`})]}):null]}),a?(0,B.jsxs)(`div`,{role:`menu`,className:P(`absolute z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,ha(t,`start`)),children:[(0,B.jsxs)(`div`,{className:`flex items-baseline gap-2 px-3 pt-2 pb-2.5`,children:[(0,B.jsxs)(`span`,{className:`font-display font-semibold text-[1rem] tracking-tight`,children:[`engenty`,(0,B.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,B.jsx)(`span`,{className:`ml-1 font-normal text-ink-3`,children:`wizards`})]}),(0,B.jsx)(`span`,{className:P(S,`tabular-nums`),children:$s})]}),f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":p?`menu`:void 0,"aria-expanded":p?l:void 0,className:P(`flex w-full items-center gap-3 rounded-lg px-2.5 py-1.5 text-left transition hover:bg-accent`,l&&`bg-accent`),onClick:()=>{p?d(e=>!e):(o(!1),m())},children:[(0,B.jsx)(hc,{org:f,size:`xs`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,B.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:f.name}),(0,B.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:f.plan?`${R(`organization.title`)} · ${f.plan.name}`:R(`organization.title`)})]}),p?(0,B.jsx)(u,{className:`size-4 shrink-0 text-ink-4`}):null]}),l?(0,B.jsxs)(`div`,{role:`menu`,className:P(`absolute top-12 z-50 w-80 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,t===`right`?`right-full mr-1.5`:`left-full ml-1.5`),children:[(0,B.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:R(`organizations.switch`)}),(0,B.jsx)(_c,{me:e,onDone:()=>o(!1)})]}):null,C]}):null,(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>b(`/settings/about`),children:R(`about.title`)}),_?(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>v?.newer?b(`/settings/about`):y.mutate(),children:[R(`about.update.check`),ee?(0,B.jsx)(`span`,{className:ee.tone,children:ee.text}):null]}):null,(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>b(`/settings/about?tab=new`),children:R(`about.tab.new`)}),C,(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>b(`/settings`),children:[R(`nav.settings`),` …`,(0,B.jsx)(`span`,{className:S,children:xc?`⌘ ,`:`Ctrl ,`})]}),ya()?null:(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>{o(!1),h?Ea(h):c(!0)},children:R(`install.app.action`)}),C,(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:x,onClick:()=>b(`/settings/about?tab=credits`),children:R(`about.creditsMenu`)})]}):null,(0,B.jsx)(sc,{open:s,onClose:()=>c(!1)})]})}var Cc=[],wc=0,Tc=new Set;function Ec(){for(let e of Tc)e()}function Dc(e){let t=(0,z.useRef)(e);t.current=e;let n=e!==null,r=e?.icon,i=e?.label;(0,z.useEffect)(()=>{if(!n||!r||i===void 0)return;let e=++wc;return Cc=[...Cc,{id:e,action:{icon:r,label:i,run:()=>t.current?.run()}}],Ec(),()=>{Cc=Cc.filter(t=>t.id!==e),Ec()}},[n,r,i])}function Oc(){return(0,z.useSyncExternalStore)(e=>(Tc.add(e),()=>Tc.delete(e)),()=>Cc.at(-1)?.action??null,()=>null)}var kc=(0,z.lazy)(()=>It(()=>import(`./AboutDialog-pMHleH_y.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])));function Ac(e,t=!1){return P(`shrink-0 rounded-lg transition`,t?`flex h-10 w-full items-center gap-3 px-2.5 font-medium text-[0.875rem]`:`grid size-10 place-items-center`,e?`bg-paper text-ink shadow-soft dark:ring-1 dark:ring-border-soft`:`text-ink-3 hover:bg-ink/10 hover:text-ink`)}function jc({children:e}){return(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})}function Mc({me:e,labels:t}){let{project:n}=I(),r=Qm(e),i=r?e.tenant.name??void 0:void 0;return(0,B.jsxs)($m,{me:e,placement:`bar-start`,label:n?.name??R(`nav.space`),className:e=>t?P(`flex w-full items-center gap-3 rounded-lg p-0.5 pr-2 text-left transition hover:bg-ink/10`,e&&`bg-ink/10`):P(`block rounded-lg transition`,e?`ring-2 ring-ink/80 ring-offset-2 ring-offset-sidebar`:`hover:shadow-soft`),children:[(0,B.jsx)(Zm,{project:n,name:i}),t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-semibold text-[0.875rem] text-ink`,children:i??n?.name??R(`nav.space`)}),r?null:(0,B.jsx)($n,{className:`size-4 shrink-0 text-ink-4`})]}):null]})}var Nc={left:di,top:hi,right:pi,bottom:si},Pc=[{pick:`light`,icon:Qt,label:`appbar.light`},{pick:`dark`,icon:Wt,label:`appbar.dark`},{pick:null,icon:ri,label:`appbar.system`}];function Fc({at:e,room:t,onClose:n}){let{position:r,labels:i}=fa(),a=Vt(),o=V,s=(0,z.useRef)(null);Jm(s,!0,n);let[c,l]=(0,z.useState)({x:0,y:0});(0,z.useLayoutEffect)(()=>{let e=s.current?.getBoundingClientRect();e&&l({x:Math.min(0,window.innerWidth-8-e.right),y:Math.min(0,window.innerHeight-8-e.bottom)})},[]);let u=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink disabled:pointer-events-none disabled:opacity-50`,d=`px-3 pt-2 pb-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.07em]`;return(0,B.jsxs)(`div`,{ref:s,role:`menu`,className:`fixed z-[60] w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,style:{left:Math.max(8,e.x+c.x),top:Math.max(8,e.y+c.y)},onContextMenu:e=>e.preventDefault(),children:[(0,B.jsx)(`div`,{className:d,children:R(`appbar.position`)}),o.map(e=>{let t=Nc[e];return(0,B.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===r,className:P(u,e===r&&`text-ink`),onClick:()=>{ua({position:e}),n()},children:[(0,B.jsx)(t,{className:`size-4`}),(0,B.jsx)(`span`,{className:`flex-1`,children:R(`appbar.${e}`)}),e===r?(0,B.jsx)(fe,{className:`size-4 text-ember-strong`}):null]},e)}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":i,disabled:!(i||t),className:P(u,i&&`text-ink`),onClick:()=>{ua({labels:!i}),n()},children:[(0,B.jsx)(li,{className:`size-4`}),(0,B.jsx)(`span`,{className:`flex-1`,children:R(`appbar.labels`)}),i?(0,B.jsx)(fe,{className:`size-4 text-ember-strong`}):null]}),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsx)(`div`,{className:d,children:R(`appbar.theme`)}),Pc.map(({pick:e,icon:t,label:r})=>(0,B.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===a,className:P(u,e===a&&`text-ink`),onClick:()=>{Ht(e),n()},children:[(0,B.jsx)(t,{className:`size-4`}),(0,B.jsx)(`span`,{className:`flex-1`,children:R(r)}),e===a?(0,B.jsx)(fe,{className:`size-4 text-ember-strong`}):null]},r))]})}function Ic(){let{pathname:e}=tt();return e===`/new`?`new`:e===`/`||e.startsWith(`/edit/`)?`home`:e===`/space/results`||e.startsWith(`/space/results/`)?`results`:e===`/settings`||e.startsWith(`/settings/`)?`settings`:e===`/space`||e.startsWith(`/space/`)?`space`:null}function Lc({me:e,labels:t,room:n}){let r=bh(),{position:i}=fa(),a=pa(i),s=Ic(),[c,l]=(0,z.useState)(null),u=e=>{e.preventDefault(),l({x:e.clientX,y:e.clientY})},d=(0,z.useRef)(null),f=(0,z.useRef)(!1),p=()=>{d.current&&=(window.clearTimeout(d.current.timer),null)};return(0,B.jsxs)(`aside`,{"aria-label":Kt.name,onContextMenu:u,onPointerDown:e=>{if(e.pointerType===`mouse`)return;p();let{clientX:t,clientY:n}=e;d.current={x:t,y:n,timer:window.setTimeout(()=>{d.current=null,f.current=!0,window.setTimeout(()=>{f.current=!1},700),l({x:t,y:n})},500)}},onPointerMove:e=>{d.current&&Math.hypot(e.clientX-d.current.x,e.clientY-d.current.y)>10&&p()},onPointerUp:p,onPointerCancel:p,onPointerLeave:p,onClickCapture:e=>{f.current&&(f.current=!1,e.preventDefault(),e.stopPropagation())},className:P(`flex shrink-0 select-none bg-sidebar [-webkit-touch-callout:none]`,a?`w-full flex-row items-center gap-1.5 px-2`:P(`h-full flex-col pt-2 pb-3 transition-[width] duration-200 ease-out`,t?`w-56 items-stretch px-2.5`:`w-16 items-center`),i===`bottom`&&`pt-1.5 pb-[calc(0.375rem+env(safe-area-inset-bottom))]`,i===`top`&&`pt-[calc(0.375rem+env(safe-area-inset-top))] pb-1.5`),children:[(0,B.jsx)(Sc,{me:e,position:i,horizontal:a,labels:t}),(0,B.jsx)(`div`,{className:a?`ml-1`:`mt-2`,children:(0,B.jsx)(Mc,{me:e,labels:t})}),(0,B.jsxs)(ce,{to:`/`,title:R(`nav.home`),"aria-label":R(`nav.home`),"aria-current":s===`home`||s===`new`?`page`:void 0,className:P(Ac(s===`home`||s===`new`,t),a?`ml-1.5`:`mt-2`),children:[(0,B.jsx)(Tr,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:R(`nav.home`)}):null]}),(0,B.jsxs)(ce,{to:`/space`,title:R(`nav.sources`),"aria-label":R(`nav.sources`),"aria-current":s===`space`?`page`:void 0,className:P(Ac(s===`space`,t),a?`ml-1.5`:`mt-2`),children:[(0,B.jsx)(Lr,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:R(`nav.sources`)}):null]}),(0,B.jsxs)(ce,{to:`/space/results`,title:R(`space.results`),"aria-label":R(`space.results`),"aria-current":s===`results`?`page`:void 0,className:P(Ac(s===`results`,t),a?`ml-1.5`:`mt-2`),children:[(0,B.jsx)(kr,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:R(`space.results`)}):null]}),r.nav.length?(0,B.jsx)(`div`,{className:P(`shrink-0 bg-border`,a?`mx-2 h-7 w-px`:P(`my-3 h-px`,t?`mx-2.5`:`w-7`))}):null,(0,B.jsx)(`nav`,{className:P(`flex min-h-0 min-w-0 flex-1 gap-1.5`,t?`items-stretch`:`items-center`,a?`flex-row overflow-x-auto`:`flex-col overflow-y-auto`),children:r.nav.map(e=>(0,B.jsx)(Wh,{of:e,children:(0,B.jsxs)(o,{to:e.to,title:e.label(),"aria-label":e.label(),className:({isActive:e})=>Ac(e,t),children:[(0,B.jsx)(e.icon,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:e.label()}):null]})},e.serial))}),(0,B.jsxs)(`div`,{className:P(`flex shrink-0 gap-2`,a?`flex-row pl-3`:`flex-col pt-3`,t?`items-stretch`:`items-center`),children:[(0,B.jsxs)(o,{to:`/settings`,title:R(`nav.settings`),"aria-label":R(`nav.settings`),className:({isActive:e})=>Ac(e,t),children:[(0,B.jsx)(ji,{className:`size-5 shrink-0`}),t?(0,B.jsx)(jc,{children:R(`nav.settings`)}):null]}),(0,B.jsx)(rh,{me:e,placement:`bar-end`,named:t})]}),c?(0,B.jsx)(Fc,{at:c,room:n,onClose:()=>l(null)}):null]})}function Rc(e){return P(`glass-press relative grid h-12 w-16 place-items-center rounded-full transition-colors`,e?`text-ink`:`text-ink-3`)}var zc=68;function Bc({index:e}){let t=(0,z.useRef)(null),n=(0,z.useRef)(e);return(0,z.useEffect)(()=>{let r=n.current;n.current=e;let i=t.current;if(!i||r===null||e===null||r===e||matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let a=r*zc,o=e*zc;i.animate([{transform:`translateX(${a}px)`},{transform:`translateX(${(a+o)/2}px) scaleX(1.35) scaleY(0.92)`,offset:.45},{transform:`translateX(${o}px)`}],{duration:420,easing:`cubic-bezier(0.34, 1.3, 0.64, 1)`})},[e]),(0,B.jsx)(`span`,{ref:t,"aria-hidden":`true`,className:`pointer-events-none absolute top-1 left-1 h-12 w-16 rounded-full bg-ink/12 transition-opacity`,style:{transform:`translateX(${(e??0)*zc}px)`,opacity:e===null?0:1}})}function Vc({me:e}){let t=bh(),n=Ic(),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(!1),s=Re(),c=(0,z.useRef)(null),l=Oc(),u=Xt(),{project:d}=I(),f=l??(u&&!d?.readOnly&&n!==`new`?{icon:vt,label:R(`home.new`),run:()=>s(`/new`)}:null);Jm(c,r,()=>i(!1));let{pathname:p}=tt();(0,z.useEffect)(()=>i(!1),[p]);let m=e=>!r&&n===e,h=r?2:n===`home`||n===`new`?0:n===`space`?1:n===`results`||n===`settings`?2:null,g=e=>{i(!1),s(e)},_=e=>P(`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-[0.9375rem] transition`,e?`bg-accent text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`);return(0,B.jsxs)(`div`,{className:`fixed inset-x-0 bottom-[calc(0.5rem+env(safe-area-inset-bottom))] z-40 flex select-none justify-center gap-2.5 [-webkit-touch-callout:none]`,children:[(0,B.jsxs)(`nav`,{ref:c,"aria-label":Kt.name,className:`liquid-glass relative flex gap-1 rounded-full p-1`,children:[(0,B.jsx)(Bc,{index:h}),(0,B.jsx)(ce,{to:`/`,"aria-label":R(`nav.home`),"aria-current":n===`home`?`page`:void 0,onClick:()=>i(!1),className:Rc(m(`home`)),children:(0,B.jsx)(Tr,{className:`size-[1.375rem]`})}),(0,B.jsx)(ce,{to:`/space`,"aria-label":R(`nav.sources`),"aria-current":n===`space`?`page`:void 0,onClick:()=>i(!1),className:Rc(m(`space`)),children:(0,B.jsx)(Lr,{className:`size-[1.375rem]`})}),(0,B.jsx)(`button`,{type:`button`,"aria-label":R(`nav.more`),"aria-expanded":r,"aria-haspopup":`menu`,onClick:()=>i(e=>!e),className:Rc(r||n===`results`||n===`settings`),children:(0,B.jsx)(dr,{className:`size-[1.375rem]`})}),r?(0,B.jsxs)(`div`,{role:`menu`,className:`absolute right-0 bottom-full mb-3 flex w-60 animate-rise flex-col rounded-2xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:_(n===`results`),onClick:()=>g(`/space/results`),children:[(0,B.jsx)(kr,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R(`space.results`)})]}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:_(n===`settings`),onClick:()=>g(`/settings`),children:[(0,B.jsx)(ji,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R(`nav.settings`)})]}),t.nav.map(e=>(0,B.jsx)(Wh,{of:e,children:(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:_(!1),onClick:()=>g(e.to),children:[(0,B.jsx)(e.icon,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label()})]})},e.serial)),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:_(!1),onClick:()=>{i(!1),o(!0)},children:[(0,B.jsx)(jr,{className:`size-[1.125rem] shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R(`about.nav`)})]})]}):null,a?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(kc,{open:!0,me:e,onClose:()=>o(!1)})}):null]}),f?(0,B.jsx)(`button`,{type:`button`,"aria-label":f.label,title:f.label,onClick:f.run,className:`liquid-glass glass-press relative grid size-14 shrink-0 place-items-center rounded-full text-ink`,children:(0,B.jsx)(f.icon,{className:`size-6`})}):null]})}var Hc=yn({route:Cn().max(400),title:Cn().max(200).optional(),view:Cn().max(200).optional(),open:yn({kind:Cn().max(60),id:Cn().max(120).optional(),label:Cn().max(200)}).optional(),selection:xn(Cn().max(120)).max(100).optional(),summary:Cn().max(2e3).optional(),fields:xn(yn({id:Cn().max(120),label:Cn().max(200),value:hn()})).max(60).optional(),plugin:Cn().max(60).optional()}),Uc=yn({name:Cn().regex(/^[a-z][a-z0-9_]{1,62}$/),description:Cn().max(2e3),parameters:mn(Cn(),hn())});yn({message:Cn().min(1).max(8e3),projectId:Cn().max(80).optional(),page:Hc.optional(),tools:xn(Uc).max(40).default([]),debug:bn().optional(),extra:bn().optional()}),yn({ref:Cn().min(1).max(40),message:Cn().min(1).max(8e3)});var Wc={initial:400,min:320,max:720},Gc=`wz.readAloud`,Kc=typeof window<`u`&&`speechSynthesis`in window&&`SpeechSynthesisUtterance`in window;function qc(){try{return localStorage.getItem(Gc)===`1`}catch{return!1}}function Jc(e){try{localStorage.setItem(Gc,e?`1`:`0`)}catch{}}function Yc(e){let t=window.speechSynthesis.getVoices(),n=e.slice(0,2);return t.find(t=>t.lang===e&&t.default)??t.find(t=>t.lang===e)??t.find(e=>e.lang.startsWith(n)&&e.default)??t.find(e=>e.lang.startsWith(n))??null}function Xc(e,t=L,n=!1){if(!Kc||!e.trim())return;let r=window.speechSynthesis;n&&r.cancel();let i=_n(t),a=new SpeechSynthesisUtterance(e.trim().slice(0,2e3));a.lang=i;let o=Yc(i);o&&(a.voice=o),r.speak(a)}function Zc(e,t=L){if(!Kc||!e.trim())return Promise.resolve();let n=window.speechSynthesis;n.cancel();let r=_n(t),i=new SpeechSynthesisUtterance(e.trim().slice(0,4e3));i.lang=r;let a=Yc(r);return a&&(i.voice=a),new Promise(e=>{i.onend=()=>e(),i.onerror=()=>e(),n.speak(i)})}function Qc(e){return e.replace(/```[\s\S]*?```/g,``).replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/https?:\/\/\S+/g,``).replace(/^#+\s*/gm,``).replace(/^\s*[-*]\s+/gm,``).replace(/[*_`>|]/g,``).replace(/\n{2,}/g,`. `).replace(/\s+/g,` `).trim()}function $c(){Kc&&window.speechSynthesis.cancel()}function el(){let[e,t]=(0,z.useState)(()=>Kc&&qc()),n=(0,z.useCallback)(e=>{t(e),Jc(e),e||$c()},[]);return(0,z.useEffect)(()=>{Kc&&window.speechSynthesis.getVoices()},[]),(0,z.useEffect)(()=>()=>$c(),[]),[e,n]}function tl(e,t,n,r){let i=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!e){i.current=null;return}let a=n.map(e=>e.key);if(!i.current){i.current=new Set(a);let e=[...n].reverse().find(e=>e.who===`bot`&&e.spoken!==!1);if(e){let n=r(e.key);n&&Xc(n,t,!0)}return}let o=n.filter(e=>!i.current?.has(e.key));for(let e of a)i.current.add(e);o.some(e=>e.who===`me`)&&$c();for(let e of o)if(e.who===`bot`&&e.spoken!==!1){let n=r(e.key);n&&Xc(n,t)}},[e,t,n,r])}var nl=/\.(png|jpe?g|gif|webp|avif|svg)$/i;function rl(e){let t=e.filter(e=>e.type.startsWith(`image/`));return t.length?Object.fromEntries(t.map(e=>[e.name,URL.createObjectURL(e)])):void 0}function il(e){let t=e.match(/(?:^|\n\n)(?:Angehängt|Attached): ([^\n]+)$/);return t?{text:e.slice(0,t.index).trim(),names:t[1].split(`, `).filter(Boolean)}:{text:e,names:[]}}function al({names:e,previews:t,fileUrl:n}){let r=e.filter(e=>t?.[e]||n&&nl.test(e)),i=e.filter(e=>!r.includes(e));return(0,B.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5`,children:[r.map(e=>{let r=t?.[e]??n?.(e)??``;return(0,B.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,title:e,children:(0,B.jsx)(`img`,{src:r,alt:e,className:`max-h-60 w-auto max-w-full rounded-xl bg-paper-2 object-contain ring-1 ring-border`})},e)}),i.length?(0,B.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:i.map(e=>(0,B.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 px-2.5 py-1 text-[0.75rem] text-ink-2`,children:[(0,B.jsx)(d,{className:`size-3 shrink-0 text-ink-4`}),(0,B.jsx)(`span`,{className:`truncate`,children:e})]},e))}):null]})}function ol(e,t){let n=D(),[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)(`idle`),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(!0),_=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(e){if(_.current!==e.id){_.current=e.id,i(e.messages);return}a===`idle`&&i(t=>e.messages.length>=t.length?e.messages:t)}},[e,a]),{messages:r,phase:a,activity:l,thought:d,startedAt:p,error:s,send:async(r,s=[])=>{if(!e||!(r.trim()||s.length)||a!==`idle`)return!1;if(c(null),m(Date.now()),f(null),s.length){o(`thinking`);try{for(let t of s){let n=await fetch(Je(`/api/studio/wizards/${e.id}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`,"accept-language":L},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}}catch(t){return c(t.message),o(`idle`),m(null),await n.invalidateQueries({queryKey:O.wizard(e.id)}),!1}let t=`${R(`editor.attached`)}: ${s.map(e=>e.name).join(`, `)}`;r=r.trim()?`${r}\n\n${t}`:t}let l=`p-${Date.now()}`;i(e=>[...e,{id:`u-${Date.now()}`,role:`user`,content:r,previews:rl(s)},{id:l,role:`assistant`,content:``,pending:!0}]),o(`thinking`),u(null);let d=!1;try{await te(`/api/studio/wizards/${e.id}/chat`,{message:r,extra:h},(e,n)=>{if(e===`text`){let e=JSON.parse(n);i(t=>t.map(t=>t.id===l?{...t,content:t.content+e}:t))}else if(e===`activity`)u(JSON.parse(n));else if(e===`thought`)f(JSON.parse(n));else if(e===`building`)o(`building`);else if(e===`done`){d=!0;let e=JSON.parse(n);i(t=>t.map(t=>t.id===l?{...t,content:e.reply,changed:e.changed,pending:!1}:t)),e.changed&&t(e.draft,e.revision)}else e===`error`&&(d=!0,c(JSON.parse(n).message))}),d||c(R(`editor.chatBroken`))}catch(e){c(e.message)}finally{u(null),f(null),m(null),i(e=>e.filter(e=>!(e.id===l&&!e.content)).map(e=>({...e,pending:!1}))),o(`idle`),await n.invalidateQueries({queryKey:O.wizard(e.id)}),await n.invalidateQueries({queryKey:[`me`]})}return!0},fileUrl:t=>Je(`/api/studio/wizards/${e?.id}/files/${encodeURIComponent(t)}`),extra:h,setExtra:g}}function sl(e){let[t,n]=(0,z.useState)(()=>Date.now());return(0,z.useEffect)(()=>{if(e===null)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e===null?null:Math.max(0,Math.floor((t-e)/1e3))}function cl(e){return e<60?`${e} s`:`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)} min`}function ll({chat:e,thought:t,className:n,spinner:r=`size-3.5`}){let i=sl(e.startedAt);return(0,B.jsxs)(`div`,{className:P(`min-w-0`,n),children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(st,{className:P(`shrink-0`,r)}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:e.activity??(e.phase===`building`?R(`editor.building`):R(`editor.thinking`))}),i===null?null:(0,B.jsx)(`span`,{className:`shrink-0 text-ink-4 tabular-nums`,children:cl(i)})]}),t&&e.thought?(0,B.jsx)(`p`,{className:`mt-0.5 truncate pl-5.5 text-[0.75rem] text-ink-4`,children:e.thought}):null]})}function ul({message:e,fileUrl:t}){let{text:n,names:r}=il(e.content);return(0,B.jsxs)(`div`,{className:`ml-8 flex flex-col items-end gap-1.5 self-end`,children:[e.signal?(0,B.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4`,children:R(`assistant.signalled`)}):null,r.length?(0,B.jsx)(al,{names:r,previews:e.previews,fileUrl:t}):null,n?(0,B.jsx)(`div`,{className:`rounded-xl rounded-br-md bg-paper-2 px-4 py-2.5 text-[0.875rem] leading-relaxed`,children:(0,B.jsx)(`span`,{className:`whitespace-pre-wrap`,children:n})}):null]})}function dl({chat:e,avatar:t,costume:n,changedLabel:r,card:i,calls:a,foot:o}){return(0,B.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.messages.map(s=>s.role===`user`?(0,B.jsx)(ul,{message:s,fileUrl:e.fileUrl},s.id):(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`div`,{className:`shrink-0`,children:(0,B.jsx)(sn,{kind:t,costume:n,size:28,interactive:!1})}),(0,B.jsxs)(`div`,{className:`min-w-0 pt-0.5 text-[0.875rem]`,children:[s.source===`mcp`?(0,B.jsxs)(`div`,{className:`mb-1 inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,B.jsx)(Rt,{className:`size-3`}),` `,R(`editor.viaClient`,{client:s.client??`MCP`})]}):null,a?a(s):null,s.content?(0,B.jsx)(bt,{text:s.content,className:`text-[0.875rem]`}):null,i&&s.cards?.length?(0,B.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:s.cards.map(e=>(0,B.jsx)(z.Fragment,{children:i(e)},e.id))}):null,s.pending?(0,B.jsx)(ll,{chat:e,thought:!0,className:`mt-1 text-[0.8125rem] text-ink-3`}):null,s.changed?(0,B.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-full bg-ember-tint px-2.5 py-0.5 text-[0.75rem] text-ember-strong`,children:[(0,B.jsx)(Ye,{className:`size-3`}),` `,r]}):null,o?o(s):null]})]},s.id))})}var fl=`wizards.editorThread.height`,pl=320,ml=120,hl=()=>Math.max(ml,window.innerHeight-260);function gl(){let[e,t]=(0,z.useState)(()=>{try{let e=Number(localStorage.getItem(fl));return e?Math.min(Math.max(e,ml),hl()):pl}catch{return pl}});return{height:e,set:e=>{let n=Math.round(Math.min(Math.max(e,ml),hl()));t(n);try{localStorage.setItem(fl,String(n))}catch{}}}}function _l({open:e,height:t,onHeight:n,onToggle:r}){let i=(0,z.useRef)(null);return(0,B.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`horizontal`,"aria-valuenow":t,"aria-valuemin":ml,"aria-label":R(`editor.threadGrip`),title:R(`editor.threadGrip`),onPointerDown:n=>{n.button===0&&(n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId),i.current={y:n.clientY,height:e?t:0,moved:!1})},onPointerMove:t=>{let a=i.current;!a||!a.moved&&Math.abs(t.clientY-a.y)<4||!(e||a.moved)&&t.clientY>a.y||(e||a.moved||r(!0),a.moved=!0,n(a.height+(a.y-t.clientY)))},onPointerUp:()=>{let t=i.current&&!i.current.moved;i.current=null,t&&r(!e)},onPointerCancel:()=>{i.current=null},onKeyDown:i=>{if(i.key===`ArrowUp`||i.key===`ArrowDown`){if(i.preventDefault(),!e){i.key===`ArrowUp`&&r(!0);return}n(t+(i.key===`ArrowUp`?32:-32))}else(i.key===`Enter`||i.key===` `)&&(i.preventDefault(),r(!e))},className:`group flex h-3.5 shrink-0 cursor-row-resize touch-none items-center justify-center outline-none`,children:(0,B.jsx)(`span`,{className:`h-1 w-10 rounded-full bg-ink-4/40 transition group-hover:bg-ink-4 group-focus-visible:bg-ember`})})}function vl({chat:e,avatar:t,costume:n,hello:r=R(`editor.chatHello`),placeholder:i=R(`editor.composer`),changedLabel:a=R(`editor.flowChanged`),compact:o,intro:s,closed:c,card:l,foldOn:u}){let[f,p]=(0,z.useState)(!1);(0,z.useEffect)(()=>{u&&p(!1)},[u]);let m=gl(),h=(0,z.useRef)(null),g=(0,z.useRef)(null);(0,z.useEffect)(()=>{h.current?.scrollTo({top:h.current.scrollHeight,behavior:`smooth`})},[e.messages,e.phase]);let _=!o||f,v=e.messages.at(-1),[y,x]=(0,z.useState)(!1),S=(0,z.useRef)(0),C=e=>!c&&e.dataTransfer.types.includes(`Files`);return(0,B.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,onDragEnter:e=>{C(e)&&(e.preventDefault(),S.current+=1,x(!0))},onDragOver:e=>{C(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:()=>{S.current=Math.max(0,S.current-1),S.current===0&&x(!1)},onDrop:e=>{C(e)&&(e.preventDefault(),S.current=0,x(!1),g.current?.add(Array.from(e.dataTransfer.files).map(rt)),g.current?.focus())},children:[y?(0,B.jsxs)(`div`,{className:`pointer-events-none absolute inset-3 z-20 flex flex-col items-center justify-center gap-2 rounded-2xl border-2 border-ember border-dashed bg-ember-veil text-[0.875rem] text-ember-strong`,children:[(0,B.jsx)(d,{className:`size-6`}),R(`editor.dropToAttach`)]}):null,(0,B.jsxs)(`div`,{className:o?P(`mb-2 flex min-h-0 flex-col overflow-hidden rounded-2xl bg-card shadow-overlay ring-1 ring-border`,!(v||e.error)&&`hidden`):`contents`,children:[o&&(v||e.error)?(0,B.jsx)(_l,{open:f,height:m.height,onHeight:m.set,onToggle:p}):null,o&&(v||e.error)?(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":f,"aria-label":R(`editor.thread`),onClick:()=>p(e=>!e),className:`flex items-center gap-2 px-4 pb-0.5 text-left text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[!(e.error||f)&&v?.pending?(0,B.jsx)(ll,{chat:e,className:`flex-1`}):(0,B.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate`,e.error&&`text-rose`),children:e.error??(f?R(`editor.thread`):v?.content)}),f?(0,B.jsx)(b,{className:`size-4 shrink-0`}):(0,B.jsx)(Zn,{className:`size-4 shrink-0`})]}):null,(0,B.jsxs)(`div`,{ref:h,className:P(`min-h-0 flex-1 overflow-y-auto px-5 py-5`,!_&&`hidden`),style:o?{height:m.height,flex:`none`}:void 0,children:[e.messages.length===0&&!c?s??(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(sn,{kind:t,costume:n,size:32,interactive:!1}),(0,B.jsx)(`p`,{className:`pt-1 text-[0.875rem] text-ink-2 leading-relaxed`,children:r})]}):null,(0,B.jsx)(dl,{chat:e,avatar:t,costume:n,changedLabel:a,card:l}),e.error?(0,B.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-3 py-2 text-[0.8125rem] text-rose`,children:e.error}):null]})]}),c?(0,B.jsx)(`p`,{className:`m-3 rounded-xl bg-paper-2 px-4 py-3 text-[0.8125rem] text-ink-2 leading-relaxed`,children:c}):(0,B.jsx)($e,{ref:g,floating:o,className:o?void 0:`p-3`,placeholder:i,disabled:e.phase!==`idle`,onSend:(t,n)=>e.send(t,n),effort:e.setExtra?{on:!!e.extra,onChange:e.setExtra}:void 0})]})}var yl=O.cloudSync();function bl(e){return e?.mode===`local`&&!!e.account&&na(e.features,`twoWaySync`)}function xl(){let e=Yt(),t=bl(e.data),n=na(e.data?.features??{},`liveChanges`);return at({queryKey:yl,queryFn:()=>_.get(`/api/studio/sync`),enabled:t,refetchInterval:t?n?12e4:2e4:!1})}function Sl(e){let t=D(),n=na(Yt().data?.features??{},`liveChanges`);return Pt({mutationFn:e,onSuccess:e=>{e&&typeof e==`object`&&`spaces`in e?t.setQueryData(yl,e):t.invalidateQueries({queryKey:yl}),!n&&(t.invalidateQueries({queryKey:[`wizard`]}),t.invalidateQueries({queryKey:[`space-page`]}),t.invalidateQueries({queryKey:[`space-table`]}))}})}var Cl=e=>new Date(e).toLocaleString(L===`de`?`de-AT`:`en-GB`,{day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`}),wl={update_here:`cloudSync.error.updateHere`,update_cloud:`cloudSync.error.updateCloud`,unreachable:`cloudSync.error.unreachable`,signed_out:`cloudSync.error.signedOut`,refused:`cloudSync.error.refused`};function Tl(e){let t=e.reason?wl[e.reason]:void 0;return t?R(t):e.message}var El={space:`cloudSync.kind.space`,wizard:`cloudSync.kind.wizard`,translation:`cloudSync.kind.translation`,message:`cloudSync.kind.message`,page:`cloudSync.kind.page`,table:`cloudSync.kind.table`,row:`cloudSync.kind.row`,category:`cloudSync.kind.category`,file:`cloudSync.kind.file`,connector:`cloudSync.kind.connector`},Dl={title:`cloudSync.word.title`,markdown:`cloudSync.word.text`,description:`cloudSync.word.description`,steps:`cloudSync.word.steps`,fields:`cloudSync.word.fields`,instructions:`cloudSync.word.instructions`,prompt:`cloudSync.word.prompt`,label:`cloudSync.word.label`,cells:`cloudSync.word.cells`,columns:`cloudSync.word.columns`,name:`cloudSync.word.name`,brand:`cloudSync.word.brand`,facts:`cloudSync.word.facts`,themes:`cloudSync.word.themes`,files:`cloudSync.word.files`,options:`cloudSync.word.options`,categories:`cloudSync.word.categories`,values:`cloudSync.word.values`,texts:`cloudSync.word.texts`,page:`cloudSync.word.page`};function Ol(e){return e.split(` › `).map(e=>e.startsWith(`“`)||!Dl[e]?e:R(Dl[e])).join(` › `)}var kl=new Map,Al=new Set;function jl(e){(0,z.useEffect)(()=>{if(e){kl.set(e,(kl.get(e)??0)+1);for(let e of Al)e();return()=>{kl.set(e,(kl.get(e)??1)-1),kl.get(e)||kl.delete(e);for(let e of Al)e()}}},[e])}function Ml(){let[,e]=(0,z.useState)(0);return(0,z.useEffect)(()=>{let t=()=>e(e=>e+1);return Al.add(t),()=>{Al.delete(t)}},[]),[...kl.keys()]}function Nl(){let e=xl(),t=Sl(()=>_.post(`/api/studio/sync/now`,{})),n=Sl(e=>_.put(`/api/studio/sync/spaces/${e.id}`,{on:e.on})),r=e.data;return r?(0,B.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,B.jsx)(_t,{title:R(`cloudSync.title`),hint:R(`cloudSync.hint`),action:(0,B.jsxs)(k,{variant:`secondary`,size:`sm`,busy:t.isPending,onClick:()=>t.mutate(void 0),children:[(0,B.jsx)(ve,{className:`size-3.5`}),` `,R(`cloudSync.now`)]}),children:(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:r.spaces.map(e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-4 py-3 first:pt-0 last:pb-0`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:e.name}),(0,B.jsx)(Pl,{space:e,refusals:r.refusals[e.spaceId]})]}),e.organization?null:(0,B.jsx)(et,{checked:e.on,label:R(`cloudSync.spaceOn`),disabled:n.isPending,onChange:t=>n.mutate({id:e.spaceId,on:t})})]},e.spaceId))})}),r.conflicts.length?(0,B.jsx)(Fl,{view:r}):null,r.merges.length?(0,B.jsx)(Rl,{merges:r.merges}):null]}):e.isLoading?(0,B.jsx)(st,{className:`size-5`}):null}function Pl({space:e,refusals:t}){let n=`mt-0.5 text-[0.8125rem] text-ink-3`;return e.organization?(0,B.jsx)(`p`,{className:n,children:R(`cloudSync.state.otherOrganization`,{name:e.organization})}):e.on?(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:[e.error?(0,B.jsxs)(`p`,{className:`text-[0.8125rem] text-rose`,children:[Tl(e.error),e.error.reason===`refused`&&t?.length?` ${t.join(` · `)}`:``]}):e.waiting?(0,B.jsx)(T,{tone:`warn`,children:R(`cloudSync.state.waiting`,{count:e.waiting})}):e.conflicts?null:(0,B.jsx)(T,{tone:`live`,children:R(`cloudSync.state.ok`)}),e.conflicts?(0,B.jsx)(T,{tone:`ember`,children:R(`cloudSync.state.conflicts`,{count:e.conflicts})}):null,e.syncedAt?(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:R(`cloudSync.state.at`,{when:Cl(e.syncedAt)})}):null]}):(0,B.jsx)(`p`,{className:n,children:R(e.here?`cloudSync.state.hereOnly`:`cloudSync.state.cloudOnly`)})}function Fl({view:e}){let t=Sl(e=>_.post(`/api/studio/sync/spaces/${e}/keep-cloud`,{})),n=[...new Set(e.conflicts.map(e=>e.spaceId))];return(0,B.jsx)(_t,{title:R(`cloudSync.conflicts`),hint:R(`cloudSync.conflictsHint`),action:e.conflicts.length>1&&n.length===1?(0,B.jsx)(k,{variant:`secondary`,size:`sm`,busy:t.isPending,onClick:()=>t.mutate(n[0]),children:R(`cloudSync.keepCloudAll`)}):null,children:(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:e.conflicts.map(e=>(0,B.jsx)(`li`,{className:`py-4 first:pt-0 last:pb-0`,children:(0,B.jsx)(Ll,{conflict:e})},e.id))})})}var Il=e=>e===void 0?R(`cloudSync.removed`):typeof e==`string`?e:JSON.stringify(e,null,1);function Ll({conflict:e}){let[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(()=>e.conflicts.map(()=>`local`)),[a,o]=(0,z.useState)(null),s=Sl(t=>_.post(`/api/studio/sync/conflicts/${e.id}/resolve`,t)),c=Pt({mutationFn:()=>_.post(`/api/studio/sync/conflicts/${e.id}/propose`,{}),onSuccess:e=>o(e.record)}),l=e.deleted===`remote`?R(`cloudSync.conflict.deletedRemote`):e.deleted===`local`?R(`cloudSync.conflict.deletedLocal`):R(`cloudSync.conflict.both`);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`p`,{className:`font-medium text-[0.9375rem]`,children:[(0,B.jsxs)(`span`,{className:`text-ink-3`,children:[R(El[e.kind]),` · `]}),e.title]}),(0,B.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:l})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(k,{size:`sm`,variant:`secondary`,busy:s.isPending,onClick:()=>s.mutate({take:`remote`}),children:R(`cloudSync.keepCloud`)}),(0,B.jsx)(k,{size:`sm`,variant:`secondary`,busy:s.isPending,onClick:()=>s.mutate({take:`local`}),children:R(`cloudSync.keepLocal`)}),e.conflicts.length?(0,B.jsx)(k,{size:`sm`,variant:`ghost`,onClick:()=>n(e=>!e),children:R(`cloudSync.pick`)}):null,e.deleted?null:(0,B.jsx)(k,{size:`sm`,variant:`ghost`,busy:c.isPending,onClick:()=>c.mutate(),children:R(`cloudSync.ai`)})]}),t?(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-paper-2 p-3`,children:[e.conflicts.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,B.jsx)(`p`,{className:`font-medium text-[0.8125rem]`,children:Ol(e.label)}),[`local`,`remote`].map(n=>(0,B.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[0.8125rem]`,children:[(0,B.jsx)(`input`,{type:`radio`,className:`mt-1`,checked:r[t]===n,onChange:()=>i(e=>e.map((e,r)=>r===t?n:e))}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsxs)(`span`,{className:`text-ink-3`,children:[R(n===`local`?`cloudSync.here`:`cloudSync.cloud`),`:`,` `]}),(0,B.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:Il(e[n])})]})]},n))]},e.label)),(0,B.jsx)(`div`,{children:(0,B.jsx)(k,{size:`sm`,busy:s.isPending,onClick:()=>s.mutate({choices:r.map(e=>({take:e}))}),children:R(`cloudSync.apply`)})})]}):null,c.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:R(`cloudSync.aiFailed`,{error:c.error.message})}):null,a?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-paper-2 p-3`,children:[(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:R(`cloudSync.aiProposal`)}),(0,B.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-[0.75rem] text-ink-2`,children:JSON.stringify(a,null,2)}),(0,B.jsx)(`div`,{children:(0,B.jsx)(k,{size:`sm`,busy:s.isPending,onClick:()=>s.mutate({record:a}),children:R(`cloudSync.aiTake`)})})]}):null,s.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:s.error.message}):null]})}function Rl({merges:e}){return(0,B.jsx)(_t,{title:R(`cloudSync.merges`),hint:R(`cloudSync.mergesHint`),children:(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:e.map(e=>(0,B.jsx)(`li`,{className:`py-4 first:pt-0 last:pb-0`,children:(0,B.jsx)(zl,{merge:e})},e.id))})})}function zl({merge:e,compact:t}){let n=Sl(()=>_.post(`/api/studio/sync/merges/seen`,{ids:[e.id]})),r=Sl(t=>_.post(`/api/studio/sync/merges/${e.id}/undo`,{take:t}));return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`text-[0.8125rem]`,children:[(0,B.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:t?R(`cloudSync.merged`):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`text-ink-3`,children:[R(El[e.kind]),` · `]}),e.title]})}),e.local.length?(0,B.jsx)(`p`,{className:`mt-0.5 text-ink-3`,children:R(`cloudSync.mergedHere`,{places:e.local.map(Ol).join(`, `)})}):null,e.remote.length?(0,B.jsx)(`p`,{className:`mt-0.5 text-ink-3`,children:R(`cloudSync.mergedThere`,{places:e.remote.map(Ol).join(`, `)})}):null]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(k,{size:`sm`,variant:`secondary`,busy:n.isPending,onClick:()=>n.mutate(void 0),children:R(`cloudSync.ok`)}),(0,B.jsx)(k,{size:`sm`,variant:`ghost`,busy:r.isPending,onClick:()=>r.mutate(`local`),children:R(`cloudSync.undoLocal`)}),(0,B.jsx)(k,{size:`sm`,variant:`ghost`,busy:r.isPending,onClick:()=>r.mutate(`remote`),children:R(`cloudSync.undoRemote`)})]})]})}function Bl({kind:e,item:t}){let n=xl(),r=n.data?.conflicts.find(n=>n.kind===e&&n.item===t),i=n.data?.merges.find(n=>n.kind===e&&n.item===t);return jl(r?r.id:null),r?(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-border-soft border-b bg-amber-tint px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,B.jsx)(tr,{className:`size-4 shrink-0 text-amber`}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1`,children:R(`cloudSync.conflict.both`)}),(0,B.jsx)(ce,{to:`/settings/cloud`,className:`shrink-0 underline transition hover:text-ink`,children:R(`cloudSync.settle`)})]}):i?(0,B.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-border-soft border-b bg-moss-tint px-4 py-2 sm:px-6`,children:[(0,B.jsx)(yr,{className:`mt-1 size-4 shrink-0 text-moss`}),(0,B.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,B.jsx)(zl,{merge:i,compact:!0})})]}):null}function Vl({me:e}){let t=xl(),n=Ml(),r=(t.data?.conflicts??[]).filter(e=>!n.includes(e.id)).length;return!bl(e)||!r?null:(0,B.jsxs)(`div`,{className:`flex items-center gap-3 border-border-soft border-b bg-amber-tint px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,B.jsx)(tr,{className:`size-4 shrink-0 text-amber`}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1`,children:R(`cloudSync.bar`,{count:r})}),(0,B.jsx)(ce,{to:`/settings/cloud`,className:`shrink-0 underline transition hover:text-ink`,children:R(`cloudSync.settle`)})]})}function Hl(e,t){let n=e?.mode===`managed`&&na(e.features,`organizationSettings`),r=R(`settings.groupOrganization`),i=n?R(`settings.groupStudio`):void 0,a=e=>i?{...e,group:i}:e;return[...n?[]:[{id:`account`,label:R(`account.title`),icon:Gi,menu:!0}],...n?[{id:`general`,label:R(`orgSettings.general`),icon:qn,menu:!1,group:r},{id:`members`,label:R(`orgSettings.members`),icon:qi,menu:!0,group:r},{id:`credits`,label:R(`credits.title`),icon:Ct,menu:!1,group:r},{id:`usage`,label:R(`credits.usage`),icon:St,menu:!1,group:r},{id:`invoices`,label:R(`credits.invoices`),icon:Ci,menu:!1,group:r},{id:`keys`,label:R(`orgSettings.keys`),icon:Nr,menu:!1,group:r}]:e?.mode===`managed`&&na(e.features,`teamPlans`)?[{id:`organization`,label:R(`organization.title`),icon:qi,menu:!0}]:[],...bl(e)?[a({id:`cloud`,label:R(`cloudSync.title`),icon:rr,menu:!1})]:[],a({id:`connectors`,label:R(`connectors.title`),icon:Rt,menu:!0}),a({id:`models`,label:R(`local.title`),icon:sr,menu:!0}),a({id:`integrate`,label:R(`integrate.nav`),icon:Yn,menu:!0}),...t.sections.map(e=>a({id:e.id,label:e.label(),icon:e.icon,menu:e.menu??!1,plugin:e})),...t.plugins.length||t.problems.length||t.canReload&&e?.account?[a({id:`plugins`,label:R(`plugins.title`),icon:Un,menu:!1})]:[],{id:`about`,label:R(`about.nav`),icon:jr,menu:!1}]}function Ul(){return[{id:`profile`,label:R(`konto.profile`),icon:Gi,menu:!0},{id:`orgs`,label:R(`konto.organizations`),icon:qn,menu:!1},{id:`apps`,label:R(`konto.apps`),icon:Rt,menu:!1}]}var Wl=`wizards.assistant`,Gl={place:`center`,height:null,dev:!1};function Kl(){try{let e=JSON.parse(localStorage.getItem(Wl)??`null`);return{place:e?.place===`right`?`right`:`center`,height:typeof e?.height==`number`?e.height:null,dev:e?.dev===!0}}catch{return Gl}}var ql=Kl(),Jl=new Set,Yl=()=>{for(let e of Jl)e()},Xl=e=>(Jl.add(e),()=>Jl.delete(e));function Zl(e){ql={...ql,...e};try{localStorage.setItem(Wl,JSON.stringify(ql))}catch{}Yl()}function Ql(){return(0,z.useSyncExternalStore)(Xl,()=>ql)}var $l=64,eu=12,tu=null,nu=new Set;function ru(e){tu=e;for(let e of nu)e()}function iu(){return(0,z.useSyncExternalStore)(e=>(nu.add(e),()=>nu.delete(e)),()=>tu)}var au=e=>Math.min(600,e-24);function W(e,t,n){let r=au(e.width),i=e.height-eu-t;return{center:{left:(e.width-r)/2,top:i,width:r,height:t},right:e.width>=r+24+240?{left:e.width-eu-r,top:i,width:r,height:t}:null,sidebar:n?{left:e.width-400+8,top:8,width:384,height:e.height-16}:null}}var ou=e=>e>=au(e)+24+240;function su(e,t){if(e.button!==0)return;e.preventDefault();let n={x:e.clientX,y:e.clientY},r=t.frame()?.getBoundingClientRect(),i=r?{x:n.x-r.left,y:n.y-r.top}:{x:28,y:24},a=!1,o=null,s=r=>{if(r.pointerId!==e.pointerId||!a&&Math.hypot(r.clientX-n.x,r.clientY-n.y)<5)return;a||(a=!0,document.body.style.userSelect=`none`,t.onLeave?.());let s=t.column()?.getBoundingClientRect();if(!s)return;let c=t.frame()?.getBoundingClientRect(),l=au(s.width),u=c?.height??160,d=Math.min(Math.max(r.clientX-s.left-i.x,8),Math.max(8,s.width-120)),f=Math.min(Math.max(r.clientY-s.top-i.y,8),Math.max(8,s.height-u-8)),p=W(s,u,t.sidebar),m=s.height-(f+u)<$l,h=s.width-(d+l)<$l||window.innerWidth-r.clientX<$l,g;if(p.sidebar&&h&&(!m||window.innerWidth-r.clientX<$l))g=`sidebar`;else{let e=d+l/2;g=p.right&&Math.abs(e-(p.right.left+l/2))<Math.abs(e-(p.center.left+l/2))?`right`:`center`}o={left:d,top:f,width:l,zone:g,spot:p[g]??o?.spot??null},ru(o)},c=n=>{if(n.pointerId!==e.pointerId)return;window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),document.body.style.userSelect=``;let r=o;if(ru(null),!a){t.onClick?.();return}r?.zone&&t.onDrop(r.zone)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)}var cu=null,lu=new Set;function uu(e){cu=e;for(let e of lu)e()}function du(){return(0,z.useSyncExternalStore)(e=>(lu.add(e),()=>lu.delete(e)),()=>cu)}var fu=null,pu=new Set;function mu(e){fu=e;for(let e of pu)e()}function hu(){return(0,z.useSyncExternalStore)(e=>(pu.add(e),()=>pu.delete(e)),()=>fu)}var gu=1300,_u=3e3;function vu(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}var yu=typeof window<`u`&&(!!vu()||!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`);function bu(e){return e.toLowerCase().split(/[\s\-–—/]+/).map(e=>e.replace(/[^\p{L}\p{N}]/gu,``)).filter(Boolean)}function xu(e,t){let n=new Set(bu(t)),r=bu(e);return r.length<2||r.filter(e=>n.has(e)).length/r.length>=.75}function Su(e){let[t,n]=(0,z.useState)(`off`),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(0),[d,f]=(0,z.useState)(``),[p,m]=(0,z.useState)(null),h=(0,z.useRef)(`off`),g=(0,z.useRef)(!1),v=(0,z.useRef)(null),y=(0,z.useRef)(null),b=(0,z.useRef)(null),x=(0,z.useRef)(``),S=(0,z.useRef)({text:``,until:0}),C=(0,z.useRef)(``),ee=(0,z.useRef)(null),w=(0,z.useRef)(null),te=(0,z.useRef)(e);te.current=e;let T=(0,z.useRef)(p);T.current=p;let E=(0,z.useCallback)(e=>{h.current=e,n(e)},[]),ne=(0,z.useCallback)(()=>{$c(),b.current&&=(b.current.pause(),null),x.current=``},[]),re=(0,z.useCallback)(()=>{ee.current&&=(clearTimeout(ee.current),null);let e=C.current.trim();C.current=``,f(``),e&&h.current!==`off`&&(E(`thinking`),w.current=te.current.messages.at(-1)?.id??null,te.current.send(e).then(e=>{!e&&h.current===`thinking`&&E(`listening`)}))},[E]),D=(0,z.useCallback)((e,t)=>{if(!(g.current||h.current===`off`||h.current===`thinking`)){if(h.current===`speaking`){if(xu(e,x.current))return;ne(),E(`listening`)}else if(Date.now()<S.current.until&&xu(e,S.current.text))return;f(e),t&&(C.current=`${C.current} ${e}`.trim(),f(C.current)),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(re,gu)}},[re,ne,E]),ie=(0,z.useCallback)(()=>{let e=vu();if(!e||v.current)return;let t=new e;t.continuous=!0,t.interimResults=!0,t.lang=un[L],t.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n];r.isFinal?D(r[0].transcript,!0):t+=r[0].transcript}t.trim()&&D(`${C.current} ${t}`.trim(),!1)},t.onerror=e=>{(e.error===`not-allowed`||e.error===`service-not-allowed`)&&c(`denied`)},t.onend=()=>{v.current=null,h.current!==`off`&&!g.current&&setTimeout(ie,200)},v.current=t;try{t.start()}catch{v.current=null}},[D]),ae=(0,z.useCallback)((e,t)=>{let n=null,r=[],i=0,a=new Uint8Array(t.fftSize),o=()=>{if(h.current===`off`){n?.stop();return}t.getByteTimeDomainData(a);let s=0;for(let e of a)s=Math.max(s,Math.abs(e-128)/128);if(s>.08&&!g.current&&h.current===`listening`){if(i=Date.now(),!n){let t=Date.now()<S.current.until?S.current.text:``;r=[],n=new MediaRecorder(e),n.ondataavailable=e=>e.data.size&&r.push(e.data),n.onstop=async()=>{let e=new File(r,`live`,{type:(n?.mimeType||`audio/webm`).split(`;`)[0]});if(n=null,e.size&&h.current!==`off`){E(`thinking`);try{let{text:n}=await _.upload(`/api/studio/transcribe`,e);if(t&&xu(n,t)){E(`listening`);return}C.current=n,re()}catch(e){c(e.message),E(`listening`)}}},n.start()}}else n&&Date.now()-i>gu&&n.stop();setTimeout(o,100)};o()},[re,E]),oe=(0,z.useCallback)(async()=>{if(h.current!==`off`)return;c(null);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch{c(`denied`);return}y.current=e,w.current=te.current.messages.at(-1)?.id??null,E(`listening`),o(Date.now());let t=new AudioContext,n=t.createAnalyser();n.fftSize=512,t.createMediaStreamSource(e).connect(n);let r=new Uint8Array(n.fftSize),i=()=>{if(h.current===`off`){t.close();return}n.getByteTimeDomainData(r);let e=0;for(let t of r)e=Math.max(e,Math.abs(t-128)/128);u(g.current?0:Math.min(1,e*3)),setTimeout(i,90)};i(),vu()?ie():ae(e,n),T.current||_.get(`/api/studio/assistant/voice`).then(({way:e})=>m({way:e,natural:e===`key`||e===`local`})).catch(()=>m({way:`none`,natural:!1}))},[ie,ae,E]),se=(0,z.useCallback)(()=>{E(`off`),o(null),f(``),u(0),C.current=``,ee.current&&clearTimeout(ee.current),v.current?.abort(),v.current=null,ne();for(let e of y.current?.getTracks()??[])e.stop();y.current=null},[ne,E]),ce=(0,z.useCallback)(()=>{let e=!g.current;g.current=e,i(e);for(let t of y.current?.getAudioTracks()??[])t.enabled=!e;e?(v.current?.abort(),v.current=null):h.current!==`off`&&ie()},[ie]),le=(0,z.useCallback)(async e=>{let t=Qc(e);if(!t){E(`listening`);return}E(`speaking`),x.current=t;let n=T.current?.natural&&T.current.way!==`none`,r=!1;if(n)try{let e=await fetch(Je(`/api/studio/assistant/speak`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t.slice(0,4e3)})});if(e.ok&&h.current===`speaking`){let t=URL.createObjectURL(await e.blob()),n=new Audio(t);b.current=n,await new Promise(e=>{n.onended=()=>e(),n.onerror=()=>e(),n.onpause=()=>e(),n.play().catch(()=>e())}),URL.revokeObjectURL(t),r=!0}}catch{}!r&&h.current===`speaking`&&await Zc(t,L),b.current=null,x.current=``,h.current===`speaking`&&(S.current={text:t,until:Date.now()+_u},C.current=``,f(``),v.current?.abort(),E(`listening`))},[E]);return(0,z.useEffect)(()=>{if(t!==`thinking`||e.phase!==`idle`)return;let n=e.messages.at(-1);n?.role===`assistant`&&n.id!==w.current&&!n.pending?(w.current=n.id,le(n.content)):e.error&&E(`listening`)},[t,e.phase,e.messages,e.error,le,E]),(0,z.useEffect)(()=>()=>se(),[se]),{state:t,muted:r,since:a,error:s,level:l,heard:d,voice:p,setNatural:e=>m(t=>t&&{...t,natural:e}),start:oe,end:se,toggleMute:ce}}var Cu=new Map,wu={},Tu=new Set;function Eu(){wu=Object.assign({},...Cu.values());for(let e of Tu)e()}function Du(){return(0,z.useSyncExternalStore)(e=>(Tu.add(e),()=>Tu.delete(e)),()=>wu)}function Ou(){for(let e of Cu.values())e.onChanged?.()}function ku(e){let t=(0,z.useId)(),n=(0,z.useRef)(e);n.current=e;let{onChanged:r,...i}=e,a=JSON.stringify(i);(0,z.useEffect)(()=>{Cu.set(t,{...JSON.parse(a),onChanged:()=>n.current.onChanged?.()}),Eu()},[t,a]),(0,z.useEffect)(()=>()=>{Cu.delete(t),Eu()},[t])}function Au(){let e=document.getElementById(ah);if(!e)return;let t=e.getBoundingClientRect().top;for(let n of e.querySelectorAll(`[data-assist-section]`)){let e=n.getBoundingClientRect();if(e.bottom>t+40&&e.top<window.innerHeight*.6)return n.dataset.assistSection||void 0}}function ju(){let{title:e,hello:t,about:n,placeholder:r,suggestions:i,compact:a,onChanged:o,...s}=wu,c=Vm().map(e=>e.label),l=window.location.pathname,u=l.startsWith(ct)?l.slice(ct.length)||`/`:l,d=Au(),f=(e,t)=>e&&e.length>t?`${e.slice(0,t-1)}…`:e;return{route:`${u}${window.location.search}`.slice(0,400),...c.length?{title:f(c.join(` / `),200)}:{},...d?{view:f(d,200)}:{},...s.open?{open:{kind:s.open.kind.slice(0,60),...s.open.id?{id:s.open.id.slice(0,120)}:{},label:f(s.open.label,200)??``}}:{},...s.selection?{selection:s.selection.slice(0,100).map(e=>e.slice(0,120))}:{},...s.summary?{summary:f(s.summary,2e3)}:{},...s.fields?{fields:s.fields.slice(0,60).map(e=>({id:e.id.slice(0,120),label:f(e.label,200)??``,value:e.value}))}:{},...s.plugin?{plugin:s.plugin}:{}}}var Mu=()=>document.getElementById(`studio-scroll`)??document.body,Nu=`[data-assist],h1,h2,h3,h4,button,a[href],input,textarea,select,[role=switch],[role=checkbox],[role=tab],[contenteditable=true]`,Pu=150,Fu=0;function Iu(e){return e.dataset.assist?e.dataset.assist:(e.dataset.assistRef||(Fu+=1,e.dataset.assistRef=`e${Fu}`),e.dataset.assistRef)}var Lu=(e,t=120)=>(e??``).replace(/\s+/g,` `).trim().slice(0,t);function Ru(e){if(e.dataset.assistLabel)return Lu(e.dataset.assistLabel);let t=e.getAttribute(`aria-label`);if(t)return Lu(t);if(e.dataset.assist&&!e.matches(`input,textarea,select,button,a`)){let t=e.querySelector(`h1,h2,h3,h4,[data-assist-section]`);if(t)return Lu(t.getAttribute(`data-assist-section`)||t.textContent)}if(e.id){let t=document.querySelector(`label[for="${CSS.escape(e.id)}"]`);if(t)return Lu(t.textContent)}let n=e.closest(`label`);if(n&&n!==e)return Lu(n.textContent);let r=e.parentElement?.querySelector(`label`);return r&&(e.matches(`input,textarea,select`)||e.getAttribute(`role`)===`switch`)?Lu(r.textContent):Lu(e.textContent||e.placeholder||e.getAttribute(`title`)||``)}function zu(e){if(e instanceof HTMLInputElement)return e.type===`password`?e.value?`••••`:``:e.type===`checkbox`||e.type===`radio`?e.checked:e.value.slice(0,300);if(e instanceof HTMLTextAreaElement)return e.value.slice(0,600);if(e instanceof HTMLSelectElement)return Lu(e.selectedOptions[0]?.textContent??e.value);let t=e.getAttribute(`role`);if(t===`switch`||t===`checkbox`)return e.getAttribute(`aria-checked`)===`true`;if(e.isContentEditable)return Lu(e.textContent,600)}function Bu(e){return e.dataset.assist&&!e.matches(`input,textarea,select,button,a`)?`area`:/^H[1-4]$/.test(e.tagName)?`heading`:e.matches(`input,textarea,select,[role=switch],[role=checkbox],[contenteditable=true]`)?`field`:e.getAttribute(`role`)===`tab`?`tab`:e.tagName===`A`?`link`:`button`}function Vu(e){if(e.closest(`[data-assistant-ui],[aria-hidden=true]`))return!1;let t=getComputedStyle(e);if(t.display===`none`||t.visibility===`hidden`)return!1;let n=e.getBoundingClientRect();return n.width>0||n.height>0}function Hu(e){let t=e.getBoundingClientRect();return t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth}function Uu(e,t){let n=[];for(let r of e.querySelectorAll(Nu)){if(n.length>=Pu)break;if(!Vu(r)||t&&!Hu(r))continue;let e=Bu(r),i=Ru(r);if(!i&&e!==`field`)continue;let a=e===`field`?zu(r):void 0,o=r.disabled||r.getAttribute(`aria-disabled`)===`true`;n.push({ref:Iu(r),kind:e,label:i,...a===void 0?{}:{value:a},...o?{disabled:!0}:{},...r.getAttribute(`aria-current`)||r.getAttribute(`aria-selected`)===`true`?{current:!0}:{}})}return n}function Wu(e){let t=Mu(),n=e.trim(),r=document.querySelector(`[data-assist="${CSS.escape(n)}"]`)??document.querySelector(`[data-assist-ref="${CSS.escape(n)}"]`)??(/^[A-Za-z][\w-]*$/.test(n)?document.getElementById(n):null);if(r)return r;let i=n.toLowerCase(),a=null;for(let e of t.querySelectorAll(Nu)){if(!Vu(e))continue;let t=Ru(e).toLowerCase();if(t===i)return e;!a&&t.includes(i)&&(a=e)}return a}var Gu=e=>({error:`Nothing on the page is "${e}". look_at_page lists what is there.`}),Ku=null,qu=0,Ju=new Set;function Yu(e){Ku=e;for(let e of Ju)e()}function Xu(){return(0,z.useSyncExternalStore)(e=>(Ju.add(e),()=>Ju.delete(e)),()=>Ku)}var Zu=null,Qu=()=>[];function $u(e,t){Zu=e,Qu=t}function ed(e){let t=e.split(/[?#]/)[0]||`/`;return Qu().some(e=>RegExp(`^${e.split(`/`).map(e=>e.startsWith(`:`)?e.endsWith(`?`)?`(?:[^/]+)?`:`[^/]+`:e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`/`)}/?$`).test(t))}var G=()=>new Promise(e=>setTimeout(e,450));function K(e){return!e.startsWith(`/`)||e.startsWith(`//`)||/^\/(api|w|s)\//.test(e)||!(Zu&&ed(e))?!1:(Zu(e),!0)}var q={type:`string`,description:`A ref or area from look_at_page, or the label`},J=new Map;function Y(){return[...J.values()].map(({name:e,description:t,parameters:n})=>({name:e,description:t,parameters:n}))}var td=[{name:`navigate`,description:`Open a page of the studio by its address (/settings/models, /space/knowledge, /space/data, a plugin's page). The chat stays open.`,parameters:{type:`object`,properties:{to:{type:`string`,description:`The studio address, starting with /`}},required:[`to`]},run:async({to:e})=>{let t=String(e??``);return t.startsWith(`/`)&&ed(t)?(Zu?.(t),await G(),{opened:t,pageTools:Y()}):{error:`The studio has no page "${t}".`,pages:Qu()}}},{name:`highlight`,description:"Point at one element: `spotlight` dims the page except it, `ring` only rings it. A small card beside it shows a title, a text and buttons; a button the person presses comes back as their next message. Scrolls it into view.",parameters:{type:`object`,properties:{target:q,mode:{type:`string`,enum:[`spotlight`,`ring`]},title:{type:`string`,maxLength:80},text:{type:`string`,maxLength:400},buttons:{type:`array`,items:{type:`string`,maxLength:40},maxItems:3,description:`Answers the person can give with one click`}},required:[`target`]},run:async({target:e,mode:t,title:n,text:r,buttons:i})=>{let a=Wu(String(e??``));return a?(a.scrollIntoView({behavior:`smooth`,block:`center`}),await G(),qu+=1,Yu({id:qu,el:a,mode:t===`ring`?`ring`:`spotlight`,title:n?String(n):void 0,text:r?String(r):void 0,buttons:Array.isArray(i)?i.map(String).slice(0,3):[]}),{shown:Ru(a)}):Gu(String(e))}},{name:`look_at_page`,description:`What is on the screen now, as a list: headings, areas, buttons, links, tabs and fields with their values, each with a ref to point at (at most 150). Not a picture.`,parameters:{type:`object`,properties:{}},run:()=>({route:window.location.pathname,scrolled:Math.round(Mu().scrollTop),items:Uu(Mu(),!0),pageTools:Y()})},{name:`read_section`,description:`Everything in one area of the page, also what is scrolled away: its elements with values, and its text.`,parameters:{type:`object`,properties:{target:q},required:[`target`]},run:({target:e})=>{let t=Wu(String(e??``));return t?{area:Ru(t),items:Uu(t,!1),text:Lu(t.innerText,4e3)}:Gu(String(e))}},{name:`fill_field`,description:`Put a value into a field of the page, as if typed: text, a choice by its label, yes/no for a switch. Not saved by you: the person checks and saves.`,parameters:{type:`object`,properties:{target:q,value:{type:[`string`,`number`,`boolean`]}},required:[`target`,`value`]},run:async({target:e,value:t})=>{let n=Wu(String(e??``));if(!n)return Gu(String(e));if(n.scrollIntoView({behavior:`smooth`,block:`center`}),n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`))n.checked!==!!t&&n.click();else if(n.getAttribute(`role`)===`switch`||n.getAttribute(`role`)===`checkbox`)n.getAttribute(`aria-checked`)===`true`!=!!t&&n.click();else if(n instanceof HTMLSelectElement){let e=[...n.options].find(e=>e.value===String(t)||Lu(e.textContent).toLowerCase()===String(t).toLowerCase());if(!e)return{error:`No such choice.`,choices:[...n.options].map(e=>Lu(e.textContent))};n.value=e.value,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}else if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){if(n.disabled||n.readOnly)return{error:`The field takes nothing here.`};let e=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(e,`value`)?.set?.call(n,String(t)),n.dispatchEvent(new Event(`input`,{bubbles:!0})),n.dispatchEvent(new Event(`change`,{bubbles:!0}))}else return{error:`That is not a field.`};return n.focus({preventScroll:!0}),{filled:Ru(n),value:zu(n)}}},{name:`page_tool`,description:`Runs a tool the page shown now offers, by its name, with its arguments: a page opened during this answer brings tools that are not among yours (navigate and look_at_page list them with their parameters).`,parameters:{type:`object`,properties:{name:{type:`string`},args:{type:`object`,description:`The tool's arguments, as its parameters say`}},required:[`name`]},run:async({name:e,args:t})=>{let n=J.get(String(e??``));return n?n.run(t??{}):{error:`The page offers no tool "${String(e)}".`,pageTools:Y()}}},{name:`scroll_to`,description:`Scroll an element of the page into view.`,parameters:{type:`object`,properties:{target:q},required:[`target`]},run:async({target:e})=>{let t=Wu(String(e??``));return t?(t.scrollIntoView({behavior:`smooth`,block:`start`}),await G(),{at:Ru(t)}):Gu(String(e))}}];function nd(e,t,n){let r=(0,z.useRef)(n);r.current=n;let i=JSON.stringify(t);(0,z.useEffect)(()=>{if(td.some(t=>t.name===e))throw Error(`"${e}" is a tool of the assistant itself.`);if(!/^[a-z][a-z0-9_]{1,62}$/.test(e))throw Error(`"${e}": a tool's name is lower case letters, digits and _.`);let{description:t,parameters:n}=JSON.parse(i);return J.set(e,{name:e,description:t,parameters:n??{type:`object`,properties:{}},run:e=>r.current(e)}),()=>{J.delete(e)}},[e,i])}function rd(){return[...td,...J.values()].map(({name:e,description:t,parameters:n})=>({name:e,description:t,parameters:n}))}async function id(e,t){let n=td.find(t=>t.name===e)??J.get(e);if(!n)return null;try{return{result:await n.run(t??{})}}catch(e){return{result:{error:e.message}}}}var ad=e=>({id:e.id,role:e.role,content:e.content,cards:e.cards.map((t,n)=>({...t,id:`${e.id}-${n}`})),toolCalls:e.toolCalls,changed:e.changed});function od(e){return e.type.startsWith(`image/`)&&/logo/i.test(e.name)?`logo`:/^(image|video|audio)\//.test(e.type)?`asset`:`document`}var sd=0,cd=e=>`${e}-${Date.now()}-${++sd}`,ld=(0,z.createContext)(null);function ud(){return(0,z.useContext)(ld)}function dd(){let e=bh(),t=Yt(),n=(0,z.useRef)([]);return n.current=[`/`,`/new`,`/edit/:id`,`/space`,`/space/:group`,`/settings`,...Hl(t.data,e).map(e=>`/settings/${e.id}`),...e.pages.map(e=>e.path)],(0,z.useCallback)(()=>n.current,[])}function fd({children:e}){let t=D(),n=Yt(),r=!!n.data,{project:i}=I(),a=Re(),o=dd();(0,z.useEffect)(()=>{$u(e=>a(e),o)},[a,o]);let s=at({queryKey:[`assistant-chat`],queryFn:()=>_.get(`/api/studio/assistant/chat`),enabled:r,staleTime:1/0}),c=at({queryKey:[`assistant-layout`],queryFn:()=>_.get(`/api/studio/assistant/layout`),enabled:r,staleTime:1/0}),[l,u]=(0,z.useState)([]),[d,f]=(0,z.useState)(`idle`),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(null),[v,y]=(0,z.useState)(null),[b,x]=(0,z.useState)(!1),[S,C]=(0,z.useState)(!1),[ee,w]=(0,z.useState)({kind:`chat`}),[T,E]=(0,z.useState)(null),[ne,re]=(0,z.useState)(void 0),[ie,ae]=(0,z.useState)([]),[oe,se]=(0,z.useState)([]),ce=(0,z.useRef)(null),le=Ql(),ue=!!n.data?.assistantDev,de=ue&&le.dev,fe=(0,z.useRef)(de);fe.current=de;let[k,pe]=(0,z.useState)(!1),A=(0,z.useRef)(k);A.current=k,(0,z.useEffect)(()=>{s.data&&ce.current!==s.data.id&&(ce.current=s.data.id,u(s.data.messages.map(ad)))},[s.data]);let me=(0,z.useCallback)(e=>{E(e),t.setQueryData([`assistant-layout`],t=>({...t,layout:e})),_.put(`/api/studio/assistant/layout`,{layout:e}).catch(()=>null)},[t]),he=(0,z.useCallback)((e,n=!0)=>{re(e),n&&(t.setQueryData([`assistant-layout`],t=>({...t,width:e})),_.put(`/api/studio/assistant/layout`,{width:e}).catch(()=>null))},[t]),ge=(0,z.useRef)(null),_e=(0,z.useCallback)(()=>(ge.current??=(async()=>{await Promise.all([t.invalidateQueries({queryKey:O.spaces()}),i?t.invalidateQueries({queryKey:O.files(i.id)}):null,i?t.invalidateQueries({queryKey:O.knowledge(i.id)}):null]),Ou(),ge.current=null})(),ge.current),[t,i]),j=(0,z.useRef)([]),M=(0,z.useCallback)(e=>{j.current=e(j.current),ae(j.current)},[]),ve=(0,z.useRef)(!1),ye=(0,z.useRef)(null),be=(0,z.useRef)(null),xe=(0,z.useRef)(()=>void 0),Se=(0,z.useRef)(new Set),N=(0,z.useCallback)(()=>{let e=ye.current?.runId;if(e)for(let t of j.current)t.way!==`signal`||Se.current.has(t.id)||(Se.current.add(t.id),_.post(`/api/studio/assistant/run/${e}/signal`,{ref:t.id,message:t.text}).catch(()=>{}))},[]),Ce=(0,z.useCallback)(async(e,t)=>{if(!t.length)return e;if(!i||i.readOnly)return m(R(`assistant.filesNeedSpace`)),null;try{for(let e of t)await _.upload(`/api/studio/projects/${i.id}/files?kind=${od(e)}`,e)}catch(e){return m(e.message),await _e(),null}await _e();let n=`${R(`editor.attached`)}: ${t.map(e=>e.name).join(`, `)}`;return e.trim()?`${e}\n\n${n}`:n},[i,_e]),we=(0,z.useCallback)(async(e,n)=>{ve.current=!0,m(null),f(`thinking`),y(Date.now()),Yu(null),w({kind:`chat`});let r=cd(`p`),a=cd(`u`);u(t=>[...t,{id:a,role:`user`,content:e,previews:n},{id:r,role:`assistant`,content:``,pending:!0}]),g(null);let o=e=>{let t=r;u(n=>n.map(n=>n.id===t?e(n):n))},s=fe.current?{id:cd(`t`),message:e,startedAt:Date.now(),endedAt:null,prompt:null,events:[]}:null;s&&se(e=>[...e,s]);let c=(e,t)=>{s&&(s.events.push({at:Date.now(),event:e,data:t}),e===`prompt`&&(s.prompt=t),se(e=>e.map(e=>e.id===s.id?{...s}:e)))},l=new AbortController,d={runId:null,abort:l,stopped:!1};ye.current=d;let p=!1;try{await te(`/api/studio/assistant/turn`,{message:e,projectId:i?.id,page:ju(),tools:rd(),lang:L,...fe.current?{debug:!0}:{},...A.current?{extra:!0}:{}},(e,t)=>{let n=JSON.parse(t);switch(c(e,n),e){case`run_started`:{let e=n;d.runId=e.runId,u(t=>t.map(t=>t.id===a?{...t,id:e.messageId}:t)),N();break}case`text`:o(e=>({...e,content:e.content+n.delta}));break;case`activity`:g(n.label);break;case`tool_call`:{let e=n;o(t=>({...t,toolCalls:[...t.toolCalls??[],e]})),id(e.toolCallName,e.args).then(t=>{t&&_.post(`/api/studio/assistant/tool/${e.toolCallId}`,{result:t.result??null}).catch(()=>null)});break}case`tool_result`:{let e=n;o(t=>({...t,toolCalls:t.toolCalls?.map(t=>t.toolCallId===e.toolCallId?{...t,result:e.content}:t)}));break}case`card`:{let e=n;o(t=>({...t,cards:[...t.cards??[],{...e,id:`${t.id}-${t.cards?.length??0}`}]}));break}case`changed`:_e();break;case`step`:o(e=>({...e,steps:[...e.steps??[],n]}));break;case`signal`:{let e=n,t=r;r=cd(`p`),M(t=>t.filter(t=>t.id!==e.ref)),u(n=>[...n.flatMap(n=>n.id===t?n.content||n.toolCalls?.length||n.cards?.length||n.steps?.length?[{...n,id:e.answerId??n.id,pending:!1}]:[]:[n]),{id:e.messageId,role:`user`,content:e.content,signal:!0},{id:r,role:`assistant`,content:``,pending:!0}]);break}case`done`:{p=!0;let e=n;o(t=>({...t,id:e.messageId,content:e.reply,changed:e.changed,pending:!1}));break}case`error`:p=!0,m(n.message)}},l.signal),p||m(R(`editor.chatBroken`))}catch(e){d.stopped||m(e.message)}finally{s&&(s.endedAt=Date.now(),se(e=>e.map(e=>e.id===s.id?{...s}:e))),ye.current=null,g(null),y(null),u(e=>e.filter(e=>!(e.pending&&!e.content&&!e.cards?.length&&!e.toolCalls?.length&&!e.steps?.length)).map(e=>({...e,pending:!1}))),f(`idle`),ve.current=!1,await ge.current,t.invalidateQueries({queryKey:[`me`]})}let h=be.current;if(be.current=null,!(h||d.stopped)){let e=j.current.filter(e=>e.way===`signal`),t=e.length?e:j.current.filter(e=>e.way===`queue`).slice(0,1);t.length&&(M(e=>e.filter(e=>!t.includes(e))),h=t.map(e=>e.text).join(`
|
|
25
25
|
|
|
26
26
|
`))}h&&xe.current(h)},[i,_e,t,N,M]);xe.current=e=>void we(e);let Te=(0,z.useCallback)(async(e,t=[],n=`signal`)=>{if(!(e.trim()||t.length))return!1;if(C(!0),!ve.current){ve.current=!0,f(`thinking`);let n=await Ce(e,t);return n===null?(ve.current=!1,f(`idle`),!1):(we(n,rl(t)),!0)}let r=await Ce(e,t);return r!==null&&(M(e=>[...e,{id:cd(`s`),text:r,way:n}]),N(),!0)},[Ce,we,N,M]),Ee=(0,z.useCallback)(()=>{let e=ye.current;e&&(e.stopped=!0,e.abort.abort())},[]),De=(0,z.useCallback)(e=>{let t=j.current.find(t=>t.id===e);t&&(M(e=>e.filter(e=>e!==t)),ye.current?(be.current=t.text,Ee()):ve.current||we(t.text))},[we,Ee,M]),Oe=(0,z.useCallback)(e=>{let t=j.current.find(t=>t.id===e);return M(e=>e.filter(e=>e!==t)),t},[M]),ke=(0,z.useCallback)(async()=>{Ee(),M(()=>[]),u([]),se([]),m(null),w({kind:`chat`}),x(!0);try{let e=await _.post(`/api/studio/assistant/chat/new`);ce.current=e.id,t.setQueryData([`assistant-chat`],e),await t.invalidateQueries({queryKey:[`assistant-chats`]})}catch(e){m(e.message)}finally{x(!1)}},[t,Ee,M]),Ae=(0,z.useCallback)((e,t)=>Te(e,t),[Te]),je=(0,z.useMemo)(()=>({messages:l,phase:d,activity:h,startedAt:v,error:p,send:Ae}),[l,d,h,v,p,Ae]),Me=Su(je),Ne=(0,z.useCallback)(e=>Zl({dev:e}),[]),Pe=(0,z.useMemo)(()=>({chat:je,ready:!!s.data,renewing:b,newChat:ke,send:Te,pending:ie,sendNow:De,takeBack:Oe,stop:Ee,extra:k,setExtra:pe,layout:T??c.data?.layout??`bottom`,setLayout:me,width:ne===void 0?c.data?.width??null:ne,setWidth:he,open:S,setOpen:C,view:ee,setView:w,live:Me,dev:{offered:ue,on:de,set:Ne,turns:oe}}),[je,s.data,b,ke,Te,ie,De,Oe,Ee,k,T,c.data,me,ne,he,S,ee,Me,ue,de,Ne,oe]);return(0,B.jsx)(ld.Provider,{value:Pe,children:e})}function pd(e){return at({queryKey:[`assistant-chats`],queryFn:()=>_.get(`/api/studio/assistant/chats`),enabled:e,refetchInterval:e=>e.state.data?.chats.some(e=>e.summarising)?2e3:!1})}function md(e){return at({queryKey:[`assistant-chat`,e],queryFn:async()=>{let t=await _.get(`/api/studio/assistant/chats/${e}`);return{...t,messages:t.messages.map(ad)}},enabled:!!e})}var hd=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),gd=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,_d=e=>e?`$${e<.01?e.toFixed(4):e.toFixed(3)}`:`$0`,vd=e=>Math.round(e/4),yd=(e,t)=>R(`assistant.tokens`,{input:hd(e),output:hd(t),total:hd(e+t)});function bd({steps:e}){return e?.length?(0,B.jsx)(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.map(e=>(0,B.jsxs)(`details`,{className:`group text-[0.75rem] text-ink-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer list-none truncate hover:text-ink-3`,children:[R(`assistant.step`,{n:e.step}),e.model,yd(e.inputTokens,e.outputTokens),gd(e.ms),e.costUsd?_d(e.costUsd):null].filter(Boolean).join(` · `)}),(0,B.jsxs)(`div`,{className:`mt-1 rounded-lg bg-paper-2 px-3 py-2 font-mono text-[0.6875rem] text-ink-3`,children:[R(`assistant.stepTools`),`: `,e.tools.length?e.tools.join(`, `):`–`,e.cachedInputTokens?` · cache ${hd(e.cachedInputTokens)}`:``]})]},e.step))}):null}function xd(e){if(typeof e!=`string`)return JSON.stringify(e,null,2)??``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Sd({calls:e}){return e?.length?(0,B.jsx)(`div`,{className:`mb-1.5 flex flex-col gap-1`,children:e.map(e=>(0,B.jsxs)(`details`,{className:`rounded-lg bg-paper-2 text-[0.75rem]`,children:[(0,B.jsxs)(`summary`,{className:`cursor-pointer px-2.5 py-1 font-mono text-ink-3 hover:text-ink`,children:[e.toolCallName,e.result===void 0?` …`:``]}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 pb-2`,children:[(0,B.jsx)(`span`,{className:`text-ink-4`,children:R(`assistant.args`)}),(0,B.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-all font-mono text-[0.6875rem] text-ink-2`,children:xd(e.args)}),e.result===void 0?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-ink-4`,children:R(`assistant.result`)}),(0,B.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-all font-mono text-[0.6875rem] text-ink-2`,children:xd(e.result)})]})]})]},e.toolCallId))}):null}function Cd(e){let t=[];for(let n of e)n.role===`user`&&!n.signal?t.push([]):n.steps?.length&&(t.length||t.push([]),t[t.length-1].push(...n.steps));let n=e=>({input:e.reduce((e,t)=>e+t.inputTokens,0),output:e.reduce((e,t)=>e+t.outputTokens,0),ms:e.reduce((e,t)=>e+t.ms,0),cost:e.reduce((e,t)=>e+t.costUsd,0),steps:e.length}),r=t.flat(),i=r.at(-1);return{last:n([...t].reverse().find(e=>e.length)??[]),thread:n(r),lastStep:i,context:i?.inputTokens??0,window:i?.window??null}}function wd({ratio:e}){let t=2*Math.PI*7;return(0,B.jsxs)(`svg`,{viewBox:`0 0 18 18`,className:`size-[18px] -rotate-90`,"aria-hidden":`true`,children:[(0,B.jsx)(`circle`,{cx:`9`,cy:`9`,r:7,fill:`none`,strokeWidth:`2.5`,className:`stroke-paper-3`}),(0,B.jsx)(`circle`,{cx:`9`,cy:`9`,r:7,fill:`none`,strokeWidth:`2.5`,strokeDasharray:`${Math.min(1,e)*t} ${t}`,strokeLinecap:`round`,className:e>.8?`stroke-rose`:`stroke-ember`})]})}function Td({messages:e,narrow:t}){let[n,r]=(0,z.useState)(!1),i=(0,z.useRef)(null);Jm(i,n,()=>r(!1));let a=Cd(e);if(!a.lastStep)return null;let o=a.window?a.context/a.window:0,s=(e,t)=>(0,B.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,B.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,B.jsx)(`span`,{className:`font-mono tabular-nums`,children:t})]});return(0,B.jsxs)(`div`,{className:`relative`,ref:i,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":n,title:R(`assistant.usage`),onClick:()=>r(e=>!e),className:`flex h-8 items-center gap-1.5 rounded-lg px-1.5 font-mono text-[0.75rem] text-ink-3 tabular-nums transition hover:bg-accent hover:text-ink`,children:[t?null:(0,B.jsxs)(`span`,{className:`whitespace-nowrap max-sm:hidden`,children:[hd(a.last.input+a.last.output),` / `,hd(a.thread.input+a.thread.output)]}),(0,B.jsx)(wd,{ratio:o})]}),n?(0,B.jsxs)(`div`,{role:`dialog`,"aria-label":R(`assistant.window`),className:`absolute top-9 right-0 z-50 flex w-72 animate-rise flex-col gap-1.5 rounded-xl bg-card p-3 text-[0.8125rem] shadow-overlay ring-1 ring-border-soft`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:R(`assistant.window`)}),(0,B.jsxs)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:[hd(a.context),` /`,` `,a.window?`${hd(a.window)} (${Math.round(o*100)}%)`:`?`]})]}),(0,B.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-paper-2`,children:(0,B.jsx)(`span`,{className:P(`block h-full rounded-full`,o>.8?`bg-rose`:`bg-ember`),style:{width:`${Math.min(100,o*100)}%`}})}),(0,B.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:a.lastStep.model}),(0,B.jsx)(`span`,{className:`mt-1 font-medium text-[0.75rem] text-ink-3`,children:R(`assistant.lastTurn`)}),s(R(`assistant.promptTokens`),hd(a.last.input)),s(R(`assistant.answerTokens`),hd(a.last.output)),s(R(`assistant.duration`),gd(a.last.ms)),s(R(`assistant.cost`),_d(a.last.cost)),(0,B.jsx)(`span`,{className:`mt-1 font-medium text-[0.75rem] text-ink-3`,children:R(`assistant.wholeChat`)}),s(R(`assistant.promptTokens`),hd(a.thread.input)),s(R(`assistant.answerTokens`),hd(a.thread.output)),s(R(`assistant.steps`),String(a.thread.steps)),s(R(`assistant.cost`),_d(a.thread.cost))]}):null]})}function Ed(e,t){return JSON.stringify({messages:e.map(({previews:e,...t})=>t),turns:t},null,2)}function Dd({messages:e,turns:t}){let[n,r]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>r(!1),1500);return()=>clearTimeout(e)},[n]),(0,B.jsx)(ge,{label:R(n?`assistant.copied`:`assistant.copyThread`),onClick:()=>void navigator.clipboard.writeText(Ed(e,t)).then(()=>r(!0)),className:`size-8`,children:n?(0,B.jsx)(fe,{className:`size-4`}):(0,B.jsx)(le,{className:`size-4`})})}function Od({prompt:e}){let t=e.history.reduce((e,t)=>e+t.chars,0),n=e.tools.reduce((e,t)=>e+t.chars,0),r=[{label:R(`assistant.system`),chars:e.system.length},{label:R(`assistant.context`),chars:e.context.length},{label:R(`assistant.history`,{n:e.history.length}),chars:t},{label:R(`assistant.tools`,{n:e.tools.length}),chars:n}],i=r.reduce((e,t)=>e+t.chars,0)||1,a=(e,t)=>(0,B.jsxs)(`details`,{className:`rounded-lg bg-paper-2`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer px-3 py-2 font-medium text-[0.8125rem]`,children:e}),(0,B.jsx)(`div`,{className:`px-3 pb-3`,children:t})]});return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 text-[0.8125rem]`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-ink-3`,children:[(0,B.jsx)(`span`,{className:`font-mono`,children:e.model}),(0,B.jsx)(`span`,{children:R(`assistant.estimate`,{tokens:hd(vd(i))})})]}),(0,B.jsx)(`div`,{className:`flex h-2 overflow-hidden rounded-full bg-paper-2`,children:r.map((e,t)=>(0,B.jsx)(`span`,{title:e.label,className:[`bg-ember`,`bg-ink-3`,`bg-ember-strong`,`bg-ink-4`][t],style:{width:`${e.chars/i*100}%`}},e.label))}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-1`,children:r.map(e=>(0,B.jsxs)(`li`,{className:`flex justify-between gap-4`,children:[(0,B.jsx)(`span`,{children:e.label}),(0,B.jsxs)(`span`,{className:`font-mono text-ink-3 tabular-nums`,children:[hd(vd(e.chars)),` · `,Math.round(e.chars/i*100),`%`]})]},e.label))}),a(R(`assistant.system`),(0,B.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap font-mono text-[0.6875rem] text-ink-2`,children:e.system})),a(R(`assistant.context`),(0,B.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap font-mono text-[0.6875rem] text-ink-2`,children:e.context})),a(R(`assistant.tools`,{n:e.tools.length}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-0.5 font-mono text-[0.6875rem]`,children:e.tools.map(e=>(0,B.jsxs)(`li`,{className:`flex justify-between gap-4`,children:[(0,B.jsx)(`span`,{children:e.name}),(0,B.jsx)(`span`,{className:`text-ink-3`,children:hd(vd(e.chars))})]},e.name))}))]})}function kd({turn:e}){let t=e.endedAt??e.events.at(-1)?.at??e.startedAt,n=Math.max(1,t-e.startedAt),r=[],i=new Map;for(let t of e.events){let e=t.data;if(t.event===`tool_call`)i.set(e.toolCallId,{name:e.toolCallName,at:t.at});else if(t.event===`tool_result`&&i.has(e.toolCallId)){let n=i.get(e.toolCallId);r.push({label:n.name,from:n.at,to:t.at,kind:`tool`})}else t.event===`step`&&r.push({label:`${R(`assistant.step`,{n:e.step})} · ${yd(e.inputTokens,e.outputTokens)}`,from:t.at-e.ms,to:t.at,kind:`step`})}return r.sort((e,t)=>e.from-t.from),(0,B.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between gap-3 text-[0.8125rem]`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.message}),(0,B.jsx)(`span`,{className:`shrink-0 text-ink-3 tabular-nums`,children:gd(n)})]}),r.map((t,r)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[0.75rem]`,children:[(0,B.jsx)(`span`,{className:`w-40 shrink-0 truncate font-mono text-ink-3`,children:t.label}),(0,B.jsx)(`span`,{className:`relative h-3 flex-1 rounded bg-paper-2`,children:(0,B.jsx)(`span`,{className:P(`absolute inset-y-0 rounded`,t.kind===`step`?`bg-ember`:`bg-ink-4`),style:{left:`${Math.max(0,t.from-e.startedAt)/n*100}%`,width:`${Math.max(1,(t.to-t.from)/n*100)}%`}})}),(0,B.jsx)(`span`,{className:`w-14 shrink-0 text-right text-ink-4 tabular-nums`,children:gd(t.to-t.from)})]},`${t.label}-${r}`))]})}function Ad({open:e,onClose:t,turns:n,messages:r}){let[i,a]=(0,z.useState)(`timeline`),o=n.at(-1);return(0,B.jsx)(Qe,{open:e,onClose:t,title:R(`assistant.turns`),wide:!0,height:`tall`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(Le,{value:i,onChange:a,options:[{id:`timeline`,label:R(`assistant.turnsTimeline`)},{id:`prompt`,label:R(`assistant.turnsPrompt`)},{id:`events`,label:R(`assistant.turnsEvents`)}]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(Dd,{messages:r,turns:n}),(0,B.jsx)(ge,{label:R(`assistant.download`),onClick:()=>{let e=n.flatMap(e=>e.events.map(t=>JSON.stringify({turn:e.id,...t}))),t=new Blob([`${e.join(`
|
|
27
27
|
`)}\n`],{type:`application/x-ndjson`}),r=document.createElement(`a`);r.href=URL.createObjectURL(t),r.download=`goose-${new Date().toISOString().slice(0,19)}.jsonl`,r.click(),setTimeout(()=>URL.revokeObjectURL(r.href),1e3)},disabled:!n.length,className:`size-8`,children:(0,B.jsx)(x,{className:`size-4`})})]})]}),n.length?i===`timeline`?(0,B.jsx)(`div`,{className:`flex flex-col gap-5`,children:n.map(e=>(0,B.jsx)(kd,{turn:e},e.id))}):i===`prompt`?o?.prompt?(0,B.jsx)(Od,{prompt:o.prompt}):(0,B.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:R(`assistant.noTurns`)}):(0,B.jsx)(`div`,{className:`flex flex-col gap-1 font-mono text-[0.6875rem]`,children:n.flatMap(e=>e.events.map((t,n)=>(0,B.jsxs)(`details`,{className:`rounded bg-paper-2`,children:[(0,B.jsxs)(`summary`,{className:`cursor-pointer px-2 py-1 text-ink-3`,children:[(0,B.jsxs)(`span`,{className:`tabular-nums`,children:[`+`,gd(t.at-e.startedAt)]}),` `,(0,B.jsx)(`span`,{className:`text-ink`,children:t.event})]}),(0,B.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-all px-2 pb-2 text-ink-2`,children:JSON.stringify(t.data,null,2)})]},`${e.id}-${n}`)))}):(0,B.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:R(`assistant.noTurns`)})]})})}var jd=(0,z.lazy)(()=>It(()=>import(`./Marketplace-CpjRqTvn.js`).then(e=>e.a).then(e=>({default:e.MarketplaceCards})),__vite__mapDeps([12,1,2,3,4,5,13,14,15,7,6]))),Md=1520,Nd=768,Pd={min:120,max:900};function Fd(){return(0,z.useSyncExternalStore)(e=>(window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)),()=>window.innerWidth)}function Id(e){let t=Fd(),n=Du(),r=t>=Md,i=t<Nd,a=e.layout;a===`sidebar`&&(!r||i)&&(a=`bottom`);let o=a===`bottom`&&!!n.compact;return o&&(a=`avatar`),{where:a,wide:r&&!i,phone:i,compact:o}}var Ld=new Set([`scroll_to`]);function Rd(e){let t=e.args??{},n={};try{n=e.result?JSON.parse(e.result):{}}catch{}let r=/^e\d+$/.test(String(t.target??``))?``:String(t.target??``),i=String(n.shown||n.filled||n.area||r);switch(e.toolCallName){case`navigate`:return R(`assistant.tool.navigate`,{where:String(t.to??``)});case`highlight`:return R(`assistant.tool.highlight`,{what:i});case`look_at_page`:return R(`assistant.tool.look`);case`read_section`:return R(`assistant.tool.read`,{what:i});case`fill_field`:return R(`assistant.tool.fill`,{what:i});case`docs_search`:case`docs_read`:case`authoring_guide`:return R(`assistant.tool.docs`);case`gallery_search`:case`gallery_detail`:case`show_templates`:return R(`assistant.tool.gallery`);case`plans`:case`account`:case`usage`:return R(`assistant.tool.account`);case`chats_search`:case`chat_read`:return R(`assistant.tool.chats`);case`wizards`:case`runs`:return R(`assistant.tool.space`);case`models`:return R(`assistant.tool.models`);default:return null}}function zd({calls:e}){let t=[...new Set((e??[]).filter(e=>!Ld.has(e.toolCallName)).map(Rd).filter(e=>!!e))];return t.length?(0,B.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:t.map(e=>(0,B.jsx)(`span`,{className:`inline-flex max-w-full items-center rounded-full bg-paper-2 px-2.5 py-0.5 text-[0.75rem] text-ink-3`,children:(0,B.jsx)(`span`,{className:`truncate`,children:e})},e))}):null}function Bd({card:e,send:t}){if(!e.plugin&&e.tool===`extraEffort`)return(0,B.jsx)(Vd,{reason:String(e.data.reason??``)});if(!e.plugin&&e.tool===`templates`){let{entries:t}=e.data;return(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(st,{className:`m-2 size-4`}),children:(0,B.jsx)(jd,{entries:t})})}return(0,B.jsx)(Hd,{card:e,send:t})}function Vd({reason:e}){let t=ud(),[n,r]=(0,z.useState)(!1);return!t||n?null:(0,B.jsxs)(`div`,{className:`my-2 flex flex-col gap-2 rounded-xl bg-amber/10 p-3 text-[0.8125rem] ring-1 ring-amber/30`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`font-medium`,children:R(`assistant.extraTitle`)}),` `,(0,B.jsx)(`span`,{className:`text-ink-2`,children:e})]}),t.extra?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-ink-2`,children:[(0,B.jsx)(fe,{className:`size-3.5 text-moss`,strokeWidth:3}),` `,R(`assistant.extraOn`)]}):(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>t.setExtra(!0),className:`inline-flex h-8 items-center rounded-full bg-primary px-3 font-medium text-primary-foreground text-[0.8125rem]`,children:R(`assistant.extraOnButton`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`inline-flex h-8 items-center rounded-full px-3 text-ink-2 ring-1 ring-border hover:bg-paper-2`,children:R(`assistant.extraNo`)})]})]})}function Hd({card:e,send:t}){let n=bh().cards.find(t=>t.plugin===e.plugin&&t.tool===e.tool);return n?(0,B.jsx)(Wh,{of:n,children:(0,B.jsx)(n.component,{data:e.data,send:t})}):null}function Ud(){return[{label:R(`assistant.suggest.what`)},{label:R(`assistant.suggest.models`)},{label:R(`assistant.suggest.credits`)}]}function Wd({state:e,composer:t,top:n}){let r=Du(),i=(r.suggestions?.length?r.suggestions:Ud()).slice(0,3);return(0,B.jsxs)(`div`,{className:P(`flex flex-col`,n?`gap-5`:`gap-4`),children:[(0,B.jsxs)(`div`,{className:P(`flex items-start`,n?`gap-4`:`gap-3`),children:[(0,B.jsx)(`div`,{className:`shrink-0`,children:(0,B.jsx)(sn,{kind:`round`,size:n?64:44,helmet:!0,interactive:!1})}),(0,B.jsxs)(`div`,{className:`min-w-0 pt-0.5`,children:[(0,B.jsx)(`h2`,{className:P(`font-display font-semibold leading-tight tracking-tight`,n?`text-[1.25rem]`:`text-[1.0625rem]`),children:r.title??R(`assistant.helloTitle`)}),(0,B.jsx)(`p`,{className:P(`mt-1 text-ink-2 leading-relaxed`,n?`max-w-2xl text-[0.9375rem]`:`text-[0.875rem]`),children:r.hello??R(`assistant.hello`)}),n&&r.about?(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-[0.875rem] text-ink-3 leading-relaxed`,children:r.about}):null]})]}),(0,B.jsx)(`div`,{className:P(`flex gap-1.5`,n?`flex-wrap sm:pl-20`:`flex-col`),children:i.map(r=>(0,B.jsxs)(`button`,{type:`button`,disabled:e.chat.phase!==`idle`,onClick:()=>{let n=r.message??r.label;r.fill?t.current?.fill(n):e.chat.send(n)},className:P(`flex items-center gap-2 bg-paper-2 text-left text-[0.875rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:opacity-60`,n?`rounded-full px-3.5 py-2`:`rounded-xl px-3.5 py-2.5`),children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:r.label}),r.fill?(0,B.jsx)(Fi,{className:`size-3.5 shrink-0 text-ink-4`}):null]},r.label))})]})}function Gd({state:e}){let t=pd(!0);if(t.isLoading)return(0,B.jsx)(st,{className:`m-4 size-4`});let n=t.data?.chats??[];return n.length?(0,B.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(t=>(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.setView({kind:`read`,id:t.id}),className:`flex w-full flex-col gap-0.5 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,B.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:t.title||R(`assistant.untitled`)}),(0,B.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-4 tabular-nums`,children:new Date(t.closedAt).toLocaleDateString(L)})]}),(0,B.jsx)(`span`,{className:`line-clamp-1 text-[0.8125rem] text-ink-3`,children:t.summarising?R(`assistant.summarising`):t.summary.split(`
|
|
@@ -31,4 +31,4 @@ Error generating stack: `+e.message+`
|
|
|
31
31
|
`))t.startsWith(`event:`)?n=t.slice(6).trim():t.startsWith(`data:`)&&(r+=t.slice(5).replace(/^ /,``));t({event:n,...r?JSON.parse(r):{}}),o=i.indexOf(`
|
|
32
32
|
|
|
33
33
|
`)}}}wp([...Zp,...Up,...Wp,...Kp]);function om(e){let[,t]=(0,z.useReducer)(e=>e+1,0);return(0,z.useEffect)(()=>zp(e,t),[e]),Rp(e)}function sm(e){let t=0;for(let n of e)t=(t*31+n.charCodeAt(0))%360;return`oklch(72% 0.13 ${t})`}var cm=e=>e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`?`;function lm(e){let t=Math.max(0,Math.round((Date.parse(e)-Date.now())/1e3));return new Intl.RelativeTimeFormat(L,{numeric:`auto`}).format(Math.abs(t)<60?-Math.abs(t):-Math.round(Math.abs(t)/60),Math.abs(t)<60?`second`:`minute`)}function um(e){let t=e.whoKind===`assistant`?R(`presence.assistant`,{person:e.client??R(`presence.someone`)}):e.whoKind===`agent`?e.client?R(`presence.agentFor`,{name:e.name,person:e.client,ago:lm(e.seenAt)}):R(`presence.agent`,{name:e.name,ago:lm(e.seenAt)}):R(e.state===`editing`?`presence.editing`:`presence.viewing`,{name:e.name});return e.placeLabel?R(`presence.at`,{who:t,place:e.placeLabel}):t}function dm({kind:e,item:t,me:n,className:r}){let i=qp(e,t,n),a=new Map;for(let e of i){let t=a.get(e.who);(!t||e.state===`editing`&&t.state!==`editing`)&&a.set(e.who,e)}let o=[...a.values()];return o.length?(0,B.jsxs)(`ul`,{"aria-label":R(`presence.here`),className:P(`flex shrink-0 items-center -space-x-1.5`,r),children:[o.slice(0,4).map(e=>(0,B.jsx)(`li`,{title:um(e),"aria-label":um(e),className:P(`relative grid size-7 place-items-center rounded-full font-semibold text-[0.6875rem] ring-2 ring-background`,e.state===`editing`&&`outline-2 outline-offset-1`),style:{background:sm(e.who),outlineColor:sm(e.who),color:`oklch(24% 0.03 260)`},children:e.whoKind===`person`?cm(e.name):(0,B.jsx)(Lt,{className:`size-3.5`})},e.who)),o.length>4?(0,B.jsxs)(`li`,{className:`grid size-7 place-items-center rounded-full bg-paper-2 text-[0.6875rem] text-ink-3 ring-2 ring-background`,children:[`+`,o.length-4]}):null]}):null}function fm(e,t,n,r){let i=qp(e,t,n);return r?i.find(e=>e.place===r&&e.state===`editing`&&e.whoKind===`person`)??null:null}function pm(e,t,n){return qp(e,t,n).filter(e=>e.state===`editing`)}function mm({wizard:e,className:t,onDeleted:n}){let r=D(),i=Re(),a=Jt(),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(!1),u=(0,z.useRef)(null);Jm(u,o,()=>s(!1));let d=Pt({mutationFn:()=>_.post(`/api/studio/wizards/${e.id}/duplicate`),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:[`wizards`]}),i(`/edit/${e}`)}}),f=Pt({mutationFn:()=>_.del(`/api/studio/wizards/${e.id}`),onSuccess:async()=>{l(!1),await r.invalidateQueries({queryKey:[`wizards`]}),await r.invalidateQueries({queryKey:O.spaces()}),n?.()}}),p=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 transition hover:bg-accent hover:text-ink`;return(0,B.jsxs)(`div`,{ref:u,className:P(`relative`,t),onClick:e=>e.stopPropagation(),children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":R(`wizardMenu.label`),title:R(`wizardMenu.label`),"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>s(e=>!e),className:P(`grid size-8 place-items-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,o&&`bg-accent text-ink`),children:(0,B.jsx)(g,{className:`size-4`})}),o?(0,B.jsxs)(`div`,{role:`menu`,className:`absolute top-full right-0 z-50 mt-1 w-60 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:p,disabled:d.isPending,onClick:()=>{s(!1),d.mutate()},children:[(0,B.jsx)(le,{className:`size-4 shrink-0`}),` `,R(`wizardMenu.duplicate`)]}),(0,B.jsxs)(`a`,{role:`menuitem`,href:Je(`/api/studio/wizards/${e.id}/export`),download:!0,className:p,onClick:()=>s(!1),children:[(0,B.jsx)(x,{className:`size-4 shrink-0`}),` `,R(`editor.export`)]}),a?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:P(p,`text-rose hover:bg-rose-tint hover:text-rose`),onClick:()=>{s(!1),l(!0)},children:[(0,B.jsx)(lt,{className:`size-4 shrink-0`}),` `,R(`wizardMenu.delete`)]})]}):null]}):null,(0,B.jsxs)(Qe,{open:c,onClose:()=>l(!1),title:R(`wizardMenu.deleteTitle`,{title:e.title}),children:[(0,B.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:e.published?R(`wizardMenu.deletePublished`):R(`wizardMenu.deleteDraft`)}),f.error?(0,B.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,B.jsx)(k,{variant:`ghost`,onClick:()=>l(!1),children:R(`common.cancel`)}),(0,B.jsxs)(k,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:[(0,B.jsx)(lt,{className:`size-4`}),` `,R(`wizardMenu.delete`)]})]})]})]})}var hm=e({HomePage:()=>Mm,NewSpaceDialog:()=>_m,ProjectSwitcher:()=>vm}),gm=[{icon:Dt,name:()=>R(`nav.wizards`),what:`space.holds.wizards`},{icon:pr,name:()=>R(`space.info`),what:`space.holds.info`},{icon:Gn,name:()=>`${R(`space.knowledge`)} & ${R(`space.data`)}`,what:`space.holds.knowledge`},{icon:Rt,name:()=>R(`connectors.title`),what:`space.holds.connectors`},{icon:kr,name:()=>R(`space.results`),what:`space.holds.results`}];function _m({open:e,onClose:t}){let{select:n}=I(),r=D(),[i,a]=(0,z.useState)(``),o=Pt({mutationFn:()=>_.post(`/api/studio/projects`,{name:i}),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:O.spaces()}),n(e),a(``),t()}});return(0,B.jsxs)(Qe,{open:e,onClose:t,title:R(`home.newProject`),children:[(0,B.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:R(`space.holds.intro`)}),(0,B.jsx)(`dl`,{className:`mt-4 flex flex-col gap-2.5 text-[0.8125rem]`,children:gm.map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,B.jsx)(e.icon,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`dt`,{className:`w-28 shrink-0 font-medium text-ink`,children:e.name()}),(0,B.jsx)(`dd`,{className:`min-w-0 text-ink-3`,children:R(e.what)})]},e.what))}),(0,B.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-4`,children:R(`space.holds.shared`)}),(0,B.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,B.jsx)(me,{autoFocus:!0,placeholder:R(`home.projectName`),value:i,onChange:e=>a(e.target.value)}),(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,B.jsx)(k,{variant:`ghost`,onClick:t,children:R(`common.cancel`)}),(0,B.jsx)(k,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:R(`home.newProject`)})]})]})]})}function vm(){let{project:e,projects:t,select:n}=I(),r=Yt().data?.limits.projects??1,i=Xt(),[a,o]=(0,z.useState)(!1);return!e||r!==null&&r<=1?null:(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Oe,{className:`w-56`,value:e.id,onChange:e=>e===`__new`?o(!0):n(e),options:[...t.map(e=>({value:e.id,label:e.name})),...i?[r===null||t.length<r?{value:`__new`,label:`+ ${R(`home.newProject`)}`}:{value:`__new`,label:R(`home.projectLimit`,{n:r}),disabled:!0}]:[]]}),(0,B.jsx)(_m,{open:a,onClose:()=>o(!1)})]})}function ym({url:e}){let[t,n]=(0,z.useState)(!1);return(0,B.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[t?(0,B.jsx)(fe,{className:`size-3.5`}):(0,B.jsx)(le,{className:`size-3.5`}),R(t?`share.copied`:`share.link`)]})}function bm(){let e=Re(),t=op(!1),[n,r]=(0,z.useState)(!1),i=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(!n)return;let e=e=>{i.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,B.jsxs)(`div`,{className:`relative`,ref:i,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[(0,B.jsx)(le,{className:`size-3.5`}),` `,R(`share.link`)]}),n?(0,B.jsxs)(`div`,{className:`absolute right-0 bottom-10 z-20 flex w-72 animate-rise flex-col gap-3 rounded-xl bg-card p-3.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-relaxed`,children:R(`teaser.link`)}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(k,{size:`sm`,busy:t.link.isPending,onClick:()=>t.link.mutate({}),children:R(`account.signIn`)}),(0,B.jsx)(k,{size:`sm`,variant:`secondary`,onClick:()=>e(`/settings/account`),children:R(`account.create`)})]}),(0,B.jsx)(sp,{...t})]}):null]})}function xm({w:e,me:t,runners:n,present:r}){let i=va(`account`),a=Re(),o=np(e,t,e.cloud),s=rp(o),c=s??(e.published?Q(e):null),l=om(e.id);return(0,B.jsxs)(`div`,{className:`group/card relative pt-6`,children:[(0,B.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-4 z-10`,children:(0,B.jsx)(sn,{kind:e.avatar,costume:e.costume,size:52})}),(0,B.jsxs)(y,{className:P(`relative flex h-full cursor-pointer flex-col px-5 pt-10 pb-3 transition hover:shadow-elevated`,l),onClick:()=>a(`/edit/${e.id}`),children:[(0,B.jsx)(`div`,{className:`absolute top-3 right-3`,children:e.published?(0,B.jsx)(ip,{where:o,me:t}):(0,B.jsx)(T,{children:R(`home.draft`)})}),(0,B.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem] leading-snug`,children:e.title}),(0,B.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[0.875rem] text-ink-3`,children:e.description}),(0,B.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between pt-3`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-2.5 text-[0.75rem] text-ink-4`,children:[R(`home.steps`,{n:e.stepCount}),(0,B.jsx)(bp,{w:e,runners:n}),r?.length?(0,B.jsx)(`span`,{role:`img`,className:`inline-flex items-center gap-1`,title:r.map(um).join(`
|
|
34
|
-
`),"aria-label":r.map(um).join(`, `),children:r.slice(0,3).map(e=>(0,B.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:sm(e.who)}},`${e.who}|${e.tab}`))}):null]}),(0,B.jsxs)(`div`,{className:`flex items-center`,children:[(0,B.jsx)(mm,{wizard:e,className:`opacity-0 transition group-hover/card:opacity-100 has-[[aria-expanded=true]]:opacity-100 focus-within:opacity-100 coarse:opacity-100`}),s?(0,B.jsx)(ym,{url:s}):o.kind===`here`&&i?(0,B.jsx)(bm,{}):null,c?(0,B.jsx)(ge,{label:R(s?`share.open`:`share.openHere`),className:`ml-1 size-8`,onClick:e=>{e.stopPropagation(),Wf(c)},children:(0,B.jsx)(Vn,{className:`size-4`})}):null]})]})]})]})}var Sm=[`draft`,`here`,`live`,`missing`],Cm={draft:ht,here:Fr,live:xi,missing:wt},wm=e=>R(e===`draft`?`home.draft`:e===`here`?`where.here`:e===`live`?`home.live`:`where.missing`);function Tm(e,t){let{kind:n}=np(e,t,e.cloud);return n===`draft`||n===`here`?n:n===`live`||n===`unknown`?`live`:`missing`}function Em({wizards:e,me:t,value:n,onChange:r}){let i=new Map;for(let n of e){let e=Tm(n,t);i.set(e,(i.get(e)??0)+1)}if(i.size<2)return null;let a=e=>P(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] transition`,e?`bg-paper-2 text-ink`:`text-ink-3 hover:text-ink`);return(0,B.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-1`,children:[(0,B.jsxs)(`button`,{type:`button`,className:a(n===null),onClick:()=>r(null),children:[R(`home.all`),(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:e.length})]}),Sm.filter(e=>i.has(e)).map(e=>{let t=Cm[e];return(0,B.jsxs)(`button`,{type:`button`,"aria-pressed":n===e,className:a(n===e),onClick:()=>r(n===e?null:e),children:[(0,B.jsx)(t,{className:`size-3.5`}),wm(e),(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:i.get(e)})]},e)})]})}var Dm=12,Om=3;function km({value:e,onChange:t}){return(0,B.jsxs)(`label`,{className:`relative flex h-10 w-full max-w-md items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[(0,B.jsx)(Pe,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:R(`home.search`),"aria-label":R(`home.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),e?(0,B.jsx)(`button`,{type:`button`,"aria-label":R(`market.reset`),onClick:()=>t(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,B.jsx)(it,{className:`size-4`})}):null]})}var Am=`curl -fsSL https://engenty.ai/install.sh | bash`;function jm(){let[e,t]=(0,z.useState)(!1),n=[R(`home.local.install`),R(`home.local.signIn`),R(`home.local.publish`)];return(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-xl animate-rise flex-col items-center pt-4 text-center`,children:[(0,B.jsx)(sn,{kind:`round`,size:120}),(0,B.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[1.75rem] leading-tight tracking-tight`,children:R(`home.local.title`)}),(0,B.jsx)(`p`,{className:`mt-3 text-[0.9375rem] text-ink-2 leading-relaxed`,children:R(`home.local.text`)}),(0,B.jsx)(`ol`,{className:`mt-8 flex w-full flex-col gap-4 text-left`,children:n.map((n,r)=>(0,B.jsxs)(`li`,{className:`flex gap-3`,children:[(0,B.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-paper-2 font-medium text-[0.8125rem] text-ink-2`,children:r+1}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,B.jsx)(`p`,{className:`text-[0.9375rem] leading-snug`,children:n}),r===0?(0,B.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-lg bg-paper-2 py-1.5 pr-1.5 pl-3`,children:[(0,B.jsx)(`code`,{className:`min-w-0 flex-1 select-all overflow-x-auto whitespace-nowrap font-mono text-[0.8125rem] text-ink-2`,children:Am}),(0,B.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(Am),t(!0),setTimeout(()=>t(!1),1500)},children:[e?(0,B.jsx)(fe,{className:`size-3.5`}):(0,B.jsx)(le,{className:`size-3.5`}),R(e?`share.copied`:`share.copy`)]})]}):null]})]},n))})]})}function Mm(){let e=Re(),t=D(),{project:n,projects:r,loading:i}=I(),a=Yt().data,o=tn(),s=Xt(),c=at({queryKey:[`wizards`,n?.id,!!a?.account],queryFn:()=>_.get(`/api/studio/projects/${n.id}/wizards`),enabled:!!n}),l=vp().data??[],u=Jp(`wizard`),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(``),h=(c.data?.length??0)>Dm,g=h?p.trim().toLowerCase():``,v=(c.data??[]).filter(e=>(!d||!a||Tm(e,a)===d)&&(!g||`${e.title} ${e.description}`.toLowerCase().includes(g))),y=!!g&&v.length<Om,b=Pt({mutationFn:e=>_.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:L}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:O.spaces()}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),x=r.reduce((e,t)=>e+t.wizardCount,0),S=s&&!n?.readOnly;return!i&&S&&r.length&&x===0?(0,B.jsx)(ke,{to:`/new`,replace:!0}):!i&&!o&&r.length===0?(0,B.jsx)(jm,{}):(0,B.jsxs)(`div`,{className:`animate-rise`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[h?(0,B.jsx)(km,{value:p,onChange:m}):(0,B.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] tracking-tight`,children:R(`home.title`,{space:n?.name??``})}),S?(0,B.jsxs)(k,{onClick:()=>e(`/new`),children:[(0,B.jsx)(vt,{className:`size-4`}),` `,R(`home.new`)]}):null]}),n?.origin===`local`?(0,B.jsxs)(`p`,{className:`mt-2 text-[0.875rem] text-ink-3`,children:[R(`home.fromLocal`),` `,n.syncedAt?R(`home.syncedAt`,{when:new Intl.DateTimeFormat(L,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n.syncedAt))}):null]}):null,c.data&&c.data.length===0?(0,B.jsxs)(w,{children:[(0,B.jsx)(`p`,{children:R(`home.empty`)}),S?(0,B.jsxs)(k,{className:`mt-5`,onClick:()=>e(`/new`),children:[(0,B.jsx)(vt,{className:`size-4`}),` `,R(`home.new`)]}):null]}):null,c.data?.length&&a?(0,B.jsx)(Em,{wizards:c.data,me:a,value:d,onChange:f}):null,g&&v.length===0?(0,B.jsx)(`p`,{className:`mt-6 text-[0.875rem] text-ink-3`,children:R(`home.noMatch`)}):null,(0,B.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:a?v.map(e=>(0,B.jsx)(xm,{w:e,me:a,runners:l,present:u?.[e.id]?.filter(e=>e.who!==a.user.id)},e.id)):null}),y?(0,B.jsxs)(B.Fragment,{children:[S?(0,B.jsx)(Ot,{query:p,busy:b.isPending,onUse:e=>n&&!b.isPending&&b.mutate(e.id)}):(0,B.jsx)(Ot,{query:p}),S?(0,B.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,B.jsxs)(k,{variant:`secondary`,onClick:()=>e(`/new?wish=${encodeURIComponent(p.trim())}`),children:[(0,B.jsx)(Ye,{className:`size-4`}),` `,R(`home.newFromSearch`,{q:p.trim()})]})}):null]}):null]})}var Nm=(0,z.lazy)(()=>It(()=>import(`./ChangelogDialog-Dc66LqBg.js`).then(e=>({default:e.ChangelogDialog})),__vite__mapDeps([11,1,2,3,4,5]))),Pm=`wizards.update-banner`;function Fm(){try{return localStorage.getItem(Pm)}catch{return null}}function Im(){let[e,t]=(0,z.useState)(Fm),[n,r]=(0,z.useState)(!1),{data:i,latest:a,apply:o,busy:s,progress:c}=rc(),l=i&&!i.newer?i.updated?.to??null:null,u=l??(i?.newer?a:null);if(!(i&&u)||e===u&&i.applying===`idle`)return null;let d=()=>{try{localStorage.setItem(Pm,u)}catch{}t(u)},f=c??(l?R(`about.update.updated`,{v:u}):i.pending?.version===u?R(`about.update.ready`,{v:u}):R(`about.update.available`,{v:u}));return(0,B.jsxs)(`div`,{className:`flex items-center gap-3 border-border-soft border-b bg-ember-tint px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[s?(0,B.jsx)(st,{className:`size-4 shrink-0 text-ember-strong`}):(0,B.jsx)(x,{className:`size-4 shrink-0 text-ember-strong`}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1`,children:f}),s?null:(0,B.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`shrink-0 underline transition hover:text-ink`,children:R(`about.update.notes`)}),n?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(Nm,{open:!0,version:u,onClose:()=>r(!1)})}):null,i.canApply&&!l&&(i.applying===`idle`||i.applying===`failed`)?(0,B.jsx)(k,{size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(),children:R(`about.update.install`)}):null,s?null:(0,B.jsx)(ge,{label:R(`install.app.close`),onClick:d,className:`size-8`,children:(0,B.jsx)(it,{className:`size-4`})})]})}var Lm=[],Rm=new Set;function zm(e){Lm=e;for(let e of Rm)e()}function Bm(e){let t=JSON.stringify(e);(0,z.useEffect)(()=>(zm(JSON.parse(t)),()=>zm([])),[t])}function Vm(){return Lm}function Hm(){return(0,z.useSyncExternalStore)(e=>(Rm.add(e),()=>Rm.delete(e)),()=>Lm)}function Um({alone:e=!1}){let t=Hm();return t.length?(0,B.jsx)(`nav`,{"aria-label":R(`nav.breadcrumb`),className:`flex min-w-0 items-center text-[0.9375rem] max-sm:hidden`,children:t.map((n,r)=>(0,B.jsxs)(z.Fragment,{children:[e&&r===0?null:(0,B.jsx)(`span`,{className:P(`mr-2 text-ink-4`,r===0?`-ml-1 sm:-ml-2`:`ml-2`),children:`/`}),n.to&&r<t.length-1?(0,B.jsx)(ce,{to:n.to,className:`truncate text-ink-3 transition hover:text-ink`,children:n.label}):(0,B.jsx)(`span`,{"aria-current":`page`,className:`truncate font-medium text-ink`,children:n.label})]},`${r}:${n.label}`))}):null}var Wm=e=>e.manageUrl??e.account?.url??null;function Gm(e){let t=Wm(e);return t?`${t}/billing`:null}function Km({me:e}){let t=qt(e),n=Gm(e);return t===null||!n?null:(0,B.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:P(`flex h-8 shrink-0 items-center whitespace-nowrap rounded-full px-3 font-medium text-[0.8125rem] tabular-nums transition`,t<50?`bg-amber-tint text-ink`:`bg-paper-2 text-ink-2 hover:text-ink`),children:R(`nav.credits`,{n:Math.floor(t).toLocaleString(L)})})}function qm(e,t){return e.mode===`local`?e.account?e.account.signedIn?`linked`:`expired`:t?`alone`:null:null}function Jm(e,t,n){let r=(0,z.useRef)(n);r.current=n,(0,z.useEffect)(()=>{if(!t)return;let n=t=>{e.current?.contains(t.target)||r.current()},i=e=>{e.key===`Escape`&&r.current()};return document.addEventListener(`pointerdown`,n),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,n),document.removeEventListener(`keydown`,i)}},[e,t])}function Ym(e,t,n){return e===`below`?n:ha(t,e===`bar-start`?`start`:`end`)}var Xm=e=>`oklch(from ${e} calc(0.16 + 0.83 * clamp(0, (0.65 - l) * 1000, 1)) 0.01 h)`;function Zm({project:e,name:t,size:n=`md`}){let r=e?.brand.colors?.[0]?.value,i=nn(t??e?.name??``),a=(0,B.jsx)(`span`,{className:P(`grid shrink-0 place-items-center font-semibold tracking-wide`,n===`md`?`size-10 rounded-lg text-[0.8125rem]`:n===`sm`?`size-9 rounded-lg text-[0.75rem]`:`size-6 rounded-md text-[0.5625rem]`,r?null:`bg-paper-3 text-ink ring-1 ring-border`),style:r?{background:r,color:Xm(r)}:void 0,children:i||(0,B.jsx)(_r,{className:`size-4`})});return e?.origin===`local`?(0,B.jsxs)(`span`,{className:`relative shrink-0`,title:R(`readonly.project`),children:[a,(0,B.jsx)(`span`,{className:`-right-1 -bottom-1 absolute grid size-4 place-items-center rounded-full bg-amber ring-2 ring-paper`,children:(0,B.jsx)(Fr,{className:`size-2.5 text-paper`})})]}):a}function Qm(e){let{projects:t}=I();return e.mode===`managed`&&!!e.tenant.name&&e.limits.projects===1&&t.length<=1}function $m({me:e,placement:t,label:n,className:r,children:i}){let a=Re(),{position:o,phone:s}=fa(),{project:c,projects:l,select:d}=I(),f=Qm(e),p=gc(e),m=Xt(),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(!1),[x,S]=(0,z.useState)(!1),C=mc(e),[ee,w]=(0,z.useState)({top:0,left:0}),te=(0,z.useRef)(null);Jm(te,h,()=>g(!1));let T=e.limits.projects,E=T!==null&&l.length>=T,ne=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 transition hover:bg-accent hover:text-ink`;return(0,B.jsx)(`div`,{className:`shrink-0`,ref:te,children:(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();w({top:t.bottom+6,left:t.left}),g(e=>!e)},"aria-expanded":h,"aria-haspopup":`menu`,"aria-label":n,title:f?void 0:R(`nav.switchSpace`),className:typeof r==`function`?r(h):r,children:i}),h?(0,B.jsxs)(`div`,{role:`menu`,style:t===`below`?{position:`fixed`,...ee}:void 0,className:P(`z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,t===`below`?null:P(`absolute`,Ym(t,o,`top-10 left-0`))),children:[f&&fc(e)&&!s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:R(`organizations.mine`)}),(0,B.jsx)(_c,{me:e,onDone:()=>g(!1)}),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`})]}):null,f&&!(fc(e)&&s)?null:C&&fc(e)?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition hover:bg-accent`,onClick:()=>{g(!1),S(!0)},children:[(0,B.jsx)(hc,{org:C,size:`xs`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,B.jsx)(`span`,{className:`truncate font-semibold text-[0.875rem] text-ink`,children:C.name}),C.plan?(0,B.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:C.plan.name}):null]}),(0,B.jsx)(`span`,{className:`shrink-0 text-[0.8125rem] text-ink-3`,children:R(`organizations.switchShort`)}),(0,B.jsx)(u,{className:`size-4 shrink-0 text-ink-4`})]}),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`})]}):e.tenant.name?(0,B.jsx)(`div`,{className:`truncate px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:e.tenant.name}):null,(f?[]:l).map(e=>{let t=e.id===c?.id;return(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition hover:bg-accent`,onClick:()=>{g(!1),t?a(`/`):d(e.id)},children:[(0,B.jsx)(Zm,{project:e,size:`sm`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,B.jsx)(`span`,{className:P(`truncate text-[0.875rem]`,t?`font-semibold text-ink`:`font-medium text-ink-2`),children:e.name}),(0,B.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:R(`nav.wizardCount`,{n:e.wizardCount})})]}),t?(0,B.jsx)(fe,{className:`size-4 shrink-0 text-ember-strong`}):null]},e.id)}),f?null:(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),[{to:`/`,icon:Dt,label:R(f?`nav.allWizards`:`nav.wizardsInSpace`),show:!0},{to:`/new`,icon:vt,label:R(`nav.addWizard`),show:m}].filter(e=>e.show).map(e=>(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:ne,onClick:()=>{g(!1),a(e.to)},children:[(0,B.jsx)(e.icon,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.label})]},e.to)),f&&!fc(e)?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:ne,onClick:()=>{g(!1),p()},children:[(0,B.jsx)(ji,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:R(`organizations.manage`)})]})]}):null,c&&!c.readOnly&&!f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:ne,onClick:()=>{g(!1),b(!0)},children:[(0,B.jsx)(we,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:R(`nav.renameSpace`)})]})]}):null,m&&!E?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:ne,onClick:()=>{g(!1),v(!0)},children:[(0,B.jsx)(vt,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:(0,B.jsx)(`span`,{className:`truncate`,children:R(`nav.addSpace`)})})]})]}):null]}):null,(0,B.jsx)(_m,{open:_,onClose:()=>v(!1)}),fc(e)?(0,B.jsx)(yc,{me:e,open:x,onClose:()=>S(!1)}):null,c?(0,B.jsx)(eh,{project:c,open:y,onClose:()=>b(!1)}):null]})})}function eh({project:e,open:t,onClose:n}){let r=D(),[i,a]=(0,z.useState)(e.name);(0,z.useEffect)(()=>{t&&a(e.name)},[t,e.name]);let o=Pt({mutationFn:()=>_.patch(`/api/studio/projects/${e.id}`,{name:i.trim()}),onSuccess:async()=>{await r.invalidateQueries({queryKey:O.spaces()}),n()}});return(0,B.jsx)(Qe,{open:t,onClose:n,title:R(`nav.renameSpace`),children:(0,B.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,B.jsx)(me,{autoFocus:!0,maxLength:80,"aria-label":R(`nav.renameSpace`),value:i,onChange:e=>a(e.target.value)}),(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,B.jsx)(k,{variant:`ghost`,onClick:n,children:R(`common.cancel`)}),(0,B.jsx)(k,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:R(`settings.save`)})]})]})})}function th({me:e,project:t}){let n=e.mode===`local`||t.origin===`local`,r=n?Fr:ar,i=R(n?`nav.spaceLocal`:`nav.spaceCloud`);return(0,B.jsx)(`span`,{title:i,className:`grid size-6 shrink-0 place-items-center text-ink-4`,children:(0,B.jsx)(r,{className:`size-3.5`,"aria-label":i})})}function nh({me:e}){let{project:t}=I(),{phone:n}=fa(),r=Qm(e);return t?r&&e.tenant.name?(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,B.jsxs)($m,{me:e,placement:`below`,label:e.tenant.name,className:e=>P(n?`-ml-1 flex max-w-[16rem] items-center gap-2.5 rounded-xl py-1 pr-2 pl-1`:`-mx-1 flex max-w-[16rem] items-center gap-1 rounded-md px-2 py-0.5`,`text-left font-medium text-[0.9375rem] text-ink transition hover:bg-accent`,e&&`bg-accent`),children:[n?(0,B.jsx)(Zm,{project:t,name:e.tenant.name,size:`sm`}):null,(0,B.jsx)(`span`,{className:`truncate`,children:e.tenant.name}),(0,B.jsx)($n,{className:`size-3.5 shrink-0 text-ink-4`})]}),(0,B.jsx)(th,{me:e,project:t})]}):(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[e.tenant.name&&!n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(vc,{me:e,className:`max-lg:hidden`}),(0,B.jsx)(`span`,{className:`text-ink-4 max-lg:hidden`,"aria-hidden":`true`,children:`/`})]}):null,(0,B.jsx)($m,{me:e,placement:`below`,label:t.name,className:e=>P(n?`-ml-1 flex max-w-[16rem] items-center gap-2.5 rounded-xl py-1 pr-2 pl-1 text-left font-medium text-[0.9375rem] text-ink transition hover:bg-accent`:`-mx-1 max-w-[16rem] translate-y-[0.5px] truncate rounded-md px-2 py-0.5 text-left font-medium text-[0.9375rem] text-ink transition hover:bg-accent`,e&&`bg-accent`),children:n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Zm,{project:t,size:`sm`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col leading-tight`,children:[e.tenant.name?(0,B.jsx)(`span`,{className:`truncate font-normal text-[0.75rem] text-ink-3`,children:e.tenant.name}):null,(0,B.jsx)(`span`,{className:`truncate`,children:t.name})]})]}):t.name}),(0,B.jsx)(th,{me:e,project:t})]}):null}function rh({me:e,placement:t=`below`,named:n}){let[r,i]=(0,z.useState)(!1),a=(0,z.useRef)(null),o=Re(),{position:s,phone:c}=fa();Jm(a,r,()=>i(!1));let l=Ta(),[u,d]=(0,z.useState)(!1),f=nn(e.user.name),p=qm(e,va(`account`)),m=`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`;return(0,B.jsxs)(`div`,{className:P(`relative`,n&&`w-full`),ref:a,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:n?P(`flex w-full items-center gap-3 rounded-lg p-0.5 pr-2 text-left transition hover:bg-ink/10`,r&&`bg-ink/10`):`block shrink-0 rounded-full`,"aria-label":e.user.name||`Menu`,children:[(0,B.jsxs)(`span`,{className:P(`relative flex shrink-0 items-center justify-center rounded-full bg-ember-tint font-semibold text-[0.8125rem] text-ember-strong ring-1 ring-border-soft`,t===`below`?`size-9`:`size-10`),children:[e.user.image?(0,B.jsx)(`img`,{src:e.user.image,alt:``,className:`size-full rounded-full object-cover`}):f,p===`linked`||p===`expired`?(0,B.jsx)(`span`,{title:p===`linked`?R(`nav.connected`,{host:tp(e.account?.cloudUrl??``)}):R(`nav.expired`),className:`-right-1 -bottom-1 absolute flex size-4 items-center justify-center rounded-full bg-card ring-1 ring-border-soft`,children:p===`linked`?(0,B.jsx)(ar,{className:`size-2.5 text-moss`}):(0,B.jsx)(wt,{className:`size-2.5 text-amber`})}):null]}),n?(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem] text-ink-2`,children:e.user.name}):null]}),r?(0,B.jsxs)(`div`,{className:P(`absolute z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,Ym(t,s,`top-11 right-0`)),children:[(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5`,children:[(0,B.jsxs)(`div`,{className:`truncate font-medium text-[0.875rem]`,children:[e.user.name,p===`alone`?(0,B.jsxs)(`span`,{className:`font-normal text-ink-4`,children:[` (`,R(`nav.local`),`)`]}):null]}),(0,B.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.user.email}),e.tenant.name?(0,B.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 text-[0.75rem] text-ink-2`,children:[(0,B.jsx)(qn,{className:`size-3.5 shrink-0 text-ink-4`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.tenant.name})]}):null]}),p?(0,B.jsxs)(`button`,{type:`button`,className:`mx-1.5 mb-1.5 flex w-[calc(100%-0.75rem)] items-start gap-2.5 rounded-lg bg-paper-2 px-2.5 py-2 text-left text-[0.8125rem] text-ink-2 hover:text-ink`,onClick:()=>{i(!1),o(`/settings/account`)},children:[p===`linked`?(0,B.jsx)(ar,{className:`mt-0.5 size-4 shrink-0 text-moss`}):p===`expired`?(0,B.jsx)(wt,{className:`mt-0.5 size-4 shrink-0 text-amber`}):(0,B.jsx)(Fr,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-snug`,children:[(0,B.jsx)(`span`,{className:`break-words`,children:p===`linked`?R(`nav.connected`,{host:tp(e.account?.cloudUrl??``)}):R(p===`expired`?`nav.expired`:`nav.onlyHere`)}),(0,B.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:p===`linked`?e.account?.credits!==null&&e.account?.credits!==void 0?R(`nav.credits`,{n:Math.floor(e.account.credits).toLocaleString(L)}):null:R(p===`expired`?`account.signInAgain`:`account.signIn`)})]})]}):null,e.mode===`managed`&&na(e.features,`organizationSettings`)?(0,B.jsxs)(`button`,{type:`button`,className:m,onClick:()=>{i(!1),o(`/account`)},children:[(0,B.jsx)(Gi,{className:`size-4`}),` `,R(`konto.title`)]}):e.manageUrl?(0,B.jsxs)(`a`,{className:m,href:`${e.manageUrl}/account`,target:`_blank`,rel:`noreferrer`,children:[(0,B.jsx)(lr,{className:`size-4`}),` `,R(`nav.account`)]}):null,c&&!ya()?(0,B.jsxs)(`button`,{type:`button`,className:m,onClick:()=>{i(!1),l?Ea(l):d(!0)},children:[(0,B.jsx)(kt,{className:`size-4`}),` `,R(`install.app.action`)]}):null,(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 text-[0.875rem] text-ink-2`,children:[R(`nav.theme`),(0,B.jsx)(ep,{})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 text-[0.875rem] text-ink-2`,children:[R(`nav.language`),(0,B.jsx)(Ef,{tone:`surface`})]}),e.mode===`managed`?(0,B.jsxs)(`button`,{type:`button`,className:m,onClick:()=>{i(!1),Vs({where:`studio`})},children:[(0,B.jsx)(Et,{className:`size-4`}),` `,R(`report.open`)]}):null,e.mode===`managed`?(0,B.jsxs)(`button`,{type:`button`,className:m,onClick:()=>void on(),children:[(0,B.jsx)(Ur,{className:`size-4`}),` `,R(`nav.logout`)]}):null]}):null,(0,B.jsx)(sc,{open:u,onClose:()=>d(!1)})]})}function ih({me:e,children:t}){let{phone:n}=fa(),r=tt().pathname.startsWith(`/account`);return(0,B.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 px-3 coarse:h-14 sm:gap-3 sm:px-4 md:px-5`,children:[r?null:(0,B.jsx)(nh,{me:e}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,B.jsx)(Um,{alone:r}),t]}),r?null:(0,B.jsx)(Km,{me:e}),n?(0,B.jsx)(rh,{me:e}):null]})}var ah=`studio-scroll`;function oh(){return document.getElementById(`studio-scroll`)??document.documentElement}var sh={left:`md:py-2 md:pr-2`,right:`md:py-2 md:pl-2`,top:`md:px-2 md:pb-2`,bottom:`md:px-2 md:pt-2`},ch={left:`flex-row`,right:`flex-row-reverse`,top:`flex-col`,bottom:`flex-col-reverse`};function lh({me:e,wide:t,full:n,children:r}){let{position:i,phone:a}=fa(),o=(0,z.useRef)(null),s=a&&!n?`calc(4.75rem + env(safe-area-inset-bottom))`:`0px`,c=va(`goose`),l=yf()&&c&&!n,u=ma(!!n||l);return tm(e.tenant.id),(0,B.jsxs)(`div`,{className:P(`flex h-dvh overflow-hidden bg-sidebar`,ch[i]),children:[a?n?null:(0,B.jsx)(Vc,{me:e}):(0,B.jsx)(Lc,{me:e,labels:u.shown,room:u.room}),(0,B.jsxs)(`div`,{className:P(`flex min-h-0 min-w-0 flex-1 md:gap-2`,sh[i]),children:[(0,B.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background md:rounded-xl md:shadow-elevated md:dark:ring-1 md:dark:ring-border-soft`,children:[e.impersonation?(0,B.jsx)(Xi,{name:e.user.name||e.user.email,until:e.impersonation.until}):null,(0,B.jsx)(Im,{}),(0,B.jsx)(dc,{me:e}),(0,B.jsx)(Vl,{me:e}),n?(0,B.jsx)(`main`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden`,children:r}):(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(ih,{me:e}),(0,B.jsxs)(`div`,{ref:o,className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,B.jsx)(`main`,{id:ah,className:`relative min-h-0 flex-1 overflow-y-auto`,style:{paddingBottom:`max(var(--assistant-dock, 0px), ${s})`},children:(0,B.jsx)(`div`,{className:P(`mx-auto w-full px-3 pt-4 pb-12 sm:px-6 sm:pt-6`,t?`max-w-[88rem]`:`max-w-5xl`),children:r})}),c&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(mf,{column:o}),(0,B.jsx)(xf,{})]})]})]})]}),c&&!n?(0,B.jsx)(bf,{}):null]})]})}function uh(){return[{id:`info`,label:R(`space.info`),icon:pr},{id:`brand`,label:R(`space.brand`),icon:Li},{id:`knowledge`,label:R(`space.knowledge`),icon:Gn},{id:`data`,label:R(`space.data`),icon:E},{id:`page`,label:R(`space.page`),icon:zt}]}function dh(e,t){let n=[...e];for(let e of t.spaceParts){let r=n.findIndex(t=>t.id===(e.after??`data`))+1;for(;r<n.length&&t.spaceParts.some(e=>e.id===n[r].id);)r++;n.splice(r,0,{id:e.id,label:e.label(),icon:e.icon})}return n}function fh(e){return e===`info`||e===`brand`||e===`knowledge`||e===`data`||e===`page`||e===`results`}var ph=[{id:`base`,group:`info`,label:`project.base`,icon:jt},{id:`facts`,group:`info`,label:`project.facts`,icon:Tt},{id:`logos`,group:`brand`,label:`project.logos`,icon:Ni},{id:`colors`,group:`brand`,label:`project.colors`,icon:ai},{id:`typography`,group:`brand`,label:`project.typography`,icon:Fn},{id:`assets`,group:`brand`,label:`project.assets`,icon:Dr},{id:`documents`,group:`knowledge`,label:`project.documents`,icon:re},{id:`page`,group:`page`,label:`page.sectionPage`,icon:zt},{id:`page-words`,group:`page`,label:`page.sectionWords`,icon:jt},{id:`page-wizards`,group:`page`,label:`page.sectionWizards`,icon:zr}],mh=ph.map(e=>e.id);function hh(e,t){let n=t.spaceSections.find(t=>t.id===e);return ph.find(t=>t.id===e)?.group??(n?n.group??`knowledge`:null)}function gh(e,t,n=[]){let r=ph.filter(t=>t.group===e&&!n.includes(t.id)).map(e=>({id:e.id,label:R(e.label),icon:e.icon})),i=new Map;for(let n of t.spaceSections){if((n.group??`knowledge`)!==e)continue;let t=i.get(n.plugin)??[];t.push({id:n.id,label:n.label()}),i.set(n.plugin,t)}return[...r.length?[{plugin:null,label:null,sections:r}]:[],...[...i].map(([e,n])=>({plugin:e,label:t.plugins.find(t=>t.id===e)?.name??e,sections:n}))]}globalThis.__WIZARDS_STUDIO__={react:z,jsx:B,reactDom:{createPortal:ea.createPortal,flushSync:ea.flushSync},router:{Link:ce,Navigate:ke,NavLink:o,useLocation:tt,useNavigate:Re,useParams:N,useSearchParams:qe},query:{useMutation:Pt,useQuery:at,useQueryClient:D},ui:ot,sdk:Qi};var _h=0,$={status:`idle`,plugins:[],canReload:!1,problems:[],failed:{},pages:[],nav:[],sections:[],spaceSections:[],spaceParts:[],spaceMenus:{},shareSections:[],shareSetups:[],cards:[]},vh=new Set;function yh(e){$={...$,...e};for(let e of vh)e()}function bh(){return(0,z.useSyncExternalStore)(e=>(vh.add(e),()=>vh.delete(e)),()=>$)}var xh=new Set([`account`,`project`,`connectors`,`models`,`build`,`plugins`]),Sh=new Set([`info`,`brand`,`knowledge`,`data`,`page`,`results`]),Ch=new Map,wh=null,Th=e=>`${e.script}|${e.styles}`,Eh=e=>`__wizardsPlugin_${e.replaceAll(`-`,`_`)}`;function Dh(){let{project:e}=I(),t=e?.id,n=e?.name??``,r=e?.readOnly??!1,i=JSON.stringify({name:e?.brand.name??``,colors:(e?.brand.colors??[]).map(({name:e,value:t})=>({name:e,value:t})),fonts:(e?.brand.fonts??[]).map(({family:e,role:t,weights:n})=>({family:e,role:t,weights:n}))});return(0,z.useMemo)(()=>t?{id:t,name:n,readOnly:r,brand:JSON.parse(i)}:null,[t,n,r,i])}var Oh=(0,z.createContext)(null);function kh({part:e,children:t}){return(0,B.jsx)(Oh.Provider,{value:e,children:t})}function Ah(e){let t=(0,z.useContext)(Oh),n=JSON.stringify(e.map(e=>[e.id,e.label]));(0,z.useEffect)(()=>{if(t)return yh({spaceMenus:{...$.spaceMenus,[t]:e}}),()=>{let{[t]:e,...n}=$.spaceMenus;yh({spaceMenus:n})}},[t,n])}function jh({plugin:e,...t}){return ku({...t,plugin:e}),null}function Mh(e,t){let{id:n}=e,r=e=>`/api/studio/plugins/${n}${e.startsWith(`/`)?e:`/${e}`}`,i=e=>e.filter(e=>e.plugin!==n);return{plugin:{id:n,name:e.name,version:e.version},registerPage(e){let r=e.path.split(`/`)[1]??``;if(!e.path.startsWith(`/`)||Ae.has(r))throw Error(`"${e.path}" is an address of the studio itself.`);if([...i($.pages),...t.pages].some(t=>t.path===e.path))throw Error(`"${e.path}" is registered already.`);t.pages.push({...e,plugin:n,serial:++_h})},registerNav(e){t.nav.push({...e,plugin:n,serial:++_h})},registerSettingsSection(e){let r=[...i($.sections),...t.sections].some(t=>t.id===e.id);if(xh.has(e.id)||r)throw Error(`The settings have a section "${e.id}" already.`);t.sections.push({...e,plugin:n,serial:++_h})},registerSpaceSection(e){let r=[...i($.spaceSections),...t.spaceSections].some(t=>t.id===e.id);if(mh.includes(e.id)||r)throw Error(`The space page has a section "${e.id}" already.`);t.spaceSections.push({...e,plugin:n,serial:++_h})},registerSpacePart(e){let r=[...i($.spaceParts),...t.spaceParts].some(t=>t.id===e.id);if(!/^[a-z][a-z0-9-]{0,39}$/.test(e.id)||Sh.has(e.id)||r)throw Error(`The space page has a part "${e.id}" already.`);t.spaceParts.push({...e,plugin:n,serial:++_h})},registerShareSection(e){if([...i($.shareSections),...t.shareSections].some(t=>t.runner===e.runner))throw Error(`The runner "${e.runner}" has a share section already.`);t.shareSections.push({...e,plugin:n,serial:++_h})},registerShareSetup(e){if([...i($.shareSetups),...t.shareSetups].some(t=>t.runner===e.runner))throw Error(`The runner "${e.runner}" has a share setup already.`);t.shareSetups.push({...e,plugin:n,serial:++_h})},registerAssistantCard(e){if(t.cards.some(t=>t.tool===e.tool))throw Error(`The tool "${e.tool}" has a card already.`);t.cards.push({...e,plugin:n,serial:++_h})},useSpace:Dh,useSpaceMenu:Ah,useCrumbs:Bm,Assistant:e=>(0,B.jsx)(jh,{plugin:n,...e}),useAssistantPage:e=>ku({...e,plugin:n}),useAssistantTool:(e,t,r)=>nd(`${n.replaceAll(`-`,`_`)}_${e}`,t,r),i18n:{register:e=>(t,n)=>{let r=e[L]?.[t]??e.de[t]??t;for(let[e,t]of Object.entries(n??{}))r=r.replace(`{${e}}`,String(t));return r},lang:()=>L},api:{get:e=>_.get(r(e)),post:(e,t)=>_.post(r(e),t),put:(e,t)=>_.put(r(e),t),patch:(e,t)=>_.patch(r(e),t),del:e=>_.del(r(e))},me:()=>({user:{id:wh.user.id,name:wh.user.name,email:wh.user.email},tenant:wh.tenant,mode:wh.mode}),onUnload(e){t.disposers.push(e)}}}function Nh(e){return new Promise((t,n)=>{let r=document.createElement(`script`);r.src=e,r.onload=()=>{r.remove(),t()},r.onerror=()=>{r.remove(),n(Error(`The plugin's script did not load.`))},document.head.append(r)})}function Ph(e,t){return new Promise(n=>{let r=document.createElement(`link`);r.rel=`stylesheet`,r.href=t,r.dataset.plugin=e,r.onload=()=>n(r),r.onerror=()=>n(r),document.head.append(r)})}function Fh(e,t,n){for(let n of t)try{n()}catch(t){console.error(`[plugin ${e}]`,t)}n?.remove()}function Ih(e){let t=Ch.get(e);Ch.delete(e),Fh(e,t?.disposers??[],t?.link??null);let{[e]:n,...r}=$.failed;yh({failed:r,pages:$.pages.filter(t=>t.plugin!==e),nav:$.nav.filter(t=>t.plugin!==e),sections:$.sections.filter(t=>t.plugin!==e),spaceSections:$.spaceSections.filter(t=>t.plugin!==e),spaceParts:$.spaceParts.filter(t=>t.plugin!==e),shareSections:$.shareSections.filter(t=>t.plugin!==e),shareSetups:$.shareSetups.filter(t=>t.plugin!==e),cards:$.cards.filter(t=>t.plugin!==e)})}async function Lh(e){let{id:t}=e,n={pages:[],nav:[],sections:[],spaceSections:[],spaceParts:[],shareSections:[],shareSetups:[],cards:[],disposers:[]},r=null;try{e.styles&&(r=await Ph(t,Je(e.styles))),await Nh(Je(e.script));let i=globalThis,a=Eh(t),o=i[a];i[a]=void 0;let s=typeof o==`function`?o:o?.default;if(typeof s!=`function`)throw Error(`The plugin's script has no default export.`);s(Mh(e,n))}catch(i){console.error(`[plugin ${t}]`,i),Fh(t,n.disposers,r),Ih(t),Ch.set(t,{key:Th(e),disposers:[],link:null}),yh({failed:{...$.failed,[t]:i.message}});return}let i=Ch.get(t);Ch.set(t,{key:Th(e),disposers:n.disposers,link:r});let{[t]:a,...o}=$.failed;yh({failed:o,pages:[...$.pages.filter(e=>e.plugin!==t),...n.pages],nav:[...$.nav.filter(e=>e.plugin!==t),...n.nav],sections:[...$.sections.filter(e=>e.plugin!==t),...n.sections],spaceSections:[...$.spaceSections.filter(e=>e.plugin!==t),...n.spaceSections],spaceParts:[...$.spaceParts.filter(e=>e.plugin!==t),...n.spaceParts],shareSections:[...$.shareSections.filter(e=>e.plugin!==t),...n.shareSections],shareSetups:[...$.shareSetups.filter(e=>e.plugin!==t),...n.shareSetups],cards:[...$.cards.filter(e=>e.plugin!==t),...n.cards]}),Fh(t,i?.disposers??[],i?.link??null)}var Rh=Promise.resolve();function zh(){return Rh=Rh.catch(()=>void 0).then(async()=>{let e=await _.get(`/api/studio/plugins`);for(let t of[...Ch.keys()])e.plugins.some(e=>e.id===t&&e.script)||Ih(t);yh(e);for(let t of e.plugins)t.script&&Ch.get(t.id)?.key!==Th(t)&&await Lh(t)}).catch(e=>console.error(`[plugins]`,e)).finally(()=>yh({status:`ready`})),Rh}var Bh=null;function Vh(e){wh=e,$.status===`idle`&&(yh({status:`loading`}),zh().then(()=>{$.canReload&&!Bh&&(Bh=new EventSource(Je(`/api/studio/plugins/-/events`),{withCredentials:!0}),Bh.addEventListener(`change`,()=>void zh()))}))}async function Hh(e){await _.post(e?`/api/studio/plugins/-/reload/${e}`:`/api/studio/plugins/-/reload`),await zh()}var Uh=class extends z.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`[plugin]`,e)}render(){return this.state.failed?(0,B.jsx)(w,{children:R(`plugins.crashed`)}):this.props.children}};function Wh({of:e,children:t}){return(0,B.jsx)(`div`,{"data-plugin":e.plugin,className:`contents`,children:(0,B.jsx)(Uh,{children:t},e.serial)})}function Gh({end:e,className:t}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4 ${t??``}`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,B.jsx)(ln,{size:28}),(0,B.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight ${e?`max-sm:sr-only`:``}`,children:[`engenty`,(0,B.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-ember-strong`,children:`.`}),(0,B.jsx)(`span`,{className:`font-normal text-ink-2`,children:`wizards`})]})]}),(0,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:e?`flex max-sm:hidden`:`flex`,children:(0,B.jsx)(ep,{tone:`surface`})}),(0,B.jsx)(Ef,{tone:`surface`}),e]})]})}var Kh={de:{imprint:`/de/impressum`,privacy:`/de/datenschutz`,terms:`/de/nutzungsbedingungen`},en:{imprint:`/imprint`,privacy:`/privacy`,terms:`/terms`}};function qh({failed:e}){let t=gn(),[n,r]=(0,z.useState)(()=>Zt()??``),[i,o]=(0,z.useState)(!1),s=Ve(n,r,{endpoint:null}),c=()=>{let e=n.trim();e&&!i&&(s.listening&&s.stop(),o(!0),an(e),rn(`${a}/new`,e))};return(0,B.jsxs)(`div`,{className:`min-h-dvh px-6 pb-16 sm:px-10`,children:[(0,B.jsx)(Gh,{className:`pt-6 sm:pt-8`,end:(0,B.jsx)(k,{variant:`secondary`,size:`sm`,onClick:()=>rn(`${a}/`),children:R(`guest.signIn`)})}),(0,B.jsxs)(`div`,{className:`mx-auto max-w-2xl animate-rise pt-8 md:pt-12`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,B.jsx)(`div`,{className:`size-[84px] md:size-auto`,children:(0,B.jsx)(`div`,{className:`origin-top-left scale-[0.56] md:scale-100`,children:(0,B.jsx)(sn,{kind:`sprout`,size:150,fluffy:!0})})}),(0,B.jsx)(`h1`,{className:`mt-1 font-display font-semibold text-[1.5rem] leading-tight tracking-tight md:mt-2 md:text-[2.375rem]`,children:R(`new.title`)})]}),(0,B.jsxs)(`div`,{className:`relative mt-6 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus md:mt-8`,children:[(0,B.jsx)(Se,{autoFocus:!0,minRows:4,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&c()},placeholder:s.listening?R(`editor.listening`):R(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pb-1`,children:[s.supported?(0,B.jsx)(Ie,{speech:s,labelled:!0}):null,(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsxs)(k,{size:`md`,onClick:c,busy:i,disabled:!n.trim(),children:[R(`new.build`),` `,(0,B.jsx)(Ze,{className:`size-4`})]})]})]}),s.error?(0,B.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:s.error===`denied`?R(`editor.micDenied`):s.error}):null,e?(0,B.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:R(`auth.failed`)}):null,(0,B.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-ink-3`,children:R(`guest.hint`)})]}),(0,B.jsxs)(`section`,{className:`mx-auto max-w-5xl`,children:[(0,B.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:R(`new.orStarter`)}),(0,B.jsx)(At,{onGuestOpen:e=>rn(`${a}/new?starter=${encodeURIComponent(e.id)}`)})]}),(0,B.jsxs)(`footer`,{className:`mt-16 flex flex-wrap justify-center gap-x-5 gap-y-1 text-[0.75rem] text-ink-3`,children:[(0,B.jsx)(`span`,{children:`engenty.wizards`}),[`imprint`,`privacy`,`terms`].map(e=>(0,B.jsx)(`a`,{href:Kh[t][e],className:`transition hover:text-ink-2`,children:R(`legal.${e}`)},e))]})]})}var Jh=/(?:^|;\s*)engenty_signed_in=1(?:;|$)/;function Yh(){return!!window.engentyDesktop}function Xh({text:e}){return e.split(/(?<=[.!?])\s+/).map(e=>(0,B.jsx)(`span`,{className:`block`,children:e},e))}function Zh({title:e,children:t,className:n=`mt-8`}){return(0,B.jsxs)(`div`,{className:`${n} w-full rounded-xl bg-card px-5 py-4 text-left text-[0.875rem] text-ink-2 leading-relaxed shadow-soft ring-1 ring-border-soft`,children:[(0,B.jsx)(`div`,{className:`mb-1.5 font-medium text-ink`,children:e}),t]})}function Qh({text:e}){let[t,n]=(0,z.useState)(!1);return(0,B.jsxs)(`div`,{className:`mt-2 flex items-center gap-3 rounded-xl bg-[oklch(22%_0.02_262)] py-2.5 pr-2.5 pl-4 font-mono text-[0.9375rem] text-white shadow-soft`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`select-none text-white/40`,children:`$`}),(0,B.jsx)(`code`,{className:`min-w-0 flex-1 select-all break-all`,children:e}),(0,B.jsx)(`button`,{type:`button`,"aria-label":R(t?`settings.copied`:`settings.copy`),title:R(t?`settings.copied`:`settings.copy`),className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-white/60 transition hover:bg-white/10 hover:text-white focus-visible:outline-2 focus-visible:outline-white/60`,onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},children:t?(0,B.jsx)(fe,{className:`size-4`}):(0,B.jsx)(le,{className:`size-4`})})]})}function $h(){let e=at({queryKey:[`config`],queryFn:()=>_.get(`/api/config`),refetchInterval:e=>e.state.status===`error`&&!(e.state.error instanceof ne&&e.state.error.body?.code===`host`)&&2e3,retry:!1}),t=D(),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(!1),o=new URLSearchParams(window.location.search).get(`signin`)===`failed`,s=e.data?.mode===`local`&&e.data.devLogin,[c,l]=(0,z.useState)(!1),u=e.data?.mode===`managed`&&!o&&!Yh()&&Jh.test(document.cookie);if((0,z.useEffect)(()=>{u&&rn()},[u]),(0,z.useEffect)(()=>{if(!s||c)return;let e=!0;return _.post(`/api/dev/login`).then(()=>t.invalidateQueries()).catch(()=>{e&&l(!0)}),()=>{e=!1}},[s,c,t]),e.isLoading||u||s&&!c)return(0,B.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center`,children:(0,B.jsx)(sn,{kind:`round`,size:56})});if(e.data?.mode===`managed`&&!e.data.devLogin&&!Yh())return(0,B.jsx)(qh,{failed:o});let d=e.data?.mode===`local`&&!e.data.devLogin,f=e.error instanceof ne&&e.error.body?.code===`host`?e.error:null,p=f?String(f.body.appUrl??``):null,m=d&&!f&&!e.isError,h=e.data?.openCommand===void 0?`wizards open`:e.data.openCommand;return(0,B.jsxs)(`div`,{className:`relative flex min-h-dvh flex-col items-center justify-center px-6 py-16`,children:[(0,B.jsx)(Gh,{className:`absolute inset-x-6 top-6 sm:inset-x-10 sm:top-8`}),(0,B.jsxs)(`div`,{className:`flex w-full max-w-md animate-rise flex-col items-center text-center`,children:[(0,B.jsx)(sn,{kind:`round`,size:d||e.isError?140:200,fluffy:!0}),(0,B.jsxs)(`span`,{className:`mt-2 font-display font-semibold text-[0.9375rem] text-ink-3 tracking-tight`,children:[(0,B.jsx)(cn,{}),(0,B.jsx)(`span`,{className:`font-normal`,children:`wizards`})]}),(0,B.jsx)(`h1`,{className:`mt-3 text-balance font-display font-semibold text-[2.125rem] leading-[1.1] tracking-tight`,children:m?R(`auth.localTitle`):(0,B.jsx)(Xh,{text:R(`brand.tagline`)})}),m?null:(0,B.jsx)(`p`,{className:`mt-4 text-balance text-[1rem] text-ink-2 leading-relaxed`,children:(0,B.jsx)(Xh,{text:R(`brand.sub`)})}),p?(0,B.jsxs)(Zh,{title:R(`auth.wrongHost`),children:[(0,B.jsx)(`p`,{children:R(`auth.wrongHostWhy`)}),(0,B.jsx)(`a`,{href:`${p}${window.location.pathname}`,className:`mt-1.5 block break-all font-medium text-ember-strong underline-offset-2 hover:underline`,children:p})]}):e.isError?(0,B.jsx)(Zh,{title:R(`auth.unreachable`),children:R(`auth.unreachableWhy`,{address:window.location.host})}):null,(0,B.jsxs)(`div`,{className:`mt-10 flex w-full flex-col gap-3`,children:[o?(0,B.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R(`auth.failed`)}):null,e.data?.mode===`managed`?(0,B.jsx)(k,{size:`lg`,busy:n,className:`w-full`,onClick:async()=>{r(!0);let e=window.engentyDesktop;if(!e){rn();return}let{url:t}=await _.post(`/api/auth/desktop/start`);e.open(t),a(!0),r(!1)},children:R(i?`local.accountWaiting`:`auth.signIn`)}):null,e.data?.devLogin?(0,B.jsx)(k,{size:`lg`,busy:n,className:`w-full`,onClick:async()=>{r(!0),await _.post(`/api/dev/login`),await t.invalidateQueries(),r(!1)},children:R(`auth.dev`)}):null,m?(0,B.jsxs)(`div`,{className:`-mt-6 text-left text-[0.9375rem] text-ink-2 leading-relaxed`,children:[h?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{children:R(`auth.localWhy`)}),(0,B.jsx)(Qh,{text:h}),(0,B.jsx)(`p`,{className:`mt-6 text-[0.875rem] text-ink-3`,children:R(`auth.localStartLink`)}),(0,B.jsx)(Qh,{text:`${h} --print`})]}):(0,B.jsx)(`p`,{children:R(`auth.localFromStart`)}),(0,B.jsx)(`p`,{className:`mt-6 text-center text-[0.875rem] text-ink-3`,children:R(`auth.localNoAccount`)})]}):null]}),e.data?.mode===`managed`?(0,B.jsx)(`p`,{className:`mt-6 text-[0.8125rem] text-ink-3`,children:R(`auth.legal`)}):null]}),(0,B.jsxs)(`footer`,{className:`absolute inset-x-0 bottom-6 text-center text-[0.75rem] text-ink-3 sm:bottom-8`,children:[`© engenty · `,R(`about.version`,{v:$s})]})]})}var eg=(0,z.lazy)(()=>It(()=>import(`./PublicRunner-C7i0QdlT.js`).then(e=>({default:e.PublicRunner})),__vite__mapDeps([16,1,2,3,4,5,17,9,14,15,7,6,18,19]))),tg=(0,z.lazy)(()=>It(()=>import(`./SharePage-BDeYhYRB.js`).then(e=>({default:e.SharePage})),__vite__mapDeps([20,1,2,3,4,5,17,9,14,15,7,6,18,19,16]))),ng=(0,z.lazy)(()=>It(()=>import(`./EditorPage-CWtOGKs7.js`).then(e=>({default:e.EditorPage})),__vite__mapDeps([21,1,2,3,4,5,12,13,14,15,7,6,9,22,17,18,19,23,24,25,10,26,27]))),rg=(0,z.lazy)(()=>It(()=>Promise.resolve().then(()=>hm).then(e=>({default:e.HomePage})),void 0)),ig=(0,z.lazy)(()=>It(()=>import(`./OnboardingPage-CoCBYKvL.js`).then(e=>({default:e.OnboardingPage})),__vite__mapDeps([28,1,2,3,4,5,13,15,7,6,23]))),ag=(0,z.lazy)(()=>It(()=>import(`./NewWizardPage-DGHwvXLf.js`).then(e=>({default:e.NewWizardPage})),__vite__mapDeps([29,1,2,3,4,5,12,13,14,15,7,6,23,27,18,24]))),og=(0,z.lazy)(()=>It(()=>import(`./SettingsPage-Ctul7RLy.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([30,1,2,3,4,5,12,13,14,15,7,6,25,31,8,9,10,32,33]))),sg=(0,z.lazy)(()=>It(()=>import(`./ProjectPage-Cmhm9qh1.js`).then(e=>({default:e.ProjectPage})),__vite__mapDeps([34,1,2,3,4,5,12,13,14,15,7,6,22,17,9,18,19,23,24,31,8,10]))),cg=(0,z.lazy)(()=>It(()=>import(`./SetupPage-CuuQVDH2.js`).then(e=>({default:e.SetupPage})),__vite__mapDeps([35,1,2,3,4,5,13,15,7,6,32,33]))),lg=null;function ug(){return(0,B.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center`,children:(0,B.jsx)(sn,{kind:`round`,size:56})})}function dg({children:e,bare:t,wide:n,full:r}){let i=Yt(),a=tt();return en(i.data),(0,z.useEffect)(()=>{i.data&&Vh(i.data)},[i.data]),i.isLoading?(0,B.jsx)(ug,{}):i.data?i.data.mode===`local`&&!i.data.setupDone&&a.pathname!==`/setup`?(0,B.jsx)(ke,{to:`/setup`,replace:!0}):i.data.onboarding&&a.pathname!==`/start`?(0,B.jsx)(ke,{to:`/start`,replace:!0}):t?(0,B.jsxs)(B.Fragment,{children:[i.data.impersonation?(0,B.jsx)(Xi,{name:i.data.user.name||i.data.user.email,until:i.data.impersonation.until}):null,e]}):(0,B.jsx)(lh,{me:i.data,wide:n,full:r,children:e}):(0,B.jsx)($h,{})}function fg(){return gn(),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(ug,{}),children:(0,B.jsxs)(Ge,{children:[lg,(0,B.jsx)(F,{path:`/w/:token`,element:(0,B.jsx)(eg,{})}),(0,B.jsx)(F,{path:`/w/:token/steps`,element:(0,B.jsx)(eg,{steps:!0})}),(0,B.jsx)(F,{path:`/w/:token/steps/:runId`,element:(0,B.jsx)(eg,{steps:!0})}),(0,B.jsx)(F,{path:`/w/:token/chat`,element:(0,B.jsx)(eg,{chat:!0})}),(0,B.jsx)(F,{path:`/w/:token/chat/:runId`,element:(0,B.jsx)(eg,{chat:!0})}),(0,B.jsx)(F,{path:`/w/:token/talk`,element:(0,B.jsx)(eg,{chat:!0,talk:!0})}),(0,B.jsx)(F,{path:`/w/:token/talk/:runId`,element:(0,B.jsx)(eg,{chat:!0,talk:!0})}),(0,B.jsx)(F,{path:`/w/:token/video`,element:(0,B.jsx)(eg,{chat:!0,video:!0})}),(0,B.jsx)(F,{path:`/w/:token/video/:runId`,element:(0,B.jsx)(eg,{chat:!0,video:!0})}),(0,B.jsx)(F,{path:`/w/:token/:runId`,element:(0,B.jsx)(eg,{})}),(0,B.jsx)(F,{path:`/s/:token`,element:(0,B.jsx)(tg,{})}),(0,B.jsx)(F,{path:`*`,element:(0,B.jsx)(pg,{})})]})})}function pg(){return(0,z.useEffect)(()=>{window.location.replace(`${a}/`)},[]),(0,B.jsx)(ug,{})}function mg(){return bh().status===`ready`?(0,B.jsx)(ke,{to:`/`,replace:!0}):(0,B.jsx)(ug,{})}function hg(){gn(),(0,z.useEffect)(()=>(document.documentElement.dataset.studio=``,()=>{delete document.documentElement.dataset.studio}),[]);let e=bh();return(0,B.jsx)(fd,{children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(ug,{}),children:(0,B.jsxs)(Ge,{children:[(0,B.jsx)(F,{path:`/`,element:(0,B.jsx)(dg,{children:(0,B.jsx)(rg,{})})}),(0,B.jsx)(F,{path:`/sign-in`,element:(0,B.jsx)(dg,{children:(0,B.jsx)(ke,{to:`/`,replace:!0})})}),(0,B.jsx)(F,{path:`/new`,element:(0,B.jsx)(dg,{children:(0,B.jsx)(ag,{})})}),(0,B.jsx)(F,{path:`/edit/:id`,element:(0,B.jsx)(dg,{full:!0,children:(0,B.jsx)(ng,{})})}),(0,B.jsx)(F,{path:`/space/:group?`,element:(0,B.jsx)(dg,{wide:!0,children:(0,B.jsx)(sg,{})})}),(0,B.jsx)(F,{path:`/settings/:section?`,element:(0,B.jsx)(dg,{wide:!0,children:(0,B.jsx)(og,{})})}),(0,B.jsx)(F,{path:`/account/:section?`,element:(0,B.jsx)(dg,{wide:!0,children:(0,B.jsx)(og,{scope:`account`})})}),(0,B.jsx)(F,{path:`/setup`,element:(0,B.jsx)(dg,{bare:!0,children:(0,B.jsx)(cg,{})})}),(0,B.jsx)(F,{path:`/start`,element:(0,B.jsx)(dg,{bare:!0,children:(0,B.jsx)(ig,{})})}),e.pages.map(e=>(0,B.jsx)(F,{path:e.path,element:(0,B.jsx)(dg,{wide:e.wide,children:(0,B.jsx)(Wh,{of:e,children:(0,B.jsx)(e.component,{})})})},e.serial)),(0,B.jsx)(F,{path:`*`,element:(0,B.jsx)(dg,{bare:!0,children:(0,B.jsx)(mg,{})})})]})})})}var gg=class extends z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){Xe(`error`,e.message,e.stack)}render(){let{error:e}=this.state;return e?(0,B.jsxs)(`div`,{className:`flex min-h-dvh flex-col items-center justify-center p-6 text-center`,children:[(0,B.jsx)(`h1`,{className:`font-display font-semibold text-[1.375rem]`,children:R(`report.crashed`)}),(0,B.jsx)(`p`,{className:`mt-2 max-w-md text-[0.9375rem] text-ink-3`,children:R(`report.crashedNote`)}),(0,B.jsxs)(`div`,{className:`mt-6 flex gap-3`,children:[(0,B.jsx)(k,{variant:`secondary`,onClick:()=>window.location.reload(),children:R(`report.reload`)}),(0,B.jsx)(k,{onClick:()=>Vs({where:this.props.where,error:{message:e.message,stack:e.stack}}),children:R(`report.open`)})]}),(0,B.jsx)(Xs,{})]}):this.props.children}},_g=`wizards.organizationHint`,vg=30;function yg(e){try{let t=JSON.parse(sessionStorage.getItem(_g)??`null`);return t?.slug===e&&Date.now()-t.at<vg*1e3}catch{return!1}}function bg(e){try{sessionStorage.setItem(_g,JSON.stringify({slug:e,at:Date.now()}))}catch{}}function xg(e,t){let n=e.slice(a.length),r=n.split(`/`)[1]??``;if(!t)return{kind:`here`,root:Ae.has(r)?a:`${a}/${r}`};let i=t.mode===`managed`?t.tenant.slug:null;if(!i)return{kind:`here`,root:a};let o=`${a}/${i}`;return r===i?{kind:`here`,root:o}:t.organizations.some(e=>e.slug===r)&&!yg(r)?{kind:`switch`,slug:r}:Ae.has(r)?{kind:`move`,root:o,to:`${o}${n||`/`}`}:{kind:`foreign`,address:r,home:`${o}${n.slice(r.length+1)||`/`}`,me:t}}function Sg({children:e}){let t=Yt(),n=(0,z.useRef)(null);if(t.isLoading)return(0,B.jsx)(ug,{});n.current||={place:xg(window.location.pathname,t.data),tenant:t.data?.tenant.id??null};let{place:r}=n.current,{pathname:i,search:o,hash:s}=window.location;if(r.kind===`switch`){bg(r.slug);let e=new URLSearchParams({organization:r.slug,return:`${i}${o}`});return window.location.replace(Je(`/api/auth/login?${e}`)),(0,B.jsx)(ug,{})}if(r.kind===`foreign`)return(0,B.jsx)(Cg,{address:r.address,home:r.home,me:r.me});r.kind===`move`&&(window.history.replaceState(window.history.state,``,`${r.to}${o}${s}`),n.current.place={kind:`here`,root:r.root});let c=r.root,l=t.data?.mode===`managed`?t.data.tenant.slug:null,u=l?`${a}/${l}`:c;if(c!==a&&u!==c&&t.data?.tenant.id===n.current.tenant){let e=i.startsWith(c)?i.slice(c.length):`/`;window.history.replaceState(window.history.state,``,`${u}${e}${o}${s}`),n.current.place={kind:`here`,root:u},c=u}return Ce(c),(0,B.jsx)(j,{basename:c,children:e},c)}function Cg({address:e,home:t,me:n}){return(0,B.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center px-6`,children:(0,B.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-5 text-center`,children:[(0,B.jsx)(sn,{kind:`round`,size:56}),(0,B.jsxs)(`div`,{className:`rounded-md bg-paper-2 px-2.5 py-1 font-mono text-[0.8125rem] text-ink-2`,children:[`/studio/`,e]}),(0,B.jsx)(`h1`,{className:`text-balance font-display font-semibold text-2xl`,children:R(`address.foreign.title`)}),(0,B.jsx)(`p`,{className:`text-[0.9375rem] text-ink-2`,children:R(`address.foreign.text`,{email:n.user.email})}),(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,B.jsxs)(k,{onClick:()=>window.location.assign(t),children:[R(`address.foreign.continue`,{name:n.tenant.name??``}),(0,B.jsx)(Ze,{className:`size-4`})]}),(0,B.jsxs)(k,{variant:`secondary`,onClick:()=>void on(),children:[(0,B.jsx)(Ur,{className:`size-4`}),R(`address.foreign.switchAccount`)]})]})]})})}function wg({view:e,failed:t}){let n=ga(),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(!1);if(!n.data?.reports)return null;let l=(0,B.jsxs)(k,{variant:`ghost`,size:`sm`,onClick:()=>Vs({where:`run`,runId:e.id,error:t&&e.error?{message:e.error}:null}),children:[(0,B.jsx)(Et,{className:`size-4`}),` `,R(`report.open`)]});if(t)return(0,B.jsx)(`div`,{className:`mt-4 flex justify-center`,children:l});let u=async(t,n)=>{i(t),await fetch(Je(`/api/runs/${e.id}/feedback`),{method:`POST`,headers:{"content-type":`application/json`},credentials:`include`,body:JSON.stringify({good:t,...n?{comment:n}:{}})}).catch(()=>void 0),n!==void 0&&c(!0)};return(0,B.jsx)(`div`,{className:`mt-8 rounded-2xl border border-border bg-card p-4 sm:p-5`,children:s?(0,B.jsx)(`p`,{className:`text-ink-2 text-sm`,children:R(`feedback.thanks`)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`mr-2 font-medium text-[0.9375rem]`,children:R(`feedback.ask`)}),(0,B.jsxs)(k,{size:`sm`,variant:r===!0?`quiet`:`secondary`,onClick:()=>void u(!0),children:[(0,B.jsx)(Vi,{className:`size-4`}),` `,R(`feedback.good`)]}),(0,B.jsxs)(k,{size:`sm`,variant:r===!1?`quiet`:`secondary`,onClick:()=>void u(!1),children:[(0,B.jsx)(zi,{className:`size-4`}),` `,R(`feedback.bad`)]}),(0,B.jsx)(`span`,{className:`ml-auto`,children:l})]}),r===null?null:(0,B.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 sm:flex-row sm:items-end`,children:[(0,B.jsx)(Se,{rows:2,value:a,placeholder:R(`feedback.more`),onChange:e=>o(e.target.value),className:`flex-1`}),(0,B.jsx)(k,{size:`sm`,onClick:()=>void u(r,a.trim()),children:R(`feedback.send`)})]})]})})}var Tg={mail:Gr,folder:hr,chat:$r,plug:Rt,globe:zt};function Eg({runId:e,job:t,onAgain:n,onHome:r}){let[i,a]=(0,z.useState)(!1);if(t.status===`running`&&t.ask)return(0,B.jsx)(oe,{runId:e,ask:t.ask},t.ask.id);if(t.status===`running`){let n=t.events.slice(-5);return(0,B.jsxs)(`div`,{className:`animate-rise`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col items-center py-6 text-center`,children:[(0,B.jsx)(st,{className:`size-7 text-ember`}),(0,B.jsx)(`h3`,{className:`mt-4 font-display font-semibold text-[1.125rem]`,children:R(`shareRun.working`)}),(0,B.jsx)(`div`,{className:`mt-4 flex min-h-[5.5rem] w-full max-w-sm flex-col gap-1.5`,children:n.map((e,t)=>(0,B.jsxs)(`div`,{className:P(`flex items-center justify-center gap-2 text-[0.8125rem]`,t===n.length-1?`text-ink-2`:`text-ink-4`),children:[t===n.length-1?(0,B.jsx)(Ye,{className:`size-3.5 shrink-0 animate-breathe text-ember`}):null,(0,B.jsx)(`span`,{className:`truncate`,children:e.message})]},e.at+e.message))})]}),(0,B.jsx)(`div`,{className:`flex justify-center`,children:(0,B.jsx)(k,{variant:`ghost`,busy:i,onClick:()=>{a(!0),_.post(`/api/runs/${e}/share/jobs/${t.id}/cancel`).catch(()=>void 0)},children:R(`common.cancel`)})})]})}let o=t.status===`done`;return(0,B.jsxs)(`div`,{className:`animate-rise`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col items-center py-4 text-center`,children:[(0,B.jsx)(`div`,{className:P(`flex size-12 items-center justify-center rounded-full`,o?`bg-moss-tint text-moss`:`bg-rose-tint text-rose`),children:o?(0,B.jsx)(fe,{className:`size-6`}):(0,B.jsx)(He,{className:`size-6`})}),(0,B.jsx)(`h3`,{className:`mt-4 font-display font-semibold text-[1.125rem]`,children:R(o?`shareRun.done`:t.status===`cancelled`?`shareRun.cancelled`:`shareRun.failed`)}),o&&t.result?(0,B.jsx)(bt,{text:t.result.summary,className:`mt-2 max-w-md text-[0.875rem] text-ink-2`}):t.error?(0,B.jsx)(`p`,{className:`mt-2 max-w-md text-[0.875rem] text-ink-2 leading-relaxed`,children:t.error}):null,o&&t.result?.url?(0,B.jsxs)(`a`,{href:t.result.url,target:`_blank`,rel:`noreferrer`,className:`mt-4 inline-flex h-10 items-center gap-2 rounded-full bg-paper-2 px-4 font-medium text-[0.875rem] text-ink hover:bg-paper-3 coarse:h-11`,children:[(0,B.jsx)(ie,{className:`size-4`}),` `,R(`share.open`)]}):null]}),(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3`,children:[n?(0,B.jsx)(k,{variant:`ghost`,onClick:n,children:R(o?`shareRun.again`:`shareRun.backToForm`)}):(0,B.jsx)(`span`,{}),(0,B.jsx)(k,{onClick:r,children:R(`shareRun.elsewhere`)})]})]})}function Dg({steps:e,now:t}){return(0,B.jsx)(`ol`,{className:`mb-6 flex gap-2`,children:e.map((e,n)=>(0,B.jsxs)(`li`,{className:`min-w-0 flex-1`,"aria-current":n===t?`step`:void 0,children:[(0,B.jsx)(`div`,{className:P(`h-1 rounded-full`,n<t?`bg-moss`:n===t?`bg-ember`:`bg-paper-3`)}),(0,B.jsxs)(`div`,{className:P(`mt-1.5 truncate font-medium text-[0.75rem]`,n<t?`text-moss`:n===t?`text-ember-strong`:`text-ink-4`),children:[n+1,` · `,e]})]},e))})}function Og(e){return[...e.shown.filter(e=>e.output&&e.formats.length).map(e=>({from:e.step.id,label:e.label??e.step.title,formats:e.formats})),...e.lists.filter(e=>e.formats.length).map(e=>({from:`lists.${e.def.id}`,label:e.label??e.def.title,formats:e.formats}))]}function kg({deliverables:e,picked:t,onPick:n,error:r}){return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{children:R(`shareRun.files`)}),(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg ring-1 ring-input`,children:e.map(e=>{let r=!!t[e.from];return(0,B.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-border-soft border-b bg-card px-3 py-2.5 last:border-0`,children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-1 basis-40 cursor-pointer items-center gap-2.5 text-[0.875rem] coarse:min-h-11`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:r,onChange:t=>n(e.from,t.target.checked?e.formats[0]:null),className:`size-4 shrink-0 accent-[var(--ember)] coarse:size-5`}),(0,B.jsx)(`span`,{className:P(`truncate`,!r&&`text-ink-3`),children:e.label})]}),r?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.formats.map(r=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":t[e.from]===r,onClick:()=>n(e.from,r),className:P(`h-7 rounded-full px-2.5 font-medium text-[0.75rem] ring-1 transition coarse:h-9 coarse:px-3`,t[e.from]===r?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-3 ring-input hover:text-ink`),children:be[r]},r))}):null]},e.from)})}),r?(0,B.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-rose`,children:r}):null]})}function Ag({field:e,value:t,choices:n,error:r,onChange:i}){let a=e.fromAccount?n:e.options;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{required:e.required,hint:e.help,children:e.label}),e.kind===`textarea`?(0,B.jsx)(Se,{minRows:3,maxRows:12,value:t,placeholder:e.placeholder,onChange:e=>i(e.target.value)}):e.kind===`select`&&a?.length?(0,B.jsx)(Oe,{value:t,onChange:i,options:a,placeholder:``}):(0,B.jsx)(me,{type:e.kind===`url`?`url`:`text`,inputMode:e.kind===`emails`?`email`:void 0,autoCapitalize:e.kind===`text`?void 0:`off`,autoComplete:`off`,spellCheck:e.kind===`text`,value:t,disabled:e.fromAccount&&n===void 0,placeholder:e.fromAccount&&n===void 0?R(`common.loading`):e.placeholder,onChange:e=>i(e.target.value)}),e.fromAccount&&n===null?(0,B.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:R(`shareRun.choicesFailed`)}):null,r?(0,B.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-rose`,children:r}):null]})}function jg({view:e,target:t,draft:n,onStarted:r}){let i=e.id,a=!!t.connection,o=!t.connection||!!t.connection.account,[s,c]=(0,z.useState)(!o);(0,z.useEffect)(()=>{o||c(!0)},[o]);let l=(0,z.useMemo)(()=>Og(e),[e]),[u,d]=(0,z.useState)(()=>n?.picked??Object.fromEntries(l.map(e=>[e.from,e.formats[0]]))),[f,p]=(0,z.useState)(()=>n?.values??Object.fromEntries(t.fields.map(e=>[e.id,e.value??``]))),[m,h]=(0,z.useState)({}),[g,v]=(0,z.useState)({}),[y,b]=(0,z.useState)(null),[x,S]=(0,z.useState)(!1),C=t.fields.filter(e=>e.fromAccount).map(e=>e.id);(0,z.useEffect)(()=>{if(!o)return;let e=!0;for(let n of C)_.get(`/api/runs/${i}/share/targets/${encodeURIComponent(t.key)}/choices/${n}?lang=${L}`).then(t=>e&&h(e=>({...e,[n]:t.choices.length?t.choices:null})),()=>e&&h(e=>({...e,[n]:null})));return()=>{e=!1}},[o,i,t.key]);let ee=[...a?[R(`shareRun.stepAccount`)]:[],R(`shareRun.stepForm`),R(`shareRun.stepSend`)],w=async()=>{S(!0),v({}),b(null);let e=t.takes===`files`?l.flatMap(e=>u[e.from]?[{from:e.from,format:u[e.from]}]:[]):[];try{r(await _.post(`/api/runs/${i}/share/jobs`,{target:t.key,items:e,values:f,lang:L}),{values:f,picked:u})}catch(e){let t=e instanceof ne&&e.status===422?e.body?.fields:null;t?(v(t),t._account&&c(!0)):b(e.message)}finally{S(!1)}};return a&&s?(0,B.jsxs)(`div`,{className:`animate-rise`,children:[(0,B.jsx)(Dg,{steps:ee,now:0}),(0,B.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-2 leading-relaxed`,children:R(`shareRun.accountHint`)}),(0,B.jsx)(mt,{runId:i,connection:t.connection??void 0}),g._account?(0,B.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:g._account}):null,(0,B.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,B.jsxs)(k,{disabled:!o,onClick:()=>c(!1),children:[R(`run.next`),` `,(0,B.jsx)(Ze,{className:`size-4`})]})})]}):(0,B.jsxs)(`form`,{className:`animate-rise`,onSubmit:e=>{e.preventDefault(),w()},children:[(0,B.jsx)(Dg,{steps:ee,now:+!!a}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[a&&t.connection?.account?(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem]`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-ink-2`,children:R(`shareRun.as`,{account:t.connection.account.label})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`shrink-0 text-ink-3 hover:text-ink coarse:min-h-11`,children:R(`shareRun.changeAccount`)})]}):null,t.agent?(0,B.jsxs)(`p`,{className:`flex items-start gap-2.5 rounded-lg bg-ember-tint px-3 py-2.5 text-[0.8125rem] text-ink-2 leading-relaxed`,children:[(0,B.jsx)(Lt,{className:`mt-0.5 size-4 shrink-0 text-ember-strong`}),` `,R(`shareRun.agentHint`)]}):null,t.presets.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.presets.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>p(t=>({...t,...e.values})),className:`h-9 rounded-full bg-card px-3.5 font-medium text-[0.8125rem] text-ink-2 ring-1 ring-input transition hover:text-ink hover:ring-ember coarse:h-11`,children:e.label},e.label))}):null,t.fields.map(e=>(0,B.jsx)(Ag,{field:e,value:f[e.id]??``,choices:m[e.id],error:g[e.id],onChange:t=>p(n=>({...n,[e.id]:t}))},e.id)),t.takes===`files`&&l.length?(0,B.jsx)(kg,{deliverables:l,picked:u,error:g._files,onPick:(e,t)=>d(n=>({...n,[e]:t}))}):null,y?(0,B.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[0.875rem] text-rose`,children:y}):null]}),(0,B.jsx)(`div`,{className:`action-bar mt-6 flex justify-end`,children:(0,B.jsxs)(k,{type:`submit`,busy:x,children:[(0,B.jsx)(ki,{className:`size-4`}),` `,R(t.agent?`shareRun.start`:`shareRun.send`)]})})]})}function Mg(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);return[{id:`mail`,label:R(`shareRun.email`),href:`mailto:?subject=${r}&body=${r}%0A%0A${n}`},{id:`x`,label:`X`,href:`https://x.com/intent/post?text=${r}&url=${n}`},{id:`linkedin`,label:`LinkedIn`,href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`},{id:`whatsapp`,label:`WhatsApp`,href:`https://wa.me/?text=${r}%20${n}`},{id:`facebook`,label:`Facebook`,href:`https://www.facebook.com/sharer/sharer.php?u=${n}`}]}var Ng={x:`𝕏`,linkedin:`in`,whatsapp:`WA`,facebook:`f`};function Pg({view:e,title:t}){let n=e.id,[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)({at:`home`}),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)({}),p=e.shareJob?.status===`running`?e.shareJob:null,m=(0,z.useCallback)(async()=>{try{c(await _.get(`/api/runs/${n}/share/targets?lang=${L}`)),u(null)}catch(e){u(e.message)}},[n]),h=()=>{i(!0),o(p?{at:`job`,id:p.id,key:null}:{at:`home`}),m()};(0,z.useEffect)(()=>{r&&a.at===`target`&&m()},[r,a.at,e,m]);let g=e.shareJob?.status;(0,z.useEffect)(()=>{r&&g&&g!==`running`&&m()},[r,g,m]);let v=a.at===`target`||a.at===`job`?s?.targets.find(e=>e.key===a.key):void 0,y=a.at===`job`?e.shareJob?.id===a.id?e.shareJob:s?.jobs.find(e=>e.id===a.id):void 0,b=a.at===`home`||a.at===`job`&&y?.status===`running`?null:()=>o({at:`home`});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(k,{variant:`secondary`,onClick:h,children:[p?(0,B.jsx)(st,{className:`size-4`}):(0,B.jsx)(We,{className:`size-4`}),` `,R(`shareRun.button`)]}),(0,B.jsx)(Qe,{open:r,onClose:()=>i(!1),wide:!0,title:(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[b?(0,B.jsx)(ge,{label:R(`run.back`),onClick:b,className:`-my-1.5 -ml-2`,children:(0,B.jsx)(ee,{className:`size-4`})}):null,a.at===`link`?R(`shareRun.linkTitle`):v?.name??y?.name??R(`shareRun.title`)]}),children:a.at===`link`?(0,B.jsx)(zg,{view:e,title:t,onWithdrawn:()=>o({at:`home`})}):a.at===`target`&&v?(0,B.jsx)(jg,{view:e,target:v,draft:d[v.key],onStarted:(e,t)=>{f(e=>({...e,[v.key]:t})),o({at:`job`,id:e.id,key:v.key})}},v.key):a.at===`job`&&y?(0,B.jsx)(Eg,{runId:n,job:y,onAgain:a.key?()=>o({at:`target`,key:a.key}):null,onHome:()=>o({at:`home`})}):l?(0,B.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[0.875rem] text-rose`,children:l}):s?(0,B.jsx)(Lg,{overview:s,onLink:()=>o({at:`link`}),onTarget:e=>o({at:`target`,key:e}),onJob:e=>o({at:`job`,id:e,key:null})}):(0,B.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,B.jsx)(st,{})})})]})}function Fg({icon:e,name:t,description:n,onClick:r,selected:i}){let a=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:P(`flex size-11 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-2 transition`,r&&`group-hover:bg-ember-tint group-hover:text-ember-strong`,i&&`bg-ember-tint text-ember-strong`),children:(0,B.jsx)(e,{className:`size-5`})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block truncate font-medium text-[0.9375rem]`,children:t}),(0,B.jsx)(`span`,{className:`block text-[0.8125rem] text-ink-3 leading-snug`,children:n})]}),r?(0,B.jsx)(u,{className:`size-4 shrink-0 text-ink-4 transition group-hover:text-ember-strong`}):null]}),o=P(`group flex items-center gap-3 rounded-xl bg-card p-3 text-left ring-1 ring-input transition`,r&&`hover:ring-ember`,i&&`ring-2 ring-ember`);return r?(0,B.jsx)(`button`,{type:`button`,onClick:r,className:o,children:a}):(0,B.jsx)(`div`,{className:o,children:a})}function Ig(e){return new Intl.DateTimeFormat(L,{dateStyle:`short`,timeStyle:`short`}).format(new Date(e))}function Lg({overview:e,onLink:t,onTarget:n,onJob:r}){let i=e.jobs.filter(e=>e.status!==`cancelled`);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,B.jsxs)(`div`,{className:`grid gap-2.5 sm:grid-cols-2`,children:[(0,B.jsx)(Fg,{icon:p,name:R(`share.link`),description:R(`shareRun.linkHint`),onClick:t}),e.targets.map(e=>(0,B.jsx)(Fg,{icon:Tg[e.icon],name:e.name,description:e.description,onClick:()=>n(e.key)},e.key))]}),i.length?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`mb-2 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:R(`shareRun.recent`)}),(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg ring-1 ring-border-soft`,children:i.slice(0,5).map(e=>(0,B.jsx)(`li`,{className:`border-border-soft border-b last:border-0`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`flex w-full items-center gap-2.5 px-3 py-2 text-left text-[0.8125rem] hover:bg-paper-2 coarse:min-h-11`,children:[(0,B.jsx)(Rg,{job:e}),(0,B.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-ink-3`,children:e.result?.summary??e.error??R(`shareRun.working`)}),(0,B.jsx)(`span`,{className:`shrink-0 text-ink-4 tabular-nums`,children:Ig(e.createdAt)})]})},e.id))})]}):null]})}function Rg({job:e}){return e.status===`running`?(0,B.jsx)(st,{className:`size-3.5 shrink-0 text-ember`}):(0,B.jsx)(`span`,{className:P(`size-2 shrink-0 rounded-full`,e.status===`done`?`bg-moss`:e.status===`failed`?`bg-rose`:`bg-ink-4`)})}function zg({view:e,title:t,onWithdrawn:n}){let r=e.id,[i,a]=(0,z.useState)(e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(null);(0,z.useEffect)(()=>{if(i)return;let e=!0;return _.post(`/api/runs/${r}/share`).then(t=>e&&a(t)).catch(t=>e&&l(t.message)),()=>{e=!1}},[r,i]);let u=async()=>{await _.del(`/api/runs/${r}/share`),n()},d=()=>{i&&(navigator.clipboard.writeText(i.url),s(!0),setTimeout(()=>s(!1),1500))},f=Ue(`share`)||typeof navigator<`u`&&`share`in navigator,m=i?.expiresAt?new Intl.DateTimeFormat(L,{dateStyle:`long`}).format(new Date(i.expiresAt)):null;return c?(0,B.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[0.875rem] text-rose`,children:c}):i?(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-paper-2 p-1.5 pl-3`,children:[(0,B.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`input`,{readOnly:!0,value:i.url,onFocus:e=>e.target.select(),"aria-label":R(`share.link`),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] outline-none coarse:h-11`}),(0,B.jsxs)(k,{size:`sm`,onClick:d,children:[o?(0,B.jsx)(fe,{className:`size-3.5`}):(0,B.jsx)(le,{className:`size-3.5`}),R(o?`share.copied`:`share.copy`)]})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-6`,children:[Mg(i.url,t).map(e=>(0,B.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,B.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 font-semibold text-[0.9375rem] transition hover:bg-paper-3`,children:e.id===`mail`?(0,B.jsx)(Gr,{className:`size-5`}):Ng[e.id]}),e.label]},e.id)),f?(0,B.jsxs)(`button`,{type:`button`,onClick:()=>void(Ue(`share`)?De(`share`,{link:i.url,title:t}):navigator.share({title:t,url:i.url})).catch(()=>void 0),className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,B.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 transition hover:bg-paper-3`,children:(0,B.jsx)(We,{className:`size-5`})}),R(`shareRun.more`)]}):null]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[0.8125rem] text-ink-3`,children:[(0,B.jsx)(`span`,{children:m?R(`shareRun.until`,{date:m}):R(`shareRun.kept`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void u(),className:`shrink-0 hover:text-rose coarse:min-h-11`,children:R(`shareRun.withdraw`)})]})]}):(0,B.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,B.jsx)(st,{})})}S({lang:L,runBase:e=>`/api/runs/${e}`,withBase:Je,asset:Ke,serviceWorker:`${se}/sw.js`,app:{can:Ue,call:De,tell:Me,download:dt},Mascot:sn,ShareResultButton:Pg,RunEnd:wg,onServerError:e=>Xe(`error`,e)}),C(),he();var Bg=`wizards.reloadedForBuild`;window.addEventListener(`vite:preloadError`,e=>{let t=0;try{if(t=Number(sessionStorage.getItem(Bg))||0,Date.now()-t<6e4)return;sessionStorage.setItem(Bg,String(Date.now()))}catch{return}e.preventDefault(),window.location.reload()}),`engentyDesktop`in window&&(document.documentElement.dataset.desktop=``);var Vg=window.location.pathname,Hg=Vg===a||Vg.startsWith(`${a}/`);Hg&&`serviceWorker`in navigator&&navigator.serviceWorker.register(`${se}/sw.js`).catch(()=>void 0);var Ug=new kn({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});(0,Ji.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(Be,{client:Ug,children:Hg?(0,B.jsx)(Sg,{children:(0,B.jsxs)(gg,{where:`studio`,children:[(0,B.jsx)(hg,{}),(0,B.jsx)(Xs,{})]})}):(0,B.jsx)(j,{basename:se,children:(0,B.jsxs)(gg,{where:`run`,children:[(0,B.jsx)(fg,{}),(0,B.jsx)(Xs,{})]})})})}));export{Of as $,Ep as A,ai as At,Af as B,Nr as Bt,sm as C,qi as Ct,om as D,Di as Dt,pm as E,ji as Et,rp as F,Yr as Ft,Lf as G,ar as Gt,Mf as H,kr as Ht,np as I,Gr as It,Pf as J,Ff as K,Zn as Kt,ep as L,zr as Lt,sp as M,ti as Mt,op as N,$r as Nt,qp as O,Ti as Ot,ip as P,Zr as Pt,Bf as Q,Kf as R,Lr as Rt,dm as S,Zi as St,fm as T,Ui as Tt,kf as U,yr as Ut,jf as V,jr as Vt,Vf as W,lr as Wt,Hf as X,Uf as Y,Z,Gm as _,rc as _t,Dg as a,Ul as at,vm as b,va as bt,kh as c,Bl as ct,hh as d,ol as dt,Df as et,fh as f,Kc as ft,Km as g,pc as gt,dh as h,Dc as ht,kg as i,ku as it,mp as j,ri as jt,Xp as k,yi as kt,Hh as l,vl as lt,uh as m,tl as mt,Fg as n,Sf as nt,Tg as o,Hl as ot,gh as p,el as pt,If as q,Vn as qt,Ag as r,ff as rt,Wh as s,Nl as st,Pg as t,Ef as tt,bh as u,ll as ut,oh as v,$s as vt,um as w,Gi as wt,mm as x,na as xt,Bm as y,ga as yt,Wf as z,Fr as zt};
|
|
34
|
+
`),"aria-label":r.map(um).join(`, `),children:r.slice(0,3).map(e=>(0,B.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:sm(e.who)}},`${e.who}|${e.tab}`))}):null]}),(0,B.jsxs)(`div`,{className:`flex items-center`,children:[(0,B.jsx)(mm,{wizard:e,className:`opacity-0 transition group-hover/card:opacity-100 has-[[aria-expanded=true]]:opacity-100 focus-within:opacity-100 coarse:opacity-100`}),s?(0,B.jsx)(ym,{url:s}):o.kind===`here`&&i?(0,B.jsx)(bm,{}):null,c?(0,B.jsx)(ge,{label:R(s?`share.open`:`share.openHere`),className:`ml-1 size-8`,onClick:e=>{e.stopPropagation(),Wf(c)},children:(0,B.jsx)(Vn,{className:`size-4`})}):null]})]})]})]})}var Sm=[`draft`,`here`,`live`,`missing`],Cm={draft:ht,here:Fr,live:xi,missing:wt},wm=e=>R(e===`draft`?`home.draft`:e===`here`?`where.here`:e===`live`?`home.live`:`where.missing`);function Tm(e,t){let{kind:n}=np(e,t,e.cloud);return n===`draft`||n===`here`?n:n===`live`||n===`unknown`?`live`:`missing`}function Em({wizards:e,me:t,value:n,onChange:r}){let i=new Map;for(let n of e){let e=Tm(n,t);i.set(e,(i.get(e)??0)+1)}if(i.size<2)return null;let a=e=>P(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] transition`,e?`bg-paper-2 text-ink`:`text-ink-3 hover:text-ink`);return(0,B.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-1`,children:[(0,B.jsxs)(`button`,{type:`button`,className:a(n===null),onClick:()=>r(null),children:[R(`home.all`),(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:e.length})]}),Sm.filter(e=>i.has(e)).map(e=>{let t=Cm[e];return(0,B.jsxs)(`button`,{type:`button`,"aria-pressed":n===e,className:a(n===e),onClick:()=>r(n===e?null:e),children:[(0,B.jsx)(t,{className:`size-3.5`}),wm(e),(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:i.get(e)})]},e)})]})}var Dm=12,Om=3;function km({value:e,onChange:t}){return(0,B.jsxs)(`label`,{className:`relative flex h-10 w-full max-w-md items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[(0,B.jsx)(Pe,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:R(`home.search`),"aria-label":R(`home.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),e?(0,B.jsx)(`button`,{type:`button`,"aria-label":R(`market.reset`),onClick:()=>t(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,B.jsx)(it,{className:`size-4`})}):null]})}var Am=`curl -fsSL https://engenty.ai/install.sh | bash`;function jm(){let[e,t]=(0,z.useState)(!1),n=[R(`home.local.install`),R(`home.local.signIn`),R(`home.local.publish`)];return(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-xl animate-rise flex-col items-center pt-4 text-center`,children:[(0,B.jsx)(sn,{kind:`round`,size:120}),(0,B.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[1.75rem] leading-tight tracking-tight`,children:R(`home.local.title`)}),(0,B.jsx)(`p`,{className:`mt-3 text-[0.9375rem] text-ink-2 leading-relaxed`,children:R(`home.local.text`)}),(0,B.jsx)(`ol`,{className:`mt-8 flex w-full flex-col gap-4 text-left`,children:n.map((n,r)=>(0,B.jsxs)(`li`,{className:`flex gap-3`,children:[(0,B.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-paper-2 font-medium text-[0.8125rem] text-ink-2`,children:r+1}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,B.jsx)(`p`,{className:`text-[0.9375rem] leading-snug`,children:n}),r===0?(0,B.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-lg bg-paper-2 py-1.5 pr-1.5 pl-3`,children:[(0,B.jsx)(`code`,{className:`min-w-0 flex-1 select-all overflow-x-auto whitespace-nowrap font-mono text-[0.8125rem] text-ink-2`,children:Am}),(0,B.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(Am),t(!0),setTimeout(()=>t(!1),1500)},children:[e?(0,B.jsx)(fe,{className:`size-3.5`}):(0,B.jsx)(le,{className:`size-3.5`}),R(e?`share.copied`:`share.copy`)]})]}):null]})]},n))})]})}function Mm(){let e=Re(),t=D(),{project:n,projects:r,loading:i}=I(),a=Yt().data,o=tn(),s=Xt(),c=at({queryKey:[`wizards`,n?.id,!!a?.account],queryFn:()=>_.get(`/api/studio/projects/${n.id}/wizards`),enabled:!!n}),l=vp().data??[],u=Jp(`wizard`),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(``),h=(c.data?.length??0)>Dm,g=h?p.trim().toLowerCase():``,v=(c.data??[]).filter(e=>(!d||!a||Tm(e,a)===d)&&(!g||`${e.title} ${e.description}`.toLowerCase().includes(g))),y=!!g&&v.length<Om,b=Pt({mutationFn:e=>_.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:L}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:O.spaces()}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),x=r.reduce((e,t)=>e+t.wizardCount,0),S=s&&!n?.readOnly;return!i&&S&&r.length&&x===0?(0,B.jsx)(ke,{to:`/new`,replace:!0}):!i&&!o&&r.length===0?(0,B.jsx)(jm,{}):(0,B.jsxs)(`div`,{className:`animate-rise`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[h?(0,B.jsx)(km,{value:p,onChange:m}):(0,B.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] tracking-tight`,children:R(`home.title`,{space:n?.name??``})}),S?(0,B.jsxs)(k,{onClick:()=>e(`/new`),children:[(0,B.jsx)(vt,{className:`size-4`}),` `,R(`home.new`)]}):null]}),n?.origin===`local`?(0,B.jsxs)(`p`,{className:`mt-2 text-[0.875rem] text-ink-3`,children:[R(`home.fromLocal`),` `,n.syncedAt?R(`home.syncedAt`,{when:new Intl.DateTimeFormat(L,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n.syncedAt))}):null]}):null,c.data&&c.data.length===0?(0,B.jsxs)(w,{children:[(0,B.jsx)(`p`,{children:R(`home.empty`)}),S?(0,B.jsxs)(k,{className:`mt-5`,onClick:()=>e(`/new`),children:[(0,B.jsx)(vt,{className:`size-4`}),` `,R(`home.new`)]}):null]}):null,c.data?.length&&a?(0,B.jsx)(Em,{wizards:c.data,me:a,value:d,onChange:f}):null,g&&v.length===0?(0,B.jsx)(`p`,{className:`mt-6 text-[0.875rem] text-ink-3`,children:R(`home.noMatch`)}):null,(0,B.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:a?v.map(e=>(0,B.jsx)(xm,{w:e,me:a,runners:l,present:u?.[e.id]?.filter(e=>e.who!==a.user.id)},e.id)):null}),y?(0,B.jsxs)(B.Fragment,{children:[S?(0,B.jsx)(Ot,{query:p,busy:b.isPending,onUse:e=>n&&!b.isPending&&b.mutate(e.id)}):(0,B.jsx)(Ot,{query:p}),S?(0,B.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,B.jsxs)(k,{variant:`secondary`,onClick:()=>e(`/new?wish=${encodeURIComponent(p.trim())}`),children:[(0,B.jsx)(Ye,{className:`size-4`}),` `,R(`home.newFromSearch`,{q:p.trim()})]})}):null]}):null]})}var Nm=(0,z.lazy)(()=>It(()=>import(`./ChangelogDialog-Cxwkcjdy.js`).then(e=>({default:e.ChangelogDialog})),__vite__mapDeps([11,1,2,3,4,5]))),Pm=`wizards.update-banner`;function Fm(){try{return localStorage.getItem(Pm)}catch{return null}}function Im(){let[e,t]=(0,z.useState)(Fm),[n,r]=(0,z.useState)(!1),{data:i,latest:a,apply:o,busy:s,progress:c}=rc(),l=i&&!i.newer?i.updated?.to??null:null,u=l??(i?.newer?a:null);if(!(i&&u)||e===u&&i.applying===`idle`)return null;let d=()=>{try{localStorage.setItem(Pm,u)}catch{}t(u)},f=c??(l?R(`about.update.updated`,{v:u}):i.pending?.version===u?R(`about.update.ready`,{v:u}):R(`about.update.available`,{v:u}));return(0,B.jsxs)(`div`,{className:`flex items-center gap-3 border-border-soft border-b bg-ember-tint px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[s?(0,B.jsx)(st,{className:`size-4 shrink-0 text-ember-strong`}):(0,B.jsx)(x,{className:`size-4 shrink-0 text-ember-strong`}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1`,children:f}),s?null:(0,B.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`shrink-0 underline transition hover:text-ink`,children:R(`about.update.notes`)}),n?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(Nm,{open:!0,version:u,onClose:()=>r(!1)})}):null,i.canApply&&!l&&(i.applying===`idle`||i.applying===`failed`)?(0,B.jsx)(k,{size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(),children:R(`about.update.install`)}):null,s?null:(0,B.jsx)(ge,{label:R(`install.app.close`),onClick:d,className:`size-8`,children:(0,B.jsx)(it,{className:`size-4`})})]})}var Lm=[],Rm=new Set;function zm(e){Lm=e;for(let e of Rm)e()}function Bm(e){let t=JSON.stringify(e);(0,z.useEffect)(()=>(zm(JSON.parse(t)),()=>zm([])),[t])}function Vm(){return Lm}function Hm(){return(0,z.useSyncExternalStore)(e=>(Rm.add(e),()=>Rm.delete(e)),()=>Lm)}function Um({alone:e=!1}){let t=Hm();return t.length?(0,B.jsx)(`nav`,{"aria-label":R(`nav.breadcrumb`),className:`flex min-w-0 items-center text-[0.9375rem] max-sm:hidden`,children:t.map((n,r)=>(0,B.jsxs)(z.Fragment,{children:[e&&r===0?null:(0,B.jsx)(`span`,{className:P(`mr-2 text-ink-4`,r===0?`-ml-1 sm:-ml-2`:`ml-2`),children:`/`}),n.to&&r<t.length-1?(0,B.jsx)(ce,{to:n.to,className:`truncate text-ink-3 transition hover:text-ink`,children:n.label}):(0,B.jsx)(`span`,{"aria-current":`page`,className:`truncate font-medium text-ink`,children:n.label})]},`${r}:${n.label}`))}):null}var Wm=e=>e.manageUrl??e.account?.url??null;function Gm(e){let t=Wm(e);return t?`${t}/billing`:null}function Km({me:e}){let t=qt(e),n=Gm(e);return t===null||!n?null:(0,B.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:P(`flex h-8 shrink-0 items-center whitespace-nowrap rounded-full px-3 font-medium text-[0.8125rem] tabular-nums transition`,t<50?`bg-amber-tint text-ink`:`bg-paper-2 text-ink-2 hover:text-ink`),children:R(`nav.credits`,{n:Math.floor(t).toLocaleString(L)})})}function qm(e,t){return e.mode===`local`?e.account?e.account.signedIn?`linked`:`expired`:t?`alone`:null:null}function Jm(e,t,n){let r=(0,z.useRef)(n);r.current=n,(0,z.useEffect)(()=>{if(!t)return;let n=t=>{e.current?.contains(t.target)||r.current()},i=e=>{e.key===`Escape`&&r.current()};return document.addEventListener(`pointerdown`,n),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,n),document.removeEventListener(`keydown`,i)}},[e,t])}function Ym(e,t,n){return e===`below`?n:ha(t,e===`bar-start`?`start`:`end`)}var Xm=e=>`oklch(from ${e} calc(0.16 + 0.83 * clamp(0, (0.65 - l) * 1000, 1)) 0.01 h)`;function Zm({project:e,name:t,size:n=`md`}){let r=e?.brand.colors?.[0]?.value,i=nn(t??e?.name??``),a=(0,B.jsx)(`span`,{className:P(`grid shrink-0 place-items-center font-semibold tracking-wide`,n===`md`?`size-10 rounded-lg text-[0.8125rem]`:n===`sm`?`size-9 rounded-lg text-[0.75rem]`:`size-6 rounded-md text-[0.5625rem]`,r?null:`bg-paper-3 text-ink ring-1 ring-border`),style:r?{background:r,color:Xm(r)}:void 0,children:i||(0,B.jsx)(_r,{className:`size-4`})});return e?.origin===`local`?(0,B.jsxs)(`span`,{className:`relative shrink-0`,title:R(`readonly.project`),children:[a,(0,B.jsx)(`span`,{className:`-right-1 -bottom-1 absolute grid size-4 place-items-center rounded-full bg-amber ring-2 ring-paper`,children:(0,B.jsx)(Fr,{className:`size-2.5 text-paper`})})]}):a}function Qm(e){let{projects:t}=I();return e.mode===`managed`&&!!e.tenant.name&&e.limits.projects===1&&t.length<=1}function $m({me:e,placement:t,label:n,className:r,children:i}){let a=Re(),{position:o,phone:s}=fa(),{project:c,projects:l,select:d}=I(),f=Qm(e),p=gc(e),m=Xt(),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(!1),[x,S]=(0,z.useState)(!1),C=mc(e),[ee,w]=(0,z.useState)({top:0,left:0}),te=(0,z.useRef)(null);Jm(te,h,()=>g(!1));let T=e.limits.projects,E=T!==null&&l.length>=T,ne=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 transition hover:bg-accent hover:text-ink`;return(0,B.jsx)(`div`,{className:`shrink-0`,ref:te,children:(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();w({top:t.bottom+6,left:t.left}),g(e=>!e)},"aria-expanded":h,"aria-haspopup":`menu`,"aria-label":n,title:f?void 0:R(`nav.switchSpace`),className:typeof r==`function`?r(h):r,children:i}),h?(0,B.jsxs)(`div`,{role:`menu`,style:t===`below`?{position:`fixed`,...ee}:void 0,className:P(`z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,t===`below`?null:P(`absolute`,Ym(t,o,`top-10 left-0`))),children:[f&&fc(e)&&!s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:R(`organizations.mine`)}),(0,B.jsx)(_c,{me:e,onDone:()=>g(!1)}),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`})]}):null,f&&!(fc(e)&&s)?null:C&&fc(e)?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition hover:bg-accent`,onClick:()=>{g(!1),S(!0)},children:[(0,B.jsx)(hc,{org:C,size:`xs`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,B.jsx)(`span`,{className:`truncate font-semibold text-[0.875rem] text-ink`,children:C.name}),C.plan?(0,B.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:C.plan.name}):null]}),(0,B.jsx)(`span`,{className:`shrink-0 text-[0.8125rem] text-ink-3`,children:R(`organizations.switchShort`)}),(0,B.jsx)(u,{className:`size-4 shrink-0 text-ink-4`})]}),(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`})]}):e.tenant.name?(0,B.jsx)(`div`,{className:`truncate px-2 pt-1.5 pb-1 text-[0.75rem] text-ink-3`,children:e.tenant.name}):null,(f?[]:l).map(e=>{let t=e.id===c?.id;return(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition hover:bg-accent`,onClick:()=>{g(!1),t?a(`/`):d(e.id)},children:[(0,B.jsx)(Zm,{project:e,size:`sm`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,B.jsx)(`span`,{className:P(`truncate text-[0.875rem]`,t?`font-semibold text-ink`:`font-medium text-ink-2`),children:e.name}),(0,B.jsx)(`span`,{className:`truncate text-[0.75rem] text-ink-4`,children:R(`nav.wizardCount`,{n:e.wizardCount})})]}),t?(0,B.jsx)(fe,{className:`size-4 shrink-0 text-ember-strong`}):null]},e.id)}),f?null:(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),[{to:`/`,icon:Dt,label:R(f?`nav.allWizards`:`nav.wizardsInSpace`),show:!0},{to:`/new`,icon:vt,label:R(`nav.addWizard`),show:m}].filter(e=>e.show).map(e=>(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:ne,onClick:()=>{g(!1),a(e.to)},children:[(0,B.jsx)(e.icon,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.label})]},e.to)),f&&!fc(e)?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:ne,onClick:()=>{g(!1),p()},children:[(0,B.jsx)(ji,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:R(`organizations.manage`)})]})]}):null,c&&!c.readOnly&&!f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:ne,onClick:()=>{g(!1),b(!0)},children:[(0,B.jsx)(we,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:R(`nav.renameSpace`)})]})]}):null,m&&!E?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:ne,onClick:()=>{g(!1),v(!0)},children:[(0,B.jsx)(vt,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:(0,B.jsx)(`span`,{className:`truncate`,children:R(`nav.addSpace`)})})]})]}):null]}):null,(0,B.jsx)(_m,{open:_,onClose:()=>v(!1)}),fc(e)?(0,B.jsx)(yc,{me:e,open:x,onClose:()=>S(!1)}):null,c?(0,B.jsx)(eh,{project:c,open:y,onClose:()=>b(!1)}):null]})})}function eh({project:e,open:t,onClose:n}){let r=D(),[i,a]=(0,z.useState)(e.name);(0,z.useEffect)(()=>{t&&a(e.name)},[t,e.name]);let o=Pt({mutationFn:()=>_.patch(`/api/studio/projects/${e.id}`,{name:i.trim()}),onSuccess:async()=>{await r.invalidateQueries({queryKey:O.spaces()}),n()}});return(0,B.jsx)(Qe,{open:t,onClose:n,title:R(`nav.renameSpace`),children:(0,B.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,B.jsx)(me,{autoFocus:!0,maxLength:80,"aria-label":R(`nav.renameSpace`),value:i,onChange:e=>a(e.target.value)}),(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,B.jsx)(k,{variant:`ghost`,onClick:n,children:R(`common.cancel`)}),(0,B.jsx)(k,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:R(`settings.save`)})]})]})})}function th({me:e,project:t}){let n=e.mode===`local`||t.origin===`local`,r=n?Fr:ar,i=R(n?`nav.spaceLocal`:`nav.spaceCloud`);return(0,B.jsx)(`span`,{title:i,className:`grid size-6 shrink-0 place-items-center text-ink-4`,children:(0,B.jsx)(r,{className:`size-3.5`,"aria-label":i})})}function nh({me:e}){let{project:t}=I(),{phone:n}=fa(),r=Qm(e);return t?r&&e.tenant.name?(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,B.jsxs)($m,{me:e,placement:`below`,label:e.tenant.name,className:e=>P(n?`-ml-1 flex max-w-[16rem] items-center gap-2.5 rounded-xl py-1 pr-2 pl-1`:`-mx-1 flex max-w-[16rem] items-center gap-1 rounded-md px-2 py-0.5`,`text-left font-medium text-[0.9375rem] text-ink transition hover:bg-accent`,e&&`bg-accent`),children:[n?(0,B.jsx)(Zm,{project:t,name:e.tenant.name,size:`sm`}):null,(0,B.jsx)(`span`,{className:`truncate`,children:e.tenant.name}),(0,B.jsx)($n,{className:`size-3.5 shrink-0 text-ink-4`})]}),(0,B.jsx)(th,{me:e,project:t})]}):(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[e.tenant.name&&!n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(vc,{me:e,className:`max-lg:hidden`}),(0,B.jsx)(`span`,{className:`text-ink-4 max-lg:hidden`,"aria-hidden":`true`,children:`/`})]}):null,(0,B.jsx)($m,{me:e,placement:`below`,label:t.name,className:e=>P(n?`-ml-1 flex max-w-[16rem] items-center gap-2.5 rounded-xl py-1 pr-2 pl-1 text-left font-medium text-[0.9375rem] text-ink transition hover:bg-accent`:`-mx-1 max-w-[16rem] translate-y-[0.5px] truncate rounded-md px-2 py-0.5 text-left font-medium text-[0.9375rem] text-ink transition hover:bg-accent`,e&&`bg-accent`),children:n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Zm,{project:t,size:`sm`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col leading-tight`,children:[e.tenant.name?(0,B.jsx)(`span`,{className:`truncate font-normal text-[0.75rem] text-ink-3`,children:e.tenant.name}):null,(0,B.jsx)(`span`,{className:`truncate`,children:t.name})]})]}):t.name}),(0,B.jsx)(th,{me:e,project:t})]}):null}function rh({me:e,placement:t=`below`,named:n}){let[r,i]=(0,z.useState)(!1),a=(0,z.useRef)(null),o=Re(),{position:s,phone:c}=fa();Jm(a,r,()=>i(!1));let l=Ta(),[u,d]=(0,z.useState)(!1),f=nn(e.user.name),p=qm(e,va(`account`)),m=`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`;return(0,B.jsxs)(`div`,{className:P(`relative`,n&&`w-full`),ref:a,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:n?P(`flex w-full items-center gap-3 rounded-lg p-0.5 pr-2 text-left transition hover:bg-ink/10`,r&&`bg-ink/10`):`block shrink-0 rounded-full`,"aria-label":e.user.name||`Menu`,children:[(0,B.jsxs)(`span`,{className:P(`relative flex shrink-0 items-center justify-center rounded-full bg-ember-tint font-semibold text-[0.8125rem] text-ember-strong ring-1 ring-border-soft`,t===`below`?`size-9`:`size-10`),children:[e.user.image?(0,B.jsx)(`img`,{src:e.user.image,alt:``,className:`size-full rounded-full object-cover`}):f,p===`linked`||p===`expired`?(0,B.jsx)(`span`,{title:p===`linked`?R(`nav.connected`,{host:tp(e.account?.cloudUrl??``)}):R(`nav.expired`),className:`-right-1 -bottom-1 absolute flex size-4 items-center justify-center rounded-full bg-card ring-1 ring-border-soft`,children:p===`linked`?(0,B.jsx)(ar,{className:`size-2.5 text-moss`}):(0,B.jsx)(wt,{className:`size-2.5 text-amber`})}):null]}),n?(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem] text-ink-2`,children:e.user.name}):null]}),r?(0,B.jsxs)(`div`,{className:P(`absolute z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,Ym(t,s,`top-11 right-0`)),children:[(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5`,children:[(0,B.jsxs)(`div`,{className:`truncate font-medium text-[0.875rem]`,children:[e.user.name,p===`alone`?(0,B.jsxs)(`span`,{className:`font-normal text-ink-4`,children:[` (`,R(`nav.local`),`)`]}):null]}),(0,B.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.user.email}),e.tenant.name?(0,B.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 text-[0.75rem] text-ink-2`,children:[(0,B.jsx)(qn,{className:`size-3.5 shrink-0 text-ink-4`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.tenant.name})]}):null]}),p?(0,B.jsxs)(`button`,{type:`button`,className:`mx-1.5 mb-1.5 flex w-[calc(100%-0.75rem)] items-start gap-2.5 rounded-lg bg-paper-2 px-2.5 py-2 text-left text-[0.8125rem] text-ink-2 hover:text-ink`,onClick:()=>{i(!1),o(`/settings/account`)},children:[p===`linked`?(0,B.jsx)(ar,{className:`mt-0.5 size-4 shrink-0 text-moss`}):p===`expired`?(0,B.jsx)(wt,{className:`mt-0.5 size-4 shrink-0 text-amber`}):(0,B.jsx)(Fr,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-snug`,children:[(0,B.jsx)(`span`,{className:`break-words`,children:p===`linked`?R(`nav.connected`,{host:tp(e.account?.cloudUrl??``)}):R(p===`expired`?`nav.expired`:`nav.onlyHere`)}),(0,B.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:p===`linked`?e.account?.credits!==null&&e.account?.credits!==void 0?R(`nav.credits`,{n:Math.floor(e.account.credits).toLocaleString(L)}):null:R(p===`expired`?`account.signInAgain`:`account.signIn`)})]})]}):null,e.mode===`managed`&&na(e.features,`organizationSettings`)?(0,B.jsxs)(`button`,{type:`button`,className:m,onClick:()=>{i(!1),o(`/account`)},children:[(0,B.jsx)(Gi,{className:`size-4`}),` `,R(`konto.title`)]}):e.manageUrl?(0,B.jsxs)(`a`,{className:m,href:`${e.manageUrl}/account`,target:`_blank`,rel:`noreferrer`,children:[(0,B.jsx)(lr,{className:`size-4`}),` `,R(`nav.account`)]}):null,c&&!ya()?(0,B.jsxs)(`button`,{type:`button`,className:m,onClick:()=>{i(!1),l?Ea(l):d(!0)},children:[(0,B.jsx)(kt,{className:`size-4`}),` `,R(`install.app.action`)]}):null,(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 text-[0.875rem] text-ink-2`,children:[R(`nav.theme`),(0,B.jsx)(ep,{})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 text-[0.875rem] text-ink-2`,children:[R(`nav.language`),(0,B.jsx)(Ef,{tone:`surface`})]}),e.mode===`managed`?(0,B.jsxs)(`button`,{type:`button`,className:m,onClick:()=>{i(!1),Vs({where:`studio`})},children:[(0,B.jsx)(Et,{className:`size-4`}),` `,R(`report.open`)]}):null,e.mode===`managed`?(0,B.jsxs)(`button`,{type:`button`,className:m,onClick:()=>void on(),children:[(0,B.jsx)(Ur,{className:`size-4`}),` `,R(`nav.logout`)]}):null]}):null,(0,B.jsx)(sc,{open:u,onClose:()=>d(!1)})]})}function ih({me:e,children:t}){let{phone:n}=fa(),r=tt().pathname.startsWith(`/account`);return(0,B.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 px-3 coarse:h-14 sm:gap-3 sm:px-4 md:px-5`,children:[r?null:(0,B.jsx)(nh,{me:e}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,B.jsx)(Um,{alone:r}),t]}),r?null:(0,B.jsx)(Km,{me:e}),n?(0,B.jsx)(rh,{me:e}):null]})}var ah=`studio-scroll`;function oh(){return document.getElementById(`studio-scroll`)??document.documentElement}var sh={left:`md:py-2 md:pr-2`,right:`md:py-2 md:pl-2`,top:`md:px-2 md:pb-2`,bottom:`md:px-2 md:pt-2`},ch={left:`flex-row`,right:`flex-row-reverse`,top:`flex-col`,bottom:`flex-col-reverse`};function lh({me:e,wide:t,full:n,children:r}){let{position:i,phone:a}=fa(),o=(0,z.useRef)(null),s=a&&!n?`calc(4.75rem + env(safe-area-inset-bottom))`:`0px`,c=va(`goose`),l=yf()&&c&&!n,u=ma(!!n||l);return tm(e.tenant.id),(0,B.jsxs)(`div`,{className:P(`flex h-dvh overflow-hidden bg-sidebar`,ch[i]),children:[a?n?null:(0,B.jsx)(Vc,{me:e}):(0,B.jsx)(Lc,{me:e,labels:u.shown,room:u.room}),(0,B.jsxs)(`div`,{className:P(`flex min-h-0 min-w-0 flex-1 md:gap-2`,sh[i]),children:[(0,B.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background md:rounded-xl md:shadow-elevated md:dark:ring-1 md:dark:ring-border-soft`,children:[e.impersonation?(0,B.jsx)(Xi,{name:e.user.name||e.user.email,until:e.impersonation.until}):null,(0,B.jsx)(Im,{}),(0,B.jsx)(dc,{me:e}),(0,B.jsx)(Vl,{me:e}),n?(0,B.jsx)(`main`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden`,children:r}):(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(ih,{me:e}),(0,B.jsxs)(`div`,{ref:o,className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,B.jsx)(`main`,{id:ah,className:`relative min-h-0 flex-1 overflow-y-auto`,style:{paddingBottom:`max(var(--assistant-dock, 0px), ${s})`},children:(0,B.jsx)(`div`,{className:P(`mx-auto w-full px-3 pt-4 pb-12 sm:px-6 sm:pt-6`,t?`max-w-[88rem]`:`max-w-5xl`),children:r})}),c&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(mf,{column:o}),(0,B.jsx)(xf,{})]})]})]})]}),c&&!n?(0,B.jsx)(bf,{}):null]})]})}function uh(){return[{id:`info`,label:R(`space.info`),icon:pr},{id:`brand`,label:R(`space.brand`),icon:Li},{id:`knowledge`,label:R(`space.knowledge`),icon:Gn},{id:`data`,label:R(`space.data`),icon:E},{id:`page`,label:R(`space.page`),icon:zt}]}function dh(e,t){let n=[...e];for(let e of t.spaceParts){let r=n.findIndex(t=>t.id===(e.after??`data`))+1;for(;r<n.length&&t.spaceParts.some(e=>e.id===n[r].id);)r++;n.splice(r,0,{id:e.id,label:e.label(),icon:e.icon})}return n}function fh(e){return e===`info`||e===`brand`||e===`knowledge`||e===`data`||e===`page`||e===`results`}var ph=[{id:`base`,group:`info`,label:`project.base`,icon:jt},{id:`facts`,group:`info`,label:`project.facts`,icon:Tt},{id:`logos`,group:`brand`,label:`project.logos`,icon:Ni},{id:`colors`,group:`brand`,label:`project.colors`,icon:ai},{id:`typography`,group:`brand`,label:`project.typography`,icon:Fn},{id:`assets`,group:`brand`,label:`project.assets`,icon:Dr},{id:`documents`,group:`knowledge`,label:`project.documents`,icon:re},{id:`page`,group:`page`,label:`page.sectionPage`,icon:zt},{id:`page-words`,group:`page`,label:`page.sectionWords`,icon:jt},{id:`page-wizards`,group:`page`,label:`page.sectionWizards`,icon:zr}],mh=ph.map(e=>e.id);function hh(e,t){let n=t.spaceSections.find(t=>t.id===e);return ph.find(t=>t.id===e)?.group??(n?n.group??`knowledge`:null)}function gh(e,t,n=[]){let r=ph.filter(t=>t.group===e&&!n.includes(t.id)).map(e=>({id:e.id,label:R(e.label),icon:e.icon})),i=new Map;for(let n of t.spaceSections){if((n.group??`knowledge`)!==e)continue;let t=i.get(n.plugin)??[];t.push({id:n.id,label:n.label()}),i.set(n.plugin,t)}return[...r.length?[{plugin:null,label:null,sections:r}]:[],...[...i].map(([e,n])=>({plugin:e,label:t.plugins.find(t=>t.id===e)?.name??e,sections:n}))]}globalThis.__WIZARDS_STUDIO__={react:z,jsx:B,reactDom:{createPortal:ea.createPortal,flushSync:ea.flushSync},router:{Link:ce,Navigate:ke,NavLink:o,useLocation:tt,useNavigate:Re,useParams:N,useSearchParams:qe},query:{useMutation:Pt,useQuery:at,useQueryClient:D},ui:ot,sdk:Qi};var _h=0,$={status:`idle`,plugins:[],canReload:!1,problems:[],failed:{},pages:[],nav:[],sections:[],spaceSections:[],spaceParts:[],spaceMenus:{},shareSections:[],shareSetups:[],cards:[]},vh=new Set;function yh(e){$={...$,...e};for(let e of vh)e()}function bh(){return(0,z.useSyncExternalStore)(e=>(vh.add(e),()=>vh.delete(e)),()=>$)}var xh=new Set([`account`,`project`,`connectors`,`models`,`build`,`plugins`]),Sh=new Set([`info`,`brand`,`knowledge`,`data`,`page`,`results`]),Ch=new Map,wh=null,Th=e=>`${e.script}|${e.styles}`,Eh=e=>`__wizardsPlugin_${e.replaceAll(`-`,`_`)}`;function Dh(){let{project:e}=I(),t=e?.id,n=e?.name??``,r=e?.readOnly??!1,i=JSON.stringify({name:e?.brand.name??``,colors:(e?.brand.colors??[]).map(({name:e,value:t})=>({name:e,value:t})),fonts:(e?.brand.fonts??[]).map(({family:e,role:t,weights:n})=>({family:e,role:t,weights:n}))});return(0,z.useMemo)(()=>t?{id:t,name:n,readOnly:r,brand:JSON.parse(i)}:null,[t,n,r,i])}var Oh=(0,z.createContext)(null);function kh({part:e,children:t}){return(0,B.jsx)(Oh.Provider,{value:e,children:t})}function Ah(e){let t=(0,z.useContext)(Oh),n=JSON.stringify(e.map(e=>[e.id,e.label]));(0,z.useEffect)(()=>{if(t)return yh({spaceMenus:{...$.spaceMenus,[t]:e}}),()=>{let{[t]:e,...n}=$.spaceMenus;yh({spaceMenus:n})}},[t,n])}function jh({plugin:e,...t}){return ku({...t,plugin:e}),null}function Mh(e,t){let{id:n}=e,r=e=>`/api/studio/plugins/${n}${e.startsWith(`/`)?e:`/${e}`}`,i=e=>e.filter(e=>e.plugin!==n);return{plugin:{id:n,name:e.name,version:e.version},registerPage(e){let r=e.path.split(`/`)[1]??``;if(!e.path.startsWith(`/`)||Ae.has(r))throw Error(`"${e.path}" is an address of the studio itself.`);if([...i($.pages),...t.pages].some(t=>t.path===e.path))throw Error(`"${e.path}" is registered already.`);t.pages.push({...e,plugin:n,serial:++_h})},registerNav(e){t.nav.push({...e,plugin:n,serial:++_h})},registerSettingsSection(e){let r=[...i($.sections),...t.sections].some(t=>t.id===e.id);if(xh.has(e.id)||r)throw Error(`The settings have a section "${e.id}" already.`);t.sections.push({...e,plugin:n,serial:++_h})},registerSpaceSection(e){let r=[...i($.spaceSections),...t.spaceSections].some(t=>t.id===e.id);if(mh.includes(e.id)||r)throw Error(`The space page has a section "${e.id}" already.`);t.spaceSections.push({...e,plugin:n,serial:++_h})},registerSpacePart(e){let r=[...i($.spaceParts),...t.spaceParts].some(t=>t.id===e.id);if(!/^[a-z][a-z0-9-]{0,39}$/.test(e.id)||Sh.has(e.id)||r)throw Error(`The space page has a part "${e.id}" already.`);t.spaceParts.push({...e,plugin:n,serial:++_h})},registerShareSection(e){if([...i($.shareSections),...t.shareSections].some(t=>t.runner===e.runner))throw Error(`The runner "${e.runner}" has a share section already.`);t.shareSections.push({...e,plugin:n,serial:++_h})},registerShareSetup(e){if([...i($.shareSetups),...t.shareSetups].some(t=>t.runner===e.runner))throw Error(`The runner "${e.runner}" has a share setup already.`);t.shareSetups.push({...e,plugin:n,serial:++_h})},registerAssistantCard(e){if(t.cards.some(t=>t.tool===e.tool))throw Error(`The tool "${e.tool}" has a card already.`);t.cards.push({...e,plugin:n,serial:++_h})},useSpace:Dh,useSpaceMenu:Ah,useCrumbs:Bm,Assistant:e=>(0,B.jsx)(jh,{plugin:n,...e}),useAssistantPage:e=>ku({...e,plugin:n}),useAssistantTool:(e,t,r)=>nd(`${n.replaceAll(`-`,`_`)}_${e}`,t,r),i18n:{register:e=>(t,n)=>{let r=e[L]?.[t]??e.de[t]??t;for(let[e,t]of Object.entries(n??{}))r=r.replace(`{${e}}`,String(t));return r},lang:()=>L},api:{get:e=>_.get(r(e)),post:(e,t)=>_.post(r(e),t),put:(e,t)=>_.put(r(e),t),patch:(e,t)=>_.patch(r(e),t),del:e=>_.del(r(e))},me:()=>({user:{id:wh.user.id,name:wh.user.name,email:wh.user.email},tenant:wh.tenant,mode:wh.mode}),onUnload(e){t.disposers.push(e)}}}function Nh(e){return new Promise((t,n)=>{let r=document.createElement(`script`);r.src=e,r.onload=()=>{r.remove(),t()},r.onerror=()=>{r.remove(),n(Error(`The plugin's script did not load.`))},document.head.append(r)})}function Ph(e,t){return new Promise(n=>{let r=document.createElement(`link`);r.rel=`stylesheet`,r.href=t,r.dataset.plugin=e,r.onload=()=>n(r),r.onerror=()=>n(r),document.head.append(r)})}function Fh(e,t,n){for(let n of t)try{n()}catch(t){console.error(`[plugin ${e}]`,t)}n?.remove()}function Ih(e){let t=Ch.get(e);Ch.delete(e),Fh(e,t?.disposers??[],t?.link??null);let{[e]:n,...r}=$.failed;yh({failed:r,pages:$.pages.filter(t=>t.plugin!==e),nav:$.nav.filter(t=>t.plugin!==e),sections:$.sections.filter(t=>t.plugin!==e),spaceSections:$.spaceSections.filter(t=>t.plugin!==e),spaceParts:$.spaceParts.filter(t=>t.plugin!==e),shareSections:$.shareSections.filter(t=>t.plugin!==e),shareSetups:$.shareSetups.filter(t=>t.plugin!==e),cards:$.cards.filter(t=>t.plugin!==e)})}async function Lh(e){let{id:t}=e,n={pages:[],nav:[],sections:[],spaceSections:[],spaceParts:[],shareSections:[],shareSetups:[],cards:[],disposers:[]},r=null;try{e.styles&&(r=await Ph(t,Je(e.styles))),await Nh(Je(e.script));let i=globalThis,a=Eh(t),o=i[a];i[a]=void 0;let s=typeof o==`function`?o:o?.default;if(typeof s!=`function`)throw Error(`The plugin's script has no default export.`);s(Mh(e,n))}catch(i){console.error(`[plugin ${t}]`,i),Fh(t,n.disposers,r),Ih(t),Ch.set(t,{key:Th(e),disposers:[],link:null}),yh({failed:{...$.failed,[t]:i.message}});return}let i=Ch.get(t);Ch.set(t,{key:Th(e),disposers:n.disposers,link:r});let{[t]:a,...o}=$.failed;yh({failed:o,pages:[...$.pages.filter(e=>e.plugin!==t),...n.pages],nav:[...$.nav.filter(e=>e.plugin!==t),...n.nav],sections:[...$.sections.filter(e=>e.plugin!==t),...n.sections],spaceSections:[...$.spaceSections.filter(e=>e.plugin!==t),...n.spaceSections],spaceParts:[...$.spaceParts.filter(e=>e.plugin!==t),...n.spaceParts],shareSections:[...$.shareSections.filter(e=>e.plugin!==t),...n.shareSections],shareSetups:[...$.shareSetups.filter(e=>e.plugin!==t),...n.shareSetups],cards:[...$.cards.filter(e=>e.plugin!==t),...n.cards]}),Fh(t,i?.disposers??[],i?.link??null)}var Rh=Promise.resolve();function zh(){return Rh=Rh.catch(()=>void 0).then(async()=>{let e=await _.get(`/api/studio/plugins`);for(let t of[...Ch.keys()])e.plugins.some(e=>e.id===t&&e.script)||Ih(t);yh(e);for(let t of e.plugins)t.script&&Ch.get(t.id)?.key!==Th(t)&&await Lh(t)}).catch(e=>console.error(`[plugins]`,e)).finally(()=>yh({status:`ready`})),Rh}var Bh=null;function Vh(e){wh=e,$.status===`idle`&&(yh({status:`loading`}),zh().then(()=>{$.canReload&&!Bh&&(Bh=new EventSource(Je(`/api/studio/plugins/-/events`),{withCredentials:!0}),Bh.addEventListener(`change`,()=>void zh()))}))}async function Hh(e){await _.post(e?`/api/studio/plugins/-/reload/${e}`:`/api/studio/plugins/-/reload`),await zh()}var Uh=class extends z.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`[plugin]`,e)}render(){return this.state.failed?(0,B.jsx)(w,{children:R(`plugins.crashed`)}):this.props.children}};function Wh({of:e,children:t}){return(0,B.jsx)(`div`,{"data-plugin":e.plugin,className:`contents`,children:(0,B.jsx)(Uh,{children:t},e.serial)})}function Gh({end:e,className:t}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4 ${t??``}`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,B.jsx)(ln,{size:28}),(0,B.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight ${e?`max-sm:sr-only`:``}`,children:[`engenty`,(0,B.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-ember-strong`,children:`.`}),(0,B.jsx)(`span`,{className:`font-normal text-ink-2`,children:`wizards`})]})]}),(0,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:e?`flex max-sm:hidden`:`flex`,children:(0,B.jsx)(ep,{tone:`surface`})}),(0,B.jsx)(Ef,{tone:`surface`}),e]})]})}var Kh={de:{imprint:`/de/impressum`,privacy:`/de/datenschutz`,terms:`/de/nutzungsbedingungen`},en:{imprint:`/imprint`,privacy:`/privacy`,terms:`/terms`}};function qh({failed:e}){let t=gn(),[n,r]=(0,z.useState)(()=>Zt()??``),[i,o]=(0,z.useState)(!1),s=Ve(n,r,{endpoint:null}),c=()=>{let e=n.trim();e&&!i&&(s.listening&&s.stop(),o(!0),an(e),rn(`${a}/new`,e))};return(0,B.jsxs)(`div`,{className:`min-h-dvh px-6 pb-16 sm:px-10`,children:[(0,B.jsx)(Gh,{className:`pt-6 sm:pt-8`,end:(0,B.jsx)(k,{variant:`secondary`,size:`sm`,onClick:()=>rn(`${a}/`),children:R(`guest.signIn`)})}),(0,B.jsxs)(`div`,{className:`mx-auto max-w-2xl animate-rise pt-8 md:pt-12`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,B.jsx)(`div`,{className:`size-[84px] md:size-auto`,children:(0,B.jsx)(`div`,{className:`origin-top-left scale-[0.56] md:scale-100`,children:(0,B.jsx)(sn,{kind:`sprout`,size:150,fluffy:!0})})}),(0,B.jsx)(`h1`,{className:`mt-1 font-display font-semibold text-[1.5rem] leading-tight tracking-tight md:mt-2 md:text-[2.375rem]`,children:R(`new.title`)})]}),(0,B.jsxs)(`div`,{className:`relative mt-6 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus md:mt-8`,children:[(0,B.jsx)(Se,{autoFocus:!0,minRows:4,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&c()},placeholder:s.listening?R(`editor.listening`):R(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pb-1`,children:[s.supported?(0,B.jsx)(Ie,{speech:s,labelled:!0}):null,(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsxs)(k,{size:`md`,onClick:c,busy:i,disabled:!n.trim(),children:[R(`new.build`),` `,(0,B.jsx)(Ze,{className:`size-4`})]})]})]}),s.error?(0,B.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:s.error===`denied`?R(`editor.micDenied`):s.error}):null,e?(0,B.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:R(`auth.failed`)}):null,(0,B.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-ink-3`,children:R(`guest.hint`)})]}),(0,B.jsxs)(`section`,{className:`mx-auto max-w-5xl`,children:[(0,B.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:R(`new.orStarter`)}),(0,B.jsx)(At,{onGuestOpen:e=>rn(`${a}/new?starter=${encodeURIComponent(e.id)}`)})]}),(0,B.jsxs)(`footer`,{className:`mt-16 flex flex-wrap justify-center gap-x-5 gap-y-1 text-[0.75rem] text-ink-3`,children:[(0,B.jsx)(`span`,{children:`engenty.wizards`}),[`imprint`,`privacy`,`terms`].map(e=>(0,B.jsx)(`a`,{href:Kh[t][e],className:`transition hover:text-ink-2`,children:R(`legal.${e}`)},e))]})]})}var Jh=/(?:^|;\s*)engenty_signed_in=1(?:;|$)/;function Yh(){return!!window.engentyDesktop}function Xh({text:e}){return e.split(/(?<=[.!?])\s+/).map(e=>(0,B.jsx)(`span`,{className:`block`,children:e},e))}function Zh({title:e,children:t,className:n=`mt-8`}){return(0,B.jsxs)(`div`,{className:`${n} w-full rounded-xl bg-card px-5 py-4 text-left text-[0.875rem] text-ink-2 leading-relaxed shadow-soft ring-1 ring-border-soft`,children:[(0,B.jsx)(`div`,{className:`mb-1.5 font-medium text-ink`,children:e}),t]})}function Qh({text:e}){let[t,n]=(0,z.useState)(!1);return(0,B.jsxs)(`div`,{className:`mt-2 flex items-center gap-3 rounded-xl bg-[oklch(22%_0.02_262)] py-2.5 pr-2.5 pl-4 font-mono text-[0.9375rem] text-white shadow-soft`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`select-none text-white/40`,children:`$`}),(0,B.jsx)(`code`,{className:`min-w-0 flex-1 select-all break-all`,children:e}),(0,B.jsx)(`button`,{type:`button`,"aria-label":R(t?`settings.copied`:`settings.copy`),title:R(t?`settings.copied`:`settings.copy`),className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-white/60 transition hover:bg-white/10 hover:text-white focus-visible:outline-2 focus-visible:outline-white/60`,onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},children:t?(0,B.jsx)(fe,{className:`size-4`}):(0,B.jsx)(le,{className:`size-4`})})]})}function $h(){let e=at({queryKey:[`config`],queryFn:()=>_.get(`/api/config`),refetchInterval:e=>e.state.status===`error`&&!(e.state.error instanceof ne&&e.state.error.body?.code===`host`)&&2e3,retry:!1}),t=D(),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(!1),o=new URLSearchParams(window.location.search).get(`signin`)===`failed`,s=e.data?.mode===`local`&&e.data.devLogin,[c,l]=(0,z.useState)(!1),u=e.data?.mode===`managed`&&!o&&!Yh()&&Jh.test(document.cookie);if((0,z.useEffect)(()=>{u&&rn()},[u]),(0,z.useEffect)(()=>{if(!s||c)return;let e=!0;return _.post(`/api/dev/login`).then(()=>t.invalidateQueries()).catch(()=>{e&&l(!0)}),()=>{e=!1}},[s,c,t]),e.isLoading||u||s&&!c)return(0,B.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center`,children:(0,B.jsx)(sn,{kind:`round`,size:56})});if(e.data?.mode===`managed`&&!e.data.devLogin&&!Yh())return(0,B.jsx)(qh,{failed:o});let d=e.data?.mode===`local`&&!e.data.devLogin,f=e.error instanceof ne&&e.error.body?.code===`host`?e.error:null,p=f?String(f.body.appUrl??``):null,m=d&&!f&&!e.isError,h=e.data?.openCommand===void 0?`wizards open`:e.data.openCommand;return(0,B.jsxs)(`div`,{className:`relative flex min-h-dvh flex-col items-center justify-center px-6 py-16`,children:[(0,B.jsx)(Gh,{className:`absolute inset-x-6 top-6 sm:inset-x-10 sm:top-8`}),(0,B.jsxs)(`div`,{className:`flex w-full max-w-md animate-rise flex-col items-center text-center`,children:[(0,B.jsx)(sn,{kind:`round`,size:d||e.isError?140:200,fluffy:!0}),(0,B.jsxs)(`span`,{className:`mt-2 font-display font-semibold text-[0.9375rem] text-ink-3 tracking-tight`,children:[(0,B.jsx)(cn,{}),(0,B.jsx)(`span`,{className:`font-normal`,children:`wizards`})]}),(0,B.jsx)(`h1`,{className:`mt-3 text-balance font-display font-semibold text-[2.125rem] leading-[1.1] tracking-tight`,children:m?R(`auth.localTitle`):(0,B.jsx)(Xh,{text:R(`brand.tagline`)})}),m?null:(0,B.jsx)(`p`,{className:`mt-4 text-balance text-[1rem] text-ink-2 leading-relaxed`,children:(0,B.jsx)(Xh,{text:R(`brand.sub`)})}),p?(0,B.jsxs)(Zh,{title:R(`auth.wrongHost`),children:[(0,B.jsx)(`p`,{children:R(`auth.wrongHostWhy`)}),(0,B.jsx)(`a`,{href:`${p}${window.location.pathname}`,className:`mt-1.5 block break-all font-medium text-ember-strong underline-offset-2 hover:underline`,children:p})]}):e.isError?(0,B.jsx)(Zh,{title:R(`auth.unreachable`),children:R(`auth.unreachableWhy`,{address:window.location.host})}):null,(0,B.jsxs)(`div`,{className:`mt-10 flex w-full flex-col gap-3`,children:[o?(0,B.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R(`auth.failed`)}):null,e.data?.mode===`managed`?(0,B.jsx)(k,{size:`lg`,busy:n,className:`w-full`,onClick:async()=>{r(!0);let e=window.engentyDesktop;if(!e){rn();return}let{url:t}=await _.post(`/api/auth/desktop/start`);e.open(t),a(!0),r(!1)},children:R(i?`local.accountWaiting`:`auth.signIn`)}):null,e.data?.devLogin?(0,B.jsx)(k,{size:`lg`,busy:n,className:`w-full`,onClick:async()=>{r(!0),await _.post(`/api/dev/login`),await t.invalidateQueries(),r(!1)},children:R(`auth.dev`)}):null,m?(0,B.jsxs)(`div`,{className:`-mt-6 text-left text-[0.9375rem] text-ink-2 leading-relaxed`,children:[h?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{children:R(`auth.localWhy`)}),(0,B.jsx)(Qh,{text:h}),(0,B.jsx)(`p`,{className:`mt-6 text-[0.875rem] text-ink-3`,children:R(`auth.localStartLink`)}),(0,B.jsx)(Qh,{text:`${h} --print`})]}):(0,B.jsx)(`p`,{children:R(`auth.localFromStart`)}),(0,B.jsx)(`p`,{className:`mt-6 text-center text-[0.875rem] text-ink-3`,children:R(`auth.localNoAccount`)})]}):null]}),e.data?.mode===`managed`?(0,B.jsx)(`p`,{className:`mt-6 text-[0.8125rem] text-ink-3`,children:R(`auth.legal`)}):null]}),(0,B.jsxs)(`footer`,{className:`absolute inset-x-0 bottom-6 text-center text-[0.75rem] text-ink-3 sm:bottom-8`,children:[`© engenty · `,R(`about.version`,{v:$s})]})]})}var eg=(0,z.lazy)(()=>It(()=>import(`./PublicRunner-B5RGNs07.js`).then(e=>({default:e.PublicRunner})),__vite__mapDeps([16,1,2,3,4,5,17,9,14,15,7,6,18,19]))),tg=(0,z.lazy)(()=>It(()=>import(`./SharePage-DF8LO8-K.js`).then(e=>({default:e.SharePage})),__vite__mapDeps([20,1,2,3,4,5,17,9,14,15,7,6,18,19,16]))),ng=(0,z.lazy)(()=>It(()=>import(`./EditorPage-v7cpENx3.js`).then(e=>({default:e.EditorPage})),__vite__mapDeps([21,1,2,3,4,5,12,13,14,15,7,6,9,22,17,18,19,23,24,25,10,26,27]))),rg=(0,z.lazy)(()=>It(()=>Promise.resolve().then(()=>hm).then(e=>({default:e.HomePage})),void 0)),ig=(0,z.lazy)(()=>It(()=>import(`./OnboardingPage-C9XM_VXs.js`).then(e=>({default:e.OnboardingPage})),__vite__mapDeps([28,1,2,3,4,5,13,15,7,6,23]))),ag=(0,z.lazy)(()=>It(()=>import(`./NewWizardPage-Coswm2WX.js`).then(e=>({default:e.NewWizardPage})),__vite__mapDeps([29,1,2,3,4,5,12,13,14,15,7,6,23,27,18,24]))),og=(0,z.lazy)(()=>It(()=>import(`./SettingsPage-CfL1e3Vs.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([30,1,2,3,4,5,12,13,14,15,7,6,25,31,8,9,10,32,33]))),sg=(0,z.lazy)(()=>It(()=>import(`./ProjectPage-Cw7hdXO6.js`).then(e=>({default:e.ProjectPage})),__vite__mapDeps([34,1,2,3,4,5,12,13,14,15,7,6,22,17,9,18,19,23,24,31,8,10]))),cg=(0,z.lazy)(()=>It(()=>import(`./SetupPage-BRPenYa-.js`).then(e=>({default:e.SetupPage})),__vite__mapDeps([35,1,2,3,4,5,13,15,7,6,32,33]))),lg=null;function ug(){return(0,B.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center`,children:(0,B.jsx)(sn,{kind:`round`,size:56})})}function dg({children:e,bare:t,wide:n,full:r}){let i=Yt(),a=tt();return en(i.data),(0,z.useEffect)(()=>{i.data&&Vh(i.data)},[i.data]),i.isLoading?(0,B.jsx)(ug,{}):i.data?i.data.mode===`local`&&!i.data.setupDone&&a.pathname!==`/setup`?(0,B.jsx)(ke,{to:`/setup`,replace:!0}):i.data.onboarding&&a.pathname!==`/start`?(0,B.jsx)(ke,{to:`/start`,replace:!0}):t?(0,B.jsxs)(B.Fragment,{children:[i.data.impersonation?(0,B.jsx)(Xi,{name:i.data.user.name||i.data.user.email,until:i.data.impersonation.until}):null,e]}):(0,B.jsx)(lh,{me:i.data,wide:n,full:r,children:e}):(0,B.jsx)($h,{})}function fg(){return gn(),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(ug,{}),children:(0,B.jsxs)(Ge,{children:[lg,(0,B.jsx)(F,{path:`/w/:token`,element:(0,B.jsx)(eg,{})}),(0,B.jsx)(F,{path:`/w/:token/steps`,element:(0,B.jsx)(eg,{steps:!0})}),(0,B.jsx)(F,{path:`/w/:token/steps/:runId`,element:(0,B.jsx)(eg,{steps:!0})}),(0,B.jsx)(F,{path:`/w/:token/chat`,element:(0,B.jsx)(eg,{chat:!0})}),(0,B.jsx)(F,{path:`/w/:token/chat/:runId`,element:(0,B.jsx)(eg,{chat:!0})}),(0,B.jsx)(F,{path:`/w/:token/talk`,element:(0,B.jsx)(eg,{chat:!0,talk:!0})}),(0,B.jsx)(F,{path:`/w/:token/talk/:runId`,element:(0,B.jsx)(eg,{chat:!0,talk:!0})}),(0,B.jsx)(F,{path:`/w/:token/video`,element:(0,B.jsx)(eg,{chat:!0,video:!0})}),(0,B.jsx)(F,{path:`/w/:token/video/:runId`,element:(0,B.jsx)(eg,{chat:!0,video:!0})}),(0,B.jsx)(F,{path:`/w/:token/:runId`,element:(0,B.jsx)(eg,{})}),(0,B.jsx)(F,{path:`/s/:token`,element:(0,B.jsx)(tg,{})}),(0,B.jsx)(F,{path:`*`,element:(0,B.jsx)(pg,{})})]})})}function pg(){return(0,z.useEffect)(()=>{window.location.replace(`${a}/`)},[]),(0,B.jsx)(ug,{})}function mg(){return bh().status===`ready`?(0,B.jsx)(ke,{to:`/`,replace:!0}):(0,B.jsx)(ug,{})}function hg(){gn(),(0,z.useEffect)(()=>(document.documentElement.dataset.studio=``,()=>{delete document.documentElement.dataset.studio}),[]);let e=bh();return(0,B.jsx)(fd,{children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(ug,{}),children:(0,B.jsxs)(Ge,{children:[(0,B.jsx)(F,{path:`/`,element:(0,B.jsx)(dg,{children:(0,B.jsx)(rg,{})})}),(0,B.jsx)(F,{path:`/sign-in`,element:(0,B.jsx)(dg,{children:(0,B.jsx)(ke,{to:`/`,replace:!0})})}),(0,B.jsx)(F,{path:`/new`,element:(0,B.jsx)(dg,{children:(0,B.jsx)(ag,{})})}),(0,B.jsx)(F,{path:`/edit/:id`,element:(0,B.jsx)(dg,{full:!0,children:(0,B.jsx)(ng,{})})}),(0,B.jsx)(F,{path:`/space/:group?`,element:(0,B.jsx)(dg,{wide:!0,children:(0,B.jsx)(sg,{})})}),(0,B.jsx)(F,{path:`/settings/:section?`,element:(0,B.jsx)(dg,{wide:!0,children:(0,B.jsx)(og,{})})}),(0,B.jsx)(F,{path:`/account/:section?`,element:(0,B.jsx)(dg,{wide:!0,children:(0,B.jsx)(og,{scope:`account`})})}),(0,B.jsx)(F,{path:`/setup`,element:(0,B.jsx)(dg,{bare:!0,children:(0,B.jsx)(cg,{})})}),(0,B.jsx)(F,{path:`/start`,element:(0,B.jsx)(dg,{bare:!0,children:(0,B.jsx)(ig,{})})}),e.pages.map(e=>(0,B.jsx)(F,{path:e.path,element:(0,B.jsx)(dg,{wide:e.wide,children:(0,B.jsx)(Wh,{of:e,children:(0,B.jsx)(e.component,{})})})},e.serial)),(0,B.jsx)(F,{path:`*`,element:(0,B.jsx)(dg,{bare:!0,children:(0,B.jsx)(mg,{})})})]})})})}var gg=class extends z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){Xe(`error`,e.message,e.stack)}render(){let{error:e}=this.state;return e?(0,B.jsxs)(`div`,{className:`flex min-h-dvh flex-col items-center justify-center p-6 text-center`,children:[(0,B.jsx)(`h1`,{className:`font-display font-semibold text-[1.375rem]`,children:R(`report.crashed`)}),(0,B.jsx)(`p`,{className:`mt-2 max-w-md text-[0.9375rem] text-ink-3`,children:R(`report.crashedNote`)}),(0,B.jsxs)(`div`,{className:`mt-6 flex gap-3`,children:[(0,B.jsx)(k,{variant:`secondary`,onClick:()=>window.location.reload(),children:R(`report.reload`)}),(0,B.jsx)(k,{onClick:()=>Vs({where:this.props.where,error:{message:e.message,stack:e.stack}}),children:R(`report.open`)})]}),(0,B.jsx)(Xs,{})]}):this.props.children}},_g=`wizards.organizationHint`,vg=30;function yg(e){try{let t=JSON.parse(sessionStorage.getItem(_g)??`null`);return t?.slug===e&&Date.now()-t.at<vg*1e3}catch{return!1}}function bg(e){try{sessionStorage.setItem(_g,JSON.stringify({slug:e,at:Date.now()}))}catch{}}function xg(e,t){let n=e.slice(a.length),r=n.split(`/`)[1]??``;if(!t)return{kind:`here`,root:Ae.has(r)?a:`${a}/${r}`};let i=t.mode===`managed`?t.tenant.slug:null;if(!i)return{kind:`here`,root:a};let o=`${a}/${i}`;return r===i?{kind:`here`,root:o}:t.organizations.some(e=>e.slug===r)&&!yg(r)?{kind:`switch`,slug:r}:Ae.has(r)?{kind:`move`,root:o,to:`${o}${n||`/`}`}:{kind:`foreign`,address:r,home:`${o}${n.slice(r.length+1)||`/`}`,me:t}}function Sg({children:e}){let t=Yt(),n=(0,z.useRef)(null);if(t.isLoading)return(0,B.jsx)(ug,{});n.current||={place:xg(window.location.pathname,t.data),tenant:t.data?.tenant.id??null};let{place:r}=n.current,{pathname:i,search:o,hash:s}=window.location;if(r.kind===`switch`){bg(r.slug);let e=new URLSearchParams({organization:r.slug,return:`${i}${o}`});return window.location.replace(Je(`/api/auth/login?${e}`)),(0,B.jsx)(ug,{})}if(r.kind===`foreign`)return(0,B.jsx)(Cg,{address:r.address,home:r.home,me:r.me});r.kind===`move`&&(window.history.replaceState(window.history.state,``,`${r.to}${o}${s}`),n.current.place={kind:`here`,root:r.root});let c=r.root,l=t.data?.mode===`managed`?t.data.tenant.slug:null,u=l?`${a}/${l}`:c;if(c!==a&&u!==c&&t.data?.tenant.id===n.current.tenant){let e=i.startsWith(c)?i.slice(c.length):`/`;window.history.replaceState(window.history.state,``,`${u}${e}${o}${s}`),n.current.place={kind:`here`,root:u},c=u}return Ce(c),(0,B.jsx)(j,{basename:c,children:e},c)}function Cg({address:e,home:t,me:n}){return(0,B.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center px-6`,children:(0,B.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-5 text-center`,children:[(0,B.jsx)(sn,{kind:`round`,size:56}),(0,B.jsxs)(`div`,{className:`rounded-md bg-paper-2 px-2.5 py-1 font-mono text-[0.8125rem] text-ink-2`,children:[`/studio/`,e]}),(0,B.jsx)(`h1`,{className:`text-balance font-display font-semibold text-2xl`,children:R(`address.foreign.title`)}),(0,B.jsx)(`p`,{className:`text-[0.9375rem] text-ink-2`,children:R(`address.foreign.text`,{email:n.user.email})}),(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,B.jsxs)(k,{onClick:()=>window.location.assign(t),children:[R(`address.foreign.continue`,{name:n.tenant.name??``}),(0,B.jsx)(Ze,{className:`size-4`})]}),(0,B.jsxs)(k,{variant:`secondary`,onClick:()=>void on(),children:[(0,B.jsx)(Ur,{className:`size-4`}),R(`address.foreign.switchAccount`)]})]})]})})}function wg({view:e,failed:t}){let n=ga(),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(!1);if(!n.data?.reports)return null;let l=(0,B.jsxs)(k,{variant:`ghost`,size:`sm`,onClick:()=>Vs({where:`run`,runId:e.id,error:t&&e.error?{message:e.error}:null}),children:[(0,B.jsx)(Et,{className:`size-4`}),` `,R(`report.open`)]});if(t)return(0,B.jsx)(`div`,{className:`mt-4 flex justify-center`,children:l});let u=async(t,n)=>{i(t),await fetch(Je(`/api/runs/${e.id}/feedback`),{method:`POST`,headers:{"content-type":`application/json`},credentials:`include`,body:JSON.stringify({good:t,...n?{comment:n}:{}})}).catch(()=>void 0),n!==void 0&&c(!0)};return(0,B.jsx)(`div`,{className:`mt-8 rounded-2xl border border-border bg-card p-4 sm:p-5`,children:s?(0,B.jsx)(`p`,{className:`text-ink-2 text-sm`,children:R(`feedback.thanks`)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`mr-2 font-medium text-[0.9375rem]`,children:R(`feedback.ask`)}),(0,B.jsxs)(k,{size:`sm`,variant:r===!0?`quiet`:`secondary`,onClick:()=>void u(!0),children:[(0,B.jsx)(Vi,{className:`size-4`}),` `,R(`feedback.good`)]}),(0,B.jsxs)(k,{size:`sm`,variant:r===!1?`quiet`:`secondary`,onClick:()=>void u(!1),children:[(0,B.jsx)(zi,{className:`size-4`}),` `,R(`feedback.bad`)]}),(0,B.jsx)(`span`,{className:`ml-auto`,children:l})]}),r===null?null:(0,B.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 sm:flex-row sm:items-end`,children:[(0,B.jsx)(Se,{rows:2,value:a,placeholder:R(`feedback.more`),onChange:e=>o(e.target.value),className:`flex-1`}),(0,B.jsx)(k,{size:`sm`,onClick:()=>void u(r,a.trim()),children:R(`feedback.send`)})]})]})})}var Tg={mail:Gr,folder:hr,chat:$r,plug:Rt,globe:zt};function Eg({runId:e,job:t,onAgain:n,onHome:r}){let[i,a]=(0,z.useState)(!1);if(t.status===`running`&&t.ask)return(0,B.jsx)(oe,{runId:e,ask:t.ask},t.ask.id);if(t.status===`running`){let n=t.events.slice(-5);return(0,B.jsxs)(`div`,{className:`animate-rise`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col items-center py-6 text-center`,children:[(0,B.jsx)(st,{className:`size-7 text-ember`}),(0,B.jsx)(`h3`,{className:`mt-4 font-display font-semibold text-[1.125rem]`,children:R(`shareRun.working`)}),(0,B.jsx)(`div`,{className:`mt-4 flex min-h-[5.5rem] w-full max-w-sm flex-col gap-1.5`,children:n.map((e,t)=>(0,B.jsxs)(`div`,{className:P(`flex items-center justify-center gap-2 text-[0.8125rem]`,t===n.length-1?`text-ink-2`:`text-ink-4`),children:[t===n.length-1?(0,B.jsx)(Ye,{className:`size-3.5 shrink-0 animate-breathe text-ember`}):null,(0,B.jsx)(`span`,{className:`truncate`,children:e.message})]},e.at+e.message))})]}),(0,B.jsx)(`div`,{className:`flex justify-center`,children:(0,B.jsx)(k,{variant:`ghost`,busy:i,onClick:()=>{a(!0),_.post(`/api/runs/${e}/share/jobs/${t.id}/cancel`).catch(()=>void 0)},children:R(`common.cancel`)})})]})}let o=t.status===`done`;return(0,B.jsxs)(`div`,{className:`animate-rise`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col items-center py-4 text-center`,children:[(0,B.jsx)(`div`,{className:P(`flex size-12 items-center justify-center rounded-full`,o?`bg-moss-tint text-moss`:`bg-rose-tint text-rose`),children:o?(0,B.jsx)(fe,{className:`size-6`}):(0,B.jsx)(He,{className:`size-6`})}),(0,B.jsx)(`h3`,{className:`mt-4 font-display font-semibold text-[1.125rem]`,children:R(o?`shareRun.done`:t.status===`cancelled`?`shareRun.cancelled`:`shareRun.failed`)}),o&&t.result?(0,B.jsx)(bt,{text:t.result.summary,className:`mt-2 max-w-md text-[0.875rem] text-ink-2`}):t.error?(0,B.jsx)(`p`,{className:`mt-2 max-w-md text-[0.875rem] text-ink-2 leading-relaxed`,children:t.error}):null,o&&t.result?.url?(0,B.jsxs)(`a`,{href:t.result.url,target:`_blank`,rel:`noreferrer`,className:`mt-4 inline-flex h-10 items-center gap-2 rounded-full bg-paper-2 px-4 font-medium text-[0.875rem] text-ink hover:bg-paper-3 coarse:h-11`,children:[(0,B.jsx)(ie,{className:`size-4`}),` `,R(`share.open`)]}):null]}),(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3`,children:[n?(0,B.jsx)(k,{variant:`ghost`,onClick:n,children:R(o?`shareRun.again`:`shareRun.backToForm`)}):(0,B.jsx)(`span`,{}),(0,B.jsx)(k,{onClick:r,children:R(`shareRun.elsewhere`)})]})]})}function Dg({steps:e,now:t}){return(0,B.jsx)(`ol`,{className:`mb-6 flex gap-2`,children:e.map((e,n)=>(0,B.jsxs)(`li`,{className:`min-w-0 flex-1`,"aria-current":n===t?`step`:void 0,children:[(0,B.jsx)(`div`,{className:P(`h-1 rounded-full`,n<t?`bg-moss`:n===t?`bg-ember`:`bg-paper-3`)}),(0,B.jsxs)(`div`,{className:P(`mt-1.5 truncate font-medium text-[0.75rem]`,n<t?`text-moss`:n===t?`text-ember-strong`:`text-ink-4`),children:[n+1,` · `,e]})]},e))})}function Og(e){return[...e.shown.filter(e=>e.output&&e.formats.length).map(e=>({from:e.step.id,label:e.label??e.step.title,formats:e.formats})),...e.lists.filter(e=>e.formats.length).map(e=>({from:`lists.${e.def.id}`,label:e.label??e.def.title,formats:e.formats}))]}function kg({deliverables:e,picked:t,onPick:n,error:r}){return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{children:R(`shareRun.files`)}),(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg ring-1 ring-input`,children:e.map(e=>{let r=!!t[e.from];return(0,B.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-border-soft border-b bg-card px-3 py-2.5 last:border-0`,children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-1 basis-40 cursor-pointer items-center gap-2.5 text-[0.875rem] coarse:min-h-11`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:r,onChange:t=>n(e.from,t.target.checked?e.formats[0]:null),className:`size-4 shrink-0 accent-[var(--ember)] coarse:size-5`}),(0,B.jsx)(`span`,{className:P(`truncate`,!r&&`text-ink-3`),children:e.label})]}),r?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.formats.map(r=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":t[e.from]===r,onClick:()=>n(e.from,r),className:P(`h-7 rounded-full px-2.5 font-medium text-[0.75rem] ring-1 transition coarse:h-9 coarse:px-3`,t[e.from]===r?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-3 ring-input hover:text-ink`),children:be[r]},r))}):null]},e.from)})}),r?(0,B.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-rose`,children:r}):null]})}function Ag({field:e,value:t,choices:n,error:r,onChange:i}){let a=e.fromAccount?n:e.options;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(M,{required:e.required,hint:e.help,children:e.label}),e.kind===`textarea`?(0,B.jsx)(Se,{minRows:3,maxRows:12,value:t,placeholder:e.placeholder,onChange:e=>i(e.target.value)}):e.kind===`select`&&a?.length?(0,B.jsx)(Oe,{value:t,onChange:i,options:a,placeholder:``}):(0,B.jsx)(me,{type:e.kind===`url`?`url`:`text`,inputMode:e.kind===`emails`?`email`:void 0,autoCapitalize:e.kind===`text`?void 0:`off`,autoComplete:`off`,spellCheck:e.kind===`text`,value:t,disabled:e.fromAccount&&n===void 0,placeholder:e.fromAccount&&n===void 0?R(`common.loading`):e.placeholder,onChange:e=>i(e.target.value)}),e.fromAccount&&n===null?(0,B.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:R(`shareRun.choicesFailed`)}):null,r?(0,B.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-rose`,children:r}):null]})}function jg({view:e,target:t,draft:n,onStarted:r}){let i=e.id,a=!!t.connection,o=!t.connection||!!t.connection.account,[s,c]=(0,z.useState)(!o);(0,z.useEffect)(()=>{o||c(!0)},[o]);let l=(0,z.useMemo)(()=>Og(e),[e]),[u,d]=(0,z.useState)(()=>n?.picked??Object.fromEntries(l.map(e=>[e.from,e.formats[0]]))),[f,p]=(0,z.useState)(()=>n?.values??Object.fromEntries(t.fields.map(e=>[e.id,e.value??``]))),[m,h]=(0,z.useState)({}),[g,v]=(0,z.useState)({}),[y,b]=(0,z.useState)(null),[x,S]=(0,z.useState)(!1),C=t.fields.filter(e=>e.fromAccount).map(e=>e.id);(0,z.useEffect)(()=>{if(!o)return;let e=!0;for(let n of C)_.get(`/api/runs/${i}/share/targets/${encodeURIComponent(t.key)}/choices/${n}?lang=${L}`).then(t=>e&&h(e=>({...e,[n]:t.choices.length?t.choices:null})),()=>e&&h(e=>({...e,[n]:null})));return()=>{e=!1}},[o,i,t.key]);let ee=[...a?[R(`shareRun.stepAccount`)]:[],R(`shareRun.stepForm`),R(`shareRun.stepSend`)],w=async()=>{S(!0),v({}),b(null);let e=t.takes===`files`?l.flatMap(e=>u[e.from]?[{from:e.from,format:u[e.from]}]:[]):[];try{r(await _.post(`/api/runs/${i}/share/jobs`,{target:t.key,items:e,values:f,lang:L}),{values:f,picked:u})}catch(e){let t=e instanceof ne&&e.status===422?e.body?.fields:null;t?(v(t),t._account&&c(!0)):b(e.message)}finally{S(!1)}};return a&&s?(0,B.jsxs)(`div`,{className:`animate-rise`,children:[(0,B.jsx)(Dg,{steps:ee,now:0}),(0,B.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-2 leading-relaxed`,children:R(`shareRun.accountHint`)}),(0,B.jsx)(mt,{runId:i,connection:t.connection??void 0}),g._account?(0,B.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:g._account}):null,(0,B.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,B.jsxs)(k,{disabled:!o,onClick:()=>c(!1),children:[R(`run.next`),` `,(0,B.jsx)(Ze,{className:`size-4`})]})})]}):(0,B.jsxs)(`form`,{className:`animate-rise`,onSubmit:e=>{e.preventDefault(),w()},children:[(0,B.jsx)(Dg,{steps:ee,now:+!!a}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[a&&t.connection?.account?(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem]`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-ink-2`,children:R(`shareRun.as`,{account:t.connection.account.label})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`shrink-0 text-ink-3 hover:text-ink coarse:min-h-11`,children:R(`shareRun.changeAccount`)})]}):null,t.agent?(0,B.jsxs)(`p`,{className:`flex items-start gap-2.5 rounded-lg bg-ember-tint px-3 py-2.5 text-[0.8125rem] text-ink-2 leading-relaxed`,children:[(0,B.jsx)(Lt,{className:`mt-0.5 size-4 shrink-0 text-ember-strong`}),` `,R(`shareRun.agentHint`)]}):null,t.presets.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.presets.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>p(t=>({...t,...e.values})),className:`h-9 rounded-full bg-card px-3.5 font-medium text-[0.8125rem] text-ink-2 ring-1 ring-input transition hover:text-ink hover:ring-ember coarse:h-11`,children:e.label},e.label))}):null,t.fields.map(e=>(0,B.jsx)(Ag,{field:e,value:f[e.id]??``,choices:m[e.id],error:g[e.id],onChange:t=>p(n=>({...n,[e.id]:t}))},e.id)),t.takes===`files`&&l.length?(0,B.jsx)(kg,{deliverables:l,picked:u,error:g._files,onPick:(e,t)=>d(n=>({...n,[e]:t}))}):null,y?(0,B.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[0.875rem] text-rose`,children:y}):null]}),(0,B.jsx)(`div`,{className:`action-bar mt-6 flex justify-end`,children:(0,B.jsxs)(k,{type:`submit`,busy:x,children:[(0,B.jsx)(ki,{className:`size-4`}),` `,R(t.agent?`shareRun.start`:`shareRun.send`)]})})]})}function Mg(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);return[{id:`mail`,label:R(`shareRun.email`),href:`mailto:?subject=${r}&body=${r}%0A%0A${n}`},{id:`x`,label:`X`,href:`https://x.com/intent/post?text=${r}&url=${n}`},{id:`linkedin`,label:`LinkedIn`,href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`},{id:`whatsapp`,label:`WhatsApp`,href:`https://wa.me/?text=${r}%20${n}`},{id:`facebook`,label:`Facebook`,href:`https://www.facebook.com/sharer/sharer.php?u=${n}`}]}var Ng={x:`𝕏`,linkedin:`in`,whatsapp:`WA`,facebook:`f`};function Pg({view:e,title:t}){let n=e.id,[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)({at:`home`}),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)({}),p=e.shareJob?.status===`running`?e.shareJob:null,m=(0,z.useCallback)(async()=>{try{c(await _.get(`/api/runs/${n}/share/targets?lang=${L}`)),u(null)}catch(e){u(e.message)}},[n]),h=()=>{i(!0),o(p?{at:`job`,id:p.id,key:null}:{at:`home`}),m()};(0,z.useEffect)(()=>{r&&a.at===`target`&&m()},[r,a.at,e,m]);let g=e.shareJob?.status;(0,z.useEffect)(()=>{r&&g&&g!==`running`&&m()},[r,g,m]);let v=a.at===`target`||a.at===`job`?s?.targets.find(e=>e.key===a.key):void 0,y=a.at===`job`?e.shareJob?.id===a.id?e.shareJob:s?.jobs.find(e=>e.id===a.id):void 0,b=a.at===`home`||a.at===`job`&&y?.status===`running`?null:()=>o({at:`home`});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(k,{variant:`secondary`,onClick:h,children:[p?(0,B.jsx)(st,{className:`size-4`}):(0,B.jsx)(We,{className:`size-4`}),` `,R(`shareRun.button`)]}),(0,B.jsx)(Qe,{open:r,onClose:()=>i(!1),wide:!0,title:(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[b?(0,B.jsx)(ge,{label:R(`run.back`),onClick:b,className:`-my-1.5 -ml-2`,children:(0,B.jsx)(ee,{className:`size-4`})}):null,a.at===`link`?R(`shareRun.linkTitle`):v?.name??y?.name??R(`shareRun.title`)]}),children:a.at===`link`?(0,B.jsx)(zg,{view:e,title:t,onWithdrawn:()=>o({at:`home`})}):a.at===`target`&&v?(0,B.jsx)(jg,{view:e,target:v,draft:d[v.key],onStarted:(e,t)=>{f(e=>({...e,[v.key]:t})),o({at:`job`,id:e.id,key:v.key})}},v.key):a.at===`job`&&y?(0,B.jsx)(Eg,{runId:n,job:y,onAgain:a.key?()=>o({at:`target`,key:a.key}):null,onHome:()=>o({at:`home`})}):l?(0,B.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[0.875rem] text-rose`,children:l}):s?(0,B.jsx)(Lg,{overview:s,onLink:()=>o({at:`link`}),onTarget:e=>o({at:`target`,key:e}),onJob:e=>o({at:`job`,id:e,key:null})}):(0,B.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,B.jsx)(st,{})})})]})}function Fg({icon:e,name:t,description:n,onClick:r,selected:i}){let a=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:P(`flex size-11 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-2 transition`,r&&`group-hover:bg-ember-tint group-hover:text-ember-strong`,i&&`bg-ember-tint text-ember-strong`),children:(0,B.jsx)(e,{className:`size-5`})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block truncate font-medium text-[0.9375rem]`,children:t}),(0,B.jsx)(`span`,{className:`block text-[0.8125rem] text-ink-3 leading-snug`,children:n})]}),r?(0,B.jsx)(u,{className:`size-4 shrink-0 text-ink-4 transition group-hover:text-ember-strong`}):null]}),o=P(`group flex items-center gap-3 rounded-xl bg-card p-3 text-left ring-1 ring-input transition`,r&&`hover:ring-ember`,i&&`ring-2 ring-ember`);return r?(0,B.jsx)(`button`,{type:`button`,onClick:r,className:o,children:a}):(0,B.jsx)(`div`,{className:o,children:a})}function Ig(e){return new Intl.DateTimeFormat(L,{dateStyle:`short`,timeStyle:`short`}).format(new Date(e))}function Lg({overview:e,onLink:t,onTarget:n,onJob:r}){let i=e.jobs.filter(e=>e.status!==`cancelled`);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,B.jsxs)(`div`,{className:`grid gap-2.5 sm:grid-cols-2`,children:[(0,B.jsx)(Fg,{icon:p,name:R(`share.link`),description:R(`shareRun.linkHint`),onClick:t}),e.targets.map(e=>(0,B.jsx)(Fg,{icon:Tg[e.icon],name:e.name,description:e.description,onClick:()=>n(e.key)},e.key))]}),i.length?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`mb-2 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:R(`shareRun.recent`)}),(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg ring-1 ring-border-soft`,children:i.slice(0,5).map(e=>(0,B.jsx)(`li`,{className:`border-border-soft border-b last:border-0`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`flex w-full items-center gap-2.5 px-3 py-2 text-left text-[0.8125rem] hover:bg-paper-2 coarse:min-h-11`,children:[(0,B.jsx)(Rg,{job:e}),(0,B.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-ink-3`,children:e.result?.summary??e.error??R(`shareRun.working`)}),(0,B.jsx)(`span`,{className:`shrink-0 text-ink-4 tabular-nums`,children:Ig(e.createdAt)})]})},e.id))})]}):null]})}function Rg({job:e}){return e.status===`running`?(0,B.jsx)(st,{className:`size-3.5 shrink-0 text-ember`}):(0,B.jsx)(`span`,{className:P(`size-2 shrink-0 rounded-full`,e.status===`done`?`bg-moss`:e.status===`failed`?`bg-rose`:`bg-ink-4`)})}function zg({view:e,title:t,onWithdrawn:n}){let r=e.id,[i,a]=(0,z.useState)(e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(null);(0,z.useEffect)(()=>{if(i)return;let e=!0;return _.post(`/api/runs/${r}/share`).then(t=>e&&a(t)).catch(t=>e&&l(t.message)),()=>{e=!1}},[r,i]);let u=async()=>{await _.del(`/api/runs/${r}/share`),n()},d=()=>{i&&(navigator.clipboard.writeText(i.url),s(!0),setTimeout(()=>s(!1),1500))},f=Ue(`share`)||typeof navigator<`u`&&`share`in navigator,m=i?.expiresAt?new Intl.DateTimeFormat(L,{dateStyle:`long`}).format(new Date(i.expiresAt)):null;return c?(0,B.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[0.875rem] text-rose`,children:c}):i?(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-paper-2 p-1.5 pl-3`,children:[(0,B.jsx)(p,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`input`,{readOnly:!0,value:i.url,onFocus:e=>e.target.select(),"aria-label":R(`share.link`),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] outline-none coarse:h-11`}),(0,B.jsxs)(k,{size:`sm`,onClick:d,children:[o?(0,B.jsx)(fe,{className:`size-3.5`}):(0,B.jsx)(le,{className:`size-3.5`}),R(o?`share.copied`:`share.copy`)]})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-6`,children:[Mg(i.url,t).map(e=>(0,B.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,B.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 font-semibold text-[0.9375rem] transition hover:bg-paper-3`,children:e.id===`mail`?(0,B.jsx)(Gr,{className:`size-5`}):Ng[e.id]}),e.label]},e.id)),f?(0,B.jsxs)(`button`,{type:`button`,onClick:()=>void(Ue(`share`)?De(`share`,{link:i.url,title:t}):navigator.share({title:t,url:i.url})).catch(()=>void 0),className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,B.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 transition hover:bg-paper-3`,children:(0,B.jsx)(We,{className:`size-5`})}),R(`shareRun.more`)]}):null]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[0.8125rem] text-ink-3`,children:[(0,B.jsx)(`span`,{children:m?R(`shareRun.until`,{date:m}):R(`shareRun.kept`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void u(),className:`shrink-0 hover:text-rose coarse:min-h-11`,children:R(`shareRun.withdraw`)})]})]}):(0,B.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,B.jsx)(st,{})})}S({lang:L,runBase:e=>`/api/runs/${e}`,withBase:Je,asset:Ke,serviceWorker:`${se}/sw.js`,app:{can:Ue,call:De,tell:Me,download:dt},Mascot:sn,ShareResultButton:Pg,RunEnd:wg,onServerError:e=>Xe(`error`,e)}),C(),he();var Bg=`wizards.reloadedForBuild`;window.addEventListener(`vite:preloadError`,e=>{let t=0;try{if(t=Number(sessionStorage.getItem(Bg))||0,Date.now()-t<6e4)return;sessionStorage.setItem(Bg,String(Date.now()))}catch{return}e.preventDefault(),window.location.reload()}),`engentyDesktop`in window&&(document.documentElement.dataset.desktop=``);var Vg=window.location.pathname,Hg=Vg===a||Vg.startsWith(`${a}/`);Hg&&`serviceWorker`in navigator&&navigator.serviceWorker.register(`${se}/sw.js`).catch(()=>void 0);var Ug=new kn({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});(0,Ji.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(Be,{client:Ug,children:Hg?(0,B.jsx)(Sg,{children:(0,B.jsxs)(gg,{where:`studio`,children:[(0,B.jsx)(hg,{}),(0,B.jsx)(Xs,{})]})}):(0,B.jsx)(j,{basename:se,children:(0,B.jsxs)(gg,{where:`run`,children:[(0,B.jsx)(fg,{}),(0,B.jsx)(Xs,{})]})})})}));export{Of as $,Ep as A,ai as At,Af as B,Nr as Bt,sm as C,qi as Ct,om as D,Di as Dt,pm as E,ji as Et,rp as F,Yr as Ft,Lf as G,ar as Gt,Mf as H,kr as Ht,np as I,Gr as It,Pf as J,Ff as K,Zn as Kt,ep as L,zr as Lt,sp as M,ti as Mt,op as N,$r as Nt,qp as O,Ti as Ot,ip as P,Zr as Pt,Bf as Q,Kf as R,Lr as Rt,dm as S,Zi as St,fm as T,Ui as Tt,kf as U,yr as Ut,jf as V,jr as Vt,Vf as W,lr as Wt,Hf as X,Uf as Y,Z,Gm as _,rc as _t,Dg as a,Ul as at,vm as b,va as bt,kh as c,Bl as ct,hh as d,ol as dt,Df as et,fh as f,Kc as ft,Km as g,pc as gt,dh as h,Dc as ht,kg as i,ku as it,mp as j,ri as jt,Xp as k,yi as kt,Hh as l,vl as lt,uh as m,tl as mt,Fg as n,Sf as nt,Tg as o,Hl as ot,gh as p,el as pt,If as q,Vn as qt,Ag as r,ff as rt,Wh as s,Nl as st,Pg as t,Ef as tt,bh as u,ll as ut,oh as v,$s as vt,um as w,Gi as wt,mm as x,na as xt,Bm as y,ga as yt,Wf as z,Fr as zt};
|