@a-t-h-i/bot-lobby 0.6.73 → 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-3n1E__cD.js → CodeSurface-B4OE4fFl.js} +1 -1
- package/webui/dist/assets/{TerminalView-BDSx8e_Y.js → TerminalView-BBbYiw6R.js} +1 -1
- package/webui/dist/assets/{index-4ZW1egtb.js → index-BwV-TLHH.js} +6 -6
- package/webui/dist/assets/index-xsQmwvq1.css +2 -0
- package/webui/dist/build.json +11 -11
- package/webui/dist/index.html +2 -2
- package/webui/dist/assets/index-BEsCUPUK.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}"] {
|
|
@@ -89,7 +89,7 @@ Error generating stack: `+e.message+`
|
|
|
89
89
|
`)),n=[]),n.push(i);return t.push(n.join(`
|
|
90
90
|
`)),t}function FI(e,t,n=!1){let r=t?.start?.offset,i=t?.end?.offset;if(r===void 0||i===void 0)return;let a=e.slice(r,i);if(!n){let e=a.match(/^`+/)?.[0];return e&&a.endsWith(e)?a.slice(e.length,-e.length):a}let o=a.match(/^ {0,3}(`{3,}|~{3,})[^\r\n]*(?:\r\n|\n|\r)/);if(!o)return a;let s=a.slice(o[0].length),c=RegExp(`^ {0,3}${o[1][0]}{${o[1].length},}[ \\t]*$`,`m`).exec(s);return c?s.slice(0,c.index):s}function II(e,t){return!e&&!t}async function LI(e,t){if(!t)throw Error(`Clipboard is unavailable. Select the code and copy it manually.`);await t.writeText(e)}var RI,zI=new Set;function BI(){for(let e of[...zI])e()}function VI(e){RI=e,BI()}function HI(){RI&&(RI=void 0,BI())}function UI(e){return zI.add(e),()=>{zI.delete(e)}}var WI=/\.(png|jpe?g|gif|webp|avif|svg)$/i;function GI(e){if(!e)return!1;let t=e.split(/[?#]/,1)[0]??``;return WI.test(t)||/\/files\/preview\/attachments\//.test(t)}function KI(e){return t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),VI(e))}}var qI={type:`spring`,stiffness:520,damping:32,mass:.7};function JI(){let e=(0,m.useSyncExternalStore)(UI,()=>RI,()=>void 0),t=qT(!!e,KT.image),n=Jd(),[r,i]=(0,m.useState)(!1);(0,m.useEffect)(()=>i(!1),[e]);let a=t&&!!e;return(0,B.jsx)(Mb,{open:a,onOpenChange:e=>{e||HI()},children:(0,B.jsx)(tu,{children:a&&e?(0,B.jsxs)(Ib,{forceMount:!0,children:[(0,B.jsx)(Rb,{asChild:!0,forceMount:!0,children:(0,B.jsx)(Yd.div,{className:`fixed inset-0 z-[1000] bg-scrim backdrop-blur-sm`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.14,ease:`easeOut`}})}),(0,B.jsxs)(Hb,{forceMount:!0,"aria-describedby":void 0,className:`fixed inset-0 z-[1000] flex flex-col outline-none`,onClick:e=>{e.target===e.currentTarget&&HI()},children:[(0,B.jsx)(qb,{className:`sr-only`,children:e.alt?`Image: ${e.alt}`:`Image`}),(0,B.jsxs)(`div`,{className:`pointer-events-none flex shrink-0 items-center justify-end gap-1 p-3`,children:[(0,B.jsx)(`a`,{href:e.src,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open the original in a new tab`,title:`Open the original`,className:`lightbox-tool pointer-events-auto`,children:(0,B.jsx)(Cp,{"aria-hidden":`true`,className:`size-4`})}),(0,B.jsx)(Zb,{"aria-label":`Close the image`,title:`Close · Esc`,className:`lightbox-tool pointer-events-auto`,children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-4`})})]}),(0,B.jsx)(`div`,{className:Y(`min-h-0 flex-1 overscroll-contain px-4 pb-4`,r?`overflow-auto`:`grid place-items-center overflow-hidden`),onClick:e=>{e.target===e.currentTarget&&HI()},children:(0,B.jsx)(Yd.img,{src:e.src,alt:e.alt??``,draggable:!1,onClick:()=>i(e=>!e),className:Y(`lightbox-image select-none rounded-xl`,r?`m-auto max-w-none cursor-zoom-out`:`max-h-[calc(100svh-5.5rem)] max-w-full cursor-zoom-in object-contain`),initial:{opacity:0,scale:n?1:.92},animate:{opacity:1,scale:1},exit:{opacity:0,scale:n?1:.96,transition:{duration:.12,ease:`easeIn`}},transition:n?{duration:.12}:qI},e.src)}),e.alt?(0,B.jsx)(`p`,{className:`pointer-events-none shrink-0 truncate px-4 pb-4 text-center text-xs text-muted-foreground`,children:e.alt}):null]})]}):null})})}var YI=/^-\s+(.+?)\s+\(([^()\s]+\/[^()\s]+)\)\s*$/;function XI(e){let t=e.lastIndexOf(`${ZT}\n`);if(t<0||t>0&&e[t-1]!==`
|
|
91
91
|
`)return{body:e,files:[]};let n=e.slice(t+ZT.length+1).split(`
|
|
92
|
-
`).filter(Boolean),r=[];for(let t of n){let n=YI.exec(t);if(!n)return{body:e,files:[]};let i=n[1].split(/[\\/]/).pop()??``;if(!/^[\w.-]+$/.test(i))return{body:e,files:[]};r.push({id:i,name:i.replace(/^[a-z0-9]+-/,``),mime:n[2]})}return r.length>0?{body:e.slice(0,t).trimEnd(),files:r}:{body:e,files:[]}}var ZI=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function QI({files:e}){return e.length===0?null:(0,B.jsx)(`ul`,{className:`mt-2 flex min-w-0 max-w-full flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,B.jsx)(`li`,{children:ZI.has(e.mime)?(0,B.jsx)(`a`,{href:P(`/files/preview/attachments/${e.id}`),target:`_blank`,rel:`noopener noreferrer`,onClick:KI({src:P(`/files/preview/attachments/${e.id}`),alt:e.name}),"aria-label":`${e.name}: open the image`,className:`block max-w-full overflow-hidden rounded-lg border border-border bg-muted/40 transition-transform duration-150 ease-snap hover:scale-[1.02] focus-visible:outline-2 focus-visible:outline-ring`,children:(0,B.jsx)(`img`,{src:P(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-[min(14rem,100%)] object-cover`})}):(0,B.jsxs)(`span`,{className:`inline-flex max-w-[min(16rem,100%)] min-w-0 items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[e.mime===`application/pdf`?(0,B.jsx)(jp,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,B.jsx)(hm,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}function $I(e){return e(),()=>{}}var eL=8;function tL(e,t=24){let[n,r]=(0,m.useState)(t),i=(0,m.useRef)(8),a=n<e;return(0,m.useEffect)(()=>{if(!a)return;let e=0,t=$I(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,C_.flushSync)(()=>r(e=>e+i.current));let t=Math.max(1,performance.now()-e);i.current=Math.max(2,Math.min(400,Math.round(i.current*eL/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}var nL=`bot-lobby.code.wrap`,rL=`bot-lobby.code.layout`,iL=new Set,aL={open:!1,request:0};function oL(){for(let e of[...iL])e()}function sL(e){return iL.add(e),()=>{iL.delete(e)}}function cL(e,t){aL={open:!0,...e?{path:e}:aL.path?{path:aL.path}:{},...t?{mode:t}:{},request:aL.request+1},oL()}function lL(){aL.open&&(aL={...aL,open:!1},oL())}function uL(){aL.open?lL():cL()}function dL(){return(0,m.useSyncExternalStore)(sL,()=>aL)}function fL(e){try{return localStorage.getItem(e)}catch{return null}}function pL(e,t){try{localStorage.setItem(e,t)}catch{}}var mL=fL(nL)===`1`,hL=fL(rL)===`split`?`split`:`unified`;function gL(e){mL=e,pL(nL,e?`1`:`0`),oL()}function _L(e){hL=e,pL(rL,e),oL()}function vL(){return(0,m.useSyncExternalStore)(sL,()=>mL)}function yL(){return(0,m.useSyncExternalStore)(sL,()=>hL)}var bL=new Set(`ts tsx mts cts js jsx mjs cjs json jsonc json5 jsonl md mdx css scss sass less html htm vue svelte astro py rb go rs java kt kts swift c h cc cpp hpp cs php lua sh bash zsh fish ps1 sql graphql gql yml yaml toml ini cfg conf env xml svg txt lock prisma proto dockerfile mk gradle`.split(` `));function xL(e){let t=e.trim();if(!t||t.length>300||/\s/.test(t)||/^[a-z][\w+.-]*:\/\//i.test(t))return;let n=t.replace(/:\d+(?::\d+)?$/,``).replace(/^\.\//,``);if(!/^[\w@~./-]+$/.test(n)||n.endsWith(`/`)||n.includes(`..`))return;let r=n.split(`/`).at(-1)??``,i=/^[\w@.-]*[A-Za-z_][\w@-]*\.[A-Za-z][\w]{0,9}$/.test(r)||/^\.[A-Za-z][\w.-]*$/.test(r),a=/^(Dockerfile|Makefile|LICENSE|Procfile|Gemfile|Rakefile)$/.test(r)&&n.includes(`/`);if((i||a)&&!/^v?\d+(\.\d+)+$/.test(r)&&(n.includes(`/`)||r.startsWith(`.`)||bL.has(r.slice(r.lastIndexOf(`.`)+1).toLowerCase())))return n}function SL({path:e,children:t,className:n}){return(0,B.jsx)(`button`,{type:`button`,"data-file-link":e,title:`Open ${e} in the code viewer`,onClick:t=>{t.stopPropagation(),cL(e)},className:Y(`file-link`,n),children:t})}function CL(e){return e.split(/(\s+)/).map((e,t)=>{let n=e.replace(/^[("'`[]+|[)"'`\],.;:!?]+$/g,``),r=n?xL(n):void 0;if(!r)return e;let i=e.indexOf(n);return(0,B.jsxs)(`span`,{children:[e.slice(0,i),(0,B.jsx)(SL,{path:r,children:n}),e.slice(i+n.length)]},t)})}function wL(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(wL).join(``)}function TL(e,t=!1){let n=t||e.tagName===`a`;e.tagName===`code`&&(e.properties={...e.properties,copyBlocked:n,blockCode:t===!1&&e.properties?.blockCode});for(let t of e.children??[])e.tagName===`pre`&&(t.properties={...t.properties,blockCode:!0}),TL(t,n)}function EL(){return e=>TL(e)}var DL=/(?<![\w/@.:-])((?:\.{1,2}\/)?(?:[\w@.-]+\/)+[\w@.-]*[A-Za-z_][\w@-]*\.[A-Za-z]\w{0,9})(:\d+)?(?![\w/])/g;function OL(e){if(e.tagName===`code`||e.tagName===`pre`||e.tagName===`a`)return;let t=e.children;if(!t)return;let n=[];for(let e of t){if(e.type!==`text`||!e.value||!e.value.includes(`/`)){OL(e),n.push(e);continue}let t=0;for(let r of e.value.matchAll(DL)){let i=xL(r[1]);i&&(r.index>t&&n.push({type:`text`,value:e.value.slice(t,r.index)}),n.push({type:`element`,tagName:`span`,properties:{dataFilePath:i},children:[{type:`text`,value:r[0]}]}),t=r.index+r[0].length)}t===0?n.push(e):t<e.value.length&&n.push({type:`text`,value:e.value.slice(t)})}e.children=n}function kL(){return e=>OL(e)}function AL(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await LI(e,navigator.clipboard),n(!0),H.success(`Code copied.`)}catch{H.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function jL({text:e,children:t,block:n=!1}){let{copy:r}=AL(e),i=(0,m.useRef)(void 0);return(0,B.jsxs)(`code`,{role:`button`,tabIndex:0,"aria-label":`Copy code`,"aria-keyshortcuts":`Enter Space`,title:`Copy code · Enter / Space`,className:`cursor-copy focus-visible:outline-2 focus-visible:outline-ring`,onPointerDown:e=>{i.current={x:e.clientX,y:e.clientY,moved:!1}},onPointerMove:e=>{let t=i.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>4&&(t.moved=!0)},onClick:e=>{e.stopPropagation(),II(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),II(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,B.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function ML({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=AL(FI(n,r?.position,!0)??wL(r)),o=r?.children?.find(e=>e.tagName===`code`)?.properties?.className,s=(Array.isArray(o)?o:[]).map(String).find(e=>e.startsWith(`language-`))?.slice(9);return(0,B.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,B.jsx)(EI,{label:i?`Copied`:`Copy the code`,icon:i?Jf:yp,iconOnly:!0,onClick:()=>void a()})]}),(0,B.jsx)(`pre`,{className:`!my-0 overflow-x-auto !rounded-t-none !bg-transparent px-3 pb-3 text-sm leading-relaxed [&>code]:block`,children:t})]})}function NL(e){return{pre:t=>(0,B.jsx)(ML,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,B.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode,a=i?void 0:xL(wL(r));return a?(0,B.jsx)(SL,{path:a,children:(0,B.jsx)(`code`,{children:n})}):(0,B.jsx)(jL,{text:FI(e,r?.position,i)??wL(r),block:i,children:n})},span:({node:e,children:t,...n})=>{let r=e?.properties?.dataFilePath;return typeof r==`string`?(0,B.jsx)(SL,{path:r,children:t}):(0,B.jsx)(`span`,{...n,children:t})},a:({node:e,href:t,children:n})=>{let r=t?P(t):void 0;return(0,B.jsx)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer nofollow`,onClick:r&&GI(t)?KI({src:r,alt:wL(e)||void 0}):void 0,children:n})},img:({src:e,alt:t})=>{let n=typeof e==`string`?P(e):void 0,r=(0,B.jsx)(`img`,{src:n,alt:t??``,loading:`lazy`});return n?(0,B.jsx)(`button`,{type:`button`,className:`md-image`,"aria-label":t?`${t}: open the image`:`Open the image`,onClick:KI({src:n,alt:t??void 0}),children:r}):r},table:({children:e})=>(0,B.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,B.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var PL=(0,m.memo)(function({text:e}){return(0,B.jsx)(hN,{remarkPlugins:[bI],rehypePlugins:[EL,kL],urlTransform:kI,components:NL(e),children:e})}),FL=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=XI(e),i=n?PI(n):[],a=tL(i.length,3);return(0,B.jsxs)(`div`,{className:Y(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,B.jsx)(PL,{text:e},t)),(0,B.jsx)(QI,{files:r})]})});function IL(e,t){let n=new Set(t.toLowerCase().match(/[a-z][a-z0-9]{3,}/g)??[]);return e.map(e=>({note:e,score:(e.text.toLowerCase().match(/[a-z][a-z0-9]{3,}/g)??[]).filter(e=>n.has(e)).length})).filter(e=>e.score>1).sort((e,t)=>t.score-e.score).slice(0,3).map(e=>e.note)}function LL({notes:e,onOpen:t,onSaved:n}){let r=vE(`lobby`).data,[i,a]=(0,m.useState)(),[o,s]=(0,m.useState)(!1),c=r?.chat.at(-1)?.id??0;if((0,m.useEffect)(()=>{let e=e=>{let t=String(e.detail??``);s(!1),a({text:t,at:Date.now(),after:c})};return window.addEventListener(hD,e),()=>window.removeEventListener(hD,e)},[c]),!i)return null;let l=r?.chat.find(e=>e.id>i.after&&e.role!==`you`&&e.role!==`note`),u=l?.text??r?.reply??``,d=u?IL(e,`${i.text} ${u}`):[],f=async()=>{await U(`knowledge.add`,{agent:`master`,file:`knowledge.md`,text:`- ${u.replace(/\s+/g,` `).trim()}`})&&(s(!0),n())};return(0,B.jsxs)(`section`,{className:`cs-knask`,"aria-label":`Answer from saved knowledge`,"aria-live":`polite`,children:[(0,B.jsxs)(`div`,{className:`cs-ah`,children:[(0,B.jsx)(qm,{"aria-hidden":`true`,className:`size-3.5`}),`Answer from saved knowledge`,(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-tip cs-b ml-auto`,"data-tip":`Dismiss`,"aria-label":`Dismiss the answer`,onClick:()=>a(void 0),children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})})]}),(0,B.jsxs)(`p`,{className:`cs-aq`,children:[`You asked: `,i.text]}),(0,B.jsx)(`div`,{className:`cs-aa`,children:u?(0,B.jsx)(FL,{text:u}):(0,B.jsx)(`span`,{className:`cs-wtx`,children:`Looking through what the agents know`})}),d.length?(0,B.jsx)(`div`,{className:`cs-bs`,children:d.map((e,n)=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-bsr`,onClick:()=>t(e.key),children:[(0,B.jsx)(`span`,{className:`cs-n`,children:n+1}),(0,B.jsx)(`span`,{className:`cs-dot`,style:{background:tD[e.agent]}}),(0,B.jsx)(`span`,{className:`cs-t`,children:e.text}),(0,B.jsxs)(`span`,{className:`cs-f`,children:[HE[e.agent],` · `,e.file]})]},e.key))}):null,l?(0,B.jsx)(`div`,{className:`cs-aact`,children:(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,disabled:o,onClick:()=>void f(),children:[(0,B.jsx)(Dm,{"aria-hidden":`true`,className:`size-3.5`}),o?`Saved as a note`:`Save as a note`]})}):null]})}var RL=m.createContext({title:``,description:``});function zL({children:e,open:t,onOpenChange:n,defaultOpen:r}){let i=m.useId(),a=m.useId(),o=m.Children.toArray(e),s=o.filter(e=>m.isValidElement(e)&&e.type===BL),c=o.filter(e=>!s.includes(e));return(0,B.jsx)(Cw,{...t===void 0?{}:{open:t},...n?{onOpenChange:n}:{},...r===void 0?{}:{defaultOpen:r},children:(0,B.jsxs)(RL.Provider,{value:{title:i,description:a},children:[(0,B.jsx)(ww,{asChild:!0,children:(0,B.jsx)(`span`,{"data-slot":`alert-dialog`,className:`inline-flex max-w-full`,children:c})}),s]})})}function BL({className:e,children:t,...n}){let r=m.useContext(RL);return(0,B.jsx)(Ew,{children:(0,B.jsx)(Dw,{"data-slot":`alert-dialog-content`,role:`alertdialog`,"aria-labelledby":r.title,"aria-describedby":r.description,side:`bottom`,align:`end`,sideOffset:8,collisionPadding:12,className:Y(`cs-cfm z-[1100] grid w-[min(20rem,calc(100vw-2rem))] gap-3 rounded-2xl p-3.5 text-sm outline-none origin-(--radix-popover-content-transform-origin)`,e),...n,children:t})})}function VL({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:Y(`flex flex-col gap-1`,e),...t})}function HL({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:Y(`flex flex-row justify-end gap-2`,e),...t})}function UL({className:e,...t}){let n=m.useContext(RL);return(0,B.jsx)(`h2`,{id:n.title,"data-slot":`alert-dialog-title`,className:Y(`m-0 text-[13.5px] font-semibold text-foreground`,e),...t})}function WL({className:e,...t}){let n=m.useContext(RL);return(0,B.jsx)(`p`,{id:n.description,"data-slot":`alert-dialog-description`,className:Y(`m-0 text-[12.5px] leading-snug text-muted-foreground`,e),...t})}function GL({className:e,variant:t=`default`,...n}){return(0,B.jsx)(Ow,{asChild:!0,children:(0,B.jsx)(OT,{variant:t,size:`sm`,"data-slot":`alert-dialog-action`,className:Y(`h-7 gap-1 px-2.5`,e),...n})})}function KL({className:e,...t}){return(0,B.jsx)(Ow,{asChild:!0,children:(0,B.jsx)(OT,{variant:`outline`,size:`sm`,"data-slot":`alert-dialog-cancel`,className:Y(`h-7 gap-1 px-2.5`,e),...t})})}function qL({label:e,text:t,shortcut:n,title:r,description:i,confirmLabel:a,onConfirm:o,icon:s,disabled:c,variant:l=`outline`,iconOnly:u,compact:d,className:f,side:p}){let[h,g]=(0,m.useState)(!1),_=qT(h,KT.confirm),v=l===`destructive`;return RE(`y`,()=>{g(!1),o()},{enabled:h&&_,inDialog:!0}),(0,B.jsxs)(zL,{open:h&&_,onOpenChange:g,children:[(0,B.jsx)(EI,{label:e,icon:s,tone:v?`danger`:`neutral`,disabled:c,shortcut:n,iconOnly:u,...d?{"data-compact":!0,className:`size-8`}:f?{className:f}:{},...p?{side:p}:{},...t?{text:t}:{},onClick:()=>g(!0)}),(0,B.jsxs)(BL,{children:[(0,B.jsxs)(VL,{children:[(0,B.jsx)(UL,{children:r}),(0,B.jsx)(WL,{children:i})]}),(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:v?`destructive`:`default`,onClick:o,children:[a,(0,B.jsx)(IT,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function JL({text:e,className:t,onClick:n}){let r=e.split(/(`[^`]+`)/g).filter(Boolean);return(0,B.jsx)(`p`,{className:t,onClick:n,children:r.map((e,t)=>e.startsWith("`")&&e.endsWith("`")&&e.length>2?(0,B.jsx)(`span`,{className:`cs-cod`,children:e.slice(1,-1)},t):(0,B.jsx)(`span`,{children:e},t))})}function YL({initial:e,label:t,action:n,placeholder:r,onSave:i,onCancel:a}){let[o,s]=(0,m.useState)(e),[c,l]=(0,m.useState)(!1),u=async()=>{if(c||!o.trim())return;l(!0);let e=await i(o.trim());l(!1),e&&a()};return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`textarea`,{autoFocus:!0,"aria-label":t,className:`cs-knta`,value:o,placeholder:r,disabled:c,onChange:e=>s(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),a()):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),u()))}}),(0,B.jsxs)(`div`,{className:`cs-knea`,children:[(0,B.jsx)(`span`,{className:`cs-h2`,children:UE}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm`,onClick:a,disabled:c,children:`Cancel`}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,onClick:()=>void u(),disabled:c||!o.trim(),children:n})]})]})}function XL(e){let t=aD(e.since);return e.source?`${e.source}${t?` · ${t}`:``}`:`${HE[e.agent]} · ${e.file}`}function ZL({note:e,selected:t,dragging:n,activeTags:r,onOpen:i,onTag:a,onDragStart:o,onDragEnd:s,onSave:c,onDelete:l,onPin:u,onReview:d,editing:f,onEditing:p}){let[h,g]=(0,m.useState)(!1),_=f??h,v=e=>p?p(e):g(e),y=tD[e.agent];return(0,B.jsxs)(`article`,{className:`cs-knc`,"data-sel":t||void 0,"data-drag":n||void 0,draggable:!_,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.key),o()},onDragEnd:s,"aria-label":`${HE[e.agent]}: ${e.text}`,children:[(0,B.jsxs)(`div`,{className:`cs-knch`,style:{"--c":y},children:[(0,B.jsx)(`span`,{className:`cs-knd`,"aria-hidden":`true`,children:(0,B.jsx)(zp,{className:`size-3.5`})}),(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:nD(e.agent)}),(0,B.jsx)(`b`,{children:HE[e.agent]}),(0,B.jsxs)(`span`,{className:`cs-fl`,children:[`· `,e.file]}),(0,B.jsxs)(`div`,{className:`cs-kna`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-pin cs-tip cs-b`,"data-on":e.pinned?`true`:`false`,"data-tip":e.pinned?`Unpin`:`Pin to the top`,"aria-label":e.pinned?`Unpin`:`Pin to the top`,"aria-pressed":e.pinned,onClick:u,children:(0,B.jsx)(Cm,{className:`size-3.5`,"aria-hidden":`true`})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-h cs-tip cs-b`,"data-tip":`Edit`,"aria-label":`Edit the note`,onClick:()=>v(!0),children:(0,B.jsx)(ym,{className:`size-3.5`,"aria-hidden":`true`})}),(0,B.jsx)(qL,{iconOnly:!0,className:`cs-knb cs-h cs-dg`,icon:rh,label:`Delete the note`,title:`Delete this note?`,description:`The note and its comments are removed. The version before is archived.`,confirmLabel:`Delete note`,variant:`destructive`,onConfirm:l})]})]}),_?(0,B.jsx)(YL,{initial:e.entry.text,label:`Edit note`,action:`Save`,onSave:c,onCancel:()=>v(!1)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JL,{className:`cs-knx`,text:e.text,onClick:i}),e.comments.map(e=>(0,B.jsxs)(`p`,{className:`cs-knn`,children:[(0,B.jsx)(sm,{"aria-hidden":`true`,className:`size-3.5`}),(0,B.jsx)(`span`,{children:e.text})]},e.id)),e.flag?(0,B.jsxs)(`p`,{className:`cs-knfl`,children:[(0,B.jsx)(rp,{"aria-hidden":`true`,className:`size-3.5`}),(0,B.jsx)(`span`,{children:e.flag.kind===`stale`?`Not used in ${e.flag.days} days`:`A newer proposal in the Inbox disagrees with this`}),e.flag.kind===`stale`?(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm`,title:`Takes it out of the file; the version before is archived`,onClick:l,children:`Archive`}):(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm`,onClick:d,children:`Review`})]}):null,(0,B.jsxs)(`div`,{className:`cs-knf3`,children:[e.tags.length?(0,B.jsx)(`div`,{className:`cs-tg`,children:e.tags.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-ktg`,"data-on":r.includes(e)||void 0,onClick:()=>a(e),children:[`#`,e]},e))}):null,(0,B.jsxs)(`div`,{className:`cs-pv`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`cs-src`,onClick:i,children:[(0,B.jsx)(Yp,{"aria-hidden":`true`,className:`size-3 flex-none`}),(0,B.jsx)(`span`,{children:XL(e)})]}),(0,B.jsxs)(`span`,{className:`cs-use`,children:[(0,B.jsx)(`span`,{className:`cs-ubar`,"aria-hidden":`true`,children:(0,B.jsx)(`i`,{style:{width:`${Math.min(100,e.uses.length*6)}%`}})}),oD(e.uses.length)]})]})]})]})]})}var QL=85;function $L({proposals:e,onChanged:t}){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=e.filter(e=>(e.confidence??0)>=QL),s=async e=>{a(!0);let n=!0;for(let t of e)n=await t()!==void 0&&n;return a(!1),t(),n};return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`cs-kih`,children:[(0,B.jsx)(`p`,{children:e.length?`${e.length} ${e.length===1?`proposal`:`proposals`} from finished work, waiting for you`:`Nothing waiting`}),o.length?(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,disabled:i,onClick:()=>void s(o.map(e=>()=>U(`knowledge.accept`,{id:e.id}))),children:[(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3.5`}),`Accept `,o.length,` confident`]}):null]}),e.length?(0,B.jsx)(`div`,{className:`cs-kib`,children:e.map(e=>{let t=(e.confidence??0)>=QL;return(0,B.jsxs)(`article`,{className:`cs-kir`,style:{"--c":tD[e.agent]},"aria-label":`Proposal for ${HE[e.agent]}`,children:[(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:nD(e.agent)}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[n===e.id?(0,B.jsx)(`div`,{className:`cs-edi`,children:(0,B.jsx)(YL,{initial:e.text,label:`Edit before accepting`,action:`Accept`,onSave:t=>s([()=>U(`knowledge.accept`,{id:e.id,text:t})]),onCancel:()=>r(void 0)})}):(0,B.jsx)(`p`,{className:`cs-tx`,children:e.text}),(0,B.jsxs)(`div`,{className:`cs-mt`,children:[(0,B.jsx)(`b`,{style:{color:tD[e.agent],fontWeight:600},children:HE[e.agent]}),(0,B.jsxs)(`span`,{children:[`· `,e.source,e.at?` · ${aD(e.at)}`:``]}),e.confidence===void 0?null:(0,B.jsxs)(`span`,{className:`cs-kcf`,"data-k":t?`ok`:`chk`,children:[`· `,e.confidence,`% `,t?`confident`:`worth a look`]})]}),e.replaces?(0,B.jsxs)(`p`,{className:`cs-rp`,children:[(0,B.jsx)(`b`,{children:`Replaces`}),(0,B.jsx)(`s`,{children:e.replaces})]}):null]}),(0,B.jsxs)(`div`,{className:`cs-ac`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,disabled:i||n===e.id,onClick:()=>void s([()=>U(`knowledge.accept`,{id:e.id})]),children:[(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3.5`}),`Accept`]}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":`Edit first`,"aria-label":`Edit first`,disabled:i,onClick:()=>r(e.id),children:(0,B.jsx)(ym,{"aria-hidden":`true`,className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":`Dismiss`,"aria-label":`Dismiss`,disabled:i,onClick:()=>void s([()=>U(`knowledge.dismiss`,{id:e.id})]),children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})})]})]},e.id)})}):(0,B.jsxs)(`div`,{className:`cs-knempty`,children:[(0,B.jsx)(`b`,{children:`Inbox is clear`}),`New proposals from finished work land here for your review.`]})]})}function eR(e,t,n,r=!0){gE();let[i,a]=(0,m.useState)({loading:!0,at:0}),[o,s]=(0,m.useState)(0),c=[N.status().connection,...n.map(e=>N.get(e).version)].join(`,`),l=JSON.stringify(t);(0,m.useEffect)(()=>{if(!r)return;let t=!0,n=performance.now();return a(e=>({...e,loading:!0})),I(e,JSON.parse(l)).then(e=>t&&a({data:e,loading:!1,at:n}),e=>t&&a(t=>({...t,error:e instanceof Error?e.message:String(e),loading:!1}))),()=>{t=!1}},[e,l,c,o,r]);let u=(0,m.useCallback)(()=>s(e=>e+1),[]);return{data:i.data,error:i.error,loading:i.loading,requestedAt:i.at,reload:u}}function tR(){let e=eR(`tasks.list`,{},[`tasks`]);return(0,m.useMemo)(()=>Object.fromEntries((e.data?.rows??[]).map(e=>[e.id,e.title])),[e.data])}function nR({note:e,onPin:t,onEdit:n,onComment:r,onDelete:i}){return(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`cs-knwh min-w-0`,style:{"--c":tD[e.agent]},children:[(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:nD(e.agent)}),(0,B.jsxs)(`span`,{className:`truncate`,children:[(0,B.jsx)(`b`,{children:HE[e.agent]}),` · `,e.file]})]}),(0,B.jsxs)(`div`,{className:`cs-knwhx`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":e.pinned?`Unpin`:`Pin to the top`,"aria-label":e.pinned?`Unpin`:`Pin to the top`,"aria-pressed":e.pinned,"data-on":e.pinned||void 0,onClick:t,children:(0,B.jsx)(Cm,{"aria-hidden":`true`,className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":`Edit`,"aria-label":`Edit the note`,onClick:n,children:(0,B.jsx)(ym,{"aria-hidden":`true`,className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":`Comment`,"aria-label":`Comment on the note`,onClick:r,children:(0,B.jsx)(am,{"aria-hidden":`true`,className:`size-3.5`})}),(0,B.jsx)(qL,{iconOnly:!0,side:`bottom`,className:`cs-kc cs-sm cs-ib`,icon:rh,label:`Delete the note`,title:`Delete this note?`,description:`The note and its comments are removed. The version before is archived.`,confirmLabel:`Delete note`,variant:`destructive`,onConfirm:i})]})]})}function rR(e){if(e===`you`)return{name:`You`,letter:`Y`,color:`var(--c-orc)`};let t=VE.find(t=>HE[t].toLowerCase().startsWith(e.toLowerCase())||t===`master`&&/oracle|master/i.test(e));return{name:e,letter:e.charAt(0).toUpperCase(),color:t?tD[t]:`var(--muted-foreground)`}}function iR({note:e,view:t,commenting:n,onCommenting:r,onTag:i,onMove:a,onChanged:o}){let[s,c]=(0,m.useState)(!1),l=tR(),{agent:u,file:d}=e,f=KE(e.entry),p=async e=>{c(!0);let t=await e()!==void 0;return c(!1),t&&o(),t},h=sD(e.uses),g=[...new Map(e.uses.filter(e=>e.taskId).map(e=>[e.taskId,e.at])).entries()].slice(0,5);return(0,B.jsxs)(`article`,{"aria-label":`${HE[u]} note`,children:[(0,B.jsx)(JL,{className:`cs-knwt`,text:e.text}),e.comments.length?(0,B.jsx)(`ul`,{className:`cs-kwu mt-2.5`,children:e.comments.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{title:e.text,children:e.text}),(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-tip cs-b`,"data-tip":`Take it back`,"aria-label":`Take the comment back`,disabled:s,onClick:()=>void p(()=>U(`knowledge.unnote`,{id:e.id})),children:(0,B.jsx)(sh,{"aria-hidden":`true`,className:`size-3.5`})})]},e.id))}):null,n?(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(YL,{initial:``,label:`Comment on this note`,action:`Add comment`,placeholder:`Tell the agent what to change; it reads comments with the note`,onSave:e=>p(()=>U(`knowledge.comment`,{agent:u,file:d,ref:f,text:e})),onCancel:()=>r(!1)})}):null,e.tags.length?(0,B.jsx)(`div`,{className:`cs-knwtg`,children:e.tags.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-ktg`,onClick:()=>i(e),children:[`#`,e]},e))}):null,(0,B.jsx)(`h3`,{className:`cs-kwh`,children:`Where it came from`}),e.history.length?(0,B.jsx)(`ul`,{className:`cs-kwtl`,children:e.history.map(e=>{let t=rR(e.by);return(0,B.jsxs)(`li`,{className:`cs-kwi`,style:{"--c":t.color},children:[(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:t.letter}),(0,B.jsxs)(`div`,{className:`cs-tx`,children:[(0,B.jsx)(`b`,{children:t.name}),e.what,(0,B.jsx)(`em`,{children:aD(e.at)})]}),e.before?(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-tip cs-b`,"data-tip":`Restore this version`,"aria-label":`Restore the version before: ${e.before}`,disabled:s,onClick:()=>void p(()=>U(`knowledge.restore`,{agent:u,file:d,ref:f,event:e.id})),children:(0,B.jsx)(sh,{"aria-hidden":`true`,className:`size-3.5`})}):null]},e.id)})}):(0,B.jsxs)(`p`,{className:`cs-hd2 m-0`,children:[`It was in `,HE[u],`'s `,d,` before its history was kept.`]}),t?.over?(0,B.jsx)(`p`,{className:`cs-kagw`,children:GE(d)}):null,(0,B.jsxs)(`h3`,{className:`cs-kwh`,children:[`Used by agents`,(0,B.jsx)(`span`,{children:e.uses.length?`${e.uses.length} ${e.uses.length===1?`use`:`uses`} in 30 days`:`never`})]}),(0,B.jsx)(`div`,{className:`cs-kwb`,"aria-hidden":`true`,children:h.map((e,t)=>(0,B.jsx)(`i`,{"data-z":e===0||void 0,style:{height:`${e||8}%`}},t))}),g.length?(0,B.jsx)(`ul`,{className:`cs-kwu mt-3`,children:g.map(([e,t])=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3.5`}),(0,B.jsx)(`span`,{children:l[e]??`Task ${e}`}),(0,B.jsx)(`i`,{children:aD(t)})]},e))}):e.uses.length===0?(0,B.jsx)(`p`,{className:`cs-hd2 m-0 mt-2`,children:`No agent has used this note yet.`}):null,(0,B.jsx)(`h3`,{className:`cs-kwh`,children:`Move to`}),(0,B.jsx)(`div`,{className:`cs-kwmv`,children:VE.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-tip cs-b`,"data-tip":e===u?`Kept by ${HE[e]}`:`Move to ${HE[e]}`,"aria-label":e===u?`Kept by ${HE[e]}`:`Move to ${HE[e]}`,"aria-pressed":e===u,"data-on":e===u||void 0,disabled:s||e===u,style:{"--c":tD[e]},onClick:()=>a(e),children:nD(e)},e))})]})}var aR=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function oR(){return(0,B.jsx)(uE,{className:`m-4 flex-1`,children:(0,B.jsxs)(dE,{children:[(0,B.jsx)(pE,{variant:`icon`,children:(0,B.jsx)(Wf,{"aria-hidden":`true`})}),(0,B.jsx)(mE,{children:`No knowledge files yet. The agents write what they learn here as they work.`})]})})}function sR({rest:e}){let t=e[0]===`agents`?`agents`:e[0]===`inbox`?`inbox`:`notes`,n=eD(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)([]),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),[E,ee]=(0,m.useState)(),D=(0,m.useRef)(null),O=(0,m.useMemo)(()=>{let e=n.notes.filter(e=>(!r||e.agent===r)&&(!a||e.file===a)&&s.every(t=>e.tags.includes(t))&&rD(e,l)&&(!d||(d===`pinned`?e.pinned:e.flag?.kind===d)));return p?[...e].sort((e,t)=>t.uses.length-e.uses.length):[...e].sort((e,t)=>Number(t.pinned)-Number(e.pinned))},[n.notes,r,a,s,l,d,p]),k=(0,m.useMemo)(()=>{let e=new Map;for(let t of n.notes)for(let n of t.tags)e.set(n,(e.get(n)??0)+1);return[...e].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,12)},[n.notes]),te=n.notes.find(e=>e.key===v),A=(0,m.useRef)(void 0);te&&(A.current=te);let j=e=>c(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),ne=e=>iE(rE(`knowledge`,...e===`notes`?[]:[e])),re=e=>n.views.find(t=>t.agent===e.agent&&t.file===e.file),M=e=>{i(e),o(void 0)},ie=async(e,t)=>{let r=await U(`knowledge.edit`,{agent:e.agent,file:e.file,ref:KE(e.entry),text:t})!==void 0;return r&&n.reload(),r},ae=async e=>{await U(`knowledge.remove`,{agent:e.agent,file:e.file,ref:KE(e.entry)})&&(v===e.key&&y(void 0),n.reload())},oe=async e=>{await U(`knowledge.pin`,{agent:e.agent,file:e.file,ref:KE(e.entry),on:!e.pinned})&&n.reload()},se=async(e,t)=>{t!==e.agent&&await U(`knowledge.move`,{agent:e.agent,file:e.file,ref:KE(e.entry),to:t,toFile:iD(n.files,t,e.file)})&&(y(void 0),n.reload())},ce=r??`master`,le=a??iD(n.files,ce,`knowledge.md`),ue=async e=>{let t=await U(`knowledge.add`,{agent:ce,file:le,text:e.startsWith(`-`)?e:`- ${e}`})!==void 0;return t&&n.reload(),t},de=e=>t=>{t.preventDefault(),ee(void 0);let r=n.notes.find(e=>e.key===(t.dataTransfer.getData(`text/plain`)||w));r&&se(r,e)};if(!n.views.length&&n.error)return(0,B.jsx)(cE,{message:`Could not load the knowledge. ${n.error}`,onRetry:n.reload});if(!n.loading&&!n.files.length)return(0,B.jsx)(oR,{});let N=qE(n.files),fe=[[],[]];O.forEach((e,t)=>fe[t%2].push(e));let pe=e=>n.notes.filter(t=>e===`pinned`?t.pinned:t.flag?.kind===e).length,me=pe(`pinned`),P=n.proposals.length,F=e=>f(t=>t===e?void 0:e);return(0,B.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`div`,{ref:D,className:`cs-scroll pb-dock`,children:(0,B.jsxs)(`div`,{className:`cs-pg cs-kn`,children:[(0,B.jsxs)(`div`,{className:`cs-knh`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`cs-hd1`,children:`Knowledge`}),(0,B.jsxs)(`p`,{className:`cs-hd2`,children:[aR(n.notes.length,`note`),` · `,aR(N.length,`agent`),` · `,me,` pinned`]})]}),(0,B.jsx)(hE,{as:`tab`,label:`Knowledge view`,value:t,onChange:ne,items:[{id:`notes`,label:`Notes`},{id:`agents`,label:`Agents`},{id:`inbox`,label:(0,B.jsxs)(B.Fragment,{children:[`Inbox`,P?(0,B.jsx)(`span`,{className:`cs-kbn`,children:P}):null]}),name:P?`Inbox, ${P} waiting`:`Inbox`}]})]}),!n.views.length&&n.loading?(0,B.jsx)(jE,{}):t===`agents`?(0,B.jsx)(lD,{data:n,onOpen:e=>{M(e),ne(`notes`)}}):t===`inbox`?(0,B.jsx)($L,{proposals:n.proposals,onChanged:n.reload}):(0,B.jsxs)(`div`,{className:`cs-knl`,children:[(0,B.jsxs)(`nav`,{className:`cs-knr`,"aria-label":`Filter notes`,children:[(0,B.jsx)(`div`,{className:`cs-knrh cs-f`,children:`Agents`}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-knri`,"data-sel":!r||void 0,"aria-pressed":!r,onClick:()=>M(void 0),children:[(0,B.jsx)(`span`,{className:`cs-nm`,children:`All notes`}),(0,B.jsx)(`span`,{className:`cs-ct`,children:n.notes.length})]}),VE.filter(e=>N.some(t=>t.agent===e)).map(e=>(0,B.jsxs)(`div`,{className:`contents`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`cs-knri`,"data-sel":r===e&&!a||void 0,"data-drop":E===e||void 0,"aria-pressed":r===e,style:{"--c":tD[e]},onClick:()=>M(r===e&&!a?void 0:e),onDragOver:t=>{w&&(t.preventDefault(),ee(e))},onDragLeave:()=>ee(t=>t===e?void 0:t),onDrop:de(e),children:[(0,B.jsx)(`span`,{className:`cs-kd`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`cs-nm`,children:HE[e]}),n.files.some(t=>t.agent===e&&t.over)?(0,B.jsx)(`span`,{className:`cs-ovd`,title:`A file is over the compaction threshold`}):null,(0,B.jsx)(`span`,{className:`cs-ct`,children:n.notes.filter(t=>t.agent===e).length})]}),r===e?n.files.filter(t=>t.agent===e).map(t=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-knri`,"data-k":`file`,"data-sel":a===t.file||void 0,"aria-pressed":a===t.file,style:{"--c":tD[e]},onClick:()=>o(e=>e===t.file?void 0:t.file),children:[(0,B.jsx)(`span`,{className:`cs-nm`,children:t.file}),t.over?(0,B.jsx)(`span`,{className:`cs-ovd`,title:`Over the compaction threshold`}):null,(0,B.jsx)(`span`,{className:`cs-ct`,children:WE(t.chars)})]},t.file)):null]},e)),k.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`cs-knrh`,children:`Tags`}),(0,B.jsx)(`div`,{className:`cs-kntags`,children:k.map(([e,t])=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-ktg`,"data-on":s.includes(e)||void 0,"aria-pressed":s.includes(e),onClick:()=>j(e),children:[`#`,e,(0,B.jsx)(`span`,{className:`ml-[5px] opacity-60`,children:t})]},e))})]}):null,(0,B.jsx)(`p`,{className:`cs-knhint`,children:`Drag a note onto an agent to move it. Pinned notes always load first.`})]}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`cs-knt`,children:[(0,B.jsxs)(`label`,{className:`cs-kns`,children:[(0,B.jsx)(Vm,{"aria-hidden":`true`,className:`size-4 flex-none`}),(0,B.jsx)(`input`,{type:`text`,value:l,placeholder:`Search notes, tags and sources`,"aria-label":`Search notes`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Escape`&&l&&(e.stopPropagation(),u(``))}}),l?(0,B.jsx)(`button`,{type:`button`,className:`cs-kx`,"aria-label":`Clear the search`,onClick:()=>u(``),children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})}):null]}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm`,"data-on":d===`pinned`?`true`:void 0,"aria-pressed":d===`pinned`,onClick:()=>F(`pinned`),children:[(0,B.jsx)(Cm,{"aria-hidden":`true`,className:`size-3.5`}),`Pinned `,(0,B.jsx)(`span`,{className:`cs-mut`,children:me})]}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm`,"data-on":d===`stale`?`true`:void 0,"aria-pressed":d===`stale`,onClick:()=>F(`stale`),children:[`Stale `,(0,B.jsx)(`span`,{className:`cs-mut`,children:pe(`stale`)})]}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm`,"data-on":d===`conflict`?`true`:void 0,"aria-pressed":d===`conflict`,onClick:()=>F(`conflict`),children:[`Conflicts `,(0,B.jsx)(`span`,{className:`cs-mut`,children:pe(`conflict`)})]}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm`,title:`Change the order`,onClick:()=>h(e=>!e),children:p?`Most used`:`Pinned first`}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,disabled:g,onClick:()=>_(!0),children:[(0,B.jsx)(Dm,{"aria-hidden":`true`,className:`size-3.5`}),`New note`]})]}),(0,B.jsx)(LL,{notes:n.notes,onOpen:y,onSaved:n.reload}),g?(0,B.jsxs)(`div`,{className:`cs-knc mb-3`,children:[(0,B.jsxs)(`div`,{className:`cs-knch`,style:{"--c":tD[ce]},children:[(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:nD(ce)}),(0,B.jsx)(`b`,{children:HE[ce]}),(0,B.jsxs)(`span`,{className:`cs-fl`,children:[`· new note in `,le]})]}),(0,B.jsx)(YL,{initial:``,label:`New note`,action:`Add note`,placeholder:`What should ${HE[ce]} keep in mind?`,onSave:ue,onCancel:()=>_(!1)})]}):null,O.length?(0,B.jsx)(`div`,{className:`cs-kng`,children:fe.map((e,t)=>(0,B.jsx)(`div`,{className:`cs-kcol`,children:e.map(e=>(0,B.jsx)(ZL,{note:e,selected:e.key===v,dragging:e.key===w,activeTags:s,editing:b===e.key,onEditing:t=>x(t?e.key:void 0),onOpen:()=>{C(!1),y(e.key)},onTag:j,onDragStart:()=>T(e.key),onDragEnd:()=>{T(void 0),ee(void 0)},onSave:t=>ie(e,t),onDelete:()=>void ae(e),onPin:()=>void oe(e),onReview:()=>ne(`inbox`)},e.key))},t))}):(0,B.jsxs)(`div`,{className:`cs-knempty`,children:[(0,B.jsx)(`b`,{children:n.notes.length?`No notes match`:`No notes yet`}),n.notes.length?`Try another word, or clear the filters.`:`New note writes the first one.`]})]})]})]})}),(0,B.jsx)(Qg,{target:D}),(0,B.jsx)(BE,{open:!!te,onClose:()=>y(void 0),label:`Note`,className:`cs-knw`,head:A.current?(0,B.jsx)(nR,{note:A.current,onPin:()=>void oe(A.current),onEdit:()=>{let e=A.current.key;y(void 0),x(e)},onComment:()=>C(!0),onDelete:()=>void ae(A.current)}):null,children:A.current?(0,B.jsx)(iR,{note:A.current,view:re(A.current),commenting:S,onCommenting:C,onTag:e=>{y(void 0),M(void 0),j(e)},onMove:e=>void se(A.current,e),onChanged:n.reload},A.current.key):null})]})}function cR(e){let t=e[0];try{return{id:t?decodeURIComponent(t):void 0}}catch{return{id:t}}}function lR({className:e,...t}){return(0,B.jsx)(`span`,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:Y(`inline-flex size-4 shrink-0 items-end justify-between text-primary`,e),...t,children:[0,1,2].map(e=>(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`block aspect-square h-[28%] shrink-0 rounded-full bg-current motion-safe:animate-[hop_0.9s_ease-in-out_infinite]`,style:{animationDelay:`${e*.14}s`}},e))})}function uR(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(!0),[r,i]=(0,m.useState)(!0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{n.current=!0,i(!0);let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]);return(0,m.useLayoutEffect)(()=>{n.current&&s()},[e,s]),(0,m.useLayoutEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)});return r.observe(e),a.current=r,()=>{r.disconnect(),a.current=void 0,o.current=null}},[]),(0,m.useLayoutEffect)(()=>{let e=a.current,n=t.current?.firstElementChild??null;e&&n!==o.current&&(o.current&&e.unobserve(o.current),n&&e.observe(n),o.current=n)},[e]),{ref:t,atBottom:r,stick:s,onScroll:(0,m.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,i(n.current))},[])}}var dR={MASTER:[`M2 7l5 4 5-7 5 7 5-4-2 12H4z`],DESIGN:[`M12 3a9 9 0 1 0 0 18c1.1 0 2-.9 2-2 0-.5-.2-1-.5-1.3-.3-.4-.5-.8-.5-1.3 0-1.1.9-2 2-2H17a4 4 0 0 0 4-4c0-4.4-4-8-9-8z`,`M7.5 11h.01M10 7h.01M15 7h.01`],DEV:[`M8 8l-5 4 5 4M16 8l5 4-5 4M14 5l-4 14`],QA:[`M12 3l8 3v6c0 4.5-3.2 8-8 9-4.8-1-8-4.5-8-9V6z`,`M8.5 12l2.5 2.5 4.5-5`],RESEARCH:[`M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18z`,`M3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18`],SCOUT:[`M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z`,`M12 9a3 3 0 1 0 0 6 3 3 0 1 0 0-6z`]};function fR(e){let t=e?.toUpperCase();if(t)return t===`ORACLE`||t===`MASTER`?`MASTER`:t===`BACKEND`?`DEV`:t===`DESIGNER`||t===`FRONTEND`?`DESIGN`:t===`RESEARCHER`?`RESEARCH`:dR[t]?t:void 0}function pR(e){let t=fR(e);return t===`MASTER`?`var(--c-orc)`:t===`DESIGN`?`var(--c-des)`:t===`DEV`?`var(--c-dev)`:t===`QA`?`var(--c-qa)`:t===`RESEARCH`?`var(--c-res)`:t===`SCOUT`?`var(--c-sc)`:e?.toUpperCase()===`PLANNER`||e?.toUpperCase()===`PANEL`?`var(--c-pl)`:`var(--muted-foreground)`}function mR(e,t){let n=fR(e);return n?n===fR(t):e?.toUpperCase()===t?.toUpperCase()}function hR(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function gR(e){return e.role===`you`||e.role===`note`?e.role:e.role===`panel`?`PLANNER`:e.agent??`MASTER`}var _R={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,SCOUT:`text-source-scout`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function vR(e){return e===`MASTER`?`Oracle`:e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function yR(e){return _R[e]??`text-muted-foreground`}var bR={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,SCOUT:`var(--source-scout)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function xR(e){return bR[e]??`var(--muted-foreground)`}function SR(e){if(e.role===`researcher`)return`RESEARCH`;let t=e.domain??e.role;return t===`backend`||t===`dev`?`DEV`:t===`designer`||t===`design`?`DESIGN`:t===`researcher`||t===`research`?`RESEARCH`:t===`qa`?`QA`:t?String(t).toUpperCase():`AGENT`}function CR(e,t=40){let n=new Map;for(let t of e)n.set(t.source,t);return[...n.values()].sort((e,t)=>e.at-t.at).slice(-t)}function wR({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,named:s,waiting:c,tile:l}){let u=c||r&&(s||!hR(e));return l?(0,B.jsx)(`div`,{className:`cs-pmsg`,children:(0,B.jsx)(wR,{source:e,name:t,head:r,time:n,live:i,children:a,aside:o,waiting:c,named:s??!0})}):(0,B.jsxs)(`div`,{className:`chat-agent group/msg`,"data-live":i||void 0,style:i?{"--orb":xR(e)}:void 0,children:[u||o?(0,B.jsxs)(`p`,{className:`chat-speaker`,children:[u?(0,B.jsx)(`b`,{className:`chat-name`,title:n,style:{"--who":xR(e)},children:c?(0,B.jsx)(kR,{text:t}):t}):null,o?(0,B.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,c?null:(0,B.jsx)(`div`,{className:`chat-prose`,title:u?void 0:n,children:a})]})}var TR=`C13 7.5 15.4 12.6 20.6 14.8C21.4 15.2 21.1 16 20.2 16`;function ER(){return(0,B.jsxs)(`svg`,{className:`cs-ut`,viewBox:`0 0 22 16`,"aria-hidden":`true`,focusable:`false`,children:[(0,B.jsx)(`path`,{d:`M13 0${TR}H6`,className:`cs-ut-edge`}),(0,B.jsx)(`path`,{d:`M0 0H13${TR}H0Z`,className:`cs-ut-fill`})]})}function DR({time:e,head:t,note:n,children:r,below:i,actions:a,fresh:o}){return(0,B.jsxs)(`div`,{className:`group/msg relative flex flex-col items-end gap-1`,children:[(0,B.jsxs)(`div`,{className:`chat-bubble cs-umsg`,"data-new":o||void 0,title:e,children:[(0,B.jsx)(`i`,{className:`cs-ue`,"aria-hidden":`true`,children:(0,B.jsx)(`b`,{className:`cs-ub`})}),(0,B.jsx)(`i`,{className:`cs-uf`,"aria-hidden":`true`,children:(0,B.jsx)(`b`,{className:`cs-ub`})}),(0,B.jsx)(ER,{}),(0,B.jsx)(`div`,{className:`cs-ux`,children:r})]}),n?(0,B.jsxs)(`div`,{className:`chat-meta flex items-center gap-2 pr-[9px]`,"data-note":``,children:[a,(0,B.jsx)(`span`,{children:n})]}):a?(0,B.jsx)(`div`,{className:`chat-meta absolute top-1/2 right-full mr-2 flex -translate-y-1/2 items-center gap-2`,children:a}):null,i]})}function OR({failed:e,auto:t,children:n}){return(0,B.jsx)(`div`,{role:`note`,className:Y(`chat-note`,e&&`text-destructive`,t&&`chat-note-auto`),children:(0,B.jsx)(`span`,{children:n})})}function kR({text:e}){return(0,B.jsxs)(`span`,{className:`activity-shimmer`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:e}),[...e].map((e,t)=>(0,B.jsx)(`span`,{"aria-hidden":`true`,style:{"--i":t},children:e},t))]})}function AR({onClick:e,className:t}){return(0,B.jsx)(`button`,{type:`button`,"aria-label":`Jump to latest`,title:`Jump to latest`,onClick:e,className:Y(`jump-latest btn-outline grid size-9 place-items-center rounded-full border bg-card text-foreground shadow-card outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t),children:(0,B.jsx)(Mf,{"aria-hidden":`true`,className:`size-4`})})}var jR=8;function MR(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function NR({done:e,total:t}){let n=Math.min(t,jR);if(n<=0)return null;let r=Math.min(n,Math.round(Math.max(0,e)/t*n));return(0,B.jsx)(`span`,{className:`cs-pips`,"aria-hidden":`true`,style:{"--n":n,"--d":r}})}function PR({mark:e,className:t}){return(0,B.jsxs)(`span`,{"aria-hidden":`true`,className:Y(`cs-mk`,t),"data-s":e===`open`?void 0:e,children:[(0,B.jsx)(`svg`,{className:`cs-ck`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7.5`})}),(0,B.jsx)(`svg`,{className:`cs-xx`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M7 7l10 10M17 7L7 17`})}),(0,B.jsx)(`svg`,{className:`cs-sl`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M6 18L18 6`})})]})}function FR({check:e,live:t,waiting:n,className:r}){return(0,B.jsx)(PR,{mark:e===`done`?`done`:e===`dropped`?`drop`:n?`warn`:t?`now`:`open`,...r?{className:r}:{}})}var IR=`auto mode`;function LR(e){return e<10?`0${e}`:String(e)}function RR(e){if(!Number.isFinite(e))return`0`;let t=new Date(e);return`${LR(t.getHours())}:${LR(t.getMinutes())}`}function zR(e){if(!Number.isFinite(e)||e<5e3)return`now`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}function BR(e){let t=zR(e);return t===`now`?`just now`:`${t} ago`}function VR({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,B.jsxs)(`section`,{className:Y(`workspace-frame group/frame relative flex min-h-0 min-w-0 flex-col rounded-xl border shadow-xs`,i&&`flex-none`,n),...s,children:[e||t||a?(0,B.jsxs)(`div`,{className:Y(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,B.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,B.jsx)(`span`,{}),(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,B.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-label":i?`Expand ${c}`:`Minimize ${c}`,title:`${i?`Expand`:`Minimize`}${o?` · ${o}`:``}`,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,"aria-describedby":`focused-action-help`,onClick:a,className:`btn-ghost -mr-1.5 inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2 text-muted-foreground transition-[box-shadow,color,scale] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] motion-reduce:active:scale-100`,children:[o?(0,B.jsx)(IT,{chord:o,className:`kbd-hint`}):null,(0,B.jsx)(Yf,{"aria-hidden":`true`,className:Y(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function HR(e,t){if(e===`app.sidebar`&&t==null){let e=globalThis.matchMedia;return typeof e==`function`&&e(`(max-width: 1023.98px)`).matches}return e===`lobby.thinking`||t===`1`}var UR=`bot-lobby.collapsed.`,WR=new Set,GR=new Map;function KR(e){if(GR.has(e))return GR.get(e);if(e===`lobby.thinking`)return HR(e);try{return HR(e,localStorage.getItem(UR+e))}catch{return!1}}function qR(e,t){GR.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(UR+e,t?`1`:`0`)}catch{}for(let e of[...WR])e()}function JR(e){return WR.add(e),()=>{WR.delete(e)}}function YR(e){qR(e,!KR(e))}function XR(e){return[(0,m.useSyncExternalStore)(JR,()=>KR(e),()=>HR(e)),(0,m.useCallback)(()=>qR(e,!KR(e)),[e])]}var ZR=`lobby.activity.open`;function QR({entry:e}){return e.pending?(0,B.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--orb)]`}):e.kind===`error`?(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,B.jsx)(ah,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,B.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function $R({entry:e}){return(0,B.jsxs)(`li`,{className:`cs-wl activity-step`,title:RR(e.at),style:e.pending?{"--orb":xR(e.source)}:void 0,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,B.jsx)(QR,{entry:e})}),(0,B.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,B.jsx)(`b`,{children:vR(e.source)}),` `,(0,B.jsxs)(`span`,{className:e.kind===`error`?`text-destructive`:e.pending?`text-foreground`:void 0,children:[CL(e.text),e.pending?`…`:``]})]})]})}function ez(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function tz(e){let t=[...e].reverse().find(e=>e.pending),n=[...new Set(e.map(e=>vR(e.source)))];return{...t?{live:t}:{},took:(e.at(-1)?.at??0)-(e[0]?.at??0),count:`${e.length} ${e.length===1?`step`:`steps`}`,sources:n.length>3?`${n.slice(0,3).join(`, `)} +${n.length-3}`:n.join(`, `),errors:e.filter(e=>e.kind===`error`).length,warnings:e.filter(e=>e.kind===`warning`).length}}function nz(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function rz({entries:e}){let[t]=XR(ZR),[n,r]=(0,m.useState)();(0,m.useEffect)(()=>r(void 0),[t]);let i=n??t,a=(0,m.useId)(),{live:o,took:s,count:c,sources:l,errors:u,warnings:d}=tz(e),f=nz(!!o),p=o?{"--orb":xR(o.source)}:void 0;return(0,B.jsxs)(`div`,{className:`cs-work activity-run`,"data-live":o?!0:void 0,"data-open":i||void 0,style:p,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":a,onClick:()=>r(!i),className:`cs-wrow activity-toggle`,children:[o?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`cs-wtx`,children:`Working`}),(0,B.jsxs)(`span`,{className:`activity-live-step min-w-0 truncate`,children:[(0,B.jsx)(`span`,{className:Y(`font-medium`,yR(o.source)),children:vR(o.source)}),` `,o.text]},o.id),(0,B.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[c,e[0]&&f-e[0].at>=1e3?` · ${ez(f-e[0].at)}`:``]})]}):(0,B.jsxs)(`span`,{className:`min-w-0 truncate`,children:[s>=1e3?`Worked for ${ez(s)}`:`Worked`,` · `,c,l?` · ${l}`:``]}),u?(0,B.jsxs)(`span`,{className:`shrink-0 text-[var(--bad)]`,children:[u,` `,u===1?`error`:`errors`]}):null,d?(0,B.jsxs)(`span`,{className:`shrink-0 text-[var(--warn)]`,children:[d,` `,d===1?`warning`:`warnings`]}):null,(0,B.jsx)(Yf,{"aria-hidden":`true`,className:`cs-chev size-3.5 shrink-0`})]}),(0,B.jsx)(`div`,{className:`cs-wbody`,inert:!i,children:(0,B.jsx)(`div`,{className:`cs-wi`,children:(0,B.jsx)(`ol`,{id:a,"aria-label":`Activity`,className:`cs-wlines`,children:i?e.map(e=>(0,B.jsx)($R,{entry:e},e.id)):null})})})]})}var iz=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,az=260,oz=200,sz=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function cz(e){let t=[],n=[],r=!1;for(let i of e){if(/^\s*(```|~~~)/.test(i)&&(r=!r),!r&&!i.trim()){n.length&&t.push(n.join(`
|
|
92
|
+
`).filter(Boolean),r=[];for(let t of n){let n=YI.exec(t);if(!n)return{body:e,files:[]};let i=n[1].split(/[\\/]/).pop()??``;if(!/^[\w.-]+$/.test(i))return{body:e,files:[]};r.push({id:i,name:i.replace(/^[a-z0-9]+-/,``),mime:n[2]})}return r.length>0?{body:e.slice(0,t).trimEnd(),files:r}:{body:e,files:[]}}var ZI=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function QI({files:e}){return e.length===0?null:(0,B.jsx)(`ul`,{className:`mt-2 flex min-w-0 max-w-full flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,B.jsx)(`li`,{children:ZI.has(e.mime)?(0,B.jsx)(`a`,{href:P(`/files/preview/attachments/${e.id}`),target:`_blank`,rel:`noopener noreferrer`,onClick:KI({src:P(`/files/preview/attachments/${e.id}`),alt:e.name}),"aria-label":`${e.name}: open the image`,className:`block max-w-full overflow-hidden rounded-lg border border-border bg-muted/40 transition-transform duration-150 ease-snap hover:scale-[1.02] focus-visible:outline-2 focus-visible:outline-ring`,children:(0,B.jsx)(`img`,{src:P(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-[min(14rem,100%)] object-cover`})}):(0,B.jsxs)(`span`,{className:`inline-flex max-w-[min(16rem,100%)] min-w-0 items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[e.mime===`application/pdf`?(0,B.jsx)(jp,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,B.jsx)(hm,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}function $I(e){return e(),()=>{}}var eL=8;function tL(e,t=24){let[n,r]=(0,m.useState)(t),i=(0,m.useRef)(8),a=n<e;return(0,m.useEffect)(()=>{if(!a)return;let e=0,t=$I(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,C_.flushSync)(()=>r(e=>e+i.current));let t=Math.max(1,performance.now()-e);i.current=Math.max(2,Math.min(400,Math.round(i.current*eL/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}var nL=`bot-lobby.code.wrap`,rL=`bot-lobby.code.layout`,iL=new Set,aL={open:!1,request:0};function oL(){for(let e of[...iL])e()}function sL(e){return iL.add(e),()=>{iL.delete(e)}}function cL(e,t){aL={open:!0,...e?{path:e}:aL.path?{path:aL.path}:{},...t?{mode:t}:{},request:aL.request+1},oL()}function lL(){aL.open&&(aL={...aL,open:!1},oL())}function uL(){aL.open?lL():cL()}function dL(){return(0,m.useSyncExternalStore)(sL,()=>aL)}function fL(e){try{return localStorage.getItem(e)}catch{return null}}function pL(e,t){try{localStorage.setItem(e,t)}catch{}}var mL=fL(nL)===`1`,hL=fL(rL)===`split`?`split`:`unified`;function gL(e){mL=e,pL(nL,e?`1`:`0`),oL()}function _L(e){hL=e,pL(rL,e),oL()}function vL(){return(0,m.useSyncExternalStore)(sL,()=>mL)}function yL(){return(0,m.useSyncExternalStore)(sL,()=>hL)}var bL=new Set(`ts tsx mts cts js jsx mjs cjs json jsonc json5 jsonl md mdx css scss sass less html htm vue svelte astro py rb go rs java kt kts swift c h cc cpp hpp cs php lua sh bash zsh fish ps1 sql graphql gql yml yaml toml ini cfg conf env xml svg txt lock prisma proto dockerfile mk gradle`.split(` `));function xL(e){let t=e.trim();if(!t||t.length>300||/\s/.test(t)||/^[a-z][\w+.-]*:\/\//i.test(t))return;let n=t.replace(/:\d+(?::\d+)?$/,``).replace(/^\.\//,``);if(!/^[\w@~./-]+$/.test(n)||n.endsWith(`/`)||n.includes(`..`))return;let r=n.split(`/`).at(-1)??``,i=/^[\w@.-]*[A-Za-z_][\w@-]*\.[A-Za-z][\w]{0,9}$/.test(r)||/^\.[A-Za-z][\w.-]*$/.test(r),a=/^(Dockerfile|Makefile|LICENSE|Procfile|Gemfile|Rakefile)$/.test(r)&&n.includes(`/`);if((i||a)&&!/^v?\d+(\.\d+)+$/.test(r)&&(n.includes(`/`)||r.startsWith(`.`)||bL.has(r.slice(r.lastIndexOf(`.`)+1).toLowerCase())))return n}function SL({path:e,children:t,className:n}){return(0,B.jsx)(`button`,{type:`button`,"data-file-link":e,title:`Open ${e} in the code viewer`,onClick:t=>{t.stopPropagation(),cL(e)},className:Y(`file-link`,n),children:t})}function CL(e){return e.split(/(\s+)/).map((e,t)=>{let n=e.replace(/^[("'`[]+|[)"'`\],.;:!?]+$/g,``),r=n?xL(n):void 0;if(!r)return e;let i=e.indexOf(n);return(0,B.jsxs)(`span`,{children:[e.slice(0,i),(0,B.jsx)(SL,{path:r,children:n}),e.slice(i+n.length)]},t)})}function wL(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(wL).join(``)}function TL(e,t=!1){let n=t||e.tagName===`a`;e.tagName===`code`&&(e.properties={...e.properties,copyBlocked:n,blockCode:t===!1&&e.properties?.blockCode});for(let t of e.children??[])e.tagName===`pre`&&(t.properties={...t.properties,blockCode:!0}),TL(t,n)}function EL(){return e=>TL(e)}var DL=/(?<![\w/@.:-])((?:\.{1,2}\/)?(?:[\w@.-]+\/)+[\w@.-]*[A-Za-z_][\w@-]*\.[A-Za-z]\w{0,9})(:\d+)?(?![\w/])/g;function OL(e){if(e.tagName===`code`||e.tagName===`pre`||e.tagName===`a`)return;let t=e.children;if(!t)return;let n=[];for(let e of t){if(e.type!==`text`||!e.value||!e.value.includes(`/`)){OL(e),n.push(e);continue}let t=0;for(let r of e.value.matchAll(DL)){let i=xL(r[1]);i&&(r.index>t&&n.push({type:`text`,value:e.value.slice(t,r.index)}),n.push({type:`element`,tagName:`span`,properties:{dataFilePath:i},children:[{type:`text`,value:r[0]}]}),t=r.index+r[0].length)}t===0?n.push(e):t<e.value.length&&n.push({type:`text`,value:e.value.slice(t)})}e.children=n}function kL(){return e=>OL(e)}function AL(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await LI(e,navigator.clipboard),n(!0),H.success(`Code copied.`)}catch{H.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function jL({text:e,children:t,block:n=!1}){let{copy:r}=AL(e),i=(0,m.useRef)(void 0);return(0,B.jsxs)(`code`,{role:`button`,tabIndex:0,"aria-label":`Copy code`,"aria-keyshortcuts":`Enter Space`,title:`Copy code · Enter / Space`,className:`cursor-copy focus-visible:outline-2 focus-visible:outline-ring`,onPointerDown:e=>{i.current={x:e.clientX,y:e.clientY,moved:!1}},onPointerMove:e=>{let t=i.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>4&&(t.moved=!0)},onClick:e=>{e.stopPropagation(),II(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),II(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,B.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function ML({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=AL(FI(n,r?.position,!0)??wL(r)),o=r?.children?.find(e=>e.tagName===`code`)?.properties?.className,s=(Array.isArray(o)?o:[]).map(String).find(e=>e.startsWith(`language-`))?.slice(9);return(0,B.jsxs)(`div`,{className:`relative my-3 rounded-lg bg-muted`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,B.jsx)(EI,{label:i?`Copied`:`Copy the code`,icon:i?Jf:yp,iconOnly:!0,onClick:()=>void a()})]}),(0,B.jsx)(`pre`,{className:`!my-0 overflow-x-auto !rounded-t-none !bg-transparent px-3 pb-3 text-sm leading-relaxed [&>code]:block`,children:t})]})}function NL(e){return{pre:t=>(0,B.jsx)(ML,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,B.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode,a=i?void 0:xL(wL(r));return a?(0,B.jsx)(SL,{path:a,children:(0,B.jsx)(`code`,{children:n})}):(0,B.jsx)(jL,{text:FI(e,r?.position,i)??wL(r),block:i,children:n})},span:({node:e,children:t,...n})=>{let r=e?.properties?.dataFilePath;return typeof r==`string`?(0,B.jsx)(SL,{path:r,children:t}):(0,B.jsx)(`span`,{...n,children:t})},a:({node:e,href:t,children:n})=>{let r=t?P(t):void 0;return(0,B.jsx)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer nofollow`,onClick:r&&GI(t)?KI({src:r,alt:wL(e)||void 0}):void 0,children:n})},img:({src:e,alt:t})=>{let n=typeof e==`string`?P(e):void 0,r=(0,B.jsx)(`img`,{src:n,alt:t??``,loading:`lazy`});return n?(0,B.jsx)(`button`,{type:`button`,className:`md-image`,"aria-label":t?`${t}: open the image`:`Open the image`,onClick:KI({src:n,alt:t??void 0}),children:r}):r},table:({children:e})=>(0,B.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,B.jsx)(`table`,{className:`w-full border-collapse text-sm`,children:e})})}}var PL=(0,m.memo)(function({text:e}){return(0,B.jsx)(hN,{remarkPlugins:[bI],rehypePlugins:[EL,kL],urlTransform:kI,components:NL(e),children:e})}),FL=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=XI(e),i=n?PI(n):[],a=tL(i.length,3);return(0,B.jsxs)(`div`,{className:Y(`md-body`,t),children:[i.slice(0,a).map((e,t)=>(0,B.jsx)(PL,{text:e},t)),(0,B.jsx)(QI,{files:r})]})});function IL(e,t){let n=new Set(t.toLowerCase().match(/[a-z][a-z0-9]{3,}/g)??[]);return e.map(e=>({note:e,score:(e.text.toLowerCase().match(/[a-z][a-z0-9]{3,}/g)??[]).filter(e=>n.has(e)).length})).filter(e=>e.score>1).sort((e,t)=>t.score-e.score).slice(0,3).map(e=>e.note)}function LL({notes:e,onOpen:t,onSaved:n}){let r=vE(`lobby`).data,[i,a]=(0,m.useState)(),[o,s]=(0,m.useState)(!1),c=r?.chat.at(-1)?.id??0;if((0,m.useEffect)(()=>{let e=e=>{let t=String(e.detail??``);s(!1),a({text:t,at:Date.now(),after:c})};return window.addEventListener(hD,e),()=>window.removeEventListener(hD,e)},[c]),!i)return null;let l=r?.chat.find(e=>e.id>i.after&&e.role!==`you`&&e.role!==`note`),u=l?.text??r?.reply??``,d=u?IL(e,`${i.text} ${u}`):[],f=async()=>{await U(`knowledge.add`,{agent:`master`,file:`knowledge.md`,text:`- ${u.replace(/\s+/g,` `).trim()}`})&&(s(!0),n())};return(0,B.jsxs)(`section`,{className:`cs-knask`,"aria-label":`Answer from saved knowledge`,"aria-live":`polite`,children:[(0,B.jsxs)(`div`,{className:`cs-ah`,children:[(0,B.jsx)(qm,{"aria-hidden":`true`,className:`size-3.5`}),`Answer from saved knowledge`,(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-tip cs-b ml-auto`,"data-tip":`Dismiss`,"aria-label":`Dismiss the answer`,onClick:()=>a(void 0),children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})})]}),(0,B.jsxs)(`p`,{className:`cs-aq`,children:[`You asked: `,i.text]}),(0,B.jsx)(`div`,{className:`cs-aa`,children:u?(0,B.jsx)(FL,{text:u}):(0,B.jsx)(`span`,{className:`cs-wtx`,children:`Looking through what the agents know`})}),d.length?(0,B.jsx)(`div`,{className:`cs-bs`,children:d.map((e,n)=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-bsr`,onClick:()=>t(e.key),children:[(0,B.jsx)(`span`,{className:`cs-n`,children:n+1}),(0,B.jsx)(`span`,{className:`cs-dot`,style:{background:tD[e.agent]}}),(0,B.jsx)(`span`,{className:`cs-t`,children:e.text}),(0,B.jsxs)(`span`,{className:`cs-f`,children:[HE[e.agent],` · `,e.file]})]},e.key))}):null,l?(0,B.jsx)(`div`,{className:`cs-aact`,children:(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,disabled:o,onClick:()=>void f(),children:[(0,B.jsx)(Dm,{"aria-hidden":`true`,className:`size-3.5`}),o?`Saved as a note`:`Save as a note`]})}):null]})}var RL=m.createContext({title:``,description:``});function zL({children:e,open:t,onOpenChange:n,defaultOpen:r}){let i=m.useId(),a=m.useId(),o=m.Children.toArray(e),s=o.filter(e=>m.isValidElement(e)&&e.type===BL),c=o.filter(e=>!s.includes(e));return(0,B.jsx)(Cw,{...t===void 0?{}:{open:t},...n?{onOpenChange:n}:{},...r===void 0?{}:{defaultOpen:r},children:(0,B.jsxs)(RL.Provider,{value:{title:i,description:a},children:[(0,B.jsx)(ww,{asChild:!0,children:(0,B.jsx)(`span`,{"data-slot":`alert-dialog`,className:`inline-flex max-w-full`,children:c})}),s]})})}function BL({className:e,children:t,...n}){let r=m.useContext(RL);return(0,B.jsx)(Ew,{children:(0,B.jsx)(Dw,{"data-slot":`alert-dialog-content`,role:`alertdialog`,"aria-labelledby":r.title,"aria-describedby":r.description,side:`bottom`,align:`end`,sideOffset:8,collisionPadding:12,className:Y(`cs-cfm z-[1100] grid w-[min(20rem,calc(100vw-2rem))] gap-3 rounded-2xl p-3.5 text-sm outline-none origin-(--radix-popover-content-transform-origin)`,e),...n,children:t})})}function VL({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:Y(`flex flex-col gap-1`,e),...t})}function HL({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:Y(`flex flex-row justify-end gap-2`,e),...t})}function UL({className:e,...t}){let n=m.useContext(RL);return(0,B.jsx)(`h2`,{id:n.title,"data-slot":`alert-dialog-title`,className:Y(`m-0 text-[13.5px] font-semibold text-foreground`,e),...t})}function WL({className:e,...t}){let n=m.useContext(RL);return(0,B.jsx)(`p`,{id:n.description,"data-slot":`alert-dialog-description`,className:Y(`m-0 text-[12.5px] leading-snug text-muted-foreground`,e),...t})}function GL({className:e,variant:t=`default`,...n}){return(0,B.jsx)(Ow,{asChild:!0,children:(0,B.jsx)(OT,{variant:t,size:`sm`,"data-slot":`alert-dialog-action`,className:Y(`h-7 gap-1 px-2.5`,e),...n})})}function KL({className:e,...t}){return(0,B.jsx)(Ow,{asChild:!0,children:(0,B.jsx)(OT,{variant:`outline`,size:`sm`,"data-slot":`alert-dialog-cancel`,className:Y(`h-7 gap-1 px-2.5`,e),...t})})}function qL({label:e,text:t,shortcut:n,title:r,description:i,confirmLabel:a,onConfirm:o,icon:s,disabled:c,variant:l=`outline`,iconOnly:u,compact:d,className:f,side:p}){let[h,g]=(0,m.useState)(!1),_=qT(h,KT.confirm),v=l===`destructive`;return RE(`y`,()=>{g(!1),o()},{enabled:h&&_,inDialog:!0}),(0,B.jsxs)(zL,{open:h&&_,onOpenChange:g,children:[(0,B.jsx)(EI,{label:e,icon:s,tone:v?`danger`:`neutral`,disabled:c,shortcut:n,iconOnly:u,...d?{"data-compact":!0,className:`size-8`}:f?{className:f}:{},...p?{side:p}:{},...t?{text:t}:{},onClick:()=>g(!0)}),(0,B.jsxs)(BL,{children:[(0,B.jsxs)(VL,{children:[(0,B.jsx)(UL,{children:r}),(0,B.jsx)(WL,{children:i})]}),(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:v?`destructive`:`default`,onClick:o,children:[a,(0,B.jsx)(IT,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function JL({text:e,className:t,onClick:n}){let r=e.split(/(`[^`]+`)/g).filter(Boolean);return(0,B.jsx)(`p`,{className:t,onClick:n,children:r.map((e,t)=>e.startsWith("`")&&e.endsWith("`")&&e.length>2?(0,B.jsx)(`span`,{className:`cs-cod`,children:e.slice(1,-1)},t):(0,B.jsx)(`span`,{children:e},t))})}function YL({initial:e,label:t,action:n,placeholder:r,onSave:i,onCancel:a}){let[o,s]=(0,m.useState)(e),[c,l]=(0,m.useState)(!1),u=async()=>{if(c||!o.trim())return;l(!0);let e=await i(o.trim());l(!1),e&&a()};return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`textarea`,{autoFocus:!0,"aria-label":t,className:`cs-knta`,value:o,placeholder:r,disabled:c,onChange:e=>s(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),a()):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),u()))}}),(0,B.jsxs)(`div`,{className:`cs-knea`,children:[(0,B.jsx)(`span`,{className:`cs-h2`,children:UE}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm`,onClick:a,disabled:c,children:`Cancel`}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,onClick:()=>void u(),disabled:c||!o.trim(),children:n})]})]})}function XL(e){let t=aD(e.since);return e.source?`${e.source}${t?` · ${t}`:``}`:`${HE[e.agent]} · ${e.file}`}function ZL({note:e,selected:t,dragging:n,activeTags:r,onOpen:i,onTag:a,onDragStart:o,onDragEnd:s,onSave:c,onDelete:l,onPin:u,onReview:d,editing:f,onEditing:p}){let[h,g]=(0,m.useState)(!1),_=f??h,v=e=>p?p(e):g(e),y=tD[e.agent];return(0,B.jsxs)(`article`,{className:`cs-knc`,"data-sel":t||void 0,"data-drag":n||void 0,draggable:!_,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.key),o()},onDragEnd:s,"aria-label":`${HE[e.agent]}: ${e.text}`,children:[(0,B.jsxs)(`div`,{className:`cs-knch`,style:{"--c":y},children:[(0,B.jsx)(`span`,{className:`cs-knd`,"aria-hidden":`true`,children:(0,B.jsx)(zp,{className:`size-3.5`})}),(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:nD(e.agent)}),(0,B.jsx)(`b`,{children:HE[e.agent]}),(0,B.jsxs)(`span`,{className:`cs-fl`,children:[`· `,e.file]}),(0,B.jsxs)(`div`,{className:`cs-kna`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-pin cs-tip cs-b`,"data-on":e.pinned?`true`:`false`,"data-tip":e.pinned?`Unpin`:`Pin to the top`,"aria-label":e.pinned?`Unpin`:`Pin to the top`,"aria-pressed":e.pinned,onClick:u,children:(0,B.jsx)(Cm,{className:`size-3.5`,"aria-hidden":`true`})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-h cs-tip cs-b`,"data-tip":`Edit`,"aria-label":`Edit the note`,onClick:()=>v(!0),children:(0,B.jsx)(ym,{className:`size-3.5`,"aria-hidden":`true`})}),(0,B.jsx)(qL,{iconOnly:!0,className:`cs-knb cs-h cs-dg`,icon:rh,label:`Delete the note`,title:`Delete this note?`,description:`The note and its comments are removed. The version before is archived.`,confirmLabel:`Delete note`,variant:`destructive`,onConfirm:l})]})]}),_?(0,B.jsx)(YL,{initial:e.entry.text,label:`Edit note`,action:`Save`,onSave:c,onCancel:()=>v(!1)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JL,{className:`cs-knx`,text:e.text,onClick:i}),e.comments.map(e=>(0,B.jsxs)(`p`,{className:`cs-knn`,children:[(0,B.jsx)(sm,{"aria-hidden":`true`,className:`size-3.5`}),(0,B.jsx)(`span`,{children:e.text})]},e.id)),e.flag?(0,B.jsxs)(`p`,{className:`cs-knfl`,children:[(0,B.jsx)(rp,{"aria-hidden":`true`,className:`size-3.5`}),(0,B.jsx)(`span`,{children:e.flag.kind===`stale`?`Not used in ${e.flag.days} days`:`A newer proposal in the Inbox disagrees with this`}),e.flag.kind===`stale`?(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm`,title:`Takes it out of the file; the version before is archived`,onClick:l,children:`Archive`}):(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm`,onClick:d,children:`Review`})]}):null,(0,B.jsxs)(`div`,{className:`cs-knf3`,children:[e.tags.length?(0,B.jsx)(`div`,{className:`cs-tg`,children:e.tags.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-ktg`,"data-on":r.includes(e)||void 0,onClick:()=>a(e),children:[`#`,e]},e))}):null,(0,B.jsxs)(`div`,{className:`cs-pv`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`cs-src`,onClick:i,children:[(0,B.jsx)(Yp,{"aria-hidden":`true`,className:`size-3 flex-none`}),(0,B.jsx)(`span`,{children:XL(e)})]}),(0,B.jsxs)(`span`,{className:`cs-use`,children:[(0,B.jsx)(`span`,{className:`cs-ubar`,"aria-hidden":`true`,children:(0,B.jsx)(`i`,{style:{width:`${Math.min(100,e.uses.length*6)}%`}})}),oD(e.uses.length)]})]})]})]})]})}var QL=85;function $L({proposals:e,onChanged:t}){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=e.filter(e=>(e.confidence??0)>=QL),s=async e=>{a(!0);let n=!0;for(let t of e)n=await t()!==void 0&&n;return a(!1),t(),n};return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`cs-kih`,children:[(0,B.jsx)(`p`,{children:e.length?`${e.length} ${e.length===1?`proposal`:`proposals`} from finished work, waiting for you`:`Nothing waiting`}),o.length?(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,disabled:i,onClick:()=>void s(o.map(e=>()=>U(`knowledge.accept`,{id:e.id}))),children:[(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3.5`}),`Accept `,o.length,` confident`]}):null]}),e.length?(0,B.jsx)(`div`,{className:`cs-kib`,children:e.map(e=>{let t=(e.confidence??0)>=QL;return(0,B.jsxs)(`article`,{className:`cs-kir`,style:{"--c":tD[e.agent]},"aria-label":`Proposal for ${HE[e.agent]}`,children:[(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:nD(e.agent)}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[n===e.id?(0,B.jsx)(`div`,{className:`cs-edi`,children:(0,B.jsx)(YL,{initial:e.text,label:`Edit before accepting`,action:`Accept`,onSave:t=>s([()=>U(`knowledge.accept`,{id:e.id,text:t})]),onCancel:()=>r(void 0)})}):(0,B.jsx)(`p`,{className:`cs-tx`,children:e.text}),(0,B.jsxs)(`div`,{className:`cs-mt`,children:[(0,B.jsx)(`b`,{style:{color:tD[e.agent],fontWeight:600},children:HE[e.agent]}),(0,B.jsxs)(`span`,{children:[`· `,e.source,e.at?` · ${aD(e.at)}`:``]}),e.confidence===void 0?null:(0,B.jsxs)(`span`,{className:`cs-kcf`,"data-k":t?`ok`:`chk`,children:[`· `,e.confidence,`% `,t?`confident`:`worth a look`]})]}),e.replaces?(0,B.jsxs)(`p`,{className:`cs-rp`,children:[(0,B.jsx)(`b`,{children:`Replaces`}),(0,B.jsx)(`s`,{children:e.replaces})]}):null]}),(0,B.jsxs)(`div`,{className:`cs-ac`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,disabled:i||n===e.id,onClick:()=>void s([()=>U(`knowledge.accept`,{id:e.id})]),children:[(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3.5`}),`Accept`]}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":`Edit first`,"aria-label":`Edit first`,disabled:i,onClick:()=>r(e.id),children:(0,B.jsx)(ym,{"aria-hidden":`true`,className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":`Dismiss`,"aria-label":`Dismiss`,disabled:i,onClick:()=>void s([()=>U(`knowledge.dismiss`,{id:e.id})]),children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})})]})]},e.id)})}):(0,B.jsxs)(`div`,{className:`cs-knempty`,children:[(0,B.jsx)(`b`,{children:`Inbox is clear`}),`New proposals from finished work land here for your review.`]})]})}function eR(e,t,n,r=!0){gE();let[i,a]=(0,m.useState)({loading:!0,at:0}),[o,s]=(0,m.useState)(0),c=[N.status().connection,...n.map(e=>N.get(e).version)].join(`,`),l=JSON.stringify(t);(0,m.useEffect)(()=>{if(!r)return;let t=!0,n=performance.now();return a(e=>({...e,loading:!0})),I(e,JSON.parse(l)).then(e=>t&&a({data:e,loading:!1,at:n}),e=>t&&a(t=>({...t,error:e instanceof Error?e.message:String(e),loading:!1}))),()=>{t=!1}},[e,l,c,o,r]);let u=(0,m.useCallback)(()=>s(e=>e+1),[]);return{data:i.data,error:i.error,loading:i.loading,requestedAt:i.at,reload:u}}function tR(){let e=eR(`tasks.list`,{},[`tasks`]);return(0,m.useMemo)(()=>Object.fromEntries((e.data?.rows??[]).map(e=>[e.id,e.title])),[e.data])}function nR({note:e,onPin:t,onEdit:n,onComment:r,onDelete:i}){return(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`cs-knwh min-w-0`,style:{"--c":tD[e.agent]},children:[(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:nD(e.agent)}),(0,B.jsxs)(`span`,{className:`truncate`,children:[(0,B.jsx)(`b`,{children:HE[e.agent]}),` · `,e.file]})]}),(0,B.jsxs)(`div`,{className:`cs-knwhx`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":e.pinned?`Unpin`:`Pin to the top`,"aria-label":e.pinned?`Unpin`:`Pin to the top`,"aria-pressed":e.pinned,"data-on":e.pinned||void 0,onClick:t,children:(0,B.jsx)(Cm,{"aria-hidden":`true`,className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":`Edit`,"aria-label":`Edit the note`,onClick:n,children:(0,B.jsx)(ym,{"aria-hidden":`true`,className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib cs-tip cs-b`,"data-tip":`Comment`,"aria-label":`Comment on the note`,onClick:r,children:(0,B.jsx)(am,{"aria-hidden":`true`,className:`size-3.5`})}),(0,B.jsx)(qL,{iconOnly:!0,side:`bottom`,className:`cs-kc cs-sm cs-ib`,icon:rh,label:`Delete the note`,title:`Delete this note?`,description:`The note and its comments are removed. The version before is archived.`,confirmLabel:`Delete note`,variant:`destructive`,onConfirm:i})]})]})}function rR(e){if(e===`you`)return{name:`You`,letter:`Y`,color:`var(--c-orc)`};let t=VE.find(t=>HE[t].toLowerCase().startsWith(e.toLowerCase())||t===`master`&&/oracle|master/i.test(e));return{name:e,letter:e.charAt(0).toUpperCase(),color:t?tD[t]:`var(--muted-foreground)`}}function iR({note:e,view:t,commenting:n,onCommenting:r,onTag:i,onMove:a,onChanged:o}){let[s,c]=(0,m.useState)(!1),l=tR(),{agent:u,file:d}=e,f=KE(e.entry),p=async e=>{c(!0);let t=await e()!==void 0;return c(!1),t&&o(),t},h=sD(e.uses),g=[...new Map(e.uses.filter(e=>e.taskId).map(e=>[e.taskId,e.at])).entries()].slice(0,5);return(0,B.jsxs)(`article`,{"aria-label":`${HE[u]} note`,children:[(0,B.jsx)(JL,{className:`cs-knwt`,text:e.text}),e.comments.length?(0,B.jsx)(`ul`,{className:`cs-kwu mt-2.5`,children:e.comments.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{title:e.text,children:e.text}),(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-tip cs-b`,"data-tip":`Take it back`,"aria-label":`Take the comment back`,disabled:s,onClick:()=>void p(()=>U(`knowledge.unnote`,{id:e.id})),children:(0,B.jsx)(sh,{"aria-hidden":`true`,className:`size-3.5`})})]},e.id))}):null,n?(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(YL,{initial:``,label:`Comment on this note`,action:`Add comment`,placeholder:`Tell the agent what to change; it reads comments with the note`,onSave:e=>p(()=>U(`knowledge.comment`,{agent:u,file:d,ref:f,text:e})),onCancel:()=>r(!1)})}):null,e.tags.length?(0,B.jsx)(`div`,{className:`cs-knwtg`,children:e.tags.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-ktg`,onClick:()=>i(e),children:[`#`,e]},e))}):null,(0,B.jsx)(`h3`,{className:`cs-kwh`,children:`Where it came from`}),e.history.length?(0,B.jsx)(`ul`,{className:`cs-kwtl`,children:e.history.map(e=>{let t=rR(e.by);return(0,B.jsxs)(`li`,{className:`cs-kwi`,style:{"--c":t.color},children:[(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:t.letter}),(0,B.jsxs)(`div`,{className:`cs-tx`,children:[(0,B.jsx)(`b`,{children:t.name}),e.what,(0,B.jsx)(`em`,{children:aD(e.at)})]}),e.before?(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-tip cs-b`,"data-tip":`Restore this version`,"aria-label":`Restore the version before: ${e.before}`,disabled:s,onClick:()=>void p(()=>U(`knowledge.restore`,{agent:u,file:d,ref:f,event:e.id})),children:(0,B.jsx)(sh,{"aria-hidden":`true`,className:`size-3.5`})}):null]},e.id)})}):(0,B.jsxs)(`p`,{className:`cs-hd2 m-0`,children:[`It was in `,HE[u],`'s `,d,` before its history was kept.`]}),t?.over?(0,B.jsx)(`p`,{className:`cs-kagw`,children:GE(d)}):null,(0,B.jsxs)(`h3`,{className:`cs-kwh`,children:[`Used by agents`,(0,B.jsx)(`span`,{children:e.uses.length?`${e.uses.length} ${e.uses.length===1?`use`:`uses`} in 30 days`:`never`})]}),(0,B.jsx)(`div`,{className:`cs-kwb`,"aria-hidden":`true`,children:h.map((e,t)=>(0,B.jsx)(`i`,{"data-z":e===0||void 0,style:{height:`${e||8}%`}},t))}),g.length?(0,B.jsx)(`ul`,{className:`cs-kwu mt-3`,children:g.map(([e,t])=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3.5`}),(0,B.jsx)(`span`,{children:l[e]??`Task ${e}`}),(0,B.jsx)(`i`,{children:aD(t)})]},e))}):e.uses.length===0?(0,B.jsx)(`p`,{className:`cs-hd2 m-0 mt-2`,children:`No agent has used this note yet.`}):null,(0,B.jsx)(`h3`,{className:`cs-kwh`,children:`Move to`}),(0,B.jsx)(`div`,{className:`cs-kwmv`,children:VE.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cs-knb cs-tip cs-b`,"data-tip":e===u?`Kept by ${HE[e]}`:`Move to ${HE[e]}`,"aria-label":e===u?`Kept by ${HE[e]}`:`Move to ${HE[e]}`,"aria-pressed":e===u,"data-on":e===u||void 0,disabled:s||e===u,style:{"--c":tD[e]},onClick:()=>a(e),children:nD(e)},e))})]})}var aR=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function oR(){return(0,B.jsx)(uE,{className:`m-4 flex-1`,children:(0,B.jsxs)(dE,{children:[(0,B.jsx)(pE,{variant:`icon`,children:(0,B.jsx)(Wf,{"aria-hidden":`true`})}),(0,B.jsx)(mE,{children:`No knowledge files yet. The agents write what they learn here as they work.`})]})})}function sR({rest:e}){let t=e[0]===`agents`?`agents`:e[0]===`inbox`?`inbox`:`notes`,n=eD(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)([]),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),[E,ee]=(0,m.useState)(),D=(0,m.useRef)(null),O=(0,m.useMemo)(()=>{let e=n.notes.filter(e=>(!r||e.agent===r)&&(!a||e.file===a)&&s.every(t=>e.tags.includes(t))&&rD(e,l)&&(!d||(d===`pinned`?e.pinned:e.flag?.kind===d)));return p?[...e].sort((e,t)=>t.uses.length-e.uses.length):[...e].sort((e,t)=>Number(t.pinned)-Number(e.pinned))},[n.notes,r,a,s,l,d,p]),k=(0,m.useMemo)(()=>{let e=new Map;for(let t of n.notes)for(let n of t.tags)e.set(n,(e.get(n)??0)+1);return[...e].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,12)},[n.notes]),te=n.notes.find(e=>e.key===v),A=(0,m.useRef)(void 0);te&&(A.current=te);let j=e=>c(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),ne=e=>iE(rE(`knowledge`,...e===`notes`?[]:[e])),re=e=>n.views.find(t=>t.agent===e.agent&&t.file===e.file),M=e=>{i(e),o(void 0)},ie=async(e,t)=>{let r=await U(`knowledge.edit`,{agent:e.agent,file:e.file,ref:KE(e.entry),text:t})!==void 0;return r&&n.reload(),r},ae=async e=>{await U(`knowledge.remove`,{agent:e.agent,file:e.file,ref:KE(e.entry)})&&(v===e.key&&y(void 0),n.reload())},oe=async e=>{await U(`knowledge.pin`,{agent:e.agent,file:e.file,ref:KE(e.entry),on:!e.pinned})&&n.reload()},se=async(e,t)=>{t!==e.agent&&await U(`knowledge.move`,{agent:e.agent,file:e.file,ref:KE(e.entry),to:t,toFile:iD(n.files,t,e.file)})&&(y(void 0),n.reload())},ce=r??`master`,le=a??iD(n.files,ce,`knowledge.md`),ue=async e=>{let t=await U(`knowledge.add`,{agent:ce,file:le,text:e.startsWith(`-`)?e:`- ${e}`})!==void 0;return t&&n.reload(),t},de=e=>t=>{t.preventDefault(),ee(void 0);let r=n.notes.find(e=>e.key===(t.dataTransfer.getData(`text/plain`)||w));r&&se(r,e)};if(!n.views.length&&n.error)return(0,B.jsx)(cE,{message:`Could not load the knowledge. ${n.error}`,onRetry:n.reload});if(!n.loading&&!n.files.length)return(0,B.jsx)(oR,{});let N=qE(n.files),fe=[[],[]];O.forEach((e,t)=>fe[t%2].push(e));let pe=e=>n.notes.filter(t=>e===`pinned`?t.pinned:t.flag?.kind===e).length,me=pe(`pinned`),P=n.proposals.length,F=e=>f(t=>t===e?void 0:e);return(0,B.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`div`,{ref:D,className:`cs-scroll pb-dock`,children:(0,B.jsxs)(`div`,{className:`cs-pg cs-kn`,children:[(0,B.jsxs)(`div`,{className:`cs-knh`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`cs-hd1`,children:`Knowledge`}),(0,B.jsxs)(`p`,{className:`cs-hd2`,children:[aR(n.notes.length,`note`),` · `,aR(N.length,`agent`),` · `,me,` pinned`]})]}),(0,B.jsx)(hE,{as:`tab`,label:`Knowledge view`,value:t,onChange:ne,items:[{id:`notes`,label:`Notes`},{id:`agents`,label:`Agents`},{id:`inbox`,label:(0,B.jsxs)(B.Fragment,{children:[`Inbox`,P?(0,B.jsx)(`span`,{className:`cs-kbn`,children:P}):null]}),name:P?`Inbox, ${P} waiting`:`Inbox`}]})]}),!n.views.length&&n.loading?(0,B.jsx)(jE,{}):t===`agents`?(0,B.jsx)(lD,{data:n,onOpen:e=>{M(e),ne(`notes`)}}):t===`inbox`?(0,B.jsx)($L,{proposals:n.proposals,onChanged:n.reload}):(0,B.jsxs)(`div`,{className:`cs-knl`,children:[(0,B.jsxs)(`nav`,{className:`cs-knr`,"aria-label":`Filter notes`,children:[(0,B.jsx)(`div`,{className:`cs-knrh cs-f`,children:`Agents`}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-knri`,"data-sel":!r||void 0,"aria-pressed":!r,onClick:()=>M(void 0),children:[(0,B.jsx)(`span`,{className:`cs-nm`,children:`All notes`}),(0,B.jsx)(`span`,{className:`cs-ct`,children:n.notes.length})]}),VE.filter(e=>N.some(t=>t.agent===e)).map(e=>(0,B.jsxs)(`div`,{className:`contents`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`cs-knri`,"data-sel":r===e&&!a||void 0,"data-drop":E===e||void 0,"aria-pressed":r===e,style:{"--c":tD[e]},onClick:()=>M(r===e&&!a?void 0:e),onDragOver:t=>{w&&(t.preventDefault(),ee(e))},onDragLeave:()=>ee(t=>t===e?void 0:t),onDrop:de(e),children:[(0,B.jsx)(`span`,{className:`cs-kd`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`cs-nm`,children:HE[e]}),n.files.some(t=>t.agent===e&&t.over)?(0,B.jsx)(`span`,{className:`cs-ovd`,title:`A file is over the compaction threshold`}):null,(0,B.jsx)(`span`,{className:`cs-ct`,children:n.notes.filter(t=>t.agent===e).length})]}),r===e?n.files.filter(t=>t.agent===e).map(t=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-knri`,"data-k":`file`,"data-sel":a===t.file||void 0,"aria-pressed":a===t.file,style:{"--c":tD[e]},onClick:()=>o(e=>e===t.file?void 0:t.file),children:[(0,B.jsx)(`span`,{className:`cs-nm`,children:t.file}),t.over?(0,B.jsx)(`span`,{className:`cs-ovd`,title:`Over the compaction threshold`}):null,(0,B.jsx)(`span`,{className:`cs-ct`,children:WE(t.chars)})]},t.file)):null]},e)),k.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`cs-knrh`,children:`Tags`}),(0,B.jsx)(`div`,{className:`cs-kntags`,children:k.map(([e,t])=>(0,B.jsxs)(`button`,{type:`button`,className:`cs-ktg`,"data-on":s.includes(e)||void 0,"aria-pressed":s.includes(e),onClick:()=>j(e),children:[`#`,e,(0,B.jsx)(`span`,{className:`ml-[5px] opacity-60`,children:t})]},e))})]}):null,(0,B.jsx)(`p`,{className:`cs-knhint`,children:`Drag a note onto an agent to move it. Pinned notes always load first.`})]}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`cs-knt`,children:[(0,B.jsxs)(`label`,{className:`cs-kns`,children:[(0,B.jsx)(Vm,{"aria-hidden":`true`,className:`size-4 flex-none`}),(0,B.jsx)(`input`,{type:`text`,value:l,placeholder:`Search notes, tags and sources`,"aria-label":`Search notes`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Escape`&&l&&(e.stopPropagation(),u(``))}}),l?(0,B.jsx)(`button`,{type:`button`,className:`cs-kx`,"aria-label":`Clear the search`,onClick:()=>u(``),children:(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5`})}):null]}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm`,"data-on":d===`pinned`?`true`:void 0,"aria-pressed":d===`pinned`,onClick:()=>F(`pinned`),children:[(0,B.jsx)(Cm,{"aria-hidden":`true`,className:`size-3.5`}),`Pinned `,(0,B.jsx)(`span`,{className:`cs-mut`,children:me})]}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm`,"data-on":d===`stale`?`true`:void 0,"aria-pressed":d===`stale`,onClick:()=>F(`stale`),children:[`Stale `,(0,B.jsx)(`span`,{className:`cs-mut`,children:pe(`stale`)})]}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm`,"data-on":d===`conflict`?`true`:void 0,"aria-pressed":d===`conflict`,onClick:()=>F(`conflict`),children:[`Conflicts `,(0,B.jsx)(`span`,{className:`cs-mut`,children:pe(`conflict`)})]}),(0,B.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm`,title:`Change the order`,onClick:()=>h(e=>!e),children:p?`Most used`:`Pinned first`}),(0,B.jsxs)(`button`,{type:`button`,className:`cs-kc cs-sm cs-pri`,disabled:g,onClick:()=>_(!0),children:[(0,B.jsx)(Dm,{"aria-hidden":`true`,className:`size-3.5`}),`New note`]})]}),(0,B.jsx)(LL,{notes:n.notes,onOpen:y,onSaved:n.reload}),g?(0,B.jsxs)(`div`,{className:`cs-knc mb-3`,children:[(0,B.jsxs)(`div`,{className:`cs-knch`,style:{"--c":tD[ce]},children:[(0,B.jsx)(`span`,{className:`cs-kat`,"aria-hidden":`true`,children:nD(ce)}),(0,B.jsx)(`b`,{children:HE[ce]}),(0,B.jsxs)(`span`,{className:`cs-fl`,children:[`· new note in `,le]})]}),(0,B.jsx)(YL,{initial:``,label:`New note`,action:`Add note`,placeholder:`What should ${HE[ce]} keep in mind?`,onSave:ue,onCancel:()=>_(!1)})]}):null,O.length?(0,B.jsx)(`div`,{className:`cs-kng`,children:fe.map((e,t)=>(0,B.jsx)(`div`,{className:`cs-kcol`,children:e.map(e=>(0,B.jsx)(ZL,{note:e,selected:e.key===v,dragging:e.key===w,activeTags:s,editing:b===e.key,onEditing:t=>x(t?e.key:void 0),onOpen:()=>{C(!1),y(e.key)},onTag:j,onDragStart:()=>T(e.key),onDragEnd:()=>{T(void 0),ee(void 0)},onSave:t=>ie(e,t),onDelete:()=>void ae(e),onPin:()=>void oe(e),onReview:()=>ne(`inbox`)},e.key))},t))}):(0,B.jsxs)(`div`,{className:`cs-knempty`,children:[(0,B.jsx)(`b`,{children:n.notes.length?`No notes match`:`No notes yet`}),n.notes.length?`Try another word, or clear the filters.`:`New note writes the first one.`]})]})]})]})}),(0,B.jsx)(Qg,{target:D}),(0,B.jsx)(BE,{open:!!te,onClose:()=>y(void 0),label:`Note`,className:`cs-knw`,head:A.current?(0,B.jsx)(nR,{note:A.current,onPin:()=>void oe(A.current),onEdit:()=>{let e=A.current.key;y(void 0),x(e)},onComment:()=>C(!0),onDelete:()=>void ae(A.current)}):null,children:A.current?(0,B.jsx)(iR,{note:A.current,view:re(A.current),commenting:S,onCommenting:C,onTag:e=>{y(void 0),M(void 0),j(e)},onMove:e=>void se(A.current,e),onChanged:n.reload},A.current.key):null})]})}function cR(e){let t=e[0];try{return{id:t?decodeURIComponent(t):void 0}}catch{return{id:t}}}function lR({className:e,...t}){return(0,B.jsx)(`span`,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:Y(`inline-flex size-4 shrink-0 items-end justify-between text-primary`,e),...t,children:[0,1,2].map(e=>(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`block aspect-square h-[28%] shrink-0 rounded-full bg-current motion-safe:animate-[hop_0.9s_ease-in-out_infinite]`,style:{animationDelay:`${e*.14}s`}},e))})}function uR(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(!0),[r,i]=(0,m.useState)(!0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{n.current=!0,i(!0);let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]);return(0,m.useLayoutEffect)(()=>{n.current&&s()},[e,s]),(0,m.useLayoutEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)});return r.observe(e),a.current=r,()=>{r.disconnect(),a.current=void 0,o.current=null}},[]),(0,m.useLayoutEffect)(()=>{let e=a.current,n=t.current?.firstElementChild??null;e&&n!==o.current&&(o.current&&e.unobserve(o.current),n&&e.observe(n),o.current=n)},[e]),{ref:t,atBottom:r,stick:s,onScroll:(0,m.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,i(n.current))},[])}}var dR={MASTER:[`M2 7l5 4 5-7 5 7 5-4-2 12H4z`],DESIGN:[`M12 3a9 9 0 1 0 0 18c1.1 0 2-.9 2-2 0-.5-.2-1-.5-1.3-.3-.4-.5-.8-.5-1.3 0-1.1.9-2 2-2H17a4 4 0 0 0 4-4c0-4.4-4-8-9-8z`,`M7.5 11h.01M10 7h.01M15 7h.01`],DEV:[`M8 8l-5 4 5 4M16 8l5 4-5 4M14 5l-4 14`],QA:[`M12 3l8 3v6c0 4.5-3.2 8-8 9-4.8-1-8-4.5-8-9V6z`,`M8.5 12l2.5 2.5 4.5-5`],RESEARCH:[`M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18z`,`M3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18`],SCOUT:[`M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z`,`M12 9a3 3 0 1 0 0 6 3 3 0 1 0 0-6z`]};function fR(e){let t=e?.toUpperCase();if(t)return t===`ORACLE`||t===`MASTER`?`MASTER`:t===`BACKEND`?`DEV`:t===`DESIGNER`||t===`FRONTEND`?`DESIGN`:t===`RESEARCHER`?`RESEARCH`:dR[t]?t:void 0}function pR(e){let t=fR(e);return t===`MASTER`?`var(--c-orc)`:t===`DESIGN`?`var(--c-des)`:t===`DEV`?`var(--c-dev)`:t===`QA`?`var(--c-qa)`:t===`RESEARCH`?`var(--c-res)`:t===`SCOUT`?`var(--c-sc)`:e?.toUpperCase()===`PLANNER`||e?.toUpperCase()===`PANEL`?`var(--c-pl)`:`var(--muted-foreground)`}function mR(e,t){let n=fR(e);return n?n===fR(t):e?.toUpperCase()===t?.toUpperCase()}function hR(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function gR(e){return e.role===`you`||e.role===`note`?e.role:e.role===`panel`?`PLANNER`:e.agent??`MASTER`}var _R={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,SCOUT:`text-source-scout`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function vR(e){return e===`MASTER`?`Oracle`:e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function yR(e){return _R[e]??`text-muted-foreground`}var bR={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,SCOUT:`var(--source-scout)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function xR(e){return bR[e]??`var(--muted-foreground)`}function SR(e){if(e.role===`researcher`)return`RESEARCH`;let t=e.domain??e.role;return t===`backend`||t===`dev`?`DEV`:t===`designer`||t===`design`?`DESIGN`:t===`researcher`||t===`research`?`RESEARCH`:t===`qa`?`QA`:t?String(t).toUpperCase():`AGENT`}function CR(e,t=40){let n=new Map;for(let t of e)n.set(t.source,t);return[...n.values()].sort((e,t)=>e.at-t.at).slice(-t)}function wR({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,named:s,waiting:c,tile:l}){let u=c||r&&(s||!hR(e));return l?(0,B.jsx)(`div`,{className:`cs-pmsg`,children:(0,B.jsx)(wR,{source:e,name:t,head:r,time:n,live:i,children:a,aside:o,waiting:c,named:s??!0})}):(0,B.jsxs)(`div`,{className:`chat-agent group/msg`,"data-live":i||void 0,style:i?{"--orb":xR(e)}:void 0,children:[u||o?(0,B.jsxs)(`p`,{className:`chat-speaker`,children:[u?(0,B.jsx)(`b`,{className:`chat-name`,title:n,style:{"--who":pR(e)},children:c?(0,B.jsx)(kR,{text:t}):t}):null,o?(0,B.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,c?null:(0,B.jsx)(`div`,{className:`chat-prose`,title:u?void 0:n,children:a})]})}var TR=`C13 7.5 15.4 12.6 20.6 14.8C21.4 15.2 21.1 16 20.2 16`;function ER(){return(0,B.jsxs)(`svg`,{className:`cs-ut`,viewBox:`0 0 22 16`,"aria-hidden":`true`,focusable:`false`,children:[(0,B.jsx)(`path`,{d:`M13 0${TR}H6`,className:`cs-ut-edge`}),(0,B.jsx)(`path`,{d:`M0 0H13${TR}H0Z`,className:`cs-ut-fill`})]})}function DR({time:e,head:t,note:n,children:r,below:i,actions:a,fresh:o}){return(0,B.jsxs)(`div`,{className:`group/msg relative flex flex-col items-end gap-1`,children:[(0,B.jsxs)(`div`,{className:`chat-bubble cs-umsg`,"data-new":o||void 0,title:e,children:[(0,B.jsx)(`i`,{className:`cs-ue`,"aria-hidden":`true`,children:(0,B.jsx)(`b`,{className:`cs-ub`})}),(0,B.jsx)(`i`,{className:`cs-uf`,"aria-hidden":`true`,children:(0,B.jsx)(`b`,{className:`cs-ub`})}),(0,B.jsx)(ER,{}),(0,B.jsx)(`div`,{className:`cs-ux`,children:r}),a&&!n?(0,B.jsx)(`div`,{className:`chat-meta absolute top-1/2 right-full mr-2 flex -translate-y-1/2 items-center gap-2 whitespace-nowrap`,children:a}):null]}),n?(0,B.jsxs)(`div`,{className:`chat-meta flex items-center gap-2 pr-[9px]`,"data-note":``,children:[a,(0,B.jsx)(`span`,{children:n})]}):null,i]})}function OR({failed:e,auto:t,children:n}){return(0,B.jsx)(`div`,{role:`note`,className:Y(`chat-note`,e&&`text-destructive`,t&&`chat-note-auto`),children:(0,B.jsx)(`span`,{children:n})})}function kR({text:e}){return(0,B.jsxs)(`span`,{className:`activity-shimmer`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:e}),[...e].map((e,t)=>(0,B.jsx)(`span`,{"aria-hidden":`true`,style:{"--i":t},children:e},t))]})}function AR({onClick:e,className:t}){return(0,B.jsx)(`button`,{type:`button`,"aria-label":`Jump to latest`,title:`Jump to latest`,onClick:e,className:Y(`jump-latest btn-outline grid size-9 place-items-center rounded-full border bg-card text-foreground shadow-card outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t),children:(0,B.jsx)(Mf,{"aria-hidden":`true`,className:`size-4`})})}var jR=8;function MR(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function NR({done:e,total:t}){let n=Math.min(t,jR);if(n<=0)return null;let r=Math.min(n,Math.round(Math.max(0,e)/t*n));return(0,B.jsx)(`span`,{className:`cs-pips`,"aria-hidden":`true`,style:{"--n":n,"--d":r}})}function PR({mark:e,className:t}){return(0,B.jsxs)(`span`,{"aria-hidden":`true`,className:Y(`cs-mk`,t),"data-s":e===`open`?void 0:e,children:[(0,B.jsx)(`svg`,{className:`cs-ck`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7.5`})}),(0,B.jsx)(`svg`,{className:`cs-xx`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M7 7l10 10M17 7L7 17`})}),(0,B.jsx)(`svg`,{className:`cs-sl`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M6 18L18 6`})})]})}function FR({check:e,live:t,waiting:n,className:r}){return(0,B.jsx)(PR,{mark:e===`done`?`done`:e===`dropped`?`drop`:n?`warn`:t?`now`:`open`,...r?{className:r}:{}})}var IR=`auto mode`;function LR(e){return e<10?`0${e}`:String(e)}function RR(e){if(!Number.isFinite(e))return`0`;let t=new Date(e);return`${LR(t.getHours())}:${LR(t.getMinutes())}`}function zR(e){if(!Number.isFinite(e)||e<5e3)return`now`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}function BR(e){let t=zR(e);return t===`now`?`just now`:`${t} ago`}function VR({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,B.jsxs)(`section`,{className:Y(`workspace-frame group/frame relative flex min-h-0 min-w-0 flex-col rounded-xl border shadow-xs`,i&&`flex-none`,n),...s,children:[e||t||a?(0,B.jsxs)(`div`,{className:Y(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,B.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,B.jsx)(`span`,{}),(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,B.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-label":i?`Expand ${c}`:`Minimize ${c}`,title:`${i?`Expand`:`Minimize`}${o?` · ${o}`:``}`,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,"aria-describedby":`focused-action-help`,onClick:a,className:`btn-ghost -mr-1.5 inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2 text-muted-foreground transition-[box-shadow,color,scale] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.97] motion-reduce:active:scale-100`,children:[o?(0,B.jsx)(IT,{chord:o,className:`kbd-hint`}):null,(0,B.jsx)(Yf,{"aria-hidden":`true`,className:Y(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function HR(e,t){if(e===`app.sidebar`&&t==null){let e=globalThis.matchMedia;return typeof e==`function`&&e(`(max-width: 1023.98px)`).matches}return e===`lobby.thinking`||t===`1`}var UR=`bot-lobby.collapsed.`,WR=new Set,GR=new Map;function KR(e){if(GR.has(e))return GR.get(e);if(e===`lobby.thinking`)return HR(e);try{return HR(e,localStorage.getItem(UR+e))}catch{return!1}}function qR(e,t){GR.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(UR+e,t?`1`:`0`)}catch{}for(let e of[...WR])e()}function JR(e){return WR.add(e),()=>{WR.delete(e)}}function YR(e){qR(e,!KR(e))}function XR(e){return[(0,m.useSyncExternalStore)(JR,()=>KR(e),()=>HR(e)),(0,m.useCallback)(()=>qR(e,!KR(e)),[e])]}var ZR=`lobby.activity.open`;function QR({entry:e}){return e.pending?(0,B.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--orb)]`}):e.kind===`error`?(0,B.jsx)(yh,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,B.jsx)(ah,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,B.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function $R({entry:e}){return(0,B.jsxs)(`li`,{className:`cs-wl activity-step`,title:RR(e.at),style:e.pending?{"--orb":xR(e.source)}:void 0,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,B.jsx)(QR,{entry:e})}),(0,B.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,B.jsx)(`b`,{children:vR(e.source)}),` `,(0,B.jsxs)(`span`,{className:e.kind===`error`?`text-destructive`:e.pending?`text-foreground`:void 0,children:[CL(e.text),e.pending?`…`:``]})]})]})}function ez(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function tz(e){let t=[...e].reverse().find(e=>e.pending),n=[...new Set(e.map(e=>vR(e.source)))];return{...t?{live:t}:{},took:(e.at(-1)?.at??0)-(e[0]?.at??0),count:`${e.length} ${e.length===1?`step`:`steps`}`,sources:n.length>3?`${n.slice(0,3).join(`, `)} +${n.length-3}`:n.join(`, `),errors:e.filter(e=>e.kind===`error`).length,warnings:e.filter(e=>e.kind===`warning`).length}}function nz(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function rz({entries:e}){let[t]=XR(ZR),[n,r]=(0,m.useState)();(0,m.useEffect)(()=>r(void 0),[t]);let i=n??t,a=(0,m.useId)(),{live:o,took:s,count:c,sources:l,errors:u,warnings:d}=tz(e),f=nz(!!o),p=o?{"--orb":xR(o.source)}:void 0;return(0,B.jsxs)(`div`,{className:`cs-work activity-run`,"data-live":o?!0:void 0,"data-open":i||void 0,style:p,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":a,onClick:()=>r(!i),className:`cs-wrow activity-toggle`,children:[o?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`cs-wtx`,children:`Working`}),(0,B.jsxs)(`span`,{className:`activity-live-step min-w-0 truncate`,children:[(0,B.jsx)(`span`,{className:Y(`font-medium`,yR(o.source)),children:vR(o.source)}),` `,o.text]},o.id),(0,B.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[c,e[0]&&f-e[0].at>=1e3?` · ${ez(f-e[0].at)}`:``]})]}):(0,B.jsxs)(`span`,{className:`min-w-0 truncate`,children:[s>=1e3?`Worked for ${ez(s)}`:`Worked`,` · `,c,l?` · ${l}`:``]}),u?(0,B.jsxs)(`span`,{className:`shrink-0 text-[var(--bad)]`,children:[u,` `,u===1?`error`:`errors`]}):null,d?(0,B.jsxs)(`span`,{className:`shrink-0 text-[var(--warn)]`,children:[d,` `,d===1?`warning`:`warnings`]}):null,(0,B.jsx)(Yf,{"aria-hidden":`true`,className:`cs-chev size-3.5 shrink-0`})]}),(0,B.jsx)(`div`,{className:`cs-wbody`,inert:!i,children:(0,B.jsx)(`div`,{className:`cs-wi`,children:(0,B.jsx)(`ol`,{id:a,"aria-label":`Activity`,className:`cs-wlines`,children:i?e.map(e=>(0,B.jsx)($R,{entry:e},e.id)):null})})})]})}var iz=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,az=260,oz=200,sz=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function cz(e){let t=[],n=[],r=!1;for(let i of e){if(/^\s*(```|~~~)/.test(i)&&(r=!r),!r&&!i.trim()){n.length&&t.push(n.join(`
|
|
93
93
|
`).trim()),n=[];continue}n.push(i)}return n.length&&t.push(n.join(`
|
|
94
94
|
`).trim()),t.filter(Boolean)}function lz(e){let t=e.split(/(?<=[.!?…])\s+(?=[A-Z"'“‘`(\[])/),n=[];for(let e of t){let t=n.at(-1);t!==void 0&&(t.split("`").length-1)%2==1?n[n.length-1]=`${t} ${e}`:n.push(e)}return n}function uz(e){if(e.length<=az||sz.test(e))return[e];let t=[],n=``;for(let r of lz(e.replace(/\s*\n\s*/g,` `)))n&&n.length+r.length+1>oz?(t.push(n),n=r):n=n?`${n} ${r}`:r;return n&&t.push(n),t}function dz(e){let t=e.replace(/\r\n?/g,`
|
|
95
95
|
`).trim().split(`
|
|
@@ -103,10 +103,10 @@ Error generating stack: `+e.message+`
|
|
|
103
103
|
.dark { … }`,className:`max-h-56 font-mono text-xs`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`input`,{ref:l,type:`file`,accept:`.css,.json,text/css,application/json`,hidden:!0,tabIndex:-1,"aria-label":`Upload a theme file`,onChange:e=>{d(e.target.files?.[0]),e.target.value=``}}),(0,B.jsx)(EI,{label:`Save and apply the pasted theme`,text:`Save theme`,icon:Jf,tone:`primary`,disabled:!t.trim()||s,onClick:()=>void u(t,`Custom theme`)}),(0,B.jsx)(EI,{label:`Upload a .css or .json theme file`,text:`Upload file`,icon:lh,disabled:s,onClick:()=>l.current?.click()}),a?(0,B.jsx)(`p`,{role:`alert`,className:`ml-2 min-w-0 text-xs text-destructive`,children:a}):null]})]})}function HV(){let{theme:e,setTheme:t}=eV(),n=Qz();return(0,B.jsx)(GB,{prominent:!0,title:fV.appearance,children:(0,B.jsxs)(RB,{children:[(0,B.jsx)(LB,{label:`Prompt sounds`,help:`A droplet for each new actionable prompt or delivery review. Kept in this browser; sound starts after interaction. Desktop notifications remain separate.`,children:(0,B.jsx)(SB,{checked:!n,onCheckedChange:e=>Xz(!e),"aria-label":`Prompt sounds`})}),(0,B.jsx)(LB,{label:NV.themeLabel,help:NV.appearanceHelp,children:(0,B.jsx)(zB,{value:e,items:NV.themeItems.map(e=>({value:e.id,label:e.label})),label:NV.themeLabel,onChange:e=>t(e)})}),(0,B.jsx)(LB,{label:`Colour theme`,help:`The page's colours, the same in every pi session.`,stacked:!0,children:(0,B.jsx)(RV,{})}),(0,B.jsx)(LB,{label:`Typeface`,help:`The face for the page's text, kept in this browser.`,stacked:!0,children:(0,B.jsx)(tV,{kind:`font`})}),(0,B.jsx)(LB,{label:`Code typeface`,help:`The face for code, paths and commands.`,stacked:!0,children:(0,B.jsx)(tV,{kind:`mono`})}),(0,B.jsx)(LB,{label:`Saved themes`,help:`Themes you imported, kept with pi for every session and project.`,stacked:!0,children:(0,B.jsx)(BV,{})}),(0,B.jsx)(LB,{label:`Import a theme`,stacked:!0,children:(0,B.jsx)(VV,{})})]})})}function UV({className:e,...t}){return(0,B.jsx)(fx,{"aria-keyshortcuts":`Space`,"aria-description":`When focused, press Space to toggle.`,"data-slot":`checkbox`,className:Y(`cs-cb`,e),...t,children:(0,B.jsx)(mx,{forceMount:!0,"data-slot":`checkbox-indicator`,className:`contents`,children:(0,B.jsx)(Jf,{"aria-hidden":`true`,strokeWidth:3.4})})})}var WV=`flex min-h-10 w-full flex-col gap-1 rounded-lg border border-transparent px-3 py-2.5 text-left outline-none transition-colors duration-150 hover:bg-accent/60 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-[current=true]:bg-accent`,GV={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]};function KV(e,t){let n=GV[t].reduce((e,t)=>e[t],e);return{...n.mcpTools?{mcpTools:n.mcpTools}:{},...n.skills?{skills:n.skills}:{}}}function qV(e,t){return GV[e].reduceRight((e,t)=>({[t]:e}),t)}function JV(e,t){let n=e.mcpTools?e.mcpTools.length===0?Q.noTools:`${e.mcpTools.length} MCP tool${e.mcpTools.length===1?``:`s`}`:Q.allTools;return t===`master`?n:`${n} · ${e.skills?e.skills.length===0?Q.noSkills:`${e.skills.length} skill${e.skills.length===1?``:`s`}`:Q.allSkills}`}var YV=/^mcp__[A-Za-z0-9_]+__[A-Za-z0-9_]+$/;function XV(e,t){let n=`mcp__${t}__`;return e.startsWith(n)?e.slice(n.length):e}function ZV(e){return/^mcp__([A-Za-z0-9_]+?)__/.exec(e)?.[1]??``}function QV({config:e,save:t,agent:n,onAgent:r}){let i=eR(`settings.grants`,{},[]),a=i.data;return(0,B.jsxs)(GB,{prominent:!0,title:fV.grants,children:[(0,B.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:Q.intro}),(0,B.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,13rem)_minmax(0,1fr)] items-start gap-4`,children:[(0,B.jsx)(`nav`,{"aria-label":Q.agents,className:`flex flex-col gap-0.5`,children:nV.map(t=>(0,B.jsxs)(`button`,{type:`button`,"aria-current":t===n,onClick:()=>r(t),className:Y(WV,`min-h-0 gap-0.5 py-2`),children:[(0,B.jsx)(`span`,{className:`flex items-center gap-2 text-[0.8125rem] font-medium`,children:rV[t]}),(0,B.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:JV(KV(e,t),t)})]},t))}),(0,B.jsxs)(PB,{dense:!0,"aria-label":`${rV[n]} ${Q.cardLabel}`,children:[(0,B.jsx)(tH,{kind:n,grants:KV(e,n),offered:a?.mcpTools,error:i.error,save:t},`tools-${n}`),(0,B.jsx)(nH,{kind:n,grants:KV(e,n),offered:a?.skills,error:i.error,save:t},`skills-${n}`)]})]})]})}function $V({title:e,note:t}){return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,B.jsx)(`h4`,{className:`text-sm font-semibold`,children:e}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})}function eH({id:e,name:t,help:n,tag:r,tagTone:i,checked:a,disabled:o,title:s,onChange:c}){return(0,B.jsxs)(`label`,{htmlFor:e,title:s,className:Y(`flex min-w-0 cursor-pointer items-start gap-3 rounded-lg px-2 py-1.5 transition-colors hover:bg-accent/60`,o&&`cursor-not-allowed opacity-60 hover:bg-transparent`),children:[(0,B.jsx)(UV,{id:e,checked:a,disabled:o,onCheckedChange:e=>c(e===!0),className:`mt-0.5`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,B.jsx)(`span`,{className:`break-all font-mono text-[0.8125rem]`,children:t}),n?(0,B.jsx)(`span`,{className:`break-words text-xs text-muted-foreground`,children:n}):null]}),r?(0,B.jsx)(`span`,{className:Y(`shrink-0 rounded-md px-1.5 py-0.5 text-[0.6875rem] font-medium`,i===`warning`?`bg-warning/12 text-warning`:`bg-accent text-muted-foreground`),children:r}):null]})}function tH({kind:e,grants:t,offered:n,error:r,save:i}){let[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(``),l=!t.mcpTools,u=t.mcpTools??[],d=new Set(u),f=pV.has(e),p=t=>i(qV(e,{mcpTools:t?[...new Set(t)]:null})),h=(e,t)=>void p(t?[...u,...e]:u.filter(t=>!e.includes(t))),g=new Set((n??[]).map(e=>e.name)),_=u.filter(e=>!g.has(e)).map(e=>({name:e,server:ZV(e),description:``,readOnly:!1})),v=a.trim().toLowerCase(),y=[...n??[],..._].filter(e=>!v||e.name.toLowerCase().includes(v)||e.description.toLowerCase().includes(v)),b=[...new Set(y.map(e=>e.server))],x=e=>!f||e.readOnly||!g.has(e.name),S=e=>void p(e?null:(n??[]).filter(x).map(e=>e.name)),C=()=>{let e=s.trim();if(!YV.test(e)){H.error(Q.badName);return}c(``),d.has(e)||p([...u,e])};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(IB,{className:`gap-1 border-b border-(--frame-panel-border-color) py-2.5`,children:[(0,B.jsx)($V,{title:Q.tools,note:l?Q.allTools:`${u.length} granted`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.readOnlyHelp:e===`qa`?Q.qaHelp:Q.toolsHelp})]}),(0,B.jsxs)(FB,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everyTool}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f?Q.everyToolReadOnlyHelp:Q.everyToolHelp})]}),(0,B.jsx)(SB,{checked:l,onCheckedChange:S,"aria-label":`${rV[e]} ${Q.everyTool.toLowerCase()}`})]}),(n?.length??0)>8?(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(Vm,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,B.jsx)(xB,{value:a,placeholder:Q.filter,"aria-label":Q.filter,className:`pl-8`,onChange:e=>o(e.target.value)})]}):null,!n&&!r?(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&_.length===0?(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[Q.noServers,` `,(0,B.jsx)(`code`,{className:`rounded bg-accent px-1 py-0.5 font-mono text-xs`,children:`pi mcp add <name> -- <command>`})]}):null,b.map(t=>{let n=y.filter(e=>e.server===t),r=n.filter(x).map(e=>e.name),i=l?r.length:r.filter(e=>d.has(e)).length;return(0,B.jsxs)(`div`,{role:`group`,"aria-label":`${t} tools`,className:Y(`flex flex-col gap-0.5`,l&&`opacity-60`),children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1 text-xs font-medium text-muted-foreground`,children:[(0,B.jsx)(UV,{checked:i===0?!1:i===r.length||`indeterminate`,disabled:l||r.length===0,"aria-label":`Every ${t} tool`,onCheckedChange:e=>h(r,e===!0)}),(0,B.jsx)(`span`,{className:`font-mono`,children:t||Q.unknownServer}),(0,B.jsxs)(`span`,{children:[i,` of `,n.length]})]}),n.map(t=>{let n=g.has(t.name),r=!x(t);return(0,B.jsx)(eH,{id:`grant-${e}-${t.name}`,name:XV(t.name,t.server),help:n?t.description||void 0:Q.notConnectedHelp,tag:n?t.readOnly?Q.readOnly:Q.writes:Q.notConnected,tagTone:n?`muted`:`warning`,checked:l?!r:d.has(t.name),disabled:l||r&&!d.has(t.name),...r?{title:Q.blockedHelp}:{},onChange:e=>h([t.name],e)},t.name)})]},t)}),!l&&u.length===0?(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,B.jsx)(rp,{"aria-hidden":`true`,className:`size-3.5`}),Q.noToolsWarning]}):null,(0,B.jsxs)(`div`,{hidden:l,className:`flex min-w-0 items-center gap-2 border-t border-(--frame-panel-border-color) pt-3`,children:[(0,B.jsx)(xB,{value:s,placeholder:`mcp__server__tool`,"aria-label":Q.addLabel,className:`min-w-0 flex-1 font-mono`,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),C())}}),(0,B.jsx)(EI,{label:Q.add,icon:Dm,onClick:C})]})]})]})}function nH({kind:e,grants:t,offered:n,error:r,save:i}){if(e===`master`)return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(IB,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:(0,B.jsx)($V,{title:Q.skills,note:Q.sessionSkills})}),(0,B.jsx)(FB,{fit:!0,className:`py-3`,children:(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q.masterSkills})})]});let a=!t.skills,o=new Set(t.skills??[]),s=t=>i(qV(e,{skills:t?[...new Set(t)]:null})),c=new Set((n??[]).map(e=>e.name)),l=(t.skills??[]).filter(e=>!c.has(e));return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(IB,{className:`gap-1 border-y border-(--frame-panel-border-color) py-2.5`,children:[(0,B.jsx)($V,{title:Q.skills,note:a?Q.allSkills:`${o.size} granted`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.skillsHelp})]}),(0,B.jsxs)(FB,{fit:!0,className:`flex flex-col gap-3 py-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 px-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:Q.everySkill}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q.everySkillHelp})]}),(0,B.jsx)(SB,{checked:a,onCheckedChange:e=>void s(e?null:(n??[]).map(e=>e.name)),"aria-label":`${rV[e]} ${Q.everySkill.toLowerCase()}`})]}),!n&&!r?(0,B.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.looking}):null,r&&!n?(0,B.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:r}):null,n&&n.length===0&&l.length===0?(0,B.jsx)(`p`,{className:`px-2 text-sm text-muted-foreground`,children:Q.noSkillsFound}):null,(0,B.jsxs)(`div`,{role:`group`,"aria-label":`${rV[e]} skills`,className:Y(`flex flex-col gap-0.5`,a&&`opacity-60`),children:[(n??[]).map(t=>(0,B.jsx)(eH,{id:`skill-${e}-${t.name}`,name:t.name,help:t.description,checked:a||o.has(t.name),disabled:a,title:t.path,onChange:e=>void s(e?[...o,t.name]:[...o].filter(e=>e!==t.name))},t.name)),l.map(t=>(0,B.jsx)(eH,{id:`skill-${e}-${t}`,name:t,help:Q.skillMissingHelp,tag:Q.notFound,tagTone:`warning`,checked:!0,onChange:()=>void s([...o].filter(e=>e!==t))},t))]}),!a&&o.size===0?(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 px-2 text-xs text-warning`,children:[(0,B.jsx)(rp,{"aria-hidden":`true`,className:`size-3.5`}),Q.noneWarning]}):null]})]})}function rH(e){let t=[[`designer`,e.agents.designer],[`backend`,e.agents.backend],[`qa`,e.agents.qa],[`scout`,e.scout],[`researcher`,e.researcher]],n={};for(let[e,r]of t)r.harness&&PV.has(e)&&(n[r.harness]??=[]).push(e);return n}function iH({value:e,label:t,placeholder:n,onSave:r}){let[i,a]=(0,m.useState)(e);(0,m.useEffect)(()=>a(e),[e]);let o=()=>{let t=i.trim();t!==e&&r(t)};return(0,B.jsx)(xB,{value:i,placeholder:n,"aria-label":t,spellCheck:!1,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function aH({value:e,label:t,onSave:n}){let r=e>0?String(e):``,[i,a]=(0,m.useState)(r);(0,m.useEffect)(()=>a(r),[r]);let o=()=>{let e=i.trim().replace(/[,_\s]/g,``);if(e===r)return;if(e===``)return n(0);let t=Number(e);if(!Number.isFinite(t)||t<1e4||t>2e6){H.error(`"${i}" is not between 10,000 and 2,000,000 tokens.`),a(r);return}n(Math.round(t))};return(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(xB,{type:`number`,inputMode:`numeric`,min:1e4,max:2e6,step:1e4,value:i,placeholder:`harness default`,"aria-label":t,className:`pr-14`,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:`tokens`})]})}function oH({status:e}){let t=!!e.path;return(0,B.jsxs)(`span`,{title:e.path??`${e.command||`No command`} is not on PATH`,className:Y(`inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium`,t?`bg-success/8 text-success dark:bg-success/16`:`bg-warning/8 text-warning dark:bg-warning/16`),children:[t?(0,B.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}):(0,B.jsx)(rp,{"aria-hidden":`true`,className:`size-3.5`}),t?`${$.installed}${e.version?` · ${e.version}`:``}`:$.notFound]})}function sH({status:e,config:t,users:n,save:r}){let i=e.id,a=t.harnesses[i],o=e=>void r({harnesses:{[i]:e}}),s=e.protocol===`acp`,c=i===`codex`?`CODEX_HOME`:i===`claude`?`CLAUDE_CONFIG_DIR`:void 0,l=e.providers.some(e=>e.value===a.modelProvider)||!a.modelProvider?e.providers:[...e.providers,{value:a.modelProvider,label:a.modelProvider}];return(0,B.jsxs)(`section`,{"data-slot":`harness-card`,"aria-label":e.label,className:`glass flex min-w-0 flex-col gap-3 rounded-xl border px-3.5 pt-3 pb-3.5`,children:[(0,B.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-semibold`,children:e.label}),(0,B.jsx)(oH,{status:e})]}),(0,B.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:e.blurb}),(0,B.jsxs)(`p`,{className:`break-words text-xs`,children:[(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[$.usedBy,`: `]}),n.length>0?n.map(e=>rV[e]).join(`, `):(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:$.unused.toLowerCase()})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-col divide-y divide-border border-t border-border [&>*]:py-2.5 [&>*:last-child]:pb-0`,children:[(0,B.jsx)(LB,{stacked:!0,label:$.binary,help:$.binaryHelp,children:(0,B.jsx)(iH,{value:a.binaryPath,label:`${e.label} ${$.binary.toLowerCase()}`,placeholder:e.command||`/path/to/agent`,onSave:e=>o({binaryPath:e})})}),(0,B.jsx)(LB,{stacked:!0,label:$.args,help:i===`acp`?$.argsAcpHelp:$.argsHelp,children:(0,B.jsx)(iH,{value:a.launchArgs,label:`${e.label} ${$.args.toLowerCase()}`,placeholder:i===`acp`?`--acp`:`none`,onSave:e=>o({launchArgs:e})})}),c?(0,B.jsx)(LB,{stacked:!0,label:$.home,help:$.homeHelp(c),children:(0,B.jsx)(iH,{value:a.homePath,label:`${e.label} ${$.home.toLowerCase()}`,placeholder:i===`codex`?`~/.codex`:`~/.claude`,onSave:e=>o({homePath:e})})}):null,l.length>0?(0,B.jsx)(LB,{stacked:!0,label:$.provider,help:$.providerHelp,children:(0,B.jsx)(zB,{value:a.modelProvider,items:l.map(e=>({value:e.value,label:e.label})),label:`${e.label} ${$.provider.toLowerCase()}`,onChange:e=>o({modelProvider:e})})}):null,s?null:(0,B.jsx)(LB,{stacked:!0,label:$.compact,help:$.compactHelp,children:(0,B.jsx)(aH,{value:a.compactAt,label:`${e.label} ${$.compact.toLowerCase()}`,onSave:e=>o({compactAt:e})})}),i===`antigravity`?(0,B.jsx)(LB,{stacked:!0,label:$.harnessPath,help:$.harnessPathHelp,children:(0,B.jsx)(iH,{value:a.harnessPath,label:`${e.label} ${$.harnessPath.toLowerCase()}`,placeholder:`localharness_external`,onSave:e=>o({harnessPath:e})})}):null,(0,B.jsx)(LB,{stacked:!0,label:$.custom,help:$.customHelp,children:(0,B.jsx)(iH,{value:a.customModels.join(` `),label:`${e.label} ${$.custom.toLowerCase()}`,placeholder:i===`opencode`?`anthropic/claude-sonnet-5-5`:`model-id`,onSave:e=>o({customModels:e.split(/[\s,]+/).filter(Boolean)})})}),(0,B.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:$.inject}),(0,B.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.injectHelp})]}),(0,B.jsx)(SB,{checked:a.injectPrompts,onCheckedChange:e=>o({injectPrompts:e}),"aria-label":`${e.label}: ${$.inject}`})]})]})]})}function cH({config:e,statuses:t,error:n,save:r}){let i=rH(e);return(0,B.jsxs)(GB,{prominent:!0,title:fV.harnesses,children:[(0,B.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:$.intro}),t?(0,B.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-3 xl:grid-cols-3`,children:t.map(t=>(0,B.jsx)(sH,{status:t,config:e,users:i[t.id]??[],save:r},t.id))}):(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n??`Looking for installed harnesses…`})]})}var lH={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],planner:[`planner`]},uH=[...hV,..._V.map(e=>({id:`panel:${e.id}`,label:e.label,help:vV}))];function dH(e,t){switch(t){case`master`:return e.master;case`scout`:return{model:e.scout.model,thinking:`low`,mcpTools:e.scout.mcpTools,...e.scout.skills?{skills:e.scout.skills}:{},...e.scout.autoCompact===!1?{autoCompact:!1}:{},...e.scout.compactAt?{compactAt:e.scout.compactAt}:{},...e.scout.harness?{harness:e.scout.harness}:{},...e.scout.harnessModel?{harnessModel:e.scout.harnessModel}:{}};case`researcher`:return e.researcher;case`planner`:return e.planner;default:return e.agents[t]}}function fH(e,t){return lH[e].reduceRight((e,t)=>({[t]:e}),t)}function pH(e,t){return e.find(e=>e.id===t)?.thinkingLevels??dV}function mH(e,t){return dV[BB(dV,e,Math.max(0,dV.indexOf(t)))]??t}var hH=e=>e>0?`${e} round${e===1?``:`s`}`:`unlimited`;function gH(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(``),a=e.models.some(t=>t.id===e.value),o=[...e.inherit?[{value:iV,label:aV,help:oV}]:[],...e.none?[{value:iV,label:`none`,help:`Use the primary model`}]:[],...!e.inherit&&!e.none&&e.value===`inherit`?[{value:iV,label:aV,help:oV}]:[],...e.models.map(e=>({value:e.id,label:e.id,...e.label&&e.label!==e.id?{help:e.label}:{}})),...!a&&e.value!==`inherit`?[{value:e.value,label:e.value,help:lV}]:[],{value:sV,label:cV,help:lV}],s=t=>{if(t!==`__custom__`)return e.onChange(t);i(a?``:e.value),n(!0)},c=()=>{let t=r.trim();n(!1),t&&t!==e.value&&e.onChange(t)};return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(zB,{value:e.value,items:o,label:e.label,onChange:s}),t?(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,B.jsx)(xB,{autoFocus:!0,value:r,placeholder:`provider/model`,"aria-label":`Model id`,className:`min-w-0 flex-1`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,B.jsx)(EI,{label:`Use this model`,icon:Jf,tone:`primary`,onClick:c})]}):null]})}function _H({label:e,help:t,checked:n,onChange:r,name:i}){return(0,B.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,B.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,B.jsx)(SB,{checked:n,onCheckedChange:r,"aria-label":i??e})]})}function vH({value:e,onSave:t,placeholder:n,label:r}){let[i,a]=(0,m.useState)(e);(0,m.useEffect)(()=>a(e),[e]);let o=()=>{let n=i.trim();n!==e&&t(n)};return(0,B.jsx)(xB,{value:i,placeholder:n,"aria-label":r,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function yH({value:e,label:t,onSave:n}){let r=Math.round(e/6e4);return(0,B.jsx)(SH,{label:t,value:String(r),min:1,suffix:`min`,onSave:e=>{let t=Number(e);return!Number.isFinite(t)||t<=0?(H.error(`"${e}" is not a positive number of minutes.`),!1):(n(Math.round(t*6e4)),!0)}})}function bH({value:e,label:t,onSave:n}){return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-1.5`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`text-[0.8125rem] font-medium`,children:mV.label}),(0,B.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:mV.help})]}),(0,B.jsx)(`div`,{className:`w-36 shrink-0`,children:(0,B.jsx)(SH,{label:t,value:e?String(e):``,min:mV.min,max:mV.max,step:1e3,placeholder:mV.placeholder,suffix:`tokens`,onSave:e=>{if(e===``)return n(null),!0;let t=Number(e);return!Number.isInteger(t)||t<mV.min||t>mV.max?(H.error(mV.bad(e)),!1):(n(t),!0)}})})]})}function xH({value:e,onSave:t}){return(0,B.jsx)(SH,{label:SV,value:String(e),min:0,max:65535,onSave:e=>!/^\d+$/.test(e)||Number(e)>65535?(H.error(`"${e}" is not a port (0, or 1-65535).`),!1):(t(Number(e)),!0)})}function SH({label:e,value:t,min:n,max:r,step:i,placeholder:a,suffix:o,onSave:s}){let[c,l]=(0,m.useState)(t);(0,m.useEffect)(()=>l(t),[t]);let u=()=>{c!==t&&(s(c.trim())||l(t))};return(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(xB,{type:`number`,inputMode:`numeric`,min:n,max:r,step:i,placeholder:a,value:c,"aria-label":e,className:o?o.length>3?`pr-14`:`pr-10`:void 0,onChange:e=>l(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u())}}),o?(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:o}):null]})}function CH({value:e,label:t,onSave:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,B.jsx)(CB,{rows:2,value:r,"aria-label":t,onChange:e=>i(e.target.value),onBlur:()=>{r.trim()!==e&&n(r.trim())}}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved when you leave the field.`})]})}function wH({value:e,statuses:t,label:n,onChange:r}){let i=[{value:`pi`,label:$.piLabel,help:$.piHelp},...t.map(e=>({value:e.id,label:e.label,help:e.path?e.version?`v${e.version}`:$.installed:$.missing}))];return i.some(t=>t.value===e)||i.push({value:e,label:e}),(0,B.jsx)(zB,{value:e,items:i,label:n,onChange:r})}function TH({value:e,models:t,label:n,onChange:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=e===``||t.some(t=>t.id===e),l=[{value:``,label:$.defaultModel,help:$.defaultModelHelp},...t.map(e=>({value:e.id,label:e.label,help:e.custom?lV:e.current?e.id:`${e.id} · ${$.older}`})),...c?[]:[{value:e,label:e,help:lV}],{value:sV,label:cV,help:lV}],u=t=>{if(t!==`__custom__`)return r(t);s(c?``:e),a(!0)},d=()=>{let t=o.trim();a(!1),t&&t!==e&&r(t)};return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(zB,{value:e,items:l,label:n,onChange:u}),i?(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,B.jsx)(xB,{autoFocus:!0,value:o,placeholder:`model id`,"aria-label":`Harness model id`,className:`min-w-0 flex-1`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())}}),(0,B.jsx)(EI,{label:`Use this model`,icon:Jf,tone:`primary`,onClick:d})]}):null]})}function EH(e,t){let n=e?.models.find(e=>e.id===t);if(n&&n.efforts.length>0)return n.efforts;if(e?.effort===`session`)return dV;let r=e?.models.find(e=>e.efforts.length>0)?.efforts;return r&&r.length>0?r:dV}function DH({kind:e,config:t,models:n,harnesses:r,save:i,onGrants:a}){let o=dH(t,e),s=t=>i(fH(e,t)),c=rV[e],l=o.harness?r.find(e=>e.id===o.harness):void 0,u=!!o.harness,d=o.harnessModel??``,f=u?EH(l,d):pH(n,o.model),p=t=>{if(t===(o.harness??`pi`))return;if(t===`pi`)return void s({harness:`pi`});let n=EH(r.find(e=>e.id===t),``),i={harness:t,harnessModel:``};e!==`scout`&&!n.includes(o.thinking)&&(i.thinking=mH(n,o.thinking)),s(i)},h=t=>{let n=EH(l,t),r={harnessModel:t};e!==`scout`&&!n.includes(o.thinking)&&(r.thinking=mH(n,o.thinking)),s(r)},g=t=>{let r={model:t};e!==`scout`&&!pH(n,t).includes(o.thinking)&&(r.thinking=mH(pH(n,t),o.thinking)),s(r)},_=e!==`scout`&&e!==`researcher`,[v,y]=(0,m.useState)(!1),b=OH(o,e);return(0,B.jsxs)(`section`,{"data-slot":`agent-row`,className:`glass flex min-w-0 flex-col gap-2.5 rounded-xl border px-3.5 pt-2.5 pb-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,B.jsx)(`h3`,{className:`flex min-w-0 items-center gap-2 break-words text-sm font-semibold`,children:c}),(0,B.jsx)(jH,{open:v,custom:b,onToggle:()=>y(e=>!e)})]}),PV.has(e)?(0,B.jsx)(wH,{value:o.harness??`pi`,statuses:r,label:`${c} ${$.label.toLowerCase()}`,onChange:p}):(0,B.jsx)(AH,{value:$.piLabel,note:`always ${$.piLabel}`,label:`${c} ${$.label.toLowerCase()}`}),u?(0,B.jsx)(TH,{value:d,models:l?.models??[],label:`${c} model`,onChange:h}):(0,B.jsx)(gH,{value:o.model,models:n,label:`${c} model`,inherit:e===`master`,onChange:g}),e===`scout`?(0,B.jsx)(kH,{}):(0,B.jsx)(WB,{value:o.thinking,levels:dV,supported:f,recommended:uV[e],model:u?d||`${l?.label??o.harness}'s default model`:o.model===`inherit`?`the session model`:o.model,label:`${c} effort`,onChange:e=>s({thinking:e})}),u&&l?.effort===`session`&&e!==`scout`?(0,B.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:$.effortNote}):null,(0,B.jsxs)(`div`,{className:`mt-auto grid gap-2.5`,children:[(0,B.jsx)(_H,{label:`Auto-compact`,help:e===`master`?`Compacts the oracle's context as it fills, and files what it learned into the knowledge base, shared with the agents it concerns.`:u?l?.protocol===`acp`?`${l.label} compacts on its own; this switch applies to pi, Codex and Claude Code.`:`Lets ${l?.label??`the harness`} compact this agent's context, at the threshold under Harnesses.`:`Compacts this agent's context as it fills.`,checked:o.autoCompact!==!1,onChange:e=>s({autoCompact:e}),name:`${c} auto-compact`}),o.autoCompact!==!1&&!u?(0,B.jsx)(bH,{value:o.compactAt,label:`${c} compact at`,onSave:e=>s({compactAt:e})}):null]}),(0,B.jsxs)(`div`,{hidden:!v,className:`grid gap-2 border-t border-border pt-2`,children:[u?(0,B.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:$.agentNote}):null,_?(0,B.jsx)(CH,{value:o.instructions??``,label:`${c} instructions`,onSave:e=>s({instructions:e})}):null,(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(`p`,{className:`min-w-[7rem] flex-1 break-words text-xs text-muted-foreground`,children:JV(KV(t,e),e)}),(0,B.jsx)(EI,{label:Q.edit,icon:_h,onClick:a})]})]})]})}function OH(e,t){return[t!==`scout`&&t!==`researcher`&&!!e.instructions,e.mcpTools!==void 0,t!==`master`&&e.skills!==void 0].filter(Boolean).length}function kH(){return(0,B.jsx)(AH,{value:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Kf,{"aria-hidden":`true`,className:`size-3.5`}),(0,B.jsx)(`span`,{className:`capitalize`,children:`low`})]}),note:`fixed for scouts`,label:`Scout effort`})}function AH({value:e,note:t,label:n}){return(0,B.jsxs)(`div`,{role:`group`,"aria-label":`${n}: ${t}`,className:`cs-fixrow`,children:[(0,B.jsx)(`span`,{className:`flex items-center gap-1.5`,children:e}),(0,B.jsx)(`span`,{className:`cs-fixnote`,children:t})]})}function jH({open:e,custom:t,onToggle:n}){return(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":e,onClick:n,className:`-mr-1.5 flex min-h-8 shrink-0 items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[(0,B.jsx)($f,{"aria-hidden":`true`,className:Y(`size-3.5 transition-transform duration-200 ease-snap`,e&&`rotate-90`)}),`More`,t>0?(0,B.jsxs)(`span`,{className:`text-primary`,children:[`· `,t,` customised`]}):null]})}function MH(e,t){return t.startsWith(`panel:`)?e.lobby.panels[t.slice(6)]:e.lobby[t]}function NH({config:e,item:t,save:n}){let r=t.id.startsWith(`panel:`);return(0,B.jsx)(_H,{label:t.label,help:t.help,checked:MH(e,t.id),onChange:e=>{n(r?{lobby:{panels:{[t.id.slice(6)]:e}}}:{lobby:{[t.id]:e}})}})}function PH({config:e,save:t}){let n=e.workflow.gitIsolation;return(0,B.jsx)(GB,{prominent:!0,title:fV.workflow,children:(0,B.jsx)(RB,{children:(0,B.jsx)(LB,{label:DV,help:EV.find(e=>e.id===n)?.help??`enter cycles off, branch, worktree`,children:(0,B.jsx)(zB,{value:n,items:EV.map(e=>({value:e.id,label:e.label})),label:DV,onChange:e=>void t({workflow:{gitIsolation:e}})})})})})}var FH=e=>e?`${e}/`:kV.top;function IH(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function LH({replaced:e}){let t=eR(`settings.linters`,{},[]),n=t.data?.linters;return(0,B.jsx)(LB,{label:kV.found,help:e?kV.foundReplaced:kV.foundHelp,children:n?n.length===0?(0,B.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:kV.foundNone}):(0,B.jsx)(`ul`,{"aria-label":kV.found,className:Y(`flex flex-col items-end gap-1.5`,e&&`opacity-60`),children:n.map(e=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.tool}),(0,B.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:FH(e.folder)}),(0,B.jsxs)(`span`,{title:e.installed?void 0:kV.missingHelp,className:Y(`inline-flex shrink-0 items-center gap-1 text-xs`,e.installed?`text-success`:`text-warning`),children:[e.installed?(0,B.jsx)(ap,{"aria-hidden":`true`,className:`size-3.5`}):(0,B.jsx)(rp,{"aria-hidden":`true`,className:`size-3.5`}),e.installed?kV.installed:kV.missing]})]},`${e.tool}:${e.folder}`))}):(0,B.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:t.error?t.error:`Looking…`})})}function RH({config:e,save:t}){let n=e.lint,r=n.mode===`off`,i=n.command.trim().length>0;return(0,B.jsxs)(GB,{prominent:!0,title:fV.lint,children:[(0,B.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:kV.intro}),(0,B.jsxs)(RB,{children:[(0,B.jsx)(LB,{label:kV.mode,help:OV.find(e=>e.id===n.mode)?.help,children:(0,B.jsx)(zB,{value:n.mode,items:OV.map(e=>({value:e.id,label:e.label})),label:kV.mode,onChange:e=>void t({lint:{mode:e}})})}),(0,B.jsxs)(`div`,{className:Y(`flex flex-col divide-y divide-border [&>*]:py-3 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0`,r&&`opacity-60`),"aria-disabled":r||void 0,children:[(0,B.jsx)(LB,{label:kV.command,help:kV.commandHelp,children:(0,B.jsx)(vH,{value:n.command,label:kV.command,placeholder:kV.commandPlaceholder,onSave:e=>void t({lint:{command:e}})})}),i?(0,B.jsx)(LB,{label:kV.extensions,help:kV.extensionsHelp,children:(0,B.jsx)(vH,{value:n.extensions.join(` `),label:kV.extensions,placeholder:kV.extensionsPlaceholder,onSave:e=>void t({lint:{extensions:IH(e)}})})}):null,(0,B.jsx)(LB,{label:kV.timeout,help:kV.timeoutHelp,children:(0,B.jsx)(yH,{value:n.timeoutMs,label:`Lint ${kV.timeout.toLowerCase()}`,onSave:e=>void t({lint:{timeoutMs:e}})})}),(0,B.jsx)(LH,{replaced:i})]})]})]})}function zH({config:e,save:t}){let n=e.lobby.web;return(0,B.jsx)(GB,{prominent:!0,title:fV.lobby,children:(0,B.jsxs)(RB,{children:[uH.map(n=>(0,B.jsx)(NH,{config:e,item:n,save:t},n.id)),(0,B.jsx)(LB,{label:yV,help:bV,children:(0,B.jsx)(zB,{value:String(e.lobby.maxPlanningRounds),items:xV.map(e=>({value:String(e),label:hH(e)})),label:yV,onChange:e=>void t({lobby:{maxPlanningRounds:Number(e)}})})}),(0,B.jsx)(LB,{label:SV,help:CV,children:(0,B.jsx)(xH,{value:n.port,onSave:e=>void t({lobby:{web:{port:e}}})})}),(0,B.jsx)(_H,{label:wV,help:TV,checked:n.openBrowser,onChange:e=>void t({lobby:{web:{openBrowser:e}}})}),(0,B.jsx)(BH,{})]})})}function BH(){let e=eR(`lobby.retention`,{},[]),t=async t=>{try{await I(`lobby.setRetention`,{enabled:t}),e.reload()}catch(e){H.error(e instanceof Error?e.message:`That did not work. Try again.`)}};return(0,B.jsx)(_H,{label:gV.label,help:e.error?gV.error:gV.help,checked:e.data?.enabled??!1,onChange:e=>void t(e)})}function VH(e){let t=e.indexOf(`/`);return t>0?e.slice(0,t):``}function HH(e,t){let n=new Set,r=[];for(let e of t)n.has(e.id)||(n.add(e.id),r.push({id:e.id,label:e.label,kind:`classifier`}));for(let t of e)n.has(t.id)||(n.add(t.id),r.push({id:t.id,label:t.label,kind:`chat`}));return r}function UH({value:e,models:t,classifiers:n,onChange:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=HH(t,n),l=VH(e),[u,d]=(0,m.useState)(l),f=e?l:u,p=[...new Set([...c.map(e=>VH(e.id)),...l?[l]:[]])].filter(Boolean).sort(),h=[{value:WH,label:MV.engineJev,help:MV.engineJevHelp},...p.map(e=>{let t=c.filter(t=>VH(t.id)===e),n=t.filter(e=>e.kind===`classifier`).length,r=t.length-n,i=[n?`${n} ${MV.engineClassifier}${n===1?``:`s`}`:``,r?`${r} chat model${r===1?``:`s`}`:``].filter(Boolean).join(`, `);return{value:e,label:e,...i?{help:i}:{}}})],g=c.filter(e=>VH(e.id)===f),_=[...g.map(e=>({value:e.id,label:e.id.slice(f.length+1),help:`${e.kind===`classifier`?MV.engineClassifier:MV.engineChat}${e.label&&e.label!==e.id?` · ${e.label}`:``}`})),...e&&!g.some(t=>t.id===e)?[{value:e,label:e.slice(f.length+1)||e,help:lV}]:[],{value:sV,label:cV,help:lV}],v=e=>{if(a(!1),e===WH)return d(``),r(``);d(e);let t=c.find(t=>VH(t.id)===e&&t.kind===`classifier`)??c.find(t=>VH(t.id)===e);t&&r(t.id)},y=t=>{if(t!==`__custom__`)return r(t);s(e&&!g.some(t=>t.id===e)?e:`${f}/`),a(!0)},b=()=>{let t=o.trim();a(!1),t&&t!==e&&r(t)};return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(zB,{value:f||WH,items:h,label:MV.provider,onChange:v}),f?(0,B.jsx)(zB,{value:e||`__custom__`,items:_,label:MV.engineModel,onChange:y}):null,i?(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,B.jsx)(xB,{autoFocus:!0,value:o,placeholder:`provider/model`,"aria-label":`Classifier model id`,className:`min-w-0 flex-1`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())}}),(0,B.jsx)(EI,{label:`Use this model`,icon:Jf,tone:`primary`,onClick:b})]}):null]})}var WH=`__jev__`;function GH({config:e,models:t,classifiers:n,save:r}){let i=e.classifier,a=AV.find(e=>e.id===i.provider)?.label,o=!i.engine;return(0,B.jsx)(GB,{prominent:!0,title:fV.classifier,children:(0,B.jsxs)(RB,{children:[(0,B.jsx)(_H,{label:MV.enabled,help:MV.enabledHelp,checked:i.enabled,onChange:e=>void r({classifier:{enabled:e}})}),(0,B.jsx)(LB,{label:MV.engine,help:MV.engineHelp,children:(0,B.jsx)(UH,{value:i.engine,models:t,classifiers:n,onChange:e=>void r({classifier:{engine:e}})})}),o?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(LB,{label:MV.host,children:(0,B.jsx)(zB,{value:i.provider,items:AV.map(e=>({value:e.id,label:e.label})),label:MV.host,onChange:e=>void r({classifier:{provider:e}})})}),(0,B.jsx)(LB,{label:MV.model,help:MV.modelHelp,children:(0,B.jsx)(vH,{value:i.model,label:MV.model,placeholder:`the host's default`,onSave:e=>void r({classifier:{model:e}})})}),(0,B.jsx)(LB,{label:MV.key,help:MV.keyNote,children:(0,B.jsx)(`p`,{className:`break-words text-sm text-muted-foreground text-right`,children:a??i.provider})})]}):null,jV.map(e=>(0,B.jsx)(_H,{label:e.label,help:e.help,checked:i.features[e.id],onChange:t=>void r({classifier:{features:{[e.id]:t}}})},e.id)),(0,B.jsx)(LB,{label:MV.cheap,help:MV.cheapHelp,children:(0,B.jsx)(gH,{value:i.effort.cheapModel,models:t,label:MV.cheap,none:!0,onChange:e=>void r({classifier:{effort:{cheapModel:e}}})})})]})})}function KH(){let e=cB(),t=async e=>{if(!e)return uB();let t=await lB();t===`granted`?H.success(NV.notificationsOn):H.error(t===`unsupported`?NV.notificationsUnsupported:NV.notificationsBlocked)};return(0,B.jsx)(GB,{prominent:!0,title:fV.notifications,children:(0,B.jsx)(RB,{children:(0,B.jsx)(_H,{label:NV.notificationsLabel,help:NV.notificationsHelp,checked:e,onChange:e=>void t(e)})})})}function qH(){let{available:e,install:t}=y(),n=b(),r=x();return(0,B.jsx)(GB,{prominent:!0,title:fV.install,children:(0,B.jsxs)(RB,{children:[(0,B.jsx)(LB,{label:NV.installLabel,help:n?NV.installedNow:NV.installHelp,children:n?null:(0,B.jsx)(`div`,{className:`flex justify-end`,children:(0,B.jsx)(EI,{label:NV.installButton,icon:xp,tone:`primary`,onClick:()=>e?void t().then(()=>H.success(NV.installDone)):H.warning(NV.installUnavailable)})})}),r.supported?(0,B.jsx)(LB,{label:NV.fullscreenLabel,help:NV.fullscreenHelp,children:(0,B.jsx)(`div`,{className:`flex justify-end`,children:(0,B.jsx)(EI,{label:r.on?NV.fullscreenOn:NV.fullscreenOff,icon:r.on?dm:rm,pressed:r.on,onClick:()=>void r.toggle()})})}):null]})})}var JH=[`Agents`,`Harnesses`,`Tools & skills`,`Workflow`,`Lobby`,`Classifier`,`Appearance & notifications`],YH=e=>`settings-${e.split(` `)[0]}`;function XH({config:e,models:t,classifierModels:n=[],onConfig:r}){let[i,a]=(0,m.useState)(`Agents`),[o,s]=(0,m.useState)(`master`),c=e=>{s(e),a(`Tools & skills`)},l=eR(`settings.harnesses`,{},[]),u=JSON.stringify(e.harnesses),d=l.reload,f=(0,m.useRef)(u);(0,m.useEffect)(()=>{f.current!==u&&(f.current=u,d())},[u,d]);let p=l.data?.harnesses??[],h=(0,m.useRef)(Promise.resolve()),g=e=>{let t=async()=>{try{return r((await I(`settings.set`,{patch:e})).config),H.success(NV.saved),!0}catch(e){return H.error(e instanceof Error?e.message:`That did not work. Try again.`),!1}},n=h.current.then(t,t);return h.current=n,n};return(0,B.jsxs)(`div`,{className:`cs-pg cs-set flex flex-col pb-dock`,children:[(0,B.jsx)(`header`,{className:`cs-pgh`,children:(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h1`,{className:`cs-hd1`,children:NV.title}),(0,B.jsx)(`p`,{className:`cs-hd2`,children:NV.intro})]})}),(0,B.jsx)(`nav`,{"aria-label":`Settings sections`,className:`cs-secn`,children:(0,B.jsx)(hE,{as:`nav`,size:`md`,label:`Settings sections`,items:JH.map(e=>({id:e,label:e,controls:YH(e)})),value:i,onChange:a})}),(0,B.jsxs)(`div`,{id:YH(`Agents`),hidden:i!==`Agents`,"aria-hidden":i!==`Agents`,children:[(0,B.jsx)(`h2`,{className:`sr-only`,children:fV.agents}),(0,B.jsx)(`div`,{className:`cs-agrid grid grid-cols-2 gap-3.5 lg:grid-cols-3`,children:nV.map(n=>(0,B.jsx)(DH,{kind:n,config:e,models:t,harnesses:p,save:g,onGrants:()=>c(n)},n))})]}),(0,B.jsx)(`div`,{id:YH(`Harnesses`),hidden:i!==`Harnesses`,"aria-hidden":i!==`Harnesses`,children:(0,B.jsx)(cH,{config:e,statuses:l.data?.harnesses,...l.error?{error:l.error}:{},save:g})}),(0,B.jsx)(`div`,{id:YH(`Tools & skills`),hidden:i!==`Tools & skills`,"aria-hidden":i!==`Tools & skills`,children:(0,B.jsx)(QV,{config:e,save:g,agent:o,onAgent:s})}),(0,B.jsx)(`div`,{id:YH(`Workflow`),hidden:i!==`Workflow`,"aria-hidden":i!==`Workflow`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,B.jsx)(PH,{config:e,save:g}),(0,B.jsx)(RH,{config:e,save:g})]})}),(0,B.jsx)(`div`,{id:YH(`Lobby`),hidden:i!==`Lobby`,"aria-hidden":i!==`Lobby`,children:(0,B.jsx)(zH,{config:e,save:g})}),(0,B.jsx)(`div`,{id:YH(`Classifier`),hidden:i!==`Classifier`,"aria-hidden":i!==`Classifier`,children:(0,B.jsx)(GH,{config:e,models:t,classifiers:n,save:g})}),(0,B.jsx)(`div`,{id:YH(`Appearance & notifications`),hidden:i!==`Appearance & notifications`,"aria-hidden":i!==`Appearance & notifications`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,B.jsx)(HV,{}),(0,B.jsx)(KH,{}),(0,B.jsx)(qH,{})]})})]})}function ZH(){return(0,B.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4 px-8 pt-8 pb-dock`,role:`status`,"aria-label":NV.loading,children:[0,1,2,3].map(e=>(0,B.jsx)(AE,{shape:`card`,className:`h-48`},e))})}function QH(){let e=eR(`settings.get`,{},[`status`]),[t,n]=(0,m.useState)(),r=(0,m.useRef)(0),i=(0,m.useCallback)(e=>{r.current=performance.now(),n(e)},[]);return(0,m.useEffect)(()=>{e.data&&e.requestedAt>r.current&&n(e.data.config)},[e.data,e.requestedAt]),!t&&e.error?(0,B.jsx)(cE,{message:`${NV.loadFailed} ${e.error}`,onRetry:e.reload}):t?(0,B.jsx)(XH,{config:t,models:e.data?.models??[],classifierModels:e.data?.classifierModels??[],onConfig:i}):(0,B.jsx)(ZH,{})}function $H(){let e=globalThis.DOMParser;if(!e)throw Error(`DOMParser is unavailable`);return new e}var eU=`default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src 'none'; font-src 'none'; connect-src 'none'; media-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'`,tU=new Set(`div span p br hr h1 h2 h3 h4 h5 h6 section article header footer main aside nav ul ol li dl dt dd strong em b i u s small sub sup blockquote pre code table thead tbody tfoot tr th td caption colgroup col figure figcaption style button input label select option optgroup textarea details summary fieldset legend progress meter output kbd mark`.split(` `)),nU=new Set(`class id title role aria-label aria-hidden aria-expanded aria-selected aria-checked aria-pressed aria-current colspan rowspan scope type name value placeholder for checked selected disabled readonly open min max step rows cols tabindex`.split(` `)),rU=new Set(`text search email tel url number password checkbox radio range color date time month week button reset submit`.split(` `)),iU=`button,input,select,textarea,summary,label,[role=button],[role=tab]{transition:background-color .18s ease,color .18s ease,border-color .18s ease,box-shadow .18s ease,transform .18s ease,opacity .18s ease}button,summary,label,select,[role=button],[role=tab],input[type=checkbox],input[type=radio],input[type=range]{cursor:pointer}button:active,[role=button]:active{transform:scale(.97)}details[open]>:not(summary){animation:mockup-in .22s ease-out}@keyframes mockup-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}`;function aU(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.html!=`string`||t.html.length>1e5)&&!(t.css!==void 0&&(typeof t.css!=`string`||t.css.length>12e4)))return{html:t.html,...typeof t.css==`string`?{css:t.css}:{}}}function oU(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,``);return/\\|@import|url\s*\(|image-set\s*\(|expression\s*\(|behavior\s*:|-moz-binding/i.test(t)?``:t.replace(/<\/?style/gi,``)}function sU(e){if(!tU.has(e.localName)||e.namespaceURI!==`http://www.w3.org/1999/xhtml`){e.remove();return}for(let t of[...e.attributes])t.name===`style`?e.setAttribute(`style`,oU(t.value)):nU.has(t.name)||e.removeAttribute(t.name);if(e.localName===`input`){let t=[...e.attributes].find(e=>e.name===`type`)?.value.toLowerCase();t!==void 0&&!rU.has(t)&&e.setAttribute(`type`,`text`)}e.localName===`style`&&(e.textContent=oU(e.textContent??``));for(let t of[...e.children])sU(t)}function cU(e,t){try{return lU(e,t??$H())}catch{return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${eU}"><meta name="referrer" content="no-referrer"></head><body><p role="status">Static mockup unavailable. The preview could not be safely rendered.</p></body></html>`}}function lU(e,t){let n=t.parseFromString(e.html,`text/html`);for(let e of[...n.head.children,...n.body.children])sU(e);let r=[...n.head.querySelectorAll(`style`)].map(e=>e.outerHTML).join(``);return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${eU}"><meta name="referrer" content="no-referrer"><style>body{margin:16px;overflow-wrap:anywhere}*{box-sizing:border-box}${iU}${oU(e.css??``).replace(/</g,`\\3c `)}</style>${r}</head><body>${n.body.innerHTML}</body></html>`}function uU({preview:e,label:t,className:n,frameWidth:r,minWidth:i,onOpen:a}){let o=(0,m.useMemo)(()=>cU(e),[e]),s=(0,m.useRef)(null),[c,l]=(0,m.useState)();if((0,m.useLayoutEffect)(()=>{let e=s.current;if(!r&&!i||!e)return;let t=()=>l({width:e.clientWidth,height:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r,i]),!r&&!i)return(0,B.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:Y(`h-80 w-full rounded-lg border bg-background`,n)});let u=r??Math.max(c?.width??0,i??0),d=c&&c.width>0&&u>0?Math.min(1,c.width/u):1;return(0,B.jsxs)(`div`,{ref:s,className:Y(`group/mock relative h-80 w-full max-w-full overflow-hidden rounded-lg border bg-background`,n),children:[(0,B.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:`absolute top-0 left-0 origin-top-left border-0`,style:{width:u||`100%`,height:c?c.height/d:`100%`,transform:`scale(${d})`}}),a?(0,B.jsx)(`button`,{type:`button`,"data-compact":``,onClick:a,"aria-label":`Expand the mockup: ${t}`,title:`Expand`,className:`cs-mxb outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,B.jsx)(tm,{"aria-hidden":`true`,className:`size-3`})}):null]})}var dU=/\s*\(recommended\)\s*$/i,fU=1024,pU=e=>e.replace(dU,``);function mU(e){return!!(e&&(e.htmlPreview||e.image||e.preview))}function hU({option:e}){let t=pU(e.label);return mU(e)?(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[e.htmlPreview?(0,B.jsx)(uU,{preview:e.htmlPreview,label:t,minWidth:fU,className:`h-auto min-h-[18rem] flex-1`}):null,e.image?(0,B.jsx)(`img`,{src:P(e.image),alt:`Mockup: ${t}`,className:`min-h-0 w-full flex-1 rounded-lg border bg-background object-contain`}):null,e.preview?(0,B.jsx)(FL,{text:e.preview,className:Y(`overflow-auto rounded-lg border bg-background p-4 text-sm`,!e.htmlPreview&&!e.image&&`flex-1`)}):null]}):(0,B.jsx)(`p`,{className:`grid h-full place-items-center p-6 text-sm text-muted-foreground`,children:`No mockup for this option.`})}function gU({options:e,start:t,title:n,picked:r=[],multi:i=!1,onChoose:a,onClose:o,onIndex:s}){let c=Jd(),l=(0,m.useRef)(null),u=(0,m.useRef)(null),[d,f]=(0,m.useState)(()=>Math.min(Math.max(0,t),e.length-1)),p=e[d],h=e.length-1;(0,m.useEffect)(()=>s?.(d),[d,s]),(0,m.useLayoutEffect)(()=>{let e=l.current;e&&(e.scrollLeft=d*e.clientWidth),u.current?.focus()},[]);let g=(0,m.useCallback)(e=>{let t=Math.min(Math.max(0,e),h),n=l.current;f(t),n?.scrollTo({left:t*n.clientWidth,behavior:c?`auto`:`smooth`})},[h,c]);(0,m.useEffect)(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.scrollLeft=d*e.clientWidth});return t.observe(e),()=>t.disconnect()},[d]);function _(){let e=l.current;if(!e||e.clientWidth===0)return;let t=Math.round(e.scrollLeft/e.clientWidth);t!==d&&t>=0&&t<=h&&f(t)}function v(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=t.target;if(n.closest(`input, textarea, [contenteditable='true']`))return;let r={ArrowLeft:-1,ArrowRight:1,PageUp:-1,PageDown:1}[t.key];if(r){t.preventDefault(),g(d+r);return}if(t.key===`Home`||t.key===`End`){t.preventDefault(),g(t.key===`Home`?0:h);return}let i=Number(t.key);if(Number.isInteger(i)&&i>=1&&i<=e.length){t.preventDefault(),g(i-1);return}t.key===`Enter`&&a&&!(n instanceof HTMLButtonElement)&&(t.preventDefault(),a(d))}let y=r.includes(d);return(0,B.jsxs)(`div`,{ref:u,tabIndex:-1,"data-autofocus":``,onKeyDown:v,className:`mockup-viewer flex h-full min-h-0 flex-col outline-none`,role:`region`,"aria-label":`Mockups: ${n}`,"aria-roledescription":`carousel`,children:[(0,B.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,B.jsx)(OT,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to the question`,title:`Back · Esc`,onClick:()=>o(d),children:(0,B.jsx)(lm,{"aria-hidden":`true`})}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,"aria-live":`polite`,children:[d+1,` of `,e.length]}),(0,B.jsx)(`div`,{role:`tablist`,"aria-label":`Options`,className:`flex w-full flex-wrap gap-1.5 sm:w-auto`,children:e.map((e,t)=>(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===d,"aria-controls":`mockup-slide-${t}`,"data-compact":``,onClick:()=>g(t),className:Y(`inline-flex h-7 max-w-48 items-center gap-1 rounded-lg border px-2.5 text-xs font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t===d?`border-primary/50 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,B.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t+1}),(0,B.jsx)(`span`,{className:`truncate`,children:pU(e.label)}),r.includes(t)?(0,B.jsx)(Jf,{"aria-label":`picked`,className:`size-3 text-primary`}):null]},t))})]}),(0,B.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,B.jsx)(`div`,{ref:l,onScroll:_,className:`mockup-track flex h-full snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain`,children:e.map((t,n)=>(0,B.jsxs)(`section`,{id:`mockup-slide-${n}`,role:`tabpanel`,"aria-roledescription":`slide`,"aria-label":`${n+1} of ${e.length}: ${pU(t.label)}`,"aria-hidden":n!==d,className:`flex h-full w-full shrink-0 snap-center snap-always flex-col gap-2 overflow-y-hidden px-4 py-4 sm:px-14`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[(0,B.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[n+1,`.`]}),(0,B.jsx)(`span`,{className:`font-medium`,children:pU(t.label)}),dU.test(t.label)?(0,B.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Recommended`}):null,r.includes(n)?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-primary`,children:[(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3`}),`picked`]}):null]}),t.description?(0,B.jsx)(FL,{text:t.description,className:`text-sm text-muted-foreground`}):null,(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(hU,{option:t})})]},n))}),d>0?(0,B.jsx)(OT,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Previous option`,title:`Previous · ←`,onClick:()=>g(d-1),className:`absolute top-1/2 left-2 -translate-y-1/2 rounded-full`,children:(0,B.jsx)(Zf,{"aria-hidden":`true`})}):null,d<h?(0,B.jsx)(OT,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Next option`,title:`Next · →`,onClick:()=>g(d+1),className:`absolute top-1/2 right-2 -translate-y-1/2 rounded-full`,children:(0,B.jsx)($f,{"aria-hidden":`true`})}):null]}),(0,B.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-border px-4 py-3`,children:[(0,B.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,B.jsx)(LT,{chord:`←→`,children:`option`}),a?(0,B.jsx)(LT,{chord:`Enter`,children:i?y?`unpick`:`pick`:`choose`}):null,(0,B.jsx)(LT,{chord:`Esc`,children:`back`})]}),a&&p?(0,B.jsxs)(OT,{type:`button`,onClick:()=>a(d),className:`max-w-full`,children:[i&&y?`Unpick`:i?`Pick`:`Choose`,(0,B.jsx)(`span`,{className:`truncate`,children:pU(p.label)})]}):null]})]})}function _U(e,t,n){e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),e.key===`Enter`&&e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),t()))}function vU({text:e,disabled:t=!1,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),u=(0,m.useRef)(null);(0,m.useEffect)(()=>{u.current?.focus({preventScroll:!0}),u.current?.select()},[]);let d=async()=>{if(!(t||o||!i.trim())){s(!0),l(``);try{await n(i.trim()),r()}catch(e){l(e instanceof Error?e.message:String(e)),s(!1)}}};return(0,B.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>_U(e,()=>void d(),()=>{o||r()}),children:[(0,B.jsxs)(`label`,{className:`text-sm`,children:[`Edit message`,(0,B.jsx)(CB,{ref:u,value:i,onChange:e=>a(e.target.value),disabled:o,className:`mt-2 max-h-[40vh] min-h-24`})]}),c?(0,B.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not save. `,c]}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(OT,{size:`sm`,onClick:()=>void d(),disabled:t||o||!i.trim(),children:o?`Saving…`:`Save`}),(0,B.jsx)(OT,{size:`sm`,variant:`ghost`,disabled:o,onClick:r,children:`Cancel`})]})]})}var yU=1200;function bU({question:e}){let[t,n]=(0,m.useState)(),r=qT(t!==void 0,KT.sheet),i=e.options.flatMap((e,t)=>e.mockup?[{option:e,index:t,mockup:e.mockup}]:[]);if(i.length===0)return null;let a=e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}));return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`ul`,{"aria-label":`Mockups`,className:`cs-mocks`,children:i.map(({option:e,index:t,mockup:r})=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,B.jsx)(uU,{preview:r,label:pU(e.label),frameWidth:yU,onOpen:()=>n(t),className:`cs-mk3f aspect-[3/2] h-auto`}),(0,B.jsxs)(`span`,{className:`truncate`,children:[(0,B.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,`.`]}),` `,pU(e.label)]})]},t))}),(0,B.jsx)(zT,{open:t!==void 0&&r,onOpenChange:e=>{e||n(void 0)},label:`Mockups: ${e.text}`,className:`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`,children:t===void 0?null:(0,B.jsx)(gU,{options:a,start:t,title:e.text,onClose:()=>n(void 0)})})]})}function xU({questions:e}){return(0,B.jsx)(`ol`,{className:`cs-qs`,children:e.map((e,t)=>(0,B.jsxs)(`li`,{className:`cs-qc`,style:{"--ac":pR(e.from)},children:[(0,B.jsxs)(`p`,{className:`cs-qh`,children:[(0,B.jsx)(`span`,{className:`cs-qwho`,children:vR(e.from)}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsxs)(`span`,{className:`sr-only`,children:[`Question `,t+1,`: `]}),e.text]})]}),e.options.length?(0,B.jsx)(`ul`,{"aria-label":`Options`,className:`cs-opts`,children:e.options.map(e=>(0,B.jsxs)(`li`,{className:`cs-op`,children:[(0,B.jsx)(`b`,{children:e.label}),e.description?` — ${e.description}`:``]},e.label))}):null,(0,B.jsx)(bU,{question:e})]},t))})}function SU({message:e}){let t=e.decided??[];return t.length?(0,B.jsx)(`ul`,{"aria-label":`Settled for you`,className:`cs-decided`,children:t.map((e,t)=>(0,B.jsxs)(`li`,{title:`Settled by the classifier, ${Math.round(e.probability*100)}% sure. Comment on the plan to overrule it.`,children:[(0,B.jsx)(Jf,{"aria-hidden":`true`,className:`size-3.5`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`b`,{className:`font-semibold`,style:{color:pR(e.from)},children:vR(e.from)}),` `,(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:e.question}),` `,(0,B.jsx)(`b`,{className:`font-semibold`,children:e.answer}),(0,B.jsxs)(`span`,{className:`cs-dh2`,children:[`auto · `,Math.round(e.probability*100),`% · comment to overrule`]})]})]},t))}):null}function CU({message:e,index:t,busy:n,readOnly:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),c=o&&(o.editedAt??0)>(e.editedAt??0)?o:e,l=n||c!==e,u=async n=>{let r=await I(`planner.editMessage`,{messageIndex:t,at:e.at,text:n});s(r.message)},d=!r&&!e.settled?.length&&!i?(0,B.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>a(!0),className:`chat-action`,children:[(0,B.jsx)(ym,{"aria-hidden":`true`,className:`size-3`}),`Edit`]}):null;return(0,B.jsx)(DR,{time:e.at>0?RR(e.at):void 0,head:!0,note:c.editedAt?`(edited)`:void 0,actions:d,children:i?(0,B.jsx)(vU,{text:c.text,disabled:n,onSave:u,onCancel:()=>a(!1)}):(0,B.jsx)(FL,{text:c.text})})}function wU({message:e,index:t,busy:n,readOnly:r}){if(e.role===`you`)return(0,B.jsx)(CU,{message:e,index:t,busy:n,readOnly:r});let i=e.questions??[];return(0,B.jsxs)(wR,{tile:!0,source:`PLANNER`,name:`Panel`,time:e.at>0?RR(e.at):void 0,head:!0,bubble:i.length===0,aside:i.length?`${i.length} question${i.length===1?``:`s`}`:void 0,children:[i.length>0?(0,B.jsx)(xU,{questions:i}):(0,B.jsx)(FL,{text:e.text}),(0,B.jsx)(SU,{message:e})]})}function TU({messages:e,seed:t,busy:n=!1,readOnly:r=!1}){return(0,B.jsxs)(`div`,{className:`chat-column`,role:`log`,"aria-label":`Panel conversation`,children:[t?(0,B.jsx)(OR,{children:t}):null,e.map((e,t)=>(0,B.jsx)(wU,{message:e,index:t,busy:n,readOnly:r},`${e.at}-${t}`)),n?(0,B.jsx)(wR,{tile:!0,source:`PLANNER`,name:`Panel`,head:!0,live:!0,waiting:!0,aside:`the panel is thinking`}):null]})}var EU=`ORACLE`,DU=`No draft yet.`,OU=`The draft appears after the panel's first round.`,kU=`What each seat needs`,AU=[`backend`,`designer`,`qa`,`researcher`],jU={backend:`DEV`,designer:`DESIGN`,qa:`QA`,researcher:`RESEARCH`};function MU(e,t=0){return t<=0?`round ${e}`:e>t?`round ${e} · past the limit, revising`:e===t?`final round ${e}/${t}`:`round ${e}/${t}`}function NU(e,t){return`${e} ${t}${e===1?``:`s`}`}function PU(e){return e.round===0&&e.messages.length===0&&!e.busy}function FU(e){let t=e.members.find(e=>e.status===`failed`);if(t)return(t.error??`${jU[t.member]} failed`).split(`
|
|
104
104
|
`)[0]}function IU(e){let t=[],n=FU(e);return e.busy?t.push(MU(e.round,e.limit)):n?t.push(`${n} — Retry runs the round again`):e.questions.length>0&&t.push(`${NU(e.questions.length,`question`)} waiting`),!e.busy&&e.round>0&&t.push(MU(e.round,e.limit)),!e.busy&&e.limit>0&&e.round+1===e.limit&&t.push(`the next round is the last: the oracle settles the rest`),t}function LU(e,t){let n=jU[e],r=t.seats.includes(e),i=t.members.find(t=>t.member===e),a={member:e,label:n,seated:r,working:!1};if(!r)return{...a,text:`off`};if(i?.status===`thinking`)return{...a,working:!0,text:i.step??`thinking`};if(i?.status===`failed`)return{...a,text:`failed — Retry`};if(!i)return{...a,text:`·`};if(i.reply?.status===`ready`)return{...a,text:`ready`};let o=t.questions.filter(e=>e.from===n).length;return{...a,text:o===0?`done`:NU(o,`question`)}}function RU(e){let t=e.questions.filter(e=>e.from===EU).length;return[{label:EU,seated:!0,working:e.busy,text:e.busy?`chairing`:t?NU(t,`question`):`·`},...AU.map(t=>LU(t,e))]}function zU({iconOnly:e,className:t,side:n}){return(0,B.jsx)(EI,{label:`Previous plans`,text:`Previous`,icon:jm,shortcut:`H`,iconOnly:e,...t?{className:t}:{},...n?{side:n}:{},onClick:()=>iE(rE(`plan`,`previous`))})}function BU({snap:e}){return e.busy||FU(e)===void 0?null:(0,B.jsx)(`p`,{role:`status`,className:`cs-note mx-auto mb-4 max-w-[48.75rem] text-[var(--bad)]`,children:IU(e).join(` · `)})}function VU(e){let t=vR(e.toUpperCase()===`MASTER`?`MASTER`:e.toUpperCase());return t.length<=3?t:t.slice(0,3)}function HU({cell:e,asked:t,onToggled:n}){let r=vR(e.label),i=`${e.member?e.seated?`${r} sits on the panel`:`${r} sits this one out`:`${r} chairs the panel`}${e.text&&e.text!==`·`&&e.text!==`off`?` · ${e.text}`:``}${e.member?` · click to toggle`:``}`,a=async()=>{e.member&&await U(`planner.toggleSeat`,{member:e.member})&&n()};return(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,className:`cs-sq cs-tipl`,"data-tip":i,"aria-label":i,"aria-pressed":e.member?e.seated:void 0,"data-on":e.seated?`true`:`false`,"data-fixed":e.member?void 0:`true`,"data-working":e.working?`true`:void 0,style:{"--c":pR(e.label)},onClick:e.member?()=>void a():void 0,children:[(0,B.jsx)(`span`,{className:`cs-sqt`,children:VU(e.label)}),t>0?(0,B.jsx)(`span`,{className:`cs-sqn`,children:t}):null]})})}function UU(e){let t=e.messages.at(-1);return t?.role===`planner`?t.questions??[]:[]}function WU({snap:e,onDone:t}){let n=vE(`status`).data?.keys.find(e=>e.action===`savePlan`)?.label,r=e=>async()=>{await U(e,{})&&t()},i=IU(e).join(` · `)||`No rounds yet`,a=e.busy?e.round+1:Math.max(e.round,1);return(0,B.jsxs)(`aside`,{className:`cs-pside`,"aria-label":`Planning`,children:[e.limit>0?(0,B.jsxs)(`span`,{className:`cs-rcnt cs-tipl`,"data-tip":i,role:`status`,"aria-label":i,children:[(0,B.jsx)(`b`,{children:Math.min(a,e.limit)}),(0,B.jsxs)(`i`,{children:[`/`,e.limit]})]}):(0,B.jsx)(`span`,{className:`sr-only`,role:`status`,children:i}),(0,B.jsx)(`ul`,{className:`cs-chips`,"aria-label":`Panel`,children:RU(e).map(n=>(0,B.jsx)(HU,{cell:n,asked:UU(e).filter(e=>mR(e.from,n.label)).length,onToggled:t},n.label))}),(0,B.jsx)(`div`,{className:`cs-sqsep`}),(0,B.jsxs)(`ul`,{className:`cs-chips`,"aria-label":`Plan actions`,children:[e.retryable?(0,B.jsx)(`li`,{children:(0,B.jsx)(EI,{iconOnly:!0,side:`left`,className:`cs-sq cs-act`,label:`Retry the round`,icon:Fm,shortcut:`R`,onClick:()=>void r(`planner.retry`)()})}):null,(0,B.jsx)(`li`,{children:(0,B.jsx)(zU,{iconOnly:!0,side:`left`,className:`cs-sq cs-act`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(EI,{iconOnly:!0,side:`left`,className:`cs-sq cs-act`,"data-plan-save":!0,label:`Save the plan`,icon:zm,shortcut:n??`Ctrl+S`,disabled:!e.draft||e.busy,onClick:()=>void r(`planner.save`)()})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(qL,{iconOnly:!0,side:`left`,className:`cs-sq cs-act`,icon:kp,label:`New plan`,shortcut:`N`,title:`Start a new plan?`,description:`The conversation and the draft are left behind. Saved plans are not touched.`,confirmLabel:`New plan`,onConfirm:()=>void U(`planner.new`,{}).then(t)})})]})]})}function GU(e){let t=!1;return e.split(`
|
|
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
|
-
`).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})=>e.map((r,i)=>(0,B.jsx)(YG,{row:r,head:i===0,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(`
|
|
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:`9`,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:`9`,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
|
-
`,``);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`,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,{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`,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:`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:`2.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:`2.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-BDSx8e_Y.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-3n1E__cD.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(`
|
|
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.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};
|