@a-t-h-i/bot-lobby 0.7.4 → 0.7.5
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-B9IpRRpY.js → CodeSurface-raLMzkDq.js} +1 -1
- package/webui/dist/assets/{TerminalView-CHnFTGrB.js → TerminalView-BQ_vyCt-.js} +1 -1
- package/webui/dist/assets/{index-BcsQfVsV.js → index-C0ezGgLF.js} +2 -2
- package/webui/dist/assets/index-Cam40qjn.css +2 -0
- package/webui/dist/build.json +3 -3
- package/webui/dist/index.html +2 -2
- package/webui/dist/assets/index-Dfi2IVPS.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-BQ_vyCt-.js","assets/rolldown-runtime-hePW80VL.js","assets/ccount-DQxSH8e6.js","assets/TerminalView-BrP-ENHg.css","assets/CodeSurface-raLMzkDq.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 D(e){let t=e.replace(/!important/gi,``).trim();if(t&&T.test(t)&&!E.test(t))return t}function O(e,t,n){let r=e.replace(/^--/,``).toLowerCase();if(!w.has(r))return;let i=D(t);i&&(n[r]=i)}function k(e){let t={};for(let n of e.matchAll(/--([a-z0-9-]+)\s*:\s*([^;}]+)/gi))O(n[1],n[2],t);return t}function A(e){if(!e||typeof e!=`object`)return;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&O(n,r,t);return Object.keys(t).length>0?t:void 0}function j(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`&&O(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=k(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 M={"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)`},N=`"Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,ee=`ui-monospace, "JetBrains Mono", "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace`;function te(e,t){let n=[];for(let[e,r]of Object.entries(t))e===`font-sans`?n.push(`--app-font-sans:${r},${N};`):e===`font-mono`?n.push(`--app-font-mono:${r},${ee};`):n.push(`--${e}:${r};`);for(let[e,r]of Object.entries(M))e in t||n.push(`--${e}:${r};`);return`${e}{${n.join(``)}}`}function P(e){let t=[];return e.light&&t.push(te(`:root`,e.light)),e.dark&&t.push(te(`.dark`,e.dark)),t.join(`
|
|
3
3
|
`)}var ne=`mist`,re=[{id:ne,name:`Default`}],ie={light:{background:`#faf9f5`,card:`#ffffff`,primary:`#c96442`,accent:`#f0eee6`},dark:{background:`#262624`,card:`#30302e`,primary:`#d97757`,accent:`#1f1e1d`}};function ae(e,t){let n=t?e.dark:e.light,r=ie[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 oe={activity:400,thoughts:40,chat:100};function se(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 ce=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:se(t.activity,e.activity??[],oe.activity),thoughts:se(t.thoughts,e.thoughts??[],oe.thoughts),chat:se(t.chat,e.chat??[],oe.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 le(){return new ce}var F=le(),ue=/^[a-f0-9]{32}$/;function de(){return globalThis.location}function fe(){let e=de()?.search??``,t=new URLSearchParams(e).getAll(`project`);if(t.length){if(t.length!==1||!ue.test(t[0]))throw Error(`Invalid project ID. Choose a running project below.`);return t[0]}}function I(e){if(!e.startsWith(`/api/`)&&!e.startsWith(`/files/preview/`))return e;let t=fe();return t?`/projects/${t}${e}`:e}function L(e,t){if(!ue.test(e))throw Error(`Invalid project ID.`);let n=de();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 pe=`bot-lobby.projectFolders`,me=new Map;function he(){try{return globalThis.sessionStorage}catch{return}}function ge(){try{let e=JSON.parse(he()?.getItem(pe)??`{}`);for(let[t,n]of Object.entries(e))ue.test(t)&&typeof n==`string`&&me.set(t,n)}catch{}}function _e(e){ge();for(let t of e)ue.test(t.id)&&me.set(t.id,t.cwd);try{he()?.setItem(pe,JSON.stringify(Object.fromEntries([...me].slice(-64))))}catch{}}function ve(e){return me.has(e)||ge(),me.get(e)}async function ye(e){let t;try{t=fe()}catch{return!1}if(!t)return!1;let n=ve(t);if(!n)return!1;let{projects:r}=await e();if(_e(r),r.some(e=>e.id===t))return!1;let i=r.find(e=>e.cwd===n),a=de(),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 be=class extends Error{code;status;constructor(e,t,n){super(e),this.name=`ApiError`,this.code=t,this.status=n}},xe={"Content-Type":`application/json`};async function R(e,t={}){let n=await fetch(e===`auth.login`||e.startsWith(`projects.`)?`/api/${e}`:I(`/api/${e}`),{method:`POST`,headers:xe,body:JSON.stringify(t),credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new be(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw r.code===`unauthorized`&&F.onStatus({signedOut:!0}),new be(r.error,r.code,n.status);return r.result}function Se(){return globalThis.location}async function Ce(){let e=Se(),t=e?new URLSearchParams(e.hash.replace(/^#/,``)).get(`token`):null;if(!t||!(await fetch(`/api/auth.login`,{method:`POST`,headers:xe,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),F.onStatus({signedOut:!1}),!0}var we=`bot-lobby.palette`,Te=`bot-lobby-palette`,Ee=`custom`,De=new Set,Oe=Ae();function ke(e){let t=e;if(!t||typeof t.id!=`string`||typeof t.name!=`string`)return;let n=A(t.light),r=A(t.dark);if(n||r)return{id:t.id,name:t.name.slice(0,40),...n?{light:n}:{},...r?{dark:r}:{}}}function Ae(){try{let e=localStorage.getItem(we);if(!e)return{id:ne,saved:[]};let t=JSON.parse(e),n=(t.saved??[]).map(ke).filter(e=>!!e),r=ke(t.legacy??(t.custom?{...t.custom,id:Ee}:void 0)),i=new Set([...re.map(e=>e.id),...n.map(e=>e.id),...r?[Ee]:[]]);return{id:t.id&&i.has(t.id)?t.id:ne,saved:n,...r?{legacy:r}:{}}}catch{return{id:ne,saved:[]}}}function je(e){return[...re,...e.saved,...e.legacy?[e.legacy]:[]]}function Me(e){return je(e).find(t=>t.id===e.id)??re[0]}function Ne(){if(typeof document>`u`)return;let e=P(Me(Oe)),t=document.getElementById(Te);if(!e){t?.remove();return}t||(t=document.createElement(`style`),t.id=Te,document.head.appendChild(t)),t.textContent=e}function Pe(e){Oe=e;try{localStorage.setItem(we,JSON.stringify(e))}catch{}Ne();for(let e of[...De])e()}function Fe(e){let t=e.themes.map(e=>ke(e)).filter(e=>!!e),{legacy:n}=Oe;Pe({id:e.active??(Oe.id===Ee&&n?Ee:`mist`),saved:t,...n?{legacy:n}:{}})}var Ie,Le=Promise.resolve();function Re(e=!1){return Ie&&!e||(Ie=(async()=>{let e=await R(`themes.get`,{}),t=Oe.legacy;if(t){let n=e.active??(Oe.id===Ee?void 0:Oe.id);e=await R(`themes.save`,{name:t.name,...t.light?{light:t.light}:{},...t.dark?{dark:t.dark}:{}}),n&&(e=await R(`themes.choose`,{id:n}));let{legacy:r,...i}=Oe;Oe=i}Fe(e)})().catch(()=>{Ie=void 0})),Ie}typeof window<`u`&&(Ne(),window.addEventListener(`storage`,e=>{if(e.key===we){Oe=Ae(),Ne();for(let e of[...De])e()}}),window.addEventListener(`focus`,()=>void Re(!0)));function ze(e){return De.add(e),()=>{De.delete(e)}}function Be(){let e=(0,m.useSyncExternalStore)(ze,()=>Oe,()=>Oe),t=(0,m.useCallback)(e=>{Pe({...Oe,id:e}),e!==Ee&&(Le=Le.then(()=>R(`themes.choose`,{id:e})).then(Fe,()=>{}))},[]),n=(0,m.useCallback)(async(e,t)=>(Fe(await R(`themes.save`,{name:t,...e.light?{light:e.light}:{},...e.dark?{dark:e.dark}:{}})),Me(Oe)),[]),r=(0,m.useCallback)(async(e,t)=>Fe(await R(`themes.rename`,{id:e,name:t})),[]),i=(0,m.useCallback)(async e=>Fe(await R(`themes.remove`,{id:e})),[]),a=e.legacy?[...e.saved,e.legacy]:e.saved;return{active:Me(e),saved:a,all:je(e),isSaved:e=>a.some(t=>t.id===e),choose:t,adopt:n,rename:r,remove:i}}var Ve=[{id:`theme`,label:`Default`,help:`San Francisco on Apple devices, Inter elsewhere`},{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`}],He=[{id:`theme`,label:`Default mono`,help:`SF Mono on Apple devices, JetBrains Mono elsewhere`},{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`}],Ue={font:`bot-lobby.typeface`,mono:`bot-lobby.typeface-code`},We={font:Ve,mono:He},Ge={font:`theme`,mono:`theme`},Ke=new Set;function qe(e){let t=null;try{t=localStorage.getItem(Ue[e])}catch{t=Ge[e]}return We[e].some(e=>e.id===t)?t:`theme`}function Je(e,t){let n=document.documentElement;t===`theme`?delete n.dataset[e]:n.dataset[e]=t}function Ye(e,t){Ge[e]=t;try{localStorage.setItem(Ue[e],t)}catch{}Je(e,t);for(let e of Ke)e()}function Xe(e){return Ke.add(e),()=>Ke.delete(e)}function Ze(e){return(0,m.useSyncExternalStore)(Xe,()=>qe(e),()=>`theme`)}typeof document<`u`&&(Je(`font`,qe(`font`)),Je(`mono`,qe(`mono`)));var Qe={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`},$e=(0,m.createContext)({});function et(e){let t=(0,m.useRef)(null);return t.current===null&&(t.current=e()),t.current}var tt=typeof window<`u`?m.useLayoutEffect:m.useEffect,nt=(0,m.createContext)(null);function rt(e,t){e.indexOf(t)===-1&&e.push(t)}function it(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var at=(e,t,n)=>n>t?t:n<e?e:n,ot={},st=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),ct=e=>typeof e==`object`&&!!e,lt=e=>/^0[^.\s]+$/u.test(e);function ut(e){let t;return()=>(t===void 0&&(t=e()),t)}var dt=e=>e,ft=(...e)=>e.reduce((e,t)=>n=>t(e(n))),pt=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},mt=class{constructor(){this.subscriptions=[]}add(e){return rt(this.subscriptions,e),()=>this.remove(e)}remove(e){it(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}},ht=e=>e*1e3,gt=e=>e/1e3,_t=(e,t)=>t?1e3/t*e:0,vt=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e},yt=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,bt=1e-7,xt=12;function St(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=yt(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>bt&&++s<xt);return o}function Ct(e,t,n,r){if(e===t&&n===r)return dt;let i=t=>St(t,0,1,e,n);return e=>e===0||e===1?e:yt(i(e),t,r)}var wt=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Tt=e=>t=>1-e(1-t),Et=Ct(.33,1.53,.69,.99),Dt=Tt(Et),Ot=wt(Dt),kt=e=>e>=1?1:(e*=2)<1?.5*Dt(e):.5*(2-2**(-10*(e-1))),At=e=>1-Math.sin(Math.acos(e)),jt=Tt(At),Mt=wt(At),Nt=Ct(.42,0,1,1),Pt=Ct(0,0,.58,1),Ft=Ct(.42,0,.58,1),It=e=>Array.isArray(e)&&typeof e[0]!=`number`;function Lt(e,t){return It(e)?e[vt(0,e.length,t)]:e}var Rt=e=>Array.isArray(e)&&typeof e[0]==`number`,zt={linear:dt,easeIn:Nt,easeInOut:Ft,easeOut:Pt,circIn:At,circInOut:Mt,circOut:jt,backIn:Dt,backInOut:Ot,backOut:Et,anticipate:kt},Bt=e=>typeof e==`string`,Vt=e=>{if(Rt(e)){e.length;let[t,n,r,i]=e;return Ct(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||ot.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=>at(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=>at(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(`%`),z=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):ft($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=ot.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:dt,!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:gt(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=at(vr.minDuration,vr.maxDuration,gt(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:ht(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:-gt(e),p=s/(2*Math.sqrt(o*c)),m=gt(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=>ht(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=ht(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=ht(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||ot.mix||ar,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=ft(Array.isArray(t)?t[n]||dt: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=pt(e[r],e[r+1],n);return s[r](i)};return n?t=>l(at(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=pt(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||Ft).splice(0,e.length-1)}function Lr({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=It(r)?r.map(Vt):Vt(r)||Ft,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:(ot.mix||ar)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?at(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 _t(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=ft(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=at(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 gt(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+gt(e)}get time(){return gt(this.currentTime)}set time(e){e=ht(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=gt(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={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:z,translateX:z,translateY:z,translateZ:z,x:z,y:z,z,perspective:z,transformPerspective:z,opacity:en,originX:vn,originY:vn,originZ:z},ii={borderWidth:z,borderTopWidth:z,borderRightWidth:z,borderBottomWidth:z,borderLeftWidth:z,borderRadius:z,borderTopLeftRadius:z,borderTopRightRadius:z,borderBottomRightRadius:z,borderBottomLeftRadius:z,width:z,maxWidth:z,height:z,maxHeight:z,top:z,right:z,bottom:z,left:z,inset:z,insetBlock:z,insetBlockStart:z,insetBlockEnd:z,insetInline:z,insetInlineStart:z,insetInlineEnd:z,padding:z,paddingTop:z,paddingRight:z,paddingBottom:z,paddingLeft:z,paddingBlock:z,paddingBlockStart:z,paddingBlockEnd:z,paddingInline:z,paddingInlineStart:z,paddingInlineEnd:z,margin:z,marginTop:z,marginRight:z,marginBottom:z,marginLeft:z,marginBlock:z,marginBlockStart:z,marginBlockEnd:z,marginInline:z,marginInlineStart:z,marginInlineEnd:z,fontSize:z,backgroundPositionX:z,backgroundPositionY:z,...ri,zIndex:ni,fillOpacity:en,strokeOpacity:en,numOctaves:ni},ai={...ii,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},oi=e=>ai[e],si=new Set([ei,ti]);function ci(e,t){let n=oi(e);return si.has(n)||(n=zn),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function li(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var ui=e=>e*180/Math.PI,di=e=>pi(ui(Math.atan2(e[1],e[0]))),fi={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:di,rotateZ:di,skewX:e=>ui(Math.atan(e[1])),skewY:e=>ui(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},pi=e=>(e%=360,e<0&&(e+=360),e),mi=di,hi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),gi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),_i={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:hi,scaleY:gi,scale:e=>(hi(e)+gi(e))/2,rotateX:e=>pi(ui(Math.atan2(e[6],e[5]))),rotateY:e=>pi(ui(Math.atan2(-e[2],e[0]))),rotateZ:mi,rotate:mi,skewX:e=>ui(Math.atan(e[4])),skewY:e=>ui(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function vi(e){return+!!e.includes(`scale`)}function yi(e,t){if(!e||e===`none`)return vi(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=_i,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=fi,i=t}if(!i)return vi(t);let a=r[t],o=i[1].split(`,`).map(xi);return typeof a==`function`?a(o):o[a]}var bi=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return yi(n,t)};function xi(e){return parseFloat(e.trim())}var Si=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Ci=new Set([...Si,`pathRotation`]),wi=e=>e===$t||e===z,Ti=new Set([`x`,`y`,`z`]),Ei=Si.filter(e=>!Ti.has(e));function Di(e){let t=[];return Ei.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 Oi=new Set([`bottom`,`right`]);function ki(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 Ai={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>ki(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>ki(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})=>yi(e,`x`),y:({transform:e})=>yi(e,`y`)};Ai.translateX=Ai.x,Ai.translateY=Ai.y;var ji=new Set,Mi=!1,Ni=!1,Pi=!1;function Fi(){if(Ni){let e=[],t=new Set,n=new Set;ji.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),Oi.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=Di(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)})}Ni=!1,Mi=!1,ji.forEach(e=>e.complete(Pi)),ji.clear()}function Ii(){ji.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Ni=!0)})}function Li(){Pi=!0,Ii(),Fi(),Pi=!1}function Ri(e,t,n){if(typeof e==`string`){if(st(e)||lt(e))return parseFloat(e);if(!zn.test(e)&&zn.test(n))return ci(t,n)}return e??void 0}var zi=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?(ji.add(this),Mi||(Mi=!0,ur.read(Ii),ur.resolveKeyframes(Fi))):(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=Ri(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])}li(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ji.delete(this)}cancel(){this.state===`scheduled`&&(ji.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Bi=e=>e.startsWith(`--`);function Vi(e,t,n){Bi(t)?e.style.setProperty(t,n):e.style[t]=n}var Hi={};function Ui(e,t){let n=ut(e);return()=>Hi[t]??n()}var Wi=Ui(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Gi=Ui(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Ki=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,qi={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Ki([0,.65,.55,1]),circOut:Ki([.55,0,1,.45]),backIn:Ki([.31,.01,.66,-.59]),backOut:Ki([.33,1.53,.69,.99])};function Ji(e,t){if(e)return typeof e==`function`?Gi()?mr(e,t):`ease-out`:Rt(e)?Ki(e):Array.isArray(e)?e.map(e=>Ji(e,t)||qi.easeOut):qi[e]}function Yi(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=Ji(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 Xi(e){return typeof e==`function`&&`applyToOptions`in e}function Zi({type:e,...t}){return Xi(e)&&Gi()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Qi=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=Zi(e);this.animation=Yi(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),Vi(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 gt(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+gt(e)}get time(){return gt(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=ht(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&&Wi()?(this.animation.timeline=e,t?.(this.animation),dt):n(this)}},$i={anticipate:kt,backInOut:Ot,circInOut:Mt};function ea(e){return e in $i}function ta(e){typeof e.ease==`string`&&ea(e.ease)&&(e.ease=$i[e.ease])}var na=10,B=class extends Qi{constructor(e){ta(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(na,Gt.now()-this.startTime),c=at(0,na,s-na),l=o.sample(s).value,{name:u}=this.options;i&&u&&Vi(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 aa(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`||Xi(n))&&r}function oa(e){e.duration=0,e.type=`keyframes`}var sa=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),ca=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function la(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&ca.test(e[t]))return!0;return!1}var ua=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),da=ut(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function fa(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(sa.has(n)||ua.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 da()&&(sa.has(n)||ua.has(n)&&la(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var pa=40,ma=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||zi;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;aa(e,i,a,o)||(u=!1,(ot.instantAnimations||!s)&&l?.(Hr(e,n,t)),e[0]=e[e.length-1],oa(n),n.repeat=0);let d=r?this.resolvedAt&&this.resolvedAt-this.createdAt>pa?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&&fa(n),m;if(p){n.element=n.motionValue?.owner?.current;try{m=new B(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(),Li()),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()}},ha=class{constructor(e){this.stop=()=>this.runAll(`stop`),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e){let t=this.animations.map(t=>t.attachTimeline(e));return()=>{t.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll(`time`)}set time(e){this.setAll(`time`,e)}get speed(){return this.getAll(`speed`)}set speed(e){this.setAll(`speed`,e)}get state(){return this.getAll(`state`)}get startTime(){return this.getAll(`startTime`)}get duration(){return ga(this.animations,`duration`)}get iterationDuration(){return ga(this.animations,`iterationDuration`)}runAll(e){this.animations.forEach(t=>t[e]())}play(){this.runAll(`play`)}pause(){this.runAll(`pause`)}cancel(){this.runAll(`cancel`)}complete(){this.runAll(`complete`)}};function ga(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r][t];i!==null&&i>n&&(n=i)}return n}var _a=class extends ha{then(e,t){return this.finished.finally(e).then(()=>{})}};function va(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 ya=30,ba=e=>!isNaN(parseFloat(e)),xa={current:void 0},Sa=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=ba(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 mt)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new mt,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 xa.current&&xa.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Gt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ya)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,ya);return _t(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 Ca(e,t){return new Sa(e,t)}function wa(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Ta(e,t){let n=e?.[t]??e?.default??e;return n===e?n:wa(n,e)}var Ea={type:`spring`,stiffness:500,damping:25,restSpeed:10},Da=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Oa={type:`keyframes`,duration:.8},ka={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Aa=(e,{keyframes:t})=>t.length>2?Oa:Ci.has(e)?e.startsWith(`scale`)?Da(t[1]):Ea:ka,ja=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Ma(e){for(let t in e)if(!ja.has(t))return!0;return!1}var Na=(e,t,n,r={},i,a)=>o=>{let s=Ta(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=ht(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};Ma(s)||Object.assign(u,Aa(e,u)),u.duration&&=ht(u.duration),u.repeatDelay&&=ht(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(oa(u),u.delay===0&&(d=!0)),(ot.instantAnimations||ot.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,oa(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 ma(u)},Pa=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Fa(e){let t=Pa.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Ia(e,t,n=1){`${e}`;let[r,i]=Fa(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return st(e)?parseFloat(e):e}return Xt(i)?Ia(i,t,n+1):i}function La(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Ra(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...La(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function za(e,t,n){return Ra(e.getProps(),t,n,e)}var Ba=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,Va=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Si]),Ha=e=>Array.isArray(e);function Ua(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ca(n))}function Wa(e){return Ha(e)?e[e.length-1]||0:e}function Ga(e,t){let{transitionEnd:n={},transition:r={},...i}=za(e,t)||{};i={...i,...n};for(let t in i)Ua(e,t,Wa(i[t]))}var Ka=e=>!!(e&&e.getVelocity);function qa(e){return!!(Ka(e)&&e.add)}function Ja(e,t){let n=e.getValue(`willChange`);if(qa(n))return n.add(t);if(!n&&ot.WillChange){let n=new ot.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Ya(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Xa=`data-`+Ya(`framerAppearId`);function Za(e){return e.props[Xa]}var Qa=typeof window<`u`;function $a({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function eo(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?wa(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&&$a(f,t))continue;let o={delay:n,...Ta(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(Qa&&window.MotionHandoffAnimation){let n=Za(e);if(n){let e=window.MotionHandoffAnimation(n,t,ur);e!==null&&(o.startTime=e,p=!0)}}Ja(e,t);let m=l??e.shouldReduceMotion;r.start(Na(t,r,i,m&&Va.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>ur.update(()=>{o&&Ga(e,o)});d.length?Promise.all(d).then(t):t()}return d}function to(e,t,n={}){let r=za(e,t,Ba(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?eo(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(to(e,t,{...n,delay:r+(typeof o==`function`?0:o)+va(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 no(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>to(e,t,n))):typeof t==`string`?to(e,t,n):Promise.all(eo(e,za(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var ro={test:e=>e===`auto`,parse:e=>e},io=e=>t=>t.test(e),ao=[$t,z,hn,mn,_n,gn,ro],oo=e=>ao.find(io(e));function so(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||lt(e)}var co=new Set([`auto`,`none`,`0`]);function lo(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!co.has(t)&&jn(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=ci(n,i))}var uo=class extends zi{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=Ia(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Va.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=oo(r),o=oo(i);if(Qt(r)!==Qt(i)&&Ai[n]){this.needsMeasurement=!0;return}if(a!==o){if(wi(a)&&wi(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Ai[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||so(e[t]))&&n.push(t);n.length&&lo(e,n,t)}measure(){let{element:e,name:t}=this;return Ai[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()}},fo=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`],po=[];function mo(e){typeof e.test==`function`&&e.read,ho(e),po.unshift(e)}function ho(e){it(po,e)}function go(e){return po.find(t=>t.test(e))}function _o(e,t,n={},r){let i=[],{velocity:a}=n,o=n.reduceMotion??r?.shouldReduceMotion;for(let s in t){if(s===`transition`||s===`transitionEnd`)continue;let c=t[s];if(c===void 0)continue;let l=e(s),u=l.get();if(u!==void 0&&!l.isAnimating()&&!Array.isArray(c)&&c===u&&!a){ur.update(()=>l.set(c));continue}l.start(Na(s,l,c,o&&Va.has(s)?{type:!1}:n,r)),l.animation&&i.push(l.animation)}let{transitionEnd:s}=t;if(s){let t=()=>ur.update(()=>{for(let t in s)e(t).set(s[t])});i.length?Promise.all(i).then(t):t()}return i}function vo(e,t,n,r,i){return _o(r=>{let a=e.get(t,r);if(!a){let o;if(!i){let i=n[r];o=yo(i)??e.read(t,r,i),`${r}`}a=Ca(o,{owner:i}),e(t,{[r]:a})}return a},n,r,i)}function yo(e){let t=Array.isArray(e)?e[0]:void 0;return t===null?void 0:t}function bo(e){return ct(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function xo(e){return ct(e)&&`ownerSVGElement`in e}var So=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function Co(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 wo=class{constructor(e=ur.render){this.step=e,this.values=new Map,this.pending=[],this.numPending=0,this.flush=()=>{let{pending:e,numPending:t}=this;this.numPending=0;for(let n=0;n<t;n++)e[n]()}}set(e,t,n,r){if(this.values.get(e)?.onRemove(),r)for(let e of this.values.values())e.value===r&&(n=e.render);let i=()=>n&&this.schedule(n);t.get()!==void 0&&i();let a=t.on(`change`,i),o=()=>{a(),n&&!r&&this.cancel(n),this.values.get(e)?.onRemove===o&&this.values.delete(e)};return this.values.set(e,{value:t,render:r?void 0:n,onRemove:o}),o}get(e){return this.values.get(e)?.value}release(){let e=new Map;return this.values.forEach((t,n)=>{e.set(n,t.value),t.onRemove()}),this.transformKeys=this.transformValues=void 0,e}schedule(e){let{pending:t,numPending:n}=this;for(let r=0;r<n;r++)if(t[r]===e)return;n||this.step(this.flush),t[this.numPending++]=e}cancel(e){let{pending:t}=this;for(let n=0;n<this.numPending;n++)if(t[n]===e){t[n]=t[--this.numPending];return}}};function To(e,{step:t,...n}={}){let r=new WeakMap;return Object.assign((n,i)=>{let a=r.get(n)??new wo(t);r.set(n,a);let o=[];for(let t in i){let r=i[t],s=e(n,a,t,r);o.push(s)}return()=>{for(let e of o)e()}},n,{get:(e,t)=>r.get(e)?.get(t),flush:e=>r.get(e)?.flush(),state:e=>r.get(e)})}var Eo={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},Do={};function Oo(e){let t=``,{transformKeys:n=[],transformValues:r={}}=e;for(let e=0;e<n.length;e++){let i=n[e],a=r[i].get();a!==void 0&&(typeof a==`number`?a:parseFloat(a))!==+!!i.startsWith(`scale`)&&(t+=(t&&` `)+(Do[i]||(Do[i]=(Eo[i]||i)+`(`))+So(a,ri[i])+`)`)}let i=e.get(`pathRotation`)?.get();return i&&(t+=(t&&` `)+`rotate(`+So(i,ri.pathRotation)+`)`),t||`none`}var ko=new Set([`originX`,`originY`,`originZ`]),Ao=(e,t)=>So(e.get(t)?.get(),ii[t]),jo=(e,t,n,r)=>{let i,a;if(Ci.has(n)){if(n!==`pathRotation`){let e=t.transformKeys??=[];(t.transformValues??={})[n]=r,e.includes(n)||(e.push(n),e.sort((e,t)=>Si.indexOf(e)-Si.indexOf(t)))}t.get(`transform`)||(!bo(e)&&!t.get(`transformBox`)&&jo(e,t,`transformBox`,new Sa(`fill-box`)),t.set(`transform`,new Sa(`none`),()=>{e.style.transform=Oo(t)})),a=t.get(`transform`)}else ko.has(n)?(t.get(`transformOrigin`)||t.set(`transformOrigin`,new Sa(``),()=>{let n=Ao(t,`originX`)??`50%`,r=Ao(t,`originY`)??`50%`,i=Ao(t,`originZ`)??0;e.style.transformOrigin=`${n} ${r} ${i}`}),a=t.get(`transformOrigin`)):i=Bi(n)?()=>{e.style.setProperty(n,r.get())}:()=>{e.style[n]=So(r.get(),ii[n])};return t.set(n,r,i,a)},Mo=e=>bo(e)||xo(e),No=(e,t)=>{if(Ci.has(t))return bi(e,t);let n=getComputedStyle(e),r=Bi(t)?n.getPropertyValue(t):n[t];return typeof r==`string`&&r.trim()||0},Po=To(jo,{test:Mo,read:No}),Fo={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},Io=Si.length;function Lo(e,t,n){let r=``,i=!0;for(let a=0;a<Io;a++){let o=Si[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=So(s,ii[o]);if(!c){i=!1;let t=Fo[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${So(a,ii.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function Ro(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(Ci.has(e)){o=!0;continue}if(Jt(e)){i[e]=n;continue}{let t=So(n,ii[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=Lo(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 zo={offset:`stroke-dashoffset`,array:`stroke-dasharray`},Bo={offset:`strokeDashoffset`,array:`strokeDasharray`};function V(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?zo:Bo;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var Vo=[`transform`,`opacity`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function Ho(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(Ro(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 Vo)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&&V(d,i,a,o,!1)}function Uo(e,t){if(!(t in e))return!1;let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)||Object.getOwnPropertyDescriptor(e,t);return n&&typeof n.set==`function`}var Wo=(e,t,n,r,i=n)=>{let a=Uo(e,i);!a&&(i.startsWith(`data`)||i.startsWith(`aria`))&&(i=Ya(i));let o=ii[n]||ii[i],s=a?()=>{e[i]=So(r.get(),ii[n])}:()=>{let t=So(r.get(),o);t==null?e.removeAttribute(i):e.setAttribute(i,String(t))};return t.set(n,r,s)};function Go(e,t,n,r){return ur.render(()=>e.setAttribute(`pathLength`,`1`)),n===`pathOffset`?t.set(n,r,()=>{let t=r.get();e.setAttribute(`stroke-dashoffset`,`${-t}`)}):(t.get(`stroke-dasharray`)||t.set(`stroke-dasharray`,new Sa(`1 1`),()=>{let n=t.get(`pathLength`)?.get()??1,r=t.get(`pathSpacing`)?.get();e.setAttribute(`stroke-dasharray`,`${n} ${r??1-Number(n)}`)}),t.set(n,r,void 0,t.get(`stroke-dasharray`)))}var Ko=To((e,t,n,r)=>n.startsWith(`path`)?Go(e,t,n,r):n.startsWith(`attr`)?Wo(e,t,n,r,qo(n)):(Ci.has(n)||ko.has(n)||Bi(n)||n in e.style?jo:Wo)(e,t,n,r),{test:xo,read:(e,t)=>Ci.has(t)?ii[t]?.default||0:Bi(t)||Vo.includes(t)?No(e,t)||e.getAttribute(Ya(t))||0:(t=qo(t),e.getAttribute(Ya(t))??e.getAttribute(t)??void 0)});function qo(e){return e.replace(/^attr([A-Z])/,(e,t)=>t.toLowerCase())}function Jo({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Yo({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Xo(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 Zo(e){return e===void 0||e===1}function Qo({scale:e,scaleX:t,scaleY:n}){return!Zo(e)||!Zo(t)||!Zo(n)}function $o(e){return Qo(e)||es(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function es(e){return ts(e.x)||ts(e.y)}function ts(e){return e&&e!==`0%`}function ns(e,t,n){return n+t*(e-n)}function rs(e,t,n,r,i){return i!==void 0&&(e=ns(e,i,r)),ns(e,n,r)+t}function is(e,t=0,n=1,r,i){e.min=rs(e.min,t,n,r,i),e.max=rs(e.max,t,n,r,i)}function as(e,{x:t,y:n}){is(e.x,t.translate,t.scale,t.originPoint),is(e.y,n.translate,n.scale,n.originPoint)}var os=.999999999999,ss=1.0000000000001;function cs(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&&(ls(e.x,-a.scroll.offset.x),ls(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,as(e,o)),r&&$o(a.latestValues)&&fs(e,a.latestValues,a.layout?.layoutBox))}t.x<ss&&t.x>os&&(t.x=1),t.y<ss&&t.y>os&&(t.y=1)}function ls(e,t){e.min+=t,e.max+=t}function us(e,t,n,r,i=.5){is(e,t,n,Un(e.min,e.max,i),r)}function ds(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function fs(e,t,n){let r=n??e;us(e.x,ds(t.x,r.x),t.scaleX,t.scale,t.originX),us(e.y,ds(t.y,r.y),t.scaleY,t.scale,t.originY)}function ps(e,t){return Jo(Xo(e.getBoundingClientRect(),t))}function ms(e,t,n){let r=ps(e,n),{scroll:i}=t;return i&&(ls(r.x,i.offset.x),ls(r.y,i.offset.y)),r}var hs={},gs=e=>xo(e)?Ko:Po,_s=class{constructor(e,t){this.effect=e,this.current=t,this.KeyframeResolver=uo}getValue(e){return this.effect.get(this.current,e)}readValue(e,t){return this.effect.read(this.current,e,t)}render(){this.effect.flush(this.current)}measureViewportBox(){return ps(this.current)}getProps(){return hs}};function vs(e,t,n,r){if(r)return _o(e=>r.getValue(e,null),t,n,r);let i=gs(e);return vo(i,e,t,n,new _s(i,e))}var ys=To((e,t,n,r)=>t.set(n,r,()=>{e[n]=r.get()}),{test:e=>ct(e),read:(e,t)=>{let n=e[t];return typeof n==`string`||typeof n==`number`?n:void 0}}),{schedule:bs,cancel:xs}=lr(queueMicrotask,!1),Ss={x:!1,y:!1};function Cs(){return Ss.x||Ss.y}function ws(e){return e===`x`||e===`y`?Ss[e]?null:(Ss[e]=!0,()=>{Ss[e]=!1}):Ss.x||Ss.y?null:(Ss.x=Ss.y=!0,()=>{Ss.x=Ss.y=!1})}function Ts(e,t){let n=Co(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Es(e){return!(e.pointerType===`touch`||Cs())}function Ds(e,t,n={}){let[r,i,a]=Ts(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(!Es(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 Os=(e,t)=>t?e===t||Os(e,t.parentElement):!1,ks=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,As=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function js(e){return As.has(e.tagName)||e.isContentEditable===!0}var Ms=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Ns(e){return Ms.has(e.tagName)||e.isContentEditable===!0}var Ps=new WeakSet;function Fs(e){return t=>{t.key===`Enter`&&e(t)}}function Is(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Ls=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Fs(()=>{if(Ps.has(n))return;Is(n,`down`);let e=Fs(()=>{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 Rs(e){return ks(e)&&!Cs()}var zs=new WeakSet;function Bs(e,t,n={}){let[r,i,a]=Ts(e,n),o=e=>{let r=e.currentTarget;if(!Rs(e)||zs.has(e))return;Ps.add(r),n.stopPropagation&&zs.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),Ps.has(r)&&Ps.delete(r),Rs(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Os(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),bo(e)&&(e.addEventListener(`focus`,e=>Ls(e,i)),!js(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var Vs=new WeakMap,Hs,Us=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:xo(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Ws=Us(`inline`,`width`,`offsetWidth`),Gs=Us(`block`,`height`,`offsetHeight`);function Ks({target:e,borderBoxSize:t}){Vs.get(e)?.forEach(n=>{n(e,{get width(){return Ws(e,t)},get height(){return Gs(e,t)}})})}function qs(e){e.forEach(Ks)}function Js(){typeof ResizeObserver<`u`&&(Hs=new ResizeObserver(qs))}function Ys(e,t){Hs||Js();let n=Co(e);return n.forEach(e=>{let n=Vs.get(e);n||(n=new Set,Vs.set(e,n)),n.add(t),Hs?.observe(e)}),()=>{n.forEach(e=>{let n=Vs.get(e);n?.delete(t),n?.size||Hs?.unobserve(e)})}}var Xs=new Set,Zs;function Qs(){Zs=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Xs.forEach(t=>t(e))},window.addEventListener(`resize`,Zs)}function $s(e){return Xs.add(e),Zs||Qs(),()=>{Xs.delete(e),!Xs.size&&typeof Zs==`function`&&(window.removeEventListener(`resize`,Zs),Zs=void 0)}}function ec(e,t){return typeof e==`function`?$s(e):Ys(e,t)}var tc={value:null,addProjectionMetrics:null};function nc(e){return xo(e)&&e.tagName===`svg`}var rc=e=>typeof e==`number`?e:parseFloat(e),ic=()=>({translate:0,scale:1,origin:0,originPoint:0}),ac=()=>({x:ic(),y:ic()}),oc=()=>({min:0,max:0}),sc=()=>({x:oc(),y:oc()}),cc=new WeakMap;function lc(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function uc(e){return typeof e==`string`||Array.isArray(e)}var dc=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],fc=[`initial`,...dc];function pc(e){if(lc(e.animate))return!0;for(let t=0;t<fc.length;t++)if(uc(e[fc[t]]))return!0;return!1}function mc(e){return!!(pc(e)||e.variants)}function hc(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Ka(i))e.addValue(r,i);else if(Ka(a))e.addValue(r,Ca(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,Ca(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var gc={current:null},_c={current:!1},vc=typeof window<`u`;function yc(){if(_c.current=!0,vc){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>gc.current=e.matches;e.addEventListener(`change`,t),t()}else gc.current=!1}}var bc=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],xc={};function Sc(e){xc=e}function Cc(){return xc}var wc=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=zi,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=pc(t),this.isVariantNode=mc(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&&Ka(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,cc.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:(_c.current||yc(),this.shouldReduceMotion=gc.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&&sa.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Qi({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:ht(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Ci.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 xc){let t=xc[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):sc()}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<bc.length;t++){let n=bc[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=hc(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=Ca(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`&&(st(n)||lt(n))?n=parseFloat(n):typeof n!=`number`&&!zn.test(n)&&zn.test(t)&&(n=ci(e,t)),this.setBaseTarget(e,Ka(n)?n.get():n)),Ka(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new mt),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){bs.render(this.render)}},Tc=class extends wc{constructor(){super(...arguments),this.KeyframeResolver=uo}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;Ka(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},Ec=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Dc(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 Oc={};function kc(e,{layout:t,layoutId:n}){return Ci.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!Oc[e]||e===`opacity`)}function Ac(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Ka(r[t])||i&&Ka(i[t])||kc(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function jc(e){return window.getComputedStyle(e)}var Mc=class extends Tc{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Dc}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(Ci.has(t))return this.projection?.isProjecting?vi(t):bi(e,t);{let n=jc(e),r=(Jt(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return ps(e,t)}build(e,t,n){Ro(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Ac(e,t,n)}},Nc=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`]),Pc=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function Fc(e,t,n,r){Dc(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Nc.has(n)?n:Ya(n),t.attrs[n])}function Ic(e,t,n){let r=Ac(e,t,n);for(let n in e)if(Ka(e[n])||Ka(t[n])){let t=Si.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var Lc=class extends Tc{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=sc}getBaseTargetFromProps(e,t){return Ci.has(t)?super.getBaseTargetFromProps(e,t)??vi(t):e[t]}getDefaultValue(e){return Ci.has(e)?this.latestValues[e]??vi(e):void 0}readValueFromInstance(e,t){if(Ci.has(t)){let e=oi(t);return e&&e.default||0}if(Vo.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=Nc.has(t)?t:Ya(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Ic(e,t,n)}build(e,t,n){Ho(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){Fc(e,t,n,r)}mount(e){this.isSVGTag=Pc(e.tagName),super.mount(e)}};function Rc(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 zc=[...dc].reverse();function Bc(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>no(e,t,n))),n=Hc(),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(zc.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?uc(g)||g===!1?g:void 0:h,v=uc(_),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||lc(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=Vc(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}=za(e,n,Ba(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)?!Rc(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=za(s,n)?.transition?.delayChildren;r.delay=va(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&za(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&&!Ka(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=Hc(),i=!0}}}function Vc(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Rc(t,e):!1}function Hc(){let e={};for(let t of dc)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function Uc(e,t){e.min=t.min,e.max=t.max}function Wc(e,t){Uc(e.x,t.x),Uc(e.y,t.y)}function Gc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Kc=.9999,qc=1.0001,Jc=-.01,Yc=.01;function Xc(e){return e.max-e.min}function Zc(e,t,n){return Math.abs(e-t)<=n}function Qc(e,t,n,r=.5){e.origin=r,e.originPoint=Un(t.min,t.max,e.origin),e.scale=Xc(n)/Xc(t),e.translate=Un(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Kc&&e.scale<=qc||isNaN(e.scale))&&(e.scale=1),(e.translate>=Jc&&e.translate<=Yc||isNaN(e.translate))&&(e.translate=0)}function $c(e,t,n,r){Qc(e.x,t.x,n.x,r?r.originX:void 0),Qc(e.y,t.y,n.y,r?r.originY:void 0)}function el(e,t,n,r=0){e.min=(r?Un(n.min,n.max,r):n.min)+t.min,e.max=e.min+Xc(t)}function tl(e,t,n,r){el(e.x,t.x,n.x,r?.x),el(e.y,t.y,n.y,r?.y)}function nl(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+Xc(t)}function rl(e,t,n,r){nl(e.x,t.x,n.x,r?.x),nl(e.y,t.y,n.y,r?.y)}function il(e,t,n,r,i){return e-=t,e=ns(e,1/n,r),i!==void 0&&(e=ns(e,1/i,r)),e}function al(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=il(e.min,t,n,s,i),e.max=il(e.max,t,n,s,i)}function ol(e,t,[n,r,i],a,o){al(e,t[n],t[r],t[i],t.scale,a,o)}var sl=[`x`,`scaleX`,`originX`],cl=[`y`,`scaleY`,`originY`];function ll(e,t,n,r){ol(e.x,t,sl,n?n.x:void 0,r?r.x:void 0),ol(e.y,t,cl,n?n.y:void 0,r?r.y:void 0)}function ul(e){return e.translate===0&&e.scale===1}function dl(e){return ul(e.x)&&ul(e.y)}function fl(e,t){return e.min===t.min&&e.max===t.max}function pl(e,t){return fl(e.x,t.x)&&fl(e.y,t.y)}function ml(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function hl(e,t){return ml(e.x,t.x)&&ml(e.y,t.y)}function gl(e){return Xc(e.x)/Xc(e.y)}function _l(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function vl(e){return[e(`x`),e(`y`)]}function yl(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var bl={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(z.test(e))e=parseFloat(e);else return e}return`${yl(e,t.target.x)}% ${yl(e,t.target.y)}%`}},xl={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 Sl(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 Cl=fo.length,wl=e=>typeof e==`number`||z.test(e);function Tl(e,t,n,r,i,a){i?(e.opacity=Un(0,n.opacity??1,Dl(r)),e.opacityExit=Un(t.opacity??1,0,Ol(r))):a&&(e.opacity=Un(t.opacity??1,n.opacity??1,r));for(let i=0;i<Cl;i++){let a=fo[i],o=El(t,a),s=El(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||wl(o)===wl(s)?(e[a]=Math.max(Un(rc(o),rc(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 El(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Dl=kl(0,.5,jt),Ol=kl(.5,.95,dt);function kl(e,t,n){return r=>r<e?0:r>t?1:n(pt(e,t,r))}function Al(e,t,n){let r=Ka(e)?e:Ca(e);return r.start(Na(``,r,t,n)),r.animation}function jl(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var Ml=(e,t)=>e.depth-t.depth,Nl=class{constructor(){this.children=[],this.isDirty=!1}add(e){rt(this.children,e),this.isDirty=!0}remove(e){it(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Ml),this.isDirty=!1,this.children.forEach(e)}};function Pl(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 Fl(e){return Ka(e)?e.get():e}var Il=class{constructor(){this.members=[]}add(e){rt(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&&(it(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(it(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)}},Ll={borderRadius:{...bl,applyTo:[...fo]},borderTopLeftRadius:bl,borderTopRightRadius:bl,borderBottomLeftRadius:bl,borderBottomRightRadius:bl,boxShadow:xl},Rl={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(Oc,{...Ll,...Oc});var zl={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Bl=[``,`X`,`Y`,`Z`],Vl=1e3,Hl=0;function Ul(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Wl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Za(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&&Wl(r)}function Gl({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Hl++,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,tc.value&&(zl.nodes=zl.calculatedTargetDeltas=zl.calculatedProjections=0),this.nodes.forEach(Jl),this.nodes.forEach(iu),this.nodes.forEach(au),this.nodes.forEach(Yl),tc.addProjectionMetrics&&tc.addProjectionMetrics(zl)},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 Nl)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new mt),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=xo(t)&&!nc(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=Pl(i,250),Rl.hasAnimatedSinceResize&&(Rl.hasAnimatedSinceResize=!1,this.nodes.forEach(ru)))})}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()||fu,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!hl(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={...Ta(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||ru(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(ou),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&&Wl(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(Ql),this.nodes.forEach(Zl);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach($l);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(eu),this.nodes.forEach(tu),this.nodes.forEach(nu),this.nodes.forEach(Kl),this.nodes.forEach(ql)):this.nodes.forEach($l),this.clearAllSnapshots();let e=Gt.now();Ht.delta=at(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,bs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Xl),this.sharedNodes.forEach(su)}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&&!Xc(this.snapshot.measuredBox.x)&&!Xc(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||=sc(),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&&!dl(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||$o(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)),gu(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return sc();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(vu))){let{scroll:e}=this.root;e&&(ls(t.x,e.offset.x),ls(t.y,e.offset.y))}return t}removeElementScroll(e){let t=sc();if(Wc(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&&Wc(t,e),ls(t.x,i.offset.x),ls(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||sc();Wc(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&&(ls(r.x,-n.scroll.offset.x),ls(r.y,-n.scroll.offset.y)),$o(n.latestValues)&&fs(r,n.latestValues,n.layout?.layoutBox)}return $o(this.latestValues)&&fs(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=sc();Wc(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!$o(n.latestValues))continue;let r;n.instance&&(Qo(n.latestValues)&&n.updateSnapshot(),r=sc(),Wc(r,n.measurePageBox())),ll(t,n.latestValues,n.snapshot?.layoutBox,r)}return $o(this.latestValues)&&ll(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=sc(),this.targetWithTransforms=sc()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),tl(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Wc(this.target,this.layout.layoutBox),as(this.target,this.targetDelta)):Wc(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),tc.value&&zl.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Qo(this.parent.latestValues)||es(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=sc(),this.relativeTargetOrigin=sc(),rl(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Wc(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;Wc(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;cs(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=sc());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Gc(this.prevProjectionDelta.x,this.projectionDelta.x),Gc(this.prevProjectionDelta.y,this.projectionDelta.y)),$c(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!_l(this.projectionDelta.x,this.prevProjectionDelta.x)||!_l(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),tc.value&&zl.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=ac(),this.projectionDelta=ac(),this.projectionDeltaWithTransform=ac()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=ac();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=sc(),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(du));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):(cu(o.x,e.x,n),cu(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(rl(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),uu(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&pl(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=sc(),Wc(f,this.relativeTarget)),c&&(this.animationValues=a,Tl(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(()=>{Rl.hasAnimatedSinceResize=!0,this.motionValue||=Ca(0),this.motionValue.jump(0,!1),this.currentAnimation=Al(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(Vl),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&&_u(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||sc();let t=Xc(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=Xc(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}Wc(t,i),fs(t,r),$c(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&&Ul(`z`,e,r,this.animationValues);for(let t=0;t<Bl.length;t++)Ul(`rotate${Bl[t]}`,e,r,this.animationValues),Ul(`skew${Bl[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=Fl(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=Fl(t?.pointerEvents)||``),this.hasProjected&&!$o(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=Sl(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 Oc){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=Oc[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?Fl(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Zl),this.root.sharedNodes.clear()}}}function Kl(e){e.updateLayout()}function ql(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`)vl(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Xc(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Uc(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else _u(i,t.layoutBox,n)&&vl(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Xc(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=ac();$c(o,n,t.layoutBox);let s=ac();a?$c(s,e.applyTransform(r,!0),t.measuredBox):$c(s,n,t.layoutBox);let c=!dl(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=sc();rl(s,t.layoutBox,i.layoutBox,o);let c=sc();rl(c,n,a.layoutBox,o),hl(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 Jl(e){tc.value&&zl.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 Yl(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Xl(e){e.clearSnapshot()}function Zl(e){e.clearMeasurements()}function Ql(e){e.isLayoutDirty=!0,e.updateLayout()}function $l(e){e.isLayoutDirty=!1}function eu(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function tu(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function nu(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function ru(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function iu(e){e.resolveTargetDelta()}function au(e){e.calcProjection()}function ou(e){e.resetSkewAndRotation()}function su(e){e.removeLeadSnapshot()}function cu(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 lu(e,t,n,r){e.min=Un(t.min,n.min,r),e.max=Un(t.max,n.max,r)}function uu(e,t,n,r){lu(e.x,t.x,n.x,r),lu(e.y,t.y,n.y,r)}function du(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var fu={duration:.45,ease:[.4,0,.1,1]},pu=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),mu=pu(`applewebkit/`)&&!pu(`chrome/`)?Math.round:dt;function hu(e){e.min=mu(e.min),e.max=mu(e.max)}function gu(e){hu(e.x),hu(e.y)}function _u(e,t,n){return e===`position`||e===`preserve-aspect`&&!Zc(gl(t),gl(n),.2)}function vu(e){return e!==e.root&&e.scroll?.wasRoot}var yu=Gl({attachResizeListener:(e,t)=>jl(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),bu={current:void 0},xu=Gl({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!bu.current){let e=new yu({});e.mount(window),e.setOptions({layoutScroll:!0}),bu.current=e}return bu.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Su=(0,m.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Cu(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function wu(...e){return t=>{let n=!1,r=e.map(e=>{let r=Cu(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():Cu(e[t],null)}}}}function Tu(...e){return m.useCallback(wu(...e),e)}var H=i(),Eu=class extends m.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(bo(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=bo(e)&&e.offsetWidth||0,r=bo(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 Du({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)(Su),u=Tu(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}"] {
|
|
@@ -113,5 +113,5 @@ Agreed plan (from the planning session):
|
|
|
113
113
|
`){let e=a(t-1);if(e)return new DOMRect(e.right,e.top,0,e.height)}let s=i(t);if(!s)return;let c=document.createRange();c.setStart(s.node,s.local),c.collapse(!0);let l=c.getBoundingClientRect();return l.height?l:void 0}function HZ(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}function UZ({field:e,mirror:t,text:n}){let r=(0,m.useRef)(null),[i,a]=(0,m.useState)(HZ),o=(0,m.useRef)(0),s=(0,m.useRef)(!1);(0,m.useEffect)(()=>{let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);if(!e)return;let t=()=>a(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let c=(0,m.useCallback)(()=>{cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{let n=e.current,i=t.current,a=r.current,o=n?.parentElement;if(!n||!i||!a||!o)return;let c=document.activeElement===n&&n.selectionStart===n.selectionEnd?VZ(i,n.selectionDirection===`backward`?n.selectionStart:n.selectionEnd):void 0;if(!c){a.dataset.on=`false`,s.current=!1;return}let l=o.getBoundingClientRect(),u=c.left-l.left,d=c.top-l.top;a.dataset.glide=s.current?`true`:`false`,a.style.transform=`translate3d(${u}px, ${d}px, 0)`,a.style.height=`${c.height}px`,a.dataset.on=`true`,s.current=!0,a.style.animation=`none`,a.offsetWidth,a.style.animation=``})},[e,t]);return(0,m.useLayoutEffect)(()=>{i||c()},[n,i,c]),(0,m.useEffect)(()=>{let t=e.current;if(i||!t)return;let n=()=>{r.current&&(r.current.dataset.on=`false`),s.current=!1},a=new ResizeObserver(c);return a.observe(t),t.addEventListener(`focus`,c),t.addEventListener(`blur`,n),t.addEventListener(`scroll`,c),t.addEventListener(`input`,c),document.addEventListener(`selectionchange`,c),c(),()=>{cancelAnimationFrame(o.current),a.disconnect(),t.removeEventListener(`focus`,c),t.removeEventListener(`blur`,n),t.removeEventListener(`scroll`,c),t.removeEventListener(`input`,c),document.removeEventListener(`selectionchange`,c)}},[e,i,c]),i?null:(0,H.jsx)(`span`,{ref:r,className:`bubble-caret`,"data-on":`false`,"aria-hidden":`true`})}var WZ=/^\s{0,3}(`{3,}|~{3,})/,GZ=/^(\s{0,3}#{1,6})(\s+)(.*)$/,KZ=/^(\s{0,3}>[>\s]*)(.*)$/,qZ=/^(\s*)([-*+]|\d{1,9}[.)])(\s+)(\[[ xX]\]\s)?(.*)$/,JZ=/^\s{0,3}([-*_])(\s*\1){2,}\s*$/,YZ=/(`+)([^`\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 XZ(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 ZZ=(...e)=>e.filter(Boolean).join(` `);function QZ(e,t,n){let r=0;for(let i of t.matchAll(YZ)){let a=i.index;XZ(e,t.slice(r,a),n);let[o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]=i;if(s)XZ(e,s,ZZ(n,`code`,`mark`)),XZ(e,c,ZZ(n,`code`)),XZ(e,s,ZZ(n,`code`,`mark`));else if(l)XZ(e,`[`,ZZ(n,`mark`)),XZ(e,l,ZZ(n,`link`)),XZ(e,`](${u})`,ZZ(n,`mark`));else if(d)XZ(e,d,ZZ(n,`mark`)),QZ(e,f,ZZ(n,`strong`)),XZ(e,d,ZZ(n,`mark`));else if(p)XZ(e,p,ZZ(n,`mark`)),QZ(e,m,ZZ(n,`strike`)),XZ(e,p,ZZ(n,`mark`));else if(h||_){let t=h??_;XZ(e,t,ZZ(n,`mark`)),QZ(e,g??v,ZZ(n,`em`)),XZ(e,t,ZZ(n,`mark`))}else y?XZ(e,y,ZZ(n,`link`)):b?XZ(e,b,ZZ(n,`mention`)):XZ(e,o,n);r=a+o.length}XZ(e,t.slice(r),n)}function $Z(e){let t=[],n;return e.split(`
|
|
114
114
|
`).forEach((e,r)=>{r>0&&XZ(t,`
|
|
115
115
|
`,``);let i=WZ.exec(e);if(n!==void 0){i&&i[1].startsWith(n)?(n=void 0,XZ(t,e,`codeblock mark`)):XZ(t,e,`codeblock`);return}if(i){n=i[1][0].repeat(3),XZ(t,e,`codeblock mark`);return}if(r===0&&/^\/[a-z][\w-]*/i.test(e)){let n=/^\/[a-z][\w-]*/i.exec(e)[0];XZ(t,n,`mention`),QZ(t,e.slice(n.length),``);return}if(JZ.test(e))return XZ(t,e,`mark`);let a=GZ.exec(e);if(a)return XZ(t,a[1]+a[2],`heading mark`),QZ(t,a[3],`heading`);let o=KZ.exec(e);if(o)return XZ(t,o[1],`quote mark`),QZ(t,o[2],`quote`);let s=qZ.exec(e);if(s)return XZ(t,s[1],``),XZ(t,s[2],`list`),XZ(t,s[3],``),s[4]&&XZ(t,s[4],`list`),QZ(t,s[5],``);QZ(t,e,``)}),t}function eQ(e){if(e.startsWith(`/`))return`var(--primary)`;let t=GV(e.slice(1));return t===`var(--muted-foreground)`?`var(--primary)`:t}var tQ=260;function nQ(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}function rQ(e,t,n,r,i){let a=nQ(e,t);if(!a)return[];let o=a.end-a.start;return[...n.filter(e=>i-e.at<tQ&&!(e.start<a.start&&e.end>a.start)).map(e=>e.start>=a.start?{...e,start:e.start+o,end:e.end+o}:e),{...a,seq:r,at:i}].sort((e,t)=>e.start-t.start)}var iQ=(0,m.memo)(function({text:e,fresh:t}){let n=0;return(0,H.jsxs)(H.Fragment,{children:[$Z(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:eQ(e.text)}:void 0,s=[],c=i;for(let e of t){let t=Math.max(i,e.start),r=Math.min(n,e.end);r<=t||(t>c&&s.push({a:c,b:t}),s.push({a:t,b:r,seq:e.seq}),c=r)}return c<n&&s.push({a:c,b:n}),s.map(({a:t,b:n,seq:s})=>{let c=e.text.slice(t-i,n-i),l=s!==void 0;return a||l?(0,H.jsx)(`span`,{className:[a,l?`md-new`:``].filter(Boolean).join(` `),style:o,children:c},l?`n${s}-${r}`:`${r}-${t}`):c})}),``]})}),aQ=(0,m.forwardRef)(function({text:e},t){let n=(0,m.useRef)({text:e,fresh:[],seq:0});if(n.current.text!==e){let t=n.current.seq+1;n.current={text:e,seq:t,fresh:rQ(n.current.text,e,n.current.fresh,t,performance.now())}}return(0,H.jsx)(`div`,{ref:t,className:`bubble-text bubble-mirror`,"aria-hidden":`true`,children:(0,H.jsx)(iQ,{text:e,fresh:n.current.fresh})})}),oQ=e=>e.preventDefault();function sQ({onStop:e}){let[t,n]=(0,m.useState)(!1),r=gk(t,hk.confirm),i=()=>{n(!1),e()};return lA(`y`,i,{enabled:t&&r,inDialog:!0}),(0,H.jsxs)(_V,{open:t&&r,onOpenChange:n,children:[(0,H.jsx)(`button`,{type:`button`,className:`bubble-send bubble-key bubble-stop`,"data-tip":`Interrupt`,onPointerDown:oQ,onClick:()=>n(!0),"aria-label":`Stop`,"aria-haspopup":`dialog`,children:(0,H.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,H.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),(0,H.jsxs)(vV,{children:[(0,H.jsxs)(yV,{children:[(0,H.jsx)(xV,{children:`Stop the orchestrator?`}),(0,H.jsx)(SV,{children:`The current response stops. Work already recorded is kept.`})]}),(0,H.jsxs)(bV,{children:[(0,H.jsxs)(wV,{children:[`Cancel`,(0,H.jsx)(ak,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,H.jsxs)(CV,{variant:`destructive`,onClick:i,children:[`Stop`,(0,H.jsx)(ak,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function cQ({sending:e,disabled:t,steering:n,onSend:r}){let[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(e);return(0,m.useEffect)(()=>{if(!i)return;l(!0);let e=setTimeout(()=>l(!1),640);return()=>clearTimeout(e)},[i]),(0,m.useEffect)(()=>{if(e&&!u.current&&a(e=>e+1),u.current=e,!e)return s(!1);let t=setTimeout(()=>s(!0),600);return()=>clearTimeout(t)},[e]),(0,H.jsx)(`button`,{type:`button`,className:Y(`bubble-send`,(!t||c)&&`bubble-key`),"data-tip":n?`Steer`:`Send`,"data-flying":c||void 0,onPointerDown:oQ,onClick:r,disabled:t,"aria-label":`Send`,"aria-keyshortcuts":`Enter`,children:o?(0,H.jsx)(VV,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):(0,H.jsxs)(`span`,{className:`bubble-plane-wrap`,"data-fly":i>0?``:void 0,"aria-hidden":`true`,children:[(0,H.jsxs)(`svg`,{className:`bubble-plane`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{d:`M22 2L11 13`}),(0,H.jsx)(`path`,{d:`M22 2l-7 20-4-9-9-4z`})]}),(0,H.jsx)(`span`,{className:`bubble-trail`})]},i)})}function lQ(e){return e.agent?GV(e.agent):e.tag===`lobby`?`var(--c-orc)`:e.tag===`skill`?`var(--c-pl)`:`var(--c-qa)`}function uQ(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 dQ(e){return[...Sk.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 fQ(e,t=[]){let n=e.kind===`slash-command`?dQ(t):xk.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 pQ(e,t){return`${e}-${encodeURIComponent(t)}`}var mQ={"slash-command":`Commands`,mention:`Agents`};function hQ(e){return 8+Math.min(e,8)*30}var gQ;function _Q(e,t){let n=0;try{if(gQ??=document.createElement(`canvas`).getContext(`2d`),!gQ)throw Error(`no canvas`);for(let r of e){gQ.font=`500 13px ${t}`;let e=gQ.measureText(r.label.slice(1)).width;gQ.font=`400 12px ${t}`,n=Math.max(n,e+gQ.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 vQ=(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,H.jsx)(`div`,{ref:t,id:e.listId,role:`listbox`,"aria-label":mQ[e.triggerKind],"data-composer-command-drawer":`true`,className:`bubble-pane bubble-scroll overflow-y-auto p-1`,style:{height:hQ(e.items.length)},children:e.items.map((t,r)=>{let i=e.activeItemId===t.id;return(0,H.jsxs)(`div`,{id:pQ(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?null:(0,H.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":lQ(t)},children:t.label.charAt(1).toUpperCase()}),(0,H.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-(--bubble-ink)`,style:t.agent?{color:lQ(t)}:void 0,children:t.label.slice(1)}),(0,H.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-(--bubble-muted)`,children:t.description}),(0,H.jsx)(`span`,{className:`cs-ktag`,style:{"--k":lQ(t)},children:t.tag})]},t.id)})})});function yQ(e){return typeof e==`object`&&e?e:{}}function bQ(e){return typeof e==`string`?e.trim():``}function xQ(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function SQ(e){let t=yQ(e),n=bQ(t.label);if(!n)return;let r=bQ(t.description),i=bQ(t.preview),a=bQ(t.image),o=vq(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function CQ(e){let t=yQ(e),n=bQ(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(SQ).filter(e=>!!e);return{question:n,header:bQ(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function wQ(e){let t=yQ(e),n=bQ(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=bQ(t.message),i=xQ(t.options),a=bQ(t.placeholder),o=bQ(t.prefill);return{id:bQ(t.id),method:n,title:bQ(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function TQ(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(CQ).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function EQ(e){return{kind:`choose`,title:bQ(e.title)||`Choose an option`,options:xQ(e.options)}}function DQ(e){let t=bQ(e.question)||bQ(e.title)||`Continue?`,n=bQ(e.detail)||bQ(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function OQ(e){let t=bQ(e.question)||bQ(e.title)||`Type an answer`,n=bQ(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function kQ(e){let t=yQ(e.payload);if(e.kind===`questionnaire`)return TQ(t);if(e.kind===`choose`)return EQ(t);if(e.kind===`confirm`)return DQ(t);if(e.kind===`text`)return OQ(t);let n=wQ(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var AQ=`That question was already answered in the terminal.`;function jQ(e){let t=e.from.trim();return/panel|plann/i.test(t)?`PLANNER`:/oracle|orchestrator|master|lobby/i.test(t)||!t?`MASTER`:t.split(/\s+/)[0].toUpperCase()}function MQ(e,t){let n=jQ(e);return n===`PLANNER`&&t&&GV(t)!==`var(--muted-foreground)`?t.toUpperCase():n}function NQ(e,t){let n=MQ(e,t);if(n!==jQ(e))return n===`DEV`||n===`BACKEND`?`Dev`:n===`QA`?`QA`:n.charAt(0)+n.slice(1).toLowerCase();let r=jQ(e);if(r===`PLANNER`)return`Panel`;if(r===`MASTER`)return`Orchestrator`;let i=e.from.trim().split(/\s+/)[0]??`Agent`;return i.charAt(0).toUpperCase()+i.slice(1)}function PQ(e,t){let{round:n,limit:r}=e.payload??{},i=n?`From planning · round ${r?`${Math.min(n,r)}/${r}`:n}`:`From planning`,a=jQ(e)===`PLANNER`?i:e.taskId?`From task ${e.taskId}`:`From the Lobby`;return t&&t!==`Question`&&MQ(e,t)===jQ(e)?`${a} · ${t}`:a}function FQ(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 IQ(e,t){return e&&e.kind===`questionnaire`?Math.max(0,e.questions.length-t):1}function LQ(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:kQ(e)})),[e]),h=p[0],g=h?.view?FQ(h.prompt,h.view,r[h.prompt.id]?.length??0):void 0,_=p.reduce((e,{prompt:t,view:n})=>e+IQ(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 be&&e.code===`question_withdrawn`?W(AQ):W.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=>W.error(e instanceof Error?e.message:`Could not dismiss the question`))},[n,g]),E=g?r[g.prompt.id]:void 0,D=(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]),O=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:D}:{},...O?{was:O}:{}}}function RQ({option:e,large:t}){let n=Eq(e.label);return e.htmlPreview?(0,H.jsx)(Cq,{preview:e.htmlPreview,label:n,frameWidth:t?void 0:880,minWidth:t?1024:void 0,className:`static-thumb h-full`}):e.image?(0,H.jsx)(`img`,{src:I(e.image),alt:t?`Mockup: ${n}`:``,loading:`lazy`}):e.preview?t?(0,H.jsx)(`div`,{className:`cs-mktext`,children:(0,H.jsx)(pV,{text:e.preview})}):(0,H.jsx)(`pre`,{className:`cs-mktext`,children:e.preview}):null}function zQ(e,t){return e!==void 0&&(e===t||e.split(`, `).includes(t))}function BQ({color:e,children:t}){return(0,H.jsx)(`span`,{className:`bubble-glyph cs-kg`,"aria-hidden":`true`,style:{"--k":e},children:t})}function VQ({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,H.jsx)(`div`,{className:`bubble-pane p-3 text-sm text-(--bubble-muted)`,children:`No questions are waiting.`});let a=GV(MQ(n.prompt,n.header)),o=n.options.some(Dq),s=n.options.length;return(0,H.jsxs)(`div`,{className:`bubble-pane p-1.5`,role:`group`,"aria-label":`Question`,children:[(0,H.jsxs)(`div`,{className:`cs-askh`,children:[(0,H.jsxs)(`div`,{className:`cs-asks`,children:[(0,H.jsx)(`b`,{style:{color:a},children:NQ(n.prompt,n.header)}),(0,H.jsx)(`span`,{className:`cs-askf`,children:PQ(n.prompt,n.header)}),e.back?(0,H.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,H.jsxs)(`span`,{className:`cs-askn`,children:[e.position,` of `,e.total]}),(0,H.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,H.jsx)(`p`,{className:`cs-askq`,children:n.question})]}),o?(0,H.jsx)(`div`,{className:`cs-askm`,style:{"--cols":s<=2||s===4?2:3},children:n.options.map((n,r)=>(0,H.jsxs)(`button`,{type:`button`,className:`cs-mko`,"data-on":e.picks.includes(r)||zQ(e.was,n.label)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{animationDelay:`${r*30}ms`},children:[(0,H.jsxs)(`div`,{className:`cs-mk3`,children:[(0,H.jsx)(RQ,{option:n}),(0,H.jsx)(`span`,{className:`cs-mxb`,role:`button`,"aria-label":`Expand ${Eq(n.label)}`,onClick:e=>{e.stopPropagation(),t(r)},children:(0,H.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,H.jsx)(`path`,{d:`M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7`})})})]}),(0,H.jsxs)(`span`,{className:`cs-mkl`,children:[(0,H.jsx)(BQ,{color:a,children:r+1}),(0,H.jsx)(`span`,{children:Eq(n.label)})]}),n.description?(0,H.jsx)(`span`,{className:`cs-mkd`,children:n.description}):null]},n.label))}):(0,H.jsxs)(`div`,{className:`cs-askopts`,children:[n.options.map((t,r)=>(0,H.jsxs)(`button`,{type:`button`,className:`bubble-row cs-aro`,"data-active":e.picks.includes(r)||zQ(e.was,t.label)||void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>e.choose(r),style:{"--delay":`${(s-1-r)*22}ms`},children:[(0,H.jsx)(BQ,{color:a,children:r+1}),(0,H.jsxs)(`span`,{className:`cs-arot`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:Eq(t.label)}),t.description?(0,H.jsx)(`span`,{className:`cs-arod`,children:t.description}):null]}),n.multi?(0,H.jsx)(`span`,{className:`cs-cb cs-sm`,"data-on":e.picks.includes(r),children:(0,H.jsx)(km,{"aria-hidden":`true`,strokeWidth:3})}):null]},t.label)),s===0?(0,H.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,H.jsx)(`button`,{type:`button`,className:`bubble-row`,disabled:e.picks.length===0,onMouseDown:e=>e.preventDefault(),onClick:e.submitPicks,children:(0,H.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 HQ({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?GV(MQ(r.prompt,r.header)):`var(--primary)`;return(0,H.jsxs)(`div`,{className:`cs-mxw`,"data-open":a,"aria-hidden":!a,inert:!a,children:[(0,H.jsx)(`div`,{className:`cs-shbd`,onClick:()=>n(-1)}),(0,H.jsxs)(`div`,{ref:c,role:a?`dialog`:void 0,"aria-modal":a?`true`:void 0,"aria-label":s?`Mockup: ${Eq(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,H.jsx)(`div`,{className:`cs-mxbig`,children:s?(0,H.jsx)(RQ,{option:s,large:!0}):null}),s&&r?(0,H.jsxs)(`div`,{className:`cs-mxf`,children:[(0,H.jsx)(BQ,{color:u,children:o.current+1}),(0,H.jsx)(`b`,{children:Eq(s.label)}),(0,H.jsxs)(`span`,{className:`cs-mxwho`,children:[NQ(r.prompt,r.header),` · `,r.question]}),i.length>1?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Previous mockup`,onClick:()=>l(-1),children:(0,H.jsx)(Nm,{"aria-hidden":`true`,className:`size-3.5`})}),(0,H.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Next mockup`,onClick:()=>l(1),children:(0,H.jsx)(Fm,{"aria-hidden":`true`,className:`size-3.5`})})]}):null,(0,H.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,H.jsx)(`button`,{type:`button`,className:`cs-kc cs-sm cs-ib`,"aria-label":`Close`,onClick:()=>n(-1),children:(0,H.jsx)(l_,{"aria-hidden":`true`,className:`size-3.5`})})]}):null]})]})}var UQ=`bot-lobby.questionsPutAway`,WQ=new Set,GQ;function KQ(){if(GQ!==void 0)return GQ;try{GQ=sessionStorage.getItem(UQ)===`1`}catch{GQ=!1}return GQ}function qQ(e){if(KQ()!==e){GQ=e;try{e?sessionStorage.setItem(UQ,`1`):sessionStorage.removeItem(UQ)}catch{}for(let e of[...WQ])e()}}function JQ(e){return WQ.add(e),()=>{WQ.delete(e)}}function YQ(){return(0,m.useSyncExternalStore)(JQ,KQ,()=>!1)}var XQ={id:`oracle`,label:`Message the team`,placeholder:`Write a message, run a command, or ask an agent`},ZQ=new Set([`lobby`,`tasks`,`plan`,`knowledge`]);function QQ(e){return e.kind===`settings`||e.kind===`tab`&&ZQ.has(e.tab)}var $Q={id:`knowledge`,label:`Ask what the agents know`,placeholder:`Ask what the agents know…`};function e$(e,t){if(e.kind!==`tab`)return XQ;if(e.tab===`knowledge`)return $Q;if(e.tab===`plan`)return{id:`panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`};let n=e.tab===`tasks`?BV(e.rest).id??t:void 0;return n?{id:`comment`,label:`Comment on ${n}`,placeholder:`Comment on ${n}'s plan…`,taskId:n}:XQ}var t$={w:260,h:97},n$=0,r$=document.createElement(`canvas`).getContext(`2d`);function i$(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}var a$={duration:.16,ease:`easeOut`};function o$({file:e,onRemove:t}){let n=(0,H.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,H.jsx)(l_,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,H.jsxs)(Qf.li,{layout:!0,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:a$,title:`${e.name} · ${cZ(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-xl border border-(--bubble-edge) bg-background`,children:[(0,H.jsx)(`img`,{src:I(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,H.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,H.jsx)(VV,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}),`uploading`]}):null,n]}):(0,H.jsxs)(Qf.li,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:a$,className:`flex min-w-0 basis-full items-center gap-2 text-sm text-foreground`,children:[(0,H.jsx)(_h,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.state===`uploading`?(0,H.jsx)(VV,{className:`size-2.5`,"aria-hidden":`true`,role:`presentation`}):null,e.state===`uploading`?`uploading…`:cZ(e.size)]}),n]})}var s$=0;function c$(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 l$({children:e}){return(0,H.jsx)(`kbd`,{className:`bubble-kbd`,"data-glyph":/^[^A-Za-z0-9]$/.test(e)||void 0,children:e})}function u$(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),h:aZ(38)}:{w:n??aZ(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 d$({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=Vk(`status`),g=Vk(`lobby`),_=vk(),v=(h.data?.busy??!1)||!!g.data?.reply?.trim(),y=QQ(e),b=(0,m.useRef)(y);b.current=y;let{taskId:x}=NJ(),S=e.kind===`tab`?e.tab:e.kind,C=(0,m.useMemo)(()=>e$(e,x),[e,x]),w=RA(),[T,E]=(0,m.useState)(-1),D=(0,m.useRef)(null),O=(0,m.useRef)(null),k=(0,m.useRef)(null),A=(0,m.useRef)(null),j=(0,m.useRef)(null),M=(0,m.useRef)(null),N=(0,m.useRef)(null),ee=(0,m.useRef)(null),te=(0,m.useRef)(o);te.current=o;let P=(0,m.useRef)(void 0),[ne,re]=(0,m.useState)(0),[ie,ae]=(0,m.useState)(null),[oe,se]=(0,m.useState)(void 0),ce=r&&!!n.step&&y&&!_&&f===null,le=C.id===`oracle`&&!f&&!ce?uQ(i,ne):void 0,F=(0,m.useMemo)(()=>le?fQ(le,h.data?.commands):[],[le?.kind,le?.query,h.data?.commands]),ue=!!le&&F.length>0&&oe!==i&&y&&!_,de=ue?F.find(e=>e.id===ie)??F[0]:void 0,fe=`composer-suggestions`,I={answer:n.left>0&&!r,plan:S===`plan`&&!!w},L=!ue&&f===null&&!ce&&y&&!_&&(I.answer||I.plan),pe=ue||ce||f!==null&&y&&!_,{shrunk:me,expand:he}=c$(D,y&&!_,e,pe),[ge,_e]=(0,m.useState)(!1),ve=(0,m.useRef)(me);(0,m.useEffect)(()=>{if(ve.current===me)return;ve.current=me,_e(!0);let e=setTimeout(()=>_e(!1),400);return()=>clearTimeout(e)},[me]);let ye=L&&!me&&!ge,be=pe||ye;(0,m.useEffect)(()=>{let e=document.documentElement;return e.style.setProperty(`--dock-bar`,L?oZ(44):`0px`),()=>e.style.setProperty(`--dock-bar`,`0px`)},[L]),(0,m.useEffect)(()=>p(null),[S]),(0,m.useEffect)(()=>{(!y||_)&&p(null)},[y,_]),(0,m.useEffect)(()=>{if(!f)return;let e=e=>{O.current?.contains(e.target)||p(null)};return document.addEventListener(`pointerdown`,e,{capture:!0}),()=>document.removeEventListener(`pointerdown`,e,{capture:!0})},[f]);let xe=(0,m.useCallback)(e=>{he(),p(t=>t===e||e===`projects`&&t===`browse`?null:e)},[he]),Se=(0,m.useCallback)(()=>{p(e=>{let t=e===`attach`?`[data-composer-attach]`:e?`[role="combobox"][aria-label="Project"]`:void 0;return t&&requestAnimationFrame(()=>O.current?.querySelector(t)?.focus({preventScroll:!0})),null})},[]);lA(`p`,()=>xe(`projects`),{enabled:y&&!_&&f===null}),(0,m.useEffect)(()=>{let e=()=>{he(),p(`projects`)};return window.addEventListener(bZ,e),()=>window.removeEventListener(bZ,e)},[he]);let Ce=(0,m.useRef)(`suggest`),we=(0,m.useRef)({w:320,h:0}),Te=f??(ce?`ask`:ue?`suggest`:ye?`bar`:Ce.current),Ee=(0,m.useRef)(null),De=Te===`ask`&&!!n.step?.options.some(Dq),Oe=u$(Te,Ee,Te===`ask`?4e3:void 0);if(be){Ce.current=Te;let e=j.current?getComputedStyle(j.current).fontFamily:`system-ui, sans-serif`;we.current=Te===`suggest`?sZ({w:_Q(F,e),h:hQ(F.length)}):Te===`attach`?sZ(t$):Te===`projects`?sZ(SZ(t)):Te===`bar`||Te===`ask`?Oe:sZ(TZ)}let ke=(0,m.useRef)({items:[],kind:`slash-command`});ue&&le&&de&&(ke.current={items:F,kind:le.kind,lit:de.id});let Ae=(0,m.useCallback)(e=>{let t=i.replace(/^\s*[/@][a-z0-9:_.-]*\s*/i,``),n=`${e.insert} ${t}`,r=e.insert.length+1;P.current={start:r,end:r},re(r),a(n),ae(null),j.current?.focus()},[i]);(0,m.useLayoutEffect)(()=>{let e=P.current,t=j.current;e&&t&&(P.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let je=(0,m.useCallback)(e=>{P.current={start:e.start,end:e.end},re(e.end),a(e.value)},[]);(0,m.useLayoutEffect)(()=>{let e=A.current,t=O.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()},[me]),(0,m.useLayoutEffect)(()=>{let e=j.current,t=O.current;if(!e||!t)return;if(me||!i)return void t.style.removeProperty(`--cg`);let n=getComputedStyle(e);r$.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`;let r=Math.max(...i.split(`
|
|
116
|
-
`).map(e=>r$.measureText(e).width));t.style.setProperty(`--cg`,`${Math.ceil((r+aZ(44))/aZ(48))*aZ(48)}px`)},[i,me]),(0,m.useLayoutEffect)(()=>{M.current&&j.current&&(M.current.scrollTop=j.current.scrollTop)}),(0,m.useEffect)(()=>{let e=k.current,t=D.current;if(!e||!t)return;let n=document.documentElement,r=()=>{let r=e.getBoundingClientRect(),i=t.getBoundingClientRect().bottom,a=t.hasAttribute(`data-shrunk`)||e.closest(`.bubble`)?.hasAttribute(`data-morphing`),o=Math.ceil(i-r.top);if(a||(s$=o),n.style.setProperty(`--composer-h`,_||!y?`0px`:`${a?Math.max(s$,o):o}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 Me=(0,m.useCallback)(e=>{if(!b.current)return;let t=[...e],n=8-te.current.length;t.length>n&&W.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++n$}`,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`}]),lZ(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{W.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),Ne=(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)})},[]),Pe=o.some(e=>e.state===`uploading`),Fe=o.flatMap(e=>e.info?[e.info.id]:[]),Ie=(i.trim().length>0||Fe.length>0)&&!Pe&&!c,Le=(0,m.useCallback)(async()=>{if(!Ie||!b.current)return;l(!0);let e=Fe.length>0?Fe:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0,n=C.id===`knowledge`&&/^\s*[/@]/.test(i);if(C.id===`oracle`||n){let e=await R(`lobby.send`,t);e.notice&&W(e.notice),e.open===`plan`?Dk(Ek(`plan`)):S===`knowledge`&&Dk(Ek(`lobby`))}else C.id===`knowledge`?(e=await G(`knowledge.ask`,t)!==void 0,e&&window.dispatchEvent(new CustomEvent(BA,{detail:i.trim()}))):e=C.id===`panel`?await G(`planner.send`,t)!==void 0:await G(`tasks.comment`,{taskId:C.taskId,...t})!==void 0;if(e){Np(`sent`),a(``);for(let e of te.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){W.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[Ie,Fe,C,i,e,S]),Re=(0,m.useCallback)(async()=>{try{await R(`lobby.abort`,{})}catch(e){W.error(e instanceof Error?e.message:`Could not stop`)}},[]),ze=e=>{if(ue&&de&&!e.nativeEvent.isComposing){let t=F.indexOf(de);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+F.length)%F.length;ae(F[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),Ae(de);return}if(e.key===`Escape`){e.preventDefault(),se(i);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),f?p(null):ce?qQ(!0):Qk();return}if(ce&&i$(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;je(r===`k`?dZ(a,n,i):uZ(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=pZ(t.value,t.selectionStart);n&&(e.preventDefault(),je(n));return}if(e.key===`Backspace`&&t.value===``&&te.current.length>0){e.preventDefault(),Ne(te.current.at(-1).key);return}(i$(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),Le())},Be=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),Me(t))},Ve=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&Me(e.dataTransfer.files)},He=h.data?.workspace.name??`bot-lobby`,Ue=h.data?.branch??h.data?.workspace.branch,We=v&&C.id===`oracle`,Ge=me?S===`knowledge`?`Ask what the agents know…`:`Write a message…`:ce?n.step?.typed?n.step.placeholder:`Pick an answer above`:We?`The orchestrator is working. Enter steers it…`:C.placeholder,Ke=e=>{p(null),e.current?.click()},qe=Te===`ask`?(0,H.jsx)(`div`,{ref:Ee,children:(0,H.jsx)(VQ,{drawer:n,onExpand:E})},`ask`):Te===`bar`?(0,H.jsx)(`div`,{ref:Ee,className:`bubble-pane p-1`,style:{width:`max-content`},children:(0,H.jsxs)(`div`,{className:`cs-pbar`,children:[I.answer?(0,H.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq cs-acc`,onMouseDown:e=>e.preventDefault(),onClick:()=>{qQ(!1),requestAnimationFrame(()=>j.current?.focus({preventScroll:!0}))},children:[(0,H.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,H.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`}),(0,H.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,H.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:`Answer questions`}),(0,H.jsxs)(`span`,{className:`cs-ktag`,style:{"--k":`var(--primary)`},children:[n.left,` left`]})]}):null,I.plan?(0,H.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,"aria-keyshortcuts":`V`,onMouseDown:e=>e.preventDefault(),onClick:()=>w?.(),children:[(0,H.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,H.jsx)(`path`,{d:`M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z`}),(0,H.jsx)(`path`,{d:`M14 3v5h5M9 13h6M9 17h4`})]}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`View plan`}),(0,H.jsx)(`span`,{className:`cs-kb`,children:`V`})]}):null]})},`bar`):Te===`suggest`?(0,H.jsx)(vQ,{listId:fe,items:ue?F:ke.current.items,triggerKind:ue&&le?le.kind:ke.current.kind,activeItemId:de?.id??null,onHighlightedItemChange:ae,onSelect:Ae},`suggest`):Te===`attach`?(0,H.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,H.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`24ms`},onClick:()=>Ke(N),children:[(0,H.jsx)(_h,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload a file…`})]}),(0,H.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`12ms`},onClick:()=>Ke(ee),children:[(0,H.jsx)(Dh,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload an image…`})]}),(0,H.jsx)(`div`,{className:`h-px`}),(0,H.jsx)(`div`,{className:`flex h-7 items-center px-2 text-[11.5px] text-(--bubble-muted)`,children:`Or drop files on the composer`})]},`attach`):Te===`projects`?(0,H.jsx)(wZ,{projects:t,tab:S,onBrowse:()=>p(`browse`),onClose:()=>p(null)},`projects`):(0,H.jsx)(kZ,{tab:S,onClose:Se},`browse`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`cs-scrim`,"data-open":pe||void 0,"aria-hidden":`true`}),(0,H.jsx)(`div`,{id:`app-dock`,ref:D,"data-shrunk":me||void 0,onFocus:he,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,H.jsx)(BZ,{ref:O,open:be,size:we.current,"data-ask":ce?De?`mockups`:`text`:void 0,shrunk:me,morphing:ge,menu:qe,toasts:y,className:`composer-shell pointer-events-auto`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(f?(e.preventDefault(),Se()):ce&&(e.preventDefault(),qQ(!0)))},children:(0,H.jsxs)(`div`,{ref:k,className:`bubble-composer group/composer composer-box`,"data-dragging":u||void 0,"data-chat-composer-main-surface":`true`,onPointerDown:he,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:Ve,children:[(0,H.jsxs)(`div`,{ref:A,"data-chat-composer-surface":`true`,children:[(0,H.jsx)(Nu,{initial:!1,children:o.length>0?(0,H.jsx)(Qf.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,H.jsx)(o$,{file:e,onRemove:()=>Ne(e.key)},e.key))},`files`):null}),(0,H.jsxs)(`div`,{className:`bubble-field`,children:[(0,H.jsx)(aQ,{ref:M,text:i}),(0,H.jsx)(`textarea`,{ref:j,id:`composer-text`,"aria-label":C.label,...C.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":ue,"aria-controls":ue?fe:void 0}:{},...de?{"aria-activedescendant":pQ(fe,de.id)}:{},value:i,onChange:e=>{a(e.target.value),re(e.target.selectionStart),p(null)},onSelect:e=>re(e.currentTarget.selectionStart),onKeyDown:ze,onPaste:Be,onScroll:e=>{M.current&&(M.current.scrollTop=e.currentTarget.scrollTop)},placeholder:Ge,rows:1,className:`bubble-text bubble-input`}),(0,H.jsx)(UZ,{field:j,mirror:M,text:i})]}),(0,H.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:`bubble-tools composer-tools`,children:[(0,H.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:()=>xe(`attach`),className:`bubble-iconbtn bubble-tip bubble-tool size-8 rounded-full`,style:{"--i":0},children:(0,H.jsx)(ag,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.7})}),(0,H.jsx)(`span`,{className:`bubble-tool flex min-w-0`,style:{"--i":1},children:(0,H.jsx)(CZ,{projects:t,name:He,branch:Ue,open:f===`projects`||f===`browse`,onToggle:()=>xe(`projects`)})}),(0,H.jsx)(`span`,{className:`flex-1`}),(0,H.jsx)(`span`,{className:`bubble-hints bubble-tool`,style:{"--i":2},"aria-hidden":`true`,children:ue?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(l$,{children:`↑`}),(0,H.jsx)(l$,{children:`↓`}),`choose`,(0,H.jsx)(l$,{children:`↵`}),`insert`]}):f?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(l$,{children:`Esc`}),`close`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(l$,{children:`Shift`}),(0,H.jsx)(l$,{children:`↵`}),`new line`]})}),(0,H.jsxs)(`span`,{"data-chat-composer-actions":`right`,className:`bubble-tool flex shrink-0 items-center gap-2`,style:{"--i":3},children:[We?(0,H.jsx)(sQ,{onStop:()=>void Re()}):null,(0,H.jsx)(cQ,{sending:c,disabled:!Ie,steering:We,onSend:()=>void Le()})]})]})]}),(0,H.jsx)(`input`,{ref:N,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),(0,H.jsx)(`input`,{ref:ee,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach images`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),u?(0,H.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,H.jsx)(HQ,{drawer:n,at:ce?T:-1,onAt:E})]})}var f$=3e4,p$,m$=0,h$=new Set;function g$(){for(let e of h$)e()}function _$(){return p$}function v$(e){p$=e,window.clearTimeout(m$),m$=window.setTimeout(y$,f$),g$()}function y$(){p$&&(p$=void 0,window.clearTimeout(m$),g$())}function b$(e){p$&&e&&(e===p$.sessionId||p$.from&&e!==p$.from)&&y$()}function x$(){return(0,m.useSyncExternalStore)(e=>(h$.add(e),()=>h$.delete(e)),()=>p$)}var S$=.6;function C$(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:S$,...n}}}var w$=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function T$(e,t=0,n=1){return C$(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:S$,times:w$(t,n),ease:`easeInOut`},strokeOpacity:{duration:S$,times:w$(t,t+.02)}})}function E$(e,t){return C$(e,{scale:[0,0,1.3,1]},{times:w$(t,t+.18),ease:`easeOut`})}function D$(e,t,n=1.3){return C$(e,{scale:[1,1,n,1,1]},{times:[0,Math.max(t,.001),Math.min(t+.15,.9),Math.min(t+.35,.99),1],ease:`easeInOut`})}var O$=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function k$({play:e}){return(0,H.jsxs)(Qf.g,{style:O$(.1,.9),...C$(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,H.jsx)(`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}),[8,12,16].map((t,n)=>(0,H.jsx)(Qf.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...C$(e,{fillOpacity:[0,0,1,1,0],y:[0,0,-1.5,0,0]},{times:[0,.12+n*.12,.24+n*.12,.72,1]})},t))]})}function A$({play:e}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Qf.path,{d:`M13 5h8`,...T$(e,.15,.45)}),(0,H.jsx)(Qf.path,{d:`M13 12h8`,...T$(e,.3,.6)}),(0,H.jsx)(Qf.path,{d:`M13 19h8`,...T$(e,.45,.75)}),(0,H.jsx)(Qf.path,{d:`m3 17 2 2 4-4`,...T$(e,.35,.7)}),(0,H.jsx)(Qf.path,{d:`m3 7 2 2 4-4`,...T$(e,0,.35)})]})}function j$({play:e}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Qf.circle,{cx:6,cy:19,r:3,style:O$(),...D$(e,0)}),(0,H.jsx)(Qf.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...T$(e,.1,.7)}),(0,H.jsx)(Qf.circle,{cx:18,cy:5,r:3,style:O$(),...E$(e,.62)})]})}var M$=1.05;function N$(e,t){let n=e=>Math.min(t+e,.999);return C$(e,{scaleX:[1,1,.02,-1,-1,-1],skewY:[0,0,-14,0,0,0],y:[0,0,-1.2,0,0,0],strokeOpacity:[0,0,1,.9,0,0],fillOpacity:[0,0,.22,.14,0,0]},{duration:M$,times:[0,Math.max(t,.001),n(.17),n(.34),n(.4),1],ease:`easeInOut`})}function P$({play:e}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Qf.g,{style:O$(),...C$(e,{scaleX:[1,1.08,1.06,1],y:[0,-.6,-.4,0]},{duration:M$,times:[0,.15,.8,1],ease:`easeInOut`}),children:[(0,H.jsx)(`path`,{d:`M12 5v16`}),(0,H.jsx)(`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`})]}),e?[.06,.26,.46].map(t=>(0,H.jsx)(Qf.path,{d:`M12 6.4C13.6 5 15.6 4.4 18.6 4.5V16.6C15.6 16.5 13.6 17 12 18.4z`,fill:`currentColor`,strokeWidth:1.4,style:O$(0,.5),...N$(e,t)},t)):null]})}var F$={lobby:k$,tasks:A$,plan:j$,knowledge:P$};function I$({id:e,play:t,className:n}){let r=F$[e];return r?(0,H.jsx)(`svg`,{"aria-hidden":`true`,"data-tab-icon":e,"data-play":t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,className:Y(`overflow-visible`,n),children:(0,H.jsx)(r,{play:t})},t):null}function L$(){let e=(e,t)=>(0,H.jsxs)(`filter`,{id:e,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,H.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:t,result:`b`}),(0,H.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,H.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,H.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,H.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.6`,result:`rimB`}),(0,H.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,H.jsx)(`feFlood`,{style:{floodColor:`var(--hl)`},result:`hlc`}),(0,H.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,H.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,H.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,H.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.6`,result:`shB`}),(0,H.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,H.jsx)(`feFlood`,{style:{floodColor:`var(--sh)`},result:`shc`}),(0,H.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,H.jsxs)(`feMerge`,{children:[(0,H.jsx)(`feMergeNode`,{in:`shape`}),(0,H.jsx)(`feMergeNode`,{in:`sh`}),(0,H.jsx)(`feMergeNode`,{in:`hl`})]})]});return(0,H.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,H.jsxs)(`defs`,{children:[e(`cs-baylit`,3.5),e(`cs-worklit`,3.2),(0,H.jsxs)(`filter`,{id:`cs-bayedge`,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,H.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`3.5`,result:`b`}),(0,H.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,H.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,H.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,H.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.3`,result:`tS1`}),(0,H.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,H.jsx)(`feFlood`,{style:{floodColor:`var(--ehl)`},result:`tc`}),(0,H.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,H.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,H.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,H.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.3`,result:`bS1`}),(0,H.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,H.jsx)(`feFlood`,{style:{floodColor:`var(--esh)`},result:`bc`}),(0,H.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,H.jsxs)(`feMerge`,{children:[(0,H.jsx)(`feMergeNode`,{in:`shape`}),(0,H.jsx)(`feMergeNode`,{in:`eh`}),(0,H.jsx)(`feMergeNode`,{in:`es`})]})]})]})})}function R$({className:e,style:t}){return(0,H.jsxs)(`div`,{className:e,"aria-hidden":`true`,style:t,children:[(0,H.jsx)(`div`,{className:`cs-layer cs-edge`,children:(0,H.jsx)(`div`,{className:`cs-bb`})}),(0,H.jsx)(`div`,{className:`cs-layer cs-fill`,children:(0,H.jsx)(`div`,{className:`cs-bb`})})]})}function z$(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);(0,m.useEffect)(()=>()=>u.current?.(),[]);let d=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}}},f=(0,m.useRef)(null),p=n||i;return(0,m.useEffect)(()=>{if(!p)return;let e=()=>{window.clearTimeout(o.current),r(!1),a(!1);let e=f.current;e&&document.activeElement instanceof HTMLElement&&e.contains(document.activeElement)&&document.activeElement.blur()},t=t=>{let n=t.target;n&&!f.current?.contains(n)&&(n.closest(`[role='dialog'], [role='alertdialog'], [role='menu'], [role='listbox']`)||e())};return document.addEventListener(`pointerdown`,t,!0),window.addEventListener(`blur`,e),()=>{document.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`blur`,e)}},[p]),{open:p,flash:l,close:()=>{window.clearTimeout(o.current),r(!1)},handlers:{onPointerDown:d,onPointerEnter:e=>{f.current=e.currentTarget,e.pointerType!==`touch`&&s()},onPointerLeave:e=>{if(e.pointerType===`touch`)return;let t=e.currentTarget,n=document.activeElement;n instanceof HTMLElement&&t.contains(n)&&!n.matches(`:focus-visible`)&&!n.matches(`input, textarea`)&&(n.blur(),a(!1)),c()},onFocus:e=>{f.current=e.currentTarget,a(!0)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||a(!1)}}}}function B$({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,H.jsx)(`svg`,{...t,children:(0,H.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`})}):e===`tasks`?(0,H.jsxs)(`svg`,{...t,children:[(0,H.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,H.jsx)(`path`,{d:`M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11`})]}):e===`plan`?(0,H.jsxs)(`svg`,{...t,children:[(0,H.jsx)(`path`,{d:`M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3z`}),(0,H.jsx)(`path`,{d:`M9 3v15M15 6v15`})]}):e===`knowledge`?(0,H.jsxs)(`svg`,{...t,children:[(0,H.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 016.5 17H20`}),(0,H.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z`})]}):(0,H.jsxs)(`svg`,{...t,children:[(0,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,H.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`})]})}function V$({tabs:e,activeId:t,onSelect:n}){let r=(0,m.useRef)(null),i=(0,m.useRef)(null),a=(0,m.useRef)({}),[o,s]=(0,m.useState)(346),c=e.map(e=>e.label).join(`|`),[l,u]=(0,m.useState)({}),d=(0,m.useRef)(t),f=e.findIndex(e=>e.id===t);(0,m.useEffect)(()=>{d.current!==t&&(d.current=t,t&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches&&u(e=>({...e,[t]:(e[t]??0)+1})))},[t]),(0,m.useLayoutEffect)(()=>{let e=()=>s(i.current?Math.ceil(i.current.getBoundingClientRect().width):346);e(),document.fonts?.ready.then(e)},[c,t]);function p(r){if(r.key===`ArrowDown`&&!r.altKey){Zk()&&r.preventDefault();return}let i=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!i||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))+i+e.length)%e.length];$k.active=!0,$k.to=s.id,window.setTimeout(()=>{$k.active=!1,$k.to=void 0},3e3),n(s.id),a.current[s.id]?.focus({preventScroll:!0})}let h={"--wT":`${o}px`,"--hT":oZ(40)};return{vars:h,ghost:(0,H.jsx)(R$,{className:`cs-gt`,style:h}),bay:(0,H.jsxs)(`div`,{className:`cs-tbwrap`,style:h,children:[(0,H.jsx)(`div`,{ref:i,className:`cs-track cs-tsizer`,"aria-hidden":`true`,children:e.map(e=>(0,H.jsxs)(`span`,{className:`cs-tab`,"data-chosen":e.id===t?``:void 0,children:[(0,H.jsx)(`span`,{className:`cs-ti`}),(0,H.jsx)(`span`,{className:`cs-tl`,children:(0,H.jsx)(`span`,{children:e.label})})]},e.id))}),(0,H.jsx)(`div`,{className:`cs-tbx`,children:(0,H.jsx)(`div`,{className:`cs-tbo`,"data-none":t?void 0:``,children:(0,H.jsx)(`div`,{ref:r,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:p,className:`cs-track`,children:e.map((e,n)=>(0,H.jsxs)(`a`,{ref:t=>{a.current[e.id]=t},role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":e.id===t,"aria-keyshortcuts":e.key,"data-tip":e.label,"data-tip-keys":e.key,"data-tip-side":`bottom`,tabIndex:e.id===t||!t&&n===0?0:-1,className:`cs-tab`,"data-side":f<0||n===f?void 0:n<f?`l`:`r`,style:{"--i":n},children:[(0,H.jsx)(`span`,{className:`cs-ti`,children:(0,H.jsx)(I$,{id:e.id,play:l[e.id]??0,className:`size-4`})}),(0,H.jsx)(`span`,{className:`cs-tl`,children:(0,H.jsx)(`span`,{children:e.label})})]},e.id))})})})]})}}function H$({children:e}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(R$,{className:`cs-gr`}),(0,H.jsx)(`div`,{className:Y(`cs-rbx`),children:e})]})}var U$=(0,m.createContext)(()=>{});function W$({name:e,onRename:t,onArchive:n,onDelete:r,onOpenChange:i}){let a=(0,m.useContext)(U$),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1),u=gk(c,hk.confirm),d=(0,m.useRef)(!1),f=o||c;(0,m.useEffect)(()=>{a(f),i?.(f)},[f,a,i]),(0,m.useEffect)(()=>()=>a(!1),[a]);let p=()=>{l(!1),r?.()};lA(`y`,p,{enabled:c&&u,inDialog:!0});let h=[];t&&h.push({key:`R`,label:`Rename`,run:()=>{d.current=!0,t()}}),n&&h.push({key:`A`,label:`Archive`,run:n,rule:h.length>0}),r&&h.push({key:`D`,label:`Delete`,run:()=>l(!0),danger:!0,rule:h.length>0&&!n});let g=e=>{s(!1),window.setTimeout(e.run,0)};return(0,H.jsxs)(_V,{open:c&&u,onOpenChange:l,children:[(0,H.jsxs)(ZD,{open:o,onOpenChange:s,modal:!1,children:[(0,H.jsx)(QD,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`More for ${e}`,className:`cs-sact cs-smore`,children:(0,H.jsx)(ah,{"aria-hidden":`true`,className:`size-4`})})}),(0,H.jsx)($D,{children:(0,H.jsx)(eO,{align:`end`,side:`bottom`,sideOffset:6,collisionPadding:12,loop:!0,onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=h.find(t=>t.key.toLowerCase()===e.key.toLowerCase());t&&(e.preventDefault(),e.stopPropagation(),g(t))},onCloseAutoFocus:e=>{d.current&&e.preventDefault(),d.current=!1},className:`reui-menu cs-smenu`,children:h.map(e=>(0,H.jsxs)(`div`,{className:`contents`,children:[e.rule?(0,H.jsx)(nO,{className:`cs-smenu-rule`}):null,(0,H.jsxs)(tO,{className:`cs-smenu-item`,"data-danger":e.danger||void 0,"aria-keyshortcuts":e.key,onSelect:t=>{t.preventDefault(),g(e)},children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.jsx)(`kbd`,{className:`cs-smenu-key`,children:e.key})]})]},e.key))})})]}),(0,H.jsxs)(vV,{children:[(0,H.jsxs)(yV,{children:[(0,H.jsxs)(xV,{children:[`Delete `,e,`?`]}),(0,H.jsx)(SV,{children:`Its conversation file is removed for good. Archive it instead to keep it.`})]}),(0,H.jsxs)(bV,{children:[(0,H.jsxs)(wV,{children:[`Cancel`,(0,H.jsx)(ak,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,H.jsxs)(CV,{variant:`destructive`,onClick:p,children:[`Delete`,(0,H.jsx)(ak,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function G$(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 K$(e,t){let n=e?.sessionId,r={id:`here`,name:e?.sessionName?.trim()||`New session`,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:G$(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 q$=`app.sidebar.pinned`,J$=()=>FH(q$),Y$={w:288,h:`min(${oZ(600)}, calc(100vh - ${oZ(40)}))`},X$=`cs-iconbtn cs-sm`;function Z$(){let e=Vk(`status`).data,t=MV(`sessions.list`,{},[`sessions`]),n=x$();(0,m.useEffect)(()=>{t1=e?.sessionId,b$(e?.sessionId)},[e?.sessionId]);let r=K$(e,t.data);return n?n.id===Q$?r.map(e=>e.where===`here`?{...e,name:`New session`,state:`idle`,switching:!0,fresh:!0}:e):r.map(e=>e.id===n.id?{...e,state:`starting`,switching:!0}:e):r}var Q$=`new`,$$=()=>requestAnimationFrame(()=>document.getElementById(`composer-text`)?.focus());async function e1(){if(Dk(`#/lobby`),_$())return void W.info(`Still switching. One moment.`);v$({id:Q$,...t1?{from:t1}:{}}),$$();try{let{opened:e}=await R(`sessions.new`,{});e||y$()}catch(e){y$(),W.error(e instanceof Error?e.message:`Could not open a new session. Try again.`)}}var t1;async function n1(e){if(e.where===`here`)return Dk(`#/lobby`);if(e.where===`elsewhere`)return void W.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);if(_$())return void W.info(`Still switching. One moment.`);v$({id:e.id,...e.sessionId?{sessionId:e.sessionId}:{},...t1?{from:t1}:{}}),Dk(`#/lobby`);let t=await G(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId});(!t||!/switching this window/.test(t.notice))&&y$()}function r1(){return(0,m.useCallback)(n1,[])}var i1={entries:[]};async function a1(e){let t=i1.entries.filter(e=>e.where!==`elsewhere`),n=t.findIndex(e=>e.where===`here`);if(t.length<2||n<0)return void W.info(`No other session to switch to.`);i1.flash?.(),await n1(t[(n+e+t.length)%t.length])}function o1({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,H.jsxs)(`span`,{className:`cs-badge`,children:[(0,H.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,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,H.jsx)(`path`,{d:`M9.1 9a3 3 0 015.8 1c0 2-3 2.5-3 4M12 17h.01`})]}),e.waiting,(0,H.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,H.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,H.jsx)(Um,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,H.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,H.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var s1={here:`Current`,background:`Background`,elsewhere:`Other terminal`,saved:`Recent`};function c1(e){let t=e.key?{key:e.key}:{sessionId:e.sessionId};return G(`sessions.archive`,t,{undo:()=>void G(`sessions.archive`,{...t,archived:!1})})}function l1({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 G(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,H.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-7 w-full min-w-0 rounded-md bg-[var(--fill)] px-1.5 text-[14px] text-foreground outline-none ring-2 ring-ring`})}function u1({entry:e,index:t}){let n=r1(),[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},[d,f]=(0,m.useState)(!1);return(0,H.jsxs)(`li`,{className:`cs-srow session-item`,"data-fresh":e.fresh||void 0,"data-menu":d||void 0,"data-acts":l||void 0,children:[r?(0,H.jsx)(`div`,{className:`cs-sr`,"data-active":e.where===`here`||void 0,style:u,children:(0,H.jsx)(l1,{entry:e,onDone:()=>i(!1)})}):(0,H.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}`,...qz(e.name,{side:`right`}),"data-tip-trunc":``,"data-where":e.where,"data-state":e.state,"data-dim":a||void 0,"data-active":e.switching||void 0,"aria-busy":e.switching||void 0,onClick:()=>void n(e),onDoubleClick:e=>{o&&(e.preventDefault(),i(!0))},className:`cs-sr session-row`,style:u,children:[(0,H.jsx)(`span`,{className:`cs-grow`,children:e.name}),(0,H.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,l&&`cs-sstate`),children:(0,H.jsx)(o1,{entry:e})})]}),!r&&l?(0,H.jsx)(`span`,{className:`cs-sacts`,children:(0,H.jsx)(W$,{name:e.name,onOpenChange:f,...o?{onRename:()=>i(!0)}:{},...s?{onArchive:()=>void c1(e)}:{},...c?{onDelete:()=>void G(`sessions.delete`,{sessionId:e.sessionId})}:{}})}):null]})}function d1({id:e,label:t,entries:n,start:r,archivable:i=!1}){let[a,o]=IH(`app.sidebar.${e}`),s=(0,m.useId)();return n.length===0?null:(0,H.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,H.jsxs)(`div`,{className:`cs-sh`,style:{"--i":r},children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":!a,"aria-controls":s,onClick:o,className:`cs-shf flex flex-1 items-center gap-1.5 text-left`,children:[(0,H.jsx)(`span`,{children:t}),a?(0,H.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,H.jsx)(jm,{"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,H.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)await G(`sessions.archive`,e.key?{key:e.key}:{sessionId:e.sessionId})})(),className:`cs-shf shrink-0`,children:`Archive all`}):null]}),a?null:(0,H.jsx)(`ul`,{id:s,className:`flex flex-col`,children:n.map((e,t)=>(0,H.jsx)(u1,{entry:e,index:r+1+t},e.id))})]})}function f1(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${s1[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}var p1=(0,H.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,H.jsx)(`path`,{d:`M12 20h9`}),(0,H.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]});function m1({hint:e}){return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>void e1(),"aria-keyshortcuts":e,className:`cs-sr cs-snew`,style:{"--i":0},children:[p1,(0,H.jsx)(`span`,{className:`cs-grow`,children:`New session`}),(0,H.jsx)(ak,{chord:e,className:`cs-kbd-quiet`})]})}function h1({query:e,onQuery:t}){return(0,H.jsxs)(`label`,{className:`cs-sr cs-search`,style:{"--i":1},children:[(0,H.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,H.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,H.jsx)(`path`,{d:`M21 21l-4.3-4.3`})]}),(0,H.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(``))}})]})}function g1({query:e}){let t=Z$().filter(t=>f1(t,e)),n=[...t.filter(e=>e.where===`here`&&e.state!==`exited`),...t.filter(e=>e.where===`background`&&e.state!==`exited`)],r=t.filter(e=>e.where===`elsewhere`),i=t.filter(e=>e.where!==`elsewhere`&&e.state===`exited`),a=2,o=e=>{let t=a;return a+=e+1,t},s=o(n.length);return(0,H.jsxs)(`nav`,{"aria-label":`Sessions list`,className:`cs-sblist`,children:[t.length===0?(0,H.jsxs)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):null,n.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`cs-sh`,style:{"--i":s},children:`Sessions`}),(0,H.jsx)(`ul`,{className:`flex flex-col`,children:n.map((e,t)=>(0,H.jsx)(u1,{entry:e,index:s+1+t},e.id))})]}):null,(0,H.jsx)(d1,{id:`ended`,label:`Recent`,entries:i,start:o(i.length),archivable:!0}),(0,H.jsx)(d1,{id:`elsewhere`,label:`Other terminals`,entries:r,start:o(r.length)})]})}function _1({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,H.jsxs)(`div`,{className:`cs-sbfoot`,children:[(0,H.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,H.jsx)(B$,{id:`settings`}),(0,H.jsx)(`span`,{className:`cs-grow`,children:`Settings`}),(0,H.jsx)(ak,{chord:r})]}),(0,H.jsxs)(`div`,{className:`cs-sr cs-tools`,style:{"--i":21},children:[(0,H.jsx)($X,{hint:t.help??`Alt+H`,onHelp:n,className:X$}),(0,H.jsx)(eZ,{className:X$}),(0,H.jsx)(nZ,{className:X$}),(0,H.jsx)(rZ,{className:X$})]})]})}function v1(e){let[t,n]=IH(q$),r=z$(160,1600);i1.entries=Z$(),i1.flash=r.flash;let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=t||r.open||o,l={"--wL":oZ(c?Y$.w:122),"--hL":c?Y$.h:oZ(40),"--sb-open-h":Y$.h};return{open:c,pinned:t,ghost:(0,H.jsx)(R$,{className:`cs-gl`,style:l}),bay:(0,H.jsx)(`div`,{className:`cs-sbwrap`,style:l,...r.handlers,children:(0,H.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,className:`cs-sbx`,children:[(0,H.jsxs)(`div`,{className:`cs-sbmini`,inert:c,children:[(0,H.jsx)(`button`,{type:`button`,"aria-label":`Sessions`,"aria-pressed":t,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:`cs-iconbtn`,...qz(t?`Unpin sidebar`:`Pin sidebar`,{keys:e.keys.sidebar,side:`bottom`,keep:!0}),children:(0,H.jsx)(B$,{id:`lobby`})}),(0,H.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-keyshortcuts":e.keys.newSession,onClick:()=>void e1(),className:`cs-iconbtn`,...qz(`New session`,{keys:e.keys.newSession??`Alt+N`,side:`bottom`}),children:(0,H.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,H.jsx)(`path`,{d:`M12 20h9`}),(0,H.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})}),(0,H.jsx)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.route.kind===`settings`?`page`:void 0,className:`cs-iconbtn`,...qz(`Settings`,{keys:e.keys.settings??`Alt+S`,side:`bottom`}),children:(0,H.jsx)(B$,{id:`settings`})})]}),(0,H.jsxs)(`div`,{className:`cs-sbfull`,inert:!c,children:[(0,H.jsx)(m1,{hint:e.keys.newSession??`Alt+N`}),(0,H.jsx)(h1,{query:i,onQuery:a}),(0,H.jsx)(U$.Provider,{value:s,children:(0,H.jsx)(g1,{query:i})}),(0,H.jsx)(_1,{...e})]})]})})}}var y1=`modulepreload`,b1=function(e){return`/`+e},x1={},S1=function(e){return e.pathname.endsWith(`.css`)},C1=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=b1(t,n);let r=s(t);if(r.href in x1)return;x1[r.href]=!0;let i=S1(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`:y1,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)})},w1=(0,m.lazy)(()=>C1(()=>import(`./TerminalView-CHnFTGrB.js`),__vite__mapDeps([0,1,2,3]))),T1=`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 E1({hint:e,className:t}){let n=oK();return(0,H.jsx)(eB,{side:`top`,label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:iK,className:t,children:(0,H.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,H.jsx)(`path`,{d:`M4 17l6-6-6-6M12 19h8`})})})})}function D1(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await R(`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 O1({height:e,max:t}){let n=(0,m.useRef)(null);return(0,H.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":KG.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&&aK(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:()=>aK(KG.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),aK(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function k1({toggleKey:e}){let t=oK(),n=uK(),r=sK(),i=gk(t&&n,hk.sheet),{list:a,error:o,reload:s}=D1(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),_=pK();(0,m.useEffect)(()=>{_&&(l(_.id),s())},[_,s]),(0,m.useEffect)(()=>{let e=()=>p(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let v=(0,m.useCallback)(async()=>{d(!0);try{let e=await R(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){W.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),y=(0,m.useCallback)(async e=>{try{await R(`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 b=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){b.current=!1;return}!a||!a.available||a.terminals.length>0||b.current||u||(b.current=!0,v())},[t,a,u,v]);let x=t&&!n?Math.min(r,f):0;if((0,m.useEffect)(()=>{let e=document.documentElement;return x?e.style.setProperty(`--terminal-h`,`${x}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[x]),!t)return null;let S=(0,H.jsx)(A1,{list:a,error:o,terminals:h,shown:g,busy:u,popup:n,toggleKey:e,onPick:l,onStart:()=>void v(),onEnd:e=>void y(e),onReload:()=>void s()});return n?(0,H.jsx)(ck,{open:i,onOpenChange:e=>{e||rK(!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,H.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:S})}):(0,H.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,H.jsx)(O1,{height:Math.min(r,f),max:f}),S]})}function A1({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,H.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,H.jsx)(eB,{side:`top`,label:`New terminal`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:T1,children:(0,H.jsx)(_g,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,H.jsx)(eB,{side:`top`,label:`End this terminal`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:T1,children:(0,H.jsx)(qg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,H.jsx)(eB,{side:`top`,label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>lK(!a),className:T1,children:(0,H.jsx)(dg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,H.jsx)(eB,{side:`top`,label:`Hide terminal`,hint:o,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>rK(!1),className:T1,children:a?(0,H.jsx)(l_,{"aria-hidden":`true`,className:`size-3.5`}):(0,H.jsx)(jm,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,H.jsx)(H.Fragment,{children:e&&!e.available?(0,H.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,H.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,H.jsxs)(m.Suspense,{fallback:(0,H.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,H.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,H.jsx)(w1,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,H.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,H.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,H.jsx)(Vg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,H.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,H.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,H.jsx)(Vg,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,H.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,H.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var j1=(0,m.lazy)(()=>C1(()=>import(`./CodeSurface-B9IpRRpY.js`),__vite__mapDeps([4,1,2]))),M1=`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 N1({hint:e,className:t}){let{open:n}=UB();return(0,H.jsx)(eB,{side:`bottom`,label:`Code and changes`,hint:e,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?VB():BB(),className:t,children:(0,H.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,H.jsx)(`path`,{d:`M16 18l6-6-6-6M8 6l-6 6 6 6`})})})})}var P1={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 F1(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function I1({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,H.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,H.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,H.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function L1(){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 R1({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,H.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,H.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,H.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,H.jsx)(jg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,H.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,H.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,H.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,H.jsx)(I1,{change:l,className:`ml-auto`}),(0,H.jsx)(eB,{side:`bottom`,label:`Read the changes again`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y(M1,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,H.jsx)(yg,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,H.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}=F1(e.path),a=P1[e.status];return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),"aria-current":e.path===r?`true`:void 0,"data-tip":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,H.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,H.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,H.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,H.jsx)(I1,{change:e})]})},e.path)}),e&&!e.git?(0,H.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,H.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,H.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function z1(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 R(`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 B1({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=MV(`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:_}=z1(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=XB(),D=ZB(),O=L1(),k=f?.file,A=v!==void 0&&v!==k?.contents;(0,m.useEffect)(()=>a(A),[A,a]),(0,m.useEffect)(()=>{if(!e||e===c){t&&d(t);return}M({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)(()=>{k&&k.path!==c&&l(k.path)},[k?.path]),(0,m.useEffect)(()=>{o&&M({kind:`close`})},[o]);function j(e){if(T(void 0),C(!1),e.kind===`close`){i();return}y(void 0),l(e.path)}function M(e){(e.kind!==`open`||e.path!==c)&&(A?T(e):j(e))}async function N(e=!1){if(k&&v!==void 0&&!b){x(!0);try{let t=await R(`code.save`,{path:k.path,contents:v,mtimeMs:k.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&&j(w),!0}catch(e){return e instanceof be&&e.code===`conflict`?C(!0):W.error(e instanceof Error?e.message:`The file could not be saved.`),!1}finally{x(!1)}}}function ee(e){(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`s`?(e.preventDefault(),e.stopPropagation(),N()):r&&NX(e.nativeEvent,r)&&(e.preventDefault(),M({kind:`close`}))}let te=k?.change,P=!!te||k?.original!==void 0,ne=P?u:`code`,{dir:re,name:ie}=F1(k?.path??c??``),ae=!!(k?.exists&&k.contents!==void 0),oe=te?P1[te.status]:void 0;return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:ee,children:[(0,H.jsx)(R1,{changes:s.data,loading:s.loading,error:s.error,current:k?.path??c,onPick:e=>M({kind:`open`,path:e}),onRefresh:()=>{s.reload(),A||_()}}),(0,H.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,H.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[oe?(0,H.jsx)(`span`,{title:oe.word,className:Y(`font-mono text-xs font-semibold`,oe.tone),children:oe.letter}):(0,H.jsx)(dh,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:k?.path??c,children:[re?(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[re,`/`]}):null,(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:ie}),A?(0,H.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]}),te?(0,H.jsx)(I1,{change:te}):null]}):(0,H.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),P?(0,H.jsx)(Rk,{label:`View`,value:ne,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,ne===`diff`?(0,H.jsx)(eB,{side:`bottom`,label:D===`split`?`Unified diff`:`Side by side`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":D===`split`,onClick:()=>YB(D===`split`?`unified`:`split`),className:M1,children:D===`split`?(0,H.jsx)(Dg,{"aria-hidden":`true`,className:`size-4`}):(0,H.jsx)($m,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,H.jsx)(eB,{side:`bottom`,label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>JB(!E),className:M1,children:(0,H.jsx)(Gg,{"aria-hidden":`true`,className:`size-4`})})}),(0,H.jsx)(eB,{side:`bottom`,label:`Save`,hint:`Ctrl+S`,children:(0,H.jsxs)(ZO,{size:`sm`,variant:A?`default`:`outline`,disabled:!A||b,onClick:()=>void N(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,H.jsx)(kg,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,H.jsx)(eB,{side:`bottom`,label:`Close`,hint:r,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>M({kind:`close`}),className:M1,children:(0,H.jsx)(l_,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,H.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,H.jsx)(sg,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ie,` has unsaved edits.`]}),(0,H.jsx)(ZO,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,H.jsx)(ZO,{size:`xs`,variant:`outline`,onClick:()=>j(w),children:`Discard`}),(0,H.jsx)(ZO,{size:`xs`,onClick:()=>void N(),disabled:b,children:`Save`})]}):null,S?(0,H.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,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ie,` changed on disk since you opened it, maybe by an agent.`]}),(0,H.jsx)(ZO,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,H.jsx)(ZO,{size:`xs`,onClick:()=>void N(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,H.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,H.jsx)(`p`,{role:`alert`,className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:h}):c?k?k.binary||k.tooLarge?(0,H.jsx)(`p`,{className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:k.binary?`This is a binary file, so it is not shown.`:`This file is too large to show here.`}):!k.exists&&ne===`code`?(0,H.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,H.jsx)(yh,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,H.jsx)(m.Suspense,{fallback:(0,H.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,H.jsx)(j1,{path:k.path,version:`${f.version}`,contents:k.contents??``,draft:v,original:k.original,mode:ne,layout:D,wrap:E,dark:O,readOnly:!ae,onDraft:y})}):(0,H.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,H.jsx)(V1,{loading:s.loading})})]})]})}function V1({loading:e}){return(0,H.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,H.jsx)(ph,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,H.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 H1({codeKey:e}){let{open:t,path:n,mode:r,request:i}=UB(),a=gk(t,hk.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,H.jsx)(ck,{open:a,onOpenChange:e=>{e||(o?u():VB())},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,H.jsx)(B1,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:VB,onDirtyChange:s,closeAsked:c}):null})}function U1(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 W1(){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 Ce()?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(U1(e))}return(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,H.jsxs)(`form`,{onSubmit:s,className:`cs-dlg w-full max-w-[420px]`,children:[(0,H.jsxs)(`div`,{className:`cs-dh flex items-center gap-3.5 pt-[22px]`,children:[(0,H.jsx)(`span`,{className:`cs-drop`,"aria-hidden":`true`,children:(0,H.jsx)(jh,{className:`size-[18px]`})}),(0,H.jsx)(`h1`,{children:`Sign in to bot-lobby`})]}),(0,H.jsxs)(`div`,{className:`cs-db`,children:[(0,H.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,H.jsx)(`code`,{className:`cs-cd`,children:`/bot-lobby web`}),` to see it again). Paste it here.`]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:`Lobby link or token`}),(0,H.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,H.jsx)(`p`,{role:`alert`,className:`mt-2.5 text-[12.5px] text-[var(--bad)]`,children:n}):null]}),(0,H.jsxs)(`div`,{className:`cs-df`,children:[(0,H.jsx)(ZO,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,H.jsx)(ZO,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var G1=`plan:`,K1=`bot-lobby:plan-put-away`,q1=e=>e.startsWith(G1);function J1(){try{let e=JSON.parse(sessionStorage.getItem(K1)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`number`):[]}catch{return[]}}function Y1(e){let t=e?.messages.at(-1);if(e&&!e.busy&&t?.role===`planner`&&t.questions?.length)return{id:`${G1}${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 X1(e,t){let n=e.payload.questions??[];return(t.answers??[]).map(e=>`${XV(n[e.questionIndex]?.header??``)}: ${e.question} ${e.answer}`.trim()).join(`
|
|
116
|
+
`).map(e=>r$.measureText(e).width));t.style.setProperty(`--cg`,`${Math.ceil((r+aZ(44))/aZ(48))*aZ(48)}px`)},[i,me]),(0,m.useLayoutEffect)(()=>{M.current&&j.current&&(M.current.scrollTop=j.current.scrollTop)}),(0,m.useEffect)(()=>{let e=k.current,t=D.current;if(!e||!t)return;let n=document.documentElement,r=()=>{let r=e.getBoundingClientRect(),i=t.getBoundingClientRect().bottom,a=t.hasAttribute(`data-shrunk`)||e.closest(`.bubble`)?.hasAttribute(`data-morphing`),o=Math.ceil(i-r.top);if(a||(s$=o),n.style.setProperty(`--composer-h`,_||!y?`0px`:`${a?Math.max(s$,o):o}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 Me=(0,m.useCallback)(e=>{if(!b.current)return;let t=[...e],n=8-te.current.length;t.length>n&&W.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++n$}`,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`}]),lZ(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{W.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),Ne=(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)})},[]),Pe=o.some(e=>e.state===`uploading`),Fe=o.flatMap(e=>e.info?[e.info.id]:[]),Ie=(i.trim().length>0||Fe.length>0)&&!Pe&&!c,Le=(0,m.useCallback)(async()=>{if(!Ie||!b.current)return;l(!0);let e=Fe.length>0?Fe:void 0,t={text:i,...e?{attachments:e}:{}};try{let e=!0,n=C.id===`knowledge`&&/^\s*[/@]/.test(i);if(C.id===`oracle`||n){let e=await R(`lobby.send`,t);e.notice&&W(e.notice),e.open===`plan`?Dk(Ek(`plan`)):S===`knowledge`&&Dk(Ek(`lobby`))}else C.id===`knowledge`?(e=await G(`knowledge.ask`,t)!==void 0,e&&window.dispatchEvent(new CustomEvent(BA,{detail:i.trim()}))):e=C.id===`panel`?await G(`planner.send`,t)!==void 0:await G(`tasks.comment`,{taskId:C.taskId,...t})!==void 0;if(e){Np(`sent`),a(``);for(let e of te.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){W.error(e instanceof Error?e.message:`Could not send`)}finally{l(!1)}},[Ie,Fe,C,i,e,S]),Re=(0,m.useCallback)(async()=>{try{await R(`lobby.abort`,{})}catch(e){W.error(e instanceof Error?e.message:`Could not stop`)}},[]),ze=e=>{if(ue&&de&&!e.nativeEvent.isComposing){let t=F.indexOf(de);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=(t+(e.key===`ArrowDown`?1:-1)+F.length)%F.length;ae(F[n].id);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),Ae(de);return}if(e.key===`Escape`){e.preventDefault(),se(i);return}}if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),f?p(null):ce?qQ(!0):Qk();return}if(ce&&i$(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;je(r===`k`?dZ(a,n,i):uZ(a,n,i,r===`b`?`**`:r===`i`?`_`:"`"));return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=pZ(t.value,t.selectionStart);n&&(e.preventDefault(),je(n));return}if(e.key===`Backspace`&&t.value===``&&te.current.length>0){e.preventDefault(),Ne(te.current.at(-1).key);return}(i$(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),Le())},Be=e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),Me(t))},Ve=e=>{e.preventDefault(),d(!1),e.dataTransfer.files.length>0&&Me(e.dataTransfer.files)},He=h.data?.workspace.name??`bot-lobby`,Ue=h.data?.branch??h.data?.workspace.branch,We=v&&C.id===`oracle`,Ge=me?S===`knowledge`?`Ask what the agents know…`:`Write a message…`:ce?n.step?.typed?n.step.placeholder:`Pick an answer above`:We?`The orchestrator is working. Enter steers it…`:C.placeholder,Ke=e=>{p(null),e.current?.click()},qe=Te===`ask`?(0,H.jsx)(`div`,{ref:Ee,children:(0,H.jsx)(VQ,{drawer:n,onExpand:E})},`ask`):Te===`bar`?(0,H.jsx)(`div`,{ref:Ee,className:`bubble-pane p-1`,style:{width:`max-content`},children:(0,H.jsxs)(`div`,{className:`cs-pbar`,children:[I.answer?(0,H.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq cs-acc`,onMouseDown:e=>e.preventDefault(),onClick:()=>{qQ(!1),requestAnimationFrame(()=>j.current?.focus({preventScroll:!0}))},children:[(0,H.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,H.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`}),(0,H.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,H.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-accent)`,children:`Answer questions`}),(0,H.jsxs)(`span`,{className:`cs-ktag`,style:{"--k":`var(--primary)`},children:[n.left,` left`]})]}):null,I.plan?(0,H.jsxs)(`button`,{type:`button`,className:`bubble-row cs-pbq`,"aria-keyshortcuts":`V`,onMouseDown:e=>e.preventDefault(),onClick:()=>w?.(),children:[(0,H.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,H.jsx)(`path`,{d:`M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z`}),(0,H.jsx)(`path`,{d:`M14 3v5h5M9 13h6M9 17h4`})]}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`View plan`}),(0,H.jsx)(`span`,{className:`cs-kb`,children:`V`})]}):null]})},`bar`):Te===`suggest`?(0,H.jsx)(vQ,{listId:fe,items:ue?F:ke.current.items,triggerKind:ue&&le?le.kind:ke.current.kind,activeItemId:de?.id??null,onHighlightedItemChange:ae,onSelect:Ae},`suggest`):Te===`attach`?(0,H.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,H.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`24ms`},onClick:()=>Ke(N),children:[(0,H.jsx)(_h,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload a file…`})]}),(0,H.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`bubble-row`,style:{"--delay":`12ms`},onClick:()=>Ke(ee),children:[(0,H.jsx)(Dh,{"aria-hidden":`true`,className:`size-4 shrink-0 text-(--bubble-muted)`,strokeWidth:1.7}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-(--bubble-ink)`,children:`Upload an image…`})]}),(0,H.jsx)(`div`,{className:`h-px`}),(0,H.jsx)(`div`,{className:`flex h-7 items-center px-2 text-[11.5px] text-(--bubble-muted)`,children:`Or drop files on the composer`})]},`attach`):Te===`projects`?(0,H.jsx)(wZ,{projects:t,tab:S,onBrowse:()=>p(`browse`),onClose:()=>p(null)},`projects`):(0,H.jsx)(kZ,{tab:S,onClose:Se},`browse`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`cs-scrim`,"data-open":pe||void 0,"aria-hidden":`true`}),(0,H.jsx)(`div`,{id:`app-dock`,ref:D,"data-shrunk":me||void 0,onFocus:he,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,H.jsx)(BZ,{ref:O,open:be,size:we.current,"data-ask":ce?De?`mockups`:`text`:void 0,shrunk:me,morphing:ge,menu:qe,toasts:y,className:`composer-shell pointer-events-auto`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(f?(e.preventDefault(),Se()):ce&&(e.preventDefault(),qQ(!0)))},children:(0,H.jsxs)(`div`,{ref:k,className:`bubble-composer group/composer composer-box`,"data-dragging":u||void 0,"data-chat-composer-main-surface":`true`,onPointerDown:he,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:Ve,children:[(0,H.jsxs)(`div`,{ref:A,"data-chat-composer-surface":`true`,children:[(0,H.jsx)(Nu,{initial:!1,children:o.length>0?(0,H.jsx)(Qf.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,H.jsx)(o$,{file:e,onRemove:()=>Ne(e.key)},e.key))},`files`):null}),(0,H.jsxs)(`div`,{className:`bubble-field`,children:[(0,H.jsx)(aQ,{ref:M,text:i}),(0,H.jsx)(`textarea`,{ref:j,id:`composer-text`,"aria-label":C.label,...C.id===`oracle`?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":ue,"aria-controls":ue?fe:void 0}:{},...de?{"aria-activedescendant":pQ(fe,de.id)}:{},value:i,onChange:e=>{a(e.target.value),re(e.target.selectionStart),p(null)},onSelect:e=>re(e.currentTarget.selectionStart),onKeyDown:ze,onPaste:Be,onScroll:e=>{M.current&&(M.current.scrollTop=e.currentTarget.scrollTop)},placeholder:Ge,rows:1,className:`bubble-text bubble-input`}),(0,H.jsx)(UZ,{field:j,mirror:M,text:i})]}),(0,H.jsxs)(`div`,{"data-chat-composer-footer":`true`,className:`bubble-tools composer-tools`,children:[(0,H.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:()=>xe(`attach`),className:`bubble-iconbtn bubble-tip bubble-tool size-8 rounded-full`,style:{"--i":0},children:(0,H.jsx)(ag,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.7})}),(0,H.jsx)(`span`,{className:`bubble-tool flex min-w-0`,style:{"--i":1},children:(0,H.jsx)(CZ,{projects:t,name:He,branch:Ue,open:f===`projects`||f===`browse`,onToggle:()=>xe(`projects`)})}),(0,H.jsx)(`span`,{className:`flex-1`}),(0,H.jsx)(`span`,{className:`bubble-hints bubble-tool`,style:{"--i":2},"aria-hidden":`true`,children:ue?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(l$,{children:`↑`}),(0,H.jsx)(l$,{children:`↓`}),`choose`,(0,H.jsx)(l$,{children:`↵`}),`insert`]}):f?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(l$,{children:`Esc`}),`close`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(l$,{children:`Shift`}),(0,H.jsx)(l$,{children:`↵`}),`new line`]})}),(0,H.jsxs)(`span`,{"data-chat-composer-actions":`right`,className:`bubble-tool flex shrink-0 items-center gap-2`,style:{"--i":3},children:[We?(0,H.jsx)(sQ,{onStop:()=>void Re()}):null,(0,H.jsx)(cQ,{sending:c,disabled:!Ie,steering:We,onSend:()=>void Le()})]})]})]}),(0,H.jsx)(`input`,{ref:N,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),(0,H.jsx)(`input`,{ref:ee,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach images`,onChange:e=>{Me(e.target.files??[]),e.target.value=``}}),u?(0,H.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,H.jsx)(HQ,{drawer:n,at:ce?T:-1,onAt:E})]})}var f$=3e4,p$,m$=0,h$=new Set;function g$(){for(let e of h$)e()}function _$(){return p$}function v$(e){p$=e,window.clearTimeout(m$),m$=window.setTimeout(y$,f$),g$()}function y$(){p$&&(p$=void 0,window.clearTimeout(m$),g$())}function b$(e){p$&&e&&(e===p$.sessionId||p$.from&&e!==p$.from)&&y$()}function x$(){return(0,m.useSyncExternalStore)(e=>(h$.add(e),()=>h$.delete(e)),()=>p$)}var S$=.6;function C$(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:S$,...n}}}var w$=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function T$(e,t=0,n=1){return C$(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:S$,times:w$(t,n),ease:`easeInOut`},strokeOpacity:{duration:S$,times:w$(t,t+.02)}})}function E$(e,t){return C$(e,{scale:[0,0,1.3,1]},{times:w$(t,t+.18),ease:`easeOut`})}function D$(e,t,n=1.3){return C$(e,{scale:[1,1,n,1,1]},{times:[0,Math.max(t,.001),Math.min(t+.15,.9),Math.min(t+.35,.99),1],ease:`easeInOut`})}var O$=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function k$({play:e}){return(0,H.jsxs)(Qf.g,{style:O$(.1,.9),...C$(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,H.jsx)(`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}),[8,12,16].map((t,n)=>(0,H.jsx)(Qf.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...C$(e,{fillOpacity:[0,0,1,1,0],y:[0,0,-1.5,0,0]},{times:[0,.12+n*.12,.24+n*.12,.72,1]})},t))]})}function A$({play:e}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Qf.path,{d:`M13 5h8`,...T$(e,.15,.45)}),(0,H.jsx)(Qf.path,{d:`M13 12h8`,...T$(e,.3,.6)}),(0,H.jsx)(Qf.path,{d:`M13 19h8`,...T$(e,.45,.75)}),(0,H.jsx)(Qf.path,{d:`m3 17 2 2 4-4`,...T$(e,.35,.7)}),(0,H.jsx)(Qf.path,{d:`m3 7 2 2 4-4`,...T$(e,0,.35)})]})}function j$({play:e}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Qf.circle,{cx:6,cy:19,r:3,style:O$(),...D$(e,0)}),(0,H.jsx)(Qf.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...T$(e,.1,.7)}),(0,H.jsx)(Qf.circle,{cx:18,cy:5,r:3,style:O$(),...E$(e,.62)})]})}var M$=1.05;function N$(e,t){let n=e=>Math.min(t+e,.999);return C$(e,{scaleX:[1,1,.02,-1,-1,-1],skewY:[0,0,-14,0,0,0],y:[0,0,-1.2,0,0,0],strokeOpacity:[0,0,1,.9,0,0],fillOpacity:[0,0,.22,.14,0,0]},{duration:M$,times:[0,Math.max(t,.001),n(.17),n(.34),n(.4),1],ease:`easeInOut`})}function P$({play:e}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Qf.g,{style:O$(),...C$(e,{scaleX:[1,1.08,1.06,1],y:[0,-.6,-.4,0]},{duration:M$,times:[0,.15,.8,1],ease:`easeInOut`}),children:[(0,H.jsx)(`path`,{d:`M12 5v16`}),(0,H.jsx)(`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`})]}),e?[.06,.26,.46].map(t=>(0,H.jsx)(Qf.path,{d:`M12 6.4C13.6 5 15.6 4.4 18.6 4.5V16.6C15.6 16.5 13.6 17 12 18.4z`,fill:`currentColor`,strokeWidth:1.4,style:O$(0,.5),...N$(e,t)},t)):null]})}var F$={lobby:k$,tasks:A$,plan:j$,knowledge:P$};function I$({id:e,play:t,className:n}){let r=F$[e];return r?(0,H.jsx)(`svg`,{"aria-hidden":`true`,"data-tab-icon":e,"data-play":t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,className:Y(`overflow-visible`,n),children:(0,H.jsx)(r,{play:t})},t):null}function L$(){let e=(e,t)=>(0,H.jsxs)(`filter`,{id:e,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,H.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:t,result:`b`}),(0,H.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,H.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,H.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`rimA`}),(0,H.jsx)(`feGaussianBlur`,{in:`rimA`,stdDeviation:`0.6`,result:`rimB`}),(0,H.jsx)(`feComposite`,{in:`rimB`,in2:`shape`,operator:`in`,result:`rimC`}),(0,H.jsx)(`feFlood`,{style:{floodColor:`var(--hl)`},result:`hlc`}),(0,H.jsx)(`feComposite`,{in:`hlc`,in2:`rimC`,operator:`in`,result:`hl`}),(0,H.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,H.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`shA`}),(0,H.jsx)(`feGaussianBlur`,{in:`shA`,stdDeviation:`0.6`,result:`shB`}),(0,H.jsx)(`feComposite`,{in:`shB`,in2:`shape`,operator:`in`,result:`shC`}),(0,H.jsx)(`feFlood`,{style:{floodColor:`var(--sh)`},result:`shc`}),(0,H.jsx)(`feComposite`,{in:`shc`,in2:`shC`,operator:`in`,result:`sh`}),(0,H.jsxs)(`feMerge`,{children:[(0,H.jsx)(`feMergeNode`,{in:`shape`}),(0,H.jsx)(`feMergeNode`,{in:`sh`}),(0,H.jsx)(`feMergeNode`,{in:`hl`})]})]});return(0,H.jsx)(`svg`,{width:`0`,height:`0`,className:`absolute`,"aria-hidden":`true`,focusable:`false`,children:(0,H.jsxs)(`defs`,{children:[e(`cs-baylit`,3.5),e(`cs-worklit`,3.2),(0,H.jsxs)(`filter`,{id:`cs-bayedge`,x:`-20%`,y:`-35%`,width:`140%`,height:`170%`,colorInterpolationFilters:`sRGB`,children:[(0,H.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`3.5`,result:`b`}),(0,H.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,H.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`1.5`,result:`dn`}),(0,H.jsx)(`feComposite`,{in:`shape`,in2:`dn`,operator:`out`,result:`tS0`}),(0,H.jsx)(`feGaussianBlur`,{in:`tS0`,stdDeviation:`0.3`,result:`tS1`}),(0,H.jsx)(`feComposite`,{in:`tS1`,in2:`shape`,operator:`in`,result:`tS`}),(0,H.jsx)(`feFlood`,{style:{floodColor:`var(--ehl)`},result:`tc`}),(0,H.jsx)(`feComposite`,{in:`tc`,in2:`tS`,operator:`in`,result:`eh`}),(0,H.jsx)(`feOffset`,{in:`shape`,dx:`0`,dy:`-1`,result:`up`}),(0,H.jsx)(`feComposite`,{in:`shape`,in2:`up`,operator:`out`,result:`bS0`}),(0,H.jsx)(`feGaussianBlur`,{in:`bS0`,stdDeviation:`0.3`,result:`bS1`}),(0,H.jsx)(`feComposite`,{in:`bS1`,in2:`shape`,operator:`in`,result:`bS`}),(0,H.jsx)(`feFlood`,{style:{floodColor:`var(--esh)`},result:`bc`}),(0,H.jsx)(`feComposite`,{in:`bc`,in2:`bS`,operator:`in`,result:`es`}),(0,H.jsxs)(`feMerge`,{children:[(0,H.jsx)(`feMergeNode`,{in:`shape`}),(0,H.jsx)(`feMergeNode`,{in:`eh`}),(0,H.jsx)(`feMergeNode`,{in:`es`})]})]})]})})}function R$({className:e,style:t}){return(0,H.jsxs)(`div`,{className:e,"aria-hidden":`true`,style:t,children:[(0,H.jsx)(`div`,{className:`cs-layer cs-edge`,children:(0,H.jsx)(`div`,{className:`cs-bb`})}),(0,H.jsx)(`div`,{className:`cs-layer cs-fill`,children:(0,H.jsx)(`div`,{className:`cs-bb`})})]})}function z$(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);(0,m.useEffect)(()=>()=>u.current?.(),[]);let d=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}}},f=(0,m.useRef)(null),p=n||i;return(0,m.useEffect)(()=>{if(!p)return;let e=()=>{window.clearTimeout(o.current),r(!1),a(!1);let e=f.current;e&&document.activeElement instanceof HTMLElement&&e.contains(document.activeElement)&&document.activeElement.blur()},t=t=>{let n=t.target;n&&!f.current?.contains(n)&&(n.closest(`[role='dialog'], [role='alertdialog'], [role='menu'], [role='listbox']`)||e())};return document.addEventListener(`pointerdown`,t,!0),window.addEventListener(`blur`,e),()=>{document.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`blur`,e)}},[p]),{open:p,flash:l,close:()=>{window.clearTimeout(o.current),r(!1)},handlers:{onPointerDown:d,onPointerEnter:e=>{f.current=e.currentTarget,e.pointerType!==`touch`&&s()},onPointerLeave:e=>{if(e.pointerType===`touch`)return;let t=e.currentTarget,n=document.activeElement;n instanceof HTMLElement&&t.contains(n)&&!n.matches(`:focus-visible`)&&!n.matches(`input, textarea`)&&(n.blur(),a(!1)),c()},onFocus:e=>{f.current=e.currentTarget,a(!0)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||a(!1)}}}}function B$({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,H.jsx)(`svg`,{...t,children:(0,H.jsx)(`path`,{d:`M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z`})}):e===`tasks`?(0,H.jsxs)(`svg`,{...t,children:[(0,H.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,H.jsx)(`path`,{d:`M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11`})]}):e===`plan`?(0,H.jsxs)(`svg`,{...t,children:[(0,H.jsx)(`path`,{d:`M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3z`}),(0,H.jsx)(`path`,{d:`M9 3v15M15 6v15`})]}):e===`knowledge`?(0,H.jsxs)(`svg`,{...t,children:[(0,H.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 016.5 17H20`}),(0,H.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z`})]}):(0,H.jsxs)(`svg`,{...t,children:[(0,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,H.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`})]})}function V$({tabs:e,activeId:t,onSelect:n}){let r=(0,m.useRef)(null),i=(0,m.useRef)(null),a=(0,m.useRef)({}),[o,s]=(0,m.useState)(346),c=e.map(e=>e.label).join(`|`),[l,u]=(0,m.useState)({}),d=(0,m.useRef)(t),f=e.findIndex(e=>e.id===t);(0,m.useEffect)(()=>{d.current!==t&&(d.current=t,t&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches&&u(e=>({...e,[t]:(e[t]??0)+1})))},[t]),(0,m.useLayoutEffect)(()=>{let e=()=>s(i.current?Math.ceil(i.current.getBoundingClientRect().width):346);e(),document.fonts?.ready.then(e)},[c,t]);function p(r){if(r.key===`ArrowDown`&&!r.altKey){Zk()&&r.preventDefault();return}let i=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!i||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))+i+e.length)%e.length];$k.active=!0,$k.to=s.id,window.setTimeout(()=>{$k.active=!1,$k.to=void 0},3e3),n(s.id),a.current[s.id]?.focus({preventScroll:!0})}let h={"--wT":`${o}px`,"--hT":oZ(40)};return{vars:h,ghost:(0,H.jsx)(R$,{className:`cs-gt`,style:h}),bay:(0,H.jsxs)(`div`,{className:`cs-tbwrap`,style:h,children:[(0,H.jsx)(`div`,{ref:i,className:`cs-track cs-tsizer`,"aria-hidden":`true`,children:e.map(e=>(0,H.jsxs)(`span`,{className:`cs-tab`,"data-chosen":e.id===t?``:void 0,children:[(0,H.jsx)(`span`,{className:`cs-ti`}),(0,H.jsx)(`span`,{className:`cs-tl`,children:(0,H.jsx)(`span`,{children:e.label})})]},e.id))}),(0,H.jsx)(`div`,{className:`cs-tbx`,children:(0,H.jsx)(`div`,{className:`cs-tbo`,"data-none":t?void 0:``,children:(0,H.jsx)(`div`,{ref:r,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:p,className:`cs-track`,children:e.map((e,n)=>(0,H.jsxs)(`a`,{ref:t=>{a.current[e.id]=t},role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":e.id===t,"aria-keyshortcuts":e.key,"data-tip":e.label,"data-tip-keys":e.key,"data-tip-side":`bottom`,tabIndex:e.id===t||!t&&n===0?0:-1,className:`cs-tab`,"data-side":f<0||n===f?void 0:n<f?`l`:`r`,style:{"--i":n},children:[(0,H.jsx)(`span`,{className:`cs-ti`,children:(0,H.jsx)(I$,{id:e.id,play:l[e.id]??0,className:`size-4`})}),(0,H.jsx)(`span`,{className:`cs-tl`,children:(0,H.jsx)(`span`,{children:e.label})})]},e.id))})})})]})}}function H$({children:e}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(R$,{className:`cs-gr`}),(0,H.jsx)(`div`,{className:Y(`cs-rbx`),children:e})]})}var U$=(0,m.createContext)(()=>{});function W$({name:e,onRename:t,onArchive:n,onDelete:r,onOpenChange:i}){let a=(0,m.useContext)(U$),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1),u=gk(c,hk.confirm),d=(0,m.useRef)(!1),f=o||c;(0,m.useEffect)(()=>{a(f),i?.(f)},[f,a,i]),(0,m.useEffect)(()=>()=>a(!1),[a]);let p=()=>{l(!1),r?.()};lA(`y`,p,{enabled:c&&u,inDialog:!0});let h=[];t&&h.push({key:`R`,label:`Rename`,run:()=>{d.current=!0,t()}}),n&&h.push({key:`A`,label:`Archive`,run:n,rule:h.length>0}),r&&h.push({key:`D`,label:`Delete`,run:()=>l(!0),danger:!0,rule:h.length>0&&!n});let g=e=>{s(!1),window.setTimeout(e.run,0)};return(0,H.jsxs)(_V,{open:c&&u,onOpenChange:l,children:[(0,H.jsxs)(ZD,{open:o,onOpenChange:s,modal:!1,children:[(0,H.jsx)(QD,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`More for ${e}`,className:`cs-sact cs-smore`,children:(0,H.jsx)(ah,{"aria-hidden":`true`,className:`size-4`})})}),(0,H.jsx)($D,{children:(0,H.jsx)(eO,{align:`end`,side:`bottom`,sideOffset:6,collisionPadding:12,loop:!0,onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=h.find(t=>t.key.toLowerCase()===e.key.toLowerCase());t&&(e.preventDefault(),e.stopPropagation(),g(t))},onCloseAutoFocus:e=>{d.current&&e.preventDefault(),d.current=!1},className:`reui-menu cs-smenu`,children:h.map(e=>(0,H.jsxs)(`div`,{className:`contents`,children:[e.rule?(0,H.jsx)(nO,{className:`cs-smenu-rule`}):null,(0,H.jsxs)(tO,{className:`cs-smenu-item`,"data-danger":e.danger||void 0,"aria-keyshortcuts":e.key,onSelect:t=>{t.preventDefault(),g(e)},children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.jsx)(`kbd`,{className:`cs-smenu-key`,children:e.key})]})]},e.key))})})]}),(0,H.jsxs)(vV,{children:[(0,H.jsxs)(yV,{children:[(0,H.jsxs)(xV,{children:[`Delete `,e,`?`]}),(0,H.jsx)(SV,{children:`Its conversation file is removed for good. Archive it instead to keep it.`})]}),(0,H.jsxs)(bV,{children:[(0,H.jsxs)(wV,{children:[`Cancel`,(0,H.jsx)(ak,{chord:`Esc`,className:`kbd-hint ml-1`})]}),(0,H.jsxs)(CV,{variant:`destructive`,onClick:p,children:[`Delete`,(0,H.jsx)(ak,{chord:`Y`,className:`kbd-hint ml-1`})]})]})]})]})}function G$(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 K$(e,t){let n=e?.sessionId,r={id:`here`,name:e?.sessionName?.trim()||`New session`,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:G$(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 q$=`app.sidebar.pinned`,J$=()=>FH(q$),Y$={w:288,h:`min(${oZ(600)}, calc(100vh - ${oZ(40)}))`},X$=`cs-iconbtn cs-sm`;function Z$(){let e=Vk(`status`).data,t=MV(`sessions.list`,{},[`sessions`]),n=x$();(0,m.useEffect)(()=>{t1=e?.sessionId,b$(e?.sessionId)},[e?.sessionId]);let r=K$(e,t.data);return n?n.id===Q$?r.map(e=>e.where===`here`?{...e,name:`New session`,state:`idle`,switching:!0,fresh:!0}:e):r.map(e=>e.id===n.id?{...e,state:`starting`,switching:!0}:e):r}var Q$=`new`,$$=()=>requestAnimationFrame(()=>document.getElementById(`composer-text`)?.focus());async function e1(){if(Dk(`#/lobby`),_$())return void W.info(`Still switching. One moment.`);v$({id:Q$,...t1?{from:t1}:{}}),$$();try{let{opened:e}=await R(`sessions.new`,{});e||y$()}catch(e){y$(),W.error(e instanceof Error?e.message:`Could not open a new session. Try again.`)}}var t1;async function n1(e){if(e.where===`here`)return Dk(`#/lobby`);if(e.where===`elsewhere`)return void W.info(`${e.name} runs in another terminal. Switch to that terminal to work in it.`);if(_$())return void W.info(`Still switching. One moment.`);v$({id:e.id,...e.sessionId?{sessionId:e.sessionId}:{},...t1?{from:t1}:{}}),Dk(`#/lobby`);let t=await G(`sessions.switch`,e.key?{key:e.key}:{sessionId:e.sessionId});(!t||!/switching this window/.test(t.notice))&&y$()}function r1(){return(0,m.useCallback)(n1,[])}var i1={entries:[]};async function a1(e){let t=i1.entries.filter(e=>e.where!==`elsewhere`),n=t.findIndex(e=>e.where===`here`);if(t.length<2||n<0)return void W.info(`No other session to switch to.`);i1.flash?.(),await n1(t[(n+e+t.length)%t.length])}function o1({entry:e}){return e.where!==`elsewhere`&&e.state===`asking`?(0,H.jsxs)(`span`,{className:`cs-badge`,children:[(0,H.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,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,H.jsx)(`path`,{d:`M9.1 9a3 3 0 015.8 1c0 2-3 2.5-3 4M12 17h.01`})]}),e.waiting,(0,H.jsxs)(`span`,{className:`sr-only`,children:[e.waiting===1?` question`:` questions`,`, Waiting`]})]}):e.where!==`elsewhere`&&(e.state===`working`||e.state===`starting`)?(0,H.jsxs)(`span`,{className:Y(`inline-flex shrink-0`,e.state===`working`?`text-primary`:`text-muted-foreground`),children:[(0,H.jsx)(Um,{"aria-hidden":`true`,className:`session-spin size-3.5`}),(0,H.jsx)(`span`,{className:`sr-only`,children:e.state===`working`?`Working`:`Starting`})]}):(0,H.jsx)(`span`,{className:`sr-only`,children:e.where===`elsewhere`?`Other terminal`:e.state===`exited`?`Ended`:`Idle`})}var s1={here:`Current`,background:`Background`,elsewhere:`Other terminal`,saved:`Recent`};function c1(e){let t=e.key?{key:e.key}:{sessionId:e.sessionId};return G(`sessions.archive`,t,{undo:()=>void G(`sessions.archive`,{...t,archived:!1})})}function l1({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 G(`sessions.rename`,{...e.where===`here`?{}:{key:e.key},name:r}),t()};return(0,H.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-7 w-full min-w-0 rounded-md bg-[var(--fill)] px-1.5 text-[14px] text-foreground outline-none ring-2 ring-ring`})}function u1({entry:e,index:t}){let n=r1(),[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},[d,f]=(0,m.useState)(!1);return(0,H.jsxs)(`li`,{className:`cs-srow session-item`,"data-fresh":e.fresh||void 0,"data-menu":d||void 0,"data-acts":l||void 0,children:[r?(0,H.jsx)(`div`,{className:`cs-sr`,"data-active":e.where===`here`||void 0,style:u,children:(0,H.jsx)(l1,{entry:e,onDone:()=>i(!1)})}):(0,H.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}`,...qz(e.name,{side:`right`}),"data-tip-trunc":``,"data-where":e.where,"data-state":e.state,"data-dim":a||void 0,"data-active":e.switching||void 0,"aria-busy":e.switching||void 0,onClick:()=>void n(e),onDoubleClick:e=>{o&&(e.preventDefault(),i(!0))},className:`cs-sr session-row`,style:u,children:[(0,H.jsx)(`span`,{className:`cs-grow`,children:e.name}),(0,H.jsx)(`span`,{className:Y(`flex shrink-0 items-center`,l&&`cs-sstate`),children:(0,H.jsx)(o1,{entry:e})})]}),!r&&l?(0,H.jsx)(`span`,{className:`cs-sacts`,children:(0,H.jsx)(W$,{name:e.name,onOpenChange:f,...o?{onRename:()=>i(!0)}:{},...s?{onArchive:()=>void c1(e)}:{},...c?{onDelete:()=>void G(`sessions.delete`,{sessionId:e.sessionId})}:{}})}):null]})}function d1({id:e,label:t,entries:n,start:r,archivable:i=!1}){let[a,o]=IH(`app.sidebar.${e}`),s=(0,m.useId)();return n.length===0?null:(0,H.jsxs)(`section`,{"aria-label":t,className:`group/shelf flex flex-col`,children:[(0,H.jsxs)(`div`,{className:`cs-sh`,style:{"--i":r},children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":!a,"aria-controls":s,onClick:o,className:`cs-shf flex flex-1 items-center gap-1.5 text-left`,children:[(0,H.jsx)(`span`,{children:t}),a?(0,H.jsx)(`span`,{className:`tabular-nums`,children:n.length}):null,(0,H.jsx)(jm,{"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,H.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{for(let e of n)await G(`sessions.archive`,e.key?{key:e.key}:{sessionId:e.sessionId})})(),className:`cs-shf shrink-0`,children:`Archive all`}):null]}),a?null:(0,H.jsx)(`ul`,{id:s,className:`flex flex-col`,children:n.map((e,t)=>(0,H.jsx)(u1,{entry:e,index:r+1+t},e.id))})]})}function f1(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),r=`${e.name} ${s1[e.where]}`.toLowerCase();return n.every(e=>r.includes(e))}var p1=(0,H.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,H.jsx)(`path`,{d:`M12 20h9`}),(0,H.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]});function m1({hint:e}){return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>void e1(),"aria-keyshortcuts":e,className:`cs-sr cs-snew`,style:{"--i":0},children:[p1,(0,H.jsx)(`span`,{className:`cs-grow`,children:`New session`}),(0,H.jsx)(ak,{chord:e,className:`cs-kbd-quiet`})]})}function h1({query:e,onQuery:t}){return(0,H.jsxs)(`label`,{className:`cs-sr cs-search`,style:{"--i":1},children:[(0,H.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,H.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,H.jsx)(`path`,{d:`M21 21l-4.3-4.3`})]}),(0,H.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(``))}})]})}function g1({query:e}){let t=Z$().filter(t=>f1(t,e)),n=[...t.filter(e=>e.where===`here`&&e.state!==`exited`),...t.filter(e=>e.where===`background`&&e.state!==`exited`)],r=t.filter(e=>e.where===`elsewhere`),i=t.filter(e=>e.where!==`elsewhere`&&e.state===`exited`),a=2,o=e=>{let t=a;return a+=e+1,t},s=o(n.length);return(0,H.jsxs)(`nav`,{"aria-label":`Sessions list`,className:`cs-sblist`,children:[t.length===0?(0,H.jsxs)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`No sessions match “`,e.trim(),`”.`]}):null,n.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`cs-sh`,style:{"--i":s},children:`Sessions`}),(0,H.jsx)(`ul`,{className:`flex flex-col`,children:n.map((e,t)=>(0,H.jsx)(u1,{entry:e,index:s+1+t},e.id))})]}):null,(0,H.jsx)(d1,{id:`ended`,label:`Recent`,entries:i,start:o(i.length),archivable:!0}),(0,H.jsx)(d1,{id:`elsewhere`,label:`Other terminals`,entries:r,start:o(r.length)})]})}function _1({route:e,keys:t,onHelp:n}){let r=t.settings??`Alt+S`;return(0,H.jsxs)(`div`,{className:`cs-sbfoot`,children:[(0,H.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,H.jsx)(B$,{id:`settings`}),(0,H.jsx)(`span`,{className:`cs-grow`,children:`Settings`}),(0,H.jsx)(ak,{chord:r})]}),(0,H.jsxs)(`div`,{className:`cs-sr cs-tools`,style:{"--i":21},children:[(0,H.jsx)($X,{hint:t.help??`Alt+H`,onHelp:n,className:X$}),(0,H.jsx)(eZ,{className:X$}),(0,H.jsx)(nZ,{className:X$}),(0,H.jsx)(rZ,{className:X$})]})]})}function v1(e){let[t,n]=IH(q$),r=z$(160,1600);i1.entries=Z$(),i1.flash=r.flash;let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),c=t||r.open||o,l={"--wL":oZ(c?Y$.w:122),"--hL":c?Y$.h:oZ(40),"--sb-open-h":Y$.h};return{open:c,pinned:t,ghost:(0,H.jsx)(R$,{className:`cs-gl`,style:l}),bay:(0,H.jsx)(`div`,{className:`cs-sbwrap`,style:l,...r.handlers,children:(0,H.jsxs)(`aside`,{id:`app-sidebar`,"aria-label":`Sidebar`,className:`cs-sbx`,children:[(0,H.jsxs)(`div`,{className:`cs-sbmini`,inert:c,children:[(0,H.jsx)(`button`,{type:`button`,"aria-label":`Sessions`,"aria-pressed":t,"aria-keyshortcuts":e.keys.sidebar,onClick:n,className:`cs-iconbtn`,...qz(t?`Unpin sidebar`:`Pin sidebar`,{keys:e.keys.sidebar,side:`bottom`,keep:!0}),children:(0,H.jsx)(B$,{id:`lobby`})}),(0,H.jsx)(`button`,{type:`button`,"aria-label":`New session`,"aria-keyshortcuts":e.keys.newSession,onClick:()=>void e1(),className:`cs-iconbtn`,...qz(`New session`,{keys:e.keys.newSession??`Alt+N`,side:`bottom`}),children:(0,H.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,H.jsx)(`path`,{d:`M12 20h9`}),(0,H.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`})]})}),(0,H.jsx)(`a`,{href:`#/settings`,"aria-label":`Settings`,"aria-current":e.route.kind===`settings`?`page`:void 0,className:`cs-iconbtn`,...qz(`Settings`,{keys:e.keys.settings??`Alt+S`,side:`bottom`}),children:(0,H.jsx)(B$,{id:`settings`})})]}),(0,H.jsxs)(`div`,{className:`cs-sbfull`,inert:!c,children:[(0,H.jsx)(m1,{hint:e.keys.newSession??`Alt+N`}),(0,H.jsx)(h1,{query:i,onQuery:a}),(0,H.jsx)(U$.Provider,{value:s,children:(0,H.jsx)(g1,{query:i})}),(0,H.jsx)(_1,{...e})]})]})})}}var y1=`modulepreload`,b1=function(e){return`/`+e},x1={},S1=function(e){return e.pathname.endsWith(`.css`)},C1=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=b1(t,n);let r=s(t);if(r.href in x1)return;x1[r.href]=!0;let i=S1(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`:y1,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)})},w1=(0,m.lazy)(()=>C1(()=>import(`./TerminalView-BQ_vyCt-.js`),__vite__mapDeps([0,1,2,3]))),T1=`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 E1({hint:e,className:t}){let n=oK();return(0,H.jsx)(eB,{side:`top`,label:n?`Hide terminal`:`Terminal`,hint:e,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Terminal`,"aria-pressed":n,"aria-controls":n?`terminal-drawer`:void 0,"aria-keyshortcuts":e,onClick:iK,className:t,children:(0,H.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,H.jsx)(`path`,{d:`M4 17l6-6-6-6M12 19h8`})})})})}function D1(e){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(``),a=(0,m.useCallback)(async()=>{try{n(await R(`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 O1({height:e,max:t}){let n=(0,m.useRef)(null);return(0,H.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-label":`Resize terminal`,"aria-orientation":`horizontal`,"aria-valuenow":e,"aria-valuemin":KG.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&&aK(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:()=>aK(KG.start),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),aK(Math.min(t,e+(n.key===`ArrowUp`?24:-24))))}})}function k1({toggleKey:e}){let t=oK(),n=uK(),r=sK(),i=gk(t&&n,hk.sheet),{list:a,error:o,reload:s}=D1(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),_=pK();(0,m.useEffect)(()=>{_&&(l(_.id),s())},[_,s]),(0,m.useEffect)(()=>{let e=()=>p(Math.round(window.innerHeight*.7));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let v=(0,m.useCallback)(async()=>{d(!0);try{let e=await R(`terminal.open`,{cols:100,rows:24});l(e.id),await s()}catch(e){W.error(e instanceof Error?e.message:`The terminal did not start.`)}finally{d(!1)}},[s]),y=(0,m.useCallback)(async e=>{try{await R(`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 b=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!t){b.current=!1;return}!a||!a.available||a.terminals.length>0||b.current||u||(b.current=!0,v())},[t,a,u,v]);let x=t&&!n?Math.min(r,f):0;if((0,m.useEffect)(()=>{let e=document.documentElement;return x?e.style.setProperty(`--terminal-h`,`${x}px`):e.style.removeProperty(`--terminal-h`),()=>{e.style.removeProperty(`--terminal-h`)}},[x]),!t)return null;let S=(0,H.jsx)(A1,{list:a,error:o,terminals:h,shown:g,busy:u,popup:n,toggleKey:e,onPick:l,onStart:()=>void v(),onEnd:e=>void y(e),onReload:()=>void s()});return n?(0,H.jsx)(ck,{open:i,onOpenChange:e=>{e||rK(!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,H.jsx)(`div`,{id:`terminal-drawer`,className:`flex min-h-0 flex-1`,children:S})}):(0,H.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,H.jsx)(O1,{height:Math.min(r,f),max:f}),S]})}function A1({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,H.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,H.jsx)(eB,{side:`top`,label:`New terminal`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`New terminal`,disabled:i||e?.available===!1,onClick:c,className:T1,children:(0,H.jsx)(_g,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,H.jsx)(eB,{side:`top`,label:`End this terminal`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`End this terminal`,disabled:!r,onClick:()=>r&&l(r.id),className:T1,children:(0,H.jsx)(qg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,H.jsx)(eB,{side:`top`,label:a?`Back to the drawer`:`Open in a pop-up`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Pop out terminal`,"aria-pressed":a,onClick:()=>lK(!a),className:T1,children:(0,H.jsx)(dg,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px bg-border/80`}),(0,H.jsx)(eB,{side:`top`,label:`Hide terminal`,hint:o,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Hide terminal`,onClick:()=>rK(!1),className:T1,children:a?(0,H.jsx)(l_,{"aria-hidden":`true`,className:`size-3.5`}):(0,H.jsx)(jm,{"aria-hidden":`true`,className:`size-3.5`})})})]}),f=(0,H.jsx)(H.Fragment,{children:e&&!e.available?(0,H.jsx)(`p`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e.reason}):t?(0,H.jsx)(`p`,{role:`alert`,className:`flex h-full items-center justify-center px-6 text-center text-sm text-destructive`,children:t}):(0,H.jsxs)(m.Suspense,{fallback:(0,H.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading the terminal…`}),children:[e&&n.length===0&&!i?(0,H.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,H.jsx)(w1,{id:e.id,active:e.id===r?.id,toggleKey:o,onExit:u},e.id))]})}),p=n.length>1?(0,H.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,H.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,H.jsx)(Vg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.title}),e.alive?null:(0,H.jsx)(`span`,{className:`sr-only`,children:`, ended`})]},e.id))}):null;return a?(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,H.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border/70 pr-2 pl-4`,children:[(0,H.jsx)(Vg,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:`Terminal`}),d]}),(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1 py-2 pl-2`,children:(0,H.jsx)(`div`,{className:`relative h-full`,children:f})}),p]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f,(0,H.jsx)(`div`,{className:`pointer-events-none absolute top-2 right-2 z-20`,children:d})]}),p]})}var j1=(0,m.lazy)(()=>C1(()=>import(`./CodeSurface-raLMzkDq.js`),__vite__mapDeps([4,1,2]))),M1=`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 N1({hint:e,className:t}){let{open:n}=UB();return(0,H.jsx)(eB,{side:`bottom`,label:`Code and changes`,hint:e,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Code`,"aria-pressed":n,"aria-keyshortcuts":e,onClick:()=>n?VB():BB(),className:t,children:(0,H.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,H.jsx)(`path`,{d:`M16 18l6-6-6-6M8 6l-6 6 6 6`})})})})}var P1={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 F1(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t),name:e.slice(t+1)}}function I1({change:e,className:t}){return e.additions===void 0&&e.deletions===void 0?null:(0,H.jsxs)(`span`,{className:Y(`shrink-0 font-mono text-[0.6875rem] tabular-nums`,t),children:[(0,H.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,H.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions??0]})]})}function L1(){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 R1({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,H.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,H.jsx)(`form`,{onSubmit:u,className:`border-b border-border p-2`,children:(0,H.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,H.jsx)(jg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,H.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,H.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 px-3 text-xs`,children:[(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:`Changes`}),(0,H.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[c.length,e?.truncated?`+`:``]}),(0,H.jsx)(I1,{change:l,className:`ml-auto`}),(0,H.jsx)(eB,{side:`bottom`,label:`Read the changes again`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Refresh changes`,onClick:a,disabled:t,className:Y(M1,`-mr-1.5 size-6`,c.length?``:`ml-auto`),children:(0,H.jsx)(yg,{"aria-hidden":`true`,className:Y(`size-3.5`,t&&`animate-spin motion-reduce:animate-none`)})})})]}),(0,H.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}=F1(e.path),a=P1[e.status];return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),"aria-current":e.path===r?`true`:void 0,"data-tip":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,H.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,H.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,H.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:t}):null]}),(0,H.jsx)(I1,{change:e})]})},e.path)}),e&&!e.git?(0,H.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,H.jsx)(`li`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:`No changes since the last commit.`}):null,n?(0,H.jsx)(`li`,{role:`alert`,className:`px-2 py-3 text-xs text-destructive`,children:n}):null]})]})}function z1(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 R(`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 B1({requested:e,requestedMode:t,request:n,codeKey:r,onClose:i,onDirtyChange:a,closeAsked:o}){let s=MV(`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:_}=z1(c),[v,y]=(0,m.useState)(),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(),E=XB(),D=ZB(),O=L1(),k=f?.file,A=v!==void 0&&v!==k?.contents;(0,m.useEffect)(()=>a(A),[A,a]),(0,m.useEffect)(()=>{if(!e||e===c){t&&d(t);return}M({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)(()=>{k&&k.path!==c&&l(k.path)},[k?.path]),(0,m.useEffect)(()=>{o&&M({kind:`close`})},[o]);function j(e){if(T(void 0),C(!1),e.kind===`close`){i();return}y(void 0),l(e.path)}function M(e){(e.kind!==`open`||e.path!==c)&&(A?T(e):j(e))}async function N(e=!1){if(k&&v!==void 0&&!b){x(!0);try{let t=await R(`code.save`,{path:k.path,contents:v,mtimeMs:k.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&&j(w),!0}catch(e){return e instanceof be&&e.code===`conflict`?C(!0):W.error(e instanceof Error?e.message:`The file could not be saved.`),!1}finally{x(!1)}}}function ee(e){(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`s`?(e.preventDefault(),e.stopPropagation(),N()):r&&NX(e.nativeEvent,r)&&(e.preventDefault(),M({kind:`close`}))}let te=k?.change,P=!!te||k?.original!==void 0,ne=P?u:`code`,{dir:re,name:ie}=F1(k?.path??c??``),ae=!!(k?.exists&&k.contents!==void 0),oe=te?P1[te.status]:void 0;return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1`,onKeyDown:ee,children:[(0,H.jsx)(R1,{changes:s.data,loading:s.loading,error:s.error,current:k?.path??c,onPick:e=>M({kind:`open`,path:e}),onRefresh:()=>{s.reload(),A||_()}}),(0,H.jsxs)(`section`,{"aria-label":`File`,className:`flex min-w-0 flex-1 flex-col`,children:[(0,H.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border pr-2 pl-3`,children:[c?(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[oe?(0,H.jsx)(`span`,{title:oe.word,className:Y(`font-mono text-xs font-semibold`,oe.tone),children:oe.letter}):(0,H.jsx)(dh,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`h2`,{className:`min-w-0 truncate text-[0.8125rem]`,title:k?.path??c,children:[re?(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[re,`/`]}):null,(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:ie}),A?(0,H.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]}),te?(0,H.jsx)(I1,{change:te}):null]}):(0,H.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-muted-foreground`,children:`Code`}),P?(0,H.jsx)(Rk,{label:`View`,value:ne,onChange:d,items:[{id:`code`,label:`Code`},{id:`diff`,label:`Diff`}]}):null,ne===`diff`?(0,H.jsx)(eB,{side:`bottom`,label:D===`split`?`Unified diff`:`Side by side`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Side by side`,"aria-pressed":D===`split`,onClick:()=>YB(D===`split`?`unified`:`split`),className:M1,children:D===`split`?(0,H.jsx)(Dg,{"aria-hidden":`true`,className:`size-4`}):(0,H.jsx)($m,{"aria-hidden":`true`,className:`size-4`})})}):null,(0,H.jsx)(eB,{side:`bottom`,label:E?`Do not wrap lines`:`Wrap long lines`,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Wrap lines`,"aria-pressed":E,onClick:()=>JB(!E),className:M1,children:(0,H.jsx)(Gg,{"aria-hidden":`true`,className:`size-4`})})}),(0,H.jsx)(eB,{side:`bottom`,label:`Save`,hint:`Ctrl+S`,children:(0,H.jsxs)(ZO,{size:`sm`,variant:A?`default`:`outline`,disabled:!A||b,onClick:()=>void N(),"aria-keyshortcuts":`Control+S Meta+S`,children:[(0,H.jsx)(kg,{"aria-hidden":`true`}),b?`Saving…`:`Save`]})}),(0,H.jsx)(eB,{side:`bottom`,label:`Close`,hint:r,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`Close code viewer`,onClick:()=>M({kind:`close`}),className:M1,children:(0,H.jsx)(l_,{"aria-hidden":`true`,className:`size-4`})})})]}),w?(0,H.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,H.jsx)(sg,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ie,` has unsaved edits.`]}),(0,H.jsx)(ZO,{size:`xs`,variant:`ghost`,onClick:()=>T(void 0),children:`Keep editing`}),(0,H.jsx)(ZO,{size:`xs`,variant:`outline`,onClick:()=>j(w),children:`Discard`}),(0,H.jsx)(ZO,{size:`xs`,onClick:()=>void N(),disabled:b,children:`Save`})]}):null,S?(0,H.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,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ie,` changed on disk since you opened it, maybe by an agent.`]}),(0,H.jsx)(ZO,{size:`xs`,variant:`outline`,onClick:()=>{y(void 0),C(!1),_()},children:`Load theirs`}),(0,H.jsx)(ZO,{size:`xs`,onClick:()=>void N(!0),disabled:b,children:`Overwrite with mine`})]}):null,(0,H.jsx)(`div`,{className:`code-pane relative flex min-h-0 flex-1 flex-col`,children:h?(0,H.jsx)(`p`,{role:`alert`,className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:h}):c?k?k.binary||k.tooLarge?(0,H.jsx)(`p`,{className:`m-auto max-w-sm px-6 text-center text-sm text-muted-foreground`,children:k.binary?`This is a binary file, so it is not shown.`:`This file is too large to show here.`}):!k.exists&&ne===`code`?(0,H.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,H.jsx)(yh,{"aria-hidden":`true`,className:`size-5`}),`This file was deleted. Switch to Diff to see what it held.`]}):(0,H.jsx)(m.Suspense,{fallback:(0,H.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:`Loading code…`}),children:(0,H.jsx)(j1,{path:k.path,version:`${f.version}`,contents:k.contents??``,draft:v,original:k.original,mode:ne,layout:D,wrap:E,dark:O,readOnly:!ae,onDraft:y})}):(0,H.jsx)(`p`,{role:`status`,className:`m-auto text-xs text-muted-foreground`,children:g?`Opening…`:``}):(0,H.jsx)(V1,{loading:s.loading})})]})]})}function V1({loading:e}){return(0,H.jsxs)(`div`,{className:`m-auto flex max-w-xs flex-col items-center gap-2 px-6 text-center`,children:[(0,H.jsx)(ph,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,H.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 H1({codeKey:e}){let{open:t,path:n,mode:r,request:i}=UB(),a=gk(t,hk.help),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(0),u=()=>l(e=>e+1);return(0,H.jsx)(ck,{open:a,onOpenChange:e=>{e||(o?u():VB())},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,H.jsx)(B1,{requested:n,requestedMode:r,request:i,codeKey:e,onClose:VB,onDirtyChange:s,closeAsked:c}):null})}function U1(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 W1(){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 Ce()?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(U1(e))}return(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6`,children:(0,H.jsxs)(`form`,{onSubmit:s,className:`cs-dlg w-full max-w-[420px]`,children:[(0,H.jsxs)(`div`,{className:`cs-dh flex items-center gap-3.5 pt-[22px]`,children:[(0,H.jsx)(`span`,{className:`cs-drop`,"aria-hidden":`true`,children:(0,H.jsx)(jh,{className:`size-[18px]`})}),(0,H.jsx)(`h1`,{children:`Sign in to bot-lobby`})]}),(0,H.jsxs)(`div`,{className:`cs-db`,children:[(0,H.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,H.jsx)(`code`,{className:`cs-cd`,children:`/bot-lobby web`}),` to see it again). Paste it here.`]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:`Lobby link or token`}),(0,H.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,H.jsx)(`p`,{role:`alert`,className:`mt-2.5 text-[12.5px] text-[var(--bad)]`,children:n}):null]}),(0,H.jsxs)(`div`,{className:`cs-df`,children:[(0,H.jsx)(ZO,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void o(void 0),children:`Retry`}),(0,H.jsx)(ZO,{type:`submit`,disabled:i||!e.trim(),children:`Sign in`})]})]})})}var G1=`plan:`,K1=`bot-lobby:plan-put-away`,q1=e=>e.startsWith(G1);function J1(){try{let e=JSON.parse(sessionStorage.getItem(K1)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`number`):[]}catch{return[]}}function Y1(e){let t=e?.messages.at(-1);if(e&&!e.busy&&t?.role===`planner`&&t.questions?.length)return{id:`${G1}${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 X1(e,t){let n=e.payload.questions??[];return(t.answers??[]).map(e=>`${XV(n[e.questionIndex]?.header??``)}: ${e.question} ${e.answer}`.trim()).join(`
|
|
117
117
|
`)}function Z1(){let e=MV(`planner.get`,{},[`planner`]),[t,n]=(0,m.useState)(J1),r=Y1(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 R(`planner.send`,{text:X1(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(K1,JSON.stringify(n))}catch{}return n})},[])}}var Q1=2;function $1(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function e0(e){try{return JSON.parse(e)}catch{return}}function t0(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 n0(e,t=$1){let n=t(I(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===Q1?`offline`:`connecting`),n.onmessage=t=>{let n=e0(t.data);n&&t0(n,e)},()=>n.close()}var r0=2e3,i0=()=>R(`projects.list`,{});async function a0(){let e;try{e=fe()}catch{return}if(e&&!ve(e))try{_e((await i0()).projects)}catch{}}function o0(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{fe()}catch{F.onStatus({connection:`offline`});return}e.current=n0({onHello:e=>{F.onHello(e),a0()},onChanged:(e,t)=>F.onChanged(e,t),onFeed:e=>F.onFeedDelta(e),onReply:e=>F.onReplyDelta(e),onNotice:(e,t)=>W[t](e),onConnection:e=>{F.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{ye(i0).catch(()=>!1).finally(n)},r0))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var s0=`bot-lobby.recoveredAt`,c0;function l0(e,t=u0()){try{c0===void 0&&(c0=Number(t?.getItem(s0)??0))}catch{c0??=0}if(c0!==void 0&&e<=c0)return!1;c0=e;try{t?.setItem(s0,String(e))}catch{}return!0}function u0(){try{return globalThis.sessionStorage}catch{return}}function d0(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&l0(t)&&W.success(n)},[t,n])}function f0(){let e=Vk(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await R(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await R(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}var p0=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,H.jsxs)(`div`,{role:`alert`,className:`cs-pg cs-blank`,children:[(0,H.jsx)(`h2`,{children:`This page hit a snag`}),(0,H.jsx)(`p`,{children:e.message||String(e)}),(0,H.jsx)(`p`,{children:(0,H.jsx)(`button`,{type:`button`,className:`cs-kc`,onClick:()=>this.setState({error:void 0}),children:`Try again`})})]}):this.props.children}};function m0(e,t,n,r,i){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?Dk(`#/settings`):e===`thinking`?t.kind===`tab`&&t.tab===`lobby`?FH(`lobby.thinking`):Dk(Ek(`lobby`)):e===`nextSession`||e===`prevSession`?a1(e===`nextSession`?1:-1):e===`newSession`?e1():e===`sidebar`?i():e===`terminal`?iK():e===`code`?HB():e===`activity`?t.kind===`tab`&&t.tab===`lobby`?FH(LH):Dk(Ek(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&G(`planner.save`,{})}var h0=`cs-iconbtn cs-sq10`,g0=2500;function _0(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),g0);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function v0({connection:e,onRetry:t}){return _0(e)?(0,H.jsx)(`div`,{className:`cs-outage`,children:(0,H.jsx)(Mk,{onRetry:t})}):null}var y0={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{y0.route=++y0.tick}),document.addEventListener(`focusin`,()=>{y0.focus=++y0.tick});var b0=()=>y0.focus>y0.route;function x0(e){return e.kind===`tab`?e.tab:e.kind}function S0(){let e=Ok(),t=Vk(`status`);Vk(`lobby`);let{prompts:n,loading:r,answer:i,dismiss:a}=f0(),o=Z1(),s=(0,m.useMemo)(()=>[...n,...o.prompts],[n,o.prompts]),c=LQ(s,(0,m.useCallback)((e,t)=>q1(e)?o.answer(e,t):i(e,t),[i,o.answer]),(0,m.useCallback)(e=>q1(e)?o.dismiss(e):a(e),[a,o.dismiss])),{connection:l,signedOut:u}=Bk(),[d,f]=(0,m.useState)(!1),p=YQ();(0,m.useEffect)(()=>{s.length===0&&!r&&qQ(!1)},[s.length,r]);let h=(0,m.useRef)(null),g=o0();ZU();let _=t.data;d0(_);let v=!!_&&!u;(0,m.useEffect)(()=>{v&&Re()},[v]);let y=_?.tabs??[],b=_?.keys??[],x=e.kind===`tab`?e.tab:void 0,S=(0,m.useCallback)(e=>Dk(Ek(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&&Dk(Ek(n.id))},[y,x]),w=(0,m.useCallback)(()=>f(e=>!e),[]),T=gZ(),E=(0,m.useCallback)(()=>J$(),[]),D=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||_?.panels?.[t]!==!1)&&m0(t,Tk(window.location.hash)??e,w,C,E)},[e,w,C,E,_?.panels]),O=S,k=(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},[]);BX({enabled:!!_,keys:b,tabs:y,insideApp:k,onAction:D,onTab:O});let A=(0,m.useCallback)(()=>F.onHello({}),[]),j=e.kind===`tab`?e.tab:e.kind,M=!!_;(0,m.useEffect)(()=>{if(!M)return;let e=$k.active&&$k.to===j;if($k.active=!1,$k.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(b0()||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)},[j,M]);let N=Object.fromEntries(b.map(e=>[e.action,e.label])),ee=V$({tabs:y,activeId:x,onSelect:S}),te=v1({route:e,keys:N,onHelp:w});return u||!_?(0,H.jsxs)(`div`,{ref:h,className:`cs-frame`,children:[(0,H.jsx)(L$,{}),(0,H.jsx)(`main`,{id:`main`,tabIndex:-1,className:`cs-main`,children:u?(0,H.jsx)(W1,{}):t.error?(0,H.jsx)(jk,{message:t.error,onRetry:A}):(0,H.jsx)(Ak,{})}),(0,H.jsxs)(H$,{children:[(0,H.jsx)(tZ,{className:h0,side:`bottom`}),(0,H.jsx)(eZ,{className:h0,side:`bottom`})]})]}):(0,H.jsxs)(`div`,{ref:h,className:`cs-frame`,"data-sb":te.open?`open`:`closed`,"data-sbpin":te.pinned||void 0,"data-tb":`open`,children:[(0,H.jsx)(L$,{}),(0,H.jsxs)(`div`,{className:`cs-body`,children:[(0,H.jsx)(v0,{connection:l,onRetry:g}),(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,H.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||Uk(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||Qk()&&e.preventDefault()},role:x?`tabpanel`:void 0,"aria-labelledby":x?`tab-${x}`:void 0,className:`cs-main surface`,children:(0,H.jsx)(Qf.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,H.jsx)(p0,{children:DX(e)})},x0(e))}),(0,H.jsx)(p0,{fallback:(e,t)=>(0,H.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,H.jsx)(`button`,{type:`button`,className:`font-medium text-primary underline`,onClick:t,children:`Try again`})]}),children:(0,H.jsx)(d$,{route:e,projects:T,drawer:c,drawerOpen:s.length>0&&!p})})]}),(0,H.jsx)(k1,{toggleKey:N.terminal??"Ctrl+`"})]}),te.ghost,ee.ghost,(0,H.jsxs)(H$,{children:[(0,H.jsx)(N1,{hint:N.code,className:h0}),(0,H.jsx)(E1,{hint:N.terminal,className:h0})]}),te.bay,ee.bay,(0,H.jsx)(vZ,{projects:T}),(0,H.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`}),(0,H.jsx)(H1,{codeKey:b.find(e=>e.action===`code`)?.key}),(0,H.jsx)(EB,{}),(0,H.jsx)(ZX,{open:d,onOpenChange:f,keys:b,tabs:y})]})}async function C0(e){switch(e){case`status`:return R(`status.get`,{});case`lobby`:return R(`lobby.snapshot`,{});case`prompts`:return R(`prompts.list`,{});default:return}}var w0=[`status`,`lobby`,`prompts`];function T0(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await Ce(),e&&(F.markUsed(w0,C0),t(!0))})(),()=>{e=!1}},[]),e}function E0(){return T0()?(0,H.jsx)(S0,{}):(0,H.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,H.jsx)(Ak,{})})}var D0={info:`Note:`,success:`Done:`,warning:`Warning:`,error:`Error:`};function O0(){let{item:e,waiting:t}=Up(),n=vk(),r=qp(),i=e&&!n?e:void 0;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>Vp(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:i?`${D0[i.kind]} ${i.message}`:``}),(0,H.jsx)(k0,{enabled:!r})]})}function k0({enabled:e}){let t=FZ(e,`floor`);return t.item?(0,H.jsxs)(`div`,{className:`bubble toast-lone`,style:t.vars,children:[(0,H.jsx)(RZ,{id:`toast`}),(0,H.jsx)(`div`,{className:`bubble-layer bubble-edge`,"aria-hidden":`true`,children:(0,H.jsx)(IZ,{t})}),(0,H.jsx)(`div`,{className:`bubble-layer bubble-fill`,"aria-hidden":`true`,children:(0,H.jsx)(IZ,{t})}),(0,H.jsx)(`div`,{className:`bubble-real`,children:(0,H.jsx)(LZ,{t})})]}):null}(0,ip.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(m.StrictMode,{children:(0,H.jsx)(AW,{children:(0,H.jsxs)(Bu,{reducedMotion:`user`,children:[(0,H.jsx)(E0,{}),(0,H.jsx)(O0,{}),(0,H.jsx)(nB,{})]})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});export{I as i,NX as n,R as r,C1 as t};
|