offsite 0.0.36 → 0.0.38

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/image-viewer-4LhMaTO_.js","assets/jsx-runtime-DKj5X9O4.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/zoomable-image-CZlWBm_z.js","assets/button-BF3wjXXJ.js","assets/utils-PtDt7m8t.js","assets/tooltip-CiWlkHa6.js","assets/preview-dialog-jk_R2034.js","assets/dist-CwYFZY7g.js","assets/dist-CkDQKgh1.js","assets/preload-helper-BLdHbfdN.js","assets/video-viewer-CJ129jI3.js","assets/video-player-Bcow2OC5.js","assets/react-99wk3OSj.js","assets/audio-player-BBuXiV2_.js","assets/mermaid.core-BvdElKsv.js","assets/tags-DrTyXsO5.js","assets/chunk-7S6XSTFO-VvdR34BD.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-BbHDS76q.js","assets/chunk-DSNLSHJZ-Npz5XPWZ.js","assets/dist-B_J_HbC0.js","assets/chunk-OYAV6JZA-rT8O_-D6.js","assets/chunk-YZO67HFG-B_UXK566.js","assets/chunk-AQDTSKZB-DWCLLcEu.js","assets/chunk-UHW7PFBP-Cu9Ayl_R.js","assets/chunk-HAGFOTED-B1IVU9Z4.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-ZAUX2LTX-BaD-GxqC.js","assets/chunk-WQQL4CDK-BAxY1EoE.js","assets/line-QLqjjjjp.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/chunk-HNE4Q36P-ByoLUQMm.js","assets/chunk-EJLWFMJV-DyjKClu9.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-LNGE3PJU-Cz3NAIRA.js","assets/video-player-hDoAwJRk.js","assets/zoomable-image-DyuZJmov.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/image-viewer-4LhMaTO_.js","assets/jsx-runtime-DKj5X9O4.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/zoomable-image-CZlWBm_z.js","assets/button-BF3wjXXJ.js","assets/utils-PtDt7m8t.js","assets/tooltip-CiWlkHa6.js","assets/preview-dialog-jk_R2034.js","assets/dist-2-LcTRVV.js","assets/dist-CkDQKgh1.js","assets/preload-helper-BLdHbfdN.js","assets/video-viewer-CJ129jI3.js","assets/video-player-Bcow2OC5.js","assets/react-99wk3OSj.js","assets/audio-player-BBuXiV2_.js","assets/mermaid.core-BvdElKsv.js","assets/tags-DrTyXsO5.js","assets/chunk-7S6XSTFO-VvdR34BD.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-BbHDS76q.js","assets/chunk-DSNLSHJZ-Npz5XPWZ.js","assets/dist-B_J_HbC0.js","assets/chunk-OYAV6JZA-rT8O_-D6.js","assets/chunk-YZO67HFG-B_UXK566.js","assets/chunk-AQDTSKZB-DWCLLcEu.js","assets/chunk-UHW7PFBP-Cu9Ayl_R.js","assets/chunk-HAGFOTED-B1IVU9Z4.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-ZAUX2LTX-BaD-GxqC.js","assets/chunk-WQQL4CDK-BAxY1EoE.js","assets/line-QLqjjjjp.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/chunk-HNE4Q36P-ByoLUQMm.js","assets/chunk-EJLWFMJV-DyjKClu9.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-LNGE3PJU-Cz3NAIRA.js","assets/video-player-hDoAwJRk.js","assets/zoomable-image-DyuZJmov.js"])))=>i.map(i=>d[i]);
2
2
  import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.js";import{n as r,t as i}from"./jsx-runtime-DKj5X9O4.js";import{S as a,_ as o,a as s,b as c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,x as w}from"./button-BF3wjXXJ.js";import{A as T,C as E,D,E as O,O as k,S as A,T as ee,_ as j,a as M,b as te,c as ne,d as re,f as ie,g as ae,h as oe,i as se,k as ce,l as le,m as ue,n as de,o as fe,p as pe,r as me,s as he,u as ge,v as N,w as _e,x as ve,y as ye}from"./tags-DrTyXsO5.js";import{a as be,c as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,s as De,t as Oe}from"./tooltip-CiWlkHa6.js";import{C as ke,S as Ae,T as je,_ as Me,a as Ne,b as Pe,c as Fe,d as Ie,f as Le,g as Re,h as ze,i as Be,l as Ve,m as He,n as Ue,o as We,p as Ge,r as Ke,s as qe,t as Je,u as Ye,v as Xe,w as Ze,x as Qe,y as $e}from"./preview-dialog-jk_R2034.js";import{a as et,i as tt,n as nt,r as rt,t as P}from"./utils-PtDt7m8t.js";import{t as it}from"./preload-helper-BLdHbfdN.js";import{A as at,B as ot,C as st,D as ct,E as lt,F as ut,G as dt,H as ft,I as pt,J as mt,K as ht,L as gt,M as _t,N as vt,O as yt,P as bt,Q as xt,R as St,S as Ct,T as wt,U as Tt,V as Et,W as Dt,X as Ot,Y as kt,Z as At,g as jt,h as Mt,j as Nt,k as Pt,l as Ft,n as It,o as Lt,p as Rt,q as zt,t as Bt,w as Vt,x as Ht,z as Ut}from"./dist-CkDQKgh1.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=e(r(),1),Wt=F.useLayoutEffect;function Gt(e){return e[e.length-1]}function Kt(e,t){return typeof e==`function`?e(t):e}var qt=Object.prototype.hasOwnProperty;function Jt(e){for(let t in e)if(qt.call(e,t))return!0;return!1}var Yt=()=>Object.create(null),Xt=(e,t)=>Zt(e,t,!0);function Zt(e,t,n,r=0){if(e===t)return e;if(r++>500)return t;let i=Array.isArray(e)&&Array.isArray(t);if(!i&&!(Qt(e)&&Qt(t)))return t;let a=Object.keys(e),o=a.length,s=Object.keys(t),c=s.length;if(i?o!==e.length||c!==t.length||o&&Gt(a)!==`${o-1}`||c&&Gt(s)!==`${c-1}`:o!==Object.getOwnPropertyNames(e).length||c!==Object.getOwnPropertyNames(t).length||Object.getOwnPropertySymbols(t).length)return t;let l=0,u,d,f;if(i){for(;l<c&&(f=l,d=e[f],u=t[f],u=d===u?d:typeof d==`object`?Zt(d,u,n,r):u,u===d);l++);if(l===c&&o===c)return e}else{let i=o===c,p=!0;for(;l<c;l++){f=s[l],d=e[f];let o=t[f];u=d===o?d:typeof d==`object`?Zt(d,o,n,r):o,i&&=u===d&&(a[l]===f||qt.call(e,f)),p&&=Object.is(u,o),a[l]=u}if(i)return Object.getOwnPropertySymbols(e).length?t:e;if(p)return t}let p=i?s.fill(0):n?Yt():{};for(let o=0;o<c;o++)f=i?o:s[o],i?(d=e[f],o>l&&(u=t[f],u=d===u?d:typeof d==`object`?Zt(d,u,n,r):u),p[f]=o<l?d:u):p[f]=a[o];return p}function Qt(e){return!e||typeof e!=`object`?!1:(Object.getPrototypeOf(e)?.constructor??Object)===Object}function $t(e,t,n,r){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0,a=e.length;i<a;i++){let a=e[i],o=t[i];if(a!==o&&!$t(a,o,n,r))return!1}return!0}if(Qt(e)&&Qt(t)){if(n){for(let i in t)if((r||t[i]!==void 0)&&!$t(e[i],t[i],n,r))return!1;return!0}let i=0;if(r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;for(let a in t)if((r||t[a]!==void 0)&&(i--===0||!$t(e[a],t[a],n,r)))return!1;return i===0}return!1}var en=/[\x00-\x1f\x7f"<>`{}]/g;function tn(e){return e.replace(en,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function nn(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return tn(t)}var rn=[`http:`,`https:`,`mailto:`,`tel:`];function an(e){if(e[0]!==`/`&&e.includes(`:`))return/^[\x00-\x20]*([a-z][a-z\d+.\t\n\r-]*:)/i.exec(e)?.[1]?.replace(/[\t\n\r]/g,``).toLowerCase()}var on=/^[\x00-\x20]*[\\/][\t\n\r]*[\\/]/;function sn(e,t){if(!e)return!1;if(on.test(e))return!0;let n=an(e);return n?!t.has(n):!1}function cn(e){if(!e)return e;let t=e;if(/[%\\\x00-\x1f\x7f]/.test(e)){let n=/%25|%5C/gi,r=0,i;for(t=``;(i=n.exec(e))!==null;)t+=nn(e.slice(r,i.index))+i[0],r=n.lastIndex;t+=nn(r?e.slice(r):e)}return t}function ln(e){return/[\s\u0080-\uFFFF]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function un(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function dn(){throw Error(`Invariant failed`)}function fn(e){return e.replace(/\/{2,}/g,`/`)}function pn(e){return e===`/`?e:e.replace(/^\/+/,``)}function mn(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/+$/,``):e}function hn(e){return mn(pn(e))}function gn(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function _n(e,t,n=`never`,r){if(t.includes(`//`)&&(t=fn(t)),t.startsWith(`/`))return t.length===1||n===`preserve`?t:n===`always`?t.endsWith(`/`)?t:`${t}/`:t.endsWith(`/`)?t.slice(0,-1):t;let i=t===`.`,a;if(r){a=i?e:e+`\0`+t;let n=r.get(a);if(n)return n}let o;if(i)o=e.split(`/`);else{for(e.includes(`//`)&&(e=fn(e)),o=e.split(`/`);o.length>1&&Gt(o)===``;)o.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&o.push(r):o=[r]:r===`..`?o.length>1?o.pop():o=[``]:r===`.`||o.push(r)}}o.length>1&&(Gt(o)===``?n===`never`&&o.pop():n===`always`&&o.push(``));let s=o.join(`/`),c=(i?fn(s):s)||`/`;return a&&r&&r.set(a,c),c}function vn(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=new RegExp([...t.keys()].join(`|`).replace(/[.*()]/g,`\\$&`),`g`);return e=>e.replace(n,e=>t.get(e)??e)}function yn(e){return e==null||e===``}function bn(e,t,n){if(typeof t!=`string`)return``+(t??void 0);let r=e===`_splat`;if(r&&(!t||/^[a-zA-Z0-9\-._~!/]*$/.test(t)))return t;let i=encodeURIComponent(t);return r&&(i=i.replaceAll(`%2F`,`/`)),n?n(i):i}function xn(e,t,n,r,i){let a=e.endsWith(`/`)?`/`:``,o=``;for(let e of t){if(typeof e==`string`){o+=e;continue}let[t,s,c,l]=e,u=t===2,d=u&&l!==void 0?l+a:l,f=n[s];if(t!==3||f!=null){if(i&&(i[s]=f,u&&(i[`*`]=f)),u&&yn(f)){if(c===`/`&&!d)continue;f=``}o+=c+bn(s,f,r)+(d||``)}}return o+a||`/`}function Sn(e){return e?.isNotFound===!0}function Cn(){try{return sessionStorage}catch{return}}var wn=`tsr-scroll-restoration-v1_3`,Tn=Cn();function En(){try{return JSON.parse(Tn?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}var Dn=En(),On=`data-scroll-restoration-id`,kn=e=>e.state.__TSR_key||e.href;function An(e){let t=e.getAttribute(On);if(t)return`[${On}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var jn=!1,Mn=`window`;function Nn(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function Pn(e){let t=new Set;for(let n of e){if(n===Mn)continue;let e=Nn(n);e&&t.add(e)}return t}function Fn(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.e=!0);let i=e.options.getScrollRestorationKey||kn,a=new Set,o=e=>{let t=Dn[e]||={};for(let e of a)e===document?t[Mn]={scrollX,scrollY}:e.isConnected&&(t[An(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.s&&(r.s=!0,jn=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{jn||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{history.scrollRestoration=`auto`,o(i(e.stores.resolvedLocation.get()??e.stores.location.get()));try{Tn?.setItem(wn,JSON.stringify(Dn))}catch{}}),addEventListener(`pageshow`,e=>{e.persisted&&(history.scrollRestoration=`manual`)})),!r.r&&(r.r=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.n,c=r.h,l;if(a.clear(),r.n=!0,r.h=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.e&&d&&d!==u){let e=Dn[d];if(e){let t=Dn[u];for(let n in e){if(n===Mn){if(s)continue}else{let e=Nn(n);if(!e||s&&o&&(l??=Pn(o),l.has(e)))continue}t||=Dn[u]={},t[n]??=e[n]}}}jn=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=Pn(o));let t=e&&i&&c,s=r.e?Dn[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===Mn){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=Nn(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{jn=!1}}))}function In(e,t=String){let n;for(let r in e){let i=e[r];i!==void 0&&(n||=new URLSearchParams).set(r,t(i))}return n?n.toString():``}function Ln(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function Rn(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=Ln(r):Array.isArray(t)?t.push(Ln(r)):n[e]=[t,Ln(r)]}return n}var zn=/^(?:\s|["[{\d-]|fa|nu|tr)/,Bn=Hn(JSON.parse),Vn=Un(JSON.stringify,JSON.parse);function Hn(e){let t=e===JSON.parse;return n=>{n[0]===`?`&&(n=n.slice(1));let r=Rn(n);for(let n in r){let i=r[n];if(typeof i==`string`){if(t&&!zn.test(i))continue;try{r[n]=e(i)}catch{}}}return r}}function Un(e,t){let n=t===JSON.parse;function r(r){if(r&&typeof r==`object`)try{return e(r)}catch{}else if(t&&typeof r==`string`){if(n&&!zn.test(r))return r;try{return t(r),e(r)}catch{}}return r}return e=>{let t=In(e,r);return t?`?${t}`:``}}var Wn=`__root__`;function Gn(e){e.statusCode=e.statusCode||e.code||307;let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function Kn(e){return e instanceof Response&&!!e.options}function qn(e){let t=new Map,n,r;return{get(e){let n=t.get(e);if(n)return n.visited=!0,n.value},set(i,a){let o=t.get(i);if(o){o.value=a;return}if(t.size>=e){let e=n?.next().value;for(;!e||e.visited;)e?e.visited=!1:n=t.values(),e=n.next().value;e===r&&(n=void 0),t.delete(e.key)}let s={key:i,value:a,visited:!1};r=s,t.set(i,s)},clear(){t.clear(),n=void 0,r=void 0}}}var Jn=4,Yn=5;function Xn(e){let t=e.names;if(t)return t;let n=[];for(let t of e)typeof t!=`string`&&n.push(t[1]);return e.names=n}function Zn(e,t,n){let r=e.slice(t,n);if(r.charCodeAt(0)===36)return r.length===1?[2,`_splat`,``,void 0]:[1,r.slice(1),``,``];let i=r.indexOf(`{`);if(i>=0){let a=r.indexOf(`}`,i),o=r.charCodeAt(i+1)===45,s=i+(o?3:2);if(a>=0&&r.charCodeAt(s-1)===36&&(!o||s<a)){let c=r.slice(s,a);return[o?3:c?1:2,c||`_splat`,r.slice(0,i),e.slice(t+a+1,c?n:e.length)]}}return r}function Qn(e,t,n,r,i,a){let o=n,s=t.fullPath??t.from,c=t.options,l=s.length,u=s.endsWith(`/`)?l-1:l,d=c?.caseSensitive??e,f=c?.params?.parse??c?.parseParams,p,m=a?n-1:0;if(!r||s.includes(`$`)){p=a?.slice()??[];let e=Gt(p);e&&typeof e!=`string`&&e[0]===2&&(p[p.length-1]=[e[0],e[1],e[2],e[3]===void 0?void 0:e[3]+s.substring(n-(s[n-2]===`/`?2:1),u)],m=l)}for(;o<l;){let e=o,t=s.indexOf(`/`,e),n=t===-1?l:t,a=Zn(s,e,n);o=n+1;let c;if(typeof a==`string`){if(!r)continue;let e=a,t;d?t=r.static??=new Map:(e=a.toLowerCase(),t=r.staticInsensitive??=new Map);let n=t.get(e);if(n)c=n;else{let n=er(r);c=n,t.set(e,n)}}else{let t=a[0],h=a[2],g=a[3]??``;if(t===2&&(n=l,o=n+1),p&&m<n&&(m<e-1&&p.push(s.slice(m,e-1)),a[2]=`/`+h,t===2&&a[3]!==void 0&&u<l&&(a[3]=g.slice(0,-1)),p.push(a),m=n),!r)continue;let _=d&&!!(h||g);d||(h=h.toLowerCase(),g=g.toLowerCase());let v=t===1?r.dynamic??=[]:t===3?r.optional??=[]:r.wildcard??=[],y=t!==2&&!f&&v.find(e=>!e.parse&&e.caseSensitive===_&&e.prefix===h&&e.suffix===g);if(y)c=y;else{let e=er(r,t,_,h,g);c=e,v.push(e),v.length===2&&i?.push(v)}}r=c}p&&m<u&&p.push(s.slice(m,u));let h=p?.slice();if(!r)return h;if(f&&t.children&&!t.isRoot&&t.id&&t.id.charCodeAt(t.id.lastIndexOf(`/`)+1)===95){let e=er(r,Yn);(r.pathless??=[]).push(e),r=e}let g=(t.path||!t.children)&&!t.isRoot;if(g&&u<l){let e=er(r,Jn);r.index=e,r=e}return r.parse=f??null,r.priority=c?.params?.priority??0,r.route||(r.data=h,g&&(r.route=t)),[r,o,h]}function $n(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function er(e,t=0,n,r,i){return{kind:t,depth:e?e.depth+1:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,data:void 0,parent:e,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function tr(e,t){let n=er(),r=[];function i(e,t,n,a){let[o,s,c]=Qn(!1,e,t,n,r,a);if(e.children)for(let t of e.children)i(t,s,o,c)}for(let t of e)i(t,1,n);for(let e of r)e.sort($n);t.masksTree=n,t.flatCache=qn(1e3)}function nr(e,t){e||=`/`;let n=t.flatCache.get(e);if(n!==void 0)return n;let r=or(e,t.masksTree);return t.flatCache.set(e,r),r}function rr(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=er(),Qn(t,{from:e},1,o),i.singleCache.set(a,o)),or(r,o,n)}function ir(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=or(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=cr(a.route)),t.matchCache.set(r,a),a}function ar(e,t=!1){let n=er(),r=[],i={},a={},o=0;function s(e,n,c,l){if(e.init(o),e.id in i&&dn(),i[e.id]=e,o!==0&&e.path){let t=mn(e.fullPath);(!a[t]||e.fullPath.endsWith(`/`))&&(a[t]=e)}o++;let[u,d,f]=Qn(t,e,n,c,r,l);if(e._interpolation=f,e.children)for(let t of e.children)s(t,d,u,f)}s(e,1,n);for(let e of r)e.sort($n);return{processedTree:{segmentTree:n,singleCache:qn(1e3),matchCache:qn(1e3),flatCache:null,masksTree:null},routesById:i,routesByPath:a}}function or(e,t,n=!1){let r=e.split(`/`),i=ur(e,r,t,n);if(!i)return null;let[a]=sr(e,r,i);return{route:i.node.route,rawParams:a}}function sr(e,t,n){let r=lr(n.node),i=n.node.data&&Xn(n.node.data),a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.param??0;for(;s<r.length;o++,s++,c++){let u=r[s];if(u.kind===Jn)break;if(u.kind===Yn){o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1||u.kind===3){let e=i[l++];if(u.kind===3&&n.skipped&1<<s){o--,c=f-1;continue}let t=u.suffix||u.prefix?d.substring(u.prefix.length,d.length-u.suffix.length):d;(t||u.kind===1)&&(a[e]=decodeURIComponent(t))}else if(u.kind===2){let t=u,n=e.substring(f+t.prefix.length,e.length-t.suffix.length),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,param:l}]}function cr(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function lr(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function ur(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!Gt(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,statics:f,dynamics:p,optionals:m}=n,{extract:h,rawParams:g}=n;if(i.kind===2&&i.route&&!mr(l,n))continue;if(i.parse){if(!pr(e,t,n))continue;g=n.rawParams,h=n.extract}r&&i.route&&i.kind!==Jn&&mr(c,n)&&(c=n);let _=u===o;if(_&&(i.route&&(!a||i.kind===Jn||i.kind===2)&&mr(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let v=_?void 0:t[u],y;if(_&&i.index){let n={node:i.index,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g},r=!0;if(i.index.parse&&(pr(e,t,n)||(r=!1)),r){if(!p&&!m&&!d&&fr(f,o))return n;mr(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!r||!_&&(n.caseSensitive?v:y??=v.toLowerCase()).startsWith(r)){if(a){if(_)continue;let e=t.slice(u).join(`/`),i=e.slice(-a.length);if((n.caseSensitive?i:i.toLowerCase())!==a||e.length-a.length<r.length)continue}s.push({node:n,index:o,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(i.optional){let e=d|1<<i.depth+1;for(let t=i.optional.length-1;t>=0;t--){let n=i.optional[t];s.push({node:n,index:u,skipped:e,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_)for(let e=i.optional.length-1;e>=0;e--){let t=i.optional[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p,optionals:m+dr(o,u),extract:h,rawParams:g})}}if(!_&&i.dynamic&&v)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p+dr(o,u),optionals:m,extract:h,rawParams:g})}if(!_&&i.staticInsensitive){let e=i.staticInsensitive.get(y??=v.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,statics:f+dr(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_&&i.static){let e=i.static.get(v);e&&s.push({node:e,index:u+1,skipped:d,statics:f+dr(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(i.pathless)for(let e=i.pathless.length-1;e>=0;e--){let t=i.pathless[e];s.push({node:t,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function dr(e,t){return 2**(e-t-1)}function fr(e,t){return e===2**(t-1)-1}function pr(e,t,n){let r,i;try{[r,i]=sr(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function mr(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===Jn)>(e.node.kind===Jn)||t.node.kind===Jn==(e.node.kind===Jn)&&t.node.depth>e.node.depth)))}function hr(e,t,n){let r=hn(e),i=`/${r}`,a=t?i:i.toLowerCase(),o=`${a}/`,s={input:({url:e})=>{let n=t?e.pathname:e.pathname.toLowerCase();return n===a?e.pathname=`/`:n.startsWith(o)&&(e.pathname=e.pathname.slice(i.length)),e},output:({url:e})=>(e.pathname=fn(`/${r}${e.pathname}`),e)};return n?{input:({url:e})=>gr(n,s.input({url:e})),output:({url:e})=>s.output({url:_r(n,e)})}:s}function gr(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function _r(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function vr(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i}=t,a=new Map,o=n(`idle`),s=n(e),c=n(void 0),l=n([]),u=r(()=>l.get().map(e=>a.get(e).get())),d=r(()=>({status:o.get(),isLoading:o.get()===`pending`,matches:u.get(),location:s.get(),resolvedLocation:c.get()}));function f(e){let t=a.get(e);return t||(t=n(void 0),a.set(e,t)),t}let p={status:o,location:s,resolvedLocation:c,ids:l,matches:u,byRoute:a,__store:d,getMatchStore:f,setMatches:m};function m(e){let t=l.get(),n=e.map(e=>e.routeId);i(()=>{un(t,n)||l.set(n);for(let e of t)n.includes(e)||a.get(e).set(()=>void 0);for(let t of e){let e=f(t.routeId);e.get()!==t&&e.set(t)}})}return p}var yr=`__TSR_index`,br=`popstate`,xr=`beforeunload`,Sr=/^[\x00-\x20]*(?:[\\/][\t\n\r]*){2,}/;function Cr(e){let t=Sr.exec(e);return t?`/`+e.slice(t[0].length):e}function wr(e){return/[\x00-\x1f\x7f]/.test(e)&&(e=e.replace(/[\x00-\x1f\x7f]/g,e=>`
3
3
  \r`.includes(e)?``:encodeURIComponent(e))),Cr(e)}function Tr(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async n=>{let r=n.navigateOpts?.ignoreBlocker?void 0:e.getBlockers?.();if(typeof document<`u`&&r?.length&&(n.type===`PUSH`||n.type===`REPLACE`))for(let i of r){let r=Or(n.path,n.state);if(await i.blockerFn({currentLocation:t,nextLocation:r,action:n.type})){e.onBlocked?.();return}}n.task()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[yr];i=Er(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[yr];i=Er(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t,n?.ignoreBlocker??!1),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[yr]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r,_getBlockers:()=>e.getBlockers?.()??[]}}function Er(e,t){let n=kr();return{...t,key:n,__TSR_key:n,[yr]:e}}function Dr(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=t=>wr(e?.createHref?e.createHref(t):t),c=e?.parseLocation??(()=>Or(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=kr();t.history.replaceState({[yr]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_=()=>{g&&(S._ignoreSubscribers=!0,(g[2]?t.history.pushState:t.history.replaceState)(g[1],``,g[0]),S._ignoreSubscribers=!1,g=void 0,u=void 0)},v=(t,n,r)=>{let i=e?.createHref?s(n):void 0,a=!!g;a||(u=l),l=Or(n,r),g=[i??l.href,r,g?.[2]||t],a||queueMicrotask(()=>_())},y=e=>{l=c(),S.notify({type:e})},b=async()=>{if(m=!1,f){f=!1;return}let e=c(),n=e.state[yr]-l.state[yr],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let r=a();if(typeof document<`u`&&r.length){for(let i of r)if(await i.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(-n),S.notify(u);return}}}l=c(),S.notify(u)},x=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0||typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},S=Tr({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>v(!0,e,t),replaceState:(e,t)=>v(!1,e,t),back:e=>(e&&(p=!0,m=!0),t.history.back()),forward:e=>{e&&(p=!0,m=!0),t.history.forward()},go:(e,n)=>{d=!0,n&&(p=!0,m=!0),t.history.go(e)},createHref:s,flush:_,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(xr,x,{capture:!0}),t.removeEventListener(br,b)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return S._ignoreNextBeforeUnload=e=>{m=!1;try{e=new URL(e,t.document.baseURI).href,m=/^https?:/.test(e)&&(!e.includes(`#`)||e.split(`#`)[0]!==t.location.href.split(`#`)[0])}catch{}},t.addEventListener(xr,x,{capture:!0}),t.addEventListener(br,b),t.history.pushState=function(...e){let r=n.apply(t.history,e);return S._ignoreSubscribers||y(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return S._ignoreSubscribers||y(`REPLACE`),n},S}function Or(e,t){let n=wr(e),r=n.indexOf(`#`),i=n.indexOf(`?`);if(!t){let e=kr();t={[yr]:0,key:e,__TSR_key:e}}return{href:n,pathname:n.slice(0,r>-1?i>-1?Math.min(r,i):r:i>-1?i:n.length),hash:r>-1?n.slice(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t}}function kr(){return(Math.random()+1).toString(36).slice(7)}function Ar(e,t){return e.protocol!==`http:`&&e.protocol!==`https:`||e.origin!==t||!!e.username||!!e.password}function jr(e){return e.pathname+e.search+e.hash}function Mr(e){return e.options.loader||e.options.beforeLoad||e.lazyFn||e.options.component?.preload||e.options.pendingComponent?.preload}function Nr(e,t){return{fromLocation:t,toLocation:e,pathChanged:t?.pathname!==e.pathname,hrefChanged:t?.href!==e.href,hashChanged:t?.hash!==e.hash}}function Pr({key:e,__TSR_key:t,__TSR_index:n,__hashScrollIntoViewOptions:r,...i}){return i}function Fr(e){return e.findIndex(e=>e.status===`error`||e.status===`notFound`||e._notFound)+1}function Ir(e,t,n,r,i,a){r&&(t=t.slice(0,r)),i&&(n=n.slice(0,i));for(let r of t){if(a&&e._tx!==a)return;n.some(e=>e.routeId===r.routeId)||e.routesById[r.routeId].options.onLeave?.(r)}for(let r of n){if(a&&e._tx!==a)return;e.routesById[r.routeId].options[t.some(e=>e.routeId===r.routeId)?`onStay`:`onEnter`]?.(r)}}var Lr=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={n:!0},this.subscribers=new Set,this._cache=new Map,this._committed=[],this.startTransition=async e=>(e(),!1),this.update=e=>{let t=this.options;this.options={...t,...e},this.isServer=this.options.isServer??!1??typeof document>`u`,this.staticLocations=new WeakMap,this.protocolAllowlist=new Set(this.options.protocolAllowlist),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history?this.options.history:Dr()),this.origin=this.options.origin,this.origin||=window?.origin&&window.origin!==`null`?window.origin:`http://localhost`;let n=this.options.basepath??`/`,r=this.options.rewrite,i=this.basepath!==n||t?.rewrite!==r||t?.caseSensitive!==this.options.caseSensitive;if(i&&(this.basepath=n,this.rewrite=n!==`/`&&hn(n)?hr(n,this.options.caseSensitive,r):r),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;e=this.buildRouteTree(),this.setRoutes(e)}if(this.stores)i&&this.stores.location.set(this.latestLocation);else if(this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=vr(this.latestLocation,e),Fn(this)}},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=ar(this.routeTree,this.options.caseSensitive);return this.options.routeMasks&&tr(this.options.routeMasks,e.processedTree),{...e,resolvePathCache:qn(1e3)}},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{for(let t of this.subscribers)if(t.eventType===e.type)try{t.fn(e)}catch(e){console.error(e)}},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i},a)=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:cn(e),external:!1,searchStr:o,search:Xt(t?.search,i),hash:cn(r.slice(1)),state:Zt(t?.state,a)}}let o=gr(this.rewrite,new URL(i,this.origin)),s=this.options.parseSearch(o.search),c=this.options.stringifySearch(s);return o.search=c,{href:o.href.replace(o.origin,``),publicHref:i,pathname:cn(Cr(o.pathname)),external:!!this.rewrite&&Ar(o,this.origin),searchStr:c,search:Xt(t?.search,s),hash:cn(o.hash.slice(1)),state:Zt(t?.state,a)}},r=n(e,e.state),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i,{...i.state,__tempLocation:void 0,key:r.state.key,__TSR_key:r.state.__TSR_key});return e.maskedLocation=r,e}return r},this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>{let t=Object.create(null),n=ir(mn(e),this.processedTree,!0);return n&&Object.assign(t,n.rawParams),[n?.branch||[this.routesById.__root__],t,n?.route]},this.buildLocation=e=>{{let t=this.staticLocations.get(e);if(t)return t}let t=!1,n=(n={})=>{if(n.href){let e=Or(n.href,{});n={...n,to:gr(this.rewrite,new URL(e.pathname,this.origin)).pathname,search:this.options.parseSearch(e.search),hash:e.hash.slice(1)}}let r=e._fromLocation||this._pendingLocation||this.latestLocation,i,a=()=>(t=!0,r),o=()=>i??=this.matchRoutesLightweight(a()),s=n.to?`${n.to}`:`.`,c=_n(s[0]===`/`?``:n.unsafeRelative===`path`?a().pathname:n.from??o()[1],s,this.options.trailingSlash,this.resolvePathCache),l=this.routesByPath[mn(c)],u=c.includes(`$`),d;if(l)d=l._branch??=cr(l);else if(u)d=[];else{let[e,t,n]=this.getMatchedRoutes(c);d=e,this.options.notFoundRoute&&(!n||n.path!==`/`&&t[`**`])&&(d=[...d,this.options.notFoundRoute])}let f=u?l?._interpolation??Qn(!1,{fullPath:c},0):void 0,p;for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;if(t){let e=o()[3];if(p??=Hr(n.params,e),!Jt(p))break;p===e&&(p=Object.assign(Yt(),p));try{Object.assign(p,t(p))}catch{}}}p??=Hr(n.params,Ur(n.params,f)?o()[3]:Wr);let m=e.leaveParams?c:Cr(cn(f?xn(c,f,p,this.pathParamsDecoder):c)),h=Gr(d,e._includeValidateSearch),g=()=>{let t=o()[2];if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(n=>{if(n.options.validateSearch)try{Object.assign(e,Vr(n.options.validateSearch,{...e,...t}))}catch{}}),t=e}return t},_=h.length?Kr(h,g(),n):n.search===!0?g():typeof n.search==`function`?n.search(g()):n.search||Wr,v=this.options.stringifySearch(_),y=n.hash===!0?a().hash:typeof n.hash==`function`?n.hash(a().hash):n.hash||void 0,b=y?`#${y}`:``,x=n.state?n.state===!0?a().state:typeof n.state==`function`?n.state(a().state):n.state:Wr,S=`${m}${v}${b}`,C,w,T=!1;if(this.rewrite){let e=new URL(S,this.origin),t=e.origin,n=_r(this.rewrite,e);C=jr(e),Ar(n,t)?(w=n.href,T=!0):w=Cr(jr(n))}else C=ln(S),w=C;return{publicHref:w,href:C,pathname:m,search:_,searchStr:v,state:x,hash:y??``,external:T,unmaskOnReload:n.unmaskOnReload}},r=n(e);if(e.mask)r.maskedLocation=n({from:e.from,...e.mask});else if(this.options.routeMasks){let t=nr(r.pathname,this.processedTree);if(t){let i=Object.assign(Yt(),t.rawParams),{from:a,params:o,...s}=t.route,c=Hr(o,i);r.maskedLocation=n({from:e.from,...s,params:c})}}return!t&&e._fromLocation&&this.staticLocations.set(e,r),r},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r=n.maskedLocation??n;if(r.external)return Rr(this,r.publicHref,{replace:n.replace,ignoreBlocker:t});let i,a=mn(this.latestLocation.href)===mn(n.href)&&$t(Pr(n.state),Pr(this.latestLocation.state)),o=this._commitPromise,s,c=new Promise(e=>{s=e});if(c.resolve=()=>{s(),o?.resolve()},this._commitPromise=c,a)this.load();else{let{maskedLocation:r,hashScrollIntoView:a,...o}=n;r&&(o={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state={...o.state,__hashScrollIntoViewOptions:a??this.options.defaultHashScrollIntoView??!0},this.shouldViewTransition=e,i=n.replace?`REPLACE`:`PUSH`,this.history[i===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t}),this.history.subscribers.size||this.load({action:{type:i}})}return this._scroll.n=n.resetScroll??!0,this._commitPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,...a}={})=>{let o=this.buildLocation({...a,_includeValidateSearch:!0});this._pendingLocation=o;let s=this.commitLocation({...o,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this._pendingLocation===o&&(this._pendingLocation=void 0)}),s},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=n?an(n):void 0;if(a||t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i}),a=t.maskedLocation??t;n??=a.publicHref,r??=a.publicHref}let t=!a&&r?r:n;return Rr(this,t,i)}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.load=async e=>{this.updateLatestLocation(),e?.action&&(this._scroll.h=e.action.type===`PUSH`||e.action.type===`REPLACE`),await zi(this,e)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&window.CSS?.supports?.(`selector(:active-view-transition-type(a))`)){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(Nr(r,i)):t.types;if(a===!1)return e();n={update:e,types:a}}else n=e;return document.startViewTransition(n).updateCallbackDone}return e()},this.invalidate=e=>{let t=this._committed,n=e?.filter,r=this._preloads,i=new Set,a=e=>{(!n||n(e))&&i.add(e.id)};t.forEach(a),this._cache.forEach(a),r?.forEach(e=>e.forEach(a)),this._tx?.[3].forEach(a);let o=[];for(let[e,t]of r??[])t.some(e=>i.has(e.id))&&(r.delete(e),o.push(e));let s=t=>{if(i.has(t.id)){let n=this.routesById[t.routeId],r={...t,invalid:!0,...(e?.forcePending||t.status===`error`||t.status===`notFound`)&&Mr(n)?{status:`pending`,error:void 0}:void 0};return t._flight=void 0,r}return t};this._committed=t.map(s);for(let[t,n]of this._cache)i.has(t)&&(n.invalid=!0,e?.forcePending&&(n.status=`pending`));for(let e of i){let t=this._flights?.get(e);this._flights?.delete(e),t&&!t[2]&&o.push(t[1])}for(let e of o)e.abort();return this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{let t=e.options,n=e.headers.get(`Location`)||t.href;if(!n){let e=this.buildLocation(t);n=(e.maskedLocation??e).publicHref||`/`}let r;if(on.test(n)||(r=an(n))&&!this.protocolAllowlist.has(r))throw Error(`Redirect blocked: unsafe protocol`);if(r===`http:`||r===`https:`){let e=new URL(n);e.pathname.startsWith(`//`)?n=e.href:Ar(e,this.origin)||(n=jr(e),r=void 0)}return r&&(t.reloadDocument=!0),t.href=n,e.headers.set(`Location`,n),e},this.clearCache=e=>{let t=this._cache,n=this._preloads,r=e?.filter,i=[],a=[];for(let[e,n]of t)(!r||r(n))&&(a.push(e),i.push(n));let o=[];for(let[e,t]of n??[])(!r||t.some(r))&&(o.push(e),i.push(...t));for(let e of a)t.delete(e);for(let e of o)n.delete(e);for(let e of i){let t=e._flight;e._flight=void 0,t&&!--t[2]&&(this._flights?.get(e.id)===t&&this._flights.delete(e.id),o.push(t[1]))}for(let e of o)e.abort()},this.loadRouteChunk=Zr,this.preloadRoute=e=>Bi(this,e),this.matchRoute=(e,t)=>{let n={...e,to:e.to?_n(e.from||``,e.to,this.options.trailingSlash,this.resolvePathCache):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n),i=this.stores.status.get()===`pending`;if(t?.pending&&!i)return!1;let a=t?.pending??!i?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),o=rr(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,a.pathname,this.processedTree);return!o||e.params&&!$t(o.rawParams,e.params,!0)?!1:t?.includeSearch??!0?$t(a.search,r.search,!0)?o.rawParams:!1:o.rawParams},this.getStoreConfig=t,e.pathParamsAllowedCharacters?.length&&(this.pathParamsDecoder=vn(e.pathParamsAllowedCharacters)),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??Vn,parseSearch:e.parseSearch??Bn,protocolAllowlist:e.protocolAllowlist??rn}),self.__TSR_ROUTER__=this}isShell(){return!!this.options.isShell}get state(){return this.stores.__store.get()}setRoutes(e){Object.assign(this,e),this.lightweightCache=new WeakMap,this.staticLocations=new WeakMap;let t=this.options.notFoundRoute;t&&(t.init(99999999999),this.routesById[t.id]!==t&&(t._interpolation=Qn(!1,t,0)),this.routesById[t.id]=t)}matchRoutesInternal(e,t){let[n,r,i]=this.getMatchedRoutes(e.pathname),a=n,o=!1;(i?i.path!==`/`&&r[`**`]:mn(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?qr(this.options.notFoundMode,a):void 0,c=Array(a.length),l=this._committed,u=(e,t)=>{let n=l[t];return n?.routeId===e.id?n:e===this.options.notFoundRoute?l.find(t=>t.routeId===e.id):void 0},d;for(let n=0;n<a.length;n++){let i=a[n],o=c[n-1],l,f,p;{let n=o?.search??e.search,r=o?._strictSearch??void 0;try{let e=Vr(i.options.validateSearch,{...n})??void 0;l={...n,...e},f={...r,...e}}catch(e){let r=e;if(e instanceof zr||(r=new zr(e.message,{cause:e})),t?.throwOnError)throw r;l=n,f={},p=r}}let m=``,h=``;try{m=i.options.loaderDeps?.({search:l})??``,h=m&&JSON.stringify(m)||``}catch(e){if(t?.throwOnError)throw e;p??=e}let g=Yt(),_=i._interpolation?xn(i.fullPath,i._interpolation,r,this.pathParamsDecoder,g):i.fullPath,v=i.id+_+h,y=u(i,n),b=this._cache.get(v)??(y?.id===v?y:void 0);d=b?._strictParams??Object.assign(g,d);let x;if(!b)try{Jr(i,d)}catch(e){if(x=Sn(e)||Kn(e)?e:new Br(e.message,{cause:e}),t?.throwOnError)throw x}let S=y?`stay`:`enter`,C;if(b)C={...b,cause:S,search:Xt(y?y.search:b.search,l),_strictSearch:f,searchError:p};else{let e=Mr(i)?`pending`:`success`;C={id:v,ssr:i.options.ssr,index:n,routeId:i.id,params:y?.params??d,_strictParams:d,pathname:_,updatedAt:Date.now(),search:y?Xt(y.search,l):l,_strictSearch:f,searchError:p,status:e,isFetching:!1,error:void 0,paramsError:x,context:{},abortController:t?._controller??new AbortController,cause:S,loaderDeps:y?Zt(y.loaderDeps,m):m,invalid:!1,preload:!1,staticData:i.options.staticData||{},fullPath:i.fullPath}}let w=s===i.id;C._notFound&&!w&&(C.error=void 0),C._notFound=w,c[n]=C}for(let e=0;e<c.length;e++){let n=c[e];n.params=n.cause===`stay`?Xt(n.params,d):d,t?._controller&&(n.context={})}return c}matchRoutesLightweight(e){let t=Gt(this.stores.ids.get()),n=t?this.stores.byRoute.get(t).get():void 0,r=n?.id,i=this.lightweightCache.get(e);if(i&&i[0]===r)return i[1];let[a,o]=this.getMatchedRoutes(e.pathname),s=Gt(a),c={...e.search};for(let e of a)try{Object.assign(c,Vr(e.options.validateSearch,c))}catch{}let l=n&&n.routeId===s.id&&n.pathname===e.pathname,u;if(l)u=n.params;else{let e=o;for(let t of a)try{Jr(t,e)}catch{}u=e}let d=[a,s.fullPath,c,u];return this.lightweightCache.set(e,[r,d]),d}};async function Rr(e,t,{replace:n,ignoreBlocker:r}){if(!sn(t,e.protocolAllowlist)){if(!r){let t=e.history._getBlockers();for(let r of t)if(r?.blockerFn&&await r.blockerFn({currentLocation:e.history.location,nextLocation:e.history.location,action:n?`REPLACE`:`PUSH`}))return}e.history._ignoreNextBeforeUnload?.(t),n?window.location.replace(t):window.location.href=t}}var zr=class extends Error{},Br=class extends Error{};function Vr(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new zr(`Async validation not supported`);if(n.issues)throw new zr(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function Hr(e,t){if(e===void 0||e===!0)return t;let n=Object.create(null);return e===!1||e===null?n:typeof e==`function`?(Object.assign(n,t),Object.assign(n,e(n))):Object.assign(n,t,e)}function Ur(e,t){return typeof e==`function`?!0:!t||e===!1||e===null?!1:e===void 0||e===!0||t.some(t=>typeof t!=`string`&&!qt.call(e,t[1]))}var Wr=Object.freeze({});function Gr(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r].options;`search`in i?i.search?.middlewares&&n.push(...i.search.middlewares):(i.preSearchFilters||i.postSearchFilters)&&n.push(({search:e,next:t})=>{let n=t(i.preSearchFilters?i.preSearchFilters.reduce((e,t)=>t(e),e):e);return i.postSearchFilters?i.postSearchFilters.reduce((e,t)=>t(e),n):n});let a=i.validateSearch;t&&a&&n.push(({search:e,next:t,meta:n})=>{let r=t(e);try{let e=Vr(a,r);if(n&&e)for(let t in e)t in r||(n.defaulted||=new Map).set(t,e[t]);return{...r,...e}}catch{}return r})}return n}function Kr(e,t,n){let r=(t,i,a)=>{if(t>=e.length){if(!n.search)return{};if(n.search===!0)return i;let e=Kt(n.search,i);return a&&(a.explicit=e),e}return e[t]({search:i,next:(e,n)=>{if(n){let n=a||{};return{search:r(t+1,e,n),meta:n}}return r(t+1,e,a)},meta:a})};return r(0,t)}function qr(e,t){if(e!==`root`){let e;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.options.notFoundComponent)return r.id;e||=r.children&&r.id}if(e)return e}return Wn}function Jr(e,t){let n=e.options.params?.parse??e.options.parseParams;n&&Object.assign(t,n(t))}function Yr(e,t){return e.options[t]?.preload?.()}function Xr(e,t){let n=Yr(e,`component`),r=Yr(e,`pendingComponent`);return t&&(r?r=r.then(t):t()),n&&r?Promise.all([n,r]).then(()=>{}):n??r}function Zr(e,t,n){let r=()=>t===!1?void 0:t?Yr(e,t):Xr(e,n),i=e._lazy;if(i)return i===!0?r():i.then(r);if(!e.lazyFn)return r();let a=e.lazyFn().then(t=>{{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazy=!0}},t=>{throw e._lazy=void 0,t});return e._lazy=a,a.then(r)}function Qr(e){let t=e.findIndex(e=>e.status!==`success`||e._notFound)+1;return t&&t<e.length?e.slice(0,t):e}function $r(e,t,n){let r=e._tx;return t&&r?.[2]===n&&!r[3].some(e=>e.routeId===t)}var ei=0,ti=1,ni=2,ri=3,ii=[4];function ai(e){return typeof e[0]==`number`}function oi(e,t){return t.aborted?Promise.race([Promise.reject(t),e]):new Promise((n,r)=>{let i=()=>r(t);t.addEventListener(`abort`,i,{once:!0}),Promise.resolve(e).then(n,r).then(()=>t.removeEventListener(`abort`,i))})}function si(e,t){return e.routesById[t.routeId]}function ci(e,t,n){return Kn(e)?[ri,e]:Sn(e)?(e.routeId||=n,[ni,e]):t?(typeof e?.then==`function`&&(e=Error(`A Promise was thrown`,{cause:e})),[ti,e]):[ei,e]}function li(e,t){let n=ci(t,!0,e.id);if(n[0]!==ti)return n;try{e.options.onError?.(n[1])}catch(t){n=ci(t,!0,e.id)}return n}function ui(e,t,n,r,i){return i[0].signal.aborted?ii:Ei(e,t,n,li(n,r),i)}async function di(e,t,n,r,i,a){let[o,s]=t,c=n[0].signal,l=!!n[3];for(let i=n[6]??0;i<r;i++){let r=s[i],u=si(e,r);r.abortController=n[0];let d=s[i-1]?.context??e.options.context??{},f={params:r.params,location:o,navigate:t=>e.navigate({...t,_fromLocation:o}),buildLocation:e.buildLocation,cause:l?`preload`:r.cause,abortController:n[0],preload:l,matches:s,routeId:u.id};try{let e=r._ctx||=u.options.context?u.options.context({...f,deps:r.loaderDeps,context:d})||{}:void 0;r.context={...d,...e}}catch(a){return pi(e,r),[i,ui(e,t,u,a,n)]}if(c.aborted)return[i,ii];let p=r.paramsError??r.searchError;if(p!==void 0)return pi(e,r),[i,ui(e,t,u,p,n)];let m=u.options.beforeLoad;if(!m)continue;let h=r.status;i>=a&&(r.status=`pending`,n[7]?.());try{gi(e,r,`beforeLoad`,n[0]);let a=m({...f,search:r.search,context:r.context,...e.options.additionalContext}),o=await(typeof a?.then==`function`?oi(a,c):a);if(c.aborted)return[i,ii];let s=Ei(e,t,u,ci(o,!1,u.id),n);if(s[0]!==ei)return pi(e,r),[i,s];r.context={...r.context,...o}}catch(a){return pi(e,r),[i,ui(e,t,u,a,n)]}finally{r.status=h,gi(e,r,!1,n[0])}}i()}function fi(e,t,n){if(!(!n||--n[2])){if(e._flights?.get(t.id)===n){let n=e._tx;if(n&&!n[0].signal.aborted&&!n[3].includes(t)&&n[3].some(e=>e.id===t.id)&&n[3].some(e=>e.isFetching===`beforeLoad`))return;e._flights.delete(t.id)}return n[1]}}function pi(e,t){let n=t._flight;t._flight=void 0,fi(e,t,n)?.abort()}function mi(e,t,n,r){let i=[];for(let a of t)if(!n?.includes(a)){let t=a._flight;if(a._flight=void 0,r&&t?.[2]===1&&e._flights?.get(a.id)===t&&n?.some(e=>e.id===a.id))t[2]=0;else{let n=fi(e,a,t);n&&i.push(n)}}for(let e of i)e.abort()}function hi(e){for(let t of e){let e=t._flight;e&&e[2]++}}function gi(e,t,n,r){if(t.isFetching=n,r&&e._tx?.[0]!==r)return;let i=e.stores.byRoute.get(t.routeId),a=i?.get();a?.id===t.id&&i.set({...a,isFetching:n})}function _i(e,t,n,r,i,a,o){let s=t[0];return{params:n.params,location:s,navigate:t=>e.navigate({...t,_fromLocation:s}),cause:o?`preload`:n.cause,abortController:i,preload:o,deps:n.loaderDeps,parentMatchPromise:a,context:n.context,route:r,...e.options.additionalContext}}async function vi(e,t,n,r,i,a,o){let s=o[0],c=s.signal;if(c.aborted)return ii;if(!i)return[ei,void 0];let l=n._flight;gi(e,n,`loader`,s);try{if(!l){let s=new AbortController;l=[Promise.resolve().then(()=>i(_i(e,t,n,r,s,a,!!o[3]))).then(e=>ci(e,!1,r.id),e=>ci(e,!0,r.id)).then(t=>(t[0]!==ei&&e._flights?.get(n.id)===l&&(e._flights.delete(n.id),l[2]||s.abort()),t[0]===ti&&l[2]?li(r,t[1]):t)),s,1],(e._flights??=new Map).set(n.id,l)}return n._flight=l,n.abortController=l[1],Ei(e,t,r,await oi(l[0],c),o)}catch(t){if(t!==c||!c.aborted)throw t;return pi(e,n),ii}finally{gi(e,n,!1,s)}}function yi(e,t,n){t[0]!==ri&&(e.status=`success`,e.error=void 0,t[0]===ei?(e.loaderData=t[1],e.invalid=!1,e.updatedAt=Date.now(),e.preload=n):e.invalid=!0)}function bi(e,t,n){let r=e._cache.get(t.id);if(r!==n||e._committed.some(e=>e.id===t.id&&e._flight===t._flight))return;let i={...t,_notFound:void 0,context:{}};i._flight&&i._flight[2]++,e._cache.set(t.id,i),r&&pi(e,r)}function xi(e,t){return t[0]===ti||t[0]===ni?{...e,status:t[0]===ti?`error`:`notFound`,error:t[1],_flight:void 0}:e}function Si(e,t,n,r,i,a,o){let s=t[1][n],c=si(e,s),l=!!a[3],u=e._cache.get(s.id),d,f=!1,p;try{if(s.status===`success`&&(d=c.options.shouldReload,typeof d==`function`&&(d=d(_i(e,t,s,c,a[0],i,l))),a[0].signal.aborted&&(p=ii)),!p){if(s.status!==`success`)f=!0;else{let t=l||s.preload?c.options.preloadStaleTime??e.options.defaultPreloadStaleTime??3e4:c.options.staleTime??e.options.defaultStaleTime??0;f=!!(s.invalid||d||d===void 0&&Date.now()-s.updatedAt>=t&&(a[5]||s.cause===`enter`||a[2].some(e=>e.routeId===s.routeId&&e.id!==s.id)))}}}catch(n){s.invalid=!0,pi(e,s),p=ui(e,t,c,n,a)}let m=c.options.loader,h=typeof m==`function`,g=h?m:m?.handler,_=!l||c.options.preload!==!1,v=_&&m?e._flights?.get(s.id):void 0;v===s._flight||p?v=void 0:v&&!f&&!l&&d===void 0?f=!0:f||(v=void 0);let y=!(!m||!f||s.status!==`success`||l||a[4]||((h?void 0:m.staleReloadMode)??e.options.defaultStaleReloadMode)===`blocking`),b=f&&_,x=b&&!y&&(s.status!==`success`||!!m),S=n>=o?a[7]:void 0,C=c.lazyFn&&c._lazy!==!0?S:void 0;if(b&&!m&&(s.invalid=!1,s.updatedAt=Date.now()),v&&v[2]++,x){let t=s._flight;s._flight=v,fi(e,s,t)?.abort(),n>=o&&(s.status=`pending`),S?.()}b||(s.isFetching=!1);let w=!p&&x?vi(e,t,s,c,g,i,a).then(t=>(yi(s,t,l),t[0]===ei&&(m&&!a[0].signal.aborted&&bi(e,s,u),n>=o&&(s.status=`pending`)),t)):Promise.resolve(p??[ei,s.loaderData]),T=(async()=>{try{let e=Zr(c,void 0,C);e&&await oi(e,a[0].signal)}catch(r){if(!t[1].some((e,t)=>t<=n&&(e.status===`error`||e.status===`notFound`||e._notFound)))return[n,ui(e,t,c,r,a)]}let r=await w;x&&r[0]===ei&&s.status===`pending`&&!a[0].signal.aborted&&(s.status=`success`,S?.())})();if(r.push([n,w,T]),!y)return w.then(e=>xi(s,e));let E={...s,status:`pending`,preload:!1,_flight:v};s.invalid=!1,s.isFetching=`loader`;let D=vi(e,t,E,c,g,i,a).then(e=>(s.isFetching=!1,yi(E,e,!1),e));return(t[2]??=[]).push([n,D,T,E]),D.then(e=>xi(E,e))}async function Ci(e,t,n,r,i=0){let a=n?.[1][1],o=a?.routeId?t.findIndex(e=>e.routeId===a.routeId):n?.[0]??t.length-1;o<0&&(o=0);for(let n=o;n>=0;n--){let i=si(e,t[n]);try{let e=Zr(i,!1);e&&await oi(e,r)}catch(e){if(e===r&&r.aborted)throw e}if(i.options.notFoundComponent)return n}return a?.routeId?o:i}function wi(e,t){t[2]&&=(mi(e,t[2].map(e=>e[3])),void 0)}async function Ti(e,t,n,r){let i;try{await Promise.all(e.map(e=>e[1].then(async t=>{let a=e[0];if(!(r&&a>=await r)){if(t[0]>=ri)throw[a,t];!i&&t[0]!==ei&&(i=[a,t],await Promise.all((n??[]).map(e=>{if(!(e[0]<=a))return e[1].then(t=>{if(t[0]===ri)throw[e[0],t]})})))}})))}catch(e){return e}return t??i}function Ei(e,t,n,r,i,a){for(;r[0]===ri;){let o=r[1],s=o.options;try{if((s.href||o.headers.has(`Location`))&&(e.resolveRedirect(o),s.reloadDocument)||(s.reloadDocument?i[3]:i[1]>=20))return r;let n=e.buildLocation({...s,_fromLocation:t[0],_includeValidateSearch:!0}),a=n.maskedLocation??n;if(a.external){let t=o.clone();return t.options={...s},t.headers.set(`Location`,a.publicHref),e.resolveRedirect(t),i[3]?[ri,t]:[ri,t,a]}return[ri,o,n]}catch(e){r=a?[ti,e]:li(n,e),a=!0}}return r}async function Di(e,t,n,r,i,a){let o=t[1],s=await i,c=!1,l=o.findIndex(e=>e._notFound),u=t=>t[1][0]===ni?Ci(e,o,t,r.signal):t[0],d=l<0?o.length:l;if((s?.[1][0]??0)>=ri)d=0;else if(s){d=s[2]??=await u(s);for(let e of n){if(e[0]>=d)break;let t=await e[1];if(t[0]!==ei&&t[0]<ri&&!(`loaderData`in o[e[0]])){s=[e[0],t],d=s[2]=await u(s);break}}}for(let e of n){if(e[0]>=d)break;let t=await e[2];if(t){s=t;break}}if((s?.[1][0]??0)>=ri){let n=s[1];if(n[0]!==ri||n[1].options.reloadDocument||n[2])return wi(e,t),n;c=!0,s=[0,[ti,Error(`Too many redirects`)]]}let f=s?s[2]??await u(s):l;if(f>=0){let i=s?.[1],l=i?.[0],u=o[f],d=i?.[1],p=()=>{i&&(u._notFound=void 0,l===ti?u.status=`error`:(d.routeId=u.routeId,u.routeId===e.routeTree.id?(u.status=`success`,u._notFound=!0):u.status=`notFound`),u.error=d,u.isFetching=!1)};p(),i||a?.();let m=si(e,u);try{await oi(i?Promise.resolve().then(()=>Zr(m,l===ti?`errorComponent`:`notFoundComponent`)):Promise.all([Zr(m),Zr(m,`notFoundComponent`)]),r.signal)}catch(n){if(n===r.signal&&r.signal.aborted)return wi(e,t),ii}i?c&&(r.abort(),await Promise.all([...n.map(e=>e[1]),...n.map(e=>e[2]),...(t[2]??[]).map(e=>e[1])]),wi(e,t),mi(e,o),p()):u.status=`success`}return t}async function Oi(e,t,n,r=0,i=t[1].length){let a=t[1];for(let t=r;t<i;t++){let r=a[t],i=si(e,r).options;if(i.head||i.scripts)try{let t={ssr:e.options.ssr,matches:a,match:r,params:r.params,loaderData:r.loaderData},[o,s]=await oi(Promise.all([i.head?.(t),i.scripts?.(t)]),n);r.meta=o?.meta,r.links=o?.links,r.headScripts=o?.scripts,r.styles=o?.styles,r.scripts=s}catch(e){if(e===n&&n.aborted)break;console.error(e)}if(r.status!==`success`||r._notFound)break}return t}async function ki(e,t,n,r){let i=[t,n],a=r[0].signal,o;try{let t=e.stores.matches.get(),s=n.findIndex(e=>e._notFound);if(e.options.notFoundMode!==`root`&&s>=0){let t=await Ci(e,n,void 0,a,s);n[s]._notFound=void 0,n[t]._notFound=!0,s=t}let c=s<0?n.length:s+1,l=0;for(;l<c&&l!==s;){let e=n[l],i=r[2][l],a=t[l];if(i?.id!==e.id||i.status!==`success`||e.preload||a?.id!==e.id||a.status!==`success`||(l++,i._notFound||a._notFound))break}let u=[],d=r[6]??0,f=d?Promise.resolve(n[d-1]):void 0,p=()=>{for(let t=d;t<c&&!a.aborted;t++)f=Si(e,i,t,u,f,r,l)},m=await di(e,i,r,c,p,l);if(m){if(r[4]=!0,c=m[0],m[1][0]===ni){let t=await Ci(e,n,m,a);m[2]=t,c=Math.min(c,t+1)}else m[1][0]>=ri&&(c=0);p()}if(!a.aborted&&!r[3]){let t=[];for(let[n,r]of e._flights??[])r[2]||(e._flights.delete(n),t.push(r[1]));for(let e of t)e.abort()}let h=Di(e,i,u,r[0],Ti(u,m,i[2]),r[7]);i[2]?.length&&(i[3]=Ti(i[2],void 0,void 0,h.then(e=>ai(e)?0:Qr(n).length,()=>0))),o=await h}catch(t){if(wi(e,i),t===a&&a.aborted)return ii;throw t}return ai(o)?o:Oi(e,o,a,r[6]===n.length?r[6]:0)}function Ai(e,t){if(e._tx!==t)return;let n=t[3],r=e.stores.matches.get(),i=e._pending;for(let a=0;a<n.length;a++){let o=n[a],s=o.status===`success`&&!o._notFound,c=r[a]?.id===o.id&&r[a]?.status===`pending`;if(s&&!c)continue;let l=si(e,o),u=s||o.invalid?0:l.options.pendingMs??e.options.defaultPendingMs,d=l.options.pendingComponent??e.options.defaultPendingComponent;if(!d||typeof u!=`number`||u===1/0){i&&(i[0]=t,i[2]=0,i[4]=!0);return}let f=l.options.pendingMinMs??e.options.defaultPendingMinMs??0,p=!1;if(i?.[1]===o.id?(p=i[0]!==t,i[0]=t):(clearTimeout(i?.[3]),e._pending=i=void 0),i||(e._pending=i=[t,o.id,c?Date.now()+f:t[4]+u,void 0,c||void 0,d]),i[4]&&!p&&i[5]===d)return;if(i[5]=d,!i[4]){clearTimeout(i[3]);let n=i[2]-Date.now();if(n>0){i[3]=setTimeout(()=>Ai(e,t),n);return}i[2]=0}let m=n.map(e=>({...e,_flight:void 0}));m[a].status=`pending`;let h=i[4]=e.startTransition(()=>e.stores.setMatches(m),m).then(t=>(t&&e._pending===i&&i[4]===h&&!i[2]&&(i[2]=Date.now()+f),t));return}}function ji(e,t){let n=e._pending;(e._tx===t||!e._tx?.[3].some(e=>e.id===n?.[1]))&&(clearTimeout(n?.[3]),e._pending=void 0)}async function Mi(e,t){let n=e._pending;if(!n)return;clearTimeout(n[3]);let r=n[2]-Date.now();if(!n[4]||r<=0||!Qr(t[3]).some(e=>e.id===n[1]))return;let i;try{await oi(new Promise(e=>{i=setTimeout(e,r)}),t[0].signal)}catch{}clearTimeout(i)}function Ni(e,t){e._committed=t,e.stores.setMatches(t)}function Pi(e,t,n,r){let i=e._committed,a=e._lifecycleEnd,o=e._cache;for(let e of n)e.preload=!1,r&&(e._assetEnd=void 0);let s=Qr(n).length,c=new Map;{let t=Date.now(),r=new Set;for(let e=0;e<n.length;e++){let t=n[e];(e<s||t.status===`success`)&&r.add(t.id)}for(let n of[...i,...o.values()]){if(n.status!==`success`||r.has(n.id))continue;let i=si(e,n);!i.options.loader||t-n.updatedAt>=(n.preload?i.options.preloadGcTime??e.options.defaultPreloadGcTime??3e5:i.options.gcTime??e.options.defaultGcTime??3e5)||c.set(n.id,o.get(n.id)===n?n:{...n,_flight:void 0,isFetching:!1,context:{}})}}t[3]=[],e._cache=c;let l=e._lifecycleEnd=Fr(n);Ni(e,n),mi(e,[...o.values(),...i].filter(e=>e._flight&&c.get(e.id)!==e),n),Ir(e,i,n,a,l,t)}async function Fi(e,t){let n=e._tx;for(;n&&n!==t;)t=n,await n[5],n=e._tx}function Ii(e,t,n){let r=n[1].options,i=n[2];if(!i)return e.navigate({...r,replace:!0,ignoreBlocker:!0});if(r.reloadDocument)return e.navigate({href:(i.maskedLocation??i).publicHref,reloadDocument:!0,replace:!0,ignoreBlocker:!0});i._redirects=t[1]+1,e._pendingLocation=i;let a=e.commitLocation({...i,viewTransition:r.viewTransition,replace:!0,resetScroll:r.resetScroll,hashScrollIntoView:r.hashScrollIntoView,ignoreBlocker:!0});return queueMicrotask(()=>{e._pendingLocation===i&&(e._pendingLocation=void 0)}),a}async function Li(e,t,n,r,i){let a=n.map(e=>({...e}));hi(a);for(let t of r)pi(e,a[t[0]]),a[t[0]]=t[3];let o=[t[2],a],s;try{s=await Di(e,o,r,t[0],i)}catch(t){throw mi(e,a),t}if(ai(s))mi(e,a),s[0]===ri&&e._tx===t&&e._committed===n&&await Ii(e,t,s);else if(await Oi(e,s,t[0].signal),e._tx!==t||e._committed!==n)mi(e,a);else{for(let t of a){let n=e._cache.get(t.id);n?._flight&&n._flight===t._flight&&(e._cache.delete(t.id),pi(e,n))}Ni(e,a),mi(e,n,a)}}async function Ri(e,t,n,r,i,a){let o=await ki(e,t[2],t[3],[t[0],t[1],e._committed,void 0,i,n,a,r]);if(ai(o)){let n=o[0]===ri&&e._tx===t;if((!n||o[1].options.reloadDocument)&&ji(e,t),mi(e,t[3]),t[3]=[],!n)return;if(e._tx!==t){ji(e,t);return}await Ii(e,t,o);return}let s=o[1];if(e._tx===t&&await Mi(e,t),e._tx!==t){ji(e,t),mi(e,s),wi(e,o);return}let c=t[2],l=Nr(c,e.stores.resolvedLocation.get()),u=o[2];await e.startViewTransition(async()=>{if(e._tx===t&&await Mi(e,t),e._tx!==t){ji(e,t),mi(e,s),wi(e,o);return}let n=await e.startTransition(()=>{ji(e,t),Pi(e,t,s,a),e._tx===t&&(e.emit({type:`onLoad`,...l}),e._tx===t&&e.emit({type:`onBeforeRouteMount`,...l}))},s);e._tx===t?(u?.length&&Li(e,t,s,u,o[3]).catch(console.error),e.batch(()=>{e.stores.resolvedLocation.set(c),e.stores.status.set(`idle`),e._tx===t&&e.emit({type:`onResolved`,...l}),n&&e._tx===t&&e.emit({type:`onRendered`,...l})}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0)):wi(e,o)})}async function zi(e,t){let n=e._tx,r=e.stores.resolvedLocation.get(),i=r??e.stores.location.get(),a=e.latestLocation,o=e._pendingLocation,s=o?.href===a.href?o._redirects??0:0,c=e._handoff,l=c?.[0](),u=new AbortController,d=e._preflight;if(e._preflight=u,l||c?.[1](),d?.abort(),!u.signal.aborted){let t=Nr(a,r);e.emit({type:`onBeforeNavigate`,...t}),u.signal.aborted||e.emit({type:`onBeforeLoad`,...t})}if(u.signal.aborted){await Fi(e,n);return}let f=i.href===a.href,p=u,m=e.matchRoutes(a,{_controller:u});hi(m);let h=l?c[1](m):void 0;if(h?p=l:l?.abort(),u.signal.aborted){mi(e,m),await Fi(e,n);return}e._preflight=void 0;let g,_=()=>Ri(e,y,f,()=>Ai(e,y),t?.sync,h),v=t?.sync?new Promise(e=>g=e):Promise.resolve().then(_),y=[p,s,a,m,Date.now(),v.then(()=>Fi(e,y))];if(e._tx=y,n){for(let t of e.stores.matches.get()){if(e._tx!==y)break;t.isFetching&&gi(e,t,!1)}n[0].abort(),mi(e,n[3],y[3],!0)}e._tx===y?(e.batch(()=>{e.stores.status.set(`pending`),e.stores.location.set(a)}),(h||!e._committed.length&&m[0]?.status!==`success`&&!m.some(e=>e._notFound))&&Ai(e,y),g?.(_()),await y[5]):(mi(e,y[3]),y[3]=[],g?.(),await Fi(e,y))}async function Bi(e,t){let n=e.buildLocation(t);for(let t=0;;t++){let r=e._committed,i=new AbortController,a,o,s;try{try{a=e.matchRoutes(n,{_controller:i}),hi(a),o=(e._preloads??=new Map).set(i,a),s=await ki(e,n,a,[i,t,r,!0])}finally{o&&(o=o.delete(i),mi(e,a)),i.abort()}if(!ai(s))return s[1];if(!o||s.length<3)return;n=s[2]}catch(e){Sn(e)||console.error(e);return}}}var Vi=`Error preloading route! ☝️`,Hi=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e,this._branch=void 0;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=Wn:this.parentRoute||dn();let r=n?Wn:t?.path;r&&r!==`/`&&(r=pn(r));let i=t?.id||r,a=n?Wn:fn((this.parentRoute.id===`__root__`?``:this.parentRoute.id)+`/`+(i??``));r===`__root__`&&(r=`/`);let o=a===`__root__`?`/`:r===void 0?this.parentRoute.fullPath:fn(this.parentRoute.fullPath+`/`+r);this._path=r,this._id=a,this._fullPath=o,this._to=mn(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>Gn({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},Ui=class extends Hi{constructor(e){super(e)}},I=i(),Wi=class extends F.Component{constructor(...e){super(...e),this.state={error:0},this.reset=()=>{this.setState({error:0})}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:0}:{resetKey:n}}static getDerivedStateFromError(e){return{error:[e]}}componentDidCatch(e,t){this.props.onCatch?.(e,t)}render(){let e=this.state.error;return e?F.createElement(this.props.errorComponent??Gi,{error:e[0],reset:this.reset}):this.props.children}};function Gi({error:e}){let[t,n]=F.useState(!1);return(0,I.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,I.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,I.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,I.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,I.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,I.jsx)(`div`,{children:(0,I.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e?.message?(0,I.jsx)(`code`,{children:e.message}):null})}):null]})}var Ki=()=>!0,qi=()=>!1;function Ji({children:e,fallback:t=null}){return(0,I.jsx)(F.Fragment,{children:Yi()?e:t})}function Yi(e=!0){return F.useSyncExternalStore(Xi,Ki,e?qi:Ki)}function Xi(){return()=>{}}var Zi=F.createContext(null);function Qi(e){return F.useContext(Zi)}function $i(e,t){let n=e.stores.location,r=new Set,i,a,o=n=>{$r(e,t,n)||(i=n,r.forEach(e=>e()))};return[()=>i??n.get(),e=>(r.size||(i=n.get(),a=n.subscribe(o).unsubscribe),r.add(e),()=>{r.delete(e),r.size||(a(),i=void 0)})]}var ea=F.createContext(void 0),ta=F.createContext(void 0);function na({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0)n=e.nextSub;else{for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function ra(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var ia=[],aa=0,{link:oa,unlink:sa,propagate:ca,checkDirty:la,shallowPropagate:ua}=na({update(e){return e._update()},notify(e){ia[fa++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,ga(e))}}),da=0,fa=0,pa,ma=0;function ha(e){try{++ma,e()}finally{--ma||_a()}}function ga(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=sa(n,e)}function _a(){if(!(ma>0)){for(;da<fa;){let e=ia[da];ia[da++]=void 0,e.notify()}da=0,fa=0}}function va(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return pa!==void 0&&oa(i,pa,aa),i._snapshot},subscribe(e){let t=ra(e),n={current:!1},r=ya(()=>{i.get(),n.current?(pa=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=pa,o=t?.compare??Object.is;if(n)pa=i,++aa,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{pa=a,n&&(i.flags&=-5),ga(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&la(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&ua(e)}}else e&32&&(i.flags=e&-33);return pa!==void 0&&oa(i,pa,aa),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(ca(e),ua(e),_a())}},i}function ya(e){let t=()=>{let t=pa;pa=n,++aa,n.depsTail=void 0,n.flags=6;try{return e()}finally{pa=t,n.flags&=-5,ga(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&la(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,ga(this)}};return t(),n}var ba=n((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),xa=n(((e,t)=>{t.exports=ba()})),Sa=n((e=>{var t=r(),n=xa();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Ca=n(((e,t)=>{t.exports=Sa()}))();function wa(e,t){return e===t}function Ta(e,t=e=>e,n){let r=n?.compare??wa,i=(0,F.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,F.useCallback)(()=>e.get(),[e]);return(0,Ca.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var Ea={};function Da(e,t){let n=F.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=Zt(n.current,i):i}}function Oa(e){let t=Qi(),n=F.useContext(e.from?ta:ea),r=e.from??n,i=t.stores.getMatchStore(r),a=Da(e,t),o=Ta(i,e=>e?a(e):Ea);if(o!==Ea)return o;(e.shouldThrow??!0)&&dn()}function ka(e){return Oa({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function Aa(e){let{select:t,...n}=e;return Oa({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function ja(e){return Oa({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function Ma(e){return Oa({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function Na(e){let t=Qi();return F.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Pa(e){return Oa({...e,select:t=>e.select?e.select(t.context):t.context})}function Fa(...e){let t=F.useRef(e),n=t.current;return e.forEach((e,t)=>{$t(n[t],e,!1,!0)||(n[t]=e)}),t.current}function Ia(e,t){e.preloadRoute(t).catch(e=>{console.warn(e),console.warn(Vi)})}function La(e,t){let n=typeof e==`string`&&an(e);if(n)return t.has(n)?e:null}function Ra(e,t,n,r){let i=gn(e.pathname,r),a=gn(t.pathname,r);return(n?.exact?i!==a:!i.startsWith(a)||i.length!==a.length&&i[a.length]!==`/`)||(n?.includeSearch??!0)&&!$t(e.search,t.search,!n?.exact,n?.explicitUndefined)?!1:!n?.includeHash||e.hash===t.hash}function za(e,t,n){let r=Qi(),i=F.useRef(null),a=F.useCallback(e=>{if(i.current=e,typeof t==`function`)return t(e);t&&(t.current=e)},[t]),{activeOptions:o,to:s,preload:c,preloadDelay:l,disabled:u,target:d,onClick:f,onBlur:p,onFocus:m,onMouseEnter:h,onMouseLeave:g,onTouchStart:_}=e,[v,y,b]=Fa(e.search,e.params,o),x=F.useContext(ea),S=(r.stores._linkScopes??={})[x]??=$i(r,x),[C,w,T]=F.useMemo(()=>{let t=La(s,r.protocolAllowlist);if(t!==void 0){let n=[t??void 0];return[e,()=>n]}let n={...e},i,a,o,c=()=>{let e=S[0]();if(e!==i){n._fromLocation=e;let t=r.buildLocation(n),o=qa(t,r,u),s=u||o&&!an(o)?Ra(e,t,b,r.basepath):void 0;(!a||a[0]!==o||a[1]!==s)&&(a=[o,s]),i=e}return a};return[n,c,b?.includeHash&&(()=>{let e=c();return e[1]?o??=[e[0],!1]:e})]},[r,S,e.from,e.hash,e.href,s,v,y,e.state,e.mask,e.unsafeRelative,b,u]),[E,D]=F.useSyncExternalStore(S[1],w,T||w),O=D===void 0&&E,k=u||E===void 0,A=F.useRef(!1),ee=e.reloadDocument||O||k?!1:c??r.options.defaultPreload,j=l??r.options.defaultPreloadDelay??0,M=F.useCallback(e=>{let t=e?.isIntersecting;t??ee===`intent`?j?i.t??=setTimeout(()=>{i.t=void 0,Ia(r,C)},j):Ia(r,C):t===!1&&Ga(i)},[r,C,i,ee,j]);F.useEffect(()=>{if(!ee)return;ee===`render`&&!A.current&&(A.current=!0,Ia(r,C));let e=!0,t;return ee===`viewport`&&i.current&&typeof IntersectionObserver==`function`&&(t=new IntersectionObserver(t=>{e&&M(t.pop())},{rootMargin:`100px`}),t.observe(i.current)),()=>{e=!1,t?.disconnect(),Ga(i)}},[r,C,ee,M,i]);let te=Ua(e,n);if(te.ref=t?a:i,O)return te.href=O,te;let ne=t=>{let n=d??t.currentTarget.getAttribute(`target`);!k&&!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&(!n||n===`_self`)&&t.button===0&&(t.preventDefault(),Ga(i),r.navigate({...e,_fromLocation:C._fromLocation}))},re=()=>{ee===`intent`&&Ia(r,C)},ie=()=>{ee===`intent`&&Ga(i)};return te.onClick=Ka(f,ne),te.onBlur=Ka(p,ie),te.onFocus=Ka(m,M),te.onMouseEnter=Ka(h,M),te.onMouseLeave=Ka(g,ie),te.onTouchStart=Ka(_,re),Wa(te,e,D,E,k,n)}var Ba={},Va={className:`active`},Ha=new Set([`to`,`params`,`search`,`hash`,`state`,`mask`,`from`,`unsafeRelative`,`reloadDocument`,`preload`,`preloadDelay`,`preloadIntentProximity`,`hashScrollIntoView`,`replace`,`startTransition`,`resetScroll`,`viewTransition`,`ignoreBlocker`,`activeProps`,`inactiveProps`,`activeOptions`,`_asChild`]);function Ua(e,t){let n={};for(let r in e)Ha.has(r)||r===`type`&&t!==void 0||r===`disabled`&&t===`a`||(n[r]=e[r]);return n}function Wa(e,t,n,r,i,a){let{activeProps:o,inactiveProps:s,className:c,style:l,target:u}=t,d=Kt(n?o:s,{})??(n?Va:Ba);Object.assign(e,d),e.href=r,a!==`a`&&(e.disabled=i),e.target=u;let f=d.style;(l||f)&&(e.style=l&&f?{...l,...f}:l||f);let p=d.className;return(c||p)&&(e.className=c?p?`${c} ${p}`:c:p),i&&(e.role=`link`,e[`aria-disabled`]=!0),n&&(e[`data-status`]=`active`,e[`aria-current`]=`page`),e}var Ga=e=>{clearTimeout(e.t),e.t=void 0},Ka=(e,t)=>e?n=>n.defaultPrevented||(e(n),n.defaultPrevented||t(n)):t;function qa(e,t,n){if(n)return;let r=e.maskedLocation??e,i=r.external?r.publicHref:t.history.createHref(r.publicHref)||`/`;if(!r.external&&i===r.publicHref||!sn(i,t.protocolAllowlist))return i}var Ja=F.memo(F.forwardRef((e,t)=>{let n=e._asChild||`a`,r=za(e,t,n),i=typeof e.children==`function`?e.children({isActive:r[`data-status`]===`active`}):e.children;return F.createElement(n,r,i)}),Ya);function Ya(e,t){let n=0;for(let r in t)if(n++,e[r]!==t[r]&&(!Ha.has(r)||!$t(e[r],t[r],!1,!0)))return!1;for(let t in e)n--;return n===0}var Xa=class extends Hi{constructor(e){super(e),this.useMatch=e=>Oa({...e,from:this.id}),this.useRouteContext=e=>Pa({...e,from:this.id}),this.useSearch=e=>Ma({...e,from:this.id}),this.useParams=e=>ja({...e,from:this.id}),this.useLoaderDeps=e=>Aa({...e,from:this.id}),this.useLoaderData=e=>ka({...e,from:this.id}),this.useNavigate=()=>Na({from:this.fullPath}),this.Link=F.forwardRef((e,t)=>(0,I.jsx)(Ja,{ref:t,from:this.fullPath,...e}))}};function Za(e){return new Xa(e)}var Qa=class extends Ui{constructor(e){super(e),this.useMatch=e=>Oa({...e,from:this.id}),this.useRouteContext=e=>Pa({...e,from:this.id}),this.useSearch=e=>Ma({...e,from:this.id}),this.useParams=e=>ja({...e,from:this.id}),this.useLoaderDeps=e=>Aa({...e,from:this.id}),this.useLoaderData=e=>ka({...e,from:this.id}),this.useNavigate=()=>Na({from:this.fullPath}),this.Link=F.forwardRef((e,t)=>(0,I.jsx)(Ja,{ref:t,from:this.fullPath,...e}))}};function $a(e){return new Qa(e)}function eo(e){let t=Qi(),n=`not-found-${Ta(t.stores.location,e=>e.pathname)}-${Ta(t.stores.status)}`;return(0,I.jsx)(Wi,{getResetKey:()=>n,onCatch:(t,n)=>{if(Sn(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(Sn(t))return e.fallback?.(t);throw t},children:e.children})}function to(){return(0,I.jsx)(`p`,{children:`Not Found`})}function no(e,t,n){return t.options.notFoundComponent?(0,I.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,I.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,I.jsx)(to,{})}function ro(e,t){let n=t?.options.pendingComponent??e.options.defaultPendingComponent;return n?(0,I.jsx)(n,{}):null}var io=(e,t)=>e[0]===t[0]&&e[1]===t[1],ao=(e,t,n)=>!t.isRoot||t.options.shellComponent||t.options.wrapInSuspense||n===!1||n===`data-only`||!e.ssr,oo=F.memo(function({routeId:e}){let t=Qi();return so(t,Ta(t.stores.getMatchStore(e)))});function so(e,t){let n=e.routesById[t.routeId],r=ro(e,n),i=n.options.errorComponent??e.options.defaultErrorComponent,a=n.options.onCatch??e.options.defaultOnCatch,o=n.isRoot?n.options.notFoundComponent??e.options.notFoundRoute?.options.component:n.options.notFoundComponent,s=t.ssr===!1||t.ssr===`data-only`,c=ao(e,n,t.ssr)&&(n.options.wrapInSuspense??r??(n.options.errorComponent?.preload||s)),l=(0,I.jsx)(co,{match:t});s&&(l=(0,I.jsx)(Ji,{fallback:r,children:l})),o&&(l=(0,I.jsx)(eo,{fallback:e=>{if(e.routeId??=t.routeId,e.routeId!==t.routeId)throw e;return F.createElement(o,e)},children:l})),i&&(l=(0,I.jsx)(Wi,{getResetKey:()=>t,errorComponent:i,onCatch:(e,n)=>{if(Sn(e))throw e.routeId??=t.routeId,e;a?.(e,n)},children:l})),c&&(l=(0,I.jsx)(F.Suspense,{fallback:r,children:l}));let u=n.isRoot&&n.options.shellComponent;return u?(0,I.jsx)(ea.Provider,{value:t.routeId,children:(0,I.jsxs)(u,{children:[l,null]})}):(0,I.jsxs)(ea.Provider,{value:t.routeId,children:[l,null]})}var co=F.memo(function({match:e}){let t=Qi(),n=e.routeId,r=t.routesById[n],i=F.useMemo(()=>{let i=(r.options.remountDeps??t.options.defaultRemountDeps)?.({routeId:n,loaderDeps:e.loaderDeps,params:e._strictParams,search:e._strictSearch});return i?JSON.stringify(i):void 0},[n,e.loaderDeps,e._strictParams,e._strictSearch,r.options.remountDeps,t.options.defaultRemountDeps]),a=F.useMemo(()=>{let e=r.options.component??t.options.defaultComponent;return e?(0,I.jsx)(e,{},i):(0,I.jsx)(lo,{})},[i,r.options.component,t.options.defaultComponent]);if(e.status===`pending`){if(t.ssr&&!ao(t,r,e.ssr))return a;if(t._tx)throw t._tx[5];return ro(t,r)}if(e.status===`notFound`)return no(t,r,e.error);if(e.status===`error`)throw e.error;return a}),lo=F.memo(function(){let e=Qi(),t=F.useContext(ea),n,r,i;{let a=e.stores.getMatchStore(t);[n,r]=Ta(a,e=>[!!e._notFound,e.error],{compare:io}),i=Ta(e.stores.ids,e=>e[e.indexOf(t)+1])}if(n)return no(e,e.routesById[t],r);if(!i)return null;let a=(0,I.jsx)(oo,{routeId:i});return t===`__root__`?(0,I.jsx)(F.Suspense,{fallback:ro(e),children:a}):a});function uo(e,t){let n=e[1];e.length=0,n?.(t)}function fo({t:e}){let t=Qi(),n=t._rendered??=[];return t.startTransition=(r,i)=>new Promise(a=>{uo(n,!1),n.push(i,a),e(t),F.startTransition(r)}),Wt(()=>{let e=t.history.subscribe(t.load);t.updateLatestLocation();let r=t.latestLocation,i=t.buildLocation({to:r.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});if(mn(r.publicHref)!==mn(i.publicHref))return t.commitLocation({...i,replace:!0,ignoreBlocker:!0}),e;let a=t.stores.resolvedLocation.get();return a?.href===r.href&&a.state.__TSR_key===r.state.__TSR_key?n.push(t.stores.matches.get(),e=>{e&&t.emit({type:`onRendered`,...Nr(a,a)})}):t._tx||t.load({sync:!0}).catch(console.error),e},[t,t.history]),null}function po(){let e=Qi(),t=e.routesById[Wn],n=ro(e,t),r=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(fo,{t:F.useState()[1]}),e.ssr?(0,I.jsx)(mo,{}):(0,I.jsx)(F.Suspense,{fallback:n,children:(0,I.jsx)(mo,{})})]});return e.options.InnerWrap?(0,I.jsx)(e.options.InnerWrap,{children:r}):r}function mo(){let e=Qi(),t=e._rendered,n=Ta(e.stores.matches,e=>t[0]??e),r=n[0],i=r?.routeId;Wt(()=>{t[0]===n&&uo(t,!0)},[t,n]);let a=i?(0,I.jsx)(oo,{routeId:i}):null;return e.options.disableGlobalCatchBoundary?a:(0,I.jsx)(Wi,{getResetKey:()=>r,onCatch:void 0,children:a})}var ho=e=>({createMutableStore:va,createReadonlyStore:va,batch:ha}),go=e=>new _o(e),_o=class extends Lr{constructor(e){super(e,ho)}};function vo({router:e,children:t,...n}){Jt(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,I.jsx)(Zi.Provider,{value:e,children:t});return e.options.Wrap?(0,I.jsx)(e.options.Wrap,{children:r}):r}function yo({router:e,...t}){return(0,I.jsx)(vo,{router:e,...t,children:(0,I.jsx)(po,{})})}var bo=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ee(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ee(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function ee(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ee(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),xo=n(((e,t)=>{t.exports=bo()})),So=n((e=>{var t=xo(),n=r(),i=a();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(o(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return d(i),e;if(a===r)return d(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,l=i.child;l;){if(l===n){s=!0,n=i,r=a;break}if(l===r){s=!0,r=i,n=a;break}l=l.sibling}if(!s){for(l=a.child;l;){if(l===n){s=!0,n=a,r=i;break}if(l===r){s=!0,r=a,n=i;break}l=l.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function h(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function g(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function _(e){var t=[null,null],n=h(e);return n===null||v(t,e,n.child,{foundSelf:!1}),t}function v(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&v(e,t,n.child,r))return!0;n=n.sibling}return!1}function y(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(o(559))}}var b=null,x=null;function S(e,t,n){return e===n||e===t&&(b=e,!0)}function C(e,t,n){return e===n?(x=e,!1):e===t&&(x!==null&&(b=e),!0)}function w(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function T(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var E=Object.assign,D=Symbol.for(`react.element`),O=Symbol.for(`react.transitional.element`),k=Symbol.for(`react.portal`),A=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),j=Symbol.for(`react.profiler`),M=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.legacy_hidden`),le=Symbol.for(`react.memo_cache_sentinel`),ue=Symbol.for(`react.view_transition`),de=Symbol.for(`react.recoverable`),fe=Symbol.iterator;function pe(e){return typeof e!=`object`||!e?null:(e=fe&&e[fe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function he(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case A:return`Fragment`;case j:return`Profiler`;case ee:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case se:return`Activity`;case ue:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case k:return`Portal`;case te:return e.displayName||`Context`;case M:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?he(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}var ge=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ye=[],be=-1;function xe(e){return{current:e}}function Se(e){0>be||(e.current=ye[be],ye[be]=null,be--)}function Ce(e,t){be++,ye[be]=e.current,e.current=t}var we=xe(null),Te=xe(null),Ee=xe(null),De=xe(null);function Oe(e,t){switch(Ce(Ee,t),Ce(Te,e),Ce(we,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?wp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=wp(t),e=Tp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Se(we),Ce(we,e)}function ke(){Se(we),Se(Te),Se(Ee)}function Ae(e){var t=e.memoizedState;t!==null&&(xh._currentValue=t.memoizedState,Ce(De,e)),t=we.current;var n=Tp(t,e.type);t!==n&&(Ce(Te,e),Ce(we,n))}function je(e){Te.current===e&&(Se(we),Se(Te)),De.current===e&&(Se(De),xh._currentValue=ve)}var Me,Ne;function Pe(e){if(Me===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Me=t&&t[1]||``,Ne=-1<e.stack.indexOf(`
4
4
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
@@ -92,7 +92,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
92
92
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
93
93
  `,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=EP(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}kP.peek=AP;function kP(e){return e.value||``}function AP(){return`<`}jP.peek=MP;function jP(e,t,n,r){let i=bP(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function MP(){return`!`}NP.peek=PP;function NP(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function PP(){return`!`}FP.peek=IP;function FP(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function IP(){return"`"}function LP(e,t){let n=pT(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}RP.peek=zP;function RP(e,t,n,r){let i=bP(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(LP(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function zP(e,t,n){return LP(e,n)?`<`:`[`}BP.peek=VP;function BP(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function VP(){return`[`}function HP(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function UP(e){let t=HP(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function WP(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function GP(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function KP(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?WP(n):HP(n),s=e.ordered?o===`.`?`)`:`.`:UP(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),GP(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function qP(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function JP(e,t,n,r){let i=qP(n),a=n.bulletCurrent||HP(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function YP(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function XP(e,t,n,r){if(!e.children.some(function(e){return lP(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function ZP(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}QP.attention=$P,QP.peek=eF;function QP(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function $P(e,t){return{construct:`strong`,markers:ZP(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function eF(e,t,n){return n.options.strong||`*`}function tF(e,t,n,r){let i=t?t.children:[],a=i.indexOf(e);return n.safe(e.value,{...r,afterNode:i[a+1],beforeNode:i[a-1]})}function nF(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function rF(e,t,n){let r=(GP(n)+(n.options.ruleSpaces?` `:``)).repeat(nF(n));return n.options.ruleSpaces?r.slice(0,-1):r}var iF={blockquote:uP,break:mP,code:vP,definition:xP,emphasis:CP,hardBreak:mP,heading:OP,html:kP,image:jP,imageReference:NP,inlineCode:FP,link:RP,linkReference:BP,list:KP,listItem:JP,paragraph:YP,root:XP,strong:QP,text:tF,thematicBreak:rF};function aF(){return{enter:{table:oF,tableData:uF,tableHeader:uF,tableRow:cF},exit:{codeText:dF,table:sF,tableData:lF,tableHeader:lF,tableRow:lF}}}function oF(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function sF(e){this.exit(e),this.data.inTable=void 0}function cF(e){this.enter({type:`tableRow`,children:[]},e)}function lF(e){this.exit(e)}function uF(e){this.enter({type:`tableCell`,children:[]},e)}function dF(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,fF));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function fF(e,t){return t===`|`?t:e}function pF(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
94
94
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
95
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return oP(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=iF.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function mF(){return{exit:{taskListCheckValueChecked:gF,taskListCheckValueUnchecked:gF,paragraph:_F}}}function hF(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:vF}}}function gF(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function _F(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function vF(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=iF.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function yF(){return[CN(),qN(),QN(),aF(),mF()]}function bF(e){return{extensions:[wN(),JN(e),$N(),pF(e),hF()]}}var xF={tokenize:PF,partial:!0},SF={tokenize:FF,partial:!0},CF={tokenize:IF,partial:!0},wF={tokenize:LF,partial:!0},Oie={tokenize:RF,partial:!0},TF={name:`wwwAutolink`,tokenize:MF,previous:zF},EF={name:`protocolAutolink`,tokenize:NF,previous:BF},DF={name:`emailAutolink`,tokenize:jF,previous:VF},OF={};function kF(){return{text:OF}}for(var AF=48;AF<123;)OF[AF]=DF,AF++,AF===58?AF=65:AF===91&&(AF=97);OF[43]=DF,OF[45]=DF,OF[46]=DF,OF[95]=DF,OF[72]=[DF,EF],OF[104]=[DF,EF],OF[87]=[DF,TF],OF[119]=[DF,TF];function jF(e,t,n){let r=this,i,a;return o;function o(t){return!HF(t)||!VF.call(r,r.previous)||UF(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return HF(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Oie,u,l)(t):t===45||t===95||TT(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&wT(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function MF(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!zF.call(r,r.previous)||UF(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(xF,e.attempt(SF,e.attempt(CF,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function NF(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&BF.call(r,r.previous)&&!UF(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(wT(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||ET(t)||OT(t)||jT(t)||AT(t)?n(t):e.attempt(SF,e.attempt(CF,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function PF(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function FF(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(wF,c,s)(t):t===null||OT(t)||jT(t)||t!==45&&AT(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function IF(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(wF,t,a)(o):o===null||OT(o)||jT(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function LF(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||OT(o)||jT(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||OT(e)||jT(e)?t(e):r(e)}function a(e){return wT(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):wT(t)?(e.consume(t),o):n(t)}}function RF(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return TT(e)?n(e):t(e)}}function zF(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||OT(e)}function BF(e){return!wT(e)}function VF(e){return!(e===47||HF(e))}function HF(e){return e===43||e===45||e===46||e===95||TT(e)}function UF(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var WF={tokenize:QF,partial:!0};function GF(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:YF,continuation:{tokenize:XF},exit:ZF}},text:{91:{name:`gfmFootnoteCall`,tokenize:JF},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:KF,resolveTo:qF}}}}function KF(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=CT(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function qF(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function JF(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||OT(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(CT(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return OT(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function YF(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||OT(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=CT(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return OT(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),PT(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function XF(e,t,n){return e.check(UT,t,e.attempt(WF,t,n))}function ZF(e){e.exit(`gfmFootnoteDefinition`)}function QF(e,t,n){let r=this;return PT(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function $F(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&vT(o,o.length,0,BT(s,e.slice(r+1,n),t)),vT(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),vT(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=zT(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=zT(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var eI=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){tI(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function tI(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function nI(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function rI(){return{flow:{null:{name:`table`,tokenize:iI,resolveAll:aI}}}}function iI(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):B(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):kT(t)?PT(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||OT(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,kT(t)?PT(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return kT(t)?PT(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||B(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return kT(t)?PT(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||B(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||B(n)?(e.exit(`tableRow`),t(n)):kT(n)?PT(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||OT(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function aI(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new eI;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(sI(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=oI(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=oI(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=oI(f,t,o,i,n,d)):(o[0]=o[1],d=oI(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&sI(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=nI(t.events,n))}return e}function oI(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},cI(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=cI(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=cI(t.events,n[2]),a=cI(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},cI(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function sI(e,t,n,r,i){let a=[],o=cI(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function cI(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var lI={name:`tasklistCheck`,tokenize:dI};function uI(){return{text:{91:lI}}}function dI(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return OT(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return B(r)?t(r):kT(r)?e.check({tokenize:fI},t,n)(r):n(r)}}function fI(e,t,n){return PT(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function pI(e){return xT([kF(),GF(),$F(e),rI(),uI()])}var mI={};function hI(e){let t=this,n=e||mI,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(pI(n)),a.push(yF()),o.push(bF(n))}var gI=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}];function _I(){let e=Z().prefs.theme,t=gI.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function vI(){let e=Q(e=>e.prefs.theme),t=gI.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function yI(){let e=_I(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}function bI(e){let[t,n]=(0,F.useState)(null),r=vI();return(0,F.useEffect)(()=>{let t=!0;return it(async()=>{let{getSharedHighlighter:e}=await import(`./dist-CwYFZY7g.js`);return{getSharedHighlighter:e}},__vite__mapDeps([8,9,2,10])).then(({getSharedHighlighter:t})=>t({themes:[r],langs:[e.language],preferredHighlighter:`shiki-wasm`}).then(t=>({highlighter:t,lang:e.language})).catch(()=>t({themes:[r],langs:[`text`],preferredHighlighter:`shiki-wasm`}).then(e=>({highlighter:e,lang:`text`})))).then(({highlighter:t,lang:n})=>t.codeToHast(e.code,{lang:n,themes:{light:r,dark:r},defaultColor:!1,transformers:[{pre(e){delete e.properties.style}}]})).then(e=>{t&&n((0,I.jsx)(`div`,{className:`chat-markdown-shiki`,children:aT(e,{Fragment:F.Fragment,jsx:I.jsx,jsxs:I.jsxs})}))}).catch(e=>console.error(e)),()=>{t=!1}},[e.code,e.language,r]),t===null?(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{children:e.code})}):t}function xI(){let[e,t]=(0,F.useState)(!1);async function n(e){try{if(!window.isSecureContext)throw Error(`Copying needs https or localhost`);await navigator.clipboard.writeText(e),t(!0),setTimeout(()=>t(!1),1500)}catch(e){R9(e)}}return{copied:e,copy:n}}function SI(e){let t=(0,F.useRef)(null),[n,r]=(0,F.useState)(!0),i=xI(),a=n?`Collapse table cells`:`Expand table cells`,o=i.copied?`Copied`:`Copy table`;function s(e){let n=t.current;if(n===null)return;let r=[...n.rows].map(e=>[...e.cells].map(e=>(e.textContent??``).trim())),a=e===`markdown`?r.flatMap((e,t)=>{let n=`| ${e.map(e=>e.replaceAll(`|`,`\\|`)).join(` | `)} |`;return t===0?[n,`| ${e.map(()=>`---`).join(` | `)} |`]:[n]}).join(`
95
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return oP(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=iF.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function mF(){return{exit:{taskListCheckValueChecked:gF,taskListCheckValueUnchecked:gF,paragraph:_F}}}function hF(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:vF}}}function gF(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function _F(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function vF(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=iF.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function yF(){return[CN(),qN(),QN(),aF(),mF()]}function bF(e){return{extensions:[wN(),JN(e),$N(),pF(e),hF()]}}var xF={tokenize:PF,partial:!0},SF={tokenize:FF,partial:!0},CF={tokenize:IF,partial:!0},wF={tokenize:LF,partial:!0},Oie={tokenize:RF,partial:!0},TF={name:`wwwAutolink`,tokenize:MF,previous:zF},EF={name:`protocolAutolink`,tokenize:NF,previous:BF},DF={name:`emailAutolink`,tokenize:jF,previous:VF},OF={};function kF(){return{text:OF}}for(var AF=48;AF<123;)OF[AF]=DF,AF++,AF===58?AF=65:AF===91&&(AF=97);OF[43]=DF,OF[45]=DF,OF[46]=DF,OF[95]=DF,OF[72]=[DF,EF],OF[104]=[DF,EF],OF[87]=[DF,TF],OF[119]=[DF,TF];function jF(e,t,n){let r=this,i,a;return o;function o(t){return!HF(t)||!VF.call(r,r.previous)||UF(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return HF(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Oie,u,l)(t):t===45||t===95||TT(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&wT(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function MF(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!zF.call(r,r.previous)||UF(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(xF,e.attempt(SF,e.attempt(CF,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function NF(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&BF.call(r,r.previous)&&!UF(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(wT(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||ET(t)||OT(t)||jT(t)||AT(t)?n(t):e.attempt(SF,e.attempt(CF,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function PF(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function FF(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(wF,c,s)(t):t===null||OT(t)||jT(t)||t!==45&&AT(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function IF(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(wF,t,a)(o):o===null||OT(o)||jT(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function LF(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||OT(o)||jT(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||OT(e)||jT(e)?t(e):r(e)}function a(e){return wT(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):wT(t)?(e.consume(t),o):n(t)}}function RF(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return TT(e)?n(e):t(e)}}function zF(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||OT(e)}function BF(e){return!wT(e)}function VF(e){return!(e===47||HF(e))}function HF(e){return e===43||e===45||e===46||e===95||TT(e)}function UF(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var WF={tokenize:QF,partial:!0};function GF(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:YF,continuation:{tokenize:XF},exit:ZF}},text:{91:{name:`gfmFootnoteCall`,tokenize:JF},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:KF,resolveTo:qF}}}}function KF(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=CT(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function qF(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function JF(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||OT(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(CT(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return OT(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function YF(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||OT(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=CT(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return OT(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),PT(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function XF(e,t,n){return e.check(UT,t,e.attempt(WF,t,n))}function ZF(e){e.exit(`gfmFootnoteDefinition`)}function QF(e,t,n){let r=this;return PT(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function $F(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&vT(o,o.length,0,BT(s,e.slice(r+1,n),t)),vT(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),vT(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=zT(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=zT(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var eI=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){tI(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function tI(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function nI(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function rI(){return{flow:{null:{name:`table`,tokenize:iI,resolveAll:aI}}}}function iI(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):B(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):kT(t)?PT(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||OT(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,kT(t)?PT(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return kT(t)?PT(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||B(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return kT(t)?PT(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||B(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||B(n)?(e.exit(`tableRow`),t(n)):kT(n)?PT(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||OT(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function aI(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new eI;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(sI(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=oI(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=oI(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=oI(f,t,o,i,n,d)):(o[0]=o[1],d=oI(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&sI(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=nI(t.events,n))}return e}function oI(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},cI(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=cI(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=cI(t.events,n[2]),a=cI(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},cI(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function sI(e,t,n,r,i){let a=[],o=cI(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function cI(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var lI={name:`tasklistCheck`,tokenize:dI};function uI(){return{text:{91:lI}}}function dI(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return OT(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return B(r)?t(r):kT(r)?e.check({tokenize:fI},t,n)(r):n(r)}}function fI(e,t,n){return PT(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function pI(e){return xT([kF(),GF(),$F(e),rI(),uI()])}var mI={};function hI(e){let t=this,n=e||mI,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(pI(n)),a.push(yF()),o.push(bF(n))}var gI=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}];function _I(){let e=Z().prefs.theme,t=gI.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function vI(){let e=Q(e=>e.prefs.theme),t=gI.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function yI(){let e=_I(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}function bI(e){let[t,n]=(0,F.useState)(null),r=vI();return(0,F.useEffect)(()=>{let t=!0;return it(async()=>{let{getSharedHighlighter:e}=await import(`./dist-2-LcTRVV.js`);return{getSharedHighlighter:e}},__vite__mapDeps([8,9,2,10])).then(({getSharedHighlighter:t})=>t({themes:[r],langs:[e.language],preferredHighlighter:`shiki-wasm`}).then(t=>({highlighter:t,lang:e.language})).catch(()=>t({themes:[r],langs:[`text`],preferredHighlighter:`shiki-wasm`}).then(e=>({highlighter:e,lang:`text`})))).then(({highlighter:t,lang:n})=>t.codeToHast(e.code,{lang:n,themes:{light:r,dark:r},defaultColor:!1,transformers:[{pre(e){delete e.properties.style}}]})).then(e=>{t&&n((0,I.jsx)(`div`,{className:`chat-markdown-shiki`,children:aT(e,{Fragment:F.Fragment,jsx:I.jsx,jsxs:I.jsxs})}))}).catch(e=>console.error(e)),()=>{t=!1}},[e.code,e.language,r]),t===null?(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{children:e.code})}):t}function xI(){let[e,t]=(0,F.useState)(!1);async function n(e){try{if(!window.isSecureContext)throw Error(`Copying needs https or localhost`);await navigator.clipboard.writeText(e),t(!0),setTimeout(()=>t(!1),1500)}catch(e){R9(e)}}return{copied:e,copy:n}}function SI(e){let t=(0,F.useRef)(null),[n,r]=(0,F.useState)(!0),i=xI(),a=n?`Collapse table cells`:`Expand table cells`,o=i.copied?`Copied`:`Copy table`;function s(e){let n=t.current;if(n===null)return;let r=[...n.rows].map(e=>[...e.cells].map(e=>(e.textContent??``).trim())),a=e===`markdown`?r.flatMap((e,t)=>{let n=`| ${e.map(e=>e.replaceAll(`|`,`\\|`)).join(` | `)} |`;return t===0?[n,`| ${e.map(()=>`---`).join(` | `)} |`]:[n]}).join(`
96
96
  `):r.map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replaceAll(`"`,`""`)}"`:e).join(`,`)).join(`
97
97
  `);i.copy(a)}return(0,I.jsxs)(`div`,{className:`chat-markdown-table-container`,"data-expanded":n,children:[(0,I.jsx)(`div`,{className:`chat-markdown-table-scroll`,children:(0,I.jsx)(`table`,{ref:t,children:e.children})}),(0,I.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between select-none`,children:[(0,I.jsx)(Oe,{label:a,children:(0,I.jsx)(x,{type:`button`,variant:n?`secondary`:`ghost-muted`,size:`icon-xs`,"aria-pressed":n,"aria-label":a,onClick:()=>{let e=t.current;if(e!==null&&!n){let t=[];for(let n of e.rows)[...n.cells].forEach((e,n)=>{t[n]=Math.max(t[n]??0,e.getBoundingClientRect().width)});[...e.tHead?.rows[0]?.cells??[]].forEach((e,n)=>{e.style.minWidth=`${t[n]}px`})}r(!n)},children:(0,I.jsx)(w,{icon:n?N_:pee,className:`size-3`})})}),(0,I.jsxs)(MC,{children:[(0,I.jsx)(Oe,{label:o,children:(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":o,children:(0,I.jsx)(w,{icon:i.copied?Yg:d_,className:`size-3`})})})}),(0,I.jsxs)(FC,{align:`end`,children:[(0,I.jsx)(IC,{onSelect:()=>s(`markdown`),children:`Copy as Markdown`}),(0,I.jsx)(IC,{onSelect:()=>s(`csv`),children:`Copy as CSV`})]})]})]})]})}function CI(e){let[t,n]=(0,F.useState)(e.open),r=F.Children.toArray(e.children),i=r.findIndex(e=>(0,F.isValidElement)(e)&&e.type===`summary`),a=r[i];return(0,I.jsxs)(`div`,{className:`border-border/60 my-2 border-y`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":t,className:`text-foreground flex w-full items-center gap-2 py-2 text-left text-sm font-medium`,onClick:()=>n(!t),children:[(0,I.jsx)(w,{icon:Qg,"aria-hidden":!0,className:P(`text-muted-foreground size-4 shrink-0 transition-transform`,t&&`rotate-90`)}),(0,I.jsx)(`span`,{children:(0,F.isValidElement)(a)&&a.props.children!==void 0?a.props.children:`Details`})]}),t&&(0,I.jsx)(`div`,{className:`text-foreground/80 ps-6 pb-3`,children:r.filter((e,t)=>t!==i)})]})}var wI=(0,F.lazy)(async()=>({default:(await it(async()=>{let{VideoViewer:e}=await import(`./video-viewer-CJ129jI3.js`);return{VideoViewer:e}},__vite__mapDeps([11,1,2,7,4,5,12,13]))).VideoViewer}));function TI(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(null),a=e.alt===``?e.name:e.alt;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,"aria-label":`Play ${a}`,className:P(`group focus-visible:ring-ring border-border/40 relative inline-block cursor-pointer overflow-hidden rounded-lg border bg-black align-top outline-none focus-visible:ring-2`,e.className),onClick:()=>n(!0),children:[(0,I.jsx)(`video`,{src:`${e.src}#t=0.001`,"aria-hidden":!0,tabIndex:-1,muted:!0,playsInline:!0,preload:`metadata`,className:`pointer-events-none block size-full object-contain`,onError:e.onError,onLoadedMetadata:e=>i(Number.isFinite(e.currentTarget.duration)?e.currentTarget.duration:null)}),(0,I.jsx)(`span`,{className:`absolute inset-0 grid place-items-center bg-black/10 transition-colors group-hover:bg-black/25`,children:(0,I.jsx)(`span`,{className:`grid size-12 place-items-center rounded-full bg-black/60 text-white backdrop-blur-sm transition-transform group-hover:scale-105`,children:(0,I.jsx)(w,{icon:B_,className:`size-5 translate-x-px fill-current`})})}),r!==null&&(0,I.jsx)(`span`,{className:`text-2xs absolute right-2 bottom-2 rounded-md bg-black/60 px-1.5 py-0.5 font-mono text-white tabular-nums`,children:jw(r)})]}),t&&(0,I.jsx)(F.Suspense,{children:(0,I.jsx)(wI,{src:e.src,label:a,name:e.name,onClose:()=>n(!1)})})]})}var kie=new Map([[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.svg`,`image/svg+xml`],[`.mp4`,`video/mp4`],[`.m4v`,`video/mp4`],[`.webm`,`video/webm`],[`.mov`,`video/quicktime`],[`.mp3`,`audio/mpeg`],[`.wav`,`audio/wav`],[`.ogg`,`audio/ogg`],[`.opus`,`audio/ogg`],[`.m4a`,`audio/mp4`],[`.aac`,`audio/aac`],[`.flac`,`audio/flac`]]);function EI(e){let t=/\.[a-z0-9]+$/i.exec(e.split(/[?#]/)[0])?.[0],n=t===void 0?void 0:kie.get(t.toLowerCase());return n?.startsWith(`image/`)===!0?`image`:n?.startsWith(`video/`)===!0?`video`:n?.startsWith(`audio/`)===!0?`audio`:null}async function DI(e,t,n){let r=await L(e,`files.media`,{projectId:t,path:n});return`${es(e)}/api/media?${new URLSearchParams({token:r})}`}async function OI(e,t){let n=await fetch(e);if(!n.ok)throw Error(await n.text());let r=URL.createObjectURL(await n.blob()),i=document.createElement(`a`);i.href=r,i.download=t.slice(t.lastIndexOf(`/`)+1),i.click(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}var Aie=(0,F.lazy)(async()=>({default:(await it(async()=>{let{AudioPlayer:e}=await import(`./audio-player-BBuXiV2_.js`);return{AudioPlayer:e}},__vite__mapDeps([14,1,2,5,13]))).AudioPlayer})),jie={image:k_,video:Oee,audio:vee},Mie={image:ree,video:kee,audio:sv},Nie={image:`Image unavailable`,video:`Video unavailable`,audio:`Audio unavailable`};function Pie(e){let t=Q(e=>e.selection),n=xI(),[r,i]=(0,F.useState)(null);(0,F.useEffect)(()=>{if(t===null)return;let n=!0;async function r(e,t,r){try{let a=await DI(e,t,r);n&&i({path:r,src:a})}catch(e){n&&i({path:r,error:rt(e)})}}return r(t.machine,t.projectId,e.path),()=>{n=!1}},[t,e.path]);let a=r!==null&&r.path===e.path?r:null;return a!==null&&`error`in a?(0,I.jsx)(AI,{kind:EI(e.path)??`image`,reason:a.error,raw:e.raw}):(0,I.jsxs)(`span`,{className:P(`border-border bg-muted/50 flex flex-col gap-1 rounded-xl border p-1`,EI(e.path)===`audio`&&`w-fit max-w-[min(100%,36rem)]`,EI(e.path)!==`audio`&&`w-1/2`),children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1.5 pl-1.5 [contain:inline-size]`,children:[(0,I.jsx)(w,{icon:jie[EI(e.path)??`image`],"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`text-2xs min-w-0 flex-1 truncate font-mono`,title:e.path,children:e.path}),(0,I.jsx)(Oe,{label:n.copied?`Copied`:`Copy path`,children:(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`Copy path`,onClick:()=>void n.copy(e.path),children:(0,I.jsx)(w,{icon:n.copied?Yg:d_,className:`size-3`})})}),(0,I.jsx)(Oe,{label:`Download`,children:(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`Download`,disabled:a===null,onClick:()=>{if(a===null)throw Error(`media is still loading`);OI(a.src,e.path).catch(R9)},children:(0,I.jsx)(w,{icon:m_,className:`size-3`})})})]}),a!==null&&(0,I.jsx)(kI,{src:a.src,alt:e.alt,name:e.path,kind:EI(e.path)??`image`,raw:e.raw}),a===null&&EI(e.path)!==`audio`&&(0,I.jsx)(`span`,{className:`border-border/40 block aspect-[3/2] w-full rounded-lg border`})]})}function kI(e){let[t,n]=(0,F.useState)(null);return t===e.src?(0,I.jsx)(AI,{kind:e.kind,reason:`It could not be loaded`,raw:e.raw}):e.kind===`video`?(0,I.jsx)(TI,{src:e.src,alt:e.alt,name:e.name,className:`block aspect-[3/2] w-full`,onError:()=>n(e.src)}):e.kind===`audio`?(0,I.jsx)(F.Suspense,{children:(0,I.jsx)(Aie,{src:e.src,label:e.alt===``?e.name:e.alt,className:`flex w-[28rem] max-w-full`,onError:()=>n(e.src)})}):(0,I.jsx)(bw,{src:e.src,alt:e.alt,name:e.name,className:`border-border/40 block aspect-[3/2] w-full overflow-hidden rounded-lg border`,imageClassName:`size-full object-contain`,onError:()=>n(e.src)})}function AI(e){return(0,I.jsxs)(`span`,{className:`border-border/70 text-muted-foreground flex w-fit max-w-full flex-col gap-1 rounded-lg border border-dashed px-3 py-2 text-xs`,children:[(0,I.jsxs)(`span`,{className:`flex items-start gap-1.5`,children:[(0,I.jsx)(w,{icon:Mie[e.kind],"aria-hidden":!0,className:`mt-px size-3.5 shrink-0`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`span`,{className:`text-foreground/80 font-medium`,children:Nie[e.kind]}),` · ${e.reason}`]})]}),(0,I.jsx)(`span`,{className:`text-2xs font-mono break-all opacity-80`,children:e.raw})]})}var Fie=(0,F.lazy)(async()=>({default:(await it(async()=>{let{ImageViewer:e}=await import(`./image-viewer-4LhMaTO_.js`);return{ImageViewer:e}},__vite__mapDeps([0,1,2,3,4,5,6,7]))).ImageViewer})),jI=0;function Iie(e){let t=Q(e=>e.prefs.theme),[n,r]=(0,F.useState)(null);return(0,F.useEffect)(()=>{if(e===null)return;let t=!0,n=setTimeout(()=>{let n=_I();it(async()=>{let{default:e}=await import(`./mermaid.core-BvdElKsv.js`);return{default:e}},__vite__mapDeps([15,16,17,18,19,2,20,10,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37])).then(({default:t})=>(t.initialize({startOnLoad:!1,theme:`base`,themeCSS:`rect.basic, .node rect, .cluster rect, rect.actor { rx: 6px; ry: 6px } * { filter: none !important } .edgeLabel, .edgeLabel p { background-color: var(--mermaid-surface, ${n.background}) } .edgeLabel rect, .cluster rect, .relationshipLabelBox { fill: var(--mermaid-surface, ${n.background}); opacity: 1 }`,themeVariables:{darkMode:!0,fontFamily:getComputedStyle(document.body).fontFamily,fontSize:`13px`,useGradient:!1,background:n.background,primaryColor:n.selectionBackground,primaryTextColor:n.foreground,primaryBorderColor:n.palette[8],lineColor:n.palette[8],textColor:n.foreground,edgeLabelBackground:n.background,clusterBkg:n.background,clusterBorder:n.palette[0],noteBkgColor:n.palette[0],noteTextColor:n.foreground,noteBorderColor:n.palette[8],pieOpacity:`0.8`,pieStrokeColor:n.background,pieOuterStrokeColor:n.background,pieSectionTextColor:n.background,...Object.fromEntries([4,5,6,2,3,1].flatMap((e,t)=>[[`pie${t+1}`,n.palette[e]],[`git${t}`,n.palette[e]],[`cScale${t}`,n.palette[e]],[`cScaleLabel${t}`,n.background]]))}}),jI+=1,t.render(`mermaid-${jI}`,e))).then(e=>{t&&r(e.svg)}).catch(()=>{t&&r(null)})},400);return()=>{t=!1,clearTimeout(n)}},[e,t]),e===null?null:n}function Lie(e){let[t,n]=(0,F.useState)(!1);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":`View diagram`,className:`focus-visible:ring-ring flex w-full cursor-zoom-in justify-center rounded-lg px-3 pt-2 pb-3 outline-none [--mermaid-surface:color-mix(in_srgb,var(--text)_3.2%,var(--bg))] focus-visible:ring-2 [&>svg]:h-auto`,onClick:()=>n(!0),dangerouslySetInnerHTML:{__html:e.svg}}),t&&(0,I.jsx)(F.Suspense,{children:(0,I.jsx)(Fie,{src:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e.svg)}`,alt:`Diagram`,name:`Mermaid diagram`,onClose:()=>n(!1)})})]})}var Rie={note:{label:`Note`,icon:iee,border:`border-blue-500/70`,title:`text-blue-600 dark:text-blue-400`},tip:{label:`Tip`,icon:lee,border:`border-emerald-500/70`,title:`text-emerald-600 dark:text-emerald-400`},important:{label:`Important`,icon:gee,border:`border-purple-500/70`,title:`text-purple-600 dark:text-purple-400`},warning:{label:`Warning`,icon:ov,border:`border-amber-500/70`,title:`text-amber-600 dark:text-amber-500`},caution:{label:`Caution`,icon:bee,border:`border-red-500/70`,title:`text-red-600 dark:text-red-400`}},zie={...YM,attributes:{...YM.attributes,blockquote:[...YM.attributes?.blockquote??[],`dataAlert`]},protocols:{...YM.protocols,href:[...YM.protocols?.href??[],`file`]}},MI=new Set;function NI(){return e=>{function t(e){e.children?.forEach(t),Bie(e)}t(e)}}function Bie(e){if(e.type!==`blockquote`)return;let t=e.children?.[0],n=t?.children?.[0];if(t?.type!==`paragraph`||n?.type!==`text`||typeof n.value!=`string`)return;let r=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\](?:\r?\n|$)/i.exec(n.value);if(r===null)return;let i=n.value.slice(r[0].length);if(i.length>0)n.value=i;else if(r[0].endsWith(`
98
98
  `)||t.children?.length===1)t.children?.shift(),t.children?.length===0&&e.children?.shift();else return;e.data={...e.data,hProperties:{...e.data?.hProperties,dataAlert:r[1].toLowerCase()}}}var Vie={blockquote({node:e,children:t}){let n=e?.properties.dataAlert,r=n===`note`||n===`tip`||n===`important`||n===`warning`||n===`caution`?Rie[n]:null;return r===null?(0,I.jsx)(`blockquote`,{children:t}):(0,I.jsxs)(`div`,{role:`note`,className:P(`my-1 border-l-2 pl-3`,r.border),children:[(0,I.jsxs)(`p`,{className:P(`flex items-center gap-1.5 font-medium`,r.title),children:[(0,I.jsx)(w,{icon:r.icon,"aria-hidden":!0,className:`size-3.5 shrink-0`}),r.label]}),t]})},ol({node:e,start:t,children:n}){let r=e?.children.filter(e=>e.type===`element`&&e.tagName===`li`).length??0,i=t??1,a=Math.max(String(i).length,String(i+Math.max(r-1,0)).length);return(0,I.jsx)(`ol`,{start:t,ref:e=>{e!==null&&a>1&&e.style.setProperty(`--list-gutter`,`${a+2}ch`)},children:n})},a({node:e,href:t,children:n}){let r=Uie(t);if(r!==null)return(0,I.jsx)(`a`,{href:t,onClick:e=>{e.preventDefault(),$C(r)},children:n});let i=Wie(t);if(i===null)return(0,I.jsx)(`a`,{href:t,children:n});let a=e?.children.every(e=>e.type===`text`)?e.children.map(e=>e.type===`text`?e.value:``).join(``):``;return(0,I.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:a===``?n:(0,I.jsx)(Gie,{host:i,text:a})})},table({children:e}){return(0,I.jsx)(SI,{children:e})},details({open:e,children:t}){return(0,I.jsx)(CI,{open:e===!0,children:t})},img({src:e,alt:t}){return typeof e==`string`?e.startsWith(`/`)&&!e.startsWith(`//`)||e.startsWith(`./`)?(0,I.jsx)(Pie,{path:decodeURI(e),alt:t??``,raw:`![${t??``}](${e})`}):(0,I.jsx)(`span`,{className:P(`block`,EI(e)!==`audio`&&`w-1/2`),children:(0,I.jsx)(kI,{src:e,alt:t??``,name:e.startsWith(`data:`)?`Image`:e.split(/[?#]/)[0],kind:EI(e)??`image`,raw:`![${t??``}](${e})`})}):null},pre({node:e,children:t}){let n=e?.children[0];if(n?.type!==`element`||n.tagName!==`code`)return(0,I.jsx)(`pre`,{children:t});let r=n.children.map(e=>e.type===`text`?e.value:``).join(``),i=n.properties.className,a=Array.isArray(i)?i.map(String).find(e=>e.startsWith(`language-`))?.slice(9):void 0;return(0,I.jsx)(qie,{code:r.replace(/\n$/,``),language:a===`gitignore`?`ini`:a??`text`})}},PI=(0,F.memo)(Hie);function Hie(e){return(0,I.jsx)(`div`,{className:P(`chat-markdown text-foreground w-full min-w-0 text-sm leading-relaxed [overflow-wrap:anywhere] [word-break:break-word]`,e.className),"data-streaming":e.streaming===!0?``:void 0,children:(0,I.jsx)(aO,{remarkPlugins:e.lineBreaks===!0?[hI,NI,bN]:[hI,NI],rehypePlugins:e.rawHtml===!1?[]:[qM,[fN,zie]],components:Vie,urlTransform:e=>e.startsWith(`file:`)?e:lO(e),children:e.text})})}function Uie(e){if(e===void 0||e===``||e.startsWith(`#`)||e.startsWith(`//`))return null;if(e.startsWith(`file:`))return e;if(!/^[a-z]:[\\/]/i.test(e)&&/^[a-z][a-z0-9+.-]*:/i.test(e))return null;try{return decodeURI(e)}catch{return e}}function Wie(e){if(e===void 0||!/^https?:\/\//i.test(e))return null;try{return new URL(e).host}catch{return null}}function Gie(e){let t=/^https?:\/\//i.exec(e.text)?.[0].length??Math.min(e.text.length,1);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`whitespace-nowrap`,children:[(0,I.jsx)(Kie,{host:e.host}),e.text.slice(0,t)]}),Array.from(e.text.slice(t),(e,t)=>(0,I.jsxs)(`span`,{children:[e,(0,I.jsx)(`wbr`,{})]},t))]})}function Kie(e){let[t,n]=(0,F.useState)(MI.has(e.host)),r=e.host.toLowerCase(),i=r===`github.com`||r.endsWith(`.github.com`);return(0,I.jsx)(`span`,{className:`ms-[0.25em] me-[0.2em] inline-flex size-[14px] [vertical-align:-0.125em]`,"aria-hidden":!0,children:i?(0,I.jsx)(w,{icon:D_,className:`block size-full shrink-0 select-none`}):t?(0,I.jsx)(w,{icon:O_,className:`block size-full shrink-0 select-none`}):(0,I.jsx)(`img`,{src:`https://${e.host}/favicon.ico`,alt:``,loading:`lazy`,draggable:!1,className:`block size-full shrink-0 rounded-sm select-none`,onError:()=>{MI.add(e.host),n(!0)}})})}function qie(e){let[t,n]=(0,F.useState)(!0),[r,i]=(0,F.useState)(!1),a=Iie(e.language===`mermaid`?e.code:null),o=xI(),s=t?`Disable line wrap`:`Wrap lines`,c=r?`Show diagram`:`Show code`,l=o.copied?`Copied`:`Copy code`;return(0,I.jsxs)(`div`,{className:`chat-markdown-codeblock border-border/70 bg-secondary dark:bg-input/32 my-[0.65rem] overflow-hidden rounded-lg border leading-snug dark:border-transparent`,"data-language":e.language,"data-wrap":t,children:[(0,I.jsxs)(`div`,{className:`chat-markdown-codeblock-header flex items-center justify-between gap-2 pt-1.5 pr-1.5 pb-0 pl-3 select-none`,children:[(0,I.jsx)(`span`,{className:`text-2xs inline-flex min-w-0 items-center gap-1.5 font-mono`,children:Ie(e.language)?(0,I.jsx)(Oe,{label:e.language,children:(0,I.jsx)(`span`,{className:`inline-flex shrink-0 rounded-sm`,"aria-label":`Language: ${e.language}`,children:(0,I.jsx)(Ye,{path:Le(e.language),className:`size-3.5`})})}):(0,I.jsx)(`span`,{className:`truncate`,children:e.language})}),(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5`,role:`toolbar`,children:[a!==null&&(0,I.jsx)(Oe,{label:c,children:(0,I.jsx)(x,{type:`button`,variant:r?`secondary`:`ghost-muted`,size:`icon-xs`,"aria-pressed":r,"aria-label":c,onClick:()=>i(!r),children:(0,I.jsx)(w,{icon:Q_,className:`size-3`})})}),(a===null||r)&&(0,I.jsx)(Oe,{label:s,children:(0,I.jsx)(x,{type:`button`,variant:t?`secondary`:`ghost-muted`,size:`icon-xs`,"aria-pressed":t,"aria-label":s,onClick:()=>n(!t),children:(0,I.jsx)(w,{icon:iv,className:`size-3`})})}),(0,I.jsx)(Oe,{label:l,children:(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":l,onClick:()=>void o.copy(e.code),children:(0,I.jsx)(w,{icon:o.copied?Yg:d_,className:`size-3`})})})]})]}),a!==null&&!r?(0,I.jsx)(Lie,{svg:a}):(0,I.jsx)(bI,{code:e.code,language:e.language})]})}var FI=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},Jie=new class extends FI{};function Yie(e,t,n){return Jie.diff(e,t,n)}function II(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function LI(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function RI(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function zI(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function BI(e,t){return RI(e,t,``)}function VI(e,t){return zI(e,t,``)}function HI(e,t){return t.slice(0,Xie(e,t))}function Xie(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function UI(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function WI(e,t){if(t)return KI(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function GI(e,t){if(t)return KI(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function KI(e,t){if(!t)return[GI(e),WI(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=UI(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var qI=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,Zie=RegExp(`[${qI}]+|\\s+|[^${qI}]`,`ug`);new class extends FI{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=UI(e,r)}else n=e.match(Zie)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&JI(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&JI(n,i,r,null,t.intlSegmenter),e}};function JI(e,t,n,r,i){if(t&&n){let[a,o]=KI(t.value,i),[s,c]=KI(n.value,i);if(e){let r=II(a,s);e.value=zI(e.value,s,r),t.value=BI(t.value,r),n.value=BI(n.value,r)}if(r){let e=LI(o,c);r.value=RI(r.value,c,e),t.value=VI(t.value,e),n.value=VI(n.value,e)}}else if(n){if(e){let e=GI(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=GI(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=GI(r.value,i),[a,o]=KI(t.value,i),s=II(n,a);t.value=BI(t.value,s);let c=LI(BI(n,s),o);t.value=VI(t.value,c),r.value=RI(r.value,n,c),e.value=zI(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=GI(r.value,i),n=HI(WI(t.value,i),e);t.value=VI(t.value,n)}else if(e){let n=HI(WI(e.value,i),GI(t.value,i));t.value=BI(t.value,n)}}var Qie=new class extends FI{tokenize(e){let t=RegExp(`(\\r?\\n)|[${qI}]+|[^\\S\\n\\r]+|[^${qI}]`,`ug`);return e.match(t)||[]}};function $ie(e,t,n){return Qie.diff(e,t,n)}var eae=new class extends FI{constructor(){super(...arguments),this.tokenize=XI}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
@@ -108,7 +108,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
108
108
  `),n=e.split(`
109
109
  `).map(e=>e+`
110
110
  `);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function nL(e){let t=e.item;switch(t.kind){case`file_change`:return(0,I.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.diffs.map((e,t)=>(0,I.jsx)(sae,{before:e.before,after:e.after},t))});case`todo_list`:return(0,I.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:t.steps.map((e,t)=>(0,I.jsxs)(`li`,{className:P(`text-secondary-label`,e.status===`completed`&&`text-muted-foreground line-through`,e.status===`running`&&`text-foreground`),children:[e.status===`completed`?`☑`:`☐`,` `,e.text]},t))});case`plan`:return(0,I.jsx)(PI,{text:t.plan});case`tool`:return rL(t.name)===`other`?(0,I.jsx)(oae,{text:JSON.stringify(t.input,null,2)}):null;default:return null}}function aae(e,t){switch(e.kind){case`command`:return e.command;case`file_change`:return sL(e.path,t);case`web_search`:return e.url??e.query??``;case`subagent`:return e.description;case`skill`:return e.skill;case`tool`:{let n=rL(e.name);return n===`read`?sL(iL(e.input),t):n===`search`?oL(e.input.pattern):``}default:return``}}function rL(e){switch(e.toLowerCase()){case`read`:return`read`;case`grep`:case`glob`:return`search`;default:return`other`}}function iL(e){return[e.file_path,e.filePath,e.path].map(oL).find(e=>e!==``)??``}function aL(e){let t=0,n=0;for(let r of e.diffs)for(let e of YI(r.before,r.after))e.added&&(t+=e.count),e.removed&&(n+=e.count);return{added:t,removed:n}}function oae(e){return(0,I.jsx)(`pre`,{className:`text-foreground/80 text-2xs max-h-64 overflow-auto font-mono leading-relaxed whitespace-pre-wrap`,children:e.text})}function sae(e){return(0,I.jsx)(`pre`,{className:`border-border/60 text-2xs max-h-80 overflow-auto rounded-md border font-mono leading-relaxed`,children:YI(e.before,e.after).flatMap((e,t)=>e.value.replace(/\n$/,``).split(`
111
- `).map((n,r)=>(0,I.jsxs)(`div`,{className:P(`px-2 whitespace-pre-wrap`,e.added&&`bg-diff-addition/10 text-diff-addition`,e.removed&&`bg-diff-deletion/10 text-diff-deletion`,!e.added&&!e.removed&&`text-muted-foreground`),children:[e.added?`+`:e.removed?`-`:` `,` `,n]},`${t}:${r}`)))})}function oL(e){return typeof e==`string`?e:``}function sL(e,t){return e.startsWith(t+`/`)?e.slice(t.length+1):e}var cL=`(Recommended)`;function lL(e){let t=e.options.map(e=>e.label).filter(e=>e.endsWith(cL));return e.multiSelect?t:t.slice(0,1)}function uL(e){return(0,I.jsxs)(`span`,{className:P(`mt-0.5 grid size-4 shrink-0 place-items-center border transition-colors`,e.multi?`rounded`:`rounded-full`,e.selected&&`border-primary bg-primary text-primary-foreground`,e.suggested&&`border-primary border-dashed`,!e.selected&&!e.suggested&&`border-muted-foreground/40`),children:[e.selected&&e.multi&&(0,I.jsx)(w,{icon:Yg,strokeWidth:3,className:`size-3`}),e.selected&&!e.multi&&(0,I.jsx)(`span`,{className:`bg-primary-foreground size-1.5 rounded-full`})]})}function dL(e){let[t,n]=(0,F.useState)(Date.now);(0,F.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.ceil((e.at-t)/1e3));return(0,I.jsxs)(`span`,{className:`text-muted-foreground text-2xs mr-1 tabular-nums`,children:[e.label,` in`,` `,r<60?`${r}s`:`${Math.ceil(r/60)}m`]})}var cae=`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`;function lae(e){let t=e.request;if(t.kind===`question`)return(0,I.jsx)(uae,{machine:e.machine,request:t,draft:e.draft});let n=t.kind===`plan`,r=n?``:aae(t.item,e.cwd);return(0,I.jsx)(`div`,{className:P(cae,`border-warning/28 bg-linear-to-b from-warning/8 to-warning/8`),children:(0,I.jsxs)(`div`,{className:`grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-x-2 gap-y-3 px-1 py-1`,children:[(0,I.jsx)(`span`,{className:`text-warning flex justify-center pt-0.5`,children:(0,I.jsx)(w,{icon:J_,className:`size-4`})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground text-2xs flex w-full min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-warning shrink-0 font-medium`,children:n?`Ready to code?`:t.title}),e.count>1&&(0,I.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:[`1/`,e.count]})]}),r!==``&&(0,I.jsx)(`span`,{className:`text-foreground block max-h-20 w-full min-w-0 overflow-auto font-mono text-xs whitespace-pre`,children:r})]}),(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[t.autoResolve!==void 0&&(0,I.jsx)(dL,{label:t.autoResolve.decision===`allow`?`Approve`:`Decline`,at:t.autoResolve.at}),(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>dw(t.id,`deny`,null),children:n?`Keep planning`:`Decline`}),t.kind===`approval`&&t.canAlwaysAllow&&(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>dw(t.id,`always`,null),children:`Always`}),(0,I.jsx)(x,{size:`xs`,onClick:()=>dw(t.id,`allow`,null),children:n?`Approve plan`:`Approve`})]}),n&&(0,I.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,I.jsx)(PI,{text:t.plan})}),t.kind===`approval`&&t.item.kind!==`command`&&(0,I.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,I.jsx)(nL,{item:t.item})})]})})}function uae(e){let t=e.request.questions,[n,r]=(0,F.useState)(0),[i,a]=(0,F.useState)({}),[o,s]=(0,F.useState)({}),c=Object.fromEntries(t.map(e=>[e.question,[...i[e.question]??[],o[e.question]?.trim()??``].filter(e=>e!==``)])),l=Object.fromEntries(t.map(e=>[e.question,(c[e.question].length>0?c[e.question]:lL(e)).join(`, `)])),u=t[n],d=t.flatMap((e,t)=>c[e.question].length===0?[t]:[]),f=d.find(e=>e>n)??d[0];function p(e,c){let l=i[e.question]??[];e.multiSelect?a({...i,[e.question]:l.includes(c)?l.filter(e=>e!==c):[...l,c]}):(a({...i,[e.question]:[c]}),s({...o,[e.question]:``}),n<t.length-1&&r(n+1))}function m(e,t){s({...o,[e.question]:t}),!e.multiSelect&&t.trim()!==``&&a({...i,[e.question]:[]})}async function h(t,n){let r=Sw(Z().items,[e.draft,...Object.values(o)]);for(let i of n)try{let n=await KC(e.machine,i),o=n;i.type.startsWith(`image/`)&&(r+=1,o=`[Image #${r}] (saved at ${n})`),s(e=>{let n=e[t.question]??``;return{...e,[t.question]:`${n}${/(^|\s)$/.test(n)?``:` `}${o}`}}),t.multiSelect||a(e=>({...e,[t.question]:[]}))}catch(e){R9(e)}}return(0,I.jsx)(`div`,{className:`composer-glass shadow-composer relative z-10 rounded-3xl border border-(--composer-outline)`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 p-2.5`,children:[(0,I.jsxs)(`div`,{role:`tabpanel`,className:`flex min-w-0 flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-start gap-1.5 pt-1 pr-1 pl-1.5`,children:[(0,I.jsx)(`span`,{className:`bg-primary/18 text-primary grid size-6 shrink-0 place-items-center rounded-md`,children:(0,I.jsx)(w,{icon:hee,className:`size-4`})}),(0,I.jsx)(`p`,{className:`text-foreground min-w-0 flex-1 pt-0.5 text-[15px] leading-5 font-medium`,children:u.question}),(0,I.jsx)(x,{size:`icon-xs`,variant:`ghost`,"aria-label":`Skip questions`,title:`Skip questions`,onClick:()=>dw(e.request.id,`deny`,null),children:(0,I.jsx)(w,{icon:je})})]}),(0,I.jsxs)(`div`,{role:u.multiSelect?`group`:`radiogroup`,"aria-label":u.question,className:`flex max-h-[min(18rem,32dvh)] flex-col gap-0.5 overflow-y-auto`,children:[u.options.map(e=>{let t=i[u.question]?.includes(e.label)===!0,n=c[u.question].length===0&&lL(u).includes(e.label),r=e.label.endsWith(cL);return(0,I.jsxs)(`button`,{role:u.multiSelect?`checkbox`:`radio`,"aria-checked":t,className:P(`flex cursor-pointer items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors`,t?`bg-muted/70`:`hover:bg-muted/40`),onClick:()=>p(u,e.label),children:[(0,I.jsx)(uL,{multi:u.multiSelect,selected:t,suggested:n}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-foreground text-sm`,children:r?e.label.slice(0,-13).trim():e.label}),r&&(0,I.jsx)(`span`,{className:`text-muted-foreground/70 text-[11px]`,children:`Recommended`})]}),e.description!==``&&(0,I.jsx)(`span`,{className:`text-secondary-label mt-0.5 block text-xs leading-4`,children:e.description})]})]},e.label)}),(0,I.jsxs)(`label`,{className:P(`flex cursor-text items-start gap-2.5 rounded-lg px-2.5 py-2 transition-colors`,(o[u.question]??``).trim()===``?`focus-within:bg-muted/40 hover:bg-muted/40`:`bg-muted/70`),children:[(0,I.jsx)(uL,{multi:u.multiSelect,selected:(o[u.question]??``).trim()!==``,suggested:!1}),(0,I.jsx)(`textarea`,{value:o[u.question]??``,rows:1,onChange:e=>m(u,e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);if(t!==``){e.preventDefault(),document.execCommand(`insertText`,!1,t);return}let n=[...e.clipboardData.files];n.length!==0&&(e.preventDefault(),h(u,n))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),h(u,[...e.dataTransfer.files])},placeholder:`Something else…`,className:`placeholder:text-placeholder/75 [field-sizing:content] max-h-40 min-w-0 flex-1 resize-none bg-transparent text-sm leading-5 outline-none`})]})]})]},u.question),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.length>1&&(0,I.jsx)(`div`,{role:`tablist`,className:`flex min-w-0 [scrollbar-width:none] gap-1 overflow-x-auto`,children:t.map((e,t)=>(0,I.jsxs)(`button`,{role:`tab`,"aria-selected":t===n,className:P(`flex h-6 shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,t===n?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`),onClick:()=>r(t),children:[c[e.question].length>0&&(0,I.jsx)(w,{icon:Xg,"aria-label":`Answered`,className:`text-success size-3.5`}),c[e.question].length===0&&l[e.question]!==``&&(0,I.jsx)(w,{icon:n_,"aria-label":`Using the recommended answer`,className:`text-primary size-3.5`}),l[e.question]===``&&(0,I.jsx)(w,{icon:eee,"aria-label":`Not answered`,className:`text-muted-foreground size-3.5`}),e.header]},e.question))}),(0,I.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5 pr-1`,children:[e.request.autoResolve!==void 0&&(0,I.jsx)(dL,{label:`Skip`,at:e.request.autoResolve.at}),(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>dw(e.request.id,`allow`,{}),children:`Skip`}),(0,I.jsx)(x,{size:`xs`,variant:f===void 0?`default`:`outline`,onClick:()=>dw(e.request.id,`allow`,Object.fromEntries(t.flatMap(e=>c[e.question].length===0?[]:[[e.question,c[e.question].join(`, `)]]))),children:`Submit`}),f!==void 0&&(0,I.jsx)(x,{size:`xs`,onClick:()=>{c[u.question].length===0&&a({...i,[u.question]:lL(u)}),r(f)},children:`Next`})]})]})]})})}function fL({...e}){return(0,I.jsx)(Kx,{"data-slot":`popover`,...e})}function pL({...e}){return(0,I.jsx)(Jx,{"data-slot":`popover-trigger`,...e})}function mL({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,I.jsx)(Qx,{children:(0,I.jsx)(eS,{"data-slot":`popover-content`,sideOffset:n,align:t,className:P(`z-50 origin-(--radix-popover-content-transform-origin) overflow-hidden rounded-lg dropdown-glass text-popover-foreground shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] outline-none dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)] duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}var hL=`relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-(--control-radius) border border-transparent outline-none hover:bg-accent data-[state=open]:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64 [&_svg]:pointer-events-none [&_svg]:shrink-0`,gL=`h-7 gap-1.5 px-1.5 text-sm sm:px-2.5 font-medium text-secondary-label hover:text-foreground [&_svg:not([class*=text-])]:text-muted-foreground [&_svg:not([class*=size-])]:size-4`;function dae(){let e=Q(e=>e.settings),t=Q(e=>e.capabilities)?.models.find(t=>t.value===e.model);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(fae,{}),(0,I.jsx)(`span`,{className:`bg-border mx-0.5 hidden h-4 w-px shrink-0 sm:block`}),t!==void 0&&t.efforts.length>0&&(0,I.jsx)(pae,{title:`Effort`,trigger:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w,{icon:Hg}),(0,I.jsx)(`span`,{className:`capitalize`,children:e.effort??`Default`})]}),value:e.effort??`default`,options:[...e.provider===`opencode`?[{value:`default`,label:`Default`}]:[],...t.efforts.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))],onChange:e=>J9({effort:e==="default"?null:e})})]})}function fae(){let e=Q(e=>e.settings),t=Q(e=>e.selection),n=Q(e=>e.machines.find(t=>t.id===e.selection?.machine)),r=[...[...n?.claudeAccounts??[],...n?.codexAccounts??[]].filter(e=>e.valid).map(e=>({key:e.id,provider:e.provider,accountId:e.id,name:e.name,color:e.color,plan:e.plan,error:e.error})),...n?.openCode.available===!0?[{key:`opencode`,provider:`opencode`,accountId:null,name:`OpenCode`,color:null,plan:null,error:null}]:[]].filter(n=>t?.sessionId===null||n.provider===e.provider),i=e.provider===`opencode`?`opencode`:e.accountId,a=Q(e=>e.capabilities),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(i),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)({}),m=(0,F.useRef)(null),h=a?.models.find(t=>t.value===e.model)?.name??e.model??`Choose a model`,g=r.find(e=>e.key===i),_=c===null?[]:c===i?a?.models??null:f[c]??null,v=r.find(e=>e.key===c)?.provider,y=(_??[]).filter(e=>!e.hidden),b=y.length>=5,x=b?u.trim().toLowerCase():``,S=y.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(x));function C(e){if(s(e),e&&(l(i),d(``),t!==null))for(let e of r)e.key!==i&&e.error===null&&L(t.machine,`capabilities`,{provider:e.provider,accountId:e.accountId,projectId:t.projectId}).then(t=>p(n=>({...n,[e.key]:t.models})),R9)}function T(n,i){let a=r.find(e=>e.key===n);if(a===void 0||t===null)return;let o=a.provider,s={accountId:a.accountId,model:i.value,...i.effort===null?{}:{effort:i.effort}};o===e.provider?J9(s):J9({...q9(T9(Z(),t.machine).composer,o),...s})}return(0,I.jsxs)(fL,{open:o,onOpenChange:C,children:[(0,I.jsx)(pL,{asChild:!0,children:(0,I.jsxs)(`button`,{className:P(hL,gL),title:g===void 0?`Model`:`${g.name} · ${h}`,children:[(0,I.jsxs)(`span`,{className:`relative`,children:[(0,I.jsx)(Yv,{provider:e.provider,className:`size-4`}),r.filter(t=>t.provider===e.provider).length>1&&g!==void 0&&(0,I.jsx)(`span`,{className:P(`pointer-events-none absolute -right-1 -bottom-1 flex h-3 min-w-3 items-center justify-center rounded-full border px-0.5 text-[8px] leading-none font-semibold shadow-sm`,g.color===null?`bg-card text-muted-foreground`:`border-card text-white`),style:g.color===null?void 0:{backgroundColor:g.color},children:g.name.charAt(0).toUpperCase()})]}),(0,I.jsx)(`span`,{className:`max-w-40 truncate`,children:h})]})}),(0,I.jsxs)(mL,{side:`top`,className:`flex max-h-86.5 w-screen max-w-90 flex-row`,onOpenAutoFocus:e=>{e.preventDefault(),m.current?.focus()},onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:[r.length>1&&(0,I.jsxs)(`div`,{className:`bg-muted/30 flex w-11 shrink-0 [scrollbar-width:none] flex-col gap-1 overflow-y-auto p-1`,children:[r.map(t=>(0,I.jsxs)(`div`,{className:`relative w-full`,children:[t.key===c&&(0,I.jsx)(`div`,{className:`bg-primary pointer-events-none absolute top-1/2 -right-1 z-10 h-5 w-0.75 -translate-y-1/2 rounded-l-full`}),(0,I.jsx)(Oe,{side:`left`,label:t.error===null?[t.name,t.plan].filter(e=>e!==null).join(` · `):`${t.name} — ${t.error}`,children:(0,I.jsxs)(`button`,{className:P(`hover:bg-foreground/10 focus-visible:bg-foreground/10 relative flex aspect-square w-full cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,t.error!==null&&`cursor-not-allowed opacity-50 hover:bg-transparent`),"aria-label":t.name,"aria-pressed":t.key===c,"aria-disabled":t.error!==null,onClick:()=>{if(t.error!==null)return;let n=f[t.key]?.find(t=>t.value===e.model);t.key!==i&&i!==null&&a!==null&&n!==void 0&&(p(e=>({...e,[i]:a.models})),T(t.key,n)),l(t.key)},children:[(0,I.jsx)(Yv,{provider:t.provider,className:`size-5`}),r.filter(e=>e.provider===t.provider).length>1&&(0,I.jsx)(`span`,{className:P(`text-3xs pointer-events-none absolute right-0.5 bottom-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full border px-0.5 leading-none font-semibold shadow-sm`,t.color===null?`bg-card text-muted-foreground`:`border-card text-white`),style:t.color===null?void 0:{backgroundColor:t.color},children:t.name.charAt(0).toUpperCase()})]})})]},t.key)),(0,I.jsx)(Oe,{side:`left`,label:`Manage accounts`,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:bg-foreground/10 hover:text-foreground focus-visible:bg-foreground/10 mt-auto flex aspect-square w-full shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,"aria-label":`Manage accounts`,onClick:()=>{s(!1),I9(C9[e.provider])},children:(0,I.jsx)(w,{icon:uv,className:`size-4.5`})})})]}),(0,I.jsxs)(`div`,{className:P(`bg-muted/40 flex min-h-0 min-w-0 flex-1 flex-col`,r.length>1&&`border-border/70 border-l`),children:[b&&(0,I.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5`,children:(0,I.jsxs)(`div`,{className:`border-border/70 focus-within:border-ring relative border-b pb-1.5 transition-colors`,children:[(0,I.jsx)(w,{icon:W_,className:`text-muted-foreground/55 pointer-events-none absolute top-1.5 left-0 size-4`}),(0,I.jsx)(`input`,{ref:m,value:u,placeholder:`Search models...`,className:`placeholder:text-muted-foreground/70 h-6.5 w-full bg-transparent ps-5 text-sm outline-none`,onChange:e=>d(e.target.value),onKeyDown:e=>{if(e.key!==`Enter`||c===null)return;let t=S.at(0);t!==void 0&&(e.preventDefault(),T(c,t),s(!1))}})]})}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-1.5`,children:S.length===0?(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:_===null?`Loading models…`:`No models found`}):S.map(t=>(0,I.jsx)(`button`,{className:P(`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer flex-col justify-center rounded-sm px-2 py-1.5 text-left`,c===i&&t.value===e.model&&`text-foreground bg-foreground/[0.08]`),onClick:()=>{c!==null&&(T(c,t),s(!1))},children:(0,I.jsxs)(`span`,{className:`truncate text-sm leading-snug font-medium`,children:[t.name,v===`opencode`&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs font-normal`,children:t.description})]})},t.value))})]})]})]})}function pae(e){return(0,I.jsxs)(MC,{children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsx)(`button`,{className:P(hL,gL),title:e.title,children:e.trigger})}),(0,I.jsxs)(FC,{className:`w-72`,side:`top`,align:`start`,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:[(0,I.jsx)(BC,{children:e.title}),(0,I.jsx)(RC,{value:e.value,onValueChange:e.onChange,children:e.options.map(e=>(0,I.jsx)(zC,{value:e.value,children:e.label},e.value))})]})]})}function mae(e){let t=Q(e=>e.selection?.sessionId),n=Q(t=>E9(t,e.machine,e.projectId)),r=Q(e=>e.projects),i=Q(e=>e.machines);return(0,I.jsx)(`div`,{className:`absolute inset-x-0 bottom-full pb-4`,children:(0,I.jsxs)(`h1`,{className:`text-foreground w-full text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:[`What should we build in`,` `,t===null?(0,I.jsxs)(MC,{children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`border-muted-foreground/35 hover:border-foreground/60 inline-flex max-w-64 cursor-pointer border-b border-dotted align-bottom outline-none`,title:n?.path,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:n?.name}),`?`]})}),(0,I.jsx)(FC,{className:`max-h-80 w-64`,onCloseAutoFocus:t=>{t.preventDefault(),e.onCloseMenu()},children:(0,I.jsx)(RC,{value:f9(e.machine,e.projectId),children:[...r].sort((e,t)=>i.findIndex(t=>t.id===e.machine)-i.findIndex(e=>e.id===t.machine)).map(e=>(0,I.jsxs)(zC,{value:f9(e.machine,e.id),title:e.path,onSelect:()=>rw({machine:e.machine,projectId:e.id,sessionId:null}),children:[(0,I.jsx)(qv,{machine:e.machine,projectId:e.id,className:`size-4 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,i.length>1&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-1.5 text-xs`,children:i.find(t=>t.id===e.machine)?.name})]})]},f9(e.machine,e.id)))})})]}):(0,I.jsx)(`span`,{className:`border-muted-foreground/35 inline-block max-w-64 truncate border-b border-dotted align-bottom`,title:n?.path,children:n?.name}),t!==null&&`?`]})})}function hae(){let e=Q(e=>e.queue);return(0,I.jsx)(`div`,{className:`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 border-(--composer-outline) px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`grid min-h-6 grid-cols-[1.5rem_minmax(0,1fr)_auto_auto] items-center gap-x-1`,children:[(0,I.jsx)(w,{icon:fee,className:`text-muted-foreground mx-auto size-3`}),(0,I.jsx)(`span`,{className:`text-secondary-label truncate`,children:e.prompt.text===``?`${e.prompt.images.length} image(s)`:e.prompt.text}),(0,I.jsx)(x,{variant:`ghost-muted`,size:`icon-xs`,title:`Send now`,onClick:()=>cw(e.id),children:(0,I.jsx)(w,{icon:Bg})}),(0,I.jsx)(x,{variant:`ghost-muted`,size:`icon-xs`,title:`Remove from queue`,onClick:()=>sw(e.id),children:(0,I.jsx)(w,{icon:je})})]},e.id))})}function gae(e){return(0,I.jsxs)(I.Fragment,{children:[e.running&&e.empty&&(0,I.jsx)(`button`,{className:`bg-destructive/90 shadow-destructive/24 hover:bg-destructive flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full text-white shadow-xs transition-colors`,title:`Stop (Esc)`,"aria-label":`Stop generation`,onClick:e.onStop,children:(0,I.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,I.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),!(e.running&&e.empty)&&(0,I.jsx)(`button`,{className:`bg-message-action text-message-action-foreground shadow-message-action/24 hover:bg-message-action-hover relative flex size-9 items-center justify-center overflow-hidden rounded-full shadow-xs transition-all duration-150 hover:scale-105 enabled:cursor-pointer disabled:pointer-events-none disabled:opacity-64 disabled:shadow-none`,title:e.running&&e.delivery===`steer`?`Send now (Enter) · Queue (${et}+Enter)`:e.running?`Queue (Enter) · Send now (${et}+Enter)`:`Send (Enter)`,"aria-label":`Send message`,disabled:e.empty,onClick:t=>e.onSubmit(t.metaKey||t.ctrlKey),children:(0,I.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]})}var _ae=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],vae=5242880,_L=window.matchMedia(`(pointer: coarse)`);function vL(){let e=Q(e=>e.selection),t=Q(e=>e.loaded),n=Q(e=>e.items.length===0&&e.partial===``),r=Q(e=>e.requests),i=Q(e=>e.queue),a=Q(e=>e.draft),o=Q(e=>e.capabilities),s=Q(e=>e.settings.provider===`opencode`?e.machines.find(t=>t.id===e.selection?.machine)?.openCode.available!==!0:e.settings.accountId===null),[c,l]=(0,F.useState)(0),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(0),[m,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)([]),v=(0,F.useRef)(null),y=(0,F.useRef)(null),b=e?.machine??``,S=e?.projectId??``,C=Q(e=>E9(e,b,S)),T=Q(e=>T9(e,b).status),E=Q(e=>T9(e,b).config?.delivery??null),D=f9(b,e?.sessionId??S),O=Bs(D),k=O.text,A=O.images,[ee,j]=(0,F.useState)(k.length),M=Q(j9),te=t&&n&&!M,ne=r.at(0);(0,F.useEffect)(()=>{let e=v.current;e===null||_L.matches||(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[e]),(0,F.useEffect)(()=>{if(a===null)return;let e=Cw(a);Vs(D,t=>({...t,...e})),j(e.text.length),N9(null),v.current?.focus()},[a,D]),(0,F.useEffect)(()=>{T===`online`&&L(b,`files.list`,{projectId:S}).then(_,R9)},[b,S,T]);let re=k.slice(0,ee),ie=/^\/\S*$/.exec(re)?.[0]??/(?:^|\s)(@\S*)$/.exec(re)?.[1]??null,ae=ie?.slice(1).toLowerCase()??``,oe=ie===null||m?[]:ie.startsWith(`/`)?(o?.commands??[]).filter(e=>e.name.toLowerCase().includes(ae)).sort((e,t)=>Number(!e.name.toLowerCase().startsWith(ae))-Number(!t.name.toLowerCase().startsWith(ae))).map(e=>({key:e.name,label:`/${e.name}${e.hint===``?``:` ${e.hint}`}`,description:e.description,insert:`/${e.name}`})):g.filter(e=>e.toLowerCase().includes(ae)).slice(0,50).map(e=>({key:e,label:e,description:``,insert:`@${e}`})),se=Math.min(f,oe.length-1),ce=k.trim()===``&&A.length===0||c>0||u||s;function le(e,t){Vs(D,t=>({...t,text:e,images:t.images.filter(t=>e.includes(`[Image #${t.number}]`))})),j(t),p(0),h(!1)}function ue(e){if(ie===null)return;let t=ee-ie.length,n=t+e.insert.length+1;le(`${k.slice(0,t)}${e.insert} ${k.slice(ee)}`,n),requestAnimationFrame(()=>v.current?.setSelectionRange(n,n))}async function de(e){if(!ce){d(!0);try{if(E===null)throw Error(`This machine is not connected`);await ow({text:k.trim(),images:A.map(e=>({mediaType:e.mediaType,data:e.data}))},e?E===`queue`?`steer`:`queue`:E),Vs(D,e=>({...e,text:``,images:[]})),j(0)}catch(e){R9(e)}finally{d(!1)}}}async function fe(e){let t=ee,n=/(^|\s)$/.test(k.slice(0,ee))?``:` `;for(let r of e)if(_ae.includes(r.type)&&r.size<=vae){let e=await qC(r),i=Sw(Z().items,[Us(D).text])+1,a={number:i,mediaType:r.type,data:e},o=t,s=`${n}[Image #${i}] `;n=``,Vs(D,e=>({...e,text:`${e.text.slice(0,o)}${s}${e.text.slice(o)}`,images:[...e.images,a]})),t+=s.length,j(t),requestAnimationFrame(()=>v.current?.setSelectionRange(t,t))}else{l(e=>e+1);try{let e=await KC(b,r);Vs(D,t=>({...t,text:`${t.text}${/(^|\s)$/.test(t.text)?``:` `}@${e} `}))}catch(e){R9(e)}finally{l(e=>e-1)}}}return(0,I.jsx)(`div`,{className:P(`pointer-events-none z-20`,te?`absolute inset-0 flex items-center pb-3 sm:pb-4`:`relative shrink-0 before:absolute before:right-(--app-scrollbar-width) before:bottom-full before:left-0 before:h-8 before:bg-linear-to-t before:from-background before:to-transparent`),children:(0,I.jsxs)(JC,{width:`composer`,className:`pointer-events-auto relative z-10`,children:[te&&(0,I.jsx)(mae,{machine:b,projectId:S,onCloseMenu:()=>v.current?.focus()}),i.length>0&&oe.length===0&&(0,I.jsx)(hae,{}),ne!==void 0&&oe.length===0&&(0,I.jsx)(lae,{request:ne,machine:b,cwd:C?.path??``,count:r.length,draft:k},ne.id),oe.length>0&&(0,I.jsx)(ww,{items:oe,active:se,onHover:p,onPick:ue}),(0,I.jsxs)(`div`,{className:P(`composer-glass shadow-composer relative z-10 border border-(--composer-outline) transition-[border-color,box-shadow] duration-200 ease-out focus-within:border-[color-mix(in_srgb,var(--text)_16%,transparent)] focus-within:ring-4 focus-within:ring-[color-mix(in_srgb,var(--text)_4%,transparent)] dark:shadow-none`,te?`rounded-3xl`:`rounded-t-3xl border-b-0`,ne?.kind===`question`&&`hidden`),onMouseDown:e=>{e.target instanceof Element&&e.currentTarget.contains(e.target)&&(e.target.closest(`button, a, input, textarea`)||(e.preventDefault(),v.current?.focus()))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),fe([...e.dataTransfer.files])},children:[(0,I.jsxs)(`div`,{className:P(`pb-2`,A.length>0&&`pt-3.5 sm:pt-4`),children:[A.length>0&&(0,I.jsx)(xw,{draftKey:D}),(0,I.jsx)(`textarea`,{ref:v,"data-composer":!0,rows:1,spellCheck:!1,autoCorrect:`off`,"data-gramm":`false`,"data-gramm_editor":`false`,"data-enable-grammarly":`false`,"data-lt-active":`false`,value:k,onChange:e=>le(e.target.value,e.target.selectionStart),onSelect:e=>j(e.currentTarget.selectionStart),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);if(t!==``){e.preventDefault(),document.execCommand(`insertText`,!1,t);return}let n=[...e.clipboardData.files];n.length!==0&&(e.preventDefault(),fe(n))},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(oe.length>0){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;p((se+t+oe.length)%oe.length);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),ue(oe[se]);return}if(e.key===`Escape`){e.preventDefault(),h(!0);return}}if(e.key===`Enter`&&!e.shiftKey&&!_L.matches)e.preventDefault(),de(e.metaKey||e.ctrlKey);else if(e.key===`ArrowUp`&&k===``){let t=yae(Z().items);if(t===null)return;e.preventDefault(),le(t,t.length)}else e.key===`Escape`&&M&&lw()}},placeholder:s?`Add an account in Settings to start`:M&&E===`steer`?`Steer the agent… (${et}+Enter to queue)`:M?`Queue a follow-up… (${et}+Enter to send now)`:`Ask anything, @tag files/folders, or / for commands`,className:P(`placeholder:text-placeholder/75 block [field-sizing:content] w-full resize-none bg-transparent px-3 text-sm leading-relaxed outline-none sm:px-4`,A.length>0?`max-h-52 min-h-19.5`:`max-h-55.5 min-h-20 pt-3.5 sm:max-h-56 sm:pt-4 [@media(min-height:840px)]:min-h-23 sm:[@media(min-height:840px)]:min-h-23.5`)})]}),(0,I.jsxs)(`div`,{className:P(`flex min-w-0 items-center justify-between gap-2 px-3 sm:px-4`,te?`pb-3 sm:pb-4`:`pb-2.5 sm:pb-3.5`),children:[(0,I.jsx)(`div`,{className:`-m-1 -ms-3.5 flex min-w-0 flex-1 [scrollbar-width:none] items-center gap-1 overflow-x-auto p-1 ps-2`,children:(0,I.jsx)(dae,{})}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[(0,I.jsx)(`input`,{ref:y,type:`file`,multiple:!0,hidden:!0,onChange:e=>{fe([...e.target.files??[]]),e.target.value=``}}),c>0&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Uploading…`}),(0,I.jsx)(Pw,{empty:ce,delivery:E,onSubmit:()=>void de(!0)}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:`Attach files`,"aria-label":`Attach files`,onClick:()=>y.current?.click(),children:(0,I.jsx)(w,{icon:Cee})}),(0,I.jsx)(gae,{running:M,empty:ce,delivery:E,onSubmit:e=>void de(e),onStop:lw})]})]})]})]})})}function yae(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.kind===`user`&&n.parent===null&&n.format===`text`&&n.text!==``)return n.text}return null}var bae=window.matchMedia(`(pointer: coarse)`);function xae(e){let[t,n]=(0,F.useState)(!1),r=xL(e.repo);return(0,I.jsxs)(fL,{open:t,onOpenChange:n,children:[(0,I.jsx)(pL,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground hidden max-w-48 cursor-pointer items-center gap-1 text-xs sm:flex`,title:`Switch or create a branch`,children:[(0,I.jsx)(w,{icon:r===null?S_:r.icon,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.repo.branch??`detached`})]})}),(0,I.jsx)(mL,{align:`end`,className:`flex max-h-86.5 w-72 flex-col`,children:(0,I.jsx)(yL,{target:e,onClose:()=>n(!1)})})]})}function Sae(e){return(0,I.jsx)(Ke,{open:!0,onOpenChange:e.onClose,children:(0,I.jsxs)(Ne,{showCloseButton:!1,"aria-describedby":void 0,className:`flex max-h-[min(30rem,calc(100dvh-2rem))] flex-col gap-0 p-0`,onOpenAutoFocus:e=>{bae.matches&&e.preventDefault()},children:[(0,I.jsx)(Ve,{className:`sr-only`,children:`Switch branch`}),(0,I.jsx)(yL,{target:e,onClose:e.onClose})]})})}function yL(e){let t=e.target,n=t.machine,r=t.projectId,i=t.repo.path,a=t.onRefresh,[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(!1),g=xL(t.repo),_=u.trim(),v=(o??[]).filter(e=>e.toLowerCase().includes(_.toLowerCase())),y=(c??[]).filter(e=>e.toLowerCase().includes(_.toLowerCase())),b=(o??[]).includes(_);(0,F.useEffect)(()=>{L(n,`git.localBranches`,{projectId:r,repo:i}).then(s,R9),L(n,`git.fetch`,{projectId:r}).then(a,R9)},[n,r,i,a]);async function x(){h(!0);try{await L(n,`git.sync`,{projectId:r,repo:i}),e.onClose()}catch(e){R9(e)}finally{h(!1),a()}}async function S(t,o){p(!0);try{await L(n,`git.switch`,{projectId:r,repo:i,branch:t,create:o}),e.onClose()}catch(e){R9(e)}finally{p(!1),a()}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5`,children:(0,I.jsxs)(`div`,{className:`border-border/70 focus-within:border-ring relative border-b pb-1.5 transition-colors`,children:[(0,I.jsx)(w,{icon:W_,className:`text-muted-foreground/55 pointer-events-none absolute top-1.5 left-0 size-4`}),(0,I.jsx)(`input`,{value:u,placeholder:`Search or create a branch...`,disabled:f,className:`placeholder:text-muted-foreground/70 h-6.5 w-full bg-transparent ps-5 text-sm outline-none`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_!==``&&o!==null&&(e.preventDefault(),S(_,!b))}})]})}),g!==null&&(0,I.jsx)(`div`,{className:`border-border/70 shrink-0 border-b px-2 py-1.5`,children:(0,I.jsxs)(`button`,{disabled:m||f,className:`hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void x(),children:[(0,I.jsx)(w,{icon:m?n_:g.icon,className:P(`size-3.5 shrink-0`,m&&`animate-spin`)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g.label}),(0,I.jsx)(bL,{behind:t.repo.behind,ahead:t.repo.ahead})]})}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-1.5`,children:[o===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:`Loading branches…`}),o!==null&&v.length===0&&_===``&&(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:`No branches`}),v.map(n=>(0,I.jsxs)(`button`,{disabled:f,className:P(`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,n===t.repo.branch&&`text-foreground bg-foreground/[0.08]`),onClick:()=>{n===t.repo.branch?e.onClose():S(n,!1)},children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),n===t.repo.branch&&(0,I.jsx)(w,{icon:Yg,strokeWidth:2.25,className:`size-3.5 shrink-0`})]},n)),c!==null&&y.length>0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-2 pt-2 pb-1 text-xs font-medium`,children:`Remote`}),y.map(e=>(0,I.jsx)(`button`,{disabled:f,className:`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void S(e.slice(e.indexOf(`/`)+1),!1),children:(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})},e)),o!==null&&_!==``&&!b&&(0,I.jsxs)(`button`,{disabled:f,className:`hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void S(_,!0),children:[(0,I.jsx)(w,{icon:xe,className:`size-3.5 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`Create branch `,(0,I.jsx)(`span`,{className:`font-medium`,children:_})]})]})]}),(0,I.jsx)(`div`,{className:`border-border/70 shrink-0 border-t px-2 py-1.5`,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm`,onClick:()=>{c===null?L(n,`git.remoteBranches`,{projectId:r,repo:i}).then(l,R9):l(null)},children:[(0,I.jsx)(w,{icon:a_,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c===null?`Show remote branches`:`Hide remote branches`})]})})]})}function bL(e){return(0,I.jsxs)(I.Fragment,{children:[e.behind>0&&(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`↓`,e.behind]}),e.ahead>0&&(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`↑`,e.ahead]})]})}function xL(e){return e.branch===null||!e.remote?null:e.upstream===null?{icon:o_,label:`Publish branch`}:e.behind>0&&e.ahead>0?{icon:Ng,label:`Pull and push`}:e.behind>0?{icon:Fg,label:`Pull commits`}:e.ahead>0?{icon:Bg,label:`Push commits`}:null}var Cae={working:n_,done:t_,failed:jg},SL=new Set,CL=null,wL=0;function TL(e){CL=e;for(let e of SL)e();e?.state===`done`&&setTimeout(()=>{CL?.id===e.id&&TL(null)},5e3)}function wae(e){return SL.add(e),()=>{SL.delete(e)}}function EL(e,t){wL+=1,TL(`url`in t?{id:wL,state:`done`,label:e,error:``,url:t.url}:{id:wL,state:`failed`,label:e,error:t.error,url:null})}async function DL(e){wL+=1;let t=wL;TL({id:t,state:`working`,label:e.labels.working,error:``,url:null});try{let n=await e.task();CL?.id===t&&TL({id:t,state:`done`,label:e.labels.done,error:``,url:n})}catch(n){CL?.id===t&&TL({id:t,state:`failed`,label:e.labels.failed,error:rt(n),url:null})}finally{e.onRefresh()}}function OL(e,t,n,r){DL({labels:r?{working:`Committing and pushing…`,done:`Committed and pushed`,failed:`Commit and push failed`}:{working:`Committing…`,done:`Committed`,failed:`Commit failed`},task:async()=>(await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t,message:n,push:r}),null),onRefresh:e.onRefresh})}function Tae(e,t,n){DL({labels:{working:`Creating pull request…`,done:`Pull request created`,failed:`Couldn't create pull request`},task:async()=>(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:n.base,head:n.head,title:n.title,body:n.body})).url,onRefresh:e.onRefresh})}function Eae(){let e=(0,F.useSyncExternalStore)(wae,()=>CL),[t,n]=(0,F.useState)(!1);return e===null?null:(0,I.jsxs)(`div`,{className:`bg-popover text-popover-foreground flex max-w-80 items-center gap-3 rounded-md border py-2 pr-2 pl-3 shadow-md`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,I.jsx)(w,{icon:Cae[e.state],className:P(`size-4 shrink-0`,e.state===`working`&&`animate-spin`,e.state===`done`&&`text-success`,e.state===`failed`&&`text-destructive`)}),(0,I.jsx)(`span`,{className:`truncate`,children:e.label})]}),e.url!==null&&(0,I.jsx)(x,{asChild:!0,size:`xs`,variant:`outline`,children:(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open`})}),e.state===`failed`&&(0,I.jsx)(x,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>n(!0),children:`View`}),(0,I.jsx)(x,{type:`button`,size:`icon-micro`,variant:`ghost-muted`,"aria-label":`Dismiss`,onClick:()=>{n(!1),TL(null)},children:(0,I.jsx)(w,{icon:je,className:`size-3.5`})}),(0,I.jsx)(Ke,{open:t&&e.state===`failed`,onOpenChange:n,children:(0,I.jsxs)(Ne,{className:`sm:max-w-lg`,children:[(0,I.jsx)(Fe,{children:(0,I.jsx)(Ve,{children:e.label})}),(0,I.jsx)(`pre`,{className:`bg-muted/50 max-h-[60vh] overflow-y-auto rounded-lg border p-3 font-mono text-xs break-words whitespace-pre-wrap`,children:e.error})]})})]})}function kL({className:e,type:t,...n}){return(0,I.jsx)(`input`,{type:t,"data-slot":`input`,className:P(`h-9 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function AL({...e}){return(0,I.jsx)(DS,{"data-slot":`select`,...e})}function jL({...e}){return(0,I.jsx)(jS,{"data-slot":`select-value`,...e})}function ML({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(kS,{"data-slot":`select-trigger`,"data-size":t,className:P(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,I.jsx)(MS,{asChild:!0,children:(0,I.jsx)(w,{icon:cv,className:`text-muted-foreground pointer-events-none size-4`})})]})}function NL({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,I.jsx)(FS,{children:(0,I.jsxs)(LS,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:P(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,I.jsx)(Dae,{}),(0,I.jsx)(YS,{"data-position":n,className:P(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,I.jsx)(Oae,{})]})})}function PL({className:e,children:t,...n}){return(0,I.jsxs)($S,{"data-slot":`select-item`,className:P(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,I.jsx)(rC,{children:(0,I.jsx)(w,{icon:Yg,className:`pointer-events-none`})})}),(0,I.jsx)(tC,{children:t})]})}function Dae({className:e,...t}){return(0,I.jsx)(aC,{"data-slot":`select-scroll-up-button`,className:P(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(w,{icon:$g})})}function Oae({className:e,...t}){return(0,I.jsx)(sC,{"data-slot":`select-scroll-down-button`,className:P(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(w,{icon:Zg})})}function FL(e){return e.target?.kind===`failed`?(0,I.jsx)(`span`,{className:`text-destructive truncate text-xs`,children:e.target.text}):(0,I.jsxs)(`span`,{className:`text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsxs)(`span`,{className:`truncate`,children:[e.head,` →`]}),(0,I.jsxs)(AL,{value:e.target?.base??``,disabled:e.target===void 0,onValueChange:e.onBase,children:[(0,I.jsx)(ML,{size:`sm`,className:`max-w-48`,children:(0,I.jsx)(jL,{placeholder:`Loading branches…`})}),(0,I.jsx)(NL,{children:(e.target?.branches??[]).map(e=>(0,I.jsx)(PL,{value:e,children:e},e))})]})]})}function kae(e){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 ps-6`,children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground truncate text-xs`,children:[e.draft.head,` → `,e.draft.base]}),(0,I.jsx)(kL,{value:e.draft.title,onChange:t=>e.onChange({...e.draft,title:t.target.value})}),(0,I.jsx)(`textarea`,{value:e.draft.body,onChange:t=>e.onChange({...e.draft,body:t.target.value}),rows:8,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-y rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.onSkip!==null&&(0,I.jsx)(x,{variant:`ghost`,size:`sm`,onClick:e.onSkip,children:`Skip`}),(0,I.jsx)(x,{variant:`outline`,size:`sm`,onClick:e.onRegenerate,children:`Regenerate`}),(0,I.jsx)(x,{size:`sm`,disabled:e.draft.title.trim()===``,onClick:e.onCreate,children:`Create PR`})]})]})}var Aae={working:n_,review:r_,done:t_,failed:jg,skipped:_ee};function jae(e){let t=Q(t=>E9(t,e.machine,e.projectId)?.name)??``,[n]=(0,F.useState)(()=>IL(e.repos,e.action)),[r,i]=(0,F.useState)(()=>n.map(e=>e.path)),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)({}),[l,u]=(0,F.useState)(null),d=n.filter(e=>r.includes(e.path)&&s[e.path]?.kind!==`failed`),f=e.action===`pullRequest`&&d.some(e=>s[e.path]===void 0),p=d.filter(e=>e.changed>0);(0,F.useEffect)(()=>{if(e.action===`pullRequest`)for(let t of n)L(e.machine,`git.branches`,{projectId:e.projectId,repo:t.path}).then(e=>c(n=>({...n,[t.path]:{kind:`ready`,...e}})),e=>c(n=>({...n,[t.path]:{kind:`failed`,text:rt(e)}})))},[e.machine,e.projectId,e.action,n]);function m(e,t){u(n=>n?.map(n=>n.path===e?{...n,...t}:n)??null)}async function h(t,r){try{await r()}catch(r){if(n.length===1){e.onClose(),EL(`Pull request failed`,{error:rt(r)});return}m(t,{state:`failed`,text:rt(r),draft:null})}finally{e.onRefresh()}}function g(e,t){c(n=>{let r=n[e];return r?.kind===`ready`?{...n,[e]:{...r,base:t}}:n})}function _(e,t){u(d.map(t=>({path:t.path,state:`working`,text:e,url:null,draft:null})));for(let e of d)h(e.path,()=>t(e.path))}function v(t){if(n.length===1){e.onClose(),OL(e,n[0].path,a,t);return}let r=t?`Committed and pushed`:`Committed`;_(t?`Committing and pushing…`:`Committing…`,async n=>{await L(e.machine,`git.commit`,{projectId:e.projectId,repo:n,message:a,push:t}),m(n,{state:`done`,text:r})})}function y(){_(`Pushing…`,async t=>{await L(e.machine,`git.push`,{projectId:e.projectId,repo:t}),m(t,{state:`done`,text:`Pushed`})})}async function b(t,r,i){m(t,{state:`working`,text:r?`Committing local changes and writing pull request…`:`Writing pull request…`,draft:null});let a=await L(e.machine,`git.pullRequest`,{projectId:e.projectId,repo:t,base:i,commit:r});if(a.kind===`open`){if(n.length===1){e.onClose(),EL(`Pull request already open`,{url:a.url});return}m(t,{state:`done`,text:`A pull request is already open`,url:a.url})}else m(t,{state:`review`,text:`Review and create`,draft:{base:a.base,head:a.head,title:a.title,body:a.body}})}function S(e){_(`Starting…`,async t=>{let n=s[t];if(n?.kind!==`ready`)throw Error(`The branches are not loaded`);await b(t,e&&p.some(e=>e.path===t),n.base)})}function C(t,r){n.length===1?(e.onClose(),Tae(e,t,r)):h(t,async()=>{m(t,{state:`working`,text:`Creating pull request…`,draft:null}),m(t,{state:`done`,text:`Created pull request`,url:(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:r.base,head:r.head,title:r.title,body:r.body})).url})})}return(0,I.jsx)(Ke,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(Ne,{className:`top-[12vh] translate-y-0 sm:max-w-lg`,children:[(0,I.jsxs)(Fe,{children:[(0,I.jsxs)(Ve,{children:[e.action===`commit`&&`Commit changes`,e.action===`push`&&`Push`,e.action===`pullRequest`&&`Create pull request`]}),(0,I.jsxs)(We,{children:[e.action===`commit`&&(n.length===1?`Stages every change and commits it.`:`Stages every change in the selected repositories and commits it.`),e.action===`push`&&`Pushes the selected repositories to their remote.`,e.action===`pullRequest`&&`AI writes the title and description. You review them before the pull request is created.`]})]}),l===null&&(0,I.jsxs)(I.Fragment,{children:[n.length===1&&(0,I.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-1.5 text-xs`,children:[e.action===`pullRequest`?(0,I.jsx)(FL,{head:n[0].branch??`detached`,target:s[n[0].path],onBase:e=>g(n[0].path,e)}):n[0].branch??`detached`,(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`· `,n[0].changed,` `,n[0].changed===1?`change`:`changes`]})]}),n.length>1&&(0,I.jsx)(`div`,{className:`flex max-h-60 flex-col gap-0.5 overflow-y-auto`,children:n.map(n=>(0,I.jsxs)(`label`,{className:`hover:bg-accent flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5`,children:[(0,I.jsx)(`input`,{type:`checkbox`,disabled:s[n.path]?.kind===`failed`,checked:r.includes(n.path)&&s[n.path]?.kind!==`failed`,onChange:e=>i(e.target.checked?[...r,n.path]:r.filter(e=>e!==n.path))}),(0,I.jsx)(`span`,{className:`truncate font-medium`,children:LL(n.path,t)}),e.action===`pullRequest`?(0,I.jsx)(FL,{head:n.branch??`detached`,target:s[n.path],onBase:e=>g(n.path,e)}):(0,I.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:n.branch??`detached`}),(0,I.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0 text-xs tabular-nums`,children:e.action===`push`?n.upstream===null?`not pushed yet`:`↑${n.ahead}`:n.changed>0&&`${n.changed} ${n.changed===1?`change`:`changes`}`})]},n.path))}),e.action===`commit`&&(0,I.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),placeholder:`Leave empty to write the message with AI`,rows:5,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-none rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),e.action===`pullRequest`&&p.length>0&&(0,I.jsxs)(`p`,{children:[`You have local changes`,n.length>1&&` in ${p.map(e=>LL(e.path,t)).join(`, `)}`,`. Do you want to commit and push them before creating the pull request?`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.action===`commit`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(x,{variant:`outline`,size:`sm`,disabled:d.length===0,onClick:()=>v(!1),children:`Commit`}),(0,I.jsx)(x,{size:`sm`,disabled:d.length===0,onClick:()=>v(!0),children:`Commit and Push`})]}),e.action===`push`&&(0,I.jsx)(x,{size:`sm`,disabled:d.length===0,onClick:y,children:`Push`}),e.action===`pullRequest`&&p.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(x,{variant:`outline`,size:`sm`,disabled:f,onClick:()=>S(!1),children:`Continue without them`}),(0,I.jsx)(x,{size:`sm`,disabled:f,onClick:()=>S(!0),children:`Commit and continue`})]}),e.action===`pullRequest`&&p.length===0&&(0,I.jsx)(x,{size:`sm`,disabled:f||d.length===0,onClick:()=>S(!1),children:`Create pull request`})]})]}),l!==null&&(0,I.jsx)(`div`,{className:`flex max-h-[60vh] flex-col gap-2 overflow-y-auto`,children:l.map(e=>{let r=e.draft;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 overflow-hidden`,children:(0,I.jsx)(w,{icon:Aae[e.state],className:P(`size-4`,e.state===`working`&&`animate-spin`,e.state===`review`&&`text-info`,e.state===`done`&&`text-success`,e.state===`failed`&&`text-destructive`,e.state===`skipped`&&`text-muted-foreground`)})}),(0,I.jsx)(`span`,{className:`shrink-0 font-medium`,children:LL(e.path,t)}),(0,I.jsxs)(`span`,{className:P(`min-w-0 text-xs leading-5 break-words whitespace-pre-wrap`,e.state===`failed`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.url!==null&&(0,I.jsxs)(I.Fragment,{children:[` `,(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline hover:underline-offset-2`,children:e.url})]})]})]}),e.state===`review`&&r!==null&&(0,I.jsx)(kae,{draft:r,onChange:t=>m(e.path,{draft:t}),onSkip:n.length===1?null:()=>m(e.path,{state:`skipped`,text:`Skipped`,draft:null}),onRegenerate:()=>void h(e.path,()=>b(e.path,!1,r.base)),onCreate:()=>C(e.path,r)})]},e.path)})})]})})}function IL(e,t){if(t===`commit`)return e.filter(e=>e.changed>0);if(t===`push`)return e.filter(e=>e.branch!==null&&(e.upstream===null||e.ahead>0));if(t===`pullRequest`)return e.filter(e=>e.branch!==null);throw Error(`Unknown git action ${String(t)}`)}function LL(e,t){return e===``?t:e}var Mae=3e3,Nae=18e4;function RL(e,t,n){let[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(0);(0,F.useEffect)(()=>{if(t===null)return;let n=f9(e,t),r={projectId:t},a=!0,o=!1,s=!1;async function c(){if(!o){o=!0;try{let t=await L(e,`git.status`,r);if(!a)return;s=!1,i(e=>e!==null&&e.key===n&&ws(e.repos,t)?e:{key:n,repos:t})}catch(e){a&&!s&&(s=!0,R9(e))}finally{o=!1}}}function l(){document.hidden||c()}c();let u=window.setInterval(l,Mae);return window.addEventListener(`focus`,l),()=>{a=!1,window.clearInterval(u),window.removeEventListener(`focus`,l)}},[e,t,n,a]),(0,F.useEffect)(()=>{if(t===null)return;let n={projectId:t},r=!0,i=!1;async function a(){if(!document.hidden)try{await L(e,`git.fetch`,n),r&&(i=!1,o(e=>e+1))}catch(e){r&&!i&&(i=!0,R9(e))}}a();let s=window.setInterval(a,Nae);return()=>{r=!1,window.clearInterval(s)}},[e,t]);let s=(0,F.useCallback)(()=>o(e=>e+1),[]);return{repos:r!==null&&t!==null&&r.key===f9(e,t)?r.repos:[],refresh:s}}function zL(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(!1),l=IL(e.repos,`push`),u=IL(e.repos,`commit`);function d(t){DL({labels:{working:`Pushing…`,done:`Pushed`,failed:`Push failed`},task:async()=>(await L(e.machine,`git.push`,{projectId:e.projectId,repo:t}),null),onRefresh:e.onRefresh})}async function f(){if(u.length===1)i(!1),OL(e,u[0].path,``,!1);else{c(!0);try{for(let t of u)await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t.path,message:``,push:!1});i(!1)}catch(e){R9(e)}finally{c(!1),e.onRefresh()}}}return{target:e,action:t,setAction:n,menuOpen:r,setMenuOpen:i,branchRepo:a,setBranchRepo:o,committing:s,pushable:l,committable:u,push:d,yoloCommit:f}}function BL(e){let t=e.git,n=t.target.repos,r=n.reduce((e,t)=>e+t.ahead,0);return(0,I.jsxs)(I.Fragment,{children:[e.collapsed&&n.map(e=>(0,I.jsxs)(IC,{onSelect:()=>t.setBranchRepo(e.path),children:[(0,I.jsx)(w,{icon:S_}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`}),(0,I.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,I.jsx)(bL,{behind:e.behind,ahead:e.ahead})})]},e.path)),e.collapsed&&(0,I.jsx)(VC,{}),e.collapsed&&(0,I.jsxs)(IC,{disabled:t.committable.length===0,onSelect:()=>t.setAction(`commit`),children:[(0,I.jsx)(w,{icon:C_}),`Commit…`]}),(0,I.jsxs)(IC,{disabled:t.pushable.length===0||t.committing,onSelect:()=>{t.pushable.length===1?t.push(t.pushable[0].path):t.setAction(`push`)},children:[(0,I.jsx)(w,{icon:o_}),t.pushable.length>1?`Just Push…`:`Just Push`,r>0&&(0,I.jsxs)(`span`,{className:`text-muted-foreground ml-auto text-xs tabular-nums`,children:[`↑`,r]})]}),(0,I.jsxs)(IC,{disabled:t.committable.length===0||t.committing,onSelect:e=>{e.preventDefault(),t.yoloCommit()},children:[(0,I.jsx)(w,{icon:t.committing?n_:C_,className:P(t.committing&&`animate-spin`)}),t.committing?`Committing…`:`Yolo Commit`]}),(0,I.jsx)(VC,{}),(0,I.jsxs)(IC,{disabled:IL(n,`pullRequest`).length===0,onSelect:()=>t.setAction(`pullRequest`),children:[(0,I.jsx)(w,{icon:E_}),`Create pull request…`]})]})}function VL(e){let t=e.git,n=t.target.repos.find(e=>e.path===t.branchRepo);return(0,I.jsxs)(I.Fragment,{children:[t.action!==null&&(0,I.jsx)(jae,{machine:t.target.machine,projectId:t.target.projectId,action:t.action,repos:t.target.repos,onClose:()=>t.setAction(null),onRefresh:t.target.onRefresh}),t.branchRepo!==null&&n!==void 0&&(0,I.jsx)(Sae,{machine:t.target.machine,projectId:t.target.projectId,repo:n,onRefresh:t.target.onRefresh,onClose:()=>t.setBranchRepo(null)})]})}function Pae(e){let t=zL(e),[n,r]=(0,F.useState)(!1),i=[...new Set(e.repos.map(e=>e.branch??`detached`))],a=e.repos.flatMap(e=>{let t=xL(e);return t===null?[]:[{repo:e,next:t}]}),o=e.repos.map(e=>e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`).join(`
111
+ `).map((n,r)=>(0,I.jsxs)(`div`,{className:P(`px-2 whitespace-pre-wrap`,e.added&&`bg-diff-addition/10 text-diff-addition`,e.removed&&`bg-diff-deletion/10 text-diff-deletion`,!e.added&&!e.removed&&`text-muted-foreground`),children:[e.added?`+`:e.removed?`-`:` `,` `,n]},`${t}:${r}`)))})}function oL(e){return typeof e==`string`?e:``}function sL(e,t){return e.startsWith(t+`/`)?e.slice(t.length+1):e}var cL=`(Recommended)`;function lL(e){let t=e.options.map(e=>e.label).filter(e=>e.endsWith(cL));return e.multiSelect?t:t.slice(0,1)}function uL(e){return(0,I.jsxs)(`span`,{className:P(`mt-0.5 grid size-4 shrink-0 place-items-center border transition-colors`,e.multi?`rounded`:`rounded-full`,e.selected&&`border-primary bg-primary text-primary-foreground`,e.suggested&&`border-primary border-dashed`,!e.selected&&!e.suggested&&`border-muted-foreground/40`),children:[e.selected&&e.multi&&(0,I.jsx)(w,{icon:Yg,strokeWidth:3,className:`size-3`}),e.selected&&!e.multi&&(0,I.jsx)(`span`,{className:`bg-primary-foreground size-1.5 rounded-full`})]})}function dL(e){let[t,n]=(0,F.useState)(Date.now);(0,F.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.ceil((e.at-t)/1e3));return(0,I.jsxs)(`span`,{className:`text-muted-foreground text-2xs mr-1 tabular-nums`,children:[e.label,` in`,` `,r<60?`${r}s`:`${Math.ceil(r/60)}m`]})}var cae=`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`;function lae(e){let t=e.request;if(t.kind===`question`)return(0,I.jsx)(uae,{machine:e.machine,request:t,draft:e.draft});let n=t.kind===`plan`,r=n?``:aae(t.item,e.cwd);return(0,I.jsx)(`div`,{className:P(cae,`border-warning/28 bg-linear-to-b from-warning/8 to-warning/8`),children:(0,I.jsxs)(`div`,{className:`grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-x-2 gap-y-3 px-1 py-1`,children:[(0,I.jsx)(`span`,{className:`text-warning flex justify-center pt-0.5`,children:(0,I.jsx)(w,{icon:J_,className:`size-4`})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground text-2xs flex w-full min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-warning shrink-0 font-medium`,children:n?`Ready to code?`:t.title}),e.count>1&&(0,I.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:[`1/`,e.count]})]}),r!==``&&(0,I.jsx)(`span`,{className:`text-foreground block max-h-20 w-full min-w-0 overflow-auto font-mono text-xs whitespace-pre`,children:r})]}),(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[t.autoResolve!==void 0&&(0,I.jsx)(dL,{label:t.autoResolve.decision===`allow`?`Approve`:`Decline`,at:t.autoResolve.at}),(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>dw(t.id,`deny`,null),children:n?`Keep planning`:`Decline`}),t.kind===`approval`&&t.canAlwaysAllow&&(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>dw(t.id,`always`,null),children:`Always`}),(0,I.jsx)(x,{size:`xs`,onClick:()=>dw(t.id,`allow`,null),children:n?`Approve plan`:`Approve`})]}),n&&(0,I.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,I.jsx)(PI,{text:t.plan})}),t.kind===`approval`&&t.item.kind!==`command`&&(0,I.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,I.jsx)(nL,{item:t.item})})]})})}function uae(e){let t=e.request.questions,[n,r]=(0,F.useState)(0),[i,a]=(0,F.useState)({}),[o,s]=(0,F.useState)({}),c=Object.fromEntries(t.map(e=>[e.question,[...i[e.question]??[],o[e.question]?.trim()??``].filter(e=>e!==``)])),l=Object.fromEntries(t.map(e=>[e.question,(c[e.question].length>0?c[e.question]:lL(e)).join(`, `)])),u=t[n],d=t.flatMap((e,t)=>c[e.question].length===0?[t]:[]),f=d.find(e=>e>n)??d[0];function p(e,c){let l=i[e.question]??[];e.multiSelect?a({...i,[e.question]:l.includes(c)?l.filter(e=>e!==c):[...l,c]}):(a({...i,[e.question]:[c]}),s({...o,[e.question]:``}),n<t.length-1&&r(n+1))}function m(e,t){s({...o,[e.question]:t}),!e.multiSelect&&t.trim()!==``&&a({...i,[e.question]:[]})}async function h(t,n){let r=Sw(Z().items,[e.draft,...Object.values(o)]);for(let i of n)try{let n=await KC(e.machine,i),o=n;i.type.startsWith(`image/`)&&(r+=1,o=`[Image #${r}] (saved at ${n})`),s(e=>{let n=e[t.question]??``;return{...e,[t.question]:`${n}${/(^|\s)$/.test(n)?``:` `}${o}`}}),t.multiSelect||a(e=>({...e,[t.question]:[]}))}catch(e){R9(e)}}return(0,I.jsx)(`div`,{className:`composer-glass shadow-composer relative z-10 rounded-3xl border border-(--composer-outline)`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 p-2.5`,children:[(0,I.jsxs)(`div`,{role:`tabpanel`,className:`flex min-w-0 flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-start gap-1.5 pt-1 pr-1 pl-1.5`,children:[(0,I.jsx)(`span`,{className:`bg-primary/18 text-primary grid size-6 shrink-0 place-items-center rounded-md`,children:(0,I.jsx)(w,{icon:hee,className:`size-4`})}),(0,I.jsx)(`p`,{className:`text-foreground min-w-0 flex-1 pt-0.5 text-[15px] leading-5 font-medium`,children:u.question}),(0,I.jsx)(x,{size:`icon-xs`,variant:`ghost`,"aria-label":`Skip questions`,title:`Skip questions`,onClick:()=>dw(e.request.id,`deny`,null),children:(0,I.jsx)(w,{icon:je})})]}),(0,I.jsxs)(`div`,{role:u.multiSelect?`group`:`radiogroup`,"aria-label":u.question,className:`flex max-h-[min(18rem,32dvh)] flex-col gap-0.5 overflow-y-auto`,children:[u.options.map(e=>{let t=i[u.question]?.includes(e.label)===!0,n=c[u.question].length===0&&lL(u).includes(e.label),r=e.label.endsWith(cL);return(0,I.jsxs)(`button`,{role:u.multiSelect?`checkbox`:`radio`,"aria-checked":t,className:P(`flex cursor-pointer items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors`,t?`bg-muted/70`:`hover:bg-muted/40`),onClick:()=>p(u,e.label),children:[(0,I.jsx)(uL,{multi:u.multiSelect,selected:t,suggested:n}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-foreground text-sm`,children:r?e.label.slice(0,-13).trim():e.label}),r&&(0,I.jsx)(`span`,{className:`text-muted-foreground/70 text-[11px]`,children:`Recommended`})]}),e.description!==``&&(0,I.jsx)(`span`,{className:`text-secondary-label mt-0.5 block text-xs leading-4`,children:e.description})]})]},e.label)}),(0,I.jsxs)(`label`,{className:P(`flex cursor-text items-start gap-2.5 rounded-lg px-2.5 py-2 transition-colors`,(o[u.question]??``).trim()===``?`focus-within:bg-muted/40 hover:bg-muted/40`:`bg-muted/70`),children:[(0,I.jsx)(uL,{multi:u.multiSelect,selected:(o[u.question]??``).trim()!==``,suggested:!1}),(0,I.jsx)(`textarea`,{value:o[u.question]??``,rows:1,onChange:e=>m(u,e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);if(t!==``){e.preventDefault(),document.execCommand(`insertText`,!1,t);return}let n=[...e.clipboardData.files];n.length!==0&&(e.preventDefault(),h(u,n))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),h(u,[...e.dataTransfer.files])},placeholder:`Something else…`,className:`placeholder:text-placeholder/75 [field-sizing:content] max-h-40 min-w-0 flex-1 resize-none bg-transparent text-sm leading-5 outline-none`})]})]})]},u.question),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.length>1&&(0,I.jsx)(`div`,{role:`tablist`,className:`flex min-w-0 [scrollbar-width:none] gap-1 overflow-x-auto`,children:t.map((e,t)=>(0,I.jsxs)(`button`,{role:`tab`,"aria-selected":t===n,className:P(`flex h-6 shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,t===n?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`),onClick:()=>r(t),children:[c[e.question].length>0&&(0,I.jsx)(w,{icon:Xg,"aria-label":`Answered`,className:`text-success size-3.5`}),c[e.question].length===0&&l[e.question]!==``&&(0,I.jsx)(w,{icon:n_,"aria-label":`Using the recommended answer`,className:`text-primary size-3.5`}),l[e.question]===``&&(0,I.jsx)(w,{icon:eee,"aria-label":`Not answered`,className:`text-muted-foreground size-3.5`}),e.header]},e.question))}),(0,I.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5 pr-1`,children:[e.request.autoResolve!==void 0&&(0,I.jsx)(dL,{label:`Skip`,at:e.request.autoResolve.at}),(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>dw(e.request.id,`allow`,{}),children:`Skip`}),(0,I.jsx)(x,{size:`xs`,variant:f===void 0?`default`:`outline`,onClick:()=>dw(e.request.id,`allow`,Object.fromEntries(t.flatMap(e=>c[e.question].length===0?[]:[[e.question,c[e.question].join(`, `)]]))),children:`Submit`}),f!==void 0&&(0,I.jsx)(x,{size:`xs`,onClick:()=>{c[u.question].length===0&&a({...i,[u.question]:lL(u)}),r(f)},children:`Next`})]})]})]})})}function fL({...e}){return(0,I.jsx)(Kx,{"data-slot":`popover`,...e})}function pL({...e}){return(0,I.jsx)(Jx,{"data-slot":`popover-trigger`,...e})}function mL({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,I.jsx)(Qx,{children:(0,I.jsx)(eS,{"data-slot":`popover-content`,sideOffset:n,align:t,className:P(`z-50 origin-(--radix-popover-content-transform-origin) overflow-hidden rounded-lg dropdown-glass text-popover-foreground shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] outline-none dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)] duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}var hL=`relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-(--control-radius) border border-transparent outline-none hover:bg-accent data-[state=open]:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64 [&_svg]:pointer-events-none [&_svg]:shrink-0`,gL=`h-7 gap-1.5 px-1.5 text-sm sm:px-2.5 font-medium text-secondary-label hover:text-foreground [&_svg:not([class*=text-])]:text-muted-foreground [&_svg:not([class*=size-])]:size-4`;function dae(){let e=Q(e=>e.settings),t=Q(e=>e.capabilities)?.models.find(t=>t.value===e.model);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(fae,{}),(0,I.jsx)(`span`,{className:`bg-border mx-0.5 hidden h-4 w-px shrink-0 sm:block`}),t!==void 0&&t.efforts.length>0&&(0,I.jsx)(pae,{title:`Effort`,trigger:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w,{icon:Hg}),(0,I.jsx)(`span`,{className:`capitalize`,children:e.effort??`Default`})]}),value:e.effort??`default`,options:[...e.provider===`opencode`?[{value:`default`,label:`Default`}]:[],...t.efforts.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))],onChange:e=>J9({effort:e==="default"?null:e})})]})}function fae(){let e=Q(e=>e.settings),t=Q(e=>e.selection),n=Q(e=>e.machines.find(t=>t.id===e.selection?.machine)),r=[...[...n?.claudeAccounts??[],...n?.codexAccounts??[]].filter(e=>e.valid).map(e=>({key:e.id,provider:e.provider,accountId:e.id,name:e.name,color:e.color,plan:e.plan,error:e.error})),...n?.openCode.available===!0?[{key:`opencode`,provider:`opencode`,accountId:null,name:`OpenCode`,color:null,plan:null,error:null}]:[]].filter(n=>t?.sessionId===null||n.provider===e.provider),i=e.provider===`opencode`?`opencode`:e.accountId,a=Q(e=>e.capabilities),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(i),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)({}),m=(0,F.useRef)(null),h=a?.models.find(t=>t.value===e.model)?.name??e.model??`Choose a model`,g=r.find(e=>e.key===i),_=c===null?[]:c===i?a?.models??null:f[c]??null,v=r.find(e=>e.key===c)?.provider,y=(_??[]).filter(e=>!e.hidden),b=y.length>=5,x=b?u.trim().toLowerCase():``,S=y.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(x));function C(e){if(s(e),e&&(l(i),d(``),t!==null))for(let e of r)e.key!==i&&e.error===null&&L(t.machine,`capabilities`,{provider:e.provider,accountId:e.accountId,projectId:t.projectId}).then(t=>p(n=>({...n,[e.key]:t.models})),R9)}function T(n,i){let a=r.find(e=>e.key===n);if(a===void 0||t===null)return;let o=a.provider,s={accountId:a.accountId,model:i.value,...i.effort===null?{}:{effort:i.effort}};o===e.provider?J9(s):J9({...q9(T9(Z(),t.machine).composer,o),...s})}return(0,I.jsxs)(fL,{open:o,onOpenChange:C,children:[(0,I.jsx)(pL,{asChild:!0,children:(0,I.jsxs)(`button`,{className:P(hL,gL),title:g===void 0?`Model`:`${g.name} · ${h}`,children:[(0,I.jsxs)(`span`,{className:`relative`,children:[(0,I.jsx)(Yv,{provider:e.provider,className:`size-4`}),r.filter(t=>t.provider===e.provider).length>1&&g!==void 0&&(0,I.jsx)(`span`,{className:P(`pointer-events-none absolute -right-1 -bottom-1 flex h-3 min-w-3 items-center justify-center rounded-full border px-0.5 text-[8px] leading-none font-semibold shadow-sm`,g.color===null?`bg-card text-muted-foreground`:`border-card text-white`),style:g.color===null?void 0:{backgroundColor:g.color},children:g.name.charAt(0).toUpperCase()})]}),(0,I.jsx)(`span`,{className:`max-w-40 truncate`,children:h})]})}),(0,I.jsxs)(mL,{side:`top`,className:`flex max-h-86.5 w-screen max-w-90 flex-row`,onOpenAutoFocus:e=>{e.preventDefault(),m.current?.focus()},onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:[r.length>1&&(0,I.jsxs)(`div`,{className:`bg-muted/30 flex w-11 shrink-0 [scrollbar-width:none] flex-col gap-1 overflow-y-auto p-1`,children:[r.map(t=>(0,I.jsxs)(`div`,{className:`relative w-full`,children:[t.key===c&&(0,I.jsx)(`div`,{className:`bg-primary pointer-events-none absolute top-1/2 -right-1 z-10 h-5 w-0.75 -translate-y-1/2 rounded-l-full`}),(0,I.jsx)(Oe,{side:`left`,label:t.error===null?[t.name,t.plan].filter(e=>e!==null).join(` · `):`${t.name} — ${t.error}`,children:(0,I.jsxs)(`button`,{className:P(`hover:bg-foreground/10 focus-visible:bg-foreground/10 relative flex aspect-square w-full cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,t.error!==null&&`cursor-not-allowed opacity-50 hover:bg-transparent`),"aria-label":t.name,"aria-pressed":t.key===c,"aria-disabled":t.error!==null,onClick:()=>{if(t.error!==null)return;let n=f[t.key]?.find(t=>t.value===e.model);t.key!==i&&i!==null&&a!==null&&n!==void 0&&(p(e=>({...e,[i]:a.models})),T(t.key,n)),l(t.key)},children:[(0,I.jsx)(Yv,{provider:t.provider,className:`size-5`}),r.filter(e=>e.provider===t.provider).length>1&&(0,I.jsx)(`span`,{className:P(`text-3xs pointer-events-none absolute right-0.5 bottom-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full border px-0.5 leading-none font-semibold shadow-sm`,t.color===null?`bg-card text-muted-foreground`:`border-card text-white`),style:t.color===null?void 0:{backgroundColor:t.color},children:t.name.charAt(0).toUpperCase()})]})})]},t.key)),(0,I.jsx)(Oe,{side:`left`,label:`Manage accounts`,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:bg-foreground/10 hover:text-foreground focus-visible:bg-foreground/10 mt-auto flex aspect-square w-full shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,"aria-label":`Manage accounts`,onClick:()=>{s(!1),I9(C9[e.provider])},children:(0,I.jsx)(w,{icon:uv,className:`size-4.5`})})})]}),(0,I.jsxs)(`div`,{className:P(`bg-muted/40 flex min-h-0 min-w-0 flex-1 flex-col`,r.length>1&&`border-border/70 border-l`),children:[b&&(0,I.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5`,children:(0,I.jsxs)(`div`,{className:`border-border/70 focus-within:border-ring relative border-b pb-1.5 transition-colors`,children:[(0,I.jsx)(w,{icon:W_,className:`text-muted-foreground/55 pointer-events-none absolute top-1.5 left-0 size-4`}),(0,I.jsx)(`input`,{ref:m,value:u,placeholder:`Search models...`,className:`placeholder:text-muted-foreground/70 h-6.5 w-full bg-transparent ps-5 text-sm outline-none`,onChange:e=>d(e.target.value),onKeyDown:e=>{if(e.key!==`Enter`||c===null)return;let t=S.at(0);t!==void 0&&(e.preventDefault(),T(c,t),s(!1))}})]})}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-1.5`,children:S.length===0?(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:_===null?`Loading models…`:`No models found`}):S.map(t=>(0,I.jsx)(`button`,{className:P(`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer flex-col justify-center rounded-sm px-2 py-1.5 text-left`,c===i&&t.value===e.model&&`text-foreground bg-foreground/[0.08]`),onClick:()=>{c!==null&&(T(c,t),s(!1))},children:(0,I.jsxs)(`span`,{className:`truncate text-sm leading-snug font-medium`,children:[t.name,v===`opencode`&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs font-normal`,children:t.description})]})},t.value))})]})]})]})}function pae(e){return(0,I.jsxs)(MC,{children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsx)(`button`,{className:P(hL,gL),title:e.title,children:e.trigger})}),(0,I.jsxs)(FC,{className:`w-72`,side:`top`,align:`start`,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:[(0,I.jsx)(BC,{children:e.title}),(0,I.jsx)(RC,{value:e.value,onValueChange:e.onChange,children:e.options.map(e=>(0,I.jsx)(zC,{value:e.value,children:e.label},e.value))})]})]})}function mae(e){let t=Q(e=>e.selection?.sessionId),n=Q(t=>E9(t,e.machine,e.projectId)),r=Q(e=>e.projects),i=Q(e=>e.machines);return(0,I.jsx)(`div`,{className:`absolute inset-x-0 bottom-full pb-4`,children:(0,I.jsxs)(`h1`,{className:`text-foreground w-full text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:[`What should we build in`,` `,t===null?(0,I.jsxs)(MC,{children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`border-muted-foreground/35 hover:border-foreground/60 inline-flex max-w-64 cursor-pointer border-b border-dotted align-bottom outline-none`,title:n?.path,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:n?.name}),`?`]})}),(0,I.jsx)(FC,{className:`max-h-80 w-64`,onCloseAutoFocus:t=>{t.preventDefault(),e.onCloseMenu()},children:(0,I.jsx)(RC,{value:f9(e.machine,e.projectId),children:[...r].sort((e,t)=>i.findIndex(t=>t.id===e.machine)-i.findIndex(e=>e.id===t.machine)).map(e=>(0,I.jsxs)(zC,{value:f9(e.machine,e.id),title:e.path,onSelect:()=>rw({machine:e.machine,projectId:e.id,sessionId:null}),children:[(0,I.jsx)(qv,{machine:e.machine,projectId:e.id,className:`size-4 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,i.length>1&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-1.5 text-xs`,children:i.find(t=>t.id===e.machine)?.name})]})]},f9(e.machine,e.id)))})})]}):(0,I.jsx)(`span`,{className:`border-muted-foreground/35 inline-block max-w-64 truncate border-b border-dotted align-bottom`,title:n?.path,children:n?.name}),t!==null&&`?`]})})}function hae(){let e=Q(e=>e.queue);return(0,I.jsx)(`div`,{className:`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 border-(--composer-outline) px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`grid min-h-6 grid-cols-[1.5rem_minmax(0,1fr)_auto_auto] items-center gap-x-1`,children:[(0,I.jsx)(w,{icon:fee,className:`text-muted-foreground mx-auto size-3`}),(0,I.jsx)(`span`,{className:`text-secondary-label truncate`,children:e.prompt.text===``?`${e.prompt.images.length} image(s)`:e.prompt.text}),(0,I.jsx)(x,{variant:`ghost-muted`,size:`icon-xs`,title:`Send now`,onClick:()=>cw(e.id),children:(0,I.jsx)(w,{icon:Bg})}),(0,I.jsx)(x,{variant:`ghost-muted`,size:`icon-xs`,title:`Remove from queue`,onClick:()=>sw(e.id),children:(0,I.jsx)(w,{icon:je})})]},e.id))})}function gae(e){return(0,I.jsxs)(I.Fragment,{children:[e.running&&e.empty&&(0,I.jsx)(`button`,{className:`bg-destructive/90 shadow-destructive/24 hover:bg-destructive flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full text-white shadow-xs transition-colors`,title:`Stop (Esc)`,"aria-label":`Stop generation`,onClick:e.onStop,children:(0,I.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,I.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),!(e.running&&e.empty)&&(0,I.jsx)(`button`,{className:`bg-message-action text-message-action-foreground shadow-message-action/24 hover:bg-message-action-hover relative flex size-9 items-center justify-center overflow-hidden rounded-full shadow-xs transition-all duration-150 hover:scale-105 enabled:cursor-pointer disabled:pointer-events-none disabled:opacity-64 disabled:shadow-none`,title:e.running&&e.delivery===`steer`?`Send now (Enter) · Queue (${et}+Enter)`:e.running?`Queue (Enter) · Send now (${et}+Enter)`:`Send (Enter)`,"aria-label":`Send message`,disabled:e.empty,onClick:t=>e.onSubmit(t.metaKey||t.ctrlKey),children:(0,I.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]})}var _ae=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],vae=5242880,_L=window.matchMedia(`(pointer: coarse)`);function vL(){let e=Q(e=>e.selection),t=Q(e=>e.loaded),n=Q(e=>e.items.length===0&&e.partial===``),r=Q(e=>e.requests),i=Q(e=>e.queue),a=Q(e=>e.draft),o=Q(e=>e.capabilities),s=Q(e=>e.settings.provider===`opencode`?e.machines.find(t=>t.id===e.selection?.machine)?.openCode.available!==!0:e.settings.accountId===null),[c,l]=(0,F.useState)(0),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(0),[m,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)([]),v=(0,F.useRef)(null),y=(0,F.useRef)(null),b=e?.machine??``,S=e?.projectId??``,C=Q(e=>E9(e,b,S)),T=Q(e=>T9(e,b).status),E=Q(e=>T9(e,b).config?.delivery??null),D=f9(b,e?.sessionId??S),O=Bs(D),k=O.text,A=O.images,[ee,j]=(0,F.useState)(k.length),M=Q(j9),te=t&&n&&!M,ne=r.at(0);(0,F.useEffect)(()=>{let e=v.current;e===null||_L.matches||(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[e]),(0,F.useEffect)(()=>{if(a===null)return;let e=Cw(a);Vs(D,t=>({...t,...e})),j(e.text.length),N9(null),v.current?.focus()},[a,D]),(0,F.useEffect)(()=>{T===`online`&&L(b,`files.list`,{projectId:S}).then(_,R9)},[b,S,T]);let re=k.slice(0,ee),ie=/^\/\S*$/.exec(re)?.[0]??/(?:^|\s)(@\S*)$/.exec(re)?.[1]??null,ae=ie?.slice(1).toLowerCase()??``,oe=ie===null||m?[]:ie.startsWith(`/`)?(o?.commands??[]).filter(e=>e.name.toLowerCase().includes(ae)).sort((e,t)=>Number(!e.name.toLowerCase().startsWith(ae))-Number(!t.name.toLowerCase().startsWith(ae))).map(e=>({key:e.name,label:`/${e.name}${e.hint===``?``:` ${e.hint}`}`,description:e.description,insert:`/${e.name}`})):g.filter(e=>e.toLowerCase().includes(ae)).slice(0,50).map(e=>({key:e,label:e,description:``,insert:`@${e}`})),se=Math.min(f,oe.length-1),ce=k.trim()===``&&A.length===0||c>0||u||s;function le(e,t){Vs(D,t=>({...t,text:e,images:t.images.filter(t=>e.includes(`[Image #${t.number}]`))})),j(t),p(0),h(!1)}function ue(e){if(ie===null)return;let t=ee-ie.length,n=t+e.insert.length+1;le(`${k.slice(0,t)}${e.insert} ${k.slice(ee)}`,n),requestAnimationFrame(()=>v.current?.setSelectionRange(n,n))}async function de(e){if(!ce){d(!0);try{if(E===null)throw Error(`This machine is not connected`);await ow({text:k.trim(),images:A.map(e=>({mediaType:e.mediaType,data:e.data}))},e?E===`queue`?`steer`:`queue`:E),Vs(D,e=>({...e,text:``,images:[]})),j(0)}catch(e){R9(e)}finally{d(!1)}}}async function fe(e){let t=ee,n=/(^|\s)$/.test(k.slice(0,ee))?``:` `;for(let r of e)if(_ae.includes(r.type)&&r.size<=vae){let e=await qC(r),i=Sw(Z().items,[Us(D).text])+1,a={number:i,mediaType:r.type,data:e},o=t,s=`${n}[Image #${i}] `;n=``,Vs(D,e=>({...e,text:`${e.text.slice(0,o)}${s}${e.text.slice(o)}`,images:[...e.images,a]})),t+=s.length,j(t),requestAnimationFrame(()=>v.current?.setSelectionRange(t,t))}else{l(e=>e+1);try{let e=await KC(b,r);Vs(D,t=>({...t,text:`${t.text}${/(^|\s)$/.test(t.text)?``:` `}@${e} `}))}catch(e){R9(e)}finally{l(e=>e-1)}}}return(0,I.jsx)(`div`,{className:P(`pointer-events-none z-20`,te?`absolute inset-0 flex items-center pb-3 sm:pb-4`:`relative shrink-0 before:absolute before:right-(--app-scrollbar-width) before:bottom-full before:left-0 before:h-8 before:bg-linear-to-t before:from-background before:to-transparent`),children:(0,I.jsxs)(JC,{width:`composer`,className:`pointer-events-auto relative z-10`,children:[te&&(0,I.jsx)(mae,{machine:b,projectId:S,onCloseMenu:()=>v.current?.focus()}),i.length>0&&oe.length===0&&(0,I.jsx)(hae,{}),ne!==void 0&&oe.length===0&&(0,I.jsx)(lae,{request:ne,machine:b,cwd:C?.path??``,count:r.length,draft:k},ne.id),oe.length>0&&(0,I.jsx)(ww,{items:oe,active:se,onHover:p,onPick:ue}),(0,I.jsxs)(`div`,{className:P(`composer-glass shadow-composer relative z-10 border border-(--composer-outline) transition-[border-color,box-shadow] duration-150 ease-out focus-within:border-[color-mix(in_srgb,var(--text)_16%,transparent)] focus-within:ring-4 focus-within:ring-[color-mix(in_srgb,var(--text)_4%,transparent)] dark:shadow-none`,te?`rounded-3xl`:`rounded-t-3xl border-b-0`,ne?.kind===`question`&&`hidden`),onMouseDown:e=>{e.target instanceof Element&&e.currentTarget.contains(e.target)&&(e.target.closest(`button, a, input, textarea`)||(e.preventDefault(),v.current?.focus()))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),fe([...e.dataTransfer.files])},children:[(0,I.jsxs)(`div`,{className:P(`pb-2`,A.length>0&&`pt-3.5 sm:pt-4`),children:[A.length>0&&(0,I.jsx)(xw,{draftKey:D}),(0,I.jsx)(`textarea`,{ref:v,"data-composer":!0,rows:1,spellCheck:!1,autoCorrect:`off`,"data-gramm":`false`,"data-gramm_editor":`false`,"data-enable-grammarly":`false`,"data-lt-active":`false`,value:k,onChange:e=>le(e.target.value,e.target.selectionStart),onSelect:e=>j(e.currentTarget.selectionStart),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);if(t!==``){e.preventDefault(),document.execCommand(`insertText`,!1,t);return}let n=[...e.clipboardData.files];n.length!==0&&(e.preventDefault(),fe(n))},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(oe.length>0){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;p((se+t+oe.length)%oe.length);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),ue(oe[se]);return}if(e.key===`Escape`){e.preventDefault(),h(!0);return}}if(e.key===`Enter`&&!e.shiftKey&&!_L.matches)e.preventDefault(),de(e.metaKey||e.ctrlKey);else if(e.key===`ArrowUp`&&k===``){let t=yae(Z().items);if(t===null)return;e.preventDefault(),le(t,t.length)}else e.key===`Escape`&&M&&lw()}},placeholder:s?`Add an account in Settings to start`:M&&E===`steer`?`Steer the agent… (${et}+Enter to queue)`:M?`Queue a follow-up… (${et}+Enter to send now)`:`Ask anything, @tag files/folders, or / for commands`,className:P(`placeholder:text-placeholder/75 block [field-sizing:content] w-full resize-none bg-transparent px-3 text-sm leading-relaxed outline-none sm:px-4`,A.length>0?`max-h-52 min-h-19.5`:`max-h-55.5 min-h-20 pt-3.5 sm:max-h-56 sm:pt-4 [@media(min-height:840px)]:min-h-23 sm:[@media(min-height:840px)]:min-h-23.5`)})]}),(0,I.jsxs)(`div`,{className:P(`flex min-w-0 items-center justify-between gap-2 px-3 sm:px-4`,te?`pb-3 sm:pb-4`:`pb-2.5 sm:pb-3.5`),children:[(0,I.jsx)(`div`,{className:`-m-1 -ms-3.5 flex min-w-0 flex-1 [scrollbar-width:none] items-center gap-1 overflow-x-auto p-1 ps-2`,children:(0,I.jsx)(dae,{})}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[(0,I.jsx)(`input`,{ref:y,type:`file`,multiple:!0,hidden:!0,onChange:e=>{fe([...e.target.files??[]]),e.target.value=``}}),c>0&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Uploading…`}),(0,I.jsx)(Pw,{empty:ce,delivery:E,onSubmit:()=>void de(!0)}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:`Attach files`,"aria-label":`Attach files`,onClick:()=>y.current?.click(),children:(0,I.jsx)(w,{icon:Cee})}),(0,I.jsx)(gae,{running:M,empty:ce,delivery:E,onSubmit:e=>void de(e),onStop:lw})]})]})]})]})})}function yae(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.kind===`user`&&n.parent===null&&n.format===`text`&&n.text!==``)return n.text}return null}var bae=window.matchMedia(`(pointer: coarse)`);function xae(e){let[t,n]=(0,F.useState)(!1),r=xL(e.repo);return(0,I.jsxs)(fL,{open:t,onOpenChange:n,children:[(0,I.jsx)(pL,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground hidden max-w-48 cursor-pointer items-center gap-1 text-xs sm:flex`,title:`Switch or create a branch`,children:[(0,I.jsx)(w,{icon:r===null?S_:r.icon,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.repo.branch??`detached`})]})}),(0,I.jsx)(mL,{align:`end`,className:`flex max-h-86.5 w-72 flex-col`,children:(0,I.jsx)(yL,{target:e,onClose:()=>n(!1)})})]})}function Sae(e){return(0,I.jsx)(Ke,{open:!0,onOpenChange:e.onClose,children:(0,I.jsxs)(Ne,{showCloseButton:!1,"aria-describedby":void 0,className:`flex max-h-[min(30rem,calc(100dvh-2rem))] flex-col gap-0 p-0`,onOpenAutoFocus:e=>{bae.matches&&e.preventDefault()},children:[(0,I.jsx)(Ve,{className:`sr-only`,children:`Switch branch`}),(0,I.jsx)(yL,{target:e,onClose:e.onClose})]})})}function yL(e){let t=e.target,n=t.machine,r=t.projectId,i=t.repo.path,a=t.onRefresh,[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(!1),g=xL(t.repo),_=u.trim(),v=(o??[]).filter(e=>e.toLowerCase().includes(_.toLowerCase())),y=(c??[]).filter(e=>e.toLowerCase().includes(_.toLowerCase())),b=(o??[]).includes(_);(0,F.useEffect)(()=>{L(n,`git.localBranches`,{projectId:r,repo:i}).then(s,R9),L(n,`git.fetch`,{projectId:r}).then(a,R9)},[n,r,i,a]);async function x(){h(!0);try{await L(n,`git.sync`,{projectId:r,repo:i}),e.onClose()}catch(e){R9(e)}finally{h(!1),a()}}async function S(t,o){p(!0);try{await L(n,`git.switch`,{projectId:r,repo:i,branch:t,create:o}),e.onClose()}catch(e){R9(e)}finally{p(!1),a()}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5`,children:(0,I.jsxs)(`div`,{className:`border-border/70 focus-within:border-ring relative border-b pb-1.5 transition-colors`,children:[(0,I.jsx)(w,{icon:W_,className:`text-muted-foreground/55 pointer-events-none absolute top-1.5 left-0 size-4`}),(0,I.jsx)(`input`,{value:u,placeholder:`Search or create a branch...`,disabled:f,className:`placeholder:text-muted-foreground/70 h-6.5 w-full bg-transparent ps-5 text-sm outline-none`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_!==``&&o!==null&&(e.preventDefault(),S(_,!b))}})]})}),g!==null&&(0,I.jsx)(`div`,{className:`border-border/70 shrink-0 border-b px-2 py-1.5`,children:(0,I.jsxs)(`button`,{disabled:m||f,className:`hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void x(),children:[(0,I.jsx)(w,{icon:m?n_:g.icon,className:P(`size-3.5 shrink-0`,m&&`animate-spin`)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g.label}),(0,I.jsx)(bL,{behind:t.repo.behind,ahead:t.repo.ahead})]})}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-1.5`,children:[o===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:`Loading branches…`}),o!==null&&v.length===0&&_===``&&(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:`No branches`}),v.map(n=>(0,I.jsxs)(`button`,{disabled:f,className:P(`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,n===t.repo.branch&&`text-foreground bg-foreground/[0.08]`),onClick:()=>{n===t.repo.branch?e.onClose():S(n,!1)},children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),n===t.repo.branch&&(0,I.jsx)(w,{icon:Yg,strokeWidth:2.25,className:`size-3.5 shrink-0`})]},n)),c!==null&&y.length>0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-2 pt-2 pb-1 text-xs font-medium`,children:`Remote`}),y.map(e=>(0,I.jsx)(`button`,{disabled:f,className:`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void S(e.slice(e.indexOf(`/`)+1),!1),children:(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})},e)),o!==null&&_!==``&&!b&&(0,I.jsxs)(`button`,{disabled:f,className:`hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void S(_,!0),children:[(0,I.jsx)(w,{icon:xe,className:`size-3.5 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`Create branch `,(0,I.jsx)(`span`,{className:`font-medium`,children:_})]})]})]}),(0,I.jsx)(`div`,{className:`border-border/70 shrink-0 border-t px-2 py-1.5`,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm`,onClick:()=>{c===null?L(n,`git.remoteBranches`,{projectId:r,repo:i}).then(l,R9):l(null)},children:[(0,I.jsx)(w,{icon:a_,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c===null?`Show remote branches`:`Hide remote branches`})]})})]})}function bL(e){return(0,I.jsxs)(I.Fragment,{children:[e.behind>0&&(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`↓`,e.behind]}),e.ahead>0&&(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`↑`,e.ahead]})]})}function xL(e){return e.branch===null||!e.remote?null:e.upstream===null?{icon:o_,label:`Publish branch`}:e.behind>0&&e.ahead>0?{icon:Ng,label:`Pull and push`}:e.behind>0?{icon:Fg,label:`Pull commits`}:e.ahead>0?{icon:Bg,label:`Push commits`}:null}var Cae={working:n_,done:t_,failed:jg},SL=new Set,CL=null,wL=0;function TL(e){CL=e;for(let e of SL)e();e?.state===`done`&&setTimeout(()=>{CL?.id===e.id&&TL(null)},5e3)}function wae(e){return SL.add(e),()=>{SL.delete(e)}}function EL(e,t){wL+=1,TL(`url`in t?{id:wL,state:`done`,label:e,error:``,url:t.url}:{id:wL,state:`failed`,label:e,error:t.error,url:null})}async function DL(e){wL+=1;let t=wL;TL({id:t,state:`working`,label:e.labels.working,error:``,url:null});try{let n=await e.task();CL?.id===t&&TL({id:t,state:`done`,label:e.labels.done,error:``,url:n})}catch(n){CL?.id===t&&TL({id:t,state:`failed`,label:e.labels.failed,error:rt(n),url:null})}finally{e.onRefresh()}}function OL(e,t,n,r){DL({labels:r?{working:`Committing and pushing…`,done:`Committed and pushed`,failed:`Commit and push failed`}:{working:`Committing…`,done:`Committed`,failed:`Commit failed`},task:async()=>(await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t,message:n,push:r}),null),onRefresh:e.onRefresh})}function Tae(e,t,n){DL({labels:{working:`Creating pull request…`,done:`Pull request created`,failed:`Couldn't create pull request`},task:async()=>(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:n.base,head:n.head,title:n.title,body:n.body})).url,onRefresh:e.onRefresh})}function Eae(){let e=(0,F.useSyncExternalStore)(wae,()=>CL),[t,n]=(0,F.useState)(!1);return e===null?null:(0,I.jsxs)(`div`,{className:`bg-popover text-popover-foreground flex max-w-80 items-center gap-3 rounded-md border py-2 pr-2 pl-3 shadow-md`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,I.jsx)(w,{icon:Cae[e.state],className:P(`size-4 shrink-0`,e.state===`working`&&`animate-spin`,e.state===`done`&&`text-success`,e.state===`failed`&&`text-destructive`)}),(0,I.jsx)(`span`,{className:`truncate`,children:e.label})]}),e.url!==null&&(0,I.jsx)(x,{asChild:!0,size:`xs`,variant:`outline`,children:(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open`})}),e.state===`failed`&&(0,I.jsx)(x,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>n(!0),children:`View`}),(0,I.jsx)(x,{type:`button`,size:`icon-micro`,variant:`ghost-muted`,"aria-label":`Dismiss`,onClick:()=>{n(!1),TL(null)},children:(0,I.jsx)(w,{icon:je,className:`size-3.5`})}),(0,I.jsx)(Ke,{open:t&&e.state===`failed`,onOpenChange:n,children:(0,I.jsxs)(Ne,{className:`sm:max-w-lg`,children:[(0,I.jsx)(Fe,{children:(0,I.jsx)(Ve,{children:e.label})}),(0,I.jsx)(`pre`,{className:`bg-muted/50 max-h-[60vh] overflow-y-auto rounded-lg border p-3 font-mono text-xs break-words whitespace-pre-wrap`,children:e.error})]})})]})}function kL({className:e,type:t,...n}){return(0,I.jsx)(`input`,{type:t,"data-slot":`input`,className:P(`h-9 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function AL({...e}){return(0,I.jsx)(DS,{"data-slot":`select`,...e})}function jL({...e}){return(0,I.jsx)(jS,{"data-slot":`select-value`,...e})}function ML({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(kS,{"data-slot":`select-trigger`,"data-size":t,className:P(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,I.jsx)(MS,{asChild:!0,children:(0,I.jsx)(w,{icon:cv,className:`text-muted-foreground pointer-events-none size-4`})})]})}function NL({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,I.jsx)(FS,{children:(0,I.jsxs)(LS,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:P(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,I.jsx)(Dae,{}),(0,I.jsx)(YS,{"data-position":n,className:P(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,I.jsx)(Oae,{})]})})}function PL({className:e,children:t,...n}){return(0,I.jsxs)($S,{"data-slot":`select-item`,className:P(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,I.jsx)(rC,{children:(0,I.jsx)(w,{icon:Yg,className:`pointer-events-none`})})}),(0,I.jsx)(tC,{children:t})]})}function Dae({className:e,...t}){return(0,I.jsx)(aC,{"data-slot":`select-scroll-up-button`,className:P(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(w,{icon:$g})})}function Oae({className:e,...t}){return(0,I.jsx)(sC,{"data-slot":`select-scroll-down-button`,className:P(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(w,{icon:Zg})})}function FL(e){return e.target?.kind===`failed`?(0,I.jsx)(`span`,{className:`text-destructive truncate text-xs`,children:e.target.text}):(0,I.jsxs)(`span`,{className:`text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsxs)(`span`,{className:`truncate`,children:[e.head,` →`]}),(0,I.jsxs)(AL,{value:e.target?.base??``,disabled:e.target===void 0,onValueChange:e.onBase,children:[(0,I.jsx)(ML,{size:`sm`,className:`max-w-48`,children:(0,I.jsx)(jL,{placeholder:`Loading branches…`})}),(0,I.jsx)(NL,{children:(e.target?.branches??[]).map(e=>(0,I.jsx)(PL,{value:e,children:e},e))})]})]})}function kae(e){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 ps-6`,children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground truncate text-xs`,children:[e.draft.head,` → `,e.draft.base]}),(0,I.jsx)(kL,{value:e.draft.title,onChange:t=>e.onChange({...e.draft,title:t.target.value})}),(0,I.jsx)(`textarea`,{value:e.draft.body,onChange:t=>e.onChange({...e.draft,body:t.target.value}),rows:8,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-y rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.onSkip!==null&&(0,I.jsx)(x,{variant:`ghost`,size:`sm`,onClick:e.onSkip,children:`Skip`}),(0,I.jsx)(x,{variant:`outline`,size:`sm`,onClick:e.onRegenerate,children:`Regenerate`}),(0,I.jsx)(x,{size:`sm`,disabled:e.draft.title.trim()===``,onClick:e.onCreate,children:`Create PR`})]})]})}var Aae={working:n_,review:r_,done:t_,failed:jg,skipped:_ee};function jae(e){let t=Q(t=>E9(t,e.machine,e.projectId)?.name)??``,[n]=(0,F.useState)(()=>IL(e.repos,e.action)),[r,i]=(0,F.useState)(()=>n.map(e=>e.path)),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)({}),[l,u]=(0,F.useState)(null),d=n.filter(e=>r.includes(e.path)&&s[e.path]?.kind!==`failed`),f=e.action===`pullRequest`&&d.some(e=>s[e.path]===void 0),p=d.filter(e=>e.changed>0);(0,F.useEffect)(()=>{if(e.action===`pullRequest`)for(let t of n)L(e.machine,`git.branches`,{projectId:e.projectId,repo:t.path}).then(e=>c(n=>({...n,[t.path]:{kind:`ready`,...e}})),e=>c(n=>({...n,[t.path]:{kind:`failed`,text:rt(e)}})))},[e.machine,e.projectId,e.action,n]);function m(e,t){u(n=>n?.map(n=>n.path===e?{...n,...t}:n)??null)}async function h(t,r){try{await r()}catch(r){if(n.length===1){e.onClose(),EL(`Pull request failed`,{error:rt(r)});return}m(t,{state:`failed`,text:rt(r),draft:null})}finally{e.onRefresh()}}function g(e,t){c(n=>{let r=n[e];return r?.kind===`ready`?{...n,[e]:{...r,base:t}}:n})}function _(e,t){u(d.map(t=>({path:t.path,state:`working`,text:e,url:null,draft:null})));for(let e of d)h(e.path,()=>t(e.path))}function v(t){if(n.length===1){e.onClose(),OL(e,n[0].path,a,t);return}let r=t?`Committed and pushed`:`Committed`;_(t?`Committing and pushing…`:`Committing…`,async n=>{await L(e.machine,`git.commit`,{projectId:e.projectId,repo:n,message:a,push:t}),m(n,{state:`done`,text:r})})}function y(){_(`Pushing…`,async t=>{await L(e.machine,`git.push`,{projectId:e.projectId,repo:t}),m(t,{state:`done`,text:`Pushed`})})}async function b(t,r,i){m(t,{state:`working`,text:r?`Committing local changes and writing pull request…`:`Writing pull request…`,draft:null});let a=await L(e.machine,`git.pullRequest`,{projectId:e.projectId,repo:t,base:i,commit:r});if(a.kind===`open`){if(n.length===1){e.onClose(),EL(`Pull request already open`,{url:a.url});return}m(t,{state:`done`,text:`A pull request is already open`,url:a.url})}else m(t,{state:`review`,text:`Review and create`,draft:{base:a.base,head:a.head,title:a.title,body:a.body}})}function S(e){_(`Starting…`,async t=>{let n=s[t];if(n?.kind!==`ready`)throw Error(`The branches are not loaded`);await b(t,e&&p.some(e=>e.path===t),n.base)})}function C(t,r){n.length===1?(e.onClose(),Tae(e,t,r)):h(t,async()=>{m(t,{state:`working`,text:`Creating pull request…`,draft:null}),m(t,{state:`done`,text:`Created pull request`,url:(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:r.base,head:r.head,title:r.title,body:r.body})).url})})}return(0,I.jsx)(Ke,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(Ne,{className:`top-[12vh] translate-y-0 sm:max-w-lg`,children:[(0,I.jsxs)(Fe,{children:[(0,I.jsxs)(Ve,{children:[e.action===`commit`&&`Commit changes`,e.action===`push`&&`Push`,e.action===`pullRequest`&&`Create pull request`]}),(0,I.jsxs)(We,{children:[e.action===`commit`&&(n.length===1?`Stages every change and commits it.`:`Stages every change in the selected repositories and commits it.`),e.action===`push`&&`Pushes the selected repositories to their remote.`,e.action===`pullRequest`&&`AI writes the title and description. You review them before the pull request is created.`]})]}),l===null&&(0,I.jsxs)(I.Fragment,{children:[n.length===1&&(0,I.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-1.5 text-xs`,children:[e.action===`pullRequest`?(0,I.jsx)(FL,{head:n[0].branch??`detached`,target:s[n[0].path],onBase:e=>g(n[0].path,e)}):n[0].branch??`detached`,(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`· `,n[0].changed,` `,n[0].changed===1?`change`:`changes`]})]}),n.length>1&&(0,I.jsx)(`div`,{className:`flex max-h-60 flex-col gap-0.5 overflow-y-auto`,children:n.map(n=>(0,I.jsxs)(`label`,{className:`hover:bg-accent flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5`,children:[(0,I.jsx)(`input`,{type:`checkbox`,disabled:s[n.path]?.kind===`failed`,checked:r.includes(n.path)&&s[n.path]?.kind!==`failed`,onChange:e=>i(e.target.checked?[...r,n.path]:r.filter(e=>e!==n.path))}),(0,I.jsx)(`span`,{className:`truncate font-medium`,children:LL(n.path,t)}),e.action===`pullRequest`?(0,I.jsx)(FL,{head:n.branch??`detached`,target:s[n.path],onBase:e=>g(n.path,e)}):(0,I.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:n.branch??`detached`}),(0,I.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0 text-xs tabular-nums`,children:e.action===`push`?n.upstream===null?`not pushed yet`:`↑${n.ahead}`:n.changed>0&&`${n.changed} ${n.changed===1?`change`:`changes`}`})]},n.path))}),e.action===`commit`&&(0,I.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),placeholder:`Leave empty to write the message with AI`,rows:5,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-none rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),e.action===`pullRequest`&&p.length>0&&(0,I.jsxs)(`p`,{children:[`You have local changes`,n.length>1&&` in ${p.map(e=>LL(e.path,t)).join(`, `)}`,`. Do you want to commit and push them before creating the pull request?`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.action===`commit`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(x,{variant:`outline`,size:`sm`,disabled:d.length===0,onClick:()=>v(!1),children:`Commit`}),(0,I.jsx)(x,{size:`sm`,disabled:d.length===0,onClick:()=>v(!0),children:`Commit and Push`})]}),e.action===`push`&&(0,I.jsx)(x,{size:`sm`,disabled:d.length===0,onClick:y,children:`Push`}),e.action===`pullRequest`&&p.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(x,{variant:`outline`,size:`sm`,disabled:f,onClick:()=>S(!1),children:`Continue without them`}),(0,I.jsx)(x,{size:`sm`,disabled:f,onClick:()=>S(!0),children:`Commit and continue`})]}),e.action===`pullRequest`&&p.length===0&&(0,I.jsx)(x,{size:`sm`,disabled:f||d.length===0,onClick:()=>S(!1),children:`Create pull request`})]})]}),l!==null&&(0,I.jsx)(`div`,{className:`flex max-h-[60vh] flex-col gap-2 overflow-y-auto`,children:l.map(e=>{let r=e.draft;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 overflow-hidden`,children:(0,I.jsx)(w,{icon:Aae[e.state],className:P(`size-4`,e.state===`working`&&`animate-spin`,e.state===`review`&&`text-info`,e.state===`done`&&`text-success`,e.state===`failed`&&`text-destructive`,e.state===`skipped`&&`text-muted-foreground`)})}),(0,I.jsx)(`span`,{className:`shrink-0 font-medium`,children:LL(e.path,t)}),(0,I.jsxs)(`span`,{className:P(`min-w-0 text-xs leading-5 break-words whitespace-pre-wrap`,e.state===`failed`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.url!==null&&(0,I.jsxs)(I.Fragment,{children:[` `,(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline hover:underline-offset-2`,children:e.url})]})]})]}),e.state===`review`&&r!==null&&(0,I.jsx)(kae,{draft:r,onChange:t=>m(e.path,{draft:t}),onSkip:n.length===1?null:()=>m(e.path,{state:`skipped`,text:`Skipped`,draft:null}),onRegenerate:()=>void h(e.path,()=>b(e.path,!1,r.base)),onCreate:()=>C(e.path,r)})]},e.path)})})]})})}function IL(e,t){if(t===`commit`)return e.filter(e=>e.changed>0);if(t===`push`)return e.filter(e=>e.branch!==null&&(e.upstream===null||e.ahead>0));if(t===`pullRequest`)return e.filter(e=>e.branch!==null);throw Error(`Unknown git action ${String(t)}`)}function LL(e,t){return e===``?t:e}var Mae=3e3,Nae=18e4;function RL(e,t,n){let[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(0);(0,F.useEffect)(()=>{if(t===null)return;let n=f9(e,t),r={projectId:t},a=!0,o=!1,s=!1;async function c(){if(!o){o=!0;try{let t=await L(e,`git.status`,r);if(!a)return;s=!1,i(e=>e!==null&&e.key===n&&ws(e.repos,t)?e:{key:n,repos:t})}catch(e){a&&!s&&(s=!0,R9(e))}finally{o=!1}}}function l(){document.hidden||c()}c();let u=window.setInterval(l,Mae);return window.addEventListener(`focus`,l),()=>{a=!1,window.clearInterval(u),window.removeEventListener(`focus`,l)}},[e,t,n,a]),(0,F.useEffect)(()=>{if(t===null)return;let n={projectId:t},r=!0,i=!1;async function a(){if(!document.hidden)try{await L(e,`git.fetch`,n),r&&(i=!1,o(e=>e+1))}catch(e){r&&!i&&(i=!0,R9(e))}}a();let s=window.setInterval(a,Nae);return()=>{r=!1,window.clearInterval(s)}},[e,t]);let s=(0,F.useCallback)(()=>o(e=>e+1),[]);return{repos:r!==null&&t!==null&&r.key===f9(e,t)?r.repos:[],refresh:s}}function zL(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(!1),l=IL(e.repos,`push`),u=IL(e.repos,`commit`);function d(t){DL({labels:{working:`Pushing…`,done:`Pushed`,failed:`Push failed`},task:async()=>(await L(e.machine,`git.push`,{projectId:e.projectId,repo:t}),null),onRefresh:e.onRefresh})}async function f(){if(u.length===1)i(!1),OL(e,u[0].path,``,!1);else{c(!0);try{for(let t of u)await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t.path,message:``,push:!1});i(!1)}catch(e){R9(e)}finally{c(!1),e.onRefresh()}}}return{target:e,action:t,setAction:n,menuOpen:r,setMenuOpen:i,branchRepo:a,setBranchRepo:o,committing:s,pushable:l,committable:u,push:d,yoloCommit:f}}function BL(e){let t=e.git,n=t.target.repos,r=n.reduce((e,t)=>e+t.ahead,0);return(0,I.jsxs)(I.Fragment,{children:[e.collapsed&&n.map(e=>(0,I.jsxs)(IC,{onSelect:()=>t.setBranchRepo(e.path),children:[(0,I.jsx)(w,{icon:S_}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`}),(0,I.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,I.jsx)(bL,{behind:e.behind,ahead:e.ahead})})]},e.path)),e.collapsed&&(0,I.jsx)(VC,{}),e.collapsed&&(0,I.jsxs)(IC,{disabled:t.committable.length===0,onSelect:()=>t.setAction(`commit`),children:[(0,I.jsx)(w,{icon:C_}),`Commit…`]}),(0,I.jsxs)(IC,{disabled:t.pushable.length===0||t.committing,onSelect:()=>{t.pushable.length===1?t.push(t.pushable[0].path):t.setAction(`push`)},children:[(0,I.jsx)(w,{icon:o_}),t.pushable.length>1?`Just Push…`:`Just Push`,r>0&&(0,I.jsxs)(`span`,{className:`text-muted-foreground ml-auto text-xs tabular-nums`,children:[`↑`,r]})]}),(0,I.jsxs)(IC,{disabled:t.committable.length===0||t.committing,onSelect:e=>{e.preventDefault(),t.yoloCommit()},children:[(0,I.jsx)(w,{icon:t.committing?n_:C_,className:P(t.committing&&`animate-spin`)}),t.committing?`Committing…`:`Yolo Commit`]}),(0,I.jsx)(VC,{}),(0,I.jsxs)(IC,{disabled:IL(n,`pullRequest`).length===0,onSelect:()=>t.setAction(`pullRequest`),children:[(0,I.jsx)(w,{icon:E_}),`Create pull request…`]})]})}function VL(e){let t=e.git,n=t.target.repos.find(e=>e.path===t.branchRepo);return(0,I.jsxs)(I.Fragment,{children:[t.action!==null&&(0,I.jsx)(jae,{machine:t.target.machine,projectId:t.target.projectId,action:t.action,repos:t.target.repos,onClose:()=>t.setAction(null),onRefresh:t.target.onRefresh}),t.branchRepo!==null&&n!==void 0&&(0,I.jsx)(Sae,{machine:t.target.machine,projectId:t.target.projectId,repo:n,onRefresh:t.target.onRefresh,onClose:()=>t.setBranchRepo(null)})]})}function Pae(e){let t=zL(e),[n,r]=(0,F.useState)(!1),i=[...new Set(e.repos.map(e=>e.branch??`detached`))],a=e.repos.flatMap(e=>{let t=xL(e);return t===null?[]:[{repo:e,next:t}]}),o=e.repos.map(e=>e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`).join(`
112
112
  `),s=i.length===1?i[0]:`${i.length} branches`;async function c(t){r(!0);try{await L(e.machine,`git.sync`,{projectId:e.projectId,repo:t})}catch(e){R9(e)}finally{r(!1),e.onRefresh()}}return(0,I.jsxs)(`div`,{className:`flex w-fit items-center gap-3.5`,children:[e.repos.length===1&&(0,I.jsx)(xae,{machine:e.machine,projectId:e.projectId,repo:e.repos[0],onRefresh:e.onRefresh}),e.repos.length>1&&a.length===0&&(0,I.jsxs)(`span`,{className:`text-muted-foreground hidden max-w-48 items-center gap-1 text-xs sm:flex`,title:o,children:[(0,I.jsx)(w,{icon:S_,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:s})]}),e.repos.length>1&&a.length>0&&(0,I.jsxs)(MC,{children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground hidden max-w-48 cursor-pointer items-center gap-1 text-xs sm:flex`,title:o,children:[(0,I.jsx)(w,{icon:n?n_:a.length===1?a[0].next.icon:Ng,className:P(`size-3.5 shrink-0`,n&&`animate-spin`)}),(0,I.jsx)(`span`,{className:`truncate`,children:s})]})}),(0,I.jsx)(FC,{align:`end`,className:`w-64`,children:a.map(e=>(0,I.jsxs)(IC,{disabled:n,onSelect:()=>void c(e.repo.path),children:[(0,I.jsx)(w,{icon:e.next.icon}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.next.label,` ·`,` `,e.repo.path===``?e.repo.branch:e.repo.path]}),(0,I.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,I.jsx)(bL,{behind:e.repo.behind,ahead:e.repo.ahead})})]},e.repo.path))})]}),(0,I.jsxs)(`div`,{className:`flex w-fit`,children:[(0,I.jsxs)(x,{variant:`outline`,size:`xs`,className:`rounded-e-none border-e-0`,disabled:t.committable.length===0,onClick:()=>t.setAction(`commit`),children:[(0,I.jsx)(w,{icon:C_}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:`Commit`})]}),(0,I.jsxs)(MC,{open:t.menuOpen,onOpenChange:t.setMenuOpen,children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsx)(x,{variant:`outline`,size:`icon-xs`,className:`rounded-s-none`,"aria-label":`Git actions`,children:(0,I.jsx)(w,{icon:t.committing?n_:Zg,className:P(`size-4`,t.committing&&`animate-spin`)})})}),(0,I.jsx)(FC,{align:`end`,className:`w-56`,children:(0,I.jsx)(BL,{git:t,collapsed:!1})})]})]}),(0,I.jsx)(VL,{git:t})]})}function HL({...e}){return(0,I.jsx)(xy,{"data-slot":`alert-dialog`,...e})}function UL({...e}){return(0,I.jsx)(Sy,{"data-slot":`alert-dialog-trigger`,...e})}function Fae({...e}){return(0,I.jsx)(Vee,{"data-slot":`alert-dialog-portal`,...e})}function Iae({className:e,...t}){return(0,I.jsx)(Hee,{"data-slot":`alert-dialog-overlay`,className:P(`fixed inset-0 z-50 bg-background/80 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function WL({className:e,size:t=`default`,...n}){return(0,I.jsxs)(Fae,{children:[(0,I.jsx)(Iae,{}),(0,I.jsx)(Gee,{"data-slot":`alert-dialog-content`,"data-size":t,className:P(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-background p-4 text-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n})]})}function GL({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:P(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function KL({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:P(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function qL({className:e,...t}){return(0,I.jsx)(Kee,{"data-slot":`alert-dialog-title`,className:P(`text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function JL({className:e,...t}){return(0,I.jsx)(qee,{"data-slot":`alert-dialog-description`,className:P(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function YL({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,I.jsx)(x,{variant:t,size:n,asChild:!0,children:(0,I.jsx)(Jee,{"data-slot":`alert-dialog-action`,className:P(e),...r})})}function XL({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,I.jsx)(x,{variant:t,size:n,asChild:!0,children:(0,I.jsx)(Xee,{"data-slot":`alert-dialog-cancel`,className:P(e),...r})})}function ZL({className:e,size:t=`default`,...n}){return(0,I.jsx)(TC,{"data-slot":`switch`,"data-size":t,className:P(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,I.jsx)(DC,{"data-slot":`switch-thumb`,className:`bg-background dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0`})})}var QL=Yh({theme:uh().refine(e=>gI.some(t=>t.id===e)).default(gI[0].id),terminal:Yh({font:Yh({family:uh().default(`FiraCode Nerd Font`),size:Ih().default(14),lineHeight:Ih().default(1.35),ligatures:Bh().default(!0)}).prefault({}),cursor:Yh({style:rg([`block`,`bar`,`underline`]).default(`bar`),blink:Bh().default(!0)}).prefault({}),padding:Yh({top:Ih().default(4),right:Ih().default(4),bottom:Ih().default(0),left:Ih().default(4)}).prefault({}),scrollback:Ih().default(1e3),boldIsBright:Bh().default(!0),behavior:Yh({modernizeShiftEnter:Bh().default(!0),pasteBrowserImages:Bh().default(!0),captureShortcuts:Bh().default(!0),bellFlash:Bh().default(!0),bellSound:Bh().default(!0),clickToMoveCursor:Bh().default(!0),optionAsMeta:rg([`off`,`left`,`right`,`both`]).default(`off`),confirmCloseBusyTab:Bh().default(!0)}).prefault({})}).prefault({}),diff:Yh({split:Bh().default(!1),wrap:Bh().default(!0),collapsed:Bh().default(!1)}).prefault({}),rewind:rg([`all`,`chat`,`code`]).default(`chat`)}),$L=`prefs`,eR=QL.parse({});function Lae(){let e=localStorage.getItem($L);if(e===null)return structuredClone(eR);let t=QL.safeParse(JSON.parse(e));return t.success?t.data:(console.warn(`invalid stored prefs, using the defaults:\n${xl(t.error)}`),structuredClone(eR))}function Rae(e){localStorage.setItem($L,JSON.stringify(e))}function tR(e){return(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`h2`,{className:`text-muted-foreground mb-2 px-1 text-xs font-medium`,children:[e.title,e.note&&(0,I.jsxs)(`span`,{className:`font-normal`,children:[` · `,e.note]})]}),(0,I.jsx)(`div`,{className:`@container divide-y overflow-hidden rounded-xl border`,children:e.children})]})}function nR(e){return(0,I.jsxs)(`label`,{className:`flex min-h-13 flex-wrap items-center gap-x-4 gap-y-2 px-4 py-2.5`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-sm font-medium`,children:e.label}),(0,I.jsx)(`div`,{className:`max-w-full shrink-0 @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:w-full @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:*:w-full @max-lg:**:data-[slot=select-trigger]:w-full`,children:e.children})]})}function rR(e){let[t,n]=(0,F.useState)(e.value);function r(){t!==e.value&&(e.valid&&!e.valid(t)?n(e.value):e.onCommit(t))}return(0,I.jsx)(kL,{className:P(`w-56`,e.className),type:e.type,min:e.type===`number`?0:void 0,step:e.step,placeholder:e.placeholder,value:t,onChange:e=>n(e.target.value),onBlur:r,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}function iR(e){return(0,I.jsx)(rR,{type:`number`,className:`w-24`,step:e.step??1,value:String(e.value),valid:e=>e!==``&&Number(e)>=0,onCommit:t=>e.onCommit(Number(t))},e.value)}function zae(e){let t=e.prefs;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(tR,{title:`Appearance`,children:(0,I.jsx)(nR,{label:`Theme`,children:(0,I.jsxs)(AL,{value:t.theme,onValueChange:e=>L9({...t,theme:e}),children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{})}),(0,I.jsx)(NL,{children:gI.map(e=>(0,I.jsx)(PL,{value:e.id,children:e.name},e.id))})]})})}),(0,I.jsx)(Bae,{}),(0,I.jsx)(x,{variant:`outline`,onClick:e.onRestore,children:`Restore browser defaults`})]})}function Bae(){let[e,t]=(0,F.useState)(`idle`),[n,r]=(0,F.useState)(null);async function i(){t(`checking`),r(null);try{let e=`serviceWorker`in navigator?await navigator.serviceWorker.getRegistration():void 0;if(e===void 0){location.reload();return}await e.update(),t(e.installing===null&&e.waiting===null?`current`:`updating`)}catch(e){console.error(`could not check for updates`,e),r(rt(e)),t(`idle`)}}return(0,I.jsx)(tR,{title:`App`,children:(0,I.jsx)(nR,{label:`Load the newest version of OffSite in this browser`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[n!==null&&(0,I.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Could not check: `,n]}),e===`current`&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Up to date`}),e===`updating`&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Updating, the page reloads when it's ready`}),(0,I.jsx)(x,{size:`sm`,variant:`outline`,disabled:e===`checking`||e===`updating`,onClick:()=>void i(),children:`Check for updates`})]})})})}function Vae(e){for(let t=0;t<e.length;t++){let n=e[t];if(!n.startsWith(`-`)&&!n.startsWith(`+`))return!1;let r=n.startsWith(`-`),i=n.slice(1);if(i===``||i===`-`)return!1;if(i.startsWith(`-`)){if(!aR(i.slice(1),r))return!1}else for(let n=0;n<i.length;n++){let a=i[n];if(a===`o`){let a=i.slice(n+1);if(a===``){if(t++,t===e.length)return!1;a=e[t]}if(!aR(a,r))return!1;break}if(a===`b`||a===`c`||r&&`dfnprvx`.includes(a)||!r&&a===`i`)return!1}}return!0}function aR(e,t){let n=e.toLowerCase().replace(/[-_]/g,``),r=t;return n.startsWith(`no`)&&(n=n.slice(2),r=!t),[`rcs`,`globalrcs`,`interactive`,`exec`].includes(n)?r:![`privileged`,`restricted`,`sourcetrace`,`verbose`,`xtrace`].includes(n)||!r}function Hae(e,t,n){if(t===`windows`)return`Not available on Windows`;if(e!==null&&/[\n"'\\$`;&|<>()*?[\]{}#!]/.test(e))return`Not available for commands with shell syntax`;let r=e===null?[n]:e.split(/[ \t]/).filter(e=>e!==``);if(r.length===0)return`Available for bash, zsh and fish`;let i=r[0],a=i.split(`/`).pop(),o=r.slice(1);return a===`bash`?t===`macos`&&(i===`/bin/bash`||!i.includes(`/`))?`Needs a newer bash than the one macOS includes`:o.every(e=>[`-l`,`--login`,`-i`].includes(e))?null:`Not available with these bash options`:a===`zsh`?Vae(o)?null:`Not available with these zsh options`:a===`fish`?o.every(e=>{if(e.startsWith(`--`)){let t=e.slice(2).split(`=`)[0];return t===``||![`command`,`no-config`,`no-execute`].some(e=>e.startsWith(t))}return!(e.startsWith(`-`)&&/[cNn]/.test(e))})?null:`Not available with these fish options`:`Available for bash, zsh and fish`}var Uae=`3.6.8`,Wae=`1.3.1`,oR=[{family:`FiraCode Nerd Font`,label:`Fira Code`},{family:`JetBrainsMono Nerd Font`,label:`JetBrains Mono`},{family:`CaskaydiaCove Nerd Font`,label:`Cascadia Code`},{family:`Hack Nerd Font`,label:`Hack`}],Gae=[{value:`macos`,label:`macOS`},{value:`linux`,label:`Linux`},{value:`windows`,label:`Windows`}];async function sR(e){let t=`${e.font.size}px ${e.font.family}`;await Promise.all([document.fonts.load(t),document.fonts.load(`bold ${t}`)]);let n=document.documentElement.style;n.setProperty(`--pad-top`,`${e.padding.top}px`),n.setProperty(`--pad-right`,`${e.padding.right}px`),n.setProperty(`--pad-bottom`,`${e.padding.bottom}px`),n.setProperty(`--pad-left`,`${e.padding.left}px`)}function Kae(e,t){let n=_I();return{fontFamily:e.font.family,fontSize:e.font.size,lineHeight:e.font.lineHeight,ligatures:e.font.ligatures,cursorStyle:e.cursor.style,cursorBlink:e.cursor.blink,scrollback:e.scrollback,boldIsBright:e.boldIsBright,colors:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorText:n.background,selectionBackground:n.selectionBackground,selectionForeground:n.foreground,palette:n.palette},version:qae(t),clickToMoveCursor:e.behavior.clickToMoveCursor,optionAsMeta:e.behavior.optionAsMeta}}function qae(e){if(e===`offsite`)return`offsite 0.0.0`;if(e===`ghostty`)return`ghostty ${Wae}`;if(e===`iterm2`)return`iTerm2 ${Uae}`;throw Error(`unknown terminal identity ${e}`)}var cR=[10,15,30,45,60,120,180,300,600,900,1800,3600];function lR(e){let t=e.config;function n(n){H9(e.machine,{...t,...n})}return(0,I.jsxs)(tR,{title:`Agents`,children:[(0,I.jsx)(nR,{label:`Send while working`,children:(0,I.jsxs)(AL,{value:t.delivery,onValueChange:n=>{if(n!==`queue`&&n!==`steer`)throw Error(`Unknown delivery ${n}`);H9(e.machine,{...t,delivery:n})},children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{})}),(0,I.jsxs)(NL,{children:[(0,I.jsx)(PL,{value:`queue`,children:`Queue messages`}),(0,I.jsx)(PL,{value:`steer`,children:`Steer the agent`})]})]})}),(0,I.jsx)(nR,{label:`Auto-skip questions`,children:(0,I.jsx)(uR,{value:t.autoSkipQuestionTimeout,onChange:e=>n({autoSkipQuestionTimeout:e})})}),(0,I.jsx)(nR,{label:`Auto-resolve permissions`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.autoPermissionTimeout!==null&&(0,I.jsxs)(AL,{value:t.autoPermissionMode,onValueChange:e=>{if(e!==`allow`&&e!==`deny`)throw Error(`Unknown decision ${e}`);n({autoPermissionMode:e})},children:[(0,I.jsx)(ML,{className:`w-24`,children:(0,I.jsx)(jL,{})}),(0,I.jsxs)(NL,{children:[(0,I.jsx)(PL,{value:`allow`,children:`Allow`}),(0,I.jsx)(PL,{value:`deny`,children:`Deny`})]})]}),(0,I.jsx)(uR,{value:t.autoPermissionTimeout,onChange:e=>n({autoPermissionTimeout:e})})]})})]})}function uR(e){let t=e.value===null||cR.includes(e.value)?cR:[...cR,e.value].sort((e,t)=>e-t);return(0,I.jsxs)(AL,{value:e.value===null?`off`:String(e.value),onValueChange:t=>e.onChange(t===`off`?null:Number(t)),children:[(0,I.jsx)(ML,{className:`w-40`,children:(0,I.jsx)(jL,{})}),(0,I.jsxs)(NL,{children:[(0,I.jsx)(PL,{value:`off`,children:`Off`}),t.map(e=>(0,I.jsx)(PL,{value:String(e),children:e===3600?`After 1 hour`:e===60?`After 1 minute`:e%60==0?`After ${e/60} minutes`:`After ${e} seconds`},e))]})]})}function dR(e){let t=e.config.commitMessage,[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(null);(0,F.useEffect)(()=>{if(t.provider===null)return;let n=!0;return r(null),a(null),L(e.machine,`capabilities`,{provider:t.provider,accountId:t.accountId,projectId:null}).then(e=>{n&&r(e.models)},e=>{n&&a(rt(e))}),()=>{n=!1}},[e.machine,t.provider,t.accountId]);function o(t){H9(e.machine,{...e.config,commitMessage:t})}function s(t){if(t===`off`){o({provider:null,accountId:null,model:null});return}if(t===`opencode`){o({provider:`opencode`,accountId:null,model:null});return}let n=[...e.claudeAccounts,...e.codexAccounts].find(e=>e.id===t);if(n===void 0)throw Error(`That account was removed`);o({provider:n.provider,accountId:n.id,model:null})}return(0,I.jsxs)(tR,{title:`Commit messages and pull requests`,children:[(0,I.jsx)(nR,{label:`Account`,children:(0,I.jsxs)(AL,{value:t.provider===null?`off`:t.provider===`opencode`?`opencode`:t.accountId??`off`,onValueChange:s,children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{})}),(0,I.jsxs)(NL,{children:[(0,I.jsx)(PL,{value:`off`,children:`Off`}),[...e.claudeAccounts,...e.codexAccounts].map(e=>(0,I.jsxs)(PL,{value:e.id,disabled:!e.valid,children:[(0,I.jsx)(Yv,{provider:e.provider,className:`size-4`}),`${Tw[e.provider]} · ${e.name}`]},e.id)),e.openCode.available&&(0,I.jsxs)(PL,{value:`opencode`,children:[(0,I.jsx)(Yv,{provider:`opencode`,className:`size-4`}),Tw.opencode]})]})]})}),t.provider!==null&&(0,I.jsx)(nR,{label:`Model`,children:(0,I.jsxs)(AL,{value:t.model??void 0,disabled:n===null,onValueChange:e=>o({...t,model:e}),children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{placeholder:i===null?n===null?`Loading…`:`Choose a model`:`Unavailable`})}),(0,I.jsx)(NL,{children:(n??[]).map(e=>(0,I.jsx)(PL,{value:e.value,children:e.name},e.value))})]})}),i!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:i})]})}var fR={zsh:`M11.415 5.038a.58.58 0 0 0-.543.197L.135 18.021a.58.58 0 0 0 .071.814.58.58 0 0 0 .815-.07L11.757 5.979a.58.58 0 0 0-.07-.815.6.6 0 0 0-.272-.126m-8.113.317a3.133 3.133 0 0 0-3.12 3.12 3.13 3.13 0 0 0 3.12 3.119A3.133 3.133 0 0 0 6.42 8.475a3.13 3.13 0 0 0-3.119-3.119m0 1.806a1.3 1.3 0 0 1 1.314 1.313 1.3 1.3 0 0 1-1.314 1.312A1.3 1.3 0 0 1 1.99 8.475a1.3 1.3 0 0 1 1.312-1.314m5.253 5.253a3.13 3.13 0 0 0-3.119 3.119 3.13 3.13 0 0 0 3.12 3.118 3.133 3.133 0 0 0 3.118-3.12 3.133 3.133 0 0 0-3.119-3.118m0 1.805a1.3 1.3 0 0 1 1.313 1.314c0 .735-.577 1.312-1.312 1.312a1.3 1.3 0 0 1-1.314-1.312 1.3 1.3 0 0 1 1.313-1.314m7.201 3.276a.58.58 0 0 0-.578.578.58.58 0 0 0 .578.578h7.666a.58.58 0 0 0 .579-.578.58.58 0 0 0-.579-.578Z`,bash:`M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z`,fish:`m19.164 9.228-3.016 2.688v.527l3.016 2.688v-1.228l-1.936-1.723 1.936-1.724V9.228m-6.658.046v1.208l1.905 1.696-1.905 1.695v1.209l2.968-2.645v-.518l-2.968-2.645M9.781 7.847a6.519 6.519 0 0 0-2.038-.335c-.672 0-1.349.112-2.03.335a9.23 9.23 0 0 0-2.088 1.017v.723c.69-.4 1.377-.7 2.06-.897a7.388 7.388 0 0 1 2.058-.296c.684 0 1.368.098 2.052.296a9.452 9.452 0 0 1 2.075.897v-.723a9.229 9.229 0 0 0-2.09-1.017m.014 7.78a7.371 7.371 0 0 1-2.052.296 7.388 7.388 0 0 1-2.057-.296 9.18 9.18 0 0 1-2.061-.897v.723a9.228 9.228 0 0 0 2.088 1.017 6.492 6.492 0 0 0 2.03.335c.678 0 1.357-.112 2.038-.335a9.227 9.227 0 0 0 2.089-1.017v-.723c-.7.4-1.391.7-2.075.897m.602-11.23h-.51L7.28 6.92h1.19l1.672-1.62 1.671 1.62h1.191l-2.607-2.525m-2.965 13.68v-.824H6.427v.825l.786 1.527h.614l-.395-1.527M4.127 10.95v1.216H5.13V10.95H4.127m-1.16-1.695L0 11.901v.518l2.967 2.645v-1.208L1.063 12.16l1.904-1.695V9.256m20.68 3.28c-.235-.3-.574-.509-1.017-.626.395-.103.696-.278.902-.525.206-.247.31-.556.31-.926 0-.546-.197-.984-.59-1.314-.393-.33-.919-.495-1.575-.495-.22 0-.473.025-.758.073-.284.048-.61.12-.974.217v.84c.314-.12.613-.21.9-.27a4.05 4.05 0 0 1 .832-.091c.403 0 .714.093.933.278.218.185.328.451.328.798 0 .328-.118.584-.353.768-.235.184-.562.276-.98.276h-.697v.75h.696c.458 0 .821.116 1.09.346.268.23.402.542.402.934 0 .425-.134.75-.402.976-.269.226-.653.339-1.153.339a3.55 3.55 0 0 1-.89-.117 4.395 4.395 0 0 1-.91-.358v.909a6.1 6.1 0 0 0 .95.249c.323.057.639.085.95.085.738 0 1.315-.177 1.733-.53.417-.355.626-.842.626-1.463 0-.449-.118-.823-.353-1.123`,powershell:`M23.181 2.974c.568 0 .923.463.792 1.035l-3.659 15.982c-.13.572-.697 1.035-1.265 1.035H.819c-.568 0-.923-.463-.792-1.035L3.686 4.009c.13-.572.697-1.035 1.265-1.035zm-8.375 9.346c.251-.394.227-.905-.09-1.243L9.122 5.125c-.38-.404-1.037-.407-1.466-.003-.429.402-.468 1.056-.088 1.46l4.662 4.96v.11l-7.42 5.374c-.45.327-.533.977-.187 1.453.346.476.991.597 1.44.27l8.229-5.91c.28-.196.438-.365.514-.52zm-2.796 4.399a.928.928 0 00-.934.923c0 .51.418.923.934.923h4.433a.928.928 0 00.934-.923.928.928 0 00-.934-.923z`,cmd:`M8.165 6V3h7.665v3H8.165zm-.5-3H1c-.55 0-1 .45-1 1v2h7.665V3zM23 3h-6.67v3H24V4c0-.55-.45-1-1-1zM0 6.5h24V20c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V6.5zM11.5 18c0 .3.2.5.5.5h8c.3 0 .5-.2.5-.5v-1.5c0-.3-.2-.5-.5-.5h-8c-.3 0-.5.2-.5.5V18zm-5.2-4.55l-3.1 3.1c-.25.25-.25.6 0 .8l.9.9c.25.25.6.25.8 0l4.4-4.4a.52.52 0 0 0 0-.8l-4.4-4.4c-.2-.2-.6-.2-.8 0l-.9.9c-.25.2-.25.55 0 .8l3.1 3.1z`},pR={zsh:`zsh`,bash:`bash`,fish:`fish`,pwsh:`powershell`,powershell:`powershell`,cmd:`cmd`},mR={macos:[`zsh`,`bash`,`fish`,`pwsh`],linux:[`bash`,`zsh`,`fish`,`pwsh`],windows:[`pwsh`,`powershell`,`cmd`]};function hR(e){let t=e.trim().split(/[\\/]/).pop()?.toLowerCase().replace(/\.exe$/,``);return t===void 0?void 0:pR[t]}function gR(e){return e.replace(/[\\/][^\\/]*$/,``)}function _R(e){return(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4 flex-none`,fill:`currentColor`,children:(0,I.jsx)(`path`,{d:fR[e.logo]})})}function vR(e){let[t,n]=(0,F.useState)(e.value??``),[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(null),s=hR(t),c=e.platform===e.device,l=c?r:mR[e.platform].map(e=>({name:e,path:null}));(0,F.useEffect)(()=>{c&&L(e.machine,`terminal.shells`,void 0).then(i,e=>o(rt(e)))},[e.machine,c]);function u(t){n(t),t!==(e.value??``)&&e.onCommit(t===``?null:t)}return(0,I.jsxs)(`div`,{className:`relative w-56`,children:[s&&(0,I.jsx)(`span`,{className:`text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2`,children:(0,I.jsx)(_R,{logo:s})}),(0,I.jsx)(kL,{className:s?`pr-9 pl-8`:`pr-9`,placeholder:`System default`,value:t,onChange:e=>n(e.target.value),onBlur:()=>u(t),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),(0,I.jsxs)(MC,{children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon-xs`,"aria-label":`Known shells`,className:`text-muted-foreground absolute top-1/2 right-1.5 -translate-y-1/2`,children:(0,I.jsx)(w,{icon:Pg})})}),(0,I.jsxs)(FC,{align:`end`,className:`w-72`,children:[a&&(0,I.jsx)(`p`,{className:`text-destructive px-2 py-1.5 text-xs`,children:a}),l?.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-2 py-1.5 text-xs`,children:`No known shells found`}),l?.map(e=>(0,I.jsxs)(IC,{onSelect:()=>u(e.path??e.name),children:[(0,I.jsx)(_R,{logo:pR[e.name]}),e.name,e.path!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-auto min-w-0 truncate pl-3 text-xs [direction:rtl]`,title:e.path,children:(0,I.jsx)(`bdi`,{children:gR(e.path)})})]},e.path??e.name)),(0,I.jsx)(VC,{}),(0,I.jsx)(IC,{onSelect:()=>u(``),children:`System default`})]})]})]})}function yR(e){let t=e.config.workingDir[e.platform]??``;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(tR,{title:`Projects`,children:(0,I.jsx)(nR,{label:`Working directory`,children:(0,I.jsx)(rR,{className:`w-72 font-mono`,value:t,placeholder:`Home folder`,onCommit:t=>H9(e.machine,{...e.config,workingDir:{...e.config.workingDir,[e.platform]:t.trim()===``?null:t.trim()}})},`${e.machine}-${t}`)})}),(0,I.jsx)(bR,{machine:e.machine,config:e.config,platform:e.platform,defaultShell:e.defaultShell},e.machine),(0,I.jsx)(lR,{machine:e.machine,config:e.config}),(0,I.jsx)(dR,{machine:e.machine,config:e.config,claudeAccounts:e.claudeAccounts,codexAccounts:e.codexAccounts,openCode:e.openCode},`git-${e.machine}`),(0,I.jsx)(x,{variant:`outline`,onClick:e.onRestore,children:`Restore machine defaults`})]})}function bR(e){let t=e.config.terminal,[n,r]=(0,F.useState)(e.platform),i=Hae(t.shell[e.platform],e.platform,e.defaultShell);function a(t){H9(e.machine,{...e.config,terminal:t})}return(0,I.jsxs)(tR,{title:`Shell`,note:`Applies to new terminals`,children:[(0,I.jsx)(nR,{label:`Platform`,children:(0,I.jsxs)(AL,{value:n,onValueChange:e=>r(e),children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{})}),(0,I.jsx)(NL,{children:Gae.map(t=>(0,I.jsxs)(PL,{value:t.value,children:[t.label,t.value===e.platform&&(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`(this machine)`})]},t.value))})]})}),(0,I.jsx)(nR,{label:`Command`,children:(0,I.jsx)(vR,{machine:e.machine,platform:n,device:e.platform,value:t.shell[n],onCommit:e=>a({...t,shell:{...t.shell,[n]:e}})},`${e.machine}-${n}-command`)}),(0,I.jsx)(nR,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Shell integration`,(0,I.jsx)(Oe,{label:(0,I.jsxs)(`div`,{children:[`Tells the terminal where prompts and commands start and end.`,(0,I.jsxs)(`ul`,{className:`mt-1 list-disc pl-4`,children:[(0,I.jsx)(`li`,{children:`Click in the command line to move the cursor`}),(0,I.jsx)(`li`,{children:`Ignore clipboard reads once the command that asked has finished`})]})]}),children:(0,I.jsx)(`span`,{onClick:e=>e.preventDefault(),children:(0,I.jsx)(w,{icon:aee,"aria-label":`About shell integration`,className:`text-muted-foreground size-3.5`})})})]}),children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground max-w-32 text-right text-xs sm:max-w-none`,children:i}),(0,I.jsx)(ZL,{checked:i===null&&t.behavior.shellIntegration,disabled:i!==null,onCheckedChange:e=>a({...t,behavior:{...t.behavior,shellIntegration:e}})})]})}),(0,I.jsx)(xR,{identity:t.behavior.terminalIdentity,onChange:e=>a({...t,behavior:{...t.behavior,terminalIdentity:e}})})]})}function xR(e){return(0,I.jsx)(nR,{label:`Report the terminal as`,children:(0,I.jsxs)(AL,{value:e.identity,onValueChange:e.onChange,children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{})}),(0,I.jsxs)(NL,{children:[(0,I.jsx)(PL,{value:`offsite`,children:`OffSite`}),(0,I.jsx)(PL,{value:`ghostty`,children:`Ghostty`}),(0,I.jsx)(PL,{value:`iterm2`,children:`iTerm2`})]})]})})}var SR=(0,F.createContext)({});function CR(e){let t=(0,F.useRef)(null);return t.current===null&&(t.current=e()),t.current}var wR=typeof window<`u`?F.useLayoutEffect:F.useEffect,TR=(0,F.createContext)(null);function ER(e,t){e.indexOf(t)===-1&&e.push(t)}function DR(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}function OR([...e],t,n){let r=t<0?e.length+t:t;if(r>=0&&r<e.length){let r=n<0?e.length+n:n,[i]=e.splice(t,1);e.splice(r,0,i)}return e}var kR=(e,t,n)=>n>t?t:n<e?e:n,AR={},jR=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),MR=e=>typeof e==`object`&&!!e,NR=e=>/^0[^.\s]+$/u.test(e);function PR(e){let t;return()=>(t===void 0&&(t=e()),t)}var FR=e=>e,IR=(...e)=>e.reduce((e,t)=>n=>t(e(n))),LR=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},RR=class{constructor(){this.subscriptions=[]}add(e){return ER(this.subscriptions,e),()=>this.remove(e)}remove(e){DR(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}},zR=e=>e*1e3,BR=e=>e/1e3,VR=(e,t)=>t?1e3/t*e:0,HR=(e,t,n)=>e*(3*(1-e)*((1-e)*t+e*n)+e*e);function UR(e,t,n,r){return e===t&&n===r?FR:i=>{let a=0,o=1,s=i;for(let t=0;;t++){s>=a&&s<=o||(s=(a+o)/2);let r=HR(s,e,n)-i;if(r*r<1e-28||t===40)break;r>0?o=s:a=s,s-=r*1e-7/(HR(s+1e-7,e,n)-i-r)}return HR(s,t,r)}}var WR=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,GR=e=>t=>1-e(1-t),KR=UR(.33,1.53,.69,.99),qR=GR(KR),JR=WR(qR),YR=e=>e>=1?1:(e*=2)<1?.5*qR(e):.5*(2-2**(-10*(e-1))),XR=e=>1-Math.sin(Math.acos(e)),ZR=GR(XR),QR=WR(XR),$R=UR(.42,0,1,1),ez=UR(0,0,.58,1),tz=UR(.42,0,.58,1),nz=e=>Array.isArray(e)&&typeof e[0]!=`number`,rz=e=>Array.isArray(e)&&typeof e[0]==`number`,iz={linear:FR,easeIn:$R,easeInOut:tz,easeOut:ez,circIn:XR,circInOut:QR,circOut:ZR,backIn:qR,backInOut:JR,backOut:KR,anticipate:YR},az=e=>typeof e==`string`,oz=e=>{if(rz(e)){e.length;let[t,n,r,i]=e;return UR(t,n,r,i)}return az(e)?(iz[e],`${e}`,iz[e]):e},sz={delta:0,timestamp:0,isProcessing:!1},cz;function lz(){cz=void 0}var uz={now:()=>(cz===void 0&&uz.set(sz.isProcessing||AR.useManualTiming?sz.timestamp:performance.now()),cz),set:e=>{cz=e,queueMicrotask(lz)}},dz=e=>Math.round(e*1e5)/1e5,fz=e=>t=>typeof t==`string`&&t.startsWith(e),pz=fz(`--`),mz=fz(`var(--`),hz=e=>mz(e)?gz.test(e.split(`/*`)[0].trim()):!1,gz=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function _z(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var vz={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},yz={...vz,transform:e=>kR(0,1,e)},bz={...vz,default:1},xz=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Sz(e){return e==null}var Cz=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,wz=(e,t)=>n=>!!(typeof n==`string`&&Cz.test(n)&&n.startsWith(e)||t&&!Sz(n)&&Object.prototype.hasOwnProperty.call(n,t)),Tz=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(xz);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Ez=e=>kR(0,255,e),Dz={...vz,transform:e=>Math.round(Ez(e))},Oz={test:wz(`rgb`,`red`),parse:Tz(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Dz.transform(e)+`, `+Dz.transform(t)+`, `+Dz.transform(n)+`, `+dz(yz.transform(r))+`)`};function kz(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 Az={test:wz(`#`),parse:kz,transform:Oz.transform},jz=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Mz=jz(`deg`),Nz=jz(`%`),Y=jz(`px`),Pz=jz(`vh`),Fz=jz(`vw`),Iz={...Nz,parse:e=>Nz.parse(e)/100,transform:e=>Nz.transform(e*100)},Lz={test:wz(`hsl`,`hue`),parse:Tz(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Nz.transform(dz(t))+`, `+Nz.transform(dz(n))+`, `+dz(yz.transform(r))+`)`},Rz={test:e=>Oz.test(e)||Az.test(e)||Lz.test(e),parse:e=>Oz.test(e)?Oz.parse(e):Lz.test(e)?Lz.parse(e):Az.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Oz.transform(e):Lz.transform(e),getAnimatableNone:e=>{let t=Rz.parse(e);return t.alpha=0,Rz.transform(t)}},zz=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,Bz=new RegExp(xz.source),Vz=new RegExp(zz.source,`i`);function Hz(e){return isNaN(e)&&typeof e==`string`&&(Bz.test(e)||Vz.test(e))}var Uz=`number`,Wz=`color`,Gz=`var`,Kz=`var(`,qz="${}",Jz=/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+)(?![a-z]*\()/giu;function Yz(e){let t=e.toString();return Bz.test(t)||Vz.test(t)}function Xz(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(Jz,e=>(Rz.test(e)?(r.color.push(a),i.push(Wz),n.push(Rz.parse(e))):e.startsWith(Kz)?(r.var.push(a),i.push(Gz),n.push(e)):(r.number.push(a),i.push(Uz),n.push(parseFloat(e))),++a,qz)).split(qz),indexes:r,types:i}}function Zz(e){return Xz(e).values}function Qz({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===Uz?dz(r[a]):e===Wz?Rz.transform(r[a]):r[a]}return i}}function $z(e){return Qz(Xz(e))}var eB=e=>typeof e==`number`?0:Rz.test(e)?Rz.getAnimatableNone(e):e,tB=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:eB(e);function nB(e){let t=Xz(e);return Qz(t)(t.values.map((e,n)=>tB(e,t.split[n])))}var rB={test:Hz,parse:Zz,createTransformer:$z,getAnimatableNone:nB};function iB(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 aB({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=iB(s,r,e+1/3),a=iB(s,r,e),o=iB(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function oB(e,t){return n=>n>0?t:e}var sB=(e,t,n)=>e+(t-e)*n,cB=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},lB=[Az,Oz,Lz],uB=e=>lB.find(t=>t.test(e));function dB(e){let t=uB(e);if(!t)return`${e}`,!1;let n=t.parse(e);return t===Lz&&(n=aB(n)),n}var fB=(e,t)=>{let n=dB(e),r=dB(t);if(!n||!r)return oB(e,t);let i={...n};return e=>(i.red=cB(n.red,r.red,e),i.green=cB(n.green,r.green,e),i.blue=cB(n.blue,r.blue,e),i.alpha=sB(n.alpha,r.alpha,e),Oz.transform(i))},pB=new Set([`none`,`hidden`]);function mB(e,t){return pB.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function hB(e,t){return n=>sB(e,t,n)}function gB(e){return typeof e==`number`?hB:typeof e==`string`?hz(e)?oB:Rz.test(e)?fB:bB:Array.isArray(e)?_B:typeof e==`object`?Rz.test(e)?fB:vB:oB}function _B(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>gB(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function vB(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=gB(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function yB(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 bB=(e,t)=>{let n=rB.createTransformer(t),r=Xz(e),i=Xz(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?pB.has(e)&&!i.values.length||pB.has(t)&&!r.values.length?mB(e,t):IR(_B(yB(r,i),i.values),n):(`${e}${t}`,oB(e,t))},xB=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function SB(e,t){let n=xB.exec(e);if(!n)return;let r=xB.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>dz(sB(a,o,e))+i}function CB(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return sB(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=SB(e,t);if(n)return n}return gB(e)(e,t)}var wB=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function TB(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 EB=40;function DB(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=wB.reduce((e,t)=>(e[t]=TB(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=AR.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,EB),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:wB.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<wB.length;t++)o[wB[t]].cancel(e)},state:n,steps:o}}var{schedule:OB,cancel:kB,steps:AB}=DB(typeof requestAnimationFrame<`u`?requestAnimationFrame:FR,!0,sz),jB=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>OB.update(t,e),stop:()=>kB(t),now:()=>sz.isProcessing?sz.timestamp:uz.now()}},MB=(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)})`},NB=2e4;function PB(e,t=50,n=NB,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 FB(e,t=100,n){let{keyframes:r,velocity:i}=e,a=r&&r[r.length-1]-r[0],o=n({...e,velocity:i&&a?i*t/a:i,keyframes:[0,t]}),s=Math.min(PB(o),NB);return{type:`keyframes`,ease:e=>o.next(s*e).value/t,duration:BR(s)}}var IB={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},LB=e=>e<0?1/Math.max(1+e,IB.minDamping):Math.max(1-e,IB.minDamping);function RB(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 VB(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function zB(e,t){return e*Math.sqrt(1-t*t)}var BB=12;function VB(e,t,n){let r=n;for(let n=1;n<BB;n++)r-=e(r)/t(r);return r}var HB=.001;function UB({duration:e=IB.duration,bounce:t=IB.bounce}){let n,r;IB.maxDuration;let i=LB(t);e=kR(IB.minDuration,IB.maxDuration,BR(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=zB(t,i),o=Math.exp(-r);return HB-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=zB(t*t,i);return(-n(t)+HB>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=VB(n,r,a),s=o*RB(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:zR(e)}}var WB=(e,t)=>(t?e>=0:e>0)&&e<1/0;function GB(e,t){if(WB(e,t))return e}function KB(e){let t=GB(e.stiffness),n=GB(e.damping,!0),r=GB(e.mass),i={...e,stiffness:t??IB.stiffness,damping:n??IB.damping,mass:r??IB.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=LB(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*RB(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,UB(i)),i.isResolvedFromDuration=!0;(!WB(i.stiffness)||!WB(i.damping,!0))&&(i.stiffness=IB.stiffness,i.damping=IB.damping)}return i}function qB(e=IB.visualDuration,t=IB.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}=KB({...n}),f=e=>d?0:-BR(e),p=s/(2*Math.sqrt(o*c)),m=BR(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?IB.restSpeed.granular:IB.restSpeed.default),g.restDelta=n.restDelta||(e?IB.restDelta.granular:IB.restDelta.default)};_();let v,y,b;if(p<1){let e=zB(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=>zR(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=zR(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(PB(S),NB),t=MB(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}qB.applyToOptions=e=>{let t=FB(e,100,qB);return e.ease=t.ease,e.duration=zR(t.duration),e.type=`keyframes`,e};function JB({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=qB({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 YB(e,t,n){let r=[],i=n||AR.mix||CB,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=IR(Array.isArray(t)?t[n]||FR:t,a)),r.push(a)}return r}function XB(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=YB(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=LR(e[r],e[r+1],n);return s[r](i)};return n?t=>l(kR(e[0],e[a-1],t)):l}function ZB(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=LR(0,t,r);e.push(sB(n,1,i))}}function QB(e){let t=[0];return ZB(t,e.length-1),t}function $B(e,t){return e.map(e=>e*t)}function eV(e,t){return e.map(()=>t||tz).splice(0,e.length-1)}function tV({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=nz(r)?r.map(oz):oz(r)||tz,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:(AR.mix||CB)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?kR(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=XB($B(n&&n.length===t.length?n:QB(t),e),t,{ease:Array.isArray(i)?i:eV(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var nV=5;function rV(e,t,n){let r=Math.max(t-nV,0);return VR(n-e(r),t-r)}function iV(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):rV(t=>e.next(t).value,t,e.next(t).value)}var aV=e=>e!==null;function oV(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(aV),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var sV={decay:JB,inertia:JB,tween:tV,keyframes:tV,spring:qB};function cV(e){typeof e.type==`string`&&(e.type=sV[e.type])}var lV=40,uV=(e,t)=>t-e>lV&&!AR.useManualTiming?t:e;function dV(e,t){return{kind:e,animation:t,timestamp:uz.now(),frameTimestamp:sz.timestamp,frameIsProcessing:sz.isProcessing}}function fV(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...dV(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function pV(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...dV(`layout-animation-start`,e),node:t})}catch{}}var mV=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)}},hV=e=>e/100,gV=e=>Math.round(e*1e4)/1e4,_V=class extends mV{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!==uz.now()&&this.tick(uz.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),fV(this,this.options)}initAnimation(){let{options:e}=this;cV(e);let{type:t=tV,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||tV;s!==tV&&typeof o[0]!=`number`&&(this.mixKeyframes=IR(hV,CB(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=PB(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,calculatedDuration:i}=this;if(this.startTime===null)return n.next(0);let{delay:a=0,keyframes:o,type:s,onUpdate:c,finalKeyframe:l}=this.options;this.startTime===this.pendingStartTime&&(this.startTime=uV(this.startTime,e)),this.pendingStartTime=void 0,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 u=this.currentTime-a*(this.playbackSpeed>=0?1:-1),d=this.playbackSpeed>=0?u<0:u>r;this.currentTime=Math.max(u,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let f=this.generate(this.currentTime,d),{done:p}=f;!d&&i!==null&&(p=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let m=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&p);return m&&s!==JB&&(f.value=oV(o,this.options,l,this.speed)),c&&c(f.value),m&&this.finish(),f}at(e){return this.holdTime??gV((e-this.startTime)*this.playbackSpeed)}sampleAt(e,t){let{options:n,totalDuration:r}=this,i=this.at(e)-(n.delay||0);return i>=r&&n.type!==JB?oV(n.keyframes,n,t?void 0:n.finalKeyframe):this.generate(Math.max(i,0),i<0).value}generate(e,t){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o}=this,{keyframes:s,repeat:c,repeatType:l,repeatDelay:u}=this.options,d=e,f=n;if(c){let t=Math.min(e,r)/o,n=Math.floor(t),i=t%1;!i&&t>=1&&(i=1),i===1&&n--,n=Math.min(n,c+1),n%2&&(l===`reverse`?(i=1-i,u&&(i-=u/o)):l===`mirror`&&(f=a)),d=kR(0,1,i)*o}let p;return t?(this.delayState.value=s[0],p=this.delayState):p=f.next(d),i&&!t&&(p.value=i(p.value)),p}then(e,t){return this.finished.then(e,t)}get duration(){return BR(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+BR(e)}get time(){return BR(this.currentTime)}set time(e){e=zR(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 iV(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(uz.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=BR(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=jB,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??(this.pendingStartTime=n):this.startTime=n-this.holdTime/(this.playbackSpeed||1),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(uz.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)}},vV=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function yV(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(xz)||[];if(!r)return e;let i=n.replace(r,``),a=+!!vV.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var bV=/\b([a-z-]*)\(.*?\)/gu,xV={...rB,getAnimatableNone:e=>{let t=e.match(bV);return t?t.map(yV).join(` `):e}},SV={...rB,getAnimatableNone:e=>{let t=rB.parse(e);return rB.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},CV={...vz,transform:Math.round},wV={borderWidth:Y,borderTopWidth:Y,borderRightWidth:Y,borderBottomWidth:Y,borderLeftWidth:Y,borderRadius:Y,borderTopLeftRadius:Y,borderTopRightRadius:Y,borderBottomRightRadius:Y,borderBottomLeftRadius:Y,width:Y,maxWidth:Y,height:Y,maxHeight:Y,top:Y,right:Y,bottom:Y,left:Y,inset:Y,insetBlock:Y,insetBlockStart:Y,insetBlockEnd:Y,insetInline:Y,insetInlineStart:Y,insetInlineEnd:Y,padding:Y,paddingTop:Y,paddingRight:Y,paddingBottom:Y,paddingLeft:Y,paddingBlock:Y,paddingBlockStart:Y,paddingBlockEnd:Y,paddingInline:Y,paddingInlineStart:Y,paddingInlineEnd:Y,margin:Y,marginTop:Y,marginRight:Y,marginBottom:Y,marginLeft:Y,marginBlock:Y,marginBlockStart:Y,marginBlockEnd:Y,marginInline:Y,marginInlineStart:Y,marginInlineEnd:Y,fontSize:Y,backgroundPositionX:Y,backgroundPositionY:Y,rotate:Mz,pathRotation:Mz,rotateX:Mz,rotateY:Mz,rotateZ:Mz,scale:bz,scaleX:bz,scaleY:bz,scaleZ:bz,skew:Mz,skewX:Mz,skewY:Mz,distance:Y,translateX:Y,translateY:Y,translateZ:Y,x:Y,y:Y,z:Y,perspective:Y,transformPerspective:Y,opacity:yz,originX:Iz,originY:Iz,originZ:Y,zIndex:CV,fillOpacity:yz,strokeOpacity:yz,numOctaves:CV},TV={...wV,color:Rz,backgroundColor:Rz,outlineColor:Rz,fill:Rz,stroke:Rz,borderColor:Rz,borderTopColor:Rz,borderRightColor:Rz,borderBottomColor:Rz,borderLeftColor:Rz,filter:xV,WebkitFilter:xV,mask:SV,WebkitMask:SV},EV=e=>TV[e],DV=new Set([xV,SV]);function OV(e,t){let n=EV(e);return DV.has(n)||(n=rB),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function kV(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var AV=e=>e*180/Math.PI,jV=e=>NV(AV(Math.atan2(e[1],e[0]))),MV={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scaleZ:()=>1,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:jV,rotateZ:jV,skewX:e=>AV(Math.atan(e[1])),skewY:e=>AV(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},NV=e=>(e%=360,e<0&&(e+=360),e),PV=jV,FV=e=>Math.hypot(e[0],e[1]),IV=e=>Math.hypot(e[4],e[5]),LV={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:FV,scaleY:IV,scaleZ:e=>Math.hypot(e[8],e[9],e[10]),scale:e=>(FV(e)+IV(e))/2,rotateX:e=>NV(AV(Math.atan2(e[6],e[5]))),rotateY:e=>NV(AV(Math.atan2(-e[2],e[0]))),rotateZ:PV,rotate:PV,skewX:e=>AV(Math.atan(e[4])),skewY:e=>AV(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function RV(e){return+!!e.includes(`scale`)}function zV(e,t){if(!e||e===`none`)return RV(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=LV,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=MV,i=t}if(!i)return RV(t);let a=r[t],o=i[1].split(`,`).map(VV);return typeof a==`function`?a(o):o[a]}var BV=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return zV(n,t)};function VV(e){return parseFloat(e.trim())}var HV=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],UV=new Set([...HV,`pathRotation`]),WV=e=>e===vz||e===Y,GV=new Set([`x`,`y`,`z`]),KV=HV.filter(e=>!GV.has(e));function qV(e){let t=[];return KV.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 JV=new Set([`bottom`,`right`]);function YV(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 XV={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>YV(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>YV(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})=>zV(e,`x`),y:({transform:e})=>zV(e,`y`)};XV.translateX=XV.x,XV.translateY=XV.y;var ZV=new Set,QV=!1,$V=!1,eH=!1;function tH(){if($V){let e=[],t=new Set,n=new Set;ZV.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),JV.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=qV(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)})}$V=!1,QV=!1,ZV.forEach(e=>e.complete(eH)),ZV.clear()}function nH(){ZV.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&($V=!0)})}function rH(){eH=!0,nH(),tH(),eH=!1}function iH(e,t,n){if(typeof e==`string`){if(jR(e)||NR(e))return parseFloat(e);if(!rB.test(e)&&rB.test(n))return OV(t,n)}return e??void 0}var aH=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?(ZV.add(this),QV||(QV=!0,OB.read(nH),OB.resolveKeyframes(tH))):(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=iH(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])}kV(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ZV.delete(this)}cancel(){this.state===`scheduled`&&(ZV.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},oH=e=>e.startsWith(`--`);function sH(e,t,n){oH(t)?e.style.setProperty(t,n):e.style[t]=n}var cH={};function lH(e,t){let n=PR(e);return()=>cH[t]??n()}var uH=lH(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),dH=lH(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),fH=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,pH={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:fH([0,.65,.55,1]),circOut:fH([.55,0,1,.45]),backIn:fH([.31,.01,.66,-.59]),backOut:fH([.33,1.53,.69,.99])};function mH(e,t){if(e)return typeof e==`function`?dH()?MB(e,t):`ease-out`:rz(e)?fH(e):Array.isArray(e)?e.map(e=>mH(e,t)||pH.easeOut):pH[e]}function hH(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=mH(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 gH(e){return typeof e==`function`&&`applyToOptions`in e}function _H({type:e,...t}){return gH(e)&&dH()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var vH=class extends mV{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=_H(e);this.animation=hH(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=oV(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),sH(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},fV(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 BR(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+BR(e)}get time(){return BR(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=zR(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&&uH()?(this.animation.timeline=e,t?.(this.animation),FR):n(this)}},yH={anticipate:YR,backInOut:JR,circInOut:QR};function bH(e){return e in yH}function xH(e){typeof e.ease==`string`&&bH(e.ease)&&(e.ease=yH[e.ease])}var SH=class extends vH{constructor(e){xH(e),cV(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}elapsed(){return this.state===`running`?(uz.now()-this.startTime)*this.speed:this.time*1e3}sample(e){if(!this.sampler){let{motionValue:e,onUpdate:t,onComplete:n,onPlay:r,onStop:i,element:a,...o}=this.options;this.sampler=new _V({...o,autoplay:!1}),this.sampler.stop()}return this.sampler.sample(Math.max(0,e)).value}liveValue(){let{state:e}=this;if(e===`running`||e===`paused`)return this.sample(this.elapsed())}updateMotionValue(e){let{motionValue:t,element:n,name:r}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let{speed:i}=this,a=this.elapsed(),o=this.state===`running`&&i?kR(0,10,a):0,s=this.sample(a);n&&r&&sH(n,r,s),t.setWithVelocity(this.sample(a-o*Math.sign(i)),s,o/Math.abs(i||1))}},CH=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(rB.test(e)||e===`0`)&&!e.startsWith(`url(`));function wH(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 TH(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=CH(i,t),s=CH(a,t);return!o||!s?(o!==s&&`${t}${i}${a}${o?a:i}`,!1):wH(e)||(n===`spring`||gH(n))&&r}function EH(e){e.duration=0,e.type=`keyframes`}var DH=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),OH=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function kH(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&OH.test(e[t]))return!0;return!1}var AH=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),jH=PR(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function MH(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(DH.has(n)||AH.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 jH()&&(DH.has(n)||AH.has(n)&&kH(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var NH=(e,t)=>t&&typeof e==`number`?t.transform(e):e,PH={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},FH=HV.length;function IH(e,t,n){let r=``,i=!0;for(let a=0;a<FH;a++){let o=HV[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=NH(s,wV[o]);if(!c){i=!1;let t=PH[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${NH(a,wV.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}var LH=new WeakMap,RH=200,zH=.001,BH=.1,VH=.001,HH=100,UH=e=>/^(linear|ease(In|Out|InOut))$/.test(e),WH=(e,t)=>e-t,GH=(e,t,n)=>{let r=[];for(let i=0;i<=n;i++)r.push(sB(e,t,i/n));return r},KH=e=>e.motionValue.owner,qH=e=>LH.get(e),JH=(e,t)=>e.latestValues?e.latestValues[t]:e.getValue(t)?.get(),YH=({name:e,motionValue:t})=>e&&HV.includes(e)&&t?.owner?.current instanceof HTMLElement&&jH()&&dH();function XH(e){let t=KH(e),{onUpdate:n,transformTemplate:r}=t.getProps();return!e.isHandoff&&!n&&!e.hasOnUpdate&&!r&&e.type!==`inertia`&&(JH(t,`transform`)||`none`)===`none`&&!JH(t,`pathRotation`)&&!t.projection?.isProjecting()}var ZH=class extends _V{constructor(e){let t=KH(e).current,{driver:n=jB}=e,r=XH(e);e.driver=e=>{let r=n(e);return{js:r,now:r.now,start:(e=!0)=>{let n=qH(t);!n||n.isJS?r.start(e):n.schedule(!1,!e)},stop:()=>{r.stop();let e=qH(t);e?.schedule(!e.isFinishing)}}},super(e),this.canAccelerate=r;let{stop:i}=this;this.stop=()=>{this.isAccelerated()&&this.sync(),i()}}get group(){return qH(KH(this.options).current)}get js(){return this.driver?.js}get name(){return this.options.name}timing(){let{startTime:e,speed:t,totalDuration:n}=this,{delay:r=0,repeatType:i}=this.options;return this.holdTime===null?n===1/0?[e+r/t,this.resolvedDuration*(i===`loop`?1:2)/t||1]:[e+(r+n)/t,0]:[1/0,0]}isAccelerated(){let{group:e,state:t}=this;return e?.tracks.has(this)&&!e.isJS&&this.canAccelerate&&(t===`running`||t===`paused`)}liveValue(){return this.isAccelerated()?this.sampleAt(uz.now()):void 0}tween(){let{keyframes:e,type:t,ease:n,times:r,repeat:i,delay:a=0}=this.options,o=rz(n)?fH(n):UH(n)&&pH[n];if(o&&!i&&!r&&e.length===2&&t===tV&&this.holdTime===null){let e=this.startTime+a/this.speed;return[e,e+this.resolvedDuration/this.speed,o]}}boundaries(e,t){let{startTime:n,speed:r,resolvedDuration:i,options:a}=this,{delay:o=0,repeat:s=0,repeatDelay:c=0,repeatType:l,times:u,keyframes:d,type:f}=a,p=(f||tV)===tV?u||QB(d):[0,1],m=n+o/r,h=[];if(this.holdTime!==null||!(i>0))return h;for(let n=Math.max(0,Math.floor((e-m)*r/i));n<=s;n++){let a=m+n*i/r;if(a>t)break;for(let o of p){let s=a+(n%2&&l&&l!==`loop`?1-o:o)*(i-c)/r;s>e&&s<t&&h.push(s)}}return h}numberAt(e){return parseFloat(this.sampleAt(e,!0))}sync(){let e=uz.now();this.options.motionValue.setWithVelocity(this.sampleAt(e-10,!0),this.sampleAt(e,!0),10)}play(){this.isStopped||((this.group||QH(KH(this.options))).tracks.add(this),super.play())}pause(){super.pause(),this.isAccelerated()&&(this.sync(),this.group.schedule(!1))}complete(){super.complete();let{group:e}=this;e&&!e.isJS&&this.canAccelerate&&this.tick(uz.now())}get time(){return this.isAccelerated()?BR(kR(0,this.totalDuration,this.at(uz.now())-(this.options.delay||0))):super.time}set time(e){super.time=e}attachTimeline(e){return this.canAccelerate=!1,this.group?.demote(!0),super.attachTimeline(e)}};function QH(e){let t=e.current,n=new Set,r=new Map,i={},a=[],o=new Map,s=[],c=!1,l=!1,u=!1,d=-1/0,f=e=>{for(let t of n)if(t.name===e)return!0},p=(t,n)=>{let o={};for(let s of t===void 0?HV:a){let a=r.get(s),c=t===void 0?JH(e,s):a?a.sampleAt(n>t&&!a.timing()[1]?n:t):i[s];c!==void 0&&(o[s]=c)}return o},m=(e,t)=>{let n=``,r=p(e,t);for(let e in r)n+=(PH[e]||e)+`(`+NH(r[e],wV[e])+`) `;return n||`none`},h=(e=p())=>{t.style.transform=IH(e,{})},g=(e=!0)=>{e&&h(),s.forEach(({animation:e})=>e.cancel()),s=[]},_=(e,t,n=1/0)=>{let r={animation:e,offset:t,end:n};e.startTime=uz.now()+t,n<1/0&&(e.onfinish=()=>{r.isDone=!0,s.some(e=>e.end===1/0)&&(e.cancel(),s=s.filter(e=>e!==r)),E.schedule(!1)}),e.oncancel=()=>s.includes(r)&&E.demote(),s.push(r)},v=(e,t,n)=>{let r=(t,n)=>Math.abs(e(n)-e(t)),i=r(t,n);for(;n-t>.01;){let e=(t+n)/2;r(t,e)>r(e,n)?n=e:t=e}return r(t,n)>i/2?[t,n]:[]},y=(e,t,n,r)=>{let i=Math.min(RH,Math.max(2,Math.ceil((n-t)/10)));if(r.length*4>i)return;let a=GH(t,n,i).concat(r).sort(WH),o=e=>LR(t,n,e),s,c;for(let t of e){let e=a.map(e=>t.numberAt(e)),[n]=e,r=e[e.length-1]-n,i=e.map(e=>r?(e-n)/r:e-n);if(!r){if(i.some(e=>!(Math.abs(e)<=zH)))return}else if(!s)s=i,c=e=>(t.numberAt(e)-n)/r;else if(i.some((e,t)=>!(Math.abs(e-s[t])<=zH)))return}if(!s||s.every((e,t)=>Math.abs(e-o(a[t]))<=zH))return`linear`;let l=[],u=(e,t=c(e))=>l.push(gV(t)+` `+gV(o(e)*100)+`%`);return s.forEach((e,t)=>{t&&Math.abs(e-s[t-1])>.2&&v(c,a[t-1],a[t]).forEach(e=>u(e)),u(a[t],e)}),`linear(`+l+`)`},b=(e,t,n,r)=>{let i=[t],a=(t,n)=>e.every(e=>!(Math.abs(e.numberAt((t+n)/2)-(e.numberAt(t)+e.numberAt(n))/2)>(e.name.startsWith(`scale`)?VH:BH))),o=(t,n,r)=>{if(n-t<1||a(t,n))i.push(n);else if(r<4)o(t,(t+n)/2,r+1),o((t+n)/2,n,r+1);else{for(let r of e)i.push(...v(e=>r.numberAt(e),t,n));i.push(n)}},s=GH(t,n,Math.ceil((n-t)/100));for(let e of r)s.push(e,Math.min(e+.01,n));let c=t;for(let e of s.sort(WH))e>c&&o(c,e,0),c=e;return i.sort(WH)},x=e=>{let t;for(let n of e){let e=n.tween();if(!e||t?.some((t,n)=>n<2?Math.abs(e[n]-t)>1:e[n]!==t))return;t=e}return t},S=(e,n,r,i={fill:`both`},a,o)=>{let s=e.flatMap(e=>e.boundaries(n,r)),c=o||y(e,n,r,s),l=c?[n,r]:b(e,n,r,s),u=l.map(e=>m(e,a)),d={transform:u};return c||(d.offset=l.map(e=>LR(n,r,e))),u.every(e=>e===u[0])&&(h(p(n,a)),d=null),t.animate(d,{...i,duration:r-n,easing:c||`linear`})},C=c=>{let l=c,u=0,d=0,f=[],p=[],m=new Set;r.clear(),o=new Map;for(let e of n){r.set(e.name,e);let[t,n]=e.timing(),i=t===1/0;if(o.set(e,[e.at(c),e.speed,i]),i)e.sync();else{if(e.speed<0)return;if(n){if(u){let e=(t-d)/n;if(Math.abs(n-u)>1||Math.abs(e-Math.round(e))*u>1)return}else u=n,d=t;p.push(e)}else m.add(t);f.push(e),l=Math.max(l,t)}}i={},a=HV.filter(t=>{if(r.has(t))return!0;let n=i[t]=JH(e,t);return n!==void 0&&parseFloat(n)!==+!!t.startsWith(`scale`)}),g(!1);let h=!u&&x(f);try{if(h&&h[1]>c){let[e,t,n]=h;_(S(f,e,t,void 0,void 0,n),e-c,t-e)}else l>c&&(_(S(f,c,l),0,l-c),m.forEach(e=>e<l-1&&_(t.animate(null,{duration:e-c}),0,e-c)));if(u){let e=d+Math.floor((l-d)/u)*u;_(S(p,e,e+u,{iterations:1/0,iterationStart:(l-e)/u,fill:`forwards`},l),l-c)}}catch{return}return s.length||g(),!0},w=e=>{let t,r=0;for(let i of n){let n=o.get(i);if(!n)return!1;let[a,s,c]=n,l=i.at(e),u=i.timing()[0]===1/0;if(c){if(u&&l===a)continue;return!1}let d=(l-a)/s,f=u?0:i.speed/s;if(t===void 0)t=d,r=f;else if(Math.abs(d-t)>1||f!==r)return!1}if(t===void 0)return!0;if(!s.length)return!1;for(let{offset:e,end:n,isDone:r}of s){let i=t-e;if(n<1/0&&(r?i<n-1:i<0||i>=n))return!1}for(let{animation:n,offset:i,isDone:a}of s){if(a)continue;let o=t-i;r?(n.playbackRate=r,n.startTime=e-o/r):(n.pause(),n.currentTime=o)}return!0},T=()=>{let r=uz.now();if(E.isJS||(E.isFinishing=!0,n.forEach(t=>{let[n,a]=t.timing();t.state===`running`&&t.speed>0&&!a&&n<=r+1&&(t.complete(),i[t.name]=JH(e,t.name),o.has(t)||(c=!0))}),E.isFinishing=!1),l=!1,n.forEach(({state:e},t)=>{(e===`idle`||e===`finished`)&&n.delete(t)}),!n.size){LH.delete(t),E.isJS||g();return}for(let e of n)if(!e.canAccelerate)return E.demote(!0);E.isJS&&(E.isJS=!1,c=!0,n.forEach(e=>e.js?.stop()));let a=c,s=u;if(c=u=!1,a||!w(r)){if(s){if(r-d<HH)return E.demote();d=r}if(!C(r))return E.demote()}},E={tracks:n,isJS:!1,isFinishing:!1,schedule(e,t){c||=e,u||=!!t,l||(l=!0,sz.isProcessing?OB.render(T,!1,!0):queueMicrotask(T))},check(){if(!E.isJS){for(let t in i)if(JH(e,t)!==i[t]&&!f(t))return E.schedule(!0,!0)}},demote(e){E.isJS||(n.forEach(t=>{t.isAccelerated()&&t.sync(),e||(t.canAccelerate=!1)}),E.isJS=!0,o=new Map,g(),n.forEach(e=>e.state===`running`&&e.js?.start()))}};return LH.set(t,E),E}var $H=class extends mV{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=uz.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||aH;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=uz.now();let u=!0;TH(e,i,a,o)||(u=!1,(AR.instantAnimations||!s)&&l?.(oV(e,n,t)),e[0]=e[e.length-1],EH(n),n.repeat=0);let{onComplete:d}=n;n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{d?.(),this.notifyFinished()};let f=u&&!c&&MH(n),p=!f&&YH(n);r&&(f||p||this.resolvedAt!==this.createdAt)&&(n.startTime??=uV(this.createdAt,this.resolvedAt));let m;if(f){n.element=n.motionValue?.owner?.current;try{m=new SH(n)}catch{m=new _V(n)}}else m=p?new ZH(n):new _V(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(()=>{})}liveValue(){return this._animation?.liveValue?.()}get animation(){return this._animation||(this.keyframeResolver?.resume(),rH()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function eU(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 tU=30,nU=e=>!isNaN(parseFloat(e)),rU={current:void 0},iU=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=uz.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=uz.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=nU(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 RR)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new RR,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(){OB.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(){rU.current&&rU.current.push(this);let e=this.animation?.liveValue?.();return e===void 0?this.current:e}getCurrent(){return this.current}getPrevious(){return this.prev}getVelocity(){let e=uz.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>tU)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,tU);return VR(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 aU(e,t){return new iU(e,t)}function oU(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function sU(e,t){let n=e?.[t]??e?.default??e;return n===e?n:oU(n,e)}var cU={type:`spring`,stiffness:500,damping:25,restSpeed:10},lU=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),uU={type:`keyframes`,duration:.8},dU={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},fU=(e,{keyframes:t})=>t.length>2?uU:UV.has(e)?e.startsWith(`scale`)?lU(t[1]):cU:dU,pU=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function mU(e){for(let t in e)if(!pU.has(t))return!0;return!1}var hU=(e,t,n,r={},i,a)=>o=>{let s=sU(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=zR(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,hasOnUpdate:!!s.onUpdate};mU(s)||Object.assign(u,fU(e,u)),u.duration&&=zR(u.duration),u.repeatDelay&&=zR(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(EH(u),u.delay===0&&(d=!0)),(AR.instantAnimations||AR.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,EH(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=oV(u.keyframes,s);if(e!==void 0){OB.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new _V(u):new $H(u)},gU=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function _U(e){let t=gU.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function vU(e,t,n=1){`${e}`;let[r,i]=_U(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return jR(e)?parseFloat(e):e}return hz(i)?vU(i,t,n+1):i}function yU(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function bU(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...yU(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function xU(e,t,n){return bU(e.getProps(),t,n,e)}var SU=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,CU=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...HV]),wU=e=>Array.isArray(e);function TU(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,aU(n))}function EU(e){return wU(e)?e[e.length-1]||0:e}function DU(e,t){let{transitionEnd:n={},transition:r={},...i}=xU(e,t)||{};i={...i,...n};for(let t in i)TU(e,t,EU(i[t]))}var OU=e=>!!(e&&e.getVelocity);function kU(e){return!!(OU(e)&&e.add)}function AU(e,t){let n=e.getValue(`willChange`);if(kU(n))return n.add(t);if(!n&&AR.WillChange){let n=new AR.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function jU(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var MU=`data-`+jU(`framerAppearId`);function NU(e){return e.props[MU]}var PU=typeof window<`u`;function FU({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function IU(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?oU(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&&FU(f,t))continue;let o={delay:n,...sU(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){OB.update(()=>r.set(i));continue}let p=!1;if(PU&&window.MotionHandoffAnimation){let n=NU(e);if(n){let e=window.MotionHandoffAnimation(n,t,OB);e!==null&&(o.startTime=e,p=!0)}}AU(e,t);let m=l??e.shouldReduceMotion;r.start(hU(t,r,i,m&&CU.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>OB.update(()=>{o&&DU(e,o)});d.length?Promise.all(d).then(t):t()}return d}function LU(e,t,n={}){let r=xU(e,t,SU(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?IU(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(LU(e,t,{...n,delay:r+(typeof o==`function`?0:o)+eU(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 RU(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>LU(e,t,n))):typeof t==`string`?LU(e,t,n):Promise.all(IU(e,xU(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var zU={test:e=>e===`auto`,parse:e=>e},BU=e=>t=>t.test(e),VU=[vz,Y,Nz,Mz,Fz,Pz,zU],HU=e=>VU.find(BU(e));function UU(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||NR(e)}var WU=new Set([`auto`,`none`,`0`]);function GU(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!WU.has(t)&&Yz(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=OV(n,i))}var KU=class extends aH{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}scheduleResolve(){if(this.canReadNow()&&(this.readKeyframes(),!this.needsMeasurement))return this.complete();super.scheduleResolve()}canReadNow(){let{unresolvedKeyframes:e,element:t,motionValue:n}=this,r=e[0]??n?.get();if(!t?.current||r===void 0)return!1;for(let t=0;t<e.length;t++)if(_z(t?e[t]:r))return!1;return!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(),hz(r))){let i=vU(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!CU.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=HU(r),o=HU(i);if(_z(r)!==_z(i)&&XV[n])this.needsMeasurement=!0;else if(a!==o){if(WV(a)&&WV(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else XV[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||UU(e[t]))&&n.push(t);n.length&&GU(e,n,t)}measure(){let{element:e,name:t}=this;return XV[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()}},qU=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function JU(e){return MR(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function YU(e){return MR(e)&&`ownerSVGElement`in e}function XU(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)}function ZU(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(UV.has(e))o=!0;else if(pz(e))i[e]=n;else{let t=NH(n,wV[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=IH(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 QU={offset:`stroke-dashoffset`,array:`stroke-dasharray`},$U={offset:`strokeDashoffset`,array:`strokeDasharray`};function eW(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?QU:$U;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var tW=[`transform`,`opacity`,`clipPath`,`filter`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function nW(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(ZU(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 tW)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&&eW(d,i,a,o,!1)}function rW({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function iW({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function aW(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 oW(e){return e===void 0||e===1}function sW({scale:e,scaleX:t,scaleY:n}){return!oW(e)||!oW(t)||!oW(n)}function cW(e){return sW(e)||lW(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function lW(e){return uW(e.x)||uW(e.y)}function uW(e){return e&&e!==`0%`}function dW(e,t,n){return n+t*(e-n)}function fW(e,t,n,r,i){return i!==void 0&&(e=dW(e,i,r)),dW(e,n,r)+t}function pW(e,t=0,n=1,r,i){e.min=fW(e.min,t,n,r,i),e.max=fW(e.max,t,n,r,i)}function mW(e,{x:t,y:n}){pW(e.x,t.translate,t.scale,t.originPoint),pW(e.y,n.translate,n.scale,n.originPoint)}var hW=.999999999999,gW=1.0000000000001;function _W(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&&(vW(e.x,-a.scroll.offset.x),vW(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,mW(e,o)),r&&cW(a.latestValues)&&xW(e,a.latestValues,a.layout?.layoutBox))}t.x<gW&&t.x>hW&&(t.x=1),t.y<gW&&t.y>hW&&(t.y=1)}function vW(e,t){e.min+=t,e.max+=t}function yW(e,t,n,r,i=.5){pW(e,t,n,sB(e.min,e.max,i),r)}function bW(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function xW(e,t,n){let r=n??e;yW(e.x,bW(t.x,r.x),t.scaleX,t.scale,t.originX),yW(e.y,bW(t.y,r.y),t.scaleY,t.scale,t.originY)}function SW(e,t){return rW(aW(e.getBoundingClientRect(),t))}function CW(e,t,n){let r=SW(e,n),{scroll:i}=t;return i&&(vW(r.x,i.offset.x),vW(r.y,i.offset.y)),r}var{schedule:wW,cancel:Jae}=DB(queueMicrotask,!1),TW={x:!1,y:!1};function EW(){return TW.x||TW.y}function DW(e){return e===`x`||e===`y`?TW[e]?null:(TW[e]=!0,()=>{TW[e]=!1}):TW.x||TW.y?null:(TW.x=TW.y=!0,()=>{TW.x=TW.y=!1})}function OW(e,t){let n=XU(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function kW(e){return!(e.pointerType===`touch`||EW())}function AW(e,t,n={}){let[r,i,a]=OW(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=>{e.pointerType!==`touch`&&(n?r=!0:s(e))};e.addEventListener(`pointerenter`,n=>{if(!kW(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 jW=(e,t)=>t?e===t||jW(e,t.parentElement):!1,MW=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,NW=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function PW(e){return NW.has(e.tagName)||e.isContentEditable===!0}var FW=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function IW(e){return FW.has(e.tagName)||e.isContentEditable===!0}var LW=new WeakSet;function RW(e){return t=>{t.key===`Enter`&&e(t)}}function zW(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var BW=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=RW(()=>{if(LW.has(n))return;zW(n,`down`);let e=RW(()=>{zW(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>zW(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function VW(e){return MW(e)&&!EW()}var HW=new WeakSet;function UW(e,t,n={}){let[r,i,a]=OW(e,n),o=e=>{let r=e.currentTarget;if(!VW(e)||HW.has(e))return;LW.add(r),n.stopPropagation&&HW.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),LW.has(r)&&LW.delete(r),VW(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||jW(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),JU(e)&&(e.addEventListener(`focus`,e=>BW(e,i)),!PW(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var WW=new WeakMap,GW,KW=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:YU(r)&&`getBBox`in r?r.getBBox()[t]:r[n],qW=KW(`inline`,`width`,`offsetWidth`),JW=KW(`block`,`height`,`offsetHeight`);function YW({target:e,borderBoxSize:t}){WW.get(e)?.forEach(n=>{n(e,{get width(){return qW(e,t)},get height(){return JW(e,t)}})})}function XW(e){e.forEach(YW)}function ZW(){typeof ResizeObserver<`u`&&(GW=new ResizeObserver(XW))}function QW(e,t){GW||ZW();let n=XU(e);return n.forEach(e=>{let n=WW.get(e);n||(n=new Set,WW.set(e,n)),n.add(t),GW?.observe(e)}),()=>{n.forEach(e=>{let n=WW.get(e);n?.delete(t),n?.size||GW?.unobserve(e)})}}var $W=new Set,eG;function tG(){eG=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};$W.forEach(t=>t(e))},window.addEventListener(`resize`,eG)}function nG(e){return $W.add(e),eG||tG(),()=>{$W.delete(e),!$W.size&&typeof eG==`function`&&(window.removeEventListener(`resize`,eG),eG=void 0)}}function rG(e,t){return typeof e==`function`?nG(e):QW(e,t)}var iG={value:null,addProjectionMetrics:null};function aG(e){return YU(e)&&e.tagName===`svg`}function oG(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=XB(i,a,o);return t?s(r):s}var sG=e=>typeof e==`number`?e:parseFloat(e),cG=()=>({translate:0,scale:1,origin:0,originPoint:0}),lG=()=>({x:cG(),y:cG()}),uG=()=>({min:0,max:0}),dG=()=>({x:uG(),y:uG()}),fG=new WeakMap;function pG(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function mG(e){return typeof e==`string`||Array.isArray(e)}var hG=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],gG=[`initial`,...hG];function _G(e){if(pG(e.animate))return!0;for(let t=0;t<gG.length;t++)if(mG(e[gG[t]]))return!0;return!1}function vG(e){return!!(_G(e)||e.variants)}function yG(e,t,n){for(let r in t){let i=t[r],a=n[r];if(OU(i))e.addValue(r,i);else if(OU(a))e.addValue(r,aU(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,aU(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var bG={current:null},xG={current:!1},SG=typeof window<`u`;function CG(){if(xG.current=!0,SG){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>bG.current=e.matches;e.addEventListener(`change`,t),t()}else bG.current=!1}}var wG=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],TG={};function EG(e){TG=e}function DG(){return TG}var OG=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=aH,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=uz.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,OB.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=_G(t),this.isVariantNode=vG(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&&OU(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,fG.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:(xG.current||CG(),this.shouldReduceMotion=bG.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(),kB(this.notifyUpdate),kB(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&&DH.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new vH({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:zR(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=UV.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&OB.preRender(this.notifyUpdate),n&&(this.projection&&(this.projection.isTransformDirty=!0),LH.get(this.current)?.check()),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 TG){let t=TG[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):dG()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){let{transformTemplate:n,onUpdate:r}=this.props;(e.transformTemplate||n)&&this.scheduleRender(),(e.transformTemplate&&!n||e.onUpdate&&!r)&&LH.get(this.current)?.demote(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<wG.length;t++){let n=wG[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=yG(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=aU(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`&&(jR(n)||NR(n))?n=parseFloat(n):typeof n!=`number`&&!rB.test(n)&&rB.test(t)&&(n=OV(e,t)),this.setBaseTarget(e,OU(n)?n.get():n)),OU(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new RR),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){wW.render(this.render)}},kG=class extends OG{constructor(){super(...arguments),this.KeyframeResolver=KU}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;OU(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},AG=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function jG(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 MG={};function NG(e,{layout:t,layoutId:n}){return UV.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!MG[e]||e===`opacity`)}function PG(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(OU(r[t])||i&&OU(i[t])||NG(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function FG(e){return window.getComputedStyle(e)}var IG=class extends kG{constructor(){super(...arguments),this.type=`html`,this.renderInstance=jG}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(UV.has(t))return this.projection?.isProjecting?RV(t):BV(e,t);{let n=FG(e),r=(pz(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return SW(e,t)}build(e,t,n){ZU(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return PG(e,t,n)}},LG=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`]),RG=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function zG(e,t,n,r){jG(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(LG.has(n)?n:jU(n),t.attrs[n])}function BG(e,t,n){let r=PG(e,t,n);for(let n in e)if(n!==`children`&&(OU(e[n])||OU(t[n]))){let t=HV.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var VG=class extends kG{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=dG}getBaseTargetFromProps(e,t){return UV.has(t)?super.getBaseTargetFromProps(e,t)??RV(t):e[t]}getDefaultValue(e){return UV.has(e)?this.latestValues[e]??RV(e):void 0}readValueFromInstance(e,t){if(UV.has(t)){let e=EV(t);return e&&e.default||0}if(tW.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=LG.has(t)?t:jU(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return BG(e,t,n)}build(e,t,n){nW(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){zG(e,t,n,r)}mount(e){this.isSVGTag=RG(e.tagName),super.mount(e)}};function HG(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 UG=[...hG].reverse();function WG(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>RU(e,t,n))),n=KG(),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(UG.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?mG(g)||g===!1?g:void 0:h,v=mG(_),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||pG(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=GG(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}=xU(e,n,SU(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)?!HG(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=xU(s,n)?.transition?.delayChildren;r.delay=eU(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&xU(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&&!OU(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=KG(),i=!0}}}function GG(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!HG(t,e):!1}function KG(){let e={};for(let t of hG)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function qG(e,t){e.min=t.min,e.max=t.max}function JG(e,t){qG(e.x,t.x),qG(e.y,t.y)}function YG(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var XG=.9999,ZG=1.0001,QG=-.01,$G=.01;function eK(e){return e.max-e.min}function tK(e,t,n){return Math.abs(e-t)<=n}function nK(e,t,n,r=.5){e.origin=r,e.originPoint=sB(t.min,t.max,e.origin),e.scale=eK(n)/eK(t),e.translate=sB(n.min,n.max,e.origin)-e.originPoint,(e.scale>=XG&&e.scale<=ZG||isNaN(e.scale))&&(e.scale=1),(e.translate>=QG&&e.translate<=$G||isNaN(e.translate))&&(e.translate=0)}function rK(e,t,n,r){nK(e.x,t.x,n.x,r?r.originX:void 0),nK(e.y,t.y,n.y,r?r.originY:void 0)}function iK(e,t,n,r=0){e.min=(r?sB(n.min,n.max,r):n.min)+t.min,e.max=e.min+eK(t)}function aK(e,t,n,r){iK(e.x,t.x,n.x,r?.x),iK(e.y,t.y,n.y,r?.y)}function oK(e,t,n,r=0){let i=r?sB(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+eK(t)}function sK(e,t,n,r){oK(e.x,t.x,n.x,r?.x),oK(e.y,t.y,n.y,r?.y)}function cK(e,t,n,r,i){return e-=t,e=dW(e,1/n,r),i!==void 0&&(e=dW(e,1/i,r)),e}function lK(e,t=0,n=1,r=.5,i,a=e,o=e){if(Nz.test(t)&&(t=parseFloat(t),t=sB(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=sB(a.min,a.max,r);e===a&&(s-=t),e.min=cK(e.min,t,n,s,i),e.max=cK(e.max,t,n,s,i)}function uK(e,t,[n,r,i],a,o){lK(e,t[n],t[r],t[i],t.scale,a,o)}var dK=[`x`,`scaleX`,`originX`],fK=[`y`,`scaleY`,`originY`];function pK(e,t,n,r){uK(e.x,t,dK,n?n.x:void 0,r?r.x:void 0),uK(e.y,t,fK,n?n.y:void 0,r?r.y:void 0)}function mK(e){return e.translate===0&&e.scale===1}function hK(e){return mK(e.x)&&mK(e.y)}function gK(e,t){return e.min===t.min&&e.max===t.max}function _K(e,t){return gK(e.x,t.x)&&gK(e.y,t.y)}function vK(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function yK(e,t){return vK(e.x,t.x)&&vK(e.y,t.y)}function bK(e){return eK(e.x)/eK(e.y)}function xK(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function SK(e){return[e(`x`),e(`y`)]}function CK(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var wK={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(Y.test(e))e=parseFloat(e);else return e}return`${CK(e,t.target.x)}% ${CK(e,t.target.y)}%`}},TK={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=rB.parse(e);if(i.length>5)return r;let a=rB.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=sB(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 EK(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 DK=qU.length,OK=e=>typeof e==`number`||Y.test(e);function kK(e,t,n,r,i,a){i?(e.opacity=sB(0,n.opacity??1,jK(r)),e.opacityExit=sB(t.opacity??1,0,MK(r))):a&&(e.opacity=sB(t.opacity??1,n.opacity??1,r));for(let i=0;i<DK;i++){let a=qU[i],o=AK(t,a),s=AK(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||OK(o)===OK(s)?(e[a]=Math.max(sB(sG(o),sG(s),r),0),(Nz.test(s)||Nz.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=sB(t.rotate||0,n.rotate||0,r))}function AK(e,t){return e[t]===void 0?e.borderRadius:e[t]}var jK=NK(0,.5,ZR),MK=NK(.5,.95,FR);function NK(e,t,n){return r=>r<e?0:r>t?1:n(LR(e,t,r))}function PK(e,t,n){let r=OU(e)?e:aU(e);return r.start(hU(``,r,t,n)),r.animation}function FK(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var IK=(e,t)=>e.depth-t.depth,LK=class{constructor(){this.children=[],this.isDirty=!1}add(e){ER(this.children,e),this.isDirty=!0}remove(e){DR(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(IK),this.isDirty=!1,this.children.forEach(e)}};function RK(e,t){let n=uz.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(kB(r),e(a-t))};return OB.setup(r,!0),()=>kB(r)}function zK(e){return OU(e)?e.get():e}var BK=class{constructor(){this.members=[]}add(e){ER(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&&(DR(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(DR(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)}},VK={borderRadius:{...wK,applyTo:[...qU]},borderTopLeftRadius:wK,borderTopRightRadius:wK,borderBottomLeftRadius:wK,borderBottomRightRadius:wK,boxShadow:TK},HK={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(MG,{...VK,...MG});var UK={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},WK=[``,`X`,`Y`,`Z`],GK=1e3,KK=0;function qK(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}var JK=({instance:e})=>e&&LH.get(e)?.demote();function YK(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=NU(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,OB,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&YK(r)}function XK({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=KK++,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,iG.value&&(UK.nodes=UK.calculatedTargetDeltas=UK.calculatedProjections=0),this.nodes.forEach($K),this.nodes.forEach(uq),this.nodes.forEach(dq),this.nodes.forEach(eq),iG.addProjectionMetrics&&iG.addProjectionMetrics(UK)},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 LK)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new RR),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=YU(t)&&!aG(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;OB.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=RK(i,250),HK.hasAnimatedSinceResize&&(HK.hasAnimatedSinceResize=!1,this.nodes.forEach(lq)))})}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.isAnimationBlocked){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||vq,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!yK(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={...sU(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||lq(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(),kB(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(fq),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&&YK(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;JK(this),this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,JK(t),(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1),t.isAnimationBlocked&&(t.dragSnapshot||=t.measure(),this.dragAncestor=t)}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(rq),this.nodes.forEach(nq);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(iq);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(oq),this.nodes.forEach(sq),this.nodes.forEach(cq),this.nodes.forEach(ZK),this.nodes.forEach(QK)):this.nodes.forEach(iq),this.clearAllSnapshots();let e=uz.now();sz.delta=kR(0,1e3/60,e-sz.timestamp),sz.timestamp=e,sz.isProcessing=!0,AB.update.process(sz),AB.preRender.process(sz),AB.render.process(sz),sz.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,wW.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(tq),this.sharedNodes.forEach(pq)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,OB.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){OB.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!eK(this.snapshot.measuredBox.x)&&!eK(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||=dG(),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;e&&JK(this);let t=this.projectionDelta&&!hK(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||cW(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)),Sq(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return dG();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(wq))){let{scroll:e}=this.root;e&&(vW(t.x,e.offset.x),vW(t.y,e.offset.y))}return t}removeElementScroll(e){let t=dG();if(JG(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&&JG(t,e),vW(t.x,i.offset.x),vW(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||dG();JG(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&&(vW(r.x,-n.scroll.offset.x),vW(r.y,-n.scroll.offset.y)),cW(n.latestValues)&&xW(r,n.latestValues,n.layout?.layoutBox)}return cW(this.latestValues)&&xW(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=dG();JG(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!cW(n.latestValues))continue;let r;n.instance&&(sW(n.latestValues)&&n.updateSnapshot(),r=dG(),JG(r,n.measurePageBox())),pK(t,n.latestValues,n.snapshot?.layoutBox,r)}return cW(this.latestValues)&&pK(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!==sz.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=sz.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=dG(),this.targetWithTransforms=dG()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),aK(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):JG(this.target,this.layout.layoutBox),mW(this.target,this.targetDelta)):JG(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),iG.value&&UK.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||sW(this.parent.latestValues)||lW(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=dG(),this.relativeTargetOrigin=dG(),sK(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),JG(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===sz.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;JG(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;_W(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=dG());let{target:s}=e;s?(!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(YG(this.prevProjectionDelta.x,this.projectionDelta.x),YG(this.prevProjectionDelta.y,this.projectionDelta.y)),rK(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!xK(this.projectionDelta.x,this.prevProjectionDelta.x)||!xK(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),iG.value&&UK.calculatedProjections++):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}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=lG(),this.projectionDelta=lG(),this.projectionDeltaWithTransform=lG()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=lG();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=dG(),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(_q));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=sB(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=sB(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(mq(o.x,e.x,n),mq(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(sK(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),gq(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&_K(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=dG(),JG(f,this.relativeTarget)),c&&(this.animationValues=a,kK(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&&=(kB(this.pendingAnimation),void 0),this.pendingAnimation=OB.update(()=>{HK.hasAnimatedSinceResize=!0,this.motionValue||=aU(0),this.motionValue.jump(0,!1),this.currentAnimation=PK(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()}}),pV(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(GK),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&&Cq(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||dG();let t=eK(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=eK(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}JG(t,i),xW(t,r),rK(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new BK),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&&qK(`z`,e,r,this.animationValues);for(let t=0;t<WK.length;t++)qK(`rotate${WK[t]}`,e,r,this.animationValues),qK(`skew${WK[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=zK(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=zK(t?.pointerEvents)||``),this.hasProjected&&!cW(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=EK(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 MG){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=MG[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?zK(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=this.dragSnapshot=this.dragAncestor=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(nq),this.root.sharedNodes.clear()}}}function ZK(e){e.updateLayout(),aq(e)}function QK(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`)SK(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=eK(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;qG(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else Cq(i,t.layoutBox,n)&&SK(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=eK(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=lG();rK(o,n,t.layoutBox);let s=lG();a?rK(s,e.applyTransform(r,!0),t.measuredBox):rK(s,n,t.layoutBox);let c=!hK(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=dG();sK(s,t.layoutBox,i.layoutBox,o);let c=dG();sK(c,n,a.layoutBox,o),yK(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 $K(e){iG.value&&UK.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 eq(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function tq(e){e.clearSnapshot()}function nq(e){e.clearMeasurements()}function rq(e){e.isLayoutDirty=!0,e.updateLayout()}function iq(e){e.isLayoutDirty=!1}function aq(e){let{snapshot:t,dragAncestor:n}=e,r=n?.layout;if(!t||!r||e.resumeFrom||e.isAnimationBlocked)return;let i=n.dragSnapshot;SK(e=>vW(t.layoutBox[e],r.layoutBox[e].min-i.layoutBox[e].min))}function oq(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.dragSnapshot||e.layout,e.isLayoutDirty=!0)}function sq(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function cq(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function lq(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function uq(e){e.resolveTargetDelta()}function dq(e){e.calcProjection()}function fq(e){e.resetSkewAndRotation()}function pq(e){e.removeLeadSnapshot()}function mq(e,t,n){e.translate=sB(t.translate,0,n),e.scale=sB(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function hq(e,t,n,r){e.min=sB(t.min,n.min,r),e.max=sB(t.max,n.max,r)}function gq(e,t,n,r){hq(e.x,t.x,n.x,r),hq(e.y,t.y,n.y,r)}function _q(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var vq={duration:.45,ease:[.4,0,.1,1]},yq=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),bq=yq(`applewebkit/`)&&!yq(`chrome/`)?Math.round:FR;function xq(e){e.min=bq(e.min),e.max=bq(e.max)}function Sq(e){xq(e.x),xq(e.y)}function Cq(e,t,n){return e===`position`||e===`preserve-aspect`&&!tK(bK(t),bK(n),.2)}function wq(e){return e!==e.root&&e.scroll?.wasRoot}var Tq=XK({attachResizeListener:(e,t)=>FK(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Eq={current:void 0},Dq=XK({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Eq.current){let e=new Tq({});e.mount(window),e.setOptions({layoutScroll:!0}),Eq.current=e}return Eq.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Oq=(0,F.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function kq(e=!0){let t=(0,F.useContext)(TR);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,F.useId)();(0,F.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,F.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var Aq=(0,F.createContext)({strict:!1}),jq={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},Mq=!1;function Nq(){if(Mq)return;let e={};for(let t in jq)e[t]={isEnabled:e=>jq[t].some(t=>!!e[t])};EG(e),Mq=!0}function Pq(){return Nq(),DG()}function Fq(e){let t=Pq();for(let n in e)t[n]={...t[n],...e[n]};EG(t)}var Iq=(0,F.createContext)({});function Lq(e,t){if(_G(e)){let{initial:t,animate:n}=e;return{initial:t===!1||mG(t)?t:void 0,animate:mG(n)?n:void 0}}return e.inherit===!1?{}:t}function Rq(e){let{initial:t,animate:n}=Lq(e,(0,F.useContext)(Iq));return(0,F.useMemo)(()=>({initial:t,animate:n}),[zq(t),zq(n)])}function zq(e){return Array.isArray(e)?e.join(` `):e}var Bq=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Vq(e,t,n){for(let r in t)!OU(t[r])&&!NG(r,n)&&(e[r]=t[r])}function Hq({transformTemplate:e},t){return(0,F.useMemo)(()=>{let n=Bq();return ZU(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Uq(e,t){let n=e.style||{},r={};return Vq(r,n,e),Object.assign(r,Hq(e,t)),r}function Wq(e,t){let n={},r=Uq(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var Gq=()=>({...Bq(),attrs:{}});function Kq(e,t,n,r){let i=(0,F.useMemo)(()=>{let n=Gq();return nW(n,t,RG(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Vq(t,e.style,e),i.style={...t,...i.style}}return i}var qq=new Set(`animate.exit.variants.initial.style.values.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function Jq(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||qq.has(e)}function Yq(e,t){return e.startsWith(`on`)?!Jq(e):t?.(e)??!Jq(e)}function Xq(e,t,n,r){let i={};for(let a in e)(a!==`values`||typeof e.values!=`object`)&&(OU(e[a])||(Yq(a,r)||n===!0&&Jq(a)||!t&&!Jq(a)||e.draggable&&a.startsWith(`onDrag`))&&(i[a]=e[a]));return i}var Zq=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function Qq(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Zq.indexOf(e)>-1||/[A-Z]/u.test(e))}function $q(e,t,n,{latestValues:r},i,a=!1,o,s){let c=(o??Qq(e)?Kq:Wq)(t,r,i,e),l=Xq(t,typeof e==`string`,a,s),u=e===F.Fragment?{}:{...l,...c,ref:n},{children:d}=t,f=(0,F.useMemo)(()=>OU(d)?d.get():d,[d]);return(0,F.createElement)(e,{...u,children:f})}function eJ({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:tJ(n,r,i,e),renderState:t()}}function tJ(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=zK(a[e]);let{initial:o,animate:s}=e,c=_G(e),l=vG(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!pG(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=bU(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var nJ=e=>(t,n)=>{let r=(0,F.useContext)(Iq),i=(0,F.useContext)(TR),a=()=>eJ(e,t,r,i);return n?a():CR(a)},rJ=nJ({scrapeMotionValuesFromProps:PG,createRenderState:Bq}),iJ=nJ({scrapeMotionValuesFromProps:BG,createRenderState:Gq}),aJ=Symbol.for(`motionComponentSymbol`);function oJ(e,t,n){let r=(0,F.useRef)(n);(0,F.useInsertionEffect)(()=>{r.current=n});let i=(0,F.useRef)(null);return(0,F.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`){if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n)}else a&&(a.current=n)},[t])}var sJ=(0,F.createContext)({});function cJ(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function lJ(e,t,n,r,i,a){let{visualElement:o}=(0,F.useContext)(Iq),s=(0,F.useContext)(Aq),c=(0,F.useContext)(TR),l=(0,F.useContext)(Oq),u=l.reducedMotion,d=l.skipAnimations,f=(0,F.useRef)(null),p=(0,F.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,F.useContext)(sJ);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&uJ(f.current,n,i,h);let g=(0,F.useRef)(!1);(0,F.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[MU],v=(0,F.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return wR(()=>{p.current&&m&&(m.animationState?.animateChanges(),m.enteringChildren=void 0)},[]),wR(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,F.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function uJ(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:dJ(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&cJ(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function dJ(e){if(e)return e.options.allowProjection===!1?dJ(e.parent):e.projection}function fJ(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Fq(r);let a=n?n===`svg`:Qq(e),o=a?iJ:rJ;function s(n,s){let c,l={...(0,F.useContext)(Oq),...n,layoutId:pJ(n)},{isStatic:u,isValidProp:d}=l,f=Rq(n),p=o(n,u);if(!u&&typeof window<`u`){mJ(l,r);let t=hJ(l);c=t.MeasureLayout,f.visualElement=lJ(e,p,l,i,t.ProjectionNode,a)}return(0,I.jsxs)(Iq.Provider,{value:f,children:[c&&f.visualElement?(0,I.jsx)(c,{visualElement:f.visualElement,...l}):null,$q(e,n,oJ(p,f.visualElement,s),p,u,t,a,d)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,F.forwardRef)(s);return c[aJ]=e,c}function pJ({layoutId:e}){let t=(0,F.useContext)(SR).id;return t&&e!==void 0?t+`-`+e:e}function mJ(e,t){(0,F.useContext)(Aq).strict}function hJ(e){let{drag:t,layout:n}=Pq();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function gJ(e,t){if(typeof Proxy>`u`)return fJ;let n=new Map,r=(n,r)=>fJ(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,fJ(a,void 0,e,t)),n.get(a))})}var _J=(e,t)=>t.isSVG??Qq(e)?new VG(t):new IG(t,{allowProjection:e!==F.Fragment}),vJ=class extends AG{constructor(e){super(e),e.animationState||=WG(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();pG(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},yJ=0,bJ={animation:{Feature:vJ},exit:{Feature:class extends AG{constructor(){super(...arguments),this.id=yJ++}update(){let{presenceContext:e,prevPresenceContext:t,animationState:n}=this.node;if(!e||!n)return;let{isPresent:r,onExitComplete:i}=e,a=t?.isPresent;if(r===a)return;if(r&&a===!1){if(this.exit===!0){let{initial:e}=this.node.getProps();if(e&&!Array.isArray(e)){let{transition:t,transitionEnd:n,...r}=xU(this.node,e)||{};for(let e in r)this.node.getValue(e)?.jump(r[e])}this.node.blockInitialAnimation=!1,n.reset(),n.animateChanges()}else n.setActive(`exit`,!1);this.exit=void 0;return}let o=this.exit=n.setActive(`exit`,!r);i&&!r&&o.then(()=>{this.exit===o&&(this.exit=!0,i(this.id))})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function xJ(e){return{point:{x:e.pageX,y:e.pageY}}}var SJ=e=>t=>MW(t)&&e(t,xJ(t));function CJ(e,t,n,r){return FK(e,t,SJ(n),r)}var wJ=({current:e})=>e?e.ownerDocument.defaultView:null,TJ=(e,t)=>Math.abs(e-t);function EJ(e,t){let n=TJ(e.x,t.x),r=TJ(e.y,t.y);return Math.sqrt(n**2+r**2)}var DJ=new Set([`auto`,`scroll`]),OJ=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=kJ(this.lastRawMoveEventInfo,this.transformPagePoint));let e=jJ(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=EJ(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e;this.history.push({...r,timestamp:uz.now()});let{onStart:i,onMove:a}=this.handlers;t||(i&&i(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),a&&a(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=kJ(t,this.transformPagePoint),this.hasPendingMove=!0,OB.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.hasPendingMove&&this.updatePoint(),this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=jJ(e.type===`pointercancel`?this.lastMoveEventInfo:kJ(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!MW(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=kJ(xJ(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=sz;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,jJ(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=IR(CJ(this.contextWindow,`pointermove`,this.handlePointerMove,d),CJ(this.contextWindow,`pointerup`,this.handlePointerUp,d),CJ(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(DJ.has(e.overflowX)||DJ.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};(i.x!==0||i.y!==0)&&(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),OB.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),kB(this.updatePoint)}};function kJ(e,t){return t?{point:t(e.point)}:e}function AJ(e,t){return{x:e.x-t.x,y:e.y-t.y}}function jJ({point:e},t){return{point:e,delta:AJ(e,NJ(t)),offset:AJ(e,MJ(t)),velocity:PJ(t,.1)}}function MJ(e){return e[0]}function NJ(e){return e[e.length-1]}function PJ(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=NJ(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>zR(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>zR(t)*2&&(r=e[1]);let a=BR(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function FJ(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?sB(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?sB(n,e,r.max):Math.min(e,n)),e}function IJ(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function LJ(e,{top:t,left:n,bottom:r,right:i}){return{x:IJ(e.x,n,i),y:IJ(e.y,t,r)}}function RJ(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function zJ(e,t){return{x:RJ(e.x,t.x),y:RJ(e.y,t.y)}}function BJ(e,t){let n=.5,r=eK(e),i=eK(t);return i>r?n=LR(t.min,t.max-r,e.min):r>i&&(n=LR(e.min,e.max-i,t.min)),kR(0,1,n)}function VJ(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var HJ=.35;function UJ(e=HJ){return e===!1?e=0:e===!0&&(e=HJ),{x:WJ(e,`left`,`right`),y:WJ(e,`top`,`bottom`)}}function WJ(e,t,n){return{min:GJ(e,t),max:GJ(e,n)}}function GJ(e,t){return typeof e==`number`?e:e[t]||0}var KJ=new WeakMap,qJ=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=dG(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(e),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=DW(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),SK(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Nz.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=eK(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&OB.update(()=>i(e,t),!1,!0),AU(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;r&&this.currentDirection===null?(this.currentDirection=ZJ(o),this.currentDirection!==null&&i&&i(this.currentDirection)):(this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&OB.update(()=>a(e,t),!1,!0))},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new OJ(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:wJ(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&OB.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!XJ(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=FJ(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&cJ(e)?this.constraints||=this.resolveRefConstraints():this.constraints=e&&n?LJ(n.layoutBox,e):!1,this.elastic=UJ(t),r!==this.constraints&&!cJ(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&SK(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=VJ(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!cJ(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=CW(n,r.root,this.visualElement.getTransformPagePoint()),a=zJ(r.layout.layoutBox,i);if(t){let e=t(iW(a));this.hasMutatedConstraints=!!e,e&&(a=rW(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=SK(o=>{if(!XJ(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return AU(this.visualElement,e),n.start(hU(e,n,0,t,this.visualElement,!1))}stopAnimation(){SK(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor({clientX:e,clientY:t}){let{drag:n}=this.getProps(),r={x:e,y:t},i=this.visualElement.getTransformPagePoint()?.(r)||r,a=this.visualElement.measureViewportBox();SK(e=>{if(!XJ(e,n,this.currentDirection))return;let t=this.getAxisMotionValue(e),{min:r,max:o}=a[e];t.set((t.get()||0)+i[e]-sB(r,o,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!cJ(t)||!n||!this.constraints)return;this.stopAnimation();let r=this.constraints,i={x:0,y:0};SK(e=>{let t=this.getAxisMotionValue(e).get();i[e]=BJ({min:t,max:t},r[e])});let{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),SK(t=>{let n=this.getAxisMotionValue(t);if(!XJ(t,e,null)||!n.get())return;let{min:r,max:a}=this.constraints[t];n.set(sB(r,a,i[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;KJ.set(this.visualElement,this);let e=this.visualElement.current,t=CJ(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&IW(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();cJ(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=YJ(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),OB.read(r);let o=FK(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(SK(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=HJ,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function JJ(e){let t=!0;return()=>{t?t=!1:e()}}function YJ(e,t,n){let r=rG(e,JJ(n)),i=rG(t,JJ(n));return()=>{r(),i()}}function XJ(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function ZJ(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var QJ=class extends AG{constructor(e){super(e),this.removeGroupControls=FR,this.removeListeners=FR,this.controls=new qJ(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||FR}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},$J=e=>(t,n)=>{e&&OB.update(()=>e(t,n),!1,!0)},eY=class extends AG{constructor(){super(...arguments),this.removePointerDownListener=FR}onPointerDown(e){this.session=new OJ(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:wJ(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:$J(e),onStart:$J(t),onMove:$J(n),onEnd:(e,t)=>{delete this.session,r&&OB.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=CJ(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},tY=!1,nY=class extends F.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),tY&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),HK.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a&&(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),tY=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||OB.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),wW.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;tY=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function rY(e){let[t,n]=kq(),r=(0,F.useContext)(SR);return(0,I.jsx)(nY,{...e,layoutGroup:r,switchLayoutGroup:(0,F.useContext)(sJ),isPresent:t,safeToRemove:n})}var iY={pan:{Feature:eY},drag:{Feature:QJ,ProjectionNode:Dq,MeasureLayout:rY}};function aY(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&OB.postRender(()=>i(t,xJ(t)))}var oY=class extends AG{mount(){let{current:e}=this.node;e&&(this.unmount=AW(e,(e,t)=>(aY(this.node,t,`Start`),e=>aY(this.node,e,`End`))))}unmount(){}},sY=class extends AG{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}e&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=IR(FK(this.node.current,`focus`,()=>this.onFocus()),FK(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function cY(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&OB.postRender(()=>i(t,xJ(t)))}var lY=class extends AG{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=UW(e,(e,t)=>(cY(this.node,t,`Start`),(e,{success:t})=>cY(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},uY=new WeakMap,dY=new WeakMap,fY=e=>{let t=uY.get(e.target);t&&t(e)},pY=e=>{e.forEach(fY)};function mY({root:e,...t}){let n=e||document;dY.has(n)||dY.set(n,{});let r=dY.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(pY,{root:e,...t})),r[i]}function hY(e,t,n){let r=mY(t);return uY.set(e,n),r.observe(e),()=>{uY.delete(e),r.unobserve(e)}}var gY={some:0,all:1},_Y=class extends AG{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:gY[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=hY(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(vY(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function vY({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var yY={inView:{Feature:_Y},tap:{Feature:lY},focus:{Feature:sY},hover:{Feature:oY}},bY={layout:{ProjectionNode:Dq,MeasureLayout:rY}},xY=gJ({...bJ,...yY,...iY,...bY},_J);function SY(e){let t=CR(()=>aU(e)),{isStatic:n}=(0,F.useContext)(Oq);if(n){let[,n]=(0,F.useState)(e);(0,F.useEffect)(()=>t.on(`change`,n),[])}return t}function CY(e,t){let n=SY(t()),r=()=>n.set(t());return r(),wR(()=>{let t=()=>OB.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return r(),()=>{n.forEach(e=>e()),kB(r)}}),n}function wY(e){rU.current=[],e();let t=CY(rU.current,e);return rU.current=void 0,t}function TY(e,t,n,r){if(typeof e==`function`)return wY(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return DY(e,t,n,r);let i=typeof t==`function`?t:oG(t,n,r),a=Array.isArray(e)?EY(e,i):EY([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;if(o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1){let e=r?.ease;a.accelerate={...o,times:[0,...t,1],keyframes:[n[0],...n,n[n.length-1]],isTransformed:!0,...e?{ease:Array.isArray(e)?[e[0],...e]:e}:{}}}return a}function EY(e,t){let n=CR(()=>[]);return CY(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function DY(e,t,n,r){let i=CR(()=>Object.keys(n)),a=CR(()=>({}));for(let o of i)a[o]=TY(e,t,n[o],r);return a}var OY=class{constructor(){this.componentControls=new Set}subscribe(e){return this.componentControls.add(e),()=>this.componentControls.delete(e)}start(e,t){this.componentControls.forEach(n=>{n.start(e.nativeEvent||e,t)})}cancel(){this.componentControls.forEach(e=>{e.cancel()})}stop(){this.componentControls.forEach(e=>{e.stop()})}},kY=()=>new OY;function AY(){return CR(kY)}var jY=(0,F.createContext)(null);function MY(e,t,n,r,i,a=`ltr`){let o=e.findIndex(e=>e.value===t);if(o===-1)return e;if(i===`xy`){let{layout:t}=e[o],r={x:sB(t.x.min,t.x.max,.5)+n.x,y:sB(t.y.min,t.y.max,.5)+n.y},i=NY(e),s=i.find(t=>t.items.includes(e[o])),c=i.reduce((e,t)=>PY(r.y,t)<PY(r.y,e)?t:e);if(c!==s)return FY(e,o,r.x,c,a);let l=IY(r,t),u=-1,d=l;return e.forEach((e,t)=>{if(t===o)return;let n=IY(r,e.layout);n<d&&(u=t,d=n)}),u===-1?e:OR(e,o,o+Math.sign(u-o))}if(!r[i])return e;let s=r[i]>0?1:-1,c=e[o+s];if(!c)return e;let l=e[o].layout[i],u=c.layout[i],d=sB(u.min,u.max,.5);return s===1&&l.max+n[i]>d||s===-1&&l.min+n[i]<d?OR(e,o,o+s):e}function NY(e){let t=[];return e.forEach(e=>{let{min:n,max:r}=e.layout.y,i=t[t.length-1];!i||n>=i.max||r<=i.min?t.push({items:[e],min:n,max:r}):(i.items.push(e),i.min=Math.min(i.min,n),i.max=Math.max(i.max,r))}),t}function PY(e,t){return e<t.min?t.min-e:e>t.max?e-t.max:0}function FY(e,t,n,r,i){let a=e.filter((e,n)=>n!==t),o=r.items.find(e=>{let t=sB(e.layout.x.min,e.layout.x.max,.5);return i===`ltr`?n<t:n>t}),s=o?a.indexOf(o):a.indexOf(r.items[r.items.length-1])+1,c=[...a];return c.splice(s,0,e[t]),c.every((t,n)=>t===e[n])?e:c}function IY(e,t){let n=Math.max(t.x.min-e.x,0,e.x-t.x.max),r=Math.max(t.y.min-e.y,0,e.y-t.y.max);return n*n+r*r}var LY=(e,t)=>e.max<=t.min||t.max<=e.min;function RY(e){let t=!1,n=!1;for(let r=0;r<e.length;r++)for(let i=r+1;i<e.length;i++)if(t||=LY(e[r].x,e[i].x),n||=LY(e[r].y,e[i].y),t&&n)return`xy`;return t?`x`:`y`}function zY({children:e,as:t=`ul`,axis:n,onReorder:r,values:i,onPointerDownCapture:a,onClickCapture:o,...s},c){let l=CR(()=>xY[t]),u=(0,F.useRef)(new Map),[d,f]=(0,F.useState)(`y`),p=(0,F.useRef)(!1),m=(0,F.useRef)(!1),h=(0,F.useRef)(null),g=n||d,_=new Set(i);u.current.forEach((e,t)=>{_.has(t)||u.current.delete(t)});let v={axis:g,groupRef:h,hasReordered:m,registerItem:(e,t)=>{if(u.current.set(e,t),!n){let e=RY(i.flatMap(e=>{let t=u.current.get(e);return t?[t]:[]}));e!==d&&f(e)}},updateOrder:(e,t,n)=>{if(p.current)return;let a=i.flatMap(e=>{let t=u.current.get(e);return t?[{value:e,layout:t}]:[]}),o=h.current?.ownerDocument.defaultView?.getComputedStyle(h.current).direction===`rtl`?`rtl`:`ltr`,s=MY(a,e,t,n,g,o);if(a!==s){p.current=!0,m.current=!0;let e=[...i],t=a.map(({value:e})=>i.indexOf(e));s.forEach(({value:n},r)=>{e[t[r]]=n}),r(e)}}};(0,F.useEffect)(()=>{p.current=!1},[i]);let y=e=>{h.current=e,typeof c==`function`?c(e):c&&(c.current=e)},b={overflowAnchor:`none`,...s.style};return(0,I.jsx)(l,{...s,style:b,ref:y,onPointerDownCapture:e=>{m.current=!1,a?.(e)},onClickCapture:e=>{m.current&&e.detail&&(m.current=!1,e.stopPropagation(),e.preventDefault()),o?.(e)},ignoreStrict:!0,children:(0,I.jsx)(jY.Provider,{value:v,children:e})})}var BY=(0,F.forwardRef)(zY),VY=50,HY=25,UY=new Set([`auto`,`scroll`]),WY=new WeakMap,GY=new WeakMap,KY=null;function qY(){if(KY){let e=YY(KY,`y`);e&&(GY.delete(e),WY.delete(e));let t=YY(KY,`x`);t&&t!==e&&(GY.delete(t),WY.delete(t)),KY=null}}function JY(e,t){let n=getComputedStyle(e),r=t===`x`?n.overflowX:n.overflowY,i=e===document.body||e===document.documentElement;return UY.has(r)||i}function YY(e,t){let n=e?.parentElement;for(;n;){if(JY(n,t))return n;n=n.parentElement}return null}function XY(e,t,n){let r=t.getBoundingClientRect(),i=n===`x`?Math.max(0,r.left):Math.max(0,r.top),a=n===`x`?Math.min(window.innerWidth,r.right):Math.min(window.innerHeight,r.bottom),o=e-i,s=a-e;if(o<VY){let e=1-o/VY;return{amount:-25*e*e,edge:`start`}}if(s<VY){let e=1-s/VY;return{amount:HY*e*e,edge:`end`}}return{amount:0,edge:null}}function ZY(e,t,n,r){if(!e)return;KY=e;let i=YY(e,n);if(!i)return;let{amount:a,edge:o}=XY(t-(n===`x`?window.scrollX:window.scrollY),i,n);if(o===null){GY.delete(i),WY.delete(i);return}let s=GY.get(i),c=i===document.body||i===document.documentElement;if(s!==o){if(!(o===`start`&&r<0||o===`end`&&r>0))return;GY.set(i,o);let e=n===`x`?i.scrollWidth-(c?window.innerWidth:i.clientWidth):i.scrollHeight-(c?window.innerHeight:i.clientHeight);WY.set(i,e)}if(a>0){let e=WY.get(i);if((n===`x`?c?window.scrollX:i.scrollLeft:c?window.scrollY:i.scrollTop)>=e)return}n===`x`?c?window.scrollBy({left:a}):i.scrollLeft+=a:c?window.scrollBy({top:a}):i.scrollTop+=a}function QY(e,t=0){return OU(e)?e:SY(t)}function $Y({children:e,style:t={},value:n,as:r=`li`,onDrag:i,onDragEnd:a,layout:o=!0,...s},c){let l=CR(()=>xY[r]),u=(0,F.useContext)(jY),d={x:QY(t.x),y:QY(t.y)},f=TY([d.x,d.y],([e,t])=>e||t?1:`unset`),{axis:p,registerItem:m,updateOrder:h,groupRef:g,hasReordered:_}=u;return(0,I.jsx)(l,{drag:p===`xy`||p,...s,dragSnapToOrigin:!0,style:{...t,x:d.x,y:d.y,zIndex:f},layout:o,onDrag:(e,t)=>{let{velocity:r,point:a}=t,o={x:d.x.get(),y:d.y.get()};h(n,o,r);let s=p===`xy`?Math.abs(r.x)>Math.abs(r.y)?`x`:`y`:p;ZY(g.current,a[s],s,r[s]),i&&i(e,t)},onDragEnd:(e,t)=>{_.current=!1,qY(),a&&a(e,t)},onLayoutMeasure:e=>{m(n,e)},ref:c,ignoreStrict:!0,children:e})}var eX=(0,F.forwardRef)($Y);function tX(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(null);return(0,I.jsxs)(`form`,{className:`grid`,onSubmit:async n=>{n.preventDefault(),u(null);try{if(t)await h9(d9(a).address,s.trim()===``?null:s.trim());else{let e=d9(r);await h9(e.address,e.code)}e.onAdded?.()}catch(e){u(rt(e))}},children:[(0,I.jsxs)(`div`,{className:P(`grid gap-2`,e.fieldsClassName),children:[t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(kL,{"aria-label":`Server URL`,placeholder:`Server URL, e.g. http://127.0.0.1:47841`,spellCheck:!1,autoComplete:`off`,value:a,onChange:e=>o(e.target.value)}),(0,I.jsx)(kL,{"aria-label":`Pairing code`,placeholder:`Pairing code, empty if auth is off`,spellCheck:!1,autoComplete:`off`,value:s,onChange:e=>c(e.target.value)})]}):(0,I.jsx)(kL,{"aria-label":`Pairing link`,placeholder:`Pairing link`,spellCheck:!1,autoComplete:`off`,value:r,onChange:e=>i(e.target.value)}),l!==null&&(0,I.jsx)(`p`,{className:`text-destructive text-sm break-all`,children:l}),(0,I.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground w-fit cursor-pointer text-xs`,onClick:()=>{n(!t),u(null)},children:t?`Paste a pairing link instead`:`Enter the server URL and code separately`})]}),e.actions(t?a.trim()!==``:r.trim()!==``)]})}function nX(e){return(0,I.jsx)(Ke,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(Ne,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,children:[(0,I.jsxs)(Fe,{className:`gap-1 px-6 pt-4 pr-12`,children:[(0,I.jsx)(Ve,{className:`text-base`,children:`Add machine`}),(0,I.jsx)(We,{children:`Paste the pairing link that OffSite printed when it started.`})]}),(0,I.jsx)(tX,{fieldsClassName:`p-6`,onAdded:e.onClose,actions:t=>(0,I.jsxs)(qe,{className:`bg-muted/40 border-t px-6 py-4`,children:[(0,I.jsx)(x,{type:`button`,variant:`outline`,onClick:e.onClose,children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,disabled:!t,children:`Add machine`})]})})]})})}var rX={connecting:`Connecting…`,online:`Online`,offline:`Offline`,unpaired:`Needs pairing`};function iX(){let e=Q(e=>e.machines),t=Q(e=>e.machines.find(t=>t.id===e.settingsEditedMachine)),[n,r]=(0,F.useState)(!1);return t===void 0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(tR,{title:`Machines`,note:`This browser connects to each one directly. The list stays in this browser`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`flex min-h-13 items-center gap-4 px-4 py-2.5`,children:[(0,I.jsx)(w,{icon:Gv[e.icon],className:`text-muted-foreground size-5 shrink-0`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),e.addresses.map(e=>(0,I.jsx)(`p`,{className:`text-muted-foreground truncate font-mono text-xs`,children:e},e)),e.providers.filter(e=>e.state===`error`).map(e=>(0,I.jsxs)(`p`,{className:`text-destructive truncate text-xs`,title:e.error??void 0,children:[Tw[e.provider],` threads: `,e.error]},e.provider))]}),(0,I.jsxs)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:[rX[e.status],e.status===`online`&&e.via!==null&&e.via!==e.addresses[0]&&` · via ${new URL(e.via).host}`]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost`,title:`Reconnect, trying the first address first`,onClick:()=>b9(e.id),children:(0,I.jsx)(w,{icon:Eee})}),(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost-muted`,title:`Open machine`,onClick:()=>$({settingsEditedMachine:e.id}),children:(0,I.jsx)(w,{icon:Lg})})]})]},e.id))}),(0,I.jsx)(`div`,{className:`flex gap-2`,children:(0,I.jsx)(x,{variant:`outline`,size:`sm`,onClick:()=>r(!0),children:`Add machine…`})}),n&&(0,I.jsx)(nX,{onClose:()=>r(!1)})]}):(0,I.jsx)(aX,{machine:t})}function aX(e){let t=e.machine,[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(``),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(null),u=c??t.addresses,d=(0,F.useRef)(null);(0,F.useEffect)(()=>{n&&d.current?.focus()},[n]);function f(e){s(null);try{return v9(t.id,{addresses:[...new Set(e.map(e=>d9(e).address))]}),!0}catch(e){return s(rt(e)),!1}}async function p(e){s(null);let n=e.trim();if(n===``)return!0;try{let e=n.includes(`#`)?d9(n).code:n;if(e===null)throw Error(`That link has no pairing code`);return await g9(t.id,e),!0}catch(e){return s(rt(e)),!1}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(tR,{title:`Machine`,children:[(0,I.jsx)(nR,{label:`Name`,children:(0,I.jsx)(rR,{value:t.label??``,placeholder:t.hostname,onCommit:e=>v9(t.id,{label:e.trim()===``?null:e.trim()})},t.label)}),(0,I.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:`Icon`}),(0,I.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:Object.entries(Gv).map(e=>(0,I.jsx)(x,{size:`icon-sm`,variant:e[0]===t.icon?`default`:`ghost`,title:e[0],"aria-pressed":e[0]===t.icon,onClick:()=>v9(t.id,{icon:e[0]}),children:(0,I.jsx)(w,{icon:e[1]})},e[0]))})]})]}),(0,I.jsx)(tR,{title:`Pairing`,children:(0,I.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[t.pairedAt!==null&&t.status!==`unpaired`&&(0,I.jsx)(`span`,{className:`text-sm`,children:t.pairedAt===null?`Paired`:`Paired ${kw(t.pairedAt)}`}),(t.pairedAt===null||t.status===`unpaired`)&&(0,I.jsxs)(`form`,{className:`flex flex-1 items-center gap-3`,onSubmit:async e=>{e.preventDefault(),await p(i)&&a(``)},children:[(0,I.jsx)(kL,{className:`flex-1 font-mono`,placeholder:`Pairing link or code`,spellCheck:!1,autoComplete:`off`,value:i,onChange:e=>a(e.target.value)}),(0,I.jsxs)(x,{type:`submit`,variant:`outline`,className:`px-4`,disabled:i.trim()===``,children:[(0,I.jsx)(w,{icon:uee}),`Pair`]})]})]})}),(0,I.jsxs)(tR,{title:`Addresses`,note:`OffSite tries them in order whenever it reconnects`,children:[(0,I.jsx)(BY,{as:`div`,axis:`y`,className:`divide-y`,values:u,onReorder:l,children:u.map((e,t)=>(0,I.jsxs)(oX,{address:e,onDragEnd:()=>{c!==null&&f(c),l(null)},children:[(0,I.jsx)(rR,{className:`flex-1 font-mono`,value:e,onCommit:e=>f(u.map((n,r)=>r===t?e:n))}),(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost`,title:`Remove address`,disabled:u.length===1,onClick:()=>f(u.filter((e,n)=>n!==t)),children:(0,I.jsx)(w,{icon:p_})})]},e))}),n&&(0,I.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,I.jsx)(kL,{ref:d,className:`font-mono`,placeholder:`http://192.168.1.10:47841`,spellCheck:!1,autoComplete:`off`,onBlur:e=>{let n=e.target.value.trim();(n===``||f([...t.addresses,n]))&&r(!1)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}),!n&&(0,I.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>r(!0),children:[(0,I.jsx)(w,{icon:kg,className:`size-4`}),`Add address`]})]}),o!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-1 text-xs break-all`,children:o}),(0,I.jsxs)(HL,{children:[(0,I.jsx)(UL,{asChild:!0,children:(0,I.jsx)(x,{variant:`outline`,className:`text-destructive`,children:`Remove machine`})}),(0,I.jsxs)(WL,{children:[(0,I.jsxs)(GL,{children:[(0,I.jsxs)(qL,{children:[`Remove `,t.name,`?`]}),(0,I.jsx)(JL,{children:`This browser forgets the machine. The machine and its threads stay untouched.`})]}),(0,I.jsxs)(KL,{children:[(0,I.jsx)(XL,{children:`Cancel`}),(0,I.jsx)(YL,{variant:`destructive`,onClick:()=>{$({settingsEditedMachine:null}),_ue(t.id)},children:`Remove machine`})]})]})]})]})}function oX(e){let t=AY();return(0,I.jsxs)(eX,{as:`div`,value:e.address,dragListener:!1,dragControls:t,onDragEnd:e.onDragEnd,className:`bg-background relative flex items-center gap-3 px-4 py-2.5`,children:[(0,I.jsx)(`span`,{className:`text-muted-foreground hover:text-foreground cursor-grab touch-none active:cursor-grabbing`,title:`Drag to reorder`,onPointerDown:e=>t.start(e),children:(0,I.jsx)(w,{icon:h_,className:`size-4`})}),e.children]})}var sX=`notifications`,cX=Promise.resolve(),lX=new Set;function uX(){return window.isSecureContext?!(`Notification`in window)||!(`serviceWorker`in navigator)?`unsupported`:Notification.permission:`insecure`}function dX(){let e=localStorage.getItem(sX);if(e===null||e===`on`)return!0;if(e===`off`)return!1;throw Error(`unknown notification setting ${e}`)}async function fX(e){e&&Notification.permission==="default"&&await Notification.requestPermission(),localStorage.setItem(sX,e?`on`:`off`)}async function pX(e,t){(await navigator.permissions.query({name:`notifications`})).addEventListener(`change`,t,{signal:e})}function mX(e,t,n){if(document.hidden)for(let r of t){let t=gX(e,r);_X(e,r,`${t===void 0?`Agent`:Tw[t.provider]} ${n}`,t?.title??`Session`,f9(e,r)).catch(e=>console.error(`could not show a notification`,e))}}function hX(e,t,n){_X(e,t,gX(e,t)?.title??`Session`,n,`push:${f9(e,t)}`).catch(e=>console.error(`could not show a notification`,e))}function gX(e,t){return Z().sessions.find(n=>n.machine===e&&n.id===t)}async function _X(e,t,n,r,i){if(uX()!==`granted`||!dX()||!T9(Z(),e).notifier)return;let a=gX(e,t);await(await navigator.serviceWorker.ready).showNotification(n,{body:r,tag:i,data:a===void 0?null:{kind:`session`,machine:e,project:a.projectId,sessionId:t}})}async function vX(e,t,n){uX()===`granted`&&dX()&&T9(Z(),n.machine).notifier&&await(await navigator.serviceWorker.ready).showNotification(e,{body:t,data:{kind:`terminal`,...n}})}function yX(){let e=Z().machines.filter(e=>$o(e.id)&&!e.notifier&&!lX.has(e.id)).map(e=>e.id);if(e.length!==0){for(let t of e)lX.add(t);bX().then(t=>Promise.all(e.map(e=>L(e,`notifications.claim`,{endpoint:t})))).catch(e=>console.error(`could not claim notifications`,e)).finally(()=>{for(let t of e)lX.delete(t)})}}async function bX(){if(xX()!==`supported`)return null;let e=await navigator.serviceWorker.getRegistration();if(e===void 0)return null;let t=await e.pushManager.getSubscription();return t===null?null:t.endpoint}function xX(){return window.isSecureContext?!(`Notification`in window)||!(`serviceWorker`in navigator)||!(`PushManager`in window)?SX()?`install`:`unsupported`:Notification.permission===`denied`?`denied`:`supported`:`insecure`}function SX(){return/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.userAgent.includes(`Mac`)&&navigator.maxTouchPoints>1}async function CX(){return await(await navigator.serviceWorker.ready).pushManager.getSubscription()!==null}async function wX(){return Notification.permission==="default"&&await Notification.requestPermission(),Notification.permission===`granted`&&(await DX(OX),!0)}function TX(){return DX(kX)}function EX(e){return DX(async()=>{if(xX()!==`supported`)return;let t=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!t)return;let n=await AX(),r=t.options.applicationServerKey;r!==null&&MX(r)===n.publicKey?await NX(e,t,n):await OX()})}function DX(e){let t=cX.then(e);return cX=t.catch(()=>void 0),t}async function OX(){await kX();let e=await AX(),t=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:e.publicKey});await Promise.all(jX().map(n=>NX(n,t,e)))}async function kX(){let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();e&&(await Promise.all(jX().map(t=>L(t,`push.unsubscribe`,{endpoint:e.endpoint}))),await e.unsubscribe())}async function AX(){let e=await caches.open(`offsite-worker`),t=await e.match(`/push-keys`);if(t!==void 0)return await t.json();let n=await crypto.subtle.generateKey({name:`ECDSA`,namedCurve:`P-256`},!0,[`sign`,`verify`]),r=(await crypto.subtle.exportKey(`jwk`,n.privateKey)).d;if(r===void 0)throw Error(`the browser did not export the push key`);let i={publicKey:MX(await crypto.subtle.exportKey(`raw`,n.publicKey)),privateKey:r};return await e.put(`/push-keys`,new Response(JSON.stringify(i))),i}function jX(){return Z().machines.filter(e=>$o(e.id)).map(e=>e.id)}function MX(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``)}async function NX(e,t,n){await L(e,`push.subscribe`,{subscription:t.toJSON(),...n,machine:e})}var PX=new Map([[`denied`,`Blocked in the browser's site settings`],[`insecure`,`Needs https or localhost`],[`install`,`Add OffSite to the Home Screen first`],[`unsupported`,`Not supported in this browser`]]);function FX(e){let t=e.prefs.terminal,n=t.behavior;function r(r){L9({...e.prefs,terminal:{...t,behavior:{...n,...r}}})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(tR,{title:`Notifications`,children:[(0,I.jsx)(nR,{label:`Desktop notifications on this device`,children:(0,I.jsx)(IX,{})}),(0,I.jsx)(nR,{label:`Push terminal alerts when no OffSite page is open`,children:(0,I.jsx)(LX,{})})]}),(0,I.jsxs)(tR,{title:`Terminal bell`,children:[(0,I.jsx)(nR,{label:`Flash the screen on bell`,children:(0,I.jsx)(ZL,{checked:n.bellFlash,onCheckedChange:e=>r({bellFlash:e})})}),(0,I.jsx)(nR,{label:`Play a sound on bell`,children:(0,I.jsx)(ZL,{checked:n.bellSound,onCheckedChange:e=>r({bellSound:e})})})]})]})}function IX(){let[e,t]=(0,F.useState)(uX),[n,r]=(0,F.useState)(dX);(0,F.useEffect)(()=>{let e=uX();if(e===`insecure`||e===`unsupported`)return;let n=new AbortController;return pX(n.signal,()=>t(uX())).catch(e=>console.error(`could not watch the notification permission`,e)),()=>n.abort()},[]);async function i(e){await fX(e),r(e),t(uX())}return(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[PX.has(e)&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:PX.get(e)}),(0,I.jsx)(ZL,{checked:e===`granted`&&n,disabled:e!==`granted`&&e!=="default",onCheckedChange:e=>void i(e)})]})}function LX(){let[e,t]=(0,F.useState)(xX),[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(()=>xX()===`supported`),[o,s]=(0,F.useState)(null);(0,F.useEffect)(()=>{if(xX()!==`supported`)return;let e=!0;async function t(){try{let t=await CX();e&&r(t)}catch(e){console.error(`could not read the push subscription`,e)}e&&a(!1)}return t(),()=>{e=!1}},[]);async function c(e){a(!0),s(null);try{e?r(await wX()):(await TX(),r(!1))}catch(e){console.error(`could not change push notifications`,e),s(rt(e))}t(xX()),a(!1)}return(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o!==null&&(0,I.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Could not update: `,o]}),PX.has(e)&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:PX.get(e)}),(0,I.jsx)(ZL,{checked:e===`supported`&&n,disabled:e!==`supported`||i,onCheckedChange:e=>void c(e)})]})}var RX={five_hour:`5h`,seven_day:`Week`,seven_day_opus:`Week (Opus)`,seven_day_sonnet:`Week (Sonnet)`};function zX(e){return RX[e.window]??e.window}function BX(e){let t=e.account,[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(null),c=n===null?null:n.models;(0,F.useEffect)(()=>{let n=!0;return r(null),a(null),L(e.machine,`capabilities`,{provider:t.provider,accountId:t.id,projectId:null}).then(e=>{n&&r(e)},e=>{n&&a(rt(e))}),()=>{n=!1}},[e.machine,t.provider,t.id,t.configDir]);async function l(n){s(null);try{await L(e.machine,`accounts.update`,{id:t.id,name:t.name,color:t.color,configDir:t.configDir,enabled:t.enabled,hiddenModels:t.hiddenModels,...n})}catch(e){s(rt(e))}}async function u(){s(null);try{await L(e.machine,`accounts.remove`,{id:t.id}),$({settingsAccount:null})}catch(e){s(rt(e))}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(tR,{title:`Account`,children:[(0,I.jsx)(nR,{label:`Name`,children:(0,I.jsx)(rR,{value:t.name,valid:e=>e.trim()!==``,onCommit:e=>void l({name:e})},t.name)}),(0,I.jsx)(nR,{label:`Color`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.color!==null&&(0,I.jsx)(`span`,{className:`size-5 shrink-0 rounded-full`,style:{backgroundColor:t.color}}),(0,I.jsx)(rR,{className:`w-28 font-mono`,value:t.color??``,placeholder:`#3b82f6`,valid:e=>e===``||/^#[0-9a-f]{6}$/i.test(e),onCommit:e=>void l({color:e===``?null:e})},t.color??``)]})}),(0,I.jsx)(nR,{label:`Config directory`,children:(0,I.jsx)(rR,{className:`w-72 font-mono`,value:t.configDir??``,placeholder:t.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`,onCommit:e=>void l({configDir:e})},t.configDir??``)})]}),o!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:o}),(0,I.jsxs)(tR,{title:`Models`,note:`Overrides the provider settings`,children:[i!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:i}),i===null&&c===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-4 py-3 text-xs`,children:`Loading…`}),(c??[]).map(n=>{let r=e.settings[n.value]?.hidden??n.deprecated,i=t.hiddenModels[n.value],a=i??r;return(0,I.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-1.5`,children:[(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate text-sm`,a&&`text-muted-foreground`),children:n.name}),i!==void 0&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Override`}),(0,I.jsx)(ZL,{size:`sm`,checked:!a,onCheckedChange:e=>{let i={...t.hiddenModels};!e===r?delete i[n.value]:i[n.value]=!e,l({hiddenModels:i})},"aria-label":`Show ${n.name}`})]},n.value)})]}),(0,I.jsxs)(HL,{children:[(0,I.jsx)(UL,{asChild:!0,children:(0,I.jsx)(x,{variant:`outline`,className:`text-destructive`,children:`Remove account`})}),(0,I.jsxs)(WL,{children:[(0,I.jsxs)(GL,{children:[(0,I.jsxs)(qL,{children:[`Remove `,t.name,`?`]}),(0,I.jsx)(JL,{children:`OffSite stops using this account. Its config directory and sessions stay untouched.`})]}),(0,I.jsxs)(KL,{children:[(0,I.jsx)(XL,{children:`Cancel`}),(0,I.jsx)(YL,{variant:`destructive`,onClick:()=>void u(),children:`Remove account`})]})]})]})]})}function VX(e){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(null);async function l(){o(!0),c(null);try{await L(e.machine,`accounts.add`,{provider:e.provider,name:t,configDir:r}),$({settingsAccount:null})}catch(e){c(rt(e)),o(!1)}}return(0,I.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,I.jsxs)(tR,{title:`Account`,children:[(0,I.jsx)(nR,{label:`Name`,children:(0,I.jsx)(kL,{className:`w-56`,value:t,onChange:e=>n(e.target.value),placeholder:`Work`})}),(0,I.jsx)(nR,{label:`Config directory`,children:(0,I.jsx)(kL,{className:`w-72 font-mono`,value:r,onChange:e=>i(e.target.value),placeholder:e.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`})})]}),s!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:s}),(0,I.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,I.jsx)(x,{type:`button`,variant:`ghost`,onClick:()=>$({settingsAccount:null}),children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,disabled:a||t.trim()===``,children:`Add account`})]})]})}function HX(e){let t=e.config,n=t.enabledProviders[e.provider],r=e.provider===`claude`?e.claudeAccounts:e.provider===`codex`?e.codexAccounts:[],i=r.find(e=>e.valid),a=t.claudeBaseDir[e.platform]??e.defaultClaudeBaseDir;if(e.selected===`new`){if(e.provider===`opencode`)throw Error(`OpenCode accounts cannot be added`);return(0,I.jsx)(VX,{machine:e.machine,provider:e.provider})}if(e.selected!==null){let n=r.find(t=>t.id===e.selected);return n===void 0?(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This account no longer exists.`}):(0,I.jsx)(BX,{machine:e.machine,settings:t.models[e.provider],account:n})}return(0,I.jsxs)(I.Fragment,{children:[e.provider===`claude`&&(0,I.jsx)(`div`,{className:`divide-y overflow-hidden rounded-xl border`,children:(0,I.jsx)(nR,{label:`Base directory`,children:(0,I.jsx)(rR,{className:`w-72 font-mono`,value:a,valid:e=>e.trim()!==``,onCommit:n=>H9(e.machine,{...t,claudeBaseDir:{...t.claudeBaseDir,[e.platform]:n}})},a)})}),(0,I.jsxs)(`div`,{className:P(`space-y-5 transition-opacity`,!n&&`opacity-50`),children:[e.provider!==`opencode`&&(0,I.jsx)(tR,{title:`Accounts`,children:(0,I.jsx)(WX,{machine:e.machine,accounts:r})}),n&&e.provider===`opencode`&&e.openCode.available&&(0,I.jsx)(UX,{machine:e.machine,config:t,composer:e.composer,provider:e.provider,accountId:null}),n&&e.provider!==`opencode`&&i!==void 0&&(0,I.jsx)(UX,{machine:e.machine,config:t,composer:e.composer,provider:e.provider,accountId:i.id})]})]})}function UX(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(null),a=e.config.models[e.provider],o=t===null?null:t.models,s=e.composer[e.provider],c=s.model??(t===null?null:t.defaultModel);(0,F.useEffect)(()=>{let t=!0;return n(null),i(null),L(e.machine,`capabilities`,{provider:e.provider,accountId:e.accountId,projectId:null}).then(e=>{t&&n(e)},e=>{t&&i(rt(e))}),()=>{t=!1}},[e.machine,e.provider,e.accountId]);function l(t,n){H9(e.machine,{...e.config,models:{...e.config.models,[e.provider]:{...a,[t]:n}}})}return(0,I.jsxs)(tR,{title:`Models`,children:[o!==null&&(0,I.jsx)(nR,{label:`Default model`,children:(0,I.jsxs)(AL,{value:c??void 0,onValueChange:t=>{let n=o?.find(e=>e.value===t)?.effort??null;W9(e.machine,{...e.composer,[e.provider]:{...s,model:t,...n===null?{}:{effort:n}}})},children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{placeholder:`Choose a model`})}),(0,I.jsx)(NL,{children:o.filter(e=>!(a[e.value]?.hidden??e.deprecated)||e.value===c).map(e=>(0,I.jsx)(PL,{value:e.value,children:e.name},e.value))})]})}),r!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r}),r===null&&o===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-4 py-3 text-xs`,children:`Loading…`}),(o??[]).map(t=>{let n=a[t.value]??{hidden:t.deprecated,effort:t.effort};return(0,I.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-1.5`,children:[(0,I.jsxs)(`div`,{className:P(`min-w-0 flex-1 truncate text-sm`,n.hidden&&`text-muted-foreground`),children:[t.name,e.provider===`opencode`&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs`,children:t.description})]}),t.efforts.length>0&&(0,I.jsxs)(AL,{value:n.effort??t.effort??void 0,onValueChange:e=>l(t.value,{...n,effort:e}),children:[(0,I.jsx)(ML,{size:`sm`,className:`w-28`,children:(0,I.jsx)(jL,{placeholder:`Effort`})}),(0,I.jsx)(NL,{children:t.efforts.map(e=>(0,I.jsx)(PL,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,I.jsx)(ZL,{size:`sm`,checked:!n.hidden,onCheckedChange:e=>l(t.value,{...n,hidden:!e}),"aria-label":`Show ${t.name}`})]},t.value)})]})}function WX(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(null);async function a(e){n(!0),i(null);try{await e()}catch(e){i(rt(e))}finally{n(!1)}}return(0,I.jsxs)(I.Fragment,{children:[e.accounts.map(n=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:P(`min-w-0 flex-1`,!n.enabled&&`opacity-50`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:P(`size-2 shrink-0 rounded-full`,!n.enabled&&`bg-muted-foreground/40`,n.enabled&&n.error!==null&&`bg-destructive`,n.enabled&&n.error===null&&!n.linked&&`bg-warning`,n.enabled&&n.error===null&&n.linked&&`bg-success`)}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n.name}),n.plan!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:n.plan})]}),n.error!==null&&(0,I.jsx)(`p`,{className:`text-destructive mt-1 truncate pl-4 text-xs`,children:n.error}),n.error===null&&!n.linked&&(0,I.jsx)(`p`,{className:`text-warning mt-1 truncate pl-4 text-xs`,children:`Not linked to shared threads · hidden in the composer`}),n.error===null&&n.linked&&n.limits.length>0&&(0,I.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-5 gap-y-1.5 pl-4`,children:n.limits.map(e=>(0,I.jsx)(GX,{limit:e},e.window))})]}),(0,I.jsx)(ZL,{size:`sm`,checked:n.enabled,disabled:t,onCheckedChange:t=>void a(()=>L(e.machine,`accounts.update`,{id:n.id,name:n.name,color:n.color,configDir:n.configDir,enabled:t,hiddenModels:n.hiddenModels})),"aria-label":`Enable ${n.name}`}),(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost-muted`,title:`Open account`,onClick:()=>$({settingsAccount:n.id}),children:(0,I.jsx)(w,{icon:Lg})})]},n.id)),(0,I.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>$({settingsAccount:`new`}),children:[(0,I.jsx)(w,{icon:kg,className:`size-4`}),`Add account`]}),r!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r})]})}function GX(e){let t=e.limit,n=t.rejected?100:t.utilization===null?null:Math.min(100,Math.round(t.utilization*100));return n===null?null:(0,I.jsx)(Oe,{label:t.resetsAt===null?`Reset time unknown`:`Resets ${kw(t.resetsAt*1e3)}`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:zX(t)}),(0,I.jsx)(`div`,{className:`bg-foreground/10 h-1 w-16 overflow-hidden rounded-full`,children:(0,I.jsx)(`div`,{className:P(`h-full rounded-full`,t.rejected&&`bg-destructive`,!t.rejected&&n>=80&&`bg-warning`,!t.rejected&&n<80&&`bg-foreground/50`),style:{width:`${n}%`}})}),(0,I.jsxs)(`span`,{className:P(`tabular-nums`,t.rejected&&`text-destructive`,!t.rejected&&`text-muted-foreground`),children:[n,`%`]})]})})}var KX=tt?`⌘`:`Ctrl+Shift`,qX=[[`Enter`,`Send, or queue or steer while the agent works`],[`${et}+Enter`,`Send the other way while the agent works`],[`Shift+Enter`,`New line`],[`↑`,`Recall your last message`],[`Esc`,`Stop the agent`],[`/`,`Slash commands`],[`@`,`Mention a file`],[`${et}+K`,`Search sessions and actions`],[`${et}+N or ${et}+T`,`New thread`],[tt?"⌘+` or Ctrl+`":"Ctrl+`",`Toggle the terminal`],[`${et}+B`,`Toggle the sidebar`],[`${et}+J`,`Toggle the right panel`],[`${KX}+T`,`New terminal tab, in the terminal`],[`${KX}+W`,`Close the terminal tab`],[`${KX}+F`,`Find in the terminal`],[`Ctrl+Tab`,`Next terminal tab`],[`Ctrl+Shift+Tab`,`Previous terminal tab`]];function JX(){return(0,I.jsx)(tR,{title:`Keyboard shortcuts`,children:qX.map(([e,t])=>(0,I.jsx)(nR,{label:t,children:(0,I.jsx)(`kbd`,{className:`bg-muted text-muted-foreground rounded px-1.5 py-0.5 font-sans text-xs`,children:e})},e))})}var YX=1048576;function XX(e){window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{console.warn(`could not copy to the clipboard`,e),ms(`Could not copy to the clipboard`)}):console.warn(`copy from the terminal needs https or localhost`)}async function ZX(e){if(!window.isSecureContext){console.warn(`programs can read the clipboard only over https or localhost`),ms(`Programs can read the clipboard only over https or localhost`);return}let t;try{t=await navigator.clipboard.readText()}catch(e){console.warn(`could not read the clipboard`,e),ms(`Could not read the clipboard`);return}new TextEncoder().encode(t).length>YX?(console.warn(`the clipboard is over 1 MiB, not replying`),ms(`The clipboard is too large to share (over 1 MiB)`)):e(t)}var QX={macos:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},linux:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},windows:{label:`Alt+V`,ctrl:!1,alt:!0,data:`\x1Bv`}};function $X(e,t){let n=QX[t];return e.key.toLowerCase()===`v`&&e.ctrlKey===n.ctrl&&e.altKey===n.alt&&!e.shiftKey&&!e.metaKey}async function eZ(e,t){let n=[];for(let e of await navigator.clipboard.read()){let t=e.types.find(e=>e.startsWith(`image/`));t&&n.push(await e.getType(t))}return n.length===0?(ms(`No image in the clipboard`),!1):(await tZ(e,t,n),!0)}async function tZ(e,t,n){let r=[];for(let t of n){let n=await L(e,`terminal.paste`,{type:t.type,data:await qC(t)});r.push(/\s/.test(n)?`"${n}"`:n)}t.paste(r.join(` `))}function nZ(e){console.error(`could not paste image`,e),ms(`Could not paste the image`)}function rZ(e){let t=e.prefs.terminal,[n,r]=(0,F.useState)(!oR.some(e=>e.family===t.font.family));function i(t){L9({...e.prefs,terminal:t})}function a(e,n){i({...t,[e]:{...t[e],...n}})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(tR,{title:`Font`,children:[(0,I.jsx)(nR,{label:`Family`,children:(0,I.jsxs)(AL,{value:n?`custom`:t.font.family,onValueChange:e=>{r(e===`custom`),e!==`custom`&&a(`font`,{family:e})},children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{})}),(0,I.jsxs)(NL,{children:[oR.map(e=>(0,I.jsx)(PL,{value:e.family,children:e.label},e.family)),(0,I.jsx)(PL,{value:`custom`,children:`Custom`})]})]})}),n&&(0,I.jsx)(nR,{label:`Custom family`,children:(0,I.jsx)(rR,{placeholder:`Installed font name`,value:t.font.family,onCommit:e=>a(`font`,{family:e})})}),(0,I.jsx)(nR,{label:`Size`,children:(0,I.jsx)(iR,{value:t.font.size,step:.5,onCommit:e=>a(`font`,{size:e})})}),(0,I.jsx)(nR,{label:`Line height`,children:(0,I.jsx)(iR,{value:t.font.lineHeight,step:.05,onCommit:e=>a(`font`,{lineHeight:e})})}),(0,I.jsx)(nR,{label:`Ligatures`,children:(0,I.jsx)(ZL,{checked:t.font.ligatures,onCheckedChange:e=>a(`font`,{ligatures:e})})}),(0,I.jsx)(nR,{label:`Bold text in bright colors`,children:(0,I.jsx)(ZL,{checked:t.boldIsBright,onCheckedChange:e=>i({...t,boldIsBright:e})})})]}),(0,I.jsxs)(tR,{title:`Cursor`,children:[(0,I.jsx)(nR,{label:`Style`,children:(0,I.jsxs)(AL,{value:t.cursor.style,onValueChange:e=>a(`cursor`,{style:e}),children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{})}),(0,I.jsxs)(NL,{children:[(0,I.jsx)(PL,{value:`block`,children:`Block`}),(0,I.jsx)(PL,{value:`bar`,children:`Bar`}),(0,I.jsx)(PL,{value:`underline`,children:`Underline`})]})]})}),(0,I.jsx)(nR,{label:`Blink`,children:(0,I.jsx)(ZL,{checked:t.cursor.blink,onCheckedChange:e=>a(`cursor`,{blink:e})})})]}),(0,I.jsx)(iZ,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,I.jsx)(aZ,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,I.jsxs)(tR,{title:`Layout`,children:[[`top`,`right`,`bottom`,`left`].map(e=>(0,I.jsx)(nR,{label:`Padding ${e}`,children:(0,I.jsx)(iR,{value:t.padding[e],onCommit:t=>a(`padding`,{[e]:t})})},e)),(0,I.jsx)(nR,{label:`Scrollback lines`,children:(0,I.jsx)(iR,{value:t.scrollback,step:1e3,onCommit:e=>i({...t,scrollback:e})})})]})]})}function iZ(e){return(0,I.jsxs)(tR,{title:`Behavior`,children:[(0,I.jsx)(nR,{label:`Modernize Shift+Enter`,children:(0,I.jsx)(ZL,{checked:e.behavior.modernizeShiftEnter,onCheckedChange:t=>e.onChange({modernizeShiftEnter:t})})}),(0,I.jsx)(nR,{label:`${QX.linux.label} (${QX.windows.label} on Windows machines) pastes images from the browser clipboard`,children:(0,I.jsx)(ZL,{checked:e.behavior.pasteBrowserImages,onCheckedChange:t=>e.onChange({pasteBrowserImages:t})})}),(0,I.jsx)(nR,{label:`Capture browser shortcuts`,children:(0,I.jsx)(ZL,{checked:e.behavior.captureShortcuts,onCheckedChange:t=>e.onChange({captureShortcuts:t})})}),(0,I.jsx)(nR,{label:`Click moves the cursor in the command line`,children:(0,I.jsx)(ZL,{checked:e.behavior.clickToMoveCursor,onCheckedChange:t=>e.onChange({clickToMoveCursor:t})})}),(0,I.jsx)(nR,{label:`Ask before closing a tab that is running a program`,children:(0,I.jsx)(ZL,{checked:e.behavior.confirmCloseBusyTab,onCheckedChange:t=>e.onChange({confirmCloseBusyTab:t})})})]})}function aZ(e){return tt?(0,I.jsx)(tR,{title:`Mac keys`,note:`Meta keeps that Option key from typing @, | and other symbols. Safari and Firefox use US key positions`,children:(0,I.jsx)(nR,{label:`Use Option as Meta`,children:(0,I.jsxs)(AL,{value:e.behavior.optionAsMeta,onValueChange:t=>e.onChange({optionAsMeta:t}),children:[(0,I.jsx)(ML,{className:`w-56`,children:(0,I.jsx)(jL,{})}),(0,I.jsxs)(NL,{children:[(0,I.jsx)(PL,{value:`off`,children:`Off`}),(0,I.jsx)(PL,{value:`left`,children:`Left Option`}),(0,I.jsx)(PL,{value:`right`,children:`Right Option`}),(0,I.jsx)(PL,{value:`both`,children:`Both Options`})]})]})})}):null}var oZ=[`General`,`Terminal`,`Notifications`,`Shortcuts`,`Machines`],sZ=[`Machine`,`Claude`,`Codex`,`OpenCode`];function cZ(){let e=Q(e=>e.machines),t=Q(e=>e.settingsMachine===null?null:T9(e,e.settingsMachine)),n=Q(e=>e.settingsPage),r=pZ(n),i=Q(e=>r===null?null:e.settingsAccount),a=Q(e=>n===`Machines`?e.machines.find(t=>t.id===e.settingsEditedMachine)??null:null);return{machines:e,machine:t,config:t===null?null:t.config,system:t===null?null:t.system,page:n,provider:r,account:i,editedMachine:a,subpage:i!==null||a!==null,subpageTitle:i===`new`?`New account`:i===null?a?.name:[...t?.claudeAccounts??[],...t?.codexAccounts??[]].find(e=>e.id===i)?.name}}function lZ(){let e=Q(e=>e.settingsOpen),t=cZ(),n=t.page,r=t.machine;function i(e){return(0,I.jsx)(`button`,{className:P(`text-muted-foreground hover:bg-accent hover:text-foreground flex h-9 flex-none items-center rounded-md px-2 text-sm transition-colors`,e===n&&`bg-accent text-foreground`),onClick:()=>I9(e),children:(0,I.jsx)(uZ,{page:e})},e)}return(0,I.jsx)(Ke,{open:e,onOpenChange:F9,children:(0,I.jsxs)(Ne,{showCloseButton:!1,"aria-describedby":void 0,className:`flex h-[min(44rem,calc(100dvh-2rem))] flex-col gap-0 overflow-hidden p-0 sm:max-w-4xl sm:flex-row`,children:[(0,I.jsxs)(`nav`,{className:`flex flex-none gap-1 overflow-x-auto border-b p-3 sm:w-48 sm:flex-col sm:border-r sm:border-b-0`,children:[(0,I.jsx)(Ve,{className:`hidden px-2 pt-1 pb-3 text-base font-semibold sm:block`,children:`Settings`}),oZ.map(i),(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-1 sm:mt-6 sm:flex-col sm:items-stretch`,children:[r!==null&&t.machines.length>1&&(0,I.jsxs)(AL,{value:r.id,onValueChange:e=>$({settingsMachine:e,settingsAccount:null}),children:[(0,I.jsx)(ML,{className:`mb-1 w-40 sm:w-full`,children:(0,I.jsx)(jL,{})}),(0,I.jsx)(NL,{children:t.machines.map(e=>(0,I.jsxs)(PL,{value:e.id,children:[(0,I.jsx)(w,{icon:Gv[e.icon]}),e.name]},e.id))})]}),r!==null&&t.machines.length===1&&(0,I.jsxs)(`p`,{className:`text-muted-foreground flex h-9 items-center gap-1.5 px-2 text-xs font-medium [&_svg]:size-4`,children:[(0,I.jsx)(w,{icon:Gv[r.icon]}),(0,I.jsx)(`span`,{className:`truncate`,children:r.name})]}),sZ.map(i)]})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pt-4 pb-7`,children:[(0,I.jsxs)(`div`,{className:`mb-5 flex h-9 items-center`,children:[t.subpage&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground text-xl font-semibold tracking-tight transition-colors`,onClick:()=>$({settingsAccount:null,settingsEditedMachine:null}),children:n}),(0,I.jsx)(w,{icon:Lg,className:`text-muted-foreground mx-1.5 size-5`}),(0,I.jsx)(`h2`,{className:`truncate text-xl font-semibold tracking-tight`,children:t.subpageTitle})]}),!t.subpage&&(0,I.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:n===`Machine`?`General`:n}),(0,I.jsx)(dZ,{view:t,className:`ml-3`}),(0,I.jsx)(Be,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon`,className:`-mr-2 ml-auto`,"aria-label":`Close settings`,children:(0,I.jsx)(w,{icon:Kg})})})]}),(0,I.jsx)(fZ,{view:t})]})]})})}function uZ(e){let t=pZ(e.page);return(0,I.jsxs)(I.Fragment,{children:[t!==null&&(0,I.jsx)(`span`,{className:`mr-2.5 flex size-4 items-center justify-center`,children:(0,I.jsx)(Yv,{provider:t,className:P(t===`claude`&&`size-4`,t===`codex`&&`size-[19px] shrink-0`,t===`opencode`&&`h-3.5`)})}),e.page===`Machine`?`General`:e.page]})}function dZ(e){let t=e.view.machine,n=e.view.config,r=e.view.provider;return r===null||e.view.account!==null||t===null||n===null?null:(0,I.jsx)(ZL,{className:e.className,checked:n.enabledProviders[r],onCheckedChange:e=>void H9(t.id,{...n,enabledProviders:{...n.enabledProviders,[r]:e}}),"aria-label":`Enable ${e.view.page}`})}function fZ(e){let t=Q(e=>e.prefs),n=e.view.page,r=e.view.machine,i=e.view.config,a=e.view.system,o=sZ.includes(n),[s,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(0);return(0,I.jsxs)(I.Fragment,{children:[o&&r!==null&&r.configError!==null&&(0,I.jsxs)(`p`,{className:`text-destructive mb-5 text-sm whitespace-pre-wrap`,children:[`Not saved: `,r.configError]}),(0,I.jsxs)(`div`,{className:`w-full space-y-5`,children:[n===`General`&&(0,I.jsx)(zae,{prefs:t,onRestore:()=>c(`browser`)}),n===`Machine`&&r!==null&&i!==null&&a!==null&&(0,I.jsx)(yR,{machine:r.id,config:i,platform:a.platform,defaultShell:a.defaultShell,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,onRestore:()=>c(`machine`)}),o&&r===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Add a machine to see its settings.`}),o&&r!==null&&(i===null||a===null)&&(0,I.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[r.name,` is not connected. Its settings show up once it is.`]}),n===`Terminal`&&(0,I.jsx)(rZ,{prefs:t}),n===`Notifications`&&(0,I.jsx)(FX,{prefs:t}),e.view.provider!==null&&r!==null&&i!==null&&r.composer!==null&&a!==null&&(0,I.jsx)(HX,{machine:r.id,config:i,composer:r.composer,platform:a.platform,defaultClaudeBaseDir:a.defaultClaudeBaseDir,provider:e.view.provider,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,selected:e.view.account},e.view.provider),n===`Machines`&&(0,I.jsx)(iX,{}),n===`Shortcuts`&&(0,I.jsx)(JX,{})]},l),(0,I.jsx)(HL,{open:s!==null,onOpenChange:e=>{e||c(null)},children:(0,I.jsxs)(WL,{children:[(0,I.jsxs)(GL,{children:[(0,I.jsx)(qL,{children:s===`browser`?`Restore browser defaults?`:`Restore machine defaults?`}),(0,I.jsx)(JL,{children:s===`browser`?`All settings of this browser go back to their defaults.`:`All settings of ${r?.name} go back to their defaults.`})]}),(0,I.jsxs)(KL,{children:[(0,I.jsx)(XL,{children:`Cancel`}),(0,I.jsx)(YL,{variant:`destructive`,onClick:()=>{if(u(l+1),s===`browser`)L9(eR);else{if(r===null||i===null||a===null)throw Error(`Restoring machine defaults needs a connected machine`);H9(r.id,{...a.defaults,claudeAccounts:i.claudeAccounts,codexAccounts:i.codexAccounts})}},children:`Restore defaults`})]})]})})]})}function pZ(e){return e===`Claude`?`claude`:e===`Codex`?`codex`:e===`OpenCode`?`opencode`:null}function mZ(){let e=Q(e=>e.settingsOpen),t=Q(e=>e.settingsListing),n=cZ(),r=n.machine;function i(){t?F9(!1):n.subpage?$({settingsAccount:null,settingsEditedMachine:null}):$({settingsListing:!0})}function a(e){return(0,I.jsxs)(`button`,{className:`active:bg-accent flex min-h-12 w-full items-center px-4 text-left text-sm font-medium`,onClick:()=>I9(e),children:[(0,I.jsx)(uZ,{page:e}),(0,I.jsx)(w,{icon:Lg,className:`text-muted-foreground ml-auto size-4`})]},e)}return(0,I.jsx)(Ge,{open:e,onOpenChange:F9,children:(0,I.jsx)(Xe,{children:(0,I.jsxs)(ze,{"aria-describedby":void 0,className:`bg-background text-foreground data-open:animate-in data-open:slide-in-from-right fixed inset-0 z-50 flex flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] text-sm duration-200 outline-none [--workspace-topbar-height:44px] motion-reduce:animate-none`,children:[(0,I.jsxs)(`header`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-1.5 pr-3 pl-1`,children:[(0,I.jsx)(x,{variant:`ghost`,size:`icon`,"aria-label":`Back`,onClick:i,children:(0,I.jsx)(w,{icon:Ig,className:`text-foreground size-5`,strokeWidth:2})}),(0,I.jsxs)($e,{className:`min-w-0 flex-1 truncate font-medium`,children:[t&&`Settings`,!t&&n.subpage&&n.subpageTitle,!t&&!n.subpage&&n.page]}),!t&&(0,I.jsx)(dZ,{view:n,className:`shrink-0`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pt-2 pb-6`,children:[t&&(0,I.jsxs)(`div`,{className:`space-y-5`,children:[(0,I.jsx)(tR,{title:`This browser`,children:oZ.map(a)}),(0,I.jsxs)(tR,{title:`Machine`,children:[r!==null&&(0,I.jsxs)(nR,{label:`Machine`,children:[n.machines.length>1&&(0,I.jsxs)(AL,{value:r.id,onValueChange:e=>$({settingsMachine:e,settingsAccount:null}),children:[(0,I.jsx)(ML,{className:`w-40`,children:(0,I.jsx)(jL,{})}),(0,I.jsx)(NL,{children:n.machines.map(e=>(0,I.jsxs)(PL,{value:e.id,children:[(0,I.jsx)(w,{icon:Gv[e.icon]}),e.name]},e.id))})]}),n.machines.length===1&&(0,I.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1.5 text-sm [&_svg]:size-4`,children:[(0,I.jsx)(w,{icon:Gv[r.icon]}),r.name]})]}),sZ.map(a)]})]}),!t&&(0,I.jsx)(fZ,{view:n})]})]})})})}function hZ(){return(0,I.jsx)(`div`,{className:`grid flex-1 place-items-center p-6`,children:(0,I.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,I.jsx)(`h1`,{className:`text-foreground text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:`Connect a machine`}),(0,I.jsx)(`p`,{className:`text-muted-foreground mt-2 text-center text-sm`,children:`Run this on the computer you want to use, then open the pairing link it prints.`}),(0,I.jsx)(`pre`,{className:`bg-muted text-foreground mt-5 rounded-lg px-4 py-3 font-mono text-sm select-all`,children:`npx offsite serve`}),(0,I.jsx)(`p`,{className:`text-muted-foreground mt-8 mb-3 text-sm`,children:`Or connect it here.`}),(0,I.jsx)(tX,{actions:e=>(0,I.jsx)(x,{type:`submit`,className:`mt-4`,disabled:!e,children:`Connect`})})]})})}function gZ(){let e=Q(e=>e.paletteOpen),t=Q(e=>e.selection),n=Q(e=>e.machines),r=Q(e=>e.projects),[i,a]=(0,F.useState)(``),[o]=zv(i,150),[s,c]=(0,F.useState)([]),[l,u]=(0,F.useState)(0),d=(0,F.useRef)(null),f=i.toLowerCase().split(/\s+/).filter(Boolean),p=[...t===null?[]:[{key:`new`,label:`New thread`,detail:r.find(e=>e.machine===t.machine&&e.id===t.projectId)?.path??``,run:()=>rw({...t,sessionId:null})}],{key:`accounts`,label:`Manage accounts`,detail:``,run:()=>I9(C9[Z().settings.provider])},{key:`settings`,label:`Settings`,detail:`Theme, notifications, keyboard shortcuts`,run:()=>F9(!0)}],m=s.map(e=>({key:f9(e.machine,e.id),label:e.title,detail:`${e.status===`minimized`?`Minimized · `:``}${n.length>1?`${n.find(t=>t.id===e.machine)?.name??``}:`:``}${r.find(t=>t.machine===e.machine&&t.id===e.projectId)?.path??``}`,run:()=>rw({machine:e.machine,projectId:e.projectId,sessionId:e.id})})),h=[...p.filter(e=>{let t=`${e.label} ${e.detail}`.toLowerCase();return f.every(e=>t.includes(e))}),...m],g=Math.min(l,h.length-1);(0,F.useEffect)(()=>{if(!e)return;let t=!0;return Promise.all(Z().machines.filter(e=>e.status===`online`).map(async e=>(await L(e.id,`sessions.search`,{query:o})).map(t=>({...t,machine:e.id})))).then(e=>{t&&c(e.flat())}).catch(R9),()=>{t=!1}},[e,o]),(0,F.useLayoutEffect)(()=>{d.current?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})},[g]);function _(e){P9(!1),e.run()}return(0,I.jsx)(Ke,{open:e,onOpenChange:e=>{P9(e),a(``),u(0)},children:(0,I.jsxs)(Ne,{showCloseButton:!1,className:`top-[20%] translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-xl`,children:[(0,I.jsx)(Ve,{className:`sr-only`,children:`Search threads`}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 border-b px-4`,children:[(0,I.jsx)(w,{icon:W_,className:`text-muted-foreground size-4 shrink-0`}),(0,I.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),u(0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;u((g+t+h.length)%h.length)}e.key===`Enter`&&g>=0&&(e.preventDefault(),_(h[g]))},placeholder:`Search threads and actions…`,className:`placeholder:text-placeholder/75 h-11 w-full bg-transparent text-sm outline-none`})]}),(0,I.jsxs)(`div`,{ref:d,className:`max-h-96 overflow-y-auto p-1`,children:[h.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-3 py-6 text-center text-xs`,children:`Nothing matches.`}),h.map((e,t)=>(0,I.jsxs)(`button`,{"data-active":t===g,className:P(`flex w-full cursor-pointer flex-col rounded-lg px-2.5 py-1.5 text-left`,t===g&&`bg-accent`),onMouseMove:()=>u(t),onClick:()=>_(e),children:[(0,I.jsx)(`span`,{className:`truncate text-sm`,children:e.label}),e.detail!==``&&(0,I.jsx)(`span`,{className:`text-secondary-label truncate text-xs`,children:e.detail})]},e.key))]})]})})}var _Z=`group/sidebar-row relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function vZ(e){let t=e.session,n=Bv(t.machine,t.projectId),r=Q(e=>Gv[T9(e,t.machine).icon]),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)({open:!1,busy:!1,terminals:0}),u=(0,F.useRef)(null),d=e.activity?.waiting===!0,f=!d&&e.activity?.running===!0,p=Object.values(e.activity?.tasks??{}).includes(`running`),m=f||!d&&p,h=e.activity?.running===!0||p,g=!d&&!m&&e.unseen,_=!e.selected&&!d&&!g;function v(){_w(t.machine,t.id,e.scope)}async function y(){let e=await gw(t.machine,t.id);e!==null&&(h||e>0?l({open:!0,busy:h,terminals:e}):v())}let b=(0,I.jsx)(HL,{open:c.open,onOpenChange:e=>l({...c,open:e}),children:(0,I.jsxs)(WL,{children:[(0,I.jsxs)(GL,{children:[(0,I.jsx)(qL,{children:c.busy?`Stop running work?`:`Close terminals?`}),(0,I.jsxs)(JL,{children:[c.busy&&`The agent or background tasks are running. Do you really want to stop them? `,c.terminals>0&&`This is the last active thread in this project, so its ${c.terminals} terminal${c.terminals===1?``:`s`} will also be closed.`]})]}),(0,I.jsxs)(KL,{children:[(0,I.jsx)(XL,{children:`Cancel`}),(0,I.jsx)(YL,{variant:`destructive`,onClick:v,children:c.busy?`Stop and Make Inactive`:`Close and Make Inactive`})]})]})}),x=e.saved&&(0,I.jsxs)(MC,{onOpenChange:()=>s(!1),children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Thread actions`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(w,{icon:g_,className:`size-3.5`})})}),(0,I.jsxs)(FC,{align:`end`,className:`w-44`,onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>{u.current!==null&&(e.preventDefault(),u.current.focus(),u.current.select())},children:[(0,I.jsxs)(IC,{onSelect:()=>a(t.title),children:[(0,I.jsx)(w,{icon:L_}),`Rename`]}),(0,I.jsxs)(IC,{onSelect:()=>void hw(t.machine,t.id,{status:t.status===`pinned`?`active`:`pinned`}),children:[(0,I.jsx)(w,{icon:t.status===`pinned`?R_:z_}),t.status===`pinned`?`Unpin`:`Pin`]}),(0,I.jsxs)(IC,{onSelect:()=>void hw(t.machine,t.id,{status:t.status===`minimized`?`active`:`minimized`}),children:[(0,I.jsx)(w,{icon:t.status===`minimized`?M_:P_}),t.status===`minimized`?`Restore`:`Minimize`]}),t.status===`inactive`?(0,I.jsxs)(IC,{onSelect:()=>void hw(t.machine,t.id,{status:`active`}),children:[(0,I.jsx)(w,{icon:H_}),`Make active`]}):(0,I.jsxs)(IC,{onSelect:()=>void y(),children:[(0,I.jsx)(w,{icon:V_}),`Make inactive`]}),(0,I.jsx)(VC,{}),(0,I.jsxs)(IC,{variant:`destructive`,title:`Also removes it from ${Tw[t.provider]}`,onSelect:e=>{o?vw(t.machine,t.id):(e.preventDefault(),s(!0))},children:[(0,I.jsx)(w,{icon:p_}),o?`Click again to delete`:`Delete`]})]})]}),S=i===null?(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate text-sm`,_?`text-secondary-label font-normal`:`font-medium`,!_&&(e.unseen||d)&&`text-foreground`,!_&&!e.unseen&&!d&&`text-foreground/90`),children:t.title}):(0,I.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&hw(t.machine,t.id,{title:n})},children:(0,I.jsx)(`input`,{ref:u,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),C=P(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,_&&`text-sidebar-muted-foreground/75 hover:bg-sidebar-row-hover hover:text-sidebar-foreground`,!e.selected&&!_&&`text-sidebar-foreground hover:bg-sidebar-row-hover bg-transparent`);return e.slim?(0,I.jsxs)(`li`,{className:`list-none`,children:[(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:P(_Z,C,`flex h-9 items-center gap-2.5 px-2.5`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,I.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale transition-opacity group-hover/sidebar-row:opacity-100 group-hover/sidebar-row:grayscale-0`,children:(0,I.jsx)(qv,{machine:t.machine,projectId:t.projectId})}),S,(0,I.jsxs)(`span`,{className:`relative ml-auto flex h-6 min-w-8 shrink-0 items-center justify-end`,children:[(0,I.jsx)(`span`,{className:`text-secondary-label group-any-hover/sidebar-row:opacity-0 inline-flex justify-end text-xs tabular-nums transition-opacity`,children:Dw(t.updatedAt)}),(0,I.jsx)(`span`,{className:`group-any-hover/sidebar-row:opacity-100 absolute inset-y-0 right-0 -mr-1 flex items-center opacity-0 transition-opacity has-[[data-state=open]]:opacity-100`,children:x})]})]}),b]}):(0,I.jsxs)(`li`,{className:`list-none py-0.5`,children:[(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:P(_Z,C,m&&!e.selected&&`opacity-70 transition-opacity focus-within:opacity-100 hover:opacity-100`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(qv,{machine:t.machine,projectId:t.projectId,className:`size-5`}),S,t.status===`pinned`&&(0,I.jsx)(w,{icon:z_,className:`text-muted-foreground/65 size-3 shrink-0`}),m&&(0,I.jsx)(`span`,{title:f?`Working`:`Running in background`,className:P(`flex`,f?`text-info`:`text-muted-foreground`),children:(0,I.jsx)(w,{icon:n_,className:`size-4 shrink-0 animate-spin`})}),d&&(0,I.jsx)(`span`,{title:`Waiting for approval`,className:`text-question flex`,children:(0,I.jsx)(w,{icon:Z_,className:`size-4 shrink-0`})}),g&&(0,I.jsx)(`span`,{title:`Done`,className:`text-success flex`,children:(0,I.jsx)(w,{icon:t_,className:`size-4 shrink-0`})})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:r,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:P(`min-w-0 flex-1 truncate`,_?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:Dw(t.updatedAt)})]})]}),e.saved&&(0,I.jsxs)(`div`,{className:P(`group-any-hover/sidebar-row:pointer-events-auto group-any-hover/sidebar-row:opacity-100 pointer-events-none absolute inset-y-0 right-0 flex w-20 flex-col items-end bg-linear-to-l from-50% to-transparent py-(--sidebar-content-inset) pr-1.5 opacity-0 transition-opacity has-[[data-state=open]]:pointer-events-auto has-[[data-state=open]]:opacity-100`,e.selected?`from-sidebar-row-active`:`from-sidebar-row-hover`),children:[(0,I.jsx)(`div`,{className:`flex h-6 items-center`,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Make inactive`,"aria-label":`Make inactive`,onClick:e=>{e.stopPropagation(),y()},children:(0,I.jsx)(w,{icon:V_,className:`size-3.5 scale-160`})})}),(0,I.jsx)(`div`,{className:`mt-1 flex h-5 items-center`,children:x})]})]}),b]})}function yZ(e){let t=Bv(e.machine,e.projectId),n=Q(t=>Gv[T9(t,e.machine).icon]);return(0,I.jsx)(`li`,{className:`list-none py-0.5`,children:(0,I.jsx)(`div`,{role:`button`,tabIndex:0,className:P(_Z,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(qv,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,I.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,I.jsx)(w,{icon:ev,className:`text-warning-foreground size-4 shrink-0`})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:n,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}function bZ(e){return(0,I.jsxs)(MC,{children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsx)(`button`,{className:e.className,title:`Menu`,"aria-label":`Menu`,children:(0,I.jsx)(w,{icon:mee})})}),(0,I.jsxs)(FC,{align:`start`,className:`w-48`,children:[(0,I.jsx)(RC,{value:e.filter,children:[[`active`,H_],[`minimized`,P_],[`inactive`,V_]].map(([t,n])=>(0,I.jsxs)(zC,{value:t,className:`capitalize`,onSelect:()=>e.onFilter(t),children:[(0,I.jsx)(w,{icon:n}),t]},t))}),(0,I.jsx)(VC,{}),(0,I.jsxs)(IC,{onSelect:()=>F9(!0),children:[(0,I.jsx)(w,{icon:q_}),`Settings`]})]})]})}function xZ({...e}){return(0,I.jsx)(ex,{"data-slot":`context-menu`,...e})}function SZ({className:e,...t}){return(0,I.jsx)(nx,{"data-slot":`context-menu-trigger`,className:P(`select-none`,e),...t})}function CZ({className:e,...t}){return(0,I.jsx)(rx,{children:(0,I.jsx)(ax,{"data-slot":`context-menu-content`,className:P(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...t})})}function wZ({className:e,inset:t,variant:n=`default`,...r}){return(0,I.jsx)(ox,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:P(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function TZ({className:e,children:t,checked:n,inset:r,...i}){return(0,I.jsxs)(sx,{"data-slot":`context-menu-checkbox-item`,"data-inset":r,className:P(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...i,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2`,children:(0,I.jsx)(cx,{children:(0,I.jsx)(w,{icon:av,strokeWidth:2})})}),t]})}function EZ({className:e,...t}){return(0,I.jsx)(lx,{"data-slot":`context-menu-separator`,className:P(`-mx-1 my-1 h-px bg-border`,e),...t})}var DZ=`relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none touch-pan-y [-webkit-touch-callout:none] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function OZ(e){let t=e.session,n=Bv(t.machine,t.projectId),r=Q(e=>Gv[T9(e,t.machine).icon]),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)({open:!1,busy:!1,terminals:0}),[u,d]=(0,F.useState)(0),f=(0,F.useRef)(null),p=(0,F.useRef)(null),m=(0,F.useRef)(!1),h=e.activity?.waiting===!0,g=!h&&e.activity?.running===!0,_=Object.values(e.activity?.tasks??{}).includes(`running`),v=g||!h&&_,y=e.activity?.running===!0||_,b=!h&&!v&&e.unseen,x=!e.selected&&!h&&!b,S=e.saved&&!e.slim&&(t.status===`active`||t.status===`pinned`);function C(){_w(t.machine,t.id,e.scope)}async function T(){let e=await gw(t.machine,t.id);e!==null&&(y||e>0?l({open:!0,busy:y,terminals:e}):C())}function E(e){let t=p.current;p.current=null,d(0),t!==null&&t.swiping&&(m.current=!0,e.clientX-t.x>e.currentTarget.offsetWidth*.4&&T())}let D=(0,I.jsx)(HL,{open:c.open,onOpenChange:e=>l({...c,open:e}),children:(0,I.jsxs)(WL,{children:[(0,I.jsxs)(GL,{children:[(0,I.jsx)(qL,{children:c.busy?`Stop running work?`:`Close terminals?`}),(0,I.jsxs)(JL,{children:[c.busy&&`The agent or background tasks are running. Do you really want to stop them? `,c.terminals>0&&`This is the last active thread in this project, so its ${c.terminals} terminal${c.terminals===1?``:`s`} will also be closed.`]})]}),(0,I.jsxs)(KL,{children:[(0,I.jsx)(XL,{children:`Cancel`}),(0,I.jsx)(YL,{variant:`destructive`,onClick:C,children:c.busy?`Stop and Make Inactive`:`Close and Make Inactive`})]})]})}),O=(0,I.jsxs)(CZ,{className:`w-44`,onCloseAutoFocus:e=>{f.current!==null&&(e.preventDefault(),f.current.focus(),f.current.select())},children:[(0,I.jsxs)(wZ,{onSelect:()=>a(t.title),children:[(0,I.jsx)(w,{icon:L_}),`Rename`]}),(0,I.jsxs)(wZ,{onSelect:()=>void hw(t.machine,t.id,{status:t.status===`pinned`?`active`:`pinned`}),children:[(0,I.jsx)(w,{icon:t.status===`pinned`?R_:z_}),t.status===`pinned`?`Unpin`:`Pin`]}),(0,I.jsxs)(wZ,{onSelect:()=>void hw(t.machine,t.id,{status:t.status===`minimized`?`active`:`minimized`}),children:[(0,I.jsx)(w,{icon:t.status===`minimized`?M_:P_}),t.status===`minimized`?`Restore`:`Minimize`]}),t.status===`inactive`?(0,I.jsxs)(wZ,{onSelect:()=>void hw(t.machine,t.id,{status:`active`}),children:[(0,I.jsx)(w,{icon:H_}),`Make active`]}):(0,I.jsxs)(wZ,{onSelect:()=>void T(),children:[(0,I.jsx)(w,{icon:V_}),`Make inactive`]}),(0,I.jsx)(EZ,{}),(0,I.jsxs)(wZ,{variant:`destructive`,title:`Also removes it from ${Tw[t.provider]}`,onSelect:e=>{o?vw(t.machine,t.id):(e.preventDefault(),s(!0))},children:[(0,I.jsx)(w,{icon:p_}),o?`Tap again to delete`:`Delete`]})]}),k=i===null?(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate text-sm`,x?`text-secondary-label font-normal`:`font-medium`,!x&&(e.unseen||h)&&`text-foreground`,!x&&!e.unseen&&!h&&`text-foreground/90`),children:t.title}):(0,I.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&hw(t.machine,t.id,{title:n})},children:(0,I.jsx)(`input`,{ref:f,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),A=P(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,x&&`text-sidebar-muted-foreground/75`,!e.selected&&!x&&`text-sidebar-foreground bg-transparent`);return e.slim?(0,I.jsxs)(`li`,{className:`list-none`,children:[(0,I.jsxs)(xZ,{onOpenChange:()=>s(!1),children:[(0,I.jsx)(SZ,{asChild:!0,disabled:!e.saved,children:(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:P(DZ,A,`flex h-9 items-center gap-2.5 px-2.5`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,I.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale`,children:(0,I.jsx)(qv,{machine:t.machine,projectId:t.projectId})}),k,(0,I.jsx)(`span`,{className:`text-secondary-label ml-auto shrink-0 text-xs tabular-nums`,children:Dw(t.updatedAt)})]})}),O]}),D]}):(0,I.jsxs)(`li`,{className:`relative list-none py-0.5`,children:[u>0&&(0,I.jsx)(`div`,{className:`bg-destructive absolute inset-x-0 inset-y-0.5 flex items-center rounded-md px-4 text-white`,children:(0,I.jsx)(w,{icon:V_,className:`size-6`})}),(0,I.jsxs)(xZ,{onOpenChange:()=>s(!1),children:[(0,I.jsx)(SZ,{asChild:!0,disabled:!e.saved,children:(0,I.jsx)(`div`,{role:`button`,tabIndex:0,className:P(DZ,A,v&&!e.selected&&`opacity-70`,u>0&&`bg-sidebar`),style:u>0?{transform:`translateX(${u}px)`}:void 0,onClick:()=>{m.current?m.current=!1:e.onSelect()},onPointerDown:e=>{S&&e.pointerType===`touch`&&(m.current=!1,p.current={x:e.clientX,y:e.clientY,swiping:!1})},onPointerMove:e=>{let t=p.current;if(t===null)return;let n=e.clientX-t.x,r=e.clientY-t.y;!t.swiping&&Math.abs(n)<10&&Math.abs(r)<10||(!t.swiping&&n<=Math.abs(r)?p.current=null:(t.swiping=!0,d(Math.max(0,n))))},onPointerUp:E,onPointerCancel:()=>{p.current=null,d(0)},onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(qv,{machine:t.machine,projectId:t.projectId,className:`size-5`}),k,t.status===`pinned`&&(0,I.jsx)(w,{icon:z_,className:`text-muted-foreground/65 size-3 shrink-0`}),v&&(0,I.jsx)(`span`,{title:g?`Working`:`Running in background`,className:P(`flex`,g?`text-info`:`text-muted-foreground`),children:(0,I.jsx)(w,{icon:n_,className:`size-4 shrink-0 animate-spin`})}),h&&(0,I.jsx)(`span`,{title:`Waiting for approval`,className:`text-question flex`,children:(0,I.jsx)(w,{icon:Z_,className:`size-4 shrink-0`})}),b&&(0,I.jsx)(`span`,{title:`Done`,className:`text-success flex`,children:(0,I.jsx)(w,{icon:t_,className:`size-4 shrink-0`})})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:r,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:P(`min-w-0 flex-1 truncate`,x?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:Dw(t.updatedAt)})]})]})})}),O]}),D]})}function kZ(e){let t=Bv(e.machine,e.projectId),n=Q(t=>Gv[T9(t,e.machine).icon]);return(0,I.jsx)(`li`,{className:`list-none py-0.5`,children:(0,I.jsx)(`div`,{role:`button`,tabIndex:0,className:P(DZ,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(qv,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,I.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,I.jsx)(w,{icon:ev,className:`text-warning-foreground size-4 shrink-0`})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:n,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}function AZ({className:e,...t}){return(0,I.jsx)(Fx,{"data-slot":`label`,className:P(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var jZ=/\.(png|jpe?g|gif|webp|svg)$/i;function MZ(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(null),s=t?.filter(e=>jZ.test(e)&&e.toLowerCase().includes(r.toLowerCase()));return(0,F.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await L(e.machine,`files.list`,{projectId:e.projectId});t||n(r)}catch(e){t||o(rt(e))}})(),()=>{t=!0}},[e.machine,e.projectId]),(0,I.jsx)(Ke,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(Ne,{className:`gap-0 overflow-hidden p-0 sm:max-w-lg`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,I.jsx)(Ve,{className:`sr-only`,children:`Pick icon`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b p-1`,children:[(0,I.jsxs)(`label`,{className:`flex h-7 min-w-0 flex-1 items-center gap-2.5 px-2`,children:[(0,I.jsx)(w,{icon:W_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`input`,{className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none`,placeholder:`Search images in this project`,value:r,onChange:e=>i(e.target.value)})]}),(0,I.jsx)(Be,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,children:(0,I.jsx)(w,{icon:Kg})})})]}),(0,I.jsxs)(`div`,{className:`h-72 overflow-y-auto p-1`,children:[s?.map(t=>(0,I.jsxs)(`button`,{className:`hover:bg-muted flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm transition-colors`,onClick:async()=>{try{let n=await L(e.machine,`files.read`,{projectId:e.projectId,path:t});n.kind===`image`?e.onPick(`data:${n.mediaType};base64,${n.data}`):n.kind===`large`?o(`${t} is too large`):o(`${t} is not an image`)}catch(e){o(rt(e))}},children:[(0,I.jsx)(w,{icon:k_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-xs`,children:t})]},t)),s?.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground grid h-full place-items-center text-sm`,children:r===``?`No images in this project`:`No matching images`})]}),a!==null&&(0,I.jsx)(`p`,{className:`text-destructive border-t px-3 py-2 text-sm break-all`,children:a})]})})}function NZ(e){let t=Q(e=>e.machines),[n,r]=(0,F.useState)(e.machine),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(()=>PZ(t.find(t=>t.id===e.machine))),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(!1),m=c.trim()===``?void 0:i?.listing,h=m?.directories.filter(e=>e.name.toLowerCase().includes(u.toLowerCase()));function g(e){l(e),d(``)}return(0,F.useEffect)(()=>{if(c.trim()===``)return;let e=!1,t=setTimeout(async()=>{try{let t=await L(n,`directories.list`,{path:c});if(e)return;a({path:c,listing:t}),s(null)}catch(t){if(e)return;a(null),s(rt(t))}},150);return()=>{e=!0,clearTimeout(t)}},[n,c]),(0,I.jsx)(Ke,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(Ne,{className:`gap-0 overflow-hidden p-0 sm:max-w-lg`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,I.jsx)(Ve,{className:`sr-only`,children:`Add project`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b p-1`,children:[(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Home folder`,onClick:()=>g(`~`),children:(0,I.jsx)(w,{icon:nee})}),(0,I.jsx)(`div`,{className:`bg-border mx-0.5 h-4 w-px`}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Parent folder`,disabled:m?.parent===void 0||m.parent===null,onClick:()=>{m?.parent!==void 0&&m.parent!==null&&g(m.parent)},children:(0,I.jsx)(w,{icon:Bg})}),(0,I.jsx)(`input`,{"aria-label":`Folder path`,className:`hover:bg-muted focus:bg-muted h-7 min-w-0 flex-1 rounded-md bg-transparent px-1.5 font-mono text-xs outline-none`,spellCheck:!1,value:c,onChange:e=>g(e.target.value)}),(0,I.jsx)(Be,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,children:(0,I.jsx)(w,{icon:Kg})})})]}),(0,I.jsxs)(`label`,{className:`flex h-9 items-center gap-2.5 border-b px-3`,children:[(0,I.jsx)(w,{icon:W_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`input`,{className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none`,placeholder:`Search this folder`,value:u,onChange:e=>d(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`h-72 overflow-y-auto p-1`,children:[h?.map(e=>(0,I.jsxs)(`button`,{className:`hover:bg-muted flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm transition-colors`,onClick:()=>g(e.path),children:[(0,I.jsx)(w,{icon:b_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),h?.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground grid h-full place-items-center text-sm`,children:u===``?`No folders here`:`No matching folders`})]}),o!==null&&c.trim()!==``&&(0,I.jsx)(`p`,{className:`text-destructive border-t px-3 py-2 text-sm break-all`,children:o}),(0,I.jsxs)(qe,{className:`border-t p-3`,children:[t.length>1&&(0,I.jsxs)(AL,{value:n,onValueChange:e=>{r(e),a(null),g(PZ(t.find(t=>t.id===e)))},children:[(0,I.jsx)(ML,{className:`sm:mr-auto sm:w-56`,children:(0,I.jsx)(jL,{})}),(0,I.jsx)(NL,{children:t.map(e=>(0,I.jsx)(PL,{value:e.id,disabled:e.status!==`online`,children:e.name},e.id))})]}),(0,I.jsx)(x,{disabled:i?.path!==c||f,onClick:async()=>{if(i!==null&&i.path===c){p(!0);try{e.onAdd({...await Vv(n,i.listing.path),machine:n})}catch(e){s(rt(e)),p(!1)}}},children:`Add project`})]})]})})}function PZ(e){return e===void 0||e.config===null||e.system===null?`~`:e.config.workingDir[e.system.platform]??`~`}function FZ(e){let t=e.project.path,[n,r]=(0,F.useState)(e.project.name),[i,a]=(0,F.useState)(e.project.logo),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),m=(0,F.useRef)(null);return(0,I.jsx)(Ke,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(Ne,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,children:[(0,I.jsxs)(`form`,{className:`grid`,onSubmit:async t=>{t.preventDefault(),l(!0);try{await Hv(e.project.machine,e.project.id,{name:n,logo:i}),e.onClose()}catch(e){s(rt(e)),l(!1)}},children:[(0,I.jsxs)(Fe,{className:`gap-1 px-6 pt-4 pr-12`,children:[(0,I.jsx)(Ve,{className:`text-base`,children:`Edit project`}),(0,I.jsx)(We,{className:`truncate font-mono text-xs`,title:t,children:t})]}),(0,I.jsxs)(`div`,{className:`grid gap-6 p-6`,children:[(0,I.jsxs)(`div`,{className:`grid gap-2.5`,children:[(0,I.jsx)(AZ,{children:`Icon`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,I.jsx)(Jv,{name:n.trim()===``?Ew(t):n,logo:i,className:`ring-foreground/10 size-16 rounded-2xl ring-1 [&>img]:rounded-2xl [&>svg]:rounded-2xl`}),(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,title:`Upload an image from this device`,onClick:()=>m.current?.click(),children:[(0,I.jsx)(w,{icon:lv}),`Upload`]}),(0,I.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,title:`Choose an image from the project on the server`,onClick:()=>p(!0),children:[(0,I.jsx)(w,{icon:b_}),`Choose from project`]}),i!==null&&(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`sm`,onClick:()=>a(null),children:`Remove`})]}),(0,I.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`PNG, JPG, GIF, WebP, SVG or ICO, up to 384 KB`})]})]}),(0,I.jsx)(`input`,{ref:m,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp,image/svg+xml,image/x-icon`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&a(`data:${t.type};base64,${await qC(t)}`)}})]}),(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsx)(AZ,{htmlFor:`project-name`,children:`Name`}),(0,I.jsx)(kL,{id:`project-name`,placeholder:Ew(t),value:n,onChange:e=>r(e.target.value)})]}),o!==null&&(0,I.jsx)(`p`,{className:`text-destructive text-sm break-all`,children:o})]}),(0,I.jsxs)(qe,{className:`bg-muted/40 border-t px-6 py-4`,children:[(0,I.jsxs)(x,{type:`button`,variant:u?`destructive`:`ghost`,className:P(`sm:mr-auto`,!u&&`text-destructive hover:bg-destructive/10 hover:text-destructive`),title:`Its threads stay in their provider`,onClick:async()=>{if(!u)d(!0);else try{await Uv(e.project.machine,e.project.id),e.onRemoved()}catch(e){s(rt(e))}},children:[(0,I.jsx)(w,{icon:p_,className:`text-current`}),u?`Click again to remove`:`Remove project`]}),(0,I.jsx)(x,{type:`button`,variant:`outline`,onClick:e.onClose,children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,disabled:n.trim()===``||c,children:`Save`})]})]}),f&&(0,I.jsx)(MZ,{machine:e.project.machine,projectId:e.project.id,onClose:()=>p(!1),onPick:e=>{a(e),p(!1)}})]})})}function IZ(e){let t=Q(e=>e.machines),n=Q(e=>e.projects),r=Q(e=>e.sessions),i=Q(e=>e.unseen),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(null),l=(0,F.useRef)(!1),u=t.map(e=>({machine:e,projects:n.filter(t=>t.machine===e.id).sort((t,n)=>s!==null&&s.machine===e.id?s.ids.indexOf(t.id)-s.ids.indexOf(n.id):0)})).filter(e=>e.projects.length>0),d=r.filter(e=>{let n=k9(t,e.machine,e.id);return n?.running===!0||n?.waiting===!0||Object.values(n?.tasks??{}).includes(`running`)||i.includes(f9(e.machine,e.id))});function f(e,t){return n.find(n=>n.machine===e&&n.id===t)}function p(e){return e.status===`online`?e.name:e.status===`unpaired`?`${e.name} · needs pairing`:`${e.name} · offline`}return(0,I.jsxs)(MC,{open:a,onOpenChange:o,children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`hover:bg-sidebar-row-hover data-[state=open]:bg-sidebar-row-hover -ml-1.5 flex h-7 min-w-0 cursor-pointer items-center gap-1.5 rounded-[var(--control-radius)] px-1.5 text-sm font-medium`,title:e.scope===null?`Inbox`:f(e.scope.machine,e.scope.projectId)?.path,children:[e.scope===null?(0,I.jsx)(w,{icon:A_,className:`size-4 shrink-0 text-(--sidebar-icon-color)`}):(0,I.jsx)(qv,{machine:e.scope.machine,projectId:e.scope.projectId,className:`size-4 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.scope===null?`Inbox`:f(e.scope.machine,e.scope.projectId)?.name}),(0,I.jsx)(w,{icon:Zg,className:`text-sidebar-muted-foreground size-3.5 shrink-0`})]})}),(0,I.jsxs)(FC,{className:`w-64`,children:[(0,I.jsxs)(RC,{value:e.scope===null?``:f9(e.scope.machine,e.scope.projectId),children:[(0,I.jsxs)(zC,{value:``,className:`pr-9 pl-8 *:data-[slot=dropdown-menu-radio-item-indicator]:right-auto *:data-[slot=dropdown-menu-radio-item-indicator]:left-2`,onSelect:()=>e.onScope(null),children:[(0,I.jsx)(w,{icon:A_}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Inbox`}),d.length>0&&(0,I.jsx)(`span`,{className:`text-foreground grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,children:d.length})]}),u.length>0&&(0,I.jsx)(VC,{}),u.map(({machine:n,projects:r},i)=>(0,I.jsxs)(F.Fragment,{children:[i>0&&(0,I.jsx)(VC,{}),t.length>1&&(0,I.jsxs)(BC,{className:`text-2xs flex items-center gap-1 pl-5`,children:[(0,I.jsx)(w,{icon:Gv[n.icon],className:`size-3 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:p(n)})]}),(0,I.jsx)(BY,{as:`div`,axis:`y`,values:r.map(e=>e.id),onReorder:e=>c({machine:n.id,ids:e}),children:r.map(t=>{let n=d.filter(e=>e.machine===t.machine&&e.projectId===t.id).length;return(0,I.jsx)(eX,{as:`div`,value:t.id,className:`relative`,onDragStart:()=>{l.current=!0},onDragEnd:async()=>{if(s!==null){try{await Wv(s.machine,s.ids)}catch(e){R9(e)}c(null)}},children:(0,I.jsxs)(zC,{value:f9(t.machine,t.id),title:t.path,className:`group/project pr-2 pl-8 *:data-[slot=dropdown-menu-radio-item-indicator]:right-auto *:data-[slot=dropdown-menu-radio-item-indicator]:left-2`,onPointerDown:()=>{l.current=!1},onSelect:n=>{l.current?n.preventDefault():e.onScope({machine:t.machine,projectId:t.id})},onContextMenu:n=>{n.preventDefault(),o(!1),e.onEdit(t)},children:[(0,I.jsx)(qv,{machine:t.machine,projectId:t.id,className:`size-5 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name}),n>0&&(0,I.jsx)(`span`,{className:`text-foreground grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,children:n}),(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground hover:bg-foreground/10 -my-0.5 grid size-5 shrink-0 cursor-pointer place-items-center rounded-sm opacity-0 transition-opacity group-data-highlighted/project:opacity-100 pointer-coarse:opacity-100 [&_svg]:size-3.5`,title:`Configure project`,"aria-label":`Configure ${t.name}`,onClick:n=>{n.stopPropagation(),o(!1),e.onEdit(t)},children:(0,I.jsx)(w,{icon:q_})})]})},f9(t.machine,t.id))})})]},n.id))]}),(0,I.jsx)(VC,{}),(0,I.jsxs)(IC,{className:`pl-8`,onSelect:e.onAddProject,children:[(0,I.jsx)(w,{icon:kg}),`Add project…`]}),(0,I.jsxs)(IC,{className:`pl-8`,onSelect:e.onAddMachine,children:[(0,I.jsx)(w,{icon:l_}),`Add machine…`]})]})]})}function LZ(e){let t=Q(e=>e.errors),n=Q(e=>e.machines),r=Q(e=>e.sessions),i=Q(e=>e.unseen),a=n.filter(e=>e.status===`offline`||e.status===`unpaired`),o=r.filter(e=>Object.values(k9(n,e.machine,e.id)?.tasks??{}).includes(`failed`)),s=r.filter(e=>k9(n,e.machine,e.id)?.waiting===!0),c=r.filter(e=>{let t=k9(n,e.machine,e.id);return i.includes(f9(e.machine,e.id))&&t?.waiting!==!0&&t?.running!==!0&&!Object.values(t?.tasks??{}).includes(`running`)}),l=t.length+a.length+o.length,u=!e.hideDone&&c.length>0;return l===0&&s.length===0&&!u?null:(0,I.jsxs)(`div`,{className:P(`flex shrink-0 items-center gap-1`,e.className),children:[u&&(0,I.jsx)(RZ,{className:`bg-success/15 text-success`,icon:t_,count:c.length,label:`${c.length} done`,children:c.map(e=>(0,I.jsx)(BZ,{session:e,icon:t_,className:`text-success`,detail:`Done`},f9(e.machine,e.id)))}),s.length>0&&(0,I.jsx)(RZ,{className:`bg-question/15 text-question`,icon:Z_,count:s.length,label:`${s.length} waiting for approval`,children:s.map(e=>(0,I.jsx)(BZ,{session:e,icon:Z_,className:`text-question`,detail:`Waiting for approval`},f9(e.machine,e.id)))}),l>0&&(0,I.jsxs)(RZ,{className:P(t.length>0&&`bg-error/15 text-error`,t.length===0&&`bg-warning/15 text-warning-foreground`),icon:t.length>0?jg:Ag,count:l,label:l===1?`1 problem`:`${l} problems`,onClose:bue,children:[t.map((e,t)=>(0,I.jsx)(zZ,{icon:jg,className:`text-error`,children:(0,I.jsx)(`span`,{className:`text-error-foreground whitespace-pre-wrap`,children:e})},t)),a.map(e=>(0,I.jsxs)(zZ,{icon:Ag,className:`text-warning-foreground`,children:[e.status===`offline`&&`${e.name} is offline`,e.status===`unpaired`&&`${e.name} needs pairing`]},e.id)),o.map(e=>(0,I.jsx)(BZ,{session:e,icon:Ag,className:`text-warning-foreground`,detail:`Background task failed`},f9(e.machine,e.id)))]})]})}function RZ(e){return(0,I.jsxs)(fL,{onOpenChange:t=>!t&&e.onClose?.(),children:[(0,I.jsx)(pL,{asChild:!0,children:(0,I.jsxs)(`button`,{className:P(`flex h-5 shrink-0 cursor-pointer items-center gap-0.75 rounded-[6px] px-1.25 text-[11px] font-medium tabular-nums`,e.className),title:e.label,"aria-label":e.label,children:[(0,I.jsx)(w,{icon:e.icon,className:`size-3 shrink-0`}),e.count]})}),(0,I.jsx)(mL,{align:`end`,collisionPadding:12,className:`flex max-h-80 w-[min(20rem,calc(100vw-2rem))] flex-col gap-px overflow-y-auto p-1 text-sm`,children:e.children})]})}function zZ(e){return(0,I.jsxs)(`div`,{className:`flex items-start gap-2 px-2 py-1.5`,children:[(0,I.jsx)(w,{icon:e.icon,className:P(`mt-0.5 size-4 shrink-0`,e.className)}),(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children})]})}function BZ(e){return(0,I.jsx)(oS,{asChild:!0,children:(0,I.jsx)(`button`,{className:`hover:bg-accent cursor-pointer rounded-md text-left`,onClick:()=>rw({machine:e.session.machine,projectId:e.session.projectId,sessionId:e.session.id}),children:(0,I.jsxs)(zZ,{icon:e.icon,className:e.className,children:[(0,I.jsx)(`div`,{className:`text-foreground truncate`,children:e.session.title}),(0,I.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:e.detail})]})})})}var VZ=`text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground flex shrink-0 cursor-pointer items-center justify-center rounded-[var(--control-radius)] [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-(--sidebar-icon-color) hover:[&>svg]:text-sidebar-foreground`;function HZ(e){let t=Q(e=>e.selection),n=Q(e=>e.machines),r=Q(e=>e.sessions),i=Q(e=>e.projects),a=Q(e=>e.settings.provider),o=Q(e=>e.unseen),s=Q(e=>e.loaded),c=Q(e=>e.inactive),l=Q(e=>e.inactiveVersion),[u,d]=Iv(`sidebarScope`,null),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)(null),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)(`active`),[T,E]=Iv(`sidebarWidth`,240),D=r.filter(e=>u===null||e.machine===u.machine&&e.projectId===u.projectId).sort((e,t)=>t.updatedAt-e.updatedAt),O=[...D.filter(e=>e.status===`pinned`),...D.filter(e=>e.status===`active`)],k=D.filter(e=>e.status===`minimized`),A=e.mobile?S===`inactive`:b,ee=u?.machine??null,j=u?.projectId??null,M=t!==null&&t.sessionId!==null&&s&&!r.some(e=>e.machine===t.machine&&e.id===t.sessionId)?{machine:t.machine,id:t.sessionId,provider:a,title:`New thread`,projectId:t.projectId,branch:null,updatedAt:Date.now(),status:`active`}:null,te=e.mobile?kZ:yZ;(0,F.useEffect)(()=>{if(!A)return;let e=!0,t=ee===null?Z().machines.filter(e=>e.status===`online`).map(e=>e.id):[ee];return Promise.all(t.map(async e=>(await L(e,`sessions.inactive`,{projectId:j})).map(t=>({...t,machine:e})))).then(t=>{e&&$({inactive:t.flat()})}).catch(R9),()=>{e=!1}},[A,ee,j,l]);let ne=u?.machine??t?.machine??n.at(0)?.id;function re(e,t,n){rw({machine:e,projectId:t,sessionId:n})}function ie(){let e=u??t??ae();e===null?p(!0):re(e.machine,e.projectId,null)}function ae(){let e=localStorage.getItem(`lastProject`),t=e===null?null:JSON.parse(e),n=(t===null?void 0:i.find(e=>e.machine===t.machine&&e.id===t.projectId))??i.at(0);return n===void 0?null:{machine:n.machine,projectId:n.id}}Av([`mod+n`,`mod+t`],ie,{enableOnFormTags:!0,preventDefault:!0});function oe(e){let t=e.clientX-T;nt(e,e=>{let n=Math.min(480,Math.max(200,e.clientX-t));E(n)})}function se(r,i){let a=e.mobile?OZ:vZ;return(0,I.jsx)(a,{session:r,slim:i,selected:t?.machine===r.machine&&t.sessionId===r.id,activity:k9(n,r.machine,r.id),unseen:o.includes(f9(r.machine,r.id)),saved:r!==M,scope:u,onSelect:()=>re(r.machine,r.projectId,r.id)},f9(r.machine,r.id))}function ce(e,t,n,r,i){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`li`,{className:P(`mx-0.5 h-9 pt-2`,i&&`mt-auto`),children:(0,I.jsxs)(`button`,{"aria-expanded":n,className:`text-sidebar-muted-foreground/60 flex h-9 w-full cursor-pointer items-center gap-2 rounded-md px-2 text-left text-xs font-medium`,onClick:r,children:[(0,I.jsx)(`span`,{className:`shrink-0`,children:e}),(0,I.jsx)(`span`,{className:`bg-sidebar-border/60 h-px min-w-2 flex-1`}),(0,I.jsx)(w,{icon:Zg,className:P(`size-3 shrink-0 transition-transform`,!n&&`rotate-180`)})]})}),n&&t.map(e=>se(e,e.status===`inactive`))]})}return(0,I.jsxs)(`aside`,{className:P(`bg-sidebar text-sidebar-foreground border-sidebar-border flex flex-none border-r select-none`,e.className),children:[(0,I.jsxs)(`div`,{className:P(`relative flex min-w-0 flex-col`,e.mobile&&`flex-1`),style:e.mobile?void 0:{width:T},children:[(0,I.jsxs)(`div`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-2 px-3`,children:[e.mobile?(0,I.jsx)(bZ,{className:P(VZ,`size-7`),filter:S,onFilter:C}):(0,I.jsx)(`button`,{className:P(VZ,`size-7`),title:`Hide sidebar (${et}+B)`,"aria-label":`Hide sidebar`,onClick:e.onHide,children:(0,I.jsx)(w,{icon:xee})}),(0,I.jsx)(IZ,{scope:u,onScope:d,onEdit:_,onAddProject:()=>p(!0),onAddMachine:()=>h(!0)}),e.mobile&&(0,I.jsx)(LZ,{hideDone:!0}),(0,I.jsx)(`button`,{className:P(VZ,`ml-auto size-7`),title:`Search (${et}+K)`,"aria-label":`Search`,onClick:()=>P9(!0),children:(0,I.jsx)(w,{icon:W_})}),(0,I.jsx)(`button`,{className:P(VZ,`size-7`),title:`New thread (${et}+N)`,onClick:ie,children:(0,I.jsx)(w,{icon:ev})})]}),(0,I.jsx)(`nav`,{className:`flex min-h-0 flex-1 [scrollbar-width:none] flex-col overflow-y-auto px-(--sidebar-content-inset) pb-(--sidebar-content-inset)`,children:(0,I.jsxs)(`ul`,{className:`flex flex-1 flex-col gap-px`,children:[e.mobile&&S!==`active`&&(0,I.jsxs)(I.Fragment,{children:[(S===`minimized`?k:c).map(e=>se(e,S===`inactive`)),(S===`minimized`?k:c).length===0&&(0,I.jsxs)(`li`,{className:`text-sidebar-muted-foreground/60 px-2.5 py-6 text-center text-xs`,children:[`No `,S,` threads`]})]}),(!e.mobile||S===`active`)&&(0,I.jsxs)(I.Fragment,{children:[t!==null&&t.sessionId===null&&(0,I.jsx)(te,{machine:t.machine,projectId:t.projectId,onSelect:()=>re(t.machine,t.projectId,null)}),M!==null&&se(M,!1),O.map(e=>se(e,!1)),O.length===0&&M===null&&t?.sessionId!==null&&(0,I.jsx)(`li`,{className:`text-sidebar-muted-foreground/60 px-2.5 py-6 text-center text-xs`,children:`No threads yet`})]}),!e.mobile&&(0,I.jsxs)(I.Fragment,{children:[k.length>0&&ce(v?`Minimized`:`Minimized (${k.length})`,k,v,()=>y(!v),!0),ce(`Inactive`,c,b,()=>x(!b),k.length===0)]})]})}),!e.mobile&&(0,I.jsxs)(`div`,{className:`border-sidebar-border @container flex shrink-0 items-center gap-1 border-t p-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`button`,{className:P(VZ,`h-8 flex-1 justify-start gap-2 px-2.5 text-sm`),title:`Settings`,onClick:()=>F9(!0),children:[(0,I.jsx)(w,{icon:q_}),(0,I.jsx)(`span`,{className:`hidden @min-[15rem]:inline`,children:`Settings`})]}),(0,I.jsx)(LZ,{hideDone:!1})]}),!e.mobile&&(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize select-none`,onPointerDown:oe,children:(0,I.jsx)(`span`,{className:`group-hover:bg-border group-active:bg-primary/60 pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-colors`})})]}),f&&ne===void 0&&(0,I.jsx)(nX,{onClose:()=>p(!1)}),f&&ne!==void 0&&(0,I.jsx)(NZ,{machine:ne,onClose:()=>p(!1),onAdd:e=>{p(!1),d({machine:e.machine,projectId:e.id}),re(e.machine,e.id,null)}}),m&&(0,I.jsx)(nX,{onClose:()=>h(!1)}),g!==null&&(0,I.jsx)(FZ,{project:g,onClose:()=>_(null),onRemoved:()=>{u?.machine===g.machine&&u.projectId===g.id&&d(null),_(null)}})]})}var UZ=`/assets/ghostty-vt-CQAu1Gs5.wasm`,WZ=Uint8Array,GZ=Uint16Array,KZ=Int32Array,qZ=new WZ([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),JZ=new WZ([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),YZ=new WZ([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),XZ=function(e,t){for(var n=new GZ(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new KZ(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},ZZ=XZ(qZ,2),QZ=ZZ.b,$Z=ZZ.r;QZ[28]=258,$Z[258]=28;var eQ=XZ(JZ,0),tQ=eQ.b;eQ.r;for(var nQ=new GZ(32768),rQ=0;rQ<32768;++rQ){var iQ=(rQ&43690)>>1|(rQ&21845)<<1;iQ=(iQ&52428)>>2|(iQ&13107)<<2,iQ=(iQ&61680)>>4|(iQ&3855)<<4,nQ[rQ]=((iQ&65280)>>8|(iQ&255)<<8)>>1}for(var aQ=(function(e,t,n){for(var r=e.length,i=0,a=new GZ(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new GZ(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new GZ(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[nQ[d]>>c]=l}else for(s=new GZ(r),i=0;i<r;++i)e[i]&&(s[i]=nQ[o[e[i]-1]++]>>15-e[i]);return s}),oQ=new WZ(288),rQ=0;rQ<144;++rQ)oQ[rQ]=8;for(var rQ=144;rQ<256;++rQ)oQ[rQ]=9;for(var rQ=256;rQ<280;++rQ)oQ[rQ]=7;for(var rQ=280;rQ<288;++rQ)oQ[rQ]=8;for(var sQ=new WZ(32),rQ=0;rQ<32;++rQ)sQ[rQ]=5;var cQ=aQ(oQ,9,1),lQ=aQ(sQ,5,1),uQ=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},dQ=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},fQ=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},pQ=function(e){return(e+7)/8|0},mQ=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new WZ(e.subarray(t,n))},hQ=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],gQ=function(e,t,n){var r=Error(t||hQ[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,gQ),!n)throw r;return r},_Q=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new WZ(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new WZ(i*3));var l=function(e){var t=n.length;if(e>t){var r=new WZ(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=dQ(e,d,1);var v=dQ(e,d+1,3);if(d+=3,!v){var y=pQ(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&gQ(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=cQ,m=lQ,h=9,g=5;else if(v==2){var S=dQ(e,d,31)+257,C=dQ(e,d+10,15)+4,w=S+dQ(e,d+5,31)+1;d+=14;for(var T=new WZ(w),E=new WZ(19),D=0;D<C;++D)E[YZ[D]]=dQ(e,d+D*3,7);d+=C*3;for(var O=uQ(E),k=(1<<O)-1,A=aQ(E,O,1),D=0;D<w;){var ee=A[dQ(e,d,k)];d+=ee&15;var y=ee>>4;if(y<16)T[D++]=y;else{var j=0,M=0;for(y==16?(M=3+dQ(e,d,3),d+=2,j=T[D-1]):y==17?(M=3+dQ(e,d,7),d+=3):y==18&&(M=11+dQ(e,d,127),d+=7);M--;)T[D++]=j}}var te=T.subarray(0,S),ne=T.subarray(S);h=uQ(te),g=uQ(ne),p=aQ(te,h,1),m=aQ(ne,g,1)}else gQ(1);if(d>_){c&&gQ(0);break}}s&&l(f+131072);for(var re=(1<<h)-1,ie=(1<<g)-1,ae=d;;ae=d){var j=p[fQ(e,d)&re],oe=j>>4;if(d+=j&15,d>_){c&&gQ(0);break}if(j||gQ(2),oe<256)n[f++]=oe;else if(oe==256){ae=d,p=null;break}else{var se=oe-254;if(oe>264){var D=oe-257,ce=qZ[D];se=dQ(e,d,(1<<ce)-1)+QZ[D],d+=ce}var le=m[fQ(e,d)&ie],ue=le>>4;le||gQ(3),d+=le&15;var ne=tQ[ue];if(ue>3){var ce=JZ[ue];ne+=fQ(e,d)&(1<<ce)-1,d+=ce}if(d>_){c&&gQ(0);break}s&&l(f+131072);var de=f+se;if(f<ne){var fe=a-ne,pe=Math.min(ne,de);for(fe+f<0&&gQ(3);f<pe;++f)n[f]=r[fe+f]}for(;f<de;++f)n[f]=n[f-ne]}}t.l=p,t.p=ae,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?mQ(n,0,f):n.subarray(0,f)},vQ=new WZ(0),yQ=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&gQ(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&gQ(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2},bQ=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new WZ(32768),this.p=new WZ(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||gQ(5),this.d&&gQ(4),!this.p.length)this.p=e;else if(e.length){var t=new WZ(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=_Q(this.p,this.s,this.o);this.ondata(mQ(n,t,this.s.b),this.d),this.o=mQ(n,this.s.b-32768),this.s.b=this.o.length,this.p=mQ(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),xQ=function(){function e(e,t){bQ.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(bQ.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(yQ(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&gQ(6,`invalid zlib data`),this.p=this.p.subarray(0,-4)),bQ.prototype.c.call(this,t)},e}();function SQ(e,t){return _Q(e.subarray(yQ(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var CQ=typeof TextDecoder<`u`&&new TextDecoder;try{CQ.decode(vQ,{stream:!0})}catch{}function wQ(e,t=`utf8`){return new TextDecoder(t).decode(e)}var TQ=new TextEncoder;function EQ(e){return TQ.encode(e)}var DQ=8192,OQ=(()=>{let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),kQ={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array},AQ=class e{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=DQ,n={}){let r=!1;typeof t==`number`?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);let i=n.offset?n.offset>>>0:0,a=t.byteLength-i,o=i;(ArrayBuffer.isView(t)||t instanceof e)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),this.lastWrittenByte=r?a:0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw Error(`Mark stack empty`);return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let t=(this.offset+e)*2,n=new Uint8Array(t);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=t,this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,`uint8`)}readArray(e,t){let n=kQ[t].BYTES_PER_ELEMENT*e,r=this.byteOffset+this.offset,i=this.buffer.slice(r,r+n);if(this.littleEndian===OQ&&t!==`uint8`&&t!==`int8`){let e=new Uint8Array(this.buffer.slice(r,r+n));e.reverse();let i=new kQ[t](e.buffer);return this.offset+=n,i.reverse(),i}let a=new kQ[t](i);return this.offset+=n,a}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){let e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){let e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t=``;for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return wQ(this.readBytes(e))}decodeText(e=1,t=`utf8`){return wQ(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(EQ(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}},jQ=[];for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;jQ[e]=t}var MQ=4294967295;function NQ(e,t,n){let r=e;for(let e=0;e<n;e++)r=jQ[(r^t[e])&255]^r>>>8;return r}function PQ(e,t){return(NQ(MQ,e,t)^MQ)>>>0}function FQ(e,t,n){let r=e.readUint32(),i=PQ(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(i!==r)throw Error(`CRC mismatch for chunk ${n}. Expected ${r}, found ${i}`)}function IQ(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}function LQ(e,t,n,r){let i=0;for(;i<r;i++)t[i]=e[i];for(;i<n;i++)t[i]=e[i]+t[i-r]&255}function RQ(e,t,n,r){let i=0;if(n.length===0)for(;i<r;i++)t[i]=e[i];else for(;i<r;i++)t[i]=e[i]+n[i]&255}function zQ(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+(t[a-i]>>1)&255}else{for(;a<i;a++)t[a]=e[a]+(n[a]>>1)&255;for(;a<r;a++)t[a]=e[a]+(t[a-i]+n[a]>>1)&255}}function BQ(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+t[a-i]&255}else{for(;a<i;a++)t[a]=e[a]+n[a]&255;for(;a<r;a++)t[a]=e[a]+VQ(t[a-i],n[a],n[a-i])&255}}function VQ(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function HQ(e,t,n,r,i,a){switch(e){case 0:IQ(t,n,i);break;case 1:LQ(t,n,i,a);break;case 2:RQ(t,n,r,i);break;case 3:zQ(t,n,r,i,a);break;case 4:BQ(t,n,r,i,a);break;default:throw Error(`Unsupported filter: ${e}`)}}var UQ=new Uint16Array([255]),WQ=new Uint8Array(UQ.buffer)[0]===255;function GQ(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],s=Math.ceil(a/8)*i,c=new Uint8Array(r*n*s),l=0;for(let e=0;e<7;e++){let i=o[e],a=Math.ceil((n-i.x)/i.xStep),u=Math.ceil((r-i.y)/i.yStep);if(a<=0||u<=0)continue;let d=a*s,f=new Uint8Array(d);for(let e=0;e<u;e++){let o=t[l++],u=t.subarray(l,l+d);l+=d;let p=new Uint8Array(d);HQ(o,u,p,f,d,s),f.set(p);for(let t=0;t<a;t++){let a=i.x+t*i.xStep,o=i.y+e*i.yStep;if(!(a>=n||o>=r))for(let e=0;e<s;e++)c[(o*n+a)*s+e]=p[t*s+e]}}}if(a===16){let e=new Uint16Array(c.buffer);if(WQ)for(let t=0;t<e.length;t++)e[t]=KQ(e[t]);return e}return c}function KQ(e){return(e&255)<<8|e>>8&255}var qQ=new Uint16Array([255]),JQ=new Uint8Array(qQ.buffer)[0]===255,YQ=new Uint8Array;function XQ(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=Math.ceil(a/8)*i,s=Math.ceil(a/8*i*n),c=new Uint8Array(r*s),l=YQ,u=0,d,f;for(let e=0;e<r;e++){switch(d=t.subarray(u+1,u+1+s),f=c.subarray(e*s,(e+1)*s),t[u]){case 0:IQ(d,f,s);break;case 1:LQ(d,f,s,o);break;case 2:RQ(d,f,l,s);break;case 3:zQ(d,f,l,s,o);break;case 4:BQ(d,f,l,s,o);break;default:throw Error(`Unsupported filter: ${t[u]}`)}l=f,u+=s+1}if(a===16){let e=new Uint16Array(c.buffer);if(JQ)for(let t=0;t<e.length;t++)e[t]=ZQ(e[t]);return e}return c}function ZQ(e){return(e&255)<<8|e>>8&255}var QQ=Uint8Array.of(137,80,78,71,13,10,26,10);function $Q(e){if(!e$(e.readBytes(QQ.length)))throw Error(`wrong PNG signature`)}function e$(e){if(e.length<QQ.length)return!1;for(let t=0;t<QQ.length;t++)if(e[t]!==QQ[t])return!1;return!0}var t$=`tEXt`,n$=0,r$=new TextDecoder(`latin1`);function i$(e){if(o$(e),e.length===0||e.length>79)throw Error(`keyword length must be between 1 and 79`)}var a$=/^[\u0000-\u00FF]*$/;function o$(e){if(!a$.test(e))throw Error(`invalid latin1 text`)}function s$(e,t,n){let r=c$(t);e[r]=l$(t,n-r.length-1)}function c$(e){for(e.mark();e.readByte()!==n$;);let t=e.offset;e.reset();let n=r$.decode(e.readBytes(t-e.offset-1));return e.skip(1),i$(n),n}function l$(e,t){return r$.decode(e.readBytes(t))}var u$={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},d$={UNKNOWN:-1,DEFLATE:0},f$={UNKNOWN:-1,ADAPTIVE:0},p$={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},m$={NONE:0,BACKGROUND:1,PREVIOUS:2},h$={SOURCE:0,OVER:1},g$=class extends AQ{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;_chunks;_inflatorResult;constructor(e,t={}){super(e);let{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new xQ((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._png={width:-1,height:-1,channels:-1,data:new Uint8Array,depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array,this._compressionMethod=d$.UNKNOWN,this._filterMethod=f$.UNKNOWN,this._interlaceMethod=p$.UNKNOWN,this._colorType=u$.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this._inflatorResult=new Uint8Array,this.setBigEndian()}decode(){for($Q(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this._inflator.push(new Uint8Array,!0),this.decodeImage(),this._png}decodeApng(){for($Q(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){let n=this.offset;switch(t){case`IHDR`:this.decodeIHDR();break;case`PLTE`:this.decodePLTE(e);break;case`IDAT`:this.decodeIDAT(e);break;case`IEND`:this._end=!0;break;case`tRNS`:this.decodetRNS(e);break;case`iCCP`:this.decodeiCCP(e);break;case t$:s$(this._png.text,this,e);break;case`pHYs`:this.decodepHYs();break;default:this.skip(e)}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?FQ(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){let n=this.offset;switch(t!==`fdAT`&&t!==`IDAT`&&this._writingDataChunks&&this.pushDataToFrame(),t){case`acTL`:this.decodeACTL();break;case`fcTL`:this.decodeFCTL();break;case`fdAT`:this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?FQ(this,e+4,t):this.skip(4)}decodeIHDR(){let e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=_$(this.readUint8());let t=this.readUint8();this._colorType=t;let n;switch(t){case u$.GREYSCALE:n=1;break;case u$.TRUECOLOUR:n=3;break;case u$.INDEXED_COLOUR:n=1;break;case u$.GREYSCALE_ALPHA:n=2;break;case u$.TRUECOLOUR_ALPHA:n=4;break;case u$.UNKNOWN:default:throw Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==d$.DEFLATE)throw Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){let e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array};this._frames.push(e)}decodePLTE(e){if(e%3!=0)throw RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);let t=e/3;this._hasPalette=!0;let n=[];this._palette=n;for(let e=0;e<t;e++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;n+=4,t-=4;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodetRNS(e){switch(this._colorType){case u$.GREYSCALE:case u$.TRUECOLOUR:if(e%2!=0)throw RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break;case u$.INDEXED_COLOUR:{if(e>this._palette.length)throw Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){let e=this.readByte();this._palette[t].push(e)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case u$.UNKNOWN:case u$.GREYSCALE_ALPHA:case u$.TRUECOLOUR_ALPHA:default:throw Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){let t=c$(this),n=this.readUint8();if(n!==d$.DEFLATE)throw Error(`Unsupported iCCP compression method: ${n}`);let r=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:SQ(r)}}decodepHYs(){let e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){let t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=XQ({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{let r=this._apng.frames.at(e-1);this.disposeFrame(n,r,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case m$.NONE:break;case m$.BACKGROUND:for(let t=0;t<this._png.height;t++)for(let r=0;r<this._png.width;r++){let i=(t*e.width+r)*this._png.channels;for(let e=0;e<this._png.channels;e++)n.data[i+e]=0}break;case m$.PREVIOUS:n.data.set(t.data);break;default:throw Error(`Unknown disposeOp`)}}addFrameDataToCanvas(e,t){let n=1<<this._png.depth,r=(e,n)=>({index:((e+t.yOffset)*this._png.width+t.xOffset+n)*this._png.channels,frameIndex:(e*t.width+n)*this._png.channels});switch(t.blendOp){case h$.SOURCE:for(let n=0;n<t.height;n++)for(let i=0;i<t.width;i++){let{index:a,frameIndex:o}=r(n,i);for(let n=0;n<this._png.channels;n++)e.data[a+n]=t.data[o+n]}break;case h$.OVER:for(let i=0;i<t.height;i++)for(let a=0;a<t.width;a++){let{index:o,frameIndex:s}=r(i,a);for(let r=0;r<this._png.channels;r++){let i=t.data[s+this._png.channels-1]/n,a=r%(this._png.channels-1)==0?1:t.data[s+r],c=Math.floor(i*a+(1-i)*e.data[o+r]);e.data[o+r]+=c}}break;default:throw Error(`Unknown blendOp`)}}decodeImage(){let e=this._inflatorResult;if(this._filterMethod!==f$.ADAPTIVE)throw Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===p$.NO_INTERLACE)this._png.data=XQ({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===p$.ADAM7)this._png.data=GQ({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){this._inflator.push(new Uint8Array,!0);let e=this._inflatorResult,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:m$.NONE,blendOp:h$.SOURCE,data:e}),this._inflator=new xQ((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._writingDataChunks=!1}};function _$(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw Error(`invalid bit depth: ${e}`);return e}function v$(e){let t=e.palette,n=e.depth;if(!t)throw Error(`Color palette is undefined.`);y$(e);let r=e.width*e.height,i=r*t[0].length,a=new Uint8Array(i),o=0,s=0,c=new Uint8Array(r),l=255;switch(n){case 1:l=128;break;case 2:l=192;break;case 4:l=240;break;case 8:l=255;break;default:throw Error(`Incorrect depth value`)}for(let t of e.data){let r=l,i=8;for(;r&&(i-=n,c[o++]=(t&r)>>i,r>>=n,o%e.width!==0););}if(e.palette)for(let t of c){let n=e.palette.at(t);if(!n)throw Error(`Incorrect index of palette color`);a.set(n,s),s+=n.length}return a}function y$(e){let t=e.depth<8?Math.ceil(e.width*e.depth/8)*e.height*e.channels:e.width*e.height*e.channels;if(e.data.length!==t)throw RangeError(`wrong data size. Found ${e.data.length}, expected ${t}`)}function b$(e,t){return new g$(e,t).decode()}var x$=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_FOREGROUND=e.DEFAULT_BACKGROUND=e.PALETTE_ANSI_256=e.PALETTE_VT340_GREY=e.PALETTE_VT340_COLOR=e.normalizeHLS=e.normalizeRGB=e.nearestColorIndex=e.fromRGBA8888=e.toRGBA8888=e.alpha=e.blue=e.green=e.red=e.BIG_ENDIAN=void 0,e.BIG_ENDIAN=new Uint8Array(new Uint32Array([4278190080]).buffer)[0]===255,e.BIG_ENDIAN&&console.warn(`BE platform detected. This version of node-sixel works only on LE properly.`);function t(e){return e&255}e.red=t;function n(e){return e>>>8&255}e.green=n;function r(e){return e>>>16&255}e.blue=r;function i(e){return e>>>24&255}e.alpha=i;function a(e,t,n,r=255){return((r&255)<<24|(n&255)<<16|(t&255)<<8|e&255)>>>0}e.toRGBA8888=a;function o(e){return[e&255,e>>8&255,e>>16&255,e>>>24]}e.fromRGBA8888=o;function s(e,i){let a=t(e),o=n(e),s=r(e),c=2**53-1,l=-1;for(let e=0;e<i.length;++e){let t=a-i[e][0],n=o-i[e][1],r=s-i[e][2],u=t*t+n*n+r*r;if(!u)return e;u<c&&(c=u,l=e)}return l}e.nearestColorIndex=s;function c(e,t,n){return Math.max(e,Math.min(n,t))}function l(e,t,n){return n<0&&(n+=1),n>1&&--n,n*6<1?t+(e-t)*6*n:n*2<1?e:n*3<2?t+(e-t)*(4-n*6):t}function u(e,t,n){if(!n){let e=Math.round(t*255);return a(e,e,e)}let r=t<.5?t*(1+n):t+n-t*n,i=2*t-r;return a(c(0,255,Math.round(l(r,i,e+1/3)*255)),c(0,255,Math.round(l(r,i,e)*255)),c(0,255,Math.round(l(r,i,e-1/3)*255)))}function d(e,t,n){return(4278190080|Math.round(n/100*255)<<16|Math.round(t/100*255)<<8|Math.round(e/100*255))>>>0}e.normalizeRGB=d;function f(e,t,n){return u((e+240)/360,t/100,n/100)}e.normalizeHLS=f,e.PALETTE_VT340_COLOR=new Uint32Array([d(0,0,0),d(20,20,80),d(80,13,13),d(20,80,20),d(80,20,80),d(20,80,80),d(80,80,20),d(53,53,53),d(26,26,26),d(33,33,60),d(60,26,26),d(33,60,33),d(60,33,60),d(33,60,60),d(60,60,33),d(80,80,80)]),e.PALETTE_VT340_GREY=new Uint32Array([d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46),d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46)]),e.PALETTE_ANSI_256=(()=>{let e=[a(0,0,0),a(205,0,0),a(0,205,0),a(205,205,0),a(0,0,238),a(205,0,205),a(0,250,205),a(229,229,229),a(127,127,127),a(255,0,0),a(0,255,0),a(255,255,0),a(92,92,255),a(255,0,255),a(0,255,255),a(255,255,255)],t=[0,95,135,175,215,255];for(let n=0;n<6;++n)for(let r=0;r<6;++r)for(let i=0;i<6;++i)e.push(a(t[n],t[r],t[i]));for(let t=8;t<=238;t+=10)e.push(a(t,t,t));return new Uint32Array(e)})(),e.DEFAULT_BACKGROUND=a(0,0,0,255),e.DEFAULT_FOREGROUND=a(255,255,255,255)})),S$=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LIMITS=void 0,e.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:`AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF`}})),C$=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=x$(),n=S$();function r(e){if(typeof Buffer<`u`)return Buffer.from(e,`base64`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<n.length;++e)n[e]=t.charCodeAt(e);return n}var i=r(n.LIMITS.BYTES),a,o=new Uint32Array,s=class{constructor(){this.bandHandler=e=>1,this.modeHandler=e=>1}handle_band(e){return this.bandHandler(e)}mode_parsed(e){return this.modeHandler(e)}},c={memoryLimit:134217728,sixelColor:t.DEFAULT_FOREGROUND,fillColor:t.DEFAULT_BACKGROUND,palette:t.PALETTE_VT340_COLOR,paletteLimit:n.LIMITS.PALETTE_SIZE,truncate:!0};function l(e){let t=new s,n={env:{handle_band:t.handle_band.bind(t),mode_parsed:t.mode_parsed.bind(t)}};return WebAssembly.instantiate(a||i,n).then(n=>(a||=n.module,new u(e,n.instance||n,t)))}e.DecoderAsync=l;var u=class{constructor(e,r,s){if(this._PIXEL_OFFSET=n.LIMITS.MAX_WIDTH+4,this._canvas=o,this._bandWidths=[],this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},c,e),this._opts.paletteLimit>n.LIMITS.PALETTE_SIZE)throw Error(`DecoderOptions.paletteLimit must not exceed ${n.LIMITS.PALETTE_SIZE}`);if(r)s.bandHandler=this._handle_band.bind(this),s.modeHandler=this._initCanvas.bind(this);else{let e=a||=new WebAssembly.Module(i);r=new WebAssembly.Instance(e,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=r,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),n.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),n.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(e){if(e===2){let e=this.width*this.height;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}this._maxWidth=this._width}else if(e===1){if(this._level===2){let e=Math.min(this._rasterWidth,n.LIMITS.MAX_WIDTH)*this._rasterHeight;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536))}return 0}_realloc(e,t){let n=e+t;if(n>this._canvas.length){if(this._opts.memoryLimit&&n*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);let e=new Uint32Array(Math.ceil(n/65536)*65536);e.set(this._canvas),this._canvas=e}}_handle_band(e){let t=this._PIXEL_OFFSET,n=this._lastOffset;if(this._mode===2){let r=this.height-this._currentHeight,i=0;for(;i<6&&r>0;)this._canvas.set(this._pSrc.subarray(t*i,t*i+e),n+e*i),i++,r--;this._lastOffset+=e*i,this._currentHeight+=i}else if(this._mode===1){this._realloc(n,e*6),this._maxWidth=Math.max(this._maxWidth,e),this._minWidth=Math.min(this._minWidth,e);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r);this._bandWidths.push(e),this._lastOffset+=e*6,this._currentHeight+=6}return 0}get width(){return this._mode===1?Math.max(this._maxWidth,this._wasm.current_width()):this._width}get height(){return this._mode===1?this._wasm.current_width()?this._bandWidths.length*6+this._wasm.current_height():this._bandWidths.length*6:this._height}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(e=this._opts.fillColor,t=this._opts.palette,r=this._opts.paletteLimit,i=this._opts.truncate){this._wasm.init(this._opts.sixelColor,e,r,+!!i),t&&this._palette.set(t.subarray(0,n.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);this._chunk.set(e.subarray(i,i+=t)),this._wasm.decode(0,t)}}decodeString(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);for(let n=0,r=i;n<t;++n,++r)this._chunk[n]=e.charCodeAt(r);i+=t,this._wasm.decode(0,t)}}get data32(){if(this._mode===0||!this.width||!this.height)return o;let e=this._wasm.current_width();if(this._mode===2){let t=this.height-this._currentHeight;if(t>0){let n=this._PIXEL_OFFSET,r=this._lastOffset,i=0;for(;i<6&&t>0;)this._canvas.set(this._pSrc.subarray(n*i,n*i+e),r+e*i),i++,t--;t&&this._canvas.fill(this._fillColor,r+e*i)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let t=!1;if(e){if(e!==this._minWidth)t=!0;else{let t=this._PIXEL_OFFSET,n=this._lastOffset;this._realloc(n,e*6);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r)}}if(!t)return this._canvas.subarray(0,this.width*this.height)}let t=new Uint32Array(this.width*this.height);t.fill(this._fillColor);let n=0,r=0;for(let e=0;e<this._bandWidths.length;++e){let i=this._bandWidths[e];for(let e=0;e<6;++e)t.set(this._canvas.subarray(r,r+=i),n),n+=this.width}if(e){let r=this._PIXEL_OFFSET,i=this._wasm.current_height();for(let a=0;a<i;++a)t.set(this._pSrc.subarray(r*a,r*a+e),n+this.width*a)}return t}return o}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=o,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};e.Decoder=u;function d(e,t){let n=new u(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decode=d;async function f(e,t){let n=await l(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decodeAsync=f})),w$=x$(),T$=C$(),E$=w$.PALETTE_ANSI_256.slice();E$.set(w$.PALETTE_VT340_COLOR);var D$=200,O$=new TextEncoder,k$=`offsite-image:`;async function A$(e){let t=await(0,T$.decodeAsync)(e,{fillColor:0,palette:E$});return!t.width||!t.height?null:createImageBitmap(new ImageData(new Uint8ClampedArray(t.data8),t.width,t.height))}function j$(e,t,n){return e===void 0||e===`auto`?0:e.endsWith(`%`)?parseInt(e.slice(0,-1))*t/100:e.endsWith(`px`)?parseInt(e.slice(0,-2)):parseInt(e)*n}async function M$(e,t){let n=e.indexOf(`:`);if(n===-1)return null;let r=new Map(e.slice(0,n).split(`;`).map(e=>{let t=e.indexOf(`=`);return[e.slice(0,t),e.slice(t+1)]}));if(r.get(`inline`)!==`1`)return null;let i=Uint8Array.from(atob(e.slice(n+1)),e=>e.charCodeAt(0)),a=await createImageBitmap(new Blob([i])),o=j$(r.get(`width`),t.width,t.cellWidth),s=j$(r.get(`height`),t.height,t.cellHeight),c=[a.width,a.height];if(!o&&!s){let e=Math.min(t.width/a.width,(t.height-t.cellHeight)/a.height);e<1&&(c=[a.width*e,a.height*e])}else c=o?r.get(`preserveAspectRatio`)!==`0`||!s?[o,a.height*o/a.width]:[o,s]:[a.width*s/a.height,s];let[l,u]=c.map(e=>Math.max(1,Math.floor(e*t.pixelRatio))),d=await createImageBitmap(a,{resizeWidth:l,resizeHeight:u});return a.close(),d}function N$(e){let t=b$(e),{width:n,height:r,depth:i,channels:a}=t,o=n*r,s=new Uint8Array(o*4);if(t.palette){let e=v$(t),i=t.palette[0].length;for(let t=0;t<o;t+=1)s.set(e.subarray(t*i,t*i+3),t*4),s[t*4+3]=i===4?e[t*i+3]:255;return{width:n,height:r,data:s}}let c=2**i-1,l=Math.ceil(n*i/8);function u(e){if(i>=8)return t.data[e];let r=e%n*i;return t.data[Math.floor(e/n)*l+(r>>3)]>>8-i-(r&7)&c}function d(e){return i===16?e>>8:i===8?e:Math.round(e*255/c)}let f=t.transparency;for(let e=0;e<o;e+=1){let t=e*4;if(a===1||a===2){let n=u(e*a);s.fill(d(n),t,t+3),s[t+3]=a===2?d(u(e*2+1)):f?.[0]===n?0:255}else if(a===3||a===4){let n=u(e*a),r=u(e*a+1),i=u(e*a+2);s[t]=d(n),s[t+1]=d(r),s[t+2]=d(i),s[t+3]=a===4?d(u(e*4+3)):f?.[0]===n&&f[1]===r&&f[2]===i?0:255}else throw Error(`unsupported PNG with ${a} channels`)}return{width:n,height:r,data:s}}var P$=class{core;images=[];nextImage=0;constructor(e){this.core=e}place(e,t,n){let r=`${k$}${this.nextImage++}`;this.core.write(O$.encode(`\x1b]8;;${r}\x1b\\ \x1b]8;;\x1b\\\b`));let i={ref:this.core.trackCursor(),marker:r,bitmap:e,width:e.width/t,height:e.height/t,alternate:this.core.isAlternateScreen()};if(this.images.push(i),this.images.length>D$){let e=this.images.shift();e&&this.remove(e)}let a=Math.ceil(i.height/n);a>1&&this.core.write(O$.encode(`\x1BD`.repeat(a-1)))}visible(e,t,n){if(this.images.length===0)return[];let r=this.core.isAlternateScreen(),i=[],a=[];for(let o of this.images){if(o.alternate!==r){a.push(o);continue}let s=this.core.trackedPoint(o.ref);if(s===null||this.core.trackedHyperlink(o.ref)!==o.marker){this.remove(o);continue}a.push(o);let c=s.y-e;c+Math.ceil(o.height/n)<=0||c>=t||i.push({bitmap:o.bitmap,width:o.width,height:o.height,x:s.x,y:c})}return this.images=a,i}clear(){for(let e of this.images)this.remove(e);this.images=[]}remove(e){this.core.untrack(e.ref),e.bitmap.close()}},F$=new Uint8Array([0,97,115,109,1,0,0,0,1,35,5,96,4,127,127,127,127,0,96,3,127,127,127,1,127,96,2,127,127,0,96,3,127,127,127,0,96,5,127,127,127,127,127,1,127,2,49,6,3,101,110,118,1,119,0,0,3,101,110,118,1,100,0,1,3,101,110,118,1,115,0,1,3,101,110,118,1,98,0,2,3,101,110,118,1,118,0,3,3,101,110,118,1,112,0,4,7,25,6,1,119,0,0,1,100,0,1,1,115,0,2,1,98,0,3,1,118,0,4,1,112,0,5]),I$={userdata:0,writePty:1,bell:2,xtversion:4,size:6,deviceAttributes:8},L$=1,R$=-3,z$={width:0,height:4,data:8,length:12},B$=new TextDecoder,V$=new TextEncoder,H$=class e{memory;layouts;exports;memoryView;hosts=new Map;nextHostId=1;callbacks={writePty:0,deviceAttributes:0,size:0,bell:0,xtversion:0};version={pointer:0,size:0};constructor(e){this.exports=e.exports;let t=e.exports.memory;if(!(t instanceof WebAssembly.Memory))throw Error(`libghostty-vt did not export its memory`);this.memory=t,this.memoryView=new DataView(t.buffer);let n=this.call(`ghostty_type_json`),r=new Uint8Array(t.buffer),i=n;for(;i<r.length&&r[i]!==0;)i+=1;this.layouts=JSON.parse(B$.decode(r.subarray(n,i)))}static async load(){let t=await fetch(UZ);if(!t.ok)throw Error(`could not load libghostty-vt (${t.status})`);let n=null,r=await WebAssembly.instantiate(await t.arrayBuffer(),{env:{log:(e,t)=>{n&&console.debug(`[libghostty-vt]`,B$.decode(new Uint8Array(n.buffer,e,t)))}}}),i=new e(r.instance);return n=i.memory,i.installCallbacks(),i}call(e,...t){let n=this.exports[e];if(typeof n!=`function`)throw Error(`libghostty-vt export is missing: ${e}`);return n(...t)}layout(e){let t=this.layouts[e];if(!t)throw Error(`libghostty-vt layout is missing: ${e}`);return t}field(e,t){let n=this.layout(e).fields[t];if(!n)throw Error(`libghostty-vt field is missing: ${e}.${t}`);return n}alloc(e){let t=this.call(`ghostty_wasm_alloc_u8_array`,e);if(t===0)throw Error(`libghostty-vt could not allocate ${e} bytes`);return new Uint8Array(this.memory.buffer,t,e).fill(0),t}free(e,t){e!==0&&this.call(`ghostty_wasm_free_u8_array`,e,t)}allocOpaque(){let e=this.call(`ghostty_wasm_alloc_opaque`);if(e===0)throw Error(`libghostty-vt could not allocate a pointer`);return new DataView(this.memory.buffer).setUint32(e,0,!0),e}freeOpaque(e){e!==0&&this.call(`ghostty_wasm_free_opaque`,e)}readPointer(e){return this.dataView().getUint32(e,!0)}check(e,t){if(t!==0)throw Error(`${e} failed with result ${t}`)}flag(e,t,n){let r=this.alloc(1),i=this.call(e,t,n,r),a=this.bytes(r,1)[0];return this.free(r,1),i===0&&a!==0}encodeOutput(e){let t=this.call(`ghostty_wasm_alloc_usize`),n=``,r=e(0,0,t),i=this.view(t,4).getUint32(0,!0);if(r===R$&&i>0){let r=this.alloc(i),a=e(r,i,t),o=this.view(t,4).getUint32(0,!0);a===0&&(n=B$.decode(this.bytes(r,o))),this.free(r,i)}return this.call(`ghostty_wasm_free_usize`,t),n}attachHost(e,t){let n=this.nextHostId++;this.hosts.set(n,t),this.call(`ghostty_terminal_set`,e,I$.userdata,n);for(let t of[[I$.writePty,this.callbacks.writePty],[I$.deviceAttributes,this.callbacks.deviceAttributes],[I$.size,this.callbacks.size],[I$.bell,this.callbacks.bell],[I$.xtversion,this.callbacks.xtversion]])this.call(`ghostty_terminal_set`,e,t[0],t[1]);return n}detachHost(e,t){this.call(`ghostty_terminal_set`,e,I$.xtversion,0),this.call(`ghostty_terminal_set`,e,I$.bell,0),this.call(`ghostty_terminal_set`,e,I$.size,0),this.call(`ghostty_terminal_set`,e,I$.deviceAttributes,0),this.call(`ghostty_terminal_set`,e,I$.writePty,0),this.call(`ghostty_terminal_set`,e,I$.userdata,0),this.hosts.delete(t)}view(e,t){return new DataView(this.memory.buffer,e,t)}bytes(e,t){return new Uint8Array(this.memory.buffer,e,t)}dataView(){return this.memoryView.buffer!==this.memory.buffer&&(this.memoryView=new DataView(this.memory.buffer)),this.memoryView}setField(e,t,n,r){let i=this.field(t,n),a=this.dataView(),o=e+i.offset;if(i.type===`bool`||i.type===`u8`)a.setUint8(o,r);else if(i.type===`u16`)a.setUint16(o,r,!0);else if(i.type===`i32`)a.setInt32(o,r,!0);else if(i.type===`u32`||i.type===`enum`)a.setUint32(o,r,!0);else if(i.type===`u64`)a.setBigUint64(o,BigInt(r),!0);else throw Error(`unsupported libghostty-vt field type ${i.type}`)}readField(e,t,n){let r=this.field(t,n),i=this.dataView(),a=e+r.offset;if(r.type===`bool`||r.type===`u8`)return i.getUint8(a);if(r.type===`u16`)return i.getUint16(a,!0);if(r.type===`i32`)return i.getInt32(a,!0);if(r.type===`u32`||r.type===`enum`)return i.getUint32(a,!0);if(r.type===`u64`)return Number(i.getBigUint64(a,!0));throw Error(`unsupported libghostty-vt field type ${r.type}`)}installCallbacks(){let e=new WebAssembly.Instance(new WebAssembly.Module(F$),{env:{w:(e,t,n,r)=>{let i=this.hosts.get(t);i&&r!==0&&i.write(B$.decode(new Uint8Array(this.memory.buffer,n,r)))},d:(e,t,n)=>this.hosts.has(t)?(this.writeDeviceAttributes(n),1):0,s:(e,t,n)=>{let r=this.hosts.get(t);if(!r)return 0;let i=r.size(),a=`GhosttySizeReportSize`;return this.setField(n,a,`rows`,i.rows),this.setField(n,a,`columns`,i.columns),this.setField(n,a,`cell_width`,i.cellWidth),this.setField(n,a,`cell_height`,i.cellHeight),1},b:(e,t)=>{this.hosts.get(t)?.bell()},v:(e,t,n)=>{let r=this.hosts.get(n);r&&this.writeVersion(e,r.version())},p:(e,t,n,r,i)=>this.decodePng(t,n,r,i)}}),t=this.exports.__indirect_function_table;if(!(t instanceof WebAssembly.Table))throw Error(`libghostty-vt did not expose its callback table`);let n=[`w`,`d`,`s`,`b`,`v`,`p`].map(n=>{let r=e.exports[n];if(typeof r!=`function`)throw Error(`libghostty-vt callback is missing: ${n}`);let i=t.length;return t.grow(1),t.set(i,r),i});if(this.callbacks={writePty:n[0],deviceAttributes:n[1],size:n[2],bell:n[3],xtversion:n[4]},this.call(`ghostty_sys_set`,L$,n[5])!==0)throw Error(`libghostty-vt did not accept the PNG decoder`)}decodePng(e,t,n,r){let i;try{i=N$(new Uint8Array(this.memory.buffer,t,n))}catch(e){return console.warn(`could not decode a kitty PNG image`,e),0}let a=this.call(`ghostty_alloc`,e,i.data.length);if(a===0)return 0;this.bytes(a,i.data.length).set(i.data);let o=this.dataView();return o.setUint32(r+z$.width,i.width,!0),o.setUint32(r+z$.height,i.height,!0),o.setUint32(r+z$.data,a,!0),o.setUint32(r+z$.length,i.data.length,!0),1}writeVersion(e,t){let n=V$.encode(t);this.free(this.version.pointer,this.version.size);let r=this.alloc(n.length);this.bytes(r,n.length).set(n),this.version={pointer:r,size:n.length},this.dataView().setUint32(e+this.field(`GhosttyString`,`ptr`).offset,r,!0),this.setField(e,`GhosttyString`,`len`,n.length)}writeDeviceAttributes(e){let t=e+this.field(`GhosttyDeviceAttributes`,`primary`).offset,n=e+this.field(`GhosttyDeviceAttributes`,`secondary`).offset,r=e+this.field(`GhosttyDeviceAttributes`,`tertiary`).offset,i=`GhosttyDeviceAttributesPrimary`,a=`GhosttyDeviceAttributesSecondary`,o=t+this.field(i,`features`).offset,s=this.dataView(),c=[4,22];c.forEach((e,t)=>s.setUint16(o+t*2,e,!0)),this.setField(t,i,`conformance_level`,62),this.setField(t,i,`num_features`,c.length),this.setField(n,a,`device_type`,0),this.setField(n,a,`firmware_version`,276),this.setField(n,a,`rom_cartridge`,0),this.setField(r,`GhosttyDeviceAttributesTertiary`,`unit_id`,0)}},U$=null;async function W$(){U$=await H$.load()}function G$(){if(!U$)throw Error(`libghostty-vt is not loaded`);return U$}var K$=new Map(`Unidentified.Backquote.Backslash.BracketLeft.BracketRight.Comma.Digit0.Digit1.Digit2.Digit3.Digit4.Digit5.Digit6.Digit7.Digit8.Digit9.Equal.IntlBackslash.IntlRo.IntlYen.KeyA.KeyB.KeyC.KeyD.KeyE.KeyF.KeyG.KeyH.KeyI.KeyJ.KeyK.KeyL.KeyM.KeyN.KeyO.KeyP.KeyQ.KeyR.KeyS.KeyT.KeyU.KeyV.KeyW.KeyX.KeyY.KeyZ.Minus.Period.Quote.Semicolon.Slash.AltLeft.AltRight.Backspace.CapsLock.ContextMenu.ControlLeft.ControlRight.Enter.MetaLeft.MetaRight.ShiftLeft.ShiftRight.Space.Tab.Convert.KanaMode.NonConvert.Delete.End.Help.Home.Insert.PageDown.PageUp.ArrowDown.ArrowLeft.ArrowRight.ArrowUp.NumLock.Numpad0.Numpad1.Numpad2.Numpad3.Numpad4.Numpad5.Numpad6.Numpad7.Numpad8.Numpad9.NumpadAdd.NumpadBackspace.NumpadClear.NumpadClearEntry.NumpadComma.NumpadDecimal.NumpadDivide.NumpadEnter.NumpadEqual.NumpadMemoryAdd.NumpadMemoryClear.NumpadMemoryRecall.NumpadMemoryStore.NumpadMemorySubtract.NumpadMultiply.NumpadParenLeft.NumpadParenRight.NumpadSubtract.NumpadSeparator.NumpadArrowUp.NumpadArrowDown.NumpadArrowRight.NumpadArrowLeft.NumpadBegin.NumpadHome.NumpadEnd.NumpadInsert.NumpadDelete.NumpadPageUp.NumpadPageDown.Escape.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12.F13.F14.F15.F16.F17.F18.F19.F20.F21.F22.F23.F24.F25.Fn.FnLock.PrintScreen.ScrollLock.Pause.BrowserBack.BrowserFavorites.BrowserForward.BrowserHome.BrowserRefresh.BrowserSearch.BrowserStop.Eject.LaunchApp1.LaunchApp2.LaunchMail.MediaPlayPause.MediaSelect.MediaStop.MediaTrackNext.MediaTrackPrevious.Power.Sleep.AudioVolumeDown.AudioVolumeMute.AudioVolumeUp.WakeUp.Copy.Cut.Paste`.split(`.`).map((e,t)=>[e,t]));function q$(e){return K$.get(e)??0}var J$=new Map([[`!`,`1`],[`@`,`2`],[`#`,`3`],[`$`,`4`],[`%`,`5`],[`^`,`6`],[`&`,`7`],[`*`,`8`],[`(`,`9`],[`)`,`0`],[`~`,"`"],[`_`,`-`],[`+`,`=`],[`{`,`[`],[`}`,`]`],[`|`,`\\`],[`:`,`;`],[`"`,`'`],[`<`,`,`],[`>`,`.`],[`?`,`/`]]),Y$;function X$(){return Y$||(Y$=globalThis.navigator?.keyboard?.getLayoutMap().catch(()=>void 0)??Promise.resolve(void 0),Y$)}function Z$(){return Y$=void 0,X$()}function Q$(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?0:+([...e.key].length===1)}function $$(e,t){if([...e.key].length!==1)return 0;let n=t?.get(e.code);if(n&&[...n].length===1)return n.codePointAt(0)??0;if(/^[A-Z]$/u.test(e.key))return e.key.charCodeAt(0)+32;if(e.shiftKey){let t=J$.get(e.key);if(t)return t.codePointAt(0)??0;let n=e.key.toLowerCase();return n!==e.key&&[...n].length===1?n.codePointAt(0)??0:0}return e.key.codePointAt(0)??0}var e1=new Map([[`Backquote`,"`"],[`Minus`,`-`],[`Equal`,`=`],[`BracketLeft`,`[`],[`BracketRight`,`]`],[`Backslash`,`\\`],[`Semicolon`,`;`],[`Quote`,`'`],[`Comma`,`,`],[`Period`,`.`],[`Slash`,`/`],[`Space`,` `]]),t1=[...`0123456789`].map(e=>[`Digit${e}`,e]),n1=new Map([...J$].map(e=>[e[1],e[0]]));function r1(e){return/^Key[A-Z]$/u.test(e)?e[3].toLowerCase():/^Digit[0-9]$/u.test(e)?e[5]:e1.get(e)}function i1(e){return[...e1,...t1].every(t=>t[0]===`Space`||e.get(t[0])===t[1])}function a1(e,t){let n=t?.get(e.code),r=n&&[...n].length===1?n:r1(e.code);if(r===void 0)return[...e.key].length===1?null:e.key;if(!e.shiftKey)return r;let i=r.toUpperCase();return i!==r&&[...i].length===1?i:t===void 0||!i1(t)?null:n1.get(r)??r}var o1=new TextEncoder,s1=new Map([[`[`,`\x1B`],[`m`,`\r`],[`i`,` `],[`@`,`\0`]]),c1=class{runtime=G$();terminal;keyEncoderSlot;keyEncoder;keyEventSlot;keyEvent;mouseEncoderSlot;mouseEncoder;mouseEventSlot;mouseEvent;scratch;keyboardLayoutMap;constructor(e){let t=this.runtime;this.terminal=e,this.loadKeyboardLayout(X$()),this.keyEncoderSlot=t.allocOpaque(),t.check(`ghostty_key_encoder_new`,t.call(`ghostty_key_encoder_new`,0,this.keyEncoderSlot)),this.keyEncoder=t.readPointer(this.keyEncoderSlot),this.keyEventSlot=t.allocOpaque(),t.check(`ghostty_key_event_new`,t.call(`ghostty_key_event_new`,0,this.keyEventSlot)),this.keyEvent=t.readPointer(this.keyEventSlot),this.mouseEncoderSlot=t.allocOpaque(),t.check(`ghostty_mouse_encoder_new`,t.call(`ghostty_mouse_encoder_new`,0,this.mouseEncoderSlot)),this.mouseEncoder=t.readPointer(this.mouseEncoderSlot),this.mouseEventSlot=t.allocOpaque(),t.check(`ghostty_mouse_event_new`,t.call(`ghostty_mouse_event_new`,0,this.mouseEventSlot)),this.mouseEvent=t.readPointer(this.mouseEventSlot),this.scratch=t.alloc(1)}encodeKey(e,t=`press`,n=!1){let r=this.runtime,i=e.key.toLowerCase(),a=s1.get(i);if(a!==void 0&&t===`press`&&e.ctrlKey&&!e.altKey&&!e.metaKey&&!(e.shiftKey&&/^[a-z]$/u.test(i))&&!r.flag(`ghostty_terminal_get`,this.terminal,8))return a;let o=n?this.metaText(e):null,s=o??e.key;if(o!==null&&t===`press`&&!e.ctrlKey&&[...s].length===1&&(s.codePointAt(0)??0)>127&&r.flag(`ghostty_terminal_mode_get`,this.terminal,1036)&&this.isLegacyKeyboard())return`\x1b${s}`;r.call(`ghostty_key_encoder_setopt_from_terminal`,this.keyEncoder,this.terminal),r.call(`ghostty_key_event_set_action`,this.keyEvent,t===`release`?0:e.repeat?2:1),r.call(`ghostty_key_event_set_key`,this.keyEvent,q$(e.code));let c=+!!e.shiftKey|(e.ctrlKey?2:0)|(e.altKey?4:0)|(e.metaKey?8:0)|(e.getModifierState(`CapsLock`)?16:0)|(e.getModifierState(`NumLock`)?32:0);r.call(`ghostty_key_event_set_mods`,this.keyEvent,c),r.call(`ghostty_key_event_set_consumed_mods`,this.keyEvent,Q$(e)),r.call(`ghostty_key_event_set_composing`,this.keyEvent,+!!e.isComposing),r.call(`ghostty_key_event_set_unshifted_codepoint`,this.keyEvent,$$({code:e.code,key:s,shiftKey:e.shiftKey},this.keyboardLayoutMap));let l=o1.encode(s.length===1?s:``),u=l.length===0?0:r.alloc(l.length);u!==0&&r.bytes(u,l.length).set(l),r.call(`ghostty_key_event_set_utf8`,this.keyEvent,u,l.length);let d=r.encodeOutput((e,t,n)=>r.call(`ghostty_key_encoder_encode`,this.keyEncoder,this.keyEvent,e,t,n));return u!==0&&r.free(u,l.length),d}metaText(e){return a1(e,this.keyboardLayoutMap)}refreshKeyboardLayout(){this.loadKeyboardLayout(Z$())}encodePaste(e){let t=this.runtime,n=o1.encode(e);if(n.length===0)return``;let r=t.alloc(n.length);t.bytes(r,n.length).set(n);let i=+!!t.flag(`ghostty_terminal_mode_get`,this.terminal,2004),a=t.encodeOutput((e,a,o)=>t.call(`ghostty_paste_encode`,r,n.length,i,e,a,o));return t.free(r,n.length),a}encodeMouse(e){let t=this.runtime;t.call(`ghostty_mouse_encoder_setopt_from_terminal`,this.mouseEncoder,this.terminal);let n=t.layout(`GhosttyMouseEncoderSize`),r=t.alloc(n.size);for(let i of[[`size`,n.size],[`screen_width`,e.screenWidth],[`screen_height`,e.screenHeight],[`cell_width`,e.cellWidth],[`cell_height`,e.cellHeight],[`padding_top`,0],[`padding_bottom`,0],[`padding_right`,0],[`padding_left`,0]])t.setField(r,`GhosttyMouseEncoderSize`,i[0],Math.max(0,Math.round(i[1])));t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,2,r),t.free(r,n.size),t.bytes(this.scratch,1)[0]=+!!e.anyButtonPressed,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,3,this.scratch),t.bytes(this.scratch,1)[0]=1,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,4,this.scratch),t.call(`ghostty_mouse_event_set_action`,this.mouseEvent,{press:0,release:1,motion:2}[e.action]),e.button===null?t.call(`ghostty_mouse_event_clear_button`,this.mouseEvent):t.call(`ghostty_mouse_event_set_button`,this.mouseEvent,e.button),t.call(`ghostty_mouse_event_set_mods`,this.mouseEvent,e.mods);let i=t.layout(`GhosttyMousePosition`),a=t.alloc(i.size),o=t.view(a,i.size);return o.setFloat32(t.field(`GhosttyMousePosition`,`x`).offset,e.x,!0),o.setFloat32(t.field(`GhosttyMousePosition`,`y`).offset,e.y,!0),t.call(`ghostty_mouse_event_set_position`,this.mouseEvent,a),t.free(a,i.size),t.encodeOutput((e,n,r)=>t.call(`ghostty_mouse_encoder_encode`,this.mouseEncoder,this.mouseEvent,e,n,r))}dispose(){let e=this.runtime;e.call(`ghostty_mouse_event_free`,this.mouseEvent),e.call(`ghostty_mouse_encoder_free`,this.mouseEncoder),e.call(`ghostty_key_event_free`,this.keyEvent),e.call(`ghostty_key_encoder_free`,this.keyEncoder),e.free(this.scratch,1),e.freeOpaque(this.mouseEventSlot),e.freeOpaque(this.mouseEncoderSlot),e.freeOpaque(this.keyEventSlot),e.freeOpaque(this.keyEncoderSlot)}async loadKeyboardLayout(e){this.keyboardLayoutMap=await e}isLegacyKeyboard(){return this.encodeKey(new KeyboardEvent(`keydown`,{key:`Tab`,code:`Tab`,shiftKey:!0}))===`\x1B[Z`}},l1=26,u1=30,d1=1,f1={imageId:1,placementId:2,isVirtual:3,xOffset:4,yOffset:5,columns:10,rows:11,z:12},p1={width:3,height:4,format:5,data:7,length:8},m1={size:48,pixelWidth:4,pixelHeight:8,column:20,row:24,visible:28,sourceX:32,sourceY:36,sourceWidth:40,sourceHeight:44},h1=new Map([[0,3],[1,4],[3,2],[4,1]]),g1=new Map([773,781,782,784,786,829,830,831,838,842,843,844,848,849,850,855,859,867,868,869,870,871,872,873,874,875,876,877,878,879,1155,1156,1157,1158,1159,1426,1427,1428,1429,1431,1432,1433,1436,1437,1438,1439,1440,1441,1448,1449,1451,1452,1455,1476,1552,1553,1554,1555,1556,1557,1558,1559,1623,1624,1625,1626,1627,1629,1630,1750,1751,1752,1753,1754,1755,1756,1759,1760,1761,1762,1764,1767,1768,1771,1772,1840,1842,1843,1845,1846,1850,1853,1855,1856,1857,1859,1861,1863,1865,1866,2027,2028,2029,2030,2031,2032,2033,2035,2070,2071,2072,2073,2075,2076,2077,2078,2079,2080,2081,2082,2083,2085,2086,2087,2089,2090,2091,2092,2093,2385,2387,2388,3970,3971,3974,3975,4957,4958,4959,6109,6458,6679,6773,6774,6775,6776,6777,6778,6779,6780,7019,7021,7022,7023,7024,7025,7026,7027,7376,7377,7378,7386,7387,7392,7616,7617,7619,7620,7621,7622,7623,7624,7625,7627,7628,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7678,8400,8401,8404,8405,8406,8407,8411,8412,8417,8423,8425,8432,11503,11504,11505,11744,11745,11746,11747,11748,11749,11750,11751,11752,11753,11754,11755,11756,11757,11758,11759,11760,11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,42607,42620,42621,42736,42737,43232,43233,43234,43235,43236,43237,43238,43239,43240,43241,43242,43243,43244,43245,43246,43247,43248,43249,43696,43698,43699,43703,43704,43710,43711,43713,65056,65057,65058,65059,65060,65061,65062,68111,68152,119173,119174,119175,119176,119177,119210,119211,119212,119213,119362,119363,119364].map((e,t)=>[e,t]));function _1(e,t,n){let r=Array.from(e).slice(1,4).map(e=>g1.get(e.codePointAt(0)??0)??null),i=r[2]??null;return{imageId:t,placementId:n,row:r[0]??null,column:r[1]??null,imageIdHigh:i!==null&&i<256?i:null}}function v1(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n].cells,i=null;for(let e=0;e<r.length;e+=1){let a=r[e].placeholder;i!==null&&a!==null&&a.imageId===i.imageId&&a.placementId===i.placementId&&(a.row===null||a.row===i.row)&&(a.column===null||a.column===i.column+i.width)&&(a.imageIdHigh===null||a.imageIdHigh===i.imageIdHigh)?i.width+=1:(i!==null&&t.push(y1(i)),i=a===null?null:{x:e,y:n,imageId:a.imageId,imageIdHigh:a.imageIdHigh,placementId:a.placementId,row:a.row??0,column:a.column??0,width:1})}i!==null&&t.push(y1(i))}return t}function y1(e){return{x:e.x,y:e.y,imageId:e.imageId+(e.imageIdHigh??0)*2**24,placementId:e.placementId,row:e.row,column:e.column,width:e.width}}function b1(e,t,n,r){let i=t.columns===0?Math.ceil(n.width/r.width):t.columns,a=t.rows===0?Math.ceil(n.height/r.height):t.rows,o=i*r.width,s=a*r.height,c=n.width*s>n.height*o,l=c?o/Math.max(n.width,1):s/Math.max(n.height,1),u=c?0:(o-n.width*l)/2/l,d=c?(s-n.height*l)/2/l:0,f=n.width+u*2,p=n.height+d*2,m={x:f*e.column/i,y:p*e.row/a,width:f*e.width/i,height:p/a},h=0,g=0,_=e.width*r.width,v=r.height;if(m.y<d){let e=d-m.y;m.height-=e,g=e,v-=e*l,m.y=0,m.height>n.height&&(m.height=n.height,v=n.height*l)}else m.y+m.height>p-d?(m.y-=d,m.height=p-d-m.y-d,v=m.height*l):m.y-=d;if(m.x<u){let e=u-m.x;m.width-=e,h=e,_-=e*l,m.x=0,m.width>n.width&&(m.width=n.width,_=n.width*l)}else m.x+m.width>f-u?(m.x-=u,m.width=f-u-m.x-u,_=m.width*l):m.x-=u;if(m.width<=0||m.height<=0)return null;let y={xOffset:Math.round(h*l),yOffset:Math.round(g*l),width:Math.round(_),height:Math.round(v),source:{x:Math.round(m.x),y:Math.round(m.y),width:Math.round(m.width),height:Math.round(m.height)}};return y.width===0||y.height===0?null:y}function x1(e){let t=G$(),n=t.alloc(16),r=t.call(`ghostty_terminal_get`,e,l1,n);return t.free(n,16),r===0}var S1=class{runtime=G$();terminal;iteratorSlot;info;scratch;tail=[0,0];commands=0;cachedCommands=0;bitmaps=new Map;constructor(e){let t=this.runtime;this.terminal=e,this.iteratorSlot=t.allocOpaque(),t.check(`ghostty_kitty_graphics_placement_iterator_new`,t.call(`ghostty_kitty_graphics_placement_iterator_new`,0,this.iteratorSlot)),this.info=t.alloc(m1.size),this.scratch=t.alloc(16)}note(e){let t=[...this.tail,...e.subarray(0,2)],n=t.some((e,n)=>e===27&&t[n+1]===95&&t[n+2]===71),r=e.indexOf(27);for(;!n&&r!==-1;)n=e[r+1]===95&&e[r+2]===71,r=e.indexOf(27,r+1);n&&(this.commands+=1),this.tail=[...this.tail,...e.subarray(-2)].slice(-2)}images(e,t){this.commands!==this.cachedCommands&&(this.cachedCommands=this.commands,this.bitmaps.clear());let n=new Map,r=this.placements(e,t).map(e=>{let t=n.get(e.key)??this.bitmaps.get(e.key)??T1(e.image);return n.set(e.key,t),{placement:e,bitmap:t}});return this.bitmaps=n,r}dispose(){let e=this.runtime;e.call(`ghostty_kitty_graphics_placement_iterator_free`,e.readPointer(this.iteratorSlot)),e.free(this.info,m1.size),e.free(this.scratch,16),e.freeOpaque(this.iteratorSlot),this.bitmaps.clear()}placements(e,t){let n=this.runtime;n.check(`ghostty_terminal_get`,n.call(`ghostty_terminal_get`,this.terminal,u1,this.scratch));let r=n.readPointer(this.scratch);n.check(`ghostty_kitty_graphics_get`,n.call(`ghostty_kitty_graphics_get`,r,d1,this.iteratorSlot));let i=n.readPointer(this.iteratorSlot),a=[],o=[];for(;n.call(`ghostty_kitty_graphics_placement_next`,i);){let e=this.placementU32(i,f1.imageId);if(this.placementData(i,f1.isVirtual).getUint8(0)){o.push({imageId:e,placementId:this.placementU32(i,f1.placementId),columns:this.placementU32(i,f1.columns),rows:this.placementU32(i,f1.rows)});continue}let t=n.call(`ghostty_kitty_graphics_image`,r,e);if(t===0)throw Error(`kitty placement points to missing image ${e}`);n.bytes(this.info,m1.size).fill(0);let s=n.view(this.info,m1.size);s.setUint32(0,m1.size,!0),n.check(`ghostty_kitty_graphics_placement_render_info`,n.call(`ghostty_kitty_graphics_placement_render_info`,i,t,this.terminal,this.info)),s.getUint8(m1.visible)!==0&&a.push({...this.image(t,e),z:this.placementData(i,f1.z).getInt32(0,!0),column:s.getInt32(m1.column,!0),row:s.getInt32(m1.row,!0),xOffset:this.placementU32(i,f1.xOffset),yOffset:this.placementU32(i,f1.yOffset),width:s.getUint32(m1.pixelWidth,!0),height:s.getUint32(m1.pixelHeight,!0),source:{x:s.getUint32(m1.sourceX,!0),y:s.getUint32(m1.sourceY,!0),width:s.getUint32(m1.sourceWidth,!0),height:s.getUint32(m1.sourceHeight,!0)}})}if(o.length===0)return a;for(let i of v1(e)){let e=o.find(e=>e.imageId===i.imageId&&(i.placementId===0||e.placementId===i.placementId));if(e===void 0)continue;let s=n.call(`ghostty_kitty_graphics_image`,r,i.imageId);if(s===0)continue;let c=this.image(s,i.imageId),l=b1(i,e,c.image,t);l!==null&&a.push({...c,...l,z:-1,column:i.x,row:i.y})}return a}image(e,t){let n=this.imageData(e,p1.data),r=this.imageData(e,p1.length);return{key:`${t}:${n}:${r}`,image:{width:this.imageData(e,p1.width),height:this.imageData(e,p1.height),format:this.imageData(e,p1.format),pixels:this.runtime.bytes(n,r)}}}placementData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_placement_get`,this.runtime.call(`ghostty_kitty_graphics_placement_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4)}placementU32(e,t){return this.placementData(e,t).getUint32(0,!0)}imageData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_image_get`,this.runtime.call(`ghostty_kitty_graphics_image_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4).getUint32(0,!0)}};function C1(e,t,n,r,i){let a=r.width/i.width,o=r.height/i.height;for(let i of t){let t=i.placement;w1(t.z)===n&&e.drawImage(i.bitmap,t.source.x,t.source.y,t.source.width,t.source.height,t.column*r.width+t.xOffset*a,t.row*r.height+t.yOffset*o,t.width*a,t.height*o)}}function w1(e){return e<-1073741824?`belowBackground`:e<0?`belowText`:`aboveText`}function T1(e){let t=h1.get(e.format);if(t===void 0)throw Error(`unsupported kitty image format ${e.format}`);let n=e.width*e.height,r=e.pixels,i=new Uint8ClampedArray(n*4);if(t===4)i.set(r.subarray(0,n*4));else for(let e=0;e<n;e+=1){let n=e*t,a=e*4;t===3?i.set(r.subarray(n,n+3),a):i.fill(r[n],a,a+3),i[a+3]=t===2?r[n+1]:255}let a=new OffscreenCanvas(e.width,e.height),o=a.getContext(`2d`);if(!o)throw Error(`could not create a canvas for a kitty image`);return o.putImageData(new ImageData(i,e.width,e.height),0,0),a}var E1=8,D1=16,O1=0,k1=1,A1=2,j1=8,M1={cols:1,rows:2,dirty:3,rowIterator:4,background:5,foreground:6,cursor:7,cursorHasValue:8,cursorStyle:10,cursorVisible:11,cursorBlinking:12,cursorInViewport:14,cursorX:15,cursorY:16},N1={dirty:1,raw:2,cells:3},P1={raw:1,style:2,graphemesLength:3,graphemes:4,background:5,foreground:6,selected:7},F1={keys:0,values:20,graphemesLength:40,selected:44,background:48,foreground:52,written:56,size:60},I1={narrow:0,wide:1,spacerTail:2},L1={r:229,g:231,b:235},R1={r:0,g:0,b:0};function z1(e,t){return Math.floor((e*155+t*100)/255)}function B1(e,t){return{r:z1(e.r,t.r),g:z1(e.g,t.g),b:z1(e.b,t.b)}}function V1(e,t){let n=``;for(let r=0;r<t;r+=4096){let i=Math.min(4096,t-r),a=Array(i);for(let t=0;t<i;t+=1)a[t]=e.getUint32((r+t)*4,!0);n+=String.fromCodePoint(...a)}return n}function H1(e,t){return{text:``,wide:0,foreground:e,background:t,bold:!1,italic:!1,invisible:!1,strikethrough:!1,overline:!1,underline:0,underlineColor:null,selected:!1,placeholder:null}}function U1(e,t){let n=e.dataView();return{r:n.getUint8(t),g:n.getUint8(t+1),b:n.getUint8(t+2)}}function W1(e,t){let n=e.alloc(768);e.call(`ghostty_terminal_get`,t,21,n);let r=e.bytes(n,768),i=Array.from({length:256},(e,t)=>({r:r[t*3],g:r[t*3+1],b:r[t*3+2]}));return e.free(n,768),i}function G1(e,t){let n=[],r=[];return e.cells.forEach((e,i)=>{if(e.wide!==2)for(let a of(e.text||` `).split(``))n.push(a),r.push({x:i,y:t})}),{text:n.join(``),points:r}}var K1=class{runtime=G$();stateSlot;state;rowIteratorSlot;rowCellsSlot;scratch;style;cellQuery;graphemes=0;graphemeCapacity=0;rows=[];palette=[];constructor(){let e=this.runtime;this.stateSlot=e.allocOpaque(),e.check(`ghostty_render_state_new`,e.call(`ghostty_render_state_new`,0,this.stateSlot)),this.state=e.readPointer(this.stateSlot),this.rowIteratorSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_iterator_new`,e.call(`ghostty_render_state_row_iterator_new`,0,this.rowIteratorSlot)),this.rowCellsSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_cells_new`,e.call(`ghostty_render_state_row_cells_new`,0,this.rowCellsSlot)),this.scratch=e.alloc(16),this.style=e.alloc(e.layout(`GhosttyStyle`).size),this.cellQuery=e.alloc(F1.size);let t=e.dataView();[[P1.style,this.style],[P1.graphemesLength,this.cellQuery+F1.graphemesLength],[P1.selected,this.cellQuery+F1.selected],[P1.background,this.cellQuery+F1.background],[P1.foreground,this.cellQuery+F1.foreground]].forEach((e,n)=>{t.setUint32(this.cellQuery+F1.keys+n*4,e[0],!0),t.setUint32(this.cellQuery+F1.values+n*4,e[1],!0)})}snapshot(e,t){let n=this.runtime;n.check(`ghostty_render_state_update`,n.call(`ghostty_render_state_update`,this.state,e));let r=this.getRender(M1.cols,2),i=this.getRender(M1.rows,2),a=this.getRender(M1.dirty,4),o=this.getColor(M1.foreground,L1),s=this.getColor(M1.background,R1),c=this.getRender(M1.cursorHasValue,1)===0?o:this.getColor(M1.cursor,o),l=this.getRender(M1.cursorInViewport,1)!==0,u=this.getRender(M1.cursorVisible,1)!==0&&l;(this.rows.length!==i||this.rows.some(e=>e.cells.length!==r))&&(this.rows=Array.from({length:i},()=>({cells:Array.from({length:r},()=>H1(o,s)),isWrapContinuation:!1,wrapsToNext:!1})));let d=new Set;if(a!==0){this.palette=W1(n,e),n.check(`ghostty_render_state_get`,n.call(`ghostty_render_state_get`,this.state,M1.rowIterator,this.rowIteratorSlot));let c=n.readPointer(this.rowIteratorSlot),l=0;for(;l<i&&n.call(`ghostty_render_state_row_iterator_next`,c)!==0;)(a===2||this.getRowFlag(c,N1.dirty))&&(this.rows[l]=this.readRow(c,r,o,s,t),d.add(l),n.bytes(this.scratch,1)[0]=0,n.call(`ghostty_render_state_row_set`,c,0,this.scratch)),l+=1;n.view(this.scratch,4).setUint32(0,0,!0),n.call(`ghostty_render_state_set`,this.state,0,this.scratch)}return{cols:r,rows:i,foreground:o,background:s,cursor:c,cursorX:l?this.getRender(M1.cursorX,2):-1,cursorY:l?this.getRender(M1.cursorY,2):-1,cursorVisible:u,cursorBlinking:this.getRender(M1.cursorBlinking,1)!==0,cursorStyle:this.getRender(M1.cursorStyle,4),dirtyRows:d,rowData:this.rows}}invalidate(){this.rows=[]}dispose(){let e=this.runtime,t=e.readPointer(this.rowCellsSlot);t&&e.call(`ghostty_render_state_row_cells_free`,t);let n=e.readPointer(this.rowIteratorSlot);n&&e.call(`ghostty_render_state_row_iterator_free`,n),e.call(`ghostty_render_state_free`,this.state),e.free(this.style,e.layout(`GhosttyStyle`).size),e.free(this.cellQuery,F1.size),e.free(this.scratch,16),e.free(this.graphemes,this.graphemeCapacity),e.freeOpaque(this.rowCellsSlot),e.freeOpaque(this.rowIteratorSlot),e.freeOpaque(this.stateSlot)}readRow(e,t,n,r,i){let a=this.runtime;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,N1.raw,this.scratch));let o=a.view(this.scratch,8).getBigUint64(0,!0);a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,2,this.scratch+8);let s=a.bytes(this.scratch+8,1)[0]!==0;a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,1,this.scratch+8);let c=a.bytes(this.scratch+8,1)[0]!==0;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,N1.cells,this.rowCellsSlot));let l=a.readPointer(this.rowCellsSlot),u=a.layout(`GhosttyStyle`),d=u.size,f=u.fields,p=[];for(;p.length<t&&a.call(`ghostty_render_state_row_cells_next`,l)!==0;){a.bytes(this.style,d).fill(0),a.setField(this.style,`GhosttyStyle`,`size`,d);let e=a.call(`ghostty_render_state_row_cells_get_multi`,l,5,this.cellQuery+F1.keys,this.cellQuery+F1.values,this.cellQuery+F1.written),t=a.dataView(),o=t.getUint32(this.cellQuery+F1.written,!0);o<3&&a.check(`ghostty_render_state_row_cells_get_multi`,e);let s=t.getUint32(this.cellQuery+F1.graphemesLength,!0),c=t.getUint8(this.cellQuery+F1.selected)!==0,u=o>=4?U1(a,this.cellQuery+F1.background):r,m=o===5?U1(a,this.cellQuery+F1.foreground):o===3?this.getCellColor(l,n):n,h=``;if(s>0){let e=s*4;if(e>this.graphemeCapacity){let t=Math.max(e,this.graphemeCapacity*2),n=a.alloc(t);a.free(this.graphemes,this.graphemeCapacity),this.graphemes=n,this.graphemeCapacity=t}a.call(`ghostty_render_state_row_cells_get`,l,P1.graphemes,this.graphemes)===0&&(h=V1(a.view(this.graphemes,e),s))}let g=0;if(h.length===0&&p.at(-1)?.text.length){a.call(`ghostty_render_state_row_cells_get`,l,P1.raw,this.scratch);let e=a.view(this.scratch,8).getBigUint64(0,!0);a.view(this.scratch+8,4).setUint32(0,0,!0),a.call(`ghostty_cell_get`,e,3,this.scratch+8),g=a.view(this.scratch+8,4).getUint32(0,!0)}let _=a.dataView(),v=e=>_.getUint8(this.style+f[e].offset)!==0,y=v(`bold`);if(i&&y&&_.getUint32(this.style+E1,!0)===k1){let e=_.getUint8(this.style+D1);e<8&&(m=this.palette[e+8]??m)}if(v(`inverse`)){let e=m;m=u,u=e}v(`faint`)&&(m=B1(m,u));let b=this.style+f.underline_color.offset,x=_.getUint32(b,!0),S=b+j1,C=null;h.codePointAt(0)===1109742&&(C=_1(h,this.colorId(this.style+E1),this.colorId(b)),h=``),p.push({text:h,wide:g,foreground:m,background:u,bold:y,italic:v(`italic`),invisible:v(`invisible`),strikethrough:v(`strikethrough`),overline:v(`overline`),underline:_.getInt32(this.style+f.underline.offset,!0),underlineColor:x===k1?this.palette[_.getUint8(S)]:x===A1?U1(a,S):null,selected:c,placeholder:C})}for(;p.length<t;)p.push(H1(n,r));return{cells:p,isWrapContinuation:s,wrapsToNext:c}}getRender(e,t){this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch));let n=this.runtime.view(this.scratch,4);return t===1?n.getUint8(0):t===2?n.getUint16(0,!0):n.getUint32(0,!0)}getColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch)===0?U1(this.runtime,this.scratch):t}getRowFlag(e,t){return this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_render_state_row_get`,e,t,this.scratch)===0&&this.runtime.bytes(this.scratch,1)[0]!==0}getCellColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_row_cells_get`,e,P1.foreground,this.scratch)===0?U1(this.runtime,this.scratch):t}colorId(e){let t=this.runtime.dataView(),n=t.getUint32(e,!0);if(n===O1)return 0;if(n===k1)return t.getUint8(e+j1);if(n===A1){let t=U1(this.runtime,e+j1);return t.r<<16|t.g<<8|t.b}throw Error(`unknown style color tag ${n}`)}},q1=16,J1=589824,Y1=381888,X1=5e7,Z1=new TextDecoder;function Q1(e){let t=[...e],n=[0,95,135,175,215,255];for(let e=16;e<232;e+=1){let r=e-16;t.push({r:n[Math.floor(r/36)],g:n[Math.floor(r/6)%6],b:n[r%6]})}for(let e=0;e<24;e+=1){let n=8+e*10;t.push({r:n,g:n,b:n})}return t}var $1=class{encoder;kitty;runtime=G$();terminalSlot;terminal;renderState;formatterSlot;formatter;scratch;point;scrollbar;host;hostId=0;sizeReport;disposed=!1;boldIsBright=!1;version=``;constructor(e,t,n,r,i){let a=this.runtime,o=a.layout(`GhosttyTerminalOptions`).size,s=a.alloc(o);a.setField(s,`GhosttyTerminalOptions`,`cols`,e),a.setField(s,`GhosttyTerminalOptions`,`rows`,t);let c=Math.floor(Y1/(8*(e+1)));a.setField(s,`GhosttyTerminalOptions`,`max_scrollback`,n===0?0:Math.min((Math.ceil(n/c)+1)*J1,X1)),this.terminalSlot=a.allocOpaque();let l=a.call(`ghostty_terminal_new`,0,this.terminalSlot,s);if(a.free(s,o),a.check(`ghostty_terminal_new`,l),this.terminal=a.readPointer(this.terminalSlot),!x1(this.terminal))throw a.call(`ghostty_terminal_free`,this.terminal),a.freeOpaque(this.terminalSlot),Error(`libghostty-vt was built without kitty graphics, build it with scripts/build-ghostty-wasm.mts`);this.sizeReport={rows:t,columns:e,cellWidth:1,cellHeight:1},this.host={write:r,size:()=>this.sizeReport,bell:i,version:()=>this.version},this.hostId=a.attachHost(this.terminal,this.host),this.renderState=new K1,this.encoder=new c1(this.terminal),this.kitty=new S1(this.terminal);let u=`GhosttyFormatterTerminalOptions`,d=a.layout(u),f=a.alloc(d.size),p=a.field(u,`extra`),m=a.field(`GhosttyFormatterTerminalExtra`,`screen`);a.setField(f,u,`size`,d.size),a.setField(f,u,`trim`,1),a.setField(f+p.offset,`GhosttyFormatterTerminalExtra`,`size`,p.size),a.setField(f+p.offset+m.offset,`GhosttyFormatterScreenExtra`,`size`,m.size),this.formatterSlot=a.allocOpaque();let h=a.call(`ghostty_formatter_terminal_new`,0,this.formatterSlot,this.terminal,f);a.free(f,d.size),a.check(`ghostty_formatter_terminal_new`,h),this.formatter=a.readPointer(this.formatterSlot),this.scratch=a.alloc(16),this.point=a.alloc(a.layout(`GhosttyPoint`).size),this.scrollbar=a.alloc(a.layout(`GhosttyTerminalScrollbar`).size)}write(e){if(e.length===0)return;this.kitty.note(e);let t=this.runtime.alloc(e.length);this.runtime.bytes(t,e.length).set(e),this.runtime.call(`ghostty_terminal_vt_write`,this.terminal,t,e.length),this.runtime.free(t,e.length)}setReplies(e){e&&this.hostId===0?this.hostId=this.runtime.attachHost(this.terminal,this.host):!e&&this.hostId!==0&&(this.runtime.detachHost(this.terminal,this.hostId),this.hostId=0)}reset(){this.runtime.call(`ghostty_terminal_reset`,this.terminal),this.renderState.invalidate()}resize(e,t,n,r,i){this.sizeReport={rows:t,columns:e,cellWidth:Math.max(1,Math.round(n*i)),cellHeight:Math.max(1,Math.round(r*i))},this.runtime.check(`ghostty_terminal_resize`,this.runtime.call(`ghostty_terminal_resize`,this.terminal,Math.max(1,Math.min(65535,e)),Math.max(1,Math.min(65535,t)),this.sizeReport.cellWidth,this.sizeReport.cellHeight))}setColors(e){let t=this.runtime.alloc(3);for(let n of[[11,e.foreground],[12,e.background],[13,e.cursor]]){let e=n[1];this.runtime.bytes(t,3).set([e.r,e.g,e.b]),this.runtime.call(`ghostty_terminal_set`,this.terminal,n[0],t)}this.runtime.free(t,3);let n=Q1(e.palette),r=this.runtime.alloc(n.length*3);this.runtime.bytes(r,n.length*3).set(n.flatMap(e=>[e.r,e.g,e.b])),this.runtime.call(`ghostty_terminal_set`,this.terminal,14,r),this.runtime.free(r,n.length*3),this.renderState.invalidate()}setCursor(e,t){let n={bar:0,block:1,underline:2}[e];this.runtime.view(this.scratch,4).setUint32(0,n,!0),this.runtime.call(`ghostty_terminal_set`,this.terminal,22,this.scratch),this.runtime.bytes(this.scratch,1)[0]=+!!t,this.runtime.call(`ghostty_terminal_set`,this.terminal,23,this.scratch)}title(){if(this.runtime.bytes(this.scratch,8).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,12,this.scratch)!==0)return``;let e=this.runtime.view(this.scratch,8),t=e.getUint32(0,!0),n=e.getUint32(4,!0);return n===0?``:Z1.decode(this.runtime.bytes(t,n))}screenText(){let e=this.runtime.alloc(8),t=this.runtime.call(`ghostty_formatter_format_alloc`,this.formatter,0,e,e+4),n=this.runtime.view(e,8),r=n.getUint32(0,!0),i=n.getUint32(4,!0);if(this.runtime.free(e,8),t!==0)return``;let a=Z1.decode(this.runtime.bytes(r,i));return this.runtime.call(`ghostty_free`,0,r,i),a}scroll(e){let t=this.runtime.layout(`GhosttyTerminalScrollViewport`),n=this.runtime.alloc(t.size);this.runtime.setField(n,`GhosttyTerminalScrollViewport`,`tag`,2);let r=this.runtime.field(`GhosttyTerminalScrollViewport`,`value`);this.runtime.view(n+r.offset,r.size).setInt32(0,e,!0),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,n),this.runtime.free(n,t.size)}scrollToBottom(){let e=this.runtime.layout(`GhosttyTerminalScrollViewport`),t=this.runtime.alloc(e.size);this.runtime.setField(t,`GhosttyTerminalScrollViewport`,`tag`,1),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,t),this.runtime.free(t,e.size)}scrollbarState(){let e=this.runtime.layout(`GhosttyTerminalScrollbar`);return this.runtime.bytes(this.scrollbar,e.size).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,9,this.scrollbar)===0?{total:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`total`),offset:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`offset`),len:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`len`)}:null}isMouseTracking(){return this.flag(`ghostty_terminal_get`,11)}isMouseAnyEventTracking(){return this.flag(`ghostty_terminal_mode_get`,1003)}isFocusReporting(){return this.flag(`ghostty_terminal_mode_get`,1004)}isSynchronizedOutput(){return this.flag(`ghostty_terminal_mode_get`,2026)}endSynchronizedOutput(){this.runtime.check(`ghostty_terminal_mode_set`,this.runtime.call(`ghostty_terminal_mode_set`,this.terminal,2026,0))}currentColors(){return{foreground:this.terminalColor(18),background:this.terminalColor(19),cursor:this.terminalColor(20),palette:W1(this.runtime,this.terminal)}}isApplicationCursorKeys(){return this.flag(`ghostty_terminal_mode_get`,1)}isKittyKeyboard(){return this.flag(`ghostty_terminal_get`,8)}isAlternateScreen(){return this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,6,this.scratch)===0&&this.runtime.dataView().getUint32(this.scratch,!0)===1}setSelection(e,t){let n=this.runtime.layout(`GhosttyGridRef`).size,r=this.gridRef(e.x,e.y,2);try{let e=this.gridRef(t.x,t.y,2),i=this.runtime.layout(`GhosttySelection`),a=this.runtime.alloc(i.size);this.runtime.setField(a,`GhosttySelection`,`size`,i.size);let o=this.runtime.field(`GhosttySelection`,`start`),s=this.runtime.field(`GhosttySelection`,`end`);this.runtime.bytes(a+o.offset,o.size).set(this.runtime.bytes(r,o.size)),this.runtime.bytes(a+s.offset,s.size).set(this.runtime.bytes(e,s.size)),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,a),this.runtime.free(e,n),this.runtime.free(a,i.size)}finally{this.runtime.free(r,n)}}selectWord(e){return this.selectAt(`GhosttyTerminalSelectWordOptions`,`ghostty_terminal_select_word`,e)}selectLine(e){return this.selectAt(`GhosttyTerminalSelectLineOptions`,`ghostty_terminal_select_line`,e)}clearSelection(){this.runtime.call(`ghostty_terminal_set`,this.terminal,21,0)}selectionText(){let e=this.runtime.alloc(q1),t=this.runtime.view(e,q1);t.setUint32(0,q1,!0),t.setUint8(8,1),t.setUint8(9,1);let n=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_terminal_selection_format_buf`,this.terminal,e,t,n,r));return this.runtime.free(e,q1),n}hyperlinkAt(e,t){let n=this.gridRef(e,t,1),r=this.hyperlinkOf(n);return this.runtime.free(n,this.runtime.layout(`GhosttyGridRef`).size),r}toScreen(e){let t=this.gridRef(e.x,e.y,1),n=this.pointFromGridRef(t,2);return this.runtime.free(t,this.runtime.layout(`GhosttyGridRef`).size),n}trackCursor(){let e=this.runtime.allocOpaque(),t=this.runtime.call(`ghostty_terminal_grid_ref_track`,this.terminal,this.cursorPoint(),e),n=this.runtime.readPointer(e);return this.runtime.freeOpaque(e),this.runtime.check(`ghostty_terminal_grid_ref_track`,t),n}retrack(e){let t=this.runtime.call(`ghostty_tracked_grid_ref_set`,e,this.terminal,this.cursorPoint());this.runtime.check(`ghostty_tracked_grid_ref_set`,t)}trackedPoint(e){return this.runtime.call(`ghostty_tracked_grid_ref_point`,e,2,this.scratch)===0?{x:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`y`)}:null}trackedHyperlink(e){let t=this.runtime.layout(`GhosttyGridRef`).size,n=this.runtime.alloc(t);this.runtime.setField(n,`GhosttyGridRef`,`size`,t);let r=this.runtime.call(`ghostty_tracked_grid_ref_snapshot`,e,n)===0?this.hyperlinkOf(n):null;return this.runtime.free(n,t),r}untrack(e){this.runtime.call(`ghostty_tracked_grid_ref_free`,e)}snapshot(){return this.renderState.snapshot(this.terminal,this.boldIsBright)}invalidate(){this.renderState.invalidate()}cellSize(){return{width:this.sizeReport.cellWidth,height:this.sizeReport.cellHeight}}dispose(){if(this.disposed)return;this.disposed=!0;let e=this.runtime;e.call(`ghostty_formatter_free`,this.formatter),this.encoder.dispose(),this.kitty.dispose(),this.renderState.dispose(),this.hostId!==0&&e.detachHost(this.terminal,this.hostId),e.call(`ghostty_terminal_free`,this.terminal),e.free(this.scrollbar,e.layout(`GhosttyTerminalScrollbar`).size),e.free(this.scratch,16),e.free(this.point,e.layout(`GhosttyPoint`).size),e.freeOpaque(this.formatterSlot),e.freeOpaque(this.terminalSlot)}hyperlinkOf(e){let t=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_grid_ref_hyperlink_uri`,e,t,n,r));return t===``?null:t}cursorPosition(){this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,3,this.scratch),this.runtime.call(`ghostty_terminal_get`,this.terminal,4,this.scratch+2);let e=this.runtime.dataView();return{x:e.getUint16(this.scratch,!0),y:e.getUint16(this.scratch+2,!0)}}cursorPoint(){let e=this.cursorPosition();return this.fillPoint(this.point,e.x,e.y,0),this.point}fillPoint(e,t,n,r){this.runtime.setField(e,`GhosttyPoint`,`tag`,r);let i=this.runtime.field(`GhosttyPoint`,`value`),a=this.runtime.dataView();a.setUint16(e+i.offset,Math.max(0,t),!0),a.setUint32(e+i.offset+4,Math.max(0,n),!0)}gridRef(e,t,n){let r=this.runtime.alloc(this.runtime.layout(`GhosttyPoint`).size);this.fillPoint(r,e,t,n);let i=this.runtime.layout(`GhosttyGridRef`).size,a=this.runtime.alloc(i);this.runtime.setField(a,`GhosttyGridRef`,`size`,i);let o=this.runtime.call(`ghostty_terminal_grid_ref`,this.terminal,r,a);return this.runtime.free(r,this.runtime.layout(`GhosttyPoint`).size),o!==0&&(this.runtime.free(a,i),this.runtime.check(`ghostty_terminal_grid_ref`,o)),a}selectAt(e,t,n){let r=this.gridRef(n.x,n.y,2),i=this.runtime.layout(e),a=this.runtime.layout(`GhosttySelection`),o=this.runtime.alloc(i.size),s=this.runtime.alloc(a.size);this.runtime.setField(o,e,`size`,i.size);let c=this.runtime.field(e,`ref`);this.runtime.bytes(o+c.offset,c.size).set(this.runtime.bytes(r,c.size)),this.runtime.setField(s,`GhosttySelection`,`size`,a.size);let l=null;if(this.runtime.call(t,this.terminal,o,s)===0){let e=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`start`).offset,2),t=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`end`).offset,2);e&&t&&(l={start:e,end:t})}return this.runtime.free(s,a.size),this.runtime.free(r,this.runtime.layout(`GhosttyGridRef`).size),this.runtime.free(o,i.size),l}pointFromGridRef(e,t){let n=this.runtime.layout(`GhosttyPointCoordinate`),r=this.runtime.alloc(n.size),i=this.runtime.call(`ghostty_terminal_point_from_grid_ref`,this.terminal,e,t,r)===0?{x:this.runtime.readField(r,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(r,`GhosttyPointCoordinate`,`y`)}:null;return this.runtime.free(r,n.size),i}flag(e,t){return this.runtime.flag(e,this.terminal,t)}terminalColor(e){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.check(`ghostty_terminal_get`,this.runtime.call(`ghostty_terminal_get`,this.terminal,e,this.scratch)),U1(this.runtime,this.scratch)}};function e0(e,t){let n=[],r=e.toLowerCase(),i=t.toLowerCase(),a=r.indexOf(i);for(;a!==-1;)n.push(a),a=r.indexOf(i,a+i.length);return n}var t0=class{core;redraw;listeners=new Set;query=``;matches=[];activeMatch=-1;stale=!1;timer=null;constructor(e,t){this.core=e,this.redraw=t}find(e,t,n,r){let i=this.matches[this.activeMatch]??null;if(this.query=e,this.refresh(),this.matches.length===0)this.activeMatch=-1;else if(n||i===null){let e=i?.row??r,t=this.matches.findIndex(t=>t.row>=e);this.activeMatch=t===-1?this.matches.length-1:t}else{let e=this.matches.findIndex(e=>e.row===i.row&&e.index===i.index),n=e===-1?0:e,r=t?-1:1;this.activeMatch=(n+r+this.matches.length)%this.matches.length}return this.emit(),this.matches[this.activeMatch]??null}onResults(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}clear(){this.query=``,this.matches=[],this.activeMatch=-1}outputChanged(){this.query!==``&&(this.stale=!0,this.timer===null&&(this.timer=window.setTimeout(()=>{if(this.timer=null,!this.stale||this.query===``)return;let e=this.matches[this.activeMatch];this.refresh();let t=e?this.matches.findIndex(t=>t.row===e.row&&t.index===e.index):-1;this.activeMatch=t===-1?this.matches.length-1:t,this.emit(),this.redraw()},200)))}highlights(e,t){if(this.query===``)return[];let n=this.matches[this.activeMatch],r=[];return e.rowData.forEach((e,i)=>{let a=G1(e,i);e0(a.text,this.query).forEach((e,o)=>{let s=a.points[e],c=a.points[e+this.query.length-1];s&&c&&r.push({row:i,start:s.x,end:c.x+1,active:n?.row===t+i&&n.index===o})})}),r}dispose(){this.timer!==null&&window.clearTimeout(this.timer),this.timer=null}refresh(){this.stale=!1,this.matches=[],this.query!==``&&this.core.screenText().split(`
113
113
  `).forEach((e,t)=>{e0(e,this.query).forEach((e,n)=>this.matches.push({row:t,index:n}))})}emit(){let e={resultIndex:this.activeMatch,resultCount:this.matches.length};for(let t of this.listeners)t(e)}},n0=new TextDecoder;function r0(e){function t(e){return e.toString(16).padStart(2,`0`).repeat(2)}return`rgb:${t(e.r)}/${t(e.g)}/${t(e.b)}`}function i0(e){return Math.min(Math.max(e,0),100)}function a0(e){return n0.decode(Uint8Array.from(atob(e),e=>e.charCodeAt(0)))}function o0(e){return e===``?`s0`:[...e].filter(e=>`cpqs01234567`.includes(e)).join(``)}function s0(e){try{return a0(e)}catch(e){return console.warn(`invalid clipboard sequence`,e),null}}function c0(e,t,n){let r=Array.from(new TextEncoder().encode(e),e=>String.fromCharCode(e)).join(``);return`\x1b]52;${t};${btoa(r)}${n}`}function l0(e,t,n){let r=e===`10;?`?t.foreground:e===`11;?`?t.background:t.cursor;return`\x1b]${e.slice(0,2)};${r0(r)}${n}`}function u0(e,t,n){let r=e.split(`;`),i=[];for(let e=1;e+1<r.length;e+=2){if(r[e+1]!==`?`||!/^\d+$/.test(r[e]))continue;let a=t[Number(r[e])];a!==void 0&&i.push(`\x1b]4;${r[e]};${r0(a)}${n}`)}return i}function d0(e,t){let n=e.split(`;`);if(n.length>4)return null;let r=n[2]===void 0||n[2]===``?0:Number(n[2]),i=n[3]===void 0||n[3]===``?-1:Number(n[3]);return!Number.isInteger(r)||!Number.isInteger(i)?null:r===0?{state:r,value:0}:r===1?i<0?null:{state:r,value:i0(i)}:r===2||r===4?i<0?{state:r,value:t.value}:{state:r,value:i0(i||t.value)}:r===3?{state:r,value:t.value}:null}function f0(e,t){if(e.startsWith(`9;`)&&!/^9;\d+(;|$)/.test(e))return{title:``,body:n0.decode(t.subarray(2))};if(e.startsWith(`777;notify;`)){let e=n0.decode(t).split(`;`);return{title:e[2]??``,body:e.slice(3).join(`;`)}}return null}var p0=class{pending={id:``,title:``,body:``};add(e){let t=e.indexOf(`;`,3);if(t===-1)return null;let n=new Map;for(let r of e.slice(3,t).split(`:`)){let e=r.indexOf(`=`);e!==-1&&n.set(r.slice(0,e),r.slice(e+1))}let r=n.get(`p`)??`title`;if(r===`?`||r===`close`||r===`alive`)return null;let i=e.slice(t+1);if(n.get(`e`)===`1`)try{i=a0(i)}catch(e){return console.warn(`invalid notification sequence`,e),null}let a=n.get(`i`)??``;if(a!==this.pending.id&&(this.pending={id:a,title:``,body:``}),r===`title`&&(this.pending.title+=i),r===`body`&&(this.pending.body+=i),n.get(`d`)===`0`)return null;let o=this.pending;return this.pending={id:``,title:``,body:``},o.title===``&&o.body===``?null:{title:o.title,body:o.body}}},m0=27,h0=7,g0=24,_0=26,v0=33554432,y0=class{state=`ground`;params=``;collecting=!1;chunks=[];size=0;reset(){this.state=`ground`,this.drop()}scan(e,t){let n=0;for(let r=0;r<e.length;r+=1){let i=e[r];if(i===g0||i===_0)this.state=`ground`,this.drop();else if(this.state===`ground`)i===m0&&(this.state=`escape`);else if(this.state===`escape`){if(this.params=``,i===93){this.state=`osc`,this.begin(),n=r+1;continue}if(i===80){this.state=`dcsHeader`;continue}this.state=i===m0?`escape`:`ground`}else if(this.state===`osc`){if(i===h0){if(this.state=`ground`,this.append(e,n,r),t({type:`osc`,data:this.take(),terminator:`\x07`},r+1))return r+1;continue}i===m0&&(this.state=`oscEscape`,this.append(e,n,r))}else if(this.state===`oscEscape`){if(i===92){if(this.state=`ground`,t({type:`osc`,data:this.take(),terminator:`\x1B\\`},r+1))return r+1;continue}this.drop(),this.state=`escape`,--r}else if(this.state===`dcsHeader`){if(i===m0){this.state=`dcsEscape`;continue}if(i>=32&&i<=63){this.params.length<16&&(this.params+=String.fromCharCode(i));continue}this.state=`dcs`,i===113&&/^[0-9;]*$/.test(this.params)&&(this.begin(),n=r+1)}else if(this.state===`dcs`)i===m0&&(this.state=`dcsEscape`,this.append(e,n,r));else if(i===92){if(this.state=`ground`,this.collecting&&t({type:`sixel`,data:this.take()},r+1))return r+1}else this.drop(),this.state=`escape`,--r}return(this.state===`osc`||this.state===`dcs`)&&this.append(e,n,e.length),e.length}begin(){this.collecting=!0,this.chunks=[],this.size=0}append(e,t,n){!this.collecting||n<=t||(this.size+n-t>v0?this.drop():(this.chunks.push(e.slice(t,n)),this.size+=n-t))}take(){let e=new Uint8Array(this.size),t=0;for(let n of this.chunks)e.set(n,t),t+=n.length;return this.drop(),e}drop(){this.collecting=!1,this.chunks=[],this.size=0}},b0=`0101.0202.1010.2020.........0110.0210.0120.0220.0011.0012.0021.0022.1100.1200.2100.2200.1001.1002.2001.2002.1110.1210.2110.1120.2120.2210.1220.2220.1011.1012.2011.1021.2021.2012.1022.2022.0111.0112.0211.0212.0121.0122.0221.0222.1101.1102.1201.1202.2101.2102.2201.2202.1111.1112.1211.1212.2111.1121.2121.2112.2211.1122.1221.2212.1222.2122.2221.2222`.split(`.`),x0=[`0001`,`1000`,`0100`,`0010`,`0002`,`2000`,`0200`,`0020`,`0201`,`1020`,`0102`,`2010`],S0=`0303.3030.0310.0130.0330.0013.0031.0033.1300.3100.3300.1003.3001.3003.1310.3130.3330.1013.3031.3033.0313.0131.0333.1303.3101.3303.1313.3131.3333`.split(`.`),C0=[0,0,4,4],w0=[4,0,4,4],T0=[0,4,4,4],E0=[4,4,4,4],D0=[[[0,0,8,4]],[[0,7,8,1]],[[0,6,8,2]],[[0,5,8,3]],[[0,4,8,4]],[[0,3,8,5]],[[0,2,8,6]],[[0,1,8,7]],[[0,0,8,8]],[[0,0,7,8]],[[0,0,6,8]],[[0,0,5,8]],[[0,0,4,8]],[[0,0,3,8]],[[0,0,2,8]],[[0,0,1,8]],[[4,0,4,8]],[],[],[],[[0,0,8,1]],[[7,0,1,8]],[T0],[E0],[C0],[C0,T0,E0],[C0,E0],[C0,w0,T0],[C0,w0,E0],[w0],[w0,T0],[w0,T0,E0]],O0={9617:.25,9618:.5,9619:.75},k0={9581:[1,1],9582:[-1,1],9583:[-1,-1],9584:[1,-1]};function A0(e){return e>=9472&&e<=9547?b0[e-9472]:e>=9552&&e<=9580?S0[e-9552]:e>=9588&&e<=9599?x0[e-9588]:``}function j0(e){if(e.length!==1)return!1;let t=e.charCodeAt(0);return A0(t)!==``||k0[t]!==void 0||t>=9600&&t<=9631}function M0(e){return Math.max(1,Math.round(e.height/20))}function N0(e,t,n){let[r,i,a,o]=t,s=M0(n),c=s*2,l=Math.floor(Math.max(0,n.height-s)/2),u=l+s,d=Math.floor(Math.max(0,n.height-c)/2),f=d+c,p=Math.max(0,l-s),m=u+s,h=Math.floor(Math.max(0,n.width-s)/2),g=h+s,_=Math.floor(Math.max(0,n.width-c)/2),v=_+c,y=Math.max(0,h-s),b=g+s;function x(t,r,i,a){e.fillRect(n.left+t,n.top+r,i-t,a-r)}let S=o===`2`||i===`2`?f:o!==i||a===r?o===`3`||i===`3`?m:u:o===`0`&&i===`0`?u:l,C=o===`2`||i===`2`?d:o!==i||r===a?o===`3`||i===`3`?p:l:o===`0`&&i===`0`?l:u,w=r===`2`||a===`2`?v:r!==a||o===i?r===`3`||a===`3`?b:g:r===`0`&&a===`0`?g:h,T=r===`2`||a===`2`?_:r!==a||i===o?r===`3`||a===`3`?y:h:r===`0`&&a===`0`?h:g;r===`1`&&x(h,0,g,S),r===`2`&&x(_,0,v,S),r===`3`&&(x(y,0,h,o===`3`?l:S),x(g,0,b,i===`3`?l:S)),i===`1`&&x(T,l,n.width,u),i===`2`&&x(T,d,n.width,f),i===`3`&&(x(r===`3`?g:T,p,n.width,l),x(a===`3`?g:T,u,n.width,m)),a===`1`&&x(h,C,g,n.height),a===`2`&&x(_,C,v,n.height),a===`3`&&(x(y,o===`3`?u:C,h,n.height),x(g,i===`3`?u:C,b,n.height)),o===`1`&&x(0,l,w,u),o===`2`&&x(0,d,w,f),o===`3`&&(x(0,p,r===`3`?h:w,l),x(0,u,a===`3`?h:w,m))}function P0(e,[t,n],r){let i=M0(r),a=r.left+Math.floor(Math.max(0,r.width-i)/2)+i/2,o=r.top+Math.floor(Math.max(0,r.height-i)/2)+i/2,s=t===1?r.left+r.width:r.left,c=n===1?r.top+r.height:r.top,l=Math.min(r.width,r.height)/2;e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=i,e.beginPath(),e.moveTo(a,c),e.arcTo(a,o,s,o,l),e.lineTo(s,o),e.stroke(),e.restore()}function F0(e,t,n,r){e.save(),e.setTransform(1,0,0,1,0,0),I0(e,t.charCodeAt(0),{left:Math.round(n.left*r),top:Math.round(n.top*r),width:Math.round((n.left+n.width)*r)-Math.round(n.left*r),height:Math.round((n.top+n.height)*r)-Math.round(n.top*r)}),e.restore()}function I0(e,t,n){let r=A0(t);if(r!==``){N0(e,r,n);return}let i=k0[t];if(i!==void 0){P0(e,i,n);return}let a=O0[t];if(a!==void 0)e.globalAlpha=a,e.fillRect(n.left,n.top,n.width,n.height);else for(let[r,i,a,o]of D0[t-9600]){let t=n.left+Math.round(n.width*r/8),s=n.top+Math.round(n.height*i/8);e.fillRect(t,s,n.left+Math.round(n.width*(r+a)/8)-t,n.top+Math.round(n.height*(i+o)/8)-s)}}function L0(e){return`rgb(${e.r}, ${e.g}, ${e.b})`}function R0(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b}function z0(e,t){return Math.round(e*t)/t}function B0(e,t,n,r){let i=z0(e*n.width,r);return{left:i,width:z0(t*n.width,r)-i}}function V0(e,t,n,r,i){let a=i-2,o=n+r;if(t===1)e.fillRect(n,a,r,1);else if(t===2)e.fillRect(n,a,r,1),e.fillRect(n,a-2,r,1);else if(t===3){function t(e){return a-1+Math.sin(e/3*Math.PI)*1.5}e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=1,e.beginPath(),e.moveTo(n,t(n));for(let r=Math.floor(n)+1;r<o;r+=1)e.lineTo(r,t(r));e.lineTo(o,t(o)),e.stroke(),e.restore()}else if(t===4)for(let t=Math.ceil(n/2)*2;t<o;t+=2)e.fillRect(t,a,1,1);else if(t===5)for(let t=Math.floor(n/5)*5;t<o;t+=5){let r=Math.max(t,n),i=Math.min(t+3,o);i>r&&e.fillRect(r,a,i-r,1)}else throw Error(`unknown underline style ${t}`)}function H0(e,t){return e.selected===t.selected&&R0(e.foreground,t.foreground)&&e.bold===t.bold&&e.italic===t.italic&&e.invisible===t.invisible}function U0(e,t){return`${e.italic?`italic`:`normal`} ${e.bold?700:400} ${t.fontSize}px ${t.fontFamily}`}function W0(e,t,n,r,i){e.font=`normal 400 ${t}px ${n}`;let a=e.measureText(`M`).width,o=e.measureText(`Mg`),s=o.fontBoundingBoxAscent||t,c=s+o.fontBoundingBoxDescent,l=Math.max(1,Math.round(c*r*i))/i;return{width:Math.max(1,Math.round(a*i))/i,height:l,baseline:z0((l-c)/2+s,i),faceWidth:a}}function G0(e){return/^[!-/:-@[-`{-~]$/.test(e)}function K0(e,t,n){return!(e===null||t<e.start.y||t>e.end.y||t===e.start.y&&n<e.start.x||t===e.end.y&&n>e.end.x)}function q0(e){let{context:t,snapshot:n,metrics:r,appearance:i,cursorOn:a,previousCursorY:o,pixelRatio:s}=e,c=e.forceFull?Array.from({length:n.rows},(e,t)=>t):[...n.dirtyRows];o!==null&&!c.includes(o)&&c.push(o),n.cursorVisible&&n.cursorY>=0&&!c.includes(n.cursorY)&&c.push(n.cursorY),e.forceFull&&(t.save(),t.resetTransform(),t.fillStyle=L0(n.background),t.fillRect(0,0,t.canvas.width,t.canvas.height),t.restore());function l(e){let t=e*r.height,n=z0(t,s);return{top:t,cellTop:n,cellHeight:z0(t+r.height,s)-n}}t.textBaseline=`alphabetic`;for(let e of c){if(!n.rowData[e])continue;let{cellTop:r,cellHeight:i}=l(e);t.fillStyle=L0(n.background),t.fillRect(0,r,t.canvas.width,i)}e.drawLayer(`belowBackground`);for(let a of c){let o=n.rowData[a];if(!o)continue;let{cellTop:c,cellHeight:u}=l(a),d=0;for(;d<o.cells.length;){let e=o.cells[d],a=d+1;for(;a<o.cells.length&&o.cells[a].selected===e.selected&&R0(o.cells[a].background,e.background);)a+=1;let{left:l,width:f}=B0(d,a,r,s);e.selected?(t.fillStyle=i.selectionBackground,t.fillRect(l,c,f,u)):R0(e.background,n.background)||(t.fillStyle=L0(e.background),t.fillRect(l,c,f,u)),d=a}for(let n of e.highlights){if(n.row!==a)continue;let{left:e,width:o}=B0(n.start,n.end,r,s);t.fillStyle=i.matchBackground,t.fillRect(e,c,o,u),n.active&&(t.strokeStyle=i.activeMatchBorder,t.strokeRect(e+.5,c+.5,o-1,u-1))}}e.drawLayer(`belowText`);for(let a of c){let o=n.rowData[a];if(!o)continue;let{top:c,cellTop:u,cellHeight:d}=l(a);t.save(),t.beginPath(),t.rect(0,u,t.canvas.width,d),t.clip();for(let e=0;e<o.cells.length;e+=1){let n=o.cells[e];if(n.invisible||n.text.trim().length===0)continue;t.fillStyle=n.selected?i.selectionForeground:L0(n.foreground);let a=e*r.width;if(j0(n.text)){F0(t,n.text,{left:a,top:c,width:r.width,height:r.height},s);continue}t.font=U0(n,i);let l=a+(r.width-r.faceWidth)/2,u=e,d=e+1;if(i.ligatures&&G0(n.text)){for(;u>e-3&&u>0&&G0(o.cells[u-1].text)&&H0(o.cells[u-1],n);)--u;for(;d<e+4&&d<o.cells.length&&G0(o.cells[d].text)&&H0(o.cells[d],n);)d+=1}d-u===1?t.fillText(n.text,l,c+r.baseline):(t.save(),t.beginPath(),t.rect(a,c,r.width,r.height),t.clip(),t.fillText(o.cells.slice(u,d).map(e=>e.text).join(``),l-(e-u)*r.faceWidth,c+r.baseline),t.restore())}t.restore();for(let n=0;n<o.cells.length;n+=1){let i=o.cells[n],l=K0(e.hoveredLink,a,n);if(i.underline===0&&!i.strikethrough&&!i.overline&&!l)continue;let{left:f,width:p}=B0(n,n+1,r,s),m=u+d;t.fillStyle=L0(i.foreground),i.strikethrough&&t.fillRect(f,c+Math.floor(r.height*.55),p,1),i.overline&&t.fillRect(f,u+1,p,1),i.underline===0?l&&V0(t,1,f,p,m):(i.underlineColor!==null&&(t.fillStyle=L0(i.underlineColor)),V0(t,i.underline,f,p,m))}}if(!a||!n.cursorVisible||n.cursorX<0||n.cursorY<0)return;let u=n.cursorY*r.height,d=z0(u,s),f=z0(u+r.height,s)-d,p=n.rowData[n.cursorY]?.cells,m=p?.[n.cursorX],h=p?.[n.cursorX+1]?.wide===I1.spacerTail?2:1,{left:g,width:_}=B0(n.cursorX,n.cursorX+h,r,s);t.fillStyle=L0(n.cursor),t.strokeStyle=L0(n.cursor),!e.focused||n.cursorStyle===3?t.strokeRect(g+.5,d+.5,_-1,f-1):n.cursorStyle===0?t.fillRect(g,d,1,f):n.cursorStyle===2?t.fillRect(g,d+f-2,_,2):(t.fillRect(g,d,_,f),m?.text&&(t.fillStyle=i.cursorText,j0(m.text)?F0(t,m.text,{left:n.cursorX*r.width,top:u,width:r.width,height:r.height},s):(t.font=U0(m,i),t.fillText(m.text,n.cursorX*r.width+(r.width-r.faceWidth)/2,u+r.baseline))))}var J0=navigator.userAgent.includes(`Mac`),Y0=500,X0=/https?:\/\/[^\s"'`<>]+/g;function Z0(e){return e===0?1:e===1?3:e===2?2:null}function Q0(e,t){let n=Math.max(0,e.total-e.len);if(t<=0||e.len<=0||n===0)return null;let r=Math.min(t,Math.max(20,t*e.len/e.total)),i=t-r;return{thumbHeight:r,thumbTop:i*(Math.min(e.offset,n)/n),travel:i,maxOffset:n}}var $0=class{hoveredLink=null;context;linkPointer=null;mousePointer=null;mouseButton=null;lastMotion=``;selectionPointer=null;selectionMode=`cell`;selectionAnchor=null;selectionBase=null;selectionMoved=!1;selectionScroll=null;selectionScrollDelta=0;selectionClient=null;clickMove=null;clicks={count:0,time:0,x:0,y:0};touch=null;wheelRemainder=0;scrollbarDrag=null;constructor(e){this.context=e;let t=e.canvas,n=e.scrollbar;t.addEventListener(`pointerdown`,this.onPointerDown),t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp),t.addEventListener(`pointercancel`,this.onPointerUp),t.addEventListener(`pointerleave`,this.onPointerLeave),t.addEventListener(`wheel`,this.onWheel,{passive:!1}),t.addEventListener(`mousedown`,this.onMouseDown),n.addEventListener(`pointerdown`,this.onScrollbarDown),n.addEventListener(`pointermove`,this.onScrollbarMove),n.addEventListener(`pointerup`,this.onScrollbarUp),n.addEventListener(`pointercancel`,this.onScrollbarUp)}updateScrollbar(e){let t=this.context.core.scrollbarState(),n=t===null?null:Q0(t,e);this.context.scrollbar.hidden=n===null,n!==null&&(this.context.thumb.style.height=`${n.thumbHeight}px`,this.context.thumb.style.transform=`translateY(${n.thumbTop}px)`)}dispose(){this.setSelectionScroll(0)}scrollRows(e,t){let n=this.context.core,r=this.wheelRemainder+e/this.context.view().metrics.height,i=Math.trunc(r);if(this.wheelRemainder=r-i,i!==0){if(this.reportsMouse(t))for(let e=0;e<Math.abs(i);e+=1)this.sendMouse(`press`,i<0?4:5,t);else if(n.isAlternateScreen()){let e=(n.isApplicationCursorKeys()?`\x1BO`:`\x1B[`)+(i<0?`A`:`B`);this.context.onData(e.repeat(Math.abs(i)))}else this.context.scrollViewport(i)}}cellAt(e,t){let n=this.context.view(),r=this.context.canvas.getBoundingClientRect();return{x:Math.max(0,Math.min(n.cols-1,Math.floor((e-r.left)/n.metrics.width))),y:Math.max(0,Math.min(n.rows-1,Math.floor((t-r.top)/n.metrics.height)))}}reportsMouse(e){return this.context.core.isMouseTracking()&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey}sendMouse(e,t,n){let r=this.context.view(),i=this.context.canvas.getBoundingClientRect(),a=window.devicePixelRatio||1,o=this.context.core.encoder.encodeMouse({action:e,button:t,mods:+!!n.shiftKey|(n.ctrlKey?2:0)|(n.altKey?4:0)|(n.metaKey?8:0),x:Math.max(0,n.clientX-i.left)*a,y:Math.max(0,n.clientY-i.top)*a,screenWidth:r.cols*r.metrics.width*a,screenHeight:r.rows*r.metrics.height*a,cellWidth:r.metrics.width*a,cellHeight:r.metrics.height*a,anyButtonPressed:n.buttons!==0});if(o.length!==0){if(e===`motion`){if(o===this.lastMotion)return;this.lastMotion=o}else this.lastMotion=``;this.context.onData(o)}}linkAt(e,t){let n=this.context.view(),r=this.context.core,i=n.snapshot;if(!i)return null;let a=this.context.canvas.getBoundingClientRect(),o=e-a.left,s=t-a.top;if(o<0||s<0||o>=n.cols*n.metrics.width||s>=n.rows*n.metrics.height)return null;let c={x:Math.floor(o/n.metrics.width),y:Math.floor(s/n.metrics.height)},l=r.hyperlinkAt(c.x,c.y);if(l!==null){if(l.startsWith(`offsite-image:`))return null;let e=c.x,t=c.x;for(;e>0&&r.hyperlinkAt(e-1,c.y)===l;)--e;for(;t<n.cols-1&&r.hyperlinkAt(t+1,c.y)===l;)t+=1;return{uri:l,range:{start:{x:e,y:c.y},end:{x:t,y:c.y}}}}let u=c.y;for(;u>0&&i.rowData[u]?.isWrapContinuation;)--u;let d=c.y;for(;d<i.rows-1&&i.rowData[d]?.wrapsToNext;)d+=1;let f=``,p=[];for(let e=u;e<=d;e+=1){let t=i.rowData[e];if(!t)break;let n=G1(t,e);f+=n.text,p.push(...n.points)}for(let e of f.matchAll(X0)){let t=e[0].replace(/[.,;:!?)\]}'"]+$/,``),n=p[e.index],r=p[e.index+t.length-1];if(!n||!r)continue;let i={start:n,end:r};if(K0(i,c.y,c.x))return{uri:t,range:i}}return null}setHoveredLink(e){let t=this.hoveredLink;this.context.canvas.style.cursor=e?`pointer`:``,(t?.uri!==e?.uri||t?.range.start.x!==e?.range.start.x||t?.range.start.y!==e?.range.start.y)&&(this.hoveredLink=e,this.context.redraw())}beginSelection(e,t){let n=this.context.core,r=this.cellAt(e.clientX,e.clientY),i=n.toScreen(r);if(!i)return;this.selectionMoved=!1,this.selectionMode=t>=3?`line`:t===2?`word`:`cell`;let a=this.selectionMode===`line`?n.selectLine(i):this.selectionMode===`word`?n.selectWord(i):null;this.selectionAnchor=a?a.start:i,this.selectionBase=a,a?n.setSelection(a.start,a.end):(this.selectionMode=`cell`,n.setSelection(i,i)),this.context.redraw()}extendSelection(e,t){let n=this.context.core,r=this.selectionAnchor;if(!r)return;let i=this.cellAt(e,t),a=n.toScreen(i);if(!a)return;this.selectionMoved=!0;let o=this.selectionBase;if(o===null)n.setSelection(r,a);else{let e=this.selectionMode===`line`?n.selectLine(a):n.selectWord(a),t=a.y<o.start.y||a.y===o.start.y&&a.x<o.start.x;n.setSelection(t?o.end:o.start,e?t?e.start:e.end:a)}this.context.redraw()}setSelectionScroll(e){this.selectionScrollDelta=e,e===0?(this.selectionScroll!==null&&window.clearInterval(this.selectionScroll),this.selectionScroll=null):this.selectionScroll===null&&(this.selectionScroll=window.setInterval(()=>{this.context.scrollViewport(this.selectionScrollDelta);let e=this.selectionClient;e&&this.extendSelection(e.x,e.y)},80))}dragScrollbar(e){let t=this.context.core.scrollbarState(),n=this.scrollbarDrag;if(t===null||n===null)return;let r=this.context.scrollbar.getBoundingClientRect(),i=Q0(t,r.height);if(i===null||i.travel===0)return;let a=Math.max(0,Math.min(e-r.top-n.offset,i.travel)),o=Math.round(a/i.travel*i.maxOffset);this.context.scrollViewport(o-t.offset)}onPointerDown=e=>{let t=this.context.canvas;if(this.context.focus(),e.pointerType===`touch`){this.touch={id:e.pointerId,y:e.clientY,moved:!1},t.setPointerCapture(e.pointerId);return}if(this.reportsMouse(e)){let n=Z0(e.button);if(n===null)return;e.preventDefault(),this.mousePointer=e.pointerId,this.mouseButton=n,this.sendMouse(`press`,n,e),t.setPointerCapture(e.pointerId);return}if(e.button!==0)return;if(this.linkAt(e.clientX,e.clientY)&&(J0?e.metaKey:e.ctrlKey)){e.preventDefault(),this.linkPointer=e.pointerId;return}let n=e.timeStamp-this.clicks.time<=Y0&&Math.hypot(e.clientX-this.clicks.x,e.clientY-this.clicks.y)<=4;this.clicks={count:n?this.clicks.count>=3?1:this.clicks.count+1:1,time:e.timeStamp,x:e.clientX,y:e.clientY},this.clickMove=!e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this.context.view().clickToMoveCursor&&this.clicks.count===1?this.cellAt(e.clientX,e.clientY):null,this.selectionPointer=e.pointerId,this.beginSelection(e,this.clicks.count),t.setPointerCapture(e.pointerId)};onPointerMove=e=>{let t=this.touch;if(t?.id===e.pointerId){let n=t.y-e.clientY;if(Math.abs(n)<1)return;t.y=e.clientY,t.moved=!0,this.scrollRows(n,e)}else if(this.mousePointer===e.pointerId||this.context.core.isMouseAnyEventTracking()&&this.reportsMouse(e)){let t=e.buttons,n=t&1?1:t&4?3:t&2?2:null;this.sendMouse(`motion`,n,e)}else if(this.selectionPointer===e.pointerId){let t=this.cellAt(e.clientX,e.clientY);this.clickMove!==null&&(t.x!==this.clickMove.x||t.y!==this.clickMove.y)&&(this.clickMove=null),this.selectionClient={x:e.clientX,y:e.clientY};let n=this.context.canvas.getBoundingClientRect();this.setSelectionScroll(e.clientY<n.top?-1:+(e.clientY>n.bottom)),this.extendSelection(e.clientX,e.clientY)}else this.setHoveredLink(this.linkAt(e.clientX,e.clientY))};onPointerUp=e=>{let t=this.context.canvas;if(t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),this.touch?.id===e.pointerId)this.touch=null;else if(this.linkPointer===e.pointerId){this.linkPointer=null;let t=this.linkAt(e.clientX,e.clientY);t&&e.type===`pointerup`&&this.context.onLink(t.uri,e)}else if(this.mousePointer===e.pointerId)this.sendMouse(`release`,this.mouseButton,e),this.mousePointer=null,this.mouseButton=null;else if(this.selectionPointer===e.pointerId){this.selectionPointer=null,this.setSelectionScroll(0),!this.selectionMoved&&this.selectionMode===`cell`&&(this.context.core.clearSelection(),this.selectionAnchor=null,this.context.redraw());let t=this.clickMove;this.clickMove=null,t!==null&&e.type===`pointerup`&&this.context.moveCursorTo(t)}};onPointerLeave=()=>{this.lastMotion=``,this.setHoveredLink(null)};onWheel=e=>{if(e.deltaY===0)return;e.preventDefault();let t=this.context.view(),n=e.deltaMode===1?e.deltaY*t.metrics.height:e.deltaMode===2?e.deltaY*t.rows*t.metrics.height:e.deltaY;this.scrollRows(n,e)};onMouseDown=e=>{e.button===0&&e.preventDefault(),this.context.focus()};onScrollbarDown=e=>{let t=this.context.core.scrollbarState();if(e.button!==0||t===null)return;let n=this.context.scrollbar,r=n.getBoundingClientRect(),i=Q0(t,r.height);i!==null&&(e.preventDefault(),e.stopPropagation(),this.scrollbarDrag={id:e.pointerId,offset:e.target===this.context.thumb?e.clientY-r.top-i.thumbTop:i.thumbHeight/2},n.setPointerCapture(e.pointerId),this.dragScrollbar(e.clientY))};onScrollbarMove=e=>{this.scrollbarDrag?.id===e.pointerId&&(e.preventDefault(),this.dragScrollbar(e.clientY))};onScrollbarUp=e=>{if(this.scrollbarDrag?.id!==e.pointerId)return;this.scrollbarDrag=null;let t=this.context.scrollbar;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}},e2=[`\r`,`
114
114
  `,``,``,``,``,`\x1B[99;5u`,`\x1B[100;5u`,`\x1B[111;5u`,`\x1B[122;5u`];function t2(e,t){return e.y<t.y||e.y===t.y&&e.x<t.x}var n2=class{shell=`unknown`;generation=0;core;native=!1;input=!1;clickEvents=!1;inputRef=null;constructor(e){this.core=e}mark(e,t){let n=e.startsWith(`133;`),r=n?4:5;if(e.length>r+1&&e[r+1]!==`;`)return;let i=e.charAt(r);if(!this.core.isAlternateScreen()){if(i===`A`){let r=e.split(`;`);if(r.includes(`k=s`)||r.includes(`k=c`))return;let i=n&&r.includes(`click_events=1`),a=this.shell===`prompt`,o=a&&!this.input&&this.native!==n;if(this.shell=`prompt`,this.native=n,t&&this.trackInput(),o){this.clickEvents=this.clickEvents||i;return}if(this.input=!1,this.clickEvents=i,a)return;this.generation+=1}else if(i===`B`)this.shell=`prompt`,this.input=!0,t&&this.trackInput();else if(i===`C`)this.shell=`command`;else if(i===`D`){if(this.shell===`prompt`&&!this.input)return;this.shell=`unknown`}}}beforeInput(e){this.shell===`prompt`&&e2.some(t=>e.includes(t))&&(this.shell=`unknown`)}reset(){this.release(),this.shell=`unknown`,this.input=!1,this.clickEvents=!1}release(){this.inputRef!==null&&this.core.untrack(this.inputRef),this.inputRef=null}moveCursorInput(e,t,n){if(this.shell!==`prompt`||this.inputRef===null||t===null||t.cursorX<0||t.cursorY<0||this.core.isAlternateScreen()||this.core.isMouseTracking())return null;let r=this.core.trackedPoint(this.inputRef);if(r===null)return null;let i={x:r.x,y:r.y-n};if(t2(e,i))return null;if(this.clickEvents){let t=this.core.scrollbarState();if(t===null)return null;let r=e.y+n-(t.total-t.len);return r<0?null:`\x1b[<0;${e.x+1};${r+1}M`}if(!this.input)return null;let a={x:e.x,y:e.y};a.x>0&&t.rowData[a.y]?.cells[a.x]?.wide===I1.spacerTail&&--a.x;let o={x:t.cursorX,y:t.cursorY};if(t2(a,i)||t2(o,i))return null;let s=t2(a,o),c=s?a:o,l=s?o:a,u=0;for(let e=c.y;e<=l.y;e+=1){let n=t.rowData[e];if(n===void 0)return null;let r=e===l.y?l.x:n.cells.length;for(let t=e===c.y?c.x:0;t<r;t+=1)n.cells[t].text!==``&&(u+=1);if(e<l.y&&!n.wrapsToNext){if(s)return null;break}}let d=s?`ArrowLeft`:`ArrowRight`,f=this.core.encoder.encodeKey(new KeyboardEvent(`keydown`,{key:d,code:d}));return u>0?f.repeat(u):``}trackInput(){this.inputRef===null?this.inputRef=this.core.trackCursor():this.core.retrack(this.inputRef)}},r2=navigator.userAgent.includes(`Mac`),i2=600,a2=1e3,o2=1e4,s2=new TextDecoder(`latin1`),c2=new TextDecoder;function l2(e){let t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)throw Error(`unsupported color ${e}`);return{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}}function u2(e){return[...e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0).map(e=>/^(['"]).*\1$/.test(e)||/^[a-zA-Z][a-zA-Z0-9-]*$/.test(e)?e:`"${e.replaceAll(`"`,``)}"`),`monospace`].join(`, `)}async function d2(e){try{(await e)?.close()}catch(e){console.warn(`could not decode image`,e)}}var f2=class{element;cols=80;rows=24;canvas;input;context;core;scanner=new y0;handlers;observer;prompt;search;images;pointer;notifications=new p0;options;appearance;metrics;snapshot=null;sized=!1;fitted=!1;frame=0;forceFull=!0;renderFailed=!1;cursorOn=!0;cursorTimer=null;syncTimer=null;renderedCursorY=null;focused=!1;composing=!1;suppressedKeys=new Set;heldOptionKeys=new Set;backlog=[];blocked=!1;epoch=0;title=``;progress={state:0,value:0};disposed=!1;constructor(e,t){this.options=e,this.handlers=t,this.element=document.createElement(`div`),this.element.className=`relative h-full overflow-hidden`,this.canvas=document.createElement(`canvas`),this.canvas.className=`absolute top-0 left-0 cursor-text touch-none`,this.input=document.createElement(`textarea`),this.input.setAttribute(`aria-label`,`Terminal input`),this.input.autocapitalize=`off`,this.input.autocomplete=`off`,this.input.spellcheck=!1,this.input.style.cssText=`position:absolute;left:0;top:0;width:1px;height:1px;opacity:0;padding:0;border:0;resize:none;pointer-events:none;`;let n=document.createElement(`div`);n.className=`absolute top-0 right-0 bottom-0 w-2 cursor-default touch-none`,n.hidden=!0;let r=document.createElement(`div`);r.className=`bg-foreground/15 hover:bg-foreground/30 absolute inset-x-0.5 top-0 rounded-full`,n.append(r),this.element.append(this.canvas,this.input,n);let i=this.canvas.getContext(`2d`,{alpha:!1});if(!i)throw Error(`canvas 2d is unavailable`);this.context=i,this.appearance=this.appearanceFor(e),this.metrics=this.measure(),this.core=new $1(Math.max(1,Math.floor(window.innerWidth/this.metrics.width)),this.rows,e.scrollback,t.onReply,t.onBell),this.prompt=new n2(this.core),this.search=new t0(this.core,()=>this.redraw()),this.images=new P$(this.core),this.pointer=new $0({canvas:this.canvas,scrollbar:n,thumb:r,core:this.core,view:()=>({cols:this.cols,rows:this.rows,metrics:this.metrics,snapshot:this.snapshot,clickToMoveCursor:this.options.clickToMoveCursor}),focus:()=>this.focus(),redraw:()=>this.redraw(),scrollViewport:e=>this.scrollViewport(e),moveCursorTo:e=>this.moveCursorTo(e),onData:t.onData,onLink:t.onLink}),this.applyTerminalOptions(),this.resizeCore(),this.installEvents(),this.observer=new ResizeObserver(()=>this.fit()),this.observer.observe(this.element)}setOptions(e){this.options=e,this.appearance=this.appearanceFor(e),this.metrics=this.measure(),e.clickToMoveCursor||this.prompt.release(),this.applyTerminalOptions(),this.resizeCore(),this.forceFull=!0,this.fit(),this.requestRender()}write(e,t){this.disposed||(this.backlog.push({data:e,replay:t}),this.blocked||this.drain())}reset(){this.epoch+=1,this.backlog=[],this.blocked=!1,this.scanner.reset(),this.prompt.reset(),this.core.reset(),this.applyTerminalOptions(),this.images.clear(),this.core.clearSelection(),this.redraw()}focus(){this.input.focus({preventScroll:!0})}isKittyKeyboard(){return this.core.isKittyKeyboard()}paste(e){let t=this.core.encoder.encodePaste(e);t.length>0&&this.sendInput(t)}presize(e,t){this.fitted||e===this.cols&&t===this.rows||(this.cols=e,this.rows=t,this.resizeCore())}fit(){if(this.disposed)return;let e=this.element.clientWidth,t=this.element.clientHeight;if(e===0||t===0){this.sized=!1;return}this.sized=!0,this.fitted=!0;let n=window.devicePixelRatio||1,r=Math.round(e*n),i=Math.round(t*n);(this.canvas.width!==r||this.canvas.height!==i)&&(this.canvas.width=r,this.canvas.height=i,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this.context.setTransform(n,0,0,n,0,0),this.metrics=this.measure(),this.resizeCore(),this.forceFull=!0);let a=Math.max(1,Math.floor(e/this.metrics.width)),o=Math.max(1,Math.floor(t/this.metrics.height));(a!==this.cols||o!==this.rows)&&(this.cols=a,this.rows=o,this.resizeCore(),this.forceFull=!0,this.handlers.onResize(a,o)),this.renderFrame()}find(e,t,n){let r=this.viewportTop(),i=this.search.find(e,t,n,r);i!==null&&(i.row<r||i.row>=r+this.rows)&&this.scrollViewport(i.row-r-Math.floor(this.rows/2)),this.redraw()}onFindResults(e){return this.search.onResults(e)}clearFind(){this.search.clear(),this.redraw()}replyClipboard(e,t){t.epoch!==this.epoch||t.generation!==this.prompt.generation||t.atPrompt&&this.prompt.shell!==`prompt`||this.handlers.onReply(c0(e,t.selection,t.terminator))}beforeInput(e){this.prompt.beforeInput(e)}dispose(){this.disposed||(this.disposed=!0,this.observer.disconnect(),this.cancelRender(),this.pointer.dispose(),this.search.dispose(),window.removeEventListener(`focus`,this.onWindowFocus),document.removeEventListener(`visibilitychange`,this.onVisibilityChange),this.images.clear(),this.prompt.release(),this.core.dispose(),this.element.remove())}redraw(){this.forceFull=!0,this.requestRender()}resizeCore(){this.core.resize(this.cols,this.rows,this.metrics.width,this.metrics.height,window.devicePixelRatio||1)}appearanceFor(e){let t=e.colors;return{fontSize:e.fontSize,fontFamily:u2(e.fontFamily),ligatures:e.ligatures,cursorText:t.cursorText,selectionBackground:t.selectionBackground,selectionForeground:t.selectionForeground,matchBackground:t.palette[8],activeMatchBorder:t.palette[3]}}measure(){return W0(this.context,this.options.fontSize,this.appearance.fontFamily,this.options.lineHeight,window.devicePixelRatio||1)}applyTerminalOptions(){let e=this.options.colors;this.core.setColors({foreground:l2(e.foreground),background:l2(e.background),cursor:l2(e.cursor),palette:e.palette.map(l2)}),this.core.setCursor(this.options.cursorStyle,this.options.cursorBlink),this.core.boldIsBright=this.options.boldIsBright,this.core.version=this.options.version,this.core.invalidate()}drain(){for(;!this.blocked&&this.backlog.length>0;){let e=this.backlog.shift();e&&this.process(e)}let e=this.core.title();e!==this.title&&(this.title=e,this.handlers.onTitle(e)),this.search.outputChanged(),this.cursorOn=!0,this.requestRender()}process(e){let t=e.data,n=e.replay;this.core.setReplies(!n);let r=0,i=this.scanner.scan(t,(e,i)=>(this.core.write(t.subarray(r,i)),r=i,this.handleOutput(e,n)));this.core.write(t.subarray(r,i)),i<t.length&&this.backlog.unshift({data:t.subarray(i),replay:n})}handleOutput(e,t){if(e.type===`sixel`)return this.decodeImage(A$(e.data));let n=s2.decode(e.data);if(n.startsWith(`1337;File=`))return this.decodeImage(M$(n.slice(10),{cellWidth:this.metrics.width,cellHeight:this.metrics.height,width:this.cols*this.metrics.width,height:this.rows*this.metrics.height,pixelRatio:window.devicePixelRatio||1}));if(n.startsWith(`133;`)||n.startsWith(`6973;`))return this.prompt.mark(n,this.options.clickToMoveCursor),!1;if(n.startsWith(`52;`)){let r=n.split(`;`),i=r[2];if(t||i===void 0)return!1;if(i===`?`)return this.handlers.onClipboardRead({selection:o0(r[1]),terminator:e.terminator,generation:this.prompt.generation,epoch:this.epoch,atPrompt:this.prompt.shell===`prompt`}),!1;let a=s0(i);return a!==null&&this.handlers.onClipboard(a),!1}if(n===`10;?`||n===`11;?`||n===`12;?`)return t||this.handlers.onReply(l0(n,this.core.currentColors(),e.terminator)),!1;if(n.startsWith(`4;`)){if(!t)for(let t of u0(n,this.core.currentColors().palette,e.terminator))this.handlers.onReply(t);return!1}if(n===`9;4`||n.startsWith(`9;4;`)){let e=d0(n,this.progress);return e!==null&&(this.progress=e,this.handlers.onProgress(e)),!1}if(t)return!1;let r=n.startsWith(`99;`)?this.notifications.add(c2.decode(e.data)):f0(n,e.data);return r!==null&&this.handlers.onNotify(r.title,r.body),!1}decodeImage(e){return this.blocked=!0,this.placeImage(e,this.epoch,window.devicePixelRatio||1),!0}async placeImage(e,t,n){let r=0,i=new Promise(e=>{r=window.setTimeout(()=>e(`timeout`),o2)});try{let r=await Promise.race([e,i]);r===`timeout`?(console.warn(`image decoding took too long, skipping the image`),d2(e)):r!==null&&(t===this.epoch&&!this.disposed?this.images.place(r,n,this.metrics.height):r.close())}catch(e){console.warn(`could not decode image`,e)}window.clearTimeout(r),!(t!==this.epoch||this.disposed)&&(this.blocked=!1,this.drain())}moveCursorTo(e){if(!this.options.clickToMoveCursor)return;let t=this.prompt.moveCursorInput(e,this.snapshot,this.viewportTop());t!==null&&(t!==``&&this.sendInput(t),this.core.clearSelection(),this.redraw())}sendInput(e){this.prompt.beforeInput(e),this.core.scrollbarState()?.offset!==this.maxOffset()&&(this.core.scrollToBottom(),this.redraw()),this.handlers.onData(e)}maxOffset(){let e=this.core.scrollbarState();return e?Math.max(0,e.total-e.len):0}viewportTop(){return this.core.toScreen({x:0,y:0})?.y??0}scrollViewport(e){let t=this.core.scrollbarState(),n=Math.trunc(e);if(t!==null){let e=Math.max(0,t.total-t.len);n=Math.max(0,Math.min(t.offset+n,e))-t.offset}n!==0&&(this.core.scroll(n),this.redraw())}requestRender(){!this.disposed&&this.sized&&this.frame===0&&(this.frame=window.requestAnimationFrame(()=>{this.frame=0,this.renderFrame()}))}cancelRender(){this.frame!==0&&window.cancelAnimationFrame(this.frame),this.frame=0,this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,this.syncTimer!==null&&window.clearTimeout(this.syncTimer),this.syncTimer=null}renderFrame(){if(!this.disposed&&this.sized&&this.element.isConnected){this.frame!==0&&window.cancelAnimationFrame(this.frame),this.frame=0;try{this.draw(),this.renderFailed=!1}catch(e){this.renderFailed||console.error(`could not draw the terminal`,e),this.renderFailed=!0}}}draw(){if(this.core.isSynchronizedOutput()){this.syncTimer===null&&(this.syncTimer=window.setTimeout(()=>{this.syncTimer=null,this.core.endSynchronizedOutput(),this.requestRender()},a2));return}this.syncTimer!==null&&window.clearTimeout(this.syncTimer),this.syncTimer=null;let e=this.core.snapshot();this.snapshot=e;let t=this.focused&&e.cursorBlinking&&e.cursorVisible;t||(this.cursorOn=!0);let n=this.viewportTop(),r=this.images.visible(n,this.rows,this.metrics.height),i=this.core.cellSize(),a=this.core.kitty.images(e.rowData,i);q0({context:this.context,snapshot:e,metrics:this.metrics,appearance:this.appearance,forceFull:this.forceFull||r.length>0||a.length>0,cursorOn:this.cursorOn,previousCursorY:this.renderedCursorY,focused:this.focused,hoveredLink:this.pointer.hoveredLink?.range??null,highlights:this.search.highlights(e,n),pixelRatio:window.devicePixelRatio||1,drawLayer:e=>C1(this.context,a,e,this.metrics,i)}),C1(this.context,a,`aboveText`,this.metrics,i);for(let e of r)this.context.drawImage(e.bitmap,e.x*this.metrics.width,e.y*this.metrics.height,e.width,e.height);this.forceFull=r.length>0||a.length>0,this.renderedCursorY=this.cursorOn&&e.cursorVisible&&e.cursorY>=0?e.cursorY:null,e.cursorX>=0&&e.cursorY>=0&&(this.input.style.left=`${e.cursorX*this.metrics.width}px`,this.input.style.top=`${e.cursorY*this.metrics.height}px`),this.pointer.updateScrollbar(this.element.clientHeight),this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,t&&(this.cursorTimer=window.setTimeout(()=>{this.cursorTimer=null,this.cursorOn=!this.cursorOn,this.requestRender()},i2))}copySelection(){let e=this.core.selectionText();e.length!==0&&(window.isSecureContext?navigator.clipboard.writeText(e):console.warn(`copy from the terminal needs https or localhost`))}optionIsMeta(e){if(!r2||!e.altKey||e.metaKey)return!1;let t=this.options.optionAsMeta;if(t===`off`)return!1;if(t===`both`)return!0;if(t===`left`)return this.heldOptionKeys.has(`AltLeft`);if(t===`right`)return this.heldOptionKeys.has(`AltRight`);throw Error(`unknown option as meta mode ${t}`)}onKeyDown=e=>{if((e.code===`AltLeft`||e.code===`AltRight`)&&this.heldOptionKeys.add(e.code),!this.handlers.beforeKey(e)){this.suppressedKeys.add(e.code);return}let t=this.optionIsMeta(e),n=t&&this.core.encoder.metaText(e)!==null;if(e.isComposing||this.composing||!n&&(e.key===`Process`||e.keyCode===229)||r2&&this.options.optionAsMeta!==`off`&&!t&&e.altKey&&!e.ctrlKey&&!e.metaKey&&([...e.key].length===1||e.key===`Dead`)||!n&&e.getModifierState(`AltGraph`)&&[...e.key].length===1){this.suppressedKeys.add(e.code);return}let r=e.key.toLowerCase();if(r2?e.metaKey&&r===`c`:e.ctrlKey&&e.shiftKey&&r===`c`||e.ctrlKey&&!e.shiftKey&&r===`insert`){this.copySelection(),e.preventDefault(),this.suppressedKeys.add(e.code);return}if((r2?e.metaKey&&r===`v`:e.ctrlKey&&e.shiftKey&&r===`v`||e.shiftKey&&!e.ctrlKey&&r===`insert`)||r2&&e.metaKey&&r===`q`){this.suppressedKeys.add(e.code);return}let i=this.core.encoder.encodeKey(e,`press`,n);i.length!==0&&(this.suppressedKeys.delete(e.code),e.preventDefault(),e.stopPropagation(),this.core.selectionText().length>0&&!e.shiftKey&&(this.core.clearSelection(),this.forceFull=!0),this.sendInput(i))};onKeyUp=e=>{if(this.heldOptionKeys.delete(e.code),this.suppressedKeys.delete(e.code)||e.isComposing||this.composing)return;let t=this.core.encoder.encodeKey(e,`release`,this.optionIsMeta(e));t.length!==0&&(e.preventDefault(),this.handlers.onData(t))};onInput=e=>{let t=e;if(this.composing||t.isComposing)return;let n=this.input.value||t.data||``;this.input.value=``,n.length>0&&this.sendInput(n)};onCompositionStart=()=>{this.composing=!0};onCompositionEnd=e=>{this.composing=!1;let t=this.input.value||e.data;this.input.value=``,t.length>0&&this.sendInput(t)};onPaste=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`)??``;t.length>0&&this.paste(t)};onCopy=e=>{let t=this.core.selectionText();t.length!==0&&e.clipboardData&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,t))};onWindowFocus=()=>{r2&&this.options.optionAsMeta!==`off`&&this.core.encoder.refreshKeyboardLayout()};onContextRestored=()=>{let e=window.devicePixelRatio||1;this.context.setTransform(e,0,0,e,0,0),this.redraw()};onVisibilityChange=()=>{document.visibilityState===`visible`&&this.redraw()};onFocus=()=>{this.focused=!0,this.cursorOn=!0,this.requestRender(),!this.disposed&&this.core.isFocusReporting()&&this.handlers.onReply(`\x1B[I`)};onBlur=()=>{this.focused=!1,this.heldOptionKeys.clear(),this.cursorOn=!0,this.requestRender(),!this.disposed&&this.core.isFocusReporting()&&this.handlers.onReply(`\x1B[O`)};installEvents(){this.input.addEventListener(`keydown`,this.onKeyDown),this.input.addEventListener(`keyup`,this.onKeyUp),this.input.addEventListener(`input`,this.onInput),this.input.addEventListener(`compositionstart`,this.onCompositionStart),this.input.addEventListener(`compositionend`,this.onCompositionEnd),this.input.addEventListener(`paste`,this.onPaste),this.input.addEventListener(`copy`,this.onCopy),this.input.addEventListener(`focus`,this.onFocus),this.input.addEventListener(`blur`,this.onBlur),this.canvas.addEventListener(`contextrestored`,this.onContextRestored),window.addEventListener(`focus`,this.onWindowFocus),document.addEventListener(`visibilitychange`,this.onVisibilityChange)}};function p2(e){return e.key===`Enter`&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey}function m2(e){let t=new f2(O2(),{onData:t=>{j2().status===`active`&&V2(e,h2(t))},onReply:t=>{t===`\x1B[I`||t===`\x1B[O`?V2(e,t):H2(e,t)},onResize:(t,n)=>B2({type:`resize`,id:e,cols:t,rows:n}),onTitle:t=>M2({titles:{...j2().titles,[e]:t}}),onProgress:t=>M2({progress:{...j2().progress,[e]:t}}),onBell:()=>{let n=N2().behavior;n.bellSound&&m4(),n.bellFlash&&t.element.isConnected&&!document.hidden&&t.element.animate([{opacity:.4},{opacity:1}],{duration:200,easing:`ease-out`}),d4(e)},onNotify:(t,n)=>f4(e,t,n),onClipboard:XX,onClipboardRead:n=>{l4(e)&&ZX(e=>t.replyClipboard(e,n))},onLink:e=>{e.startsWith(`file:`)?$C(e):window.open(e,`_blank`,`noopener`)},beforeKey:n=>{if(n.type!==`keydown`)return!0;let r=N2(),i=T9(Z(),k2()).system;if(i===null)throw Error(`the terminal machine is not connected`);let a=i.platform;if(j2().status===`active`&&r.behavior.modernizeShiftEnter&&p2(n)&&!t.isKittyKeyboard())return n.preventDefault(),t.beforeInput(`\x1B\r`),V2(e,`\x1B\r`),!1;if(j2().status===`active`&&r.behavior.pasteBrowserImages&&window.isSecureContext&&$X(n,a)){n.preventDefault();let r=QX[a].data;return t.beforeInput(r),eZ(k2(),t).then(t=>{t||V2(e,r)}).catch(t=>{nZ(t),V2(e,r)}),!1}return!X2(n)||(n.preventDefault(),M2({finding:e}),document.querySelector(`[data-find]`)?.select(),!1)}});return t.element.addEventListener(`paste`,e=>{if(!e.clipboardData||e.clipboardData.getData(`text/plain`)!==``)return;let n=[...e.clipboardData.files].filter(e=>e.type.startsWith(`image/`));n.length!==0&&(e.preventDefault(),e.stopPropagation(),tZ(k2(),t,n).catch(nZ))},!0),t}function h2(e){if(!j2().ctrl||(M2({ctrl:!1}),e.length!==1))return e;let t=e.toUpperCase().charCodeAt(0);return t>=64&&t<=95?String.fromCharCode(t-64):e}function g2(){return{titles:{},progress:{},alerts:[],finding:null,quiet:[]}}var _2=new TextEncoder,v2=new Map,y2=new Set,b2=new Set,x2={status:`connecting`,failure:null,loaded:!1,open:!1,instance:null,layout:{},ctrl:!1,...g2()},S2=null,C2=null,w2=!1;async function T2(){R2(),c9.history.subscribe(R2);try{await Promise.all([W$(),sR(N2())]),M2({loaded:!0})}catch(e){console.error(`could not start the terminal`,e),M2({failure:rt(e)});return}Qo({close:e=>{e===C2&&M2({status:`connecting`})},terminal:(e,t)=>{e===C2&&(J2(t),b4())},frame:(e,t)=>{e===C2&&q2(t)}}),E2(),document.addEventListener(`visibilitychange`,()=>M2({})),window.addEventListener(`focus`,()=>{M2({}),S2!==null&&Z2(S2,Q2(S2))}),window.addEventListener(`blur`,()=>M2({})),`serviceWorker`in navigator&&navigator.serviceWorker.addEventListener(`message`,e=>{e.data.type===`select`&&z2(e.data.machine,e.data.project,e.data.tabId)});let e=Z().prefs,t=D2();yue(()=>{E2();let n=Z().prefs,r=D2(),i=n.theme!==e.theme||n.terminal!==e.terminal||r!==t;e=n,t=r,i&&e4()}),t4()}function E2(){let e=Z().selection?.machine??null;if(e!==C2&&(C2!==null&&w2&&B2({type:`detach`}),Y2({}),y2.clear(),C2=e,w2=!1,M2({status:`connecting`,instance:null,layout:{},...g2()})),C2===null)return;let t=T9(Z(),C2).status===`online`;t&&!w2&&(w2=!0,B2({type:`attach`})),t||(w2=!1)}function D2(){return C2===null?null:T9(Z(),C2).config?.terminal.behavior.terminalIdentity??null}function O2(){if(C2===null)throw Error(`the terminal has no machine`);let e=T9(Z(),C2);if(e.config===null||e.system===null)throw Error(`${e.name} is not connected`);return Kae(N2(),e.config.terminal.behavior.terminalIdentity)}function k2(){if(C2===null)throw Error(`the terminal has no machine`);return C2}function A2(e){return b2.add(e),()=>{b2.delete(e)}}function j2(){return x2}function M2(e){x2={...x2,...e},x2={...x2,...h4(e=>v2.has(e))},g4();for(let e of b2)e()}function N2(){return Z().prefs.terminal}function P2(){let e=Z().selection?.projectId;return e===void 0?null:{projectId:e,project:x2.layout[e]??null}}function F2(e){for(let[t,n]of Object.entries(x2.layout))if(n.tabs.some(t=>t.id===e))return{projectId:t,project:n};return null}function I2(e){return(e.customName??x2.titles[e.id])||`Terminal`}function L2(e){e?ZC({bottom:`terminal`}):ew(`overlay`,()=>ZC({bottom:void 0}))}function R2(){let e=YC().bottom===`terminal`;e!==x2.open&&M2({open:e})}function z2(e,t,n){let r=Z().selection;(r?.machine!==e||r.projectId!==t)&&rw({machine:e,projectId:t,sessionId:null}),L2(!0),B2({type:`select`,projectId:t,tabId:n})}function B2(e){C2!==null&&$o(C2)&&L(C2,`terminal`,e).catch(e=>console.error(`terminal request failed`,e))}function V2(e,t){C2!==null&&ts(C2,0,e,typeof t==`string`?_2.encode(t):t)}function H2(e,t){C2!==null&&ts(C2,1,e,_2.encode(t))}function U2(e,t,n,r){Q2(e).find(t,n,r)}function W2(e,t){return Q2(e).onFindResults(t)}function G2(e){let t=Q2(e);t.clearFind(),M2({finding:null}),t.focus()}function K2(){M2({ctrl:!x2.ctrl})}function q2(e){let t=v2.get(e.id);if(!t)return;let n=e.kind===3,r=n&&y2.delete(e.id);r&&t.reset(),t.write(e.data,n),r&&y2.size===0&&M2({status:`active`}),n||S4(e.id),b4()}function J2(e){let t=e.type===`active`&&e.instance!==x2.instance;if(t&&Y2({}),Y2(e.layout),e.type===`active`){y2.clear(),v2.forEach((e,t)=>{y2.add(t),e.element.isConnected&&Z2(t,e)}),M2({...t&&{instance:e.instance,...g2()},status:y2.size===0?`active`:`connecting`,layout:e.layout});return}for(let e of y2)v2.has(e)||y2.delete(e);let n=Z().selection?.projectId,r=n!==void 0&&(x2.layout[n]?.tabs.length??0)>0&&e.layout[n]?.tabs.length===0;M2({status:y2.size===0?`active`:`connecting`,layout:e.layout}),r&&x2.open&&L2(!1)}function Y2(e){let t=new Set(Object.values(e).flatMap(e=>e.tabs.map(e=>e.id)));v2.forEach((e,n)=>{t.has(n)||(e.dispose(),v2.delete(n),C4(n))});for(let e of t)v2.has(e)||v2.set(e,m2(e))}function X2(e){return e.key.toLowerCase()===`f`?tt?e.metaKey&&!e.ctrlKey&&!e.altKey:e.ctrlKey&&e.shiftKey&&!e.altKey&&!e.metaKey:!1}function Z2(e,t){B2({type:`resize`,id:e,cols:t.cols,rows:t.rows})}function Q2(e){let t=v2.get(e);if(!t)throw Error(`terminal ${e} does not exist`);return t}function $2(e,t){let n=Q2(e);t.append(n.element),n.fit();for(let e of v2.values())e.presize(n.cols,n.rows);return S2=e,Z2(e,n),n.focus(),()=>{n.element.remove(),S2===e&&(S2=null)}}async function e4(){if(await sR(N2()),v2.size>0){let e=O2();for(let t of v2.values())t.setOptions(e)}M2({})}function t4(){let e=YC(),t=e.machine,n=e.project,r=e.terminal;if(t===void 0||n===void 0||r===void 0)return;ZC({terminal:void 0});let i=A2(()=>{x2.status===`active`&&C2===t&&(i(),z2(t,n,Number(r)))})}var n4=new Map,r4=new Map,i4=new Map,a4=new Set,o4=null,s4=0,c4=!1;function l4(e){return j2().open&&P2()?.project?.activeTab===e&&!document.hidden&&document.hasFocus()}function u4(e){if(l4(e))return!1;let t=j2();return t.alerts.includes(e)||M2({alerts:[...t.alerts,e]}),!0}function d4(e){if(!u4(e)||r4.has(e))return;let t=n4.get(e);t!==void 0&&performance.now()-t<5e3||r4.set(e,window.setTimeout(()=>{r4.delete(e),!l4(e)&&(n4.set(e,performance.now()),p4(e,``,`Bell`))},500))}function f4(e,t,n){u4(e)&&(window.clearTimeout(r4.get(e)),r4.delete(e),n4.set(e,performance.now()),p4(e,t,n))}function p4(e,t,n){let r=F2(e),i=r?.project.tabs.find(t=>t.id===e);r&&i&&vX(t||I2(i),n,{machine:k2(),project:r.projectId,tabId:e}).catch(e=>console.error(`could not show a notification`,e))}function m4(){let e=performance.now();if(e-s4<150)return;s4=e,o4??=new AudioContext,o4.state===`suspended`&&o4.resume();let t=o4.createOscillator(),n=o4.createGain(),r=o4.currentTime;t.frequency.value=880,n.gain.setValueAtTime(.1,r),n.gain.exponentialRampToValueAtTime(.001,r+.15),t.connect(n).connect(o4.destination),t.start(r),t.stop(r+.15)}function h4(e){let t=j2();return{alerts:t.alerts.filter(t=>e(t)&&!l4(t)),quiet:t.quiet.filter(e)}}function g4(){let e=j2().status===`active`;if(e&&!c4)for(let e of i4.keys())_4(e);c4=e}function _4(e){window.clearTimeout(i4.get(e)),a4.delete(e);let t=Date.now();i4.set(e,window.setTimeout(()=>{j2().status===`active`&&(Date.now()-t>15e3?_4(e):(a4.add(e),v4()))},1e4))}async function v4(){await ns(k2())&&b4()}function y4(e){i4.delete(e),a4.delete(e),u4(e)&&p4(e,``,`No output for 10 seconds`)}function b4(){if(j2().status===`active`)for(let e of a4)y4(e)}function x4(e){let t=j2();t.quiet.includes(e)?(window.clearTimeout(i4.get(e)),i4.delete(e),a4.delete(e),M2({quiet:t.quiet.filter(t=>t!==e)})):M2({quiet:[...t.quiet,e]})}function S4(e){j2().quiet.includes(e)&&_4(e)}function C4(e){window.clearTimeout(r4.get(e)),r4.delete(e),n4.delete(e),window.clearTimeout(i4.get(e)),i4.delete(e),a4.delete(e)}var w4=null,T4=new Set,E4=new Set;function D4(e){return E4.add(e),()=>{E4.delete(e)}}function O4(){return w4}function k4(){w4!==null&&A4({open:!1,closing:w4.closing})}function A4(e){w4=e;for(let e of E4)e()}function j4(){return document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)!==null}function M4(e){return F2(e)?.project.tabs.find(t=>t.id===e)}async function N4(e){try{let t=await Promise.race([L(k2(),`terminal.busy`,{id:e}),new Promise((e,t)=>window.setTimeout(()=>t(Error(`timed out`)),5e3))]);return`error`in t?(console.error(`could not check whether tab ${e} is running a program`,t.error),{checked:!1}):{checked:!0,program:t.program}}catch(e){return console.error(`could not check whether a program is running`,e),{checked:!1}}}async function P4(e){if(!N2().behavior.confirmCloseBusyTab){B2({type:`closeTab`,id:e});return}if(!M4(e)||T4.has(e))return;T4.add(e);let t=await N4(e);if(T4.delete(e),t.checked&&t.program===null){B2({type:`closeTab`,id:e});return}let n=M4(e);n&&!j4()&&A4({open:!0,closing:{id:e,name:I2(n),program:t.checked?t.program:null}})}var F4=tt?`meta+t`:`ctrl+shift+t`,I4=tt?`meta+w`:`ctrl+shift+w`,L4=`ctrl+tab`,R4=`ctrl+shift+tab`;function z4(){let e=P2()?.project;j2().open&&e&&e.activeTab!==null&&Q2(e.activeTab).focus()}function B4(){return Av([F4,I4,L4,R4],(e,t)=>{e.preventDefault(),e.stopPropagation();let n=P2();if(n===null)return;if(t.hotkey===F4){B2({type:`createTab`,projectId:n.projectId});return}let r=n.project;if(r===null||r.activeTab===null)return;if(t.hotkey===I4){P4(r.activeTab);return}let i;if(t.hotkey===L4)i=1;else if(t.hotkey===R4)i=-1;else throw Error(`unknown terminal shortcut ${t.hotkey}`);let a=r.tabs.filter(e=>!e.minimized),o=a[(a.findIndex(e=>e.id===r.activeTab)+i+a.length)%a.length];o&&B2({type:`select`,projectId:n.projectId,tabId:o.id})},{enabled:()=>N2().behavior.captureShortcuts,enableOnFormTags:!0,eventListenerOptions:{capture:!0}})}function V4(e){let[t,n]=(0,F.useState)(e.name);return(0,I.jsx)(Ke,{open:!0,onOpenChange:t=>{t||e.onDone()},children:(0,I.jsx)(Ne,{onCloseAutoFocus:U4,children:(0,I.jsxs)(`form`,{className:`grid gap-4`,onSubmit:n=>{n.preventDefault(),B2({type:`renameTab`,id:e.id,name:t.trim()}),e.onDone()},children:[(0,I.jsx)(Fe,{children:(0,I.jsx)(Ve,{children:`Rename tab`})}),(0,I.jsx)(kL,{"aria-label":`Name`,placeholder:`Use terminal title`,value:t,onChange:e=>n(e.target.value)}),(0,I.jsxs)(qe,{children:[(0,I.jsx)(x,{type:`button`,variant:`outline`,onClick:e.onDone,children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,children:`Rename`})]})]})})})}function H4(){let e=(0,F.useSyncExternalStore)(D4,O4),t=(0,F.useRef)(null);if(e===null)return null;let n=e.closing;return(0,I.jsx)(HL,{open:e.open,onOpenChange:e=>{e||k4()},children:(0,I.jsxs)(WL,{onOpenAutoFocus:e=>{e.preventDefault(),t.current?.focus()},onCloseAutoFocus:U4,children:[(0,I.jsxs)(GL,{children:[(0,I.jsxs)(qL,{children:[`Close “`,n.name,`”?`]}),(0,I.jsx)(JL,{children:n.program===null?`OffSite couldn’t check whether a program is still running.`:`${n.program} is still running.`})]}),(0,I.jsxs)(KL,{children:[(0,I.jsx)(XL,{children:`Cancel`}),(0,I.jsx)(YL,{ref:t,variant:`destructive`,onClick:()=>B2({type:`closeTab`,id:n.id}),children:`Close`})]})]})})}function U4(e){e.preventDefault();let t=document.querySelector(`[role="dialog"], [role="alertdialog"]`);t===null?z4():t.focus()}function W4(e){let t=(0,F.useRef)(null),[n,r]=(0,F.useState)(``),[i,a]=(0,F.useState)({resultIndex:-1,resultCount:0});(0,F.useEffect)(()=>W2(e.id,a),[e.id]),(0,F.useEffect)(()=>t.current?.focus(),[]);function o(t,n,i){r(t),U2(e.id,t,n,i)}return(0,I.jsxs)(`div`,{className:`bg-card absolute top-2 right-4 z-10 flex items-center gap-1 rounded-lg border p-1 shadow-lg`,children:[(0,I.jsx)(kL,{ref:t,"data-find":!0,className:`h-7 w-52`,placeholder:`Find`,value:n,onChange:e=>o(e.target.value,!1,!0),onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),G2(e.id)):t.key===`Enter`?(t.preventDefault(),o(n,t.shiftKey,!1)):X2(t.nativeEvent)&&(t.preventDefault(),t.currentTarget.select())}}),(0,I.jsx)(`span`,{className:`text-muted-foreground w-16 text-center text-xs tabular-nums`,children:n===``?``:i.resultCount===0?`No results`:`${i.resultIndex+1} of ${i.resultCount}`}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous match`,onClick:()=>o(n,!0,!1),children:(0,I.jsx)(w,{icon:zg})}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next match`,onClick:()=>o(n,!1,!1),children:(0,I.jsx)(w,{icon:Pg})}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close find`,onClick:()=>G2(e.id),children:(0,I.jsx)(w,{icon:Kg})})]})}var G4=[{label:`Esc`,sequence:`\x1B`},{label:`Tab`,sequence:` `},{label:`↑`,sequence:`\x1B[A`},{label:`↓`,sequence:`\x1B[B`},{label:`←`,sequence:`\x1B[D`},{label:`→`,sequence:`\x1B[C`}];function K4(e){let t=(0,F.useSyncExternalStore)(A2,j2),[n,r]=(0,F.useState)(null),i=t.status===`active`,a=t.layout[e.projectId],o=a?.activeTab??null,s=a?.tabs.filter(e=>!e.minimized)??[],c=a?.tabs.filter(e=>e.minimized)??[],l=B4();return(0,F.useEffect)(()=>{i&&B2({type:`select`,projectId:e.projectId,tabId:null})},[e.projectId,i]),t.loaded?(0,I.jsxs)(`div`,{ref:l,className:`flex h-full flex-col text-sm`,children:[(0,I.jsxs)(`header`,{className:P(`flex h-9 flex-none select-none`,s.length===1?`bg-background`:`bg-sidebar`),children:[c.length>0&&(0,I.jsx)(Y4,{projectId:e.projectId,tabs:c,alerts:t.alerts,bordered:s.length>1}),(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 [scrollbar-width:none] overflow-x-auto`,children:s.map(n=>(0,I.jsx)(J4,{tabId:n.id,onMinimize:s.length>1?()=>B2({type:`minimizeTab`,id:n.id}):void 0,onRename:()=>r({id:n.id,name:n.customName??``}),children:(0,I.jsxs)(`div`,{className:P(`group/tab text-muted-foreground hover:text-foreground relative flex min-w-28 flex-1 items-center justify-center border-r border-b px-7 text-xs transition-colors last:border-r-0`,n.id===o&&`bg-background text-foreground border-b-transparent`),onMouseDown:e=>e.preventDefault(),onClick:()=>B2({type:`select`,projectId:e.projectId,tabId:n.id}),children:[(0,I.jsx)(`span`,{className:`truncate`,children:I2(n)}),(0,I.jsx)(X4,{id:n.id,className:`ml-1.5 size-1.5 flex-none rounded-full`}),(0,I.jsx)(Q4,{progress:t.progress[n.id]}),(0,I.jsx)(`button`,{className:P(`text-muted-foreground hover:bg-accent hover:text-foreground absolute left-1.5 grid size-4.5 place-items-center rounded opacity-0 transition-opacity group-hover/tab:opacity-100`,n.id===o&&`pointer-coarse:opacity-100`),"aria-label":`Close tab`,onClick:e=>{e.stopPropagation(),P4(n.id)},children:(0,I.jsx)(w,{icon:Kg,className:`size-3`})})]})},n.id))}),(0,I.jsx)(`button`,{className:P(`text-muted-foreground hover:text-foreground grid w-8 flex-none place-items-center transition-colors`,s.length>1&&`border-b border-l`),"aria-label":`New tab`,title:`New tab`,onClick:()=>B2({type:`createTab`,projectId:e.projectId}),children:(0,I.jsx)(w,{icon:kg,className:`size-4`})})]}),(0,I.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[o!==null&&(0,I.jsx)(q4,{id:o},`${t.instance}-${o}`),o!==null&&t.finding===o&&(0,I.jsx)(W4,{id:o},o),!i&&(0,I.jsx)(`div`,{className:`bg-background/80 animate-in fade-in absolute inset-0 z-20 grid place-items-center p-6 text-center backdrop-blur-md duration-200`,children:(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`border-foreground/15 border-t-foreground/70 size-6 animate-spin rounded-full border-[3px]`}),(0,I.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Connecting. Your terminals keep running while you wait.`})]})})]}),o!==null&&(0,I.jsxs)(`div`,{className:`bg-card hidden flex-none gap-1.5 overflow-x-auto border-t p-1.5 pointer-coarse:flex`,children:[G4.map(e=>(0,I.jsx)(x,{variant:`secondary`,className:`min-w-11`,onPointerDown:e=>e.preventDefault(),onClick:()=>V2(o,e.sequence),children:e.label},e.label)),(0,I.jsx)(x,{variant:t.ctrl?`default`:`secondary`,className:`min-w-11`,onPointerDown:e=>e.preventDefault(),onClick:K2,children:`Ctrl`})]}),n!==null&&(0,I.jsx)(V4,{id:n.id,name:n.name,onDone:()=>r(null)},n.id),(0,I.jsx)(H4,{})]}):(0,I.jsx)(`div`,{className:`text-muted-foreground grid h-full place-items-center p-4 text-xs whitespace-pre-wrap`,children:t.failure===null?`Starting the terminal…`:`The terminal could not start: ${t.failure}`})}function q4(e){let t=(0,F.useRef)(null);return(0,F.useEffect)(()=>{if(!t.current)throw Error(`terminal container missing`);return $2(e.id,t.current)},[e.id]),(0,I.jsx)(`div`,{className:`bg-background absolute inset-0 pt-(--pad-top) pr-(--pad-right) pb-(--pad-bottom) pl-(--pad-left)`,ref:t})}function J4(e){return(0,I.jsxs)(xZ,{children:[(0,I.jsx)(SZ,{asChild:!0,children:e.children}),(0,I.jsxs)(CZ,{children:[(0,I.jsxs)(wZ,{onSelect:e.onRename,children:[(0,I.jsx)(w,{icon:wee}),`Rename`]}),e.onMinimize&&(0,I.jsxs)(wZ,{onSelect:e.onMinimize,children:[(0,I.jsx)(w,{icon:Ce}),`Minimize`]}),(0,I.jsxs)(TZ,{checked:j2().quiet.includes(e.tabId),onCheckedChange:()=>x4(e.tabId),children:[(0,I.jsx)(w,{icon:yee}),`Notify when quiet for 10s`]}),(0,I.jsxs)(wZ,{variant:`destructive`,onSelect:()=>void P4(e.tabId),children:[(0,I.jsx)(w,{icon:p_}),`Close tab`]})]})]})}function Y4(e){return(0,I.jsxs)(MC,{children:[(0,I.jsx)(PC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:P(`text-muted-foreground hover:text-foreground flex flex-none items-center gap-1 px-2.5 transition-colors`,e.bordered&&`border-r border-b`),"aria-label":`Minimized tabs`,title:`Minimized tabs`,children:[(0,I.jsx)(w,{icon:see,className:`size-4`}),(0,I.jsx)(Z4,{count:e.tabs.length,alert:e.tabs.some(t=>e.alerts.includes(t.id))})]})}),(0,I.jsx)(FC,{align:`start`,children:e.tabs.map(t=>(0,I.jsxs)(IC,{onSelect:()=>B2({type:`select`,projectId:e.projectId,tabId:t.id}),children:[(0,I.jsx)(`span`,{className:`max-w-80 truncate`,children:I2(t)}),(0,I.jsx)(X4,{id:t.id,className:`size-1.5 flex-none rounded-full`})]},t.id))})]})}function X4(e){return j2().alerts.includes(e.id)?(0,I.jsx)(`span`,{className:P(`bg-primary`,e.className)}):null}function Z4(e){return(0,I.jsx)(`span`,{className:P(`grid h-3.5 min-w-3.5 place-items-center rounded-full px-1 text-[9px] leading-none font-medium tabular-nums`,e.alert?`bg-primary text-primary-foreground`:`text-foreground bg-[color-mix(in_srgb,var(--text)_22%,var(--bg))]`),children:e.count})}function Q4(e){let t=e.progress;return!t||t.state===0?null:t.state===3?(0,I.jsx)(`span`,{className:`bg-primary absolute inset-x-0 bottom-0 h-0.5 animate-pulse`}):(0,I.jsx)(`span`,{className:P(`absolute bottom-0 left-0 h-0.5 transition-[width]`,t.state===1&&`bg-primary`,t.state===2&&`bg-destructive`,t.state===4&&`bg-yellow-500`),style:{width:`${t.state!==1&&t.value===0?100:t.value}%`}})}var $4={running:`Running`,completed:`Done`,failed:`Failed`,stopped:`Stopped`};function e3(e,t){return{agents:e.flatMap(e=>e.kind===`subagent`?[{item:e,agentId:e.agentId,status:n3(e.status,e.agentId,t)}]:[]),tasks:e.flatMap(e=>e.kind===`command`&&e.background!==null?[{item:e,taskId:e.background.taskId,path:e.background.outputPath,events:e.background.events,status:n3(e.status,e.background.taskId,t)}]:[])}}function t3(e){return e.description===``?e.command:e.description}function n3(e,t,n){let r=t===null?void 0:n?.tasks[t];return r===void 0?e===`running`?t===null&&n?.running===!0?`Running`:`Stopped`:$4[e]:$4[r]}function r3(e){return(0,I.jsx)(`span`,{className:P(e.active&&`text-shimmer`),children:e.text})}function i3(e){return(0,I.jsxs)(`span`,{className:P(`flex min-w-0 items-baseline overflow-hidden text-[13px] leading-4 tracking-[-0.04px]`,e.grouped?`gap-1.5`:`gap-2`),children:[(0,I.jsx)(`span`,{className:P(`text-foreground shrink-0`,e.grouped?`font-normal`:`font-medium`),children:(0,I.jsx)(r3,{text:e.title,active:e.pending})}),e.subtitle!==void 0&&e.subtitle!==``&&(0,I.jsx)(`span`,{className:P(`min-w-0 truncate tabular-nums`,e.grouped?`text-muted-foreground/70`:`text-muted-foreground`),children:e.subtitle}),e.args?.map(t=>(0,I.jsx)(`span`,{className:P(`min-w-0 truncate tabular-nums`,e.grouped?`text-muted-foreground/70`:`text-muted-foreground`),children:t},t))]})}function a3(e){return(0,I.jsx)(`span`,{"aria-hidden":!0,className:P(`text-muted-foreground/70 flex size-6 shrink-0 items-center justify-center transition-opacity`,e.open?`opacity-100`:`opacity-0 group-hover/tool:opacity-100`,e.className),children:(0,I.jsx)(w,{icon:Pg,strokeWidth:2.5,className:P(`size-3.5 transition-transform`,!e.open&&`-rotate-90`)})})}function o3(e){let t=e.onToggle,n=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`flex max-w-[calc(100%-24px)] min-w-0 items-center`,children:(0,I.jsx)(i3,{title:e.title,subtitle:e.subtitle,args:e.args,pending:e.pending,grouped:e.grouped})}),t!==null&&(0,I.jsx)(a3,{open:e.open})]});return(0,I.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[t===null?(0,I.jsx)(`div`,{className:P(`flex w-full items-center select-none`,e.grouped?`min-h-7`:`min-h-9`),children:n}):(0,I.jsx)(`button`,{type:`button`,"aria-expanded":e.open,onClick:t,className:P(`group/tool focus-visible:ring-ring/70 flex w-full cursor-pointer items-center rounded-md text-left select-none focus-visible:ring-2 focus-visible:outline-none`,e.grouped?`h-7`:`h-9`),children:n}),e.open&&e.children!==void 0&&(0,I.jsx)(`div`,{className:P(`min-w-0 pt-1`,e.rail!==!1&&`ps-3`),children:e.children})]})}var s3=new Map([[`build`,`text-blue-400`],[`explore`,`text-yellow-400`],[`plan`,`text-pink-400`],[`review`,`text-green-400`],[`writer`,`text-purple-400`]]),c3=new Map([[`Running`,`Launched agent`],[`Done`,`Agent finished`],[`Failed`,`Agent failed`],[`Stopped`,`Agent stopped`]]),l3=new Map([[`Running`,`Started in background`],[`Done`,`Background task finished`],[`Failed`,`Background task failed`],[`Stopped`,`Background task stopped`]]),u3=[`text-sky-400`,`text-amber-400`,`text-fuchsia-400`,`text-emerald-400`,`text-violet-400`,`text-cyan-400`,`text-orange-400`,`text-teal-400`,`text-rose-400`,`text-indigo-400`,`text-lime-400`,`text-red-400`];function d3(e){let t=e.agent,n=t.toLowerCase(),r=0;for(let e of n)r=r*31+e.charCodeAt(0)>>>0;return{name:t[0].toUpperCase()+t.slice(1),description:e.description,tone:s3.get(n)??u3[r%u3.length]}}function f3(e){return(0,I.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,className:P(`size-4 shrink-0`,e.className),children:[(0,I.jsx)(`path`,{d:`M4 4.5C4 4.22386 4.22386 4 4.5 4H11.5C11.7761 4 12 4.22386 12 4.5V11.5C12 11.7761 11.7761 12 11.5 12H4.5C4.22386 12 4 11.7761 4 11.5V4.5Z`,fill:`currentColor`}),(0,I.jsx)(`path`,{d:`M14.5 1C14.7761 1 15 1.22386 15 1.5V14.5C15 14.7761 14.7761 15 14.5 15H1.5C1.22386 15 1 14.7761 1 14.5V1.5C1 1.22386 1.22386 1 1.5 1H14.5ZM2 14H14V2H2V14Z`,fill:`currentColor`})]})}function p3(e){return(0,I.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":!0,className:P(`size-4 shrink-0`,e.className),children:Array.from({length:25},(e,t)=>(0,I.jsx)(`rect`,{x:1+t%5*3,y:1+Math.floor(t/5)*3,width:2,height:2,fill:`currentColor`,className:`agent-dot`,style:{animationDelay:`${(t%5+Math.floor(t/5))*90}ms`}},t))})}function m3(e){let t=e.item;if(t.kind===`agent_message`){let n=t.target;return(0,I.jsx)(h3,{label:`Messaged agent`,detail:t.summary,pending:e.sending,onOpen:n===null?null:()=>e.onOpen(n)})}if(t.kind===`command`){let n=e.tasks.find(e=>e.item.id===t.id);if(n===void 0)throw Error(`Task ${t.id} is missing from the thread`);return(0,I.jsx)(h3,{label:l3.get(n.status)??`Background task ${n.status.toLowerCase()}`,detail:t3(n.item),pending:n.status===`Running`,onOpen:()=>e.onOpen(t.id)})}let n=e.agents.find(e=>e.item.id===t.id);if(n===void 0)throw Error(`Agent ${t.id} is missing from the thread`);return(0,I.jsx)(h3,{label:c3.get(n.status)??`Agent ${n.status.toLowerCase()}`,detail:t.description,pending:n.status===`Running`,onOpen:()=>e.onOpen(t.id)})}function h3(e){let t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:(0,I.jsx)(r3,{text:e.detail===``?e.label:`${e.label}:`,active:e.pending})}),e.detail!==``&&(0,I.jsx)(`span`,{className:`text-foreground min-w-0 truncate`,children:e.detail})]});return e.onOpen===null?(0,I.jsx)(`div`,{className:`flex min-h-7 min-w-0 items-center gap-1 text-[13px] leading-4 tracking-[-0.04px] select-none`,children:t}):(0,I.jsxs)(`button`,{type:`button`,title:`Open in Tasks panel`,onClick:e.onOpen,className:`group/agent focus-visible:ring-ring/70 flex min-h-7 w-fit max-w-full cursor-pointer items-center gap-1 rounded-md text-left text-[13px] leading-4 tracking-[-0.04px] select-none focus-visible:ring-2 focus-visible:outline-none`,children:[t,(0,I.jsx)(`span`,{className:`text-muted-foreground/70 flex shrink-0 opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-visible/agent:opacity-100 pointer-coarse:opacity-100`,children:(0,I.jsx)(w,{icon:Lg,className:`size-3.5`})})]})}function g3(e){let t={name:``,path:``,stat:{added:0,removed:0},directories:new Map,files:[]};for(let[n,r]of e){let e=n.replaceAll(`\\`,`/`).split(`/`).filter(e=>e!==``),i=e.at(-1);if(i===void 0)continue;let a=[t],o=t;for(let t of e.slice(0,-1)){let e=o.directories.get(t)??{name:t,path:o.path===``?t:`${o.path}/${t}`,stat:{added:0,removed:0},directories:new Map,files:[]};o.directories.set(t,e),o=e,a.push(o)}o.files.push({kind:`file`,name:i,path:e.join(`/`),stat:r});for(let e of a)e.stat.added+=r.added,e.stat.removed+=r.removed}return v3(t)}function _3(e,t){return e.name.localeCompare(t.name,void 0,{numeric:!0,sensitivity:`base`})}function v3(e){return[...[...e.directories.values()].sort(_3).map(e=>Yae({kind:`directory`,name:e.name,path:e.path,stat:{...e.stat},children:v3(e)})),...[...e.files].sort(_3)]}function Yae(e){let t=e;for(;t.children.length===1&&t.children[0].kind===`directory`;){let e=t.children[0];t={kind:`directory`,name:`${t.name}/${e.name}`,path:e.path,stat:e.stat,children:e.children}}return t}function Xae(e){let[t,n]=(0,F.useState)(!1),r=[...e.files],i=vs(r,e=>e[1].added),a=vs(r,e=>e[1].removed),o=r.some(([e])=>/[/\\]/.test(e)),s=t?`Collapse all folders`:`Expand all folders`;return(0,I.jsxs)(`div`,{className:`bg-secondary dark:bg-input/20 @container/changed-files mt-4 rounded-lg`,children:[(0,I.jsxs)(`div`,{className:`bg-secondary dark:bg-background dark:from-input/20 dark:to-input/20 sticky top-2 z-10 flex items-center justify-between gap-2 rounded-t-lg px-3 py-2 dark:bg-linear-to-b`,children:[(0,I.jsxs)(`div`,{className:`text-foreground flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs font-medium`,children:[(0,I.jsxs)(`span`,{children:[r.length,` changed file`,r.length===1?``:`s`]}),(i>0||a>0)&&(0,I.jsx)(y3,{added:i,removed:a,layout:`inline`,className:`text-xs leading-4`})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[o&&(0,I.jsx)(Oe,{label:s,children:(0,I.jsx)(x,{type:`button`,size:`icon-xs`,variant:`ghost-muted`,"aria-label":s,onClick:()=>n(!t),children:(0,I.jsx)(w,{icon:t?e_:cv,className:`size-3`})})}),(0,I.jsx)(Oe,{label:`Open the full diff`,children:(0,I.jsxs)(x,{type:`button`,size:`xs`,variant:`ghost-muted`,"aria-label":`Open diff`,onClick:e.onOpenDiff,children:[(0,I.jsx)(w,{icon:v_,className:`size-3`}),(0,I.jsx)(`span`,{className:`hidden @[24rem]/changed-files:inline`,children:`Open diff`})]})})]})]}),(0,I.jsx)(Zae,{files:e.files,allExpanded:t,onOpenDiff:e.onOpenDiff},String(t))]})}function Zae(e){let[t,n]=(0,F.useState)({}),r=g3(e.files),i=r.some(e=>e.kind===`directory`),a=`group hover:bg-accent/60 focus-visible:ring-ring focus-visible:ring-offset-background flex w-full items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none focus-visible:ring-inset`;function o(r,s){let c=`${8+s*14}px`;if(r.kind===`directory`){let i=t[r.path]??e.allExpanded;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":i,className:a,style:{paddingLeft:c},onClick:()=>n({...t,[r.path]:!i}),children:[(0,I.jsx)(w,{icon:Qg,"aria-hidden":!0,className:P(`text-muted-foreground/70 group-hover:text-foreground/80 size-3.5 shrink-0 transition-transform`,i&&`rotate-90`)}),(0,I.jsx)(w,{icon:i?b_:x_,className:`text-muted-foreground/75 size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`text-2xs text-muted-foreground/90 group-hover:text-foreground/90 truncate font-mono`,children:r.name}),(r.stat.added>0||r.stat.removed>0)&&(0,I.jsx)(`span`,{className:`text-3xs ml-auto shrink-0 font-mono tabular-nums`,children:(0,I.jsx)(y3,{added:r.stat.added,removed:r.stat.removed,layout:`aligned`})})]}),i&&(0,I.jsx)(`div`,{children:r.children.map(e=>o(e,s+1))})]},`dir:${r.path}`)}return(0,I.jsxs)(`button`,{type:`button`,className:a,style:{paddingLeft:c},onClick:e.onOpenDiff,children:[(i||s>0)&&(0,I.jsx)(`span`,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,I.jsx)(Ye,{path:r.path,className:`text-muted-foreground/70 size-3.5`}),(0,I.jsx)(`span`,{className:`text-foreground/85 group-hover:text-foreground flex min-w-0 font-mono text-xs`,children:(0,I.jsx)(`span`,{className:`truncate`,children:r.name})}),(0,I.jsx)(`span`,{className:`text-3xs ml-auto shrink-0 font-mono tabular-nums`,children:(0,I.jsx)(y3,{added:r.stat.added,removed:r.stat.removed,layout:`aligned`})})]},`file:${r.path}`)}return(0,I.jsx)(`div`,{className:`p-2`,children:r.map(e=>o(e,0))})}function y3(e){return(0,I.jsxs)(`span`,{role:`group`,"aria-label":`${e.added} additions, ${e.removed} deletions`,className:P(e.layout===`inline`?`inline-flex items-center gap-1 align-middle tabular-nums`:`inline-grid grid-cols-[4ch_4ch] gap-2 text-right align-middle tabular-nums`,e.className),children:[(0,I.jsxs)(`span`,{"aria-hidden":!0,className:`text-diff-addition font-mono`,children:[`+`,Aw(e.added)]}),(0,I.jsxs)(`span`,{"aria-hidden":!0,className:`text-diff-deletion font-mono`,children:[`-`,Aw(e.removed)]})]})}function Qae(e){let[t,n]=(0,F.useState)(!1),r=xI(),i=e.plan,a=b3(i),o=i.length>900||i.split(`