@a-t-h-i/bot-lobby 0.6.74 → 0.6.75
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/package.json +1 -1
- package/webui/dist/assets/{CodeSurface-C8u8tIUk.js → CodeSurface-B4OE4fFl.js} +1 -1
- package/webui/dist/assets/{TerminalView-D0ZUy1E_.js → TerminalView-BBbYiw6R.js} +1 -1
- package/webui/dist/assets/{index-Dc1omnBz.js → index-BwV-TLHH.js} +3 -3
- package/webui/dist/assets/index-xsQmwvq1.css +2 -0
- package/webui/dist/build.json +8 -8
- package/webui/dist/index.html +2 -2
- package/webui/dist/assets/index-C7636GLA.css +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-BBbYiw6R.js","assets/rolldown-runtime-hePW80VL.js","assets/ccount-DQxSH8e6.js","assets/TerminalView-BrP-ENHg.css","assets/CodeSurface-B4OE4fFl.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./ccount-DQxSH8e6.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 f=document.querySelector(`meta[property="csp-nonce"]`),p=f?.nonce||f?.content;p&&(window.__webpack_nonce__=p);var m=t(o(),1),h,g=new Set;function _(){for(let e of[...g])e()}typeof window<`u`&&(window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),h=e,_()}),window.addEventListener(`appinstalled`,()=>{h=void 0,_()}));function v(e){return g.add(e),()=>{g.delete(e)}}function y(){return{available:(0,m.useSyncExternalStore)(v,()=>h!==void 0,()=>!1),install:async()=>{let e=h;e&&(await e.prompt().catch(()=>void 0),await e.userChoice?.catch(()=>void 0),h=void 0,_())}}}function b(){let e=`(display-mode: fullscreen), (display-mode: standalone), (display-mode: minimal-ui)`,[t,n]=(0,m.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,m.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t}function x(){let e=typeof document<`u`&&typeof document.documentElement.requestFullscreen==`function`,[t,n]=(0,m.useState)(()=>typeof document<`u`&&document.fullscreenElement!==null);return(0,m.useEffect)(()=>{let e=()=>n(document.fullscreenElement!==null);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]),{supported:e,on:t,toggle:async()=>{document.fullscreenElement?await document.exitFullscreen().catch(()=>void 0):await document.documentElement.requestFullscreen().catch(()=>void 0)}}}var S=[`background`,`foreground`,`card`,`card-foreground`,`popover`,`popover-foreground`,`primary`,`primary-foreground`,`secondary`,`secondary-foreground`,`muted`,`muted-foreground`,`accent`,`accent-foreground`,`destructive`,`border`,`input`,`ring`,`chart-1`,`chart-2`,`chart-3`,`chart-4`,`chart-5`],C=[`font-sans`,`font-mono`],w=new Set([...S,...C]),T=/^[\w\s#%.,()/+*'"-]{1,300}$/,E=/url\s*\(|expression|import|javascript|\\|<|>/i;function ee(e){let t=e.replace(/!important/gi,``).trim();if(t&&T.test(t)&&!E.test(t))return t}function D(e,t,n){let r=e.replace(/^--/,``).toLowerCase();if(!w.has(r))return;let i=ee(t);i&&(n[r]=i)}function O(e){let t={};for(let n of e.matchAll(/--([a-z0-9-]+)\s*:\s*([^;}]+)/gi))D(n[1],n[2],t);return t}function k(e){if(!e||typeof e!=`object`)return;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&D(n,r,t);return Object.keys(t).length>0?t:void 0}function te(e){let t=e.trim();if(!t)return{error:`Paste a theme first.`};if(t.length>2e5)return{error:`That file is too large to be a theme.`};let n={},r={},i;if(t.startsWith(`{`)){let e;try{e=JSON.parse(t)}catch{return{error:`That is not valid JSON or CSS.`}}let a=e,o=a.cssVars;if(!o||typeof o!=`object`)return{error:`That JSON has no cssVars. Copy the theme's CSS from tweakcn instead.`};let s=e=>{let t={};for(let[n,r]of Object.entries(e??{}))typeof r==`string`&&D(n,r,t);return t};n={...s(o.theme),...s(o.light)},r={...s(o.theme),...s(o.dark)},i=typeof a.title==`string`?a.title:typeof a.name==`string`?a.name:void 0}else for(let e of t.matchAll(/(?<=^|[}\s])((?::root|html|\.dark|:root\.dark|html\.dark)(?:\s*,\s*[^{]+)?)\s*\{([^}]*)\}/g)){let t=e[1].trim(),i=O(e[2]);/\.dark/.test(t)?r={...r,...i}:n={...n,...i}}let a=e=>Object.keys(e).filter(e=>S.includes(e)).length;return a(n)<5&&a(r)<5?{error:`No theme colours found. Copy the code from tweakcn's Code panel (the :root and .dark blocks).`}:{...a(n)>=5?{light:n}:{},...a(r)>=5?{dark:r}:{},...i?{name:i}:{}}}var A={"glass-border":`var(--border)`,typing:`var(--ring)`,"tab-active":`color-mix(in oklab, var(--primary) 14%, var(--background))`,you:`color-mix(in oklab, var(--primary) 9%, var(--card))`,heading:`var(--foreground)`,link:`var(--primary)`,bullet:`var(--primary)`},j=`"Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,ne=`ui-monospace, "JetBrains Mono", "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace`;function re(e,t){let n=[];for(let[e,r]of Object.entries(t))e===`font-sans`?n.push(`--app-font-sans:${r},${j};`):e===`font-mono`?n.push(`--app-font-mono:${r},${ne};`):n.push(`--${e}:${r};`);for(let[e,r]of Object.entries(A))e in t||n.push(`--${e}:${r};`);return`${e}{${n.join(``)}}`}function M(e){let t=[];return e.light&&t.push(re(`:root`,e.light)),e.dark&&t.push(re(`.dark`,e.dark)),t.join(`
|
|
3
3
|
`)}var ie=`mist`,ae=[{id:ie,name:`Default`}],oe={light:{background:`#faf9f5`,card:`#ffffff`,primary:`#c96442`,accent:`#f0eee6`},dark:{background:`#262624`,card:`#30302e`,primary:`#d97757`,accent:`#1f1e1d`}};function se(e,t){let n=t?e.dark:e.light,r=oe[t?`dark`:`light`];return n?{background:n.background??r.background,card:n.card??r.card,primary:n.primary??r.primary,accent:n.primary?`color-mix(in oklab, ${n.primary} 18%, ${n.background??r.background})`:r.accent}:{...r}}var ce={activity:400,thoughts:40,chat:100};function le(e,t,n){let r=e??[],i=new Set(r.map(e=>e.id)),a=t.filter(e=>typeof e?.id==`number`&&!i.has(e.id));return[...r,...a].slice(-n)}var ue=class{records=new Map;listeners=new Set;reads=new Map;used=new Set;reader;currentStatus={connection:`connecting`,signedOut:!1};get(e){let t=this.records.get(e);if(t)return t;let n={version:0,data:void 0,loading:!1,error:void 0,stale:!1};return this.records.set(e,n),n}status(){return{...this.currentStatus}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}markUsed(e,t){this.reader=t;let n=e.filter(e=>!this.used.has(e));this.used=new Set(e);for(let e of n)this.read(e)}onHello(e){for(let t of this.used){let n=e[t];n!==void 0&&(this.get(t).version=n),this.read(t)}}onChanged(e,t){let n=this.get(e);n.version=t,this.used.has(e)?this.read(e):n.stale=!0,this.notify()}onFeedDelta(e){let t=this.get(`lobby`).data;t&&(this.get(`lobby`).data={...t,activity:le(t.activity,e.activity??[],ce.activity),thoughts:le(t.thoughts,e.thoughts??[],ce.thoughts),chat:le(t.chat,e.chat??[],ce.chat)},this.notify())}onReplyDelta(e){let t=this.get(`lobby`),n=t.data;n&&(t.data={...n,reply:e},this.notify())}onStatus(e){this.currentStatus={...this.currentStatus,...e},this.notify()}async read(e){let t=this.reader;if(!t)return;let n=(this.reads.get(e)??0)+1;this.reads.set(e,n);let r=this.get(e);r.loading=!0,r.error=void 0,this.notify();try{let i=await t(e);if(this.reads.get(e)!==n)return;this.apply(r,i)}catch(t){if(this.reads.get(e)!==n)return;r.loading=!1,r.error=t instanceof Error?t.message:String(t)}this.notify()}apply(e,t){e.data=t,e.loading=!1,e.stale=!1,e.error=void 0}notify(){for(let e of[...this.listeners])e()}};function de(){return new ue}var N=de(),fe=/^[a-f0-9]{32}$/;function pe(){return globalThis.location}function me(){let e=pe()?.search??``,t=new URLSearchParams(e).getAll(`project`);if(t.length){if(t.length!==1||!fe.test(t[0]))throw Error(`Invalid project ID. Choose a running project below.`);return t[0]}}function P(e){if(!e.startsWith(`/api/`)&&!e.startsWith(`/files/preview/`))return e;let t=me();return t?`/projects/${t}${e}`:e}function F(e,t){if(!fe.test(e))throw Error(`Invalid project ID.`);let n=pe();if(!n)throw Error(`Project switching requires a browser.`);let r=new URL(n.origin);r.pathname=n.pathname,r.searchParams.set(`project`,e),r.hash=`/${t}`,n.assign(r.href)}var he=`bot-lobby.projectFolders`,ge=new Map;function _e(){try{return globalThis.sessionStorage}catch{return}}function ve(){try{let e=JSON.parse(_e()?.getItem(he)??`{}`);for(let[t,n]of Object.entries(e))fe.test(t)&&typeof n==`string`&&ge.set(t,n)}catch{}}function ye(e){ve();for(let t of e)fe.test(t.id)&&ge.set(t.id,t.cwd);try{_e()?.setItem(he,JSON.stringify(Object.fromEntries([...ge].slice(-64))))}catch{}}function be(e){return ge.has(e)||ve(),ge.get(e)}async function xe(e){let t;try{t=me()}catch{return!1}if(!t)return!1;let n=be(t);if(!n)return!1;let{projects:r}=await e();if(ye(r),r.some(e=>e.id===t))return!1;let i=r.find(e=>e.cwd===n),a=pe(),o=globalThis.history;if(!i||!a||!o)return!1;let s=new URL(a.origin);return s.pathname=a.pathname,s.search=a.search,s.searchParams.set(`project`,i.id),s.hash=globalThis.location?.hash??``,o.replaceState(null,``,s.href),!0}var Se=class extends Error{code;status;constructor(e,t,n){super(e),this.name=`ApiError`,this.code=t,this.status=n}},Ce={"Content-Type":`application/json`};async function I(e,t={}){let n=await fetch(e===`auth.login`||e.startsWith(`projects.`)?`/api/${e}`:P(`/api/${e}`),{method:`POST`,headers:Ce,body:JSON.stringify(t),credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new Se(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw r.code===`unauthorized`&&N.onStatus({signedOut:!0}),new Se(r.error,r.code,n.status);return r.result}function we(){return globalThis.location}async function Te(){let e=we(),t=e?new URLSearchParams(e.hash.replace(/^#/,``)).get(`token`):null;if(!t||!(await fetch(`/api/auth.login`,{method:`POST`,headers:Ce,body:JSON.stringify({token:t}),credentials:`same-origin`}).catch(()=>void 0))?.ok)return!1;let n=globalThis.history;return n&&n.replaceState(null,``,e.pathname+e.search),N.onStatus({signedOut:!1}),!0}var Ee=`bot-lobby.palette`,De=`bot-lobby-palette`,Oe=`custom`,ke=new Set,Ae=Me();function je(e){let t=e;if(!t||typeof t.id!=`string`||typeof t.name!=`string`)return;let n=k(t.light),r=k(t.dark);if(n||r)return{id:t.id,name:t.name.slice(0,40),...n?{light:n}:{},...r?{dark:r}:{}}}function Me(){try{let e=localStorage.getItem(Ee);if(!e)return{id:ie,saved:[]};let t=JSON.parse(e),n=(t.saved??[]).map(je).filter(e=>!!e),r=je(t.legacy??(t.custom?{...t.custom,id:Oe}:void 0)),i=new Set([...ae.map(e=>e.id),...n.map(e=>e.id),...r?[Oe]:[]]);return{id:t.id&&i.has(t.id)?t.id:ie,saved:n,...r?{legacy:r}:{}}}catch{return{id:ie,saved:[]}}}function Ne(e){return[...ae,...e.saved,...e.legacy?[e.legacy]:[]]}function Pe(e){return Ne(e).find(t=>t.id===e.id)??ae[0]}function Fe(){if(typeof document>`u`)return;let e=M(Pe(Ae)),t=document.getElementById(De);if(!e){t?.remove();return}t||(t=document.createElement(`style`),t.id=De,document.head.appendChild(t)),t.textContent=e}function Ie(e){Ae=e;try{localStorage.setItem(Ee,JSON.stringify(e))}catch{}Fe();for(let e of[...ke])e()}function Le(e){let t=e.themes.map(e=>je(e)).filter(e=>!!e),{legacy:n}=Ae;Ie({id:e.active??(Ae.id===Oe&&n?Oe:`mist`),saved:t,...n?{legacy:n}:{}})}var Re,ze=Promise.resolve();function Be(e=!1){return Re&&!e||(Re=(async()=>{let e=await I(`themes.get`,{}),t=Ae.legacy;if(t){let n=e.active??(Ae.id===Oe?void 0:Ae.id);e=await I(`themes.save`,{name:t.name,...t.light?{light:t.light}:{},...t.dark?{dark:t.dark}:{}}),n&&(e=await I(`themes.choose`,{id:n}));let{legacy:r,...i}=Ae;Ae=i}Le(e)})().catch(()=>{Re=void 0})),Re}typeof window<`u`&&(Fe(),window.addEventListener(`storage`,e=>{if(e.key===Ee){Ae=Me(),Fe();for(let e of[...ke])e()}}),window.addEventListener(`focus`,()=>void Be(!0)));function Ve(e){return ke.add(e),()=>{ke.delete(e)}}function He(){let e=(0,m.useSyncExternalStore)(Ve,()=>Ae,()=>Ae),t=(0,m.useCallback)(e=>{Ie({...Ae,id:e}),e!==Oe&&(ze=ze.then(()=>I(`themes.choose`,{id:e})).then(Le,()=>{}))},[]),n=(0,m.useCallback)(async(e,t)=>(Le(await I(`themes.save`,{name:t,...e.light?{light:e.light}:{},...e.dark?{dark:e.dark}:{}})),Pe(Ae)),[]),r=(0,m.useCallback)(async(e,t)=>Le(await I(`themes.rename`,{id:e,name:t})),[]),i=(0,m.useCallback)(async e=>Le(await I(`themes.remove`,{id:e})),[]),a=e.legacy?[...e.saved,e.legacy]:e.saved;return{active:Pe(e),saved:a,all:Ne(e),isSaved:e=>a.some(t=>t.id===e),choose:t,adopt:n,rename:r,remove:i}}var Ue=[{id:`theme`,label:`System`,help:`The system's own (or the colour theme's)`},{id:`inter`,label:`Inter`,help:`Neutral and very legible`},{id:`geist`,label:`Geist`,help:`Crisp and modern`},{id:`plex`,label:`IBM Plex Sans`,help:`Technical, with character`},{id:`manrope`,label:`Manrope`,help:`Round and friendly`},{id:`dm-sans`,label:`DM Sans`,help:`Geometric, low contrast`},{id:`jakarta`,label:`Plus Jakarta Sans`,help:`Polished product sans`},{id:`figtree`,label:`Figtree`,help:`Clean and approachable`},{id:`outfit`,label:`Outfit`,help:`Geometric display feel`},{id:`nunito`,label:`Nunito`,help:`Soft rounded terminals`},{id:`space-grotesk`,label:`Space Grotesk`,help:`Quirky, technical`},{id:`source-sans`,label:`Source Sans 3`,help:`Classic UI workhorse`}],We=[{id:`theme`,label:`System mono`,help:`The system's own (or the colour theme's)`},{id:`jetbrains`,label:`JetBrains Mono`,help:`Tall, made for code`},{id:`geist-mono`,label:`Geist Mono`,help:`Pairs with Geist`},{id:`fira-code`,label:`Fira Code`,help:`Ligatures for operators`},{id:`roboto-mono`,label:`Roboto Mono`,help:`Even and compact`},{id:`source-code`,label:`Source Code Pro`,help:`Open and readable`}],Ge={font:`bot-lobby.typeface`,mono:`bot-lobby.typeface-code`},Ke={font:Ue,mono:We},qe={font:`theme`,mono:`theme`},Je=new Set;function Ye(e){let t=null;try{t=localStorage.getItem(Ge[e])}catch{t=qe[e]}return Ke[e].some(e=>e.id===t)?t:`theme`}function Xe(e,t){let n=document.documentElement;t===`theme`?delete n.dataset[e]:n.dataset[e]=t}function Ze(e,t){qe[e]=t;try{localStorage.setItem(Ge[e],t)}catch{}Xe(e,t);for(let e of Je)e()}function Qe(e){return Je.add(e),()=>Je.delete(e)}function $e(e){return(0,m.useSyncExternalStore)(Qe,()=>Ye(e),()=>`theme`)}typeof document<`u`&&(Xe(`font`,Ye(`font`)),Xe(`mono`,Ye(`mono`)));var et={inter:`"Inter Variable", system-ui, sans-serif`,geist:`"Geist Variable", system-ui, sans-serif`,plex:`"IBM Plex Sans Variable", system-ui, sans-serif`,manrope:`"Manrope Variable", system-ui, sans-serif`,jetbrains:`"JetBrains Mono Variable", ui-monospace, monospace`,"geist-mono":`"Geist Mono Variable", ui-monospace, monospace`,"dm-sans":`"DM Sans Variable", system-ui, sans-serif`,jakarta:`"Plus Jakarta Sans Variable", system-ui, sans-serif`,figtree:`"Figtree Variable", system-ui, sans-serif`,outfit:`"Outfit Variable", system-ui, sans-serif`,nunito:`"Nunito Variable", system-ui, sans-serif`,"space-grotesk":`"Space Grotesk Variable", system-ui, sans-serif`,"source-sans":`"Source Sans 3 Variable", system-ui, sans-serif`,"fira-code":`"Fira Code Variable", ui-monospace, monospace`,"roboto-mono":`"Roboto Mono Variable", ui-monospace, monospace`,"source-code":`"Source Code Pro Variable", ui-monospace, monospace`},tt=(0,m.createContext)({});function nt(e){let t=(0,m.useRef)(null);return t.current===null&&(t.current=e()),t.current}var rt=typeof window<`u`?m.useLayoutEffect:m.useEffect,it=(0,m.createContext)(null);function at(e,t){e.indexOf(t)===-1&&e.push(t)}function ot(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var st=(e,t,n)=>n>t?t:n<e?e:n,ct={},lt=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),ut=e=>typeof e==`object`&&!!e,dt=e=>/^0[^.\s]+$/u.test(e);function ft(e){let t;return()=>(t===void 0&&(t=e()),t)}var pt=e=>e,mt=(...e)=>e.reduce((e,t)=>n=>t(e(n))),ht=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},gt=class{constructor(){this.subscriptions=[]}add(e){return at(this.subscriptions,e),()=>this.remove(e)}remove(e){ot(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r){if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},_t=e=>e*1e3,vt=e=>e/1e3,yt=(e,t)=>t?1e3/t*e:0,bt=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,xt=1e-7,St=12;function Ct(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=bt(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>xt&&++s<St);return o}function wt(e,t,n,r){if(e===t&&n===r)return pt;let i=t=>Ct(t,0,1,e,n);return e=>e===0||e===1?e:bt(i(e),t,r)}var Tt=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Et=e=>t=>1-e(1-t),Dt=wt(.33,1.53,.69,.99),Ot=Et(Dt),kt=Tt(Ot),At=e=>e>=1?1:(e*=2)<1?.5*Ot(e):.5*(2-2**(-10*(e-1))),jt=e=>1-Math.sin(Math.acos(e)),Mt=Et(jt),Nt=Tt(jt),Pt=wt(.42,0,1,1),Ft=wt(0,0,.58,1),It=wt(.42,0,.58,1),Lt=e=>Array.isArray(e)&&typeof e[0]!=`number`,Rt=e=>Array.isArray(e)&&typeof e[0]==`number`,zt={linear:pt,easeIn:Pt,easeInOut:It,easeOut:Ft,circIn:jt,circInOut:Nt,circOut:Mt,backIn:Ot,backInOut:kt,backOut:Dt,anticipate:At},Bt=e=>typeof e==`string`,Vt=e=>{if(Rt(e)){e.length;let[t,n,r,i]=e;return wt(t,n,r,i)}return Bt(e)?(zt[e],`${e}`,zt[e]):e},Ht={delta:0,timestamp:0,isProcessing:!1},Ut;function Wt(){Ut=void 0}var Gt={now:()=>(Ut===void 0&&Gt.set(Ht.isProcessing||ct.useManualTiming?Ht.timestamp:performance.now()),Ut),set:e=>{Ut=e,queueMicrotask(Wt)}},Kt=e=>Math.round(e*1e5)/1e5,qt=e=>t=>typeof t==`string`&&t.startsWith(e),Jt=qt(`--`),Yt=qt(`var(--`),Xt=e=>Yt(e)?Zt.test(e.split(`/*`)[0].trim()):!1,Zt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Qt(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var $t={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},en={...$t,transform:e=>st(0,1,e)},tn={...$t,default:1},nn=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function rn(e){return e==null}var an=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,on=(e,t)=>n=>!!(typeof n==`string`&&an.test(n)&&n.startsWith(e)||t&&!rn(n)&&Object.prototype.hasOwnProperty.call(n,t)),sn=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(nn);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},cn=e=>st(0,255,e),ln={...$t,transform:e=>Math.round(cn(e))},un={test:on(`rgb`,`red`),parse:sn(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+ln.transform(e)+`, `+ln.transform(t)+`, `+ln.transform(n)+`, `+Kt(en.transform(r))+`)`};function dn(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var fn={test:on(`#`),parse:dn,transform:un.transform},pn=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),mn=pn(`deg`),hn=pn(`%`),L=pn(`px`),gn=pn(`vh`),_n=pn(`vw`),vn={...hn,parse:e=>hn.parse(e)/100,transform:e=>hn.transform(e*100)},yn={test:on(`hsl`,`hue`),parse:sn(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+hn.transform(Kt(t))+`, `+hn.transform(Kt(n))+`, `+Kt(en.transform(r))+`)`},bn={test:e=>un.test(e)||fn.test(e)||yn.test(e),parse:e=>un.test(e)?un.parse(e):yn.test(e)?yn.parse(e):fn.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?un.transform(e):yn.transform(e),getAnimatableNone:e=>{let t=bn.parse(e);return t.alpha=0,bn.transform(t)}},xn=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,Sn=new RegExp(nn.source),Cn=new RegExp(xn.source,`i`);function wn(e){return isNaN(e)&&typeof e==`string`&&(Sn.test(e)||Cn.test(e))}var Tn=`number`,En=`color`,Dn=`var`,On=`var(`,kn="${}",An=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function jn(e){let t=e.toString();return Sn.test(t)||Cn.test(t)}function Mn(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(An,e=>(bn.test(e)?(r.color.push(a),i.push(En),n.push(bn.parse(e))):e.startsWith(On)?(r.var.push(a),i.push(Dn),n.push(e)):(r.number.push(a),i.push(Tn),n.push(parseFloat(e))),++a,kn)).split(kn),indexes:r,types:i}}function Nn(e){return Mn(e).values}function Pn({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];i+=e===Tn?Kt(r[a]):e===En?bn.transform(r[a]):r[a]}return i}}function Fn(e){return Pn(Mn(e))}var In=e=>typeof e==`number`?0:bn.test(e)?bn.getAnimatableNone(e):e,Ln=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:In(e);function Rn(e){let t=Mn(e);return Pn(t)(t.values.map((e,n)=>Ln(e,t.split[n])))}var zn={test:wn,parse:Nn,createTransformer:Fn,getAnimatableNone:Rn};function Bn(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Vn({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Bn(s,r,e+1/3),a=Bn(s,r,e),o=Bn(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Hn(e,t){return n=>n>0?t:e}var Un=(e,t,n)=>e+(t-e)*n,Wn=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Gn=[fn,un,yn],Kn=e=>Gn.find(t=>t.test(e));function qn(e){let t=Kn(e);if(!t)return`${e}`,!1;let n=t.parse(e);return t===yn&&(n=Vn(n)),n}var Jn=(e,t)=>{let n=qn(e),r=qn(t);if(!n||!r)return Hn(e,t);let i={...n};return e=>(i.red=Wn(n.red,r.red,e),i.green=Wn(n.green,r.green,e),i.blue=Wn(n.blue,r.blue,e),i.alpha=Un(n.alpha,r.alpha,e),un.transform(i))},Yn=new Set([`none`,`hidden`]);function Xn(e,t){return Yn.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Zn(e,t){return n=>Un(e,t,n)}function Qn(e){return typeof e==`number`?Zn:typeof e==`string`?Xt(e)?Hn:bn.test(e)?Jn:nr:Array.isArray(e)?$n:typeof e==`object`?bn.test(e)?Jn:er:Hn}function $n(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Qn(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function er(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Qn(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function tr(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]],s=e.values[o]??0;n[i]=s,r[a]++}return n}var nr=(e,t)=>{let n=zn.createTransformer(t),r=Mn(e),i=Mn(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Yn.has(e)&&!i.values.length||Yn.has(t)&&!r.values.length?Xn(e,t):mt($n(tr(r,i),i.values),n):(`${e}${t}`,Hn(e,t))},rr=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function ir(e,t){let n=rr.exec(e);if(!n)return;let r=rr.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>Kt(Un(a,o,e))+i}function ar(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Un(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=ir(e,t);if(n)return n}return Qn(e)(e,t)}var or=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function sr(e){let t=new Set,n=new Set,r=!1,i=!1,a=new Set,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(n.add(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var cr=40;function lr(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=or.reduce((e,t)=>(e[t]=sr(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=ct.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,cr),1)),n.timestamp=o,n.isProcessing=!0,s.process(n),c.process(n),l.process(n),u.process(n),d.process(n),f.process(n),p.process(n),m.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(h))},g=()=>{r=!0,i=!0,n.isProcessing||e(h)};return{schedule:or.reduce((e,t)=>{let n=o[t];return e[t]=(e,t=!1,i=!1)=>(r||g(),n.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<or.length;t++)o[or[t]].cancel(e)},state:n,steps:o}}var{schedule:ur,cancel:dr,steps:fr}=lr(typeof requestAnimationFrame<`u`?requestAnimationFrame:pt,!0,Ht),pr=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>ur.update(t,e),stop:()=>dr(t),now:()=>Ht.isProcessing?Ht.timestamp:Gt.now()}},mr=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},hr=2e4;function gr(e,t=50,n=hr,r){let i=0,a=e.next(i);for(r?.push(a.value);!a.done&&i<n;)i+=t,a=e.next(i),r?.push(a.value);return i>=n?1/0:i}function _r(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(gr(r),hr);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:vt(i)}}var vr={stiffness:100,damping:10,mass:1,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05},yr=e=>e<0?1/Math.max(1+e,vr.minDamping):Math.max(1-e,vr.minDamping);function br(e,t){if(!(e>1))return 1;let n=Math.sqrt(e*e-1),r=e-n,i=e+n,a=2*n*Math.exp(-t)*(1+t);return Cr(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function xr(e,t){return e*Math.sqrt(1-t*t)}var Sr=12;function Cr(e,t,n){let r=n;for(let n=1;n<Sr;n++)r-=e(r)/t(r);return r}var wr=.001;function Tr({duration:e=vr.duration,bounce:t=vr.bounce}){let n,r;vr.maxDuration;let i=yr(t);e=st(vr.minDuration,vr.maxDuration,vt(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=xr(t,i),o=Math.exp(-r);return wr-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=xr(t*t,i);return(-n(t)+wr>0?-1:1)*-a*o/s}):(n=t=>-.001+Math.exp(-t*e)*(t*e+1),r=t=>Math.exp(-t*e)*(-t*(e*e)));let a=5/e,o=Cr(n,r,a),s=o*br(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:_t(e)}}var Er=(e,t)=>(t?e>=0:e>0)&&e<1/0;function Dr(e,t){if(Er(e,t))return e}function Or(e){let t=Dr(e.stiffness),n=Dr(e.damping,!0),r=Dr(e.mass),i={...e,stiffness:t??vr.stiffness,damping:n??vr.damping,mass:r??vr.mass,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=yr(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*br(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,Tr(i)),i.isResolvedFromDuration=!0;(!Er(i.stiffness)||!Er(i.damping,!0))&&(i.stiffness=vr.stiffness,i.damping=vr.damping)}return i}function kr(e=vr.visualDuration,t=vr.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:o,damping:s,mass:c,duration:l,isResolvedFromDuration:u,isTimeDefined:d}=Or({...n}),f=e=>d?0:-vt(e),p=s/(2*Math.sqrt(o*c)),m=vt(Math.sqrt(o/c)),h=p*m,g={target:i,delta:i-r,velocity:f(n.velocity||0)||0,restSpeed:0,restDelta:0},_=()=>{let e=Math.abs(g.delta)<5;g.restSpeed=n.restSpeed||(e?vr.restSpeed.granular:vr.restSpeed.default),g.restDelta=n.restDelta||(e?vr.restDelta.granular:vr.restDelta.default)};_();let v,y,b;if(p<1){let e=xr(m,p),t={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};b=()=>{t.A=(g.velocity+h*g.delta)/e,t.sinC=h*t.A+g.delta*e,t.cosC=h*g.delta-t.A*e};let n=n=>{n!==t.t&&(t.t=n,t.env=Math.exp(-h*n),t.sin=Math.sin(e*n),t.cos=Math.cos(e*n))};v=e=>(n(e),g.target-t.env*(t.A*t.sin+g.delta*t.cos)),y=e=>(n(e),t.env*(t.sinC*t.sin+t.cosC*t.cos))}else if(p===1){v=e=>g.target-Math.exp(-m*e)*(g.delta+(g.velocity+m*g.delta)*e);let e={C:0};b=()=>{e.C=g.velocity+m*g.delta},y=t=>Math.exp(-m*t)*(m*e.C*t-g.velocity)}else{let e=m*Math.sqrt(p*p-1),t=h-e,n=h+e,r=d?1/0:300/e,i=(e,t)=>Math.exp(t>r?-e*r-h*(t-r):-e*t),a={S:0,F:0};b=()=>{let t=(g.velocity+h*g.delta)/e;a.S=(g.delta+t)/2,a.F=(g.delta-t)/2},v=e=>g.target-a.S*i(t,e)-a.F*i(n,e),y=e=>t*a.S*i(t,e)+n*a.F*i(n,e)}b();let x=u&&l||null,S={calculatedDuration:x,retarget:(e,t)=>{g.target=e[e.length-1],g.delta=g.target-e[0],g.velocity=f(t),n.restSpeed&&n.restDelta||_(),S.calculatedDuration=x,a.done=!1,b()},velocity:e=>_t(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=_t(y(e));a.done=Math.abs(n)<=g.restSpeed&&Math.abs(g.target-t)<=g.restDelta}return a.value=a.done?g.target:t,a},toString:()=>{let e=Math.min(gr(S),hr),t=mr(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}kr.applyToOptions=e=>{let t=_r(e,100,kr);return e.ease=t.ease,e.duration=_t(t.duration),e.type=`keyframes`,e};function Ar({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>e<s||e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>{let t=v(e);f.done=Math.abs(t)<=l,f.value=f.done?_:_+t},b,x,S=e=>{p(f.value)&&(b=e,x=kr({keyframes:[f.value,m(f.value)],velocity:-v(e)/r*1e3,damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return!x&&b===void 0&&(t=!0,y(e),S(e)),b!==void 0&&e>=b?x.next(e-b):(!t&&y(e),f)}}}function jr(e,t,n){let r=[],i=n||ct.mix||ar,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=mt(Array.isArray(t)?t[n]||pt:t,a)),r.push(a)}return r}function Mr(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=jr(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=ht(e[r],e[r+1],n);return s[r](i)};return n?t=>l(st(e[0],e[a-1],t)):l}function Nr(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=ht(0,t,r);e.push(Un(n,1,i))}}function Pr(e){let t=[0];return Nr(t,e.length-1),t}function Fr(e,t){return e.map(e=>e*t)}function Ir(e,t){return e.map(()=>t||It).splice(0,e.length-1)}function Lr({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=Lt(r)?r.map(Vt):Vt(r)||It,a={done:!1,value:t[0]};if(t.length===2&&!Array.isArray(i)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){let[n,r]=t,o=n===r?void 0:(ct.mix||ar)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?st(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=Mr(Fr(n&&n.length===t.length?n:Pr(t),e),t,{ease:Array.isArray(i)?i:Ir(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var Rr=5;function zr(e,t,n){let r=Math.max(t-Rr,0);return yt(n-e(r),t-r)}function Br(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):zr(t=>e.next(t).value,t,e.next(t).value)}var Vr=e=>e!==null;function Hr(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(Vr),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Ur={decay:Ar,inertia:Ar,tween:Lr,keyframes:Lr,spring:kr};function Wr(e){typeof e.type==`string`&&(e.type=Ur[e.type])}function Gr(e,t){return{kind:e,animation:t,timestamp:Gt.now(),frameTimestamp:Ht.timestamp,frameIsProcessing:Ht.isProcessing}}function Kr(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...Gr(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function qr(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...Gr(`layout-animation-start`,e),node:t})}catch{}}var Jr=class{constructor(){this.isResolved=!1}get finished(){return this._finished||=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e}),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},Yr=e=>e/100,Xr=class extends Jr{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Gt.now()&&this.tick(Gt.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),Kr(this,this.options)}initAnimation(){let{options:e}=this;Wr(e);let{type:t=Lr,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||Lr;s!==Lr&&typeof o[0]!=`number`&&(this.mixKeyframes=mt(Yr,ar(o[0],o[1])),o=[0,100]);let c=s(o===e.keyframes?e:{...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=gr(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.currentTime=this.holdTime===null?t:this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=st(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==Ar&&(b.value=Hr(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return vt(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+vt(e)}get time(){return vt(this.currentTime)}set time(e){e=_t(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){return Br(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Gt.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=vt(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=pr,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Gt.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}},Zr=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Qr(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(nn)||[];if(!r)return e;let i=n.replace(r,``),a=+!!Zr.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var $r=/\b([a-z-]*)\(.*?\)/gu,ei={...zn,getAnimatableNone:e=>{let t=e.match($r);return t?t.map(Qr).join(` `):e}},ti={...zn,getAnimatableNone:e=>{let t=zn.parse(e);return zn.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},ni={...$t,transform:Math.round},ri={borderWidth:L,borderTopWidth:L,borderRightWidth:L,borderBottomWidth:L,borderLeftWidth:L,borderRadius:L,borderTopLeftRadius:L,borderTopRightRadius:L,borderBottomRightRadius:L,borderBottomLeftRadius:L,width:L,maxWidth:L,height:L,maxHeight:L,top:L,right:L,bottom:L,left:L,inset:L,insetBlock:L,insetBlockStart:L,insetBlockEnd:L,insetInline:L,insetInlineStart:L,insetInlineEnd:L,padding:L,paddingTop:L,paddingRight:L,paddingBottom:L,paddingLeft:L,paddingBlock:L,paddingBlockStart:L,paddingBlockEnd:L,paddingInline:L,paddingInlineStart:L,paddingInlineEnd:L,margin:L,marginTop:L,marginRight:L,marginBottom:L,marginLeft:L,marginBlock:L,marginBlockStart:L,marginBlockEnd:L,marginInline:L,marginInlineStart:L,marginInlineEnd:L,fontSize:L,backgroundPositionX:L,backgroundPositionY:L,rotate:mn,pathRotation:mn,rotateX:mn,rotateY:mn,rotateZ:mn,scale:tn,scaleX:tn,scaleY:tn,scaleZ:tn,skew:mn,skewX:mn,skewY:mn,distance:L,translateX:L,translateY:L,translateZ:L,x:L,y:L,z:L,perspective:L,transformPerspective:L,opacity:en,originX:vn,originY:vn,originZ:L,zIndex:ni,fillOpacity:en,strokeOpacity:en,numOctaves:ni},ii={...ri,color:bn,backgroundColor:bn,outlineColor:bn,fill:bn,stroke:bn,borderColor:bn,borderTopColor:bn,borderRightColor:bn,borderBottomColor:bn,borderLeftColor:bn,filter:ei,WebkitFilter:ei,mask:ti,WebkitMask:ti},ai=e=>ii[e],oi=new Set([ei,ti]);function si(e,t){let n=ai(e);return oi.has(n)||(n=zn),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function ci(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var li=e=>e*180/Math.PI,ui=e=>fi(li(Math.atan2(e[1],e[0]))),di={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:ui,rotateZ:ui,skewX:e=>li(Math.atan(e[1])),skewY:e=>li(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},fi=e=>(e%=360,e<0&&(e+=360),e),pi=ui,mi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),hi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),gi={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:mi,scaleY:hi,scale:e=>(mi(e)+hi(e))/2,rotateX:e=>fi(li(Math.atan2(e[6],e[5]))),rotateY:e=>fi(li(Math.atan2(-e[2],e[0]))),rotateZ:pi,rotate:pi,skewX:e=>li(Math.atan(e[4])),skewY:e=>li(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function _i(e){return+!!e.includes(`scale`)}function vi(e,t){if(!e||e===`none`)return _i(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=gi,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=di,i=t}if(!i)return _i(t);let a=r[t],o=i[1].split(`,`).map(bi);return typeof a==`function`?a(o):o[a]}var yi=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return vi(n,t)};function bi(e){return parseFloat(e.trim())}var xi=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Si=new Set([...xi,`pathRotation`]),Ci=e=>e===$t||e===L,wi=new Set([`x`,`y`,`z`]),Ti=xi.filter(e=>!wi.has(e));function Ei(e){let t=[];return Ti.forEach(n=>{let r=e.getValue(n);if(r!==void 0){let e=r.get(),i=+!!n.startsWith(`scale`);if(e===i)return;t.push([n,e]),r.set(i)}}),t}var Di=new Set([`bottom`,`right`]);function Oi(e,t,n,r,i,a){let o=parseFloat(e);if(!isNaN(o))return o;let{min:s,max:c}=t()[n],l=c-s;return a===`border-box`?l:l-parseFloat(r)-parseFloat(i)}var ki={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>Oi(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>Oi(e,i,`y`,t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{let{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{let{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:({transform:e})=>vi(e,`x`),y:({transform:e})=>vi(e,`y`)};ki.translateX=ki.x,ki.translateY=ki.y;var Ai=new Set,ji=!1,Mi=!1,Ni=!1;function Pi(){if(Mi){let e=[],t=new Set,n=new Set;Ai.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),Di.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=Ei(e);t.length&&(r.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Mi=!1,ji=!1,Ai.forEach(e=>e.complete(Ni)),Ai.clear()}function Fi(){Ai.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Mi=!0)})}function Ii(){Ni=!0,Fi(),Pi(),Ni=!1}function Li(e,t,n){if(typeof e==`string`){if(lt(e)||dt(e))return parseFloat(e);if(!zn.test(e)&&zn.test(n))return si(t,n)}return e??void 0}var Ri=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Ai.add(this),ji||(ji=!0,ur.read(Fi),ur.resolveKeyframes(Pi))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=Li(n.readValue(t,a),t,a);r!==void 0&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}ci(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ai.delete(this)}cancel(){this.state===`scheduled`&&(Ai.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},zi=e=>e.startsWith(`--`);function Bi(e,t,n){zi(t)?e.style.setProperty(t,n):e.style[t]=n}var Vi={};function Hi(e,t){let n=ft(e);return()=>Vi[t]??n()}var Ui=Hi(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Wi=Hi(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Gi=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Ki={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Gi([0,.65,.55,1]),circOut:Gi([.55,0,1,.45]),backIn:Gi([.31,.01,.66,-.59]),backOut:Gi([.33,1.53,.69,.99])};function qi(e,t){if(e)return typeof e==`function`?Wi()?mr(e,t):`ease-out`:Rt(e)?Gi(e):Array.isArray(e)?e.map(e=>qi(e,t)||Ki.easeOut):Ki[e]}function Ji(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=qi(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function Yi(e){return typeof e==`function`&&`applyToOptions`in e}function Xi({type:e,...t}){return Yi(e)&&Wi()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Zi=class extends Jr{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=Xi(e);this.animation=Ji(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Hr(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Bi(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},Kr(this,e,c)}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e!==`idle`&&e!==`finished`&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return vt(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+vt(e)}get time(){return vt(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=_t(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,onAttach:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&Ui()?(this.animation.timeline=e,t?.(this.animation),pt):n(this)}},Qi={anticipate:At,backInOut:kt,circInOut:Nt};function $i(e){return e in Qi}function ea(e){typeof e.ease==`string`&&$i(e.ease)&&(e.ease=Qi[e.ease])}var ta=10,na=class extends Zi{constructor(e){ea(e),Wr(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new Xr({...a,autoplay:!1}),s=Math.max(ta,Gt.now()-this.startTime),c=st(0,ta,s-ta),l=o.sample(s).value,{name:u}=this.options;i&&u&&Bi(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},ra=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(zn.test(e)||e===`0`)&&!e.startsWith(`url(`));function ia(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function R(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=ra(i,t),s=ra(a,t);return!o||!s?(o!==s&&`${t}${i}${a}${o?a:i}`,!1):ia(e)||(n===`spring`||Yi(n))&&r}function aa(e){e.duration=0,e.type=`keyframes`}var oa=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),sa=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ca(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&sa.test(e[t]))return!0;return!1}var la=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),ua=ft(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function da(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(oa.has(n)||la.has(n)))return!1;let c=t?.owner?.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;let{onUpdate:l,transformTemplate:u}=t.owner.getProps();return ua()&&(oa.has(n)||la.has(n)&&ca(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var fa=40,pa=class extends Jr{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Gt.now();let{keyframes:t,name:n,motionValue:r,element:i}=e,a=e;a.autoplay??=!0,a.delay??=0,a.type??=`keyframes`,a.repeat??=0,a.repeatDelay??=0,a.repeatType??=`loop`;let o=i?.KeyframeResolver||Ri;this.keyframeResolver=new o(t,(e,t,n)=>this.onKeyframesResolved(e,t,a,!n),n,r,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Gt.now();let u=!0;R(e,i,a,o)||(u=!1,(ct.instantAnimations||!s)&&l?.(Hr(e,n,t)),e[0]=e[e.length-1],aa(n),n.repeat=0);let d=r?this.resolvedAt&&this.resolvedAt-this.createdAt>fa?this.resolvedAt:this.createdAt:void 0,{onComplete:f}=n;n.startTime??=d,n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{f?.(),this.notifyFinished()};let p=u&&!c&&da(n),m;if(p){n.element=n.motionValue?.owner?.current;try{m=new na(n)}catch{m=new Xr(n)}}else m=new Xr(n);this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this._animation.finished:super.finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Ii()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function ma(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var ha=30,ga=e=>!isNaN(parseFloat(e)),_a={current:void 0},va=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Gt.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.notifyChange(),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Gt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=ga(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){var n;return e===`change`?this.onChangeSubscribe(t):((n=this.events)[e]||(n[e]=new gt)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new gt,t.change.add(this.changeSubscriber),this.changeSubscriber=void 0),t.change.add(e)),()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:t.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){ur.read(()=>{!this.changeSubscriber&&!this.events.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.notifyChange()}notifyChange(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return _a.current&&_a.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Gt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ha)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,ha);return yt(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===r&&this.clearAnimation(),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){this.animation=void 0}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function ya(e,t){return new va(e,t)}function ba(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function xa(e,t){let n=e?.[t]??e?.default??e;return n===e?n:ba(n,e)}var Sa={type:`spring`,stiffness:500,damping:25,restSpeed:10},Ca=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),wa={type:`keyframes`,duration:.8},Ta={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Ea=(e,{keyframes:t})=>t.length>2?wa:Si.has(e)?e.startsWith(`scale`)?Ca(t[1]):Sa:Ta,Da=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Oa(e){for(let t in e)if(!Da.has(t))return!0;return!1}var ka=(e,t,n,r={},i,a)=>o=>{let s=xa(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=_t(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Oa(s)||Object.assign(u,Ea(e,u)),u.duration&&=_t(u.duration),u.repeatDelay&&=_t(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(aa(u),u.delay===0&&(d=!0)),(ct.instantAnimations||ct.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,aa(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=Hr(u.keyframes,s);if(e!==void 0){ur.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new Xr(u):new pa(u)},Aa=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ja(e){let t=Aa.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Ma(e,t,n=1){`${e}`;let[r,i]=ja(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return lt(e)?parseFloat(e):e}return Xt(i)?Ma(i,t,n+1):i}function Na(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Pa(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...Na(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function Fa(e,t,n){return Pa(e.getProps(),t,n,e)}var Ia=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,La=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...xi]),Ra=e=>Array.isArray(e);function za(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,ya(n))}function Ba(e){return Ra(e)?e[e.length-1]||0:e}function Va(e,t){let{transitionEnd:n={},transition:r={},...i}=Fa(e,t)||{};i={...i,...n};for(let t in i)za(e,t,Ba(i[t]))}var Ha=e=>!!(e&&e.getVelocity);function Ua(e){return!!(Ha(e)&&e.add)}function Wa(e,t){let n=e.getValue(`willChange`);if(Ua(n))return n.add(t);if(!n&&ct.WillChange){let n=new ct.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Ga(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Ka=`data-`+Ga(`framerAppearId`);function qa(e){return e.props[Ka]}var Ja=typeof window<`u`;function Ya({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function Xa(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?ba(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState?.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&Ya(f,t))continue;let o={delay:n,...xa(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){ur.update(()=>r.set(i));continue}let p=!1;if(Ja&&window.MotionHandoffAnimation){let n=qa(e);if(n){let e=window.MotionHandoffAnimation(n,t,ur);e!==null&&(o.startTime=e,p=!0)}}Wa(e,t);let m=l??e.shouldReduceMotion;r.start(ka(t,r,i,m&&La.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>ur.update(()=>{o&&Va(e,o)});d.length?Promise.all(d).then(t):t()}return d}function Za(e,t,n={}){let r=Fa(e,t,Ia(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?Xa(e,r,n):[]),o=(r=0)=>{let{variantChildren:a}=e,{delayChildren:o=0,staggerChildren:s,staggerDirection:c}=i,l=[];return a?.forEach(e=>{e.notify(`AnimationStart`,t),l.push(Za(e,t,{...n,delay:r+(typeof o==`function`?0:o)+ma(a,e,o,s,c)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(l)},{when:s}=i;return s?s===`beforeChildren`?a().then(()=>o()):o().then(a):Promise.all([a(),o(n.delay)])}function Qa(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>Za(e,t,n))):typeof t==`string`?Za(e,t,n):Promise.all(Xa(e,Fa(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var $a={test:e=>e===`auto`,parse:e=>e},eo=e=>t=>t.test(e),to=[$t,L,hn,mn,_n,gn,$a],no=e=>to.find(eo(e));function ro(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||dt(e)}var io=new Set([`auto`,`none`,`0`]);function ao(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!io.has(t)&&jn(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=si(n,i))}var oo=class extends Ri{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Xt(r))){let i=Ma(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!La.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=no(r),o=no(i);if(Qt(r)!==Qt(i)&&ki[n]){this.needsMeasurement=!0;return}if(a!==o){if(Ci(a)&&Ci(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else ki[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||ro(e[t]))&&n.push(t);n.length&&ao(e,n,t)}measure(){let{element:e,name:t}=this;return ki[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){let{element:e,unresolvedKeyframes:t}=this;if(!e||!e.current)return;this.motionValue?.jump(this.measuredOrigin,!1);let n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},so=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function co(e){return ut(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function lo(e){return ut(e)&&`ownerSVGElement`in e}var uo=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function fo(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var po={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},mo=xi.length;function ho(e,t,n){let r=``,i=!0;for(let a=0;a<mo;a++){let o=xi[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=uo(s,ri[o]);if(!c){i=!1;let t=po[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${uo(a,ri.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function go(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(Si.has(e)){o=!0;continue}if(Jt(e)){i[e]=n;continue}{let t=uo(n,ri[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=ho(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var _o={offset:`stroke-dashoffset`,array:`stroke-dasharray`},vo={offset:`strokeDashoffset`,array:`strokeDasharray`};function yo(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?_o:vo;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var bo=[`transform`,`opacity`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function xo(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(go(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;for(let e of bo)d[e]!==void 0&&(f[e]=d[e],delete d[e]);(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&yo(d,i,a,o,!1)}function So({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Co({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function wo(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function To(e){return e===void 0||e===1}function Eo({scale:e,scaleX:t,scaleY:n}){return!To(e)||!To(t)||!To(n)}function Do(e){return Eo(e)||Oo(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Oo(e){return ko(e.x)||ko(e.y)}function ko(e){return e&&e!==`0%`}function Ao(e,t,n){return n+t*(e-n)}function jo(e,t,n,r,i){return i!==void 0&&(e=Ao(e,i,r)),Ao(e,n,r)+t}function Mo(e,t=0,n=1,r,i){e.min=jo(e.min,t,n,r,i),e.max=jo(e.max,t,n,r,i)}function No(e,{x:t,y:n}){Mo(e.x,t.translate,t.scale,t.originPoint),Mo(e.y,n.translate,n.scale,n.originPoint)}var Po=.999999999999,Fo=1.0000000000001;function Io(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(Lo(e.x,-a.scroll.offset.x),Lo(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,No(e,o)),r&&Do(a.latestValues)&&Bo(e,a.latestValues,a.layout?.layoutBox))}t.x<Fo&&t.x>Po&&(t.x=1),t.y<Fo&&t.y>Po&&(t.y=1)}function Lo(e,t){e.min+=t,e.max+=t}function Ro(e,t,n,r,i=.5){Mo(e,t,n,Un(e.min,e.max,i),r)}function zo(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function Bo(e,t,n){let r=n??e;Ro(e.x,zo(t.x,r.x),t.scaleX,t.scale,t.originX),Ro(e.y,zo(t.y,r.y),t.scaleY,t.scale,t.originY)}function Vo(e,t){return So(wo(e.getBoundingClientRect(),t))}function Ho(e,t,n){let r=Vo(e,n),{scroll:i}=t;return i&&(Lo(r.x,i.offset.x),Lo(r.y,i.offset.y)),r}var{schedule:z,cancel:Uo}=lr(queueMicrotask,!1),Wo={x:!1,y:!1};function Go(){return Wo.x||Wo.y}function Ko(e){return e===`x`||e===`y`?Wo[e]?null:(Wo[e]=!0,()=>{Wo[e]=!1}):Wo.x||Wo.y?null:(Wo.x=Wo.y=!0,()=>{Wo.x=Wo.y=!1})}function qo(e,t){let n=fo(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Jo(e){return!(e.pointerType===`touch`||Go())}function Yo(e,t,n={}){let[r,i,a]=qo(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!Jo(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Xo=(e,t)=>t?e===t||Xo(e,t.parentElement):!1,Zo=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Qo=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function $o(e){return Qo.has(e.tagName)||e.isContentEditable===!0}var es=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function ts(e){return es.has(e.tagName)||e.isContentEditable===!0}var ns=new WeakSet;function rs(e){return t=>{t.key===`Enter`&&e(t)}}function is(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var as=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=rs(()=>{if(ns.has(n))return;is(n,`down`);let e=rs(()=>{is(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>is(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function os(e){return Zo(e)&&!Go()}var ss=new WeakSet;function cs(e,t,n={}){let[r,i,a]=qo(e,n),o=e=>{let r=e.currentTarget;if(!os(e)||ss.has(e))return;ns.add(r),n.stopPropagation&&ss.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),ns.has(r)&&ns.delete(r),os(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Xo(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),co(e)&&(e.addEventListener(`focus`,e=>as(e,i)),!$o(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var ls=new WeakMap,us,ds=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:lo(r)&&`getBBox`in r?r.getBBox()[t]:r[n],fs=ds(`inline`,`width`,`offsetWidth`),ps=ds(`block`,`height`,`offsetHeight`);function ms({target:e,borderBoxSize:t}){ls.get(e)?.forEach(n=>{n(e,{get width(){return fs(e,t)},get height(){return ps(e,t)}})})}function hs(e){e.forEach(ms)}function gs(){typeof ResizeObserver<`u`&&(us=new ResizeObserver(hs))}function _s(e,t){us||gs();let n=fo(e);return n.forEach(e=>{let n=ls.get(e);n||(n=new Set,ls.set(e,n)),n.add(t),us?.observe(e)}),()=>{n.forEach(e=>{let n=ls.get(e);n?.delete(t),n?.size||us?.unobserve(e)})}}var vs=new Set,ys;function bs(){ys=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};vs.forEach(t=>t(e))},window.addEventListener(`resize`,ys)}function xs(e){return vs.add(e),ys||bs(),()=>{vs.delete(e),!vs.size&&typeof ys==`function`&&(window.removeEventListener(`resize`,ys),ys=void 0)}}function Ss(e,t){return typeof e==`function`?xs(e):_s(e,t)}var Cs={value:null,addProjectionMetrics:null};function ws(e){return lo(e)&&e.tagName===`svg`}var Ts=e=>typeof e==`number`?e:parseFloat(e),Es=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ds=()=>({x:Es(),y:Es()}),Os=()=>({min:0,max:0}),ks=()=>({x:Os(),y:Os()}),As=new WeakMap;function js(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function Ms(e){return typeof e==`string`||Array.isArray(e)}var Ns=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Ps=[`initial`,...Ns];function Fs(e){if(js(e.animate))return!0;for(let t=0;t<Ps.length;t++)if(Ms(e[Ps[t]]))return!0;return!1}function Is(e){return!!(Fs(e)||e.variants)}function Ls(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Ha(i))e.addValue(r,i);else if(Ha(a))e.addValue(r,ya(i,{owner:e}));else if(a!==i){if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,ya(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var Rs={current:null},zs={current:!1},Bs=typeof window<`u`;function Vs(){if(zs.current=!0,Bs){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>Rs.current=e.matches;e.addEventListener(`change`,t),t()}else Rs.current=!1}}var Hs=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Us={};function Ws(e){Us=e}function Gs(){return Us}var Ks=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Ri,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Gt.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,ur.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=Fs(t),this.isVariantNode=Is(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&Ha(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];if(this.current=e,As.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.isVariantNode&&!this.isControllingVariants){let e=this;do e=e.props.inherit!==!1&&e.parent;while(e&&!e.isVariantNode);if(e){let{variantChildren:t}=e;t.add(this),this.removeFromVariantTree=()=>t.delete(this)}}this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(zs.current||Vs(),this.shouldReduceMotion=Rs.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),dr(this.notifyUpdate),dr(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&oa.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Zi({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:_t(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Si.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&ur.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Us){let t=Us[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):ks()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Hs.length;t++){let n=Hs[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=Ls(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}addValue(e,t){let n=this.values.get(e);if(t!==n){n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t);let r=t.get();r!==void 0&&(this.latestValues[e]=r)}}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=ya(t??this.getDefaultValue?.(e),{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(lt(n)||dt(n))?n=parseFloat(n):typeof n!=`number`&&!zn.test(n)&&zn.test(t)&&(n=si(e,t)),this.setBaseTarget(e,Ha(n)?n.get():n)),Ha(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new gt),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){z.render(this.render)}},qs=class extends Ks{constructor(){super(...arguments),this.KeyframeResolver=oo}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;Ha(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},Js=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Ys(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}var Xs={};function Zs(e,{layout:t,layoutId:n}){return Si.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!Xs[e]||e===`opacity`)}function Qs(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Ha(r[t])||i&&Ha(i[t])||Zs(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function $s(e){return window.getComputedStyle(e)}var ec=class extends qs{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Ys}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(Si.has(t))return this.projection?.isProjecting?_i(t):yi(e,t);{let n=$s(e),r=(Jt(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Vo(e,t)}build(e,t,n){go(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Qs(e,t,n)}},tc=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),nc=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function rc(e,t,n,r){Ys(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(tc.has(n)?n:Ga(n),t.attrs[n])}function ic(e,t,n){let r=Qs(e,t,n);for(let n in e)if(Ha(e[n])||Ha(t[n])){let t=xi.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var ac=class extends qs{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=ks}getBaseTargetFromProps(e,t){return Si.has(t)?super.getBaseTargetFromProps(e,t)??_i(t):e[t]}getDefaultValue(e){return Si.has(e)?this.latestValues[e]??_i(e):void 0}readValueFromInstance(e,t){if(Si.has(t)){let e=ai(t);return e&&e.default||0}if(bo.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=tc.has(t)?t:Ga(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return ic(e,t,n)}build(e,t,n){xo(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){rc(e,t,n,r)}mount(e){this.isSVGTag=nc(e.tagName),super.mount(e)}};function oc(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var sc=[...Ns].reverse();function cc(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>Qa(e,t,n))),n=uc(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,l=r||i,u=[],d=new Set,f={},p=1/0,m=e;do m=m.props.inherit!==!1&&m.parent;while(m&&!m.isControllingVariants);if(sc.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?Ms(g)||g===!1?g:void 0:h,v=Ms(_),y=t===a?i.isActive:null;y===!1&&(p=r);let b=v&&h===void 0&&!(l&&c);if(i.protectedKeys={...f},!i.isActive&&y===null||!_&&!i.prevProp||js(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=lc(i.prevProp,_),S=x||v&&(y&&!b||r>p),C=!1,w=Array.isArray(_)?_:[_],T={};if(y!==!1)for(let n of w){let{transition:r,transitionEnd:i,...a}=Fa(e,n,Ia(e,t))||{};T={...T,...a,...i}}let{prevResolvedValues:E}=i;for(let t in{...E,...T}){if(t in f)continue;let n=T[t],r=E[t],a=Array.isArray(n)&&Array.isArray(r)?!oc(n,r)||x:n!==r;if(a&&n==null)d.add(t);else if(a||n!==void 0&&d.has(t)){S=!0,d.delete(t)&&(C=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0}if(i.prevProp=_,i.prevResolvedValues=T,i.isActive&&(f={...f,...T}),S&&(!(b&&x)||C))for(let n of w){let r={type:t};if(typeof n==`string`&&l&&c&&s?.enteringChildren){let t=Fa(s,n)?.transition?.delayChildren;r.delay=ma(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&Fa(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom);r&&r.transition&&(n.transition=r.transition),d.forEach(i=>{let a=e.getValue(i);a&&(a.liveStyle=!0);let s=r&&!Array.isArray(t)?r[i]:void 0,c=e.getBaseTargetFromProps(o,i);n[i]=(s===void 0?c!==void 0&&!Ha(c)?c:e.initialValues[i]===void 0?e.baseTarget[i]:void 0:s)??null}),u.push({animation:n})}let h=l&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!h&&u.length?t(u):Promise.resolve()}function o(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=a(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:a,setActive:o,setAnimateFunction:n=>{t=n(e)},getState:()=>n,reset:()=>{n=uc(),i=!0}}}function lc(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!oc(t,e):!1}function uc(){let e={};for(let t of Ns)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function dc(e,t){e.min=t.min,e.max=t.max}function fc(e,t){dc(e.x,t.x),dc(e.y,t.y)}function pc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var mc=.9999,hc=1.0001,gc=-.01,_c=.01;function vc(e){return e.max-e.min}function yc(e,t,n){return Math.abs(e-t)<=n}function bc(e,t,n,r=.5){e.origin=r,e.originPoint=Un(t.min,t.max,e.origin),e.scale=vc(n)/vc(t),e.translate=Un(n.min,n.max,e.origin)-e.originPoint,(e.scale>=mc&&e.scale<=hc||isNaN(e.scale))&&(e.scale=1),(e.translate>=gc&&e.translate<=_c||isNaN(e.translate))&&(e.translate=0)}function xc(e,t,n,r){bc(e.x,t.x,n.x,r?r.originX:void 0),bc(e.y,t.y,n.y,r?r.originY:void 0)}function Sc(e,t,n,r=0){e.min=(r?Un(n.min,n.max,r):n.min)+t.min,e.max=e.min+vc(t)}function Cc(e,t,n,r){Sc(e.x,t.x,n.x,r?.x),Sc(e.y,t.y,n.y,r?.y)}function wc(e,t,n,r=0){let i=r?Un(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+vc(t)}function Tc(e,t,n,r){wc(e.x,t.x,n.x,r?.x),wc(e.y,t.y,n.y,r?.y)}function Ec(e,t,n,r,i){return e-=t,e=Ao(e,1/n,r),i!==void 0&&(e=Ao(e,1/i,r)),e}function Dc(e,t=0,n=1,r=.5,i,a=e,o=e){if(hn.test(t)&&(t=parseFloat(t),t=Un(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Un(a.min,a.max,r);e===a&&(s-=t),e.min=Ec(e.min,t,n,s,i),e.max=Ec(e.max,t,n,s,i)}function Oc(e,t,[n,r,i],a,o){Dc(e,t[n],t[r],t[i],t.scale,a,o)}var kc=[`x`,`scaleX`,`originX`],Ac=[`y`,`scaleY`,`originY`];function jc(e,t,n,r){Oc(e.x,t,kc,n?n.x:void 0,r?r.x:void 0),Oc(e.y,t,Ac,n?n.y:void 0,r?r.y:void 0)}function Mc(e){return e.translate===0&&e.scale===1}function Nc(e){return Mc(e.x)&&Mc(e.y)}function Pc(e,t){return e.min===t.min&&e.max===t.max}function Fc(e,t){return Pc(e.x,t.x)&&Pc(e.y,t.y)}function Ic(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Lc(e,t){return Ic(e.x,t.x)&&Ic(e.y,t.y)}function Rc(e){return vc(e.x)/vc(e.y)}function zc(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Bc(e){return[e(`x`),e(`y`)]}function Vc(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Hc={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(L.test(e))e=parseFloat(e);else return e}return`${Vc(e,t.target.x)}% ${Vc(e,t.target.y)}%`}},Uc={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=zn.parse(e);if(i.length>5)return r;let a=zn.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Un(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}};function Wc(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var Gc=so.length,Kc=e=>typeof e==`number`||L.test(e);function qc(e,t,n,r,i,a){i?(e.opacity=Un(0,n.opacity??1,Yc(r)),e.opacityExit=Un(t.opacity??1,0,Xc(r))):a&&(e.opacity=Un(t.opacity??1,n.opacity??1,r));for(let i=0;i<Gc;i++){let a=so[i],o=Jc(t,a),s=Jc(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||Kc(o)===Kc(s)?(e[a]=Math.max(Un(Ts(o),Ts(s),r),0),(hn.test(s)||hn.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Un(t.rotate||0,n.rotate||0,r))}function Jc(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Yc=Zc(0,.5,Mt),Xc=Zc(.5,.95,pt);function Zc(e,t,n){return r=>r<e?0:r>t?1:n(ht(e,t,r))}function Qc(e,t,n){let r=Ha(e)?e:ya(e);return r.start(ka(``,r,t,n)),r.animation}function $c(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var el=(e,t)=>e.depth-t.depth,tl=class{constructor(){this.children=[],this.isDirty=!1}add(e){at(this.children,e),this.isDirty=!0}remove(e){ot(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(el),this.isDirty=!1,this.children.forEach(e)}};function nl(e,t){let n=Gt.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(dr(r),e(a-t))};return ur.setup(r,!0),()=>dr(r)}function rl(e){return Ha(e)?e.get():e}var il=class{constructor(){this.members=[]}add(e){at(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(ot(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(ot(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},al={borderRadius:{...Hc,applyTo:[...so]},borderTopLeftRadius:Hc,borderTopRightRadius:Hc,borderBottomLeftRadius:Hc,borderBottomRightRadius:Hc,boxShadow:Uc},ol={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(Xs,{...al,...Xs});var sl={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},cl=[``,`X`,`Y`,`Z`],ll=1e3,ul=0;function dl(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function fl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=qa(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,ur,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&fl(r)}function pl({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=ul++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Cs.value&&(sl.nodes=sl.calculatedTargetDeltas=sl.calculatedProjections=0),this.nodes.forEach(gl),this.nodes.forEach(El),this.nodes.forEach(Dl),this.nodes.forEach(_l),Cs.addProjectionMetrics&&Cs.addProjectionMetrics(sl)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new tl)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new gt),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=lo(t)&&!ws(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;ur.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=nl(i,250),ol.hasAnimatedSinceResize&&(ol.hasAnimatedSinceResize=!1,this.nodes.forEach(Tl)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||Pl,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!Lc(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...xa(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||Tl(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),dr(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Ol),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&fl(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(bl),this.nodes.forEach(yl);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(xl);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Sl),this.nodes.forEach(Cl),this.nodes.forEach(wl),this.nodes.forEach(ml),this.nodes.forEach(hl)):this.nodes.forEach(xl),this.clearAllSnapshots();let e=Gt.now();Ht.delta=st(0,1e3/60,e-Ht.timestamp),Ht.timestamp=e,Ht.isProcessing=!0,fr.update.process(Ht),fr.preRender.process(Ht),fr.render.process(Ht),Ht.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,z.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(vl),this.sharedNodes.forEach(kl)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ur.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ur.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!vc(this.snapshot.measuredBox.x)&&!vc(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutCorrected||=ks(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!Nc(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Do(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),Rl(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return ks();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Bl))){let{scroll:e}=this.root;e&&(Lo(t.x,e.offset.x),Lo(t.y,e.offset.y))}return t}removeElementScroll(e){let t=ks();if(fc(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&fc(t,e),Lo(t.x,i.offset.x),Lo(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||ks();fc(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(Lo(r.x,-n.scroll.offset.x),Lo(r.y,-n.scroll.offset.y)),Do(n.latestValues)&&Bo(r,n.latestValues,n.layout?.layoutBox)}return Do(this.latestValues)&&Bo(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=ks();fc(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Do(n.latestValues))continue;let r;n.instance&&(Eo(n.latestValues)&&n.updateSnapshot(),r=ks(),fc(r,n.measurePageBox())),jc(t,n.latestValues,n.snapshot?.layoutBox,r)}return Do(this.latestValues)&&jc(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ht.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Ht.timestamp;let a=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),(this.relativeTarget||this.targetDelta)&&(this.target||(this.target=ks(),this.targetWithTransforms=ks()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Cc(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):fc(this.target,this.layout.layoutBox),No(this.target,this.targetDelta)):fc(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),Cs.value&&sl.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Eo(this.parent.latestValues)||Oo(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=ks(),this.relativeTargetOrigin=ks(),Tc(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),fc(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Ht.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;fc(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Io(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=ks());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(pc(this.prevProjectionDelta.x,this.projectionDelta.x),pc(this.prevProjectionDelta.y,this.projectionDelta.y)),xc(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!zc(this.projectionDelta.x,this.prevProjectionDelta.x)||!zc(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Cs.value&&sl.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Ds(),this.projectionDelta=Ds(),this.projectionDeltaWithTransform=Ds()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=Ds();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=ks(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(Nl));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=Un(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=Un(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(Al(o.x,e.x,n),Al(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Tc(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Ml(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&Fc(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=ks(),fc(f,this.relativeTarget)),c&&(this.animationValues=a,qc(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(dr(this.pendingAnimation),void 0),this.pendingAnimation=ur.update(()=>{ol.hasAnimatedSinceResize=!0,this.motionValue||=ya(0),this.motionValue.jump(0,!1),this.currentAnimation=Qc(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),qr(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(ll),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,layout:n,latestValues:r}=e,{target:i}=e;if(t&&i&&n){if(this!==e&&this.layout&&n&&zl(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||ks();let t=vc(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=vc(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}fc(t,i),Bo(t,r),xc(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new il),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&dl(`z`,e,r,this.animationValues);for(let t=0;t<cl.length;t++)dl(`rotate${cl[t]}`,e,r,this.animationValues),dl(`skew${cl[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=rl(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=rl(t?.pointerEvents)||``),this.hasProjected&&!Do(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=Wc(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=r.animationValues?r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in Xs){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=Xs[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?rl(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(yl),this.root.sharedNodes.clear()}}}function ml(e){e.updateLayout()}function hl(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)Bc(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=vc(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;dc(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else zl(i,t.layoutBox,n)&&Bc(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=vc(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=Ds();xc(o,n,t.layoutBox);let s=Ds();a?xc(s,e.applyTransform(r,!0),t.measuredBox):xc(s,n,t.layoutBox);let c=!Nc(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=ks();Tc(s,t.layoutBox,i.layoutBox,o);let c=ks();Tc(c,n,a.layoutBox,o),Lc(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function gl(e){Cs.value&&sl.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function _l(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function vl(e){e.clearSnapshot()}function yl(e){e.clearMeasurements()}function bl(e){e.isLayoutDirty=!0,e.updateLayout()}function xl(e){e.isLayoutDirty=!1}function Sl(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Cl(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function wl(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Tl(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function El(e){e.resolveTargetDelta()}function Dl(e){e.calcProjection()}function Ol(e){e.resetSkewAndRotation()}function kl(e){e.removeLeadSnapshot()}function Al(e,t,n){e.translate=Un(t.translate,0,n),e.scale=Un(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function jl(e,t,n,r){e.min=Un(t.min,n.min,r),e.max=Un(t.max,n.max,r)}function Ml(e,t,n,r){jl(e.x,t.x,n.x,r),jl(e.y,t.y,n.y,r)}function Nl(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var Pl={duration:.45,ease:[.4,0,.1,1]},Fl=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Il=Fl(`applewebkit/`)&&!Fl(`chrome/`)?Math.round:pt;function Ll(e){e.min=Il(e.min),e.max=Il(e.max)}function Rl(e){Ll(e.x),Ll(e.y)}function zl(e,t,n){return e===`position`||e===`preserve-aspect`&&!yc(Rc(t),Rc(n),.2)}function Bl(e){return e!==e.root&&e.scroll?.wasRoot}var Vl=pl({attachResizeListener:(e,t)=>$c(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Hl={current:void 0},Ul=pl({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Hl.current){let e=new Vl({});e.mount(window),e.setOptions({layoutScroll:!0}),Hl.current=e}return Hl.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Wl=(0,m.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Gl(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Kl(...e){return t=>{let n=!1,r=e.map(e=>{let r=Gl(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Gl(e[t],null)}}}}function ql(...e){return m.useCallback(Kl(...e),e)}var B=i(),Jl=class extends m.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(co(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=co(e)&&e.offsetWidth||0,r=co(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function Yl({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,m.useId)(),s=(0,m.useRef)(null),c=(0,m.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,m.useContext)(Wl),u=ql(s,a===!1?void 0:e.props?.ref??e?.ref);return(0,m.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
|
|
4
4
|
[data-motion-pop-id="${o}"] {
|
|
@@ -105,8 +105,8 @@ Error generating stack: `+e.message+`
|
|
|
105
105
|
`).map(e=>{let n=e.trimStart().startsWith("```");return n&&(t=!t),{text:e,fenced:t||n}})}function KU({notes:e}){return(0,B.jsx)(B.Fragment,{children:e.map((e,t)=>(0,B.jsx)(`p`,{className:`cs-dnote`,children:e},t))})}var qU=[],JU=(0,m.memo)(function({row:e,index:t,notes:n,form:r,onComment:i}){let a=e.text.trim(),o=()=>i(t);return(0,B.jsxs)(`li`,{"data-line":t,className:Y(`cs-dr`,!r&&`[contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`),children:[(0,B.jsxs)(`div`,{className:`cs-dln`,children:[(0,B.jsx)(`span`,{className:`cs-dd`,"aria-hidden":`true`,children:n.length>0?(0,B.jsx)(`i`,{}):null}),(0,B.jsx)(`div`,{className:Y(`cs-dtx`,e.fenced&&`font-mono text-[12.5px] whitespace-pre-wrap break-words`),"data-on":r?`true`:void 0,"data-k":/^#{1,6}\s/.test(a)?`h`:void 0,onClick:e=>!e.target.closest(`a`)&&o(),children:e.fenced?e.text:(0,B.jsx)(FL,{text:e.text})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-dcb`,"aria-label":`Comment on this line: ${a}`,onClick:o,children:(0,B.jsx)(am,{"aria-hidden":`true`,className:`size-[15px]`})})]}),(0,B.jsx)(KU,{notes:n}),r]})});function YU({draft:e,comments:t,commenting:n,form:r,onComment:i}){let a=(0,m.useMemo)(()=>GU(e),[e]),o=tL(a.length);return(0,B.jsx)(`ul`,{className:`cs-drl`,"aria-label":`Draft plan lines`,children:a.slice(0,o).map((e,a)=>e.text.trim()?(0,B.jsx)(JU,{row:e,index:a,notes:t.get(e.text.trim())??qU,form:a===n?r:void 0,onComment:i},a):(0,B.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},a))})}function XU({notes:e}){return e.length===0?null:(0,B.jsx)(GB,{title:kU,children:(0,B.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[(0,B.jsx)(`dt`,{className:`w-20 shrink-0 font-semibold`,style:{color:pR(e.from)},children:vR(e.from)}),(0,B.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,B.jsx)(FL,{text:e.text})})]},t))})})}function ZU(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function QU({label:e,hint:t,buttonLabel:n=`Send`,onSend:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(!1),l=async()=>{a.trim()&&!s&&(c(!0),await r(a)&&o(``),c(!1))};return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,B.jsx)(CB,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{ZU(e)&&(e.preventDefault(),l())}}),t?(0,B.jsx)(`p`,{id:`${i}-hint`,className:`text-xs text-muted-foreground`,children:t}):null,(0,B.jsx)(`div`,{className:`flex self-end`,children:(0,B.jsx)(EI,{label:n,icon:s?$p:Rf,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}function $U({line:e,onCancel:t,onSent:n}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=r.current?.querySelector(`textarea`);e?.focus(),e?.scrollIntoView({block:`nearest`})},[]),(0,B.jsxs)(`div`,{ref:r,role:`group`,"aria-label":`Comment on this line`,className:`line-comment cs-dform`,children:[(0,B.jsx)(OT,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Cancel the comment`,title:`Cancel · Esc`,onClick:t,className:`absolute top-1.5 right-1.5 size-7`,children:(0,B.jsx)(yh,{"aria-hidden":`true`})}),(0,B.jsx)(QU,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async t=>await U(`planner.commentLine`,{line:e,text:t.trim()})?(n(t.trim()),!0):!1})]})}function eW({open:e,onClose:t,snap:n,comments:r,onSent:i}){let a=(0,m.useRef)(null),[o,s]=(0,m.useState)(),c=(0,m.useMemo)(()=>n.draft?GU(n.draft):[],[n.draft]),l=o===void 0?void 0:c[o]?.text.trim(),u=()=>{let e=o;s(void 0),requestAnimationFrame(()=>a.current?.querySelector(`[data-line="${e}"] button[aria-label^="Comment on this line"]`)?.focus())};return(0,B.jsx)(BE,{open:e,onClose:()=>{s(void 0),t()},label:`Draft plan`,closeText:!0,onEscape:e=>{l!==void 0&&(e.preventDefault(),u())},head:(0,B.jsxs)(`div`,{className:`cs-shtitle`,children:[(0,B.jsx)(`h3`,{children:`Draft plan`}),(0,B.jsxs)(`p`,{children:[n.round>0?`${MU(n.round,n.limit)} · `:``,`choose a line to comment on it`]})]}),children:(0,B.jsxs)(`div`,{ref:a,className:`flex flex-col gap-5`,children:[n.draft?(0,B.jsx)(YU,{draft:n.draft,comments:r,commenting:l===void 0?void 0:o,form:l===void 0?void 0:(0,B.jsx)($U,{line:l,onCancel:u,onSent:e=>(i(l,e),u())},o),onComment:s}):(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.busy?OU:DU}),(0,B.jsx)(XU,{notes:n.notes})]})})}function tW({title:e,sub:t,aside:n,className:r,children:i}){let a=(0,m.useRef)(null);function o(e){let t=a.current;if(!t||e.defaultPrevented||e.nativeEvent.isComposing||JT()||e.altKey||e.ctrlKey||e.metaKey||yE(e.target)||e.target instanceof HTMLInputElement)return;let n=bE(e.key);n?(e.preventDefault(),CE(t,e.target,n)):(e.key===`Home`||e.key===`End`)&&(e.preventDefault(),CE(t,e.target,e.key===`Home`?`first`:`last`))}return(0,B.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`div`,{ref:a,"data-pane":`list`,className:`cs-scroll pb-dock`,onKeyDown:o,children:(0,B.jsxs)(`div`,{className:Y(`cs-pg`,r),children:[(0,B.jsxs)(`div`,{className:`cs-pgh`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h1`,{className:`cs-hd1`,children:e}),t?(0,B.jsx)(`p`,{className:`cs-hd2`,children:t}):null]}),n?(0,B.jsx)(`div`,{className:`flex flex-none items-center gap-2`,children:n}):null]}),i]})}),(0,B.jsx)(Qg,{target:a})]})}function nW({on:e,label:t,count:n,onToggle:r,describe:i}){return(0,B.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"aria-label":i,className:`cs-chk`,onClick:r,children:[(0,B.jsx)(`span`,{className:`cs-cb`,"data-on":e?`true`:void 0,children:(0,B.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7.5`})})}),t,n===void 0?null:(0,B.jsx)(`span`,{className:`cs-cn`,children:n})]})}var rW=()=>iE(rE(`plan`,`previous`)),iW=e=>iE(rE(`plan`,`previous`,e));function aW(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?BR(Math.max(0,t)):``}function oW(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,aW(e.updatedAt)].filter(Boolean).join(` · `)}function sW({plan:e,selected:t}){return(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>iW(e.id),className:`cs-trw cs-prw`,children:[(0,B.jsxs)(`span`,{className:`cs-tt1`,children:[(0,B.jsx)(`span`,{className:`cs-t`,children:e.title}),(0,B.jsx)(`span`,{className:`cs-mt`,children:oW(e,e.messages)})]}),e.hasDraft?(0,B.jsx)(`span`,{className:`cs-bdg`,"data-t":`acc`,children:`draft`}):(0,B.jsx)(`span`,{})]})})}function cW({id:e,onGone:t}){let n=eR(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,B.jsx)(cE,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await U(`planner.previousOpen`,{id:e})&&iE(rE(`plan`))},o=async()=>{await U(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await U(`planner.previousDelete`,{id:e})&&t()};return(0,B.jsxs)(`article`,{className:`cs-dt flex flex-col`,"aria-label":r.title,children:[(0,B.jsxs)(DI,{className:`cs-abm`,children:[(0,B.jsx)(EI,{label:`Carry on planning`,text:`Carry on`,icon:Tm,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,B.jsx)(EI,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?Of:Af,shortcut:`E`,onClick:()=>void o()}),(0,B.jsx)(qL,{icon:rh,label:`Delete`,shortcut:`Delete`,title:`Delete "${r.title}"?`,description:`The conversation and the draft are removed for good.`,confirmLabel:`Delete plan`,variant:`destructive`,onConfirm:()=>void s()})]}),(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`h2`,{children:r.title}),(0,B.jsx)(`p`,{className:`cs-sub`,children:[i?`archived`:``,oW(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,B.jsxs)(GB,{title:`Draft plan`,children:[r.draft?(0,B.jsx)(FL,{text:r.draft}):(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,B.jsx)(XU,{notes:r.notes})]}),(0,B.jsx)(GB,{title:`Conversation`,children:(0,B.jsx)(`div`,{className:`cs-pvc`,children:(0,B.jsx)(TU,{messages:r.messages,readOnly:!0})})})]})}function lW({id:e}){let[t,n]=(0,m.useState)(!1),r=eR(`planner.previous`,t?{archived:!0}:{},[`planner`]),i=r.data?.plans??[];if(!r.data&&r.error)return(0,B.jsx)(cE,{message:`Could not load the previous plans. ${r.error}`,onRetry:r.reload});let a=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(EI,{label:`Back to the current plan`,text:`Back`,icon:Pf,onClick:()=>iE(rE(`plan`))}),(0,B.jsx)(nW,{on:t,label:`Archived`,describe:t?`Show the previous plans`:`Show the archived plans`,onToggle:()=>{n(e=>!e),rW()}})]}),o=r.data?i.length===0?(0,B.jsx)(`p`,{className:`px-2.5 py-6 text-sm text-muted-foreground`,children:t?`No archived plans.`:`No previous plans. A plan you leave without saving it as a task waits here; one saved as a task is in the Tasks tab.`}):(0,B.jsx)(`ul`,{className:`cs-lst`,"aria-label":t?`Archived plans`:`Previous plans`,children:i.map(t=>(0,B.jsx)(sW,{plan:t,selected:t.id===e},t.id))}):(0,B.jsx)(jE,{});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(tW,{title:t?`Archived plans`:`Previous plans`,sub:r.data?`${i.length} ${i.length===1?`plan`:`plans`}`:void 0,className:`cs-ts`,aside:a,children:o}),(0,B.jsx)(BE,{open:e!==void 0,onClose:rW,label:`A previous plan`,className:`cs-tdw`,children:e?(0,B.jsx)(cW,{id:e,onGone:()=>{r.reload(),rW()}},e):null})]})}function uW({snap:e,onDone:t}){let n=(0,m.useRef)(null);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{ref:n,className:`cs-scroll pb-dock`,children:(0,B.jsxs)(`div`,{className:`cs-pg cs-intro cs-blank`,children:[(0,B.jsx)(`h2`,{children:`What are we planning?`}),(0,B.jsx)(`p`,{children:`Describe it below. The panel asks what it needs, then drafts the plan.`})]})}),(0,B.jsx)(Qg,{target:n}),(0,B.jsx)(WU,{snap:e,onDone:t})]})}function dW(e,t){let n=(0,m.useRef)(t);n.current=t;let r=(0,m.useCallback)(()=>n.current(),[]);RE(`v`,r,{enabled:!!e.draft}),mD(e.draft?r:void 0)}function fW({snap:e,reload:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(new Map);dW(e,()=>r(!0));let o=(e,t)=>a(n=>new Map(n).set(e,[...n.get(e)??[],t])),{ref:s,onScroll:c}=uR(`${JSON.stringify(e.messages)}${e.busy}`);return(0,B.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,B.jsxs)(`div`,{ref:s,onScroll:c,className:`cs-thread min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pb-dock`,children:[(0,B.jsx)(BU,{snap:e}),(0,B.jsx)(TU,{messages:e.messages,busy:e.busy})]}),(0,B.jsx)(Qg,{target:s}),(0,B.jsx)(WU,{snap:e,onDone:t}),(0,B.jsx)(eW,{open:n,onClose:()=>r(!1),snap:e,comments:i,onSent:o})]})}function pW({rest:e=[]}){return e[0]===`previous`?(0,B.jsx)(lW,{id:e[1]}):(0,B.jsx)(mW,{})}function mW(){let e=eR(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,B.jsx)(cE,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,B.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=PU(t);return(0,B.jsx)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:n?(0,B.jsx)(uW,{snap:t,onDone:e.reload}):(0,B.jsx)(fW,{snap:t,reload:e.reload})})}var hW={},gW=new Set;function _W(e){hW=e;for(let e of[...gW])e()}function vW(e){hW.taskId!==e&&_W({...hW,taskId:e})}function yW(e){return gW.add(e),()=>{gW.delete(e)}}function bW(){return(0,m.useSyncExternalStore)(yW,()=>hW,()=>hW)}function xW(e,t=0,n=!1){let r=!n&&!e.waiting&&!!e.runningSince,i=r?Date.parse(e.serverNow)-Date.parse(e.runningSince):0;return Math.max(0,e.elapsedMs)+(Number.isFinite(i)?Math.max(0,i):0)+(r?Math.max(0,t):0)}function SW(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}function CW(e,t){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),!e)return;let t=performance.now(),n=window.setInterval(()=>r(performance.now()-t),1e3);return()=>window.clearInterval(n)},[e,t]),e?n:0}function wW({timing:e,stopped:t}){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),t||e.waiting||!e.runningSince)return;let n=performance.now(),i=window.setInterval(()=>r(performance.now()-n),1e3);return()=>window.clearInterval(i)},[e,t]),(0,B.jsxs)(`span`,{className:`tabular-nums break-words`,children:[e.waiting?`Waiting for you · `:``,SW(xW(e,n,t)),` execution`]})}function TW({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=CW(r,e);return(0,B.jsxs)(`span`,{className:`tabular-nums break-words`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,`worked `,SW(e.workedMs+i)]})}function EW({timing:e,work:t,stopped:n=!1}){return t?(0,B.jsx)(TW,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,B.jsx)(wW,{timing:e,stopped:n},JSON.stringify(e)):(0,B.jsx)(`span`,{children:`Timing unavailable`})}var DW=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,OW={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function kW({delivery:e,title:t}){return(0,B.jsxs)(`div`,{className:`cs-dlv grid gap-2 text-[12.5px]`,children:[(0,B.jsx)(`p`,{className:`text-[13.5px] font-semibold break-words`,children:t}),(0,B.jsxs)(`dl`,{children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Project`}),(0,B.jsx)(`dd`,{children:e.project})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Repository`}),(0,B.jsx)(`dd`,{children:e.repository??`Unavailable — refresh review`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Source`}),(0,B.jsxs)(`dd`,{children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Target`}),(0,B.jsxs)(`dd`,{children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,B.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,B.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,B.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Local completion/QA: `,e.verification.localVerified?`passed`:`not verified`,` · Repository rules: `,e.verification.rulesKnown?`known`:`unavailable`,e.verification.requiredChecks.length?` · Required: ${e.verification.requiredChecks.join(`, `)}`:``]}):null]})}function AW({action:e,delivery:t,busy:n,onAction:r}){let i=t.blocked[e],a=e===`merge_main`&&t.status===`successful`&&!!t.cleanupError,o=n||t.status===`in_progress`||t.status===`successful`&&!a||!!i;return(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,B.jsx)(OT,{variant:`outline`,size:`sm`,className:`w-fit`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e===`create_pr`?`Pushes the task branch and opens a PR targeting main. Does not merge.`:a?`Main was delivered. Removes the retained worktree after confirmation.`:`Updates and pushes main, then removes the task worktree. Requires confirmation.`}),i?(0,B.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function jW(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?I(`tasks.deliveryReview`,{taskId:t}):e===`defer`?I(`tasks.deliveryDefer`,r):I(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function MW({taskId:e,delivery:t}){let[n,r]=(0,m.useState)(t),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(null),d=me(),f=`${d}:${e}`,p=(0,m.useRef)(f);return p.current=f,(0,m.useEffect)(()=>(p.current=f,()=>{p.current=``}),[f]),(0,m.useEffect)(()=>{r(t),l(!1)},[t,e]),{current:n,setCurrent:r,busy:i,setBusy:a,error:o,setError:s,confirm:c,setConfirm:l,trigger:u,project:d,identity:f,scope:p}}function NW(e){return e.scope.current===e.identity&&e.project===me()}function PW(e,t){let n=(0,m.useRef)(!1);async function r(r){if(!(n.current||r===`merge_main`&&!e.confirm)){n.current=!0,e.setBusy(!0),e.setError(void 0),e.setConfirm(!1);try{let n=await jW(r,t.taskId,e.current.reviewId);NW(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){NW(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function FW(e){let t=MW(e),n=PW(t,e),r=qT(t.confirm,KT.confirm),i=t.current.status===`successful`||t.current.status===`in_progress`;function a(){t.trigger.current=document.activeElement,t.setConfirm(!0)}return{...t,request:n,slot:r,terminal:i,reviewMerge:a}}function IW({review:e}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,B.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:OW[e.current.status]}),e.current.error||e.error?(0,B.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.error??e.current.error,` Completed work is retained. Refresh review to reconcile the result before retrying.`]}):null,e.current.cleanupError?(0,B.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,B.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,B.jsxs)(`p`,{className:`text-sm break-all`,children:[e.current.result.action===`create_pr`?`PR #${e.current.result.pullNumber??``} created`:`main pushed · ${e.current.result.commit??``}`,e.current.result.pullUrl?(0,B.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function LW({review:e}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,B.jsx)(AW,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,B.jsx)(AW,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,B.jsx)(OT,{variant:`outline`,size:`sm`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,B.jsx)(OT,{variant:`ghost`,size:`sm`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function RW({review:e}){let t=e.current.status===`successful`&&!!e.current.cleanupError,n=t?`Main was already delivered. Remove the task worktree if it still contains only the reviewed commit. The task branch is kept.`:DW;return(0,B.jsx)(zT,{open:e.slot,onOpenChange:e.setConfirm,label:t?`Confirm worktree removal`:`Confirm merge to main`,description:n,onCloseAutoFocus:t=>{t.preventDefault(),requestAnimationFrame(()=>e.trigger.current?.focus())},children:(0,B.jsxs)(`div`,{className:`grid gap-3 p-4`,children:[(0,B.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,B.jsx)(`p`,{className:`text-sm`,children:n}),(0,B.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,B.jsx)(OT,{variant:`outline`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,B.jsx)(OT,{disabled:e.busy||!!e.current.blocked.merge_main||e.terminal&&!t,onClick:()=>void e.request(`merge_main`),children:t?`Confirm worktree removal`:`Confirm merge and push main`})]})]})})}function zW({title:e,review:t}){return(0,B.jsxs)(GB,{title:`Completed work · delivery review`,right:OW[t.current.status],children:[(0,B.jsxs)(`div`,{className:`cs-sunkbox`,children:[(0,B.jsx)(kW,{delivery:t.current,title:e}),(0,B.jsx)(IW,{review:t}),(0,B.jsx)(LW,{review:t})]}),(0,B.jsx)(RW,{review:t})]})}function BW(e){let t=FW(e);return(0,B.jsx)(zW,{title:e.title,review:t})}var VW={open:hp,delivered:lp,addressed:ap},HW={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function UW({comment:e}){let t=BR(Date.now()-Date.parse(e.createdAt)),n=VW[e.status];return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(n,{"aria-hidden":`true`,className:`size-3.5`}),HW[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function WW({comment:e,taskId:t,own:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=a&&(a.editedAt??``)>(e.editedAt??``)?a:e;return(0,B.jsxs)(`li`,{className:`cs-cmc`,children:[r?(0,B.jsx)(vU,{text:s.text,onSave:async n=>{let r=await I(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,B.jsx)(FL,{text:s.text}),(0,B.jsxs)(`div`,{className:`cs-cmeta`,"data-s":s.status,children:[(0,B.jsx)(UW,{comment:s}),n&&!r?(0,B.jsx)(`button`,{type:`button`,className:`cs-eb`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function GW({taskId:e,onAdded:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=(0,m.useId)();if(!n)return(0,B.jsxs)(OT,{size:`sm`,variant:`outline`,className:`w-fit`,onClick:()=>r(!0),children:[(0,B.jsx)(am,{"aria-hidden":`true`}),`Add comment`]});let l=async()=>{if(o||!i.trim())return;s(!0);let n=await U(`tasks.comment`,{taskId:e,text:i.trim()})!==void 0;s(!1),n&&(a(``),r(!1),t())};return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{htmlFor:c,className:`sr-only`,children:`Your comment`}),(0,B.jsx)(`textarea`,{id:c,autoFocus:!0,className:`cs-ta2`,placeholder:`Your comment`,value:i,disabled:o,onChange:e=>a(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),r(!1)):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),l()))}}),(0,B.jsxs)(`div`,{className:`cs-fa`,children:[(0,B.jsx)(`span`,{className:`cs-hint2`,children:`Enter adds the comment · Esc cancels`}),(0,B.jsx)(OT,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>r(!1),children:`Cancel`}),(0,B.jsx)(OT,{size:`sm`,disabled:o||!i.trim(),onClick:()=>void l(),children:`Add comment`})]})]})}function KW({taskId:e,finished:t,canComment:n}){let r=eR(`tasks.comments`,{taskId:e},[`tasks`]),i=vE(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,B.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`cs-sec flex flex-col gap-3`,children:[(0,B.jsxs)(`h3`,{id:`comments-${e}`,className:`cs-rl`,children:[`Comments`,o>0?(0,B.jsxs)(`span`,{className:`cs-rr`,children:[o,` open`]}):null]}),a.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan here or in the box below (Markdown and images work there); the oracle amends it.`:`No comments yet.`}):(0,B.jsx)(`ul`,{className:`cs-cm`,children:a.map(t=>(0,B.jsx)(WW,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))}),n?(0,B.jsx)(GW,{taskId:e,onAdded:r.reload}):null]})}var qW={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},JW={open:`open`,done:`done`,dropped:`abandoned`},YW={none:{label:`None`,depth:`nothing that runs changed: the engine's checks decide, no QA agent`,tone:``},low:{label:`Low`,depth:`a light check: the diff, the nearest tests, done once confident`,tone:`ok`},medium:{label:`Medium`,depth:`a standard check: the acceptance criteria and realistic regressions`,tone:`warn`},high:{label:`High`,depth:`a deep, adversarial review: invariants, recovery and everything the change reaches`,tone:`bad`}};function XW(e){let t=e.source===`classifier`?`Jev`:`rules`;if(!e.qaRequired)return`${t} · no QA agent`;let{min:n,max:r}=e.testBudget;return`${t} · ${n===r?r:`${n}-${r}`} new tests at most`}var ZW=`Nothing archived. Archive a finished task from its detail to keep this list short.`,QW=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function $W(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function eG(e){return e===`now`?`just now`:`${e} ago`}function tG(e){if(e.kind===`plan`)return[`planned`,e.age?e.age===`now`?`saved just now`:`saved ${e.age} ago`:``,e.issue?`#${e.issue}`:``].filter(Boolean).join(` · `);let t=e.owner??(e.section===`mine`?`this session`:``);return[$W(e.status,e.paused),t].filter(Boolean).join(` · `)}function nG(e){let t=[];for(let n of e){let e=t.at(-1);e&&e.section===n.section?e.rows.push(n):t.push({section:n.section,rows:[n]})}return t}var rG=1e3;function iG({taskId:e,index:t,text:n,onSkipped:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(``),f=qT(i,KT.confirm),p=(0,m.useId)(),h=(0,m.useId)(),g=o.trim(),_=e=>{c||(a(e),s(``),d(``))},v=async()=>{if(g&&!c){l(!0),d(``);try{H((await I(`tasks.skipStep`,{taskId:e,step:t,text:n,reason:g})).notice),a(!1),s(``),r()}catch(e){d(e instanceof Error?e.message:`That did not work. Try again.`)}finally{l(!1)}}};return(0,B.jsxs)(zL,{open:i&&f,onOpenChange:_,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-label":`Skip step ${t+1}`,onClick:()=>_(!0),className:`cs-skp step-skip`,children:[(0,B.jsx)(Gm,{"aria-hidden":`true`,className:`size-3.5`}),`Skip`]}),(0,B.jsxs)(BL,{children:[(0,B.jsxs)(VL,{children:[(0,B.jsxs)(UL,{children:[`Skip step `,t+1,`?`]}),(0,B.jsx)(WL,{children:`The oracle is told to carry on without it, and your reason stays with the step in the task's history.`})]}),(0,B.jsx)(`p`,{className:`rounded-md bg-muted px-2.5 py-1.5 text-sm break-words`,children:n}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,B.jsx)(`label`,{htmlFor:p,className:`text-sm font-medium`,children:`Why skip it?`}),(0,B.jsx)(CB,{id:p,value:o,autoFocus:!0,required:!0,maxLength:rG,disabled:c,"aria-describedby":h,"aria-invalid":u?!0:void 0,placeholder:`Already done by hand, not needed any more, out of scope…`,className:`max-h-48 min-h-20`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())}}),(0,B.jsx)(`p`,{id:h,className:`text-xs text-muted-foreground`,children:`A reason is required.`})]}),u?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u}):null,(0,B.jsxs)(HL,{children:[(0,B.jsx)(KL,{disabled:c,children:`Cancel`}),(0,B.jsx)(OT,{disabled:!g||c,"aria-busy":c,onClick:()=>void v(),children:c?`Skipping…`:`Skip step`})]})]})]})}function aG({step:e,stopped:t}){let n=CW(!t,e);return(0,B.jsx)(`span`,{className:`tabular-nums`,children:SW((e.workedMs??0)+n)})}function oG(e){return(e.split(`
|
|
106
106
|
`).find(e=>e.trim())?.trim()??``).replace(/^steps?\s+\d+(?:\s*[-–]\s*\d+)?\s*[:.\-–]\s*/i,``).replace(/^\*\*?goal\*\*?\s*[:\-–]\s*/i,``)}var sG=e=>SR({domain:e.domain});function cG({id:e,agents:t,stepText:n}){let[r,i]=(0,m.useState)(Date.now);(0,m.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let a=t.filter(e=>!e.parentRunId||!t.some(t=>t.runId===e.parentRunId)).flatMap(e=>[e,...t.filter(t=>t.parentRunId===e.runId)]);return(0,B.jsx)(`ul`,{id:e,"aria-label":`Agents on this step`,className:`cs-arows`,children:a.map(e=>{let i=sG(e),a=!!e.parentRunId&&t.some(t=>t.runId===e.parentRunId),o=Date.parse(e.startedAt),s=oG(e.instruction),c=s&&s.toLowerCase()!==n.trim().toLowerCase()?s:``;return(0,B.jsxs)(`li`,{className:`cs-arow`,"data-child":a?`true`:void 0,style:{"--ac":pR(i)},children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`cs-bt`}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`cs-be`}),(0,B.jsxs)(`span`,{className:`cs-ab2`,children:[(0,B.jsxs)(`span`,{className:`cs-ab2h`,children:[(0,B.jsx)(`b`,{children:vR(i)}),a?(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`child`}):null,(0,B.jsx)(`span`,{className:`cs-live`,children:`working`})]}),c?(0,B.jsx)(`span`,{className:`cs-br`,title:e.instruction,children:c}):null]}),Number.isFinite(o)?(0,B.jsx)(`span`,{className:`cs-tm`,children:SW(Math.max(0,r-o))}):null]},e.runId)})})}function lG({agents:e,count:t,step:n,stopped:r}){let i=[...new Set(e.map(sG))].slice(0,3);return(0,B.jsxs)(B.Fragment,{children:[i.length>0?(0,B.jsx)(`span`,{className:`cs-avs`,"aria-hidden":`true`,children:i.map(e=>(0,B.jsx)(`i`,{style:{"--ac":pR(e)},children:vR(e)[0]},e))}):null,(0,B.jsxs)(`span`,{className:`cs-cn1`,children:[t,` `,r?t===1?`agent`:`agents`:`working`]}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`cs-dm`,children:`·`}),(0,B.jsx)(aG,{step:n,stopped:r})]})}function uG(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function dG({step:e,index:t}){let n=e.skip?uG(e.skip.at):``;return(0,B.jsxs)(`li`,{className:`cs-stp`,"data-k":`skip`,"data-step":`skipped`,children:[(0,B.jsxs)(`div`,{className:`cs-stpa`,children:[(0,B.jsx)(PR,{mark:`skip`}),(0,B.jsxs)(`span`,{className:`cs-n`,children:[t+1,`.`]}),(0,B.jsx)(`span`,{className:`cs-tx`,children:e.text}),(0,B.jsx)(`span`,{className:`cs-skd`,children:`skipped`})]}),e.skip?(0,B.jsxs)(`p`,{className:`cs-why step-skip-reason`,children:[(0,B.jsx)(`b`,{children:`Why: `}),e.skip.reason,n?(0,B.jsxs)(`span`,{className:`text-[var(--faint)]`,children:[` · `,n]}):null]}):null]})}function fG({step:e,index:t,stopped:n,skip:r}){let i=!!e.active&&!n,a=i?e.agents??[]:[],o=a.length||(e.activeAgentCount??1),[s,c]=(0,m.useState)(!0),l=(0,m.useId)(),u=e.status===`done`;if(e.status===`skipped`)return(0,B.jsx)(dG,{step:e,index:t});let d=e.status===`current`&&!n;return(0,B.jsxs)(`li`,{className:`cs-stp`,"data-k":i?`now`:u?`done`:d?`next`:`todo`,"data-step":i?`active`:e.status,children:[(0,B.jsxs)(`div`,{className:`cs-stpa`,children:[(0,B.jsx)(PR,{mark:i?`now`:u?`done`:`open`}),(0,B.jsxs)(`span`,{className:`cs-n`,children:[t+1,`.`]}),(0,B.jsx)(`span`,{className:`cs-tx`,children:e.text}),i?(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":a.length>0?s:void 0,"aria-controls":a.length>0?l:void 0,disabled:a.length===0,onClick:()=>c(e=>!e),className:`cs-abdg`,children:[(0,B.jsx)(lG,{agents:a,count:o,step:e,stopped:n}),a.length>0?(0,B.jsx)(Yf,{"aria-hidden":`true`,className:`size-3`}):null,(0,B.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):d?(0,B.jsxs)(`span`,{className:`cs-nx`,children:[`next`,(0,B.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null,r&&!u&&!n?(0,B.jsx)(iG,{taskId:r.taskId,index:t,text:e.text,onSkipped:r.onSkipped}):null]}),s&&a.length>0?(0,B.jsx)(cG,{id:l,agents:a,stepText:e.text}):null]})}function pG({steps:e,stopped:t,skip:n}){let r=e.filter(e=>e.status===`skipped`).length;return(0,B.jsx)(GB,{title:`Steps`,...r?{right:`${r} skipped`}:{},children:(0,B.jsx)(`ol`,{className:`cs-stl`,"aria-label":`Steps`,children:e.map((e,r)=>(0,B.jsx)(fG,{step:e,index:r,stopped:t,skip:n},`${r}-${e.text}`))})})}function mG({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,B.jsxs)(GB,{title:`Full plan`,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`cs-fold w-fit`,children:[(0,B.jsx)($f,{"aria-hidden":`true`,className:`size-4`}),t?`Hide the details`:`Read the details of each step`]}),t?(0,B.jsx)(`div`,{id:r,className:`cs-fpb`,children:(0,B.jsx)(FL,{text:e})}):null]})}function hG({detail:e,finished:t}){return e.plan&&e.planDetails?(0,B.jsx)(mG,{text:e.planDetails}):e.plan?(0,B.jsx)(GB,{title:`Approved plan`,children:(0,B.jsx)(FL,{text:e.plan})}):e.proposal?(0,B.jsx)(GB,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,B.jsx)(FL,{text:e.proposal})}):(0,B.jsx)(GB,{title:`Plan`,children:(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`It ended before a plan was made.`:`No proposal or plan yet — the oracle is still clarifying or scouting.`})})}function gG({amendments:e}){return e.length===0?null:(0,B.jsx)(GB,{title:`Amendments`,children:(0,B.jsx)(`ul`,{className:`cs-bl`,children:e.map(e=>(0,B.jsx)(`li`,{className:`break-words`,children:e},e))})})}function _G({risk:e}){let t=YW[e.risk];return(0,B.jsxs)(GB,{title:`QA risk`,right:XW(e),children:[(0,B.jsxs)(`p`,{className:`cs-qa1`,"data-qa-risk":e.risk,children:[(0,B.jsx)(`span`,{className:`cs-bdg`,"data-t":t.tone,children:t.label}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,B.jsx)(`ul`,{className:`cs-bl`,"aria-label":`What QA looks at first`,children:e.focusAreas.map(e=>(0,B.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,B.jsxs)(`p`,{className:`cs-qaf`,children:[e.riskFactors.join(` · `),e.qaRequired?` · existing tests ${e.existingTestsLikelySufficient?`likely enough`:`likely not enough`}`:``]})]})}function vG({runs:e}){return e.length===0?null:(0,B.jsx)(GB,{title:`Recent runs`,children:(0,B.jsx)(`ul`,{className:`cs-bl cs-plain`,children:e.map((e,t)=>(0,B.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function yG({detail:e,finished:t,skip:n}){return(0,B.jsxs)(B.Fragment,{children:[e.steps.length>0?(0,B.jsx)(pG,{steps:e.steps,stopped:t,skip:n}):null,e.request?(0,B.jsx)(GB,{title:`Request`,children:(0,B.jsx)(FL,{text:e.request})}):null,(0,B.jsx)(hG,{detail:e,finished:t})]})}function bG({detail:e}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(gG,{amendments:e.amendments}),e.qaRisk?(0,B.jsx)(_G,{risk:e.qaRisk}):null,(0,B.jsx)(vG,{runs:e.runs})]})}function xG({row:e,quiet:t=!1}){let n=(0,m.useRef)(!0);(0,m.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);async function r(){if(e.section===`mine`)return iE(`#/lobby`);let t=me(),r=()=>n.current&&me()===t;try{let t=await I(`tasks.open`,{taskId:e.id});if(!r())return;let n=await I(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return iE(`#/lobby`);if(t.sessionId&&!t.key)return H.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return H.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await U(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&iE(`#/lobby`)}catch(e){r()&&H.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,B.jsx)(EI,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:If,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function SG({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,B.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,B.jsxs)(`span`,{children:[n>0?(0,B.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,B.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function CG({planId:e}){let t=eR(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,B.jsxs)(B.Fragment,{children:[n.issue?(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,B.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,B.jsx)(SG,{split:n.split}):null,(0,B.jsx)(GB,{title:`Agreed plan`,children:(0,B.jsx)(FL,{text:n.brief})})]}):t.error?(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function wG({row:e,onGone:t}){let n=async n=>{await U(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await U(`plans.discard`,{planId:e.id})&&t()};return(0,B.jsxs)(DI,{children:[(0,B.jsx)(EI,{label:`Start here`,icon:Tm,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,B.jsx)(EI,{label:`Start in a new session`,text:`New session`,icon:Ym,shortcut:`N`,onClick:()=>void n(`session`)}),(0,B.jsx)(qL,{icon:rh,label:`Discard`,shortcut:`Delete`,title:`Discard "${e.title}"?`,description:`The saved plan is removed from the list. This cannot be undone.`,confirmLabel:`Discard`,variant:`destructive`,onConfirm:()=>void r()})]})}function TG({row:e}){return(0,B.jsxs)(`article`,{className:`cs-dt flex min-w-0 flex-col`,"aria-label":e.title,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsxs)(`h2`,{children:[(0,B.jsx)(FR,{check:`open`}),(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,B.jsxs)(`p`,{className:`cs-sub`,children:[(0,B.jsx)(`span`,{className:`cs-bdg`,children:`planned`}),e.age?(0,B.jsxs)(`span`,{children:[`saved `,eG(e.age)]}):null]}),(0,B.jsx)(`p`,{className:`cs-ids`,children:e.id})]}),(0,B.jsx)(CG,{planId:e.id})]})}function EG({row:e,onResumed:t}){let[n,r]=(0,m.useState)(!1),i=(0,m.useRef)(!0);(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);async function a(){let n=me();r(!0);try{let r=await I(`tasks.resume`,{taskId:e.id});if(me()!==n)return;H(r.notice,{action:{label:`View task`,onClick:()=>iE(rE(`tasks`,e.id))}}),t()}catch(e){me()===n&&H.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,B.jsx)(EI,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:Tm,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function DG(e){return e instanceof Error?e.message:`That did not work. Try again.`}function OG({run:e,onDone:t}){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``);return{open:n,change:e=>{o||(r(e),a(``),l(``))},typed:i,setTyped:a,busy:o,error:c,submit:async()=>{s(!0),l(``);try{H((await e(i)).notice),r(!1),t()}catch(e){l(DG(e))}finally{s(!1)}}}}function kG({expected:e,value:t,onChange:n,disabled:r}){let i=(0,m.useId)();return(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,B.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:`Type the task's title to confirm`}),(0,B.jsx)(`p`,{className:`break-words rounded-md bg-muted px-2 py-1 font-mono text-xs select-all`,children:e}),(0,B.jsx)(xB,{id:i,value:t,disabled:r,autoComplete:`off`,spellCheck:!1,onChange:e=>n(e.target.value)})]})}function AG(e){let t=OG(e),n=qT(t.open,KT.confirm),r=e.typeToConfirm!==void 0&&t.typed!==e.typeToConfirm,i=e.tone??`neutral`;return(0,B.jsxs)(zL,{open:t.open&&n,onOpenChange:t.change,children:[(0,B.jsx)(EI,{label:e.label,icon:e.icon,tone:i,onClick:()=>t.change(!0)}),(0,B.jsxs)(BL,{children:[(0,B.jsxs)(VL,{children:[(0,B.jsx)(UL,{children:e.title}),(0,B.jsx)(WL,{children:e.description})]}),e.typeToConfirm===void 0?null:(0,B.jsx)(kG,{expected:e.typeToConfirm,value:t.typed,onChange:t.setTyped,disabled:t.busy}),t.error?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:t.error}):null,(0,B.jsxs)(HL,{children:[(0,B.jsx)(KL,{disabled:t.busy,children:`Cancel`}),(0,B.jsx)(OT,{variant:i===`danger`?`destructive`:`default`,disabled:r||t.busy,"aria-busy":t.busy,onClick:()=>void t.submit(),children:t.busy?`Working…`:e.confirmLabel})]})]})]})}function jG({taskId:e,item:t,onDone:n}){let r=n=>()=>I(`tasks.resolveApproval`,{taskId:e,approvalId:t.id,decision:n}),i=`${t.kind}${t.domain?` for ${t.domain}`:``}`;return(0,B.jsxs)(`span`,{className:`flex flex-wrap gap-1.5`,children:[(0,B.jsx)(AG,{label:`Approve`,icon:Jf,title:`Approve the ${i}?`,description:`${t.detail} The task's oracle is told and carries on with it.`,confirmLabel:`Approve`,run:r(`approved`),onDone:n}),(0,B.jsx)(AG,{label:`Reject`,icon:yh,tone:`danger`,title:`Reject the ${i}?`,description:`${t.detail} The task's oracle is told and works without it.`,confirmLabel:`Reject`,run:r(`rejected`),onDone:n})]})}function MG({taskId:e,item:t,live:n,onDone:r}){return(0,B.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 basis-60 gap-2`,children:[(0,B.jsx)(rp,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-[var(--warn)]`}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[t.kind,` `,t.detail]})]}),n&&t.id?(0,B.jsx)(jG,{taskId:e,item:t,onDone:r}):null]})}function NG({blockers:e}){return e.map((e,t)=>(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(pp,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-[var(--bad)]`}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))}function PG({row:e,detail:t,onChanged:n}){let r=e.id;return(0,B.jsxs)(`div`,{className:`cs-wacts`,children:[e.resumable?(0,B.jsx)(EG,{row:e,onResumed:n}):null,t.canAccept?(0,B.jsx)(AG,{label:`Accept as is`,icon:Um,title:`Accept "${e.title}" as is?`,description:`You accept the work unverified: missing QA and lint checks are waived on your word. The task's oracle is asked to complete it; nothing is merged.`,confirmLabel:`Accept as is`,run:()=>I(`tasks.accept`,{taskId:r}),onDone:n}):null,t.canForceClose?(0,B.jsx)(AG,{label:`Force close`,icon:dp,tone:`danger`,title:`Force close "${e.title}"?`,description:`The task is abandoned and its running work cancelled. Its code, worktree and history are kept; it is not marked complete.`,confirmLabel:`Force close`,typeToConfirm:e.title,run:e=>I(`tasks.forceClose`,{taskId:r,title:e}),onDone:n}):null]})}function FG({row:e,detail:t,onChanged:n}){let r=e.kind===`task`&&e.check===`open`,i=r&&!!(e.resumable||t.canAccept||t.canForceClose),a=t.waiting;return a.length===0&&t.blockers.length===0&&!i?null:(0,B.jsx)(GB,{title:`Waiting on`,children:(0,B.jsxs)(`div`,{className:`cs-sunkbox cs-cal`,children:[(0,B.jsxs)(`ul`,{className:`flex flex-col gap-2.5 text-[13px]`,children:[a.map((t,i)=>(0,B.jsx)(MG,{taskId:e.id,item:t,live:r,onDone:n},`${i}-${t.id||t.kind}`)),(0,B.jsx)(NG,{blockers:t.blockers})]}),i?(0,B.jsx)(PG,{row:e,detail:t,onChanged:n}):null]})})}function IG(e){if(e.kind===`archived`)return{state:`archived`,rest:eG(e.age??`now`)};let t=e.check!==`open`,n=e.owner??(e.section===`mine`?`this session`:``),r=t&&e.age?`${e.check===`dropped`?`dropped`:`done`} ${eG(e.age)}`:``;return{state:$W(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function LG(e){return e?[MR(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function RG({row:e}){return e.progress?(0,B.jsxs)(`p`,{className:`cs-prog`,children:[(0,B.jsx)(NR,{done:e.progress.done,total:e.progress.total}),(0,B.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function zG({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=IG(e),[a,o]=(0,m.useState)(!1),s=(0,m.useId)();return(0,B.jsxs)(`header`,{children:[(0,B.jsxs)(`h2`,{children:[(0,B.jsx)(FR,{check:e.check}),(0,B.jsxs)(`span`,{className:`sr-only`,children:[JW[e.check],`:`]}),(0,B.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,B.jsxs)(`p`,{className:`cs-sub`,children:[(0,B.jsx)(`span`,{className:`cs-bdg`,"data-t":e.check===`done`?`ok`:e.timing?.waiting?`warn`:e.check===`open`?`acc`:void 0,children:r}),i?(0,B.jsx)(`span`,{children:i}):null,(0,B.jsx)(`button`,{type:`button`,className:`cs-dtl`,"aria-expanded":a,"aria-controls":s,onClick:()=>o(e=>!e),children:a?`Hide details`:`Details`})]}),a?(0,B.jsx)(`p`,{id:s,className:`cs-ids`,children:[e.id,LG(t),n].filter(Boolean).join(` · `)}):null,(0,B.jsx)(RG,{row:e})]})}function BG({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await U(`tasks.restore`,{taskId:r},{undo:()=>void U(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await U(`tasks.archive`,{taskId:r},{undo:()=>void U(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await U(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void U(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function VG({row:e,archive:t}){return e.check===`open`?(0,B.jsx)(qL,{label:`Archive`,icon:Af,shortcut:`E`,title:`Archive "${e.title}"?`,description:`A task still under way is abandoned first, then moved to the archive. Restore brings it back.`,confirmLabel:`Archive`,onConfirm:()=>void t()}):(0,B.jsx)(EI,{label:`Archive`,icon:Af,shortcut:`E`,onClick:()=>void t()})}function HG({on:e,toggle:t}){return RE(`a`,t),(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:(0,B.jsxs)(`label`,{className:`cs-autol`,children:[(0,B.jsx)(km,{"aria-hidden":`true`,className:`size-3.5`}),(0,B.jsx)(`span`,{children:`Auto`}),(0,B.jsx)(SB,{small:!0,checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,B.jsx)(IT,{chord:`A`,className:`kbd-hint`})]})}),(0,B.jsx)(wI,{children:`Auto mode: the oracle decides without asking`})]})}function UG(e){return e.row.kind===`plan`?(0,B.jsx)(wG,{row:e.row,onGone:e.onGone}):(0,B.jsx)(WG,{...e})}function WG(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=BG(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,B.jsxs)(DI,{children:[t.kind===`task`&&t.check===`open`?(0,B.jsx)(xG,{row:t,quiet:s}):null,o?(0,B.jsx)(EI,{label:`Restore`,icon:Nm,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,B.jsx)(HG,{on:!!t.auto,toggle:a}):null,o?null:(0,B.jsx)(VG,{row:t,archive:r}),(0,B.jsx)(qL,{icon:rh,label:o?`Delete for good`:`Delete`,text:`Delete`,shortcut:`Delete`,title:`Delete "${t.title}" for good?`,description:`This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:()=>void i()})]})}function GG(e){let{row:t}=e,n=t.kind===`plan`,r=eR(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=vE(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,B.jsx)(TG,{row:t});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,B.jsxs)(`article`,{className:`cs-dt flex min-w-0 flex-col`,"aria-label":t.title,children:[(0,B.jsx)(zG,{row:t,task:a}),r.data?(0,B.jsx)(FG,{row:t,detail:r.data,onChanged:()=>{r.reload(),e.onChanged()}}):null,(0,B.jsx)(`p`,{className:`mt-2 text-[12.5px] text-muted-foreground`,children:(0,B.jsx)(EW,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,B.jsx)(BW,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,B.jsx)(yG,{detail:r.data,finished:!o,...o&&r.data.canSkip?{skip:{taskId:t.id,onSkipped:()=>{r.reload(),e.onChanged()}}}:{}}):null,(0,B.jsx)(KW,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,B.jsx)(bG,{detail:r.data}):null,r.error&&!r.data?(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function KG({row:e}){let t=e.work,n=!!t?.running&&e.check===`open`&&!e.timing?.waiting,r=CW(n,t??{workedMs:0,running:!1});if(!t||e.kind===`plan`)return(0,B.jsx)(`span`,{className:`cs-ttm`});let i=SW(t.workedMs+r);return(0,B.jsx)(`span`,{className:`cs-ttm`,"data-work-clock":n?`running`:`stopped`,children:i.replace(/ \d+s$/,``)})}function qG(e){return e.kind===`archived`?``:e.delivery?`delivery ${e.delivery.status.replaceAll(`_`,` `)}`:e.kind===`plan`||e.check===`open`?`${e.timing?.waiting?`waiting for you · `:``}${tG(e)}${e.auto?` · auto`:``}`:``}function JG(e){return e.check===`dropped`?`drop`:e.kind===`archived`?`arch`:e.check===`done`?`done`:`open`}function YG({row:e,selected:t,onSelect:n,head:r,count:i}){let a=e.kind!==`plan`&&e.progress&&e.progress.total>0?e.progress:void 0;return(0,B.jsxs)(`li`,{children:[r?(0,B.jsxs)(`h3`,{className:`cs-tsec`,children:[qW[e.section],(0,B.jsx)(`b`,{children:i})]}):null,(0,B.jsxs)(`button`,{type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:()=>n(e.id),className:`cs-trw`,children:[(0,B.jsx)(FR,{check:e.check}),(0,B.jsxs)(`span`,{className:`cs-tt1`,children:[(0,B.jsxs)(`span`,{className:`sr-only`,children:[JW[e.check],`:`]}),(0,B.jsx)(`span`,{className:`cs-t`,"data-k":JG(e),children:e.title}),(0,B.jsx)(`span`,{className:`cs-mt`,"data-w":e.timing?.waiting?`warn`:void 0,children:qG(e)})]}),(0,B.jsx)(`span`,{className:`cs-tpg`,children:a?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(NR,{done:a.done,total:a.total}),(0,B.jsxs)(`span`,{children:[a.done,`/`,a.total]})]}):null}),(0,B.jsx)(KG,{row:e}),(0,B.jsx)(`span`,{className:`cs-tag`,children:e.age??``})]})]})}function XG({rows:e,selectedId:t,onSelect:n}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`cs-tbh`,"aria-hidden":`true`,children:[(0,B.jsx)(`span`,{}),(0,B.jsx)(`span`,{children:`Task`}),(0,B.jsx)(`span`,{children:`Progress`}),(0,B.jsx)(`span`,{children:`Worked`}),(0,B.jsx)(`span`,{children:`Age`})]}),(0,B.jsx)(`ul`,{className:`cs-lst`,children:nG(e).flatMap(({rows:e},r,i)=>e.map((r,a)=>(0,B.jsx)(YG,{row:r,head:a===0&&i.length>1,count:e.length,selected:r.id===t,onSelect:n},`${r.kind}-${r.id}`)))})]})}var ZG=()=>iE(rE(`tasks`)),QG=e=>iE(rE(`tasks`,e));function $G(){return(0,B.jsxs)(uE,{className:`m-4 flex-1`,children:[(0,B.jsxs)(dE,{children:[(0,B.jsx)(pE,{variant:`icon`,children:(0,B.jsx)(Zp,{"aria-hidden":`true`})}),(0,B.jsx)(mE,{children:QW})]}),(0,B.jsx)(OT,{onClick:()=>iE(rE(`plan`)),children:`Plan a task`})]})}function eK({archived:e,current:t,old:n,onChange:r}){return(0,B.jsx)(hE,{label:`Show`,className:`cs-tshow`,value:e?`archived`:`active`,onChange:e=>r(e===`archived`),items:[{id:`active`,name:`Tasks`,label:(0,B.jsxs)(B.Fragment,{children:[`Tasks`,(0,B.jsx)(`span`,{className:`cs-cn`,children:t})]})},{id:`archived`,name:`Archived`,label:(0,B.jsxs)(B.Fragment,{children:[`Archived`,(0,B.jsx)(`span`,{className:`cs-cn`,children:n})]})}]})}function tK({id:e}){let[t,n]=(0,m.useState)(!1),r=eR(`tasks.list`,{},[`tasks`,`plans`]),i=eR(`tasks.archived`,{},[`tasks`]),a=r.data?.rows??[],o=i.data?.rows??[],s=t?o:a,c=[...a,...o].find(t=>t.id===e&&t.kind===`task`)?.id;if((0,m.useEffect)(()=>(vW(c),()=>vW(void 0)),[c]),!r.data&&r.error)return(0,B.jsx)(cE,{message:`Could not load tasks. ${r.error}`,onRetry:r.reload});if(r.data&&a.length===0&&o.length===0)return(0,B.jsx)($G,{});let l=[...a,...o].find(t=>t.id===e),u=l?{row:l,onGone:ZG,onChanged:r.reload}:void 0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(tW,{title:`Tasks`,className:`cs-ts`,aside:(0,B.jsx)(eK,{archived:t,current:a.length,old:o.length,onChange:n}),children:(t?i:r).data?s.length===0?(0,B.jsx)(`p`,{className:`cs-tnone`,children:t?ZW:QW}):(0,B.jsx)(XG,{rows:s,selectedId:e,onSelect:QG}):(0,B.jsx)(jE,{})}),(0,B.jsx)(BE,{open:!!e,onClose:ZG,label:l?.title??`Task`,className:`cs-tdw`,head:u?(0,B.jsx)(UG,{...u},u.row.id):null,children:u?(0,B.jsx)(GG,{...u},u.row.id):e?(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`}):null})]})}var nK={l:`lobby`,p:`plan`,t:`tasks`,n:`knowledge`,e:`settings`};function rK(e){if(e.kind===`settings`)return(0,B.jsx)(QH,{});switch(e.tab){case`lobby`:return(0,B.jsx)(Bz,{});case`tasks`:return(0,B.jsx)(tK,{...cR(e.rest)});case`plan`:return(0,B.jsx)(pW,{rest:e.rest});case`knowledge`:return(0,B.jsx)(sR,{rest:e.rest})}}function iK(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var aK={tab:`Tab`,esc:`Escape`,escape:`Escape`,enter:`Enter`,space:`Space`,pageup:`PageUp`,pagedown:`PageDown`,up:`ArrowUp`,down:`ArrowDown`,home:`Home`,end:`End`,"`":`Backquote`,"]":`BracketRight`,"[":`BracketLeft`,"/":`Slash`,"?":`Slash`,",":`Comma`,".":`Period`};function oK(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:aK[e]}function sK(e){let t={alt:!1,ctrl:!1,shift:!1,meta:!1,code:``};for(let n of e.toLowerCase().split(`+`))if(n===`alt`)t.alt=!0;else if(n===`ctrl`||n===`control`)t.ctrl=!0;else if(n===`shift`)t.shift=!0;else if(n===`meta`||n===`cmd`)t.meta=!0;else{let e=oK(n);if(!e)return;t.code=e}return t.code?t:void 0}function cK(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function lK(e,t){let n=sK(t);return n?cK(e,n):!1}function uK(e,t){for(let n of t)if(lK(e,n.key))return n.action}function dK(e,t){for(let n of t)if(lK(e,n.key))return n.id}function fK(e){return yE(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||JT()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function pK(e,t,n,r){let i=!e.shiftKey&&/^[1-9]$/.test(e.key)?t[Number(e.key)-1]:void 0;if(i)r(i.id);else if(e.key===`/`)n(`search`);else if(e.key===`?`)n(`help`);else if(e.key===`j`||e.key===`k`)wE(e.key===`j`?1:-1);else return!1;return!0}function mK(e,t){let n=dK(e,t.tabs),r=uK(e,t.keys);return!n&&!r?!1:iK(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||JT(),typing:yE(e.target)||e.target instanceof HTMLInputElement,saveAvailable:!!document.querySelector(`[data-plan-save]:not([disabled])`)})||(r===`search`||r===`savePlan`)&&!t.insideApp()?!0:(e.preventDefault(),n?t.onTab(n):r&&t.onAction(r),!0)}function hK(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=nK[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(pK(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function gK(e){(0,m.useEffect)(()=>{if(!e.enabled)return;let t=0,n=n=>{if(n.defaultPrevented||n.isComposing)return;if(n.target instanceof Element&&n.target.closest(`.xterm`)){uK(n,e.keys)===`terminal`&&(n.preventDefault(),e.onAction(`terminal`));return}if(!e.insideApp()){uK(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&fK(n)){t=0;return}if(mK(n,e)){t=0;return}t=r?hK(n,e,t):0};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e.enabled,e.keys,e.tabs,e.insideApp,e.onAction,e.onTab])}var _K=[{id:`focus`,caps:[`/`],help:`focus search, or the message box`},{id:`send`,label:`Enter`,help:`send the message`},{id:`newline`,label:`Shift+Enter`,help:`a new line (lists carry on)`},{id:`format`,label:`Ctrl+B`,help:`bold; Ctrl+I italic, Ctrl+E code, Ctrl+K link`},{id:`leave`,label:`Esc`,help:`leave the box for the tab bar`}],vK=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(nK).map(([e,t])=>({id:`go.${t}`,caps:[`g`,e],help:`jump to ${t}`})),{id:`project`,caps:[`P`],help:`open the project switcher`},{id:`theme`,caps:[`D`],help:`switch between light and dark`},{id:`edit`,label:`Ctrl+Enter`,help:`save an edited message; Esc cancels`}],yK=[{id:`tasks`,page:`Tasks`,keys:[[`E`,`archive`],[`R`,`restore`],[`A`,`auto mode`],[`Delete`,`delete`]]},{id:`saved`,page:`Saved plan`,keys:[[`S`,`start here`],[`N`,`new session`],[`Delete`,`discard`]]},{id:`plan`,page:`Plan`,keys:[[`A`,`answer`],[`R`,`retry`],[`Ctrl+S`,`save`],[`N`,`new plan`]]},{id:`knowledge`,page:`Knowledge`,keys:[[`E`,`edit`],[`A`,`add`],[`C`,`comment`],[`F`,`edit file`],[`Delete`,`delete`]]},{id:`confirm`,page:`Asked to confirm`,keys:[[`Y`,`yes, do it`],[`Esc`,`keep it`]]}],bK=[{id:`enter`,caps:[`↓`],help:`from the tab bar, into the page`},{id:`rows`,caps:[`↑`,`↓`],help:`move through a list (j and k work too)`},{id:`pane`,caps:[`←`,`→`],help:`between a list and its detail (h and l)`},{id:`ends`,caps:[`Home`,`End`],help:`first and last row`},{id:`open`,caps:[`Enter`,`Space`],help:`activate the focused button or row (links: Enter; checkboxes: Space)`},{id:`back`,label:`Esc`,help:`back up to the tab bar`}],xK=[{id:`qmove`,caps:[`↑`,`↓`],help:`move between the options`},{id:`qpick`,label:`Space`,help:`pick an option (several when allowed)`},{id:`qchoose`,label:`Enter`,help:`choose and go on; in your own answer, send it`},{id:`qacross`,caps:[`←`,`→`],help:`previous and next question`},{id:`qdigit`,caps:[`1`,`2`,`…`],help:`pick that option`},{id:`qesc`,label:`Esc`,help:`put the question away for later`}];function SK({line:e}){return(0,B.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,B.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,B.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,B.jsx)(AT,{children:e},e))}):(0,B.jsx)(IT,{chord:e.label??``})}),(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function CK(){return(0,B.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,B.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),yK.map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,B.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,B.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground`,children:e.keys.map(([e,t])=>(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(IT,{chord:e}),t]},e))})]},e.id))]})}function wK({title:e,lines:t}){return(0,B.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,B.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,B.jsx)(SK,{line:e},e.id))]})}function TK(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function EK(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function DK({open:e,onOpenChange:t,keys:n,tabs:r}){let i=e,a=qT(i,KT.help),o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(!i||!a)return;let e=e=>{let r=n.find(e=>e.action===`help`)?.key;(e.key===`Escape`||r&&lK(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t,a,i]),(0,B.jsxs)(zT,{open:i&&a,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,B.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,B.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(IT,{chord:`Esc`}),(0,B.jsx)(OT,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,B.jsx)(yh,{"aria-hidden":`true`})})]})]}),(0,B.jsxs)(`div`,{ref:o,className:`grid min-h-0 flex-1 grid-cols-2 gap-x-10 gap-y-6 overflow-y-auto p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,B.jsx)(wK,{title:`Everywhere`,lines:TK(n)}),(0,B.jsx)(wK,{title:`Jump to a tab`,lines:EK(r)}),(0,B.jsx)(wK,{title:`Navigation and editing`,lines:vK}),(0,B.jsx)(wK,{title:`Message box`,lines:_K})]}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,B.jsx)(wK,{title:`Lists and panes`,lines:bK}),(0,B.jsx)(CK,{}),(0,B.jsx)(wK,{title:`Questions`,lines:xK})]})]}),(0,B.jsx)(Qg,{target:o})]})}var OK=`size-[1.05rem]`;function kK({hint:e,onHelp:t,className:n,side:r=`top`}){return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"aria-keyshortcuts":e,"aria-describedby":`focused-action-help`,onClick:t,className:n,children:(0,B.jsx)(qp,{"aria-hidden":`true`,className:OK})})}),(0,B.jsxs)(wI,{side:r,children:[`Keyboard shortcuts `,(0,B.jsx)(IT,{chord:e})]})]})}function AK({className:e,side:t=`top`}){let n=Qz(),r=n?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,"aria-describedby":`focused-action-help`,className:e,onClick:()=>Xz(!n),children:n?(0,B.jsx)(ph,{"aria-hidden":`true`,className:OK}):(0,B.jsx)(dh,{"aria-hidden":`true`,className:OK})})}),(0,B.jsx)(wI,{side:t,children:r})]})})}function jK({className:e,side:t=`top`}){let{theme:n,setTheme:r}=eV(),i=n===`dark`||n===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":i?`Switch to light mode`:`Switch to dark mode`,"aria-keyshortcuts":`D`,"aria-describedby":`focused-action-help`,onClick:()=>r(i?`light`:`dark`),className:e,children:i?(0,B.jsx)($m,{"aria-hidden":`true`,className:OK}):(0,B.jsx)(pm,{"aria-hidden":`true`,className:OK})})}),(0,B.jsxs)(wI,{side:t,children:[i?`Light mode`:`Dark mode`,` `,(0,B.jsx)(IT,{chord:`D`})]})]})}function MK({className:e,side:t=`top`}){let n=cB(),r=n?`Turn off desktop notifications`:`Turn on desktop notifications`,i=async()=>{if(n)return uB();let e=await lB();e===`granted`?H.success(`Desktop notifications are on.`):H.error(e===`unsupported`?`This browser cannot show notifications.`:`Notifications are blocked for this page in the browser's settings.`)};return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n,className:e,onClick:()=>void i(),children:n?(0,B.jsx)(Hf,{"aria-hidden":`true`,className:OK}):(0,B.jsx)(Bf,{"aria-hidden":`true`,className:OK})})}),(0,B.jsx)(wI,{side:t,children:r})]})}function NK({className:e,side:t=`top`}){let n=x();if(!n.supported)return null;let r=n.on?`Leave full screen`:`Full screen`;return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":r,"aria-pressed":n.on,className:e,onClick:()=>void n.toggle(),children:n.on?(0,B.jsx)(dm,{"aria-hidden":`true`,className:OK}):(0,B.jsx)(rm,{"aria-hidden":`true`,className:OK})})}),(0,B.jsx)(wI,{side:t,children:r})]})}function PK(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function FK(e){if(e.size===0)throw Error(`${e.name||`That file`} is empty.`);if(e.size>20971520)throw Error(`${e.name||`That file`} is larger than 20 MB.`);let t=new URLSearchParams({name:e.name||`pasted-file`,type:e.type}),n=await fetch(P(`/api/files.upload?${t}`),{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e,credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new Se(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new Se(r.error,r.code,n.status);return r.result}function IK(e,t,n,r){let i=e.slice(0,t),a=e.slice(t,n),o=e.slice(n);if(a.length>=r.length*2&&a.startsWith(r)&&a.endsWith(r)){let e=a.slice(r.length,a.length-r.length);return{value:i+e+o,start:t,end:t+e.length}}return i.endsWith(r)&&o.startsWith(r)?{value:i.slice(0,i.length-r.length)+a+o.slice(r.length),start:t-r.length,end:n-r.length}:{value:i+r+a+r+o,start:t+r.length,end:n+r.length}}function LK(e,t,n){let r=e.slice(t,n)||`text`,i=`[${r}](url)`,a=t+r.length+3;return{value:e.slice(0,t)+i+e.slice(n),start:a,end:a+3}}var RK=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function zK(e,t){let n=e.lastIndexOf(`
|
|
107
107
|
`,t-1)+1,r=e.indexOf(`
|
|
108
|
-
`,t),i=e.slice(n,r<0?e.length:r),a=RK.exec(i);if(!a||t-n<a[0].length)return;let[o,s=``,c,l,u=`.`,d]=a;if(i.slice(o.length).trim()===``)return{value:e.slice(0,n)+e.slice(r<0?e.length:r),start:n,end:n};let f=`\n${s}${c??`${Number(l)+1}${u}`} ${d?`[ ] `:``}`;return{value:e.slice(0,t)+f+e.slice(t),start:t+f.length,end:t+f.length}}function BK(){try{return{id:me()}}catch(e){return{error:e.message}}}function VK(e,t){if(e){if(t&&!e.projects.some(e=>e.id===t))return`Selected project is unknown or offline. Refresh or choose a running project.`;if(!e.projects.length)return`No authorized running projects found. Open a folder from the Project menu, or refresh.`}}function HK(){let[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(0);async function s(){let e=++o.current;a(!0),r(void 0);try{let n=await I(`projects.list`,{});ye(n.projects),e===o.current&&t(n)}catch(t){e===o.current&&r(t.message)}finally{e===o.current&&a(!1)}}(0,m.useEffect)(()=>(s(),()=>{o.current++}),[]);let[c,l]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!i)return l(!1);let e=setTimeout(()=>l(!0),300);return()=>clearTimeout(e)},[i]),{data:e,error:n,busy:i,slow:c,refresh:s}}function UK({data:e,error:t}){let n=BK();return n.error??t??VK(e,n.id)}function WK({projects:e}){let t=UK(e);return t?(0,B.jsxs)(`p`,{role:`alert`,className:`notice flex min-w-0 items-start gap-2 pt-1 pb-0.5 text-xs break-words text-destructive`,children:[(0,B.jsx)(ah,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,B.jsx)(`span`,{children:t})]}):null}function GK(e){let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,n=e.key===`Home`?`first`:e.key===`End`?`last`:void 0;if(!t&&!n)return;let r=[...e.currentTarget.querySelectorAll(`[role='option'], [data-walk]`)];if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement);r[n===`first`?0:n===`last`?r.length-1:Math.max(0,Math.min(r.length-1,(i<0?t>0?-1:r.length:i)+t))]?.focus()}var KK=`bot-lobby:open-projects`,qK=4;function JK(e){return{w:360,h:41+Math.max(1,Math.min(e.data?.projects.length??1,qK))*44+1+30+(UK(e)?32:0)}}function YK({projects:e,name:t,branch:n,open:r,onToggle:i}){let a=UK(e);return(0,B.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${t}${n?`, branch ${n}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":r,"aria-keyshortcuts":`P ArrowDown`,"aria-busy":e.busy,"data-tip":`Switch project`,"data-on":r||void 0,onClick:i,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||r||(e.preventDefault(),i())},title:n?`${t} · ${n}`:t,className:`bubble-chip bubble-tip bubble-tool min-w-0`,children:[e.slow?(0,B.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,B.jsx)(Lp,{"aria-hidden":`true`,className:Y(`size-3.5 shrink-0`,a&&`text-destructive`)}),(0,B.jsx)(`span`,{className:`truncate`,children:t}),(0,B.jsx)(Yf,{"aria-hidden":`true`,className:`size-3 shrink-0`,strokeWidth:2})]})}function XK({projects:e,tab:t,onBrowse:n,onClose:r}){let{data:i,busy:a,refresh:o}=e,s=BK(),c=UK(e),l=s.error?`invalid`:s.id??i?.currentId??``,u=(0,m.useRef)(null);RE(`r`,()=>void o(),{inDialog:!0}),(0,m.useEffect)(()=>{(u.current?.querySelector(`[role='option'][aria-selected='true']`)??u.current?.querySelector(`[role='option']`))?.focus({preventScroll:!0})},[!!i]);function d(e){r(),e!==l&&F(e,t)}let f=Math.max(1,Math.min(i?.projects.length??1,qK));return(0,B.jsxs)(`div`,{ref:u,"aria-label":`Projects`,onKeyDown:GK,className:`bubble-pane flex flex-col p-1`,children:[(0,B.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between ps-2`,children:[(0,B.jsx)(`span`,{className:`text-[13px] font-medium text-(--bubble-muted)`,children:`Running projects`}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>void o(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`bubble-chip h-6 text-xs`,children:[a?(0,B.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,B.jsx)(km,{"aria-hidden":`true`,className:`size-3.5`}),`Refresh`,(0,B.jsx)(`kbd`,{className:`bubble-kbd`,children:`R`})]})]}),(0,B.jsx)(`div`,{className:`h-px shrink-0`}),(0,B.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`bubble-scroll flex shrink-0 flex-col overflow-y-auto`,style:{height:f*44},children:i?i.projects.map((e,t)=>{let n=e.id===l;return(0,B.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>d(e.id),className:Y(`bubble-row h-[44px] shrink-0`,n&&`bubble-prow`),style:{"--delay":`${40+t*12}ms`},children:[(0,B.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center`,children:n?(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-4 text-(--bubble-accent)`,strokeWidth:2}):null}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-medium text-(--bubble-ink)`,children:e.name}),(0,B.jsxs)(`span`,{className:`truncate text-xs text-(--bubble-muted)`,children:[e.cwd,` · :`,e.port]})]})]},e.id)}):(0,B.jsxs)(`div`,{className:`flex h-[44px] items-center gap-2 px-2 text-[13px] text-(--bubble-muted)`,children:[(0,B.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}),`Loading projects…`]})}),c?(0,B.jsxs)(`p`,{role:`alert`,className:`flex h-8 shrink-0 items-center gap-2 px-2 text-xs text-destructive`,children:[(0,B.jsx)(ah,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,title:c,children:c})]}):null,(0,B.jsx)(`div`,{className:`h-px shrink-0`}),(0,B.jsxs)(`button`,{type:`button`,"data-walk":!0,onClick:n,className:`bubble-row shrink-0`,style:{"--delay":`0ms`},children:[(0,B.jsx)(Fp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Open folder…`})]})]})}var ZK={w:500,h:304};function QK(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)();async function a(r){if(!t){n(!0),i(void 0);try{let{project:t}=await I(`projects.open`,{path:r});ye([t]),F(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function $K(e){let t=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`,n=e.split(t),r=[];return n.forEach((e,i)=>{if(!e)return;let a=n.slice(0,i+1).join(t);r.push({name:e,path:a||t})}),r.length?r:[{name:t,path:t}]}function eq(e,t,n){let r=[...e.currentTarget.querySelectorAll(`button[data-folder]:not(:disabled)`)],i=r.indexOf(document.activeElement),a={ArrowDown:Math.min(r.length-1,i+1),ArrowUp:Math.max(0,i-1),Home:0,End:r.length-1}[e.key];a!==void 0&&r.length>0?(e.preventDefault(),r[a]?.focus()):e.key===`Backspace`&&t&&(e.preventDefault(),n(t))}function tq({tab:e,onClose:t}){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)({step:0,dir:`fwd`}),o=eR(`projects.browse`,n===void 0?{}:{path:n},[]),s=QK(e),c=(0,m.useRef)(null),l=o.loading||s.opening,u=o.data?.path??n??``,d=(e,t)=>{e!==u&&(a(e=>({step:e.step+1,dir:t})),r(e))};(0,m.useEffect)(()=>{if(!o.data)return;let e=c.current?.querySelector(`button[data-folder]`);e&&!c.current?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[o.data]);let f=$K(u),p=f.slice(-4),h=o.data?.folders.length??0,g=o.error||s.error?o.error??s.error:o.loading&&!o.data?`Loading…`:h===0?`No subfolders`:`${h.toLocaleString()} ${h===1?`folder`:`folders`}${o.data?.truncated?` (first 2,000)`:``}`;return(0,B.jsxs)(`div`,{role:`group`,"aria-label":`Open project folder`,className:`bubble-pane flex flex-col gap-1 p-1`,style:{height:ZK.h},children:[(0,B.jsxs)(`div`,{className:`bubble-wellbar flex h-9 shrink-0 items-center gap-0.5 rounded-sm px-1`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":`Parent folder`,title:`Parent folder (Backspace)`,disabled:l||!o.data?.parent,onClick:()=>o.data?.parent&&d(o.data.parent,`back`),className:`bubble-iconbtn size-8 rounded-sm`,children:(0,B.jsx)(Rf,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.8})}),(0,B.jsxs)(`nav`,{"aria-label":`Folder path`,className:`flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap`,title:u,children:[f.length>p.length?(0,B.jsx)(`span`,{className:`shrink-0 px-1.5 text-[13px] text-(--bubble-muted)`,children:`…`}):null,p.map((e,t)=>(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[t>0?(0,B.jsx)($f,{"aria-hidden":`true`,className:`size-3 shrink-0 text-(--bubble-faint)`,strokeWidth:2}):null,(0,B.jsx)(`button`,{type:`button`,className:`bubble-crumb`,"data-last":t===p.length-1||void 0,"aria-current":t===p.length-1?`location`:void 0,disabled:l,onClick:()=>d(e.path,`back`),children:e.name})]},e.path))]})]}),(0,B.jsxs)(`div`,{ref:c,role:`group`,"aria-label":`Folders`,"aria-busy":o.loading,"data-dir":i.step?i.dir:void 0,onKeyDown:e=>eq(e,o.data?.parent,e=>d(e,`back`)),className:`bubble-flist bubble-scroll`,children:[o.data?.folders.map(e=>{let t=e.name.startsWith(`.`);return(0,B.jsxs)(`button`,{type:`button`,"data-folder":!0,disabled:s.opening,onClick:()=>d(e.path,`fwd`),title:e.path,className:Y(`bubble-frow`,t&&`text-(--bubble-muted)`),children:[(0,B.jsx)(`span`,{className:`bubble-ftile`,children:(0,B.jsx)(Lp,{"aria-hidden":`true`,className:`size-3.5 text-(--bubble-muted)`,strokeWidth:1.8})}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,B.jsx)($f,{"aria-hidden":`true`,className:`bubble-go size-3.5 shrink-0`,strokeWidth:2})]},e.path)}),o.data&&h===0?(0,B.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-xs text-(--bubble-muted)`,children:[(0,B.jsx)(Lp,{"aria-hidden":`true`,className:`size-6`,strokeWidth:1.5}),(0,B.jsx)(`span`,{children:`No subfolders here. You can open this folder.`})]}):null]},i.step),(0,B.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between gap-2 ps-2`,children:[(0,B.jsx)(`span`,{role:o.error||s.error?`alert`:`status`,className:Y(`min-w-0 truncate text-xs`,o.error||s.error?`text-destructive`:`text-(--bubble-muted)`),children:g}),(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[o.error?(0,B.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:o.reload,disabled:o.loading,children:`Retry`}):null,(0,B.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:t,disabled:s.opening,children:`Cancel`}),(0,B.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-key`,disabled:!o.data||o.loading||!!o.error||s.opening,onClick:()=>void s.open(o.data.path),children:s.opening?`Opening project…`:`Open this folder`})]})]})]})}function nq(){return(0,B.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,B.jsxs)(`defs`,{children:[(0,B.jsxs)(`filter`,{id:`bubble-goolit`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`3.5`,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,B.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.6`,result:`rimB`}),(0,B.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-hl)`},result:`hlc`}),(0,B.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,B.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.6`,result:`shB`}),(0,B.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-sh)`},result:`shc`}),(0,B.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`sh`}),(0,B.jsx)(`feMergeNode`,{in:`hl`})]})]}),(0,B.jsxs)(`filter`,{id:`bubble-gooedge`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`3.5`,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,B.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.3`,result:`tS1`}),(0,B.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-ehl)`},result:`tc`}),(0,B.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,B.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.3`,result:`bS1`}),(0,B.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-esh)`},result:`bc`}),(0,B.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`eh`}),(0,B.jsx)(`feMergeNode`,{in:`es`})]})]})]})})}function rq({kind:e}){return(0,B.jsxs)(`div`,{className:Y(`bubble-layer`,e===`edge`?`bubble-edge`:`bubble-fill`),"aria-hidden":`true`,children:[(0,B.jsx)(`div`,{className:`bubble-menu`,children:(0,B.jsx)(`div`,{className:`bubble-menu-clip`})}),(0,B.jsx)(`div`,{className:`bubble-ghost`})]})}function iq({open:e,size:t,shrunk:n,morphing:r,menu:i,children:a,className:o,style:s,...c}){let[l,u]=(0,m.useState)(e);return(0,m.useEffect)(()=>{if(e)return u(!0);let t=setTimeout(()=>u(!1),140);return()=>clearTimeout(t)},[e]),(0,B.jsxs)(`div`,{"data-slot":`composer-shell`,"data-open":e||void 0,"data-shrunk":n||void 0,"data-morphing":r||void 0,className:Y(`bubble`,o),style:{...s,"--w":`${t.w}px`,"--h":`${e?t.h:0}px`},...c,children:[(0,B.jsx)(nq,{}),(0,B.jsx)(rq,{kind:`edge`}),(0,B.jsx)(rq,{kind:`fill`}),(0,B.jsxs)(`div`,{className:`bubble-real`,children:[(0,B.jsx)(`div`,{className:`bubble-menu`,inert:!e,children:(0,B.jsx)(`div`,{className:`bubble-menu-clip`,children:(0,B.jsx)(`div`,{className:`bubble-menu-body`,children:e||l?i:null})})}),a]})]})}var aq=/^\s{0,3}(`{3,}|~{3,})/,oq=/^(\s{0,3}#{1,6})(\s+)(.*)$/,sq=/^(\s{0,3}>[>\s]*)(.*)$/,cq=/^(\s*)([-*+]|\d{1,9}[.)])(\s+)(\[[ xX]\]\s)?(.*)$/,lq=/^\s{0,3}([-*_])(\s*\1){2,}\s*$/,uq=/(`+)([^`\n]+?)\1|\[([^\]\n]+)\]\(([^)\s]+)\)|(\*\*|__)(?=\S)([^\n]*?\S)\5|(~~)(?=\S)([^\n]*?\S)~~|(?<![\w*])(\*)(?=[^\s*])([^*\n]*?[^\s*])\*(?!\*)|(?<![\w_])(_)(?=[^\s_])([^_\n]*?[^\s_])_(?![\w_])|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])|(?<![\w@])(@[a-z][\w-]*)/gi;function dq(e,t,n){if(!t)return;let r=e.at(-1);r&&r.kind===n?r.text+=t:e.push({text:t,kind:n})}var fq=(...e)=>e.filter(Boolean).join(` `);function pq(e,t,n){let r=0;for(let i of t.matchAll(uq)){let a=i.index;dq(e,t.slice(r,a),n);let[o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]=i;if(s)dq(e,s,fq(n,`code`,`mark`)),dq(e,c,fq(n,`code`)),dq(e,s,fq(n,`code`,`mark`));else if(l)dq(e,`[`,fq(n,`mark`)),dq(e,l,fq(n,`link`)),dq(e,`](${u})`,fq(n,`mark`));else if(d)dq(e,d,fq(n,`mark`)),pq(e,f,fq(n,`strong`)),dq(e,d,fq(n,`mark`));else if(p)dq(e,p,fq(n,`mark`)),pq(e,m,fq(n,`strike`)),dq(e,p,fq(n,`mark`));else if(h||_){let t=h??_;dq(e,t,fq(n,`mark`)),pq(e,g??v,fq(n,`em`)),dq(e,t,fq(n,`mark`))}else y?dq(e,y,fq(n,`link`)):b?dq(e,b,fq(n,`mention`)):dq(e,o,n);r=a+o.length}dq(e,t.slice(r),n)}function mq(e){let t=[],n;return e.split(`
|
|
108
|
+
`,t),i=e.slice(n,r<0?e.length:r),a=RK.exec(i);if(!a||t-n<a[0].length)return;let[o,s=``,c,l,u=`.`,d]=a;if(i.slice(o.length).trim()===``)return{value:e.slice(0,n)+e.slice(r<0?e.length:r),start:n,end:n};let f=`\n${s}${c??`${Number(l)+1}${u}`} ${d?`[ ] `:``}`;return{value:e.slice(0,t)+f+e.slice(t),start:t+f.length,end:t+f.length}}function BK(){try{return{id:me()}}catch(e){return{error:e.message}}}function VK(e,t){if(e){if(t&&!e.projects.some(e=>e.id===t))return`Selected project is unknown or offline. Refresh or choose a running project.`;if(!e.projects.length)return`No authorized running projects found. Open a folder from the Project menu, or refresh.`}}function HK(){let[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(0);async function s(){let e=++o.current;a(!0),r(void 0);try{let n=await I(`projects.list`,{});ye(n.projects),e===o.current&&t(n)}catch(t){e===o.current&&r(t.message)}finally{e===o.current&&a(!1)}}(0,m.useEffect)(()=>(s(),()=>{o.current++}),[]);let[c,l]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!i)return l(!1);let e=setTimeout(()=>l(!0),300);return()=>clearTimeout(e)},[i]),{data:e,error:n,busy:i,slow:c,refresh:s}}function UK({data:e,error:t}){let n=BK();return n.error??t??VK(e,n.id)}function WK({projects:e}){let t=UK(e);return t?(0,B.jsxs)(`p`,{role:`alert`,className:`notice flex min-w-0 items-start gap-2 pt-1 pb-0.5 text-xs break-words text-destructive`,children:[(0,B.jsx)(ah,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,B.jsx)(`span`,{children:t})]}):null}function GK(e){let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,n=e.key===`Home`?`first`:e.key===`End`?`last`:void 0;if(!t&&!n)return;let r=[...e.currentTarget.querySelectorAll(`[role='option'], [data-walk]`)];if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement);r[n===`first`?0:n===`last`?r.length-1:Math.max(0,Math.min(r.length-1,(i<0?t>0?-1:r.length:i)+t))]?.focus()}var KK=`bot-lobby:open-projects`,qK=4;function JK(e){return{w:360,h:45+Math.max(1,Math.min(e.data?.projects.length??1,qK))*46+1+32+(UK(e)?32:0)}}function YK({projects:e,name:t,branch:n,open:r,onToggle:i}){let a=UK(e);return(0,B.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${t}${n?`, branch ${n}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":r,"aria-keyshortcuts":`P ArrowDown`,"aria-busy":e.busy,"data-tip":`Switch project`,"data-on":r||void 0,onClick:i,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||r||(e.preventDefault(),i())},title:n?`${t} · ${n}`:t,className:`bubble-chip bubble-tip bubble-tool min-w-0`,children:[e.slow?(0,B.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,B.jsx)(Lp,{"aria-hidden":`true`,className:Y(`size-3.5 shrink-0`,a&&`text-destructive`)}),(0,B.jsx)(`span`,{className:`truncate`,children:t}),(0,B.jsx)(Yf,{"aria-hidden":`true`,className:`size-3 shrink-0`,strokeWidth:2})]})}function XK({projects:e,tab:t,onBrowse:n,onClose:r}){let{data:i,busy:a,refresh:o}=e,s=BK(),c=UK(e),l=s.error?`invalid`:s.id??i?.currentId??``,u=(0,m.useRef)(null);RE(`r`,()=>void o(),{inDialog:!0}),(0,m.useEffect)(()=>{(u.current?.querySelector(`[role='option'][aria-selected='true']`)??u.current?.querySelector(`[role='option']`))?.focus({preventScroll:!0})},[!!i]);function d(e){r(),e!==l&&F(e,t)}let f=Math.max(1,Math.min(i?.projects.length??1,qK));return(0,B.jsxs)(`div`,{ref:u,"aria-label":`Projects`,onKeyDown:GK,className:`bubble-pane flex flex-col p-1`,children:[(0,B.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between ps-2.5 pe-1`,children:[(0,B.jsx)(`span`,{className:`text-[13px] font-medium text-(--bubble-muted)`,children:`Running projects`}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>void o(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`bubble-chip h-6 text-xs`,children:[a?(0,B.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,B.jsx)(km,{"aria-hidden":`true`,className:`size-3.5`}),`Refresh`,(0,B.jsx)(`kbd`,{className:`bubble-kbd`,children:`R`})]})]}),(0,B.jsx)(`div`,{className:`h-px shrink-0`}),(0,B.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`bubble-scroll flex shrink-0 flex-col overflow-y-auto`,style:{height:f*46},children:i?i.projects.map((e,t)=>{let n=e.id===l;return(0,B.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>d(e.id),className:Y(`bubble-row cs-prow shrink-0`,n&&`bubble-prow`),style:{"--delay":`${40+t*12}ms`},children:[(0,B.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center`,children:n?(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-4 text-(--bubble-accent)`,strokeWidth:2}):null}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-medium text-(--bubble-ink)`,children:e.name}),(0,B.jsxs)(`span`,{className:`truncate text-xs text-(--bubble-muted)`,children:[e.cwd,` · :`,e.port]})]})]},e.id)}):(0,B.jsxs)(`div`,{className:`flex h-[46px] items-center gap-2 px-2.5 text-[13px] text-(--bubble-muted)`,children:[(0,B.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}),`Loading projects…`]})}),c?(0,B.jsxs)(`p`,{role:`alert`,className:`flex h-8 shrink-0 items-center gap-2 px-2 text-xs text-destructive`,children:[(0,B.jsx)(ah,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,title:c,children:c})]}):null,(0,B.jsx)(`div`,{className:`h-px shrink-0`}),(0,B.jsxs)(`button`,{type:`button`,"data-walk":!0,onClick:n,className:`bubble-row cs-orow shrink-0`,style:{"--delay":`0ms`},children:[(0,B.jsx)(Fp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Open folder…`})]})]})}var ZK={w:500,h:308};function QK(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)();async function a(r){if(!t){n(!0),i(void 0);try{let{project:t}=await I(`projects.open`,{path:r});ye([t]),F(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function $K(e){let t=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`,n=e.split(t),r=[];return n.forEach((e,i)=>{if(!e)return;let a=n.slice(0,i+1).join(t);r.push({name:e,path:a||t})}),r.length?r:[{name:t,path:t}]}function eq(e,t,n){let r=[...e.currentTarget.querySelectorAll(`button[data-folder]:not(:disabled)`)],i=r.indexOf(document.activeElement),a={ArrowDown:Math.min(r.length-1,i+1),ArrowUp:Math.max(0,i-1),Home:0,End:r.length-1}[e.key];a!==void 0&&r.length>0?(e.preventDefault(),r[a]?.focus()):e.key===`Backspace`&&t&&(e.preventDefault(),n(t))}function tq({tab:e,onClose:t}){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)({step:0,dir:`fwd`}),o=eR(`projects.browse`,n===void 0?{}:{path:n},[]),s=QK(e),c=(0,m.useRef)(null),l=o.loading||s.opening,u=o.data?.path??n??``,d=(e,t)=>{e!==u&&(a(e=>({step:e.step+1,dir:t})),r(e))};(0,m.useEffect)(()=>{if(!o.data)return;let e=c.current?.querySelector(`button[data-folder]`);e&&!c.current?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[o.data]);let f=$K(u),p=f.slice(-4),h=o.data?.folders.length??0,g=o.error||s.error?o.error??s.error:o.loading&&!o.data?`Loading…`:h===0?`No subfolders`:`${h.toLocaleString()} ${h===1?`folder`:`folders`}${o.data?.truncated?` (first 2,000)`:``}`;return(0,B.jsxs)(`div`,{role:`group`,"aria-label":`Open project folder`,className:`bubble-pane flex flex-col gap-1 p-1`,style:{height:ZK.h},children:[(0,B.jsxs)(`div`,{className:`bubble-wellbar flex h-9 shrink-0 items-center gap-0.5 px-1`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":`Parent folder`,title:`Parent folder (Backspace)`,disabled:l||!o.data?.parent,onClick:()=>o.data?.parent&&d(o.data.parent,`back`),className:`bubble-iconbtn size-7`,children:(0,B.jsx)(Rf,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.8})}),(0,B.jsxs)(`nav`,{"aria-label":`Folder path`,className:`flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap`,title:u,children:[f.length>p.length?(0,B.jsx)(`span`,{className:`shrink-0 px-1.5 text-[13px] text-(--bubble-muted)`,children:`…`}):null,p.map((e,t)=>(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[t>0?(0,B.jsx)($f,{"aria-hidden":`true`,className:`size-3 shrink-0 text-(--bubble-faint)`,strokeWidth:2}):null,(0,B.jsx)(`button`,{type:`button`,className:`bubble-crumb`,"data-last":t===p.length-1||void 0,"aria-current":t===p.length-1?`location`:void 0,disabled:l,onClick:()=>d(e.path,`back`),children:e.name})]},e.path))]})]}),(0,B.jsxs)(`div`,{ref:c,role:`group`,"aria-label":`Folders`,"aria-busy":o.loading,"data-dir":i.step?i.dir:void 0,onKeyDown:e=>eq(e,o.data?.parent,e=>d(e,`back`)),className:`bubble-flist bubble-scroll`,children:[o.data?.folders.map(e=>{let t=e.name.startsWith(`.`);return(0,B.jsxs)(`button`,{type:`button`,"data-folder":!0,disabled:s.opening,onClick:()=>d(e.path,`fwd`),title:e.path,className:Y(`bubble-frow`,t&&`text-(--bubble-muted)`),children:[(0,B.jsx)(`span`,{className:`bubble-ftile`,children:(0,B.jsx)(Lp,{"aria-hidden":`true`,className:`size-3.5 text-(--bubble-muted)`,strokeWidth:1.8})}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,B.jsx)($f,{"aria-hidden":`true`,className:`bubble-go size-3.5 shrink-0`,strokeWidth:2})]},e.path)}),o.data&&h===0?(0,B.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-xs text-(--bubble-muted)`,children:[(0,B.jsx)(Lp,{"aria-hidden":`true`,className:`size-6`,strokeWidth:1.5}),(0,B.jsx)(`span`,{children:`No subfolders here. You can open this folder.`})]}):null]},i.step),(0,B.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 ps-2.5 pe-1`,children:[(0,B.jsx)(`span`,{role:o.error||s.error?`alert`:`status`,className:Y(`min-w-0 truncate text-xs`,o.error||s.error?`text-destructive`:`text-(--bubble-muted)`),children:g}),(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[o.error?(0,B.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:o.reload,disabled:o.loading,children:`Retry`}):null,(0,B.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-ghostbtn`,onClick:t,disabled:s.opening,children:`Cancel`}),(0,B.jsx)(`button`,{type:`button`,className:`bubble-btn bubble-key`,disabled:!o.data||o.loading||!!o.error||s.opening,onClick:()=>void s.open(o.data.path),children:s.opening?`Opening project…`:`Open this folder`})]})]})]})}function nq(){return(0,B.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,B.jsxs)(`defs`,{children:[(0,B.jsxs)(`filter`,{id:`bubble-goolit`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`4.5`,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,B.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.6`,result:`rimB`}),(0,B.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-hl)`},result:`hlc`}),(0,B.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,B.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.6`,result:`shB`}),(0,B.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-sh)`},result:`shc`}),(0,B.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`sh`}),(0,B.jsx)(`feMergeNode`,{in:`hl`})]})]}),(0,B.jsxs)(`filter`,{id:`bubble-gooedge`,x:`-10%`,y:`-10%`,width:`120%`,height:`120%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`4.5`,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,B.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.3`,result:`tS1`}),(0,B.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-ehl)`},result:`tc`}),(0,B.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,B.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.3`,result:`bS1`}),(0,B.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--bubble-esh)`},result:`bc`}),(0,B.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`eh`}),(0,B.jsx)(`feMergeNode`,{in:`es`})]})]})]})})}function rq({kind:e}){return(0,B.jsxs)(`div`,{className:Y(`bubble-layer`,e===`edge`?`bubble-edge`:`bubble-fill`),"aria-hidden":`true`,children:[(0,B.jsx)(`div`,{className:`bubble-menu`,children:(0,B.jsx)(`div`,{className:`bubble-menu-clip`})}),(0,B.jsx)(`div`,{className:`bubble-ghost`})]})}function iq({open:e,size:t,shrunk:n,morphing:r,menu:i,children:a,className:o,style:s,...c}){let[l,u]=(0,m.useState)(e);return(0,m.useEffect)(()=>{if(e)return u(!0);let t=setTimeout(()=>u(!1),140);return()=>clearTimeout(t)},[e]),(0,B.jsxs)(`div`,{"data-slot":`composer-shell`,"data-open":e||void 0,"data-shrunk":n||void 0,"data-morphing":r||void 0,className:Y(`bubble`,o),style:{...s,"--w":`${t.w}px`,"--h":`${e?t.h:0}px`},...c,children:[(0,B.jsx)(nq,{}),(0,B.jsx)(rq,{kind:`edge`}),(0,B.jsx)(rq,{kind:`fill`}),(0,B.jsxs)(`div`,{className:`bubble-real`,children:[(0,B.jsx)(`div`,{className:`bubble-menu`,inert:!e,children:(0,B.jsx)(`div`,{className:`bubble-menu-clip`,children:(0,B.jsx)(`div`,{className:`bubble-menu-body`,children:e||l?i:null})})}),a]})]})}var aq=/^\s{0,3}(`{3,}|~{3,})/,oq=/^(\s{0,3}#{1,6})(\s+)(.*)$/,sq=/^(\s{0,3}>[>\s]*)(.*)$/,cq=/^(\s*)([-*+]|\d{1,9}[.)])(\s+)(\[[ xX]\]\s)?(.*)$/,lq=/^\s{0,3}([-*_])(\s*\1){2,}\s*$/,uq=/(`+)([^`\n]+?)\1|\[([^\]\n]+)\]\(([^)\s]+)\)|(\*\*|__)(?=\S)([^\n]*?\S)\5|(~~)(?=\S)([^\n]*?\S)~~|(?<![\w*])(\*)(?=[^\s*])([^*\n]*?[^\s*])\*(?!\*)|(?<![\w_])(_)(?=[^\s_])([^_\n]*?[^\s_])_(?![\w_])|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])|(?<![\w@])(@[a-z][\w-]*)/gi;function dq(e,t,n){if(!t)return;let r=e.at(-1);r&&r.kind===n?r.text+=t:e.push({text:t,kind:n})}var fq=(...e)=>e.filter(Boolean).join(` `);function pq(e,t,n){let r=0;for(let i of t.matchAll(uq)){let a=i.index;dq(e,t.slice(r,a),n);let[o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]=i;if(s)dq(e,s,fq(n,`code`,`mark`)),dq(e,c,fq(n,`code`)),dq(e,s,fq(n,`code`,`mark`));else if(l)dq(e,`[`,fq(n,`mark`)),dq(e,l,fq(n,`link`)),dq(e,`](${u})`,fq(n,`mark`));else if(d)dq(e,d,fq(n,`mark`)),pq(e,f,fq(n,`strong`)),dq(e,d,fq(n,`mark`));else if(p)dq(e,p,fq(n,`mark`)),pq(e,m,fq(n,`strike`)),dq(e,p,fq(n,`mark`));else if(h||_){let t=h??_;dq(e,t,fq(n,`mark`)),pq(e,g??v,fq(n,`em`)),dq(e,t,fq(n,`mark`))}else y?dq(e,y,fq(n,`link`)):b?dq(e,b,fq(n,`mention`)):dq(e,o,n);r=a+o.length}dq(e,t.slice(r),n)}function mq(e){let t=[],n;return e.split(`
|
|
109
109
|
`).forEach((e,r)=>{r>0&&dq(t,`
|
|
110
110
|
`,``);let i=aq.exec(e);if(n!==void 0){i&&i[1].startsWith(n)?(n=void 0,dq(t,e,`codeblock mark`)):dq(t,e,`codeblock`);return}if(i){n=i[1][0].repeat(3),dq(t,e,`codeblock mark`);return}if(r===0&&/^\/[a-z][\w-]*/i.test(e)){let n=/^\/[a-z][\w-]*/i.exec(e)[0];dq(t,n,`mention`),pq(t,e.slice(n.length),``);return}if(lq.test(e))return dq(t,e,`mark`);let a=oq.exec(e);if(a)return dq(t,a[1]+a[2],`heading mark`),pq(t,a[3],`heading`);let o=sq.exec(e);if(o)return dq(t,o[1],`quote mark`),pq(t,o[2],`quote`);let s=cq.exec(e);if(s)return dq(t,s[1],``),dq(t,s[2],`list`),dq(t,s[3],``),s[4]&&dq(t,s[4],`list`),pq(t,s[5],``);pq(t,e,``)}),t}function hq(e){if(e.startsWith(`/`))return`var(--primary)`;let t=pR(e.slice(1));return t===`var(--muted-foreground)`?`var(--primary)`:t}function gq(e,t){if(t.length<=e.length)return;let n=0;for(;n<e.length&&e[n]===t[n];)n++;let r=0;for(;r<e.length-n&&e[e.length-1-r]===t[t.length-1-r];)r++;let i=t.length-r;return i-n>0&&i-n<=24?{start:n,end:i}:void 0}var _q=(0,m.memo)(function({text:e,fresh:t}){let n=0;return(0,B.jsxs)(B.Fragment,{children:[mq(e).flatMap((e,r)=>{let i=n;n+=e.text.length;let a=e.kind?e.kind.split(` `).map(e=>`md-${e}`).join(` `):``,o=e.kind===`mention`?{color:hq(e.text)}:void 0,s=t&&t.start<n&&t.end>i?[[i,Math.max(i,t.start)],[Math.max(i,t.start),Math.min(n,t.end)],[Math.min(n,t.end),n]]:[[i,n]];return s.filter(([e,t])=>t>e).map(([n,c])=>{let l=t!==void 0&&s.length>1&&n===Math.max(i,t.start),u=e.text.slice(n-i,c-i);return a||l?(0,B.jsx)(`span`,{className:[a,l?`md-new`:``].filter(Boolean).join(` `),style:o,children:u},l?`n${t.seq}-${r}`:`${r}-${n}`):u})}),``]})}),vq=(0,m.forwardRef)(function({text:e},t){let n=(0,m.useRef)({text:e,fresh:void 0,seq:0});if(n.current.text!==e){let t=gq(n.current.text,e),r=n.current.seq+1;n.current={text:e,seq:r,fresh:t?{...t,seq:r}:void 0}}return(0,B.jsx)(`div`,{ref:t,className:`bubble-text bubble-mirror`,"aria-hidden":`true`,children:(0,B.jsx)(_q,{text:e,...n.current.fresh?{fresh:n.current.fresh}:{}})})}),yq=e=>e.preventDefault();function bq({onStop:e}){let[t,n]=(0,m.useState)(!1),r=qT(t,KT.confirm),i=()=>{n(!1),e()};return RE(`y`,i,{enabled:t&&r,inDialog:!0}),(0,B.jsxs)(zL,{open:t&&r,onOpenChange:n,children:[(0,B.jsx)(`button`,{type:`button`,className:`bubble-send bubble-key bubble-stop bubble-tip`,"data-tip":`Interrupt`,onPointerDown:yq,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,B.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,B.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),(0,B.jsxs)(BL,{children:[(0,B.jsxs)(VL,{children:[(0,B.jsx)(UL,{children:`Stop the oracle?`}),(0,B.jsx)(WL,{children:`The current response stops. Work already recorded is kept.`})]}),(0,B.jsxs)(HL,{children:[(0,B.jsxs)(KL,{children:[`Keep it`,(0,B.jsx)(IT,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,B.jsxs)(GL,{variant:`destructive`,onClick:i,children:[`Stop`,(0,B.jsx)(IT,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function xq({sending:e,disabled:t,steering:n,onSend:r}){return(0,B.jsx)(`button`,{type:`button`,className:Y(`bubble-send bubble-tip`,!t&&`bubble-key`),"data-tip":n?`Steer`:`Send`,onPointerDown:yq,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:e?(0,B.jsx)(lR,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,B.jsxs)(`svg`,{className:`bubble-plane`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M22 2L11 13`}),(0,B.jsx)(`path`,{d:`M22 2l-7 20-4-9-9-4z`})]})})}function Sq(e){return e.agent?pR(e.agent):e.tag===`lobby`?`var(--c-orc)`:e.tag===`skill`?`var(--c-pl)`:`var(--c-qa)`}function Cq(e,t){let n=/^\s*([/@])([a-z0-9:_.-]*)$/i.exec(e.slice(0,t));if(n&&!/\S/.test(e.slice(t,t+1)))return{kind:n[1]===`/`?`slash-command`:`mention`,query:n[2].toLowerCase()}}function wq(e){return[...$T.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.hint,tag:`lobby`})),...e.map(e=>({id:`/${e.name}`,insert:`/${e.name}`,label:`/${e.name}`,description:e.description+(e.terminal?` · continue in Pi terminal`:``),tag:e.name.startsWith(`skill:`)?`skill`:`pi`}))]}function Tq(e,t=[]){let n=e.kind===`slash-command`?wq(t):QT.map(e=>({id:`@${e.name}`,insert:`@${e.name}`,label:`@${e.name}`,description:e.hint,agent:e.agent,tag:`agent`})),r=n.filter((e,t)=>n.findIndex(t=>t.id===e.id)===t),i=r.filter(t=>t.label.slice(1).startsWith(e.query)),a=r.filter(t=>!i.includes(t)&&t.label.slice(1).includes(e.query));return[...i,...a]}function Eq(e,t){return`${e}-${encodeURIComponent(t)}`}var Dq={"slash-command":`Commands`,mention:`Agents`};function Oq(e){return 8+Math.min(e,8)*30}var kq;function Aq(e,t){let n=0;try{if(kq??=document.createElement(`canvas`).getContext(`2d`),!kq)throw Error(`no canvas`);for(let r of e){kq.font=`500 13px ${t}`;let e=kq.measureText(r.label.slice(1)).width;kq.font=`400 12px ${t}`,n=Math.max(n,e+kq.measureText(r.description).width)}}catch{for(let t of e)n=Math.max(n,t.label.length*7.4+t.description.length*6.1)}return Math.min(Math.max(Math.ceil(n)+128,180),600)}var jq=(0,m.memo)(function(e){let t=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{e.activeItemId&&t.current&&t.current.querySelector(`[data-composer-item-id="${CSS.escape(e.activeItemId)}"]`)?.scrollIntoView({block:`nearest`})},[e.activeItemId]);let n=Math.min(e.items.length,8);return(0,B.jsx)(`div`,{ref:t,id:e.listId,role:`listbox`,"aria-label":Dq[e.triggerKind],"data-composer-command-drawer":`true`,className:`bubble-pane bubble-scroll overflow-y-auto p-1`,style:{height:Oq(e.items.length)},children:e.items.map((t,r)=>{let i=e.activeItemId===t.id;return(0,B.jsxs)(`div`,{id:Eq(e.listId,t.id),role:`option`,"aria-selected":i,"data-composer-item-id":t.id,"data-active":i||void 0,onMouseMove:()=>{i||e.onHighlightedItemChange(t.id)},onMouseDown:e=>e.preventDefault(),onClick:()=>e.onSelect(t),className:`bubble-row`,style:{"--delay":`${Math.max(0,n-1-r)*22}ms`},children:[t.agent?(0,B.jsx)(`span`,{className:`cs-kdot`,"aria-hidden":`true`,style:{"--k":Sq(t)}}):(0,B.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":Sq(t)},children:t.label.charAt(1).toUpperCase()}),(0,B.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:t.label.slice(1)}),(0,B.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,children:t.description}),(0,B.jsx)(`span`,{className:`cs-ktag`,style:{"--k":Sq(t)},children:t.tag})]},t.id)})})});function Mq(e){return typeof e==`object`&&e?e:{}}function Nq(e){return typeof e==`string`?e.trim():``}function Pq(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Fq(e){let t=Mq(e),n=Nq(t.label);if(!n)return;let r=Nq(t.description),i=Nq(t.preview),a=Nq(t.image),o=aU(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function Iq(e){let t=Mq(e),n=Nq(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(Fq).filter(e=>!!e);return{question:n,header:Nq(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function Lq(e){let t=Mq(e),n=Nq(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=Nq(t.message),i=Pq(t.options),a=Nq(t.placeholder),o=Nq(t.prefill);return{id:Nq(t.id),method:n,title:Nq(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function Rq(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(Iq).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function zq(e){return{kind:`choose`,title:Nq(e.title)||`Choose an option`,options:Pq(e.options)}}function Bq(e){let t=Nq(e.question)||Nq(e.title)||`Continue?`,n=Nq(e.detail)||Nq(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function Vq(e){let t=Nq(e.question)||Nq(e.title)||`Type an answer`,n=Nq(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function Hq(e){let t=Mq(e.payload);if(e.kind===`questionnaire`)return Rq(t);if(e.kind===`choose`)return zq(t);if(e.kind===`confirm`)return Bq(t);if(e.kind===`text`)return Vq(t);let n=Lq(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var Uq=`That question was already answered in the terminal.`;function Wq(e){let t=e.from.trim();return/panel|plann/i.test(t)?`PLANNER`:/oracle|master|lobby/i.test(t)||!t?`MASTER`:t.split(/\s+/)[0].toUpperCase()}function Gq(e,t){let n=Wq(e);return n===`PLANNER`&&t&&pR(t)!==`var(--muted-foreground)`?t.toUpperCase():n}function Kq(e,t){let n=Gq(e,t);if(n!==Wq(e))return n===`DEV`||n===`BACKEND`?`Dev`:n===`QA`?`QA`:n.charAt(0)+n.slice(1).toLowerCase();let r=Wq(e);if(r===`PLANNER`)return`Panel`;if(r===`MASTER`)return`Oracle`;let i=e.from.trim().split(/\s+/)[0]??`Agent`;return i.charAt(0).toUpperCase()+i.slice(1)}function qq(e,t){let{round:n,limit:r}=e.payload??{},i=n?`From planning · round ${r?`${Math.min(n,r)}/${r}`:n}`:`From planning`,a=Wq(e)===`PLANNER`?i:e.taskId?`From task ${e.taskId}`:`From the Lobby`;return t&&t!==`Question`&&Gq(e,t)===Wq(e)?`${a} · ${t}`:a}function Jq(e,t,n){let r={prompt:e,view:t,index:0,multi:!1,placeholder:`Or type your own reply…`};if(t.kind===`questionnaire`){let e=t.questions[n];return e?{...r,index:n,question:e.question,header:e.header,multi:!!e.multiSelect,options:e.options.map(e=>({...e,value:e.label})),typed:e=>e}:void 0}if(t.kind===`choose`)return{...r,question:t.title,options:t.options.map(e=>({label:e,value:e}))};if(t.kind===`confirm`)return{...r,question:t.detail?`${t.question}\n\n${t.detail}`:t.question,options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]};if(t.kind===`text`)return{...r,question:t.question,options:[],typed:e=>e,placeholder:t.placeholder||`Type your reply…`};let i=t.dialog,a=i.message?`${i.title}\n\n${i.message}`:i.title;return i.method===`select`?{...r,question:a,options:(i.options??[]).map(e=>({label:e,value:{value:e}}))}:i.method===`confirm`?{...r,question:a,options:[{label:`Yes`,value:{confirmed:!0}},{label:`No`,value:{confirmed:!1}}]}:{...r,question:a,options:[],typed:e=>({value:e}),placeholder:i.placeholder||`Type your reply…`}}function Yq(e,t){return e&&e.kind===`questionnaire`?Math.max(0,e.questions.length-t):1}function Xq(e,t,n){let[r,i]=(0,m.useState)({}),[a,o]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(0),[d,f]=(0,m.useState)(),p=(0,m.useMemo)(()=>e.map(e=>({prompt:e,view:Hq(e)})),[e]),h=p[0],g=h?.view?Jq(h.prompt,h.view,r[h.prompt.id]?.length??0):void 0,_=p.reduce((e,{prompt:t,view:n})=>e+Yq(n,r[t.id]?.length??0),0);(0,m.useEffect)(()=>{e.length===0&&(u(0),i({}))},[e.length]);let v=g?`${g.prompt.id}:${g.index}`:``;(0,m.useEffect)(()=>o([]),[v]);let y=(0,m.useCallback)(async(e,n)=>{c(!0);try{await t(e,n)}catch(e){e instanceof Se&&e.code===`question_withdrawn`?H(Uq):H.error(e instanceof Error?e.message:`Could not send the answer`)}finally{c(!1)}},[t]),b=(0,m.useCallback)((e,t=`option`,n)=>{if(!g||s)return;if(u(e=>e+1),g.view.kind!==`questionnaire`)return void y(g.prompt.id,e);let a=[...r[g.prompt.id]??[],{questionIndex:g.index,question:g.question,kind:t,answer:String(e),...n?{selected:n}:{}}];if(a.length<g.view.questions.length)return i(e=>({...e,[g.prompt.id]:a}));y(g.prompt.id,{answers:a,cancelled:!1}).then(()=>i(e=>{let t={...e};return delete t[g.prompt.id],t}))},[s,r,y,g]),x=(0,m.useCallback)(e=>{let t=g?.options[e];if(t){if(g.multi)return o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);b(t.value)}},[g,b]),S=x,C=(0,m.useCallback)(()=>{if(!g||a.length===0)return;let e=[...a].sort((e,t)=>e-t).map(e=>g.options[e].label);b(e.join(`, `),`multi`,e)},[a,g,b]),w=(0,m.useCallback)(e=>!g?.typed||!e.trim()?!1:(b(g.typed(e.trim()),`custom`),!0),[g,b]),T=(0,m.useCallback)(()=>{g&&n(g.prompt.id).catch(e=>H.error(e instanceof Error?e.message:`Could not dismiss the question`))},[n,g]),E=g?r[g.prompt.id]:void 0,ee=(0,m.useCallback)(()=>{if(!g||s||!E?.length)return;let e=E.at(-1);i(e=>({...e,[g.prompt.id]:E.slice(0,-1)})),u(e=>Math.max(0,e-1)),f({id:g.prompt.id,index:e.questionIndex,answer:e.answer??``})},[s,E,g]),D=d&&g&&d.id===g.prompt.id&&d.index===g.index?d.answer:void 0;return{...g?{step:g}:{},position:l+1,total:l+_,left:_,picks:a,busy:s,choose:x,toggle:S,submitPicks:C,reply:w,dismiss:T,...E?.length?{back:ee}:{},...D?{was:D}:{}}}function Zq({option:e,large:t}){let n=pU(e.label);return e.htmlPreview?(0,B.jsx)(uU,{preview:e.htmlPreview,label:n,frameWidth:t?void 0:880,minWidth:t?1024:void 0,className:`static-thumb h-full`}):e.image?(0,B.jsx)(`img`,{src:P(e.image),alt:t?`Mockup: ${n}`:``,loading:`lazy`}):e.preview?t?(0,B.jsx)(`div`,{className:`cs-mktext`,children:(0,B.jsx)(FL,{text:e.preview})}):(0,B.jsx)(`pre`,{className:`cs-mktext`,children:e.preview}):null}function Qq(e,t){return e!==void 0&&(e===t||e.split(`, `).includes(t))}function $q({color:e,children:t}){return(0,B.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":e},children:t})}function eJ({drawer:e,onExpand:t}){let{step:n}=e,[r,i]=(0,m.useState)(!1);if((0,m.useEffect)(()=>i(!1),[n?.prompt.id]),!n)return(0,B.jsx)(`div`,{className:`bubble-pane p-3 text-sm text-(--bubble-muted)`,children:`No questions are waiting.`});let a=pR(Gq(n.prompt,n.header)),o=n.options.some(mU),s=n.options.length;return(0,B.jsxs)(`div`,{className:`bubble-pane p-1.5`,role:`group`,"aria-label":`Question`,children:[(0,B.jsxs)(`div`,{className:`cs-askh`,children:[(0,B.jsxs)(`div`,{className:`cs-asks`,children:[(0,B.jsx)(`b`,{style:{color:a},children:Kq(n.prompt,n.header)}),(0,B.jsx)(`span`,{className:`cs-askf`,children:qq(n.prompt,n.header)}),e.back?(0,B.jsx)(`button`,{type:`button`,className:`cs-askx`,"aria-label":`Back to the previous question`,onMouseDown:e=>e.preventDefault(),onClick:e.back,children:`‹ Back`}):null,(0,B.jsxs)(`span`,{className:`cs-askn`,children:[e.position,` of `,e.total]}),(0,B.jsx)(`button`,{type:`button`,className:`cs-askx`,"data-confirm":r||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>r?e.dismiss():i(!0),onBlur:()=>i(!1),children:r?`Dismiss it?`:`Dismiss`})]}),(0,B.jsx)(`p`,{className:`cs-askq`,title:n.question,children:n.question})]}),o?(0,B.jsx)(`div`,{className:`cs-askm`,children:n.options.map((n,r)=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-mko`,"data-on":e.picks.includes(r)||Qq(e.was,n.label)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{animationDelay:`${r*30}ms`},children:[(0,B.jsxs)(`div`,{className:`cs-mk3`,children:[(0,B.jsx)(Zq,{option:n}),(0,B.jsx)(`span`,{className:`cs-mxb`,role:`button`,"aria-label":`Expand ${pU(n.label)}`,onClick:e=>{e.stopPropagation(),t(r)},children:(0,B.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7`})})})]}),(0,B.jsxs)(`span`,{className:`cs-mkl`,children:[(0,B.jsx)($q,{color:a,children:r+1}),(0,B.jsx)(`span`,{children:pU(n.label)})]})]},n.label))}):(0,B.jsxs)(`div`,{className:`cs-askopts`,children:[n.options.map((t,r)=>(0,B.jsxs)(`button`,{type:`button`,className:`bubble-row`,"data-active":e.picks.includes(r)||Qq(e.was,t.label)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{"--delay":`${(s-1-r)*22}ms`},children:[(0,B.jsx)($q,{color:a,children:r+1}),(0,B.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,children:pU(t.label)}),t.description?(0,B.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,title:t.description,children:t.description}):null,n.multi?(0,B.jsx)(`span`,{className:`cs-cb cs-sm`,"data-on":e.picks.includes(r),children:(0,B.jsx)(Jf,{"aria-hidden":`true`,strokeWidth:3})}):null]},t.label)),s===0?(0,B.jsx)(`div`,{className:`flex h-9 items-center px-2.5 text-[13px] text-(--bubble-muted)`,children:`Type your reply in the box below, then press Enter.`}):null]}),n.multi?(0,B.jsx)(`button`,{type:`button`,className:`bubble-row`,disabled:e.picks.length===0,onMouseDown:e=>e.preventDefault(),onClick:e.submitPicks,children:(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:e.picks.length===0?`Pick one or more`:`Answer with ${e.picks.length} picked`})}):null]})}function tJ({drawer:e,at:t,onAt:n}){let r=e.step,i=r?.options??[],a=t>=0&&t<i.length,o=(0,m.useRef)(t);a&&(o.current=t);let s=i[o.current],c=(0,m.useRef)(null);(0,m.useEffect)(()=>{a&&c.current?.focus({preventScroll:!0})},[a]);let l=e=>n((o.current+e+i.length)%i.length),u=r?pR(Gq(r.prompt,r.header)):`var(--primary)`;return(0,B.jsxs)(`div`,{className:`cs-mxw`,"data-open":a,"aria-hidden":!a,inert:!a,children:[(0,B.jsx)(`div`,{className:`cs-shbd`,onClick:()=>n(-1)}),(0,B.jsxs)(`div`,{ref:c,role:a?`dialog`:void 0,"aria-modal":a?`true`:void 0,"aria-label":s?`Mockup: ${pU(s.label)}`:`Mockup`,tabIndex:-1,className:`cs-mxc`,onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),n(-1)):t.key===`ArrowRight`||t.key===`ArrowLeft`?(t.preventDefault(),l(t.key===`ArrowRight`?1:-1)):t.key===`Enter`&&s&&(t.preventDefault(),n(-1),e.choose(o.current))},children:[(0,B.jsx)(`div`,{className:`cs-mxbig`,children:s?(0,B.jsx)(Zq,{option:s,large:!0}):null}),s&&r?(0,B.jsxs)(`div`,{className:`cs-mxf`,children:[(0,B.jsx)($q,{color:u,children:o.current+1}),(0,B.jsx)(`b`,{children:pU(s.label)}),(0,B.jsxs)(`span`,{className:`cs-mxwho`,children:[Kq(r.prompt,r.header),` · `,r.question]}),i.length>1?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Previous mockup`,onClick:()=>l(-1),children:(0,B.jsx)(Zf,{"aria-hidden":`true`,className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Next mockup`,onClick:()=>l(1),children:(0,B.jsx)($f,{"aria-hidden":`true`,className:`size-3.5`})})]}):null,(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,onClick:()=>{n(-1),e.choose(o.current)},children:r.multi?e.picks.includes(o.current)?`Unpick this`:`Pick this`:`Choose this`}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Close`,onClick:()=>n(-1),children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})})]}):null]})]})}var nJ=`bot-lobby.questionsPutAway`,rJ=new Set,iJ;function aJ(){if(iJ!==void 0)return iJ;try{iJ=sessionStorage.getItem(nJ)===`1`}catch{iJ=!1}return iJ}function oJ(e){if(aJ()!==e){iJ=e;try{e?sessionStorage.setItem(nJ,`1`):sessionStorage.removeItem(nJ)}catch{}for(let e of[...rJ])e()}}function sJ(e){return rJ.add(e),()=>{rJ.delete(e)}}function cJ(){return(0,m.useSyncExternalStore)(sJ,aJ,()=>!1)}var lJ={id:`oracle`,label:`Message the team`,placeholder:`Write a message, run a command, or ask an agent`},uJ=new Set([`lobby`,`tasks`,`plan`,`knowledge`]);function dJ(e){return e.kind===`settings`||e.kind===`tab`&&uJ.has(e.tab)}var fJ={id:`knowledge`,label:`Ask what the agents know`,placeholder:`Ask what the agents know…`};function pJ(e,t,n){if(e.kind!==`tab`)return lJ;if(e.tab===`knowledge`)return n?fJ:lJ;if(e.tab===`plan`)return{id:`panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`};let r=e.tab===`tasks`?cR(e.rest).id??t:void 0;return r?{id:`comment`,label:`Comment on ${r}`,placeholder:`Comment on ${r}'s plan…`,taskId:r}:lJ}var mJ={w:260,h:97},hJ=0,gJ=document.createElement(`canvas`).getContext(`2d`);function _J(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var vJ={duration:.16,ease:`easeOut`};function yJ({file:e,onRemove:t}){let n=(0,B.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:Y(`flex shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,e.image?`absolute top-1 right-1 size-[1.625rem] rounded-full bg-background/85 text-foreground shadow-xs hover:bg-background`:`size-7`),children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,B.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:vJ,title:`${e.name} · ${PK(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-xl border border-(--bubble-edge) bg-background`,children:[(0,B.jsx)(`img`,{src:P(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,B.jsxs)(`span`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-center justify-center gap-1 bg-background/85 px-1 text-[0.625rem] text-foreground`,children:[(0,B.jsx)(lR,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,B.jsxs)(Yd.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:vJ,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,B.jsx)(jp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.state===`uploading`?(0,B.jsx)(lR,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:PK(e.size)]}),n]})}function bJ(e,t,n,r){let[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(r);o.current=r;let s=n.kind===`tab`?n.tab:n.kind;return(0,m.useEffect)(()=>a(!1),[s]),(0,m.useEffect)(()=>{if(!t)return;let n=0,r=t=>{e.current?.contains(t.target)||(n=performance.now())},i=t=>{[`PageDown`,`PageUp`,`ArrowDown`,`ArrowUp`,`Home`,`End`,` `].includes(t.key)&&!e.current?.contains(t.target)&&(n=performance.now())},s=t=>{let r=e.current;!r||o.current||performance.now()-n>400||r.contains(document.activeElement)||r.contains(t.target)||a(!0)};return document.addEventListener(`wheel`,r,{capture:!0,passive:!0}),document.addEventListener(`touchmove`,r,{capture:!0,passive:!0}),document.addEventListener(`keydown`,i,{capture:!0}),document.addEventListener(`scroll`,s,{capture:!0,passive:!0}),()=>{document.removeEventListener(`wheel`,r,{capture:!0}),document.removeEventListener(`touchmove`,r,{capture:!0}),document.removeEventListener(`keydown`,i,{capture:!0}),document.removeEventListener(`scroll`,s,{capture:!0})}},[t,e]),{shrunk:i,expand:(0,m.useCallback)(()=>a(!1),[])}}function xJ({children:e}){return(0,B.jsx)(`kbd`,{className:`bubble-kbd`,"data-glyph":/^[^A-Za-z0-9]$/.test(e)||void 0,children:e})}function SJ(e,t,n){let[r,i]=(0,m.useState)({w:250,h:38});return(0,m.useLayoutEffect)(()=>{let r=t.current;if(!r)return;let a=()=>{let t=e===`bar`?{w:Math.ceil(r.scrollWidth)+8,h:38}:{w:n??580,h:Math.ceil(r.scrollHeight)};i(e=>e.w===t.w&&e.h===t.h?e:t)};a();let o=new ResizeObserver(a);for(let e of r.children)o.observe(e);return()=>o.disconnect()}),r}function CJ({route:e,projects:t,drawer:n,drawerOpen:r}){let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null),h=vE(`status`),g=vE(`lobby`),_=YT(),v=(h.data?.busy??!1)||!!g.data?.reply?.trim(),y=dJ(e),b=(0,m.useRef)(y);b.current=y;let{taskId:x}=bW(),S=e.kind===`tab`?e.tab:e.kind,[C,w]=(0,m.useState)(!1);(0,m.useEffect)(()=>w(!1),[S]);let T=(0,m.useMemo)(()=>pJ(e,x,C),[e,x,C]),E=pD(),[ee,D]=(0,m.useState)(-1),O=(0,m.useRef)(null),k=(0,m.useRef)(null),te=(0,m.useRef)(null),A=(0,m.useRef)(null),j=(0,m.useRef)(null),ne=(0,m.useRef)(null),re=(0,m.useRef)(null),M=(0,m.useRef)(null),ie=(0,m.useRef)(o);ie.current=o;let ae=(0,m.useRef)(void 0),[oe,se]=(0,m.useState)(0),[ce,le]=(0,m.useState)(null),[ue,de]=(0,m.useState)(void 0),N=r&&!!n.step&&y&&!_&&f===null,fe=T.id===`oracle`&&!f&&!N?Cq(i,oe):void 0,pe=(0,m.useMemo)(()=>fe?Tq(fe,h.data?.commands):[],[fe?.kind,fe?.query,h.data?.commands]),me=!!fe&&pe.length>0&&ue!==i&&y&&!_,P=me?pe.find(e=>e.id===ce)??pe[0]:void 0,F=`composer-suggestions`,he={answer:n.left>0&&!r,plan:S===`plan`&&!!E,knowledge:S===`knowledge`&&!C},ge=!me&&f===null&&!N&&y&&!_&&(he.answer||he.plan||he.knowledge),_e=me||N||f!==null&&y&&!_,ve=_e||ge;(0,m.useEffect)(()=>{let e=document.documentElement;return e.style.setProperty(`--dock-bar`,ge?`44px`:`0px`),()=>e.style.setProperty(`--dock-bar`,`0px`)},[ge]);let{shrunk:ye,expand:be}=bJ(O,y&&!_,e,ve&&!ge),[xe,Se]=(0,m.useState)(!1),Ce=(0,m.useRef)(ye);(0,m.useEffect)(()=>{if(Ce.current===ye)return;Ce.current=ye,Se(!0);let e=setTimeout(()=>Se(!1),420);return()=>clearTimeout(e)},[ye]),(0,m.useEffect)(()=>p(null),[S]),(0,m.useEffect)(()=>{(!y||_)&&p(null)},[y,_]),(0,m.useEffect)(()=>{if(!f)return;let e=e=>{k.current?.contains(e.target)||p(null)};return document.addEventListener(`pointerdown`,e,{capture:!0}),()=>document.removeEventListener(`pointerdown`,e,{capture:!0})},[f]);let we=(0,m.useCallback)(e=>{be(),p(t=>t===e||e===`projects`&&t===`browse`?null:e)},[be]),Te=(0,m.useCallback)(()=>{p(e=>{let t=e===`attach`?`[data-composer-attach]`:e?`[role="combobox"][aria-label="Project"]`:void 0;return t&&requestAnimationFrame(()=>k.current?.querySelector(t)?.focus({preventScroll:!0})),null})},[]);RE(`p`,()=>we(`projects`),{enabled:y&&!_&&f===null}),(0,m.useEffect)(()=>{let e=()=>{be(),p(`projects`)};return window.addEventListener(KK,e),()=>window.removeEventListener(KK,e)},[be]);let Ee=(0,m.useRef)(`suggest`),De=(0,m.useRef)({w:320,h:0}),Oe=f??(N?`ask`:me?`suggest`:ge?`bar`:Ee.current),ke=(0,m.useRef)(null),Ae=SJ(Oe,ke,Oe===`ask`&&n.step?.options.some(mU)?Math.max(580,Math.min(960,(te.current?.clientWidth??740)-12)):void 0);if(ve){Ee.current=Oe;let e=j.current?getComputedStyle(j.current).fontFamily:`system-ui, sans-serif`;De.current=Oe===`suggest`?{w:Aq(pe,e),h:Oq(pe.length)}:Oe===`attach`?mJ:Oe===`projects`?JK(t):Oe===`bar`||Oe===`ask`?Ae:ZK}let je=(0,m.useRef)({items:[],kind:`slash-command`});me&&fe&&P&&(je.current={items:pe,kind:fe.kind,lit:P.id});let Me=(0,m.useCallback)(e=>{let t=i.replace(/^\s*[/@][a-z0-9:_.-]*\s*/i,``),n=`${e.insert} ${t}`,r=e.insert.length+1;ae.current={start:r,end:r},se(r),a(n),le(null),j.current?.focus()},[i]);(0,m.useLayoutEffect)(()=>{let e=ae.current,t=j.current;e&&t&&(ae.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let Ne=(0,m.useCallback)(e=>{ae.current={start:e.start,end:e.end},se(e.end),a(e.value)},[]);(0,m.useLayoutEffect)(()=>{let e=A.current,t=k.current;if(!e||!t)return;let n=()=>{t.hasAttribute(`data-shrunk`)||t.style.setProperty(`--ch-open`,`${Math.ceil(e.getBoundingClientRect().height)}px`)};n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[ye]),(0,m.useLayoutEffect)(()=>{let e=j.current,t=k.current;if(!e||!t)return;if(ye||!i)return void t.style.removeProperty(`--cg`);let n=getComputedStyle(e);gJ.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`;let r=Math.max(...i.split(`
|
|
111
|
-
`).map(e=>gJ.measureText(e).width));t.style.setProperty(`--cg`,`${Math.ceil((r+44)/48)*48}px`)},[i,ye]),(0,m.useLayoutEffect)(()=>{ne.current&&j.current&&(ne.current.scrollTop=j.current.scrollTop)}),(0,m.useEffect)(()=>{let e=te.current,t=O.current;if(!e||!t)return;let n=document.documentElement,r=()=>{let r=e.getBoundingClientRect(),i=t.getBoundingClientRect().bottom;if(n.style.setProperty(`--composer-h`,_||!y?`0px`:`${Math.ceil(i-r.top)}px`),!y||r.width===0){n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`);return}n.style.setProperty(`--composer-x`,`${Math.round(r.left)}px`),n.style.setProperty(`--composer-w`,`${Math.round(r.width)}px`)};r();let i=new ResizeObserver(r);return i.observe(e),e.addEventListener(`transitionend`,r),window.addEventListener(`resize`,r),()=>{i.disconnect(),e.removeEventListener(`transitionend`,r),window.removeEventListener(`resize`,r),n.style.setProperty(`--composer-h`,`0px`),n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`)}},[_,y]);let Pe=(0,m.useCallback)(e=>{if(!b.current)return;let t=[...e],n=8-ie.current.length;t.length>n&&H.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++hJ}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;s(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),FK(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{H.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),Fe=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),Ie=o.some(e=>e.state===`uploading`),Le=o.flatMap(e=>e.info?[e.info.id]:[]),Re=(i.trim().length>0||Le.length>0)&&!Ie&&!c,ze=(0,m.useCallback)(async()=>{if(!Re||!b.current)return;l(!0);let e=Le.length>0?Le:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0;if(T.id===`oracle`){let e=await I(`lobby.send`,t);e.notice&&H(e.notice),e.open===`plan`?iE(rE(`plan`)):S===`knowledge`&&iE(rE(`lobby`))}else T.id===`knowledge`?(e=await U(`knowledge.ask`,t)!==void 0,e&&(window.dispatchEvent(new CustomEvent(hD,{detail:i.trim()})),w(!1))):e=T.id===`panel`?await U(`planner.send`,t)!==void 0:await U(`tasks.comment`,{taskId:T.taskId,...t})!==void 0;if(e){a(``);for(let e of ie.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){H.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[Re,Le,T,i,e,S]),Be=(0,m.useCallback)(async()=>{try{await I(`lobby.abort`,{})}catch(e){H.error(e instanceof Error?e.message:`Could not stop`)}},[]),Ve=e=>{if(me&&P&&!e.nativeEvent.isComposing){let t=pe.indexOf(P);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+pe.length)%pe.length;le(pe[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),Me(P);return}if(e.key===`Escape`){e.preventDefault(),de(i);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),f?p(null):N?oJ(!0):C?w(!1):DE();return}if(N&&_J(e)){e.preventDefault(),n.reply(i)?a(``):!i.trim()&&n.step?.multi&&n.submitPicks();return}let t=e.currentTarget,r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(r)){e.preventDefault();let{selectionStart:n,selectionEnd:i,value:a}=t;Ne(r===`k`?LK(a,n,i):IK(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=zK(t.value,t.selectionStart);n&&(e.preventDefault(),Ne(n));return}if(e.key===`Backspace`&&t.value===``&&ie.current.length>0){e.preventDefault(),Fe(ie.current.at(-1).key);return}(_J(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),ze())},He=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),Pe(t))},Ue=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&Pe(e.dataTransfer.files)},We=h.data?.workspace.name??`bot-lobby`,Ge=h.data?.branch??h.data?.workspace.branch,Ke=v&&T.id===`oracle`,qe=ye?`Write a message…`:N?n.step?.typed?n.step.placeholder:`Pick an answer above`:Ke?`The oracle is working. Enter steers it…`:T.placeholder,Je=e=>{p(null),e.current?.click()},Ye=Oe===`ask`?(0,B.jsx)(`div`,{ref:ke,children:(0,B.jsx)(eJ,{drawer:n,onExpand:D})},`ask`):Oe===`bar`?(0,B.jsx)(`div`,{ref:ke,className:`bubble-pane p-1`,style:{width:`max-content`},children:(0,B.jsxs)(`div`,{className:`cs-pbar`,children:[he.answer?(0,B.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq cs-acc`,onMouseDown:e=>e.preventDefault(),onClick:()=>{oJ(!1),requestAnimationFrame(()=>j.current?.focus({preventScroll:!0}))},children:[(0,B.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`}),(0,B.jsx)(`path`,{d:`M9.6 9.5a2.5 2.5 0 014.8.9c0 1.6-2.4 2-2.4 3.4M12 16.5h.01`})]}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:`Answer questions`}),(0,B.jsxs)(`span`,{className:`cs-ktag`,style:{"--k":`var(--primary)`},children:[n.left,` left`]})]}):null,he.plan?(0,B.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,"aria-keyshortcuts":`V`,onMouseDown:e=>e.preventDefault(),onClick:()=>E?.(),children:[(0,B.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z`}),(0,B.jsx)(`path`,{d:`M14 3v5h5M9 13h6M9 17h4`})]}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`View plan`}),(0,B.jsx)(`span`,{className:`cs-kb`,children:`V`})]}):null,he.knowledge?(0,B.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,onMouseDown:e=>e.preventDefault(),onClick:()=>{w(!0),requestAnimationFrame(()=>j.current?.focus({preventScroll:!0}))},children:[(0,B.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z`})}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Ask the knowledge`})]}):null]})},`bar`):Oe===`suggest`?(0,B.jsx)(jq,{listId:F,items:me?pe:je.current.items,triggerKind:me&&fe?fe.kind:je.current.kind,activeItemId:P?.id??null,onHighlightedItemChange:le,onSelect:Me},`suggest`):Oe===`attach`?(0,B.jsxs)(`div`,{role:`menu`,"aria-label":`Attach`,className:`bubble-pane flex flex-col p-1`,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=[...e.currentTarget.querySelectorAll(`[role='menuitem']`)];t[(t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:t.length-1))%t.length]?.focus()},children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`24ms`},onClick:()=>Je(re),children:[(0,B.jsx)(jp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload a file…`})]}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`12ms`},onClick:()=>Je(M),children:[(0,B.jsx)(Vp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload an image…`})]}),(0,B.jsx)(`div`,{className:`h-px`}),(0,B.jsx)(`div`,{className:`flex h-7 items-center px-2 text-[11.5px] text-(--bubble-muted)`,children:`Or drop files on the composer`})]},`attach`):Oe===`projects`?(0,B.jsx)(XK,{projects:t,tab:S,onBrowse:()=>p(`browse`),onClose:()=>p(null)},`projects`):(0,B.jsx)(tq,{tab:S,onClose:Te},`browse`);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`cs-scrim`,"data-open":_e||void 0,"aria-hidden":`true`}),(0,B.jsx)(`div`,{id:`app-dock`,ref:O,"data-shrunk":ye||void 0,onFocus:be,className:Y(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(24px,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap`,_&&`opacity-0`),hidden:!y,"aria-hidden":!y||void 0,inert:_||!y,children:(0,B.jsx)(iq,{ref:k,open:ve,size:De.current,shrunk:ye,morphing:xe,menu:Ye,className:`composer-shell pointer-events-auto`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(f?(e.preventDefault(),Te()):N&&(e.preventDefault(),oJ(!0)))},children:(0,B.jsxs)(`div`,{ref:te,className:`bubble-composer group/composer composer-box`,"data-dragging":u||void 0,"data-chat-composer-main-surface":`true`,onPointerDown:be,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:Ue,children:[(0,B.jsxs)(`div`,{ref:A,"data-chat-composer-surface":`true`,children:[(0,B.jsx)(tu,{initial:!1,children:o.length>0?(0,B.jsx)(Yd.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},"aria-label":`Attachments`,className:`composer-files flex max-w-full flex-wrap gap-2 overflow-hidden px-3.5 pt-3`,children:o.map(e=>(0,B.jsx)(yJ,{file:e,onRemove:()=>Fe(e.key)},e.key))},`files`):null}),(0,B.jsxs)(`div`,{className:`bubble-field`,children:[(0,B.jsx)(vq,{ref:ne,text:i}),(0,B.jsx)(`textarea`,{ref:j,id:`composer-text`,"aria-label":T.label,...T.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":me,"aria-controls":me?F:void 0}:{},...P?{"aria-activedescendant":Eq(F,P.id)}:{},value:i,onChange:e=>{a(e.target.value),se(e.target.selectionStart),p(null)},onSelect:e=>se(e.currentTarget.selectionStart),onKeyDown:Ve,onPaste:He,onScroll:e=>{ne.current&&(ne.current.scrollTop=e.currentTarget.scrollTop)},placeholder:qe,rows:1,className:`bubble-text bubble-input`})]}),(0,B.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:`bubble-tools composer-tools`,children:[(0,B.jsx)(`button`,{type:`button`,"data-composer-attach":!0,"aria-label":`Attach images, PDFs or files`,"aria-haspopup":`menu`,"aria-expanded":f===`attach`,"data-on":f===`attach`||void 0,"data-tip":`Attach a file`,onPointerDown:e=>e.preventDefault(),onClick:()=>we(`attach`),className:`bubble-iconbtn bubble-tip bubble-tool size-8 rounded-full`,style:{"--i":0},children:(0,B.jsx)(hm,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.7})}),(0,B.jsx)(`span`,{className:`bubble-tool flex min-w-0`,style:{"--i":1},children:(0,B.jsx)(YK,{projects:t,name:We,branch:Ge,open:f===`projects`||f===`browse`,onToggle:()=>we(`projects`)})}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(`span`,{className:`bubble-hints bubble-tool`,style:{"--i":2},"aria-hidden":`true`,children:me?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(xJ,{children:`↑`}),(0,B.jsx)(xJ,{children:`↓`}),`choose`,(0,B.jsx)(xJ,{children:`↵`}),`insert`]}):f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(xJ,{children:`Esc`}),`close`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(xJ,{children:`Shift`}),(0,B.jsx)(xJ,{children:`↵`}),`new line`]})}),(0,B.jsxs)(`span`,{"data-chat-composer-actions":`right`,className:`bubble-tool flex shrink-0 items-center gap-2`,style:{"--i":3},children:[Ke?(0,B.jsx)(bq,{onStop:()=>void Be()}):null,(0,B.jsx)(xq,{sending:c,disabled:!Re,steering:Ke,onSend:()=>void ze()})]})]})]}),(0,B.jsx)(`input`,{ref:re,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{Pe(e.target.files??[]),e.target.value=``}}),(0,B.jsx)(`input`,{ref:M,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach images`,onChange:e=>{Pe(e.target.files??[]),e.target.value=``}}),u?(0,B.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center rounded-[inherit] text-sm font-medium text-(--bubble-accent)`,children:`Drop to attach`}):null]})})}),(0,B.jsx)(tJ,{drawer:n,at:N?ee:-1,onAt:D})]})}function wJ({open:e,onOpenChange:t}){let n=qT(e,KT.help),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),l=(0,m.useId)(),u=()=>{a||(t(!1),i(``),c(``))},d=async()=>{let e=r.trim();if(e&&!a){o(!0),c(``);try{H((await I(`sessions.start`,{request:e})).notice),t(!1),i(``)}catch(e){c(e instanceof Error?e.message:`That did not work. Try again.`)}finally{o(!1)}}};return(0,B.jsx)(zT,{open:n,label:`New session`,description:`Starts a task in a session of its own, in the background.`,onOpenChange:e=>{e||u()},dismissOnBackdrop:!a,className:`max-w-[460px]`,children:(0,B.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,B.jsxs)(`div`,{className:`cs-dh`,children:[(0,B.jsx)(`h2`,{children:`New session`}),(0,B.jsx)(`p`,{className:`mt-[5px] text-[12.5px] leading-normal text-muted-foreground`,children:`It runs in the background and shows up in the sidebar; this window carries on with what it is doing.`})]}),(0,B.jsxs)(`div`,{className:`cs-db flex flex-col`,children:[(0,B.jsx)(`label`,{htmlFor:l,className:`mb-[7px] text-[12.5px] font-semibold`,children:`What should it do?`}),(0,B.jsx)(CB,{id:l,value:r,autoFocus:!0,disabled:a,"aria-invalid":s?!0:void 0,placeholder:`Fix the flaky login test, add dark mode to Settings…`,className:`cs-nsta max-h-60 min-h-[108px]`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),s?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,B.jsxs)(`div`,{className:`cs-df`,children:[(0,B.jsxs)(`span`,{className:`mr-auto flex items-center gap-1.5 text-xs text-[var(--faint)]`,children:[(0,B.jsx)(IT,{chord:`Ctrl+Enter`}),` to start`]}),(0,B.jsx)(OT,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,B.jsx)(OT,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}function TJ(){let e=(e,t)=>(0,B.jsxs)(`filter`,{id:e,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:t,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,B.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.6`,result:`rimB`}),(0,B.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--hl)`},result:`hlc`}),(0,B.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,B.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.6`,result:`shB`}),(0,B.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--sh)`},result:`shc`}),(0,B.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`sh`}),(0,B.jsx)(`feMergeNode`,{in:`hl`})]})]});return(0,B.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,B.jsxs)(`defs`,{children:[e(`cs-baylit`,3),e(`cs-worklit`,3.2),(0,B.jsxs)(`filter`,{id:`cs-bayedge`,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`3`,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,B.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.3`,result:`tS1`}),(0,B.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--ehl)`},result:`tc`}),(0,B.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,B.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.3`,result:`bS1`}),(0,B.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--esh)`},result:`bc`}),(0,B.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`eh`}),(0,B.jsx)(`feMergeNode`,{in:`es`})]})]}),(0,B.jsxs)(`filter`,{id:`cs-tabdent`,x:`-10%`,y:`-45%`,width:`120%`,height:`190%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`1.6`,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`sA`}),(0,B.jsx)(`feGaussianBlur`,{in:`sA`,stdDeviation:`1.5`,result:`sB`}),(0,B.jsx)(`feComposite`,{in:`sB`,in2:`shape`,operator:`in`,result:`sC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--tdsh)`},result:`shc`}),(0,B.jsx)(`feComposite`,{in:`shc`,in2:`sC`,operator:`in`,result:`sh`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`hA`}),(0,B.jsx)(`feGaussianBlur`,{in:`hA`,stdDeviation:`1`,result:`hB`}),(0,B.jsx)(`feComposite`,{in:`hB`,in2:`shape`,operator:`in`,result:`hC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--tdhl)`},result:`hlc`}),(0,B.jsx)(`feComposite`,{in:`hlc`,in2:`hC`,operator:`in`,result:`hl`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`sh`}),(0,B.jsx)(`feMergeNode`,{in:`hl`})]})]}),(0,B.jsxs)(`filter`,{id:`cs-indgoo`,x:`-20%`,y:`-80%`,width:`140%`,height:`260%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{stdDeviation:`1.6`}),(0,B.jsx)(`feColorMatrix`,{type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10`})]})]})})}function EJ({className:e,style:t}){return(0,B.jsxs)(`div`,{className:e,"aria-hidden":`true`,style:t,children:[(0,B.jsx)(`div`,{className:`cs-layer cs-edge`,children:(0,B.jsx)(`div`,{className:`cs-bb`})}),(0,B.jsx)(`div`,{className:`cs-layer cs-fill`,children:(0,B.jsx)(`div`,{className:`cs-bb`})})]})}function DJ(e,t=e){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>window.clearTimeout(o.current),[]);let s=(0,m.useCallback)(()=>{window.clearTimeout(o.current),r(!0)},[]),c=(0,m.useCallback)(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(()=>r(!1),e)},[e]),l=(0,m.useCallback)(()=>{window.clearTimeout(o.current),r(!0),o.current=window.setTimeout(()=>r(!1),t)},[t]),u=(0,m.useRef)(void 0);return(0,m.useEffect)(()=>()=>u.current?.(),[]),{open:n||i,flash:l,close:()=>{window.clearTimeout(o.current),r(!1)},handlers:{onPointerDown:e=>{if(e.pointerType!==`touch`)return;let t=e.currentTarget;if(n)e.target.closest(`[role='tab']`)&&c();else{window.clearTimeout(o.current),r(!0),u.current?.();let e=e=>{t.contains(e.target)||(window.clearTimeout(o.current),r(!1),u.current?.())};document.addEventListener(`pointerdown`,e,!0);let n=e=>{e.preventDefault(),e.stopPropagation()};t.addEventListener(`click`,n,{capture:!0,once:!0}),window.setTimeout(()=>t.removeEventListener(`click`,n,!0),500),u.current=()=>{document.removeEventListener(`pointerdown`,e,!0),u.current=void 0}}},onPointerEnter:e=>{e.pointerType!==`touch`&&s()},onPointerLeave:e=>{e.pointerType!==`touch`&&c()},onFocus:()=>a(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||a(!1)}}}}function OJ({id:e}){let t={width:15,height:15,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0};return e===`lobby`?(0,B.jsx)(`svg`,{...t,children:(0,B.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`})}):e===`tasks`?(0,B.jsxs)(`svg`,{...t,children:[(0,B.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,B.jsx)(`path`,{d:`M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11`})]}):e===`plan`?(0,B.jsxs)(`svg`,{...t,children:[(0,B.jsx)(`path`,{d:`M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3z`}),(0,B.jsx)(`path`,{d:`M9 3v15M15 6v15`})]}):e===`knowledge`?(0,B.jsxs)(`svg`,{...t,children:[(0,B.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 016.5 17H20`}),(0,B.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z`})]}):(0,B.jsxs)(`svg`,{...t,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,B.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 00.3 1.8l.1.1a2 2 0 11-2.8 2.8l-.1-.1a1.7 1.7 0 00-1.8-.3 1.7 1.7 0 00-1 1.5V21a2 2 0 11-4 0v-.1a1.7 1.7 0 00-1.1-1.5 1.7 1.7 0 00-1.8.3l-.1.1a2 2 0 11-2.8-2.8l.1-.1a1.7 1.7 0 00.3-1.8 1.7 1.7 0 00-1.5-1H3a2 2 0 110-4h.1a1.7 1.7 0 001.5-1.1 1.7 1.7 0 00-.3-1.8l-.1-.1a2 2 0 112.8-2.8l.1.1a1.7 1.7 0 001.8.3H9a1.7 1.7 0 001-1.5V3a2 2 0 114 0v.1a1.7 1.7 0 001 1.5 1.7 1.7 0 001.8-.3l.1-.1a2 2 0 112.8 2.8l-.1.1a1.7 1.7 0 00-.3 1.8V9a1.7 1.7 0 001.5 1H21a2 2 0 110 4h-.1a1.7 1.7 0 00-1.5 1z`})]})}var kJ=`cubic-bezier(0.3,1.2,0.5,1)`,AJ=`cubic-bezier(0.22,1,0.36,1)`,jJ=190,MJ=290,NJ=14,PJ=300;function FJ({tabs:e,activeId:t,onSelect:n}){let r=(0,m.useRef)(null),i=(0,m.useRef)({}),[a,o]=(0,m.useState)(346),s=(0,m.useRef)({placed:!1}),c=e.map(e=>e.label).join(`|`);(0,m.useLayoutEffect)(()=>{let e=()=>{let e=r.current?[...r.current.querySelectorAll(`[role='tab']`)]:[],t=e.length?Math.ceil(e.reduce((e,t)=>e+t.offsetWidth,0)+(e.length-1)*2)+20:346;o(t)};e(),document.fonts?.ready.then(e)},[c]);let l=(0,m.useCallback)(()=>{let e=r.current;if(!e)return;let n=t?i.current[t]:void 0;if(!n)return;let a=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,o=!s.current.placed,c=n.offsetLeft,l=e.offsetWidth-c-n.offsetWidth,u=s.current.left===void 0||c>s.current.left;for(let t of e.querySelectorAll(`.cs-tabind`)){let n=t.firstElementChild;if(n){if(o||a||e.offsetWidth===0){n.style.transition=`none`,n.style.left=`${c}px`,n.style.right=`${l}px`;continue}c!==s.current.left&&(n.style.transition=u?`left ${MJ}ms ${AJ} ${NJ}ms, right ${jJ}ms ${kJ}`:`left ${jJ}ms ${kJ}, right ${MJ}ms ${AJ} ${NJ}ms`,n.style.left=`${c}px`,n.style.right=`${l}px`,t.animate?.([{transform:`scaleY(1)`},{transform:`scaleY(0.84)`,offset:.35},{transform:`scaleY(1.05)`,offset:.75},{transform:`scaleY(1)`}],{duration:PJ,easing:`ease-in-out`}))}}e.offsetWidth>0&&(s.current={left:c,placed:!0})},[t]);(0,m.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>requestAnimationFrame(l));return()=>cancelAnimationFrame(e)},[l,a]);function u(r){if(r.key===`ArrowDown`&&!r.altKey){EE()&&r.preventDefault();return}let a=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!a||e.length===0)return;r.preventDefault();let o=r.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,s=e[(Math.max(0,e.findIndex(e=>e.id===o))+a+e.length)%e.length];OE.active=!0,OE.to=s.id,window.setTimeout(()=>{OE.active=!1,OE.to=void 0},3e3),n(s.id),i.current[s.id]?.focus({preventScroll:!0})}let d={"--wT":`${a}px`,"--hT":`40px`};return{vars:d,ghost:(0,B.jsx)(EJ,{className:`cs-gt`,style:d}),bay:(0,B.jsx)(`div`,{className:`cs-tbwrap`,style:d,children:(0,B.jsx)(`div`,{className:`cs-tbx`,children:(0,B.jsx)(`div`,{className:`cs-tbo`,"data-none":t?void 0:``,children:(0,B.jsxs)(`div`,{ref:r,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:u,className:`cs-track`,children:[(0,B.jsx)(`span`,{className:`cs-tabind cs-dent`,"aria-hidden":`true`,children:(0,B.jsx)(`i`,{})}),(0,B.jsx)(`span`,{className:`cs-tabind cs-tint`,"aria-hidden":`true`,children:(0,B.jsx)(`i`,{})}),(0,B.jsx)(`span`,{className:`cs-tabind cs-bevel`,"aria-hidden":`true`,children:(0,B.jsx)(`i`,{})}),e.map((e,n)=>(0,B.jsxs)(`a`,{ref:t=>{i.current[e.id]=t},role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":e.id===t,"aria-keyshortcuts":e.key,title:`${e.label} · ${e.key.replace(`+`,` `)}`,tabIndex:e.id===t||!t&&n===0?0:-1,className:`cs-tab`,style:{"--i":n},children:[(0,B.jsx)(`span`,{className:`cs-ti`,children:(0,B.jsx)(OJ,{id:e.id})}),e.label]},e.id))]})})})})}}function IJ({children:e}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(EJ,{className:`cs-gr`}),(0,B.jsx)(`div`,{className:Y(`cs-rbx`),children:e})]})}function LJ(e){return e.waiting>0&&e.alive?`asking`:e.status===`exited`||!e.alive?`exited`:e.busy||e.status===`working`?`working`:e.status===`starting`?`starting`:`idle`}function RJ(e,t){let n=e?.sessionId,r={id:`here`,name:e?.sessionName?.trim()||`This window`,where:`here`,state:e?.busy?`working`:`idle`,waiting:0,...n?{sessionId:n}:{}},i=(t?.background??[]).filter(e=>!n||e.sessionId!==n).map(e=>({id:`bg:${e.key}`,name:e.name,where:`background`,state:LJ(e),waiting:e.alive?e.waiting:0,key:e.key,...e.sessionId?{sessionId:e.sessionId}:{}})),a=new Set([n,...i.map(e=>e.sessionId)].filter(Boolean)),o=(t?.live??[]).filter(e=>!a.has(e.sessionId)).map(e=>({id:`live:${e.sessionId}`,name:e.name?.trim()||`Unnamed session`,where:`elsewhere`,state:`idle`,waiting:0,sessionId:e.sessionId}));i.sort((e,t)=>Number(e.state===`exited`)-Number(t.state===`exited`));let s=new Set([...a,...o.map(e=>e.sessionId)]),c=(t?.saved??[]).filter(e=>!e.archived&&!s.has(e.sessionId)).map(e=>({id:`saved:${e.sessionId}`,name:e.name,where:`saved`,state:`exited`,waiting:0,sessionId:e.sessionId,at:e.at}));return[r,...i,...o,...c]}var zJ=`app.sidebar.pinned`,BJ=()=>YR(zJ),VJ={w:244,h:`min(600px, calc(100vh - 40px))`},HJ=`cs-iconbtn cs-sm`;function UJ({label:e,hint:t,side:n=`bottom`,children:r}){return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:r}),(0,B.jsxs)(wI,{side:n,children:[e,` `,t?(0,B.jsx)(IT,{chord:t}):null]})]})}function WJ(){let e=vE(`status`).data;return RJ(e,eR(`sessions.list`,{},[`sessions`]).data)}async function GJ(e){if(e.where===`here`)return iE(`#/lobby`);if(e.where===`elsewhere`)return void H.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await U(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&iE(`#/lobby`)}function KJ(){return(0,m.useCallback)(GJ,[])}var qJ={entries:[]};async function JJ(e){let t=qJ.entries.filter(e=>e.where!==`elsewhere`),n=t.findIndex(e=>e.where===`here`);if(t.length<2||n<0)return void H.info(`No other session to switch to.`);qJ.flash?.(),await GJ(t[(n+e+t.length)%t.length])}function YJ({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,B.jsxs)(`span`,{className:`cs-badge`,children:[(0,B.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,B.jsx)(`path`,{d:`M9.1 9a3 3 0 015.8 1c0 2-3 2.5-3 4M12 17h.01`})]}),e.waiting,(0,B.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,B.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,B.jsx)(sp,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,B.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,B.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var XJ={here:`This window`,background:`Background`,elsewhere:`Other terminal`,saved:`Recent`};function ZJ(e){let t=e.key?{key:e.key}:{sessionId:e.sessionId};return U(`sessions.archive`,t,{undo:()=>void U(`sessions.archive`,{...t,archived:!1})})}function QJ({entry:e,onDone:t}){let[n,r]=(0,m.useState)(e.name),i=(0,m.useRef)(!1),a=async()=>{if(i.current)return;i.current=!0;let r=n.replace(/\s+/g,` `).trim();r&&r!==e.name&&await U(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,B.jsx)(`input`,{value:n,autoFocus:!0,maxLength:120,"aria-label":`New name for ${e.name}`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onBlur:()=>void a(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.current=!0,t())},className:`h-6 w-full min-w-0 rounded-md bg-[var(--fill)] px-1.5 text-[13px] text-foreground outline-none ring-2 ring-ring`})}function $J({entry:e,index:t}){let n=KJ(),[r,i]=(0,m.useState)(!1),a=e.state===`exited`||e.where===`elsewhere`,o=e.where===`here`||e.where===`background`,s=e.where===`background`&&e.state===`exited`&&!!e.key||e.where===`saved`,c=e.where===`saved`,l=o||s||c,u={"--i":t};return(0,B.jsxs)(`li`,{className:`cs-srow session-item`,children:[r?(0,B.jsx)(`div`,{className:`cs-sr`,"data-active":e.where===`here`||void 0,style:u,children:(0,B.jsx)(QJ,{entry:e,onDone:()=>i(!1)})}):(0,B.jsxs)(`button`,{type:`button`,"aria-current":e.where===`here`?`true`:void 0,"aria-label":e.where===`here`?`${e.name}, this window`:e.where===`elsewhere`?`${e.name}, in another terminal`:`Switch to ${e.name}`,title:e.name,"data-where":e.where,"data-state":e.state,"data-dim":a||void 0,onClick:()=>void n(e),onDoubleClick:e=>{o&&(e.preventDefault(),i(!0))},className:`cs-sr session-row`,style:u,children:[(0,B.jsx)(`span`,{className:`cs-grow`,children:e.name}),(0,B.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,l&&`cs-sstate`),children:(0,B.jsx)(YJ,{entry:e})})]}),!r&&l?(0,B.jsxs)(`span`,{className:`cs-sacts`,children:[o?(0,B.jsx)(UJ,{label:`Rename`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>i(!0),className:`cs-sact`,children:(0,B.jsx)(ym,{"aria-hidden":`true`,className:`size-3.5`})})}):null,s?(0,B.jsx)(UJ,{label:`Archive`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void ZJ(e),className:`cs-sact`,children:(0,B.jsx)(Af,{"aria-hidden":`true`,className:`size-3.5`})})}):null,c?(0,B.jsx)(qL,{iconOnly:!0,className:`cs-sact`,side:`bottom`,label:`Delete ${e.name}`,icon:rh,variant:`destructive`,title:`Delete ${e.name}?`,description:`Its conversation file is removed for good. Archive it instead to keep it.`,confirmLabel:`Delete`,onConfirm:()=>void U(`sessions.delete`,{sessionId:e.sessionId})}):null]}):null]})}function eY({id:e,label:t,entries:n,start:r,archivable:i=!1}){let[a,o]=XR(`app.sidebar.${e}`),s=(0,m.useId)();return n.length===0?null:(0,B.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,B.jsxs)(`div`,{className:`cs-sh`,style:{"--i":r},children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":!a,"aria-controls":s,onClick:o,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left outline-none hover:text-foreground focus-visible:underline`,children:[(0,B.jsx)(`span`,{children:t}),a?(0,B.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,B.jsx)(Yf,{"aria-hidden":`true`,className:Y(`size-3 opacity-0 transition-[opacity,rotate] duration-150 group-hover/shelf:opacity-100 group-focus-within/shelf:opacity-100`,a&&`-rotate-90 opacity-100`)})]}),i?(0,B.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)await U(`sessions.archive`,e.key?{key:e.key}:{sessionId:e.sessionId})})(),className:`shrink-0 outline-none hover:text-foreground focus-visible:underline`,children:`Archive all`}):null]}),a?null:(0,B.jsx)(`ul`,{id:s,className:`flex flex-col`,children:n.map((e,t)=>(0,B.jsx)($J,{entry:e,index:r+1+t},e.id))})]})}function tY(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${XJ[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function nY({query:e,onQuery:t,onNew:n}){return(0,B.jsxs)(`label`,{className:`cs-sr cs-search`,style:{"--i":0},children:[(0,B.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,B.jsx)(`path`,{d:`M21 21l-4.3-4.3`})]}),(0,B.jsx)(`input`,{type:`search`,value:e,"aria-label":`Search sessions`,placeholder:`Search`,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))}}),(0,B.jsx)(UJ,{label:`New session`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:`flex text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground`,children:(0,B.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M12 20h9`}),(0,B.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})})]})}function rY({query:e}){let t=WJ(),n=t.filter(t=>tY(t,e)),r=n.filter(e=>e.where===`here`&&e.state!==`exited`),i=n.filter(e=>e.where===`background`&&e.state!==`exited`),a=n.filter(e=>e.where===`elsewhere`),o=n.filter(e=>e.where!==`elsewhere`&&e.state===`exited`),s=1,c=e=>{let t=s;return s+=e+1,t},l=c(r.length),u=c(i.length);return(0,B.jsxs)(`nav`,{"aria-label":`Sessions list`,className:`cs-sblist`,children:[n.length===0?(0,B.jsxs)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):null,r.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`cs-sh`,style:{"--i":l},children:`This window`}),(0,B.jsx)(`ul`,{className:`flex flex-col`,children:r.map((e,t)=>(0,B.jsx)($J,{entry:e,index:l+1+t},e.id))})]}):null,i.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`Background`}),(0,B.jsx)(`ul`,{className:`flex flex-col`,children:i.map((e,t)=>(0,B.jsx)($J,{entry:e,index:u+1+t},e.id))})]}):!e.trim()&&t.length===1?(0,B.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`No other sessions are running.`}):null,(0,B.jsx)(eY,{id:`elsewhere`,label:`Other terminals`,entries:a,start:c(a.length)}),(0,B.jsx)(eY,{id:`ended`,label:`Recent`,entries:o,start:c(o.length),archivable:!0})]})}function iY({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,B.jsxs)(`div`,{className:`cs-sbfoot`,children:[(0,B.jsxs)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.kind===`settings`?`page`:void 0,"aria-keyshortcuts":r,className:`cs-sr`,style:{"--i":20},children:[(0,B.jsx)(OJ,{id:`settings`}),(0,B.jsx)(`span`,{className:`cs-grow`,children:`Settings`}),(0,B.jsx)(IT,{chord:r})]}),(0,B.jsxs)(`div`,{className:`cs-sr cs-tools`,style:{"--i":21},children:[(0,B.jsx)(kK,{hint:t.help??`Alt+H`,onHelp:n,className:HJ}),(0,B.jsx)(AK,{className:HJ}),(0,B.jsx)(MK,{className:HJ}),(0,B.jsx)(NK,{className:HJ})]})]})}function aY(e){let[t,n]=XR(zJ),r=DJ(160,1600);qJ.entries=WJ(),qJ.flash=r.flash;let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=t||r.open||o,l={"--wL":`${c?VJ.w:122}px`,"--hL":c?VJ.h:`40px`,"--sb-open-h":VJ.h},u=(0,m.useCallback)(()=>s(!0),[]);return{open:c,ghost:(0,B.jsx)(EJ,{className:`cs-gl`,style:l}),bay:(0,B.jsxs)(`div`,{className:`cs-sbwrap`,style:l,...r.handlers,children:[(0,B.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,className:`cs-sbx`,children:[(0,B.jsxs)(`div`,{className:`cs-sbmini`,inert:c,children:[(0,B.jsx)(UJ,{label:t?`Unpin sidebar`:`Pin sidebar`,hint:e.keys.sidebar,side:`bottom`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Sessions`,"aria-pressed":t,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:`cs-iconbtn`,children:(0,B.jsx)(OJ,{id:`lobby`})})}),(0,B.jsx)(UJ,{label:`New session`,side:`bottom`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:u,className:`cs-iconbtn`,children:(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M12 20h9`}),(0,B.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})}),(0,B.jsx)(UJ,{label:`Settings`,hint:e.keys.settings??`Alt+S`,side:`bottom`,children:(0,B.jsx)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.route.kind===`settings`?`page`:void 0,className:`cs-iconbtn`,children:(0,B.jsx)(OJ,{id:`settings`})})})]}),(0,B.jsxs)(`div`,{className:`cs-sbfull`,inert:!c,children:[(0,B.jsx)(nY,{query:i,onQuery:a,onNew:u}),(0,B.jsx)(rY,{query:i}),(0,B.jsx)(iY,{...e})]})]}),(0,B.jsx)(wJ,{open:o,onOpenChange:s})]})}}var oY=`bot-lobby.terminal.open`,sY=`bot-lobby.terminal.height`,cY=`bot-lobby.terminal.popup`,lY={start:280,min:140},uY=new Set,dY,fY,pY;function mY(e){try{return localStorage.getItem(e)}catch{return null}}function hY(e,t){try{localStorage.setItem(e,t)}catch{}}function gY(){for(let e of[...uY])e()}function _Y(e){return uY.add(e),()=>{uY.delete(e)}}function vY(){return dY??=mY(oY)===`1`,dY}function yY(){if(fY===void 0){let e=Number(mY(sY));fY=e>=lY.min?e:lY.start}return fY}function bY(e){dY=e,hY(oY,e?`1`:`0`),gY()}function xY(){bY(!vY())}function SY(e){fY=Math.max(lY.min,Math.round(e)),hY(sY,String(fY)),gY()}function CY(){return(0,m.useSyncExternalStore)(_Y,vY,()=>!1)}function wY(){return(0,m.useSyncExternalStore)(_Y,yY,()=>lY.start)}function TY(){return pY??=mY(cY)===`1`,pY}function EY(e){pY=e,hY(cY,e?`1`:`0`),gY()}function DY(){return(0,m.useSyncExternalStore)(_Y,TY,()=>!1)}var OY=`modulepreload`,kY=function(e){return`/`+e},AY={},jY=function(e){return e.pathname.endsWith(`.css`)},MY=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=kY(t,n);let r=s(t);if(r.href in AY)return;AY[r.href]=!0;let i=jY(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:OY,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},NY=(0,m.lazy)(()=>MY(()=>import(`./TerminalView-D0ZUy1E_.js`),__vite__mapDeps([0,1,2,3]))),PY=`inline-flex size-6 items-center justify-center text-foreground/80 outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function FY({label:e,hint:t,children:n}){return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:n}),(0,B.jsxs)(wI,{side:`top`,children:[e,` `,t?(0,B.jsx)(IT,{chord:t}):null]})]})}function IY({hint:e,className:t}){let n=CY();return(0,B.jsx)(FY,{label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:xY,className:t,children:(0,B.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M4 17l6-6-6-6M12 19h8`})})})})}function LY(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await I(`terminal.list`,{})),i(``)}catch(e){i(e instanceof Error?e.message:`The terminals could not be read.`)}},[]);return(0,m.useEffect)(()=>{e&&a()},[e,a]),{list:t,error:r,reload:a}}function RY({height:e,max:t}){let n=(0,m.useRef)(null);return(0,B.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":lY.min,"aria-valuemax":t,className:`terminal-edge`,onPointerDown:t=>{t.button===0&&(t.currentTarget.setPointerCapture?.(t.pointerId),n.current={y:t.clientY,height:e},document.documentElement.dataset.resizing=`row`)},onPointerMove:e=>{n.current&&SY(Math.min(t,n.current.height+n.current.y-e.clientY))},onPointerUp:()=>{n.current=null,delete document.documentElement.dataset.resizing},onPointerCancel:()=>{n.current=null,delete document.documentElement.dataset.resizing},onDoubleClick:()=>SY(lY.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),SY(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function zY({toggleKey:e}){let t=CY(),n=DY(),r=wY(),i=qT(t&&n,KT.sheet),{list:a,error:o,reload:s}=LY(t),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(()=>Math.round(window.innerHeight*.7)),h=a?.terminals??[],g=h.find(e=>e.id===c)??h.at(-1);(0,m.useEffect)(()=>{let e=()=>p(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let _=(0,m.useCallback)(async()=>{d(!0);try{let e=await I(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){H.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),v=(0,m.useCallback)(async e=>{try{await I(`terminal.close`,{id:e})}catch{}await s()},[s]);(0,m.useEffect)(()=>{if(!t||h.length<2)return;let e=e=>{if(!e.ctrlKey||e.altKey||e.metaKey||e.key!==`PageDown`&&e.key!==`PageUp`)return;e.preventDefault();let t=Math.max(0,h.findIndex(e=>e.id===g?.id)),n=h[(t+(e.key===`PageDown`?1:-1)+h.length)%h.length];l(n.id)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t,h,g?.id]);let y=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){y.current=!1;return}!a||!a.available||a.terminals.length>0||y.current||u||(y.current=!0,_())},[t,a,u,_]);let b=t&&!n?Math.min(r,f):0;if((0,m.useEffect)(()=>{let e=document.documentElement;return b?e.style.setProperty(`--terminal-h`,`${b}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[b]),!t)return null;let x=(0,B.jsx)(BY,{list:a,error:o,terminals:h,shown:g,busy:u,popup:n,toggleKey:e,onPick:l,onStart:()=>void _(),onEnd:e=>void v(e),onReload:()=>void s()});return n?(0,B.jsx)(zT,{open:i,onOpenChange:e=>{e||bY(!1)},label:`Terminal`,className:`terminal-pop h-[min(72svh,40rem)] max-h-none max-w-5xl`,onEscapeKeyDown:e=>{e.target?.closest?.(`.xterm`)&&e.preventDefault()},children:(0,B.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:x})}):(0,B.jsxs)(`section`,{id:`terminal-drawer`,"aria-label":`Terminal`,className:`terminal-drawer relative flex shrink-0 border-t border-border`,style:{height:Math.min(r,f)},children:[(0,B.jsx)(RY,{height:Math.min(r,f),max:f}),x]})}function BY({list:e,error:t,terminals:n,shown:r,busy:i,popup:a,toggleKey:o,onPick:s,onStart:c,onEnd:l,onReload:u}){let d=(0,B.jsxs)(`div`,{className:`terminal-tools pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,B.jsx)(FY,{label:`New terminal`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:PY,children:(0,B.jsx)(Dm,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,B.jsx)(FY,{label:`End this terminal`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:PY,children:(0,B.jsx)(rh,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,B.jsx)(FY,{label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>EY(!a),className:PY,children:(0,B.jsx)(xm,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,B.jsx)(FY,{label:`Hide terminal`,hint:o,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>bY(!1),className:PY,children:a?(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`}):(0,B.jsx)(Yf,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,B.jsx)(B.Fragment,{children:e&&!e.available?(0,B.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,B.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,B.jsxs)(m.Suspense,{fallback:(0,B.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,B.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`No terminal is running. Start one with New terminal.`}):null,n.map(e=>(0,B.jsx)(NY,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,B.jsx)(`nav`,{"aria-label":`Terminals`,className:Y(`flex w-36 shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-border px-1 pb-1`,a?`pt-2`:`pt-10`),children:n.map(e=>(0,B.jsxs)(`button`,{type:`button`,"aria-current":e.id===r?.id?`true`:void 0,onClick:()=>s(e.id),className:Y(`flex h-6 min-w-0 items-center gap-1.5 rounded px-1.5 text-left text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent aria-[current=true]:text-foreground`,!e.alive&&`opacity-60`),children:[(0,B.jsx)(Zm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,B.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,B.jsx)(Zm,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,B.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,B.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var VY=(0,m.lazy)(()=>MY(()=>import(`./CodeSurface-C8u8tIUk.js`),__vite__mapDeps([4,1,2]))),HY=`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function UY({label:e,hint:t,children:n}){return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:n}),(0,B.jsxs)(wI,{side:`bottom`,children:[e,` `,t?(0,B.jsx)(IT,{chord:t}):null]})]})}function WY({hint:e,className:t}){let{open:n}=dL();return(0,B.jsx)(UY,{label:`Code and changes`,hint:e,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?lL():cL(),className:t,children:(0,B.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M16 18l6-6-6-6M8 6l-6 6 6 6`})})})})}var GY={modified:{letter:`M`,word:`Modified`,tone:`text-warning`},added:{letter:`A`,word:`Added`,tone:`text-success`},untracked:{letter:`U`,word:`New, not committed`,tone:`text-success`},deleted:{letter:`D`,word:`Deleted`,tone:`text-destructive`},renamed:{letter:`R`,word:`Renamed`,tone:`text-primary`}};function KY(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function qY({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,B.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,B.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,B.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function JY(){let[e,t]=(0,m.useState)(()=>document.documentElement.classList.contains(`dark`));return(0,m.useEffect)(()=>{let e=document.documentElement,n=new MutationObserver(()=>t(e.classList.contains(`dark`)));return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[]),e}function YY({changes:e,loading:t,error:n,current:r,onPick:i,onRefresh:a}){let[o,s]=(0,m.useState)(``),c=e?.files??[],l=c.reduce((e,t)=>({additions:e.additions+(t.additions??0),deletions:e.deletions+(t.deletions??0)}),{additions:0,deletions:0});function u(e){e.preventDefault();let t=o.trim();t&&(i(t),s(``))}return(0,B.jsxs)(`nav`,{"aria-label":`Changed files`,className:`code-rail flex w-64 shrink-0 flex-col border-r border-border max-md:w-52`,children:[(0,B.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,B.jsxs)(`label`,{className:`flex h-8 items-center gap-2 rounded-md border border-input bg-background px-2 transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20`,children:[(0,B.jsx)(Vm,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,B.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),"aria-label":`Open a file by path`,placeholder:`Open a file by path…`,spellCheck:!1,autoComplete:`off`,className:`h-full min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:font-sans placeholder:text-muted-foreground`})]})}),(0,B.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,B.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,B.jsx)(qY,{change:l,className:`ml-auto`}),(0,B.jsx)(UY,{label:`Read the changes again`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y(HY,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,B.jsx)(km,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,B.jsxs)(`ul`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-1.5 pb-2`,children:[c.map(e=>{let{dir:t,name:n}=KY(e.path),a=GY[e.status];return(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),"aria-current":e.path===r?`true`:void 0,title:e.from?`${e.from} → ${e.path}`:e.path,className:`group/row flex h-7 w-full min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-[0.8125rem] outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent`,children:[(0,B.jsx)(`span`,{"aria-label":a.word,className:Y(`w-3 shrink-0 text-center font-mono text-[0.6875rem] font-semibold`,a.tone),children:a.letter}),(0,B.jsxs)(`span`,{className:Y(`min-w-0 flex-1 truncate`,e.status===`deleted`&&`text-muted-foreground line-through decoration-muted-foreground/50`),children:[n,t?(0,B.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,B.jsx)(qY,{change:e})]})},e.path)}),e&&!e.git?(0,B.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`This folder is not a git repository, so there are no changes to show. Open a file by its path above.`}):null,e?.git&&c.length===0?(0,B.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,B.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function XY(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(0),c=(0,m.useCallback)(async e=>{let t=++s.current;o(!0),i(void 0);try{let r=await I(`code.read`,{path:e});t===s.current&&n(e=>({file:r,version:(e?.version??0)+1}))}catch(e){t===s.current&&(n(void 0),i(e instanceof Error?e.message:String(e)))}finally{t===s.current&&o(!1)}},[]);return(0,m.useEffect)(()=>{e?c(e):(s.current++,n(void 0),i(void 0))},[e,c]),{loaded:t,setLoaded:n,error:r,loading:a,reload:()=>e&&c(e)}}function ZY({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=eR(`code.changes`,{},[`lobby`,`tasks`]),[c,l]=(0,m.useState)(e),[u,d]=(0,m.useState)(t??`code`),{loaded:f,setLoaded:p,error:h,loading:g,reload:_}=XY(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=vL(),ee=yL(),D=JY(),O=f?.file,k=v!==void 0&&v!==O?.contents;(0,m.useEffect)(()=>a(k),[k,a]),(0,m.useEffect)(()=>{if(!e||e===c){t&&d(t);return}A({kind:`open`,path:e})},[n]),(0,m.useEffect)(()=>{if(!c&&s.data?.files[0]){let e=s.data.files.find(e=>e.status!==`deleted`)??s.data.files[0];l(e.path),t||d(`diff`)}},[s.data]),(0,m.useEffect)(()=>{O&&O.path!==c&&l(O.path)},[O?.path]),(0,m.useEffect)(()=>{o&&A({kind:`close`})},[o]);function te(e){if(T(void 0),C(!1),e.kind===`close`){i();return}y(void 0),l(e.path)}function A(e){(e.kind!==`open`||e.path!==c)&&(k?T(e):te(e))}async function j(e=!1){if(O&&v!==void 0&&!b){x(!0);try{let t=await I(`code.save`,{path:O.path,contents:v,mtimeMs:O.mtimeMs,...e?{force:!0}:{}});return p(e=>e&&{...e,file:{...e.file,contents:v,mtimeMs:t.mtimeMs,size:v.length}}),y(void 0),C(!1),s.reload(),w&&te(w),!0}catch(e){return e instanceof Se&&e.code===`conflict`?C(!0):H.error(e instanceof Error?e.message:`The file could not be saved.`),!1}finally{x(!1)}}}function ne(e){(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`s`?(e.preventDefault(),e.stopPropagation(),j()):r&&lK(e.nativeEvent,r)&&(e.preventDefault(),A({kind:`close`}))}let re=O?.change,M=!!re||O?.original!==void 0,ie=M?u:`code`,{dir:ae,name:oe}=KY(O?.path??c??``),se=!!(O?.exists&&O.contents!==void 0),ce=re?GY[re.status]:void 0;return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:ne,children:[(0,B.jsx)(YY,{changes:s.data,loading:s.loading,error:s.error,current:O?.path??c,onPick:e=>A({kind:`open`,path:e}),onRefresh:()=>{s.reload(),k||_()}}),(0,B.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,B.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[ce?(0,B.jsx)(`span`,{title:ce.word,className:Y(`font-mono text-xs font-semibold`,ce.tone),children:ce.letter}):(0,B.jsx)(Tp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,B.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:O?.path??c,children:[ae?(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[ae,`/`]}):null,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:oe}),k?(0,B.jsx)(`span`,{"aria-label":`unsaved`,title:`Unsaved edits`,className:`ml-1.5 inline-block size-1.5 -translate-y-0.5 rounded-full bg-foreground/70`}):null]}),re?(0,B.jsx)(qY,{change:re}):null]}):(0,B.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),M?(0,B.jsx)(hE,{label:`View`,value:ie,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,ie===`diff`?(0,B.jsx)(UY,{label:ee===`split`?`Unified diff`:`Side by side`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":ee===`split`,onClick:()=>_L(ee===`split`?`unified`:`split`),className:HY,children:ee===`split`?(0,B.jsx)(Lm,{"aria-hidden":`true`,className:`size-4`}):(0,B.jsx)(_p,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,B.jsx)(UY,{label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>gL(!E),className:HY,children:(0,B.jsx)(th,{"aria-hidden":`true`,className:`size-4`})})}),(0,B.jsx)(UY,{label:`Save`,hint:`Ctrl+S`,children:(0,B.jsxs)(OT,{size:`sm`,variant:k?`default`:`outline`,disabled:!k||b,onClick:()=>void j(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,B.jsx)(zm,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,B.jsx)(UY,{label:`Close`,hint:r,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>A({kind:`close`}),className:HY,children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,B.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,B.jsx)(_m,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[oe,` has unsaved edits.`]}),(0,B.jsx)(OT,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,B.jsx)(OT,{size:`xs`,variant:`outline`,onClick:()=>te(w),children:`Discard`}),(0,B.jsx)(OT,{size:`xs`,onClick:()=>void j(),disabled:b,children:`Save`})]}):null,S?(0,B.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[oe,` changed on disk since you opened it, maybe by an agent.`]}),(0,B.jsx)(OT,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,B.jsx)(OT,{size:`xs`,onClick:()=>void j(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,B.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,B.jsx)(`p`,{role:`alert`,className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:h}):c?O?O.binary||O.tooLarge?(0,B.jsx)(`p`,{className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:O.binary?`This is a binary file, so it is not shown.`:`This file is too large to show here.`}):!O.exists&&ie===`code`?(0,B.jsxs)(`p`,{className:`m-auto flex max-w-sm flex-col items-center gap-2 px-6 text-center text-sm text-muted-foreground`,children:[(0,B.jsx)(Np,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,B.jsx)(m.Suspense,{fallback:(0,B.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,B.jsx)(VY,{path:O.path,version:`${f.version}`,contents:O.contents??``,draft:v,original:O.original,mode:ie,layout:ee,wrap:E,dark:D,readOnly:!se,onDraft:y})}):(0,B.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,B.jsx)(QY,{loading:s.loading})})]})]})}function QY({loading:e}){return(0,B.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,B.jsx)(Dp,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e?`Reading the changes…`:`Pick a changed file, open one by its path, or click a file name in the Lobby chat.`})]})}function $Y({codeKey:e}){let{open:t,path:n,mode:r,request:i}=dL(),a=qT(t,KT.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,B.jsx)(zT,{open:a,onOpenChange:e=>{e||(o?u():lL())},label:`Code viewer`,className:`code-pop h-[min(86svh,52rem)] max-h-none max-w-6xl`,onEscapeKeyDown:e=>{o&&(e.preventDefault(),u())},children:t?(0,B.jsx)(ZY,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:lL,onDirtyChange:s,closeAsked:c}):null})}function eX(e){let t=e.match(/[#&?]?token=([^&\s#]+)/i);if(t?.[1])return decodeURIComponent(t[1]);let n=e.trim();return n&&!n.includes(`/`)&&!n.includes(` `)?n:void 0}function tX(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1);async function o(e){a(!0),r(void 0),e&&(window.location.hash=`token=${encodeURIComponent(e)}`),await Te()?window.location.reload():(r(e?`That link did not sign in. Copy the link from Pi and try again.`:`Paste the link from Pi below.`),a(!1))}function s(t){t.preventDefault(),o(eX(e))}return(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,B.jsxs)(`form`,{onSubmit:s,className:`cs-dlg w-full max-w-[420px]`,children:[(0,B.jsxs)(`div`,{className:`cs-dh flex items-center gap-3.5 pt-[22px]`,children:[(0,B.jsx)(`span`,{className:`cs-drop`,"aria-hidden":`true`,children:(0,B.jsx)(Gp,{className:`size-[18px]`})}),(0,B.jsx)(`h1`,{children:`Sign in to bot-lobby`})]}),(0,B.jsxs)(`div`,{className:`cs-db`,children:[(0,B.jsxs)(`p`,{className:`mb-3.5 text-[12.5px] leading-relaxed text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,B.jsx)(`code`,{className:`cs-cd`,children:`/bot-lobby web`}),` to see it again). Paste it here.`]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Lobby link or token`}),(0,B.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0,placeholder:`http://127.0.0.1:7347/#token=…`,className:`cs-inp`})]}),n?(0,B.jsx)(`p`,{role:`alert`,className:`mt-2.5 text-[12.5px] text-[var(--bad)]`,children:n}):null]}),(0,B.jsxs)(`div`,{className:`cs-df`,children:[(0,B.jsx)(OT,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,B.jsx)(OT,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var nX=`plan:`,rX=`bot-lobby:plan-put-away`,iX=e=>e.startsWith(nX);function aX(){try{let e=JSON.parse(sessionStorage.getItem(rX)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`number`):[]}catch{return[]}}function oX(e){let t=e?.messages.at(-1);if(e&&!e.busy&&t?.role===`planner`&&t.questions?.length)return{id:`${nX}${t.at}`,kind:`questionnaire`,createdAt:t.at,from:`planner`,payload:{round:Math.max(e.round,1),limit:e.limit,questions:t.questions.map(e=>({question:e.text,header:e.from,options:e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}))}))}}}function sX(e,t){let n=e.payload.questions??[];return(t.answers??[]).map(e=>`${vR(n[e.questionIndex]?.header??``)}: ${e.question} ${e.answer}`.trim()).join(`
|
|
111
|
+
`).map(e=>gJ.measureText(e).width));t.style.setProperty(`--cg`,`${Math.ceil((r+44)/48)*48}px`)},[i,ye]),(0,m.useLayoutEffect)(()=>{ne.current&&j.current&&(ne.current.scrollTop=j.current.scrollTop)}),(0,m.useEffect)(()=>{let e=te.current,t=O.current;if(!e||!t)return;let n=document.documentElement,r=()=>{let r=e.getBoundingClientRect(),i=t.getBoundingClientRect().bottom;if(n.style.setProperty(`--composer-h`,_||!y?`0px`:`${Math.ceil(i-r.top)}px`),!y||r.width===0){n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`);return}n.style.setProperty(`--composer-x`,`${Math.round(r.left)}px`),n.style.setProperty(`--composer-w`,`${Math.round(r.width)}px`)};r();let i=new ResizeObserver(r);return i.observe(e),e.addEventListener(`transitionend`,r),window.addEventListener(`resize`,r),()=>{i.disconnect(),e.removeEventListener(`transitionend`,r),window.removeEventListener(`resize`,r),n.style.setProperty(`--composer-h`,`0px`),n.style.removeProperty(`--composer-x`),n.style.removeProperty(`--composer-w`)}},[_,y]);let Pe=(0,m.useCallback)(e=>{if(!b.current)return;let t=[...e],n=8-ie.current.length;t.length>n&&H.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++hJ}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;s(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),FK(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{H.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),Fe=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),Ie=o.some(e=>e.state===`uploading`),Le=o.flatMap(e=>e.info?[e.info.id]:[]),Re=(i.trim().length>0||Le.length>0)&&!Ie&&!c,ze=(0,m.useCallback)(async()=>{if(!Re||!b.current)return;l(!0);let e=Le.length>0?Le:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0;if(T.id===`oracle`){let e=await I(`lobby.send`,t);e.notice&&H(e.notice),e.open===`plan`?iE(rE(`plan`)):S===`knowledge`&&iE(rE(`lobby`))}else T.id===`knowledge`?(e=await U(`knowledge.ask`,t)!==void 0,e&&(window.dispatchEvent(new CustomEvent(hD,{detail:i.trim()})),w(!1))):e=T.id===`panel`?await U(`planner.send`,t)!==void 0:await U(`tasks.comment`,{taskId:T.taskId,...t})!==void 0;if(e){a(``);for(let e of ie.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){H.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[Re,Le,T,i,e,S]),Be=(0,m.useCallback)(async()=>{try{await I(`lobby.abort`,{})}catch(e){H.error(e instanceof Error?e.message:`Could not stop`)}},[]),Ve=e=>{if(me&&P&&!e.nativeEvent.isComposing){let t=pe.indexOf(P);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+pe.length)%pe.length;le(pe[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),Me(P);return}if(e.key===`Escape`){e.preventDefault(),de(i);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),f?p(null):N?oJ(!0):C?w(!1):DE();return}if(N&&_J(e)){e.preventDefault(),n.reply(i)?a(``):!i.trim()&&n.step?.multi&&n.submitPicks();return}let t=e.currentTarget,r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(r)){e.preventDefault();let{selectionStart:n,selectionEnd:i,value:a}=t;Ne(r===`k`?LK(a,n,i):IK(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=zK(t.value,t.selectionStart);n&&(e.preventDefault(),Ne(n));return}if(e.key===`Backspace`&&t.value===``&&ie.current.length>0){e.preventDefault(),Fe(ie.current.at(-1).key);return}(_J(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),ze())},He=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),Pe(t))},Ue=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&Pe(e.dataTransfer.files)},We=h.data?.workspace.name??`bot-lobby`,Ge=h.data?.branch??h.data?.workspace.branch,Ke=v&&T.id===`oracle`,qe=ye?`Write a message…`:N?n.step?.typed?n.step.placeholder:`Pick an answer above`:Ke?`The oracle is working. Enter steers it…`:T.placeholder,Je=e=>{p(null),e.current?.click()},Ye=Oe===`ask`?(0,B.jsx)(`div`,{ref:ke,children:(0,B.jsx)(eJ,{drawer:n,onExpand:D})},`ask`):Oe===`bar`?(0,B.jsx)(`div`,{ref:ke,className:`bubble-pane p-1`,style:{width:`max-content`},children:(0,B.jsxs)(`div`,{className:`cs-pbar`,children:[he.answer?(0,B.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq cs-acc`,onMouseDown:e=>e.preventDefault(),onClick:()=>{oJ(!1),requestAnimationFrame(()=>j.current?.focus({preventScroll:!0}))},children:[(0,B.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`}),(0,B.jsx)(`path`,{d:`M9.6 9.5a2.5 2.5 0 014.8.9c0 1.6-2.4 2-2.4 3.4M12 16.5h.01`})]}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:`Answer questions`}),(0,B.jsxs)(`span`,{className:`cs-ktag`,style:{"--k":`var(--primary)`},children:[n.left,` left`]})]}):null,he.plan?(0,B.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,"aria-keyshortcuts":`V`,onMouseDown:e=>e.preventDefault(),onClick:()=>E?.(),children:[(0,B.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z`}),(0,B.jsx)(`path`,{d:`M14 3v5h5M9 13h6M9 17h4`})]}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`View plan`}),(0,B.jsx)(`span`,{className:`cs-kb`,children:`V`})]}):null,he.knowledge?(0,B.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,onMouseDown:e=>e.preventDefault(),onClick:()=>{w(!0),requestAnimationFrame(()=>j.current?.focus({preventScroll:!0}))},children:[(0,B.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z`})}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Ask the knowledge`})]}):null]})},`bar`):Oe===`suggest`?(0,B.jsx)(jq,{listId:F,items:me?pe:je.current.items,triggerKind:me&&fe?fe.kind:je.current.kind,activeItemId:P?.id??null,onHighlightedItemChange:le,onSelect:Me},`suggest`):Oe===`attach`?(0,B.jsxs)(`div`,{role:`menu`,"aria-label":`Attach`,className:`bubble-pane flex flex-col p-1`,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=[...e.currentTarget.querySelectorAll(`[role='menuitem']`)];t[(t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:t.length-1))%t.length]?.focus()},children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`24ms`},onClick:()=>Je(re),children:[(0,B.jsx)(jp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload a file…`})]}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`12ms`},onClick:()=>Je(M),children:[(0,B.jsx)(Vp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload an image…`})]}),(0,B.jsx)(`div`,{className:`h-px`}),(0,B.jsx)(`div`,{className:`flex h-7 items-center px-2 text-[11.5px] text-(--bubble-muted)`,children:`Or drop files on the composer`})]},`attach`):Oe===`projects`?(0,B.jsx)(XK,{projects:t,tab:S,onBrowse:()=>p(`browse`),onClose:()=>p(null)},`projects`):(0,B.jsx)(tq,{tab:S,onClose:Te},`browse`);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`cs-scrim`,"data-open":_e||void 0,"aria-hidden":`true`}),(0,B.jsx)(`div`,{id:`app-dock`,ref:O,"data-shrunk":ye||void 0,onFocus:be,className:Y(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(24px,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap`,_&&`opacity-0`),hidden:!y,"aria-hidden":!y||void 0,inert:_||!y,children:(0,B.jsx)(iq,{ref:k,open:ve,size:De.current,shrunk:ye,morphing:xe,menu:Ye,className:`composer-shell pointer-events-auto`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(f?(e.preventDefault(),Te()):N&&(e.preventDefault(),oJ(!0)))},children:(0,B.jsxs)(`div`,{ref:te,className:`bubble-composer group/composer composer-box`,"data-dragging":u||void 0,"data-chat-composer-main-surface":`true`,onPointerDown:be,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:Ue,children:[(0,B.jsxs)(`div`,{ref:A,"data-chat-composer-surface":`true`,children:[(0,B.jsx)(tu,{initial:!1,children:o.length>0?(0,B.jsx)(Yd.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},"aria-label":`Attachments`,className:`composer-files flex max-w-full flex-wrap gap-2 overflow-hidden px-3.5 pt-3`,children:o.map(e=>(0,B.jsx)(yJ,{file:e,onRemove:()=>Fe(e.key)},e.key))},`files`):null}),(0,B.jsxs)(`div`,{className:`bubble-field`,children:[(0,B.jsx)(vq,{ref:ne,text:i}),(0,B.jsx)(`textarea`,{ref:j,id:`composer-text`,"aria-label":T.label,...T.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":me,"aria-controls":me?F:void 0}:{},...P?{"aria-activedescendant":Eq(F,P.id)}:{},value:i,onChange:e=>{a(e.target.value),se(e.target.selectionStart),p(null)},onSelect:e=>se(e.currentTarget.selectionStart),onKeyDown:Ve,onPaste:He,onScroll:e=>{ne.current&&(ne.current.scrollTop=e.currentTarget.scrollTop)},placeholder:qe,rows:1,className:`bubble-text bubble-input`})]}),(0,B.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:`bubble-tools composer-tools`,children:[(0,B.jsx)(`button`,{type:`button`,"data-composer-attach":!0,"aria-label":`Attach images, PDFs or files`,"aria-haspopup":`menu`,"aria-expanded":f===`attach`,"data-on":f===`attach`||void 0,"data-tip":`Attach a file`,onPointerDown:e=>e.preventDefault(),onClick:()=>we(`attach`),className:`bubble-iconbtn bubble-tip bubble-tool size-8 rounded-full`,style:{"--i":0},children:(0,B.jsx)(hm,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.7})}),(0,B.jsx)(`span`,{className:`bubble-tool flex min-w-0`,style:{"--i":1},children:(0,B.jsx)(YK,{projects:t,name:We,branch:Ge,open:f===`projects`||f===`browse`,onToggle:()=>we(`projects`)})}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(`span`,{className:`bubble-hints bubble-tool`,style:{"--i":2},"aria-hidden":`true`,children:me?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(xJ,{children:`↑`}),(0,B.jsx)(xJ,{children:`↓`}),`choose`,(0,B.jsx)(xJ,{children:`↵`}),`insert`]}):f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(xJ,{children:`Esc`}),`close`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(xJ,{children:`Shift`}),(0,B.jsx)(xJ,{children:`↵`}),`new line`]})}),(0,B.jsxs)(`span`,{"data-chat-composer-actions":`right`,className:`bubble-tool flex shrink-0 items-center gap-2`,style:{"--i":3},children:[Ke?(0,B.jsx)(bq,{onStop:()=>void Be()}):null,(0,B.jsx)(xq,{sending:c,disabled:!Re,steering:Ke,onSend:()=>void ze()})]})]})]}),(0,B.jsx)(`input`,{ref:re,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{Pe(e.target.files??[]),e.target.value=``}}),(0,B.jsx)(`input`,{ref:M,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach images`,onChange:e=>{Pe(e.target.files??[]),e.target.value=``}}),u?(0,B.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center rounded-[inherit] text-sm font-medium text-(--bubble-accent)`,children:`Drop to attach`}):null]})})}),(0,B.jsx)(tJ,{drawer:n,at:N?ee:-1,onAt:D})]})}function wJ({open:e,onOpenChange:t}){let n=qT(e,KT.help),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(``),l=(0,m.useId)(),u=()=>{a||(t(!1),i(``),c(``))},d=async()=>{let e=r.trim();if(e&&!a){o(!0),c(``);try{H((await I(`sessions.start`,{request:e})).notice),t(!1),i(``)}catch(e){c(e instanceof Error?e.message:`That did not work. Try again.`)}finally{o(!1)}}};return(0,B.jsx)(zT,{open:n,label:`New session`,description:`Starts a task in a session of its own, in the background.`,onOpenChange:e=>{e||u()},dismissOnBackdrop:!a,className:`max-w-[460px]`,children:(0,B.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,B.jsxs)(`div`,{className:`cs-dh`,children:[(0,B.jsx)(`h2`,{children:`New session`}),(0,B.jsx)(`p`,{className:`mt-[5px] text-[12.5px] leading-normal text-muted-foreground`,children:`It runs in the background and shows up in the sidebar; this window carries on with what it is doing.`})]}),(0,B.jsxs)(`div`,{className:`cs-db flex flex-col`,children:[(0,B.jsx)(`label`,{htmlFor:l,className:`mb-[7px] text-[12.5px] font-semibold`,children:`What should it do?`}),(0,B.jsx)(CB,{id:l,value:r,autoFocus:!0,disabled:a,"aria-invalid":s?!0:void 0,placeholder:`Fix the flaky login test, add dark mode to Settings…`,className:`cs-nsta max-h-60 min-h-[108px]`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),s?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:s}):null]}),(0,B.jsxs)(`div`,{className:`cs-df`,children:[(0,B.jsxs)(`span`,{className:`mr-auto flex items-center gap-1.5 text-xs text-[var(--faint)]`,children:[(0,B.jsx)(IT,{chord:`Ctrl+Enter`}),` to start`]}),(0,B.jsx)(OT,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,B.jsx)(OT,{onClick:()=>void d(),disabled:!r.trim()||a,"aria-busy":a,children:a?`Starting…`:`Start session`})]})]})})}function TJ(){let e=(e,t)=>(0,B.jsxs)(`filter`,{id:e,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:t,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,B.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.6`,result:`rimB`}),(0,B.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--hl)`},result:`hlc`}),(0,B.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,B.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.6`,result:`shB`}),(0,B.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--sh)`},result:`shc`}),(0,B.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`sh`}),(0,B.jsx)(`feMergeNode`,{in:`hl`})]})]});return(0,B.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,B.jsxs)(`defs`,{children:[e(`cs-baylit`,3.5),e(`cs-worklit`,3.2),(0,B.jsxs)(`filter`,{id:`cs-bayedge`,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`3.5`,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,B.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.3`,result:`tS1`}),(0,B.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--ehl)`},result:`tc`}),(0,B.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,B.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.3`,result:`bS1`}),(0,B.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--esh)`},result:`bc`}),(0,B.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`eh`}),(0,B.jsx)(`feMergeNode`,{in:`es`})]})]}),(0,B.jsxs)(`filter`,{id:`cs-tabdent`,x:`-10%`,y:`-45%`,width:`120%`,height:`190%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`1.6`,result:`b`}),(0,B.jsx)(`feColorMatrix`,{in:`b`,type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10`,result:`shape`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`sA`}),(0,B.jsx)(`feGaussianBlur`,{in:`sA`,stdDeviation:`1.5`,result:`sB`}),(0,B.jsx)(`feComposite`,{in:`sB`,in2:`shape`,operator:`in`,result:`sC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--tdsh)`},result:`shc`}),(0,B.jsx)(`feComposite`,{in:`shc`,in2:`sC`,operator:`in`,result:`sh`}),(0,B.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,B.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`hA`}),(0,B.jsx)(`feGaussianBlur`,{in:`hA`,stdDeviation:`1`,result:`hB`}),(0,B.jsx)(`feComposite`,{in:`hB`,in2:`shape`,operator:`in`,result:`hC`}),(0,B.jsx)(`feFlood`,{style:{floodColor:`var(--tdhl)`},result:`hlc`}),(0,B.jsx)(`feComposite`,{in:`hlc`,in2:`hC`,operator:`in`,result:`hl`}),(0,B.jsxs)(`feMerge`,{children:[(0,B.jsx)(`feMergeNode`,{in:`shape`}),(0,B.jsx)(`feMergeNode`,{in:`sh`}),(0,B.jsx)(`feMergeNode`,{in:`hl`})]})]}),(0,B.jsxs)(`filter`,{id:`cs-indgoo`,x:`-20%`,y:`-80%`,width:`140%`,height:`260%`,colorInterpolationFilters:`sRGB`,children:[(0,B.jsx)(`feGaussianBlur`,{stdDeviation:`1.6`}),(0,B.jsx)(`feColorMatrix`,{type:`matrix`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10`})]})]})})}function EJ({className:e,style:t}){return(0,B.jsxs)(`div`,{className:e,"aria-hidden":`true`,style:t,children:[(0,B.jsx)(`div`,{className:`cs-layer cs-edge`,children:(0,B.jsx)(`div`,{className:`cs-bb`})}),(0,B.jsx)(`div`,{className:`cs-layer cs-fill`,children:(0,B.jsx)(`div`,{className:`cs-bb`})})]})}function DJ(e,t=e){let[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>window.clearTimeout(o.current),[]);let s=(0,m.useCallback)(()=>{window.clearTimeout(o.current),r(!0)},[]),c=(0,m.useCallback)(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(()=>r(!1),e)},[e]),l=(0,m.useCallback)(()=>{window.clearTimeout(o.current),r(!0),o.current=window.setTimeout(()=>r(!1),t)},[t]),u=(0,m.useRef)(void 0);return(0,m.useEffect)(()=>()=>u.current?.(),[]),{open:n||i,flash:l,close:()=>{window.clearTimeout(o.current),r(!1)},handlers:{onPointerDown:e=>{if(e.pointerType!==`touch`)return;let t=e.currentTarget;if(n)e.target.closest(`[role='tab']`)&&c();else{window.clearTimeout(o.current),r(!0),u.current?.();let e=e=>{t.contains(e.target)||(window.clearTimeout(o.current),r(!1),u.current?.())};document.addEventListener(`pointerdown`,e,!0);let n=e=>{e.preventDefault(),e.stopPropagation()};t.addEventListener(`click`,n,{capture:!0,once:!0}),window.setTimeout(()=>t.removeEventListener(`click`,n,!0),500),u.current=()=>{document.removeEventListener(`pointerdown`,e,!0),u.current=void 0}}},onPointerEnter:e=>{e.pointerType!==`touch`&&s()},onPointerLeave:e=>{e.pointerType!==`touch`&&c()},onFocus:()=>a(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||a(!1)}}}}function OJ({id:e}){let t={width:15,height:15,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0};return e===`lobby`?(0,B.jsx)(`svg`,{...t,children:(0,B.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`})}):e===`tasks`?(0,B.jsxs)(`svg`,{...t,children:[(0,B.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,B.jsx)(`path`,{d:`M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11`})]}):e===`plan`?(0,B.jsxs)(`svg`,{...t,children:[(0,B.jsx)(`path`,{d:`M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3z`}),(0,B.jsx)(`path`,{d:`M9 3v15M15 6v15`})]}):e===`knowledge`?(0,B.jsxs)(`svg`,{...t,children:[(0,B.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 016.5 17H20`}),(0,B.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z`})]}):(0,B.jsxs)(`svg`,{...t,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,B.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 00.3 1.8l.1.1a2 2 0 11-2.8 2.8l-.1-.1a1.7 1.7 0 00-1.8-.3 1.7 1.7 0 00-1 1.5V21a2 2 0 11-4 0v-.1a1.7 1.7 0 00-1.1-1.5 1.7 1.7 0 00-1.8.3l-.1.1a2 2 0 11-2.8-2.8l.1-.1a1.7 1.7 0 00.3-1.8 1.7 1.7 0 00-1.5-1H3a2 2 0 110-4h.1a1.7 1.7 0 001.5-1.1 1.7 1.7 0 00-.3-1.8l-.1-.1a2 2 0 112.8-2.8l.1.1a1.7 1.7 0 001.8.3H9a1.7 1.7 0 001-1.5V3a2 2 0 114 0v.1a1.7 1.7 0 001 1.5 1.7 1.7 0 001.8-.3l.1-.1a2 2 0 112.8 2.8l-.1.1a1.7 1.7 0 00-.3 1.8V9a1.7 1.7 0 001.5 1H21a2 2 0 110 4h-.1a1.7 1.7 0 00-1.5 1z`})]})}var kJ=`cubic-bezier(0.3,1.2,0.5,1)`,AJ=`cubic-bezier(0.22,1,0.36,1)`,jJ=190,MJ=290,NJ=14,PJ=300;function FJ({tabs:e,activeId:t,onSelect:n}){let r=(0,m.useRef)(null),i=(0,m.useRef)({}),[a,o]=(0,m.useState)(346),s=(0,m.useRef)({placed:!1}),c=e.map(e=>e.label).join(`|`);(0,m.useLayoutEffect)(()=>{let e=()=>{let e=r.current?[...r.current.querySelectorAll(`[role='tab']`)]:[],t=e.length?Math.ceil(e.reduce((e,t)=>e+t.offsetWidth,0)+(e.length-1)*2)+8:346;o(t)};e(),document.fonts?.ready.then(e)},[c]);let l=(0,m.useCallback)(()=>{let e=r.current;if(!e)return;let n=t?i.current[t]:void 0;if(!n)return;let a=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,o=!s.current.placed,c=n.offsetLeft,l=e.offsetWidth-c-n.offsetWidth,u=s.current.left===void 0||c>s.current.left;for(let t of e.querySelectorAll(`.cs-tabind`)){let n=t.firstElementChild;if(n){if(o||a||e.offsetWidth===0){n.style.transition=`none`,n.style.left=`${c}px`,n.style.right=`${l}px`;continue}c!==s.current.left&&(n.style.transition=u?`left ${MJ}ms ${AJ} ${NJ}ms, right ${jJ}ms ${kJ}`:`left ${jJ}ms ${kJ}, right ${MJ}ms ${AJ} ${NJ}ms`,n.style.left=`${c}px`,n.style.right=`${l}px`,t.animate?.([{transform:`scaleY(1)`},{transform:`scaleY(0.84)`,offset:.35},{transform:`scaleY(1.05)`,offset:.75},{transform:`scaleY(1)`}],{duration:PJ,easing:`ease-in-out`}))}}e.offsetWidth>0&&(s.current={left:c,placed:!0})},[t]);(0,m.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>requestAnimationFrame(l));return()=>cancelAnimationFrame(e)},[l,a]);function u(r){if(r.key===`ArrowDown`&&!r.altKey){EE()&&r.preventDefault();return}let a=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!a||e.length===0)return;r.preventDefault();let o=r.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,s=e[(Math.max(0,e.findIndex(e=>e.id===o))+a+e.length)%e.length];OE.active=!0,OE.to=s.id,window.setTimeout(()=>{OE.active=!1,OE.to=void 0},3e3),n(s.id),i.current[s.id]?.focus({preventScroll:!0})}let d={"--wT":`${a}px`,"--hT":`40px`};return{vars:d,ghost:(0,B.jsx)(EJ,{className:`cs-gt`,style:d}),bay:(0,B.jsx)(`div`,{className:`cs-tbwrap`,style:d,children:(0,B.jsx)(`div`,{className:`cs-tbx`,children:(0,B.jsx)(`div`,{className:`cs-tbo`,"data-none":t?void 0:``,children:(0,B.jsxs)(`div`,{ref:r,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:u,className:`cs-track`,children:[(0,B.jsx)(`span`,{className:`cs-tabind cs-dent`,"aria-hidden":`true`,children:(0,B.jsx)(`i`,{})}),(0,B.jsx)(`span`,{className:`cs-tabind cs-tint`,"aria-hidden":`true`,children:(0,B.jsx)(`i`,{})}),(0,B.jsx)(`span`,{className:`cs-tabind cs-bevel`,"aria-hidden":`true`,children:(0,B.jsx)(`i`,{})}),e.map((e,n)=>(0,B.jsxs)(`a`,{ref:t=>{i.current[e.id]=t},role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":e.id===t,"aria-keyshortcuts":e.key,title:`${e.label} · ${e.key.replace(`+`,` `)}`,tabIndex:e.id===t||!t&&n===0?0:-1,className:`cs-tab`,style:{"--i":n},children:[(0,B.jsx)(`span`,{className:`cs-ti`,children:(0,B.jsx)(OJ,{id:e.id})}),e.label]},e.id))]})})})})}}function IJ({children:e}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(EJ,{className:`cs-gr`}),(0,B.jsx)(`div`,{className:Y(`cs-rbx`),children:e})]})}function LJ(e){return e.waiting>0&&e.alive?`asking`:e.status===`exited`||!e.alive?`exited`:e.busy||e.status===`working`?`working`:e.status===`starting`?`starting`:`idle`}function RJ(e,t){let n=e?.sessionId,r={id:`here`,name:e?.sessionName?.trim()||`This window`,where:`here`,state:e?.busy?`working`:`idle`,waiting:0,...n?{sessionId:n}:{}},i=(t?.background??[]).filter(e=>!n||e.sessionId!==n).map(e=>({id:`bg:${e.key}`,name:e.name,where:`background`,state:LJ(e),waiting:e.alive?e.waiting:0,key:e.key,...e.sessionId?{sessionId:e.sessionId}:{}})),a=new Set([n,...i.map(e=>e.sessionId)].filter(Boolean)),o=(t?.live??[]).filter(e=>!a.has(e.sessionId)).map(e=>({id:`live:${e.sessionId}`,name:e.name?.trim()||`Unnamed session`,where:`elsewhere`,state:`idle`,waiting:0,sessionId:e.sessionId}));i.sort((e,t)=>Number(e.state===`exited`)-Number(t.state===`exited`));let s=new Set([...a,...o.map(e=>e.sessionId)]),c=(t?.saved??[]).filter(e=>!e.archived&&!s.has(e.sessionId)).map(e=>({id:`saved:${e.sessionId}`,name:e.name,where:`saved`,state:`exited`,waiting:0,sessionId:e.sessionId,at:e.at}));return[r,...i,...o,...c]}var zJ=`app.sidebar.pinned`,BJ=()=>YR(zJ),VJ={w:244,h:`min(600px, calc(100vh - 40px))`},HJ=`cs-iconbtn cs-sm`;function UJ({label:e,hint:t,side:n=`bottom`,children:r}){return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:r}),(0,B.jsxs)(wI,{side:n,children:[e,` `,t?(0,B.jsx)(IT,{chord:t}):null]})]})}function WJ(){let e=vE(`status`).data;return RJ(e,eR(`sessions.list`,{},[`sessions`]).data)}async function GJ(e){if(e.where===`here`)return iE(`#/lobby`);if(e.where===`elsewhere`)return void H.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);await U(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId})&&iE(`#/lobby`)}function KJ(){return(0,m.useCallback)(GJ,[])}var qJ={entries:[]};async function JJ(e){let t=qJ.entries.filter(e=>e.where!==`elsewhere`),n=t.findIndex(e=>e.where===`here`);if(t.length<2||n<0)return void H.info(`No other session to switch to.`);qJ.flash?.(),await GJ(t[(n+e+t.length)%t.length])}function YJ({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,B.jsxs)(`span`,{className:`cs-badge`,children:[(0,B.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,B.jsx)(`path`,{d:`M9.1 9a3 3 0 015.8 1c0 2-3 2.5-3 4M12 17h.01`})]}),e.waiting,(0,B.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,B.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,B.jsx)(sp,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,B.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,B.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var XJ={here:`This window`,background:`Background`,elsewhere:`Other terminal`,saved:`Recent`};function ZJ(e){let t=e.key?{key:e.key}:{sessionId:e.sessionId};return U(`sessions.archive`,t,{undo:()=>void U(`sessions.archive`,{...t,archived:!1})})}function QJ({entry:e,onDone:t}){let[n,r]=(0,m.useState)(e.name),i=(0,m.useRef)(!1),a=async()=>{if(i.current)return;i.current=!0;let r=n.replace(/\s+/g,` `).trim();r&&r!==e.name&&await U(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,B.jsx)(`input`,{value:n,autoFocus:!0,maxLength:120,"aria-label":`New name for ${e.name}`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onBlur:()=>void a(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.current=!0,t())},className:`h-6 w-full min-w-0 rounded-md bg-[var(--fill)] px-1.5 text-[13px] text-foreground outline-none ring-2 ring-ring`})}function $J({entry:e,index:t}){let n=KJ(),[r,i]=(0,m.useState)(!1),a=e.state===`exited`||e.where===`elsewhere`,o=e.where===`here`||e.where===`background`,s=e.where===`background`&&e.state===`exited`&&!!e.key||e.where===`saved`,c=e.where===`saved`,l=o||s||c,u={"--i":t};return(0,B.jsxs)(`li`,{className:`cs-srow session-item`,children:[r?(0,B.jsx)(`div`,{className:`cs-sr`,"data-active":e.where===`here`||void 0,style:u,children:(0,B.jsx)(QJ,{entry:e,onDone:()=>i(!1)})}):(0,B.jsxs)(`button`,{type:`button`,"aria-current":e.where===`here`?`true`:void 0,"aria-label":e.where===`here`?`${e.name}, this window`:e.where===`elsewhere`?`${e.name}, in another terminal`:`Switch to ${e.name}`,title:e.name,"data-where":e.where,"data-state":e.state,"data-dim":a||void 0,onClick:()=>void n(e),onDoubleClick:e=>{o&&(e.preventDefault(),i(!0))},className:`cs-sr session-row`,style:u,children:[(0,B.jsx)(`span`,{className:`cs-grow`,children:e.name}),(0,B.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,l&&`cs-sstate`),children:(0,B.jsx)(YJ,{entry:e})})]}),!r&&l?(0,B.jsxs)(`span`,{className:`cs-sacts`,children:[o?(0,B.jsx)(UJ,{label:`Rename`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Rename ${e.name}`,onClick:()=>i(!0),className:`cs-sact`,children:(0,B.jsx)(ym,{"aria-hidden":`true`,className:`size-3.5`})})}):null,s?(0,B.jsx)(UJ,{label:`Archive`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Archive ${e.name}`,onClick:()=>void ZJ(e),className:`cs-sact`,children:(0,B.jsx)(Af,{"aria-hidden":`true`,className:`size-3.5`})})}):null,c?(0,B.jsx)(qL,{iconOnly:!0,className:`cs-sact`,side:`bottom`,label:`Delete ${e.name}`,icon:rh,variant:`destructive`,title:`Delete ${e.name}?`,description:`Its conversation file is removed for good. Archive it instead to keep it.`,confirmLabel:`Delete`,onConfirm:()=>void U(`sessions.delete`,{sessionId:e.sessionId})}):null]}):null]})}function eY({id:e,label:t,entries:n,start:r,archivable:i=!1}){let[a,o]=XR(`app.sidebar.${e}`),s=(0,m.useId)();return n.length===0?null:(0,B.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,B.jsxs)(`div`,{className:`cs-sh`,style:{"--i":r},children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":!a,"aria-controls":s,onClick:o,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left outline-none hover:text-foreground focus-visible:underline`,children:[(0,B.jsx)(`span`,{children:t}),a?(0,B.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,B.jsx)(Yf,{"aria-hidden":`true`,className:Y(`size-3 opacity-0 transition-[opacity,rotate] duration-150 group-hover/shelf:opacity-100 group-focus-within/shelf:opacity-100`,a&&`-rotate-90 opacity-100`)})]}),i?(0,B.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)await U(`sessions.archive`,e.key?{key:e.key}:{sessionId:e.sessionId})})(),className:`shrink-0 outline-none hover:text-foreground focus-visible:underline`,children:`Archive all`}):null]}),a?null:(0,B.jsx)(`ul`,{id:s,className:`flex flex-col`,children:n.map((e,t)=>(0,B.jsx)($J,{entry:e,index:r+1+t},e.id))})]})}function tY(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${XJ[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}function nY({query:e,onQuery:t,onNew:n}){return(0,B.jsxs)(`label`,{className:`cs-sr cs-search`,style:{"--i":0},children:[(0,B.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,B.jsx)(`path`,{d:`M21 21l-4.3-4.3`})]}),(0,B.jsx)(`input`,{type:`search`,value:e,"aria-label":`Search sessions`,placeholder:`Search`,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))}}),(0,B.jsx)(UJ,{label:`New session`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:n,className:`flex text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground`,children:(0,B.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M12 20h9`}),(0,B.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})})]})}function rY({query:e}){let t=WJ(),n=t.filter(t=>tY(t,e)),r=n.filter(e=>e.where===`here`&&e.state!==`exited`),i=n.filter(e=>e.where===`background`&&e.state!==`exited`),a=n.filter(e=>e.where===`elsewhere`),o=n.filter(e=>e.where!==`elsewhere`&&e.state===`exited`),s=1,c=e=>{let t=s;return s+=e+1,t},l=c(r.length),u=c(i.length);return(0,B.jsxs)(`nav`,{"aria-label":`Sessions list`,className:`cs-sblist`,children:[n.length===0?(0,B.jsxs)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):null,r.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`cs-sh`,style:{"--i":l},children:`This window`}),(0,B.jsx)(`ul`,{className:`flex flex-col`,children:r.map((e,t)=>(0,B.jsx)($J,{entry:e,index:l+1+t},e.id))})]}):null,i.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`Background`}),(0,B.jsx)(`ul`,{className:`flex flex-col`,children:i.map((e,t)=>(0,B.jsx)($J,{entry:e,index:u+1+t},e.id))})]}):!e.trim()&&t.length===1?(0,B.jsx)(`p`,{className:`cs-sh`,style:{"--i":u},children:`No other sessions are running.`}):null,(0,B.jsx)(eY,{id:`elsewhere`,label:`Other terminals`,entries:a,start:c(a.length)}),(0,B.jsx)(eY,{id:`ended`,label:`Recent`,entries:o,start:c(o.length),archivable:!0})]})}function iY({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,B.jsxs)(`div`,{className:`cs-sbfoot`,children:[(0,B.jsxs)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.kind===`settings`?`page`:void 0,"aria-keyshortcuts":r,className:`cs-sr`,style:{"--i":20},children:[(0,B.jsx)(OJ,{id:`settings`}),(0,B.jsx)(`span`,{className:`cs-grow`,children:`Settings`}),(0,B.jsx)(IT,{chord:r})]}),(0,B.jsxs)(`div`,{className:`cs-sr cs-tools`,style:{"--i":21},children:[(0,B.jsx)(kK,{hint:t.help??`Alt+H`,onHelp:n,className:HJ}),(0,B.jsx)(AK,{className:HJ}),(0,B.jsx)(MK,{className:HJ}),(0,B.jsx)(NK,{className:HJ})]})]})}function aY(e){let[t,n]=XR(zJ),r=DJ(160,1600);qJ.entries=WJ(),qJ.flash=r.flash;let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=t||r.open||o,l={"--wL":`${c?VJ.w:122}px`,"--hL":c?VJ.h:`40px`,"--sb-open-h":VJ.h},u=(0,m.useCallback)(()=>s(!0),[]);return{open:c,ghost:(0,B.jsx)(EJ,{className:`cs-gl`,style:l}),bay:(0,B.jsxs)(`div`,{className:`cs-sbwrap`,style:l,...r.handlers,children:[(0,B.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,className:`cs-sbx`,children:[(0,B.jsxs)(`div`,{className:`cs-sbmini`,inert:c,children:[(0,B.jsx)(UJ,{label:t?`Unpin sidebar`:`Pin sidebar`,hint:e.keys.sidebar,side:`bottom`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Sessions`,"aria-pressed":t,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:`cs-iconbtn`,children:(0,B.jsx)(OJ,{id:`lobby`})})}),(0,B.jsx)(UJ,{label:`New session`,side:`bottom`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-haspopup":`dialog`,onClick:u,className:`cs-iconbtn`,children:(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M12 20h9`}),(0,B.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})})}),(0,B.jsx)(UJ,{label:`Settings`,hint:e.keys.settings??`Alt+S`,side:`bottom`,children:(0,B.jsx)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.route.kind===`settings`?`page`:void 0,className:`cs-iconbtn`,children:(0,B.jsx)(OJ,{id:`settings`})})})]}),(0,B.jsxs)(`div`,{className:`cs-sbfull`,inert:!c,children:[(0,B.jsx)(nY,{query:i,onQuery:a,onNew:u}),(0,B.jsx)(rY,{query:i}),(0,B.jsx)(iY,{...e})]})]}),(0,B.jsx)(wJ,{open:o,onOpenChange:s})]})}}var oY=`bot-lobby.terminal.open`,sY=`bot-lobby.terminal.height`,cY=`bot-lobby.terminal.popup`,lY={start:280,min:140},uY=new Set,dY,fY,pY;function mY(e){try{return localStorage.getItem(e)}catch{return null}}function hY(e,t){try{localStorage.setItem(e,t)}catch{}}function gY(){for(let e of[...uY])e()}function _Y(e){return uY.add(e),()=>{uY.delete(e)}}function vY(){return dY??=mY(oY)===`1`,dY}function yY(){if(fY===void 0){let e=Number(mY(sY));fY=e>=lY.min?e:lY.start}return fY}function bY(e){dY=e,hY(oY,e?`1`:`0`),gY()}function xY(){bY(!vY())}function SY(e){fY=Math.max(lY.min,Math.round(e)),hY(sY,String(fY)),gY()}function CY(){return(0,m.useSyncExternalStore)(_Y,vY,()=>!1)}function wY(){return(0,m.useSyncExternalStore)(_Y,yY,()=>lY.start)}function TY(){return pY??=mY(cY)===`1`,pY}function EY(e){pY=e,hY(cY,e?`1`:`0`),gY()}function DY(){return(0,m.useSyncExternalStore)(_Y,TY,()=>!1)}var OY=`modulepreload`,kY=function(e){return`/`+e},AY={},jY=function(e){return e.pathname.endsWith(`.css`)},MY=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=kY(t,n);let r=s(t);if(r.href in AY)return;AY[r.href]=!0;let i=jY(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:OY,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},NY=(0,m.lazy)(()=>MY(()=>import(`./TerminalView-BBbYiw6R.js`),__vite__mapDeps([0,1,2,3]))),PY=`inline-flex size-6 items-center justify-center text-foreground/80 outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function FY({label:e,hint:t,children:n}){return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:n}),(0,B.jsxs)(wI,{side:`top`,children:[e,` `,t?(0,B.jsx)(IT,{chord:t}):null]})]})}function IY({hint:e,className:t}){let n=CY();return(0,B.jsx)(FY,{label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:xY,className:t,children:(0,B.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M4 17l6-6-6-6M12 19h8`})})})})}function LY(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await I(`terminal.list`,{})),i(``)}catch(e){i(e instanceof Error?e.message:`The terminals could not be read.`)}},[]);return(0,m.useEffect)(()=>{e&&a()},[e,a]),{list:t,error:r,reload:a}}function RY({height:e,max:t}){let n=(0,m.useRef)(null);return(0,B.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":lY.min,"aria-valuemax":t,className:`terminal-edge`,onPointerDown:t=>{t.button===0&&(t.currentTarget.setPointerCapture?.(t.pointerId),n.current={y:t.clientY,height:e},document.documentElement.dataset.resizing=`row`)},onPointerMove:e=>{n.current&&SY(Math.min(t,n.current.height+n.current.y-e.clientY))},onPointerUp:()=>{n.current=null,delete document.documentElement.dataset.resizing},onPointerCancel:()=>{n.current=null,delete document.documentElement.dataset.resizing},onDoubleClick:()=>SY(lY.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),SY(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function zY({toggleKey:e}){let t=CY(),n=DY(),r=wY(),i=qT(t&&n,KT.sheet),{list:a,error:o,reload:s}=LY(t),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(()=>Math.round(window.innerHeight*.7)),h=a?.terminals??[],g=h.find(e=>e.id===c)??h.at(-1);(0,m.useEffect)(()=>{let e=()=>p(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let _=(0,m.useCallback)(async()=>{d(!0);try{let e=await I(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){H.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),v=(0,m.useCallback)(async e=>{try{await I(`terminal.close`,{id:e})}catch{}await s()},[s]);(0,m.useEffect)(()=>{if(!t||h.length<2)return;let e=e=>{if(!e.ctrlKey||e.altKey||e.metaKey||e.key!==`PageDown`&&e.key!==`PageUp`)return;e.preventDefault();let t=Math.max(0,h.findIndex(e=>e.id===g?.id)),n=h[(t+(e.key===`PageDown`?1:-1)+h.length)%h.length];l(n.id)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t,h,g?.id]);let y=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){y.current=!1;return}!a||!a.available||a.terminals.length>0||y.current||u||(y.current=!0,_())},[t,a,u,_]);let b=t&&!n?Math.min(r,f):0;if((0,m.useEffect)(()=>{let e=document.documentElement;return b?e.style.setProperty(`--terminal-h`,`${b}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[b]),!t)return null;let x=(0,B.jsx)(BY,{list:a,error:o,terminals:h,shown:g,busy:u,popup:n,toggleKey:e,onPick:l,onStart:()=>void _(),onEnd:e=>void v(e),onReload:()=>void s()});return n?(0,B.jsx)(zT,{open:i,onOpenChange:e=>{e||bY(!1)},label:`Terminal`,className:`terminal-pop h-[min(72svh,40rem)] max-h-none max-w-5xl`,onEscapeKeyDown:e=>{e.target?.closest?.(`.xterm`)&&e.preventDefault()},children:(0,B.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:x})}):(0,B.jsxs)(`section`,{id:`terminal-drawer`,"aria-label":`Terminal`,className:`terminal-drawer relative flex shrink-0 border-t border-border`,style:{height:Math.min(r,f)},children:[(0,B.jsx)(RY,{height:Math.min(r,f),max:f}),x]})}function BY({list:e,error:t,terminals:n,shown:r,busy:i,popup:a,toggleKey:o,onPick:s,onStart:c,onEnd:l,onReload:u}){let d=(0,B.jsxs)(`div`,{className:`terminal-tools pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,B.jsx)(FY,{label:`New terminal`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:PY,children:(0,B.jsx)(Dm,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,B.jsx)(FY,{label:`End this terminal`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:PY,children:(0,B.jsx)(rh,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,B.jsx)(FY,{label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>EY(!a),className:PY,children:(0,B.jsx)(xm,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,B.jsx)(FY,{label:`Hide terminal`,hint:o,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>bY(!1),className:PY,children:a?(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`}):(0,B.jsx)(Yf,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,B.jsx)(B.Fragment,{children:e&&!e.available?(0,B.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,B.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,B.jsxs)(m.Suspense,{fallback:(0,B.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,B.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`No terminal is running. Start one with New terminal.`}):null,n.map(e=>(0,B.jsx)(NY,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,B.jsx)(`nav`,{"aria-label":`Terminals`,className:Y(`flex w-36 shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-border px-1 pb-1`,a?`pt-2`:`pt-10`),children:n.map(e=>(0,B.jsxs)(`button`,{type:`button`,"aria-current":e.id===r?.id?`true`:void 0,onClick:()=>s(e.id),className:Y(`flex h-6 min-w-0 items-center gap-1.5 rounded px-1.5 text-left text-xs text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent aria-[current=true]:text-foreground`,!e.alive&&`opacity-60`),children:[(0,B.jsx)(Zm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,B.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,B.jsx)(Zm,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,B.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,B.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var VY=(0,m.lazy)(()=>MY(()=>import(`./CodeSurface-B4OE4fFl.js`),__vite__mapDeps([4,1,2]))),HY=`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-accent aria-pressed:text-foreground`;function UY({label:e,hint:t,children:n}){return(0,B.jsxs)(SI,{children:[(0,B.jsx)(CI,{asChild:!0,children:n}),(0,B.jsxs)(wI,{side:`bottom`,children:[e,` `,t?(0,B.jsx)(IT,{chord:t}):null]})]})}function WY({hint:e,className:t}){let{open:n}=dL();return(0,B.jsx)(UY,{label:`Code and changes`,hint:e,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?lL():cL(),className:t,children:(0,B.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M16 18l6-6-6-6M8 6l-6 6 6 6`})})})})}var GY={modified:{letter:`M`,word:`Modified`,tone:`text-warning`},added:{letter:`A`,word:`Added`,tone:`text-success`},untracked:{letter:`U`,word:`New, not committed`,tone:`text-success`},deleted:{letter:`D`,word:`Deleted`,tone:`text-destructive`},renamed:{letter:`R`,word:`Renamed`,tone:`text-primary`}};function KY(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function qY({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,B.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,B.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,B.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function JY(){let[e,t]=(0,m.useState)(()=>document.documentElement.classList.contains(`dark`));return(0,m.useEffect)(()=>{let e=document.documentElement,n=new MutationObserver(()=>t(e.classList.contains(`dark`)));return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[]),e}function YY({changes:e,loading:t,error:n,current:r,onPick:i,onRefresh:a}){let[o,s]=(0,m.useState)(``),c=e?.files??[],l=c.reduce((e,t)=>({additions:e.additions+(t.additions??0),deletions:e.deletions+(t.deletions??0)}),{additions:0,deletions:0});function u(e){e.preventDefault();let t=o.trim();t&&(i(t),s(``))}return(0,B.jsxs)(`nav`,{"aria-label":`Changed files`,className:`code-rail flex w-64 shrink-0 flex-col border-r border-border max-md:w-52`,children:[(0,B.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,B.jsxs)(`label`,{className:`flex h-8 items-center gap-2 rounded-md border border-input bg-background px-2 transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20`,children:[(0,B.jsx)(Vm,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,B.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),"aria-label":`Open a file by path`,placeholder:`Open a file by path…`,spellCheck:!1,autoComplete:`off`,className:`h-full min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:font-sans placeholder:text-muted-foreground`})]})}),(0,B.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,B.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,B.jsx)(qY,{change:l,className:`ml-auto`}),(0,B.jsx)(UY,{label:`Read the changes again`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y(HY,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,B.jsx)(km,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,B.jsxs)(`ul`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-1.5 pb-2`,children:[c.map(e=>{let{dir:t,name:n}=KY(e.path),a=GY[e.status];return(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),"aria-current":e.path===r?`true`:void 0,title:e.from?`${e.from} → ${e.path}`:e.path,className:`group/row flex h-7 w-full min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-[0.8125rem] outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent`,children:[(0,B.jsx)(`span`,{"aria-label":a.word,className:Y(`w-3 shrink-0 text-center font-mono text-[0.6875rem] font-semibold`,a.tone),children:a.letter}),(0,B.jsxs)(`span`,{className:Y(`min-w-0 flex-1 truncate`,e.status===`deleted`&&`text-muted-foreground line-through decoration-muted-foreground/50`),children:[n,t?(0,B.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,B.jsx)(qY,{change:e})]})},e.path)}),e&&!e.git?(0,B.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`This folder is not a git repository, so there are no changes to show. Open a file by its path above.`}):null,e?.git&&c.length===0?(0,B.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,B.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function XY(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(0),c=(0,m.useCallback)(async e=>{let t=++s.current;o(!0),i(void 0);try{let r=await I(`code.read`,{path:e});t===s.current&&n(e=>({file:r,version:(e?.version??0)+1}))}catch(e){t===s.current&&(n(void 0),i(e instanceof Error?e.message:String(e)))}finally{t===s.current&&o(!1)}},[]);return(0,m.useEffect)(()=>{e?c(e):(s.current++,n(void 0),i(void 0))},[e,c]),{loaded:t,setLoaded:n,error:r,loading:a,reload:()=>e&&c(e)}}function ZY({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=eR(`code.changes`,{},[`lobby`,`tasks`]),[c,l]=(0,m.useState)(e),[u,d]=(0,m.useState)(t??`code`),{loaded:f,setLoaded:p,error:h,loading:g,reload:_}=XY(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=vL(),ee=yL(),D=JY(),O=f?.file,k=v!==void 0&&v!==O?.contents;(0,m.useEffect)(()=>a(k),[k,a]),(0,m.useEffect)(()=>{if(!e||e===c){t&&d(t);return}A({kind:`open`,path:e})},[n]),(0,m.useEffect)(()=>{if(!c&&s.data?.files[0]){let e=s.data.files.find(e=>e.status!==`deleted`)??s.data.files[0];l(e.path),t||d(`diff`)}},[s.data]),(0,m.useEffect)(()=>{O&&O.path!==c&&l(O.path)},[O?.path]),(0,m.useEffect)(()=>{o&&A({kind:`close`})},[o]);function te(e){if(T(void 0),C(!1),e.kind===`close`){i();return}y(void 0),l(e.path)}function A(e){(e.kind!==`open`||e.path!==c)&&(k?T(e):te(e))}async function j(e=!1){if(O&&v!==void 0&&!b){x(!0);try{let t=await I(`code.save`,{path:O.path,contents:v,mtimeMs:O.mtimeMs,...e?{force:!0}:{}});return p(e=>e&&{...e,file:{...e.file,contents:v,mtimeMs:t.mtimeMs,size:v.length}}),y(void 0),C(!1),s.reload(),w&&te(w),!0}catch(e){return e instanceof Se&&e.code===`conflict`?C(!0):H.error(e instanceof Error?e.message:`The file could not be saved.`),!1}finally{x(!1)}}}function ne(e){(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`s`?(e.preventDefault(),e.stopPropagation(),j()):r&&lK(e.nativeEvent,r)&&(e.preventDefault(),A({kind:`close`}))}let re=O?.change,M=!!re||O?.original!==void 0,ie=M?u:`code`,{dir:ae,name:oe}=KY(O?.path??c??``),se=!!(O?.exists&&O.contents!==void 0),ce=re?GY[re.status]:void 0;return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:ne,children:[(0,B.jsx)(YY,{changes:s.data,loading:s.loading,error:s.error,current:O?.path??c,onPick:e=>A({kind:`open`,path:e}),onRefresh:()=>{s.reload(),k||_()}}),(0,B.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,B.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[ce?(0,B.jsx)(`span`,{title:ce.word,className:Y(`font-mono text-xs font-semibold`,ce.tone),children:ce.letter}):(0,B.jsx)(Tp,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,B.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:O?.path??c,children:[ae?(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[ae,`/`]}):null,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:oe}),k?(0,B.jsx)(`span`,{"aria-label":`unsaved`,title:`Unsaved edits`,className:`ml-1.5 inline-block size-1.5 -translate-y-0.5 rounded-full bg-foreground/70`}):null]}),re?(0,B.jsx)(qY,{change:re}):null]}):(0,B.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),M?(0,B.jsx)(hE,{label:`View`,value:ie,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,ie===`diff`?(0,B.jsx)(UY,{label:ee===`split`?`Unified diff`:`Side by side`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":ee===`split`,onClick:()=>_L(ee===`split`?`unified`:`split`),className:HY,children:ee===`split`?(0,B.jsx)(Lm,{"aria-hidden":`true`,className:`size-4`}):(0,B.jsx)(_p,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,B.jsx)(UY,{label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>gL(!E),className:HY,children:(0,B.jsx)(th,{"aria-hidden":`true`,className:`size-4`})})}),(0,B.jsx)(UY,{label:`Save`,hint:`Ctrl+S`,children:(0,B.jsxs)(OT,{size:`sm`,variant:k?`default`:`outline`,disabled:!k||b,onClick:()=>void j(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,B.jsx)(zm,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,B.jsx)(UY,{label:`Close`,hint:r,children:(0,B.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>A({kind:`close`}),className:HY,children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,B.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,B.jsx)(_m,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[oe,` has unsaved edits.`]}),(0,B.jsx)(OT,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,B.jsx)(OT,{size:`xs`,variant:`outline`,onClick:()=>te(w),children:`Discard`}),(0,B.jsx)(OT,{size:`xs`,onClick:()=>void j(),disabled:b,children:`Save`})]}):null,S?(0,B.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs`,children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[oe,` changed on disk since you opened it, maybe by an agent.`]}),(0,B.jsx)(OT,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,B.jsx)(OT,{size:`xs`,onClick:()=>void j(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,B.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,B.jsx)(`p`,{role:`alert`,className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:h}):c?O?O.binary||O.tooLarge?(0,B.jsx)(`p`,{className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:O.binary?`This is a binary file, so it is not shown.`:`This file is too large to show here.`}):!O.exists&&ie===`code`?(0,B.jsxs)(`p`,{className:`m-auto flex max-w-sm flex-col items-center gap-2 px-6 text-center text-sm text-muted-foreground`,children:[(0,B.jsx)(Np,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,B.jsx)(m.Suspense,{fallback:(0,B.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,B.jsx)(VY,{path:O.path,version:`${f.version}`,contents:O.contents??``,draft:v,original:O.original,mode:ie,layout:ee,wrap:E,dark:D,readOnly:!se,onDraft:y})}):(0,B.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,B.jsx)(QY,{loading:s.loading})})]})]})}function QY({loading:e}){return(0,B.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,B.jsx)(Dp,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e?`Reading the changes…`:`Pick a changed file, open one by its path, or click a file name in the Lobby chat.`})]})}function $Y({codeKey:e}){let{open:t,path:n,mode:r,request:i}=dL(),a=qT(t,KT.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,B.jsx)(zT,{open:a,onOpenChange:e=>{e||(o?u():lL())},label:`Code viewer`,className:`code-pop h-[min(86svh,52rem)] max-h-none max-w-6xl`,onEscapeKeyDown:e=>{o&&(e.preventDefault(),u())},children:t?(0,B.jsx)(ZY,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:lL,onDirtyChange:s,closeAsked:c}):null})}function eX(e){let t=e.match(/[#&?]?token=([^&\s#]+)/i);if(t?.[1])return decodeURIComponent(t[1]);let n=e.trim();return n&&!n.includes(`/`)&&!n.includes(` `)?n:void 0}function tX(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1);async function o(e){a(!0),r(void 0),e&&(window.location.hash=`token=${encodeURIComponent(e)}`),await Te()?window.location.reload():(r(e?`That link did not sign in. Copy the link from Pi and try again.`:`Paste the link from Pi below.`),a(!1))}function s(t){t.preventDefault(),o(eX(e))}return(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,B.jsxs)(`form`,{onSubmit:s,className:`cs-dlg w-full max-w-[420px]`,children:[(0,B.jsxs)(`div`,{className:`cs-dh flex items-center gap-3.5 pt-[22px]`,children:[(0,B.jsx)(`span`,{className:`cs-drop`,"aria-hidden":`true`,children:(0,B.jsx)(Gp,{className:`size-[18px]`})}),(0,B.jsx)(`h1`,{children:`Sign in to bot-lobby`})]}),(0,B.jsxs)(`div`,{className:`cs-db`,children:[(0,B.jsxs)(`p`,{className:`mb-3.5 text-[12.5px] leading-relaxed text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,B.jsx)(`code`,{className:`cs-cd`,children:`/bot-lobby web`}),` to see it again). Paste it here.`]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Lobby link or token`}),(0,B.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0,placeholder:`http://127.0.0.1:7347/#token=…`,className:`cs-inp`})]}),n?(0,B.jsx)(`p`,{role:`alert`,className:`mt-2.5 text-[12.5px] text-[var(--bad)]`,children:n}):null]}),(0,B.jsxs)(`div`,{className:`cs-df`,children:[(0,B.jsx)(OT,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,B.jsx)(OT,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var nX=`plan:`,rX=`bot-lobby:plan-put-away`,iX=e=>e.startsWith(nX);function aX(){try{let e=JSON.parse(sessionStorage.getItem(rX)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`number`):[]}catch{return[]}}function oX(e){let t=e?.messages.at(-1);if(e&&!e.busy&&t?.role===`planner`&&t.questions?.length)return{id:`${nX}${t.at}`,kind:`questionnaire`,createdAt:t.at,from:`planner`,payload:{round:Math.max(e.round,1),limit:e.limit,questions:t.questions.map(e=>({question:e.text,header:e.from,options:e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}))}))}}}function sX(e,t){let n=e.payload.questions??[];return(t.answers??[]).map(e=>`${vR(n[e.questionIndex]?.header??``)}: ${e.question} ${e.answer}`.trim()).join(`
|
|
112
112
|
`)}function cX(){let e=eR(`planner.get`,{},[`planner`]),[t,n]=(0,m.useState)(aX),r=oX(e.data),i=(0,m.useMemo)(()=>r&&!t.includes(r.createdAt)?[r]:[],[r?.id,t.join(`,`)]);return{prompts:i,answer:(0,m.useCallback)(async(t,n)=>{let r=i.find(e=>e.id===t);r&&(await I(`planner.send`,{text:sX(r,n)}),e.reload())},[i,e]),dismiss:(0,m.useCallback)(async e=>{let t=Number(e.slice(5));n(e=>{let n=[...e,t].slice(-20);try{sessionStorage.setItem(rX,JSON.stringify(n))}catch{}return n})},[])}}var lX=2;function uX(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function dX(e){try{return JSON.parse(e)}catch{return}}function fX(e,t){switch(e.type){case`hello`:t.onHello?.(e.versions);return;case`changed`:t.onChanged?.(e.topic,e.version);return;case`feed`:t.onFeed?.({activity:e.activity,thoughts:e.thoughts,chat:e.chat});return;case`reply`:t.onReply?.(e.text);return;case`notice`:t.onNotice?.(e.text,e.level)}}function pX(e,t=uX){let n=t(P(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===lX?`offline`:`connecting`),n.onmessage=t=>{let n=dX(t.data);n&&fX(n,e)},()=>n.close()}var mX=2e3,hX=()=>I(`projects.list`,{});async function gX(){let e;try{e=me()}catch{return}if(e&&!be(e))try{ye((await hX()).projects)}catch{}}function _X(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{me()}catch{N.onStatus({connection:`offline`});return}e.current=pX({onHello:e=>{N.onHello(e),gX()},onChanged:(e,t)=>N.onChanged(e,t),onFeed:e=>N.onFeedDelta(e),onReply:e=>N.onReplyDelta(e),onNotice:(e,t)=>H[t](e),onConnection:e=>{N.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{xe(hX).catch(()=>!1).finally(n)},mX))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var vX=`bot-lobby.recoveredAt`,yX;function bX(e,t=xX()){try{yX===void 0&&(yX=Number(t?.getItem(vX)??0))}catch{yX??=0}if(yX!==void 0&&e<=yX)return!1;yX=e;try{t?.setItem(vX,String(e))}catch{}return!0}function xX(){try{return globalThis.sessionStorage}catch{return}}function SX(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&bX(t)&&H.success(n)},[t,n])}function CX(){let e=vE(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await I(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await I(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}var wX=class extends m.Component{state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`bot-lobby: a tab failed to draw`,e,t.componentStack)}render(){let{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,()=>this.setState({error:void 0})):(0,B.jsxs)(`div`,{role:`alert`,className:`cs-pg cs-blank`,children:[(0,B.jsx)(`h2`,{children:`This page hit a snag`}),(0,B.jsx)(`p`,{children:e.message||String(e)}),(0,B.jsx)(`p`,{children:(0,B.jsx)(`button`,{type:`button`,className:`cs-kc`,onClick:()=>this.setState({error:void 0}),children:`Try again`})})]}):this.props.children}};function TX(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?iE(`#/settings`):e===`thinking`?t.kind===`tab`&&t.tab===`lobby`?YR(`lobby.thinking`):iE(rE(`lobby`)):e===`nextSession`||e===`prevSession`?JJ(e===`nextSession`?1:-1):e===`sidebar`?i():e===`terminal`?xY():e===`code`?uL():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?YR(ZR):iE(rE(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&U(`planner.save`,{})}var EX=`cs-iconbtn cs-sq10`,DX=2500;function OX(e){let[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(!1);return e===`live`&&(r.current=!0),(0,m.useEffect)(()=>{if(e!==`connecting`||!r.current)return n(!1);let t=setTimeout(()=>n(!0),DX);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function kX({connection:e,onRetry:t}){return OX(e)?(0,B.jsx)(lE,{onRetry:t}):null}var AX={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{AX.route=++AX.tick}),document.addEventListener(`focusin`,()=>{AX.focus=++AX.tick});var jX=()=>AX.focus>AX.route;function MX(e){return e.kind===`tab`?e.tab:e.kind}function NX(){let e=aE(),t=vE(`status`);vE(`lobby`);let{prompts:n,loading:r,answer:i,dismiss:a}=CX(),o=cX(),s=(0,m.useMemo)(()=>[...n,...o.prompts],[n,o.prompts]),c=Xq(s,(0,m.useCallback)((e,t)=>iX(e)?o.answer(e,t):i(e,t),[i,o.answer]),(0,m.useCallback)(e=>iX(e)?o.dismiss(e):a(e),[a,o.dismiss])),{connection:l,signedOut:u}=_E(),[d,f]=(0,m.useState)(!1),p=cJ();(0,m.useEffect)(()=>{s.length===0&&!r&&oJ(!1)},[s.length,r]);let h=(0,m.useRef)(null),g=_X();bB();let _=t.data;SX(_);let v=!!_&&!u;(0,m.useEffect)(()=>{v&&Be()},[v]);let y=_?.tabs??[],b=_?.keys??[],x=e.kind===`tab`?e.tab:void 0,S=(0,m.useCallback)(e=>iE(rE(e)),[]),C=(0,m.useCallback)(e=>{if(y.length===0)return;let t=Math.max(0,y.findIndex(e=>e.id===x)),n=y[(t+e+y.length)%y.length];n&&iE(rE(n.id))},[y,x]),w=(0,m.useCallback)(()=>f(e=>!e),[]),T=HK(),E=(0,m.useCallback)(()=>BJ(),[]),ee=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||_?.panels?.[t]!==!1)&&TX(t,nE(window.location.hash)??e,w,C,E)},[e,w,C,E,_?.panels]),D=S,O=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||h.current?.contains(e)===!0||e.closest(`.terminal-pop`)?!0:e.closest(`[data-state='closed']`)!==null},[]);gK({enabled:!!_,keys:b,tabs:y,insideApp:O,onAction:ee,onTab:D});let k=(0,m.useCallback)(()=>N.onHello({}),[]),te=e.kind===`tab`?e.tab:e.kind,A=!!_;(0,m.useEffect)(()=>{if(!A)return;let e=OE.active&&OE.to===te;if(OE.active=!1,OE.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(jX()||document.querySelector(`[role='dialog']:not([data-state='closed'])`))return;let e=document.getElementById(`composer-text`);!window.matchMedia(`(pointer: coarse)`).matches&&e&&!e.disabled&&!e.closest(`[inert]`)?e.focus({preventScroll:!0}):document.activeElement?.id!==`composer-text`&&document.getElementById(`main`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[te,A]);let j=Object.fromEntries(b.map(e=>[e.action,e.label])),ne=FJ({tabs:y,activeId:x,onSelect:S}),re=aY({route:e,keys:j,onHelp:w});return u||!_?(0,B.jsxs)(`div`,{ref:h,className:`cs-frame`,children:[(0,B.jsx)(TJ,{}),(0,B.jsx)(`main`,{id:`main`,tabIndex:-1,className:`cs-main`,children:u?(0,B.jsx)(tX,{}):t.error?(0,B.jsx)(cE,{message:t.error,onRetry:k}):(0,B.jsx)(sE,{})}),(0,B.jsxs)(IJ,{children:[(0,B.jsx)(jK,{className:EX,side:`bottom`}),(0,B.jsx)(AK,{className:EX,side:`bottom`})]})]}):(0,B.jsxs)(`div`,{ref:h,className:`cs-frame`,"data-sb":re.open?`open`:`closed`,"data-tb":`open`,children:[(0,B.jsx)(TJ,{}),(0,B.jsxs)(`div`,{className:`cs-body`,children:[(0,B.jsx)(kX,{connection:l,onRetry:g}),(0,B.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||yE(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||DE()&&e.preventDefault()},role:x?`tabpanel`:void 0,"aria-labelledby":x?`tab-${x}`:void 0,className:`cs-main surface`,children:(0,B.jsx)(Yd.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.17,ease:[.22,1,.36,1]},className:`flex min-h-0 flex-1 flex-col`,children:(0,B.jsx)(wX,{children:rK(e)})},MX(e))}),(0,B.jsx)(wX,{fallback:(e,t)=>(0,B.jsxs)(`div`,{role:`alert`,className:`pointer-events-auto absolute inset-x-0 bottom-6 z-30 mx-auto w-fit rounded-xl bg-card px-4 py-2 text-sm shadow`,children:[`The message box hit a snag: `,e.message,` `,(0,B.jsx)(`button`,{type:`button`,className:`font-medium text-primary underline`,onClick:t,children:`Try again`})]}),children:(0,B.jsx)(CJ,{route:e,projects:T,drawer:c,drawerOpen:s.length>0&&!p})})]}),(0,B.jsx)(zY,{toggleKey:j.terminal??"Ctrl+`"})]}),re.ghost,ne.ghost,(0,B.jsxs)(IJ,{children:[(0,B.jsx)(WY,{hint:j.code,className:EX}),(0,B.jsx)(IY,{hint:j.terminal,className:EX})]}),re.bay,ne.bay,(0,B.jsx)(WK,{projects:T}),(0,B.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`}),(0,B.jsx)($Y,{codeKey:b.find(e=>e.action===`code`)?.key}),(0,B.jsx)(JI,{}),(0,B.jsx)(DK,{open:d,onOpenChange:f,keys:b,tabs:y})]})}async function PX(e){switch(e){case`status`:return I(`status.get`,{});case`lobby`:return I(`lobby.snapshot`,{});case`prompts`:return I(`prompts.list`,{});default:return}}var FX=[`status`,`lobby`,`prompts`];function IX(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await Te(),e&&(N.markUsed(FX,PX),t(!0))})(),()=>{e=!1}},[]),e}function LX(){return IX()?(0,B.jsx)(NX,{}):(0,B.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,B.jsx)(sE,{})})}var RX={info:Up,success:ap,warning:ah,error:pp},zX={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`},BX={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function VX(){let{item:e,waiting:t}=ff(),n=YT(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>uf(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,B.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed z-[1050] flex justify-center px-4`,style:{bottom:`calc(var(--composer-h, 0px) + var(--terminal-h, 0px) + 0.25rem)`,left:`var(--composer-x, 0px)`,width:`var(--composer-w, 100%)`},children:(0,B.jsx)(tu,{mode:`wait`,children:r?(0,B.jsxs)(Yd.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-2.5 glass-toast rounded-lg px-3.5 py-2.5 text-sm`,children:[(0,B.jsx)(HX,{kind:e.kind}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,B.jsxs)(`span`,{className:`sr-only`,children:[zX[e.kind],` `]}),e.message]}),e.action?(0,B.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-outline -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border px-2.5 text-xs font-medium text-foreground transition-[box-shadow,scale] active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>{e.action?.onClick(),uf(e.id)},children:e.action.label}):null]},e.id):null})})}function HX({kind:e}){let t=RX[e];return(0,B.jsx)(t,{"aria-hidden":`true`,className:Y(`size-4 shrink-0`,BX[e])})}(0,tf.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(m.StrictMode,{children:(0,B.jsx)($B,{children:(0,B.jsx)(cu,{reducedMotion:`user`,children:(0,B.jsxs)(xI,{children:[(0,B.jsx)(LX,{}),(0,B.jsx)(VX,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{P as i,lK as n,I as r,MY as t};
|