blade-code 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/{chunk-8nm1hqr1.js → chunk-0n97186m.js} +2 -2
- package/dist/{chunk-t8q9ks7e.js → chunk-15d49qty.js} +1 -1
- package/dist/{chunk-tm2ckreq.js → chunk-1ndryz4h.js} +20 -20
- package/dist/{chunk-d9ddpapp.js → chunk-35yktzm1.js} +1 -1
- package/dist/chunk-4ncbd4k0.js +1 -0
- package/dist/{chunk-qhf0knnx.js → chunk-5t0vs4hz.js} +1 -1
- package/dist/{chunk-zkbf8n6y.js → chunk-5twefby5.js} +1 -1
- package/dist/{chunk-ct32ngah.js → chunk-5ze48kg7.js} +8 -8
- package/dist/{chunk-sndbq5xt.js → chunk-63ysxybd.js} +1 -1
- package/dist/{chunk-nah0cbnp.js → chunk-6tx8k249.js} +2 -2
- package/dist/chunk-7443b95r.js +1 -0
- package/dist/chunk-79s052sw.js +2 -0
- package/dist/{chunk-e2ccyhgz.js → chunk-90fnvvcf.js} +1 -1
- package/dist/{chunk-6n5xdf2r.js → chunk-948qe2pp.js} +1 -1
- package/dist/{chunk-mjp61rqd.js → chunk-9ffr01c3.js} +1 -1
- package/dist/chunk-9kwt0w46.js +180 -0
- package/dist/chunk-a7a74pza.js +1484 -0
- package/dist/{chunk-5tfzehcg.js → chunk-age5tc86.js} +3 -3
- package/dist/{chunk-44wkjs2j.js → chunk-an96c54z.js} +2 -2
- package/dist/{chunk-m9zpxzg2.js → chunk-b9v7waxf.js} +2 -2
- package/dist/{chunk-2beq0syt.js → chunk-bexgcc2d.js} +1 -1
- package/dist/chunk-ccwskwb3.js +1 -0
- package/dist/{chunk-bpzv054r.js → chunk-csr5vppa.js} +8 -8
- package/dist/chunk-d4zw0xxe.js +1 -0
- package/dist/chunk-d5a66cgn.js +160 -0
- package/dist/chunk-d7xb0vp1.js +1 -0
- package/dist/{chunk-af49jmns.js → chunk-dqvcgwhe.js} +2 -2
- package/dist/{chunk-kq5my0yy.js → chunk-drrdzmaa.js} +2 -2
- package/dist/{chunk-px5ck9pf.js → chunk-ea7wsges.js} +2 -2
- package/dist/{chunk-vjpd3nee.js → chunk-epj56s0n.js} +1 -1
- package/dist/chunk-f647z66n.js +1 -0
- package/dist/{chunk-2km4w0ky.js → chunk-ffp3ypbb.js} +2 -2
- package/dist/{chunk-0h81hxkw.js → chunk-fvhc1yj8.js} +1 -1
- package/dist/{chunk-k9a1vb8a.js → chunk-fx87s3mb.js} +2 -2
- package/dist/chunk-g6h6h8xr.js +1 -0
- package/dist/{chunk-d3236505.js → chunk-gb54hc78.js} +1 -1
- package/dist/{chunk-fjw32ex5.js → chunk-gxmrakrk.js} +1 -1
- package/dist/{chunk-a7nbn5kf.js → chunk-gxzbv67r.js} +2 -2
- package/dist/chunk-jbnrscvz.js +1 -0
- package/dist/{chunk-88vy9hh0.js → chunk-jza1rsan.js} +1 -1
- package/dist/chunk-kkd7mm55.js +1 -0
- package/dist/{chunk-ws3gc024.js → chunk-mxqpg4gy.js} +1 -1
- package/dist/chunk-n2s54h1r.js +1 -0
- package/dist/{chunk-k89phc5j.js → chunk-nr53mq0k.js} +2 -2
- package/dist/chunk-pehpndk9.js +1 -0
- package/dist/{chunk-jxv6r0c7.js → chunk-qda309d9.js} +2 -2
- package/dist/{chunk-beqaxytd.js → chunk-qm11hjd3.js} +1 -1
- package/dist/{chunk-y0hwzmdn.js → chunk-rv80ak15.js} +1 -1
- package/dist/{chunk-8mepk4tc.js → chunk-scq3ns6v.js} +2 -2
- package/dist/chunk-t8x2qpe2.js +1 -0
- package/dist/{chunk-4vaywb2r.js → chunk-tq52pbde.js} +1 -1
- package/dist/chunk-tx8f345j.js +1 -0
- package/dist/chunk-v8kp3ep9.js +6 -0
- package/dist/{chunk-vvy506b3.js → chunk-v93hcxe7.js} +1 -1
- package/dist/{chunk-rkzds6k8.js → chunk-ve9cke2g.js} +2 -2
- package/dist/{chunk-6sc78810.js → chunk-vxymgh8e.js} +5 -5
- package/dist/chunk-wdbmbk6h.js +10 -0
- package/dist/{chunk-gr5mzxdf.js → chunk-xkzy5wbm.js} +1 -1
- package/dist/{chunk-m5tjrr5c.js → chunk-xq8vf15n.js} +2 -2
- package/dist/{chunk-th7sxjtk.js → chunk-ydtcvxsm.js} +1 -1
- package/dist/{chunk-wvj9h7mb.js → chunk-ygx03mdh.js} +1 -1
- package/dist/chunk-ys8bp9jm.js +1 -0
- package/dist/{chunk-6hj2dk75.js → chunk-z906d5tb.js} +2 -2
- package/dist/chunk-zswrw5f9.js +3 -0
- package/dist/chunk-zyz82mcd.js +1 -0
- package/dist/web/assets/{ChatView-CnwNosSG.js → ChatView-iK7ff8qU.js} +5 -5
- package/dist/web/assets/{CodeBlockHighlighter-CBo_AxjZ.js → CodeBlockHighlighter-BoJp_Xb0.js} +1 -1
- package/dist/web/assets/{FilePreview-hNo6RCNY.js → FilePreview-Bi1HWOvY.js} +2 -2
- package/dist/web/assets/{MarkdownRenderer-BON4fqSr.js → MarkdownRenderer-DMW1pg5N.js} +3 -3
- package/dist/web/assets/McpModal-CHUqitJ6.js +5 -0
- package/dist/web/assets/SettingsModal-zsS9O6SW.js +1 -0
- package/dist/web/assets/SkillsModal-C2oTDXoy.js +1 -0
- package/dist/web/assets/{TaskSwitcher-Ds8CBVtp.js → TaskSwitcher-CncVasNA.js} +1 -1
- package/dist/web/assets/{TerminalPanel-Dm4bu6ib.js → TerminalPanel-CBi2mUxx.js} +1 -1
- package/dist/web/assets/index-B7etZcne.css +1 -0
- package/dist/web/assets/index-DvDtvgA4.js +32 -0
- package/dist/web/assets/useRequest-BvqVDnKl.js +1 -0
- package/dist/web/assets/{vendor-icons-CsBKlDXT.js → vendor-icons-D_AkWmWB.js} +70 -60
- package/dist/web/assets/{vendor-radix-DXRuAJHH.js → vendor-radix-DBy9B2DN.js} +1 -1
- package/dist/web/index.html +4 -4
- package/package.json +1 -1
- package/dist/chunk-0h9m2fqd.js +0 -160
- package/dist/chunk-1wyfb6s7.js +0 -1
- package/dist/chunk-3vyjshqp.js +0 -1
- package/dist/chunk-6g21dh3n.js +0 -1
- package/dist/chunk-asbp4cv4.js +0 -1
- package/dist/chunk-bqk3wqts.js +0 -1
- package/dist/chunk-cjdnfyy0.js +0 -1485
- package/dist/chunk-d8zj7c0t.js +0 -6
- package/dist/chunk-gafbzeyk.js +0 -1
- package/dist/chunk-jv4nkkb5.js +0 -1
- package/dist/chunk-m3tx1k0s.js +0 -1
- package/dist/chunk-m78ceafk.js +0 -1
- package/dist/chunk-nqq4sbmv.js +0 -1
- package/dist/chunk-p7ppnewt.js +0 -3
- package/dist/chunk-qev36qrb.js +0 -2
- package/dist/chunk-tckfyfsx.js +0 -1
- package/dist/chunk-xhpezpjq.js +0 -10
- package/dist/chunk-y5vq7gek.js +0 -174
- package/dist/chunk-ydqeg4p8.js +0 -1
- package/dist/chunk-yknrffcs.js +0 -1
- package/dist/chunk-ymmtbq2b.js +0 -1
- package/dist/chunk-z2yzyr9h.js +0 -1
- package/dist/web/assets/McpModal-Go_8v1Vu.js +0 -5
- package/dist/web/assets/SettingsModal-CRu1zGQf.js +0 -1
- package/dist/web/assets/index-BNsnHxlt.js +0 -32
- package/dist/web/assets/index-DVTiq-7u.css +0 -1
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsModal-CRu1zGQf.js","assets/vendor-react-DG5dkZ_t.js","assets/vendor-icons-CsBKlDXT.js","assets/vendor-radix-DXRuAJHH.js","assets/McpModal-Go_8v1Vu.js","assets/TaskSwitcher-Ds8CBVtp.js","assets/FilePreview-hNo6RCNY.js","assets/TerminalPanel-Dm4bu6ib.js","assets/vendor-xterm-DuYZoU4T.js","assets/vendor-xterm-9CEnUXvW.css","assets/ChatView-CnwNosSG.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Ny=Object.defineProperty;var Ay=(e,t,n)=>t in e?Ny(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _a=(e,t,n)=>Ay(e,typeof t!="symbol"?t+"":t,n);import{r as w,j as l,c as Ys,d as $y}from"./vendor-react-DG5dkZ_t.js";import{S as Py,O as mf,P as Oy,C as pf,a as Ry,T as gf,D as hf,R as My,b as bf,V as Fy,c as _y,d as xf,e as Dy,f as Ly,g as kf,h as By,i as Uy}from"./vendor-radix-DXRuAJHH.js";import{X as eo,H as ad,L as ct,F as qy,R as Li,A as yf,a as to,D as wf,b as zy,c as yi,d as Hy,e as no,G as Fc,T as Sf,C as Ky,f as co,S as _c,M as Gy,g as Vy,P as Wy,h as If,i as Dc,j as vf,k as Lc,l as Jy,m as Qy,n as Yy,o as jf,p as Xy,q as Zy,r as Cf,s as cd,I as e0,t as ld,u as Mr,v as t0,w as n0,W as ud,x as r0,y as s0,z as o0,B as i0,E as a0,J as dd,K as fd}from"./vendor-icons-CsBKlDXT.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const c0="modulepreload",l0=function(e){return"/"+e},md={},Is=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),a=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=l0(c),c in md)return;md[c]=!0;const u=c.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":c0,u||(p.as="script"),p.crossOrigin="",p.href=c,a&&p.setAttribute("nonce",a),document.head.appendChild(p),u)return new Promise((g,b)=>{p.addEventListener("load",g),p.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return s.then(i=>{for(const a of i||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};function Tf(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=Tf(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Ef(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Tf(e))&&(r&&(r+=" "),r+=t);return r}const pd=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,gd=Ef,u0=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return gd(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:o}=t,i=Object.keys(s).map(u=>{const f=n==null?void 0:n[u],p=o==null?void 0:o[u];if(f===null)return null;const g=pd(f)||pd(p);return s[u][g]}),a=n&&Object.entries(n).reduce((u,f)=>{let[p,g]=f;return g===void 0||(u[p]=g),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,f)=>{let{class:p,className:g,...b}=f;return Object.entries(b).every(x=>{let[y,v]=x;return Array.isArray(v)?v.includes({...o,...a}[y]):{...o,...a}[y]===v})?[...u,p,g]:u},[]);return gd(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},Bc="-",d0=e=>{const t=m0(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const a=i.split(Bc);return a[0]===""&&a.length!==1&&a.shift(),Nf(a,t)||f0(i)},getConflictingClassGroupIds:(i,a)=>{const c=n[i]||[];return a&&r[i]?[...c,...r[i]]:c}}},Nf=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),s=r?Nf(e.slice(1),r):void 0;if(s)return s;if(t.validators.length===0)return;const o=e.join(Bc);return(i=t.validators.find(({validator:a})=>a(o)))==null?void 0:i.classGroupId},hd=/^\[(.+)\]$/,f0=e=>{if(hd.test(e)){const t=hd.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},m0=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return g0(Object.entries(e.classGroups),n).forEach(([o,i])=>{Za(i,r,o,t)}),r},Za=(e,t,n,r)=>{e.forEach(s=>{if(typeof s=="string"){const o=s===""?t:bd(t,s);o.classGroupId=n;return}if(typeof s=="function"){if(p0(s)){Za(s(r),t,n,r);return}t.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(([o,i])=>{Za(i,bd(t,o),n,r)})})},bd=(e,t)=>{let n=e;return t.split(Bc).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},p0=e=>e.isThemeGetter,g0=(e,t)=>t?e.map(([n,r])=>{const s=r.map(o=>typeof o=="string"?t+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([i,a])=>[t+i,a])):o);return[n,s]}):e,h0=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const s=(o,i)=>{n.set(o,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(o){let i=n.get(o);if(i!==void 0)return i;if((i=r.get(o))!==void 0)return s(o,i),i},set(o,i){n.has(o)?n.set(o,i):s(o,i)}}},Af="!",b0=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,s=t[0],o=t.length,i=a=>{const c=[];let u=0,f=0,p;for(let v=0;v<a.length;v++){let k=a[v];if(u===0){if(k===s&&(r||a.slice(v,v+o)===t)){c.push(a.slice(f,v)),f=v+o;continue}if(k==="/"){p=v;continue}}k==="["?u++:k==="]"&&u--}const g=c.length===0?a:a.substring(f),b=g.startsWith(Af),x=b?g.substring(1):g,y=p&&p>f?p-f:void 0;return{modifiers:c,hasImportantModifier:b,baseClassName:x,maybePostfixModifierPosition:y}};return n?a=>n({className:a,parseClassName:i}):i},x0=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},k0=e=>({cache:h0(e.cacheSize),parseClassName:b0(e),...d0(e)}),y0=/\s+/,w0=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s}=t,o=[],i=e.trim().split(y0);let a="";for(let c=i.length-1;c>=0;c-=1){const u=i[c],{modifiers:f,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:b}=n(u);let x=!!b,y=r(x?g.substring(0,b):g);if(!y){if(!x){a=u+(a.length>0?" "+a:a);continue}if(y=r(g),!y){a=u+(a.length>0?" "+a:a);continue}x=!1}const v=x0(f).join(":"),k=p?v+Af:v,E=k+y;if(o.includes(E))continue;o.push(E);const $=s(y,x);for(let B=0;B<$.length;++B){const R=$[B];o.push(k+R)}a=u+(a.length>0?" "+a:a)}return a};function S0(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=$f(t))&&(r&&(r+=" "),r+=n);return r}const $f=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=$f(e[r]))&&(n&&(n+=" "),n+=t);return n};function I0(e,...t){let n,r,s,o=i;function i(c){const u=t.reduce((f,p)=>p(f),e());return n=k0(u),r=n.cache.get,s=n.cache.set,o=a,a(c)}function a(c){const u=r(c);if(u)return u;const f=w0(c,n);return s(c,f),f}return function(){return o(S0.apply(null,arguments))}}const Je=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Pf=/^\[(?:([a-z-]+):)?(.+)\]$/i,v0=/^\d+\/\d+$/,j0=new Set(["px","full","screen"]),C0=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,T0=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,E0=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,N0=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,A0=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Dn=e=>ys(e)||j0.has(e)||v0.test(e),cr=e=>vs(e,"length",D0),ys=e=>!!e&&!Number.isNaN(Number(e)),Da=e=>vs(e,"number",ys),Gs=e=>!!e&&Number.isInteger(Number(e)),$0=e=>e.endsWith("%")&&ys(e.slice(0,-1)),ue=e=>Pf.test(e),lr=e=>C0.test(e),P0=new Set(["length","size","percentage"]),O0=e=>vs(e,P0,Of),R0=e=>vs(e,"position",Of),M0=new Set(["image","url"]),F0=e=>vs(e,M0,B0),_0=e=>vs(e,"",L0),Vs=()=>!0,vs=(e,t,n)=>{const r=Pf.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},D0=e=>T0.test(e)&&!E0.test(e),Of=()=>!1,L0=e=>N0.test(e),B0=e=>A0.test(e),U0=()=>{const e=Je("colors"),t=Je("spacing"),n=Je("blur"),r=Je("brightness"),s=Je("borderColor"),o=Je("borderRadius"),i=Je("borderSpacing"),a=Je("borderWidth"),c=Je("contrast"),u=Je("grayscale"),f=Je("hueRotate"),p=Je("invert"),g=Je("gap"),b=Je("gradientColorStops"),x=Je("gradientColorStopPositions"),y=Je("inset"),v=Je("margin"),k=Je("opacity"),E=Je("padding"),$=Je("saturate"),B=Je("scale"),R=Je("sepia"),M=Je("skew"),P=Je("space"),N=Je("translate"),O=()=>["auto","contain","none"],_=()=>["auto","hidden","clip","visible","scroll"],te=()=>["auto",ue,t],j=()=>[ue,t],F=()=>["",Dn,cr],se=()=>["auto",ys,ue],ne=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],oe=()=>["solid","dashed","dotted","double","none"],Ie=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ve=()=>["start","end","center","between","around","evenly","stretch"],Ee=()=>["","0",ue],L=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ae=()=>[ys,ue];return{cacheSize:500,separator:":",theme:{colors:[Vs],spacing:[Dn,cr],blur:["none","",lr,ue],brightness:ae(),borderColor:[e],borderRadius:["none","","full",lr,ue],borderSpacing:j(),borderWidth:F(),contrast:ae(),grayscale:Ee(),hueRotate:ae(),invert:Ee(),gap:j(),gradientColorStops:[e],gradientColorStopPositions:[$0,cr],inset:te(),margin:te(),opacity:ae(),padding:j(),saturate:ae(),scale:ae(),sepia:Ee(),skew:ae(),space:j(),translate:j()},classGroups:{aspect:[{aspect:["auto","square","video",ue]}],container:["container"],columns:[{columns:[lr]}],"break-after":[{"break-after":L()}],"break-before":[{"break-before":L()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ne(),ue]}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:O()}],"overscroll-x":[{"overscroll-x":O()}],"overscroll-y":[{"overscroll-y":O()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Gs,ue]}],basis:[{basis:te()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ue]}],grow:[{grow:Ee()}],shrink:[{shrink:Ee()}],order:[{order:["first","last","none",Gs,ue]}],"grid-cols":[{"grid-cols":[Vs]}],"col-start-end":[{col:["auto",{span:["full",Gs,ue]},ue]}],"col-start":[{"col-start":se()}],"col-end":[{"col-end":se()}],"grid-rows":[{"grid-rows":[Vs]}],"row-start-end":[{row:["auto",{span:[Gs,ue]},ue]}],"row-start":[{"row-start":se()}],"row-end":[{"row-end":se()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ue]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ue]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...ve()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ve(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ve(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[E]}],px:[{px:[E]}],py:[{py:[E]}],ps:[{ps:[E]}],pe:[{pe:[E]}],pt:[{pt:[E]}],pr:[{pr:[E]}],pb:[{pb:[E]}],pl:[{pl:[E]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[P]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[P]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ue,t]}],"min-w":[{"min-w":[ue,t,"min","max","fit"]}],"max-w":[{"max-w":[ue,t,"none","full","min","max","fit","prose",{screen:[lr]},lr]}],h:[{h:[ue,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ue,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ue,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ue,t,"auto","min","max","fit"]}],"font-size":[{text:["base",lr,cr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Da]}],"font-family":[{font:[Vs]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ue]}],"line-clamp":[{"line-clamp":["none",ys,Da]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Dn,ue]}],"list-image":[{"list-image":["none",ue]}],"list-style-type":[{list:["none","disc","decimal",ue]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Dn,cr]}],"underline-offset":[{"underline-offset":["auto",Dn,ue]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ne(),R0]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",O0]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},F0]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[b]}],"gradient-via":[{via:[b]}],"gradient-to":[{to:[b]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...oe(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:oe()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-s":[{"border-s":[s]}],"border-color-e":[{"border-e":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:["",...oe()]}],"outline-offset":[{"outline-offset":[Dn,ue]}],"outline-w":[{outline:[Dn,cr]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Dn,cr]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",lr,_0]}],"shadow-color":[{shadow:[Vs]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...Ie(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Ie()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",lr,ue]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[p]}],saturate:[{saturate:[$]}],sepia:[{sepia:[R]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[p]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[$]}],"backdrop-sepia":[{"backdrop-sepia":[R]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ue]}],duration:[{duration:ae()}],ease:[{ease:["linear","in","out","in-out",ue]}],delay:[{delay:ae()}],animate:[{animate:["none","spin","ping","pulse","bounce",ue]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[B]}],"scale-x":[{"scale-x":[B]}],"scale-y":[{"scale-y":[B]}],rotate:[{rotate:[Gs,ue]}],"translate-x":[{"translate-x":[N]}],"translate-y":[{"translate-y":[N]}],"skew-x":[{"skew-x":[M]}],"skew-y":[{"skew-y":[M]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ue]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ue]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ue]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Dn,cr,Da]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},q0=I0(U0);function V(...e){return q0(Ef(e))}const z0=u0("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),mr=w.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...s},o)=>{const i=r?Py:"button";return l.jsx(i,{className:V(z0({variant:t,size:n,className:e})),ref:o,...s})});mr.displayName="Button";const Rf=My,H0=Oy,Mf=w.forwardRef(({className:e,...t},n)=>l.jsx(mf,{ref:n,className:V("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Mf.displayName=mf.displayName;const Uc=w.forwardRef(({className:e,children:t,hideCloseButton:n,...r},s)=>l.jsxs(H0,{children:[l.jsx(Mf,{}),l.jsxs(pf,{ref:s,"aria-modal":"true",className:V("fixed left-[50%] top-[50%] z-50 grid max-h-[calc(100dvh-24px)] w-[calc(100vw-24px)] max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,!n&&l.jsxs(Ry,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[l.jsx(eo,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Uc.displayName=pf.displayName;const qc=({className:e,...t})=>l.jsx("div",{className:V("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});qc.displayName="DialogHeader";const Ff=({className:e,...t})=>l.jsx("div",{className:V("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ff.displayName="DialogFooter";const zc=w.forwardRef(({className:e,...t},n)=>l.jsx(gf,{ref:n,className:V("text-lg font-semibold leading-none tracking-tight",e),...t}));zc.displayName=gf.displayName;const Hc=w.forwardRef(({className:e,...t},n)=>l.jsx(hf,{ref:n,className:V("text-sm text-muted-foreground",e),...t}));Hc.displayName=hf.displayName;function ft(e,t){return{...e,...t}}function _r(e,t,n){return e>=t&&e<=n}function K0(e){return e===8205}function G0(e){return _r(e,55296,56319)}function xd(e){return _r(e,127462,127487)}function _f(e){return _r(e,65024,65039)}function Df(e){return _r(e,768,879)||_r(e,6832,6911)||_r(e,7616,7679)||_r(e,65056,65071)}function fi(e){return e>65535?2:1}function kd(e,t){for(;t<e.length;){const n=e.codePointAt(t);if(Df(n)||_f(n))t+=fi(n);else break}return t}function Kc(e,t){const n=e.codePointAt(t);let r=t+fi(n);for(r=kd(e,r);r<e.length-1&&e[r]==="";){const s=e.codePointAt(r+1);r+=1+fi(s),r=kd(e,r)}return xd(n)&&r<e.length&&xd(e.codePointAt(r))&&(r+=fi(e.codePointAt(r))),r}function Lf(e){return G0(e)||Df(e)||_f(e)||K0(e)}function V0(e){let t=0,n=0;for(;n<e.length;)n=Kc(e,n),t++;return t}function W0(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=Kc(e,r),n++,n>=t)return!0;return!1}function J0(e,t){let n=0,r=0;for(;r<e.length;)if(r=Kc(e,r),n++,n>t)return!1;return!0}function Q0(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Lf(e.charCodeAt(n)))return W0(e,t);if(n++,n>=t)return!0}return!1}function Y0(e,t){let n=0;for(;n<e.length;){if(Lf(e.charCodeAt(n)))return J0(e,t);if(n++,n>t)return!1}return!0}function H(e){return Array.isArray(e)}function et(e){return h(typeof e,"bigint")}function mt(e){return h(typeof e,"boolean")}function Bi(e){if(Pe(e)||!kn(e))return!1;const t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function kn(e){return h(typeof e,"function")}function Gc(e){return Number.isInteger(e)}function Ht(e){return h(e,null)}function we(e){return Number.isFinite(e)}function an(e){return ee(e)&&!H(e)}function ee(e){return h(typeof e,"object")&&!Ht(e)}function ce(e){return h(typeof e,"string")}function Vc(e){return h(typeof e,"symbol")}function Pe(e){return h(e,void 0)}function h(e,t){return e===t}function Vr(e,t){return e>t}function ho(e,t){return e<t}function Qn(e,t){return e<=t}function js(e,t){return e>=t}function Bf(e,t){if(et(e)||et(t))return BigInt(e)%BigInt(t)===0n;const n=1e-10;if(!we(e)||Gc(e)&&1/t%1===0)return!0;const r=e%t;return Math.min(Math.abs(r),Math.abs(r-t),Math.abs(r+t))<n}function Uf(e){if(!ee(e))return!1;const t=globalThis.Object.getPrototypeOf(e);return Ht(t)?!1:h(typeof t.constructor,"function")&&!(h(t.constructor,globalThis.Object)||h(t.constructor.name,"Object"))}function Cs(e){return et(e)||mt(e)||Ht(e)||we(e)||ce(e)||Pe(e)}function X0(e){return V0(e)}function qf(e,t){return Y0(e,t)}function zf(e,t){return Q0(e,t)}function lt(e,t,n){for(let r=t;r<e.length;r++)if(!n(e[r],r))return!1;return!0}function It(e,t,n){let r=!0;for(let s=t;s<e.length;s++)n(e[s],s)||(r=!1);return r}function Ts(e,t){for(let n=0;n<e.length;n++)if(t(e[n],n))return!0;return!1}function Hf(e,t){let n=!1;for(let r=0;r<e.length;r++)t(e[r],r)&&(n=!0);return n}function Wc(e,t){return e.reduce((n,r,s)=>t(r,s)?++n:n,0)}function je(e,t,n){return h(e.length,0)?n():t(e[0],e.slice(1))}function zn(e){return h(e,"__proto__")||h(e,"constructor")||h(e,"prototype")}function C(e,t){return zn(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Jc(e){return D(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function tt(e){return Object.entries(e)}function D(e){return Object.getOwnPropertyNames(e)}function Qc(e){return Object.getOwnPropertySymbols(e)}function Yc(e){return Object.values(e)}function Z0(e,t){if(!ee(t))return!1;const n=D(e);return h(n.length,D(t).length)&&n.every(r=>Wr(e[r],t[r]))}function ew(e,t){return H(t)&&h(e.length,t.length)&&e.every((n,r)=>Wr(e[r],t[r]))}function Wr(e,t){return H(e)?ew(e,t):ee(e)?Z0(e,t):h(e,t)}const wi=Object.freeze(Object.defineProperty({__proto__:null,Counted:Wc,Entries:tt,EntriesRegExp:Jc,Every:lt,EveryAll:It,GraphemeCount:X0,HasPropertyKey:C,IsArray:H,IsBigInt:et,IsBoolean:mt,IsClassInstance:Uf,IsConstructor:Bi,IsDeepEqual:Wr,IsEqual:h,IsFunction:kn,IsGreaterEqualThan:js,IsGreaterThan:Vr,IsInteger:Gc,IsLessEqualThan:Qn,IsLessThan:ho,IsMaxLength:qf,IsMinLength:zf,IsMultipleOf:Bf,IsNull:Ht,IsNumber:we,IsObject:ee,IsObjectNotArray:an,IsString:ce,IsSymbol:Vc,IsUndefined:Pe,IsUnsafePropertyKey:zn,IsValueLike:Cs,Keys:D,ShiftLeft:je,Some:Ts,SomeAll:Hf,Symbols:Qc,Values:Yc},Symbol.toStringTag,{value:"Module"})),tw=/^[\p{ID_Start}_$][\p{ID_Continue}_$\u200C\u200D]*$/u;function nw(e){return tw.test(e)}function kt(e,t){return`(${e} && ${t})`}function Ue(e,t){return`(${e} || ${t})`}function Et(e){return`!(${e})`}function Si(e){return`Array.isArray(${e})`}function Kf(e){return`typeof ${e} === "bigint"`}function rw(e){return`typeof ${e} === "boolean"`}function sw(e){return`Number.isInteger(${e})`}function ow(e){return`${e} === null`}function Gf(e){return`Number.isFinite(${e})`}function Vf(e){return kt(Wf(e),Et(Si(e)))}function Wf(e){return`typeof ${e} === "object" && ${e} !== null`}function Jf(e){return`typeof ${e} === "string"`}function iw(e){return`typeof ${e} === "symbol"`}function ec(e){return`${e} === undefined`}function aw(e){return`typeof ${e} === "function"`}function cw(e){return`Guard.IsConstructor(${e})`}function zt(e,t){return`${e} === ${t}`}function Qf(e,t){return`${e} > ${t}`}function Xc(e,t){return`${e} < ${t}`}function Jr(e,t){return`${e} <= ${t}`}function bo(e,t){return`${e} >= ${t}`}function lw(e,t){return`Guard.IsMinLength(${e}, ${t})`}function uw(e,t){return`Guard.IsMaxLength(${e}, ${t})`}function Pn(e,t,n,r){return h(t,"0")?`${e}.every((${n[0]}, ${n[1]}) => ${r})`:`((value, callback) => { for(let index = ${t}; index < value.length; index++) if (!callback(value[index], index)) return false; return true })(${e}, (${n[0]}, ${n[1]}) => ${r})`}function dw(e,t,n){return`${e}.some((${t[0]}, ${t[1]}) => ${n})`}function fw(e,t,n){return`((value, callback) => { let result = false; for(let index = 0; index < value.length; index++) if (callback(value[index], index)) result = true; return result })(${e}, (${t[0]}, ${t[1]}) => ${n})`}function Ui(e,t,n){return`${e}.reduce((result, ${t[0]}, ${t[1]}) => (${n}) ? ++result : result, 0)`}function Yf(e){return`Object.entries(${e})`}function Qr(e){return`Object.getOwnPropertyNames(${e})`}function Ur(e,t){return h(t,'"__proto__"')||h(t,'"constructor"')?`Object.prototype.hasOwnProperty.call(${e}, ${t})`:`${t} in ${e}`}function Xf(e,t){return`Guard.IsDeepEqual(${e}, ${t})`}function mw(e){return`[${e.join(", ")}]`}function gr(e,t){return`((${e.join(", ")}) => ${t})`}function ze(e,t){return`${e}(${t.join(", ")})`}function Zc(e,t){return`new ${e}(${t.join(", ")})`}function fe(e,t){return`${e}${nw(t)?`.${t}`:`[${K(t)}]`}`}function K(e){if(!Cs(e))throw Error("Unsupported Constant");return ce(e)?JSON.stringify(e):`${e}`}function pw(e,t,n){return`(${e} ? ${t} : ${n})`}function qi(e){return`{ ${e.join("; ")}; }`}function Hn(e,t){return`const ${e} = ${t}`}function Zf(e,t){return`if(${e}) { ${t} }`}function zi(e){return`return ${e}`}function wt(e){return h(e.length,0)?"true":e.reduce((t,n)=>kt(t,n))}function el(e){return h(e.length,0)?"false":e.reduce((t,n)=>Ue(t,n))}function gw(e,t){return`Guard.IsMultipleOf(${e}, ${t})`}function hw(e){return e instanceof Boolean}function bw(e){return e instanceof Number}function xw(e){return e instanceof String}function xo(e){return globalThis.ArrayBuffer.isView(e)}function em(e){return e instanceof globalThis.RegExp}function tm(e){return e instanceof globalThis.Date}function nm(e){return e instanceof globalThis.Set}function rm(e){return e instanceof globalThis.Map}function kw(e){return C(e,"~kind")||C(e,"~unsafe")}function yw(e){const t={},n=Object.getOwnPropertyDescriptors(e);for(const r of Object.keys(n)){if(zn(r))continue;const s=n[r];C(s,"value")&&Object.defineProperty(t,r,{...s,value:qr(s.value)})}return t}function ww(e){const t={};for(const n of D(e))zn(n)||(t[n]=qr(e[n]));for(const n of Qc(e))t[n]=qr(e[n]);return t}function Sw(e){return Uf(e)?e:kw(e)?yw(e):ww(e)}function Iw(e){return e.map(t=>qr(t))}function vw(e){return e.slice()}function jw(e){return new RegExp(e.source,e.flags)}function Cw(e){return new Map(qr([...e.entries()]))}function Tw(e){return new Set(qr([...e.values()]))}function qr(e){return xo(e)?vw(e):em(e)?jw(e):rm(e)?Cw(e):nm(e)?Tw(e):H(e)?Iw(e):ee(e)?Sw(e):e}function tl(e){return qr(e)}const Ew={immutableTypes:!1,maxErrors:8,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function ko(){return Ew}function Nw(e,t){for(const n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function Aw(e,t){return{...e,...t}}function xe(e,t,n={}){const r=Aw(t,n);return Nw(r,e)}function jn(e,t){const n={},r=Object.getOwnPropertyDescriptors(tl(e)),s=new Set(t);for(const o of Object.keys(r))s.has(o)||Object.defineProperty(n,o,r[o]);return n}function me(e,t,n){const r=ko(),s=tl(e);for(const o of Object.keys(t))Object.defineProperty(s,o,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[o]});for(const o of Object.keys(n))Object.defineProperty(s,o,{configurable:!0,enumerable:!0,writable:!0,value:n[o]});return s}function Se(e,t){return ee(e)&&C(e,"~kind")&&h(e["~kind"],t)}function Wt(e){return ee(e)}function Te(e,t,n){return xe({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function ws(e){return Se(e,"Deferred")}function $w(e){return me(e,{"~readonly":!0},{})}function nl(e,t){return me($w(e),{},t)}function Pw(e,t,n,r){const s=G(e,t,n);return nl(s,r)}function Ow(e){return me(e,{"~optional":!0},{})}function rl(e,t){return me(Ow(e),{},t)}function Rw(e,t,n,r){const s=G(e,t,n);return rl(s,r)}function wr(e,t){return xe({"~kind":"Array"},{type:"array",items:e},t)}function ut(e){return Se(e,"Array")}function sl(e){return jn(e,["~kind","type","items"])}function yo(e,t,n={}){return xe({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function cn(e){return Se(e,"Constructor")}function Mw(e){return jn(e,["~kind","type","parameters","instanceType"])}function wo(e,t,n={}){return xe({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function ln(e){return Se(e,"Function")}function Fw(e){return jn(e,["~kind","type","parameters","returnType"])}function sn(e,t){return xe({"~kind":"Ref"},{$ref:e},t)}function gt(e){return Se(e,"Ref")}function So(e,t){return xe({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function ol(e){return Se(e,"Generic")}function il(e){return xe({"~kind":"Any"},{},e)}function Cn(e){return Se(e,"Any")}const _w="(?!)";function vt(e){return xe({"~kind":"Never"},{not:{}},e)}function Es(e){return Se(e,"Never")}function Vn(e,t={}){return Te("AddOptional",[e],t)}function Ii(e,t={}){return rl(e,t)}function Dw(e){return Ii(e)}function Jt(e){return Wt(e)&&C(e,"~optional")}function Lw(e){return D(e).filter(t=>!Jt(e[t]))}function sm(e){return D(e)}function om(e){return Yc(e)}function Ae(e,t={}){const n=Lw(e),r=n.length>0?{required:n}:{};return xe({"~kind":"Object"},{type:"object",...r,properties:e},t)}function Fe(e){return Se(e,"Object")}function Bw(e){return jn(e,["~kind","type","properties","required"])}function _t(e){return xe({"~kind":"Unknown"},{},e)}function yn(e){return Se(e,"Unknown")}function Io(e,t,n){const r=D(e).reduce((s,o)=>({...s,[o]:me(e[o],{},{$id:o})}),{});return xe({"~kind":"Cyclic"},{$defs:r,$ref:t},n)}function Dt(e){return Se(e,"Cyclic")}function Uw(e){return me(e,{"~unsafe":null},{})}function im(e){return an(e)&&C(e,"~unsafe")&&Ht(e["~unsafe"])}function at(e,t){var n;return((n=t[e.length])==null?void 0:n.call(t,...e))??(()=>{throw Error("Invalid Arguments")})()}function tc(...e){const[t,n]=at(e,{2:(r,s)=>[r,s,s],1:r=>[r,_t(),_t()]});return xe({"~kind":"Infer"},{type:"infer",name:t,extends:n},{})}function Qt(e){return Se(e,"Infer")}function vi(e,t,n,r={}){return xe({"~kind":"Dependent"},{if:e,then:t,else:n},r)}function un(e){return Se(e,"Dependent")}function qw(e){return jn(e,["~kind","if","then","else"])}function zw(e){return an(e)}function Hw(e){return D(e).filter(n=>isNaN(n)).reduce((n,r)=>[...n,e[r]],[])}function Kw(e){return ce(e)||we(e)}function Gw(e,t){const n=zw(e)?Hw(e):e;return xe({"~kind":"Enum"},{enum:n},t)}function dn(e){return Se(e,"Enum")}function $n(e,t={}){return xe({"~kind":"Intersect"},{allOf:e},t)}function _e(e){return Se(e,"Intersect")}function Vw(e){return jn(e,["~kind","allOf"])}let La;function Ww(){try{return cm("null")(),!0}catch{return!1}}function am(){return Pe(La)&&(La=Ww()),La&&ko().useAcceleration}function cm(...e){return new globalThis.Function(...e)}function Nt(){throw new Error("Unreachable")}function Jw(e){const t=new Set;let n=e;for(;n&&n!==Object.prototype;){for(const r of Reflect.ownKeys(n))r!=="constructor"&&typeof r!="symbol"&&t.add(r);n=Object.getPrototypeOf(n)}return[...t]}function Qw(e){return typeof e=="number"}var At;(function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"})(At||(At={}));let bs=BigInt("14695981039346656037");const[Yw,Xw]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Zw=Array.from({length:256}).map((e,t)=>BigInt(t)),lm=new Float64Array(1),um=new DataView(lm.buffer),dm=new Uint8Array(lm.buffer);function ht(e){bs=bs^Zw[e],bs=bs*Yw%Xw}function eS(e){ht(At.Array);for(const t of e)hr(t)}function tS(e){ht(At.BigInt),um.setBigInt64(0,e);for(const t of dm)ht(t)}function yd(e){ht(At.Boolean),ht(e?1:0)}function nS(e){ht(At.Constructor),hr(e.toString())}function rS(e){ht(At.Date),hr(e.getTime())}function sS(e){ht(At.Function),hr(e.toString())}function oS(e){ht(At.Null)}function wd(e){ht(At.Number),um.setFloat64(0,e,!0);for(const t of dm)ht(t)}function iS(e){ht(At.Object);for(const t of Jw(e).sort())hr(t),hr(e[t])}function aS(e){ht(At.RegExp),nc(e.toString())}const cS=new TextEncoder;function nc(e){ht(At.String);for(const t of cS.encode(e))ht(t)}function lS(e){ht(At.Symbol),hr(e.toString())}function uS(e){ht(At.TypeArray);const t=new Uint8Array(e.buffer);for(let n=0;n<t.length;n++)ht(t[n])}function dS(e){return ht(At.Undefined)}function hr(e){return xo(e)?uS(e):tm(e)?rS(e):em(e)?aS(e):hw(e)?yd(e.valueOf()):xw(e)?nc(e.valueOf()):bw(e)?wd(e.valueOf()):Qw(e)?wd(e):H(e)?eS(e):mt(e)?yd(e):et(e)?tS(e):Bi(e)?nS(e):Ht(e)?oS():ee(e)?iS(e):ce(e)?nc(e):Vc(e)?lS(e):Pe(e)?dS():kn(e)?sS(e):Nt()}function fm(e){return bs=BigInt("14695981039346656037"),hr(e),bs}function Hi(e){return fm(e).toString(16).padStart(16,"0")}const fS=Object.freeze(Object.defineProperty({__proto__:null,Hash:Hi,HashCode:fm},Symbol.toStringTag,{value:"Module"}));function mS(e){switch(e.keyword){case"additionalProperties":return"must not have additional properties";case"anyOf":return"must match a schema in anyOf";case"boolean":return"schema is false";case"const":return"must be equal to constant";case"contains":return"must contain at least 1 valid item";case"dependencies":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"dependentRequired":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"enum":return"must be equal to one of the allowed values";case"exclusiveMaximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"exclusiveMinimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"format":return`must match format "${e.params.format}"`;case"if":return`must match "${e.params.failingKeyword}" schema`;case"maxItems":return`must not have more than ${e.params.limit} items`;case"maxLength":return`must not have more than ${e.params.limit} characters`;case"maxProperties":return`must not have more than ${e.params.limit} properties`;case"maximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"minItems":return`must not have fewer than ${e.params.limit} items`;case"minLength":return`must not have fewer than ${e.params.limit} characters`;case"minProperties":return`must not have fewer than ${e.params.limit} properties`;case"minimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"multipleOf":return`must be multiple of ${e.params.multipleOf}`;case"not":return"must not be valid";case"oneOf":return"must match exactly one schema in oneOf";case"pattern":return`must match pattern "${e.params.pattern}"`;case"propertyNames":return`property names ${e.params.propertyNames.join(", ")} are invalid`;case"required":return`must have required properties ${e.params.requiredProperties.join(", ")}`;case"type":return typeof e.params.type=="string"?`must be ${e.params.type}`:`must be either ${e.params.type.join(" or ")}`;case"unevaluatedItems":return"must not have unevaluated items";case"unevaluatedProperties":return"must not have unevaluated properties";case"uniqueItems":return"must not have duplicate items";case"~refine":return e.params.message;default:return"an unknown validation error occurred"}}let pS=mS;function gS(){return pS}class mm{constructor(t,n){this.type=t,this.decode=n}Encode(t){const n=this.type,r=Yt(n)?i=>this.decode(n["~codec"].decode(i)):this.decode,s=Yt(n)?i=>n["~codec"].encode(t(i)):t,o={decode:r,encode:s};return me(this.type,{"~codec":o},{})}}class pm{constructor(t){this.type=t}Decode(t){return new mm(this.type,t)}}function al(e){return new pm(e)}function hS(e,t){return al(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function bS(e,t){return al(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function Yt(e){return Wt(e)&&C(e,"~codec")&&ee(e["~codec"])&&C(e["~codec"],"encode")&&C(e["~codec"],"decode")}function xS(e){return Jl(e)}function ji(e){return Wt(e)&&C(e,"~immutable")}function Wn(e,t={}){return Te("AddReadonly",[e],t)}function Ci(e,t={}){return nl(e,t)}function kS(e){return Ci(e)}function Ti(e){return Wt(e)&&C(e,"~readonly")}function yS(e,t){const n=cl(e)?[...e["~refine"],t]:[t];return me(e,{"~refine":n},{})}function wS(...e){const[t,n,r]=at(e,{3:(s,o,i)=>[s,o,i],2:(s,o)=>[s,o,()=>"Refine Error"]});return yS(t,{check:n,error:r})}function SS(e){return an(e)&&C(e,"check")&&C(e,"error")&&kn(e.check)&&kn(e.error)}function cl(e){return Wt(e)&&C(e,"~refine")&&H(e["~refine"])&<(e["~refine"],0,t=>SS(t))}const IS="-?(?:0|[1-9][0-9]*)n";function ll(e){return xe({"~kind":"BigInt"},{type:"bigint"},e)}function Yr(e){return Se(e,"BigInt")}function gm(e){return xe({"~kind":"Boolean"},{type:"boolean"},e)}function Sr(e){return Se(e,"Boolean")}function rc(e){return xe({"~kind":"Identifier"},{name:e})}function vS(e){return Se(e,"Identifier")}const hm="-?(?:0|[1-9][0-9]*)";function Ki(e){return xe({"~kind":"Integer"},{type:"integer"},e)}function On(e){return Se(e,"Integer")}class jS extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}}function CS(e){return et(e)?"bigint":mt(e)?"boolean":we(e)?"number":ce(e)?"string":(()=>{throw new jS(e)})()}function Re(e,t){return xe({"~kind":"Literal"},{type:CS(e),const:e},t)}function bm(e){return et(e)||mt(e)||we(e)||ce(e)}function TS(e){return Ve(e)&&et(e.const)}function ES(e){return Ve(e)&&mt(e.const)}function xm(e){return Ve(e)&&we(e.const)}function km(e){return Ve(e)&&ce(e.const)}function Ve(e){return Se(e,"Literal")}function ul(e){return xe({"~kind":"Null"},{type:"null"},e)}function vo(e){return Se(e,"Null")}const ym="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function br(e){return xe({"~kind":"Number"},{type:"number"},e)}function Zt(e){return Se(e,"Number")}function dl(e){return xe({"~kind":"Symbol"},{type:"symbol"},e)}function jo(e){return Se(e,"Symbol")}function Co(...e){const[t,n,r]=at(e,{3:(s,o,i)=>[s,o,i],2:(s,o)=>[s,o,o],1:s=>[s,_t(),_t()]});return xe({"~kind":"Parameter"},{name:t,extends:n,equals:r},{})}function NS(e){return Se(e,"Parameter")}const wm=".*";function Rn(e){return xe({"~kind":"String"},{type:"string"},e)}function Tn(e){return Se(e,"String")}function Ge(e,t={}){return xe({"~kind":"Union"},{anyOf:e},t)}function le(e){return Se(e,"Union")}function AS(e){return jn(e,["~kind","anyOf"])}function Sm(e){const t=mT(e);return h(t.length,2)?t[0]:[]}function $S(e){return!0}function Im(e){return je(e,(t,n)=>PS(t)?Im(n):!1,()=>!0)}function vm(e){return h(e.length,0)?!1:Im(e)}function PS(e){return le(e)?vm(e.anyOf):Ve(e)?$S(e.const):!1}function jm(e){return vm(e)}function Cm(e){return xe({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Tm(e,t,n=[]){return je(e,(r,s)=>Tm(s,t,[...n,`${r}${t}`]),()=>n)}function OS(e,t){return h(e.length,0)?[`${t}`]:Tm(e,t)}function Em(e,t,n=[]){return je(t,(r,s)=>Em(e,s,[...n,...Nm(e,r)]),()=>n)}function Nm(e,t){return le(t)?Em(e,t.anyOf):Ve(t)?OS(e,t.const):Nt()}function Am(e,t){return je(t,(n,r)=>Am(Nm(e,n),r),()=>e)}function RS(e){return e.map(t=>Re(t))}function MS(e){const t=Am([],e),n=RS(t);return Ge(n)}function FS(e){return h(e.length,0)?Nt():h(e.length,1)&&Ve(e[0])?e[0]:MS(e)}function $m(e){const t=Sm(e);return h(t.length,0)?Rn():jm(t)?FS(t):Cm(e)}function fl(e){const t=$m(e);return Bt(t)?Rn():t}function xr(e,t){const n="object",r={[e]:t};return xe({"~kind":"Record"},{type:n,patternProperties:r})}function _S(e){return xr(Hr,e)}function DS(e){return Ae({true:e,false:e})}function fn(e,t={}){const[n,r,s]=[e,e.length,!1];return xe({"~kind":"Tuple"},{type:"array",additionalItems:s,items:n,minItems:r},t)}function rt(e){return Se(e,"Tuple")}function LS(e){return jn(e,["~kind","type","items","minItems","additionalItems"])}function BS(e){return jn(e,["~readonly"])}function Pm(e,t){return me(BS(e),{},t)}function US(e,t,n,r){const s=G(e,t,n);return Pm(s,r)}function qS(e,t={}){return Te("RemoveReadonly",[e],t)}function zS(e,t={}){return Pm(e,t)}function HS(e){return jn(e,["~optional"])}function Om(e,t){return me(HS(e),{},t)}function KS(e,t,n,r){const s=G(e,t,n);return Om(s,r)}function GS(e,t={}){return Te("RemoveOptional",[e],t)}function Rm(e,t={}){return Om(e,t)}function Mm(e){return e.reduceRight((n,r,s)=>({[s]:r,...n}),{})}function VS(e){const t=Mm(e.items);return Ae(t)}function WS(e,t){return Ti(e)?!!Ti(t):!1}function JS(e,t){return Jt(e)?!!Jt(t):!1}function QS(e,t){const n=WS(e,t),r=JS(e,t),s=en([e,t]),o=zS(Rm(s));return n&&r?Ci(Ii(o)):n&&!r?Ci(o):!n&&r?Ii(o):o}function YS(e,t,n){return n in e?n in t?QS(e[n],t[n]):e[n]:n in t?t[n]:vt()}function XS(e,t){return[...new Set([...D(t),...D(e)])].reduce((r,s)=>({...r,[s]:YS(e,t,s)}),{})}function Sd(e){return Fe(e)?e.properties:rt(e)?Mm(e.items):Nt()}function ZS(e,t){const n=Sd(e),r=Sd(t),s=XS(n,r);return Ae(s)}function eI(e,t){const n=ta(e,t);return h(n,Fl)?e:h(n,_l)||h(n,Ml)?t:vt()}function Id(e){return Fe(e)||rt(e)}function tI(e,t){const n=le(e),r=le(t);return n||r}function nI(e,t){const n=zr(e),r=zr(t),s=tI(n,r),o=Id(n),i=Id(r);return s?en([n,r]):o&&i?ZS(n,r):o&&!i?n:!o&&i?r:eI(n,r)}function Fm(e,t,n=[]){return je(t,(r,s)=>Fm(e,s,[...n,nI(e,r)]),()=>h(n.length,0)?[e]:n)}function _m(e,t,n=[]){return je(e,(r,s)=>_m(s,t,[...n,...Ei([r],t)]),()=>n)}function Ei(e,t=[]){return je(e,(n,r)=>le(n)?Ei(r,_m(n.anyOf,t)):Ei(r,Fm(n,t)),()=>t)}function rI(e,t){const n=Jn({},e,t);return qt(n)?[]:[e]}function sI(e,t){return e.reduce((n,r)=>[...n,...rI(r,t)],[])}function Dm(e,t){const n=zr(e),r=le(n)?n.anyOf:[n],s=sI(r,t);return Xn(s)}function Ns(e,t,n){const r=$n([e,t]),s=Dm(n,e);return Xn([r,s])}function Ir(e){const t=e.map(n=>Re(n));return Xn(t)}function en(e){const t=Ei(e),n=ng(t);return As(n)}function Yn(e){const t=fl(e);return zr(t)}function Xn(e){const t=ng(e);return As(t)}function zr(e){return un(e)?Ns(e.if,e.then,e.else):dn(e)?Ir(e.enum):_e(e)?en(e.allOf):Bt(e)?Yn(e.pattern):le(e)?Xn(e.anyOf):e}function As(e){return h(e.length,1)?e[0]:h(e.length,0)?vt():Ge(e)}function oI(e,t){const n=Ir(e);return Vi(n,t)}function iI(e,t){return xr(To,t)}function aI(e,t){const n=en(e);return Vi(n,t)}function cI(e,t){return ce(e)||we(e)?Ae({[e]:t}):h(e,!1)?Ae({false:t}):h(e,!0)?Ae({true:t}):Ae({})}function lI(e,t){return xr(Wi,t)}function uI(e,t){return C(e,"pattern")&&(ce(e.pattern)||e.pattern instanceof RegExp)?xr(e.pattern.toString(),t):xr(Hr,t)}function dI(e,t){const n=Sm(e);return jm(n)?Vi(Yn(e),t):xr(e,t)}function fI(e){return le(e)?Gi(e.anyOf):[e]}function Gi(e){return e.reduce((t,n)=>[...t,...fI(n)],[])}function mI(e){return e.some(t=>Tn(t)||Zt(t)||On(t))}function pI(e,t){return h(mI(e),!0)?xr(Hr,t):void 0}function gI(e,t){return e.reduce((n,r)=>Ve(r)&&(ce(r.const)||we(r.const))?{...n,[r.const]:t}:n,{})}function hI(e,t){const n=gI(e,t);return Ae(n)}function bI(e,t){const n=Gi(e),r=pI(n,t);return Wt(r)?r:hI(n,t)}function Vi(e,t){return Cn(e)?_S(t):Sr(e)?DS(t):dn(e)?oI(e.enum,t):On(e)?iI(e,t):_e(e)?aI(e.allOf,t):Ve(e)?cI(e.const,t):Zt(e)?lI(e,t):le(e)?bI(e.anyOf,t):Tn(e)?uI(e,t):Bt(e)?dI(e.pattern,t):Ae({})}function Lm(e,t,n){return Ye([e])?me(Vi(e,t),{},n):Bm(e,t,n)}function xI(e,t,n,r,s){const o=G(e,t,n),i=G(e,t,r);return Lm(o,i,s)}const To=`^${hm}$`,Wi=`^${ym}$`,Hr=`^${wm}$`;function Bm(e,t,n={}){return Te("Record",[e,t],n)}function ml(e,t,n={}){return Lm(e,t,n)}function kI(e,t){return xr(e,t)}function sc(e){return h(e,Hr)?Rn():h(e,To)?Ki():h(e,Wi)?br():$m(e)}function mn(e){return D(e.patternProperties)[0]}function Ji(e){const t=mn(e);return sc(t)}function Lt(e){return e.patternProperties[mn(e)]}function jt(e){return Se(e,"Record")}function Qi(e){return xe({"~kind":"Rest"},{type:"rest",items:e},{})}function Yi(e){return Se(e,"Rest")}function Um(e){return xe({"~kind":"This"},{$ref:"#"},e)}function qm(e){return Se(e,"This")}function pl(e){return xe({"~kind":"Undefined"},{type:"undefined"},e)}function $s(e){return Se(e,"Undefined")}function zm(e){return xe({"~kind":"Void"},{type:"void"},e)}function Xr(e){return Se(e,"Void")}function yI(e,t){return h(e,"Array")?wr(t[0]):h(e,"Capitalize")?ag(t[0]):h(e,"ConstructorParameters")?bg(t[0]):h(e,"Evaluate")?m$(t[0]):h(e,"Exclude")?kg(t[0],t[1]):h(e,"Extract")?yg(t[0],t[1]):h(e,"Index")?ql(t[0],t[1]):h(e,"InstanceType")?Tg(t[0]):h(e,"Lowercase")?cg(t[0]):h(e,"NonNullable")?Pg(t[0]):h(e,"Omit")?Rg(t[0],t[1]):h(e,"Parameters")?_g(t[0]):h(e,"Partial")?Lg(t[0]):h(e,"Pick")?Ug(t[0],t[1]):h(e,"Readonly")?zg(t[0]):h(e,"KeyOf")?Gl(t[0]):h(e,"Record")?Bm(t[0],t[1]):h(e,"Required")?Gg(t[0]):h(e,"ReturnType")?Wg(t[0]):h(e,"Uncapitalize")?lg(t[0]):h(e,"Uppercase")?ug(t[0]):pc(sn(e),t)}function Zr(){throw Error("Unreachable")}function Hm(e,t=[]){return je(e,(n,r)=>Hm(r,[...t,n[1]]),()=>t)}function Zn(e){return h(e.length,3)?[e[0],...Hm(e[1])]:[]}function wI(e){return Co(e[0],e[2],e[4])}function SI(e){return Co(e[0],e[2],e[2])}function II(e){return Co(e[0],_t(),e[2])}function vI(e){return Co(e,_t(),_t())}function jI(e){return Zn(e)}function CI(e){return e[1]}function TI(e){return Zn(e)}function EI(e){return e[1]}function NI(e){return yI(e[0],e[1])}function AI(e){return null}function $I(e){return Rn()}function PI(e){return br()}function OI(e){return gm()}function RI(e){return pl()}function MI(e){return ul()}function FI(e){return Ki()}function _I(e){return ll()}function DI(e){return _t()}function LI(e){return il()}function BI(e){return Ae({})}function UI(e){return vt()}function qI(e){return dl()}function zI(e){return zm()}function HI(e){return Um()}function KI(e){return Re(BigInt(e))}function GI(e){return Re(h(e,"true"))}function VI(e){return Re(parseFloat(e))}function WI(e){return Re(e)}function JI(e){return e[1]}function QI(e){return Re(e)}function YI(e){return h(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function XI(e){return e[1]}function ZI(e){return Up(e)}function ev(e){return h(e.length,6)?vi(e[1],e[3],e[5]):vi(e[1],e[3],_t())}function tv(e){return e.length>0}function nv(e){return e.reduce((t,n)=>h(n.length,3)?[...t,[n[1]]]:[...t,[]],[])}function rv(e){return h(e.length,6)?[e[1],e[3],e[5]]:[]}function sv(e){return H(e)&&h(e.length,3)?e[1]:e}function ov(e){return h(e.length,2)?e[1]:[]}function vd(e,t){return t.reduce((n,r)=>{const s=r;return h(s.length,1)?ql(n,s[0]):h(s.length,0)?wr(n):Zr()},e)}function jd(e,t){return h(t.length,3)?gg(e,t[0],t[1],t[2]):e}function iv(e,t){return H(t)&&h(t.length,0)?e:Qg(e,t)}function av(e){const[t,n,r,s,o]=e;return iv(jd(t?Gl(vd(n,r)):vd(n,r),s),o)}function gl(e,t){return h(t.length,3)?(()=>{const[n,r,s]=t,o=gl(r,s);if(h(n,"&"))return _e(o)?$n([e,...o.allOf]):$n([e,o]);if(h(n,"|"))return le(o)?Ge([e,...o.anyOf]):Ge([e,o]);Zr()})():e}function cv(e){const[t,n]=e;return gl(t,n)}function lv(e){const[t,n]=e;return gl(t,n)}function uv(e){return f$(e[1])}function dv(e){return e[1]}function fv(e){return So(e[0],e[2])}function mv(e){return h(e.length,4)?tc(e[1],e[3]):h(e.length,2)?tc(e[1],_t()):Zr()}function pv(e){return`${e}`}function gv(e){return On(e[3])?To:Zt(e[3])?Wi:jo(e[3])||Tn(e[3])?Hr:Zr()}function hv(e){return e.length>0}function bv(e){return e.length>0}function xv(e){const[t,n,r,s,o]=e;return{[n]:t&&r?Wn(Vn(o)):t&&!r?Wn(o):!t&&r?Vn(o):o}}function kv(e){return Zn(e)}function Km(e){return e.reduce((t,n)=>C(n,To)||C(n,Wi)||C(n,Hr)?[t[0],ft(t[1],n)]:[ft(t[0],n),t[1]],[{},{}])}function yv(e){return Km(e[1])}function wv(e){const[t,n]=e,r=h(D(n).length,0)?{}:{patternProperties:n};return Ae(t,r)}function Sv(e){return h(e.length,5)?Wn(Vn(e[4])):h(e.length,3)?e[2]:h(e.length,4)?h(e[2],"readonly")?Wn(e[3]):Vn(e[3]):Zr()}function Iv(e){if(!H(e)||!h(e.length,3))return e;const[t,n,r]=e;return t&&r?Wn(Vn(n)):t&&!r?Wn(n):!t&&r?Vn(n):n}function vv(e){return h(e.length,2)?Qi(e[1]):h(e.length,1)?e[0]:Zr()}function jv(e){return Zn(e)}function Cv(e){return fn(e[1])}function Tv(e){return Wn(Vn(e[4]))}function Ev(e){return Wn(e[3])}function Nv(e){return Vn(e[3])}function Av(e){return e[2]}function $v(e){return h(e.length,2)?Qi(e[1]):h(e.length,1)?e[0]:Zr()}function Pv(e){return Zn(e)}function Ov(e){return wo(e[1],e[4])}function Rv(e){return yo(e[2],e[5])}function Cd(e,t){return h(e,"remove")?qS(t):h(e,"add")?Wn(t):t}function Mv(e){return h(e.length,2)&&h(e[0],"-")?"remove":h(e.length,2)&&h(e[0],"+")||h(e.length,1)?"add":"none"}function Td(e,t){return h(e,"remove")?GS(t):h(e,"add")?Vn(t):t}function Fv(e){return h(e.length,2)&&h(e[0],"-")?"remove":h(e.length,2)&&h(e[0],"+")||h(e.length,1)?"add":"none"}function _v(e){return h(e.length,2)?[e[1]]:[]}function Dv(e){return H(e[6])&&h(e[6].length,1)?gc(rc(e[3]),e[5],e[6][0],Cd(e[1],Td(e[8],e[10]))):gc(rc(e[3]),e[5],sn(e[3]),Cd(e[1],Td(e[8],e[10])))}function Lv(e){return sn(e)}function Bv(e){return BigInt(e)}function Uv(e){return parseFloat(e)}function qv(e){return h(e,"true")}function zv(e){return null}function Hv(e){return{[e[0]]:e[2]}}function Kv(e){return Zn(e)}function Gv(e){return e.reduce((t,n)=>ft(t,n),{})}function Vv(e){return Gv(e[1])}function Wv(e){return Zn(e)}function Jv(e){return e[1]}function Qv(e){return ll()}function Yv(e){return Rn()}function Xv(e){return br()}function Zv(e){return Ki()}function ej(e){return vt()}function tj(e){return Re(e)}function nj(e){return Ge(e[1])}function rj(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function sj(e){return[e[0],...e[1]]}function oj(e){return e[1]}function ij(e){return Zn(e)}function aj(e){return h(e.length,2)?e[1]:[]}function cj(e){const t=e[2],n=e[3],[r,s]=e[4],o=h(D(s).length,0)?{}:{patternProperties:s};return{[e[1]]:So(t,Ol(n,r,o))}}function lj(e){const t=e[2],[n,r]=e[3],s=h(D(r).length,0)?{}:{patternProperties:r};return{[e[1]]:Ol(t,n,s)}}function uj(e){return{[e[1]]:So(e[2],e[4])}}function dj(e){return{[e[1]]:e[3]}}function fj(e){return null}function mj(e){return Zn(e)}function pj(e){return e[1]}function gj(e){const[t,n]=[e[0],e[1]];return p$(ft(t,Km(n)[0]))}function hl(e){return h(e.length,2)}function Oe(e,t,n){return hl(e)?t(e[0],e[1]):n()}function hj(e,t){return h(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function $t(e,t){for(let n=0;n<e.length;n++){const r=hj(e[n],t);if(hl(r))return r}return[]}function oc(e,t){return Array.from({length:t-e+1},(n,r)=>String.fromCharCode(e+r))}const bj=[...oc(97,122),...oc(65,90)],Gm="0",Vm=oc(49,57),bl=[Gm,...Vm],xj=" ",xl=`
|
|
3
|
-
`,Eo="_",kl=".",kj="$",Wm="-",Jm="//",Qm="/*",yj="*/";function Ym(e){const t=e.indexOf(yj);return h(t,-1)?"":e.slice(t+2)}function Xm(e){const t=e.indexOf(xl);return h(t,-1)?"":e.slice(t)}function wj(e){return e.replace(/^[ \t\r\f\v]+/,"")}function ic(e){const t=wj(e);return t.startsWith(Qm)?ic(Ym(t.slice(2))):t.startsWith(Jm)?ic(Xm(t.slice(2))):t}function wn(e){const t=e.trimStart();return t.startsWith(Qm)?wn(Ym(t.slice(2))):t.startsWith(Jm)?wn(Xm(t.slice(2))):t}function Zm(e,t){return Oe($t([e],t),(n,r)=>[n,r],()=>["",t])}function Sj(e,t){return e.includes(t)}function Ni(e,t,n,r=""){return Oe($t(e,n),(s,o)=>Sj(t,s)?Ni(e,t,o,r):Ni(e,t,o,`${r}${s}`),()=>[r,n])}function Ij(e){return $t(Vm,e)}const vj=[...bl,Eo];function jj(e){return Ni(vj,[Eo],e)}function Cj(e){return Oe($t([Gm],e),(t,n)=>[t,n],()=>Oe(Ij(e),(t,n)=>Oe(jj(n),(r,s)=>[`${t}${r}`,s],()=>[]),()=>[]))}function ep(e){return Cj(wn(e))}function Tj(e){return Zm(Wm,e)}function Ej(e){return Oe(Tj(e),(t,n)=>Oe(ep(n),(r,s)=>[`${t}${r}`,s],()=>[]),()=>[])}function Nj(e){return Ej(wn(e))}function Aj(e){return Oe(Nj(e),(t,n)=>Oe($t(["n"],n),(r,s)=>[`${t}`,s],()=>[]),()=>[])}function tp(e){return Aj(e)}function Ba(e,t){return $t([e],t)}function S(e,t){return h(e,"")?["",t]:e.startsWith(xl)?Ba(e,ic(t)):e.startsWith(xj)?Ba(e,t):Ba(e,wn(t))}const np=[...bj,Eo,kj];function $j(e){return $t(np,e)}const Pj=[...np,...bl];function rp(e,t=""){return Oe($t(Pj,e),(n,r)=>rp(r,`${t}${n}`),()=>[t,e])}function Oj(e){return Oe($j(e),(t,n)=>Oe(rp(n),(r,s)=>[`${t}${r}`,s],()=>[]),()=>[])}function Ze(e){return Oj(wn(e))}const Rj=[...bl,Eo];function Mj(e){return hl($t([kl],e))}function sp(e){return Oe(Ni(Rj,[Eo],e),(t,n)=>h(t,"")?[]:[t,n],()=>[])}function Fj(e){return Oe($t([kl],e),(t,n)=>Oe(sp(n),(r,s)=>[`0${t}${r}`,s],()=>[]),()=>[])}function _j(e){return Oe(ep(e),(t,n)=>Oe($t([kl],n),(r,s)=>Oe(sp(s),(o,i)=>[`${t}${r}${o}`,i],()=>[`${t}`,s]),()=>[`${t}`,n]),()=>[])}function Dj(e){return Mj(e)?Fj(e):_j(e)}function Lj(e){return Dj(wn(e))}function Bj(e){return Zm(Wm,e)}function Uj(e){return Oe(Bj(e),(t,n)=>Oe(Lj(n),(r,s)=>[`${t}${r}`,s],()=>[]),()=>[])}function yl(e){return Uj(wn(e))}function qj(e){return h(e,"")?[]:[e.slice(0,1),e.slice(1)]}function op(e,t){return je(e,(n,r)=>t.startsWith(n)?!0:op(r,t),()=>!1)}function No(e,t,n=""){return Oe(qj(t),(r,s)=>op(e,t)?[n,t]:No(e,s,`${n}${r}`),()=>[])}function zj(e,t,n){return Oe($t([e],n),(r,s)=>Oe(No([t],s),(o,i)=>Oe($t([t],i),(a,c)=>[`${o}`,c],()=>[]),()=>[]),()=>[])}function Hj(e,t,n){return Oe($t([e],n),(r,s)=>Oe(No([xl,t],s),(o,i)=>Oe($t([t],i),(a,c)=>[`${o}`,c],()=>[]),()=>[]),()=>[])}function Kj(e,t,n,r){return n?zj(e,t,wn(r)):Hj(e,t,wn(r))}function Gj(e,t){return $t(e,t)}function Vj(e,t){return Kj(e,e,!1,t)}function Wj(e,t){return Oe(Gj(e,t),(n,r)=>Vj(n,`${n}${r}`),()=>[])}function wl(e,t){return Wj(e,wn(t))}function Jj(e,t){return Oe(No(e,t),(n,r)=>h(n,"")?[]:[n,r],()=>[])}const d=(e,t,n=()=>[])=>e.length===2?t(e):n(),Qj=e=>d(d(Ze(e),([t,n])=>d(S("extends",n),([r,s])=>d(be(s),([o,i])=>d(S("=",i),([a,c])=>d(be(c),([u,f])=>[[t,r,o,a,u],f]))))),([t,n])=>[wI(t),n]),Yj=e=>d(d(Ze(e),([t,n])=>d(S("extends",n),([r,s])=>d(be(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[SI(t),n]),Xj=e=>d(d(Ze(e),([t,n])=>d(S("=",n),([r,s])=>d(be(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[II(t),n]),Zj=e=>d(Ze(e),([t,n])=>[vI(t),n]),ip=e=>d(d(Qj(e),([t,n])=>[t,n],()=>d(Yj(e),([t,n])=>[t,n],()=>d(Xj(e),([t,n])=>[t,n],()=>d(Zj(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),ap=(e,t=[])=>d(d(S(",",e),([n,r])=>d(ip(r),([s,o])=>[[n,s],o])),([n,r])=>ap(r,[...t,n]),()=>[t,e]),eC=e=>d(d(d(ip(e),([t,n])=>d(ap(n),([r,s])=>d(d(S(",",s),([o,i])=>[[o],i],()=>[[],s]),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[jI(t),n]),Sl=e=>d(d(S("<",e),([t,n])=>d(eC(n),([r,s])=>d(S(">",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[CI(t),n]),cp=(e,t=[])=>d(d(S(",",e),([n,r])=>d(be(r),([s,o])=>[[n,s],o])),([n,r])=>cp(r,[...t,n]),()=>[t,e]),tC=e=>d(d(d(be(e),([t,n])=>d(cp(n),([r,s])=>d(d(S(",",s),([o,i])=>[[o],i],()=>[[],s]),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[TI(t),n]),nC=e=>d(d(S("<",e),([t,n])=>d(tC(n),([r,s])=>d(S(">",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[EI(t),n]),rC=e=>d(d(Ze(e),([t,n])=>d(nC(n),([r,s])=>[[t,r],s])),([t,n])=>[NI(t),n]),lp=e=>d(d(d(S(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[AI(),n]),up=e=>d(S("string",e),([t,n])=>[$I(),n]),dp=e=>d(S("number",e),([t,n])=>[PI(),n]),sC=e=>d(S("boolean",e),([t,n])=>[OI(),n]),oC=e=>d(S("undefined",e),([t,n])=>[RI(),n]),iC=e=>d(S("null",e),([t,n])=>[MI(),n]),fp=e=>d(S("integer",e),([t,n])=>[FI(),n]),aC=e=>d(S("bigint",e),([t,n])=>[_I(),n]),cC=e=>d(S("unknown",e),([t,n])=>[DI(),n]),lC=e=>d(S("any",e),([t,n])=>[LI(),n]),uC=e=>d(S("object",e),([t,n])=>[BI(),n]),dC=e=>d(S("never",e),([t,n])=>[UI(),n]),mp=e=>d(S("symbol",e),([t,n])=>[qI(),n]),fC=e=>d(S("void",e),([t,n])=>[zI(),n]),mC=e=>d(S("this",e),([t,n])=>[HI(),n]),pC=e=>d(d(S("${",e),([t,n])=>d(be(n),([r,s])=>d(S("}",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[JI(t),n]),Ua=e=>d(No(["${","`"],e),([t,n])=>[QI(t),n]),pp=e=>d(d(d(Ua(e),([t,n])=>d(pC(n),([r,s])=>d(pp(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d(d(Ua(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d(d(Ua(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[YI(t),n]),gp=e=>d(d(S("`",e),([t,n])=>d(pp(n),([r,s])=>d(S("`",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[XI(t),n]),gC=e=>d(gp(e),([t,n])=>[ZI(t),n]),hC=e=>d(d(d(S("if",e),([t,n])=>d(be(n),([r,s])=>d(S("then",s),([o,i])=>d(be(i),([a,c])=>d(S("else",c),([u,f])=>d(be(f),([p,g])=>[[t,r,o,a,u,p],g])))))),([t,n])=>[t,n],()=>d(d(S("if",e),([t,n])=>d(be(n),([r,s])=>d(S("then",s),([o,i])=>d(be(i),([a,c])=>[[t,r,o,a],c])))),([t,n])=>[t,n],()=>[])),([t,n])=>[ev(t),n]),bC=e=>d(tp(e),([t,n])=>[KI(t),n]),xC=e=>d(d(S("true",e),([t,n])=>[t,n],()=>d(S("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[GI(t),n]),kC=e=>d(yl(e),([t,n])=>[VI(t),n]),yC=e=>d(wl(["'",'"'],e),([t,n])=>[WI(t),n]),wC=e=>d(d(d(S("keyof",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[tv(t),n]),hp=(e,t=[])=>d(d(d(S("[",e),([n,r])=>d(be(r),([s,o])=>d(S("]",o),([i,a])=>[[n,s,i],a]))),([n,r])=>[n,r],()=>d(d(S("[",e),([n,r])=>d(S("]",r),([s,o])=>[[n,s],o])),([n,r])=>[n,r],()=>[])),([n,r])=>hp(r,[...t,n]),()=>[t,e]),SC=e=>d(hp(e),([t,n])=>[nv(t),n]),IC=e=>d(d(d(S("extends",e),([t,n])=>d(be(n),([r,s])=>d(S("?",s),([o,i])=>d(be(i),([a,c])=>d(S(":",c),([u,f])=>d(be(f),([p,g])=>[[t,r,o,a,u,p],g])))))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[rv(t),n]),vC=e=>d(d(d(S("(",e),([t,n])=>d(be(n),([r,s])=>d(S(")",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d(up(e),([t,n])=>[t,n],()=>d(dp(e),([t,n])=>[t,n],()=>d(sC(e),([t,n])=>[t,n],()=>d(oC(e),([t,n])=>[t,n],()=>d(iC(e),([t,n])=>[t,n],()=>d(fp(e),([t,n])=>[t,n],()=>d(aC(e),([t,n])=>[t,n],()=>d(cC(e),([t,n])=>[t,n],()=>d(lC(e),([t,n])=>[t,n],()=>d(uC(e),([t,n])=>[t,n],()=>d(dC(e),([t,n])=>[t,n],()=>d(mp(e),([t,n])=>[t,n],()=>d(fC(e),([t,n])=>[t,n],()=>d(mC(e),([t,n])=>[t,n],()=>d(bC(e),([t,n])=>[t,n],()=>d(xC(e),([t,n])=>[t,n],()=>d(kC(e),([t,n])=>[t,n],()=>d(yC(e),([t,n])=>[t,n],()=>d(gC(e),([t,n])=>[t,n],()=>d(hC(e),([t,n])=>[t,n],()=>d(MC(e),([t,n])=>[t,n],()=>d(DC(e),([t,n])=>[t,n],()=>d(HC(e),([t,n])=>[t,n],()=>d(zC(e),([t,n])=>[t,n],()=>d(WC(e),([t,n])=>[t,n],()=>d(rC(e),([t,n])=>[t,n],()=>d(JC(e),([t,n])=>[t,n],()=>[])))))))))))))))))))))))))))),([t,n])=>[sv(t),n]),jC=e=>d(d(d(S("with",e),([t,n])=>d(Op(n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[ov(t),n]),bp=e=>d(d(wC(e),([t,n])=>d(vC(n),([r,s])=>d(SC(s),([o,i])=>d(IC(i),([a,c])=>d(jC(c),([u,f])=>[[t,r,o,a,u],f]))))),([t,n])=>[av(t),n]),xp=e=>d(d(d(S("&",e),([t,n])=>d(bp(n),([r,s])=>d(xp(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),kp=e=>d(d(bp(e),([t,n])=>d(xp(n),([r,s])=>[[t,r],s])),([t,n])=>[cv(t),n]),yp=e=>d(d(d(S("|",e),([t,n])=>d(kp(n),([r,s])=>d(yp(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Xi=e=>d(d(kp(e),([t,n])=>d(yp(n),([r,s])=>[[t,r],s])),([t,n])=>[lv(t),n]),CC=e=>d(d(S("readonly",e),([t,n])=>d(Xi(n),([r,s])=>[[t,r],s])),([t,n])=>[uv(t),n]),TC=e=>d(d(S("|",e),([t,n])=>d(Xi(n),([r,s])=>[[t,r],s])),([t,n])=>[dv(t),n]),EC=e=>d(d(Sl(e),([t,n])=>d(S("=",n),([r,s])=>d(be(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[fv(t),n]),NC=e=>d(d(d(S("infer",e),([t,n])=>d(Ze(n),([r,s])=>d(S("extends",s),([o,i])=>d(Xi(i),([a,c])=>[[t,r,o,a],c])))),([t,n])=>[t,n],()=>d(d(S("infer",e),([t,n])=>d(Ze(n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>[])),([t,n])=>[mv(t),n]),be=e=>d(d(NC(e),([t,n])=>[t,n],()=>d(TC(e),([t,n])=>[t,n],()=>d(CC(e),([t,n])=>[t,n],()=>d(Xi(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),AC=e=>d(yl(e),([t,n])=>[pv(t),n]),$C=e=>d(Ze(e),([t,n])=>[t,n]),PC=e=>d(wl(["'",'"'],e),([t,n])=>[t,n]),OC=e=>d(d(S("[",e),([t,n])=>d(Ze(n),([r,s])=>d(S(":",s),([o,i])=>d(d(fp(i),([a,c])=>[a,c],()=>d(dp(i),([a,c])=>[a,c],()=>d(up(i),([a,c])=>[a,c],()=>d(mp(i),([a,c])=>[a,c],()=>[])))),([a,c])=>d(S("]",c),([u,f])=>[[t,r,o,a,u],f]))))),([t,n])=>[gv(t),n]),wp=e=>d(d(AC(e),([t,n])=>[t,n],()=>d($C(e),([t,n])=>[t,n],()=>d(PC(e),([t,n])=>[t,n],()=>d(OC(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),Sp=e=>d(d(d(S("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[hv(t),n]),Ip=e=>d(d(d(S("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[bv(t),n]),vp=e=>d(d(Sp(e),([t,n])=>d(wp(n),([r,s])=>d(Ip(s),([o,i])=>d(S(":",i),([a,c])=>d(be(c),([u,f])=>[[t,r,o,a,u],f]))))),([t,n])=>[xv(t),n]),Zi=e=>d(d(d(S(",",e),([t,n])=>d(S(`
|
|
4
|
-
`,n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d(d(S(";",e),([t,n])=>d(S(`
|
|
5
|
-
`,n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d(d(S(",",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d(d(S(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d(d(S(`
|
|
6
|
-
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),jp=(e,t=[])=>d(d(Zi(e),([n,r])=>d(vp(r),([s,o])=>[[n,s],o])),([n,r])=>jp(r,[...t,n]),()=>[t,e]),RC=e=>d(d(d(vp(e),([t,n])=>d(jp(n),([r,s])=>d(d(Zi(s),([o,i])=>[[o],i],()=>[[],s]),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[kv(t),n]),Il=e=>d(d(S("{",e),([t,n])=>d(RC(n),([r,s])=>d(S("}",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[yv(t),n]),MC=e=>d(Il(e),([t,n])=>[wv(t),n]),FC=e=>d(d(d(Ze(e),([t,n])=>d(S("?",n),([r,s])=>d(S(":",s),([o,i])=>d(S("readonly",i),([a,c])=>d(be(c),([u,f])=>[[t,r,o,a,u],f]))))),([t,n])=>[t,n],()=>d(d(Ze(e),([t,n])=>d(S(":",n),([r,s])=>d(S("readonly",s),([o,i])=>d(be(i),([a,c])=>[[t,r,o,a],c])))),([t,n])=>[t,n],()=>d(d(Ze(e),([t,n])=>d(S("?",n),([r,s])=>d(S(":",s),([o,i])=>d(be(i),([a,c])=>[[t,r,o,a],c])))),([t,n])=>[t,n],()=>d(d(Ze(e),([t,n])=>d(S(":",n),([r,s])=>d(be(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>[])))),([t,n])=>[Sv(t),n]),Ed=e=>d(d(FC(e),([t,n])=>[t,n],()=>d(d(Sp(e),([t,n])=>d(be(n),([r,s])=>d(Ip(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>[])),([t,n])=>[Iv(t),n]),Cp=e=>d(d(d(S("...",e),([t,n])=>d(Ed(n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d(d(Ed(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[vv(t),n]),Tp=(e,t=[])=>d(d(S(",",e),([n,r])=>d(Cp(r),([s,o])=>[[n,s],o])),([n,r])=>Tp(r,[...t,n]),()=>[t,e]),_C=e=>d(d(d(Cp(e),([t,n])=>d(Tp(n),([r,s])=>d(d(S(",",s),([o,i])=>[[o],i],()=>[[],s]),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[jv(t),n]),DC=e=>d(d(S("[",e),([t,n])=>d(_C(n),([r,s])=>d(S("]",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[Cv(t),n]),LC=e=>d(d(Ze(e),([t,n])=>d(S("?",n),([r,s])=>d(S(":",s),([o,i])=>d(S("readonly",i),([a,c])=>d(be(c),([u,f])=>[[t,r,o,a,u],f]))))),([t,n])=>[Tv(t),n]),BC=e=>d(d(Ze(e),([t,n])=>d(S(":",n),([r,s])=>d(S("readonly",s),([o,i])=>d(be(i),([a,c])=>[[t,r,o,a],c])))),([t,n])=>[Ev(t),n]),UC=e=>d(d(Ze(e),([t,n])=>d(S("?",n),([r,s])=>d(S(":",s),([o,i])=>d(be(i),([a,c])=>[[t,r,o,a],c])))),([t,n])=>[Nv(t),n]),qC=e=>d(d(Ze(e),([t,n])=>d(S(":",n),([r,s])=>d(be(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[Av(t),n]),Nd=e=>d(d(LC(e),([t,n])=>[t,n],()=>d(BC(e),([t,n])=>[t,n],()=>d(UC(e),([t,n])=>[t,n],()=>d(qC(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),Ep=e=>d(d(d(S("...",e),([t,n])=>d(Nd(n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d(d(Nd(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[$v(t),n]),Np=(e,t=[])=>d(d(S(",",e),([n,r])=>d(Ep(r),([s,o])=>[[n,s],o])),([n,r])=>Np(r,[...t,n]),()=>[t,e]),Ap=e=>d(d(d(Ep(e),([t,n])=>d(Np(n),([r,s])=>d(d(S(",",s),([o,i])=>[[o],i],()=>[[],s]),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Pv(t),n]),zC=e=>d(d(S("(",e),([t,n])=>d(Ap(n),([r,s])=>d(S(")",s),([o,i])=>d(S("=>",i),([a,c])=>d(be(c),([u,f])=>[[t,r,o,a,u],f]))))),([t,n])=>[Ov(t),n]),HC=e=>d(d(S("new",e),([t,n])=>d(S("(",n),([r,s])=>d(Ap(s),([o,i])=>d(S(")",i),([a,c])=>d(S("=>",c),([u,f])=>d(be(f),([p,g])=>[[t,r,o,a,u,p],g])))))),([t,n])=>[Rv(t),n]),KC=e=>d(d(d(S("+",e),([t,n])=>d(S("readonly",n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d(d(S("-",e),([t,n])=>d(S("readonly",n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d(d(S("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[Mv(t),n]),GC=e=>d(d(d(S("+",e),([t,n])=>d(S("?",n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d(d(S("-",e),([t,n])=>d(S("?",n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d(d(S("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[Fv(t),n]),VC=e=>d(d(d(S("as",e),([t,n])=>d(be(n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[_v(t),n]),WC=e=>d(d(S("{",e),([t,n])=>d(KC(n),([r,s])=>d(S("[",s),([o,i])=>d(Ze(i),([a,c])=>d(S("in",c),([u,f])=>d(be(f),([p,g])=>d(VC(g),([b,x])=>d(S("]",x),([y,v])=>d(GC(v),([k,E])=>d(S(":",E),([$,B])=>d(be(B),([R,M])=>d(lp(M),([P,N])=>d(S("}",N),([O,_])=>[[t,r,o,a,u,p,b,y,k,$,R,P,O],_]))))))))))))),([t,n])=>[Dv(t),n]),JC=e=>d(Ze(e),([t,n])=>[Lv(t),n]),QC=e=>d(tp(e),([t,n])=>[Bv(t),n]),YC=e=>d(yl(e),([t,n])=>[Uv(t),n]),XC=e=>d(d(S("true",e),([t,n])=>[t,n],()=>d(S("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[qv(t),n]),ZC=e=>d(wl(['"',"'"],e),([t,n])=>[t,n]),eT=e=>d(S("null",e),([t,n])=>[zv(),n]),tT=e=>d(S("undefined",e),([t,n])=>[void 0,n]),$p=e=>d(d(wp(e),([t,n])=>d(S(":",n),([r,s])=>d(vl(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[Hv(t),n]),Pp=(e,t=[])=>d(d(Zi(e),([n,r])=>d($p(r),([s,o])=>[[n,s],o])),([n,r])=>Pp(r,[...t,n]),()=>[t,e]),nT=e=>d(d(d($p(e),([t,n])=>d(Pp(n),([r,s])=>d(d(Zi(s),([o,i])=>[[o],i],()=>[[],s]),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Kv(t),n]),Op=e=>d(d(S("{",e),([t,n])=>d(nT(n),([r,s])=>d(S("}",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[Vv(t),n]),Rp=(e,t=[])=>d(d(S(",",e),([n,r])=>d(vl(r),([s,o])=>[[n,s],o])),([n,r])=>Rp(r,[...t,n]),()=>[t,e]),rT=e=>d(d(d(vl(e),([t,n])=>d(Rp(n),([r,s])=>d(d(S(",",s),([o,i])=>[[o],i],()=>[[],s]),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Wv(t),n]),sT=e=>d(d(S("[",e),([t,n])=>d(rT(n),([r,s])=>d(S("]",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[Jv(t),n]),vl=e=>d(d(QC(e),([t,n])=>[t,n],()=>d(YC(e),([t,n])=>[t,n],()=>d(XC(e),([t,n])=>[t,n],()=>d(ZC(e),([t,n])=>[t,n],()=>d(eT(e),([t,n])=>[t,n],()=>d(tT(e),([t,n])=>[t,n],()=>d(Op(e),([t,n])=>[t,n],()=>d(sT(e),([t,n])=>[t,n],()=>[])))))))),([t,n])=>[t,n]),oT=e=>d(S("-?(?:0|[1-9][0-9]*)n",e),([t,n])=>[Qv(),n]),iT=e=>d(S(".*",e),([t,n])=>[Yv(),n]),aT=e=>d(S("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([t,n])=>[Xv(),n]),cT=e=>d(S("-?(?:0|[1-9][0-9]*)",e),([t,n])=>[Zv(),n]),lT=e=>d(S("(?!)",e),([t,n])=>[ej(),n]),uT=e=>d(Jj(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,n])=>[tj(t),n]),dT=e=>d(d(oT(e),([t,n])=>[t,n],()=>d(iT(e),([t,n])=>[t,n],()=>d(aT(e),([t,n])=>[t,n],()=>d(cT(e),([t,n])=>[t,n],()=>d(lT(e),([t,n])=>[t,n],()=>d(fT(e),([t,n])=>[t,n],()=>d(uT(e),([t,n])=>[t,n],()=>[]))))))),([t,n])=>[t,n]),fT=e=>d(d(S("(",e),([t,n])=>d(jl(n),([r,s])=>d(S(")",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[nj(t),n]),Mp=e=>d(d(d(ac(e),([t,n])=>d(S("|",n),([r,s])=>d(Mp(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d(d(ac(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[]))),([t,n])=>[rj(t),n]),ac=e=>d(d(dT(e),([t,n])=>d(jl(n),([r,s])=>[[t,r],s])),([t,n])=>[sj(t),n]),jl=e=>d(d(Mp(e),([t,n])=>[t,n],()=>d(ac(e),([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),mT=e=>d(d(S("^",e),([t,n])=>d(jl(n),([r,s])=>d(S("$",s),([o,i])=>[[t,r,o],i]))),([t,n])=>[oj(t),n]),Fp=(e,t=[])=>d(d(S(",",e),([n,r])=>d(be(r),([s,o])=>[[n,s],o])),([n,r])=>Fp(r,[...t,n]),()=>[t,e]),pT=e=>d(d(d(be(e),([t,n])=>d(Fp(n),([r,s])=>d(d(S(",",s),([o,i])=>[[o],i],()=>[[],s]),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[ij(t),n]),_p=e=>d(d(d(S("extends",e),([t,n])=>d(pT(n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[aj(t),n]),gT=e=>d(d(S("interface",e),([t,n])=>d(Ze(n),([r,s])=>d(Sl(s),([o,i])=>d(_p(i),([a,c])=>d(Il(c),([u,f])=>[[t,r,o,a,u],f]))))),([t,n])=>[cj(t),n]),hT=e=>d(d(S("interface",e),([t,n])=>d(Ze(n),([r,s])=>d(_p(s),([o,i])=>d(Il(i),([a,c])=>[[t,r,o,a],c])))),([t,n])=>[lj(t),n]),bT=e=>d(d(S("type",e),([t,n])=>d(Ze(n),([r,s])=>d(Sl(s),([o,i])=>d(S("=",i),([a,c])=>d(be(c),([u,f])=>[[t,r,o,a,u],f]))))),([t,n])=>[uj(t),n]),xT=e=>d(d(S("type",e),([t,n])=>d(Ze(n),([r,s])=>d(S("=",s),([o,i])=>d(be(i),([a,c])=>[[t,r,o,a],c])))),([t,n])=>[dj(t),n]),kT=e=>d(d(d(S("export",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[fj(),n]),Dp=e=>d(d(d(S(";",e),([t,n])=>d(S(`
|
|
7
|
-
`,n),([r,s])=>[[t,r],s])),([t,n])=>[t,n],()=>d(d(S(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>d(d(S(`
|
|
8
|
-
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]),Lp=(e,t=[])=>d(d(Dp(e),([n,r])=>d(Cl(r),([s,o])=>[[n,s],o])),([n,r])=>Lp(r,[...t,n]),()=>[t,e]),yT=e=>d(d(d(Cl(e),([t,n])=>d(Lp(n),([r,s])=>d(d(Dp(s),([o,i])=>[[o],i],()=>[[],s]),([o,i])=>[[t,r,o],i]))),([t,n])=>[t,n],()=>d([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[mj(t),n]),Cl=e=>d(d(kT(e),([t,n])=>d(d(gT(n),([r,s])=>[r,s],()=>d(hT(n),([r,s])=>[r,s],()=>d(bT(n),([r,s])=>[r,s],()=>d(xT(n),([r,s])=>[r,s],()=>[])))),([r,s])=>d(lp(s),([o,i])=>[[t,r,o],i]))),([t,n])=>[pj(t),n]),wT=e=>d(d(Cl(e),([t,n])=>d(yT(n),([r,s])=>[[t,r],s])),([t,n])=>[gj(t),n]),ST=e=>d(d(wT(e),([t,n])=>[t,n],()=>d(EC(e),([t,n])=>[t,n],()=>d(be(e),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]);function IT(e){const t=gp(`\`${e}\``);return h(t.length,2)?t[0]:Nt()}function vT(e){return e.join("|")}function jT(e){return e.slice(1,e.length-1)}function CT(e,t,n){return vr(t,`${n}${e}`)}function TT(e,t){return vr(e,`${t}${IS}`)}function ET(e,t){return vr(e,`${t}${hm}`)}function NT(e,t){return vr(e,`${t}${ym}`)}function AT(e,t){return Ao(Ge([Re("false"),Re("true")]),e,t)}function $T(e,t){return vr(e,`${t}${wm}`)}function PT(e,t,n){return vr(t,`${n}${jT(e)}`)}function OT(e,t,n){const r=Tl(e,{});return Ao(r,t,n)}function RT(e,t,n){const r=Ir(e);return Ao(r,t,n)}function Bp(e,t,n,r=[]){return je(e,(s,o)=>Bp(o,t,n,[...r,Ao(s,[],"")]),()=>vr(t,`${n}(${vT(r)})`))}function Ao(e,t,n){return dn(e)?RT(e.enum,t,n):On(e)?ET(t,n):Ve(e)?CT(e.const,t,n):Yr(e)?TT(t,n):Sr(e)?AT(t,n):Zt(e)?NT(t,n):Tn(e)?$T(t,n):Bt(e)?PT(e.pattern,t,n):DT(e)?OT(e.parameters[0],t,n):le(e)?Bp(e.anyOf,t,n):_w}function vr(e,t){return je(e,(n,r)=>Ao(n,r,t),()=>t)}function MT(e){return`^${vr(e,"")}$`}function FT(e){const t=MT(e);return Cm(t)}function Tl(e,t){return Ye(e)?me(FT(e),{},t):Up(e,t)}function _T(e,t,n,r){const s=qn(e,t,n);return Tl(s,r)}function Up(e,t={}){return Te("TemplateLiteral",[e],t)}function DT(e){return Wt(e)&&C(e,"action")&&h(e.action,"TemplateLiteral")}function qp(e){return Tl(e,{})}function LT(e){const t=IT(e);return qp(t)}function BT(e,t={}){const n=ce(e)?LT(e):qp(e);return me(n,{},t)}function Bt(e){return Se(e,"TemplateLiteral")}function zp(e){return xe({"~kind":"ExtendsUnion"},{inferred:e})}function El(e){return ee(e)&&C(e,"~kind")&&C(e,"inferred")&&h(e["~kind"],"ExtendsUnion")&&ee(e.inferred)}function Y(e){return xe({"~kind":"ExtendsTrue"},{inferred:e})}function Nl(e){return ee(e)&&C(e,"~kind")&&C(e,"inferred")&&h(e["~kind"],"ExtendsTrue")&&ee(e.inferred)}function ye(){return xe({"~kind":"ExtendsFalse"},{})}function cc(e){return ee(e)&&C(e,"~kind")&&h(e["~kind"],"ExtendsFalse")}function qt(e){return El(e)||Nl(e)}function xt(e,t,n){return qt(e)?t(e.inferred):n()}const UT=Object.freeze(Object.defineProperty({__proto__:null,ExtendsFalse:ye,ExtendsTrue:Y,ExtendsUnion:zp,IsExtendsFalse:cc,IsExtendsTrue:Nl,IsExtendsTrueLike:qt,IsExtendsUnion:El,Match:xt},Symbol.toStringTag,{value:"Module"}));function qT(e,t,n,r){return xt(Qe(e,n,r),s=>Y(ft(ft(e,s),{[t]:n})),()=>ye())}function zT(e,t){return Y(e)}function HT(e,t,n,r,s){return xt(Qe(e,t,n),o=>xt(Qe(o,t,r),i=>Y(i),()=>ye()),()=>xt(Qe(e,t,s),o=>Y(o),()=>ye()))}function KT(e,t,n){const r=Ir(n);return Qe(e,t,r)}function Hp(e,t,n){return je(n,(r,s)=>xt(Qe(e,t,r),o=>Hp(o,t,s),()=>ye()),()=>Y(e))}function GT(e,t,n){const r=Yn(n);return Qe(e,t,r)}function Kp(e,t,n){return je(n,(r,s)=>xt(Qe(e,t,r),o=>Y(o),()=>Kp(e,t,s)),()=>ye())}function bt(e,t,n){return Cn(n)?zT(e):un(n)?HT(e,t,n.if,n.then,n.else):dn(n)?KT(e,t,n.enum):Qt(n)?qT(e,n.name,t,n.extends):_e(n)?Hp(e,t,n.allOf):Bt(n)?GT(e,t,n.pattern):le(n)?Kp(e,t,n.anyOf):yn(n)?Y(e):ye()}function VT(e,t,n){return Qt(n)?bt(e,t,n):Cn(n)||yn(n)?Y(e):zp(e)}function WT(e,t){const n=ji(e),r=ji(t);return n&&r||!n&&r?!0:!(n&&!r)}function JT(e,t,n,r){return ut(r)?WT(t,r)?Qe(e,n,r.items):ye():bt(e,t,r)}function QT(e,t,n){return Yr(n)?Y(e):bt(e,t,n)}function YT(e,t,n){return Sr(n)?Y(e):bt(e,t,n)}function XT(e,t,n,r,s){const o=Qt(r)?t:r,i=Qt(r)?r:t,a=Jt(t),c=Jt(r);return!a&&c?ye():xt(Qe(e,o,i),u=>Al(u,n,s),()=>ye())}function ZT(e,t,n,r){return je(r,(s,o)=>XT(e,t,n,s,o),()=>Jt(t)?Y(e):ye())}function eE(e,t,n){return je(t,(r,s)=>ZT(e,r,s,n),()=>Y(e))}function Al(e,t,n){return eE(e,t,n)}function Gp(e,t,n){return Xr(n)?Y(e):Qe(e,t,n)}function tE(e,t,n,r){return Cn(r)||yn(r)?Y(e):cn(r)?xt(Al(e,t,r.parameters),s=>Gp(s,n,r.instanceType),()=>ye()):ye()}function nE(e,t,n,r,s){return xt(Qe(e,t,s),()=>Qe(e,n,s),()=>Qe(e,r,s))}function rE(e,t,n){const r=Ir(t);return Qe(e,r,n)}function sE(e,t,n,r){return Cn(r)||yn(r)?Y(e):ln(r)?xt(Al(e,t,r.parameters),s=>Gp(s,n,r.returnType),()=>ye()):ye()}function oE(e,t,n){return On(n)||Zt(n)?Y(e):bt(e,t,n)}function iE(e,t,n){const r=en(t);return Qe(e,r,n)}function ea(e,t,n){return t===n?Y(e):ye()}function aE(e,t,n){return Ve(n)?ea(e,t,n.const):Yr(n)?Y(e):bt(e,Re(t),n)}function cE(e,t,n){return Ve(n)?ea(e,t,n.const):Sr(n)?Y(e):bt(e,Re(t),n)}function lE(e,t,n){return Ve(n)?ea(e,t,n.const):Zt(n)?Y(e):bt(e,Re(t),n)}function uE(e,t,n){return Ve(n)?ea(e,t,n.const):Tn(n)?Y(e):bt(e,Re(t),n)}function dE(e,t,n){return et(t.const)?aE(e,t.const,n):mt(t.const)?cE(e,t.const,n):we(t.const)?lE(e,t.const,n):ce(t.const)?uE(e,t.const,n):Nt()}function fE(e,t,n){return Qt(n)?bt(e,t,n):Y(e)}function mE(e,t,n){return vo(n)?Y(e):bt(e,t,n)}function pE(e,t,n){return Zt(n)?Y(e):bt(e,t,n)}function gE(e,t,n){return Jt(t)?Jt(n)?Y(e):ye():Y(e)}function hE(e,t,n){return Qt(n)&&Es(n.extends)?ye():xt(Qe(e,t,n),r=>gE(r,t,n),()=>ye())}function bE(e,t){return e.reduce((n,r)=>r in t&&qt(t[r])?{...n,...t[r].inferred}:Nt(),{})}function xE(e,t,n){const r={};for(const i of D(n))r[i]=i in t?hE({},t[i],n[i]):Jt(n[i])?Qt(n[i])?Y(ft(e,{[n[i].name]:n[i].extends})):Y(e):ye();const s=Yc(r).every(i=>qt(i)),o=s?bE(D(r),r):{};return s?Y(o):ye()}function kE(e,t,n){const r=xE(e,t,n);return qt(r)?Y(ft(e,r.inferred)):ye()}function yE(e,t,n){return kE(e,t,n)}function wE(e,t){return D(t).reduce((n,r)=>({...n,[r]:C(e,r)?le(n[r])?Ge([...n[r].anyOf,t[r]]):Ge([e[r],t[r]]):t[r]}),e)}function Vp(e,t,n,r){return je(t,(s,o)=>xt(Qe({},e[s],n),i=>Vp(e,o,n,wE(r,i)),()=>ye()),()=>Y(r))}function SE(e,t,n,r){const s=D(t);return Vp(t,s,r,e)}function IE(e,t,n){return jt(n)?SE(e,t,mn(n),Lt(n)):Fe(n)?yE(e,t,n.properties):bt(e,Ae(t),n)}function vE(e,t){return h(D(t).length,0)?Y(e):ye()}function jE(e,t,n,r,s){return Qe(e,n,s)}function CE(e,t,n,r){return jt(r)?jE(e,sc(t),n,sc(mn(r)),Lt(r)):Fe(r)?vE(e,r.properties):Cn(r)||yn(r)?Y(e):ye()}function TE(e,t,n){return Tn(n)?Y(e):bt(e,t,n)}function EE(e,t,n){return jo(n)?Y(e):bt(e,t,n)}function NE(e,t,n){const r=Yn(t);return Qe(e,r,n)}function lc(e,t){return xe({"~kind":"Inferrable"},{name:e,type:t},{})}function $l(e){return ee(e)&&C(e,"~kind")&&C(e,"name")&&C(e,"type")&&h(e["~kind"],"Inferrable")&&ce(e.name)&&ee(e.type)}function Wp(e){return Yi(e)?Qt(e.items)?ut(e.items.extends)?lc(e.items.name,e.items.extends.items):yn(e.items.extends)?lc(e.items.name,e.items.extends):void 0:Nt():void 0}function Jp(e){return Qt(e)?lc(e.name,e.extends):void 0}function Pl(e,t,n=[]){return je(e,(r,s)=>xt(Qe({},r,t),()=>Pl(s,t,[...n,r]),()=>{}),()=>n)}function AE(e,t,n,r){const s=Pl(n,r);return H(s)?Y(ft(e,{[t]:fn(s)})):ye()}function Qp(e,t,n,r){const s=Pl(n,r);return H(s)?Y(ft(e,{[t]:Ge(s)})):ye()}function $E(e){return[...e].reverse()}function uc(e,t){return t?$E(e):e}function PE(e){const t=e.length>0?e[0]:void 0,n=Wt(t)?Wp(t):void 0;return Wt(n)}function OE(e,t,n,r,s,o){return xt(Qe(e,n,s),i=>Yp(i,t,r,o),()=>ye())}function RE(e,t,n,r,s){const o=Wp(r);return $l(o)?AE(e,o.name,uc(n,t),o.type):je(n,(i,a)=>OE(e,t,i,a,r,s),()=>ye())}function ME(e,t,n,r){return je(r,(s,o)=>RE(e,t,n,s,o),()=>h(n.length,0)?Y(e):ye())}function Yp(e,t,n,r){return ME(e,t,n,r)}function FE(e,t,n){const r=Mo(e,Pt([],[]),n),s=PE(r);return Yp(e,s,uc(t,s),uc(r,s))}function Xp(e,t,n){const r=Jp(n);return $l(r)?Qp(e,r.name,t,r.type):je(t,(s,o)=>xt(Qe(e,s,n),i=>Xp(i,o,n),()=>ye()),()=>Y(e))}function _E(e,t,n){const r=Mo(e,Pt([],[]),t);return rt(n)?FE(e,r,n.items):ut(n)?Xp(e,r,n.items):bt(e,fn(r),n)}function DE(e,t,n){return Xr(n)||$s(n)?Y(e):bt(e,t,n)}function Zp(e,t,n){return je(n,(r,s)=>xt(Qe(e,t,r),o=>Y(o),()=>Zp(e,t,s)),()=>ye())}function dc(e,t,n){return je(t,(r,s)=>xt(Zp(e,r,n),o=>dc(o,s,n),()=>ye()),()=>Y(e))}function LE(e,t,n){const r=Jp(n);return $l(r)?Qp(e,r.name,t,r.type):le(n)?dc(e,t,n.anyOf):dc(e,t,[n])}function BE(e,t,n){return Qt(n)?bt(e,t,n):Cn(n)||yn(n)?Y(e):ye()}function UE(e,t,n){return Xr(n)?Y(e):bt(e,t,n)}function Qe(e,t,n){return Cn(t)?VT(e,t,n):ut(t)?JT(e,t,t.items,n):Yr(t)?QT(e,t,n):Sr(t)?YT(e,t,n):cn(t)?tE(e,t.parameters,t.instanceType,n):un(t)?nE(e,t.if,t.then,t.else,n):dn(t)?rE(e,t.enum,n):ln(t)?sE(e,t.parameters,t.returnType,n):On(t)?oE(e,t,n):_e(t)?iE(e,t.allOf,n):Ve(t)?dE(e,t,n):Es(t)?fE(e,t,n):vo(t)?mE(e,t,n):Zt(t)?pE(e,t,n):Fe(t)?IE(e,t.properties,n):jt(t)?CE(e,mn(t),Lt(t),n):Tn(t)?TE(e,t,n):jo(t)?EE(e,t,n):Bt(t)?NE(e,t.pattern,n):rt(t)?_E(e,t.items,n):$s(t)?DE(e,t,n):le(t)?LE(e,t.anyOf,n):yn(t)?BE(e,t,n):Xr(t)?UE(e,t,n):ye()}function qE(e,t){return en([...e,Ae(t)])}function eg(e,t,n){return Ye(e)?me(qE(e,t),{},n):Ol(e,t,n)}function zE(e,t,n,r,s){const o=qn(e,t,n),i=Vl(e,t,r);return eg(o,i,s)}function Ol(e,t,n={}){return Te("Interface",[e,t],n)}function Rl(e){return Wt(e)&&C(e,"action")&&h(e.action,"Interface")}function HE(e,t,n={}){return eg(e,t,n)}function KE(e,t,n){return e.includes(n)?!0:lo([...e,n],t,t[n])}function Ad(e,t,n){const r=om(n);return Fr(e,t,r)}function Fr(e,t,n){return je(n,(r,s)=>lo(e,t,r)?!0:Fr(e,t,s),()=>!1)}function lo(e,t,n){return gt(n)?KE(e,t,n.$ref):ut(n)?lo(e,t,n.items):cn(n)?Fr(e,t,[...n.parameters,n.instanceType]):ln(n)?Fr(e,t,[...n.parameters,n.returnType]):Rl(n)?Ad(e,t,n.parameters[1]):_e(n)?Fr(e,t,n.allOf):Fe(n)?Ad(e,t,n.properties):le(n)?Fr(e,t,n.anyOf):rt(n)?Fr(e,t,n.items):jt(n)?lo(e,t,Lt(n)):!1}function GE(e,t,n){return lo(e,t,n)}function VE(e,t){return t.reduce((n,r)=>GE([r],e,e[r])?[...n,r]:n,[])}function WE(e){const t=sm(e);return VE(e,t)}function JE(e,t,n){return n.includes(t)?n:t in e?uo(e,e[t],[...n,t]):Nt()}function $d(e,t,n){const r=om(t);return hs(e,r,n)}function hs(e,t,n){return t.reduce((r,s)=>uo(e,s,r),n)}function uo(e,t,n){return gt(t)?JE(e,t.$ref,n):ut(t)?uo(e,t.items,n):cn(t)?hs(e,[...t.parameters,t.instanceType],n):ln(t)?hs(e,[...t.parameters,t.returnType],n):Rl(t)?$d(e,t.parameters[1],n):_e(t)?hs(e,t.allOf,n):Fe(t)?$d(e,t.properties,n):le(t)?hs(e,t.anyOf,n):rt(t)?hs(e,t.items,n):jt(t)?uo(e,Lt(t),n):n}function QE(e,t,n){return uo(e,n,[t])}function YE(e){return il()}function XE(e){return D(e).reduce((t,n)=>({...t,[n]:Dr(e[n])}),{})}function Ws(e){return e.reduce((t,n)=>[...t,Dr(n)],[])}function Dr(e){return gt(e)?YE(e.$ref):ut(e)?wr(Dr(e.items),sl(e)):cn(e)?yo(Ws(e.parameters),Dr(e.instanceType)):ln(e)?wo(Ws(e.parameters),Dr(e.returnType)):_e(e)?$n(Ws(e.allOf)):Fe(e)?Ae(XE(e.properties)):jt(e)?ml(Ji(e),Dr(Lt(e))):le(e)?Ge(Ws(e.anyOf)):rt(e)?fn(Ws(e.items)):e}function ZE(e,t){return t in e?Dr(e[t]):_t()}function e1(e){return ZE(e.$defs,e.$ref)}function t1(e,t,n){const r=qn(e,Pt([],[]),t),s=Vl({},Pt([],[]),n);return en([...r,Ae(s)])}function n1(e,t){return D(e).filter(r=>t.includes(r)).reduce((r,s)=>{const o=e[s],i=Rl(o)?t1(e,o.parameters[0],o.parameters[1]):o;return{...r,[s]:i}},{})}function r1(e,t,n){const r=QE(e,t,n),s=n1(e,r);return Io(s,t)}function tg(e,t){return t in e?gt(e[t])?tg(e,e[t].$ref):e[t]:vt()}function $o(e,t){return tg(e,t)}function Pd(e){return Dt(e)?e1(e):im(e)?_t():e}function Jn(e,t,n){const r=Pd(t),s=Pd(n);return Qe(e,r,s)}const Ml="equal",s1="disjoint",Fl="left-inside",_l="right-inside";function ta(e,t){const n=[yn(e)?ye():Jn({},e,t),yn(e)?Y({}):Jn({},t,e)];return qt(n[0])&&qt(n[1])?Ml:qt(n[0])&&cc(n[1])?Fl:cc(n[0])&&qt(n[1])?_l:s1}function o1(e,t){return t.filter(n=>ta(e,n)!==_l)}function i1(e,t){const n=t.some(r=>{const s=ta(e,r);return h(s,Fl)||h(s,Ml)});return h(n,!1)}function a1(e,t){const n=zr(e);return Cn(n)?[n]:i1(n,t)?[...o1(n,t),n]:t}function c1(e){return e.reduce((t,n)=>Fe(n)?[...t,n]:Es(n)?t:a1(n,t),[])}function ng(e){const t=c1(e);return Gi(t)}function rg(e,t){return me(zr(e),{},t)}function l1(e,t,n,r){const s=G(e,t,n);return rg(s,r)}function Xs(e,t=[]){return ws(e)&&h(e.action,"Conditional")?gt(e.parameters[0])?Xs(e.parameters[2],Xs(e.parameters[3],[...t,e.parameters[0].$ref])):Xs(e.parameters[2],Xs(e.parameters[3],t)):ws(e)&&h(e.action,"Mapped")&&ws(e.parameters[1])&&h(e.parameters[1].action,"KeyOf")&>(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function u1(e,t){return e.reduce((n,r)=>[...n,t.includes(r.name)],[])}function sg(e,t,n=[]){return je(e,(r,s)=>je(t,(o,i)=>sg(s,i,[...n,[o,r]]),()=>n),()=>n)}function d1(e){return Bt(e)?Yn(e.pattern):dn(e)?Ir(e.enum):e}function f1(e){const t=d1(e);return le(t)?[...t.anyOf]:[t]}function m1(e,t){return e.reduce((n,r)=>[...n,[...r,t]],[])}function Od(e,t){return t.reduce((n,r)=>[...n,...m1(e,r)],[])}function Rd(e){return e.reduce((t,n)=>h(n[0],!0)?Od(t,f1(n[1])):Od(t,[n[1]]),[[]])}function p1(e,t,n){const r=Xs(n),s=u1(e,r),o=sg(t,s);return ws(n)&&h(n.action,"Conditional")||ws(n)&&h(n.action,"Mapped")?Rd(o):[t]}function g1(){return["(not-resolvable)",vt()]}function h1(){return["(not-generic)",vt()]}function b1(e,t,n){return[e,So(t,n)]}function x1(e,t,n){return t in e?og(e,t,e[t]):g1()}function og(e,t,n,r){return ol(n)?b1(t,n.parameters,n.expression):gt(n)?x1(e,n.$ref):h1()}function k1(e,t,n){return og(e,"(anonymous)",t)}function y1(e,t,n){if(Qt(t)||Ll(t)||qt(Jn({},t,n)))return;const r={parameter:e,expect:n,actual:t};throw new Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function Md(e,t,n,r,s){const o=G(e,t,s);return y1(n,o,r),ft(e,{[n]:o})}function w1(e,t,n,r,s){const o=G(e,t,n.extends),i=G(e,t,n.equals);return je(s,(a,c)=>fc(Md(e,t,n.name,o,a),t,r,c),()=>fc(Md(e,t,n.name,o,i),t,r,[]))}function fc(e,t,n,r){return je(n,(s,o)=>w1(e,t,s,o,r),()=>e)}function S1(e,t,n,r){return fc(e,t,n,r)}let mc=0,Dl=0;function I1(){if(!ho(Dl,ko().maxInstantiationCount))throw Error("Type instantiation is excessively deep and possibly infinite")}function v1(){I1(),Dl++,mc++}function j1(){mc--,h(mc,0)&&(Dl=0)}function C1(e){return Vr(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function T1(e,t){return h(C1(e),t)}function E1(e,t,n,r,s,o){v1();try{const i=S1(e,t,r,o),a=G(i,Pt([...t.callstack,n.$ref],t.visited),s);return G(i,Pt([],[]),a)}finally{j1()}}function N1(e,t,n,r,s,o){return o.reduce((i,a)=>{const c=E1(e,t,n,r,s,a);return[...i,c]},[])}function A1(e,t,n,r,s,o){const i=p1(r,o,s),a=N1(e,t,n,r,s,i);return h(a.length,1)?a[0]:Xn(a)}function ig(e,t,n,r){const s=qn(e,t,r),o=k1(e,n),i=o[0],a=o[1];return ol(a)?T1(t,i)?pc(sn(i),s):A1(e,t,sn(i),a.parameters,a.expression,s):pc(n,s)}function pc(e,t){return xe({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function $1(e,t){return ig({},Pt([],[]),e,t)}function Ll(e){return Se(e,"Call")}function P1(e){return jn(e,["~immutable"])}function O1(e,t){return me(P1(e),{},t)}function R1(e,t,n,r){const s=G(e,t,n);return O1(s,r)}function M1(e,t){return e(t)}function F1(e,t){return ce(t)?Re(M1(e,t)):Re(t)}function _1(e,t){const n=Yn(t);return Ps(e,n)}function D1(e,t){const n=t.map(r=>Ps(e,r));return Ge(n)}function Ps(e,t){return Ve(t)?F1(e,t.const):Bt(t)?_1(e,t.pattern):le(t)?D1(e,t.anyOf):t}function ag(e,t={}){return Te("Capitalize",[e],t)}function L1(e,t={}){return dg(e,t)}function cg(e,t={}){return Te("Lowercase",[e],t)}function B1(e,t={}){return fg(e,t)}function lg(e,t={}){return Te("Uncapitalize",[e],t)}function U1(e,t={}){return mg(e,t)}function ug(e,t={}){return Te("Uppercase",[e],t)}function q1(e,t={}){return pg(e,t)}const z1=e=>e[0].toUpperCase()+e.slice(1),H1=e=>e.toLowerCase(),K1=e=>e[0].toLowerCase()+e.slice(1),G1=e=>e.toUpperCase();function dg(e,t){return Ye([e])?me(Ps(z1,e),{},t):ag(e,t)}function fg(e,t){return Ye([e])?me(Ps(H1,e),{},t):cg(e,t)}function mg(e,t){return Ye([e])?me(Ps(K1,e),{},t):lg(e,t)}function pg(e,t){return Ye([e])?me(Ps(G1,e),{},t):ug(e,t)}function V1(e,t,n,r){const s=G(e,t,n);return dg(s,r)}function W1(e,t,n,r){const s=G(e,t,n);return fg(s,r)}function J1(e,t,n,r){const s=G(e,t,n);return mg(s,r)}function Q1(e,t,n,r){const s=G(e,t,n);return pg(s,r)}function gg(e,t,n,r,s={}){return Te("Conditional",[e,t,n,r],s)}function Y1(e,t,n,r,s={}){return hg({},Pt([],[]),e,t,n,r,s)}function X1(e,t,n,r,s,o){const i=Jn(e,n,r);return El(i)?Ge([G(i.inferred,t,s),G(e,t,o)]):Nl(i)?G(i.inferred,t,s):G(e,t,o)}function hg(e,t,n,r,s,o,i){return Ye([n,r])?me(X1(e,t,n,r,s,o),{},i):gg(n,r,s,o,i)}function Z1(e,t,n,r,s,o,i){const a=G(e,t,n),c=G(e,t,r);return hg(e,t,a,c,s,o,i)}function bg(e,t={}){return Te("ConstructorParameters",[e],t)}function eN(e,t={}){return xg(e,t)}function tN(e){const t=cn(e)?e.parameters:[],n=Mo({},Pt([],[]),t);return fn(n)}function xg(e,t){return Ye([e])?me(tN(e),{},t):bg(e,t)}function nN(e,t,n,r){const s=G(e,t,n);return xg(s,r)}function kg(e,t,n={}){return Te("Exclude",[e,t],n)}function rN(e,t,n={}){return Bl(e,t,n)}function Bl(e,t,n){return Ye([e,t])?me(Dm(e,t),{},n):kg(e,t,n)}function sN(e,t,n,r,s){const o=G(e,t,n),i=G(e,t,r);return Bl(o,i,s)}function yg(e,t,n={}){return Te("Extract",[e,t],n)}function oN(e,t,n={}){return wg(e,t,n)}function iN(e,t){const n=Jn({},e,t);return qt(n)?[e]:[]}function aN(e,t){return e.reduce((n,r)=>[...n,...iN(r,t)],[])}function cN(e,t){const n=zr(e),r=le(n)?n.anyOf:[n],s=aN(r,t);return Xn(s)}function wg(e,t,n){return Ye([e,t])?me(cN(e,t),{},n):yg(e,t,n)}function lN(e,t,n,r,s){const o=G(e,t,n),i=G(e,t,r);return wg(o,i,s)}function uN(e){return e.reduce((t,n)=>bm(n)?[...t,Re(n)]:t,[])}function Ul(e){const t=uN(e);return Ge(t)}function ql(e,t,n={}){return Te("Index",[e,t],n)}function dN(e,t,n={}){const r=H(t)?Ul(t):t;return Cg(e,r,n)}function fN(e,t){const n=$o(e,t);return es(n)}function mN(e,t,n){const r=Ns(e,t,n);return es(r)}function pN(e,t){const n=D(e).filter(f=>!C(t,f)),r=D(t).filter(f=>!C(e,f)),s=D(e).filter(f=>C(t,f)),o=n.reduce((f,p)=>({...f,[p]:e[p]}),{}),i=r.reduce((f,p)=>({...f,[p]:t[p]}),{}),a=s.reduce((f,p)=>({...f,[p]:en([e[p],t[p]])}),{}),c=ft(o,i);return ft(c,a)}function gN(e){return e.reduce((t,n)=>pN(t,es(n)),{})}function hN(e){const t=VS(fn(e));return es(t)}function bN(e,t){return D(e).filter(s=>s in t).reduce((s,o)=>({...s,[o]:Xn([e[o],t[o]])}),{})}function Sg(e,t){return je(e,(n,r)=>Sg(r,bN(t,es(n))),()=>t)}function xN(e){return je(e,(t,n)=>Sg(n,es(t)),()=>Nt())}function es(e){return Dt(e)?fN(e.$defs,e.$ref):un(e)?mN(e.if,e.then,e.else):_e(e)?gN(e.allOf):le(e)?xN(e.anyOf):rt(e)?hN(e.items):Fe(e)?e.properties:{}}function zl(e){const t=es(e);return Ae(t)}const kN=new RegExp("^(?:0|[1-9][0-9]*)$");function Hl(e){const t=`${e}`;return kN.test(t)?parseInt(t):e}function yN(e){return Re(Hl(e))}function Fd(e){return e.map(t=>Ig(t))}function Ig(e){return _e(e)?$n(Fd(e.allOf)):le(e)?Ge(Fd(e.anyOf)):Ve(e)?yN(e.const):e}function wN(e,t){const n=Ig(t),r=Jn({},n,br());return qt(r)?e:Ve(t)&&h(t.const,"length")?br():vt()}function SN(e,t){const n=$o(e,t);return ts(n)}function IN(e,t,n){const r=Ns(e,t,n);return ts(r)}function vN(e){const t=Ir(e);return ts(t)}function jN(e){const t=en(e);return ts(t)}function CN(e){return[`${e}`]}function TN(e){const t=Yn(e);return ts(t)}function EN(e){return e.reduce((t,n)=>[...t,...ts(n)],[])}function ts(e){return Dt(e)?SN(e.$defs,e.$ref):un(e)?IN(e.if,e.then,e.else):dn(e)?vN(e.enum):_e(e)?jN(e.allOf):Ve(e)?CN(e.const):Bt(e)?TN(e.pattern):le(e)?EN(e.anyOf):[]}function Kl(e){return ts(e)}function Js(e,t){return t.map(n=>ro(e,n))}function ro(e,t){return ut(t)?wr(ro(e,t.items)):cn(t)?yo(Js(e,t.parameters),ro(e,t.instanceType)):ln(t)?wo(Js(e,t.parameters),ro(e,t.returnType)):rt(t)?fn(Js(e,t.items)):le(t)?Ge(Js(e,t.anyOf)):_e(t)?$n(Js(e,t.allOf)):qm(t)?Ae(e):t}function NN(e,t){return ro(e,t)}function AN(e,t){const n=t in e?e[t]:vt();return NN(e,n)}function vg(e,t){return t.reduce((n,r)=>[...n,AN(e,r)],[])}function $N(e,t){const n=Kl(t),r=vg(e,n);return Xn(r)}const PN=new RegExp(To);function ON(e){return e.filter(n=>PN.test(n))}function RN(e){const t=sm(e),n=ON(t),r=vg(e,n);return Xn(r)}function MN(e,t){return Zt(t)?RN(e):$N(e,t)}function FN(e){return Re(Hl(e))}function _d(e){return e.map(t=>jg(t))}function jg(e){return _e(e)?$n(_d(e.allOf)):le(e)?Ge(_d(e.anyOf)):Ve(e)?FN(e.const):e}function _N(e,t){return e.reduceRight((n,r,s)=>{const o=Jn({},Re(s),t);return qt(o)?[r,...n]:n},[])}function DN(e,t){const n=jg(t),r=_N(e,n);return As(r)}function LN(e){return As(e)}function BN(e,t){return Ve(t)&&h(t.const,"length")?Re(e.length):Zt(t)||On(t)?LN(e):DN(e,t)}function UN(e,t){return ut(e)?wN(e.items,t):Fe(e)?MN(e.properties,t):rt(e)?BN(e.items,t):vt()}function qN(e){return Dt(e)||un(e)||_e(e)||le(e)?zl(e):e}function Cg(e,t,n){return Ye([e,t])?me(UN(qN(e),t),{},n):ql(e,t,n)}function zN(e,t,n,r,s){const o=G(e,t,n),i=G(e,t,r);return Cg(o,i,s)}function Tg(e,t={}){return Te("InstanceType",[e],t)}function HN(e,t={}){return Eg(e,t)}function KN(e){return cn(e)?e.instanceType:vt()}function Eg(e,t){return Ye([e])?me(KN(e),{},t):Tg(e,t)}function GN(e,t,n,r={}){const s=G(e,t,n);return Eg(s,r)}function Gl(e,t={}){return Te("KeyOf",[e],t)}function VN(e,t={}){return Ng(e,t)}function WN(){return Ge([br(),Rn(),dl()])}function JN(e){return br()}function QN(e){return e.reduce((n,r)=>bm(r)?[...n,Re(Hl(r))]:Nt(),[])}function YN(e){const t=D(e),n=QN(t);return As(n)}function XN(e){return Ji(e)}function ZN(e){const t=e.map((n,r)=>Re(r));return As(t)}function eA(e){return Cn(e)?WN():ut(e)?JN(e.items):Fe(e)?YN(e.properties):jt(e)?XN(e):rt(e)?ZN(e.items):vt()}function tA(e){return Dt(e)||un(e)||_e(e)||le(e)?zl(e):e}function Ng(e,t){return Ye([e])?me(eA(tA(e)),{},t):Gl(e,t)}function nA(e,t,n,r){const s=G(e,t,n);return Ng(s,r)}function gc(e,t,n,r,s={}){return Te("Mapped",[e,t,n,r],s)}function rA(e,t,n,r,s={}){return Ag({},Pt([],[]),e,t,n,r,s)}function sA(e){const t=Yn(e);return na(t)}function oA(e){return e.reduce((t,n)=>[...t,...na(n)],[])}function iA(e){const t=Ir(e);return na(t)}function aA(e){return we(e)?[Re(`${e}`)]:[Re(e)]}function na(e){return dn(e)?iA(e.enum):Ve(e)?aA(e.const):Bt(e)?sA(e.pattern):le(e)?oA(e.anyOf):[e]}function cA(e){return na(e)}function lA(e){return Bt(e)?Yn(e.pattern):e}function uA(e,t,n,r,s,o){const i=ft(e,{[n.name]:r}),a=G(i,t,s),c=lA(a),u=G(i,t,o);return xm(c)||km(c)?{[c.const]:u}:{}}function dA(e,t,n,r,s,o){return r.reduce((i,a)=>[...i,uA(e,t,n,a,s,o)],[])}function fA(e){return e.reduce((t,n)=>[...t,Ae(n)],[])}function mA(e,t,n,r,s,o){const i=cA(r),a=dA(e,t,n,i,s,o),c=fA(a);return en(c)}function Ag(e,t,n,r,s,o,i){return Ye([r])?me(mA(e,t,n,r,s,o),{},i):gc(n,r,s,o,i)}function pA(e,t,n,r,s,o,i){const a=G(e,t,r);return Ag(e,t,n,a,s,o,i)}function gA(e,t,n){const r=ft(e,t);return D(t).filter(o=>n.includes(o)).reduce((o,i)=>({...o,[i]:r1(r,i,t[i])}),{})}function hA(e,t,n){const r=ft(e,t);return D(t).filter(o=>!n.includes(o)).reduce((o,i)=>({...o,[i]:G(r,Pt([],[]),t[i])}),{})}function bA(e,t,n){const r=WE(t),s=gA(e,t,r),o=hA(e,t,r),i={...s,...o};return me(i,{},n)}function $g(e,t,n,r){return bA(e,n,r)}function Pg(e,t={}){return Te("NonNullable",[e],t)}function xA(e,t={}){return Og(e,t)}function kA(e){const t=Ge([ul(),pl()]);return Bl(e,t,{})}function Og(e,t){return Ye([e])?me(kA(e),{},t):Pg(e,t)}function yA(e,t,n,r){const s=G(e,t,n);return Og(s,r)}function Rg(e,t,n={}){return Te("Omit",[e,t],n)}function wA(e,t,n={}){const r=H(t)?Ul(t):t;return Fg(e,r,n)}function Mg(e){const t=zl(e);return Fe(t)?t.properties:Nt()}function SA(e,t){return D(e).reduce((r,s)=>t.includes(s)?r:{...r,[s]:e[s]},{})}function IA(e,t){const n=Mg(e),r=Kl(t),s=SA(n,r);return Ae(s)}function Fg(e,t,n){return Ye([e,t])?me(IA(e,t),{},n):Rg(e,t,n)}function vA(e,t,n,r,s){const o=G(e,t,n),i=G(e,t,r);return Fg(o,i,s)}function _g(e,t={}){return Te("Parameters",[e],t)}function jA(e,t={}){return Dg(e,t)}function CA(e){const t=ln(e)?e.parameters:[],n=Mo({},Pt([],[]),t);return fn(n)}function Dg(e,t){return Ye([e])?me(CA(e),{},t):_g(e,t)}function TA(e,t,n,r){const s=G(e,t,n);return Dg(s,r)}function Lg(e,t={}){return Te("Partial",[e],t)}function EA(e,t={}){return Bg(e,t)}function NA(e,t){const n=$o(e,t),r=Po(n);return Io(ft(e,{[t]:r}),t)}function AA(e,t,n){const r=Ns(e,t,n);return Po(r)}function $A(e){const t=en(e);return Po(t)}function PA(e){const t=e.map(n=>Po(n));return Ge(t)}function OA(e){const t=D(e).reduce((r,s)=>({...r,[s]:Ii(e[s])}),{});return Ae(t)}function Po(e){return Dt(e)?NA(e.$defs,e.$ref):un(e)?AA(e.if,e.then,e.else):_e(e)?$A(e.allOf):le(e)?PA(e.anyOf):Fe(e)?OA(e.properties):Ae({})}function Bg(e,t){return Ye([e])?me(Po(e),{},t):Lg(e,t)}function RA(e,t,n,r){const s=G(e,t,n);return Bg(s,r)}function Ug(e,t,n={}){return Te("Pick",[e,t],n)}function MA(e,t,n={}){const r=H(t)?Ul(t):t;return qg(e,r,n)}function FA(e,t){return D(e).reduce((r,s)=>t.includes(s)?ft(r,{[s]:e[s]}):r,{})}function _A(e,t){const n=Mg(e),r=Kl(t),s=FA(n,r);return Ae(s)}function qg(e,t,n){return Ye([e,t])?me(_A(e,t),{},n):Ug(e,t,n)}function DA(e,t,n,r,s){const o=G(e,t,n),i=G(e,t,r);return qg(o,i,s)}function zg(e,t={}){return Te("ReadonlyObject",[e],t)}function Hg(e,t={}){return Kg(e,t)}const LA=Hg;function BA(e){return Jl(wr(e))}function UA(e,t){const n=$o(e,t),r=Oo(n);return Io(ft(e,{[t]:r}),t)}function qA(e,t,n){const r=Ns(e,t,n);return Oo(r)}function zA(e){const t=en(e);return Oo(t)}function HA(e){const t=D(e).reduce((r,s)=>({...r,[s]:Ci(e[s])}),{});return Ae(t)}function KA(e){return Jl(fn(e))}function GA(e){const t=e.map(n=>Oo(n));return Ge(t)}function Oo(e){return ut(e)?BA(e.items):Dt(e)?UA(e.$defs,e.$ref):un(e)?qA(e.if,e.then,e.else):_e(e)?zA(e.allOf):Fe(e)?HA(e.properties):rt(e)?KA(e.items):le(e)?GA(e.anyOf):e}function Kg(e,t){return Ye([e])?me(Oo(e),{},t):zg(e)}function VA(e,t,n,r){const s=G(e,t,n);return Kg(s,r)}function WA(e,t,n,r){return t.visited.includes(r)?n:r in e?G(e,Pt(t.callstack,[...t.visited,r]),e[r]):n}function JA(e,t){const n=$o(e,t),r=Ro(n);return Io(ft(e,{[t]:r}),t)}function QA(e,t,n){const r=Ns(e,t,n);return Ro(r)}function YA(e){const t=en(e);return Ro(t)}function XA(e){const t=e.map(n=>Ro(n));return Ge(t)}function ZA(e){const t=D(e).reduce((r,s)=>({...r,[s]:Rm(e[s])}),{});return Ae(t)}function Ro(e){return Dt(e)?JA(e.$defs,e.$ref):un(e)?QA(e.if,e.then,e.else):_e(e)?YA(e.allOf):le(e)?XA(e.anyOf):Fe(e)?ZA(e.properties):Ae({})}function Gg(e,t={}){return Te("Required",[e],t)}function e$(e,t={}){return Vg(e,t)}function Vg(e,t){return Ye([e])?me(Ro(e),{},t):Gg(e,t)}function t$(e,t,n,r){const s=G(e,t,n);return Vg(s,r)}function Wg(e,t={}){return Te("ReturnType",[e],t)}function n$(e,t={}){return Jg(e,t)}function r$(e){return ln(e)?e.returnType:vt()}function Jg(e,t){return Ye([e])?me(r$(e),{},t):Wg(e,t)}function s$(e,t,n,r={}){const s=G(e,t,n);return Jg(s,r)}function Qg(e,t){return Te("With",[e,t],{})}function Yg(e,t){return Xg(e,t)}function Xg(e,t){return Ye([e])?me(e,{},t):Qg(e,t)}function o$(e,t,n,r){const s=G(e,t,n);return Xg(s,r)}function i$(e){return Yi(e)?rt(e.items)?Zg(e.items.items):Qt(e.items)?[e]:gt(e.items)?[e]:[vt()]:[e]}function Zg(e){return e.reduce((n,r)=>[...n,...i$(r)],[])}function Pt(e,t){return{callstack:e,visited:t}}function Ye(e){return je(e,(t,n)=>gt(t)?!1:Ye(n),()=>!0)}function Vl(e,t,n){return D(n).reduce((r,s)=>({...r,[s]:G(e,t,n[s])}),{})}function Mo(e,t,n){const r=qn(e,t,n);return Zg(r)}function qn(e,t,n){return n.map(r=>G(e,t,r))}function a$(e,t){const n=Jt(e)?rl(t,{}):t,r=Ti(e)?nl(n,{}):n;return ji(e)?Wl(r,{}):r}function c$(e,t,n,r,s){return h(n,"AddImmutable")?d$(e,t,r[0],s):h(n,"RemoveImmutable")?R1(e,t,r[0],s):h(n,"AddReadonly")?Pw(e,t,r[0],s):h(n,"RemoveReadonly")?US(e,t,r[0],s):h(n,"AddOptional")?Rw(e,t,r[0],s):h(n,"RemoveOptional")?KS(e,t,r[0],s):h(n,"Capitalize")?V1(e,t,r[0],s):h(n,"Conditional")?Z1(e,t,r[0],r[1],r[2],r[3],s):h(n,"ConstructorParameters")?nN(e,t,r[0],s):h(n,"Evaluate")?l1(e,t,r[0],s):h(n,"Exclude")?sN(e,t,r[0],r[1],s):h(n,"Extract")?lN(e,t,r[0],r[1],s):h(n,"Index")?zN(e,t,r[0],r[1],s):h(n,"InstanceType")?GN(e,t,r[0],s):h(n,"Interface")?zE(e,t,r[0],r[1],s):h(n,"KeyOf")?nA(e,t,r[0],s):h(n,"Lowercase")?W1(e,t,r[0],s):h(n,"Mapped")?pA(e,t,r[0],r[1],r[2],r[3],s):h(n,"Module")?$g(e,t,r[0],s):h(n,"NonNullable")?yA(e,t,r[0],s):h(n,"Pick")?DA(e,t,r[0],r[1],s):h(n,"Parameters")?TA(e,t,r[0],s):h(n,"Partial")?RA(e,t,r[0],s):h(n,"Omit")?vA(e,t,r[0],r[1],s):h(n,"ReadonlyObject")?VA(e,t,r[0],s):h(n,"Record")?xI(e,t,r[0],r[1],s):h(n,"Required")?t$(e,t,r[0],s):h(n,"ReturnType")?s$(e,t,r[0],s):h(n,"TemplateLiteral")?_T(e,t,r[0],s):h(n,"Uncapitalize")?J1(e,t,r[0],s):h(n,"Uppercase")?Q1(e,t,r[0],s):h(n,"With")?o$(e,t,r[0],r[1]):Te(n,r,s)}function l$(e,t,n){const r=gt(n)?WA(e,t,n,n.$ref):ut(n)?wr(G(e,t,n.items),sl(n)):Ll(n)?ig(e,t,n.target,n.arguments):cn(n)?yo(qn(e,t,n.parameters),G(e,t,n.instanceType),Mw(n)):ln(n)?wo(qn(e,t,n.parameters),G(e,t,n.returnType),Fw(n)):un(n)?vi(G(e,t,n.if),G(e,t,n.then),G(e,t,n.else),qw(n)):_e(n)?$n(qn(e,t,n.allOf),Vw(n)):Fe(n)?Ae(Vl(e,t,n.properties),Bw(n)):jt(n)?kI(mn(n),G(e,t,Lt(n))):Yi(n)?Qi(G(e,t,n.items)):rt(n)?fn(Mo(e,t,n.items),LS(n)):le(n)?Ge(qn(e,t,n.anyOf),AS(n)):n;return a$(n,r)}function G(e,t,n){return ws(n)?c$(e,t,n.action,n.parameters,n.options):l$(e,t,n)}function Os(e,t){return G(e,Pt([],[]),t)}function u$(e){return me(e,{"~immutable":!0},{})}function Wl(e,t){return me(u$(e),{},t)}function d$(e,t,n,r){const s=G(e,t,n);return Wl(s,r)}function f$(e,t={}){return Te("AddImmutable",[e],t)}function Jl(e,t={}){return Wl(e,t)}function m$(e,t={}){return Te("Evaluate",[e],t)}function Mn(e,t={}){return rg(e,t)}function p$(e,t={}){return Te("Module",[e],t)}function g$(e,t={}){return $g({},Pt([],[]),e,t)}function h$(e,t){const n=ta(e,t);return h(n,"right-inside")||h(n,"disjoint")?1:0}function eh(e,t,n=[]){return je(t,(r,s)=>h(h$(e,r),1)?eh(e,s,[...n,r]):[...n,e,...t],()=>[...n,e])}function th(e,t=[]){return je(e,(n,r)=>th(r,eh(n,t)),()=>t)}function b$(e){return th(e)}function x$(...e){const[t,n,r]=at(e,{2:(i,a)=>ce(i)?[{},i,a]:[i,a,{}],3:(i,a,c)=>[i,a,c],1:i=>[{},i,{}]}),s=ST(n),o=H(s)&&h(s.length,2)?G(t,Pt([],[]),s[0]):vt();return me(o,{},r)}const m=Object.freeze(Object.defineProperty({__proto__:null,Any:il,Array:wr,BigInt:ll,Boolean:gm,Call:$1,Capitalize:L1,Codec:al,Conditional:Y1,Constructor:yo,ConstructorParameters:eN,Cyclic:Io,Decode:hS,DecodeBuilder:pm,Dependent:vi,Encode:bS,EncodeBuilder:mm,Enum:Gw,Evaluate:Mn,Exclude:rN,Extends:Jn,ExtendsResult:UT,Extract:oN,Function:wo,Generic:So,Identifier:rc,Immutable:xS,Index:dN,Infer:tc,InstanceType:HN,Instantiate:Os,Integer:Ki,Interface:HE,Intersect:$n,IsAny:Cn,IsArray:ut,IsBigInt:Yr,IsBoolean:Sr,IsCall:Ll,IsCodec:Yt,IsConstructor:cn,IsCyclic:Dt,IsDependent:un,IsEnum:dn,IsEnumValue:Kw,IsFunction:ln,IsGeneric:ol,IsIdentifier:vS,IsImmutable:ji,IsInfer:Qt,IsInteger:On,IsIntersect:_e,IsKind:Se,IsLiteral:Ve,IsNever:Es,IsNull:vo,IsNumber:Zt,IsObject:Fe,IsOptional:Jt,IsParameter:NS,IsReadonly:Ti,IsRecord:jt,IsRef:gt,IsRefine:cl,IsRest:Yi,IsSchema:Wt,IsString:Tn,IsSymbol:jo,IsTemplateLiteral:Bt,IsThis:qm,IsTuple:rt,IsUndefined:$s,IsUnion:le,IsUnknown:yn,IsUnsafe:im,IsVoid:Xr,KeyOf:VN,Literal:Re,Lowercase:B1,Mapped:rA,Module:g$,Never:vt,NonNullable:xA,Null:ul,Number:br,Object:Ae,Omit:wA,Optional:Dw,Parameter:Co,Parameters:jA,Partial:EA,Pick:MA,Readonly:kS,ReadonlyObject:Hg,ReadonlyType:LA,Record:ml,RecordKey:Ji,RecordPattern:mn,RecordValue:Lt,Ref:sn,Refine:wS,Required:e$,Rest:Qi,ReturnType:n$,Script:x$,String:Rn,Symbol:dl,TemplateLiteral:BT,This:Um,Tuple:fn,Uncapitalize:U1,Undefined:pl,Union:Ge,Unknown:_t,Unsafe:Uw,Uppercase:q1,Void:zm,With:Yg},Symbol.toStringTag,{value:"Module"}));function ra(e){return C(e,"~refine")&&H(e["~refine"])&<(e["~refine"],0,t=>ee(t)&&C(t,"check")&&C(t,"error")&&kn(t.check)&&kn(t.error))}function Xt(e){return ee(e)&&!H(e)}function Fo(e){return mt(e)}function Me(e){return Xt(e)||Fo(e)}function _o(e){return C(e,"additionalItems")&&Me(e.additionalItems)}function er(e){return C(e,"additionalProperties")&&Me(e.additionalProperties)}function sa(e){return C(e,"allOf")&&H(e.allOf)&&e.allOf.every(t=>Me(t))}function Ai(e){return C(e,"$anchor")&&ce(e.$anchor)}function oa(e){return C(e,"anyOf")&&H(e.anyOf)&&e.anyOf.every(t=>Me(t))}function ia(e){return C(e,"const")}function ns(e){return C(e,"contains")&&Me(e.contains)}function k$(e){return C(e,"contentEncoding")&&ce(e.contentEncoding)}function y$(e){return C(e,"contentMediaType")&&ce(e.contentMediaType)}function jr(e){return C(e,"default")}function w$(e){return C(e,"$defs")&&ee(e.$defs)&&Object.values(e.$defs).every(t=>Me(t))}function Do(e){return C(e,"dependencies")&&ee(e.dependencies)&&Object.values(e.dependencies).every(t=>Me(t)||H(t)&&t.every(n=>ce(n)))}function Lo(e){return C(e,"dependentRequired")&&ee(e.dependentRequired)&&Object.values(e.dependentRequired).every(t=>H(t)&&t.every(n=>ce(n)))}function Bo(e){return C(e,"dependentSchemas")&&ee(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(t=>Me(t))}function Kr(e){return C(e,"$dynamicAnchor")&&ce(e.$dynamicAnchor)}function aa(e){return C(e,"$dynamicRef")&&ce(e.$dynamicRef)}function ca(e){return C(e,"else")&&Me(e.else)}function la(e){return C(e,"enum")&&H(e.enum)}function Uo(e){return C(e,"exclusiveMaximum")&&(we(e.exclusiveMaximum)||et(e.exclusiveMaximum))}function Cr(e){return C(e,"exclusiveMinimum")&&(we(e.exclusiveMinimum)||et(e.exclusiveMinimum))}function Rs(e){return C(e,"format")&&ce(e.format)}function kr(e){return C(e,"$id")&&ce(e.$id)}function ua(e){return C(e,"if")&&Me(e.if)}function Tr(e){return C(e,"items")&&(Me(e.items)||H(e.items)&&e.items.every(t=>Me(t)))}function da(e){return Tr(e)&&H(e.items)}function S$(e){return Tr(e)&&!H(e.items)}function qo(e){return C(e,"maximum")&&(we(e.maximum)||et(e.maximum))}function zo(e){return C(e,"maxContains")&&we(e.maxContains)}function Ms(e){return C(e,"maxItems")&&we(e.maxItems)}function Ho(e){return C(e,"maxLength")&&we(e.maxLength)}function Ko(e){return C(e,"maxProperties")&&we(e.maxProperties)}function Er(e){return C(e,"minimum")&&(we(e.minimum)||et(e.minimum))}function rs(e){return C(e,"minContains")&&we(e.minContains)}function ss(e){return C(e,"minItems")&&we(e.minItems)}function Fs(e){return C(e,"minLength")&&we(e.minLength)}function _s(e){return C(e,"minProperties")&&we(e.minProperties)}function Go(e){return C(e,"multipleOf")&&(we(e.multipleOf)||et(e.multipleOf))}function fa(e){return C(e,"not")&&Me(e.not)}function ma(e){return C(e,"oneOf")&&H(e.oneOf)&&e.oneOf.every(t=>Me(t))}function Ds(e){return C(e,"pattern")&&(ce(e.pattern)||e.pattern instanceof RegExp)}function os(e){return C(e,"patternProperties")&&ee(e.patternProperties)&&Object.values(e.patternProperties).every(t=>Me(t))}function tr(e){return C(e,"prefixItems")&&H(e.prefixItems)&&e.prefixItems.every(t=>Me(t))}function is(e){return C(e,"properties")&&ee(e.properties)&&Object.values(e.properties).every(t=>Me(t))}function Vo(e){return C(e,"propertyNames")&&(ee(e.propertyNames)||Me(e.propertyNames))}function nh(e){return C(e,"$recursiveAnchor")&&mt(e.$recursiveAnchor)}function mi(e){return nh(e)&&h(e.$recursiveAnchor,!0)}function pa(e){return C(e,"$recursiveRef")&&ce(e.$recursiveRef)}function ga(e){return C(e,"$ref")&&ce(e.$ref)}function nr(e){return C(e,"required")&&H(e.required)&&e.required.every(t=>ce(t))}function ha(e){return C(e,"then")&&Me(e.then)}function Wo(e){return C(e,"type")&&(ce(e.type)||H(e.type)&&e.type.every(t=>ce(t)))}function yr(e){return C(e,"uniqueItems")&&mt(e.uniqueItems)}function Ls(e){return C(e,"unevaluatedItems")&&Me(e.unevaluatedItems)}function Bs(e){return C(e,"unevaluatedProperties")&&Me(e.unevaluatedProperties)}function I$(e){return Ls(e)||Bs(e)||Ts(D(e),t=>$i(e[t]))}function v$(e){return Ts(e,t=>$i(t))}function $i(e){return H(e)?v$(e):ee(e)?I$(e):!1}function rh(e,t){return $i(t)||Ts(D(e),n=>$i(e[n]))}class sh{constructor(t){this.hasUnevaluated=t}UseUnevaluated(){return this.hasUnevaluated}Push(){return ze(fe("context","Push"),[])}Pop(){return ze(fe("context","Pop"),[])}AddIndex(t){return ze(fe("context","AddIndex"),[t])}AddKey(t){return ze(fe("context","AddKey"),[t])}Merge(t){return ze(fe("context","Merge"),[t])}}class Fn{constructor(){const t=new Set,n=new Set;this.stack=[{indices:t,keys:n}]}Push(){const t=new Set,n=new Set;return this.stack.push({indices:t,keys:n}),!0}Pop(){return this.stack.pop(),!0}AddIndex(t){return this.GetIndices().add(t),!0}AddKey(t){return this.GetKeys().add(t),!0}GetIndices(){return this.stack[this.stack.length-1].indices}GetKeys(){return this.stack[this.stack.length-1].keys}Merge(t){for(const n of t)n.GetIndices().forEach(r=>this.GetIndices().add(r)),n.GetKeys().forEach(r=>this.GetKeys().add(r));return!0}}class Ql extends Fn{constructor(t){super(),this.callback=t}AddError(t){return this.callback(t),!1}}class _n extends Ql{constructor(){super(t=>this.errors.push(t)),this.errors=[]}AddError(t){return this.errors.push(t),!1}GetErrors(){return this.errors}}const Pi={identifier:"External",variables:[]};function as(e){const t=`External[${Pi.variables.length}]`;return Pi.variables.push(e),t}function oh(){Pi.variables=[]}function ih(){return{...Pi}}function ah(e,t,n,r){const s=as(n["~refine"].map(o=>o));return Pn(s,K(0),["refinement","_"],ze(fe("refinement","check"),[r]))}function ch(e,t,n,r){return lt(n["~refine"],0,(s,o)=>s.check(r))}function lh(e,t,n,r,s,o){return It(s["~refine"],0,(i,a)=>i.check(o)||t.AddError({keyword:"~refine",schemaPath:n,instancePath:r,params:{index:a,message:i.error(o)}}))}let j$=0;function it(){return`var_${j$++}`}function Yl(e){return Tr(e)&&H(e.items)}function C$(e,t,n,r){const[s,o]=[it(),it()],i=En(e,t,n.additionalItems,s),a=Xc(o,K(n.items.length)),c=t.AddIndex(o);return Pn(r,K(0),[s,o],Ue(a,kt(i,c)))}function T$(e,t,n,r){const[s,o]=[it(),it()],i=En(e,t,n.additionalItems,s),a=Xc(o,K(n.items.length));return Pn(r,K(0),[s,o],Ue(a,i))}function uh(e,t,n,r){return Yl(n)?t.UseUnevaluated()?C$(e,t,n,r):T$(e,t,n,r):K(!0)}function dh(e,t,n,r){return Yl(n)?lt(r,0,(o,i)=>ho(i,n.items.length)||Nr(e,t,n.additionalItems,o)&&t.AddIndex(i)):!0}function fh(e,t,n,r,s,o){return Yl(s)?lt(o,0,(a,c)=>{const u=`${n}/additionalItems`,f=`${r}/${c}`;return ho(c,s.items.length)||Ar(e,t,u,f,s.additionalItems,a)&&t.AddIndex(c)}):!0}function E$(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function Xl(e){const t=[];return os(e)&&t.push(...D(e.patternProperties)),is(e)&&t.push(...D(e.properties).map(E$)),h(t.length,0)?"(?!)":`(${t.join("|")})`}function mh(e,t,n){return nr(t)&&is(t)&&!os(t)&&h(t.additionalProperties,!1)&&h(D(t.properties).length,t.required.length)}function ph(e,t,n){return zt(fe(ze(fe("Object","getOwnPropertyNames"),[n]),"length"),K(t.required.length))}function gh(e,t,n,r){const[s,o]=[it(),it()],i=as(new RegExp(Xl(n))),a=En(e,t,n.additionalProperties,`${r}[${s}]`),c=ze(fe(i,"test"),[s]),u=t.AddKey(s),f=t.UseUnevaluated()?Ue(c,kt(a,u)):Ue(c,a);return Pn(Qr(r),K(0),[s,o],f)}function hh(e,t,n,r){return mh(t,n)?ph(t,n,r):gh(e,t,n,r)}function bh(e,t,n,r){const s=new RegExp(Xl(n));return lt(D(r),0,(i,a)=>s.test(i)||Nr(e,t,n.additionalProperties,r[i])&&t.AddKey(i))}function xh(e,t,n,r,s,o){const i=new RegExp(Xl(s)),a=[];return It(D(o),0,(u,f)=>{const p=`${n}/additionalProperties`,g=`${r}/${u}`,b=new _n,x=i.test(u)||Ar(e,b,p,g,s.additionalProperties,o[u])&&t.AddKey(u);return x||a.push(u),x})||t.AddError({keyword:"additionalProperties",schemaPath:n,instancePath:r,params:{additionalProperties:a}})}function Jo(e,t,n,r,s){const o=Hn("results","[]"),i=n.map((f,p)=>Hn(`context_${p}`,Zc("CheckContext",[]))),a=n.map((f,p)=>Hn(`condition_${p}`,ze(gr(["context"],st(e,t,f,r)),[`context_${p}`]))),c=n.map((f,p)=>Zf(`condition_${p}`,ze(fe("results","push"),[`context_${p}`]))),u=zi(kt(s,t.Merge("results")));return ze(gr([],qi([o,...i,...a,...c,u])),[])}function N$(e,t,n,r){return Jo(e,t,n.allOf,r,zt(fe("results","length"),K(n.allOf.length)))}function A$(e,t,n,r){return wt(n.allOf.map(s=>st(e,t,s,r)))}function kh(e,t,n,r){return t.UseUnevaluated()?N$(e,t,n,r):A$(e,t,n,r)}function yh(e,t,n,r){const s=n.allOf.reduce((o,i)=>{const a=new Fn;return ot(e,a,i,r)?[...o,a]:o},[]);return h(s.length,n.allOf.length)&&t.Merge(s)}function wh(e,t,n,r,s,o){const i=[],a=s.allOf.reduce((u,f,p)=>{const g=`${n}/allOf/${p}`,b=new _n,x=St(e,b,g,r,f,o);return x||i.push(b),x?[...u,b]:u},[]),c=h(a.length,s.allOf.length)&&t.Merge(a);return c||i.forEach(u=>u.GetErrors().forEach(f=>t.AddError(f))),c}function $$(e,t,n,r){return Jo(e,t,n.anyOf,r,Qf(fe("results","length"),K(0)))}function P$(e,t,n,r){return el(n.anyOf.map(s=>st(e,t,s,r)))}function Sh(e,t,n,r){return t.UseUnevaluated()?$$(e,t,n,r):P$(e,t,n,r)}function Ih(e,t,n,r){const s=n.anyOf.reduce((o,i)=>{const a=new Fn;return ot(e,a,i,r)?[...o,a]:o},[]);return Vr(s.length,0)&&t.Merge(s)}function vh(e,t,n,r,s,o){const i=[],a=s.anyOf.reduce((u,f,p)=>{const g=new _n,b=`${n}/anyOf/${p}`,x=St(e,g,b,r,f,o);return x||i.push(g),x?[...u,g]:u},[]),c=Vr(a.length,0)&&t.Merge(a);return c||i.forEach(u=>u.GetErrors().forEach(f=>t.AddError(f))),c||t.AddError({keyword:"anyOf",schemaPath:n,instancePath:r,params:{}})}function jh(e,t,n,r){return K(!!n)}function Zl(e,t,n,r){return n}function Ch(e,t,n,r,s,o){return Zl(e,t,s)||t.AddError({keyword:"boolean",schemaPath:n,instancePath:r,params:{}})}function Th(e,t,n,r){return Cs(n.const)?zt(r,K(n.const)):Xf(r,as(n.const))}function eu(e,t,n,r){return Cs(n.const)?h(r,n.const):Wr(r,n.const)}function Eh(e,t,n,r,s,o){return eu(e,t,s,o)||t.AddError({keyword:"const",schemaPath:n,instancePath:r,params:{allowedValue:s.const}})}function Nh(e){return!(rs(e)&&h(e.minContains,0))}function O$(e,t,n,r){const[s,o]=[it(),it()],i=Et(zt(fe(r,"length"),K(0))),a=fw(r,[s,o],kt(st(e,t,n.contains,s),t.AddIndex(o)));return kt(i,a)}function R$(e,t,n,r){const[s]=[it()],o=Et(zt(fe(r,"length"),K(0))),i=dw(r,[s,"_"],st(e,t,n.contains,s));return kt(o,i)}function Ah(e,t,n,r){return Nh(n)?t.UseUnevaluated()?O$(e,t,n,r):R$(e,t,n,r):K(!0)}function tu(e,t,n,r){return Nh(n)?!h(r.length,0)&&Hf(r,(s,o)=>ot(e,t,n.contains,s)&&t.AddIndex(o)):!0}function $h(e,t,n,r,s,o){return tu(e,t,s,o)||t.AddError({keyword:"contains",schemaPath:n,instancePath:r,params:{minContains:1}})}function Ph(e,t,n,r){const s=zt(fe(Qr(r),"length"),K(0)),o=wt(tt(n.dependencies).map(([i,a])=>{const c=Et(Ur(r,K(i))),u=st(e,t,a,r),f=p=>wt(p.map(g=>Ur(r,K(g))));return Ue(c,H(a)?f(a):u)}));return Ue(s,o)}function Oh(e,t,n,r){const s=h(D(r).length,0),o=lt(tt(n.dependencies),0,([i,a])=>!C(r,i)||(H(a)?a.every(c=>C(r,c)):ot(e,t,a,r)));return s||o}function Rh(e,t,n,r,s,o){const i=h(D(o).length,0),a=It(tt(s.dependencies),0,([c,u])=>{const f=`${n}/dependencies/${c}`;return!C(o,c)||(H(u)?u.every(p=>C(o,p)||t.AddError({keyword:"dependencies",schemaPath:n,instancePath:r,params:{property:c,dependencies:u}})):St(e,t,f,r,u,o))});return i||a}function Mh(e,t,n,r){const s=zt(fe(Qr(r),"length"),K(0)),o=wt(tt(n.dependentRequired).map(([i,a])=>{const c=Et(Ur(r,K(i))),u=wt(a.map(f=>Ur(r,K(f))));return Ue(c,u)}));return Ue(s,o)}function Fh(e,t,n,r){const s=h(D(r).length,0),o=lt(tt(n.dependentRequired),0,([i,a])=>!C(r,i)||a.every(c=>C(r,c)));return s||o}function _h(e,t,n,r,s,o){const i=h(D(o).length,0),a=It(tt(s.dependentRequired),0,([c,u])=>!C(o,c)||It(u,0,f=>C(o,f)||t.AddError({keyword:"dependentRequired",schemaPath:n,instancePath:r,params:{property:c,dependencies:u}})));return i||a}function Dh(e,t,n,r){const s=zt(fe(Qr(r),"length"),K(0)),o=wt(tt(n.dependentSchemas).map(([i,a])=>{const c=Et(Ur(r,K(i))),u=st(e,t,a,r);return Ue(c,u)}));return Ue(s,o)}function Lh(e,t,n,r){const s=h(D(r).length,0),o=lt(tt(n.dependentSchemas),0,([i,a])=>!C(r,i)||ot(e,t,a,r));return s||o}function Bh(e,t,n,r,s,o){const i=h(D(o).length,0),a=It(tt(s.dependentSchemas),0,([c,u])=>{const f=`${n}/dependentSchemas/${c}`;return!C(o,c)||St(e,t,f,r,u,o)});return i||a}function M$(e,t,n,r){const s=e.DynamicRef(n)??!1;return Us(e,t,s,r)}function F$(e,t,n,r){const s=e.DynamicRef(n)??!1;return Me(s)&&ot(e,t,s,r)}function _$(e,t,n,r,s,o){const i=e.DynamicRef(s)??!1;return Me(i)&&St(e,t,"#",r,i,o)}function Uh(e,t,n,r){return el(n.enum.map(s=>{if(Cs(s))return zt(r,K(s));const o=as(s);return Xf(r,o)}))}function nu(e,t,n,r){return Ts(n.enum,s=>Cs(s)?h(r,s):Wr(r,s))}function qh(e,t,n,r,s,o){return nu(e,t,s,o)||t.AddError({keyword:"enum",schemaPath:n,instancePath:r,params:{allowedValues:s.enum}})}function zh(e,t,n,r){return Xc(r,K(n.exclusiveMaximum))}function ru(e,t,n,r){return ho(r,n.exclusiveMaximum)}function Hh(e,t,n,r,s,o){return ru(e,t,s,o)||t.AddError({keyword:"exclusiveMaximum",schemaPath:n,instancePath:r,params:{comparison:"<",limit:s.exclusiveMaximum}})}function Kh(e,t,n,r){return Qf(r,K(n.exclusiveMinimum))}function su(e,t,n,r){return Vr(r,n.exclusiveMinimum)}function Gh(e,t,n,r,s,o){return su(e,t,s,o)||t.AddError({keyword:"exclusiveMinimum",schemaPath:n,instancePath:r,params:{comparison:">",limit:s.exclusiveMinimum}})}const D$=[0,31,28,31,30,31,30,31,31,30,31,30,31],L$=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function B$(e){return e%4===0&&(e%100!==0||e%400===0)}function ou(e){const t=L$.exec(e);if(!t)return!1;const n=+t[1],r=+t[2],s=+t[3];return r>=1&&r<=12&&s>=1&&s<=(r===2&&B$(n)?29:D$[r])}const U$=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(?:Z|([+-])(\d\d):(\d\d))?$/i;function iu(e,t=!0){const n=U$.exec(e);if(!n)return!1;const r=+n[1],s=+n[2],o=+n[3],i=n[4]==="-"?-1:1,a=+(n[5]||0),c=+(n[6]||0);if(a>23||c>59||t&&!n[4]&&e.toLowerCase().indexOf("z")===-1)return!1;if(r<=23&&s<=59&&o<60)return!0;const u=s-c*i,f=r-a*i-(u<0?1:0);return(f===23||f===-1)&&(u===59||u===-1)&&o<61}function Vh(e,t=!0){const n=e.split(/T/i);return n.length===2&&ou(n[0])&&iu(n[1],t)}const q$=/^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;function Wh(e){return q$.test(e)}const z$=/^(?!.*\.\.)[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i;function Jh(e){return z$.test(e)}const Lr=36,pi=1,hc=26,H$=38,K$=700,G$=72,V$=128;function W$(e,t,n){e=n?Math.floor(e/K$):e>>1,e+=Math.floor(e/t);let r=0;for(;e>(Lr-pi)*hc>>1;)e=Math.floor(e/(Lr-pi)),r+=Lr;return r+Math.floor((Lr-pi+1)*e/(e+H$))}function J$(e){const t=[];let n=V$,r=0,s=G$;const o=e.lastIndexOf("-");if(o>0)for(let a=0;a<o;a++){const c=e.charCodeAt(a);if(c>=128)throw new Error("Invalid punycode: non-basic before delimiter");t.push(c)}let i=o<0?0:o+1;for(;i<e.length;){const a=r;let c=1,u=Lr;for(;;){if(i>=e.length)throw new Error("Invalid punycode: unexpected end of input");const p=e.charCodeAt(i++);let g;if(p>=97&&p<=122)g=p-97;else if(p>=48&&p<=57)g=p-48+26;else if(p>=65&&p<=90)Nt();else throw new Error("Invalid punycode: bad digit character");r+=g*c;const b=u<=s?pi:u>=s+hc?hc:u-s;if(g<b)break;c*=Lr-b,u+=Lr}const f=t.length+1;s=W$(r-a,f,a===0),n+=Math.floor(r/f),r%=f,t.splice(r,0,n),r++}return globalThis.String.fromCodePoint(...t)}function Q$(e){return new RegExp("\\p{Mn}","u").test(String.fromCodePoint(e))}function Y$(e){return new RegExp("\\p{Mc}","u").test(String.fromCodePoint(e))}function X$(e){return new RegExp("\\p{Me}","u").test(String.fromCodePoint(e))}function Z$(e){return Q$(e)||Y$(e)||X$(e)}const eP=new Set([1600,2042,12334,12335,12337,12338,12339,12340,12341,12347]),tP=new Set([2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,6980,7082,7083,43456,69702,69759,69817,69939,69940,70080,70197,70477,70722,70850,71103,71231,71350,72767,73028,73029]);function nP(e){return new RegExp("\\p{Script=Greek}","u").test(String.fromCodePoint(e))}function rP(e){return new RegExp("\\p{Script=Hebrew}","u").test(String.fromCodePoint(e))}function sP(e){return new RegExp("\\p{Script=Hiragana}","u").test(String.fromCodePoint(e))}function oP(e){return new RegExp("\\p{Script=Katakana}","u").test(String.fromCodePoint(e))}function iP(e){return new RegExp("\\p{Script=Han}","u").test(String.fromCodePoint(e))}function aP(e){return e>=1632&&e<=1641}function cP(e){return e>=1776&&e<=1785}function Dd(e){return tP.has(e)}function Qh(e){if(e.length===0)return Nt();const t=[...e].map(i=>i.codePointAt(0)),n=t.length;if(t[0]===45||t[n-1]===45||n>=4&&t[2]===45&&t[3]===45||Z$(t[0]))return!1;let r=!1,s=!1,o=!1;for(let i=0;i<n;i++){const a=t[i];if(eP.has(a))return!1;(sP(a)||oP(a)||iP(a))&&(r=!0),aP(a)&&(s=!0),cP(a)&&(o=!0);const c=t[i-1],u=t[i+1];switch(a){case 183:if(c!==108||u!==108)return!1;break;case 885:if(u===void 0||!nP(u))return!1;break;case 1523:case 1524:if(c===void 0||!rP(c))return!1;break;case 8204:if(c===void 0||c<128&&!Dd(c))return!1;break;case 8205:if(c===void 0||!Dd(c))return!1;break}}return!(e.includes("・")&&!r||s&&o)}function lP(e){if(e.charCodeAt(0)===45||e.charCodeAt(e.length-1)===45||e.length>=4&&e.charCodeAt(2)===45&&e.charCodeAt(3)===45)return!1;for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(!(n>=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||n===45))return!1}return!0}function Yh(e){return e.toLowerCase().startsWith("xn--")}function Xh(e){try{const t=e.slice(4).toLowerCase();if(t.lastIndexOf("-")===0)return!1;const r=J$(t);return r?Qh(r):!1}catch{return!1}}function uP(e){return e.length===0||e.length>63?!1:Yh(e)?Xh(e):Qh(e)}function dP(e){return e.length===0||e.length>63?!1:Yh(e)?Xh(e):lP(e)}function Zh(e){if(e.length===0||e.length>253||e.charCodeAt(e.length-1)===46)return!1;for(const t of e.split("."))if(!dP(t))return!1;return!0}const fP=/^(?!.*\.\.)[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+(?:\.[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+)*@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?)*$/iu;function eb(e){return fP.test(e)}function tb(e){if(e.length===0||e.includes(" "))return!1;const t=e.normalize("NFC").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".");if(t.length>253)return!1;for(const n of t.split("."))if(!uP(n))return!1;return!0}function nb(e,t,n){let r=0,s=0,o=0,i=0;for(let a=t;a<n;a++){const c=e.charCodeAt(a);if(c===46){if(o===0||s>255||i===48&&o>1)return!1;r++,s=0,o=0,i=0}else if(c>=48&&c<=57)o===0&&(i=c),s=s*10+(c-48),o++;else return!1}return r===3&&o>0&&s<=255&&!(i===48&&o>1)}function rb(e){return nb(e,0,e.length)}function mP(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function sb(e){const t=e.length;if(t===0)return!1;let n=0,r=!1,s=0;if(e.charCodeAt(0)===58&&e.charCodeAt(1)===58){if(t===2)return!0;r=!0,s=2}for(;s<t;){let o=0;const i=s;for(;s<t&&mP(e.charCodeAt(s));)s++,o++;if(o===0)return!1;const a=e.charCodeAt(s);if(a===46){if(!nb(e,i,t))return!1;n+=2,s=t;break}if(o>4)return!1;if(n++,s===t)break;if(a!==58)return!1;if(s++,e.charCodeAt(s)===58){if(r||e.charCodeAt(s+1)===58)return!1;if(r=!0,s++,s===t)break}}return r?n<=7:n===8}function Ld(e){try{return new URL(e,"http://example.com"),!0}catch{return!1}}function ob(e){if(e.includes(" ")||e.includes("\\")||/[\x00-\x1F\x7F]/.test(e)||/%(?![0-9a-fA-F]{2})/.test(e))return!1;if(e==="")return!0;const t=e.indexOf(":");return t>0&&/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(e.substring(0,t))?Ld(e):e.match(/^([a-zA-Z][a-zA-Z0-9+\-.]*)(\/\/)/)&&t===-1?!1:Ld(e)}function ib(e){try{return new URL(e),!0}catch{return!1}}const pP=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function ab(e){return pP.test(e)}const gP=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function cb(e){return gP.test(e)}function lb(e){if(e.length===0)return!1;try{return new RegExp(e),!0}catch{return!1}}const hP=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function ub(e){return hP.test(e)}const bP=/^(?!.*[^\x00-\x7F])(?!.*\\)(?:(?:[a-z][a-z0-9+\-.]*:)?(?:\/\/[^\s[\]{}<>^`|]*)?|[^\s[\]{}<>^`|]*)(?:\?[^\s[\]{}<>^`|]*)?(?:#[^\s[\]{}<>^`|]*)?$/i;function db(e){return bP.test(e)}const xP=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;function fb(e){return xP.test(e)}function mb(e){return e>=97&&e<=122||e>=65&&e<=90}function pb(e){return mb(e)||e>=48&&e<=57}function ci(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function kP(e){return pb(e)||e===43||e===45||e===46}function bc(e){return pb(e)||e===45||e===46||e===95||e===126}function xc(e){return e===33||e===36||e===38||e===39||e===40||e===41||e===42||e===43||e===44||e===59||e===61}function yP(e){return bc(e)||xc(e)||e===58||e===64}function gb(e){const t=e.length;if(t===0||!mb(e.charCodeAt(0)))return!1;let n=1;for(;n<t;){const r=e.charCodeAt(n);if(r===58)break;if(!kP(r))return!1;n++}if(e.charCodeAt(n)!==58)return!1;if(n++,e.charCodeAt(n)===47&&e.charCodeAt(n+1)===47){n+=2;const r=n;let s=-1;for(let o=n;o<t;o++){const i=e.charCodeAt(o);if(i===64){s=o;break}if(i===47||i===63||i===35)break}if(s!==-1){for(let o=r;o<s;o++){const i=e.charCodeAt(o);if(i===91||i===93)return!1;if(i===37){if(o+2>=s||!ci(e.charCodeAt(o+1))||!ci(e.charCodeAt(o+2)))return!1;o+=2}else if(!bc(i)&&!xc(i)&&i!==58)return!1}n=s+1}if(e.charCodeAt(n)===91){for(n++;n<t&&e.charCodeAt(n)!==93;)n++;if(e.charCodeAt(n)!==93)return!1;n++}else for(;n<t;){const o=e.charCodeAt(n);if(o===47||o===63||o===35||o===58)break;if(o<128&&!bc(o)&&!xc(o))return!1;n++}if(e.charCodeAt(n)===58)for(n++;n<t;){const o=e.charCodeAt(n);if(o===47||o===63||o===35)break;if(o<48||o>57)return!1;n++}}for(;n<t;){const r=e.charCodeAt(n);if(r===37){if(n+2>=t||!ci(e.charCodeAt(n+1))||!ci(e.charCodeAt(n+2)))return!1;n+=2}else{if(r>127)return!1;if(!(yP(r)||r===47||r===63||r===35))return!1}n++}return!0}const wP=/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;function hb(e){return wP.test(e)}const SP=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function bb(e){return SP.test(e)}const Be=new Map;function xb(){Be.clear()}function IP(){return[...Be.entries()]}function vP(e,t){Be.set(e,t)}function jP(e){return Be.has(e)}function CP(e){return Be.get(e)}function kb(e,t){var n;return((n=Be.get(e))==null?void 0:n(t))??!0}function yb(){xb(),Be.set("date-time",Vh),Be.set("date",ou),Be.set("duration",Wh),Be.set("email",Jh),Be.set("hostname",Zh),Be.set("idn-email",eb),Be.set("idn-hostname",tb),Be.set("ipv4",rb),Be.set("ipv6",sb),Be.set("iri-reference",ob),Be.set("iri",ib),Be.set("json-pointer-uri-fragment",ab),Be.set("json-pointer",cb),Be.set("regex",lb),Be.set("relative-json-pointer",ub),Be.set("time",iu),Be.set("uri-reference",db),Be.set("uri-template",fb),Be.set("uri",gb),Be.set("url",hb),Be.set("uuid",bb)}yb();const TP=Object.freeze(Object.defineProperty({__proto__:null,Clear:xb,Entries:IP,Get:CP,Has:jP,IsDate:ou,IsDateTime:Vh,IsDuration:Wh,IsEmail:Jh,IsHostname:Zh,IsIPv4:rb,IsIPv6:sb,IsIdnEmail:eb,IsIdnHostname:tb,IsIri:ib,IsIriReference:ob,IsJsonPointer:cb,IsJsonPointerUriFragment:ab,IsRegex:lb,IsRelativeJsonPointer:ub,IsTime:iu,IsUri:gb,IsUriReference:db,IsUriTemplate:fb,IsUrl:hb,IsUuid:bb,Reset:yb,Set:vP,Test:kb},Symbol.toStringTag,{value:"Module"}));function wb(e,t,n,r){return ze(fe("Format","Test"),[K(n.format),r])}function au(e,t,n,r){return kb(n.format,r)}function Sb(e,t,n,r,s,o){return au(e,t,s,o)||t.AddError({keyword:"format",schemaPath:n,instancePath:r,params:{format:s.format}})}function Ib(e,t,n,r){const s=ha(n)?n.then:!0,o=ca(n)?n.else:!0;return pw(st(e,t,n.if,r),st(e,t,s,r),st(e,t,o,r))}function vb(e,t,n,r){const s=ha(n)?n.then:!0,o=ca(n)?n.else:!0;return ot(e,t,n.if,r)?ot(e,t,s,r):ot(e,t,o,r)}function jb(e,t,n,r,s,o){const i=ha(s)?s.then:!0,a=ca(s)?s.else:!0,c=new _n,u=St(e,c,`${n}/if`,r,s.if,o)?St(e,c,`${n}/then`,r,i,o)||t.AddError({keyword:"if",schemaPath:n,instancePath:r,params:{failingKeyword:"then"}}):St(e,t,`${n}/else`,r,a,o)||t.AddError({keyword:"if",schemaPath:n,instancePath:r,params:{failingKeyword:"else"}});return u&&t.Merge([c]),u}function EP(e,t,n,r){return wt(n.items.map((s,o)=>{const i=Jr(fe(r,"length"),K(o)),a=En(e,t,s,`${r}[${o}]`),c=t.AddIndex(K(o));return Ue(i,kt(a,c))}))}function NP(e,t,n,r){return wt(n.items.map((s,o)=>{const i=Jr(fe(r,"length"),K(o)),a=En(e,t,s,`${r}[${o}]`);return Ue(i,a)}))}function AP(e,t,n,r){return t.UseUnevaluated()?EP(e,t,n,r):NP(e,t,n,r)}function $P(e,t,n,r){return lt(n.items,0,(s,o)=>Qn(r.length,o)||Nr(e,t,s,r[o])&&t.AddIndex(o))}function PP(e,t,n,r,s,o){return It(s.items,0,(i,a)=>{const c=`${n}/items/${a}`,u=`${r}/${a}`;return Qn(o.length,a)||Ar(e,t,c,u,i,o[a])&&t.AddIndex(a)})}function OP(e,t,n,r){const s=tr(n)?n.prefixItems.length:0,o=En(e,t,n.items,"element"),i=t.AddIndex("index");return Pn(r,K(s),["element","index"],kt(o,i))}function RP(e,t,n,r){const s=tr(n)?n.prefixItems.length:0,o=En(e,t,n.items,"element");return Pn(r,K(s),["element","index"],o)}function MP(e,t,n,r){return t.UseUnevaluated()?OP(e,t,n,r):RP(e,t,n,r)}function FP(e,t,n,r){const s=tr(n)?n.prefixItems.length:0;return lt(r,s,(o,i)=>Nr(e,t,n.items,o)&&t.AddIndex(i))}function _P(e,t,n,r,s,o){const i=tr(s)?s.prefixItems.length:0;return It(o,i,(a,c)=>{const u=`${n}/items`,f=`${r}/${c}`;return Ar(e,t,u,f,s.items,a)&&t.AddIndex(c)})}function Cb(e,t,n,r){return da(n)?AP(e,t,n,r):MP(e,t,n,r)}function Tb(e,t,n,r){return da(n)?$P(e,t,n,r):FP(e,t,n,r)}function Eb(e,t,n,r,s,o){return da(s)?PP(e,t,n,r,s,o):_P(e,t,n,r,s,o)}function Nb(e){return ns(e)}function Ab(e,t,n,r){if(!Nb(n))return K(!0);const[s]=[it()],o=Ui(r,[s,"_"],st(e,t,n.contains,s));return Jr(o,K(n.maxContains))}function cu(e,t,n,r){if(!Nb(n))return!0;const s=Wc(r,o=>ot(e,t,n.contains,o));return Qn(s,n.maxContains)}function $b(e,t,n,r,s,o){const i=rs(s)?s.minContains:1;return cu(e,t,s,o)||t.AddError({keyword:"contains",schemaPath:n,instancePath:r,params:{minContains:i,maxContains:s.maxContains}})}function Pb(e,t,n,r){return Jr(r,K(n.maximum))}function lu(e,t,n,r){return Qn(r,n.maximum)}function Ob(e,t,n,r,s,o){return lu(e,t,s,o)||t.AddError({keyword:"maximum",schemaPath:n,instancePath:r,params:{comparison:"<=",limit:s.maximum}})}function Rb(e,t,n,r){return Jr(fe(r,"length"),K(n.maxItems))}function uu(e,t,n,r){return Qn(r.length,n.maxItems)}function Mb(e,t,n,r,s,o){return uu(e,t,s,o)||t.AddError({keyword:"maxItems",schemaPath:n,instancePath:r,params:{limit:s.maxItems}})}function Fb(e,t,n,r){return uw(r,K(n.maxLength))}function du(e,t,n,r){return qf(r,n.maxLength)}function _b(e,t,n,r,s,o){return du(e,t,s,o)||t.AddError({keyword:"maxLength",schemaPath:n,instancePath:r,params:{limit:s.maxLength}})}function Db(e,t,n,r){return Jr(fe(Qr(r),"length"),K(n.maxProperties))}function fu(e,t,n,r){return Qn(D(r).length,n.maxProperties)}function Lb(e,t,n,r,s,o){return fu(e,t,s,o)||t.AddError({keyword:"maxProperties",schemaPath:n,instancePath:r,params:{limit:s.maxProperties}})}function Bb(e){return ns(e)}function DP(e,t,n,r){const[s,o]=[it(),it()],i=Ui(r,[s,o],kt(st(e,t,n.contains,s),t.AddIndex(o)));return bo(i,K(n.minContains))}function LP(e,t,n,r){const[s]=[it()],o=Ui(r,[s,"_"],st(e,t,n.contains,s));return bo(o,K(n.minContains))}function Ub(e,t,n,r){return Bb(n)?t.UseUnevaluated()?DP(e,t,n,r):LP(e,t,n,r):K(!0)}function mu(e,t,n,r){if(!Bb(n))return!0;const s=Wc(r,(o,i)=>ot(e,t,n.contains,o)&&t.AddIndex(i));return js(s,n.minContains)}function qb(e,t,n,r,s,o){return mu(e,t,s,o)||t.AddError({keyword:"contains",schemaPath:n,instancePath:r,params:{minContains:s.minContains}})}function zb(e,t,n,r){return bo(r,K(n.minimum))}function pu(e,t,n,r){return js(r,n.minimum)}function Hb(e,t,n,r,s,o){return pu(e,t,s,o)||t.AddError({keyword:"minimum",schemaPath:n,instancePath:r,params:{comparison:">=",limit:s.minimum}})}function Kb(e,t,n,r){return bo(fe(r,"length"),K(n.minItems))}function gu(e,t,n,r){return js(r.length,n.minItems)}function Gb(e,t,n,r,s,o){return gu(e,t,s,o)||t.AddError({keyword:"minItems",schemaPath:n,instancePath:r,params:{limit:s.minItems}})}function Vb(e,t,n,r){return lw(r,K(n.minLength))}function hu(e,t,n,r){return zf(r,n.minLength)}function Wb(e,t,n,r,s,o){return hu(e,t,s,o)||t.AddError({keyword:"minLength",schemaPath:n,instancePath:r,params:{limit:s.minLength}})}function Jb(e,t,n,r){return bo(fe(Qr(r),"length"),K(n.minProperties))}function bu(e,t,n,r){return js(D(r).length,n.minProperties)}function Qb(e,t,n,r,s,o){return bu(e,t,s,o)||t.AddError({keyword:"minProperties",schemaPath:n,instancePath:r,params:{limit:s.minProperties}})}function Yb(e,t,n,r){return gw(r,K(n.multipleOf))}function xu(e,t,n,r){return Bf(r,n.multipleOf)}function Xb(e,t,n,r,s,o){return xu(e,t,s,o)||t.AddError({keyword:"multipleOf",schemaPath:n,instancePath:r,params:{multipleOf:s.multipleOf}})}function BP(e,t,n,r){return Jo(e,t,[n.not],r,Et(zt(fe("results","length"),K(1))))}function UP(e,t,n,r){return Et(st(e,t,n.not,r))}function Zb(e,t,n,r){return t.UseUnevaluated()?BP(e,t,n,r):UP(e,t,n,r)}function ku(e,t,n,r){const s=new Fn;return!ot(e,s,n.not,r)&&t.Merge([s])}function ex(e,t,n,r,s,o){return ku(e,t,s,o)||t.AddError({keyword:"not",schemaPath:n,instancePath:r,params:{}})}function qP(e,t,n,r){return Jo(e,t,n.oneOf,r,zt(fe("results","length"),K(1)))}function zP(e,t,n,r){const[s]=[it()],o=mw(n.oneOf.map(a=>st(e,t,a,r))),i=Ui(o,[s,"_"],zt(s,K(!0)));return zt(i,K(1))}function tx(e,t,n,r){return t.UseUnevaluated()?qP(e,t,n,r):zP(e,t,n,r)}function nx(e,t,n,r){const s=n.oneOf.reduce((o,i)=>{const a=new Fn;return ot(e,a,i,r)?[...o,a]:o},[]);return h(s.length,1)&&t.Merge(s)}function rx(e,t,n,r,s,o){const i=[],a=[],c=s.oneOf.reduce((f,p,g)=>{const b=new _n,x=`${n}/oneOf/${g}`,y=St(e,b,x,r,p,o);return y&&a.push(g),y||i.push(b),y?[...f,b]:f},[]),u=h(c.length,1)&&t.Merge(c);return!u&&h(a.length,0)&&i.forEach(f=>f.GetErrors().forEach(p=>t.AddError(p))),u||t.AddError({keyword:"oneOf",schemaPath:n,instancePath:r,params:{passingSchemas:a}})}function sx(e,t,n,r){const s=as(ce(n.pattern)?new RegExp(n.pattern,"u"):n.pattern);return ze(fe(s,"test"),[r])}function yu(e,t,n,r){return(ce(n.pattern)?new RegExp(n.pattern,"u"):n.pattern).test(r)}function ox(e,t,n,r,s,o){return yu(e,t,s,o)||t.AddError({keyword:"pattern",schemaPath:n,instancePath:r,params:{pattern:s.pattern}})}function ix(e,t,n,r){return wt(tt(n.patternProperties).map(([s,o])=>{const[i,a]=[it(),it()],c=as(new RegExp(s,"u")),u=Et(ze(fe(c,"test"),[i])),f=En(e,t,o,a),p=t.AddKey(i),g=t.UseUnevaluated()?Ue(u,kt(f,p)):Ue(u,f);return Pn(Yf(r),K(0),[`[${i}, ${a}]`,"_"],g)}))}function ax(e,t,n,r){return lt(tt(n.patternProperties),0,([s,o])=>{const i=new RegExp(s,"u");return lt(tt(r),0,([a,c])=>!i.test(a)||Nr(e,t,o,c)&&t.AddKey(a))})}function cx(e,t,n,r,s,o){return It(tt(s.patternProperties),0,([i,a])=>{const c=`${n}/patternProperties/${i}`,u=new RegExp(i,"u");return It(tt(o),0,([f,p])=>{const g=`${r}/${f}`;return!u.test(f)||Ar(e,t,c,g,a,p)&&t.AddKey(f)})})}function lx(e,t,n,r){return wt(n.prefixItems.map((s,o)=>{const i=Jr(fe(r,"length"),K(o)),a=En(e,t,s,`${r}[${o}]`),c=t.AddIndex(K(o)),u=t.UseUnevaluated()?kt(a,c):a;return Ue(i,u)}))}function ux(e,t,n,r){return h(r.length,0)||lt(n.prefixItems,0,(s,o)=>Qn(r.length,o)||Nr(e,t,s,r[o])&&t.AddIndex(o))}function dx(e,t,n,r,s,o){return h(o.length,0)||It(s.prefixItems,0,(i,a)=>{const c=`${n}/prefixItems/${a}`,u=`${r}/${a}`;return Qn(o.length,a)||Ar(e,t,c,u,i,o[a])&&t.AddIndex(a)})}function wu(e,t){return e.includes(t)||ko().exactOptionalPropertyTypes}function HP(e,t){return ec(fe(e,t))}function fx(e,t){return Pe(e[t])}function mx(e,t,n,r){const s=nr(n)?n.required:[],o=tt(n.properties).map(([i,a])=>{const c=Et(Ur(r,K(i))),u=En(e,t,a,fe(r,i)),f=t.AddKey(K(i)),p=t.UseUnevaluated()?kt(u,f):u,g=s.includes(i)?p:Ue(c,p);return wu(s,i)?g:Ue(HP(r,i),g)});return wt(o)}function px(e,t,n,r){const s=nr(n)?n.required:[];return lt(tt(n.properties),0,([i,a])=>{const c=!C(r,i)||Nr(e,t,a,r[i])&&t.AddKey(i);return wu(s,i)?c:fx(r,i)||c})}function gx(e,t,n,r,s,o){const i=nr(s)?s.required:[];return It(tt(s.properties),0,([c,u])=>{const f=`${n}/properties/${c}`,p=`${r}/${c}`,g=()=>!C(o,c)||Ar(e,t,f,p,u,o[c])&&t.AddKey(c);return wu(i,c)?g():fx(o,c)||g()})}function hx(e,t,n,r){const[s,o]=[it(),it()];return Pn(Qr(r),K(0),[s,o],st(e,t,n.propertyNames,s))}function bx(e,t,n,r){return lt(D(r),0,(s,o)=>ot(e,t,n.propertyNames,s))}function xx(e,t,n,r,s,o){const i=[];return It(D(o),0,(c,u)=>{const f=`${r}/${c}`,p=`${n}/propertyNames`,g=new _n,b=St(e,g,p,f,s.propertyNames,c);return b||i.push(c),b})||t.AddError({keyword:"propertyNames",schemaPath:n,instancePath:r,params:{propertyNames:i}})}function kx(e,t,n,r){const s=e.RecursiveRef(n)??!1;return Us(e,t,s,r)}function yx(e,t,n,r){const s=e.RecursiveRef(n)??!1;return Me(s)&&ot(e,t,s,r)}function wx(e,t,n,r,s,o){const i=e.RecursiveRef(s)??!1;return Me(i)&&St(e,t,"#",r,i,o)}function KP(e,t,n,r){const s=gr(["context","value"],Us(e,t,n,"value")),o=gr(["context","value"],qi([Hn("nextContext",Zc("CheckContext",[])),Hn("result",ze(s,["nextContext","value"])),Zf("result",t.Merge("[nextContext]")),zi("result")]));return ze(o,["context",r])}function GP(e,t,n,r){return Us(e,t,n,r)}function Sx(e,t,n,r){const s=e.Ref(n)??!1;return t.UseUnevaluated()?KP(e,t,s,r):GP(e,t,s,r)}function Ix(e,t,n,r){const s=e.Ref(n)??!1,o=new Fn,i=Me(s)&&ot(e,o,s,r);return i&&t.Merge([o]),i}function vx(e,t,n,r,s,o){const i=e.Ref(s)??!1,a=new _n,c=Me(i)&&St(e,a,"#",r,i,o);return c&&t.Merge([a]),c||a.GetErrors().forEach(u=>t.AddError(u)),c}function jx(e,t,n,r){return wt(n.required.map(s=>Ur(r,K(s))))}function Cx(e,t,n,r){return lt(n.required,0,s=>C(r,s))}function Tx(e,t,n,r,s,o){const i=[];return It(s.required,0,c=>{const u=C(o,c);return u||i.push(c),u})||t.AddError({keyword:"required",schemaPath:n,instancePath:r,params:{requiredProperties:i}})}function Ex(e,t,n,r){return h(n,"object")?Vf(r):h(n,"array")?Si(r):h(n,"boolean")?rw(r):h(n,"integer")?sw(r):h(n,"number")?Gf(r):h(n,"null")?ow(r):h(n,"string")?Jf(r):h(n,"bigint")?Kf(r):h(n,"constructor")?cw(r):h(n,"function")?aw(r):h(n,"symbol")?iw(r):h(n,"undefined")||h(n,"void")?ec(r):K(!0)}function Su(e,t,n,r,s){return h(n,"object")?an(s):h(n,"array")?H(s):h(n,"boolean")?mt(s):h(n,"integer")?Gc(s):h(n,"number")?we(s):h(n,"null")?Ht(s):h(n,"string")?ce(s):h(n,"bigint")?et(s):h(n,"constructor")?Bi(s):h(n,"function")?kn(s):h(n,"symbol")?Vc(s):h(n,"undefined")||h(n,"void")?Pe(s):!0}function VP(e,t,n,r){return el(n.map(s=>Ex(e,t,s,r)))}function Nx(e,t,n,r,s){return Ts(n,o=>Su(e,t,o,r,s))}function Ax(e,t,n,r){return H(n.type)?VP(e,t,n.type,r):Ex(e,t,n.type,r)}function $x(e,t,n,r){return H(n.type)?Nx(e,t,n.type,n,r):Su(e,t,n.type,n,r)}function Px(e,t,n,r,s,o){return(H(s.type)?Nx(e,t,s.type,s,o):Su(e,t,s.type,s,o))||t.AddError({keyword:"type",schemaPath:n,instancePath:r,params:{type:s.type}})}function Ox(e,t,n,r){const[s,o]=[it(),it()],i=ze(fe("context","GetIndices"),[]),a=ze(fe("indices","has"),[s]),c=st(e,t,n.unevaluatedItems,o),u=ze(fe("context","AddIndex"),[s]),f=Pn(r,K(0),[o,s],kt(Ue(a,c),u));return ze(gr(["context"],qi([Hn("indices",i),zi(f)])),["context"])}function Rx(e,t,n,r){const s=t.GetIndices();return lt(r,0,(o,i)=>(s.has(i)||ot(e,t,n.unevaluatedItems,o))&&t.AddIndex(i))}function Mx(e,t,n,r,s,o){const i=t.GetIndices(),a=[];return It(o,0,(u,f)=>{const p=new _n,g=(i.has(f)||St(e,p,n,r,s.unevaluatedItems,u))&&t.AddIndex(f);return g||a.push(f),g})||t.AddError({keyword:"unevaluatedItems",schemaPath:n,instancePath:r,params:{unevaluatedItems:a}})}function Fx(e,t,n,r){const[s,o]=[it(),it()],i=ze(fe("context","GetKeys"),[]),a=ze(fe("keys","has"),[s]),c=ze(fe("context","AddKey"),[s]),u=st(e,t,n.unevaluatedProperties,o),f=Pn(Yf(r),K(0),[`[${s}, ${o}]`,"_"],Ue(a,kt(u,c)));return ze(gr(["context"],qi([Hn("keys",i),zi(f)])),["context"])}function _x(e,t,n,r){const s=t.GetKeys();return lt(tt(r),0,([o,i])=>s.has(o)||ot(e,t,n.unevaluatedProperties,i)&&t.AddKey(o))}function Dx(e,t,n,r,s,o){const i=t.GetKeys(),a=[];return It(tt(o),0,([u,f])=>{const p=new _n,g=i.has(u)||St(e,p,n,r,s.unevaluatedProperties,f)&&t.AddKey(u);return g||a.push(u),g})||t.AddError({keyword:"unevaluatedProperties",schemaPath:n,instancePath:r,params:{unevaluatedProperties:a}})}function Iu(e){return!h(e.uniqueItems,!1)}function Lx(e,t,n,r){if(!Iu(n))return K(!0);const s=fe(Zc("Set",[ze(fe(r,"map"),[fe("Hashing","Hash")])]),"size"),o=fe(r,"length");return zt(s,o)}function Bx(e,t,n,r){if(!Iu(n))return!0;const s=new Set(r.map(Hi)).size,o=r.length;return h(s,o)}function Ux(e,t,n,r,s,o){if(!Iu(s))return!0;const i=new Set,a=o.reduce((u,f,p)=>{const g=Hi(f);return i.has(g)?[...u,p]:(i.add(g),u)},[]);return h(a.length,0)||t.AddError({keyword:"uniqueItems",schemaPath:n,instancePath:r,params:{duplicateItems:a}})}function fo(e,t){return Wo(e)&&(H(e.type)&&Vr(e.type.length,0)&<(e.type,0,n=>h(n,t))||h(e.type,t))}function WP(e){return fo(e,"object")}function JP(e){return Xt(e)&&(er(e)||Do(e)||Lo(e)||Bo(e)||is(e)||os(e)||Vo(e)||_s(e)||Ko(e)||nr(e)||Bs(e))}function QP(e){return fo(e,"array")}function YP(e){return Xt(e)&&(_o(e)||Tr(e)||ns(e)||zo(e)||Ms(e)||rs(e)||ss(e)||tr(e)||Ls(e)||yr(e))}function XP(e){return fo(e,"string")}function ZP(e){return Xt(e)&&(Fs(e)||Ho(e)||Rs(e)||Ds(e))}function eO(e){return fo(e,"number")||fo(e,"bigint")}function tO(e){return Xt(e)&&(Er(e)||qo(e)||Uo(e)||Cr(e)||Go(e))}function En(e,t,n,r){return t.UseUnevaluated()?kt(kt(t.Push(),st(e,t,n,r)),t.Pop()):st(e,t,n,r)}function st(e,t,n,r){e.Push(n);const s=[];if(Fo(n))return jh(e,t,n);if(Wo(n)&&s.push(Ax(e,t,n,r)),JP(n)){const i=[];nr(n)&&i.push(jx(e,t,n,r)),er(n)&&i.push(hh(e,t,n,r)),Do(n)&&i.push(Ph(e,t,n,r)),Lo(n)&&i.push(Mh(e,t,n,r)),Bo(n)&&i.push(Dh(e,t,n,r)),os(n)&&i.push(ix(e,t,n,r)),is(n)&&i.push(mx(e,t,n,r)),Vo(n)&&i.push(hx(e,t,n,r)),_s(n)&&i.push(Jb(e,t,n,r)),Ko(n)&&i.push(Db(e,t,n,r));const a=wt(i),c=Ue(Et(Vf(r)),a);s.push(WP(n)?a:c)}if(YP(n)){const i=[];_o(n)&&i.push(uh(e,t,n,r)),ns(n)&&i.push(Ah(e,t,n,r)),Tr(n)&&i.push(Cb(e,t,n,r)),zo(n)&&i.push(Ab(e,t,n,r)),Ms(n)&&i.push(Rb(e,t,n,r)),rs(n)&&i.push(Ub(e,t,n,r)),ss(n)&&i.push(Kb(e,t,n,r)),tr(n)&&i.push(lx(e,t,n,r)),yr(n)&&i.push(Lx(e,t,n,r));const a=wt(i),c=Ue(Et(Si(r)),a);s.push(QP(n)?a:c)}if(ZP(n)){const i=[];Ho(n)&&i.push(Fb(e,t,n,r)),Fs(n)&&i.push(Vb(e,t,n,r)),Rs(n)&&i.push(wb(e,t,n,r)),Ds(n)&&i.push(sx(e,t,n,r));const a=wt(i),c=Ue(Et(Jf(r)),a);s.push(XP(n)?a:c)}if(tO(n)){const i=[];Uo(n)&&i.push(zh(e,t,n,r)),Cr(n)&&i.push(Kh(e,t,n,r)),qo(n)&&i.push(Pb(e,t,n,r)),Er(n)&&i.push(zb(e,t,n,r)),Go(n)&&i.push(Yb(e,t,n,r));const a=wt(i),c=Ue(Et(Ue(Gf(r),Kf(r))),a);s.push(eO(n)?a:c)}ga(n)&&s.push(Sx(e,t,n,r)),pa(n)&&s.push(kx(e,t,n,r)),aa(n)&&s.push(M$(e,t,n,r)),ia(n)&&s.push(Th(e,t,n,r)),la(n)&&s.push(Uh(e,t,n,r)),ua(n)&&s.push(Ib(e,t,n,r)),fa(n)&&s.push(Zb(e,t,n,r)),sa(n)&&s.push(kh(e,t,n,r)),oa(n)&&s.push(Sh(e,t,n,r)),ma(n)&&s.push(tx(e,t,n,r)),Ls(n)&&s.push(Ue(Et(Si(r)),Ox(e,t,n,r))),Bs(n)&&s.push(Ue(Et(Wf(r)),Fx(e,t,n,r))),ra(n)&&s.push(ah(e,t,n,r));const o=wt(s);return e.Pop(n),o}function Nr(e,t,n,r){return t.Push()&&ot(e,t,n,r)&&t.Pop()}function ot(e,t,n,r){e.Push(n);const s=Fo(n)?Zl(e,t,n):(!Wo(n)||$x(e,t,n,r))&&(!(ee(r)&&!H(r))||(!nr(n)||Cx(e,t,n,r))&&(!er(n)||bh(e,t,n,r))&&(!Do(n)||Oh(e,t,n,r))&&(!Lo(n)||Fh(e,t,n,r))&&(!Bo(n)||Lh(e,t,n,r))&&(!os(n)||ax(e,t,n,r))&&(!is(n)||px(e,t,n,r))&&(!Vo(n)||bx(e,t,n,r))&&(!_s(n)||bu(e,t,n,r))&&(!Ko(n)||fu(e,t,n,r)))&&(!H(r)||(!_o(n)||dh(e,t,n,r))&&(!ns(n)||tu(e,t,n,r))&&(!Tr(n)||Tb(e,t,n,r))&&(!zo(n)||cu(e,t,n,r))&&(!Ms(n)||uu(e,t,n,r))&&(!rs(n)||mu(e,t,n,r))&&(!ss(n)||gu(e,t,n,r))&&(!tr(n)||ux(e,t,n,r))&&(!yr(n)||Bx(e,t,n,r)))&&(!ce(r)||(!Ho(n)||du(e,t,n,r))&&(!Fs(n)||hu(e,t,n,r))&&(!Rs(n)||au(e,t,n,r))&&(!Ds(n)||yu(e,t,n,r)))&&(!(we(r)||et(r))||(!Uo(n)||ru(e,t,n,r))&&(!Cr(n)||su(e,t,n,r))&&(!qo(n)||lu(e,t,n,r))&&(!Er(n)||pu(e,t,n,r))&&(!Go(n)||xu(e,t,n,r)))&&(!ga(n)||Ix(e,t,n,r))&&(!pa(n)||yx(e,t,n,r))&&(!aa(n)||F$(e,t,n,r))&&(!ia(n)||eu(e,t,n,r))&&(!la(n)||nu(e,t,n,r))&&(!ua(n)||vb(e,t,n,r))&&(!fa(n)||ku(e,t,n,r))&&(!sa(n)||yh(e,t,n,r))&&(!oa(n)||Ih(e,t,n,r))&&(!ma(n)||nx(e,t,n,r))&&(!Ls(n)||!H(r)||Rx(e,t,n,r))&&(!Bs(n)||!ee(r)||_x(e,t,n,r))&&(!ra(n)||ch(e,t,n,r));return e.Pop(n),s}function Ar(e,t,n,r,s,o){return t.Push()&&St(e,t,n,r,s,o)&&t.Pop()}function St(e,t,n,r,s,o){e.Push(s);const i=Fo(s)?Ch(e,t,n,r,s):!!(+(!Wo(s)||Px(e,t,n,r,s,o))&+(!(ee(o)&&!H(o))||!!(+(!nr(s)||Tx(e,t,n,r,s,o))&+(!er(s)||xh(e,t,n,r,s,o))&+(!Do(s)||Rh(e,t,n,r,s,o))&+(!Lo(s)||_h(e,t,n,r,s,o))&+(!Bo(s)||Bh(e,t,n,r,s,o))&+(!os(s)||cx(e,t,n,r,s,o))&+(!is(s)||gx(e,t,n,r,s,o))&+(!Vo(s)||xx(e,t,n,r,s,o))&+(!_s(s)||Qb(e,t,n,r,s,o))&+(!Ko(s)||Lb(e,t,n,r,s,o))))&+(!H(o)||!!(+(!_o(s)||fh(e,t,n,r,s,o))&+(!ns(s)||$h(e,t,n,r,s,o))&+(!Tr(s)||Eb(e,t,n,r,s,o))&+(!zo(s)||$b(e,t,n,r,s,o))&+(!Ms(s)||Mb(e,t,n,r,s,o))&+(!rs(s)||qb(e,t,n,r,s,o))&+(!ss(s)||Gb(e,t,n,r,s,o))&+(!tr(s)||dx(e,t,n,r,s,o))&+(!yr(s)||Ux(e,t,n,r,s,o))))&+(!ce(o)||!!(+(!Ho(s)||_b(e,t,n,r,s,o))&+(!Fs(s)||Wb(e,t,n,r,s,o))&+(!Rs(s)||Sb(e,t,n,r,s,o))&+(!Ds(s)||ox(e,t,n,r,s,o))))&+(!(we(o)||et(o))||!!(+(!Uo(s)||Hh(e,t,n,r,s,o))&+(!Cr(s)||Gh(e,t,n,r,s,o))&+(!qo(s)||Ob(e,t,n,r,s,o))&+(!Er(s)||Hb(e,t,n,r,s,o))&+(!Go(s)||Xb(e,t,n,r,s,o))))&+(!ga(s)||vx(e,t,n,r,s,o))&+(!pa(s)||wx(e,t,n,r,s,o))&+(!aa(s)||_$(e,t,n,r,s,o))&+(!ia(s)||Eh(e,t,n,r,s,o))&+(!la(s)||qh(e,t,n,r,s,o))&+(!ua(s)||jb(e,t,n,r,s,o))&+(!fa(s)||ex(e,t,n,r,s,o))&+(!sa(s)||wh(e,t,n,r,s,o))&+(!oa(s)||vh(e,t,n,r,s,o))&+(!ma(s)||rx(e,t,n,r,s,o))&+(!Ls(s)||!H(o)||Mx(e,t,n,r,s,o))&+(!Bs(s)||!ee(o)||Dx(e,t,n,r,s,o)))&&(!ra(s)||lh(e,t,n,r,s,o));return e.Pop(s),i}const qx=[0],gi=new Map,so=new Map;function nO(){return`${qx[0]++}`}function rO(e,t){gi.has(e)||gi.set(e,new Map);const n=gi.get(e);if(n.has(t))return n.get(t);const r=nO();return n.set(t,r),r}function sO(e,t,n,r){return e.UseUnevaluated()?ze(`check_${n}`,["context",r]):ze(`check_${n}`,[r])}function oO(e,t,n,r){const s=st(e,t,n,"value");return t.UseUnevaluated()?Hn(`check_${r}`,gr(["context","value"],s)):Hn(`check_${r}`,gr(["value"],s))}function zx(){qx[0]=0,gi.clear(),so.clear()}function Hx(){return[...so.values()]}function Us(e,t,n,r){const s=rO(n,e.BaseURL().href),o=sO(t,n,s,r);return so.has(s)||(so.set(s,""),so.set(s,oO(e,t,n,s))),o}function Kx(e){if(e.length===0)throw Error("Cannot set root")}function Gx(e){if(!ee(e))throw Error("Cannot set value")}function iO(e){if(zn(e))throw Error("Pointer contains unsafe property key")}function Vx(e){for(const t of e)iO(t)}function aO(e){return/^(0|[1-9]\d*)$/.test(e)}function Wx(e){return[e.slice(0,e.length-1),e.slice(e.length-1)[0]]}function cO(e,t){return ee(t)&&C(t,e)}function lO(e,t){return ee(t)&&!zn(e)?t[e]:void 0}function vu(e,t){return e.reduce((n,r)=>lO(r,n),t)}function Qo(e){if(h(e.length,0))return[];const t=e.split("/").map(n=>n.replace(/~1/g,"/").replace(/~0/g,"~"));return t.length>0&&t[0]===""?t.slice(1):t}function uO(e,t){let n=e;return Qo(t).every(r=>cO(r,n)?(n=n[r],!0):!1)}function Jx(e,t){const n=Qo(t);return vu(n,e)}function kc(e,t,n){const r=Qo(t);Kx(r),Vx(r);const[s,o]=Wx(r),i=vu(s,e);return Gx(i),i[o]=n,e}function Qx(e,t){const n=Qo(t);Kx(n),Vx(n);const[r,s]=Wx(n),o=vu(r,e);return Gx(o),H(o)&&aO(s)?o.splice(+s,1):delete o[s],e}const Yx=Object.freeze(Object.defineProperty({__proto__:null,Delete:Qx,Get:Jx,Has:uO,Indices:Qo,Set:kc},Symbol.toStringTag,{value:"Module"}));function dO(e,t,n){if(e.$id===n.hash)return e;const r=new URL(e.$id,t.href),s=new URL(n.href,t.href);if(h(r.pathname,s.pathname))return n.hash.startsWith("#")?Xx(e,t,n):e}function fO(e,t,n){const r=new URL(`#${e.$anchor}`,t.href),s=new URL(n.href,t.href);return h(r.href,s.href)?e:void 0}function mO(e,t,n){const r=new URL(`#${e.$dynamicAnchor}`,t.href),s=new URL(n.href,t.href);return h(r.href,s.href)?e:void 0}function Xx(e,t,n){if(n.href.endsWith("#"))return e;if(!n.hash.startsWith("#"))return;const r=decodeURIComponent(n.hash.slice(1));if(r.startsWith("/"))return Jx(e,r)}function pO(e,t,n){if(kr(e)){const r=dO(e,t,n);if(!Pe(r))return r}if(Ai(e)){const r=fO(e,t,n);if(!Pe(r))return r}if(Kr(e)){const r=mO(e,t,n);if(!Pe(r))return r}return Xx(e,t,n)}function gO(e,t,n){return e.reduce((r,s)=>{const o=ju(s,t,n);return Pe(o)?r:o},void 0)}function hO(e,t,n){return D(e).reduce((r,s)=>{const o=ju(e[s],t,n);return Pe(o)?r:o},void 0)}function ju(e,t,n){const r=Xt(e)&&kr(e)?new URL(e.$id,t.href):t;if(Xt(e)){const s=pO(e,r,n);if(!Pe(s))return s}if(H(e))return gO(e,r,n);if(ee(e))return hO(e,r,n)}function Gr(e,t){const n=new URL("http://unknown/"),r=kr(e)?new URL(e.$id,n.href):n,s=new URL(t,r.href);return ju(e,r,s)}function Zx(e,t,n,r){const s=n.$dynamicRef.startsWith("#")?Gr(t,n.$dynamicRef):Gr(e,n.$dynamicRef);return Pe(s)?void 0:!Xt(s)||!Kr(s)||new URL(n.$dynamicRef,"http://unknown/").hash.startsWith("#/")?s:r.find(a=>a.$dynamicAnchor===s.$dynamicAnchor)??s}const bO=Object.freeze(Object.defineProperty({__proto__:null,DynamicRef:Zx,Ref:Gr},Symbol.toStringTag,{value:"Module"}));var xs=function(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)},fr,ek,tk,nk,rk;class Yo{constructor(t,n){fr.add(this),this.context=t,this.schema=n,this.ids=[],this.anchors=[],this.recursiveAnchors=[],this.dynamicAnchors=[]}BaseURL(){return this.ids.reduce((t,n)=>new URL(n.$id,t),new URL("http://unknown"))}Base(){return this.ids[this.ids.length-1]??this.schema}Push(t){Xt(t)&&(kr(t)&&(this.ids.push(t),xs(this,fr,"m",ek).call(this,t)),Ai(t)&&this.anchors.push(t),mi(t)&&this.recursiveAnchors.push(t),Kr(t)&&this.dynamicAnchors.push(t))}Pop(t){Xt(t)&&(kr(t)&&(this.ids.pop(),xs(this,fr,"m",tk).call(this,t)),Ai(t)&&this.anchors.pop(),mi(t)&&this.recursiveAnchors.pop(),Kr(t)&&this.dynamicAnchors.pop())}Ref(t){return xs(this,fr,"m",nk).call(this,t)??xs(this,fr,"m",rk).call(this,t)}RecursiveRef(t){return mi(this.Base())?Gr(this.recursiveAnchors[0],t.$recursiveRef):Gr(this.Base(),t.$recursiveRef)}DynamicRef(t){const n=this.schema;return Zx(n,this.Base(),t,this.dynamicAnchors)}}fr=new WeakSet,ek=function e(t,n=!0){if(!Xt(t))return;const r=t;if(!(!n&&kr(r))){!n&&Kr(r)&&this.dynamicAnchors.push(r);for(const s of D(r))xs(this,fr,"m",e).call(this,r[s],!1)}},tk=function e(t,n=!0){if(!Xt(t))return;const r=t;if(!(!n&&kr(r))){!n&&Kr(r)&&this.dynamicAnchors.pop();for(const s of D(r))xs(this,fr,"m",e).call(this,r[s],!1)}},nk=function(t){return C(this.context,t.$ref)?this.context[t.$ref]:void 0},rk=function(t){const n=this.schema;return t.$ref.startsWith("#")?Gr(this.Base(),t.$ref):Gr(n,t.$ref)};function xO(e){const t=e.Functions().join(`;
|
|
9
|
-
`),n=e.UseUnevaluated()?["const context = new CheckContext({}, {})",`return ${e.Entry()}`]:[`return ${e.Entry()}`];return`${t}; return (value) => { ${n.join("; ")} }`}function kO(e,t){return cm("CheckContext","Guard","Format","Hashing",e.External().identifier,t)(Fn,wi,TP,fS,e.External().variables)}function yO(e){const t=new Yo(e.Context(),e.Schema()),n=new Fn;return r=>ot(t,n,e.Schema(),r)}function wO(e,t){return am()?kO(e,t):yO(e)}class sk{constructor(t,n,r){this.isAccelerated=t,this.code=n,this.check=r}IsAccelerated(){return this.isAccelerated}Code(){return this.code}Check(t){return this.check(t)}}class ok{constructor(t,n,r,s,o,i){this.context=t,this.schema=n,this.external=r,this.functions=s,this.entry=o,this.useUnevaluated=i}Context(){return this.context}Schema(){return this.schema}UseUnevaluated(){return this.useUnevaluated}External(){return this.external}Functions(){return this.functions}Entry(){return this.entry}Evaluate(){const t=xO(this),n=wO(this,t);return new sk(am(),t,n)}}function ik(...e){const[t,n]=at(e,{2:(c,u)=>[c,u],1:c=>[{},c]});oh(),zx();const r=new Yo(t,n),s=new sh(rh(t,n)),o=Us(r,s,n,"value"),i=Hx(),a=ih();return new ok(t,n,a,i,o,s.UseUnevaluated())}function mo(...e){const[t,n,r]=at(e,{3:(f,p,g)=>[f,p,g],2:(f,p)=>[{},f,p]}),s=ko(),o=gS(),i=[],a=new Yo(t,n),c=new Ql(f=>{if(!js(i.length,s.maxErrors))return i.push({...f,message:o(f)})});return[St(a,c,"#","",n,r),i]}function Cu(...e){const[t,n,r]=at(e,{3:(i,a,c)=>[i,a,c],2:(i,a)=>[{},i,a]}),s=new Yo(t,n),o=new Fn;return ot(s,o,n,r)}let Tu=class{constructor(t,n,r){this.schema=t,this.value=n,this.errors=r}};function SO(...e){const[t,n,r]=at(e,{3:(s,o,i)=>[s,o,i],2:(s,o)=>[{},s,o]});if(!Cu(t,n,r)){const[s,o]=mo(t,n,r);throw new Tu(n,r,o)}return r}class ak{constructor(t,n){this.buildResult=ik(t,n),this.evaluateResult=this.buildResult.Evaluate()}IsAccelerated(){return this.evaluateResult.IsAccelerated()}Schema(){return this.buildResult.Schema()}Check(t){return this.evaluateResult.Check(t)}Parse(t){if(this.evaluateResult.Check(t))return t;const[n,r]=mo(this.buildResult.Context(),this.buildResult.Schema(),t);throw new Tu(this.buildResult.Schema(),t,r)}Errors(t){return mo(this.buildResult.Context(),this.buildResult.Schema(),t)}}function IO(...e){const[t,n]=at(e,{2:(r,s)=>[r,s],1:r=>[{},r]});return new ak(t,n)}const vO=Object.freeze(Object.defineProperty({__proto__:null,AccumulatedErrorContext:_n,Build:ik,BuildAdditionalItems:uh,BuildAdditionalProperties:hh,BuildAdditionalPropertiesFast:ph,BuildAdditionalPropertiesStandard:gh,BuildAllOf:kh,BuildAnyOf:Sh,BuildConst:Th,BuildContains:Ah,BuildContext:sh,BuildDependencies:Ph,BuildDependentRequired:Mh,BuildDependentSchemas:Dh,BuildEnum:Uh,BuildExclusiveMaximum:zh,BuildExclusiveMinimum:Kh,BuildFormat:wb,BuildIf:Ib,BuildItems:Cb,BuildMaxContains:Ab,BuildMaxItems:Rb,BuildMaxLength:Fb,BuildMaxProperties:Db,BuildMaximum:Pb,BuildMinContains:Ub,BuildMinItems:Kb,BuildMinLength:Vb,BuildMinProperties:Jb,BuildMinimum:zb,BuildMultipleOf:Yb,BuildNot:Zb,BuildOneOf:tx,BuildPattern:sx,BuildPatternProperties:ix,BuildPrefixItems:lx,BuildProperties:mx,BuildPropertyNames:hx,BuildRecursiveRef:kx,BuildRef:Sx,BuildRefine:ah,BuildRequired:jx,BuildResult:ok,BuildSchema:st,BuildSchemaBoolean:jh,BuildSchemaPushStack:En,BuildType:Ax,BuildUnevaluatedItems:Ox,BuildUnevaluatedProperties:Fx,BuildUniqueItems:Lx,CanAdditionalPropertiesFast:mh,Check:Cu,CheckAdditionalItems:dh,CheckAdditionalProperties:bh,CheckAllOf:yh,CheckAnyOf:Ih,CheckConst:eu,CheckContains:tu,CheckContext:Fn,CheckDependencies:Oh,CheckDependentRequired:Fh,CheckDependentSchemas:Lh,CheckEnum:nu,CheckExclusiveMaximum:ru,CheckExclusiveMinimum:su,CheckFormat:au,CheckIf:vb,CheckItems:Tb,CheckMaxContains:cu,CheckMaxItems:uu,CheckMaxLength:du,CheckMaxProperties:fu,CheckMaximum:lu,CheckMinContains:mu,CheckMinItems:gu,CheckMinLength:hu,CheckMinProperties:bu,CheckMinimum:pu,CheckMultipleOf:xu,CheckNot:ku,CheckOneOf:nx,CheckPattern:yu,CheckPatternProperties:ax,CheckPrefixItems:ux,CheckProperties:px,CheckPropertyNames:bx,CheckRecursiveRef:yx,CheckRef:Ix,CheckRefine:ch,CheckRequired:Cx,CheckSchema:ot,CheckSchemaBoolean:Zl,CheckSchemaPushStack:Nr,CheckType:$x,CheckUnevaluatedItems:Rx,CheckUnevaluatedProperties:_x,CheckUniqueItems:Bx,Compile:IO,CreateFunction:Us,CreateVariable:as,ErrorAdditionalItems:fh,ErrorAdditionalProperties:xh,ErrorAllOf:wh,ErrorAnyOf:vh,ErrorConst:Eh,ErrorContains:$h,ErrorContext:Ql,ErrorDependencies:Rh,ErrorDependentRequired:_h,ErrorDependentSchemas:Bh,ErrorEnum:qh,ErrorExclusiveMaximum:Hh,ErrorExclusiveMinimum:Gh,ErrorFormat:Sb,ErrorIf:jb,ErrorItems:Eb,ErrorMaxContains:$b,ErrorMaxItems:Mb,ErrorMaxLength:_b,ErrorMaxProperties:Lb,ErrorMaximum:Ob,ErrorMinContains:qb,ErrorMinItems:Gb,ErrorMinLength:Wb,ErrorMinProperties:Qb,ErrorMinimum:Hb,ErrorMultipleOf:Xb,ErrorNot:ex,ErrorOneOf:rx,ErrorPattern:ox,ErrorPatternProperties:cx,ErrorPrefixItems:dx,ErrorProperties:gx,ErrorPropertyNames:xx,ErrorRecursiveRef:wx,ErrorRef:vx,ErrorRefine:lh,ErrorRequired:Tx,ErrorSchema:St,ErrorSchemaBoolean:Ch,ErrorSchemaPushStack:Ar,ErrorType:Px,ErrorUnevaluatedItems:Mx,ErrorUnevaluatedProperties:Dx,ErrorUniqueItems:Ux,Errors:mo,EvaluateResult:sk,GetExternal:ih,GetFunctions:Hx,HasUnevaluated:rh,IsAdditionalItems:_o,IsAdditionalProperties:er,IsAllOf:sa,IsAnchor:Ai,IsAnyOf:oa,IsConst:ia,IsContains:ns,IsContentEncoding:k$,IsContentMediaType:y$,IsDefault:jr,IsDefs:w$,IsDependencies:Do,IsDependentRequired:Lo,IsDependentSchemas:Bo,IsDynamicAnchor:Kr,IsDynamicRef:aa,IsElse:ca,IsEnum:la,IsExclusiveMaximum:Uo,IsExclusiveMinimum:Cr,IsFormat:Rs,IsId:kr,IsIf:ua,IsItems:Tr,IsItemsSized:da,IsItemsUnsized:S$,IsMaxContains:zo,IsMaxItems:Ms,IsMaxLength:Ho,IsMaxProperties:Ko,IsMaximum:qo,IsMinContains:rs,IsMinItems:ss,IsMinLength:Fs,IsMinProperties:_s,IsMinimum:Er,IsMultipleOf:Go,IsNot:fa,IsOneOf:ma,IsPattern:Ds,IsPatternProperties:os,IsPrefixItems:tr,IsProperties:is,IsPropertyNames:Vo,IsRecursiveAnchor:nh,IsRecursiveAnchorTrue:mi,IsRecursiveRef:pa,IsRef:ga,IsRefine:ra,IsRequired:nr,IsSchema:Me,IsSchemaBoolean:Fo,IsSchemaObject:Xt,IsThen:ha,IsType:Wo,IsUnevaluatedItems:Ls,IsUnevaluatedProperties:Bs,IsUniqueItems:yr,Parse:SO,ParseError:Tu,Pointer:Yx,Reducer:Jo,ResetExternal:oh,ResetFunctions:zx,Resolve:bO,Stack:Yo,Validator:ak},Symbol.toStringTag,{value:"Module"}));function nt(...e){const[t,n,r]=at(e,{3:(s,o,i)=>[s,o,i],2:(s,o)=>[{},s,o]});return Cu(t,n,r)}function Xo(...e){const[t,n,r]=at(e,{3:(i,a,c)=>[i,a,c],2:(i,a)=>[{},i,a]}),[s,o]=mo(t,n,r);return o}class ba extends Error{constructor(t,n,r){super(t),Object.defineProperty(this,"cause",{value:{source:t,errors:r,value:n},writable:!1,configurable:!1,enumerable:!1})}}function ck(...e){const[t,n,r]=at(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});if(!nt(t,n,r))throw new ba("Assert",r,Xo(t,n,r))}function jO(e,t,n){return H(n)?n.map(r=>Sn(e,t.items,r)):n}function CO(e,t,n){return Sn({...e,...t.$defs},sn(t.$ref),n)}function TO(e,t){const n=C(t,"unevaluatedProperties")?{additionalProperties:t.unevaluatedProperties}:{},r=Os(e,t),s=Mn(r);return Fe(s)?Yg(s,n):s}function EO(e,t,n){const r=TO(e,t);return Sn(e,r,n)}function lk(e){return C(e,"additionalProperties")?e.additionalProperties:void 0}function NO(e,t,n){if(!ee(n)||H(n))return n;const r=lk(t);for(const s of D(n)){if(C(t.properties,s)){n[s]=Sn(e,t.properties[s],n[s]);continue}if(mt(r)&&h(r,!0)||Wt(r)&&nt(e,r,n[s])){n[s]=Sn(e,r,n[s]);continue}delete n[s]}return n}function AO(e,t,n){if(!ee(n))return n;const r=lk(t),[s,o]=[new RegExp(mn(t)),Lt(t)];for(const i of D(n)){if(s.test(i)){n[i]=Sn(e,o,n[i]);continue}if(mt(r)&&h(r,!0)||Wt(r)&&nt(e,r,n[i])){n[i]=Sn(e,r,n[i]);continue}delete n[i]}return n}function $O(e,t,n){return C(e,t.$ref)?Sn(e,e[t.$ref],n):n}function PO(e,t,n){if(!H(n))return n;const r=Math.min(n.length,t.items.length);for(let s=0;s<r;s++)n[s]=Sn(e,t.items[s],n[s]);return Vr(n.length,r)?n.slice(0,r):n}function Ft(e){return tl(e)}function OO(e,t,n){for(const r of t.anyOf){const s=Sn(e,r,Ft(n));if(nt(e,r,s))return s}return n}function Sn(e,t,n){return ut(t)?jO(e,t,n):Dt(t)?CO(e,t,n):_e(t)?EO(e,t,n):Fe(t)?NO(e,t,n):jt(t)?AO(e,t,n):gt(t)?$O(e,t,n):rt(t)?PO(e,t,n):le(t)?OO(e,t,n):n}function RO(e,t){for(const n of wi.Keys(e))wi.HasPropertyKey(t,n)||(t[n]=e[n]);return t}function MO(e){const t={};for(const n of wi.Keys(e))t[n]=po(e[n]);return t}function FO(e){return yc(b$(e))}function yc(e){return e.map(t=>po(t))}function po(e){const t=ut(e)?wr(po(e.items),sl(e)):_e(e)?$n(yc(e.allOf)):le(e)?Ge(FO(e.anyOf)):Fe(e)?Ae(MO(e.properties)):jt(e)?ml(Ji(e),po(Lt(e))):rt(e)?fn(yc(e.items)):e;return RO(e,t)}function Eu(e){return po(e)}function Zo(...e){const[t,n,r]=at(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]}),s=Eu(n);return Sn(t,s,r)}function tn(e){return ee(e)&&C(e,"value")}function Z(e){return{value:e}}function _O(e){return H(e)?Z(e):Z([e])}function DO(e){return h(e,!0)?Z(BigInt(1)):Z(BigInt(0))}const LO=/^-?(0|[1-9]\d*)n$/,BO=/^-?(0|[1-9]\d*)\.\d+$/,UO=/^-?(0|[1-9]\d*)$/;function qO(e){return LO.test(e)}function zO(e){return BO.test(e)}function HO(e){return UO.test(e)}function KO(e){const t=e.toLowerCase();return qO(e)?Z(BigInt(e.slice(0,e.length-1))):zO(e)?Z(BigInt(e.split(".")[0])):HO(e)?Z(BigInt(e)):h(t,"false")?Z(BigInt(0)):h(t,"true")?Z(BigInt(1)):void 0}function Nu(e){return et(e)?Z(e):mt(e)?DO(e):we(e)?Z(BigInt(Math.trunc(e))):Ht(e)?Z(BigInt(0)):ce(e)?KO(e):Pe(e)?Z(BigInt(0)):void 0}function GO(e){return h(e,BigInt(0))?Z(!1):h(e,BigInt(1))?Z(!0):void 0}function VO(e){return h(e,0)?Z(!1):h(e,1)?Z(!0):void 0}function WO(e){return h(e.toLowerCase(),"false")?Z(!1):h(e.toLowerCase(),"true")?Z(!0):h(e,"0")?Z(!1):h(e,"1")?Z(!0):void 0}function uk(e){return et(e)?GO(e):mt(e)?Z(e):we(e)?VO(e):Ht(e)?Z(!1):ce(e)?WO(e):Pe(e)?Z(!1):void 0}function JO(e){return h(e,BigInt(0))?Z(null):void 0}function QO(e){return h(e,!1)?Z(null):void 0}function YO(e){return h(e,0)?Z(null):void 0}function XO(e){const t=e.toLowerCase();return h(t,"undefined")||h(t,"null")||h(e,"")||h(e,"0")?Z(null):void 0}function ZO(e){return et(e)?JO(e):mt(e)?QO(e):we(e)?YO(e):Ht(e)?Z(null):ce(e)?XO(e):Pe(e)?Z(null):void 0}const dk=BigInt(Number.MAX_SAFE_INTEGER),fk=BigInt(Number.MIN_SAFE_INTEGER);function eR(e){return e<=dk&&e>=fk?Z(Number(e)):void 0}function tR(e){return Z(e?1:0)}function nR(e){const t=+e;if(we(t))return Z(t);const n=e.toLowerCase();if(h(n,"false"))return Z(0);if(h(n,"true"))return Z(1);const r=Nu(e);return tn(r)&&r.value<=dk&&r.value>=fk?Z(Number(r.value)):void 0}function Au(e){return et(e)?eR(e):mt(e)?tR(e):we(e)?Z(e):Ht(e)?Z(0):ce(e)?nR(e):Pe(e)?Z(0):void 0}function mk(e){return et(e)||mt(e)||we(e)?Z(e.toString()):Ht(e)?Z("null"):ce(e)?Z(e):Pe(e)?Z(""):void 0}function rR(e){return h(e,BigInt(0))?Z(void 0):void 0}function sR(e){return h(e,!1)?Z(void 0):void 0}function oR(e){return h(e,0)?Z(void 0):void 0}function iR(e){const t=e.toLowerCase();return h(t,"undefined")||h(t,"null")||h(e,"")||h(e,"0")?Z(void 0):void 0}function pk(e){return et(e)?rR(e):mt(e)?sR(e):we(e)?oR(e):Ht(e)?Z(void 0):ce(e)?iR(e):Pe(e)?Z(e):void 0}function aR(e,t,n){return _O(n).value.map(s=>pn(e,t.items,s))}function cR(e,t,n){const r=Nu(n);return tn(r)?r.value:n}function lR(e,t,n){const r=uk(n);return tn(r)?r.value:n}function uR(e,t,n){return pn({...e,...t.$defs},sn(t.$ref),n)}function dR(e,t,n){return pn(e,Mn(t),n)}function fR(e,t,n){const r=Au(n);return tn(r)?Math.trunc(r.value):n}function mR(e,t,n){const r=Os(e,t),s=Mn(r);return pn(e,s,n)}function pR(e,t,n){const r=Nu(n);return tn(r)&&h(t.const,r.value)?r.value:n}function gR(e,t,n){const r=uk(n);return tn(r)&&h(t.const,r.value)?r.value:n}function hR(e,t,n){const r=Au(n);return tn(r)&&h(t.const,r.value)?r.value:n}function bR(e,t,n){const r=mk(n);return tn(r)&&h(t.const,r.value)?r.value:n}function xR(e,t,n){return h(t.const,n)?n:TS(t)?pR(e,t,n):ES(t)?gR(e,t,n):xm(t)?hR(e,t,n):km(t)?bR(e,t,n):Nt()}function kR(e,t,n){const r=ZO(n);return tn(r)?r.value:n}function yR(e,t,n){const r=Au(n);return tn(r)?r.value:n}function gk(e,t,n,r){const s=D(r);for(const[o,i]of t)for(const a of s)o.test(a)||(r[a]=pn(e,n,r[a]));return r}function $u(e,t,n){return Jt(e)&&Pe(n[t])}function wR(e,t,n){const r=Jc(t.properties),s=D(n);for(const[o,i]of r)for(const a of s)!o.test(a)||$u(i,a,n)||(n[a]=pn(e,i,n[a]));return C(t,"additionalProperties")&&ee(t.additionalProperties)?gk(e,r,t.additionalProperties,n):n}function SR(e,t,n){return an(n)?wR(e,t,n):n}function IR(e,t,n){const r=Jc(t.patternProperties),s=D(n);for(const[o,i]of r)for(const a of s)o.test(a)&&(n[a]=pn(e,i,n[a]));return C(t,"additionalProperties")&&ee(t.additionalProperties)?gk(e,r,t.additionalProperties,n):n}function vR(e,t,n){return an(n)?IR(e,t,n):n}function jR(e,t,n){return C(e,t.$ref)?pn(e,e[t.$ref],n):n}function CR(e,t,n){const r=mk(n);return tn(r)?r.value:n}function TR(e,t,n){return pn(e,Mn(t),n)}function ER(e,t,n){if(!H(n))return n;for(let r=0;r<Math.min(t.items.length,n.length);r++)n[r]=pn(e,t.items[r],n[r]);return n}function NR(e,t,n){const r=pk(n);return tn(r)?r.value:n}function AR(e,t,n){if(t.anyOf.some(i=>nt(e,i,n)))return n;const o=t.anyOf.map(i=>pn(e,i,Ft(n))).find(i=>nt(e,t,i));return Pe(o)?n:o}function $R(e,t,n){const r=pk(n);return tn(r)?void 0:n}function pn(e,t,n){return ut(t)?aR(e,t,n):Yr(t)?cR(e,t,n):Sr(t)?lR(e,t,n):Dt(t)?uR(e,t,n):dn(t)?dR(e,t,n):On(t)?fR(e,t,n):_e(t)?mR(e,t,n):Ve(t)?xR(e,t,n):vo(t)?kR(e,t,n):Zt(t)?yR(e,t,n):Fe(t)?SR(e,t,n):jt(t)?vR(e,t,n):gt(t)?jR(e,t,n):Tn(t)?CR(e,t,n):Bt(t)?TR(e,t,n):rt(t)?ER(e,t,n):$s(t)?NR(e,t,n):le(t)?AR(e,t,n):Xr(t)?$R(e,t,n):n}function xa(...e){const[t,n,r]=at(e,{3:(s,o,i)=>[s,o,i],2:(s,o)=>[{},s,o]});return pn(t,n,r)}function PR(e,t,n){if(!H(n))return n;for(let r=0;r<n.length;r++)n[r]=In(e,t.items,n[r]);return n}function OR(e,t,n){return In({...e,...t.$defs},sn(t.$ref),n)}function RR(e,t){return Pe(t)?kn(e.default)?e.default():Ft(e.default):t}function MR(e,t,n){const r=Os(e,t),s=Mn(r);return In(e,s,n)}function FR(e,t,n){if(!ee(n))return n;const r=D(t.properties);for(const s of r){const o=In(e,t.properties[s],n[s]);Pe(o)&&(Jt(t.properties[s])||!C(t.properties[s],"default"))||(n[s]=o)}if(!er(t)||mt(t.additionalProperties))return n;for(const s of D(n))r.includes(s)||(n[s]=In(e,t.additionalProperties,n[s]));return n}function _R(e,t,n){if(!ee(n))return n;const[r,s]=[new RegExp(mn(t)),Lt(t)];for(const o of D(n))r.test(o)&&jr(s)&&(n[o]=In(e,s,n[o]));if(!er(t))return n;for(const o of D(n))r.test(o)||(n[o]=In(e,t.additionalProperties,n[o]));return n}function DR(e,t,n){return C(e,t.$ref)?In(e,e[t.$ref],n):n}function LR(e,t,n){if(!H(n))return n;const[r,s]=[t.items,Math.max(t.items.length,n.length)];for(let o=0;o<s;o++)o<r.length&&(n[o]=In(e,r[o],n[o]));return n}function BR(e,t,n){for(const r of t.anyOf){const s=In(e,r,Ft(n));if(nt(e,r,s))return s}return n}function In(e,t,n){const r=jr(t)?RR(t,n):n;return ut(t)?PR(e,t,r):Dt(t)?OR(e,t,r):_e(t)?MR(e,t,r):Fe(t)?FR(e,t,r):jt(t)?_R(e,t,r):gt(t)?DR(e,t,r):rt(t)?LR(e,t,r):le(t)?BR(e,t,r):r}function Pu(...e){const[t,n,r]=at(e,{3:(s,o,i)=>[s,o,i],2:(s,o)=>[{},s,o]});return In(t,n,r)}function hk(e){return(...t)=>{const[n,r,s]=at(t,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return e.reduce((o,i)=>i(n,r,o),s)}}function UR(e,t,n){return t["~codec"].decode(n)}function qR(e,t,n){return t["~codec"].encode(n)}function yt(e,t,n,r){return Yt(n)?h(e,"Decode")?UR(t,n,r):qR(t,n,r):r}function zR(e,t,n,r){if(!H(r))return r;for(let s=0;s<r.length;s++)r[s]=Ot(e,t,n.items,r[s]);return yt(e,t,n,r)}function HR(e,t,n,r){const s=yt(e,t,n,r);if(!H(s))return s;for(let o=0;o<s.length;o++)s[o]=Ot(e,t,n.items,s[o]);return s}function KR(e,t,n,r){return h(e,"Decode")?zR(e,t,n,r):HR(e,t,n,r)}function GR(e,t,n,r){return r=Ot(e,{...t,...n.$defs},sn(n.$ref),r),yt(e,t,n,r)}function bk(e){return e.reduce((t,n)=>({...t,...n}),{})}function xk(e,t){for(const n of t)if(!Wr(e,n))return n;return e}function VR(e,t,n,r){if(h(n.allOf.length,0))return yt(e,t,n,r);const s=n.allOf.map(a=>Ot(e,t,a,Zo(a,Ft(r)))),i=s.every(a=>ee(a))?bk(s):xk(r,s);return yt(e,t,n,i)}function WR(e,t,n,r){if(h(n.allOf.length,0))return yt(e,t,n,r);const s=yt(e,t,n,r),o=n.allOf.map(a=>Ot(e,t,a,Zo(a,Ft(s))));return o.every(a=>ee(a))?bk(o):xk(s,o)}function JR(e,t,n,r){return h(e,"Decode")?VR(e,t,n,r):WR(e,t,n,r)}function QR(e,t,n,r){if(!an(r))return r;for(const s of D(n.properties))!C(r,s)||$u(n.properties[s],s,r)||(r[s]=Ot(e,t,n.properties[s],r[s]));return yt(e,t,n,r)}function YR(e,t,n,r){const s=yt(e,t,n,r);if(!an(s))return s;for(const o of D(n.properties))!C(s,o)||$u(n.properties[o],o,s)||(s[o]=Ot(e,t,n.properties[o],s[o]));return s}function XR(e,t,n,r){return h(e,"Decode")?QR(e,t,n,r):YR(e,t,n,r)}function ZR(e,t,n,r){if(!an(r))return r;const s=new RegExp(mn(n));for(const o of D(r))s.test(o)&&(r[o]=Ot(e,t,Lt(n),r[o]));return yt(e,t,n,r)}function eM(e,t,n,r){const s=yt(e,t,n,r);if(!an(s))return s;const o=new RegExp(mn(n));for(const i of D(s))o.test(i)&&(s[i]=Ot(e,t,Lt(n),s[i]));return s}function tM(e,t,n,r){return h(e,"Decode")?ZR(e,t,n,r):eM(e,t,n,r)}function Bd(e,t,n,r){return C(t,n.$ref)?Ot(e,t,t[n.$ref],r):r}function nM(e,t,n,r){return h(e,"Decode")?yt(e,t,n,Bd(e,t,n,r)):Bd(e,t,n,yt(e,t,n,r))}function rM(e,t,n,r){if(!H(r))return r;for(let s=0;s<Math.min(n.items.length,r.length);s++)r[s]=Ot(e,t,n.items[s],r[s]);return yt(e,t,n,r)}function sM(e,t,n,r){const s=yt(e,t,n,r);if(!H(s))return r;for(let o=0;o<Math.min(n.items.length,s.length);o++)s[o]=Ot(e,t,n.items[o],s[o]);return s}function oM(e,t,n,r){return h(e,"Decode")?rM(e,t,n,r):sM(e,t,n,r)}function iM(e,t,n,r){for(const s of n.anyOf){if(!nt(t,s,r))continue;const o=Ot(e,t,s,r);return yt(e,t,n,o)}return r}function aM(e,t,n,r){const s=yt(e,t,n,r);for(const o of n.anyOf){const i=Ot(e,t,o,Ft(s));if(nt(t,o,i))return i}return s}function cM(e,t,n,r){return h(e,"Decode")?iM(e,t,n,r):aM(e,t,n,r)}function Ot(e,t,n,r){return ut(n)?KR(e,t,n,r):Dt(n)?GR(e,t,n,r):_e(n)?JR(e,t,n,r):Fe(n)?XR(e,t,n,r):jt(n)?tM(e,t,n,r):gt(n)?nM(e,t,n,r):rt(n)?oM(e,t,n,r):le(n)?cM(e,t,n,r):yt(e,t,n,r)}class lM extends ba{constructor(t,n){super("Decode",t,n)}}function uM(e,t,n){if(!nt(e,t,n))throw new lM(n,Xo(e,t,n));return n}function dM(e,t,n){const r=Eu(t);return Ot("Decode",e,r,n)}const fM=hk([(e,t,n)=>Ft(n),(e,t,n)=>Pu(e,t,n),(e,t,n)=>xa(e,t,n),(e,t,n)=>Zo(e,t,n),(e,t,n)=>uM(e,t,n),(e,t,n)=>dM(e,t,n)]);function mM(...e){const[t,n,r]=at(e,{3:(s,o,i)=>[s,o,i],2:(s,o)=>[{},s,o]});return fM(t,n,r)}class pM extends ba{constructor(t,n){super("Encode",t,n)}}function gM(e,t,n){if(!nt(e,t,n))throw new pM(n,Xo(e,t,n));return n}function hM(e,t,n){const r=Eu(t);return Ot("Encode",e,r,n)}const bM=hk([(e,t,n)=>Ft(n),(e,t,n)=>hM(e,t,n),(e,t,n)=>Pu(e,t,n),(e,t,n)=>xa(e,t,n),(e,t,n)=>Zo(e,t,n),(e,t,n)=>gM(e,t,n)]);function xM(...e){const[t,n,r]=at(e,{3:(s,o,i)=>[s,o,i],2:(s,o)=>[{},s,o]});return bM(t,n,r)}function kM(e,t){return Yt(t)||$r(e,t.items)}function yM(e,t){return Yt(t)||kk({...e,...t.$defs},sn(t.$ref))}function wM(e,t){return Yt(t)||t.allOf.some(n=>$r(e,n))}function SM(e,t){return Yt(t)||D(t.properties).some(n=>$r(e,t.properties[n]))}function IM(e,t){return Yt(t)||$r(e,Lt(t))}function kk(e,t){return wc.has(t.$ref)?!1:(wc.add(t.$ref),Yt(t)||C(e,t.$ref)&&$r(e,e[t.$ref]))}function vM(e,t){return Yt(t)||t.items.some(n=>$r(e,n))}function jM(e,t){return Yt(t)||t.anyOf.some(n=>$r(e,n))}function $r(e,t){return ut(t)?kM(e,t):Dt(t)?yM(e,t):_e(t)?wM(e,t):Fe(t)?SM(e,t):jt(t)?IM(e,t):gt(t)?kk(e,t):rt(t)?vM(e,t):le(t)?jM(e,t):Yt(t)}const wc=new Set;function CM(...e){const[t,n]=at(e,{2:(r,s)=>[r,s],1:r=>[{},r]});return wc.clear(),$r(t,n)}class ei extends Error{constructor(t,n){super(n),this.type=t}}function TM(e,t){return kn(t.default)?t.default(t):ee(t.default)?Ft(t.default):t.default}function EM(e,t){if(yr(t)&&!jr(t))throw new ei(t,"Arrays with uniqueItems constraints must specify a default annotation");const n=ss(t)?t.minItems:0;return Array.from({length:n},()=>gn(e,t.items))}function NM(e,t){return Cr(t)?BigInt(t.exclusiveMinimum)+BigInt(1):Er(t)?BigInt(t.minimum):BigInt(0)}function AM(e,t){return!1}function $M(e,t){const n=gn(e,t.instanceType);return class{constructor(){Object.assign(this,n)}}}function PM(e,t){return gn({...e,...t.$defs},sn(t.$ref))}function OM(e,t){return gn(e,Mn(t))}function RM(e,t){const n=gn(e,t.returnType);return()=>n}function MM(e,t){return Cr(t)&&we(t.exclusiveMinimum)?t.exclusiveMinimum+1:Er(t)?t.minimum:0}function FM(e,t){const n=Os(e,t),r=Mn(n);return gn(e,r)}function _M(e,t){return t.const}function DM(e,t){throw new ei(t,"Cannot create TNever types")}function LM(e,t){return null}function BM(e,t){return Cr(t)&&we(t.exclusiveMinimum)?t.exclusiveMinimum+1:Er(t)?t.minimum:0}function UM(e,t){return(Pe(t.required)?[]:t.required).reduce((r,s)=>({...r,[s]:gn(e,t.properties[s])}),{})}function qM(e,t){if(_s(t)&&!jr(t))throw new ei(t,"Record with the minProperties constraint must have a default annotation");return{}}function zM(e,t){return C(e,t.$ref)?gn(e,e[t.$ref]):(()=>{throw new ei(t,"Unable to deref Ref")})()}function HM(e,t){if((Ds(t)||Rs(t))&&!jr(t))throw Error("Strings with format or pattern constraints must specify default");const r=Fs(t)?t.minLength:0;return"".padEnd(r)}function KM(e,t){return Symbol()}function GM(e,t){const n=fl(t.pattern);if(Tn(n))throw new ei(t,"Unable to create TemplateLiteral due to infinite type expansion");return gn(e,n)}function VM(e,t){return Array.from({length:t.minItems},(n,r)=>gn(e,t.items[r]))}function WM(e,t){if(h(t.anyOf.length,0))throw Error("Unable to create Union with no variants");return gn(e,t.anyOf[0])}function gn(e,t){return jr(t)?TM(e,t):ut(t)?EM(e,t):Yr(t)?NM(e,t):Sr(t)?AM():cn(t)?$M(e,t):Dt(t)?PM(e,t):dn(t)?OM(e,t):ln(t)?RM(e,t):On(t)?MM(e,t):_e(t)?FM(e,t):Ve(t)?_M(e,t):Es(t)?DM(e,t):vo(t)?LM():Zt(t)?BM(e,t):Fe(t)?UM(e,t):jt(t)?qM(e,t):gt(t)?zM(e,t):Tn(t)?HM(e,t):jo(t)?KM():Bt(t)?GM(e,t):rt(t)?VM(e,t):$s(t)?void 0:le(t)?WM(e,t):Xr(t)?void 0:void 0}function vn(...e){const[t,n]=at(e,{2:(r,s)=>[r,s],1:r=>[{},r]});return gn(t,n)}function yk(e,t){return Wr(e,t)}function wk(e){return Hi(e)}class JM extends ba{constructor(t,n){super("Parse",t,n)}}function QM(...e){const[t,n,r]=at(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});if(nt(t,n,r))return r;throw new JM(r,Xo(t,n,r))}function ka(e,t){return{type:"update",path:e,value:t}}function Sk(e,t){return{type:"insert",path:e,value:t}}function Ik(e){return{type:"delete",path:e}}function Ud(e){if(!(ee(e)&&h(Qc(e).length,0)))throw new Error("Cannot create diffs for objects with symbols keys")}function*YM(e,t,n){if(!ee(n)||H(n))return yield ka(e,n);Ud(t),Ud(n);const r=D(t),s=D(n);for(const o of s)C(t,o)||zn(o)||(yield Sk(`${e}/${o}`,n[o]));for(const o of r)C(n,o)&&(zn(o)||yk(t,n)||(yield*ya(`${e}/${o}`,t[o],n[o])));for(const o of r)C(n,o)||zn(o)||(yield Ik(`${e}/${o}`))}function*XM(e,t,n){if(!H(n))return yield ka(e,n);for(let r=0;r<Math.min(t.length,n.length);r++)yield*ya(`${e}/${r}`,t[r],n[r]);for(let r=0;r<n.length;r++)r<t.length||(yield Sk(`${e}/${r}`,n[r]));for(let r=t.length-1;r>=0;r--)r<n.length||(yield Ik(`${e}/${r}`))}function*ZM(e,t,n){const r=globalThis.Object.getPrototypeOf(t).constructor.name,s=globalThis.Object.getPrototypeOf(n).constructor.name;if(xo(n)&&h(t.length,n.length)&&h(r,s))for(let i=0;i<Math.min(t.length,n.length);i++)yield*ya(`${e}/${i}`,t[i],n[i]);else return yield ka(e,n)}function*eF(e,t,n){t!==n&&(yield ka(e,n))}function*ya(e,t,n){return xo(t)?yield*ZM(e,t,n):H(t)?yield*XM(e,t,n):ee(t)?yield*YM(e,t,n):yield*eF(e,t,n)}function tF(e,t){return[...ya("",e,t)]}const nF=Ae({type:Re("insert"),path:Rn(),value:_t()}),rF=Object({type:Re("update"),path:Rn(),value:_t()}),sF=Ae({type:Re("delete"),path:Rn()});Ge([nF,rF,sF]);function oF(e){return e.length>0&&e[0].path===""&&e[0].type==="update"}function iF(e){return e.length===0}function aF(e,t){if(oF(t))return Ft(t[0].value);if(iF(t))return Ft(e);const n=Ft(e);for(const r of t)switch(r.type){case"insert":{kc(n,r.path,r.value);break}case"update":{kc(n,r.path,r.value);break}case"delete":{Qx(n,r.path);break}}return n}class wa extends Error{constructor(t,n,r,s){super(s),this.context=t,this.type=n,this.value=r}}function cF(e){const[t,n]=[new Set,[]];for(const r of e){const s=wk(r);t.has(s)||(t.add(s),n.push(r))}return n}function lF(e,t,n){if(nt(e,t,n))return n;const r=H(n)?n:vn(e,t),s=ss(t)&&r.length<t.minItems?[...r,...Array.from({length:t.minItems-r.length},()=>vn(e,t))]:r,i=(Ms(t)&&s.length>t.maxItems?s.slice(0,t.maxItems):s).map(c=>on(e,t.items,c));if(!yr(t)||yr(t)&&!h(t.uniqueItems,!0))return i;const a=cF(i);if(!nt(e,t,a))throw new wa(e,t,n,"Failed to repair Array due to uniqueItems constraint");return a}function uF(e,t,n){return on(e,Mn(t),n)}function dF(e,t,n){const r=Os(e,t),s=Mn(r);return on(e,s,n)}function fF(e,t,n){if(nt(e,t,n))return n;if(!an(n))return vn(e,t);const r=new Set(Pe(t.required)?[]:t.required),s={};for(const[i,a]of tt(t.properties))!r.has(i)&&Pe(n[i])||(s[i]=i in n?on(e,a,n[i]):vn(e,a));const o=D(t.properties);if(er(t)&&ee(t.additionalProperties))for(const i of D(n))o.includes(i)||(s[i]=on(e,t.additionalProperties,n[i]));return s}function mF(e,t,n){if(nt(e,t,n))return n;if(Ht(n)||!ee(n)||H(n))return vn(e,t);const r=new RegExp(mn(t)),s=Lt(t),o=new Set,i={};for(const[a,c]of tt(n))r.test(a)&&(i[a]=on(e,s,c),o.add(a));if(er(t))for(const a of D(n))o.has(a)||(i[a]=on(e,t.additionalProperties,n[a]));return i}function pF(e,t,n){return C(e,t.$ref)?on(e,e[t.$ref],n):(()=>{throw new wa(e,t,n,"Unable to de-reference target type")})()}function gF(e,t,n){const r=fl(t.pattern);return on(e,r,n)}function hF(e,t,n){return nt(e,t,n)?n:H(n)?t.items.map((r,s)=>on(e,r,n[s])):vn(e,t)}function vk(e,t,n){return gt(t)?C(e,t.$ref)?vk(e,e[t.$ref]):(()=>{throw new Error("Unable to Deref target")})():t}function bF(e,t,n){if(!(Fe(t)&&ee(n)))return 0;const r=D(n);return tt(t.properties).reduce((o,[i,a])=>{const c=Ve(a)&&h(a.const,n[i])?100:0,u=nt(e,a,n[i])?10:0,f=r.includes(i)?1:0;return o+(c+u+f)},0)}function xF(e,t,n){const r=t.anyOf.map(i=>vk(e,i));let[s,o]=[r[0],0];for(const i of r){const a=bF(e,i,n);a>o&&(s=i,o=a)}return s}function kF(e,t,n){const r=Ge(Gi(t.anyOf)),s=xF(e,r,n);return on(e,s,n)}function yF(e,t,n){return nt(e,t,n)?Ft(n):jr(t)?vn(e,t):kF(e,t,n)}function wF(e,t,n){if(nt(e,t,n))return n;const r=xa(e,t,n);return nt(e,t,r)?r:vn(e,t)}function SF(e,t,n){if(tm(n)||rm(n)||nm(n)||xo(n)||Bi(n)||kn(n))throw new wa(e,t,n,"Value is not repairable")}function IF(e,t,n){if(cn(t)||ln(t)||Es(t))throw new wa(e,t,n,"Type is not repairable")}function vF(e,t,n){return Pe(n)&&!$s(t)?vn(e,t):n}function jF(e,t,n){return cl(t)?nt(e,t,n)?n:vn(e,t):n}function on(e,t,n){SF(e,t,n),IF(e,t,n);const r=vF(e,t,n),s=ut(t)?lF(e,t,r):dn(t)?uF(e,t,r):_e(t)?dF(e,t,r):Fe(t)?fF(e,t,r):jt(t)?mF(e,t,r):gt(t)?pF(e,t,r):Bt(t)?gF(e,t,r):rt(t)?hF(e,t,r):le(t)?yF(e,t,r):wF(e,t,r);return jF(e,t,s)}function CF(...e){const[t,n,r]=at(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]}),s=on(t,n,r);return ck(t,n,s),s}const qa=Object.freeze(Object.defineProperty({__proto__:null,Assert:ck,Check:nt,Clean:Zo,Clone:Ft,Convert:xa,Create:vn,Decode:mM,Default:Pu,Diff:tF,Encode:xM,Equal:yk,Errors:Xo,HasCodec:CM,Hash:wk,Parse:QM,Patch:aF,Pointer:Yx,Repair:CF},Symbol.toStringTag,{value:"Module"}));class qd extends Error{constructor(t){super(t.map(n=>`${n.path.length>0?n.path.join("."):"root"}: ${n.message}`).join("; ")),this.issues=t,this.name="SchemaValidationError"}}function TF(e){return e?e.split("/").slice(1).map(t=>t.replace(/~1/g,"/").replace(/~0/g,"~")).map(t=>/^(0|[1-9]\d*)$/.test(t)?Number(t):t):[]}function EF(e,t){let n=e;for(const r of t){if(n===null||typeof n!="object")return;n=n[r]}return n}function zd(e,t){const[,n]=vO.Errors(e,t);return n.map(r=>{const s=TF(r.instancePath);return{code:r.keyword,path:s,message:r.message,value:EF(t,s)}})}function jk(e,t){const n=qa.Default(e,qa.Clone(t)),r=zd(e,n);if(r.length>0)return{success:!1,error:new qd(r)};const s=qa.Clean(e,n),o=zd(e,s);return o.length>0?{success:!1,error:new qd(o)}:{success:!0,data:s}}function ur(e,t){const n=jk(e,t);if(!n.success)throw n.error;return n.data}function X(e){return Object.defineProperties(e,{parse:{value:t=>ur(e,t),enumerable:!1},safeParse:{value:t=>jk(e,t),enumerable:!1}}),e}function Oi(e,t){return m.Optional({...e,default:t})}function Ce(e,t={}){return m.Unsafe({type:"string",enum:[...e],...t})}const Br=20,oo=5*1024*1024,NF=32e3,Ou=X(Ce(["default","autoEdit","yolo","plan"])),hi={DEFAULT:"default",AUTO_EDIT:"autoEdit",PLAN:"plan"},Ru=X(Ce(["user","assistant","system","tool"])),AF=X(m.Union([m.Object({type:m.Literal("text"),text:m.String()}),m.Object({type:m.Literal("image_url"),image_url:m.Object({url:m.String()})})])),Ck=m.Union([m.String(),m.Array(AF)]);X(m.Object({id:m.String(),role:Ru,content:Ck,timestamp:m.Number(),metadata:m.Optional(m.Record(m.String(),m.Unknown())),thinkingContent:m.Optional(m.String()),tool_call_id:m.Optional(m.String()),name:m.Optional(m.String()),tool_calls:m.Optional(m.Unknown())}));const $F=X(Ce(["queued","running","completed","failed","cancelled","interrupted"])),Tk=X(Ce(["local","worktree"])),PF=X(Ce(["applied","discarded","conflicted"])),OF=X(m.Object({status:PF,updatedAt:m.String(),sourceCommit:m.Optional(m.String()),changedFiles:m.Optional(m.Integer({minimum:0})),message:m.Optional(m.String())})),RF=X(m.Object({changedFiles:m.Integer({minimum:0}),additions:m.Integer({minimum:0}),deletions:m.Integer({minimum:0}),commits:m.Integer({minimum:0})})),MF=X(m.Object({path:m.String({minLength:1}),patch:m.String({maxLength:2*1024*1024}),additions:m.Integer({minimum:0}),deletions:m.Integer({minimum:0}),binary:m.Boolean(),truncated:m.Boolean()})),FF=X(m.Object({sessionId:m.String(),projectPath:m.String(),baseCommit:m.String(),files:m.Array(MF,{maxItems:100}),truncated:m.Boolean()})),_F=m.Union([m.String(),m.Number(),m.Boolean(),m.Array(m.String())]),DF=X(m.Object({name:m.String(),type:Ce(["string","number","integer","boolean","select","multi-select"]),title:m.String(),description:m.Optional(m.String()),required:m.Boolean(),defaultValue:m.Optional(_F),options:m.Optional(m.Array(m.Object({value:m.String(),label:m.String()}))),format:m.Optional(Ce(["date","uri","email","date-time"])),minimum:m.Optional(m.Number()),maximum:m.Optional(m.Number()),minLength:m.Optional(m.Number()),maxLength:m.Optional(m.Number()),minItems:m.Optional(m.Number()),maxItems:m.Optional(m.Number())}));X(m.Object({serverName:m.String(),mode:Ce(["form","url"]),message:m.String(),fields:m.Optional(m.Array(DF)),requestedSchema:m.Optional(m.Record(m.String(),m.Unknown())),url:m.Optional(m.String()),domain:m.Optional(m.String()),elicitationId:m.Optional(m.String())}));const LF=X(m.Object({type:Ce(["permission","question","elicitation"]),requestId:m.String()})),BF=X(m.Object({code:Ce(["authentication","permission","rate_limit","timeout","network","model_unavailable","context_limit","unsupported_input","runtime"]),message:m.String({minLength:1,maxLength:500}),retryable:m.Boolean()})),Mu=X(Ce(["auto","off","minimal","low","medium","high","xhigh","max"])),Fu=X(Ce(["auto","standard","fast","flex"])),_u=X(Ce(["auto","low","medium","high"])),Sa=X(m.Union([Ce(["auto","pragmatic","friendly","explanatory"]),m.String({minLength:7,maxLength:300,pattern:"^(?:(?:user|project):[a-z0-9][a-z0-9._-]{0,63}(?::[a-z0-9][a-z0-9._-]{0,63}){0,3}|plugin:[a-z0-9][a-z0-9._-]{0,63}:[a-z0-9][a-z0-9._-]{0,63}(?::[a-z0-9][a-z0-9._-]{0,63}){0,3})$"})])),Kn=X(m.Object({sessionId:m.String(),projectPath:m.String(),title:m.Optional(m.String()),gitBranch:m.Optional(m.String()),rootId:m.String(),parentId:m.Optional(m.String()),relationType:m.Optional(Ce(["subagent","fork"])),resumedFrom:m.Optional(m.String()),rootAgentId:m.Optional(m.String()),resumeDepth:m.Optional(m.Integer({minimum:0})),taskStatus:Oi($F,"completed"),taskStatusReason:m.Optional(m.String()),taskFailure:m.Optional(BF),taskStartedAt:m.Optional(m.String()),taskCompletedAt:m.Optional(m.String()),taskPromptSummary:m.Optional(m.String()),taskModelId:m.Optional(m.String()),selectedModelId:m.Optional(m.String()),reasoningEffort:m.Optional(Mu),serviceTier:m.Optional(Fu),responseVerbosity:m.Optional(_u),communicationStyle:m.Optional(Sa),communicationStyleDigest:m.Optional(m.String({pattern:"^[a-f0-9]{64}$"})),projectInstructionsDigest:m.Optional(m.String({pattern:"^[a-f0-9]{64}$"})),taskRetryAvailable:m.Optional(m.Boolean()),taskRetriedFrom:m.Optional(m.Object({sessionId:m.String(),projectPath:m.String()})),taskDelivery:m.Optional(OF),taskIsolation:m.Optional(Tk),taskSourceProjectPath:m.Optional(m.String()),taskWorktreePath:m.Optional(m.String()),taskWorktreeBranch:m.Optional(m.String()),taskBaseCommit:m.Optional(m.String()),taskDiffStat:m.Optional(RF),taskQueuePosition:m.Optional(m.Integer({minimum:1})),taskQueueDepth:m.Optional(m.Integer({minimum:0})),taskConcurrencyLimit:m.Optional(m.Integer({minimum:1})),archivedAt:m.Optional(m.String()),archivedBySessionId:m.Optional(m.String()),pendingInteraction:m.Optional(LF),messageCount:m.Number(),firstMessageTime:m.String(),lastMessageTime:m.String(),hasErrors:m.Boolean()})),UF=X(m.Object({sessions:m.Array(Kn),nextCursor:m.Optional(m.String())})),qF=X(m.Object({session:Kn,archivedSessionIds:m.Array(m.String())})),zF=X(m.Object({session:Kn,restoredSessionIds:m.Array(m.String())}));X(m.Object({version:m.Literal(1),sessionId:m.String(),goalId:m.String(),objective:m.String(),status:Ce(["active","paused","blocked","usage_limited","budget_limited","complete"]),tokenBudget:m.Optional(m.Number()),tokensUsed:m.Number(),timeUsedSeconds:m.Number(),continuationCount:m.Number(),statusReason:m.Optional(m.String()),createdAt:m.String(),updatedAt:m.String()}));const Du=X(m.Object({role:Ru,content:Ck,metadata:m.Optional(m.Unknown()),reasoningContent:m.Optional(m.String()),thinkingContent:m.Optional(m.String()),tool_call_id:m.Optional(m.String()),name:m.Optional(m.String()),tool_calls:m.Optional(m.Unknown())})),HF=X(m.Object({session:Kn,messages:m.Array(Du)})),Ek=X(Ce(["conversation","code","both"])),Nk=X(m.Object({messageId:m.String(),preview:m.String(),createdAt:m.String(),fileCount:m.Integer({minimum:0})}));X(m.Object({targetMessageId:m.String({minLength:1}),mode:Oi(Ek,"conversation")}));const KF=X(m.Object({checkpoint:Nk,mode:Ek,removedTurns:m.Integer({minimum:1}),restoredFiles:m.Array(m.String()),messages:m.Array(Du)})),GF=Ce(["running","completed","failed","cancelled"]),Sc=X(m.Object({id:m.String(),subagentType:m.String(),description:m.String(),status:GF,rootAgentId:m.String(),resumedFrom:m.Optional(m.String()),resumeDepth:m.Integer({minimum:0}),createdAt:m.Number(),lastActiveAt:m.Number(),completedAt:m.Optional(m.Number()),result:m.Optional(m.Object({success:m.Boolean(),message:m.String(),error:m.Optional(m.String()),verificationCommands:m.Optional(m.Array(m.String()))})),stats:m.Optional(m.Object({tokens:m.Optional(m.Number()),toolCalls:m.Optional(m.Number()),duration:m.Optional(m.Number())}))}));X(m.Object({prompt:m.String({minLength:1,maxLength:32e3,pattern:"\\S"})}));const VF=X(m.Object({source:Sc,session:Sc})),Ak=X(m.Object({sessionId:m.String(),projectPath:m.String()})),$k=X(m.Object({path:m.String(),name:m.String(),gitBranch:m.Optional(m.String()),available:m.Boolean(),isCurrent:m.Boolean(),boundAt:m.String()})),WF=X(m.Union([m.Object({cancelled:m.Literal(!0)}),m.Object({cancelled:m.Literal(!1),path:m.String({minLength:1})})])),Hd=X(m.Object({type:m.String(),seq:m.Optional(m.Number()),properties:m.Record(m.String(),m.Unknown())})),Pk=m.Object({type:Ce(["file","image","url"]),path:m.Optional(m.String()),url:m.Optional(m.String()),content:m.Optional(m.String({maxLength:oo})),mimeType:m.Optional(m.String()),name:m.Optional(m.String())});X(m.Object({prompt:m.String({minLength:1,maxLength:32e3,pattern:"\\S"}),title:m.Optional(m.String({minLength:1,maxLength:200})),projectPath:m.Optional(m.String()),modelId:m.Optional(m.String({minLength:1,maxLength:500})),reasoningEffort:m.Optional(Mu),serviceTier:m.Optional(Fu),responseVerbosity:m.Optional(_u),communicationStyle:m.Optional(Sa),isolation:Oi(Tk,"worktree"),permissionMode:Oi(Ou,"default"),attachments:m.Optional(m.Array(Pk,{maxItems:Br}))}));const Kd=X(m.Object({session:Kn,runId:m.String(),messageId:m.String(),status:Ce(["queued","running"]),queuePosition:m.Optional(m.Integer({minimum:1})),queueDepth:m.Optional(m.Integer({minimum:0})),maxConcurrentTasks:m.Optional(m.Integer({minimum:1}))}));X(m.Object({action:Ce(["apply","discard"])}));X(m.Object({content:m.String({maxLength:NF}),projectPath:m.Optional(m.String()),modelId:m.Optional(m.String({minLength:1,maxLength:500})),reasoningEffort:m.Optional(Mu),serviceTier:m.Optional(Fu),responseVerbosity:m.Optional(_u),communicationStyle:m.Optional(Sa),permissionMode:m.Optional(Ou),attachments:m.Optional(m.Array(Pk,{maxItems:Br}))}));const JF=Ce(["completed","failed","aborted","timed_out","spawn_error"]),QF=X(m.Object({version:m.Literal(1),command:m.String(),status:JF,exitCode:m.Union([m.Integer(),m.Null()]),durationMs:m.Number({minimum:0}),stdout:m.String(),stderr:m.String(),stdoutOmittedBytes:m.Integer({minimum:0}),stderrOmittedBytes:m.Integer({minimum:0}),binaryOutput:m.Boolean(),truncated:m.Boolean()}));X(m.Object({command:m.String({minLength:1,maxLength:32*1024,pattern:"^(?![\\s\\S]*\\u0000)(?=[\\s\\S]*\\S)[\\s\\S]*$"}),projectPath:m.Optional(m.String())}));const YF=X(m.Object({executionId:m.String(),messageId:m.String(),record:QF,auxiliary:m.Boolean(),delivery:m.Optional(Ce(["current_turn","next_turn"])),queued:m.Optional(m.Integer({minimum:0}))}));X(m.Object({messageId:m.String(),role:Ru,content:m.String(),timestamp:m.String()}));X(m.Object({approved:m.Boolean(),remember:m.Optional(m.Boolean()),scope:m.Optional(Ce(["once","session","project"])),targetMode:m.Optional(Ou),feedback:m.Optional(m.String()),answers:m.Optional(m.Record(m.String(),m.Union([m.String(),m.Array(m.String())]))),elicitation:m.Optional(m.Object({action:Ce(["accept","decline","cancel"]),content:m.Optional(m.Record(m.String(),m.Union([m.String({maxLength:4e3}),m.Number(),m.Boolean(),m.Array(m.String({maxLength:1e3}),{maxItems:100})]),{maxProperties:32}))}))}));const XF=X(m.Object({id:Sa,name:m.String({minLength:1,maxLength:80}),description:m.String({minLength:1,maxLength:256}),source:Ce(["built-in","user","project","plugin"]),contentSha256:m.Optional(m.String({pattern:"^[a-f0-9]{64}$"}))}));X(m.Object({id:m.String(),displayName:m.Optional(m.String()),provider:m.String(),model:m.String(),contextWindow:m.Optional(m.Number()),maxTokens:m.Optional(m.Number()),reasoning:m.Optional(m.Boolean()),supportedReasoningEfforts:m.Optional(m.Array(Ce(["off","minimal","low","medium","high","xhigh","max"]))),supportedServiceTiers:m.Optional(m.Array(Ce(["standard","fast","flex"]))),supportedResponseVerbosities:m.Optional(m.Array(Ce(["low","medium","high"]))),communicationStyles:m.Optional(m.Array(XF,{maxItems:36})),input:m.Optional(m.Array(Ce(["text","image"]))),overrides:m.Optional(m.Object({baseUrl:m.Optional(m.String()),temperature:m.Optional(m.Number()),maxOutputTokens:m.Optional(m.Number()),timeout:m.Optional(m.Number()),streamIdleTimeout:m.Optional(m.Number({minimum:1e3}))}))}));X(Ce(["vs-dark","vs-light","hc-black"]));const ZF=X(Ce(["light","dark","system"])),e2=X(m.Object({language:m.String(),theme:m.String(),uiTheme:ZF,autoSaveSessions:m.Boolean(),notifyBuild:m.Boolean(),notifyErrors:m.Boolean(),notifySounds:m.Boolean(),privacyTelemetry:m.Boolean(),privacyCrash:m.Boolean()}));X(m.Partial(e2));async function dr(e,t){const n=await fetch(e,t),r=await n.json().catch(()=>{});if(!n.ok){const s=r,o=s!=null&&s.error&&typeof s.error=="object"&&!Array.isArray(s.error)?s.error:void 0,i=typeof(s==null?void 0:s.error)=="string"?s.error:typeof(o==null?void 0:o.message)=="string"?o.message:typeof(s==null?void 0:s.message)=="string"?s.message:n.statusText||`Request failed (${n.status})`;throw new Error(i)}return r}const ge="",Gd=1e4,t2=m.Array(Kn),n2=m.Array($k),r2=m.Array(Du),s2=m.Array(Nk),o2=m.Array(Sc),i2=m.Object({cwd:m.String(),gitBranch:m.Optional(m.String()),taskAdmission:m.Optional(m.Object({inFlight:m.Integer({minimum:0}),queued:m.Integer({minimum:0}),maxConcurrent:m.Integer({minimum:1}),maxQueued:m.Integer({minimum:1})}))}),a2=e=>Array.isArray(e)?e:e==null?"":typeof e=="string"?e:JSON.stringify(e),c2=()=>{const e=new Date,t=String(e.getFullYear()).slice(-2),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0");return`Session ${t}-${n}-${r} ${s}:${o}`};function l2(e){const t=Ak.parse(e);return`projectPath=${encodeURIComponent(t.projectPath)}`}function dt(e,t){const n=l2(t);return`${e}${e.includes("?")?"&":"?"}${n}`}function u2(e){return{"x-blade-directory":Ak.parse(e).projectPath}}const za=(e,t,n)=>({id:`history-${t}-${n}`,role:e.role,content:a2(e.content),timestamp:n,metadata:e.metadata&&typeof e.metadata=="object"?e.metadata:void 0,tool_call_id:e.tool_call_id,name:e.name,tool_calls:e.tool_calls,thinkingContent:e.thinkingContent??e.reasoningContent}),pe={listProjects:async()=>{const e=await fetch(`${ge}/projects`);if(!e.ok)throw new Error("Failed to load projects");return ur(n2,await e.json())},bindProject:async e=>{var n;const t=await fetch(`${ge}/projects`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!t.ok){const r=await t.json().catch(()=>{});throw new Error(((n=r==null?void 0:r.error)==null?void 0:n.message)||"Failed to bind project")}return $k.parse(await t.json())},pickProjectDirectory:async()=>ur(WF,await dr(`${ge}/projects/pick`,{method:"POST"})),unbindProject:async e=>{if(!(await fetch(`${ge}/projects?path=${encodeURIComponent(e)}`,{method:"DELETE"})).ok)throw new Error("Failed to unbind project")},listSessions:async()=>{const e=await fetch(`${ge}/sessions`);if(!e.ok)throw new Error("Failed to load sessions");return ur(t2,await e.json())},listSessionPage:async(e,t=50,n=!1)=>{const r=new URLSearchParams({limit:String(t)});e&&r.set("cursor",e),n&&r.set("archived","true");const s=await fetch(`${ge}/sessions/catalog?${r.toString()}`);if(!s.ok)throw new Error("Failed to load session catalog");return UF.parse(await s.json())},getSession:async e=>Kn.parse(await dr(dt(`${ge}/sessions/${e.sessionId}`,e))),createSession:async(e,t)=>{const n=await fetch(`${ge}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e,title:t||c2()})});if(!n.ok)throw new Error("Failed to create session");return Kn.parse(await n.json())},getWorkspaceInfo:async()=>ur(i2,await dr(`${ge}/global/info`)),createTask:async e=>{var n;const t=await fetch(`${ge}/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const r=await t.json().catch(()=>{});throw new Error(((n=r==null?void 0:r.error)==null?void 0:n.message)||"Failed to dispatch task")}return Kd.parse(await t.json())},retryTask:async e=>{var n;const t=await fetch(dt(`${ge}/tasks/${e.sessionId}/retry`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>{});throw new Error(((n=r==null?void 0:r.error)==null?void 0:n.message)||"Failed to retry task")}return Kd.parse(await t.json())},deliverTask:async(e,t)=>{var r;const n=await fetch(dt(`${ge}/tasks/${e.sessionId}/delivery`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t})});if(!n.ok){const s=await n.json().catch(()=>{});throw new Error(((r=s==null?void 0:s.error)==null?void 0:r.message)||"Failed to deliver task changes")}return Kn.parse(await n.json())},getTaskDiff:async e=>{var n;const t=await fetch(dt(`${ge}/tasks/${e.sessionId}/diff`,e));if(!t.ok){const r=await t.json().catch(()=>{});throw new Error(((n=r==null?void 0:r.error)==null?void 0:n.message)||"Failed to load task diff")}return FF.parse(await t.json())},deleteSession:async e=>{if(!(await fetch(dt(`${ge}/sessions/${e.sessionId}`,e),{method:"DELETE"})).ok)throw new Error("Failed to delete session")},archiveSession:async e=>qF.parse(await dr(dt(`${ge}/sessions/${e.sessionId}/archive`,e),{method:"POST"})),unarchiveSession:async e=>zF.parse(await dr(dt(`${ge}/sessions/${e.sessionId}/unarchive`,e),{method:"POST"})),exportSessionMarkdown:async(e,t=!1)=>{var u,f;const n=dt(`${ge}/sessions/${e.sessionId}/export`,e),r=t?`${n}&includeReasoning=true`:n,s=await fetch(r);if(!s.ok){const p=await s.json().catch(()=>{});throw new Error(((u=p==null?void 0:p.error)==null?void 0:u.message)||"Failed to export session")}const o=s.headers.get("content-disposition")??"",i=((f=/filename="([A-Za-z0-9._-]+)"/.exec(o))==null?void 0:f[1])??`blade-session-${e.sessionId.slice(0,12)}.md`,a=s.headers.get("x-blade-content-sha256")??"";if(!/^[a-f0-9]{64}$/.test(a))throw new Error("Session export is missing its integrity hash");const c=p=>{const g=s.headers.get(p);if(g===null)throw new Error(`Session export is missing its ${p} header`);const b=Number(g);if(!Number.isInteger(b)||b<0)throw new Error(`Session export has an invalid ${p} header`);return b};return{filename:i,markdown:await s.text(),contentSha256:a,messageCount:c("x-blade-export-messages"),activityCount:c("x-blade-export-activities"),redactionCount:c("x-blade-export-redactions")}},updateSession:async(e,t)=>{if(!(await fetch(`${ge}/sessions/${e.sessionId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t,projectPath:e.projectPath})})).ok)throw new Error("Failed to update session")},getMessages:async e=>{const t=await fetch(dt(`${ge}/sessions/${e.sessionId}/message`,e));if(!t.ok)throw new Error("Failed to load messages");const n=ur(r2,await t.json()),r=Date.now();return n.map((s,o)=>za(s,o,r))},sendMessage:async(e,t,n)=>{var s;const r=await fetch(`${ge}/sessions/${e.sessionId}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,permissionMode:n,projectPath:e.projectPath})});if(!r.ok){const o=await r.json().catch(()=>{}),i=((s=o==null?void 0:o.error)==null?void 0:s.message)??(o==null?void 0:o.reason);throw new Error(i||"Failed to send message")}return r.json()},executeUserShellCommand:async(e,t)=>YF.parse(await dr(`${ge}/sessions/${e.sessionId}/shell`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:t,projectPath:e.projectPath})})),abortSession:async e=>{var n;const t=await fetch(dt(`${ge}/sessions/${e.sessionId}/abort`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>{});throw new Error(((n=r==null?void 0:r.error)==null?void 0:n.message)||"Failed to stop task")}},getGoal:async e=>{const t=await fetch(dt(`${ge}/sessions/${e.sessionId}/goal`,e));if(!t.ok)throw new Error("Failed to load goal");return(await t.json()).goal},createGoal:async(e,t,n,r)=>{const s=await fetch(dt(`${ge}/sessions/${e.sessionId}/goal`,e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:t,tokenBudget:n,permissionMode:r})});if(!s.ok)throw new Error("Failed to create goal");return s.json()},updateGoal:async(e,t)=>{const n=await fetch(dt(`${ge}/sessions/${e.sessionId}/goal`,e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error("Failed to update goal");return n.json()},clearGoal:async e=>{if(!(await fetch(dt(`${ge}/sessions/${e.sessionId}/goal`,e),{method:"DELETE"})).ok)throw new Error("Failed to clear goal")},listRewindCheckpoints:async e=>{const t=await fetch(dt(`${ge}/sessions/${e.sessionId}/rewind`,e));if(!t.ok)throw new Error("Failed to load rewind checkpoints");const n=await t.json();return ur(s2,n.checkpoints)},rewindSession:async(e,t,n)=>{const r=await fetch(dt(`${ge}/sessions/${e.sessionId}/rewind`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetMessageId:t,mode:n})});if(!r.ok)throw new Error("Failed to rewind session");const s=KF.parse(await r.json()),o=Date.now();return{...s,messages:s.messages.map((i,a)=>za(i,a,o))}},listSubagents:async e=>{const t=await fetch(dt(`${ge}/sessions/${e.sessionId}/subagents`,e));if(!t.ok)throw new Error("Failed to load subagents");const n=await t.json();return ur(o2,n.subagents)},resumeSubagent:async(e,t,n)=>{const r=await fetch(dt(`${ge}/sessions/${e.sessionId}/subagents/${encodeURIComponent(t)}/resume`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:n})});if(!r.ok){const s=await r.json().catch(()=>{});throw new Error((s==null?void 0:s.message)||"Failed to resume subagent")}return VF.parse(await r.json())},forkSession:async e=>{const t=await fetch(`${ge}/sessions/${e.sessionId}/fork`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.projectPath})});if(!t.ok)throw new Error("Failed to fork session");const n=HF.parse(await t.json()),r=Date.now();return{session:n.session,messages:n.messages.map((s,o)=>za(s,o,r))}},openEventSubscription:async(e,t,n)=>{const r=(n==null?void 0:n.maxRetries)??5,s=n==null?void 0:n.onConnectionChange,o=n==null?void 0:n.onConnectionStateChange;let i=null,a=0,c=null,u=Date.now(),f=null,p=null,g=!1,b=!1,x=0,y,v,k=!1;const E=new Promise((j,F)=>{y=j,v=F}),$=()=>{f&&(clearInterval(f),f=null)},B=()=>{p&&(clearTimeout(p),p=null)},R=()=>{i==null||i.close(),i=null},M=()=>{c&&(clearTimeout(c),c=null),$(),B(),R()},P=()=>{k||(k=!0,B(),y())},N=j=>{k||(k=!0,M(),v(j))},O=()=>{if(g||a>=r){a>=r&&(console.error(`SSE max retries (${r}) reached, giving up`),o==null||o("offline"));return}a++,o==null||o("reconnecting");const j=Math.min(1e3*Math.pow(2,a-1),3e4);console.log(`SSE reconnecting in ${j}ms (attempt ${a}/${r})`),c=setTimeout(()=>{te().catch(F=>{console.error("SSE reconnect failed",F),s==null||s(!1),O()})},j)},_=()=>{a=0,u=Date.now(),s==null||s(!0),o==null||o("connected"),$(),f=setInterval(()=>{Date.now()-u>45e3&&(console.warn("SSE heartbeat timeout, reconnecting..."),$(),R(),s==null||s(!1),o==null||o("reconnecting"),O())},15e3),b||(b=!0,P())},te=async()=>{if(g)return;R();const j=dt(`${ge}/sessions/${e.sessionId}/events`,e),F=x>0?`${j}${j.includes("?")?"&":"?"}lastEventId=${x}`:j;i=new EventSource(F),b||(B(),p=setTimeout(()=>{o==null||o("offline"),N(new Error("Timed out waiting for event subscription readiness"))},Gd)),i.onmessage=se=>{try{const ne=JSON.parse(se.data);typeof ne.seq=="number"&&ne.seq>x&&(x=ne.seq);const oe=Hd.parse(ne);if(u=Date.now(),oe.type==="connected"){oe.properties.sessionId===e.sessionId&&oe.properties.projectPath===e.projectPath&&(typeof oe.properties.status=="string"&&t({type:"session.status",properties:oe.properties}),_());return}if(oe.type==="heartbeat")return;t(oe)}catch(ne){console.error("Failed to parse SSE event:",se.data,ne)}},i.onerror=()=>{if(!g){if($(),R(),!b){o==null||o("offline"),N(new Error("Failed to open event subscription"));return}console.error("SSE connection error"),s==null||s(!1),O()}}};return o==null||o("connecting"),te().catch(j=>{o==null||o("offline"),N(j instanceof Error?j:new Error("Failed to open event subscription"))}),await E,()=>{g=!0,c&&(clearTimeout(c),c=null),M(),s==null||s(!1)}},openTaskEventSubscription:async(e,t)=>{const n=t==null?void 0:t.onConnectionChange,r=t==null?void 0:t.onConnectionStateChange,s=new EventSource(`${ge}/events`);let o=!1,i=!1,a,c,u;const f=new Promise((g,b)=>{c=g,u=b}),p=()=>{o||(o=!0,a!==void 0&&(clearTimeout(a),a=void 0),s.close(),n==null||n(!1),r==null||r("offline"))};return r==null||r("connecting"),a=setTimeout(()=>{i||o||(p(),u(new Error("Timed out waiting for global task events")))},Gd),s.onmessage=g=>{try{const b=Hd.parse(JSON.parse(g.data));if(b.type==="connected"){i||(i=!0,a!==void 0&&(clearTimeout(a),a=void 0),c()),n==null||n(!0),r==null||r("connected");return}if(b.type==="heartbeat")return;e(b)}catch(b){console.error("Failed to parse global task event:",g.data,b)}},s.onerror=()=>{n==null||n(!1),r==null||r(i?"reconnecting":"offline"),!i&&!o&&(p(),u(new Error("Failed to open global task events")))},await f,p},respondPermission:async(e,t,n)=>{var o;const r=new URLSearchParams({sessionId:e.sessionId,projectPath:e.projectPath}),s=await fetch(`${ge}/permissions/${t}?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok){const i=await s.json().catch(()=>{});throw new Error(((o=i==null?void 0:i.error)==null?void 0:o.message)||"Failed to respond to permission")}},respondToConfirmation:async(e,t,n)=>{if(!(await fetch(dt(`${ge}/sessions/${e.sessionId}/confirmation/${t}`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({approved:n})})).ok)throw new Error("Failed to respond to confirmation")},respondToQuestion:async(e,t,n)=>{var o;const r=new URLSearchParams({sessionId:e.sessionId,projectPath:e.projectPath}),s=await fetch(`${ge}/permissions/${t}?${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({approved:!0,answers:n})});if(!s.ok){const i=await s.json().catch(()=>{});throw new Error(((o=i==null?void 0:i.error)==null?void 0:o.message)||"Failed to respond to question")}},respondToElicitation:async(e,t,n)=>{var o;const r=new URLSearchParams({sessionId:e.sessionId,projectPath:e.projectPath}),s=await fetch(`${ge}/permissions/${t}?${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({approved:n.action==="accept",elicitation:n})});if(!s.ok){const i=await s.json().catch(()=>{});throw new Error(((o=i==null?void 0:i.error)==null?void 0:o.message)||"Failed to respond to MCP elicitation")}},getGitInfo:async e=>{const t=await fetch(`${ge}/suggestions/git-info`,{headers:u2(e)});if(!t.ok)throw new Error("Failed to get git info");return t.json()}},Vd=e=>{let t;const n=new Set,r=(u,f)=>{const p=typeof u=="function"?u(t):u;if(!Object.is(p,t)){const g=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(b=>b(t,g))}},s=()=>t,a={setState:r,getState:s,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,s,a);return a},d2=e=>e?Vd(e):Vd,f2=e=>e;function m2(e,t=f2){const n=Ys.useSyncExternalStore(e.subscribe,Ys.useCallback(()=>t(e.getState()),[e,t]),Ys.useCallback(()=>t(e.getInitialState()),[e,t]));return Ys.useDebugValue(n),n}const Wd=e=>{const t=d2(e),n=r=>m2(t,r);return Object.assign(n,t),n},Ia=e=>e?Wd(e):Wd;function Mt(){return{timeline:[],textBefore:"",toolCalls:[],textAfter:"",thinkingContent:"",tasks:[],subagent:null,subagents:[],confirmation:null,question:null,elicitation:null}}function Gn(e){return e?e.subagents&&e.subagents.length>0?e.subagents:e.subagent?[e.subagent]:[]:[]}function go(e,t,n){const r=(n?t.find(s=>s.id===n||s.sessionId===n):void 0)??t[t.length-1]??null;return{...e,subagents:t,subagent:r}}function Ic(e,t){const n=[...Gn(e)];let r=n.findIndex(i=>i.id===t.id||!!(i.sessionId&&t.sessionId&&i.sessionId===t.sessionId));if(r===-1&&t.sessionId&&(r=n.findIndex(i=>!i.sessionId&&i.status==="running"&&i.type===t.type&&i.description===t.description)),r===-1)return n.push(t),go(e,n,t.id);const s=n[r],o={...s,...t,id:s.id};return n[r]=o,go(e,n,o.id)}function Lu(e,t){return`${t}-${e.length}`}function vc(e,t){if(!t)return e;const n=[...va(e)],r=n[n.length-1];return(r==null?void 0:r.type)==="text"?n[n.length-1]={...r,content:r.content+t}:n.push({id:Lu(n,"text"),type:"text",content:t}),{...e,timeline:n}}function Ok(e,t){if(!t)return e;const n=[...va(e)],r=n[n.length-1];return(r==null?void 0:r.type)==="thinking"?n[n.length-1]={...r,content:r.content+t}:n.push({id:Lu(n,"thinking"),type:"thinking",content:t}),{...e,timeline:n}}function jc(e,t){const n=e.toolCalls.some(i=>i.toolCallId===t.toolCallId),r=n?e.toolCalls:[...e.toolCalls,t];if(n)return{...e,toolCalls:r};const s=[...va(e)],o=s[s.length-1];return(o==null?void 0:o.type)==="tool_group"?s[s.length-1]={...o,toolCallIds:[...o.toolCallIds,t.toolCallId]}:s.push({id:Lu(s,"tool_group"),type:"tool_group",toolCallIds:[t.toolCallId]}),{...e,timeline:s,toolCalls:r}}function va(e){if(e.timeline&&e.timeline.length>0)return e.timeline;const t=[];return e.thinkingContent&&t.push({id:"legacy-thinking",type:"thinking",content:e.thinkingContent}),e.textBefore&&t.push({id:"legacy-text-before",type:"text",content:e.textBefore}),e.toolCalls.length>0&&t.push({id:"legacy-tool-group",type:"tool_group",toolCallIds:e.toolCalls.map(n=>n.toolCallId)}),e.textAfter&&t.push({id:"legacy-text-after",type:"text",content:e.textAfter}),t}function p2(e){return va(e).filter(t=>t.type==="text").map(t=>t.content).filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`)}const g2=(e,t)=>({messages:[],setMessages:n=>e({messages:n}),addMessage:n=>e(r=>({messages:[...r.messages,n]})),updateMessage:(n,r)=>e(s=>({messages:s.messages.map(o=>o.id===n?{...o,...r}:o)})),appendDelta:(n,r,s)=>e(o=>({messages:o.messages.map(i=>{if(i.id!==n)return i;const a=i.agentContent||Mt();return s==="before"?{...i,agentContent:{...vc(a,r),textBefore:a.textBefore+r}}:{...i,agentContent:{...vc(a,r),textAfter:a.textAfter+r}}})})),appendToolCall:(n,r)=>e(s=>({messages:s.messages.map(o=>{if(o.id!==n)return o;const i=o.agentContent||Mt();return{...o,agentContent:jc(i,r)}})})),updateToolCall:(n,r,s)=>e(o=>({messages:o.messages.map(i=>{if(i.id!==n)return i;const a=i.agentContent;return a?{...i,agentContent:{...a,toolCalls:a.toolCalls.map(c=>c.toolCallId===r?{...c,...s}:c)}}:i})})),appendThinking:(n,r)=>e(s=>({messages:s.messages.map(o=>{if(o.id!==n)return o;const i=o.agentContent||Mt();return{...o,agentContent:{...Ok(i,r),thinkingContent:i.thinkingContent+r}}})})),setConfirmation:(n,r)=>e(s=>({messages:s.messages.map(o=>{if(o.id!==n)return o;const i=o.agentContent||Mt();return{...o,agentContent:{...i,confirmation:r}}})})),setQuestion:(n,r)=>e(s=>({messages:s.messages.map(o=>{if(o.id!==n)return o;const i=o.agentContent||Mt();return{...o,agentContent:{...i,question:r}}})})),setElicitation:(n,r)=>e(s=>({messages:s.messages.map(o=>{if(o.id!==n)return o;const i=o.agentContent||Mt();return{...o,agentContent:{...i,elicitation:r}}})})),setSubagent:(n,r)=>e(s=>({messages:s.messages.map(o=>{if(o.id!==n)return o;const i=o.agentContent||Mt();return{...o,agentContent:r?Ic(i,r):go(i,[])}})})),updateSubagent:(n,r,s)=>e(o=>({messages:o.messages.map(i=>{if(i.id!==n)return i;const a=i.agentContent||Mt(),c=[...Gn(a)],u=c.findIndex(g=>g.id===r||g.sessionId===r);if(u===-1)return i;const f=c[u],p=typeof s=="function"?s(f):s;return c[u]={...f,...p,id:f.id},{...i,agentContent:go(a,c,c[u].id)}})})),setTasks:(n,r)=>e(s=>({messages:s.messages.map(o=>{if(o.id!==n)return o;const i=o.agentContent||Mt();return{...o,agentContent:{...i,tasks:r}}})})),replaceTemp:(n,r)=>e(s=>{const o=s.messages.findIndex(a=>a.content===n&&a.role==="user");if(o===-1)return s;const i=[...s.messages];return i[o]=r,{messages:i}})}),Ha=60,h2=[/<system-reminder>[\s\S]*?<\/system-reminder>/gi,/<file[^>]*>[\s\S]*?<\/file>/gi,/<hooks_context>[\s\S]*?<\/hooks_context>/gi,/<[^>]+>/g];function b2(e){let t=e;for(const c of h2)t=t.replace(c," ");t=t.replace(/^\s*\/[a-zA-Z][\w-]*\s+/,"");const n=t.replace(/\s+/g," ").trim();if(!n)return"";const r=n.match(/^(.+?)(?:[.!?]\s|[。!?](?=\S|$)|$)/);let s=r&&r[1].length>=6?r[1]:n;if(s=s.trim().replace(/[\s.。!!??,,;;::-]+$/,""),s.length<=Ha)return s;const o=s.slice(0,Ha),i=o.lastIndexOf(" ");return`${(i>Ha*.6?o.slice(0,i):o).trimEnd()}…`}const bi="/.blade/worktrees/",x2=/-[a-f0-9]{8,}$/i,k2=/^(.+?(?:test|config))-[a-z0-9]{6,}$/i;function y2(e){const t=e.indexOf(bi);if(t<0)return null;const n=e.slice(t+bi.length).split("/")[0];return n?`${e.slice(0,t+bi.length)}${n}`:null}function w2(e){if(!e.includes("/tmp/")&&!e.includes("/T/"))return null;const t=e.split("/"),n=t.at(-1),r=n==null?void 0:n.match(k2);return r!=null&&r[1]?(t[t.length-1]=r[1],t.join("/")):null}function Cc(e){const t=e.split("/").filter(Boolean).at(-1)||e;return e.includes(bi)?t.replace(x2,""):t}function ti(e,t=null){const n=e.taskSourceProjectPath,r=w2(n||e.projectPath);if(r)return r;if(n)return n;const s=y2(e.projectPath);if(!s)return e.projectPath;const o=Cc(s);return t&&o===Cc(t)?t:s}function S2(e,t,n=null){return t?e.filter(r=>ti(r,n)===t):e}let Ka=0;const Vt=Ia((e,t)=>({currentModelId:null,currentMode:hi.DEFAULT,configuredModels:[],availableModels:[],isLoading:!1,hasLoaded:!1,loadedWorkspacePath:null,error:null,loadModels:async n=>{const r=n??null;if(t().isLoading&&t().loadedWorkspacePath===r)return;const s=++Ka;e({isLoading:!0,hasLoaded:!1,loadedWorkspacePath:r,error:null});try{const o=await dr("/models",n?{headers:{"x-blade-directory":n}}:void 0);if(s!==Ka||t().loadedWorkspacePath!==r)return;const i=o.current;e({currentModelId:(i==null?void 0:i.id)||null,configuredModels:o.configured||[],availableModels:o.available||[],isLoading:!1,hasLoaded:!0})}catch(o){if(s!==Ka||t().loadedWorkspacePath!==r)return;e({error:o instanceof Error?o.message:"Failed to load models",isLoading:!1,hasLoaded:!0})}},setCurrentModel:async(n,r)=>{if(e({error:null}),r){e({currentModelId:n});return}try{await dr("/configs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:{currentModelId:n},options:{scope:"global"}})}),e({currentModelId:n})}catch(s){throw e({error:s instanceof Error?s.message:"Failed to set model"}),s}},setMode:n=>e({currentMode:n})})),Ga="__temp__",Zs={inputTokens:0,outputTokens:0,totalTokens:0,maxContextTokens:0,isDefaultMaxTokens:!0,totalInputTokens:0,totalOutputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0};function he(e){return{sessionId:e.sessionId,projectPath:e.projectPath}}function qe(e){return JSON.stringify([e.projectPath,e.sessionId])}function de(e,t){return!e||!t?e===t:e.sessionId===t.sessionId&&e.projectPath===t.projectPath}function Bu(e,t){return e.find(n=>de(he(n),t))}function Nn(e,t){const n=he(t),r=e.findIndex(o=>de(he(o),n));if(r===-1)return[...e,t];const s=[...e];return s[r]=t,s}function Jd(e,t){return e.filter(n=>!de(he(n),t))}const Rk="blade.tasks.unread",Ri="blade:open-session";function Mk(e){return e==="completed"||e==="failed"||e==="interrupted"}function I2(e,t,n){return!Mk(t)||n?!1:e!==t&&!(e==="completed"||e==="failed"||e==="interrupted"||e==="cancelled")}function v2(e=typeof localStorage>"u"?null:localStorage){if(!e)return[];try{const t=JSON.parse(e.getItem(Rk)??"[]");return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"))]:[]}catch{return[]}}function io(e,t=typeof localStorage>"u"?null:localStorage){if(t)try{t.setItem(Rk,JSON.stringify([...new Set(e)]))}catch{}}function Qd(e,t){const n=new Set(t.map(r=>qe({sessionId:r.sessionId,projectPath:r.projectPath})));return e.filter(r=>n.has(r))}function Yd(e){if(typeof document>"u"||document.visibilityState!=="hidden"||typeof Notification>"u"||Notification.permission!=="granted")return!1;const t=new Notification(e.title,{body:e.body,icon:"/favicon.svg",tag:`blade-task-${qe(e.ref)}`});return t.onclick=()=>e.onOpen(e.ref),!0}function j2(e){if(typeof window>"u")return!1;const t=window.AudioContext??window.webkitAudioContext;if(!t)return!1;try{const n=new t,r=n.createOscillator(),s=n.createGain();return r.type="sine",r.frequency.value=e==="completed"?660:330,s.gain.setValueAtTime(1e-4,n.currentTime),s.gain.exponentialRampToValueAtTime(.045,n.currentTime+.015),s.gain.exponentialRampToValueAtTime(1e-4,n.currentTime+.18),r.connect(s),s.connect(n.destination),r.start(),r.stop(n.currentTime+.2),r.onended=()=>void n.close(),!0}catch{return!1}}const C2=2166136261,T2=16777619;function Tc(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?`[${e.map(t=>Tc(t)).join(",")}]`:typeof e=="object"?`{${Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>`${JSON.stringify(n)}:${Tc(r)}`).join(",")}}`:JSON.stringify(e)}function Fk(e){let t=C2>>>0;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,T2);return(t>>>0).toString(16)}function _k(e){return typeof e=="string"?e:Tc(e??{})}function Uu(e){return e==="completed"?"completed":e==="failed"?"failed":"running"}function Ec({explicitId:e,messageId:t,toolName:n,argumentsValue:r,toolKind:s,output:o}){if(e)return e;const i=[t||"unknown-message",n||"Unknown",_k(r),s||"",o||""].join("|");return`tool-${Fk(i)}`}function ja({explicitId:e,sessionId:t,messageId:n,agentType:r,description:s,summary:o}){if(e)return e;if(t)return t;const i=[n||"unknown-message",r||"subagent",s||"",o||""].join("|");return`subagent-${Fk(i)}`}const E2=(e,t)=>!t||typeof t!="object"?null:{id:ja({explicitId:typeof t.subagentId=="string"?t.subagentId:void 0,sessionId:t.childSessionId,messageId:e,agentType:t.agentType,description:t.description,summary:t.summary}),type:t.agentType||"subagent",description:t.description||t.summary||"",status:Uu(t.status),startTime:Date.now(),sessionId:t.childSessionId,resumedFrom:t.resumedFrom,rootAgentId:t.rootAgentId,resumeDepth:typeof t.resumeDepth=="number"?t.resumeDepth:void 0},N2=(e,t)=>!t||typeof t!="object"?[]:(Array.isArray(t.subtaskRefs)?t.subtaskRefs:t.subtaskRef&&typeof t.subtaskRef=="object"?[t.subtaskRef]:[]).map(r=>E2(e,r)).filter(r=>r!==null);function Qs(e){return typeof e=="string"?e:e.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
12
|
-
`)}function xi(e){var r,s,o;const t=[];let n=null;for(const i of e)if(i.role!=="system"){if(i.role==="user")n&&(t.push(n),n=null),t.push({id:i.id,role:i.role,content:i.content,timestamp:i.timestamp||Date.now(),metadata:i.metadata});else if(i.role==="assistant"){n&&t.push(n);const a=i.metadata;let c=Mt();i.thinkingContent&&(c=Ok(c,i.thinkingContent),c.thinkingContent=i.thinkingContent);const u=Qs(i.content);u&&(c=vc(c,u),c.textBefore=u);const f=N2(i.id,a);if(i.tool_calls&&Array.isArray(i.tool_calls))for(const p of i.tool_calls){const g=((r=p.function)==null?void 0:r.name)||"Unknown",b=_k((s=p.function)==null?void 0:s.arguments);if(g==="Task"){let y={};try{y=JSON.parse(b)}catch{}const v=typeof y.subagent_type=="string"?y.subagent_type:"subagent",k=typeof y.description=="string"?y.description:v;c=Ic(c,{id:ja({explicitId:p.id,sessionId:typeof y.subagent_session_id=="string"?y.subagent_session_id:void 0,messageId:i.id,agentType:v,description:k}),type:v,description:k,status:"running",startTime:Date.now(),sessionId:typeof y.subagent_session_id=="string"?y.subagent_session_id:void 0,resumedFrom:typeof y.resume_from=="string"?y.resume_from:typeof y.resume=="string"?y.resume:void 0});continue}const x={toolCallId:Ec({explicitId:p.id,messageId:i.id,toolName:g,argumentsValue:(o=p.function)==null?void 0:o.arguments}),toolName:g,arguments:b,status:"running",startTime:Date.now()};c=jc(c,x)}for(const p of f)c=Ic(c,p);n={id:i.id,role:"assistant",content:Qs(i.content),timestamp:i.timestamp||Date.now(),metadata:a,agentContent:c}}else if(i.role==="tool"&&n&&n.agentContent){const a=i,c=i.metadata,u=a.tool_call_id||(c==null?void 0:c.toolCallId),f=a.name||(c==null?void 0:c.toolName)||"Tool",p=c!=null&&c.metadata&&typeof c.metadata=="object"&&!Array.isArray(c.metadata)?c.metadata:void 0,g=typeof(c==null?void 0:c.error)=="string"&&c.error.length>0,b=Gn(n.agentContent),x=b.findIndex(v=>v.id===u);if(x>=0){const v=b[x],k=typeof(p==null?void 0:p.subagentStatus)=="string"?Uu(p.subagentStatus):g?"failed":"completed";b[x]={...v,sessionId:typeof(p==null?void 0:p.subagentSessionId)=="string"?p.subagentSessionId:v.sessionId,type:typeof(p==null?void 0:p.subagentType)=="string"?p.subagentType:v.type,status:k,resumedFrom:typeof(p==null?void 0:p.subagentResumedFrom)=="string"?p.subagentResumedFrom:v.resumedFrom,rootAgentId:typeof(p==null?void 0:p.subagentRootId)=="string"?p.subagentRootId:v.rootAgentId,resumeDepth:typeof(p==null?void 0:p.subagentResumeDepth)=="number"?p.subagentResumeDepth:v.resumeDepth},n.agentContent=go(n.agentContent,b,v.id);continue}const y=n.agentContent.toolCalls.find(v=>v.toolCallId===u);y?(y.output=Qs(i.content),y.status=g?"error":"success",y.metadata=p,y.summary=typeof(p==null?void 0:p.summary)=="string"?p.summary:y.summary,(!y.toolName||y.toolName==="Unknown")&&(y.toolName=f)):n.agentContent=jc(n.agentContent,{toolCallId:Ec({explicitId:u,messageId:n.id,toolName:f,output:Qs(i.content)}),toolName:f,output:Qs(i.content),status:g?"error":"success",startTime:Date.now(),metadata:p,summary:typeof(p==null?void 0:p.summary)=="string"?p.summary:void 0})}}return n&&t.push(n),t}const A2=e=>{var n;const t=[];e.content.trim()&&t.push({type:"text",text:e.content});for(const r of e.attachments??[])r.type==="image"&&t.push({type:"image_url",image_url:{url:r.content}});return t.length===0?e.content:t.length===1&&((n=t[0])==null?void 0:n.type)==="text"?t[0].text:t},li=()=>({eventUnsubscribe:null,sessionEventConnectionState:"idle",isStreaming:!1,isStopping:!1,agentPhase:"idle",currentRunId:null,pendingSteeringCount:0,pendingInputDelivery:null,recoveredSteeringCount:0,currentAssistantMessageId:null,hasToolCalls:!1}),Xd=()=>new Promise(e=>{globalThis.setTimeout(()=>{if(typeof window<"u"&&typeof window.requestIdleCallback=="function"){window.requestIdleCallback(()=>e(),{timeout:750});return}e()},350)}),$2=(e,t)=>{let n=0,r=0,s=0;const o=()=>(n+=1,n),i=c=>c===n,a=c=>{try{c()}catch(u){console.warn("Failed to clean up stale event subscription",u)}};return{sessions:[],archivedSessions:[],currentSessionId:null,currentSessionRef:null,forkingSessionRef:null,isTemporarySession:!1,isLoading:!1,catalogLoadState:"idle",catalogError:null,archivedCatalogLoadState:"idle",archivedCatalogError:null,error:null,errorContext:null,goal:null,setSessions:c=>e({sessions:c}),addSession:c=>e(u=>({sessions:Nn(u.sessions,c)})),removeSession:c=>{const u=t();u.markTaskRead(c);const f=de(u.currentSessionRef,c),p=de(u.forkingSessionRef,c);(f||p)&&o(),f&&u.unsubscribeFromEvents(),e(g=>({sessions:Jd(g.sessions,c),currentSessionId:f?null:g.currentSessionId,currentSessionRef:f?null:g.currentSessionRef,messages:f?[]:g.messages,goal:f?null:g.goal,forkingSessionRef:p?null:g.forkingSessionRef,...f?li():{}}))},setCurrentSession:c=>{o(),e({currentSessionId:(c==null?void 0:c.sessionId)??null,currentSessionRef:c,isTemporarySession:!1})},setTemporarySession:c=>e({isTemporarySession:c}),setLoading:c=>e({isLoading:c}),setError:c=>e({error:c,errorContext:null}),getNavigationVersion:()=>n,clearError:()=>e({error:null,errorContext:null}),setGoal:c=>e({goal:c}),startTemporarySession:c=>{o(),t().unsubscribeFromEvents(),c&&t().selectProject(c),e({currentSessionId:Ga,currentSessionRef:null,isTemporarySession:!0,forkingSessionRef:null,isLoading:!1,messages:[],goal:null,tokenUsage:{...Zs},error:null,errorContext:null,...li()})},loadSessions:async()=>{const c=++r,u=new Set(t().sessions.map(p=>qe(he(p)))),f=new Set;e({catalogLoadState:"loading",catalogError:null});try{let p,g=!0;do{const y=await pe.listSessionPage(p);if(c!==r)return;for(const v of y.sessions)f.add(qe(he(v)));if(e(v=>{const k=new Set(y.sessions.map($=>qe(he($))));return{sessions:g?[...y.sessions,...v.sessions.filter($=>!k.has(qe(he($))))]:y.sessions.reduce(($,B)=>Nn($,B),v.sessions),catalogLoadState:y.nextCursor?"hydrating":"ready"}}),g=!1,p=y.nextCursor,p&&(await Xd(),c!==r))return}while(p);if(c!==r)return;const b=t().sessions.filter(y=>{const v=qe(he(y));return f.has(v)||!u.has(v)}),x=Qd(t().unreadTaskKeys,b);io(x),e({sessions:b,unreadTaskKeys:x,catalogLoadState:"ready",catalogError:null})}catch(p){if(c!==r)return;e({catalogLoadState:"error",catalogError:p.message})}},loadArchivedSessions:async()=>{const c=++s;e({archivedCatalogLoadState:"loading",archivedCatalogError:null});try{let u;const f=[];do{const p=await pe.listSessionPage(u,50,!0);if(c!==s)return;for(const g of p.sessions){const b=f.findIndex(x=>de(he(x),he(g)));b===-1?f.push(g):f[b]=g}u=p.nextCursor,u&&(e({archivedCatalogLoadState:"hydrating"}),await Xd())}while(u);if(c!==s)return;e({archivedSessions:f,archivedCatalogLoadState:"ready",archivedCatalogError:null})}catch(u){if(c!==s)return;e({archivedCatalogLoadState:"error",archivedCatalogError:u.message})}},selectSession:async c=>{var f;const u=o();e({isLoading:!0,error:null,errorContext:null,forkingSessionRef:null});try{const p=Bu(t().sessions,c),[g,b,x]=await Promise.all([pe.getMessages(c),pe.getGoal(c).catch(()=>null),p?Promise.resolve(p):pe.getSession(c)]);if(!i(u))return;const y=xi(g),v=[];let k=!1;const E=await t().prepareEventSubscription(c,B=>{k?t().handleEvent(B):v.push(B)});if(!i(u)){a(E);return}const $=ti(x,t().selectedProjectPath??((f=t().taskWorkspaceInfo)==null?void 0:f.cwd)??null);t().boundProjects.some(B=>B.available&&B.path===$)&&t().selectProject($),e(B=>{var R;return{currentSessionId:c.sessionId,currentSessionRef:c,isTemporarySession:!1,messages:y,goal:b,isLoading:!1,tokenUsage:{...Zs},isStreaming:!1,isStopping:!1,agentPhase:"idle",currentRunId:null,pendingSteeringCount:0,pendingInputDelivery:null,recoveredSteeringCount:0,currentAssistantMessageId:null,hasToolCalls:!1,error:x.taskStatus==="failed"?((R=x.taskFailure)==null?void 0:R.message)??null:null,errorContext:x.taskStatus==="failed"&&x.taskFailure?{kind:"execution",sessionRef:c,failureCode:x.taskFailure.code}:null,sessions:Nn(B.sessions,x)}}),t().markTaskRead(c),k=!0,t().replaceEventSubscription(E);for(const B of v)t().handleEvent(B)}catch(p){if(!i(u))return;e({error:p.message,errorContext:{kind:"navigation",sessionRef:c},isLoading:!1})}},archiveSession:async c=>{var u;try{const f=await pe.archiveSession(c),p=new Set(f.archivedSessionIds),g=t(),b=((u=g.currentSessionRef)==null?void 0:u.projectPath)===c.projectPath&&p.has(g.currentSessionRef.sessionId);b&&(o(),g.unsubscribeFromEvents()),e(x=>{const y=x.sessions.filter(k=>k.projectPath!==c.projectPath||!p.has(k.sessionId)),v=Qd(x.unreadTaskKeys,y);return io(v),{sessions:y,archivedSessions:Nn(x.archivedSessions,f.session),unreadTaskKeys:v,currentSessionId:b?null:x.currentSessionId,currentSessionRef:b?null:x.currentSessionRef,messages:b?[]:x.messages,goal:b?null:x.goal,...b?li():{}}}),await t().loadArchivedSessions()}catch(f){e({error:f.message,errorContext:{kind:"task_action",sessionRef:c}})}},unarchiveSession:async c=>{try{const u=await pe.unarchiveSession(c),f=new Set(u.restoredSessionIds);e(p=>({archivedSessions:p.archivedSessions.filter(g=>g.projectPath!==c.projectPath||!f.has(g.sessionId)),sessions:Nn(p.sessions,u.session)})),await Promise.all([t().loadSessions(),t().loadArchivedSessions()])}catch(u){e({error:u.message,errorContext:{kind:"task_action",sessionRef:c}})}},deleteSession:async c=>{const u=t(),f=de(u.currentSessionRef,c),p=de(u.forkingSessionRef,c),g=f||p?o():null,b=f?g:null;p&&e({forkingSessionRef:null});try{await pe.deleteSession(c),t().markTaskRead(c);const x=t(),y=de(x.currentSessionRef,c)&&(b===null||i(b));y&&(o(),x.unsubscribeFromEvents()),e(v=>({sessions:Jd(v.sessions,c),currentSessionId:y?null:v.currentSessionId,currentSessionRef:y?null:v.currentSessionRef,messages:y?[]:v.messages,goal:y?null:v.goal,...y?li():{}}))}catch(x){if(b!==null&&(!i(b)||!de(t().currentSessionRef,c)))return;e({error:x.message})}},updateSession:async(c,u)=>{try{await pe.updateSession(c,u),e(f=>({sessions:f.sessions.map(p=>p.sessionId===c.sessionId&&p.projectPath===c.projectPath?{...p,title:u}:p)}))}catch(f){e({error:f.message})}},forkSession:async c=>{const u=o(),f=he(c);e({forkingSessionRef:f,isLoading:!1,error:null});let p=null;try{const g=await pe.forkSession(c),b=he(g.session),x=xi(g.messages);if(e(y=>({sessions:Nn(y.sessions,g.session)})),!i(u))return;if(p=await t().prepareEventSubscription(b),!i(u)){a(p),p=null;return}e({currentSessionId:b.sessionId,currentSessionRef:b,isTemporarySession:!1,messages:x,goal:null,tokenUsage:{...Zs},error:null,forkingSessionRef:null}),t().replaceEventSubscription(p),p=null}catch(g){if(p&&a(p),!i(u))return;e({error:g.message,forkingSessionRef:null})}},rewindSession:async(c,u)=>{const{currentSessionRef:f,isTemporarySession:p,isStreaming:g}=t();if(!f||p)return e({error:"No persisted session is available for rewind"}),!1;if(g)return e({error:"Stop the active run before rewinding"}),!1;const b=n;try{const x=await pe.rewindSession(f,c,u);if(!i(b)||!de(t().currentSessionRef,f))return!1;const y=xi(x.messages);return e(v=>({messages:y,tokenUsage:{...Zs},error:null,currentRunId:null,agentPhase:"idle",pendingSteeringCount:0,pendingInputDelivery:null,recoveredSteeringCount:0,currentAssistantMessageId:null,hasToolCalls:!1,sessions:v.sessions.map(k=>k.sessionId===f.sessionId&&k.projectPath===f.projectPath?{...k,messageCount:y.length}:k)})),!0}catch(x){return!i(b)||!de(t().currentSessionRef,f)||e({error:x.message}),!1}},sendMessage:async c=>{var N,O,_,te;const{currentSessionId:u,currentSessionRef:f,isTemporarySession:p,isStreaming:g,addSession:b,addMessage:x}=t(),y=n,v=f,k={isStreaming:g,agentPhase:t().agentPhase,currentRunId:t().currentRunId};let E=f,$=u,B=v,R=null,M=null;const P=()=>i(y)&&de(t().currentSessionRef,B);if(p||!$||$===Ga)try{const j=b2(c.content),F=await pe.createSession(t().selectedProjectPath??((N=t().taskWorkspaceInfo)==null?void 0:N.cwd)??void 0,j||void 0);if(b(F),!P())return!1;E=he(F),$=F.sessionId,e({currentSessionId:F.sessionId,currentSessionRef:E,isTemporarySession:!1}),B=E}catch(j){return P()&&e({error:j.message}),!1}if(!E||!$||$===Ga)return P()&&e({error:"Failed to create session"}),!1;try{if(!g){if(R=await t().prepareEventSubscription(E),!P())return a(R),R=null,!1;t().replaceEventSubscription(R),R=null}if(!P())return!1;const j=c.content.trim();if(j.startsWith("!")){if((((O=c.attachments)==null?void 0:O.length)??0)>0)throw new Error("User shell commands do not accept image attachments");const Ne=j.slice(1).trim();if(!Ne)throw new Error("User shell command cannot be empty");g||e({isStreaming:!0,agentPhase:"running",error:null,errorContext:null});const We=await pe.executeUserShellCommand(E,Ne);return P()?(We.auxiliary||e({isStreaming:!1,agentPhase:"idle"}),We.delivery&&e({pendingSteeringCount:We.queued??0,pendingInputDelivery:We.delivery==="current_turn"?"current_turn":"next_turn"}),!0):!1}if((((_=c.attachments)==null?void 0:_.length)??0)===0&&(j==="/goal"||j.startsWith("/goal "))){M=`goal-command-${Date.now()}`,x({id:M,role:"user",content:j,timestamp:Date.now()});const Ne=j.slice(5).trim().split(/\s+/).filter(Boolean),We=(te=Ne[0])==null?void 0:te.toLowerCase();if(!We||We==="status"){const q=await pe.getGoal(E);return P()&&e({goal:q}),P()}if(We==="clear")return await pe.clearGoal(E),P()&&e({goal:null}),P();let A;if(We==="pause")A=await pe.updateGoal(E,{action:"pause"});else if(We==="resume")A=await pe.updateGoal(E,{action:"resume"});else if(We==="edit"){const q=Ne.slice(1).join(" ").trim();if(!q)throw new Error("Usage: /goal edit <objective>");A=await pe.updateGoal(E,{action:"edit",objective:q})}else{const q=Ne.lastIndexOf("--budget");let Q;if(q>=0){const Xe=Ne[q+1];if(!Xe||!/^[1-9]\d*$/.test(Xe))throw new Error("--budget requires a positive integer");Q=Number(Xe),Ne.splice(q,2)}const De=Ne.join(" ").trim();if(!De)throw new Error("Usage: /goal <objective>");const{currentMode:Rt}=Vt.getState();A=await pe.createGoal(E,De,Q,Rt)}return P()?(e({goal:A.goal,...A.runId?{currentRunId:A.runId,isStreaming:!0,agentPhase:"running"}:{}}),!0):!1}M=`temp-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,x({id:M,role:"user",content:A2(c),timestamp:Date.now()}),e({isStreaming:!0,error:null,errorContext:null,recoveredSteeringCount:g?t().recoveredSteeringCount:0});const{currentMode:F,currentModelId:se}=Vt.getState(),{modelId:ne,...oe}=c,Ie=ne??se??void 0,ve=c.reasoningEffort,Ee=c.serviceTier,L=c.responseVerbosity,ae=c.communicationStyle,He=Ie&&!g?{...oe,modelId:Ie}:oe,re=await pe.sendMessage(E,He,F);return P()?(e({currentRunId:re.runId,pendingSteeringCount:re.status==="steering_queued"||re.status==="follow_up_queued"?Math.max(0,re.queued??1):t().pendingSteeringCount,pendingInputDelivery:re.status==="steering_queued"?"current_turn":re.status==="follow_up_queued"?"next_turn":t().pendingInputDelivery,sessions:(Ie||ve||Ee||L||ae)&&!g?t().sessions.map(Ne=>Ne.sessionId===E.sessionId&&Ne.projectPath===E.projectPath?{...Ne,...Ie?{selectedModelId:Ie}:{},...ve?{reasoningEffort:ve}:{},...Ee?{serviceTier:Ee}:{},...L?{responseVerbosity:L}:{},...ae?{communicationStyle:ae}:{}}:Ne):t().sessions}),!0):!1}catch(j){return R&&a(R),P()?M&&!t().messages.some(F=>F.id===M)?!0:(e(F=>({error:j.message,errorContext:{kind:"submission",sessionRef:E},messages:M?F.messages.filter(se=>se.id!==M):F.messages,...k})),!1):!1}},abortSession:async()=>{const{currentSessionRef:c,isStopping:u}=t();if(!c||u)return!1;e({isStopping:!0,error:null,errorContext:null});try{return await pe.abortSession(c),de(t().currentSessionRef,c)?(t().unsubscribeFromEvents(),e({isStreaming:!1,isStopping:!1,agentPhase:"idle",currentRunId:null,pendingSteeringCount:0,pendingInputDelivery:null,recoveredSteeringCount:0,currentAssistantMessageId:null,hasToolCalls:!1}),!0):!1}catch(f){return de(t().currentSessionRef,c)&&e({isStopping:!1,error:f instanceof Error?f.message:"Failed to stop task",errorContext:{kind:"task_action",sessionRef:c}}),!1}},pauseGoal:async()=>{const{currentSessionRef:c,isTemporarySession:u}=t();if(!c||u){e({error:"No persisted session is available for this goal"});return}try{const f=await pe.updateGoal(c,{action:"pause"});if(!de(t().currentSessionRef,c))return;e({goal:f.goal,error:null})}catch(f){if(!de(t().currentSessionRef,c))return;e({error:f.message})}},resumeGoal:async()=>{const{currentSessionRef:c,isTemporarySession:u}=t();if(!c||u){e({error:"No persisted session is available for this goal"});return}try{const f=await pe.updateGoal(c,{action:"resume"});if(!de(t().currentSessionRef,c))return;e({goal:f.goal,error:null,...f.runId?{currentRunId:f.runId,isStreaming:!0,agentPhase:"running"}:{}})}catch(f){if(!de(t().currentSessionRef,c))return;e({error:f.message})}},editGoal:async c=>{const{currentSessionRef:u,isTemporarySession:f}=t();if(!u||f){e({error:"No persisted session is available for this goal"});return}try{const p=await pe.updateGoal(u,{action:"edit",objective:c});if(!de(t().currentSessionRef,u))return;e({goal:p.goal,error:null,...p.runId?{currentRunId:p.runId,isStreaming:!0,agentPhase:"running"}:{}})}catch(p){if(!de(t().currentSessionRef,u))return;e({error:p.message})}},clearGoal:async()=>{const{currentSessionRef:c,isTemporarySession:u}=t();if(!c||u){e({error:"No persisted session is available for this goal"});return}try{if(await pe.clearGoal(c),!de(t().currentSessionRef,c))return;e({goal:null,error:null})}catch(f){if(!de(t().currentSessionRef,c))return;e({error:f.message})}}}},Dk={authentication:"task.failure.authentication",permission:"task.failure.permission",rate_limit:"task.failure.rateLimit",timeout:"task.failure.timeout",network:"task.failure.network",model_unavailable:"task.failure.modelUnavailable",context_limit:"task.failure.contextLimit",unsupported_input:"task.failure.unsupportedInput",runtime:"task.failure.runtime"},P2={authentication:!1,permission:!1,rate_limit:!0,timeout:!0,network:!0,model_unavailable:!0,context_limit:!1,unsupported_input:!1,runtime:!0};function Lk(e){if(typeof e=="string"&&Object.keys(Dk).includes(e))return e}function qu(e){return Dk[e]}function O2(e){return P2[e]}const R2={flushTimeout:80};class M2{constructor(t){_a(this,"config");_a(this,"channels",new Map);this.config={...R2,...t}}append(t,n,r){let s=this.channels.get(t);s||(s={buffer:"",timer:null,flushFn:null},this.channels.set(t,s)),s.buffer+=n,s.flushFn=r,s.timer||(s.timer=setTimeout(()=>{this.flushChannel(t)},this.config.flushTimeout))}flushChannel(t){const n=this.channels.get(t);if(!n||!n.buffer)return;const r=n.buffer,s=n.flushFn;n.buffer="",n.timer&&(clearTimeout(n.timer),n.timer=null),s==null||s(r)}drainAll(){for(const[t]of this.channels)this.flushChannel(t);this.channels.clear()}drainAllExcept(t){for(const[n]of this.channels)n!==t&&this.flushChannel(n);for(const[n,r]of this.channels)n!==t&&!r.buffer&&this.channels.delete(n)}reset(){for(const[,t]of this.channels)t.timer&&clearTimeout(t.timer);this.channels.clear()}}const xn=new M2,pt=(e,t,n)=>{if(t)for(const r of e){const s=Gn(r.agentContent).find(o=>o.id===t||o.sessionId===t);if(s)return{messageId:r.id,subagent:s}}if(n){const r=e.find(i=>i.id===n),s=Gn(r==null?void 0:r.agentContent),o=s.find(i=>i.status==="running")??s[s.length-1];if(o)return{messageId:n,subagent:o}}for(const r of[...e].reverse()){const s=Gn(r.agentContent),o=s.find(i=>i.status==="running")??s[s.length-1];if(o)return{messageId:r.id,subagent:o}}},nn=(e,t,n)=>{const{currentAssistantMessageId:r,messages:s,addMessage:o,startAgentResponse:i}=e();if(r&&!r.startsWith("call_")&&s.some(f=>f.id===r&&f.role==="assistant"))return r;if(n){const f=s.find(p=>p.id===n&&p.role==="assistant");if(f)return i(f.id),f.id}const a=s[s.length-1];if((a==null?void 0:a.role)==="assistant")return a.id;const c=n||`assistant-${Date.now()}`,u={id:c,role:"assistant",content:"",timestamp:Date.now(),agentContent:Mt()};return o(u),i(c),t(f=>({messages:f.messages.map(p=>p.id===c?{...p,agentContent:{...p.agentContent||Mt()}}:p)})),c},F2=(e,t,n)=>{const{currentSessionId:r,addMessage:s,startAgentResponse:o,messages:i,updateMessage:a}=t();if(e.sessionId!==r)return;const c=e.messageId,u=e.role||"assistant",f=i.find(g=>g.id===c),p={id:c,role:u,content:e.content||"",timestamp:Date.now(),agentContent:u==="assistant"?Mt():void 0};f?a(c,{role:u,content:p.content,agentContent:u==="assistant"?{...f.agentContent||Mt()}:void 0}):s(p),u==="assistant"&&o(c)},_2=(e,t,n)=>{const{currentSessionId:r,appendDelta:s,currentAssistantMessageId:o,hasToolCalls:i,addMessage:a,startAgentResponse:c}=t();if(e.sessionId!==r)return;const u=e.messageId,f=e.delta;if(!o){const g={id:u,role:"assistant",content:"",timestamp:Date.now(),agentContent:Mt()};a(g),c(u),t().appendDelta(u,f,"before");return}s(o,f,i?"after":"before")},D2=(e,t)=>{const{currentSessionId:n,updateMessage:r,messages:s}=t();if(e.sessionId!==n)return;const o=e.messageId,i=s.find(a=>a.id===o);i!=null&&i.agentContent&&r(o,{content:p2(i.agentContent)})},L2=(e,t,n)=>{const{currentSessionId:r,appendThinking:s}=t();if(e.sessionId!==r)return;const o=nn(t,n,e.messageId);o&&s(o,e.delta)},B2=()=>{},U2=(e,t,n)=>{const{currentSessionId:r,appendToolCall:s,setHasToolCalls:o,setSubagent:i}=t();if(e.sessionId!==r)return;const a=nn(t,n,e.messageId||e.toolCallId);if(!a)return;o(!0);const c=e.toolName||"Unknown",u=e.arguments;let f,p="",g,b;if(c==="Task")try{const y=JSON.parse(u);f=y.subagent_type,p=y.description||y.query||f||"",g=y.subagent_session_id,b=y.resume_from||y.resume}catch{}if(f){i(a,{id:ja({explicitId:e.toolCallId,sessionId:g,messageId:a,agentType:f,description:p}),type:f,description:p,status:"running",startTime:Date.now(),sessionId:g,resumedFrom:b,output:"",thinking:""});return}const x={toolCallId:Ec({explicitId:e.toolCallId,messageId:a,toolName:c,argumentsValue:u,toolKind:e.toolKind}),toolName:c,arguments:u,toolKind:e.toolKind,status:"running",startTime:Date.now()};s(a,x)},q2=(e,t)=>{const{currentSessionId:n,updateToolCall:r,messages:s}=t();if(e.sessionId!==n)return;const o=e.toolCallId;if(!o)return;const i=s.find(a=>{var c;return(c=a.agentContent)==null?void 0:c.toolCalls.some(u=>u.toolCallId===o)});i&&r(i.id,o,{summary:e.message,progress:typeof e.progress=="number"?e.progress:void 0,progressTotal:typeof e.total=="number"?e.total:void 0,progressMessage:e.message})},z2=(e,t,n)=>{var P;const{currentSessionId:r,updateToolCall:s,updateSubagent:o,messages:i}=t();if(e.sessionId!==r)return;const a=e.toolCallId;if(!a)return;const c=i.find(N=>{var O;return(O=N.agentContent)==null?void 0:O.toolCalls.some(_=>_.toolCallId===a)}),u=i.find(N=>Gn(N.agentContent).some(O=>O.id===a)),f=e.messageId||(c==null?void 0:c.id)||(u==null?void 0:u.id)||((P=[...i].reverse().find(N=>N.role==="assistant"))==null?void 0:P.id);if(!f)return;const p=e.output,g=e.summary||(p&&p.trim()?p.trim().split(`
|
|
13
|
-
`)[0].slice(0,120):e.success?"执行成功":"执行失败");s(f,a,{status:e.success?"success":"error",summary:g,output:p,metadata:e.metadata});const b=i.find(N=>N.id===f),x=Gn(b==null?void 0:b.agentContent).find(N=>N.id===a),y=e.metadata,v=y&&typeof y.subagentSessionId=="string"?y.subagentSessionId:void 0,k=y&&typeof y.subagentStatus=="string"?y.subagentStatus:void 0,E=y&&typeof y.subagentType=="string"?y.subagentType:void 0,$=y&&typeof y.subagentSummary=="string"?y.subagentSummary:void 0,B=y&&typeof y.subagentResumedFrom=="string"?y.subagentResumedFrom:void 0,R=y&&typeof y.subagentRootId=="string"?y.subagentRootId:void 0,M=y&&typeof y.subagentResumeDepth=="number"?y.subagentResumeDepth:void 0;x&&o(f,x.id,{sessionId:x.sessionId||v,type:E||x.type,status:k?Uu(k):e.success?"completed":"failed",resumedFrom:B||x.resumedFrom,rootAgentId:R||x.rootAgentId,resumeDepth:M??x.resumeDepth}),v&&k&&n(N=>({messages:N.messages.map(O=>{if(O.id!==f)return O;const _=O.metadata??{},te=Array.isArray(_.subtaskRefs)?_.subtaskRefs:[],j=te.findIndex(oe=>oe.childSessionId===v||oe.subagentId===a),F=j>=0?te[j]:_.subtaskRef??{},se={...F,subagentId:a,childSessionId:v,agentType:E||(typeof(F==null?void 0:F.agentType)=="string"?F.agentType:"subagent"),status:k,summary:$||(typeof(F==null?void 0:F.summary)=="string"?F.summary:""),resumedFrom:B||(typeof(F==null?void 0:F.resumedFrom)=="string"?F.resumedFrom:void 0),rootAgentId:R||(typeof(F==null?void 0:F.rootAgentId)=="string"?F.rootAgentId:v),resumeDepth:M??(typeof(F==null?void 0:F.resumeDepth)=="number"?F.resumeDepth:0)},ne=[...te];return j>=0?ne[j]=se:ne.push(se),{...O,metadata:{..._,subtaskRef:se,subtaskRefs:ne}}})}))},H2=(e,t,n)=>{const{currentSessionId:r,appendToolCall:s}=t();if(e.sessionId!==r)return;const o=nn(t,n,e.messageId||`mcp-catalog-${String(e.revision)}`);if(!o)return;const i=Array.isArray(e.added)?e.added.map(String):[],a=Array.isArray(e.removed)?e.removed.map(String):[],c=Array.isArray(e.updated)?e.updated.map(String):[],u=`MCP catalog r${String(e.revision)}: +${i.length} -${a.length} ~${c.length}`;s(o,{toolCallId:`mcp-catalog:${String(e.revision)}`,toolName:"MCP Catalog",arguments:JSON.stringify({serverName:e.serverName,added:i,removed:a,updated:c}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:u,output:[i.length>0?`Added: ${i.join(", ")}`:"",a.length>0?`Removed: ${a.join(", ")}`:"",c.length>0?`Updated: ${c.join(", ")}`:""].filter(Boolean).join(`
|
|
14
|
-
`)})},K2=(e,t,n)=>{const{currentSessionId:r,appendToolCall:s}=t();if(e.sessionId!==r)return;const o=nn(t,n,e.messageId||`mcp-content-${String(e.revision)}`);if(!o)return;const i=Array.isArray(e.added)?e.added.map(String):[],a=Array.isArray(e.removed)?e.removed.map(String):[],c=Array.isArray(e.updated)?e.updated.map(String):[],u=`MCP ${String(e.contentKind)} r${String(e.revision)}: +${i.length} -${a.length} ~${c.length}`;s(o,{toolCallId:`mcp-content:${String(e.revision)}`,toolName:"MCP Content",arguments:JSON.stringify({serverName:e.serverName,contentKind:e.contentKind,added:i,removed:a,updated:c}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:u,output:[i.length>0?`Added: ${i.join(", ")}`:"",a.length>0?`Removed: ${a.join(", ")}`:"",c.length>0?`Updated: ${c.join(", ")}`:""].filter(Boolean).join(`
|
|
15
|
-
`)})},G2=(e,t,n)=>{const{currentSessionId:r,appendToolCall:s}=t();if(e.sessionId!==r)return;const o=nn(t,n,e.messageId||`mcp-resource-${String(e.revision)}`);o&&s(o,{toolCallId:`mcp-resource:${String(e.revision)}`,toolName:"MCP Resource",arguments:JSON.stringify({serverName:e.serverName,uri:e.uri}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:`MCP resource updated: ${String(e.uri)}`,output:`${String(e.serverName)} · revision ${String(e.revision)}`})},V2=(e,t,n)=>{const{currentSessionId:r,appendToolCall:s}=t();if(e.sessionId!==r)return;const o=nn(t,n,e.messageId||`mcp-connection-${String(e.revision)}`);if(!o)return;const i=String(e.phase),a=`MCP ${String(e.serverName)} ${i}`+(i==="reconnecting"?` (${String(e.attempt)}/${String(e.maxAttempts)})`:"");s(o,{toolCallId:`mcp-connection:${String(e.revision)}`,toolName:"MCP Connection",arguments:JSON.stringify({serverName:e.serverName,phase:i,reason:e.reason,attempt:e.attempt,maxAttempts:e.maxAttempts}),toolKind:"readonly",status:i==="failed"?"error":"success",startTime:Date.now(),summary:a,output:[`Reason: ${String(e.reason)}`,e.error?`Error: ${String(e.error)}`:""].filter(Boolean).join(`
|
|
16
|
-
`)})},W2=(e,t,n)=>{const{currentSessionId:r,appendToolCall:s}=t();if(e.sessionId!==r)return;const o=nn(t,n,e.messageId||`mcp-log-${String(e.revision)}`);if(!o)return;const i=String(e.level),a=typeof e.logger=="string"?e.logger:void 0,c=`MCP ${i} · ${String(e.serverName)}`+(a?` · ${a}`:"");s(o,{toolCallId:`mcp-log:${String(e.revision)}`,toolName:"MCP Log",arguments:JSON.stringify({serverName:e.serverName,level:i,logger:a}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:c,output:[String(e.message),`SHA-256: ${String(e.dataSha256)}`,e.truncated===!0?"Truncated":"",e.detailsOmitted===!0?"Details omitted by runtime policy":""].filter(Boolean).join(`
|
|
17
|
-
`)})},J2=(e,t,n)=>{const{currentSessionId:r,appendToolCall:s}=t();if(e.sessionId!==r)return;const o=String(e.serverName),i=String(e.action),a=nn(t,n,e.messageId||`mcp-instructions-${String(e.revision)}-${o}`);if(!a)return;const c=`MCP instructions ${i}: ${o}`+(e.truncated===!0?" (truncated)":"");s(a,{toolCallId:`mcp-instructions:${String(e.revision)}:${o}:${i}`,toolName:"MCP Instructions",arguments:JSON.stringify({serverName:o,action:i,reason:e.reason}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:c,output:[typeof e.text=="string"?e.text:"",e.sha256?`SHA-256: ${String(e.sha256)}`:"",e.detailsOmitted===!0?"Details omitted by runtime policy":""].filter(Boolean).join(`
|
|
18
|
-
`)})},Q2=(e,t,n)=>{var b,x;const{currentSessionId:r,appendToolCall:s,updateToolCall:o}=t();if(e.sessionId!==r)return;const i=String(e.taskId),a=String(e.status),c=`mcp-task:${i}`,u=nn(t,n,e.messageId||`mcp-task-${i}`);if(!u)return;const f=`MCP task ${a}: ${i} · ${String(e.serverName)}/${String(e.toolName)}`,p={status:a==="failed"||a==="cancelled"?"error":a==="completed"?"success":"running",summary:f,output:[typeof e.statusMessage=="string"?e.statusMessage:"",e.hasResult===!0?"Result available via TaskOutput":"",typeof e.error=="string"?`Error: ${e.error}`:""].filter(Boolean).join(`
|
|
19
|
-
`)};if((x=(b=t().messages.find(y=>y.id===u))==null?void 0:b.agentContent)==null?void 0:x.toolCalls.some(y=>y.toolCallId===c)){o(u,c,p);return}s(u,{toolCallId:c,toolName:"MCP Task",arguments:JSON.stringify({taskId:i,serverName:e.serverName,toolName:e.toolName}),toolKind:"readonly",status:p.status,startTime:Number(e.createdAt)||Date.now(),summary:p.summary,output:p.output})},Y2=(e,t,n)=>{const{currentSessionId:r,appendToolCall:s}=t();if(e.sessionId!==r)return;const o=Array.isArray(e.files)?e.files.filter(u=>!!u&&typeof u=="object"&&!Array.isArray(u)):[],i=nn(t,n,e.messageId||`project-rules-${Date.now()}`);if(!i)return;const a=e.blockedWrite===!0,c=`Project rules loaded: ${o.length}`+(a?" (write retry required)":"");s(i,{toolCallId:`project-rules:${o.map(u=>String(u.id)).join(",")}`,toolName:"Project Rules",arguments:JSON.stringify({triggerPaths:e.triggerPaths,blockedWrite:a}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:c,output:o.map(u=>`${String(u.relativePath)} ${String(u.source)} SHA-256: ${String(u.contentSha256)}`).join(`
|
|
20
|
-
`)})},zu=e=>`user-shell-${e}`,X2=(e,t,n)=>{const{currentSessionId:r,addMessage:s,messages:o,updateMessage:i}=t();if(e.sessionId!==r||typeof e.executionId!="string"||typeof e.command!="string")return;const a=zu(e.executionId),c={id:a,role:"user",content:`! ${e.command}`,timestamp:Date.now(),metadata:{userShellExecution:{executionId:e.executionId,command:e.command,status:"running",output:""}}};o.some(u=>u.id===a)?i(a,c):s(c),e.auxiliary!==!0&&n({isStreaming:!0,agentPhase:"running",error:null,errorContext:null})},Z2=(e,t)=>{var u;const{currentSessionId:n,messages:r,updateMessage:s}=t();if(e.sessionId!==n||typeof e.executionId!="string"||typeof e.chunk!="string")return;const o=zu(e.executionId),i=r.find(f=>f.id===o);if(!i)return;const a=(u=i.metadata)!=null&&u.userShellExecution&&typeof i.metadata.userShellExecution=="object"?i.metadata.userShellExecution:{},c=`${typeof a.output=="string"?a.output:""}${e.chunk}`;s(o,{content:`! ${String(a.command??"")}
|
|
21
|
-
${c}`,metadata:{...i.metadata,userShellExecution:{...a,output:c,streamTruncated:e.streamTruncated===!0}}})},e_=(e,t,n)=>{const{currentSessionId:r,messages:s,addMessage:o,updateMessage:i}=t();if(e.sessionId!==r||typeof e.executionId!="string"||!e.record||typeof e.record!="object"||Array.isArray(e.record))return;const a=e.record,c=typeof a.command=="string"?a.command:"",u=typeof a.stdout=="string"?a.stdout:"",f=typeof a.stderr=="string"?a.stderr:"",p=[u,f?`stderr:
|
|
22
|
-
${f}`:""].filter(Boolean).join(`
|
|
23
|
-
`),g=zu(e.executionId),b={role:"user",content:[`! ${c}`,p||"(no output)"].join(`
|
|
24
|
-
`),metadata:{userShellCommand:a}};s.some(x=>x.id===g)?i(g,b):o({id:g,...b,timestamp:Date.now()}),e.auxiliary!==!0&&n({isStreaming:!1,isStopping:!1,agentPhase:"idle"}),(e.delivery==="current_turn"||e.delivery==="next_turn")&&n({pendingSteeringCount:typeof e.queued=="number"?Math.max(0,e.queued):0,pendingInputDelivery:e.delivery==="current_turn"?"current_turn":"next_turn"})},t_=(e,t)=>{const{currentSessionId:n,updateTokenUsage:r,setMaxContextTokens:s}=t();e.sessionId===n&&(r({inputTokens:e.inputTokens,outputTokens:e.outputTokens,totalTokens:e.totalTokens,cacheReadTokens:e.cacheReadTokens??0,cacheWriteTokens:e.cacheWriteTokens??0,costUsd:e.costUsd}),e.maxContextTokens&&s(e.maxContextTokens,!1))},n_=(e,t)=>{const{currentSessionId:n,setTasks:r,currentAssistantMessageId:s}=t();if(e.sessionId!==n||!s)return;const o=e.tasks||[];r(s,o)},r_=(e,t)=>{const{currentSessionId:n,setSubagent:r,currentAssistantMessageId:s}=t();if(e.sessionId!==n||!s)return;const o={id:ja({explicitId:e.subagentId,sessionId:e.subagentSessionId,messageId:s,agentType:e.type,description:e.description}),type:e.type||"unknown",description:e.description||"",status:"running",startTime:Date.now(),sessionId:e.subagentSessionId,resumedFrom:e.resumedFrom,rootAgentId:e.rootAgentId,resumeDepth:typeof e.resumeDepth=="number"?e.resumeDepth:void 0};r(s,o)},s_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=e.subagentSessionId,a=pt(s,i,r);a&&o(a.messageId,a.subagent.id,{sessionId:a.subagent.sessionId||i,currentTool:e.toolName})},o_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=e.delta;if(!i)return;const a=e.subagentSessionId,c=pt(s,a,r);c&&o(c.messageId,c.subagent.id,u=>({sessionId:u.sessionId||a,output:(u.output||"")+i}))},i_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=e.delta;if(!i)return;const a=e.subagentSessionId,c=pt(s,a,r);c&&o(c.messageId,c.subagent.id,u=>({sessionId:u.sessionId||a,thinking:(u.thinking||"")+i}))},a_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=e.subagentSessionId,a=pt(s,i,r);a&&o(a.messageId,a.subagent.id,{sessionId:a.subagent.sessionId||i,status:e.success?"completed":"failed",currentTool:void 0})},c_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=e.toolCallId,a=e.toolName;if(!i||!a)return;const c=e.subagentSessionId,u=pt(s,c,r);if(!u)return;const f={toolCallId:i,toolName:a,arguments:e.arguments,toolKind:e.toolKind,status:"running",startTime:Date.now()};o(u.messageId,u.subagent.id,p=>{const g=p.toolCalls||[];return{sessionId:p.sessionId||c,currentTool:a,toolCalls:g.some(b=>b.toolCallId===i)?g:[...g,f]}})},l_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=e.toolCallId;if(!i)return;const a=e.toolName,c=e.subagentSessionId,u=pt(s,c,r);if(!u)return;const f=e.output,p=e.success===!0,g=p?"success":"error",b=e.summary||(f&&f.trim()?f.trim().split(`
|
|
25
|
-
`)[0].slice(0,120):p?"执行成功":"执行失败");o(u.messageId,u.subagent.id,x=>({sessionId:x.sessionId||c,currentTool:x.currentTool===a?void 0:x.currentTool,toolCalls:(x.toolCalls||[]).map(y=>y.toolCallId===i?{...y,status:g,summary:b,output:f,metadata:e.metadata}:y)}))},u_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=e.toolCallId;if(!i)return;const a=pt(s,e.subagentSessionId,r);a&&o(a.messageId,a.subagent.id,c=>({toolCalls:(c.toolCalls||[]).map(u=>u.toolCallId===i?{...u,summary:e.message,progress:typeof e.progress=="number"?e.progress:void 0,progressTotal:typeof e.total=="number"?e.total:void 0,progressMessage:e.message}:u)}))},d_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=pt(s,e.subagentSessionId,r);if(!i)return;const a=Array.isArray(e.added)?e.added.map(String):[],c=Array.isArray(e.removed)?e.removed.map(String):[],u=Array.isArray(e.updated)?e.updated.map(String):[],f=`mcp-catalog:${String(e.revision)}`;o(i.messageId,i.subagent.id,p=>({toolCalls:[...(p.toolCalls||[]).filter(g=>g.toolCallId!==f),{toolCallId:f,toolName:"MCP Catalog",arguments:JSON.stringify({serverName:e.serverName,added:a,removed:c,updated:u}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:`MCP catalog r${String(e.revision)}: +${a.length} -${c.length} ~${u.length}`,output:[a.length>0?`Added: ${a.join(", ")}`:"",c.length>0?`Removed: ${c.join(", ")}`:"",u.length>0?`Updated: ${u.join(", ")}`:""].filter(Boolean).join(`
|
|
26
|
-
`)}]}))},f_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=pt(s,e.subagentSessionId,r);if(!i)return;const a=Array.isArray(e.added)?e.added.map(String):[],c=Array.isArray(e.removed)?e.removed.map(String):[],u=Array.isArray(e.updated)?e.updated.map(String):[],f=`mcp-content:${String(e.revision)}`;o(i.messageId,i.subagent.id,p=>({toolCalls:[...(p.toolCalls||[]).filter(g=>g.toolCallId!==f),{toolCallId:f,toolName:"MCP Content",arguments:JSON.stringify({serverName:e.serverName,contentKind:e.contentKind,added:a,removed:c,updated:u}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:`MCP ${String(e.contentKind)} r${String(e.revision)}: +${a.length} -${c.length} ~${u.length}`}]}))},m_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=pt(s,e.subagentSessionId,r);if(!i)return;const a=`mcp-resource:${String(e.revision)}`;o(i.messageId,i.subagent.id,c=>({toolCalls:[...(c.toolCalls||[]).filter(u=>u.toolCallId!==a),{toolCallId:a,toolName:"MCP Resource",arguments:JSON.stringify({serverName:e.serverName,uri:e.uri}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:`MCP resource updated: ${String(e.uri)}`}]}))},p_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=pt(s,e.subagentSessionId,r);if(!i)return;const a=String(e.phase),c=`mcp-connection:${String(e.revision)}`;o(i.messageId,i.subagent.id,u=>({toolCalls:[...(u.toolCalls||[]).filter(f=>f.toolCallId!==c),{toolCallId:c,toolName:"MCP Connection",arguments:JSON.stringify({serverName:e.serverName,phase:a,reason:e.reason,attempt:e.attempt,maxAttempts:e.maxAttempts}),toolKind:"readonly",status:a==="failed"?"error":"success",startTime:Date.now(),summary:`MCP ${String(e.serverName)} ${a}`+(a==="reconnecting"?` (${String(e.attempt)}/${String(e.maxAttempts)})`:""),output:e.error?`Error: ${String(e.error)}`:void 0}]}))},g_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=pt(s,e.subagentSessionId,r);if(!i)return;const a=String(e.level),c=typeof e.logger=="string"?e.logger:void 0,u=`mcp-log:${String(e.revision)}`;o(i.messageId,i.subagent.id,f=>({toolCalls:[...(f.toolCalls||[]).filter(p=>p.toolCallId!==u),{toolCallId:u,toolName:"MCP Log",arguments:JSON.stringify({serverName:e.serverName,level:a,logger:c}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:`MCP ${a} · ${String(e.serverName)}`+(c?` · ${c}`:""),output:[String(e.message),`SHA-256: ${String(e.dataSha256)}`,e.truncated===!0?"Truncated":"",e.detailsOmitted===!0?"Details omitted by runtime policy":""].filter(Boolean).join(`
|
|
27
|
-
`)}]}))},h_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=pt(s,e.subagentSessionId,r);if(!i)return;const a=String(e.serverName),c=String(e.action),u=`mcp-instructions:${String(e.revision)}:${a}:${c}`;o(i.messageId,i.subagent.id,f=>({toolCalls:[...(f.toolCalls||[]).filter(p=>p.toolCallId!==u),{toolCallId:u,toolName:"MCP Instructions",arguments:JSON.stringify({serverName:a,action:c,reason:e.reason}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:`MCP instructions ${c}: ${a}`+(e.truncated===!0?" (truncated)":""),output:[typeof e.text=="string"?e.text:"",e.sha256?`SHA-256: ${String(e.sha256)}`:"",e.detailsOmitted===!0?"Details omitted by runtime policy":""].filter(Boolean).join(`
|
|
28
|
-
`)}]}))},b_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=pt(s,e.subagentSessionId,r);if(!i)return;const a=String(e.taskId),c=String(e.status),u=`mcp-task:${a}`;o(i.messageId,i.subagent.id,f=>({toolCalls:[...(f.toolCalls||[]).filter(p=>p.toolCallId!==u),{toolCallId:u,toolName:"MCP Task",arguments:JSON.stringify({taskId:a,serverName:e.serverName,toolName:e.toolName}),toolKind:"readonly",status:c==="failed"||c==="cancelled"?"error":c==="completed"?"success":"running",startTime:Number(e.createdAt)||Date.now(),summary:`MCP task ${c}: ${a} · ${String(e.serverName)}/${String(e.toolName)}`,output:[typeof e.statusMessage=="string"?e.statusMessage:"",e.hasResult===!0?"Result available via TaskOutput":"",typeof e.error=="string"?`Error: ${e.error}`:""].filter(Boolean).join(`
|
|
29
|
-
`)}]}))},x_=(e,t)=>{const{currentSessionId:n,currentAssistantMessageId:r,messages:s,updateSubagent:o}=t();if(e.sessionId!==n)return;const i=pt(s,e.subagentSessionId,r);if(!i)return;const a=Array.isArray(e.files)?e.files.filter(u=>!!u&&typeof u=="object"&&!Array.isArray(u)):[],c=`project-rules:${a.map(u=>String(u.id)).join(",")}`;o(i.messageId,i.subagent.id,u=>({toolCalls:[...(u.toolCalls||[]).filter(f=>f.toolCallId!==c),{toolCallId:c,toolName:"Project Rules",arguments:JSON.stringify({triggerPaths:e.triggerPaths,blockedWrite:e.blockedWrite}),toolKind:"readonly",status:"success",startTime:Date.now(),summary:`Project rules loaded: ${a.length}`,output:a.map(f=>`${String(f.relativePath)} ${String(f.source)} SHA-256: ${String(f.contentSha256)}`).join(`
|
|
30
|
-
`)}]}))},k_=(e,t,n)=>{const{currentSessionId:r,setConfirmation:s}=t();if(e.sessionId!==r)return;const o=e.requestId||"",i=nn(t,n,o?`assistant-permission-${o}`:void 0);if(!i)return;const a=e.details,c=e.toolName||(a==null?void 0:a.toolName)||"Tool";s(i,{toolCallId:o,toolName:c,description:e.description,diff:(a==null?void 0:a.details)||(a==null?void 0:a.diff)||"",allowRemember:(a==null?void 0:a.type)!=="mcpSampling",status:"pending"}),n(u=>({agentPhase:"waiting_permission",isStreaming:!0,sessions:u.sessions.map(f=>f.sessionId===e.sessionId&&f.projectPath===e.projectPath?{...f,pendingInteraction:{type:"permission",requestId:o}}:f)}))},y_=(e,t,n)=>{var b,x;const{currentSessionId:r,currentSessionRef:s,messages:o,setConfirmation:i,setElicitation:a}=t();if(e.sessionId!==r)return;const c=e.requestId,u=o.find(y=>{var v,k;return((k=(v=y.agentContent)==null?void 0:v.confirmation)==null?void 0:k.toolCallId)===c}),f=(b=u==null?void 0:u.agentContent)==null?void 0:b.confirmation;u&&(f==null?void 0:f.status)==="pending"&&i(u.id,{...f,status:"denied"});const p=o.find(y=>{var v,k;return((k=(v=y.agentContent)==null?void 0:v.elicitation)==null?void 0:k.toolCallId)===c}),g=(x=p==null?void 0:p.agentContent)==null?void 0:x.elicitation;p&&(g==null?void 0:g.status)==="pending"&&a(p.id,{...g,status:"cancelled"}),n({agentPhase:"running",error:"Permission request timed out",errorContext:{kind:"interaction",...s?{sessionRef:s}:{}}})},w_=(e,t,n)=>{e.sessionId===t().currentSessionId&&n({agentPhase:"running"})},S_=(e,t,n)=>{e.sessionId===t().currentSessionId&&n({agentPhase:"compacting"})},I_=(e,t,n)=>{e.sessionId===t().currentSessionId&&(t().resetContextUsage(),n({agentPhase:"running"}))},v_=(e,t,n)=>{e.sessionId===t().currentSessionId&&n({agentPhase:"switching_model"})},j_=(e,t,n)=>{const{currentSessionId:r,setQuestion:s}=t();if(e.sessionId!==r)return;const o=e.requestId||e.toolCallId||"",i=nn(t,n,o?`assistant-question-${o}`:void 0);i&&(s(i,{toolCallId:o,questions:e.questions,status:"pending"}),n(a=>({agentPhase:"waiting_permission",isStreaming:!0,sessions:a.sessions.map(c=>c.sessionId===e.sessionId&&c.projectPath===e.projectPath?{...c,pendingInteraction:{type:"question",requestId:o}}:c)})))},C_=(e,t,n)=>{const{currentSessionId:r,setElicitation:s}=t();if(e.sessionId!==r)return;const o=e.requestId||e.toolCallId||"",i=nn(t,n,o?`assistant-elicitation-${o}`:void 0),a=e.elicitation;!i||!a||(s(i,{toolCallId:o,details:a,status:"pending"}),n(c=>({agentPhase:"waiting_permission",isStreaming:!0,sessions:c.sessions.map(u=>u.sessionId===e.sessionId&&u.projectPath===e.projectPath?{...u,pendingInteraction:{type:"elicitation",requestId:o}}:u)})))},T_=(e,t,n)=>{const{currentSessionId:r}=t();if(e.sessionId!==r)return;const s=e.requestId;n(o=>({agentPhase:"running",sessions:o.sessions.map(i=>{var a;return i.sessionId===e.sessionId&&i.projectPath===e.projectPath&&((a=i.pendingInteraction)==null?void 0:a.requestId)===s?{...i,pendingInteraction:void 0}:i})}))},E_=(e,t)=>{const{currentSessionId:n,endAgentResponse:r}=t();e.sessionId===n&&r()},N_=(e,t,n)=>{const{currentSessionId:r,currentSessionRef:s,endAgentResponse:o}=t();if(e.sessionId!==r)return;const i=e.taskFailure&&typeof e.taskFailure=="object"&&!Array.isArray(e.taskFailure)?e.taskFailure:void 0,a=Lk(i==null?void 0:i.code);n({agentPhase:"error",error:e.error||"An error occurred",errorContext:{kind:"execution",...s?{sessionRef:s}:{},...a?{failureCode:a}:{}}}),o()},A_=(e,t,n)=>{const{currentSessionId:r}=t();if(e.sessionId===r)if(e.status==="idle")n({isStreaming:!1,isStopping:!1,agentPhase:"idle",currentRunId:null,pendingSteeringCount:0,pendingInputDelivery:null,recoveredSteeringCount:0});else if(e.status==="queued"||e.status==="running"||e.status==="waiting_permission"){const s=typeof e.queued=="number"?Math.max(0,e.queued):0;n({isStreaming:!0,agentPhase:e.status==="waiting_permission"?"waiting_permission":"running",currentRunId:typeof e.runId=="string"?e.runId:t().currentRunId,pendingSteeringCount:s,pendingInputDelivery:s>0&&(e.pendingInputDelivery==="current_turn"||e.pendingInputDelivery==="next_turn")?e.pendingInputDelivery:null,recoveredSteeringCount:typeof e.recovered=="number"?Math.max(0,e.recovered):t().recoveredSteeringCount})}else e.status==="error"&&n({isStreaming:!1,isStopping:!1,agentPhase:"error",currentRunId:null,pendingSteeringCount:0,pendingInputDelivery:null})},$_=(e,t,n)=>{const{currentSessionId:r,endAgentResponse:s,messages:o,updateSubagent:i}=t();if(e.sessionId===r){n(a=>({isStreaming:!1,agentPhase:"idle",messages:a.messages.map(c=>{var f;const u=(f=c.agentContent)==null?void 0:f.elicitation;return(u==null?void 0:u.status)!=="pending"||!c.agentContent?c:{...c,agentContent:{...c.agentContent,elicitation:{...u,status:"cancelled"}}}})}));for(const a of o)for(const c of Gn(a.agentContent))c.status==="running"&&i(a.id,c.id,{status:"failed"});s()}},P_=(e,t,n)=>{e.sessionId===t().currentSessionId&&n({pendingSteeringCount:typeof e.queued=="number"?Math.max(0,e.queued):1,pendingInputDelivery:"current_turn"})},O_=(e,t,n)=>{e.sessionId===t().currentSessionId&&n({pendingSteeringCount:typeof e.queued=="number"?Math.max(0,e.queued):1,pendingInputDelivery:"next_turn"})},R_=(e,t,n)=>{if(e.sessionId!==t().currentSessionId)return;const r=typeof e.queued=="number"?Math.max(0,e.queued):0;n({pendingSteeringCount:r,pendingInputDelivery:r>0?t().pendingInputDelivery:null,recoveredSteeringCount:typeof e.recovered=="number"?Math.max(0,e.recovered):t().recoveredSteeringCount})},M_=(e,t,n)=>{if(e.sessionId!==t().currentSessionId)return;const r=typeof e.queued=="number"?Math.max(0,e.queued):0;n({agentPhase:"running",pendingSteeringCount:r,pendingInputDelivery:r>0?"current_turn":null,recoveredSteeringCount:typeof e.recovered=="number"?Math.max(0,e.recovered):t().recoveredSteeringCount})},F_=(e,t,n)=>{e.sessionId===t().currentSessionId&&n({goal:e.goal??null})},__=(e,t,n)=>{e.sessionId===t().currentSessionId&&n({goal:null})},D_=(e,t,n)=>{e.sessionId===t().currentSessionId&&n({goal:e.goal??t().goal,isStreaming:!0,agentPhase:"running"})},L_=(e,t,n)=>{if(e.sessionId!==t().currentSessionId||!Array.isArray(e.messages))return;const r=Date.now(),s=e.messages.flatMap((o,i)=>{if(typeof o!="object"||o===null)return[];const a=o;return!["user","assistant","system","tool"].includes(String(a.role))||!Array.isArray(a.content)&&typeof a.content!="string"?[]:[{id:`rewind-${i}-${r}`,role:a.role,content:a.content,timestamp:r+i,metadata:typeof a.metadata=="object"&&a.metadata!==null?a.metadata:void 0,thinkingContent:typeof a.thinkingContent=="string"?a.thinkingContent:typeof a.reasoningContent=="string"?a.reasoningContent:void 0,tool_call_id:typeof a.tool_call_id=="string"?a.tool_call_id:void 0,name:typeof a.name=="string"?a.name:void 0,tool_calls:a.tool_calls}]});n({messages:xi(s),isStreaming:!1,isStopping:!1,agentPhase:"idle",currentRunId:null,pendingSteeringCount:0,pendingInputDelivery:null,recoveredSteeringCount:0,currentAssistantMessageId:null,hasToolCalls:!1})},ui={"message.created":F2,"message.delta":_2,"message.complete":D2,"thinking.delta":L2,"thinking.completed":B2,"tool.start":U2,"tool.progress":q2,"tool.result":z2,"mcp.catalog.changed":H2,"mcp.content.changed":K2,"mcp.resource.updated":G2,"mcp.connection.changed":V2,"mcp.log":W2,"mcp.instructions.changed":J2,"mcp.task.changed":Q2,"project.rules.loaded":Y2,"user.shell.started":X2,"user.shell.output":Z2,"user.shell.completed":e_,"token.usage":t_,"task.updated":n_,"subagent.start":r_,"subagent.update":s_,"subagent.delta":o_,"subagent.thinking.delta":i_,"subagent.tool.start":c_,"subagent.tool.progress":u_,"subagent.tool.result":l_,"subagent.mcp.catalog.changed":d_,"subagent.mcp.content.changed":f_,"subagent.mcp.resource.updated":m_,"subagent.mcp.connection.changed":p_,"subagent.mcp.log":g_,"subagent.mcp.instructions.changed":h_,"subagent.mcp.task.changed":b_,"subagent.project.rules.loaded":x_,"subagent.complete":a_,"permission.asked":k_,"permission.timeout":y_,"turn.started":w_,"compaction.started":S_,"compaction.completed":I_,"model.fallback":v_,"question.required":j_,"elicitation.required":C_,"interaction.resolved":T_,"session.completed":E_,"session.error":N_,"session.status":A_,"run.cancelled":$_,"steering.queued":P_,"follow_up.queued":O_,"follow_up.started":M_,"steering.applied":R_,"goal.updated":F_,"goal.cleared":__,"goal.continuation.started":D_,"session.rewound":L_},B_=new Set(["message.delta","thinking.delta","subagent.delta","subagent.thinking.delta"]),U_=new Set(["message.complete","thinking.completed","session.completed","session.error","run.cancelled"]),Zd=(e,t)=>n=>{const r=e().currentSessionRef,s=n.properties;if(!r||s.sessionId!==r.sessionId||s.projectPath!==r.projectPath)return;if(B_.has(n.type)||console.log("[SSE Event]",n.type,n.properties),U_.has(n.type)){xn.drainAll();const i=ui[n.type];i&&i(n.properties,e,t);return}if(n.type==="tool.start"&&xn.drainAll(),n.type==="message.delta"){const{currentSessionId:i,currentAssistantMessageId:a,hasToolCalls:c}=e();if(s.sessionId!==i)return;const u=s.messageId||a,f=s.delta;if(!a){const b=ui["message.delta"];b&&b(s,e,t);return}const p=c?"after":"before",g=`content:${u}:${p}`;xn.drainAllExcept(g),xn.append(g,f,b=>{const{appendDelta:x}=e();u&&x(u,b,p)});return}if(n.type==="thinking.delta"){const{currentSessionId:i,currentAssistantMessageId:a}=e();if(s.sessionId!==i)return;if(!a){const p=ui["thinking.delta"];p&&p(s,e,t);return}const c=s.delta,u=s.messageId||a,f=`thinking:${u}`;xn.drainAllExcept(f),xn.append(f,c,p=>{const{appendThinking:g}=e();u&&g(u,p)});return}if(n.type==="subagent.delta"){const{currentSessionId:i}=e();if(s.sessionId!==i)return;const a=s.delta;if(!a)return;const c=s.subagentSessionId||"",u=`subagent:${c}`,{currentAssistantMessageId:f,messages:p}=e(),g=pt(p,c||void 0,f);xn.append(u,a,b=>{const{currentAssistantMessageId:x,messages:y,updateSubagent:v}=e(),k=g||pt(y,c||void 0,x);k&&v(k.messageId,k.subagent.id,E=>({sessionId:E.sessionId||c,output:(E.output||"")+b}))});return}if(n.type==="subagent.thinking.delta"){const{currentSessionId:i}=e();if(s.sessionId!==i)return;const a=s.delta;if(!a)return;const c=s.subagentSessionId||"",u=`subagent-thinking:${c}`,{currentAssistantMessageId:f,messages:p}=e(),g=pt(p,c||void 0,f);xn.append(u,a,b=>{const{currentAssistantMessageId:x,messages:y,updateSubagent:v}=e(),k=g||pt(y,c||void 0,x);k&&v(k.messageId,k.subagent.id,E=>({sessionId:E.sessionId||c,thinking:(E.thinking||"")+b}))});return}const o=ui[n.type];o&&o(n.properties,e,t)},q_=(e,t)=>{const n=new WeakMap;let r=null;return{isStreaming:!1,isStopping:!1,agentPhase:"idle",sessionEventConnectionState:"idle",currentRunId:null,pendingSteeringCount:0,pendingInputDelivery:null,recoveredSteeringCount:0,eventUnsubscribe:null,currentAssistantMessageId:null,hasToolCalls:!1,setStreaming:s=>e({isStreaming:s}),setAgentPhase:s=>e({agentPhase:s}),setRunId:s=>e({currentRunId:s}),prepareEventSubscription:async(s,o)=>{const i=o??Zd(t,e);let a=null,c="connecting";return a=await pe.openEventSubscription(s,i,{onConnectionStateChange:u=>{c=u,a&&r===a&&e({sessionEventConnectionState:u})}}),n.set(a,c),a},replaceEventSubscription:s=>{const o=t().eventUnsubscribe;if(r=s,e({eventUnsubscribe:s,sessionEventConnectionState:s?n.get(s)??"connected":"idle"}),xn.reset(),o&&o!==s)try{o()}catch(i){console.warn("Failed to clean up previous event subscription",i)}},setCurrentAssistantMessageId:s=>e({currentAssistantMessageId:s}),setHasToolCalls:s=>e({hasToolCalls:s}),startAgentResponse:s=>{e({currentAssistantMessageId:s,hasToolCalls:!1,isStreaming:!0,agentPhase:"running"})},endAgentResponse:()=>{xn.drainAll(),e({currentAssistantMessageId:null,hasToolCalls:!1,isStreaming:!1,isStopping:!1,agentPhase:"idle",currentRunId:null,pendingSteeringCount:0,pendingInputDelivery:null})},subscribeToEvents:async s=>{const o=await t().prepareEventSubscription(s);t().replaceEventSubscription(o)},reconnectSessionEvents:async()=>{const s=t().currentSessionRef;if(s){t().unsubscribeFromEvents(),e({sessionEventConnectionState:"connecting"});try{await t().subscribeToEvents(s)}catch(o){throw e({sessionEventConnectionState:"offline"}),o}}},unsubscribeFromEvents:()=>{const{eventUnsubscribe:s}=t();r=null,e({eventUnsubscribe:null,sessionEventConnectionState:"idle"});try{s==null||s()}catch(o){console.warn("Failed to clean up event subscription",o)}finally{xn.reset()}},handleEvent:s=>{Zd(t,e)(s)}}},z_={"app.restoring":"Restoring workspace…","layout.workspace.pathAria":"Workspace path","layout.workspace.empty":"No workspace","layout.action.rewind":"Rewind session","layout.action.filePreview":"File preview","layout.action.filePreviewToggle":"Toggle file preview","layout.action.openNavigation":"Open navigation","terminal.title":"Terminal","terminal.status.connected":"Terminal connected","terminal.status.disconnected":"Terminal disconnected","terminal.action.minimize":"Minimize terminal","terminal.action.restore":"Restore terminal","terminal.action.close":"Close terminal","sidebar.brand.badge":"WEB","sidebar.action.collapse":"Collapse sidebar","sidebar.action.expand":"Expand sidebar","sidebar.navigationAria":"Task navigation","sidebar.action.newTask":"New Task","sidebar.action.newTaskShort":"New task","sidebar.action.terminal":"Terminal","sidebar.action.terminalToggle":"Toggle terminal","sidebar.action.searchTasks":"Search tasks","sidebar.unreadTasks":"{count} unread tasks","sidebar.section.skills":"Skills","sidebar.section.mcp":"MCP","sidebar.section.settings":"Settings","sidebar.status.user":"User","sidebar.status.feedLive":"Task feed live","sidebar.status.feedOffline":"Task feed offline","sidebar.empty.title":"No tasks yet","sidebar.empty.hint":"Dispatch one from the home view","sidebar.group.running":"RUNNING","sidebar.group.queued":"QUEUED","sidebar.group.interrupted":"INTERRUPTED","sidebar.group.failed":"FAILED","sidebar.group.cancelled":"CANCELLED","sidebar.group.done":"DONE","sidebar.group.showMore":"Show {count} more","sidebar.group.showLess":"Show less","sidebar.view.project":"Projects","sidebar.view.status":"Status","sidebar.view.projectAria":"Group sessions by project","sidebar.view.statusAria":"Group sessions by status","sidebar.project.active":"active","sidebar.project.expand":"Expand {name}","sidebar.project.collapse":"Collapse {name}","sidebar.project.newTask":"New task in {name}","sidebar.project.reorder":"Reorder {name}, position {position} of {count}","sidebar.project.reorderHint":"Drag to reorder, or use Up and Down arrow keys","sidebar.project.reordered":"Moved {name} to position {position}","sidebar.project.projects":"Projects","sidebar.catalog.syncing":"Syncing task history…","sidebar.catalog.loaded":"{count} loaded","sidebar.catalog.incomplete":"Task history is incomplete","sidebar.catalog.retry":"Retry","projects.dialog.title":"Projects","projects.dialog.description":"Bind local folders to switch task context without restarting Blade.","projects.bind.placeholder":"/absolute/path/to/project","projects.bind.pathLabel":"Project path","projects.bind.action":"Bind","projects.bind.failed":"Failed to bind project","projects.pick.action":"Choose project folder","projects.pick.actionShort":"Choose","projects.pick.picking":"Choosing…","projects.pick.failed":"Failed to choose a project folder","projects.unbind.action":"Unbind project","projects.unavailable":"unavailable","sidebar.language.label":"Language","sidebar.language.aria":"Switch language","sidebar.language.en":"EN","sidebar.language.zh":"中","session.env.worktree":"worktree","session.env.local":"local","session.action.select":"Select {title}","session.action.save":"Save {title}","session.action.cancel":"Cancel {title}","session.action.more":"More actions for {title}","session.action.fork":"Fork {title}","session.action.forkShort":"Fork","session.action.rename":"Rename {title}","session.action.renameShort":"Rename","session.action.archive":"Archive {title}","session.action.archiveShort":"Archive","session.action.export":"Export {title} as Markdown","session.action.exportShort":"Export Markdown","session.action.exportingShort":"Exporting…","session.action.delete":"Delete {title}","session.action.deleteShort":"Delete","session.action.stop":"Stop {title}","session.action.stopping":"Stopping {title}","session.action.retry":"Retry {title}","session.action.retrying":"Retrying {title}","session.reason.cancelledByUser":"Cancelled by user","session.forkedFrom":"Forked from","session.retriedFrom":"Retried from","session.retryShort":"retry","session.queued":"#{position}/{depth} queued","archive.title":"Archive","archive.subtitle":"Stored safely outside the active task list","archive.open":"Open session archive","archive.refresh":"Refresh archived sessions","archive.retry":"Retry","archive.loading":"Loading archive…","archive.empty":"No archived sessions","archive.restore":"Restore {title}","archive.restoreShort":"Restore","archive.restoreAncestor":"Restore the archive root first","archive.inherited":"Archived with {id}","taskSwitcher.title":"Task switcher","taskSwitcher.description":"Search and open tasks across every project.","taskSwitcher.searchAria":"Search tasks","taskSwitcher.placeholder":"Search title, project, branch, status, or session ID…","taskSwitcher.results":"{count} results","taskSwitcher.recent":"Recent tasks","taskSwitcher.scope":"{count} tasks indexed","taskSwitcher.indexing":"Indexing tasks…","taskSwitcher.resultsAria":"Task search results","taskSwitcher.current":"Current","taskSwitcher.unread":"{count} unread","taskSwitcher.needsAction":"{count} need action","taskSwitcher.new":"New","taskSwitcher.empty":"No matching tasks","taskSwitcher.emptyHint":"Try a project, branch, status, or shorter phrase.","taskSwitcher.hint.navigate":"navigate","taskSwitcher.hint.open":"open","taskSwitcher.hint.toggle":"toggle","taskSwitcher.action.failed":"Task action failed","commandCenter.title":"Command center","commandCenter.description":"Search tasks or run workspace and application actions.","commandCenter.searchAria":"Search actions","commandCenter.placeholder":"Search actions, settings, or tools…","commandCenter.modeAria":"Command center mode","commandCenter.mode.tasks":"Tasks","commandCenter.mode.commands":"Actions","commandCenter.actions":"{count} actions","commandCenter.resultsAria":"Action search results","commandCenter.empty":"No matching actions","commandCenter.emptyHint":"Try a tool, panel, or setting name.","commandCenter.action.newTask":"New task","commandCenter.action.newTaskDescription":"Open a clean task composer","commandCenter.action.preview":"Toggle preview","commandCenter.action.previewDescription":"Review files, diffs, and run logs","commandCenter.action.terminal":"Toggle terminal","commandCenter.action.terminalDescription":"Open or close the workspace shell","commandCenter.action.settings":"Open settings","commandCenter.action.settingsDescription":"Configure appearance and behavior","commandCenter.action.models":"Configure models","commandCenter.action.modelsDescription":"Select providers and task models","commandCenter.action.shortcuts":"View keyboard shortcuts","commandCenter.action.shortcutsDescription":"Browse global and contextual keys","commandCenter.action.skills":"Manage skills","commandCenter.action.skillsDescription":"Discover and configure agent capabilities","commandCenter.action.mcp":"Manage MCP servers","commandCenter.action.mcpDescription":"Configure connected tools and servers","commandCenter.action.sidebar":"Toggle sidebar","commandCenter.action.sidebarDescription":"Show or hide project navigation","taskHome.eyebrow":"Task dispatcher · Ready","taskHome.feed.connecting":"Task dispatcher · Connecting","taskHome.feed.reconnecting":"Task dispatcher · Reconnecting","taskHome.feed.offline":"Task dispatcher · Offline","taskHome.feed.offlineDescription":"Live task updates are paused. Running tasks continue on the server.","taskHome.feed.retry":"Reconnect","taskHome.hero.prefix":"What should Blade build in","taskHome.hero.projectFallback":"current workspace","taskHome.hero.subtitle":"Dispatch a task and keep moving. Each task runs in its own worktree, persists state, and returns with a reviewable workspace when it's done.","taskHome.templates.title":"Templates","taskHome.templates.hint":"1–4 to prefill","taskHome.template.explore.title":"Explore","taskHome.template.explore.description":"Trace behavior and explain the system","taskHome.template.explore.hint":"Trace a call · map a module","taskHome.template.build.title":"Build","taskHome.template.build.description":"Implement a production-ready feature","taskHome.template.build.hint":"Ship a feature end-to-end","taskHome.template.review.title":"Review","taskHome.template.review.description":"Find correctness and regression risks","taskHome.template.review.hint":"Audit current changes","taskHome.template.fix.title":"Fix","taskHome.template.fix.description":"Diagnose and repair a concrete failure","taskHome.template.fix.hint":"Bisect · reproduce · patch","taskHome.context.isolationToggleTitle":"Toggle task isolation","taskHome.context.projectSelect":"Select target project","taskHome.context.isolation.worktree":"Isolated worktree","taskHome.context.isolation.local":"Local workspace","taskHome.context.branchFallback":"no branch","taskHome.context.preparing":"Preparing worktree","taskHome.setup.aria":"Task setup status","taskHome.setup.title":"Finish setup","taskHome.setup.description":"Keep drafting while Blade verifies the workspace and model.","taskHome.setup.workspace.title":"Workspace","taskHome.setup.workspace.loading":"Checking available workspaces…","taskHome.setup.workspace.ready":"{project} selected","taskHome.setup.workspace.required":"Choose an available project","taskHome.setup.workspace.empty":"No project","taskHome.setup.workspace.action":"Choose","taskHome.setup.workspace.retry":"Reload workspaces","taskHome.setup.model.title":"Model","taskHome.setup.model.loading":"Checking configuration…","taskHome.setup.model.ready":"Ready for this task","taskHome.setup.model.required":"Configure or select a model","taskHome.setup.model.action":"Configure","taskHome.setup.model.retry":"Retry","taskHome.composer.placeholder":"Describe the outcome, constraints, and verification you expect...","taskHome.error.dismiss":"Dismiss","taskHome.recent.title":"Recent tasks","taskHome.recent.total":"{count} total","taskHome.recent.partial":"{count} loaded · syncing","taskHome.recent.incomplete":"{count} loaded · history incomplete","taskSwitcher.indexingLoaded":"{count} loaded · syncing history","taskHome.footer.note":"Worktree isolation keeps parallel tasks from touching your active checkout","capacity.title":"{inFlight} running · {queued} queued · max {max}","capacity.suffix.running":" running","capacity.queued":"{queued} queued","recent.status.running":"running","recent.status.queued":"queued","recent.status.paused":"paused","recent.status.failed":"failed","recent.status.cancelled":"cancelled","recent.status.done":"done","recent.time.justNow":"just now","recent.time.minutes":"{n}m ago","recent.time.hours":"{n}h ago","recent.time.days":"{n}d ago","recent.session.fallbackShort":"Session {id}","recent.session.fallbackDated":"Session {y}-{m}-{d} {hh}:{mm}","attention.unreadAnnouncement":"{count} unread task updates","attention.notification.completed":"Task completed","attention.notification.failed":"Task failed","attention.notification.interrupted":"Task interrupted","attention.notification.permission":"Approval required","attention.notification.question":"Answer required","attention.notification.elicitation":"MCP input required","interaction.permission.title":"Permission required: {tool}","interaction.permission.once":"Allow once","interaction.permission.session":"Allow for session","interaction.permission.project":"Allow for project","interaction.permission.deny":"Deny","interaction.permission.failed":"Failed to respond to permission","interaction.question.answered":"Questions answered","interaction.question.other":"Other","interaction.question.submit":"Submit answers","interaction.question.failed":"Failed to submit answers","interaction.elicitation.title":"MCP input requested","interaction.elicitation.submit":"Submit to MCP","interaction.elicitation.open":"Open external URL","interaction.elicitation.decline":"Decline","interaction.elicitation.cancel":"Cancel","interaction.elicitation.responded":"MCP request answered","interaction.elicitation.cancelled":"MCP request cancelled","interaction.elicitation.failed":"Failed to respond to MCP request","interaction.elicitation.warning":"Only continue if you trust this MCP server and understand the request.","interaction.bar.permissionTitle":"Agent needs approval","interaction.bar.permissionHint":"Review the pending tool request before this task can continue.","interaction.bar.questionTitle":"Agent needs your answer","interaction.bar.questionHint":"Answer the pending question before this task can continue.","interaction.bar.elicitationTitle":"MCP server needs your input","interaction.bar.elicitationHint":"Review the MCP request before this task can continue.","interaction.bar.review":"Review request","interaction.badge.permission":"Needs approval","interaction.badge.question":"Needs answer","interaction.badge.elicitation":"MCP input","artifact.env.isolated":"isolated","artifact.env.local":"local","artifact.review":"Review changes","artifact.commits":"{count} commits","artifact.apply":"Apply","artifact.retryApply":"Retry apply","artifact.applying":"Applying","artifact.applied":"Applied","artifact.discard":"Discard task changes","artifact.discarded":"Discarded","artifact.conflict":"The task changes could not be applied safely.","artifact.conflictHint":"The isolated changes are preserved. Review them, resolve the source project, then retry or discard.","artifact.discardDialog.title":"Discard isolated changes?","artifact.discardDialog.description":"Remove {count} changed files from the isolated task workspace for {project}.","artifact.discardDialog.warning":"This permanently removes the task worktree and branch. Your source project is not modified.","artifact.discardDialog.cancel":"Keep changes","artifact.discardDialog.confirm":"Discard changes","chat.list.empty.eyebrow":"Blade · Ready","chat.list.empty.title":"Start a conversation to begin","chat.list.empty.hint":"Ask a question, describe a change, or paste a stack trace.","chat.list.loading.eyebrow":"Conversation history","chat.list.loading.title":"Restoring conversation…","chat.list.loading.hint":"Loading messages, task state, and live updates. Larger conversations may take a moment.","chat.list.showEarlier":"Show {count} earlier messages","chat.list.showEarlierWithRemaining":"Show {count} earlier messages, {remaining} hidden","chat.list.jumpLatest":"Jump to latest","chat.turns.aria":"Jump to a previous message","chat.turns.label":"Turn {n}","chat.timeline.thinking":"Thought process","chat.timeline.tools.runningOne":"Running 1 command","chat.timeline.tools.running":"Running {count} commands","chat.timeline.tools.completedOne":"Executed 1 command","chat.timeline.tools.completed":"Executed {count} commands","chat.timeline.tools.completedOneWithError":"Executed 1 command · failed","chat.timeline.tools.completedWithErrors":"Executed {count} commands · {errors} failed","chat.error.dismiss":"Dismiss error","chat.error.queueFull":"The guidance queue is full. Wait for pending instructions to start, then retry.","chat.error.turnChanged":"The active turn changed before this message was accepted. Review and retry it.","chat.error.title.submission":"Message not sent.","chat.error.title.execution":"Run stopped.","chat.error.title.navigation":"Task not opened.","chat.error.title.generic":"Action failed.","chat.error.action.returnDraft":"Return to draft","chat.error.action.editResend":"Edit and resend","chat.error.action.retryTask":"Retry task","chat.error.action.retryingTask":"Retrying…","chat.error.action.checkModels":"Check model settings","task.failure.authentication":"Provider authentication failed. Check model credentials.","task.failure.permission":"Provider rejected this request. Check account and model permissions.","task.failure.rateLimit":"Provider rate limit or quota exceeded.","task.failure.timeout":"Provider request timed out.","task.failure.network":"Provider connection failed.","task.failure.modelUnavailable":"The selected model is unavailable.","task.failure.contextLimit":"The request exceeded the model context limit.","task.failure.unsupportedInput":"The selected model does not support this input.","task.failure.runtime":"Agent execution failed.","chat.connection.reconnecting":"Reconnecting live updates. The active run continues in the background.","chat.connection.offline":"Live updates are offline. Progress shown here may be stale.","chat.connection.retry":"Reconnect","chat.footer.disclaimer":"Blade can make mistakes. Please check important information.","chat.input.placeholder.default":"Type @ for files, / for commands...","chat.input.placeholder.steering":"Add guidance to steer the active turn...","chat.input.steering.status":"Active turn is steerable","chat.input.steering.queued":"Guidance accepted · {count} pending","chat.input.steering.enterHint":" · Enter sends guidance","chat.input.followUp.queued":"Follow-up accepted · {count} queued for the next turn","chat.input.steering.recoveredOne":"Recovered {count} queued instruction after restart","chat.input.steering.recoveredMany":"Recovered {count} queued instructions after restart","chat.input.attachment.add":"Attach images","chat.input.attachment.remove":"Remove","chat.input.attachment.countLimit":"You can attach up to {count} images.","chat.input.attachment.sizeLimit":"Images must stay under {size} total. Remove an image or choose smaller files.","chat.input.attachment.readFailed":"Blade could not read one of these images.","chat.input.attachment.usage":"{count}/{limit} images · {used} of {budget}","chat.input.attachment.modelUnsupported":"{model} does not support images. Choose a vision model or remove the images.","chat.input.attachment.modelRequired":"Choose a vision-capable model before attaching images.","chat.input.model.placeholder":"Select Model","chat.input.model.empty":"No models configured","chat.input.model.vision":"Vision","chat.input.model.change":"Change model","chat.input.model.locked":"Wait for the active turn to finish before switching models","chat.input.effort.label":"Effort {effort}","chat.input.effort.heading":"Reasoning effort","chat.input.effort.change":"Change reasoning effort","chat.input.effort.locked":"Wait for the active turn to finish before changing reasoning effort","chat.input.effort.option":"Use {effort} reasoning effort","chat.input.effort.autoHint":"near high","chat.input.serviceTier.label":"Speed {tier}","chat.input.serviceTier.heading":"Provider service tier","chat.input.serviceTier.change":"Change provider service tier","chat.input.serviceTier.locked":"Wait for the current turn to finish before changing service tier","chat.input.serviceTier.option":"Use {tier} service tier","chat.input.serviceTier.fastHint":"priority","chat.input.serviceTier.flexHint":"lower cost","chat.input.responseVerbosity.label":"Output {verbosity}","chat.input.responseVerbosity.heading":"Response verbosity","chat.input.responseVerbosity.change":"Change response verbosity","chat.input.responseVerbosity.locked":"Wait for the current turn to finish before changing response verbosity","chat.input.responseVerbosity.option":"Use {verbosity} response verbosity","chat.input.responseVerbosity.autoHint":"model default","chat.input.communicationStyle.label":"Style {style}","chat.input.communicationStyle.heading":"Communication style","chat.input.communicationStyle.change":"Change communication style","chat.input.communicationStyle.locked":"Wait for the current turn to finish before changing communication style","chat.input.communicationStyle.option":"Use {style} communication style","chat.input.communicationStyle.autoHint":"Blade default","chat.input.communicationStyle.pragmaticHint":"direct","chat.input.communicationStyle.friendlyHint":"warm","chat.input.communicationStyle.explanatoryHint":"explain choices","chat.notice.dismiss":"Dismiss notice","chat.input.mode.default":"Default","chat.input.mode.autoEdit":"Auto Edit","chat.input.mode.plan":"Plan","chat.input.action.stop":"Stop active turn","chat.input.action.stopping":"Stopping active turn","chat.input.action.steer":"Steer active turn","chat.input.action.send":"Send message","chat.input.action.submitting":"Submitting message","status.context":"Context","status.tokenLimitTooltip":"Token limit is estimated. It updates when the model reports its context size.","status.phase.running":"Generating...","status.phase.compacting":"Compacting context...","status.phase.switchingModel":"Switching model...","status.phase.waitingPermission":"Waiting for permission...","status.phase.error":"Run failed","preview.title":"Preview","preview.action.resize":"Resize preview","preview.action.close":"Close preview","preview.action.retry":"Retry","preview.tab.diff":"Diff","preview.tab.files":"Files","preview.tab.logs":"Logs","preview.diff.loadingTitle":"Loading task diff…","preview.diff.loadingHint":"Reading the durable worktree artifact.","preview.diff.failedTitle":"Failed to load task diff","preview.diff.discardedTitle":"Changes discarded","preview.diff.discardedHint":"The isolated workspace was removed. The source project was not changed.","preview.diff.emptyTitle":"No patch yet","preview.diff.emptyHint":"Run a tool that changes files to see diffs here.","preview.diff.searchAria":"Search changed files","preview.diff.searchPlaceholder":"Filter changed files…","preview.diff.changedFiles":"{count} changed files","preview.diff.expandAll":"Expand all","preview.diff.collapseAll":"Collapse all","preview.diff.showMoreFiles":"Show {count} more files","preview.diff.showMoreLines":"Show {count} more lines","preview.diff.noMatches":"No matching changed files","preview.diff.patch":"Patch","preview.diff.line":"Line {line}","preview.files.loadingTitle":"Loading files…","preview.files.loadingHint":"Fetching workspace tree.","preview.files.failedTitle":"Failed to load files","preview.files.emptyTitle":"No files yet","preview.files.emptyHint":"Select a project to load its workspace tree.","preview.files.treeFailed":"Failed to load workspace tree","preview.files.searchAria":"Search workspace files","preview.files.searchPlaceholder":"Find a file…","preview.files.searchResultsAria":"File search results","preview.files.searchFailed":"Failed to search workspace files","preview.files.noMatches":"No matching files","preview.files.directoryLoading":"Loading folder…","preview.files.directoryEmpty":"Empty folder","preview.files.selectTitle":"Select a file to preview","preview.files.status.loading":"Loading…","preview.files.status.truncated":"Truncated","preview.files.status.ready":"Ready","preview.files.truncatedNotice":"Preview truncated to 200k characters.","preview.files.pickHint":"Pick a file from the tree to preview.","preview.files.contentFailed":"Failed to load file","preview.files.editorLoading":"Loading editor…","preview.logs.searchAria":"Search tool logs","preview.logs.searchPlaceholder":"Search tool, summary, or output…","preview.logs.filterAria":"Filter logs by status","preview.logs.filter.all":"All","preview.logs.filter.running":"Running","preview.logs.filter.error":"Failed","preview.logs.filter.success":"Success","preview.logs.noMatches":"No matching logs","preview.logs.noMatchesHint":"Try another phrase or status.","preview.logs.emptyTitle":"No logs yet","preview.logs.emptyHint":"Tool runs will appear here.","preview.logs.expand":"Expand","preview.logs.collapse":"Collapse","preview.logs.showMore":"Show {count} more logs","preview.logs.status.running":"Running","preview.logs.status.error":"Failed","preview.logs.status.success":"Success","goal.aria.section":"Goal controls","goal.status.active":"Goal running","goal.status.paused":"Goal paused","goal.status.blocked":"Goal blocked","goal.status.usageLimited":"Usage limited","goal.status.budgetLimited":"Budget reached","goal.status.complete":"Goal complete","goal.field.objective":"Goal objective","goal.action.edit":"Edit goal","goal.action.pause":"Pause goal","goal.action.resume":"Resume goal","goal.action.delete":"Delete goal","goal.action.expand":"Expand goal details","goal.action.collapse":"Collapse goal details","goal.action.cancel":"Cancel","goal.action.save":"Save","goal.metrics.tokens":"tokens","goal.metrics.continuationOne":"{n} continuation","goal.metrics.continuationMany":"{n} continuations","goal.dialog.title":"Delete this goal?","goal.dialog.description":"The goal state will be removed. Session history and workspace files are not affected."},H_={"app.restoring":"正在恢复工作区…","layout.workspace.pathAria":"工作区路径","layout.workspace.empty":"未选择工作区","layout.action.rewind":"回溯会话","layout.action.filePreview":"文件预览","layout.action.filePreviewToggle":"切换文件预览","layout.action.openNavigation":"打开导航","terminal.title":"终端","terminal.status.connected":"终端已连接","terminal.status.disconnected":"终端未连接","terminal.action.minimize":"最小化终端","terminal.action.restore":"恢复终端","terminal.action.close":"关闭终端","sidebar.brand.badge":"网页版","sidebar.action.collapse":"收起侧边栏","sidebar.action.expand":"展开侧边栏","sidebar.navigationAria":"任务导航","sidebar.action.newTask":"新建任务","sidebar.action.newTaskShort":"新建任务","sidebar.action.terminal":"终端","sidebar.action.terminalToggle":"切换终端","sidebar.action.searchTasks":"搜索任务","sidebar.unreadTasks":"{count} 个未读任务","sidebar.section.skills":"技能","sidebar.section.mcp":"MCP","sidebar.section.settings":"设置","sidebar.status.user":"用户","sidebar.status.feedLive":"任务通道已连接","sidebar.status.feedOffline":"任务通道未连接","sidebar.empty.title":"暂无任务","sidebar.empty.hint":"在主页派发新任务","sidebar.group.running":"进行中","sidebar.group.queued":"排队中","sidebar.group.interrupted":"已暂停","sidebar.group.failed":"已失败","sidebar.group.cancelled":"已取消","sidebar.group.done":"已完成","sidebar.group.showMore":"再显示 {count} 条","sidebar.group.showLess":"收起","sidebar.view.project":"项目","sidebar.view.status":"状态","sidebar.view.projectAria":"按项目分组会话","sidebar.view.statusAria":"按状态分组会话","sidebar.project.active":"当前","sidebar.project.expand":"展开 {name}","sidebar.project.collapse":"收起 {name}","sidebar.project.newTask":"在 {name} 中新建任务","sidebar.project.reorder":"调整 {name} 的顺序,当前位置 {position}/{count}","sidebar.project.reorderHint":"拖拽调整顺序,或使用上下方向键移动","sidebar.project.reordered":"已将 {name} 移到第 {position} 位","sidebar.project.projects":"项目","sidebar.catalog.syncing":"正在同步任务历史…","sidebar.catalog.loaded":"已载入 {count} 条","sidebar.catalog.incomplete":"任务历史未完整加载","sidebar.catalog.retry":"重试","projects.dialog.title":"项目","projects.dialog.description":"绑定本地目录,无需重启 Blade 即可切换任务上下文。","projects.bind.placeholder":"/项目的绝对路径","projects.bind.pathLabel":"项目路径","projects.bind.action":"绑定","projects.bind.failed":"项目绑定失败","projects.pick.action":"选择项目文件夹","projects.pick.actionShort":"选择","projects.pick.picking":"选择中…","projects.pick.failed":"无法选择项目文件夹","projects.unbind.action":"解除项目绑定","projects.unavailable":"目录不可用","sidebar.language.label":"语言","sidebar.language.aria":"切换语言","sidebar.language.en":"EN","sidebar.language.zh":"中","session.env.worktree":"独立分支","session.env.local":"本地","session.action.select":"选择「{title}」","session.action.save":"保存「{title}」","session.action.cancel":"取消「{title}」","session.action.more":"「{title}」的更多操作","session.action.fork":"派生「{title}」","session.action.forkShort":"派生","session.action.rename":"重命名「{title}」","session.action.renameShort":"重命名","session.action.archive":"归档「{title}」","session.action.archiveShort":"归档","session.action.export":"将「{title}」导出为 Markdown","session.action.exportShort":"导出 Markdown","session.action.exportingShort":"正在导出…","session.action.delete":"删除「{title}」","session.action.deleteShort":"删除","session.action.stop":"停止「{title}」","session.action.stopping":"正在停止「{title}」","session.action.retry":"重试「{title}」","session.action.retrying":"正在重试「{title}」","session.reason.cancelledByUser":"已由用户取消","session.forkedFrom":"派生自","session.retriedFrom":"重试自","session.retryShort":"重试","session.queued":"排队 #{position}/{depth}","archive.title":"归档","archive.subtitle":"安全保留,不占用当前任务列表","archive.open":"打开会话归档","archive.refresh":"刷新归档会话","archive.retry":"重试","archive.loading":"正在载入归档…","archive.empty":"暂无归档会话","archive.restore":"恢复「{title}」","archive.restoreShort":"恢复","archive.restoreAncestor":"请先恢复归档根会话","archive.inherited":"随 {id} 一同归档","taskSwitcher.title":"任务切换器","taskSwitcher.description":"跨项目搜索并打开任务。","taskSwitcher.searchAria":"搜索任务","taskSwitcher.placeholder":"搜索标题、项目、分支、状态或 Session ID…","taskSwitcher.results":"{count} 个结果","taskSwitcher.recent":"最近任务","taskSwitcher.scope":"已索引 {count} 个任务","taskSwitcher.indexing":"正在索引任务…","taskSwitcher.resultsAria":"任务搜索结果","taskSwitcher.current":"当前","taskSwitcher.unread":"{count} 个未读","taskSwitcher.needsAction":"{count} 个需要操作","taskSwitcher.new":"新","taskSwitcher.empty":"没有匹配的任务","taskSwitcher.emptyHint":"尝试项目、分支、状态或更短的关键词。","taskSwitcher.hint.navigate":"选择","taskSwitcher.hint.open":"打开","taskSwitcher.hint.toggle":"切换","taskSwitcher.action.failed":"任务操作失败","commandCenter.title":"命令中心","commandCenter.description":"搜索任务,或执行工作区与应用操作。","commandCenter.searchAria":"搜索操作","commandCenter.placeholder":"搜索操作、设置或工具…","commandCenter.modeAria":"命令中心模式","commandCenter.mode.tasks":"任务","commandCenter.mode.commands":"操作","commandCenter.actions":"{count} 个操作","commandCenter.resultsAria":"操作搜索结果","commandCenter.empty":"没有匹配的操作","commandCenter.emptyHint":"尝试工具、面板或设置名称。","commandCenter.action.newTask":"新建任务","commandCenter.action.newTaskDescription":"打开一个干净的任务编辑器","commandCenter.action.preview":"切换预览区","commandCenter.action.previewDescription":"审查文件、Diff 与运行日志","commandCenter.action.terminal":"切换终端","commandCenter.action.terminalDescription":"打开或关闭工作区 Shell","commandCenter.action.settings":"打开设置","commandCenter.action.settingsDescription":"配置外观与行为","commandCenter.action.models":"配置模型","commandCenter.action.modelsDescription":"选择 Provider 与任务模型","commandCenter.action.shortcuts":"查看键盘快捷键","commandCenter.action.shortcutsDescription":"浏览全局与上下文按键","commandCenter.action.skills":"管理 Skills","commandCenter.action.skillsDescription":"发现并配置 Agent 能力","commandCenter.action.mcp":"管理 MCP Server","commandCenter.action.mcpDescription":"配置已连接的工具与服务","commandCenter.action.sidebar":"切换侧边栏","commandCenter.action.sidebarDescription":"显示或隐藏项目导航","taskHome.eyebrow":"任务调度台 · 就绪","taskHome.feed.connecting":"任务调度台 · 正在连接","taskHome.feed.reconnecting":"任务调度台 · 正在重连","taskHome.feed.offline":"任务调度台 · 已离线","taskHome.feed.offlineDescription":"实时任务更新已暂停,服务端正在运行的任务不会停止。","taskHome.feed.retry":"重新连接","taskHome.hero.prefix":"要在这里让 Blade 做点什么:","taskHome.hero.projectFallback":"当前工作区","taskHome.hero.subtitle":"派发一个任务后即可继续手头的工作。每个任务在独立的 worktree 中运行、状态持久保存,完成时会以可复核的工作区形式返回。","taskHome.templates.title":"模板","taskHome.templates.hint":"按 1–4 快速填充","taskHome.template.explore.title":"探索","taskHome.template.explore.description":"追踪行为,梳理系统全貌","taskHome.template.explore.hint":"调用链 · 模块结构","taskHome.template.build.title":"开发","taskHome.template.build.description":"实现一个可上线的功能","taskHome.template.build.hint":"端到端交付特性","taskHome.template.review.title":"评审","taskHome.template.review.description":"找出正确性与回归风险","taskHome.template.review.hint":"审查当前改动","taskHome.template.fix.title":"修复","taskHome.template.fix.description":"定位并修好一个具体故障","taskHome.template.fix.hint":"二分 · 复现 · 打补丁","taskHome.context.isolationToggleTitle":"切换任务隔离方式","taskHome.context.projectSelect":"选择目标项目","taskHome.context.isolation.worktree":"独立 worktree","taskHome.context.isolation.local":"本地工作区","taskHome.context.branchFallback":"无分支","taskHome.context.preparing":"正在准备 worktree","taskHome.setup.aria":"任务准备状态","taskHome.setup.title":"完成准备","taskHome.setup.description":"你可以继续编辑草稿,Blade 正在核对工作区和模型。","taskHome.setup.workspace.title":"工作区","taskHome.setup.workspace.loading":"正在检查可用工作区…","taskHome.setup.workspace.ready":"已选择 {project}","taskHome.setup.workspace.required":"选择一个可用项目","taskHome.setup.workspace.empty":"无项目","taskHome.setup.workspace.action":"选择","taskHome.setup.workspace.retry":"重新加载工作区","taskHome.setup.model.title":"模型","taskHome.setup.model.loading":"正在检查配置…","taskHome.setup.model.ready":"可用于当前任务","taskHome.setup.model.required":"配置或选择一个模型","taskHome.setup.model.action":"配置","taskHome.setup.model.retry":"重试","taskHome.composer.placeholder":"描述目标、约束以及你期望的验收方式……","taskHome.error.dismiss":"关闭","taskHome.recent.title":"最近任务","taskHome.recent.total":"共 {count} 条","taskHome.recent.partial":"已载入 {count} 条 · 继续同步","taskHome.recent.incomplete":"已载入 {count} 条 · 历史不完整","taskSwitcher.indexingLoaded":"已载入 {count} 条 · 正在同步历史","taskHome.footer.note":"独立 worktree 让并行任务不会干扰你当前的工作副本","capacity.title":"{inFlight} 进行中 · {queued} 排队 · 上限 {max}","capacity.suffix.running":" 进行中","capacity.queued":"排队 {queued}","recent.status.running":"进行中","recent.status.queued":"排队中","recent.status.paused":"已暂停","recent.status.failed":"已失败","recent.status.cancelled":"已取消","recent.status.done":"已完成","recent.time.justNow":"刚刚","recent.time.minutes":"{n} 分钟前","recent.time.hours":"{n} 小时前","recent.time.days":"{n} 天前","recent.session.fallbackShort":"会话 {id}","recent.session.fallbackDated":"会话 {y}-{m}-{d} {hh}:{mm}","attention.unreadAnnouncement":"{count} 个未读任务更新","attention.notification.completed":"任务已完成","attention.notification.failed":"任务失败","attention.notification.interrupted":"任务已中断","attention.notification.permission":"需要审批","attention.notification.question":"需要回答","attention.notification.elicitation":"MCP 需要输入","interaction.permission.title":"需要授权:{tool}","interaction.permission.once":"仅本次允许","interaction.permission.session":"本会话允许","interaction.permission.project":"本项目允许","interaction.permission.deny":"拒绝","interaction.permission.failed":"授权响应失败","interaction.question.answered":"问题已回答","interaction.question.other":"其他","interaction.question.submit":"提交回答","interaction.question.failed":"回答提交失败","interaction.elicitation.title":"MCP 请求输入","interaction.elicitation.submit":"提交给 MCP","interaction.elicitation.open":"打开外部链接","interaction.elicitation.decline":"拒绝","interaction.elicitation.cancel":"取消","interaction.elicitation.responded":"已响应 MCP 请求","interaction.elicitation.cancelled":"MCP 请求已取消","interaction.elicitation.failed":"响应 MCP 请求失败","interaction.elicitation.warning":"仅在信任该 MCP 服务器并理解请求用途时继续。","interaction.bar.permissionTitle":"Agent 正在等待审批","interaction.bar.permissionHint":"请检查待处理的工具请求,审批后任务才会继续。","interaction.bar.questionTitle":"Agent 正在等待回答","interaction.bar.questionHint":"请回答待处理的问题,任务才能继续。","interaction.bar.elicitationTitle":"MCP 服务器正在等待输入","interaction.bar.elicitationHint":"请检查 MCP 请求,响应后任务才会继续。","interaction.bar.review":"查看请求","interaction.badge.permission":"需要审批","interaction.badge.question":"需要回答","interaction.badge.elicitation":"MCP 输入","artifact.env.isolated":"独立分支","artifact.env.local":"本地","artifact.review":"查看变更","artifact.commits":"{count} 次提交","artifact.apply":"应用","artifact.retryApply":"重新应用","artifact.applying":"应用中","artifact.applied":"已应用","artifact.discard":"丢弃任务变更","artifact.discarded":"已丢弃","artifact.conflict":"任务变更无法安全应用。","artifact.conflictHint":"隔离变更已保留。请查看变更、处理源项目状态,然后重试或丢弃。","artifact.discardDialog.title":"丢弃隔离变更?","artifact.discardDialog.description":"将删除 {project} 隔离任务工作区中的 {count} 个变更文件。","artifact.discardDialog.warning":"此操作会永久删除任务 worktree 和分支,不会修改源项目。","artifact.discardDialog.cancel":"保留变更","artifact.discardDialog.confirm":"丢弃变更","chat.list.empty.eyebrow":"Blade · 就绪","chat.list.empty.title":"发送一条消息开始对话","chat.list.empty.hint":"提问、描述改动,或者粘贴一段错误堆栈。","chat.list.loading.eyebrow":"历史对话","chat.list.loading.title":"正在恢复对话…","chat.list.loading.hint":"正在加载消息、任务状态和实时更新。对话较长时可能需要一点时间。","chat.list.showEarlier":"显示更早的 {count} 条消息","chat.list.showEarlierWithRemaining":"显示更早的 {count} 条消息,当前隐藏 {remaining} 条","chat.list.jumpLatest":"回到最新消息","chat.turns.aria":"跳转到之前的消息","chat.turns.label":"第 {n} 轮","chat.timeline.thinking":"思考过程","chat.timeline.tools.runningOne":"正在执行 1 条命令","chat.timeline.tools.running":"正在执行 {count} 条命令","chat.timeline.tools.completedOne":"已执行 1 条命令","chat.timeline.tools.completed":"已执行 {count} 条命令","chat.timeline.tools.completedOneWithError":"已执行 1 条命令 · 执行失败","chat.timeline.tools.completedWithErrors":"已执行 {count} 条命令 · {errors} 条失败","chat.error.dismiss":"关闭错误","chat.error.queueFull":"指令队列已满。请等待已有指令开始执行后重试。","chat.error.turnChanged":"当前轮次已发生变化,此消息尚未接收。请确认内容后重试。","chat.error.title.submission":"消息未发送。","chat.error.title.execution":"本轮运行已停止。","chat.error.title.navigation":"未能打开任务。","chat.error.title.generic":"操作失败。","chat.error.action.returnDraft":"返回草稿","chat.error.action.editResend":"编辑后重发","chat.error.action.retryTask":"重试任务","chat.error.action.retryingTask":"正在重试…","chat.error.action.checkModels":"检查模型设置","task.failure.authentication":"模型服务认证失败,请检查模型凭据。","task.failure.permission":"模型服务拒绝了请求,请检查账号和模型权限。","task.failure.rateLimit":"模型服务达到速率或额度限制。","task.failure.timeout":"模型服务请求超时。","task.failure.network":"无法连接模型服务。","task.failure.modelUnavailable":"当前选择的模型不可用。","task.failure.contextLimit":"请求超出模型上下文限制。","task.failure.unsupportedInput":"当前模型不支持此类输入。","task.failure.runtime":"Agent 运行失败。","chat.connection.reconnecting":"正在恢复实时更新,当前任务仍在后台继续运行。","chat.connection.offline":"实时更新已离线,当前显示的进度可能已经过期。","chat.connection.retry":"重新连接","chat.footer.disclaimer":"Blade 可能会出错,请核对重要信息。","chat.input.placeholder.default":"输入 @ 提及文件,/ 触发命令……","chat.input.placeholder.steering":"添加指令来引导当前轮次……","chat.input.steering.status":"当前轮次可被引导","chat.input.steering.queued":"引导指令已接收 · 待处理 {count} 条","chat.input.steering.enterHint":" · 回车下发指令","chat.input.followUp.queued":"后续指令已接收 · 下一轮排队 {count} 条","chat.input.steering.recoveredOne":"重启后已恢复 {count} 条排队指令","chat.input.steering.recoveredMany":"重启后已恢复 {count} 条排队指令","chat.input.attachment.add":"添加图片","chat.input.attachment.remove":"移除","chat.input.attachment.countLimit":"最多可添加 {count} 张图片。","chat.input.attachment.sizeLimit":"图片编码后总大小不能超过 {size},请移除图片或选择更小的文件。","chat.input.attachment.readFailed":"Blade 无法读取其中一张图片。","chat.input.attachment.usage":"{count}/{limit} 张图片 · 已用 {used} / {budget}","chat.input.attachment.modelUnsupported":"{model} 不支持图片输入,请选择视觉模型或移除图片。","chat.input.attachment.modelRequired":"请先选择支持图片输入的视觉模型。","chat.input.model.placeholder":"选择模型","chat.input.model.empty":"未配置模型","chat.input.model.vision":"视觉","chat.input.model.change":"切换模型","chat.input.model.locked":"请等待当前轮次结束后再切换模型","chat.input.effort.label":"推理 {effort}","chat.input.effort.heading":"推理强度","chat.input.effort.change":"切换推理强度","chat.input.effort.locked":"请等待当前轮次结束后再切换推理强度","chat.input.effort.option":"使用 {effort} 推理强度","chat.input.effort.autoHint":"接近 high","chat.input.serviceTier.label":"速度 {tier}","chat.input.serviceTier.heading":"Provider 服务等级","chat.input.serviceTier.change":"切换 Provider 服务等级","chat.input.serviceTier.locked":"请等待当前轮次结束后再切换服务等级","chat.input.serviceTier.option":"使用 {tier} 服务等级","chat.input.serviceTier.fastHint":"优先通道","chat.input.serviceTier.flexHint":"低成本","chat.input.responseVerbosity.label":"输出 {verbosity}","chat.input.responseVerbosity.heading":"响应详略","chat.input.responseVerbosity.change":"切换响应详略","chat.input.responseVerbosity.locked":"请等待当前轮次结束后再切换响应详略","chat.input.responseVerbosity.option":"使用 {verbosity} 响应详略","chat.input.responseVerbosity.autoHint":"模型默认","chat.input.communicationStyle.label":"风格 {style}","chat.input.communicationStyle.heading":"沟通风格","chat.input.communicationStyle.change":"切换沟通风格","chat.input.communicationStyle.locked":"请等待当前轮次结束后再切换沟通风格","chat.input.communicationStyle.option":"使用 {style} 沟通风格","chat.input.communicationStyle.autoHint":"Blade 默认","chat.input.communicationStyle.pragmaticHint":"直接","chat.input.communicationStyle.friendlyHint":"协作","chat.input.communicationStyle.explanatoryHint":"解释取舍","chat.notice.dismiss":"关闭提示","chat.input.mode.default":"默认","chat.input.mode.autoEdit":"自动编辑","chat.input.mode.plan":"计划","chat.input.action.stop":"停止当前轮次","chat.input.action.stopping":"正在停止当前轮次","chat.input.action.steer":"引导当前轮次","chat.input.action.send":"发送消息","chat.input.action.submitting":"正在提交消息","status.context":"上下文","status.tokenLimitTooltip":"此为估算的 token 上限,模型回报上下文尺寸后会自动更新。","status.phase.running":"生成中…","status.phase.compacting":"正在压缩上下文…","status.phase.switchingModel":"正在切换模型…","status.phase.waitingPermission":"等待授权…","status.phase.error":"运行失败","preview.title":"预览","preview.action.resize":"调整预览区宽度","preview.action.close":"关闭预览区","preview.action.retry":"重试","preview.tab.diff":"变更","preview.tab.files":"文件","preview.tab.logs":"日志","preview.diff.loadingTitle":"正在加载任务变更…","preview.diff.loadingHint":"正在读取持久化的 worktree 产物。","preview.diff.failedTitle":"任务变更加载失败","preview.diff.discardedTitle":"变更已丢弃","preview.diff.discardedHint":"隔离工作区已删除,源项目没有被修改。","preview.diff.emptyTitle":"暂无变更","preview.diff.emptyHint":"工具修改文件后,变更会显示在这里。","preview.diff.searchAria":"搜索变更文件","preview.diff.searchPlaceholder":"筛选变更文件…","preview.diff.changedFiles":"{count} 个变更文件","preview.diff.expandAll":"全部展开","preview.diff.collapseAll":"全部收起","preview.diff.showMoreFiles":"再显示 {count} 个文件","preview.diff.showMoreLines":"再显示 {count} 行","preview.diff.noMatches":"没有匹配的变更文件","preview.diff.patch":"补丁","preview.diff.line":"第 {line} 行","preview.files.loadingTitle":"正在加载文件…","preview.files.loadingHint":"正在获取工作区文件树。","preview.files.failedTitle":"文件加载失败","preview.files.emptyTitle":"暂无文件","preview.files.emptyHint":"选择项目后即可加载工作区文件树。","preview.files.treeFailed":"工作区文件树加载失败","preview.files.searchAria":"搜索工作区文件","preview.files.searchPlaceholder":"查找文件…","preview.files.searchResultsAria":"文件搜索结果","preview.files.searchFailed":"工作区文件搜索失败","preview.files.noMatches":"没有匹配的文件","preview.files.directoryLoading":"正在加载目录…","preview.files.directoryEmpty":"空目录","preview.files.selectTitle":"选择要预览的文件","preview.files.status.loading":"加载中…","preview.files.status.truncated":"已截断","preview.files.status.ready":"就绪","preview.files.truncatedNotice":"预览内容已截断至 20 万字符。","preview.files.pickHint":"从文件树中选择一个文件进行预览。","preview.files.contentFailed":"文件加载失败","preview.files.editorLoading":"正在加载编辑器…","preview.logs.searchAria":"搜索工具日志","preview.logs.searchPlaceholder":"搜索工具、摘要或输出…","preview.logs.filterAria":"按状态筛选日志","preview.logs.filter.all":"全部","preview.logs.filter.running":"进行中","preview.logs.filter.error":"失败","preview.logs.filter.success":"成功","preview.logs.noMatches":"没有匹配的日志","preview.logs.noMatchesHint":"尝试其他关键词或状态。","preview.logs.emptyTitle":"暂无日志","preview.logs.emptyHint":"工具运行记录会显示在这里。","preview.logs.expand":"展开","preview.logs.collapse":"收起","preview.logs.showMore":"再显示 {count} 条日志","preview.logs.status.running":"进行中","preview.logs.status.error":"失败","preview.logs.status.success":"成功","goal.aria.section":"目标控制条","goal.status.active":"目标进行中","goal.status.paused":"目标已暂停","goal.status.blocked":"目标已阻塞","goal.status.usageLimited":"用量受限","goal.status.budgetLimited":"预算已达上限","goal.status.complete":"目标已完成","goal.field.objective":"目标描述","goal.action.edit":"编辑目标","goal.action.pause":"暂停目标","goal.action.resume":"恢复目标","goal.action.delete":"删除目标","goal.action.expand":"展开目标详情","goal.action.collapse":"收起目标详情","goal.action.cancel":"取消","goal.action.save":"保存","goal.metrics.tokens":"tokens","goal.metrics.continuationOne":"续跑 {n} 次","goal.metrics.continuationMany":"续跑 {n} 次","goal.dialog.title":"删除此目标?","goal.dialog.description":"仅移除目标状态,会话历史与工作区文件不会受影响。"},K_=["en","zh"],Va={en:z_,zh:H_},Bk="blade-ui-locale",Hu=typeof window<"u"&&typeof document<"u";function G_(){var e,t;if(Hu){try{const r=(e=window.localStorage)==null?void 0:e.getItem(Bk);if(r==="en"||r==="zh")return r}catch{}return(typeof navigator<"u"&&(navigator.language||((t=navigator.languages)==null?void 0:t[0]))||"").toLowerCase().startsWith("zh")?"zh":"en"}return"en"}let Ss=G_();const Nc=new Set;function V_(){for(const e of Nc)e()}function W_(e){var t;if(e!==Ss){if(Ss=e,Hu){try{(t=window.localStorage)==null||t.setItem(Bk,e)}catch{}document!=null&&document.documentElement&&(document.documentElement.lang=e==="zh"?"zh-CN":"en")}V_()}}function Uk(e){return Nc.add(e),()=>Nc.delete(e)}function J_(e,t){return t?e.replace(/\{(\w+)\}/g,(n,r)=>{const s=t[r];return s==null?n:String(s)}):e}function ks(e,t){const r=(Va[Ss]??Va.en)[e]??Va.en[e];return J_(r,t)}function Ut(){return w.useSyncExternalStore(Uk,()=>Ss,()=>"en"),ks}function Q_(){return{locale:w.useSyncExternalStore(Uk,()=>Ss,()=>"en"),setLocale:W_}}Hu&&(document!=null&&document.documentElement)&&(document.documentElement.lang=Ss==="zh"?"zh-CN":"en");const Y_=e=>e==="system"?typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches:e==="dark",ki=e=>{if(typeof document>"u")return;const t=document.documentElement;if(t.classList.remove("light","dark"),e==="system"){const r=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";t.classList.add(r)}else t.classList.add(e)},bn={language:"zh-CN",theme:"dracula",uiTheme:"system",autoSaveSessions:!0,notifyBuild:!0,notifyErrors:!1,notifySounds:!1,privacyTelemetry:!1,privacyCrash:!0},Mi=Ia((e,t)=>({...bn,isLoading:!1,error:null,loadSettings:async()=>{e({isLoading:!0,error:null});try{const n=await fetch("/configs");if(!n.ok)throw new Error("Failed to load settings");const r=await n.json(),s=r.uiTheme??bn.uiTheme;e({language:r.language??bn.language,theme:r.theme??bn.theme,uiTheme:s,autoSaveSessions:r.autoSaveSessions??bn.autoSaveSessions,notifyBuild:r.notifyBuild??bn.notifyBuild,notifyErrors:r.notifyErrors??bn.notifyErrors,notifySounds:r.notifySounds??bn.notifySounds,privacyTelemetry:r.privacyTelemetry??bn.privacyTelemetry,privacyCrash:r.privacyCrash??bn.privacyCrash,isLoading:!1}),ki(s)}catch(n){e({error:n.message,isLoading:!1})}},updateSettings:async n=>{const r=t();e({...n,error:null}),n.uiTheme&&ki(n.uiTheme);try{if(!(await fetch("/configs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:n,options:{scope:"global"}})})).ok)throw new Error("Failed to save settings")}catch(s){e({language:r.language,theme:r.theme,uiTheme:r.uiTheme,autoSaveSessions:r.autoSaveSessions,notifyBuild:r.notifyBuild,notifyErrors:r.notifyErrors,notifySounds:r.notifySounds,privacyTelemetry:r.privacyTelemetry,privacyCrash:r.privacyCrash,error:s.message}),n.uiTheme&&ki(r.uiTheme)}}}));ki(bn.uiTheme);const vD=()=>Mi(e=>Y_(e.uiTheme)),qk="blade.projects.selected";function ef(){return typeof localStorage>"u"?null:localStorage.getItem(qk)}function di(e){typeof localStorage<"u"&&localStorage.setItem(qk,e)}const X_=new Set(["queued","running","completed","failed","cancelled","interrupted"]),tf=new Set(["auto","off","minimal","low","medium","high","xhigh","max"]),nf=new Set(["auto","standard","fast","flex"]),rf=new Set(["auto","low","medium","high"]),sf=new Set(["auto","pragmatic","friendly","explanatory"]);function Z_(e){return typeof e=="string"&&X_.has(e)}function e5(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e;if(!["changedFiles","additions","deletions","commits"].some(r=>typeof t[r]!="number"||!Number.isInteger(t[r])||t[r]<0))return{changedFiles:t.changedFiles,additions:t.additions,deletions:t.deletions,commits:t.commits}}function of(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n=Lk(t.code);if(!(!n||typeof t.message!="string"||typeof t.retryable!="boolean"))return{code:n,message:ks(qu(n)),retryable:O2(n)}}function t5(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e;if(!(!["applied","discarded","conflicted"].includes(String(t.status))||typeof t.updatedAt!="string"))return{status:t.status,updatedAt:t.updatedAt,...typeof t.sourceCommit=="string"?{sourceCommit:t.sourceCommit}:{},...typeof t.changedFiles=="number"&&Number.isInteger(t.changedFiles)&&t.changedFiles>=0?{changedFiles:t.changedFiles}:{},...typeof t.message=="string"?{message:t.message}:{}}}function ps(e,t){return typeof e=="number"&&Number.isInteger(e)&&e>=t?e:void 0}const n5=(e,t)=>{let n=null,r=!1,s=!1,o=0;const i=new Map,a=u=>{const f=qe(u),p=++o;i.set(f,p),pe.getSession(u).then(g=>{i.get(f)===p&&e(b=>({sessions:Nn(b.sessions,g)}))}).catch(()=>{i.get(f)===p&&t().loadSessions()}).finally(()=>{i.get(f)===p&&i.delete(f)})},c=u=>{const f=qe(u),p=++o;i.set(f,p),queueMicrotask(()=>{i.get(f)===p&&i.delete(f)})};return{taskEventsConnected:!1,taskEventConnectionState:"connecting",taskEventUnsubscribe:null,taskWorkspaceInfo:null,isTaskWorkspaceLoading:!1,taskWorkspaceError:null,boundProjects:[],selectedProjectPath:ef(),isDispatchingTask:!1,isBindingProject:!1,cancellingTaskKeys:[],retryingTaskKeys:[],taskDeliveryActions:{},unreadTaskKeys:v2(),handleTaskEvent:u=>{var M,P;if(u.type==="session.created"){const N=u.properties.sessionId,O=u.properties.projectPath;if(typeof N!="string"||typeof O!="string")return;a({sessionId:N,projectPath:O});return}if(u.type==="session.deleted"){const N=u.properties.sessionId,O=u.properties.projectPath;if(typeof N!="string"||typeof O!="string")return;const _={sessionId:N,projectPath:O};c(_),t().removeSession(_);return}if(u.type==="session.archived"){const N=u.properties.sessionId,O=u.properties.projectPath;if(typeof N!="string"||typeof O!="string")return;const _={sessionId:N,projectPath:O};c(_),t().removeSession(_),t().loadArchivedSessions();return}if(u.type==="session.unarchived"){const N=u.properties.sessionId,O=u.properties.projectPath;if(typeof N!="string"||typeof O!="string")return;a({sessionId:N,projectPath:O}),t().loadArchivedSessions();return}if(u.type==="session.updated"){const N=u.properties.sessionId,O=u.properties.projectPath,_=u.properties.title,te=u.properties.selectedModelId,j=u.properties.reasoningEffort,F=u.properties.serviceTier,se=u.properties.responseVerbosity,ne=u.properties.communicationStyle;if(typeof N!="string"||typeof O!="string"||!(typeof _=="string"&&_.trim()||typeof te=="string"&&te.trim()||tf.has(j)||nf.has(F)||rf.has(se)||sf.has(ne)))return;const oe={sessionId:N,projectPath:O};if(!t().sessions.some(ve=>de(he(ve),oe))){a(oe);return}e(ve=>({sessions:ve.sessions.map(Ee=>de({sessionId:Ee.sessionId,projectPath:Ee.projectPath},oe)?{...Ee,...typeof _=="string"&&_.trim()?{title:_}:{},...typeof te=="string"&&te.trim()?{selectedModelId:te}:{},...tf.has(j)?{reasoningEffort:j}:{},...nf.has(F)?{serviceTier:F}:{},...rf.has(se)?{responseVerbosity:se}:{},...sf.has(ne)?{communicationStyle:ne}:{}}:Ee)}));return}if(u.type==="task.delivery"){const N=u.properties.sessionId,O=u.properties.projectPath,_=t5(u.properties.taskDelivery);if(typeof N!="string"||typeof O!="string"||!_)return;const te={sessionId:N,projectPath:O},j=u.properties.taskWorktreeRemoved===!0;e(F=>({sessions:F.sessions.map(se=>de(he(se),te)?{...se,taskDelivery:_,...j?{taskWorktreePath:void 0,taskWorktreeBranch:void 0}:{},lastMessageTime:typeof u.properties.updatedAt=="string"?u.properties.updatedAt:se.lastMessageTime}:se)}));return}if(u.type==="interaction.pending"){const N=u.properties.sessionId,O=u.properties.projectPath,_=u.properties.interactionType,te=u.properties.requestId;if(typeof N!="string"||typeof O!="string"||_!=="permission"&&_!=="question"&&_!=="elicitation"||typeof te!="string"||!te)return;const j={sessionId:N,projectPath:O},F=t().sessions.find(ne=>de(he(ne),j));if(!F){t().loadSessions();return}if(e(ne=>({sessions:ne.sessions.map(oe=>de(he(oe),j)?{...oe,pendingInteraction:{type:_,requestId:te}}:oe)})),!(typeof document<"u"&&document.visibilityState==="visible"&&de(t().currentSessionRef,j))&&Mi.getState().notifyErrors){const oe=F.title??F.sessionId??N;Yd({ref:j,title:`Blade · ${ks(_==="question"?"attention.notification.question":_==="elicitation"?"attention.notification.elicitation":"attention.notification.permission")}`,body:oe,onOpen:Ie=>{typeof window>"u"||(window.focus(),window.dispatchEvent(new CustomEvent(Ri,{detail:Ie})))}})}return}if(u.type==="interaction.resolved"){const N=u.properties.sessionId,O=u.properties.projectPath,_=u.properties.requestId;if(typeof N!="string"||typeof O!="string"||typeof _!="string")return;const te={sessionId:N,projectPath:O};e(j=>({sessions:j.sessions.map(F=>{var se;return de(he(F),te)&&((se=F.pendingInteraction)==null?void 0:se.requestId)===_?{...F,pendingInteraction:void 0}:F})}));return}if(u.type!=="task.status")return;const f=u.properties.sessionId,p=u.properties.projectPath,g=u.properties.taskStatus;if(typeof f!="string"||typeof p!="string"||!Z_(g))return;const b={sessionId:f,projectPath:p},x=ps(u.properties.taskInFlight,0),y=ps(u.properties.taskQueueDepth,0),v=ps(u.properties.taskConcurrencyLimit,1);x!==void 0&&y!==void 0&&v!==void 0&&e(N=>{var O;return{taskWorkspaceInfo:N.taskWorkspaceInfo?{...N.taskWorkspaceInfo,taskAdmission:{inFlight:x,queued:y,maxConcurrent:v,maxQueued:((O=N.taskWorkspaceInfo.taskAdmission)==null?void 0:O.maxQueued)??100}}:null}});const k=t().sessions.find(N=>de(he(N),b)),E=typeof document<"u"&&document.visibilityState==="visible"&&de(t().currentSessionRef,b),$=I2(k==null?void 0:k.taskStatus,g,E),B=qe(b),R=!t().unreadTaskKeys.includes(B);if($&&R){e(_=>{const te=[..._.unreadTaskKeys,B];return io(te),{unreadTaskKeys:te}});const N=Mi.getState();if(N.notifySounds&&Mk(g)&&j2(g),g==="completed"?N.notifyBuild:N.notifyErrors){const _=ks(g==="completed"?"attention.notification.completed":g==="failed"?"attention.notification.failed":"attention.notification.interrupted"),te=((M=of(u.properties.taskFailure))==null?void 0:M.message)??(typeof u.properties.taskStatusReason=="string"?u.properties.taskStatusReason:((P=k==null?void 0:k.taskFailure)==null?void 0:P.message)??(k==null?void 0:k.taskStatusReason)),j=(k==null?void 0:k.title)??(k==null?void 0:k.sessionId)??f;Yd({ref:b,title:`Blade · ${_}`,body:te?`${j} · ${te}`:j,onOpen:F=>{typeof window>"u"||(window.focus(),window.dispatchEvent(new CustomEvent(Ri,{detail:F})))}})}}if(!k){a(b);return}e(N=>({sessions:N.sessions.map(O=>de({sessionId:O.sessionId,projectPath:O.projectPath},b)?{...O,taskStatus:g,taskStatusReason:typeof u.properties.taskStatusReason=="string"?u.properties.taskStatusReason:void 0,taskFailure:g==="failed"?of(u.properties.taskFailure)??O.taskFailure:void 0,taskStartedAt:typeof u.properties.taskStartedAt=="string"?u.properties.taskStartedAt:g==="queued"?void 0:O.taskStartedAt,taskCompletedAt:typeof u.properties.taskCompletedAt=="string"?u.properties.taskCompletedAt:g==="queued"||g==="running"?void 0:O.taskCompletedAt,taskDiffStat:e5(u.properties.taskDiffStat)??O.taskDiffStat,taskQueuePosition:g==="queued"?ps(u.properties.taskQueuePosition,1)??O.taskQueuePosition:void 0,taskQueueDepth:g==="queued"?ps(u.properties.taskQueueDepth,0)??O.taskQueueDepth:void 0,taskConcurrencyLimit:ps(u.properties.taskConcurrencyLimit,1)??O.taskConcurrencyLimit,lastMessageTime:typeof u.properties.updatedAt=="string"?u.properties.updatedAt:O.lastMessageTime}:O)}))},subscribeToTaskEvents:async()=>{if(r=!0,!t().taskEventUnsubscribe){if(n)return n;e({taskEventsConnected:!1,taskEventConnectionState:"connecting"}),n=(async()=>{try{const u=await pe.openTaskEventSubscription(f=>t().handleTaskEvent(f),{onConnectionChange:f=>{e({taskEventsConnected:f})},onConnectionStateChange:f=>{r&&(f==="reconnecting"||f==="offline")&&(s=!0),e({taskEventsConnected:f==="connected",taskEventConnectionState:f}),f==="connected"&&s&&(s=!1,Promise.all([t().loadSessions(),t().loadTaskWorkspaceInfo(),t().loadBoundProjects(),Vt.getState().loadModels()]))}});if(!r||t().taskEventUnsubscribe){u();return}e({taskEventUnsubscribe:u})}catch(u){throw s=!0,e({taskEventsConnected:!1,taskEventConnectionState:"offline"}),u}})();try{await n}finally{n=null}}},reconnectTaskEvents:async()=>{s=!0,t().unsubscribeFromTaskEvents(),await t().subscribeToTaskEvents()},unsubscribeFromTaskEvents:()=>{var u,f;r=!1,(f=(u=t()).taskEventUnsubscribe)==null||f.call(u),e({taskEventUnsubscribe:null,taskEventsConnected:!1,taskEventConnectionState:"offline"})},loadTaskWorkspaceInfo:async()=>{e({isTaskWorkspaceLoading:!0,taskWorkspaceError:null});try{const u=await pe.getWorkspaceInfo();e({taskWorkspaceInfo:u,isTaskWorkspaceLoading:!1})}catch(u){e({isTaskWorkspaceLoading:!1,taskWorkspaceError:u instanceof Error?u.message:"Failed to load task workspace"})}},loadBoundProjects:async()=>{try{const u=await pe.listProjects(),f=ef(),p=u.find(g=>g.available&&g.path===f)??u.find(g=>g.isCurrent)??u.find(g=>g.available);p&&di(p.path),e({boundProjects:u,selectedProjectPath:(p==null?void 0:p.path)??null})}catch(u){e({error:u instanceof Error?u.message:"Failed to load projects"})}},bindProject:async u=>{e({isBindingProject:!0,error:null});try{const f=await pe.bindProject(u);di(f.path),e(p=>({boundProjects:[...p.boundProjects.filter(g=>g.path!==f.path),f].sort((g,b)=>g.isCurrent!==b.isCurrent?g.isCurrent?-1:1:g.name.localeCompare(b.name)),selectedProjectPath:f.path,isBindingProject:!1}))}catch(f){throw e({isBindingProject:!1,error:f instanceof Error?f.message:"Failed to bind project"}),f}},unbindProject:async u=>{try{await pe.unbindProject(u),e(f=>{const p=f.boundProjects.filter(b=>b.path!==u||b.isCurrent),g=f.selectedProjectPath===u?p.find(b=>b.isCurrent)??p.find(b=>b.available):void 0;return g&&di(g.path),{boundProjects:p,...g?{selectedProjectPath:g.path}:{}}})}catch(f){throw e({error:f instanceof Error?f.message:"Failed to unbind project"}),f}},selectProject:u=>{di(u),e({selectedProjectPath:u})},markTaskRead:u=>{const f=qe(u);e(p=>{const g=p.unreadTaskKeys.filter(b=>b!==f);return io(g),{unreadTaskKeys:g}})},clearUnreadTasks:()=>{io([]),e({unreadTaskKeys:[]})},cancelTask:async u=>{const f=qe(u);if(!t().cancellingTaskKeys.includes(f)){e(p=>({cancellingTaskKeys:[...p.cancellingTaskKeys,f],error:null,errorContext:null}));try{await pe.abortSession(u);const p=de(t().currentSessionRef,u);p&&t().unsubscribeFromEvents(),e(g=>({sessions:g.sessions.map(b=>de(he(b),u)?{...b,taskStatus:"cancelled",taskQueuePosition:void 0,taskQueueDepth:void 0,taskCompletedAt:b.taskCompletedAt??new Date().toISOString()}:b),...p?{isStreaming:!1,isStopping:!1,agentPhase:"idle",currentRunId:null,pendingSteeringCount:0,pendingInputDelivery:null,recoveredSteeringCount:0,currentAssistantMessageId:null,hasToolCalls:!1,eventUnsubscribe:null}:{}}))}catch(p){throw e({error:p instanceof Error?p.message:"Failed to stop task",errorContext:{kind:"task_action",sessionRef:u}}),p}finally{e(p=>({cancellingTaskKeys:p.cancellingTaskKeys.filter(g=>g!==f)}))}}},retryTask:async u=>{const f=qe(u);if(t().retryingTaskKeys.includes(f))return;const p=t().getNavigationVersion(),g=t().selectedProjectPath,b=()=>t().getNavigationVersion()===p&&t().selectedProjectPath===g;e(x=>({retryingTaskKeys:[...x.retryingTaskKeys,f],error:null,errorContext:null}));try{const x=await pe.retryTask(u);e(y=>({sessions:Nn(y.sessions,x.session)})),t().markTaskRead(u),b()&&await t().selectSession(he(x.session))}catch(x){throw b()&&e({error:x instanceof Error?x.message:"Failed to retry task",errorContext:{kind:"task_action",sessionRef:u}}),x}finally{e(x=>({retryingTaskKeys:x.retryingTaskKeys.filter(y=>y!==f)}))}},deliverTask:async(u,f)=>{const p=qe(u);if(!t().taskDeliveryActions[p]){e(g=>({taskDeliveryActions:{...g.taskDeliveryActions,[p]:f},error:null,errorContext:null}));try{const g=await pe.deliverTask(u,f);e(b=>({sessions:Nn(b.sessions,g)})),t().markTaskRead(u)}catch(g){throw e({error:g instanceof Error?g.message:"Failed to deliver task changes",errorContext:{kind:"task_action",sessionRef:u}}),g}finally{e(g=>{const{[p]:b,...x}=g.taskDeliveryActions;return{taskDeliveryActions:x}})}}},dispatchTask:async u=>{const f=t().getNavigationVersion(),p=t().selectedProjectPath,g=u.projectPath??p??void 0,b=()=>t().getNavigationVersion()===f&&t().selectedProjectPath===p;e({isDispatchingTask:!0,error:null,errorContext:null});try{const x=await pe.createTask({...u,projectPath:g});e(y=>({sessions:Nn(y.sessions,x.session),isDispatchingTask:!1})),b()&&await t().selectSession(he(x.session))}catch(x){throw e({isDispatchingTask:!1,...b()?{error:x instanceof Error?x.message:"Failed to dispatch task"}:{}}),x}}}},r5=e=>({tokenUsage:Zs,updateTokenUsage:t=>e(n=>{const{costUsd:r,...s}=t;return{tokenUsage:{...n.tokenUsage,...s,totalInputTokens:n.tokenUsage.totalInputTokens+Math.max(0,t.inputTokens??0),totalOutputTokens:n.tokenUsage.totalOutputTokens+Math.max(0,t.outputTokens??0),cacheReadTokens:n.tokenUsage.cacheReadTokens+Math.max(0,t.cacheReadTokens??0),cacheWriteTokens:n.tokenUsage.cacheWriteTokens+Math.max(0,t.cacheWriteTokens??0),estimatedCostUsd:n.tokenUsage.estimatedCostUsd+Math.max(0,r??0)}}}),resetContextUsage:()=>e(t=>({tokenUsage:{...t.tokenUsage,inputTokens:0,outputTokens:0,totalTokens:0}})),setMaxContextTokens:(t,n=!1)=>e(r=>({tokenUsage:{...r.tokenUsage,maxContextTokens:t,isDefaultMaxTokens:n}}))}),U=Ia()((...e)=>({...$2(...e),...n5(...e),...g2(...e),...q_(...e),...r5(...e)}));function s5(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function o5({open:e,onOpenChange:t}){const n=U(R=>R.currentSessionRef),r=U(R=>R.isStreaming),s=U(R=>R.isTemporarySession),o=U(R=>R.rewindSession),[i,a]=w.useState([]),[c,u]=w.useState(null),[f,p]=w.useState(!1),[g,b]=w.useState(!1),[x,y]=w.useState(!1),[v,k]=w.useState(null);w.useEffect(()=>{if(!e||!n)return;let R=!1;return b(!0),k(null),a([]),u(null),p(!1),pe.listRewindCheckpoints(n).then(M=>{var P;R||(a(M),u(((P=M[0])==null?void 0:P.messageId)??null))}).catch(M=>{R||k(M instanceof Error?M.message:"Failed to load rewind checkpoints")}).finally(()=>{R||b(!1)}),()=>{R=!0}},[n,e]);const E=w.useMemo(()=>i.find(R=>R.messageId===c)??null,[i,c]),$=!!E&&!g&&!x&&!r&&!s,B=async()=>{if(!E||!$)return;y(!0),k(null);const R=await o(E.messageId,f?"both":"conversation");y(!1),R?t(!1):k("Rewind failed. Review the session error and try again.")};return l.jsx(Rf,{open:e,onOpenChange:t,children:l.jsxs(Uc,{className:"max-w-[620px] gap-0 overflow-hidden border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b]",children:[l.jsx(qc,{className:"border-b border-[#E5E7EB] px-6 py-5 dark:border-zinc-800",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-md bg-[#F3F4F6] text-[#4B5563] dark:bg-zinc-800 dark:text-zinc-300",children:l.jsx(ad,{className:"h-4 w-4"})}),l.jsxs("div",{children:[l.jsx(zc,{className:"text-[15px] font-semibold text-[#111827] dark:text-zinc-100",children:"Rewind session"}),l.jsx(Hc,{className:"mt-1 text-[12px] text-[#6B7280] dark:text-zinc-400",children:"Return to the point before a user message."})]})]})}),l.jsxs("div",{className:"min-h-[260px] px-6 py-4",children:[g&&l.jsxs("div",{className:"flex h-[220px] items-center justify-center text-[#6B7280] dark:text-zinc-400",children:[l.jsx(ct,{className:"mr-2 h-4 w-4 animate-spin"}),l.jsx("span",{className:"text-xs font-mono",children:"Loading checkpoints"})]}),!g&&v&&l.jsx("div",{role:"alert",className:"rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-xs text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300",children:v}),!g&&!v&&i.length===0&&l.jsxs("div",{className:"flex h-[220px] flex-col items-center justify-center text-center",children:[l.jsx(ad,{className:"mb-3 h-5 w-5 text-[#9CA3AF] dark:text-zinc-600"}),l.jsx("p",{className:"text-sm text-[#4B5563] dark:text-zinc-300",children:"Nothing to rewind to yet"})]}),!g&&i.length>0&&l.jsx("div",{role:"radiogroup","aria-label":"Rewind checkpoint",className:"max-h-[310px] space-y-1 overflow-y-auto",children:i.map(R=>{const M=R.messageId===c;return l.jsxs("button",{type:"button",role:"radio","aria-checked":M,onClick:()=>u(R.messageId),className:V("w-full rounded-md border px-4 py-3 text-left transition-colors",M?"border-[#22C55E] bg-[#F0FDF4] dark:border-[#22C55E] dark:bg-[#052E16]/50":"border-transparent hover:bg-[#F9FAFB] dark:hover:bg-zinc-900"),children:[l.jsxs("div",{className:"flex items-start justify-between gap-4",children:[l.jsx("p",{className:"line-clamp-2 text-[13px] leading-5 text-[#111827] dark:text-zinc-100",children:R.preview||"User message"}),l.jsx("span",{className:"shrink-0 text-[10px] font-mono text-[#9CA3AF] dark:text-zinc-500",children:s5(R.createdAt)})]}),l.jsxs("div",{className:"mt-2 flex items-center gap-3 text-[10px] font-mono text-[#6B7280] dark:text-zinc-500",children:[l.jsx("span",{children:R.messageId.slice(0,10)}),R.fileCount>0&&l.jsxs("span",{className:"inline-flex items-center gap-1",children:[l.jsx(qy,{className:"h-3 w-3"}),R.fileCount," ",R.fileCount===1?"file":"files"]})]})]},R.messageId)})})]}),l.jsx("div",{className:"border-t border-[#E5E7EB] px-6 py-4 dark:border-zinc-800",children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[l.jsx("input",{type:"checkbox",checked:f,disabled:!E||E.fileCount===0,onChange:R=>p(R.target.checked),className:"mt-0.5 h-4 w-4 accent-[#16A34A] disabled:opacity-40"}),l.jsxs("span",{children:[l.jsx("span",{className:"block text-[12px] font-medium text-[#374151] dark:text-zinc-200",children:"Restore code changes"}),l.jsx("span",{className:"mt-0.5 block text-[11px] text-[#6B7280] dark:text-zinc-500",children:"Revert files changed at and after this checkpoint."})]})]})}),l.jsxs(Ff,{className:"border-t border-[#E5E7EB] px-6 py-4 dark:border-zinc-800",children:[l.jsx(mr,{variant:"ghost",onClick:()=>t(!1),disabled:x,children:"Cancel"}),l.jsxs(mr,{onClick:()=>void B(),disabled:!$,className:"bg-[#16A34A] text-white hover:bg-[#15803D]",children:[x?l.jsx(ct,{className:"mr-2 h-4 w-4 animate-spin"}):l.jsx(Li,{className:"mr-2 h-4 w-4"}),"Rewind"]})]})]})})}function zk({inFlight:e,queued:t,maxConcurrent:n,compact:r=!1,className:s}){const o=Ut(),i=Math.max(1,n),a=Array.from({length:Math.min(i,12)}),c=Math.min(e,i);return l.jsxs("div",{className:V("inline-flex items-center gap-2 font-mono",r?"text-[10.5px]":"text-[11px]",s),title:o("capacity.title",{inFlight:e,queued:t,max:n}),children:[l.jsx("span",{className:V("inline-flex items-center gap-[3px] rounded-sm",r?"px-0":"px-0.5"),children:a.map((u,f)=>{const p=f<c;return l.jsx("span",{className:V("block",r?"h-2.5 w-[3px] rounded-[1px]":"h-3 w-[3px] rounded-[1px]",p?"bg-[hsl(var(--deck-accent))] shadow-[0_0_4px_hsl(var(--deck-accent)/0.65)]":"bg-[hsl(var(--deck-border-strong))]/60")},f)})}),l.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-ink-muted))]",children:[l.jsx("span",{className:"text-[hsl(var(--deck-ink))]",children:e}),l.jsx("span",{className:"mx-[2px] opacity-40",children:"/"}),l.jsx("span",{children:n}),l.jsx("span",{className:"opacity-60",children:o("capacity.suffix.running")})]}),t>0&&l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm border border-amber-300/60 bg-amber-50 px-1.5 py-[1px] text-[10px] text-amber-800 dark:border-amber-800/60 dark:bg-amber-950/40 dark:text-amber-300",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-amber-500"}),o("capacity.queued",{queued:t})]})]})}function af(){const e=document.querySelector("textarea[data-blade-composer]:not(:disabled)");if(!e)return!1;e.focus();const t=e.value.length;return e.setSelectionRange(t,t),!0}const Hk=[{id:"searchTasks",key:"k",primaryModifier:!0,scope:"Global"},{id:"openCommands",key:"p",primaryModifier:!0,shiftKey:!0,scope:"Global"},{id:"newTask",key:"n",primaryModifier:!1,scope:"Global"},{id:"focusComposer",key:"/",primaryModifier:!1,scope:"Chat"},{id:"toggleSidebar",key:"b",primaryModifier:!0,scope:"Layout"}];function i5(e){const t=e.key.toLocaleLowerCase();return Hk.find(n=>{if(n.key!==t||e.altKey||e.shiftKey!==!!n.shiftKey)return!1;const r=e.metaKey||e.ctrlKey;return n.primaryModifier?r:!r})??null}function a5(e){return e instanceof Element?!!e.closest('input, textarea, select, [contenteditable="true"], [role="textbox"], [role="combobox"]'):!1}function c5(e){var r;const t=typeof navigator>"u"?null:navigator,n=((r=t==null?void 0:t.userAgentData)==null?void 0:r.platform)??(t==null?void 0:t.platform)??"";return/mac|iphone|ipad|ipod/i.test(n)}function l5(e,t){const n=e.key==="/"?"/":e.key.toLocaleUpperCase(),r=c5();return[...e.primaryModifier?[r?"⌘":"Ctrl"]:[],...e.shiftKey?[r?"⇧":"Shift"]:[],n]}function Ac(e,t){const n=Hk.find(r=>r.id===e);return n?l5(n).join(""):""}const Kk="blade.sidebar.view",Gk="blade.preview.width",Wa=640,u5=360,d5=960,f5=()=>{if(typeof localStorage>"u")return"project";const e=localStorage.getItem(Kk);return e==="status"||e==="project"?e:"project"},Vk=e=>Math.min(d5,Math.max(u5,Math.round(e))),m5=()=>{if(typeof localStorage>"u")return Wa;const e=localStorage.getItem(Gk);if(!e)return Wa;const t=Number(e);return Number.isFinite(t)?Vk(t):Wa},pr=Ia(e=>({isSidebarOpen:!0,toggleSidebar:()=>e(t=>({isSidebarOpen:!t.isSidebarOpen})),setSidebarOpen:t=>e({isSidebarOpen:t}),sidebarView:f5(),setSidebarView:t=>{typeof localStorage<"u"&&localStorage.setItem(Kk,t),e({sidebarView:t})},isFilePreviewOpen:!1,toggleFilePreview:()=>e(t=>({isFilePreviewOpen:!t.isFilePreviewOpen})),setFilePreviewOpen:t=>e({isFilePreviewOpen:t}),previewWidth:m5(),setPreviewWidth:t=>{const n=Vk(t);typeof localStorage<"u"&&localStorage.setItem(Gk,String(n)),e({previewWidth:n})},previewTab:"diff",setPreviewTab:t=>e({previewTab:t}),previewTargetPath:null,previewRequestId:0,openFilePreview:t=>e(n=>({isFilePreviewOpen:!0,previewTab:(t==null?void 0:t.tab)??n.previewTab,previewTargetPath:(t==null?void 0:t.targetPath)??null,previewRequestId:n.previewRequestId+1})),isSettingsOpen:!1,settingsSection:"general",toggleSettings:()=>e(t=>({isSettingsOpen:!t.isSettingsOpen,...t.isSettingsOpen?{}:{settingsSection:"general"}})),openSettings:(t="general")=>e({isSettingsOpen:!0,settingsSection:t}),isMcpOpen:!1,toggleMcp:()=>e(t=>({isMcpOpen:!t.isMcpOpen})),isSkillsOpen:!1,toggleSkills:()=>e({isSettingsOpen:!0,settingsSection:"skills"}),isTerminalOpen:!1,toggleTerminal:()=>e(t=>({isTerminalOpen:!t.isTerminalOpen})),isTaskSwitcherOpen:!1,taskSwitcherMode:"tasks",setTaskSwitcherOpen:(t,n)=>e(r=>({isTaskSwitcherOpen:t,taskSwitcherMode:n??r.taskSwitcherMode})),setTaskSwitcherMode:t=>e({taskSwitcherMode:t})}));function p5(){const e=pr(r=>r.setTaskSwitcherOpen),t=pr(r=>r.toggleSidebar),n=U(r=>r.startTemporarySession);w.useEffect(()=>{const r=s=>{if(s.repeat)return;const o=i5(s);if(!o)return;const i=pr.getState(),a=i.isTaskSwitcherOpen,c=a5(s.target),u=!!document.querySelector('[role="dialog"]');if(o.id==="searchTasks"||o.id==="openCommands"){if(u&&!a)return;s.preventDefault();const f=o.id==="searchTasks"?"tasks":"commands",p=a&&i.taskSwitcherMode===f;e(!p,f);return}if(!(c||u)){if(o.id==="newTask"){s.preventDefault(),n(),requestAnimationFrame(()=>af());return}if(o.id==="focusComposer"){af()&&s.preventDefault();return}o.id==="toggleSidebar"&&(s.preventDefault(),t())}};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,n,t])}const Ku=w.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(bf,{ref:r,className:V("overflow-hidden relative",e),...n,children:[l.jsx(Fy,{className:"h-full w-full rounded-[inherit] [&>div]:!block !overflow-auto",children:t}),l.jsx(Wk,{}),l.jsx(_y,{})]}));Ku.displayName=bf.displayName;const Wk=w.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(xf,{ref:r,orientation:t,className:V("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:l.jsx(Dy,{className:"relative flex-1 rounded-full bg-border"})}));Wk.displayName=xf.displayName;function ao(e,t){var s;const n=(s=e.title)==null?void 0:s.trim();if(n)return n;const r=e.firstMessageTime||e.lastMessageTime;if(r){const o=new Date(r);if(!Number.isNaN(o.getTime()))return t("recent.session.fallbackDated",{y:String(o.getFullYear()).slice(-2),m:String(o.getMonth()+1).padStart(2,"0"),d:String(o.getDate()).padStart(2,"0"),hh:String(o.getHours()).padStart(2,"0"),mm:String(o.getMinutes()).padStart(2,"0")})}return t("recent.session.fallbackShort",{id:e.sessionId.slice(0,6)})}async function Jk(e,t=!1){const n=await pe.exportSessionMarkdown(e,t),r=new Blob([n.markdown],{type:"text/markdown;charset=utf-8"}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=n.filename,o.hidden=!0,document.body.appendChild(o);try{o.click()}finally{o.remove(),await new Promise(i=>{window.setTimeout(()=>{URL.revokeObjectURL(s),i()},0)})}return n}const Bn=By,Un=Uy,An=w.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},s)=>l.jsx(Ly,{children:l.jsx(kf,{ref:s,align:t,sideOffset:n,className:V("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 origin-[--radix-popover-content-transform-origin]",e),...r})}));An.displayName=kf.displayName;function g5(){const e=Ut(),t=U(x=>x.archivedSessions),n=U(x=>x.archivedCatalogLoadState),r=U(x=>x.archivedCatalogError),s=U(x=>x.loadArchivedSessions),o=U(x=>x.unarchiveSession),i=U(x=>x.setError),[a,c]=w.useState(!1),[u,f]=w.useState(null),[p,g]=w.useState(null),b=x=>{c(x),x&&s()};return l.jsxs(Bn,{open:a,onOpenChange:b,children:[l.jsx(Un,{asChild:!0,children:l.jsxs("button",{type:"button",className:"flex h-8 w-full items-center justify-between rounded-md px-2.5 font-mono text-[12.5px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]","aria-label":e("archive.open"),children:[l.jsxs("span",{className:"flex items-center gap-2.5",children:[l.jsx(yf,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-ink-faint))]"}),e("archive.title")]}),t.length>0&&l.jsx("span",{className:"rounded-sm bg-[hsl(var(--deck-surface))] px-1.5 py-0.5 text-[9px] text-[hsl(var(--deck-ink-faint))]",children:t.length})]})}),l.jsxs(An,{role:"dialog","aria-label":e("archive.title"),side:"right",align:"end",sideOffset:8,className:"w-[340px] overflow-hidden p-0",children:[l.jsxs("div",{className:"flex h-10 items-center justify-between border-b border-[hsl(var(--deck-hairline))] px-3",children:[l.jsxs("div",{children:[l.jsx("div",{className:"font-mono text-[11px] font-medium uppercase tracking-[0.08em] text-[hsl(var(--deck-ink))]",children:e("archive.title")}),l.jsx("div",{className:"text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:e("archive.subtitle")})]}),l.jsx("button",{type:"button",onClick:()=>void s(),"aria-label":e("archive.refresh"),className:"flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:l.jsx(to,{className:V("h-3 w-3",(n==="loading"||n==="hydrating")&&"animate-spin")})})]}),r?l.jsxs("div",{className:"px-3 py-4 text-[11px] text-red-600 dark:text-red-400",children:[l.jsx("div",{children:r}),l.jsx("button",{type:"button",onClick:()=>void s(),className:"mt-2 font-mono text-[10px] text-[hsl(var(--deck-accent))] focus-visible:outline-none focus-visible:underline",children:e("archive.retry")})]}):t.length===0&&(n==="loading"||n==="hydrating")?l.jsxs("div",{className:"flex h-24 items-center justify-center gap-2 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:[l.jsx(ct,{className:"h-3 w-3 animate-spin"}),e("archive.loading")]}):t.length===0?l.jsx("div",{className:"flex h-24 items-center justify-center px-6 text-center text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:e("archive.empty")}):l.jsx(Ku,{className:"max-h-[340px]",children:l.jsx("div",{className:"divide-y divide-[hsl(var(--deck-hairline))]",children:t.map(x=>{var $;const y=he(x),v=qe(y),k=u===v,E=x.projectPath.split("/").filter(Boolean).at(-1)??x.projectPath;return l.jsxs("div",{className:"flex min-h-[58px] items-center gap-2 px-3 py-2",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate font-mono text-[11.5px] text-[hsl(var(--deck-ink))]",children:ao(x,e)}),l.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:[l.jsx("span",{className:"truncate",children:E}),x.archivedAt&&l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":!0,children:"·"}),l.jsx("span",{children:new Date(x.archivedAt).toLocaleString()})]})]}),x.archivedBySessionId!==x.sessionId&&l.jsx("div",{className:"mt-0.5 truncate text-[9px] text-[hsl(var(--deck-accent))]",children:e("archive.inherited",{id:(($=x.archivedBySessionId)==null?void 0:$.slice(0,8))??""})})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[l.jsx("button",{type:"button",disabled:p!==null,onClick:async()=>{g(v);try{await Jk(y)}catch(B){i(B instanceof Error?B.message:"Session export failed")}finally{g(null)}},"aria-label":e("session.action.export",{title:ao(x,e)}),title:e("session.action.exportShort"),className:"flex h-7 w-7 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-wait disabled:opacity-35",children:p===v?l.jsx(ct,{className:"h-3.5 w-3.5 animate-spin"}):l.jsx(wf,{className:"h-3.5 w-3.5"})}),l.jsx("button",{type:"button",disabled:k||x.archivedBySessionId!==x.sessionId,onClick:async()=>{f(v);try{await o(y)}finally{f(null)}},"aria-label":e("archive.restore",{title:ao(x,e)}),title:x.archivedBySessionId!==x.sessionId?e("archive.restoreAncestor"):e("archive.restoreShort"),className:"flex h-7 w-7 items-center justify-center rounded text-[hsl(var(--deck-accent))] transition-colors hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-not-allowed disabled:opacity-35",children:k?l.jsx(ct,{className:"h-3.5 w-3.5 animate-spin"}):l.jsx(zy,{className:"h-3.5 w-3.5"})})]})]},v)})})})]})]})}function Gu({className:e,size:t=28,pulse:n=!0}){return l.jsxs("span",{className:V("inline-flex relative justify-center items-center","text-[hsl(var(--deck-ink))]",e),style:{width:t,height:t},"aria-hidden":"true",children:[l.jsxs("svg",{viewBox:"0 0 32 32",width:t,height:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M16 3 L28 16 L16 29 L4 16 Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),l.jsx("path",{d:"M16 8 L24 16 L16 24",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round",opacity:"0.55"}),l.jsx("path",{d:"M16 3 L20 7",stroke:"hsl(var(--deck-accent))",strokeWidth:"2",strokeLinecap:"round"})]}),n&&l.jsx("span",{className:"absolute top-[3px] right-[3px] h-1.5 w-1.5 rounded-full",style:{background:"hsl(var(--deck-accent-glow))",boxShadow:"0 0 6px hsl(var(--deck-accent-glow) / 0.9)"}})]})}const cf={en:"sidebar.language.en",zh:"sidebar.language.zh"};function Qk({className:e,variant:t="pill"}){const{locale:n,setLocale:r}=Q_(),s=Ut();if(t==="compact"){const o=n==="en"?"zh":"en";return l.jsx("button",{type:"button",onClick:()=>r(o),"aria-label":s("sidebar.language.aria"),title:s("sidebar.language.label"),className:V("flex justify-center items-center w-10 h-10 font-mono font-medium rounded-md transition-colors text-[11px] text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",e),children:s(cf[n])})}return l.jsx("div",{role:"group","aria-label":s("sidebar.language.aria"),className:V("inline-flex h-8 items-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-[2px] font-mono text-[11px]",e),children:K_.map(o=>{const i=o===n;return l.jsx("button",{type:"button",onClick:()=>r(o),"aria-pressed":i,className:V("flex justify-center items-center px-2 h-full transition-colors min-w-[28px] rounded-[4px]",i?"bg-[hsl(var(--deck-ink))] text-[hsl(var(--deck-canvas))]":"text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:s(cf[o])},o)})})}const h5="[data-mobile-navigation-trigger]";function jD(e){return Yk(h5,e)}function Yk(e,t){const n=document.querySelector(e);return!n||n.getClientRects().length===0?!1:(t.preventDefault(),n.focus({preventScroll:!0}),!0)}function Xk({open:e,onOpenChange:t}){const n=Ut(),{boundProjects:r,selectedProjectPath:s,isBindingProject:o,loadBoundProjects:i,bindProject:a,unbindProject:c,selectProject:u,startTemporarySession:f}=U(),[p,g]=w.useState(""),[b,x]=w.useState(null),[y,v]=w.useState(!1),k=w.useRef(0);w.useEffect(()=>{if(e){i();return}k.current+=1,v(!1)},[i,e]);const E=async M=>{await a(M),g(""),f(),t(!1)},$=async M=>{if(M.preventDefault(),!(!p.trim()||o||y)){x(null);try{await E(p.trim())}catch(P){x(P instanceof Error?P.message:n("projects.bind.failed"))}}},B=async()=>{if(y||o)return;const M=++k.current;x(null),v(!0);try{const P=await pe.pickProjectDirectory();if(M!==k.current||P.cancelled)return;g(P.path),await E(P.path)}catch(P){if(M!==k.current)return;x(P instanceof Error?P.message:n("projects.pick.failed"))}finally{M===k.current&&v(!1)}},R=M=>{u(M),f(),t(!1)};return e?l.jsx(Rf,{open:e,onOpenChange:t,children:l.jsxs(Uc,{onCloseAutoFocus:M=>Yk("[data-project-setup-trigger]",M),className:"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-ink))] sm:max-w-xl",children:[l.jsxs(qc,{children:[l.jsxs(zc,{className:"flex items-center gap-2 font-mono text-[16px]",children:[l.jsx(yi,{className:"h-4 w-4 text-[hsl(var(--deck-accent))]"}),n("projects.dialog.title")]}),l.jsx(Hc,{className:"text-[12px] text-[hsl(var(--deck-ink-muted))]",children:n("projects.dialog.description")})]}),l.jsxs("form",{onSubmit:$,className:"flex gap-2",children:[l.jsx("input",{value:p,onChange:M=>g(M.target.value),disabled:o,placeholder:n("projects.bind.placeholder"),"aria-label":n("projects.bind.pathLabel"),className:"h-9 min-w-0 flex-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 font-mono text-[12px] outline-none placeholder:text-[hsl(var(--deck-ink-faint))] focus:border-[hsl(var(--deck-accent)/0.65)]"}),l.jsxs("button",{type:"button",onClick:()=>void B(),disabled:y||o,title:n("projects.pick.action"),"aria-label":n("projects.pick.action"),className:"inline-flex h-9 shrink-0 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))] disabled:cursor-wait disabled:opacity-50",children:[y?l.jsx(ct,{className:"h-3.5 w-3.5 animate-spin"}):l.jsx(Hy,{className:"h-3.5 w-3.5"}),l.jsx("span",{className:"hidden sm:inline",children:n(y?"projects.pick.picking":"projects.pick.actionShort")})]}),l.jsxs("button",{type:"submit",disabled:!p.trim()||o||y,className:"inline-flex h-9 items-center gap-2 rounded-md bg-[hsl(var(--deck-ink))] px-3 font-mono text-[12px] text-[hsl(var(--deck-canvas))] transition-opacity disabled:opacity-40",children:[o?l.jsx(ct,{className:"h-3.5 w-3.5 animate-spin"}):l.jsx(yi,{className:"h-3.5 w-3.5"}),n("projects.bind.action")]})]}),b&&l.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:b}),l.jsx("div",{className:"max-h-72 space-y-1 overflow-y-auto",children:r.map(M=>{const P=M.path===s;return l.jsxs("div",{className:V("group flex items-center gap-3 rounded-md border px-3 py-2",P?"border-[hsl(var(--deck-accent)/0.55)] bg-[hsl(var(--deck-accent-soft))]":"border-transparent hover:border-[hsl(var(--deck-border))] hover:bg-[hsl(var(--deck-surface))]"),children:[l.jsx(no,{className:V("h-4 w-4 shrink-0",P?"text-[hsl(var(--deck-accent))]":"text-[hsl(var(--deck-ink-faint))]")}),l.jsxs("button",{type:"button",disabled:!M.available,onClick:()=>R(M.path),className:"min-w-0 flex-1 text-left disabled:cursor-not-allowed disabled:opacity-50",children:[l.jsx("span",{className:"block truncate font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:M.name}),l.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 truncate font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:[M.gitBranch&&l.jsxs(l.Fragment,{children:[l.jsx(Fc,{className:"h-2.5 w-2.5"}),l.jsx("span",{children:M.gitBranch}),l.jsx("span",{children:"·"})]}),l.jsx("span",{className:"truncate",children:M.path}),!M.available&&l.jsxs("span",{className:"shrink-0 text-red-500",children:["· ",n("projects.unavailable")]})]})]}),!M.isCurrent&&l.jsx("button",{type:"button",onClick:()=>void c(M.path).catch(()=>{}),title:n("projects.unbind.action"),"aria-label":n("projects.unbind.action"),className:"rounded p-1.5 text-[hsl(var(--deck-ink-faint))] opacity-0 transition group-hover:opacity-100 hover:bg-red-50 hover:text-red-600 focus-visible:opacity-100 dark:hover:bg-red-950/30",children:l.jsx(Sf,{className:"h-3.5 w-3.5"})})]},M.path)})})]})}):null}const b5={running:"bg-blue-500 dark:bg-blue-400 shadow-[0_0_5px_rgba(59,130,246,0.7)] animate-pulse",queued:"bg-amber-400 dark:bg-amber-300",interrupted:"bg-orange-500 dark:bg-orange-400",failed:"bg-red-500 dark:bg-red-400",cancelled:"bg-zinc-400 dark:bg-zinc-500",completed:"bg-[hsl(var(--deck-accent))]"};function x5({session:e,isActive:t,isForking:n,isUnread:r,anyForking:s,isEditing:o,editingTitle:i,title:a,context:c,isCancelling:u,isRetrying:f,isExporting:p,onSelect:g,onCancelTask:b,onRetryTask:x,onFork:y,onArchive:v,onExport:k,onStartRename:E,onDelete:$,onEditingTitleChange:B,onSaveRename:R,onCancelRename:M}){const P=Ut(),[N,O]=w.useState(!1),_=w.useRef(null),te=w.useRef(null);return o?l.jsxs("div",{className:"flex h-9 w-full items-center gap-2 bg-[hsl(var(--deck-surface))] px-3",children:[l.jsx("input",{type:"text",value:i,onChange:j=>B(j.target.value),onKeyDown:j=>{j.key==="Enter"&&R(),j.key==="Escape"&&M()},autoFocus:!0,className:"flex-1 rounded bg-[hsl(var(--deck-canvas))] px-2 py-1 font-mono text-[13px] text-[hsl(var(--deck-ink))] outline-none focus:ring-1 focus:ring-[hsl(var(--deck-accent))]"}),l.jsx("button",{"aria-label":P("session.action.save",{title:a}),onClick:R,className:"flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-accent))] hover:bg-[hsl(var(--deck-canvas))]",children:l.jsx(Ky,{className:"w-3 h-3"})}),l.jsx("button",{"aria-label":P("session.action.cancel",{title:a}),onClick:M,className:"flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-canvas))]",children:l.jsx(eo,{className:"w-3 h-3"})})]}):l.jsxs("div",{className:V("flex relative items-center w-full transition-colors group min-h-[54px]",t?"bg-[hsl(var(--deck-surface))]":"hover:bg-[hsl(var(--deck-surface))]/60"),children:[t&&l.jsx("span",{className:"absolute left-0 top-1/2 h-6 w-[2px] -translate-y-1/2 rounded-r bg-[hsl(var(--deck-accent))]"}),l.jsxs("button",{type:"button","aria-label":P("session.action.select",{title:a}),"aria-current":t?"true":void 0,"aria-busy":n?"true":void 0,onClick:g,className:"flex min-h-[54px] min-w-0 flex-1 cursor-pointer items-center gap-2 py-1.5 pl-4 pr-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[l.jsx("span",{className:V("h-1.5 w-1.5 shrink-0 rounded-full",e.pendingInteraction?"animate-pulse bg-amber-500 shadow-[0_0_5px_rgba(245,158,11,0.75)]":b5[e.taskStatus]),title:e.pendingInteraction?P(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission"):e.taskStatus}),l.jsxs("span",{className:"flex-1 min-w-0 font-mono",children:[l.jsxs("span",{className:V("flex gap-2 items-center text-left truncate text-[12px]",t?"text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))]"),children:[l.jsx("span",{className:"truncate",children:a}),r&&l.jsx("span",{title:P("taskSwitcher.new"),className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[hsl(var(--deck-accent))] shadow-[0_0_5px_hsl(var(--deck-accent-glow)/0.75)]"}),e.pendingInteraction&&l.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-amber-100 px-1.5 py-0.5 text-[8.5px] text-amber-800 dark:bg-amber-950/60 dark:text-amber-300",title:P(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission"),children:[l.jsx(co,{className:"h-2.5 w-2.5"}),P(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission")]}),e.relationType==="fork"&&e.parentId&&l.jsxs("span",{title:`${P("session.forkedFrom")} ${e.parentId.slice(0,6)}`,"aria-label":`${P("session.forkedFrom")} ${e.parentId.slice(0,6)}`,className:"shrink-0 text-[9px] text-[hsl(var(--deck-accent))]",children:[P("session.forkedFrom")," ",e.parentId.slice(0,6)]}),e.taskRetriedFrom&&l.jsx("span",{title:`${P("session.retriedFrom")} ${e.taskRetriedFrom.sessionId.slice(0,6)}`,className:"shrink-0 text-[9px] text-[hsl(var(--deck-accent))]",children:P("session.retryShort")})]}),l.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 truncate text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[l.jsx("span",{className:"truncate",children:c.project}),l.jsx("span",{className:"opacity-50",children:"·"}),l.jsx("span",{className:"truncate",children:c.environment}),c.queue&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"opacity-50",children:"·"}),l.jsx("span",{className:"text-amber-700 truncate dark:text-amber-400",children:c.queue})]}),c.diff&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"opacity-50",children:"·"}),l.jsx("span",{className:"truncate text-[hsl(var(--deck-accent))]",children:c.diff})]})]}),c.reason&&l.jsx("span",{title:c.reason,className:"mt-0.5 block truncate text-[9.5px] text-red-600 dark:text-red-400",children:c.reason})]}),n&&l.jsx(ct,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"})]}),l.jsxs("div",{className:V("flex items-center gap-0.5 pr-2 transition-opacity group-focus-within:opacity-100",e.taskStatus==="running"||e.taskStatus==="queued"||e.taskRetryAvailable&&(e.taskStatus==="failed"||e.taskStatus==="interrupted"||e.taskStatus==="cancelled")?"opacity-100":"opacity-50 group-hover:opacity-100"),children:[(e.taskStatus==="running"||e.taskStatus==="queued")&&l.jsx("button",{type:"button","aria-label":P(u?"session.action.stopping":"session.action.stop",{title:a}),disabled:u,onClick:j=>{j.stopPropagation(),b()},className:"flex h-6 w-6 items-center justify-center rounded text-red-500 transition-colors hover:bg-red-500/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60",children:u?l.jsx(ct,{className:"h-3 w-3 animate-spin"}):l.jsx(_c,{className:"h-3 w-3"})}),e.taskRetryAvailable&&(e.taskStatus==="failed"||e.taskStatus==="interrupted"||e.taskStatus==="cancelled")&&l.jsx("button",{ref:_,type:"button","aria-label":P(f?"session.action.retrying":"session.action.retry",{title:a}),disabled:f,onClick:j=>{j.stopPropagation(),x()},className:"flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-accent))] transition-colors hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-wait disabled:opacity-60",children:f?l.jsx(ct,{className:"h-3 w-3 animate-spin"}):l.jsx(Li,{className:"h-3 w-3"})}),l.jsxs(Bn,{open:N,onOpenChange:O,children:[l.jsx(Un,{asChild:!0,children:l.jsx("button",{type:"button","aria-label":P("session.action.more",{title:a}),"aria-expanded":N,className:"flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-canvas))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:l.jsx(Gy,{className:"h-3.5 w-3.5"})})}),l.jsxs(An,{ref:te,role:"menu","aria-label":P("session.action.more",{title:a}),side:"right",align:"start",sideOffset:6,className:"w-40 p-1",onOpenAutoFocus:j=>{var F,se;j.preventDefault(),(se=(F=te.current)==null?void 0:F.querySelector('[role="menuitem"]:not([disabled])'))==null||se.focus()},onKeyDown:j=>{j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),O(!1),window.setTimeout(()=>{var F;return(F=_.current)==null?void 0:F.focus()},0))},children:[l.jsxs("button",{type:"button",role:"menuitem","aria-label":P("session.action.fork",{title:a}),disabled:s,onClick:j=>{j.stopPropagation(),y(),O(!1)},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:bg-[hsl(var(--deck-surface))] focus-visible:text-[hsl(var(--deck-ink))] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",children:[l.jsx(Vy,{className:"h-3 w-3","aria-hidden":!0}),P("session.action.forkShort")]}),l.jsxs("button",{type:"button",role:"menuitem","aria-label":P("session.action.rename",{title:a}),onClick:j=>{E(j),O(!1)},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:bg-[hsl(var(--deck-surface))] focus-visible:text-[hsl(var(--deck-ink))] focus-visible:outline-none",children:[l.jsx(Wy,{className:"h-3 w-3","aria-hidden":!0}),P("session.action.renameShort")]}),l.jsxs("button",{type:"button",role:"menuitem","aria-label":P("session.action.archive",{title:a}),disabled:e.taskStatus==="running"||e.taskStatus==="queued",onClick:j=>{j.stopPropagation(),v(),O(!1)},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:bg-[hsl(var(--deck-surface))] focus-visible:text-[hsl(var(--deck-ink))] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-35",children:[l.jsx(yf,{className:"h-3 w-3","aria-hidden":!0}),P("session.action.archiveShort")]}),l.jsxs("button",{type:"button",role:"menuitem","aria-label":P("session.action.export",{title:a}),disabled:p,onClick:j=>{j.stopPropagation(),k(),O(!1)},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:bg-[hsl(var(--deck-surface))] focus-visible:text-[hsl(var(--deck-ink))] focus-visible:outline-none disabled:cursor-wait disabled:opacity-45",children:[p?l.jsx(ct,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):l.jsx(wf,{className:"h-3 w-3","aria-hidden":!0}),P(p?"session.action.exportingShort":"session.action.exportShort")]}),l.jsxs("button",{type:"button",role:"menuitem","aria-label":P("session.action.delete",{title:a}),onClick:j=>{$(j),O(!1)},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-red-600 transition-colors hover:bg-red-500/10 focus-visible:bg-red-500/10 focus-visible:outline-none dark:text-red-400",children:[l.jsx(Sf,{className:"h-3 w-3","aria-hidden":!0}),P("session.action.deleteShort")]})]})]})]})]})}function k5({onExpand:e,onNewChat:t,onOpenTaskSwitcher:n,onToggleTerminal:r,onToggleSettings:s,isTerminalOpen:o,taskEventsConnected:i,unreadCount:a,className:c}){const u=Ut(),f=[{icon:If,action:s,labelKey:"sidebar.section.settings"}];return l.jsxs("div",{className:V("flex flex-col gap-2 items-center py-5 h-screen border-r w-[64px] border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]",c),children:[l.jsx("button",{onClick:e,className:"rounded-md p-1 transition-colors hover:bg-[hsl(var(--deck-surface))]","aria-label":u("sidebar.action.expand"),children:l.jsx(Gu,{size:28})}),l.jsx("button",{onClick:t,"aria-label":u("sidebar.action.newTaskShort"),title:u("sidebar.action.newTaskShort"),className:"mt-6 flex h-10 w-10 items-center justify-center rounded-md bg-[hsl(var(--deck-ink))] text-[hsl(var(--deck-canvas))] transition-colors hover:bg-[hsl(var(--deck-ink))]/85",children:l.jsx(Dc,{className:"h-4 w-4 stroke-[2.5]"})}),l.jsx("button",{onClick:r,"aria-label":u("sidebar.action.terminalToggle"),title:u("sidebar.action.terminal"),className:V("flex h-10 w-10 items-center justify-center rounded-md border transition-colors",o?"border-[hsl(var(--deck-accent)/0.55)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]":"border-transparent text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]"),children:l.jsx(vf,{className:"w-4 h-4"})}),l.jsxs("button",{onClick:n,"aria-label":u("sidebar.action.searchTasks"),title:`${u("sidebar.action.searchTasks")} (${Ac("searchTasks")})`,className:"relative flex h-10 w-10 items-center justify-center rounded-md border border-transparent text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",children:[l.jsx(Lc,{className:"h-4 w-4"}),a>0&&l.jsx("span",{"aria-label":u("sidebar.unreadTasks",{count:a}),className:"absolute right-0.5 top-0.5 flex min-h-4 min-w-4 items-center justify-center rounded-full bg-[hsl(var(--deck-accent))] px-1 font-mono text-[8px] font-semibold text-white",children:a>99?"99+":a})]}),l.jsx("div",{className:"flex-1"}),l.jsx("div",{className:"my-2 h-px w-6 bg-[hsl(var(--deck-hairline))]"}),f.map(({icon:p,action:g,labelKey:b})=>l.jsx("button",{"data-settings-trigger":!0,onClick:g,"aria-label":u(b),title:u(b),className:"flex h-10 w-10 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",children:l.jsx(p,{className:"w-4 h-4"})},b)),l.jsx(Qk,{variant:"compact"}),l.jsx("div",{className:"mt-1",children:l.jsx("div",{role:"status","aria-label":u(i?"sidebar.status.feedLive":"sidebar.status.feedOffline"),className:V("h-2 w-2 rounded-full",i?"bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.9)]":"bg-[hsl(var(--deck-ink-faint))]/60"),title:u(i?"sidebar.status.feedLive":"sidebar.status.feedOffline")})})]})}const Zk="blade.sidebar.project-order.v1";function ni(e){const t=new Set,n=[];for(const r of e)typeof r!="string"||!r||t.has(r)||(t.add(r),n.push(r));return n}function y5(){if(typeof window>"u")return[];try{const e=JSON.parse(window.localStorage.getItem(Zk)??"[]");return Array.isArray(e)?ni(e):[]}catch{return[]}}function w5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Zk,JSON.stringify(ni(e)))}catch{}}function S5(e,t){const n=new Map(ni(t).map((s,o)=>[s,o])),r=n.size;return e.map((s,o)=>({project:s,rank:n.get(s.path)??r+o})).sort((s,o)=>s.rank-o.rank).map(({project:s})=>s)}function I5(e,t,n){const r=ni(e),s=r.indexOf(t),o=r.indexOf(n);if(s<0||o<0||s===o)return r;const[i]=r.splice(s,1);return r.splice(o,0,i),r}function v5(e,t,n){const r=ni(e),s=r.indexOf(t),o=s+n;return s<0||o<0||o>=r.length||([r[s],r[o]]=[r[o],r[s]]),r}function j5({name:e,path:t,count:n,countIsPartial:r=!1,isActive:s,hasRunning:o,unreadCount:i,collapsed:a,onToggle:c,onSelect:u,onCreateTask:f,reorderPosition:p,reorderCount:g,isDragging:b=!1,onDragStart:x,onDragEnd:y,onReorderKeyDown:v}){const k=Ut();return l.jsxs("div",{className:V("group/proj flex w-full items-center gap-2 px-5 pb-1.5 pt-3 text-left transition-colors","hover:bg-[hsl(var(--deck-surface))]/40"),children:[l.jsx("button",{type:"button",draggable:!0,"data-project-drag-handle":t,onDragStart:x,onDragEnd:y,onKeyDown:v,"aria-label":k("sidebar.project.reorder",{name:e,position:p,count:g}),title:k("sidebar.project.reorderHint"),className:V("-ml-2 flex h-6 w-4 shrink-0 cursor-grab items-center justify-center rounded-sm text-[hsl(var(--deck-ink-faint))] opacity-45 transition-[opacity,color,background-color] hover:bg-[hsl(var(--deck-surface-2))] hover:text-[hsl(var(--deck-ink-muted))] hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] active:cursor-grabbing group-hover/proj:opacity-100",b&&"cursor-grabbing opacity-100 text-[hsl(var(--deck-accent))]"),children:l.jsx(Jy,{className:"h-3.5 w-3.5"})}),l.jsx("button",{type:"button",onClick:c,"aria-expanded":!a,"aria-label":k(a?"sidebar.project.expand":"sidebar.project.collapse",{name:e}),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:l.jsx(Qy,{className:V("h-3 w-3 text-[hsl(var(--deck-ink-faint))] transition-transform duration-150",!a&&"rotate-90")})}),l.jsxs("button",{type:"button",onClick:u??c,title:t,"aria-current":s?"true":void 0,className:"flex min-h-6 min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[l.jsx(no,{className:V("h-3.5 w-3.5 shrink-0",s?"text-[hsl(var(--deck-accent))]":"text-[hsl(var(--deck-ink-faint))]")}),l.jsx("span",{className:V("flex-1 truncate font-mono text-[11.5px] font-medium tracking-[-0.01em]",s?"text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))]"),children:e}),o&&l.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500 shadow-[0_0_5px_rgba(59,130,246,0.7)] animate-pulse dark:bg-blue-400","aria-hidden":!0}),i>0&&l.jsx("span",{"aria-label":k("sidebar.unreadTasks",{count:i}),className:"shrink-0 rounded-full bg-[hsl(var(--deck-accent))] px-1.5 py-0.5 font-mono text-[8px] font-semibold text-white",children:i}),l.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:[n.toString().padStart(2,"0"),r?"+":""]})]}),f&&l.jsx("button",{type:"button",onClick:f,title:k("sidebar.project.newTask",{name:e}),"aria-label":k("sidebar.project.newTask",{name:e}),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-[hsl(var(--deck-ink-faint))] opacity-0 transition-[opacity,color,background-color] hover:bg-[hsl(var(--deck-surface-2))] hover:text-[hsl(var(--deck-accent))] focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] group-hover/proj:opacity-100",children:l.jsx(Dc,{className:"h-3.5 w-3.5"})})]})}function $c(e){const t=e.lastMessageTime||e.firstMessageTime;if(!t)return 0;const n=new Date(t).getTime();return Number.isNaN(n)?0:n}function lf(e){return e.pendingInteraction?0:e.taskStatus==="running"?1:e.taskStatus==="queued"?2:3}function Vu(e,t){return lf(e)-lf(t)||$c(t)-$c(e)}const C5=["running","queued","interrupted","failed","cancelled","completed"],T5={running:"RUNNING",queued:"QUEUED",interrupted:"INTERRUPTED",failed:"FAILED",cancelled:"CANCELLED",completed:"DONE"},gs=e=>e.length>1?e.replace(/\/+$/,""):e;function ey(e){const t=new Map;for(const n of e){if(!n)continue;const r=qe(he(n));t.has(r)||t.set(r,n)}return Array.from(t.values())}function E5(e){const t=ey(e),n=[];for(const r of C5){const s=t.filter(o=>o.taskStatus===r).sort(Vu);s.length>0&&n.push({code:T5[r],status:r,sessions:s})}return n}function N5(e,t,n=[]){const r=ey(e),s=new Map,o=n.map(gs),i=new Map(o.map((u,f)=>[u,f]));for(const u of o)s.set(u,[]);for(const u of r){const f=ti(u,t),p=s.get(f);p?p.push(u):s.set(f,[u])}const a=t?gs(t):null,c=Array.from(s.entries()).map(([u,f])=>{const p=[...f].sort(Vu),g=f.reduce((b,x)=>Math.max(b,$c(x)),0);return{path:u,name:Cc(u),isActive:a?gs(u)===a:!1,isBound:i.has(gs(u)),hasRunning:f.some(b=>b.taskStatus==="running"),lastActivity:g,sessions:p}});return c.sort((u,f)=>u.isBound!==f.isBound?u.isBound?-1:1:u.isBound&&f.isBound?(i.get(gs(u.path))??Number.MAX_SAFE_INTEGER)-(i.get(gs(f.path))??Number.MAX_SAFE_INTEGER):f.lastActivity-u.lastActivity),c}const uf=12,A5={RUNNING:"sidebar.group.running",QUEUED:"sidebar.group.queued",INTERRUPTED:"sidebar.group.interrupted",FAILED:"sidebar.group.failed",CANCELLED:"sidebar.group.cancelled",DONE:"sidebar.group.done"},$5={RUNNING:"text-blue-700 dark:text-blue-400",QUEUED:"text-amber-700 dark:text-amber-400",INTERRUPTED:"text-orange-700 dark:text-orange-400",FAILED:"text-red-700 dark:text-red-400",CANCELLED:"text-[hsl(var(--deck-ink-faint))]",DONE:"text-[hsl(var(--deck-accent))]"};function P5({view:e,sessions:t,activeProjectPath:n,boundProjects:r,currentSessionRef:s,unreadTaskKeys:o,catalogLoadState:i,catalogError:a,onSelectProject:c,onCreateTask:u,onRetryCatalog:f,renderRow:p}){const g=Ut(),[b,x]=w.useState({}),[y,v]=w.useState({}),[k,E]=w.useState(y5),[$,B]=w.useState(null),[R,M]=w.useState(null),[P,N]=w.useState(""),O=i==="loading"||i==="hydrating",_=O||i==="error",te=w.useMemo(()=>e==="status"?E5(t):[],[t,e]),j=w.useMemo(()=>e==="project"?N5(t,n,r.map(L=>L.path)):[],[n,r,t,e]),F=w.useMemo(()=>S5(j,k),[j,k]),se=(L,ae)=>{const He=y[L]??!1,re=He?ae:ae.filter((A,q)=>{if(q<uf)return!0;const Q=he(A);return!!A.pendingInteraction||o.includes(qe(Q))||!!(s&&de(Q,s))}),Ne=ae.length-re.length,We=He?ae.length>uf:Ne>0;return l.jsxs(l.Fragment,{children:[re.map(p),We&&l.jsx("button",{type:"button",onClick:()=>v(A=>({...A,[L]:!He})),className:"mx-4 my-1 rounded-md px-3 py-1.5 text-left font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink-muted))]",children:He?g("sidebar.group.showLess"):g("sidebar.group.showMore",{count:Ne})})]})},ne=O?l.jsxs("div",{role:"status","aria-live":"polite",className:"mx-4 mt-2 flex items-center gap-2 rounded-md bg-[hsl(var(--deck-surface))]/55 px-3 py-2 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[l.jsx(ct,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),l.jsx("span",{className:"flex-1 min-w-0",children:g("sidebar.catalog.syncing")}),l.jsx("span",{className:"tabular-nums shrink-0",children:g("sidebar.catalog.loaded",{count:t.length})})]}):i==="error"?l.jsxs("div",{role:"alert",title:a??void 0,className:"mx-4 mt-2 flex items-center gap-2 rounded-md bg-amber-50/80 px-3 py-2 font-mono text-[9.5px] text-amber-800 dark:bg-amber-950/35 dark:text-amber-300",children:[l.jsx(co,{className:"w-3 h-3 shrink-0"}),l.jsx("span",{className:"flex-1 min-w-0",children:g("sidebar.catalog.incomplete")}),l.jsxs("button",{type:"button",onClick:f,className:"inline-flex min-h-6 shrink-0 items-center gap-1 rounded px-1.5 font-medium hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 dark:hover:bg-amber-900/50",children:[l.jsx(to,{className:"h-2.5 w-2.5"}),g("sidebar.catalog.retry")]})]}):null;if(e==="status")return l.jsxs("div",{className:"flex flex-col",children:[ne,te.map((L,ae)=>l.jsxs("div",{children:[l.jsxs("div",{className:V("flex items-center justify-between px-5 pb-2 pt-3 font-mono text-[10px] tracking-[0.16em]",$5[L.code]??"text-[hsl(var(--deck-ink-faint))]",ae===0&&"pt-2"),children:[l.jsx("span",{children:g(A5[L.code])}),l.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:[L.sessions.length.toString().padStart(2,"0"),_?"+":""]})]}),se(`status:${L.code}`,L.sessions)]},L.code))]});const oe=F.some(L=>L.isActive),Ie=L=>!!(s&&L.sessions.some(ae=>de(he(ae),s))),ve=(L,ae)=>{if(L.join("\0")===F.map(re=>re.path).join("\0"))return;E(L),w5(L);const He=F.find(re=>re.path===ae);N(g("sidebar.project.reordered",{name:(He==null?void 0:He.name)??ae,position:L.indexOf(ae)+1}))},Ee=(L,ae)=>{const He=L.sessions.filter(q=>o.includes(qe(he(q)))).length,re=Ie(L),Ne=He>0,We=L.sessions.some(q=>!!q.pendingInteraction),A=b[L.path]??(oe&&!L.isActive&&!(re||L.hasRunning||Ne||We));return l.jsxs("div",{"data-project-group":L.path,onDragEnter:q=>{!$||$===L.path||(q.preventDefault(),M(L.path))},onDragOver:q=>{!$||$===L.path||(q.preventDefault(),q.dataTransfer.dropEffect="move")},onDrop:q=>{q.preventDefault();const Q=$||q.dataTransfer.getData("text/plain");Q&&Q!==L.path&&ve(I5(F.map(De=>De.path),Q,L.path),Q),B(null),M(null)},className:V("relative transition-colors",R===L.path&&$!==L.path&&"bg-[hsl(var(--deck-accent-soft))]/55 before:absolute before:inset-y-1 before:left-0 before:w-0.5 before:rounded-full before:bg-[hsl(var(--deck-accent))]"),children:[l.jsx(j5,{name:L.name,path:L.path,count:L.sessions.length,countIsPartial:_,isActive:L.isActive,hasRunning:L.hasRunning,unreadCount:He,collapsed:A,onSelect:()=>c(L.path),onCreateTask:()=>u(L.path),reorderPosition:ae+1,reorderCount:F.length,isDragging:$===L.path,onDragStart:q=>{q.dataTransfer.effectAllowed="move",q.dataTransfer.setData("text/plain",L.path),B(L.path)},onDragEnd:()=>{B(null),M(null)},onReorderKeyDown:q=>{if(q.key!=="ArrowUp"&&q.key!=="ArrowDown")return;q.preventDefault();const Q=v5(F.map(De=>De.path),L.path,q.key==="ArrowUp"?-1:1);ve(Q,L.path)},onToggle:()=>x(q=>({...q,[L.path]:!A}))}),!A&&se(`project:${L.path}`,L.sessions)]},L.path)};return l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"sr-only","aria-live":"polite",children:P}),ne,F.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"px-5 pb-0.5 pt-2 font-mono text-[9px] uppercase tracking-[0.16em] text-[hsl(var(--deck-ink-faint))]",children:g("sidebar.project.projects")}),F.map(Ee)]})]})}function O5({className:e,onNavigate:t}){const n=Ut(),{toggleSettings:r,toggleSidebar:s,isSidebarOpen:o,isTerminalOpen:i,toggleTerminal:a,sidebarView:c,setSidebarView:u,setTaskSwitcherOpen:f}=pr(),p=U(T=>T.sessions),g=U(T=>T.catalogLoadState),b=U(T=>T.catalogError),x=U(T=>T.currentSessionRef),y=U(T=>T.forkingSessionRef),v=U(T=>T.selectSession),k=U(T=>T.startTemporarySession),E=U(T=>T.deleteSession),$=U(T=>T.archiveSession),B=U(T=>T.forkSession),R=U(T=>T.updateSession),M=U(T=>T.loadSessions),P=U(T=>T.setError),N=U(T=>T.taskEventsConnected),O=U(T=>T.taskWorkspaceInfo),_=U(T=>T.boundProjects),te=U(T=>T.selectedProjectPath),j=U(T=>T.bindProject),F=U(T=>T.selectProject),se=U(T=>T.cancelTask),ne=U(T=>T.cancellingTaskKeys),oe=U(T=>T.retryTask),Ie=U(T=>T.retryingTaskKeys),ve=U(T=>T.unreadTaskKeys),[Ee,L]=w.useState(null),[ae,He]=w.useState(""),[re,Ne]=w.useState(null),[We,A]=w.useState(!1),q=te??(O==null?void 0:O.cwd)??null,Q=T=>ao(T,n),De=T=>{var ri;const ke=T.taskSourceProjectPath||T.projectPath,Ct=ke.split("/").filter(Boolean).at(-1)||ke,or=T.taskIsolation==="worktree"?T.taskWorktreeBranch||n("session.env.worktree"):n("session.env.local"),ls=T.taskDiffStat?`+${T.taskDiffStat.additions} −${T.taskDiffStat.deletions}`:void 0,us=T.taskStatus==="queued"&&T.taskQueuePosition?n("session.queued",{position:T.taskQueuePosition,depth:T.taskQueueDepth??T.taskQueuePosition}):void 0,ie=(ri=T.taskStatusReason)==null?void 0:ri.trim(),ir=T.taskFailure?n(qu(T.taskFailure.code)):ie==="user-cancel"?n("session.reason.cancelledByUser"):ie||void 0;return{project:Ct,environment:or,diff:ls,queue:us,reason:ir}},Rt=()=>{k(q??void 0),t==null||t()},Xe=async T=>{_.some(ke=>ke.path===T)?F(T):await j(T),k(T),t==null||t()},hn=async T=>{_.some(ke=>ke.path===T)?F(T):await j(T),k(T),t==null||t()},$e=T=>{T(),t==null||t()},rr=async(T,ke)=>{T.stopPropagation(),await E(he(ke))},sr=async T=>{const ke=he(T),Ct=qe(ke);if(!re){Ne(Ct);try{await Jk(ke)}catch(or){P(or instanceof Error?or.message:"Session export failed")}finally{Ne(null)}}},rn=(T,ke)=>{T.stopPropagation(),L(qe(he(ke))),He(Q(ke))},cs=async T=>{if(!ae.trim()){L(null);return}try{await R(he(T),ae.trim()),L(null),await M()}catch(ke){console.error("Failed to rename session:",ke)}},z=()=>{L(null),He("")};return o?l.jsxs("div",{className:V("flex flex-col h-screen border-r w-[260px] border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]",e),children:[l.jsxs("div",{className:"flex flex-col gap-6 px-5 pt-5 pb-5",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsxs("div",{className:"flex items-center gap-2.5",children:[l.jsx(Gu,{size:26}),l.jsx("span",{className:"font-mono text-[15px] font-semibold tracking-[-0.01em] text-[hsl(var(--deck-ink))]",children:"Blade"}),l.jsx("span",{className:"ml-1 rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-1 py-[1px] font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:n("sidebar.brand.badge")})]}),l.jsx("button",{onClick:s,"aria-label":n("sidebar.action.collapse"),className:"flex h-8 w-8 items-center justify-center rounded transition-colors hover:bg-[hsl(var(--deck-surface))]",children:l.jsx(Yy,{className:"h-3 w-3 text-[hsl(var(--deck-ink-muted))]"})})]}),l.jsxs("div",{className:"flex flex-col gap-1.5",children:[l.jsxs("button",{onClick:Rt,className:"flex h-9 w-full items-center justify-between rounded-md bg-[hsl(var(--deck-ink))] px-3 font-mono text-[13px] font-medium text-[hsl(var(--deck-canvas))] transition-colors hover:bg-[hsl(var(--deck-ink))]/88",children:[l.jsxs("span",{className:"flex gap-2 items-center",children:[l.jsx(Dc,{className:"h-3.5 w-3.5 stroke-[2.5]"}),n("sidebar.action.newTask")]}),l.jsx("span",{className:"rounded-sm bg-white/10 px-1.5 py-[1px] font-mono text-[10px] text-white/80",children:Ac("newTask")})]}),l.jsxs("button",{onClick:()=>$e(a),className:V("flex h-9 w-full items-center gap-2 rounded-md border px-3 font-mono text-[12.5px] transition-colors",i?"border-[hsl(var(--deck-accent)/0.55)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-muted))] hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]"),children:[l.jsx(vf,{className:"h-3.5 w-3.5"}),n("sidebar.action.terminal")]}),l.jsxs("button",{type:"button",onClick:()=>$e(()=>f(!0)),className:"flex h-9 w-full items-center justify-between rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 font-mono text-[12.5px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(Lc,{className:"h-3.5 w-3.5"}),n("sidebar.action.searchTasks")]}),l.jsx("span",{className:"rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-1.5 py-[1px] font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:ve.length>0?ve.length:Ac("searchTasks")})]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("div",{className:"flex flex-1 items-center gap-0.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0.5",children:["project","status"].map(T=>l.jsx("button",{type:"button",onClick:()=>u(T),"aria-pressed":c===T,"aria-label":n(T==="project"?"sidebar.view.projectAria":"sidebar.view.statusAria"),className:V("flex-1 rounded-[5px] py-1 font-mono text-[11px] tracking-[0.02em] transition-colors",c===T?"bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-ink))] shadow-sm":"text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink-muted))]"),children:n(T==="project"?"sidebar.view.project":"sidebar.view.status")},T))}),l.jsx("button",{type:"button",onClick:()=>A(!0),title:n("projects.bind.action"),"aria-label":n("projects.bind.action"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-faint))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-accent))]",children:l.jsx(yi,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(Ku,{className:"flex-1 px-0",children:l.jsxs("div",{className:"flex flex-col",children:[(p.length>0||_.length>0||g==="loading"||g==="hydrating"||g==="error")&&l.jsx(P5,{view:c,sessions:p,activeProjectPath:q,boundProjects:_,currentSessionRef:x,unreadTaskKeys:ve,catalogLoadState:g,catalogError:b,onRetryCatalog:M,onSelectProject:T=>void Xe(T).catch(()=>{}),onCreateTask:T=>void hn(T).catch(()=>{}),renderRow:T=>{const ke=he(T),Ct=qe(ke),or=de(ke,x),ls=Ee===Ct,us=de(ke,y),ie=!!y;return l.jsx(x5,{session:T,sessionRef:ke,isActive:or,isForking:us,isUnread:ve.includes(qe(ke)),anyForking:ie,isEditing:ls,editingTitle:ae,title:Q(T),context:De(T),isCancelling:ne.includes(qe(ke)),isRetrying:Ie.includes(qe(ke)),isExporting:re===Ct,onSelect:()=>(t==null||t(),v(ke)),onCancelTask:()=>{se(ke).catch(()=>{})},onRetryTask:()=>{oe(ke).catch(()=>{})},onFork:()=>void B(T),onArchive:()=>void $(ke),onExport:()=>void sr(T),onStartRename:ir=>rn(ir,T),onDelete:ir=>rr(ir,T),onEditingTitleChange:He,onSaveRename:()=>cs(T),onCancelRename:z},Ct)}}),p.length===0&&l.jsx("div",{className:"px-5 mt-6",children:l.jsxs("div",{className:"rounded-md border border-dashed border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/60 px-4 py-6 text-center",children:[l.jsx("div",{className:"mx-auto mb-2 inline-flex h-8 w-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))]",children:l.jsx(jf,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-ink-faint))]"})}),l.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:n("sidebar.empty.title")}),l.jsx("div",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:n("sidebar.empty.hint")})]})})]})}),l.jsxs("div",{className:"flex flex-col gap-3 px-5 pt-3 pb-5",children:[l.jsxs("div",{className:"flex flex-col gap-0.5 border-t border-[hsl(var(--deck-hairline))] pt-3",children:[l.jsx(g5,{}),[{icon:If,action:()=>$e(r),labelKey:"sidebar.section.settings"}].map(({icon:T,action:ke,labelKey:Ct})=>l.jsxs("button",{"data-settings-trigger":!0,onClick:ke,className:"flex h-8 w-full items-center gap-2.5 rounded-md px-2.5 font-mono text-[12.5px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",children:[l.jsx(T,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-ink-faint))]"}),n(Ct)]},Ct))]}),l.jsxs("div",{className:"flex gap-2 justify-between items-center",children:[l.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.14em] text-[hsl(var(--deck-ink-faint))]",children:n("sidebar.language.label")}),l.jsx(Qk,{})]}),l.jsxs("div",{className:"flex items-center gap-2.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-2",children:[l.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-[hsl(var(--deck-canvas-veil))]",children:l.jsx("div",{className:"h-2 w-2 rounded-full bg-[hsl(var(--deck-ink))]"})}),l.jsxs("div",{className:"flex flex-1 flex-col gap-[1px]",children:[l.jsx("span",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:n("sidebar.status.user")}),l.jsxs("span",{className:V("flex gap-1 items-center font-mono text-[10px]",N?"text-[hsl(var(--deck-accent))]":"text-[hsl(var(--deck-ink-faint))]"),children:[l.jsx("span",{className:V("h-1 w-1 rounded-full",N?"bg-[hsl(var(--deck-accent))] shadow-[0_0_5px_hsl(var(--deck-accent-glow)/0.9)]":"bg-[hsl(var(--deck-ink-faint))]/60")}),n(N?"sidebar.status.feedLive":"sidebar.status.feedOffline")]})]})]})]}),l.jsx(Xk,{open:We,onOpenChange:A})]}):l.jsx(k5,{className:e,onExpand:s,onNewChat:Rt,onOpenTaskSwitcher:()=>$e(()=>f(!0)),onToggleTerminal:()=>$e(a),onToggleSettings:()=>$e(r),isTerminalOpen:i,taskEventsConnected:N,unreadCount:ve.length})}const R5=w.lazy(()=>Is(()=>import("./SettingsModal-CRu1zGQf.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.SettingsModal}))),M5=w.lazy(()=>Is(()=>import("./McpModal-Go_8v1Vu.js"),__vite__mapDeps([4,1,3,2])).then(e=>({default:e.McpModal}))),ty=()=>Is(()=>import("./TaskSwitcher-Ds8CBVtp.js"),__vite__mapDeps([5,1,2,3])).then(e=>({default:e.TaskSwitcher})),F5=w.lazy(ty),_5=w.lazy(()=>Is(()=>import("./FilePreview-hNo6RCNY.js"),__vite__mapDeps([6,1,2,3])).then(e=>({default:e.FilePreview}))),D5=w.lazy(()=>Is(()=>import("./TerminalPanel-Dm4bu6ib.js"),__vite__mapDeps([7,1,8,9,2,3])).then(e=>({default:e.TerminalPanel}))),Ja=e=>{if(e.startsWith("/Users/")){const t=e.split("/");if(t.length>=3)return"~/"+t.slice(3).join("/")}return e},L5=e=>e.replace(/^~\//,"~/§").split("/").filter(Boolean).map((t,n,r)=>{var s;return n===0&&((s=r[0])!=null&&s.startsWith("~"))?"~":t.replace(/^§/,"")});function B5({children:e}){var Ne,We;const t=Ut();p5();const{isSidebarOpen:n,isFilePreviewOpen:r,isMcpOpen:s,isSettingsOpen:o,isTerminalOpen:i,isTaskSwitcherOpen:a,toggleFilePreview:c,openFilePreview:u,previewRequestId:f,setSidebarOpen:p}=pr();w.useEffect(()=>{const A=window.setTimeout(()=>{ty()},1500);return()=>window.clearTimeout(A)},[]);const g=U(A=>A.currentSessionId),b=U(A=>A.currentSessionRef),x=U(A=>A.sessions),y=U(A=>A.isStreaming),v=U(A=>A.isTemporarySession),k=U(A=>A.taskWorkspaceInfo),E=U(A=>A.boundProjects),$=U(A=>A.selectedProjectPath),[B,R]=w.useState(null),[M,P]=w.useState(!1),[N,O]=w.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches),[_,te]=w.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 1023px)").matches),j=w.useRef(null),F=w.useRef(null),se=w.useRef(null),ne=w.useMemo(()=>x.find(A=>de({sessionId:A.sessionId,projectPath:A.projectPath},b)),[b,x]),oe=(ne==null?void 0:ne.taskIsolation)==="worktree"&&ne.taskSourceProjectPath&&(((Ne=ne.taskDelivery)==null?void 0:Ne.status)==="applied"||((We=ne.taskDelivery)==null?void 0:We.status)==="discarded")?ne.taskSourceProjectPath:b==null?void 0:b.projectPath;w.useEffect(()=>{if(typeof window.matchMedia!="function")return;const A=window.matchMedia("(max-width: 900px)"),q=()=>{A.matches&&p(!1)};return q(),A.addEventListener("change",q),()=>A.removeEventListener("change",q)},[p]),w.useEffect(()=>{if(typeof window.matchMedia!="function")return;const A=window.matchMedia("(max-width: 639px)"),q=()=>O(A.matches);return q(),A.addEventListener("change",q),()=>A.removeEventListener("change",q)},[]),w.useEffect(()=>{if(typeof window.matchMedia!="function")return;const A=window.matchMedia("(max-width: 1023px)"),q=()=>te(A.matches);return q(),A.addEventListener("change",q),()=>A.removeEventListener("change",q)},[]),w.useEffect(()=>{if(!N||!n)return;const A=requestAnimationFrame(()=>{var q,Q;(Q=(q=j.current)==null?void 0:q.querySelector("button"))==null||Q.focus()});return()=>{var q;cancelAnimationFrame(A),(q=F.current)==null||q.focus({preventScroll:!0})}},[N,n]);const Ie=A=>{var Rt;if(!N||!n)return;if(A.key==="Escape"){A.preventDefault(),p(!1);return}if(A.key!=="Tab")return;const q=Array.from(((Rt=j.current)==null?void 0:Rt.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))??[]);if(q.length===0)return;const Q=q[0],De=q[q.length-1];A.shiftKey&&document.activeElement===Q?(A.preventDefault(),De==null||De.focus()):!A.shiftKey&&document.activeElement===De&&(A.preventDefault(),Q==null||Q.focus())},ve=w.useMemo(()=>!g||v?$?Ja($):null:ne!=null&&ne.projectPath?Ja(ne.taskSourceProjectPath||ne.projectPath):null,[g,ne,v,$]),Ee=w.useMemo(()=>ve?L5(ve):[],[ve]);w.useEffect(()=>{var q;if(!b){R(((q=E.find(Q=>Q.path===$))==null?void 0:q.gitBranch)??null);return}(async()=>{try{const Q=await pe.getGitInfo({sessionId:b.sessionId,projectPath:oe??b.projectPath});R(Q.branch)}catch{R(null)}})()},[E,b,oe,$]);const L=k==null?void 0:k.taskAdmission,ae=oe??$??(k==null?void 0:k.cwd)??null,He=b?qe(b):`project:${$??"none"}`,re=r&&_;return l.jsxs("div",{className:"flex h-screen overflow-hidden bg-[hsl(var(--deck-canvas))]",children:[N&&n&&!re&&l.jsx("button",{type:"button","aria-label":t("sidebar.action.collapse"),onClick:()=>p(!1),className:"fixed inset-0 z-40 bg-black/25 backdrop-blur-[1px]"}),l.jsx("div",{ref:j,role:N&&n&&!re?"dialog":void 0,"aria-modal":N&&n&&!re?!0:void 0,"aria-label":N&&n&&!re?t("sidebar.navigationAria"):void 0,"aria-hidden":re||N&&!n?!0:void 0,inert:re||N&&!n?!0:void 0,onKeyDown:Ie,className:V("overflow-hidden",n?"w-[260px]":"w-[64px]",N?"fixed inset-y-0 left-0 z-50 shadow-2xl transition-none":"shrink-0 transition-[width] duration-300 ease-in-out",N&&!n&&"-translate-x-full"),children:l.jsx("div",{className:V("transition-all duration-300 ease-in-out",n?"w-[260px]":"w-[64px]"),children:l.jsx(O5,{onNavigate:()=>{N&&p(!1)}})})}),l.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[l.jsxs("header",{"aria-hidden":re||void 0,inert:re||void 0,className:"relative z-10 flex h-14 items-center gap-2 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas))]/90 px-3 backdrop-blur-md sm:gap-4 sm:px-6",children:[N&&l.jsx(mr,{ref:F,"data-mobile-navigation-trigger":!0,variant:"ghost",size:"icon",onClick:()=>p(!0),"aria-label":t("layout.action.openNavigation"),title:t("layout.action.openNavigation"),className:"h-9 w-9 shrink-0 rounded-md text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",children:l.jsx(Xy,{className:"h-4 w-4"})}),l.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[Ee.length>0?l.jsx("nav",{"aria-label":t("layout.workspace.pathAria"),title:ve??void 0,className:"flex min-w-0 items-center font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:Ee.map((A,q)=>{const Q=q===Ee.length-1,De=q===0&&A==="~";return l.jsxs("span",{className:"flex items-center min-w-0",children:[q>0&&l.jsx("span",{className:"mx-1 text-[hsl(var(--deck-ink-faint))]/70",children:"/"}),q===0&&!De&&l.jsx("span",{className:"mr-1 text-[hsl(var(--deck-ink-faint))]/70",children:"/"}),l.jsx("span",{className:V("truncate",Q?"font-medium text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))]"),children:A})]},q)})}):l.jsx("span",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-faint))]",children:k!=null&&k.cwd?Ja(k.cwd):t("layout.workspace.empty")}),B&&l.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[l.jsx(Fc,{className:"h-3 w-3 text-[hsl(var(--deck-accent))]"}),B]})]}),l.jsxs("div",{className:"flex gap-3 items-center ml-auto",children:[L&&l.jsx("span",{className:"hidden items-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2.5 py-1 md:inline-flex",children:l.jsx(zk,{inFlight:L.inFlight,queued:L.queued,maxConcurrent:L.maxConcurrent,compact:!0})}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx(mr,{variant:"ghost",size:"icon","aria-label":t("layout.action.rewind"),title:t("layout.action.rewind"),disabled:!b||v||y,onClick:()=>P(!0),className:"h-8 w-8 rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] disabled:opacity-35",children:l.jsx(Li,{className:"w-4 h-4"})}),l.jsx(mr,{ref:se,variant:"ghost",size:"icon",onClick:()=>{if(r){c();return}u((!b||v)&&f===0?{tab:"files"}:void 0)},title:t("layout.action.filePreview"),"aria-label":t("layout.action.filePreviewToggle"),className:V("h-8 w-8 rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",r&&"bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))] hover:bg-[hsl(var(--deck-accent-soft))] hover:text-[hsl(var(--deck-accent))]"),children:l.jsx(Zy,{className:"w-4 h-4"})})]})]})]}),l.jsxs("main",{className:"flex-1 overflow-hidden relative flex bg-[hsl(var(--deck-canvas))]",children:[l.jsx("div",{"data-preview-background":"content","aria-hidden":re||void 0,inert:re||void 0,className:"flex relative flex-col flex-1 min-w-0",children:o?l.jsx(w.Suspense,{fallback:null,children:l.jsx(R5,{})}):e}),r&&l.jsx(w.Suspense,{fallback:null,children:l.jsx(_5,{returnFocusElement:se.current},He)})]})]}),i&&l.jsx(w.Suspense,{fallback:null,children:l.jsx(D5,{workspacePath:ae},ae??"default-workspace")}),a&&l.jsx(w.Suspense,{fallback:null,children:l.jsx(F5,{})}),s&&l.jsx(w.Suspense,{fallback:null,children:l.jsx(M5,{})}),l.jsx(o5,{open:M,onOpenChange:P})]})}const Qa="BladeCode";function U5(){const e=Ut(),t=U(i=>i.unreadTaskKeys),n=U(i=>i.sessions),r=U(i=>i.selectSession),s=U(i=>i.selectProject),o=w.useMemo(()=>{const i=new Set(t);for(const a of n)a.pendingInteraction&&i.add(qe(he(a)));return i.size},[n,t]);return w.useEffect(()=>(document.title=o>0?`(${o}) ${Qa}`:Qa,()=>{document.title=Qa}),[o]),w.useEffect(()=>{const i=a=>{var g;const c=a.detail;if(!(c!=null&&c.sessionId)||!c.projectPath)return;const u=U.getState(),f=Bu(u.sessions,c),p=f?ti(f,u.selectedProjectPath??((g=u.taskWorkspaceInfo)==null?void 0:g.cwd)??null):c.projectPath;u.boundProjects.some(b=>b.available&&b.path===p)&&s(p),r(c)};return window.addEventListener(Ri,i),()=>window.removeEventListener(Ri,i)},[s,r]),l.jsx("div",{className:"sr-only",role:"status","aria-live":"polite",children:o>0?e("attention.unreadAnnouncement",{count:o}):""})}const ny=w.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:V("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));ny.displayName="Textarea";const q5=(e,t)=>{const n=[...e.matchAll(/(?:^|\s)(@(?:"[^"]*"|(?:[^\\ ]|\\ )*))/g)];for(const r of n){const s=r[1],o=r.index+(r[0].length-s.length),i=o+s.length;if(t>=o&&t<=i){let a=s.slice(1),c=!1;return a.startsWith('"')&&(c=!0,a=a.slice(1),a.endsWith('"')&&(a=a.slice(0,-1))),{hasQuery:!0,query:a,startIndex:o,endIndex:i,quoted:c}}}return{hasQuery:!1,query:"",startIndex:-1,endIndex:-1,quoted:!1}},z5=(e,t,n={})=>{const{debounceDelay:r=200,maxSuggestions:s=15,workspacePath:o}=n,[i,a]=w.useState([]),[c,u]=w.useState(0),[f,p]=w.useState(!1),g=w.useMemo(()=>t===void 0?{hasQuery:!1,query:"",startIndex:-1,endIndex:-1,quoted:!1}:q5(e,t),[e,t]);w.useEffect(()=>{if(!g.hasQuery){a([]),p(!1);return}let y=!1;p(!0);const k=setTimeout(async()=>{try{const E=await fetch(`/suggestions/files?q=${encodeURIComponent(g.query)}&limit=${s}`,o?{headers:{"x-blade-directory":o}}:void 0);if(!E.ok)throw new Error("Failed to fetch suggestions");const $=await E.json();y||a($)}catch(E){console.error("Failed to fetch file suggestions:",E),y||a([])}finally{y||p(!1)}},r);return()=>{y=!0,clearTimeout(k)}},[g.hasQuery,g.query,r,s,o]),w.useEffect(()=>{u(0)},[i]);const b=w.useCallback(()=>{u(y=>(y+1)%Math.max(i.length,1))},[i.length]),x=w.useCallback(()=>{u(y=>(y-1+i.length)%Math.max(i.length,1))},[i.length]);return{...g,suggestions:i,selectedIndex:c,loading:f,setSelectedIndex:u,selectNext:b,selectPrevious:x}},H5=(e,t=!1)=>e.includes(" ")||t?`@"${e}"`:`@${e}`,K5=(e,t,n)=>{if(!t.hasQuery)return{newInput:e,newCursorPos:e.length};const r=H5(n,t.quoted),s=e.slice(0,t.startIndex),o=e.slice(t.endIndex),i=s+r+" "+o,a=t.startIndex+r.length+1;return{newInput:i,newCursorPos:a}};function G5(){const[e,t]=w.useState([]),[n,r]=w.useState(-1),s=w.useRef(""),o=w.useCallback(u=>{u.trim()&&(t(f=>f[f.length-1]===u?f:[...f,u]),r(-1),s.current="")},[]),i=w.useCallback(u=>{if(e.length===0)return null;n===-1&&(s.current=u);const f=n===-1?e.length-1:Math.max(0,n-1);return r(f),e[f]??null},[e,n]),a=w.useCallback(()=>{if(n===-1)return null;const u=n+1;return u>=e.length?(r(-1),s.current):(r(u),e[u]??null)},[e,n]),c=w.useCallback(()=>{r(-1),s.current=""},[]);return{addToHistory:o,getPrevious:i,getNext:a,reset:c,historyIndex:n}}const V5=(e,t)=>{if(!e.startsWith("/"))return{hasQuery:!1,query:"",startIndex:-1,endIndex:-1};const n=e.indexOf(" "),r=n===-1?e.length:n;return t<=r?{hasQuery:!0,query:e.slice(1,t),startIndex:0,endIndex:t}:{hasQuery:!1,query:"",startIndex:-1,endIndex:-1}},W5=(e,t,n={})=>{const{debounceDelay:r=150,workspacePath:s}=n,[o,i]=w.useState([]),[a,c]=w.useState(0),[u,f]=w.useState(!1),p=w.useMemo(()=>t===void 0?{hasQuery:!1,query:"",startIndex:-1,endIndex:-1}:V5(e,t),[e,t]);w.useEffect(()=>{if(!p.hasQuery){i([]),f(!1);return}let x=!1;f(!0);const v=setTimeout(async()=>{try{const k=await fetch(`/suggestions/commands?q=${encodeURIComponent(p.query)}`,s?{headers:{"x-blade-directory":s}}:void 0);if(!k.ok)throw new Error("Failed to fetch suggestions");const E=await k.json();x||i(E)}catch(k){console.error("Failed to fetch command suggestions:",k),x||i([])}finally{x||f(!1)}},r);return()=>{x=!0,clearTimeout(v)}},[p.hasQuery,p.query,r,s]),w.useEffect(()=>{c(0)},[o]);const g=w.useCallback(()=>{c(x=>(x+1)%Math.max(o.length,1))},[o.length]),b=w.useCallback(()=>{c(x=>(x-1+o.length)%Math.max(o.length,1))},[o.length]);return{...p,suggestions:o,selectedIndex:a,loading:u,setSelectedIndex:c,selectNext:g,selectPrevious:b}},J5=(e,t,n)=>{if(!t.hasQuery)return{newInput:e,newCursorPos:e.length};const r=e.slice(t.endIndex),s=n.command+" "+r.trimStart(),o=n.command.length+1;return{newInput:s,newCursorPos:o}},Q5="blade.composer.draft.",Wu=new Map;function Fi(){return typeof sessionStorage>"u"?null:sessionStorage}function _i(e){return`${Q5}${e}`}function Y5(e){var n;if(!e)return{content:"",attachments:[]};const t=Wu.get(e);if(t)return{content:t.content,attachments:[...t.attachments]};try{return{content:((n=Fi())==null?void 0:n.getItem(_i(e)))??"",attachments:[]}}catch{return{content:"",attachments:[]}}}function Ln(e,t){var n,r;if(e){if(!t.content&&t.attachments.length===0){ry(e);return}Wu.set(e,{content:t.content,attachments:[...t.attachments]});try{t.content?(n=Fi())==null||n.setItem(_i(e),t.content):(r=Fi())==null||r.removeItem(_i(e))}catch{}}}function ry(e){var t;if(e){Wu.delete(e);try{(t=Fi())==null||t.removeItem(_i(e))}catch{}}}function Pc(e){return e.reduce((t,n)=>t+n.dataUrl.length,0)}function X5(e){return`data:${e.type||"application/octet-stream"};base64,`.length+4*Math.ceil(e.size/3)}function Z5(e,t){const r=Pc(e)+t.reduce((s,o)=>s+X5(o),0);return e.length+t.length>Br?{accepted:!1,reason:"count",estimatedBytes:r}:r>oo?{accepted:!1,reason:"bytes",estimatedBytes:r}:{accepted:!0,estimatedBytes:r}}const eD=e=>typeof e=="object"&&"command"in e,df=({type:e,suggestions:t,selectedIndex:n,loading:r,onSelect:s,onHover:o,visible:i})=>{const a=w.useRef(null),c=w.useRef(null);if(w.useEffect(()=>{if(c.current&&a.current){const f=a.current,p=c.current,g=f.getBoundingClientRect(),b=p.getBoundingClientRect();b.bottom>g.bottom?f.scrollTop+=b.bottom-g.bottom+4:b.top<g.top&&(f.scrollTop-=g.top-b.top+4)}},[n]),!i||t.length===0&&!r)return null;const u=e==="command"?Cf:cd;return l.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:l.jsxs("div",{className:"mx-4 bg-white dark:bg-zinc-900 border border-[#E5E7EB] dark:border-zinc-700 rounded-lg shadow-xl overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-[#E5E7EB] dark:border-zinc-800 text-xs text-[#6B7280] dark:text-zinc-400",children:[l.jsx(u,{className:"h-3.5 w-3.5"}),l.jsx("span",{children:e==="command"?"Commands":"Files"}),r&&l.jsx(ct,{className:"h-3 w-3 animate-spin ml-auto"})]}),l.jsx("div",{ref:a,className:"max-h-64 overflow-y-auto py-1",children:t.length===0&&r?l.jsx("div",{className:"px-3 py-4 text-center text-[#6B7280] dark:text-zinc-500 text-sm",children:"Loading..."}):t.length===0?l.jsx("div",{className:"px-3 py-4 text-center text-[#6B7280] dark:text-zinc-500 text-sm",children:"No matches found"}):t.map((f,p)=>{const g=p===n,b=eD(f);return l.jsx("button",{ref:g?c:null,className:V("w-full text-left px-3 py-2 flex items-start gap-3 transition-colors",g?"bg-[#E5E7EB] text-[#111827] dark:bg-zinc-800 dark:text-zinc-100":"text-[#6B7280] hover:bg-[#F3F4F6] hover:text-[#111827] dark:text-zinc-400 dark:hover:bg-zinc-800/50 dark:hover:text-zinc-300"),onClick:()=>s(p),onMouseEnter:()=>o(p),children:b?l.jsx(l.Fragment,{children:l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-mono text-sm text-blue-600 dark:text-blue-400",children:f.command}),f.argumentHint&&l.jsx("span",{className:"text-xs text-[#9CA3AF] dark:text-zinc-500 font-mono",children:f.argumentHint})]}),l.jsx("p",{className:"text-xs text-[#9CA3AF] dark:text-zinc-500 mt-0.5 truncate",children:f.description})]})}):l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(cd,{className:"h-4 w-4 flex-shrink-0 text-[#9CA3AF] dark:text-zinc-500"}),l.jsx("span",{className:"font-mono text-sm truncate",children:f})]})},b?f.command:f)})}),l.jsxs("div",{className:"px-3 py-1.5 border-t border-[#E5E7EB] dark:border-zinc-800 text-xs text-[#9CA3AF] dark:text-zinc-500 flex items-center gap-4",children:[l.jsxs("span",{children:[l.jsx("kbd",{className:"px-1.5 py-0.5 bg-[#E5E7EB] dark:bg-zinc-800 rounded text-[#6B7280] dark:text-zinc-400",children:"↑↓"})," ","Navigate"]}),l.jsxs("span",{children:[l.jsx("kbd",{className:"px-1.5 py-0.5 bg-[#E5E7EB] dark:bg-zinc-800 rounded text-[#6B7280] dark:text-zinc-400",children:"Tab"})," ","Select"]}),l.jsxs("span",{children:[l.jsx("kbd",{className:"px-1.5 py-0.5 bg-[#E5E7EB] dark:bg-zinc-800 rounded text-[#6B7280] dark:text-zinc-400",children:"Esc"})," ","Close"]})]})]})})},ff=[{value:hi.DEFAULT,labelKey:"chat.input.mode.default"},{value:hi.AUTO_EDIT,labelKey:"chat.input.mode.autoEdit"},{value:hi.PLAN,labelKey:"chat.input.mode.plan"}],tD=["off"],nD=["standard"],rD=[],sD=[{id:"auto",name:"Auto",description:"Use the Blade default communication style",source:"built-in"},{id:"pragmatic",name:"Pragmatic",description:"Direct, factual, concise, and action-oriented",source:"built-in"},{id:"friendly",name:"Friendly",description:"Warm, collaborative, and task-focused",source:"built-in"},{id:"explanatory",name:"Explanatory",description:"Explain codebase-specific choices and tradeoffs",source:"built-in"}];function Ya(e){return e<1024*1024?`${Math.max(1,Math.ceil(e/1024))} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function oD({onSend:e,onAbort:t,disabled:n,submitDisabled:r=!1,shellSubmitDisabled:s=!1,isStreaming:o,isStopping:i=!1,pendingSteeringCount:a=0,pendingInputDelivery:c=null,recoveredSteeringCount:u=0,variant:f="chat",draft:p,draftAttachments:g,draftRevision:b,draftKey:x,placeholder:y,workspacePath:v}){var rd,sd,od;const k=Ut(),E=w.useRef(Y5(x)),[$,B]=w.useState(E.current.content),[R,M]=w.useState(E.current.attachments),P=w.useRef($),N=w.useRef(R),[O,_]=w.useState(void 0),[te,j]=w.useState(!1),[F,se]=w.useState(!1),[ne,oe]=w.useState(!1),[Ie,ve]=w.useState(!1),[Ee,L]=w.useState(!1),[ae,He]=w.useState(!1),[re,Ne]=w.useState(!1),[We,A]=w.useState(null),[q,Q]=w.useState(null),De=$.trimStart().startsWith("!"),Rt=De?s:r,Xe=w.useRef(null),hn=w.useRef(!1),$e=w.useRef(null),rr=w.useRef(null),{currentModelId:sr,configuredModels:rn,hasLoaded:cs,loadedWorkspacePath:z,loadModels:T,setCurrentModel:ke,currentMode:Ct,setMode:or}=Vt(),ls=pr(I=>I.isSettingsOpen),us=U(I=>I.setMaxContextTokens),ie=U(I=>I.currentSessionRef),ir=U(I=>{var W;return(W=I.sessions.find(J=>J.sessionId===(ie==null?void 0:ie.sessionId)&&J.projectPath===(ie==null?void 0:ie.projectPath)))==null?void 0:W.selectedModelId}),ri=U(I=>{var W;return(W=I.sessions.find(J=>J.sessionId===(ie==null?void 0:ie.sessionId)&&J.projectPath===(ie==null?void 0:ie.projectPath)))==null?void 0:W.reasoningEffort}),sy=U(I=>{var W;return(W=I.sessions.find(J=>J.sessionId===(ie==null?void 0:ie.sessionId)&&J.projectPath===(ie==null?void 0:ie.projectPath)))==null?void 0:W.serviceTier}),oy=U(I=>{var W;return(W=I.sessions.find(J=>J.sessionId===(ie==null?void 0:ie.sessionId)&&J.projectPath===(ie==null?void 0:ie.projectPath)))==null?void 0:W.responseVerbosity}),iy=U(I=>{var W;return(W=I.sessions.find(J=>J.sessionId===(ie==null?void 0:ie.sessionId)&&J.projectPath===(ie==null?void 0:ie.projectPath)))==null?void 0:W.communicationStyle}),[ay,Ju]=w.useState(null),[cy,Ca]=w.useState(null),[ly,Ta]=w.useState(null),[uy,Ea]=w.useState(null),[dy,Qu]=w.useState(null),fy=rn.some(I=>I.id===ir),ds=ie?ay??(fy?ir:sr):sr,Ke=rn.find(I=>I.id===ds),Na=(Ke==null?void 0:Ke.supportedReasoningEfforts)??tD,my=["auto",...Na],Pr=cy??ri??"off",Aa=(Ke==null?void 0:Ke.supportedServiceTiers)??nD,py=["auto",...Aa],Or=ly??sy??"auto",$a=(Ke==null?void 0:Ke.supportedResponseVerbosities)??rD,gy=["auto",...$a],Rr=uy??oy??"auto",qs=dy??iy??"auto",Yu=(Ke==null?void 0:Ke.communicationStyles)??sD,hy=((rd=Yu.find(I=>I.id===qs))==null?void 0:rd.name)??qs,Xu=(Ke==null?void 0:Ke.displayName)||(Ke==null?void 0:Ke.model)||ds||k("chat.input.model.placeholder"),ar=((sd=Ke==null?void 0:Ke.input)==null?void 0:sd.includes("image"))===!0,zs=Ke?k("chat.input.attachment.modelUnsupported",{model:Xu}):k("chat.input.attachment.modelRequired"),si=R.length>0&&!ar,Kt=W5($,O,{workspacePath:v}),Gt=z5($,O,{workspacePath:v}),fs=G5(),Hs=Kt.hasQuery&&Kt.suggestions.length>0,oi=Gt.hasQuery&&Gt.suggestions.length>0,by=Hs||oi;w.useEffect(()=>{!ls&&(!cs||z!==(v??null))&&T(v??void 0)},[ls,T,z,cs,v]),w.useEffect(()=>{o&&(j(!1),se(!1),oe(!1),ve(!1),L(!1))},[o]),w.useEffect(()=>{Ju(null),Ca(null),Ta(null),Ea(null),Qu(null)},[ie==null?void 0:ie.projectPath,ie==null?void 0:ie.sessionId]),w.useEffect(()=>{Pr!=="auto"&&!Na.includes(Pr)&&Ca("auto")},[Pr,Na]),w.useEffect(()=>{Or!=="auto"&&!Aa.includes(Or)&&Ta("auto")},[Or,Aa]),w.useEffect(()=>{Rr!=="auto"&&!$a.includes(Rr)&&Ea("auto")},[Rr,$a]),w.useEffect(()=>{Q(null)},[ds]),w.useEffect(()=>{if(p!==void 0){const I=g??N.current;P.current=p,N.current=I,B(p),M(I),A(null),Q(null),_(p.length),Ln(x,{content:p,attachments:I}),requestAnimationFrame(()=>{var W;return(W=$e.current)==null?void 0:W.focus()})}},[p,g,x,b]),w.useEffect(()=>()=>{Ln(x,{content:P.current,attachments:N.current})},[x]),w.useEffect(()=>{if(!Ke)return;const I=!!Ke.contextWindow;us(Ke.contextWindow||0,!I)},[Ke,us]),w.useEffect(()=>{ar&&A(I=>I!==Xe.current?I:(Xe.current=null,null))},[ar]);const Pa=w.useCallback(async()=>{if(!$.trim()&&R.length===0||n||Rt||si||hn.current)return;$.trim()&&fs.addToHistory($),hn.current=!0,Ne(!0);const I=x;try{if(await e({content:$,modelId:ds??void 0,reasoningEffort:Pr,serviceTier:Or,responseVerbosity:Rr,communicationStyle:qs,attachments:R})===!1)return;ry(I),P.current="",N.current=[],B(""),M([]),A(null),Q(null),Xe.current=null,_(void 0)}catch{}finally{hn.current=!1,Ne(!1)}},[R,si,x,$,n,ds,Pr,Rr,qs,Or,Rt,e,fs]),xy=w.useCallback(I=>{A(null),Q(null),Xe.current=null,M(W=>{const J=W.filter(Le=>Le.id!==I);return N.current=J,Ln(x,{content:P.current,attachments:J}),J})},[x]),Zu=w.useCallback(I=>new Promise((W,J)=>{const Le=new FileReader;Le.onload=()=>{if(typeof Le.result!="string"){J(new Error("Failed to read image"));return}W({id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:I.name,mimeType:I.type,dataUrl:Le.result})},Le.onerror=()=>J(Le.error??new Error("Failed to read image")),Le.readAsDataURL(I)}),[]),ii=w.useCallback(async I=>{if(I.length===0)return;if(!ar){Xe.current=zs,Q(null),A(zs);return}const W=Z5(N.current,I),J=Le=>Le==="count"?k("chat.input.attachment.countLimit",{count:Br}):k("chat.input.attachment.sizeLimit",{size:Ya(oo)});if(!W.accepted){Xe.current=null,Q(null),A(J(W.reason??"bytes"));return}try{const Le=await Promise.all(I.map(ms=>Zu(ms))),Tt=new Set(N.current.map(ms=>ms.dataUrl)),id=Le.filter(ms=>Tt.has(ms.dataUrl)?!1:(Tt.add(ms.dataUrl),!0));if(id.length===0){A(null),Q(null),Xe.current=null;return}const ai=[...N.current,...id];if(Pc(ai)>oo){Xe.current=null,Q(null),A(J("bytes"));return}N.current=ai,M(ai),A(null),Q(null),Xe.current=null,Ln(x,{content:P.current,attachments:ai})}catch{Xe.current=null,Q(null),A(k("chat.input.attachment.readFailed"))}},[x,zs,ar,Zu,k]),ky=w.useCallback(async I=>{const W=Array.from(I.target.files??[]).filter(J=>J.type.startsWith("image/"));await ii(W),I.target.value=""},[ii]),yy=w.useCallback(async I=>{const W=Array.from(I.clipboardData.items).filter(J=>J.type.startsWith("image/")).map(J=>J.getAsFile()).filter(J=>J!==null);W.length!==0&&(I.preventDefault(),await ii(W))},[ii]),Oa=w.useCallback(I=>{const W=Kt.suggestions[I];if(!W)return;const{newInput:J,newCursorPos:Le}=J5($,Kt,W);P.current=J,B(J),_(Le),Ln(x,{content:J,attachments:N.current}),requestAnimationFrame(()=>{$e.current&&($e.current.focus(),$e.current.setSelectionRange(Le,Le))})},[x,$,Kt]),Ra=w.useCallback(I=>{const W=Gt.suggestions[I];if(!W)return;const{newInput:J,newCursorPos:Le}=K5($,Gt,W);P.current=J,B(J),_(Le),Ln(x,{content:J,attachments:N.current}),requestAnimationFrame(()=>{$e.current&&($e.current.focus(),$e.current.setSelectionRange(Le,Le))})},[Gt,x,$]),wy=w.useCallback(I=>{if(Hs){if(I.key==="ArrowDown"){I.preventDefault(),Kt.selectNext();return}if(I.key==="ArrowUp"){I.preventDefault(),Kt.selectPrevious();return}if(I.key==="Tab"||I.key==="Enter"&&!I.shiftKey){I.preventDefault(),Oa(Kt.selectedIndex);return}if(I.key==="Escape"){I.preventDefault(),_(void 0);return}}if(oi){if(I.key==="ArrowDown"){I.preventDefault(),Gt.selectNext();return}if(I.key==="ArrowUp"){I.preventDefault(),Gt.selectPrevious();return}if(I.key==="Tab"||I.key==="Enter"&&!I.shiftKey){I.preventDefault(),Ra(Gt.selectedIndex);return}if(I.key==="Escape"){I.preventDefault(),_(void 0);return}}if(I.key==="Enter"&&!I.shiftKey){I.preventDefault(),Pa();return}if(I.key==="ArrowUp"&&!I.shiftKey){const W=I.target,J=W.selectionStart===0&&W.selectionEnd===0,Le=!$.includes(`
|
|
31
|
-
`);if(J||Le){const Tt=fs.getPrevious($);Tt!==null&&(I.preventDefault(),P.current=Tt,B(Tt),Ln(x,{content:Tt,attachments:N.current}),requestAnimationFrame(()=>{$e.current&&$e.current.setSelectionRange(Tt.length,Tt.length)}))}return}if(I.key==="ArrowDown"&&!I.shiftKey){const W=I.target,J=W.selectionStart===$.length&&W.selectionEnd===$.length,Le=!$.includes(`
|
|
32
|
-
`);if((J||Le)&&fs.historyIndex!==-1){const Tt=fs.getNext();Tt!==null&&(I.preventDefault(),P.current=Tt,B(Tt),Ln(x,{content:Tt,attachments:N.current}),requestAnimationFrame(()=>{$e.current&&$e.current.setSelectionRange(Tt.length,Tt.length)}))}}},[Hs,oi,Kt,Gt,Oa,Ra,Pa,x,$,fs]),Sy=w.useCallback(I=>{const W=I.target.value;P.current=W,B(W),_(I.target.selectionStart),Ln(x,{content:W,attachments:N.current})},[x]),ed=w.useCallback(I=>{const W=I.target;_(W.selectionStart)},[]);w.useEffect(()=>{$e.current&&($e.current.style.height="inherit",$e.current.style.height=`${Math.min($e.current.scrollHeight,200)}px`)},[$]);const Iy=((od=ff.find(I=>I.value===Ct))==null?void 0:od.labelKey)??"chat.input.mode.default",vy=k(Iy),jy=!!$.trim()||R.length>0,td=R.length>=Br,Cy=Pc(R),Ma=We||(si?zs:null),nd=Ma?null:q,Fa=!!n||re,Ty=Fa||td||!ar,Ks=ar?td?k("chat.input.attachment.countLimit",{count:Br}):k("chat.input.attachment.add"):zs,Ey=()=>{Fa||(Q(Ks),!ar&&!o&&rn.some(I=>{var W;return(W=I.input)==null?void 0:W.includes("image")})&&j(!0))};return l.jsx("div",{className:f==="task"?"bg-transparent":"py-2.5 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas))]",children:l.jsxs("div",{className:f==="task"?"w-full":"px-4 w-full md:px-6",children:[l.jsxs("div",{className:`relative border rounded-lg bg-[hsl(var(--deck-surface))] transition-all duration-200 flex flex-col ${f==="task"?`min-h-[148px] shadow-[0_18px_60px_-24px_hsl(var(--deck-accent)/0.4)] focus-within:ring-1 ${De?"border-amber-400/70 focus-within:border-amber-500 focus-within:ring-amber-400/25":"border-[hsl(var(--deck-border))] focus-within:border-[hsl(var(--deck-accent)/0.6)] focus-within:ring-[hsl(var(--deck-accent)/0.25)]"}`:`min-h-[56px] shadow-sm focus-within:ring-1 ${De?"border-amber-400/70 focus-within:border-amber-500 focus-within:ring-amber-400/25":"border-[hsl(var(--deck-border))] focus-within:border-[hsl(var(--deck-border-strong))] focus-within:ring-[hsl(var(--deck-border-strong))]"}`}`,children:[l.jsx(df,{type:"command",suggestions:Kt.suggestions,selectedIndex:Kt.selectedIndex,loading:Kt.loading,onSelect:Oa,onHover:Kt.setSelectedIndex,visible:Hs}),l.jsx(df,{type:"file",suggestions:Gt.suggestions,selectedIndex:Gt.selectedIndex,loading:Gt.loading,onSelect:Ra,onHover:Gt.setSelectedIndex,visible:oi&&!Hs}),l.jsx(ny,{ref:$e,"data-blade-composer":!0,value:$,onChange:Sy,onKeyDown:wy,onPaste:yy,onSelect:ed,onClick:ed,placeholder:y??k(o?"chat.input.placeholder.steering":"chat.input.placeholder.default"),className:`flex-1 w-full resize-none border-0 bg-transparent px-4 focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none text-[#111827] dark:text-zinc-300 placeholder:text-[#9CA3AF] dark:placeholder:text-zinc-600 ${f==="task"?"min-h-[84px] py-4 text-[15px]":"py-2.5 text-[14px]"}`,disabled:n||re,"aria-busy":re}),De&&l.jsx("div",{className:"px-4 pb-2 font-mono text-[11px] text-amber-600 dark:text-amber-400",children:"$ user shell · runs in this Session workspace"}),o&&l.jsx("div",{className:"px-4 pb-2 text-[11px] font-mono text-amber-600 dark:text-amber-400",children:a>0&&c==="next_turn"?k("chat.input.followUp.queued",{count:a}):a>0?k("chat.input.steering.queued",{count:a}):l.jsxs(l.Fragment,{children:[k("chat.input.steering.status"),k("chat.input.steering.enterHint")]})}),u>0&&l.jsx("div",{className:"px-4 pb-2 text-[11px] font-mono text-cyan-600 dark:text-cyan-400",children:u===1?k("chat.input.steering.recoveredOne",{count:u}):k("chat.input.steering.recoveredMany",{count:u})}),Ma&&l.jsxs("div",{role:"alert",className:"mx-4 mb-2 flex min-h-8 items-center gap-2 rounded-md border border-red-200 bg-red-50 px-2.5 py-1.5 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[l.jsx(co,{className:"h-3.5 w-3.5 shrink-0"}),l.jsx("span",{className:"min-w-0 flex-1",children:Ma}),We&&l.jsx("button",{type:"button","aria-label":k("chat.error.dismiss"),onClick:()=>{A(null),Xe.current=null},className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-red-500 hover:bg-red-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 dark:hover:bg-red-950",children:l.jsx(eo,{className:"h-3 w-3"})})]}),nd&&l.jsxs("div",{role:"status","aria-live":"polite",className:"mx-4 mb-2 flex min-h-8 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-2.5 py-1.5 text-[11px] text-[hsl(var(--deck-ink-muted))]",children:[l.jsx(e0,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),l.jsx("span",{className:"min-w-0 flex-1",children:nd}),l.jsx("button",{type:"button","aria-label":k("chat.notice.dismiss"),onClick:()=>Q(null),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:l.jsx(eo,{className:"h-3 w-3"})})]}),R.length>0&&l.jsxs("div",{className:"px-4 pb-2",children:[l.jsx("div",{className:"mb-1.5 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:k("chat.input.attachment.usage",{count:R.length,limit:Br,used:Ya(Cy),budget:Ya(oo)})}),l.jsx("div",{className:"flex flex-wrap gap-2",children:R.map(I=>l.jsxs("div",{title:I.name,className:"relative overflow-hidden rounded-md border border-[#E5E7EB] bg-[#F9FAFB] dark:border-zinc-800 dark:bg-zinc-900",children:[l.jsx("img",{src:I.dataUrl,alt:I.name,className:"h-20 w-20 object-cover"}),l.jsx("button",{type:"button","aria-label":`${k("chat.input.attachment.remove")} ${I.name}`,title:`${k("chat.input.attachment.remove")} ${I.name}`,onClick:()=>xy(I.id),className:"absolute right-1 top-1 flex h-6 w-6 items-center justify-center rounded bg-black/75 text-white transition-colors hover:bg-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white",children:l.jsx(eo,{className:"h-3 w-3"})})]},I.id))})]}),l.jsxs("div",{className:"flex justify-between items-center px-3 py-2 mt-auto",children:[l.jsxs("div",{className:"flex gap-2 items-center",children:[Ty?l.jsx("button",{type:"button",disabled:Fa,"aria-disabled":"true","aria-label":Ks,title:Ks,onClick:Ey,className:"flex h-8 w-8 cursor-help items-center justify-center rounded-md text-[#9CA3AF] opacity-55 transition-colors hover:bg-[hsl(var(--deck-surface-2))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-not-allowed dark:text-zinc-500",children:l.jsx(ld,{className:"h-4 w-4"})}):l.jsxs("label",{title:Ks,className:"relative flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[#9CA3AF] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] focus-within:ring-1 focus-within:ring-[hsl(var(--deck-accent))] dark:text-zinc-500 dark:hover:bg-zinc-800/50 dark:hover:text-zinc-300",children:[l.jsx("input",{ref:rr,type:"file",accept:"image/*",multiple:!0,"aria-label":Ks,className:"absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0",onChange:ky}),l.jsx(ld,{className:"h-4 w-4"})]}),l.jsxs(Bn,{open:te,onOpenChange:I=>{!o&&!re&&j(I)},children:[l.jsx(Un,{asChild:!0,children:l.jsxs("button",{type:"button",disabled:o||re,title:k(o?"chat.input.model.locked":"chat.input.model.change"),className:"flex cursor-pointer items-center gap-1 rounded px-2 py-1 text-xs text-[#6B7280] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] disabled:cursor-not-allowed disabled:opacity-55 dark:text-zinc-500 dark:hover:bg-zinc-800/50 dark:hover:text-zinc-200",children:[Xu,l.jsx(Mr,{className:"w-3 h-3"})]})}),l.jsx(An,{className:"w-64 p-2 bg-white dark:bg-zinc-900 border border-[#E5E7EB] dark:border-zinc-700",align:"start",children:l.jsx("div",{className:"overflow-y-auto max-h-72",children:rn.length===0?l.jsx("div",{className:"text-xs text-[#6B7280] dark:text-zinc-500 px-2 py-2",children:k("chat.input.model.empty")}):Object.entries(rn.reduce((I,W)=>{const J=W.provider||"unknown";return I[J]||(I[J]=[]),I[J].push(W),I},{})).map(([I,W])=>l.jsxs("div",{className:"mb-2",children:[l.jsx("div",{className:"text-xs text-[#6B7280] dark:text-zinc-500 px-2 py-1 capitalize",children:I.replace(/-/g," ")}),W.map(J=>{var Le;return l.jsx("button",{className:`w-full text-left px-2 py-1.5 text-sm rounded hover:bg-[#E5E7EB] dark:hover:bg-zinc-800 transition-colors ${J.id===ds?"bg-[#E5E7EB] text-[#111827] dark:bg-zinc-800 dark:text-zinc-100":"text-[#6B7280] dark:text-zinc-400"}`,onClick:()=>{if(Q(null),ie){Ju(J.id),j(!1);return}ke(J.id,v??void 0).then(()=>j(!1)).catch(()=>{})},children:l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l.jsx("span",{className:"min-w-0 flex-1 truncate",children:J.displayName||J.model}),((Le=J.input)==null?void 0:Le.includes("image"))&&l.jsx("span",{className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.08em] text-[hsl(var(--deck-accent))]",children:k("chat.input.model.vision")})]})},J.id)})]},I))})})]}),l.jsxs(Bn,{open:F,onOpenChange:I=>{!o&&!re&&se(I)},children:[l.jsx(Un,{asChild:!0,children:l.jsxs("button",{type:"button",disabled:o||re,"aria-label":k("chat.input.effort.change"),title:k(o?"chat.input.effort.locked":"chat.input.effort.change"),className:"flex cursor-pointer items-center gap-1 rounded px-2 py-1 font-mono text-[11px] text-[#6B7280] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-not-allowed disabled:opacity-55 dark:text-zinc-500 dark:hover:bg-zinc-800/50 dark:hover:text-zinc-200",children:[k("chat.input.effort.label",{effort:Pr}),l.jsx(Mr,{className:"h-3 w-3"})]})}),l.jsxs(An,{className:"w-52 border border-[#E5E7EB] bg-white p-1 dark:border-zinc-700 dark:bg-zinc-900",align:"start",children:[l.jsx("div",{className:"px-2 py-1 font-mono text-[9px] uppercase tracking-[0.12em] text-[#9CA3AF] dark:text-zinc-600",children:k("chat.input.effort.heading")}),l.jsx("div",{className:"flex flex-col gap-0.5",children:my.map(I=>l.jsxs("button",{type:"button","aria-label":k("chat.input.effort.option",{effort:I}),onClick:()=>{Ca(I),se(!1)},className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left font-mono text-[11px] transition-colors hover:bg-[#E5E7EB] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] dark:hover:bg-zinc-800 ${Pr===I?"bg-[#E5E7EB] text-[#111827] dark:bg-zinc-800 dark:text-zinc-100":"text-[#6B7280] dark:text-zinc-400"}`,children:[l.jsx("span",{className:"capitalize",children:I}),I==="auto"&&l.jsx("span",{className:"text-[9px] text-[#9CA3AF] dark:text-zinc-600",children:k("chat.input.effort.autoHint")})]},I))})]})]}),l.jsxs(Bn,{open:ne,onOpenChange:I=>{!o&&!re&&oe(I)},children:[l.jsx(Un,{asChild:!0,children:l.jsxs("button",{type:"button",disabled:o||re,"aria-label":k("chat.input.serviceTier.change"),title:k(o?"chat.input.serviceTier.locked":"chat.input.serviceTier.change"),className:"flex cursor-pointer items-center gap-1 rounded px-2 py-1 font-mono text-[11px] text-[#6B7280] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-not-allowed disabled:opacity-55 dark:text-zinc-500 dark:hover:bg-zinc-800/50 dark:hover:text-zinc-200",children:[k("chat.input.serviceTier.label",{tier:Or}),l.jsx(Mr,{className:"h-3 w-3"})]})}),l.jsxs(An,{className:"w-52 border border-[#E5E7EB] bg-white p-1 dark:border-zinc-700 dark:bg-zinc-900",align:"start",children:[l.jsx("div",{className:"px-2 py-1 font-mono text-[9px] uppercase tracking-[0.12em] text-[#9CA3AF] dark:text-zinc-600",children:k("chat.input.serviceTier.heading")}),l.jsx("div",{className:"flex flex-col gap-0.5",children:py.map(I=>l.jsxs("button",{type:"button","aria-label":k("chat.input.serviceTier.option",{tier:I}),onClick:()=>{Ta(I),oe(!1)},className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left font-mono text-[11px] transition-colors hover:bg-[#E5E7EB] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] dark:hover:bg-zinc-800 ${Or===I?"bg-[#E5E7EB] text-[#111827] dark:bg-zinc-800 dark:text-zinc-100":"text-[#6B7280] dark:text-zinc-400"}`,children:[l.jsx("span",{className:"capitalize",children:I}),I==="fast"&&l.jsx("span",{className:"text-[9px] text-[#9CA3AF] dark:text-zinc-600",children:k("chat.input.serviceTier.fastHint")}),I==="flex"&&l.jsx("span",{className:"text-[9px] text-[#9CA3AF] dark:text-zinc-600",children:k("chat.input.serviceTier.flexHint")})]},I))})]})]}),l.jsxs(Bn,{open:Ie,onOpenChange:I=>{!o&&!re&&ve(I)},children:[l.jsx(Un,{asChild:!0,children:l.jsxs("button",{type:"button",disabled:o||re,"aria-label":k("chat.input.responseVerbosity.change"),title:k(o?"chat.input.responseVerbosity.locked":"chat.input.responseVerbosity.change"),className:"flex cursor-pointer items-center gap-1 rounded px-2 py-1 font-mono text-[11px] text-[#6B7280] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-not-allowed disabled:opacity-55 dark:text-zinc-500 dark:hover:bg-zinc-800/50 dark:hover:text-zinc-200",children:[k("chat.input.responseVerbosity.label",{verbosity:Rr}),l.jsx(Mr,{className:"h-3 w-3"})]})}),l.jsxs(An,{className:"w-52 border border-[#E5E7EB] bg-white p-1 dark:border-zinc-700 dark:bg-zinc-900",align:"start",children:[l.jsx("div",{className:"px-2 py-1 font-mono text-[9px] uppercase tracking-[0.12em] text-[#9CA3AF] dark:text-zinc-600",children:k("chat.input.responseVerbosity.heading")}),l.jsx("div",{className:"flex flex-col gap-0.5",children:gy.map(I=>l.jsxs("button",{type:"button","aria-label":k("chat.input.responseVerbosity.option",{verbosity:I}),onClick:()=>{Ea(I),ve(!1)},className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left font-mono text-[11px] transition-colors hover:bg-[#E5E7EB] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] dark:hover:bg-zinc-800 ${Rr===I?"bg-[#E5E7EB] text-[#111827] dark:bg-zinc-800 dark:text-zinc-100":"text-[#6B7280] dark:text-zinc-400"}`,children:[l.jsx("span",{className:"capitalize",children:I}),I==="auto"&&l.jsx("span",{className:"text-[9px] text-[#9CA3AF] dark:text-zinc-600",children:k("chat.input.responseVerbosity.autoHint")})]},I))})]})]}),l.jsxs(Bn,{open:Ee,onOpenChange:I=>{!o&&!re&&L(I)},children:[l.jsx(Un,{asChild:!0,children:l.jsxs("button",{type:"button",disabled:o||re,"aria-label":k("chat.input.communicationStyle.change"),title:k(o?"chat.input.communicationStyle.locked":"chat.input.communicationStyle.change"),className:"flex cursor-pointer items-center gap-1 rounded px-2 py-1 font-mono text-[11px] text-[#6B7280] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-not-allowed disabled:opacity-55 dark:text-zinc-500 dark:hover:bg-zinc-800/50 dark:hover:text-zinc-200",children:[k("chat.input.communicationStyle.label",{style:hy}),l.jsx(Mr,{className:"h-3 w-3"})]})}),l.jsxs(An,{className:"w-56 border border-[#E5E7EB] bg-white p-1 dark:border-zinc-700 dark:bg-zinc-900",align:"start",children:[l.jsx("div",{className:"px-2 py-1 font-mono text-[9px] uppercase tracking-[0.12em] text-[#9CA3AF] dark:text-zinc-600",children:k("chat.input.communicationStyle.heading")}),l.jsx("div",{className:"flex flex-col gap-0.5",children:Yu.map(I=>l.jsxs("button",{type:"button","aria-label":k("chat.input.communicationStyle.option",{style:I.id}),title:I.description,onClick:()=>{Qu(I.id),L(!1)},className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left font-mono text-[11px] transition-colors hover:bg-[#E5E7EB] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] dark:hover:bg-zinc-800 ${qs===I.id?"bg-[#E5E7EB] text-[#111827] dark:bg-zinc-800 dark:text-zinc-100":"text-[#6B7280] dark:text-zinc-400"}`,children:[l.jsx("span",{children:I.name}),l.jsx("span",{className:"text-[9px] text-[#9CA3AF] dark:text-zinc-600",children:I.source})]},I.id))})]})]}),l.jsxs(Bn,{open:ae,onOpenChange:He,children:[l.jsx(Un,{asChild:!0,children:l.jsxs("button",{className:"flex items-center gap-1 text-xs text-[#6B7280] hover:text-[#111827] px-2 py-1 rounded hover:bg-[#E5E7EB] dark:text-zinc-500 dark:hover:text-zinc-200 dark:hover:bg-zinc-800/50 cursor-pointer transition-colors",children:[vy,l.jsx(Mr,{className:"w-3 h-3"})]})}),l.jsx(An,{className:"w-40 p-1 bg-white dark:bg-zinc-900 border border-[#E5E7EB] dark:border-zinc-700",align:"start",children:l.jsx("div",{className:"flex flex-col gap-0.5",children:ff.map(I=>l.jsx("button",{className:`w-full text-left px-2 py-1.5 text-xs rounded hover:bg-[#E5E7EB] dark:hover:bg-zinc-800 transition-colors ${Ct===I.value?"bg-[#E5E7EB] text-[#111827] dark:bg-zinc-800 dark:text-zinc-100":"text-[#6B7280] dark:text-zinc-400"}`,onClick:()=>{or(I.value),He(!1)},children:k(I.labelKey)},I.value))})})]})]}),l.jsxs("div",{className:"flex gap-2 items-center",children:[o&&l.jsx(mr,{size:"icon",onClick:()=>{t==null||t()},disabled:i,title:k(i?"chat.input.action.stopping":"chat.input.action.stop"),"aria-label":k(i?"chat.input.action.stopping":"chat.input.action.stop"),className:"w-8 h-8 text-white bg-red-500 hover:bg-red-600",children:i?l.jsx(ct,{className:"h-3.5 w-3.5 animate-spin"}):l.jsx(_c,{className:"w-3 h-3"})}),l.jsx(mr,{size:"icon",onClick:Pa,disabled:!jy||n||Rt||si||re||by,title:k(re?"chat.input.action.submitting":o?"chat.input.action.steer":"chat.input.action.send"),"aria-label":k(re?"chat.input.action.submitting":o?"chat.input.action.steer":"chat.input.action.send"),className:"h-8 w-8 bg-[#111827] text-white hover:bg-[#0F172A] disabled:bg-[#E5E7EB] disabled:text-[#9CA3AF] dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white dark:disabled:bg-zinc-800 dark:disabled:text-zinc-600",children:re?l.jsx(ct,{className:"h-4 w-4 animate-spin"}):l.jsx(t0,{className:"w-4 h-4"})})]})]})]}),f==="chat"&&l.jsx("div",{className:"text-center text-xs text-[#6B7280] dark:text-zinc-600 mt-3 font-mono",children:k("chat.footer.disclaimer")})]})})}const iD={running:{dot:"bg-blue-500 shadow-[0_0_5px_rgba(59,130,246,0.7)] animate-pulse",labelKey:"recent.status.running",text:"text-blue-700 dark:text-blue-400"},queued:{dot:"bg-amber-400",labelKey:"recent.status.queued",text:"text-amber-700 dark:text-amber-400"},interrupted:{dot:"bg-orange-500",labelKey:"recent.status.paused",text:"text-orange-700 dark:text-orange-400"},failed:{dot:"bg-red-500",labelKey:"recent.status.failed",text:"text-red-700 dark:text-red-400"},cancelled:{dot:"bg-zinc-400",labelKey:"recent.status.cancelled",text:"text-zinc-500"},completed:{dot:"bg-[hsl(var(--deck-accent))]",labelKey:"recent.status.done",text:"text-[hsl(var(--deck-accent))]"}};function aD(e,t){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";const r=Date.now()-n.getTime(),s=Math.floor(r/6e4);if(s<1)return t("recent.time.justNow");if(s<60)return t("recent.time.minutes",{n:s});const o=Math.floor(s/60);if(o<24)return t("recent.time.hours",{n:o});const i=Math.floor(o/24);return t("recent.time.days",{n:i})}function cD(e){return e.split("/").filter(Boolean).at(-1)||e}function lD({sessions:e,onSelect:t,cancellingTaskKeys:n,retryingTaskKeys:r,unreadTaskKeys:s,onCancel:o,onRetry:i,catalogLoadState:a="ready",className:c}){const u=Ut(),f=[...e].sort(Vu).slice(0,4),p=a==="loading"||a==="hydrating";return f.length===0?!p&&a!=="error"?null:l.jsxs("div",{role:a==="error"?"alert":"status",className:V("mt-7 flex items-center gap-2 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/50 px-3 py-2 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",c),children:[p?l.jsx(ct,{className:"h-3 w-3 animate-spin text-[hsl(var(--deck-accent))]"}):l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500"}),u(p?"sidebar.catalog.syncing":"sidebar.catalog.incomplete")]}):l.jsxs("div",{className:V("mt-7",c),children:[l.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[l.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:u("taskHome.recent.title")}),l.jsx("span",{className:"font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:u(p?"taskHome.recent.partial":a==="error"?"taskHome.recent.incomplete":"taskHome.recent.total",{count:e.length})})]}),l.jsx("div",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:f.map(g=>{var O;const b=iD[g.taskStatus],x=g.pendingInteraction?g.pendingInteraction.type==="question"?"interaction.badge.question":g.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission":null,y=cD(g.taskSourceProjectPath||g.projectPath),v=ao(g,u),k=qe(he(g)),E=g.taskStatus==="running"||g.taskStatus==="queued",$=n.includes(k),B=r.includes(k),R=!!g.taskRetryAvailable&&(g.taskStatus==="failed"||g.taskStatus==="interrupted"||g.taskStatus==="cancelled"),M=s.includes(k),P=(O=g.taskStatusReason)==null?void 0:O.trim(),N=g.taskFailure?u(qu(g.taskFailure.code)):P==="user-cancel"?u("session.reason.cancelledByUser"):P||void 0;return l.jsxs("div",{className:V("group flex items-center gap-3 rounded-md border border-transparent px-3 py-1.5 text-left transition-colors","hover:border-[hsl(var(--deck-border))] hover:bg-[hsl(var(--deck-surface))]"),children:[l.jsxs("button",{type:"button",onClick:()=>t(g),className:"flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[l.jsx("span",{className:V("h-1.5 w-1.5 shrink-0 rounded-full",x?"animate-pulse bg-amber-500 shadow-[0_0_5px_rgba(245,158,11,0.75)]":b.dot)}),l.jsxs("span",{className:"min-w-0 flex-1",children:[l.jsxs("span",{className:"flex items-center gap-1.5 text-[12.5px] text-[hsl(var(--deck-ink))]",children:[l.jsx("span",{className:"truncate",children:v}),M&&l.jsx("span",{title:u("taskSwitcher.new"),className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[hsl(var(--deck-accent))] shadow-[0_0_5px_hsl(var(--deck-accent-glow)/0.75)]"}),g.taskRetriedFrom&&l.jsx("span",{title:`${u("session.retriedFrom")} ${g.taskRetriedFrom.sessionId.slice(0,6)}`,className:"shrink-0 font-mono text-[8.5px] text-[hsl(var(--deck-accent))]",children:u("session.retryShort")})]}),l.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[l.jsx("span",{className:"truncate",children:y}),l.jsx("span",{className:"opacity-40",children:"·"}),l.jsx("span",{className:V("shrink-0",x?"text-amber-700 dark:text-amber-400":b.text),children:u(x??b.labelKey)}),l.jsx("span",{className:"opacity-40",children:"·"}),l.jsx("span",{className:"shrink-0",children:aD(g.lastMessageTime||g.firstMessageTime,u)})]}),N&&l.jsx("span",{title:N,className:"mt-0.5 block truncate font-mono text-[9.5px] text-red-600 dark:text-red-400",children:N})]}),l.jsx(n0,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))] opacity-0 transition-opacity group-hover:opacity-100"})]}),E&&l.jsx("button",{type:"button","aria-label":u($?"session.action.stopping":"session.action.stop",{title:v}),disabled:$,onClick:()=>o(g),className:"rounded p-1.5 text-red-500 transition-colors hover:bg-red-500/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60",children:$?l.jsx(ct,{className:"h-3.5 w-3.5 animate-spin"}):l.jsx(_c,{className:"h-3.5 w-3.5"})}),R&&l.jsx("button",{type:"button","aria-label":u(B?"session.action.retrying":"session.action.retry",{title:v}),disabled:B,onClick:()=>i(g),className:"rounded p-1.5 text-[hsl(var(--deck-accent))] transition-colors hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-wait disabled:opacity-60",children:B?l.jsx(ct,{className:"h-3.5 w-3.5 animate-spin"}):l.jsx(Li,{className:"h-3.5 w-3.5"})})]},k)})})]})}function uD({index:e,title:t,description:n,icon:r,hint:s,onClick:o}){const i=String(e+1).padStart(2,"0"),a=`⌘${e+1}`;return l.jsxs("button",{type:"button",onClick:o,className:V("group relative flex min-h-[100px] flex-col justify-between overflow-hidden rounded-lg border p-3.5 text-left transition","border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]","hover:-translate-y-[1px] hover:border-[hsl(var(--deck-accent)/0.55)] hover:shadow-[0_10px_28px_-14px_hsl(var(--deck-accent)/0.35)]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--deck-accent))] focus-visible:ring-offset-2 focus-visible:ring-offset-[hsl(var(--deck-canvas))]","dark:bg-[hsl(var(--deck-surface))] dark:hover:shadow-[0_10px_28px_-14px_hsl(var(--deck-accent)/0.55)]"),children:[l.jsx("span",{"aria-hidden":"true",className:V("pointer-events-none absolute right-3 top-3 h-2 w-2","border-r border-t border-[hsl(var(--deck-border-strong))]","transition-colors group-hover:border-[hsl(var(--deck-accent))]")}),l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsx("span",{className:V("inline-flex h-8 w-8 items-center justify-center rounded-md border transition-colors","border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))]","group-hover:border-[hsl(var(--deck-accent)/0.5)] group-hover:bg-[hsl(var(--deck-accent-soft))]"),children:l.jsx(r,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))] transition-colors group-hover:text-[hsl(var(--deck-accent))]"})}),l.jsx("span",{className:"font-mono text-[10px] tracking-[0.16em] text-[hsl(var(--deck-ink-faint))]",children:i})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-[13px] font-semibold text-[hsl(var(--deck-ink))]",children:t}),l.jsx("div",{className:"mt-1 line-clamp-2 text-[11.5px] leading-[1.45] text-[hsl(var(--deck-ink-muted))]",children:n}),l.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[l.jsx("span",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-faint))] opacity-0 transition-opacity group-hover:opacity-100",children:s}),l.jsx("span",{className:"deck-kbd shrink-0 opacity-0 transition-opacity group-hover:opacity-100",children:a})]})]})]})}const Xa=[{key:"explore",titleKey:"taskHome.template.explore.title",descriptionKey:"taskHome.template.explore.description",icon:Lc,prompt:"Explore this codebase and explain ",hintKey:"taskHome.template.explore.hint"},{key:"build",titleKey:"taskHome.template.build.title",descriptionKey:"taskHome.template.build.description",icon:r0,prompt:"Build a production-ready ",hintKey:"taskHome.template.build.hint"},{key:"review",titleKey:"taskHome.template.review.title",descriptionKey:"taskHome.template.review.description",icon:s0,prompt:"Review the current changes for bugs, regressions, and missing tests. ",hintKey:"taskHome.template.review.hint"},{key:"fix",titleKey:"taskHome.template.fix.title",descriptionKey:"taskHome.template.fix.description",icon:o0,prompt:"Investigate and fix ",hintKey:"taskHome.template.fix.hint"}];function dD(e,t){return t?t.split("/").filter(Boolean).at(-1)||t:e("taskHome.hero.projectFallback")}function fD(){const e=Ut(),{taskWorkspaceInfo:t,isTaskWorkspaceLoading:n,taskWorkspaceError:r,isDispatchingTask:s,sessions:o,boundProjects:i,selectedProjectPath:a,error:c,selectProject:u,dispatchTask:f,sendMessage:p,startTemporarySession:g,selectSession:b,cancelTask:x,cancellingTaskKeys:y,retryTask:v,retryingTaskKeys:k,unreadTaskKeys:E,taskEventConnectionState:$,catalogLoadState:B,reconnectTaskEvents:R,clearError:M,loadTaskWorkspaceInfo:P,loadBoundProjects:N}=U(),O=pr(z=>z.openSettings),_=pr(z=>z.isSettingsOpen),te=Vt(z=>z.currentMode),j=Vt(z=>z.currentModelId),F=Vt(z=>z.configuredModels),se=Vt(z=>z.isLoading),ne=Vt(z=>z.hasLoaded),oe=Vt(z=>z.loadedWorkspacePath),Ie=Vt(z=>z.error),ve=Vt(z=>z.loadModels),[Ee,L]=w.useState("worktree"),[ae,He]=w.useState(),[re,Ne]=w.useState(!1),We=e($==="connected"?"taskHome.eyebrow":$==="reconnecting"?"taskHome.feed.reconnecting":$==="offline"?"taskHome.feed.offline":"taskHome.feed.connecting"),A=w.useMemo(()=>i.find(z=>z.path===a)??i.find(z=>z.isCurrent),[i,a]),q=w.useMemo(()=>S2(o,a,(t==null?void 0:t.cwd)??null),[a,o,t==null?void 0:t.cwd]),Q=(A!=null&&A.available?A.path:void 0)??(t==null?void 0:t.cwd),De=`task:${Q??"unavailable"}`;w.useEffect(()=>{!_&&Q&&(!ne||oe!==Q)&&ve(Q)},[_,ve,oe,ne,Q]);const Rt=!(A!=null&&A.available)&&n,Xe=A!=null&&A.available?null:r,hn=!!(Q&&!Rt&&!Xe),$e=!!(j&&F.some(z=>z.id===j)),rr=!ne||se,sr=hn&&$e&&!rr&&Ie===null,rn=w.useMemo(()=>({project:dD(e,(A==null?void 0:A.path)??(t==null?void 0:t.cwd)),branch:(A==null?void 0:A.gitBranch)??(t==null?void 0:t.gitBranch)??e("taskHome.context.branchFallback")}),[A,t,e]),cs=w.useCallback(async z=>{if(z.content.trimStart().startsWith("!")){g(Q),await p({content:z.content,attachments:[]});return}await f({prompt:z.content,projectPath:Q,isolation:Ee,permissionMode:te,modelId:z.modelId??j??void 0,reasoningEffort:z.reasoningEffort,serviceTier:z.serviceTier,responseVerbosity:z.responseVerbosity,communicationStyle:z.communicationStyle,attachments:z.attachments.map(T=>({type:"image",content:T.dataUrl,mimeType:T.mimeType,name:T.name}))})},[te,j,f,Ee,p,g,Q]);return w.useEffect(()=>{const z=T=>{if(!(T.metaKey||T.ctrlKey))return;const ke=Number.parseInt(T.key,10);if(Number.isNaN(ke)||ke<1||ke>Xa.length)return;const Ct=Xa[ke-1];Ct&&(T.preventDefault(),He({key:De,content:Ct.prompt}))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[De]),l.jsx("main",{className:"deck-canvas relative flex-1 overflow-y-auto text-[hsl(var(--deck-ink))]",children:l.jsxs("div",{className:"mx-auto flex min-h-full w-full max-w-[960px] flex-col px-6 py-8 md:px-8 md:py-10",children:[l.jsxs("div",{className:"flex gap-4 items-start mb-6",children:[l.jsx(Gu,{size:36,className:"hidden mt-1 sm:inline-flex"}),l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:V("deck-eyebrow flex items-center gap-2",$==="offline"?"text-amber-700 dark:text-amber-400":"text-[hsl(var(--deck-accent))]"),children:[$==="offline"?l.jsx(ud,{className:"w-3 h-3"}):l.jsx("span",{className:"deck-pulse-dot"}),We]}),l.jsxs("h1",{className:"mt-2.5 max-w-3xl text-balance text-[clamp(28px,3vw,34px)] font-medium leading-[1.12] tracking-[-0.028em] text-[hsl(var(--deck-ink))]",children:[e("taskHome.hero.prefix")," ",l.jsx("span",{className:"whitespace-nowrap font-mono text-[0.82em] text-[hsl(var(--deck-accent))]",children:rn.project}),l.jsx("span",{className:"text-[hsl(var(--deck-ink-muted))]",children:"?"})]}),l.jsx("p",{className:"mt-2 max-w-[46rem] text-[13px] leading-[1.55] text-[hsl(var(--deck-ink-muted))]",children:e("taskHome.hero.subtitle")})]})]}),l.jsxs("div",{className:"mb-4",children:[l.jsxs("div",{className:"flex justify-between items-center mb-2",children:[l.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:e("taskHome.templates.title")}),l.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[l.jsx(Cf,{className:"w-3 h-3"}),l.jsx("span",{children:e("taskHome.templates.hint")})]})]}),l.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-4",children:Xa.map((z,T)=>l.jsx(uD,{index:T,title:e(z.titleKey),description:e(z.descriptionKey),icon:z.icon,hint:e(z.hintKey),onClick:()=>He({key:De,content:z.prompt})},z.key))})]}),l.jsxs("div",{className:"rounded-xl border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] shadow-[0_28px_80px_-32px_hsl(var(--deck-accent)/0.28),0_2px_0_hsl(var(--deck-hairline))]",children:[l.jsxs("div",{className:"flex items-center gap-0 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/50",children:[l.jsxs("div",{className:"flex flex-1 items-center min-w-0",children:[l.jsxs(Bn,{children:[l.jsx(Un,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":e("taskHome.context.projectSelect"),disabled:i.length===0,className:"group flex h-9 min-w-0 items-center gap-2 border-r border-[hsl(var(--deck-hairline))] px-3 font-mono text-[11.5px] text-[hsl(var(--deck-ink))] transition-colors hover:bg-[hsl(var(--deck-surface))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))] disabled:opacity-50",children:[l.jsx(no,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),l.jsx("span",{className:"font-medium truncate",children:(A==null?void 0:A.name)??rn.project}),l.jsx(Mr,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))] transition-transform group-data-[state=open]:rotate-180"})]})}),l.jsx(An,{align:"start",sideOffset:4,className:"w-56 rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-1 shadow-xl",children:l.jsxs("div",{className:"flex flex-col",children:[i.map(z=>l.jsxs("button",{type:"button",disabled:!z.available,onClick:()=>{u(z.path)},className:V("flex items-center gap-2 rounded-md px-2.5 py-1.5 text-left font-mono text-[12px] transition-colors",z.path===a?"bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface-2))] hover:text-[hsl(var(--deck-ink))]",!z.available&&"opacity-40"),children:[l.jsx(no,{className:"w-3 h-3 shrink-0"}),l.jsx("span",{className:"flex-1 min-w-0 truncate",children:z.name}),z.path===a&&l.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[hsl(var(--deck-accent))]"})]},z.path)),i.length===0&&l.jsx("span",{className:"px-2.5 py-2 text-center font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:e("taskHome.setup.workspace.empty")})]})})]}),l.jsxs("button",{type:"button","aria-pressed":Ee==="worktree",onClick:()=>L(z=>z==="worktree"?"local":"worktree"),className:V("flex h-9 shrink-0 items-center gap-1.5 border-r border-[hsl(var(--deck-hairline))] px-3 font-mono text-[11px] transition-colors",Ee==="worktree"?"text-[hsl(var(--deck-accent))]":"text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),title:e("taskHome.context.isolationToggleTitle"),children:[Ee==="worktree"?l.jsx(i0,{className:"w-3 h-3"}):l.jsx(a0,{className:"w-3 h-3"}),l.jsx("span",{className:"hidden sm:inline",children:e(Ee==="worktree"?"taskHome.context.isolation.worktree":"taskHome.context.isolation.local")})]}),l.jsxs("span",{className:"flex h-9 shrink-0 items-center gap-1.5 border-r border-[hsl(var(--deck-hairline))] px-3 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:[l.jsx(Fc,{className:"w-3 h-3"}),l.jsx("span",{className:"hidden sm:inline",children:rn.branch})]})]}),l.jsxs("div",{className:"flex gap-2 items-center px-3 shrink-0",children:[(t==null?void 0:t.taskAdmission)&&l.jsx(zk,{inFlight:t.taskAdmission.inFlight,queued:t.taskAdmission.queued,maxConcurrent:t.taskAdmission.maxConcurrent,compact:!0}),s&&l.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-accent))]",children:[l.jsx(ct,{className:"w-3 h-3 animate-spin"}),l.jsx("span",{className:"hidden sm:inline",children:e("taskHome.context.preparing")})]})]})]}),!sr&&l.jsxs("section",{"aria-label":e("taskHome.setup.aria"),className:"border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-3 py-3",children:[l.jsxs("div",{className:"mb-2.5",children:[l.jsx("h2",{className:"font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-[hsl(var(--deck-ink))]",children:e("taskHome.setup.title")}),l.jsx("p",{className:"mt-0.5 text-[11px] text-[hsl(var(--deck-ink-faint))]",children:e("taskHome.setup.description")})]}),l.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-2.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-2.5",children:[l.jsx("span",{className:V("flex justify-center items-center w-7 h-7 rounded-md border shrink-0",hn?"text-emerald-700 bg-emerald-50 border-emerald-300/70 dark:border-emerald-800/70 dark:bg-emerald-950/40 dark:text-emerald-300":Xe?"text-red-700 bg-red-50 border-red-300/70 dark:border-red-900/70 dark:bg-red-950/40 dark:text-red-300":"text-amber-700 bg-amber-50 border-amber-300/70 dark:border-amber-800/70 dark:bg-amber-950/40 dark:text-amber-300"),children:Rt?l.jsx(ct,{className:"h-3.5 w-3.5 animate-spin"}):hn?l.jsx(dd,{className:"h-3.5 w-3.5"}):Xe?l.jsx(co,{className:"h-3.5 w-3.5"}):l.jsx(no,{className:"h-3.5 w-3.5"})}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block font-mono text-[11px] font-medium text-[hsl(var(--deck-ink))]",children:e("taskHome.setup.workspace.title")}),l.jsx("span",{className:"mt-0.5 block truncate text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:Rt?e("taskHome.setup.workspace.loading"):Xe||(hn?e("taskHome.setup.workspace.ready",{project:rn.project}):e("taskHome.setup.workspace.required"))})]}),!hn&&l.jsxs("div",{className:"flex gap-1 items-center shrink-0",children:[Xe&&l.jsx("button",{type:"button",onClick:()=>{Promise.all([P(),N()])},"aria-label":e("taskHome.setup.workspace.retry"),title:e("taskHome.setup.workspace.retry"),className:"flex h-8 w-8 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-canvas))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:l.jsx(to,{className:"h-3.5 w-3.5"})}),l.jsxs("button",{type:"button","data-project-setup-trigger":!0,onClick:()=>Ne(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-2.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink))] hover:border-[hsl(var(--deck-accent)/0.55)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[l.jsx(yi,{className:"w-3 h-3"}),e("taskHome.setup.workspace.action")]})]})]}),l.jsxs("div",{className:"flex min-w-0 items-center gap-2.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-2.5",children:[l.jsx("span",{className:V("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",$e&&!Ie?"border-emerald-300/70 bg-emerald-50 text-emerald-700 dark:border-emerald-800/70 dark:bg-emerald-950/40 dark:text-emerald-300":Ie?"border-red-300/70 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/40 dark:text-red-300":"border-amber-300/70 bg-amber-50 text-amber-700 dark:border-amber-800/70 dark:bg-amber-950/40 dark:text-amber-300"),children:rr?l.jsx(ct,{className:"h-3.5 w-3.5 animate-spin"}):$e&&!Ie?l.jsx(dd,{className:"h-3.5 w-3.5"}):Ie?l.jsx(co,{className:"h-3.5 w-3.5"}):l.jsx(fd,{className:"h-3.5 w-3.5"})}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block font-mono text-[11px] font-medium text-[hsl(var(--deck-ink))]",children:e("taskHome.setup.model.title")}),l.jsx("span",{title:Ie??void 0,className:V("mt-0.5 block truncate text-[10.5px]",Ie?"text-red-600 dark:text-red-400":"text-[hsl(var(--deck-ink-faint))]"),children:rr?e("taskHome.setup.model.loading"):Ie||e($e?"taskHome.setup.model.ready":"taskHome.setup.model.required")})]}),!rr&&(!$e||Ie)&&l.jsxs("button",{type:"button","data-model-setup-trigger":!0,onClick:()=>{Ie?ve(Q):O("models")},className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-2.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink))] hover:border-[hsl(var(--deck-accent)/0.55)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[Ie?l.jsx(to,{className:"w-3 h-3"}):l.jsx(fd,{className:"w-3 h-3"}),e(Ie?"taskHome.setup.model.retry":"taskHome.setup.model.action")]})]})]})]}),l.jsx("div",{className:"px-3 pt-3 pb-3",children:l.jsx(oD,{variant:"task",draft:(ae==null?void 0:ae.key)===De?ae.content:void 0,draftKey:De,placeholder:e("taskHome.composer.placeholder"),onSend:async z=>{try{return await cs(z),He(void 0),!0}catch{return!1}},disabled:s,submitDisabled:!sr,shellSubmitDisabled:!sr,workspacePath:Q},De)})]}),$==="offline"&&l.jsxs("div",{role:"alert",className:"flex flex-wrap gap-3 items-center px-3 py-2 mt-4 text-amber-900 rounded-md border border-amber-300/70 bg-amber-50/80 dark:border-amber-800/70 dark:bg-amber-950/35 dark:text-amber-200",children:[l.jsx(ud,{className:"h-3.5 w-3.5 shrink-0"}),l.jsx("span",{className:"min-w-0 flex-1 text-[12px]",children:e("taskHome.feed.offlineDescription")}),l.jsxs("button",{type:"button",onClick:()=>void R().catch(()=>{}),className:"inline-flex min-h-8 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/60 px-2.5 font-mono text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[l.jsx(to,{className:"w-3 h-3"}),e("taskHome.feed.retry")]})]}),c&&l.jsxs("div",{role:"alert",className:"flex justify-between items-center px-3 py-2 mt-4 font-mono text-xs text-red-700 rounded-md border border-red-200 bg-red-50/80 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[l.jsx("span",{children:c}),l.jsx("button",{type:"button",onClick:M,className:"underline",children:e("taskHome.error.dismiss")})]}),l.jsx(lD,{sessions:q,catalogLoadState:B,cancellingTaskKeys:y,retryingTaskKeys:k,unreadTaskKeys:E,onSelect:z=>{b(he(z))},onCancel:z=>{x(he(z)).catch(()=>{})},onRetry:z=>{v(he(z)).catch(()=>{})}}),l.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[l.jsx(jf,{className:"w-3 h-3"}),l.jsx("span",{className:"font-mono uppercase tracking-[0.14em]",children:e("taskHome.footer.note")})]}),l.jsx(Xk,{open:re,onOpenChange:Ne})]})})}const Oc="blade.sessions.last",Di="session",Rc="project",Mc="workspace";function mD(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;return typeof t.sessionId=="string"&&t.sessionId.trim()&&typeof t.projectPath=="string"&&t.projectPath.trim()?{sessionId:t.sessionId,projectPath:t.projectPath}:null}function pD(e){var o,i,a;const t=new URLSearchParams(e),n=((o=t.get(Di))==null?void 0:o.trim())||null,r=((i=t.get(Rc))==null?void 0:i.trim())||null,s=((a=t.get(Mc))==null?void 0:a.trim())||null;return{sessionRef:n&&(s||r)?{sessionId:n,projectPath:s||r}:null,projectPath:r,hasSessionParam:t.has(Di)}}function gD(e=typeof localStorage>"u"?null:localStorage){if(!e)return null;try{const t=e.getItem(Oc);return t?mD(JSON.parse(t)):null}catch{return null}}function hD(e,t,n={}){const r=n.href??(typeof window>"u"?"http://localhost/":window.location.href),s=new URL(r),o=n.displayProjectPath??(e==null?void 0:e.projectPath)??t,i=(e==null?void 0:e.projectPath)??null;e?s.searchParams.set(Di,e.sessionId):s.searchParams.delete(Di),o?s.searchParams.set(Rc,o):s.searchParams.delete(Rc),i&&o&&i!==o?s.searchParams.set(Mc,i):s.searchParams.delete(Mc);const a=n.storage===void 0?typeof localStorage>"u"?null:localStorage:n.storage;try{e?a==null||a.setItem(Oc,JSON.stringify(e)):a==null||a.removeItem(Oc)}catch{}const c=`${s.pathname}${s.search}${s.hash}`,u=n.replaceState??(typeof window>"u"?void 0:f=>window.history.replaceState(null,"",f));return u==null||u(c),c}const bD=w.lazy(()=>Is(()=>import("./ChatView-CnwNosSG.js"),__vite__mapDeps([10,1,2,3])).then(e=>({default:e.ChatView})));function xD(){const e=Ut(),[t,n]=w.useState(!1),r=U(E=>E.subscribeToTaskEvents),s=U(E=>E.unsubscribeFromTaskEvents),o=U(E=>E.currentSessionRef),i=U(E=>E.isTemporarySession),a=U(E=>E.loadTaskWorkspaceInfo),c=U(E=>E.loadBoundProjects),u=U(E=>E.loadSessions),f=U(E=>E.selectSession),p=U(E=>E.selectProject),g=U(E=>E.startTemporarySession),b=U(E=>E.setError),x=U(E=>E.sessions),y=U(E=>E.selectedProjectPath),v=Vt(E=>E.loadModels),k=Mi(E=>E.loadSettings);return w.useEffect(()=>(r().catch(E=>{console.error("Failed to subscribe to task events",E)}),s),[r,s]),w.useEffect(()=>{let E=!1;return(async()=>{var te;u(),k(),v();const B=pD(window.location.search),R=gD(),M=B.hasSessionParam?B.sessionRef:B.projectPath?null:R,P=Promise.all([a(),c()]),N=!M&&!B.projectPath;if(N&&(g(),n(!0)),await P,E)return;const O=U.getState(),_=B.projectPath?(te=O.boundProjects.find(j=>j.path===B.projectPath&&j.available))==null?void 0:te.path:null;if(_&&p(_),!(M&&(await f(M),E))){if(!M||!de(U.getState().currentSessionRef,M)){const j=M?U.getState().error:null;g(),j&&b(j)}N||n(!0)}})(),()=>{E=!0}},[c,v,u,k,a,p,f,b,g]),w.useEffect(()=>{if(!t)return;const E=o?Bu(x,o):void 0;hD(o,y,{displayProjectPath:E?ti(E,y):y})},[o,t,y,x]),l.jsxs(l.Fragment,{children:[l.jsx(U5,{}),l.jsx(B5,{children:t?!o||i?l.jsx(fD,{}):l.jsx(w.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center font-mono text-[12px] text-[hsl(var(--deck-ink-faint))]",children:e("app.restoring")}),children:l.jsx(bD,{})}):l.jsx("div",{className:"flex h-full items-center justify-center font-mono text-[12px] text-[hsl(var(--deck-ink-faint))]",children:e("app.restoring")})})]})}$y.createRoot(document.getElementById("root")).render(l.jsx(Ys.StrictMode,{children:l.jsx(xD,{})}));export{jD as A,Gu as B,oD as C,Rf as D,Vu as E,ao as F,ti as G,Cc as H,ks as I,Ac as J,Hk as K,u2 as L,mr as M,vD as N,Ku as S,Is as _,U as a,pr as b,he as c,qe as d,Uc as e,qc as f,zc as g,Hc as h,Ff as i,V as j,pe as k,p2 as l,Gn as m,va as n,xi as o,Bu as p,O2 as q,af as r,de as s,qu as t,Ut as u,dr as v,Yk as w,Vt as x,Mi as y,l5 as z};
|