howtocode 0.7.68 → 0.7.70
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/README.md +7 -1
- package/dist/{chunk-NPD6557W.js → chunk-336TZTEK.js} +1 -1
- package/dist/{chunk-7LAMZWB5.js → chunk-4SK7TRJW.js} +1 -1
- package/dist/chunk-5FIFNXLT.js +10 -0
- package/dist/{chunk-EPNFKO5O.js → chunk-63TDK73J.js} +1 -1
- package/dist/{chunk-LUBZSBUH.js → chunk-CJLCMZKZ.js} +1 -1
- package/dist/{chunk-L4XKIPIG.js → chunk-E2UZLMQH.js} +1 -1
- package/dist/{chunk-XVHYS2UZ.js → chunk-EOZHQRU2.js} +1 -1
- package/dist/chunk-FABEBOGV.js +2 -0
- package/dist/{chunk-KS6FRAVP.js → chunk-GM6T357A.js} +1 -1
- package/dist/chunk-GNV6G3JW.js +201 -0
- package/dist/{chunk-YX2QDCVK.js → chunk-GQYIIDKK.js} +1 -1
- package/dist/{chunk-4KNWFMK6.js → chunk-HGINAX3Z.js} +1 -1
- package/dist/{chunk-O3XEEDMR.js → chunk-I555QJLZ.js} +1 -1
- package/dist/{chunk-6PZTZT6T.js → chunk-LAPEUVNT.js} +1 -1
- package/dist/{chunk-HKABQFBG.js → chunk-MXO4OS67.js} +1 -1
- package/dist/{chunk-W2U7D5UF.js → chunk-RJYOUCLJ.js} +1 -1
- package/dist/chunk-RKIOE6G6.js +141 -0
- package/dist/{chunk-YFJKKWIX.js → chunk-SDU65XW4.js} +1 -1
- package/dist/{chunk-NIDL55H4.js → chunk-SOWZZCT4.js} +1 -1
- package/dist/{chunk-AVNJV7SN.js → chunk-T3KNQOMX.js} +1 -1
- package/dist/{chunk-3H2ECHBB.js → chunk-ULXYWUXZ.js} +1 -1
- package/dist/{chunk-SVONBXW3.js → chunk-ZJL4OEXX.js} +3 -3
- package/dist/{chunk-2GVIOMRN.js → cli-auth.js} +1 -1
- package/dist/main-app.js +7 -7
- package/dist/main.js +10 -0
- package/package.json +2 -2
- package/dist/chunk-465RG5I6.js +0 -10
- package/dist/chunk-HDH5ER4H.js +0 -141
- package/dist/chunk-U3GZBLTM.js +0 -2
- package/dist/chunk-VDUY46W2.js +0 -198
package/dist/chunk-VDUY46W2.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import{b as pf}from"./chunk-27TRKD65.js";import{t as cf}from"./chunk-SVONBXW3.js";import{H as Ye,K as uf,L as jn,a as Gi}from"./chunk-465RG5I6.js";import{a as sr}from"./chunk-UTYFLLSM.js";import{a as Nm,b as Dn,c as Nn,d as qm,e as Um,f as Mo,g as _m,h as Br,j as vo}from"./chunk-MVVEYKN6.js";import{a as At}from"./chunk-WOT6VMZA.js";import{spawn as k1}from"node:child_process";import{existsSync as T1,readFileSync as w1}from"node:fs";import{join as C1}from"node:path";var B={};At(B,{Match:()=>Nw});function Nw(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}var Me={};At(Me,{Get:()=>Qi,Reset:()=>FC,Set:()=>LC});var s={};At(s,{CodePointCount:()=>Zw,Counted:()=>sC,Entries:()=>uC,EntriesRegExp:()=>mC,Every:()=>rC,EveryAll:()=>nC,GraphemeCount:()=>Xw,HasPropertyKey:()=>aC,IsArray:()=>Lo,IsBigInt:()=>Fo,IsBoolean:()=>xf,IsClassInstance:()=>Qw,IsConstructor:()=>Hw,IsDeepEqual:()=>Km,IsEqual:()=>Y,IsFunction:()=>hf,IsGreaterEqualThan:()=>bf,IsGreaterThan:()=>Vw,IsInteger:()=>Bm,IsLessEqualThan:()=>If,IsLessThan:()=>Jw,IsMaxLength:()=>eC,IsMinLength:()=>tC,IsMultipleOf:()=>Yw,IsNull:()=>Wi,IsNumber:()=>Vi,IsObject:()=>jo,IsObjectNotArray:()=>zw,IsString:()=>Ji,IsSymbol:()=>Ww,IsUndefined:()=>Gm,IsUnsafePropertyKey:()=>Ef,IsValueLike:()=>$f,Keys:()=>zi,ShiftLeft:()=>Yi,Some:()=>oC,SomeAll:()=>iC,Symbols:()=>cC,Values:()=>pC});function qn(e,t,r){return e>=t&&e<=r}function qw(e){return e===8205}function ff(e){return qn(e,127462,127487)}function Uw(e){return qn(e,65024,65039)}function _w(e){return qn(e,768,879)||qn(e,6832,6911)||qn(e,7616,7679)||qn(e,65056,65071)}function Ki(e){return e>65535?2:1}function df(e,t){for(;t<e.length;){let r=e.codePointAt(t);if(_w(r)||Uw(r))t+=Ki(r);else break}return t}function Bw(e,t){let r=e.codePointAt(t),n=t+Ki(r);for(n=df(e,n);n<e.length-1&&qw(e.codePointAt(n));){let o=e.codePointAt(n+1);n+=1+Ki(o),n=df(e,n)}return ff(r)&&n<e.length&&ff(e.codePointAt(n))&&(n+=Ki(e.codePointAt(n))),n}function lf(e){let t=0,r=0;for(;r<e.length;)r=Bw(e,r),t++;return t}function Hi(e){let t=0,r=0,n=0;for(;r<e.length;){let o=e.charCodeAt(r++)>>10;t+=+((n<<8|o)!==13879),n=o}return t}function gf(e,t){return e.length<=t||e.length<=t<<1&&Hi(e)<=t}function yf(e,t){return e.length>=t<<1||e.length>=t&&Hi(e)>=t}function Lo(e){return Array.isArray(e)}function Fo(e){return Y(typeof e,"bigint")}function xf(e){return Y(typeof e,"boolean")}function Hw(e){if(Gm(e)||!hf(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function hf(e){return Y(typeof e,"function")}function Bm(e){return Number.isInteger(e)}function Wi(e){return Y(e,null)}function Vi(e){return Number.isFinite(e)}function zw(e){return jo(e)&&!Lo(e)}function jo(e){return Y(typeof e,"object")&&!Wi(e)}function Ji(e){return Y(typeof e,"string")}function Ww(e){return Y(typeof e,"symbol")}function Gm(e){return Y(e,void 0)}function Y(e,t){return e===t}function Vw(e,t){return e>t}function Jw(e,t){return e<t}function If(e,t){return e<=t}function bf(e,t){return e>=t}function Yw(e,t){if(Fo(e)||Fo(t))return BigInt(e)%BigInt(t)===0n;let r=1e-10;if(!Vi(e)||Bm(e)&&1/t%1===0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t),Math.abs(n+t))<r}function Qw(e){if(!jo(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return Wi(t)?!1:Y(typeof t.constructor,"function")&&!(Y(t.constructor,globalThis.Object)||Y(t.constructor.name,"Object"))}function $f(e){return Fo(e)||xf(e)||Wi(e)||Vi(e)||Ji(e)||Gm(e)}function Xw(e){return lf(e)}function Zw(e){return Hi(e)}function eC(e,t){return gf(e,t)}function tC(e,t){return yf(e,t)}function rC(e,t,r){return e.every((n,o)=>o<t||r(n,o))}function nC(e,t,r){let n=!0;return e.forEach((o,i)=>{i>=t&&!r(o,i)&&(n=!1)}),n}function oC(e,t){return e.some((r,n)=>t(r,n))}function iC(e,t){let r=!1;return e.forEach((n,o)=>{t(n,o)&&(r=!0)}),r}function sC(e,t){return e.reduce((r,n,o)=>t(n,o)?++r:r,0)}function Yi(e,t,r){return Y(e.length,0)?r():t(e[0],e.slice(1))}function Ef(e){return Y(e,"__proto__")||Y(e,"constructor")||Y(e,"prototype")}function aC(e,t){return Ef(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function mC(e){return zi(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function uC(e){return Object.entries(e)}function zi(e){return Object.getOwnPropertyNames(e)}function cC(e){return Object.getOwnPropertySymbols(e)}function pC(e){return Object.values(e)}function fC(e,t){if(!jo(t))return!1;let r=zi(e);return Y(r.length,zi(t).length)&&r.every(n=>Km(e[n],t[n]))}function dC(e,t){return Lo(t)&&Y(e.length,t.length)&&e.every((r,n)=>Km(e[n],t[n]))}function Km(e,t){return Lo(e)?dC(e,t):jo(e)?fC(e,t):Y(e,t)}var De={};At(De,{IsBigInt64Array:()=>CC,IsBigUint64Array:()=>RC,IsBoolean:()=>lC,IsDate:()=>AC,IsFloat32Array:()=>TC,IsFloat64Array:()=>wC,IsInt16Array:()=>$C,IsInt32Array:()=>SC,IsInt8Array:()=>hC,IsMap:()=>MC,IsNumber:()=>gC,IsRegExp:()=>PC,IsSet:()=>OC,IsString:()=>yC,IsTypeArray:()=>xC,IsUint16Array:()=>EC,IsUint32Array:()=>kC,IsUint8Array:()=>IC,IsUint8ClampedArray:()=>bC});function lC(e){return e instanceof Boolean}function gC(e){return e instanceof Number}function yC(e){return e instanceof String}function xC(e){return globalThis.ArrayBuffer.isView(e)}function hC(e){return e instanceof globalThis.Int8Array}function IC(e){return e instanceof globalThis.Uint8Array}function bC(e){return e instanceof globalThis.Uint8ClampedArray}function $C(e){return e instanceof globalThis.Int16Array}function EC(e){return e instanceof globalThis.Uint16Array}function SC(e){return e instanceof globalThis.Int32Array}function kC(e){return e instanceof globalThis.Uint32Array}function TC(e){return e instanceof globalThis.Float32Array}function wC(e){return e instanceof globalThis.Float64Array}function CC(e){return e instanceof globalThis.BigInt64Array}function RC(e){return e instanceof globalThis.BigUint64Array}function PC(e){return e instanceof globalThis.RegExp}function AC(e){return e instanceof globalThis.Date}function OC(e){return e instanceof globalThis.Set}function MC(e){return e instanceof globalThis.Map}var Sf=s;var Vt={immutableTypes:!1,maxErrors:8,maxParseErrors:1,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function FC(){Vt.immutableTypes=!1,Vt.maxErrors=8,Vt.maxParseErrors=1,Vt.maxInstantiationCount=128,Vt.useAcceleration=!0,Vt.exactOptionalPropertyTypes=!1,Vt.enumerableKind=!1,Vt.correctiveParse=!1,Vt.unionPrioritySort=!0}function LC(e){for(let t of s.Keys(e)){let r=e[t];r!==void 0&&Object.defineProperty(Vt,t,{value:r})}}function Qi(){return Vt}function Xi(e){return s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>s.IsObject(t)&&s.HasPropertyKey(t,"check")&&s.HasPropertyKey(t,"error")&&s.IsFunction(t.check)&&s.IsFunction(t.error))}function gt(e){return s.IsObject(e)&&!s.IsArray(e)}function ln(e){return s.IsBoolean(e)}function L(e){return gt(e)||ln(e)}function Zi(e){return s.HasPropertyKey(e,"additionalItems")&&L(e.additionalItems)}function _t(e){return s.HasPropertyKey(e,"additionalProperties")&&L(e.additionalProperties)}function es(e){return s.HasPropertyKey(e,"allOf")&&s.IsArray(e.allOf)&&e.allOf.every(t=>L(t))}function kf(e){return s.HasPropertyKey(e,"$anchor")&&s.IsString(e.$anchor)}function ts(e){return s.HasPropertyKey(e,"anyOf")&&s.IsArray(e.anyOf)&&e.anyOf.every(t=>L(t))}function Hm(e){return s.HasPropertyKey(e,"const")}function Gr(e){return s.HasPropertyKey(e,"contains")&&L(e.contains)}function bt(e){return s.HasPropertyKey(e,"default")}function zm(e){return s.HasPropertyKey(e,"dependencies")&&s.IsObject(e.dependencies)&&Object.values(e.dependencies).every(t=>L(t)||s.IsArray(t)&&t.every(r=>s.IsString(r)))}function Wm(e){return s.HasPropertyKey(e,"dependentRequired")&&s.IsObject(e.dependentRequired)&&Object.values(e.dependentRequired).every(t=>s.IsArray(t)&&t.every(r=>s.IsString(r)))}function rs(e){return s.HasPropertyKey(e,"dependentSchemas")&&s.IsObject(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(t=>L(t))}function Kr(e){return s.HasPropertyKey(e,"$dynamicAnchor")&&s.IsString(e.$dynamicAnchor)}function ns(e){return s.HasPropertyKey(e,"$dynamicRef")&&s.IsString(e.$dynamicRef)}function os(e){return s.HasPropertyKey(e,"else")&&L(e.else)}function Vm(e){return s.HasPropertyKey(e,"enum")&&s.IsArray(e.enum)}function Jm(e){return s.HasPropertyKey(e,"exclusiveMaximum")&&(s.IsNumber(e.exclusiveMaximum)||s.IsBigInt(e.exclusiveMaximum))}function wr(e){return s.HasPropertyKey(e,"exclusiveMinimum")&&(s.IsNumber(e.exclusiveMinimum)||s.IsBigInt(e.exclusiveMinimum))}function Do(e){return s.HasPropertyKey(e,"format")&&s.IsString(e.format)}function ut(e){return s.HasPropertyKey(e,"$id")&&s.IsString(e.$id)}function is(e){return s.HasPropertyKey(e,"if")&&L(e.if)}function gn(e){return s.HasPropertyKey(e,"items")&&(L(e.items)||s.IsArray(e.items)&&e.items.every(t=>L(t)))}function ss(e){return gn(e)&&s.IsArray(e.items)}function Ym(e){return s.HasPropertyKey(e,"maximum")&&(s.IsNumber(e.maximum)||s.IsBigInt(e.maximum))}function Qm(e){return s.HasPropertyKey(e,"maxContains")&&s.IsNumber(e.maxContains)}function No(e){return s.HasPropertyKey(e,"maxItems")&&s.IsNumber(e.maxItems)}function Xm(e){return s.HasPropertyKey(e,"maxLength")&&s.IsNumber(e.maxLength)}function Zm(e){return s.HasPropertyKey(e,"maxProperties")&&s.IsNumber(e.maxProperties)}function Cr(e){return s.HasPropertyKey(e,"minimum")&&(s.IsNumber(e.minimum)||s.IsBigInt(e.minimum))}function yn(e){return s.HasPropertyKey(e,"minContains")&&s.IsNumber(e.minContains)}function xn(e){return s.HasPropertyKey(e,"minItems")&&s.IsNumber(e.minItems)}function qo(e){return s.HasPropertyKey(e,"minLength")&&s.IsNumber(e.minLength)}function Uo(e){return s.HasPropertyKey(e,"minProperties")&&s.IsNumber(e.minProperties)}function eu(e){return s.HasPropertyKey(e,"multipleOf")&&(s.IsNumber(e.multipleOf)||s.IsBigInt(e.multipleOf))}function as(e){return s.HasPropertyKey(e,"not")&&L(e.not)}function ms(e){return s.HasPropertyKey(e,"oneOf")&&s.IsArray(e.oneOf)&&e.oneOf.every(t=>L(t))}function _o(e){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)}function Un(e){return s.HasPropertyKey(e,"patternProperties")&&s.IsObject(e.patternProperties)&&Object.values(e.patternProperties).every(t=>L(t))}function hn(e){return s.HasPropertyKey(e,"prefixItems")&&s.IsArray(e.prefixItems)&&e.prefixItems.every(t=>L(t))}function _n(e){return s.HasPropertyKey(e,"properties")&&s.IsObject(e.properties)&&Object.values(e.properties).every(t=>L(t))}function us(e){return s.HasPropertyKey(e,"propertyNames")&&(s.IsObject(e.propertyNames)||L(e.propertyNames))}function jC(e){return s.HasPropertyKey(e,"$recursiveAnchor")&&s.IsBoolean(e.$recursiveAnchor)}function Bo(e){return jC(e)&&s.IsEqual(e.$recursiveAnchor,!0)}function cs(e){return s.HasPropertyKey(e,"$recursiveRef")&&s.IsString(e.$recursiveRef)}function ps(e){return s.HasPropertyKey(e,"$ref")&&s.IsString(e.$ref)}function In(e){return s.HasPropertyKey(e,"required")&&s.IsArray(e.required)&&e.required.every(t=>s.IsString(t))}function fs(e){return s.HasPropertyKey(e,"then")&&L(e.then)}function tu(e){return s.HasPropertyKey(e,"type")&&(s.IsString(e.type)||s.IsArray(e.type)&&e.type.every(t=>s.IsString(t)))}function Hr(e){return s.HasPropertyKey(e,"uniqueItems")&&s.IsBoolean(e.uniqueItems)}function Go(e){return s.HasPropertyKey(e,"unevaluatedItems")&&L(e.unevaluatedItems)}function Ko(e){return s.HasPropertyKey(e,"unevaluatedProperties")&&L(e.unevaluatedProperties)}var ct=class{constructor(){let t=new Set,r=new Set;this.stack=[{indices:t,keys:r}]}Push(){let t=new Set,r=new Set;return this.stack.push({indices:t,keys:r}),!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(let r of t)r.GetIndices().forEach(n=>this.GetIndices().add(n)),r.GetKeys().forEach(n=>this.GetKeys().add(n));return!0}},et=class extends ct{constructor(){super(),this.errors=[]}AtCapacity(){return this.errors.length>=Me.Get().maxErrors}AddError(t,r,n,o){return this.AddErrorObject({keyword:t,schemaPath:r,instancePath:n,params:o})}AddErrors(t){return t.forEach(r=>this.AddErrorObject(r)),!1}GetErrors(){return this.errors}AddErrorObject(t){return this.AtCapacity()||this.errors.push(t),!1}};function Tf(e,t,r,n){return s.Every(r["~refine"],0,(o,i)=>o.check(n))}function wf(e,t,r,n,o,i){return s.EveryAll(o["~refine"],0,(a,m)=>a.check(i)||t.AddError("~refine",r,n,{index:m,message:a.error(i)}))}var Ho="urn:typebox:root";function Rr(e,t){return URL.canParse(e,t)?new URL(e,t):s.IsEqual(t,Ho)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Gn(e,t){let r=gt(t)&&ut(t)?Rr(t.$id,Ho).href:Ho;return{context:e,schema:t,lexicalSchema:t,lexicalBase:r,resourceBase:r,referenceBase:r,ids:[],useResourceBaseForReference:!0,recursiveAnchor:void 0,dynamicAnchors:[],resourceEntries:new Map,pendingResource:!0,enteredResource:!1}}function ru(e,t,r=!0){if(ln(t))return e;if(Array.isArray(t))return t.reduce((o,i)=>ru(o,i,!1),e);if(!gt(t)||!r&&ut(t))return e;let n=!r&&Kr(t)?[...e,t]:e;return Object.keys(t).reduce((o,i)=>ru(o,t[i],!1),n)}function zo(e,t){return e.resourceEntries.get(t)}function Cf(e,t){return e.enteredResource||zo(e,t)!==void 0}function DC(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}function NC(e,t){return ut(t)?[...e.ids,t]:e.ids}function qC(e,t){return e.recursiveAnchor??(Bo(t)?t:void 0)}function UC(e,t){let r=ut(t)?ru(e.dynamicAnchors,t):e.dynamicAnchors;return Kr(t)?[...r,t]:r}function _C(e,t){return ut(t)?!1:e.pendingResource}function Rf(e,t){let r=zo(e,t);return r?r.base:ut(t)?Rr(t.$id,e.lexicalBase).href:e.lexicalBase}function Pf(e,t){let r=zo(e,t);return r?r.base:ut(t)&&e.pendingResource?Rr(t.$id,e.resourceBase).href:e.resourceBase}function Af(e,t){return ut(t)?!DC(t):e.useResourceBaseForReference}function BC(e,t){let r=Cf(e,t),n=Af(e,t);return r||n?Pf(e,t):Rf(e,t)}function GC(e,t){let r=zo(e,t);return r?r.root:ut(t)?t:e.lexicalSchema}function KC(e,t){return gt(t)&&(ut(t)||Kr(t)||s.IsUndefined(e.recursiveAnchor)&&Bo(t)||!s.IsUndefined(zo(e,t)))}function Kn(e,t){return KC(e,t)?{...e,ids:NC(e,t),dynamicAnchors:UC(e,t),recursiveAnchor:qC(e,t),pendingResource:_C(e,t),lexicalBase:Rf(e,t),resourceBase:Pf(e,t),useResourceBaseForReference:Af(e,t),referenceBase:BC(e,t),lexicalSchema:GC(e,t),enteredResource:Cf(e,t)}:e}function Of(e){return gn(e)&&s.IsArray(e.items)}function Mf(e,t,r,n){return Of(r)?s.Every(n,0,(i,a)=>s.IsLessThan(a,r.items.length)||Ot(e,t,r.additionalItems,i)&&t.AddIndex(a)):!0}function vf(e,t,r,n,o,i){return Of(o)?s.Every(i,0,(m,c)=>{let p=`${r}/additionalItems`,f=`${n}/${c}`;return s.IsLessThan(c,o.items.length)||Mt(e,t,p,f,o.additionalItems,m)&&t.AddIndex(c)}):!0}function $t(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function zr(e){return new RegExp(e,"u")}function HC(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function Ff(e){let t=[];return Un(e)&&t.push(...s.Keys(e.patternProperties)),_n(e)&&t.push(...s.Keys(e.properties).map(HC)),s.IsEqual(t.length,0)?"(?!)":`(${t.join("|")})`}function Lf(e,t,r,n){let o=zr(Ff(r));return s.Every(s.Keys(n),0,(a,m)=>o.test(a)||Ot(e,t,r.additionalProperties,n[a])&&t.AddKey(a))}function jf(e,t,r,n,o,i){let a=zr(Ff(o)),m=[];return s.EveryAll(s.Keys(i),0,(p,f)=>{let d=`${r}/additionalProperties`,g=`${n}/${$t(p)}`,y=a.test(p)||Mt(e,t,d,g,o.additionalProperties,i[p])&&t.AddKey(p);return y||m.push(p),y})||t.AddError("additionalProperties",r,n,{additionalProperties:m})}function Df(e,t,r,n){let o=r.allOf.reduce((i,a)=>{let m=new ct;return Q(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,r.allOf.length)&&t.Merge(o)}function Nf(e,t,r,n,o,i){let a=[],m=o.allOf.reduce((p,f,d)=>{let g=`${r}/allOf/${d}`,y=new et,I=ce(e,y,g,n,f,i);return I||a.push(y),I?[...p,y]:p},[]),c=s.IsEqual(m.length,o.allOf.length)&&t.Merge(m);return c||a.forEach(p=>t.AddErrors(p.GetErrors())),c}function qf(e,t,r,n){let o=r.anyOf.reduce((i,a)=>{let m=new ct;return Q(e,m,a,n)?[...i,m]:i},[]);return s.IsGreaterThan(o.length,0)&&t.Merge(o)}function Uf(e,t,r,n,o,i){let a=[],m=o.anyOf.reduce((p,f,d)=>{let g=new et,y=`${r}/anyOf/${d}`,I=ce(e,g,y,n,f,i);return I||a.push(g),I?[...p,g]:p},[]),c=s.IsGreaterThan(m.length,0)&&t.Merge(m);return c||a.forEach(p=>t.AddErrors(p.GetErrors())),c||t.AddError("anyOf",r,n,{})}function iu(e,t,r,n){return r}function _f(e,t,r,n,o,i){return iu(e,t,o,i)||t.AddError("boolean",r,n,{})}function su(e,t,r,n){return s.IsValueLike(r.const)?s.IsEqual(n,r.const):s.IsDeepEqual(n,r.const)}function Bf(e,t,r,n,o,i){return su(e,t,o,i)||t.AddError("const",r,n,{allowedValue:o.const})}function zC(e){return!(yn(e)&&s.IsEqual(e.minContains,0))}function au(e,t,r,n){return zC(r)?!s.IsEqual(n.length,0)&&s.SomeAll(n,(o,i)=>Q(e,t,r.contains,o)&&t.AddIndex(i)):!0}function Gf(e,t,r,n,o,i){return au(e,t,o,i)||t.AddError("contains",r,n,{minContains:1})}function Kf(e,t,r,n){let o=s.IsEqual(s.Keys(n).length,0),i=s.Every(s.Entries(r.dependencies),0,([a,m])=>!s.HasPropertyKey(n,a)||(s.IsArray(m)?m.every(c=>s.HasPropertyKey(n,c)):Q(e,t,m,n)));return o||i}function Hf(e,t,r,n,o,i){let a=s.IsEqual(s.Keys(i).length,0),m=s.EveryAll(s.Entries(o.dependencies),0,([c,p])=>{let f=`${r}/dependencies/${$t(c)}`;return!s.HasPropertyKey(i,c)||(s.IsArray(p)?p.every(d=>s.HasPropertyKey(i,d)||t.AddError("dependencies",r,n,{property:c,dependencies:p})):ce(e,t,f,n,p,i))});return a||m}function zf(e,t,r,n){let o=s.IsEqual(s.Keys(n).length,0),i=s.Every(s.Entries(r.dependentRequired),0,([a,m])=>!s.HasPropertyKey(n,a)||m.every(c=>s.HasPropertyKey(n,c)));return o||i}function Wf(e,t,r,n,o,i){let a=s.IsEqual(s.Keys(i).length,0),m=s.EveryAll(s.Entries(o.dependentRequired),0,([c,p])=>!s.HasPropertyKey(i,c)||s.EveryAll(p,0,f=>s.HasPropertyKey(i,f)||t.AddError("dependentRequired",r,n,{property:c,dependencies:p})));return a||m}function Vf(e,t,r,n){let o=s.IsEqual(s.Keys(n).length,0),i=s.Every(s.Entries(r.dependentSchemas),0,([a,m])=>!s.HasPropertyKey(n,a)||Q(e,t,m,n));return o||i}function Jf(e,t,r,n,o,i){let a=s.IsEqual(s.Keys(i).length,0),m=s.EveryAll(s.Entries(o.dependentSchemas),0,([c,p])=>{let f=`${r}/dependentSchemas/${$t(c)}`;return!s.HasPropertyKey(i,c)||ce(e,t,f,n,p,i)});return a||m}var Bt={};At(Bt,{DynamicRef:()=>SR,RecursiveRef:()=>bR,Ref:()=>hR});var mr={};At(mr,{Delete:()=>YC,Get:()=>VC,Has:()=>WC,Indices:()=>Vo,Set:()=>JC});function Qf(e){throw Error(e)}function Yf(){Qf("Pointer contains unsafe property key")}function mu(){Qf("Cannot set value")}function Vo(e){let t=e.split("/").map(r=>r.replace(/~1/g,"/").replace(/~0/g,"~"));return t[0]===""?t.slice(1):t}function WC(e,t){let r=e;for(let n of Vo(t)){if(!s.IsObject(r)||!s.HasPropertyKey(r,n))return!1;r=r[n]}return!0}function VC(e,t){let r=e;for(let n of Vo(t)){if(!s.IsObject(r)||s.IsUnsafePropertyKey(n))return;r=r[n]}return r}function Xf(e,t,r){let n=e;for(let o of t)s.IsUnsafePropertyKey(o)&&Yf(),n=s.IsObject(n)?n[o]:void 0;return s.IsUnsafePropertyKey(r)&&Yf(),s.IsObject(n)||mu(),n}function JC(e,t,r){let n=Vo(t),o=n.pop();return s.IsUndefined(o)&&mu(),Xf(e,n,o)[o]=r,e}function YC(e,t){let r=Vo(t),n=r.pop();s.IsUndefined(n)&&mu();let o=Xf(e,r,n);return s.IsArray(o)&&/^(0|[1-9]\d*)$/.test(n)?o.splice(Number(n),1):delete o[n],e}function pu(e,t){return gt(e)&&ut(e)?Rr(e.$id,t.href):t}function fu(e){return Rr(e,Ho)}function uu(e){return e.href.split("#")[0]}function QC(e,t,r){return cu(e,fu(t),r)}function XC(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}function ZC(e){return e.startsWith("#/")}function Zf(e,t){if(s.IsObject(e)&&Kr(e)&&s.IsEqual(e.$dynamicAnchor,t))return e;if(s.IsObject(e))for(let r of s.Keys(e)){let n=Zf(e[r],t);if(n)return n}}function cu(e,t,r){if(s.IsEqual(e,r))return t.href;let n=pu(e,t);if(s.IsArray(e))for(let o of e){let i=cu(o,n,r);if(!s.IsUndefined(i))return i}else if(s.IsObject(e))for(let o of s.Keys(e)){let i=cu(e[o],n,r);if(!s.IsUndefined(i))return i}}function ed(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let r=decodeURIComponent(t.hash.slice(1));if(r.startsWith("/"))return mr.Get(e,r)}function eR(e,t,r){if(!ut(e))return;if(s.IsEqual(e.$id,r.hash))return e;let n=new URL(r.href,t.href);if(s.IsEqual(t.pathname,n.pathname))return r.hash.startsWith("#")?ed(e,r):e}function tR(e,t,r){if(!kf(e))return;let n=new URL(`#${e.$anchor}`,t.href),o=new URL(r.href,t.href);return s.IsEqual(n.href,o.href)?e:void 0}function rR(e,t,r){if(!Kr(e))return;let n=new URL(`#${e.$dynamicAnchor}`,t.href),o=new URL(r.href,t.href);return s.IsEqual(n.href,o.href)?e:void 0}function nR(e,t,r){if(gt(e))return eR(e,t,r)??tR(e,t,r)??rR(e,t,r)??ed(e,r)}function oR(e,t,r){if(s.IsArray(e))return e.reduce((n,o)=>{let i=ds(o,t,r);return s.IsUndefined(i)?n:i},void 0)}function iR(e,t,r){if(s.IsObject(e))return s.Keys(e).reduce((n,o)=>{if(s.IsEqual(o,"const")||s.IsEqual(o,"enum"))return n;let i=ds(e[o],t,r);return s.IsUndefined(i)?n:i},void 0)}function ds(e,t,r){let n=pu(e,t);return nR(e,n,r)??oR(e,n,r)??iR(e,n,r)}function sR(e,t,r,n){let o=ls(e,t,r,n);return gt(o)&&ut(o)?o:void 0}function aR(e,t,r){if(!t.$ref.startsWith("#")||!gt(e.schema)||s.HasPropertyKey(e.schema,"$schema"))return;let n=QC(e.lexicalSchema,e.referenceBase,r);if(!(s.IsUndefined(n)||s.IsEqual(n,e.referenceBase)))return{target:r,base:n,root:e.lexicalSchema}}function mR(e,t,r){let n=e.context[t];if(gt(n))return{target:r,base:t,root:n}}function uR(e,t,r,n,o){let i=o?mR(e,n,r):void 0;return s.IsUndefined(i)?aR(e,t,r):i}function cR(e,t,r){if(ut(r))return;let n=sR(e.context,e.schema,e.referenceBase,t);if(!(!n||e.ids.includes(n)))return{resource:n}}function pR(e,t){return s.HasPropertyKey(e,t)?e[t]:void 0}function fR(e,t,r){return ds(e,t,r)}function dR(e,t,r){let n=uu(r);if(!s.HasPropertyKey(e,n)||s.IsEqual(n,uu(t)))return;let o=e[n],i=pu(o,new URL(n));return s.IsEqual(r.hash,"")?o:ds(o,i,r)}function ls(e,t,r,n){let o=fu(r),i=Rr(n,o.href);return pR(e,n)??fR(t,o,i)??dR(e,o,i)}function lR(e,t){if(!t)return e;let r=new Map(e.resourceEntries);return r.set(t.target,{base:t.base,root:t.root}),{...e,resourceEntries:r}}function gR(e,t){return t?Kn(e,t.resource):e}function td(e,t,r,n){let o=lR({...e,pendingResource:t},r);return gR(o,n)}function yR(e,t,r){let n=uu(Rr(t.$ref,e.referenceBase)),o=!s.IsEqual(n,e.resourceBase),i=uR(e,t,r,n,o),a=o?cR(e,n,r):void 0;return{schema:r,stack:td(e,!0,i,a)}}function xR(e,t){return{schema:t,stack:td(e,!s.IsUndefined(t))}}function hR(e,t){let r=ls(e.context,XC(e,t),e.referenceBase,t.$ref);return gt(r)?yR(e,t,r):xR(e,r)}function IR(e){return gt(e.lexicalSchema)&&Bo(e.lexicalSchema)}function bR(e,t){let r=IR(e)?e.recursiveAnchor:e.lexicalSchema;return ls(e.context,r,e.lexicalBase,t.$recursiveRef)}function rd(e,t){return Rr(t.$dynamicRef,fu(e.lexicalBase).href).hash}function nd(e,t){return e.dynamicAnchors.find(r=>s.IsEqual(r.$dynamicAnchor,t))??Zf(e.schema,t)}function $R(e,t,r){if(!gt(r)||!Kr(r))return r;let n=rd(e,t);return ZC(n)?r:nd(e,r.$dynamicAnchor)}function ER(e,t){let r=rd(e,t);return nd(e,decodeURIComponent(r.slice(1)))}function SR(e,t){let r=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,n=ls(e.context,r,e.lexicalBase,t.$dynamicRef);return s.IsUndefined(n)?ER(e,t):$R(e,t,n)}function od(e,t,r,n){let o=Bt.DynamicRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return L(o)&&Q(i,t,o,n)}function id(e,t,r,n,o,i){let a=Bt.DynamicRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return L(a)&&ce(m,t,r,n,a,i)}function gu(e,t,r,n){return s.Some(r.enum,o=>s.IsValueLike(o)?s.IsEqual(n,o):s.IsDeepEqual(n,o))}function sd(e,t,r,n,o,i){return gu(e,t,o,i)||t.AddError("enum",r,n,{allowedValues:o.enum})}function yu(e,t,r,n){return s.IsLessThan(n,r.exclusiveMaximum)}function ad(e,t,r,n,o,i){return yu(e,t,o,i)||t.AddError("exclusiveMaximum",r,n,{comparison:"<",limit:o.exclusiveMaximum})}function xu(e,t,r,n){return s.IsGreaterThan(n,r.exclusiveMinimum)}function md(e,t,r,n,o,i){return xu(e,t,o,i)||t.AddError("exclusiveMinimum",r,n,{comparison:">",limit:o.exclusiveMinimum})}var Xo={};At(Xo,{Clear:()=>Ld,Entries:()=>f0,Get:()=>g0,Has:()=>l0,IsDate:()=>zn,IsDateTime:()=>gs,IsDuration:()=>ys,IsEmail:()=>xs,IsHostname:()=>Ts,IsIPv4:()=>Rs,IsIPv6:()=>Ps,IsIdnEmail:()=>ws,IsIdnHostname:()=>Cs,IsIri:()=>Os,IsIriReference:()=>As,IsJsonPointer:()=>vs,IsJsonPointerUriFragment:()=>Ms,IsRegex:()=>Fs,IsRelativeJsonPointer:()=>Ls,IsTime:()=>Wn,IsUri:()=>Ns,IsUriReference:()=>js,IsUriTemplate:()=>Ds,IsUrl:()=>qs,IsUuid:()=>Us,Reset:()=>jd,Set:()=>d0,Test:()=>y0});var kR=[0,31,28,31,30,31,30,31,31,30,31,30,31],TR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function wR(e){return e%4===0&&(e%100!==0||e%400===0)}function zn(e){let t=TR.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&wR(r)?29:kR[n])}var CR=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function Wn(e,t=!0){let r=CR.exec(e);if(!r||t&&!r[4]&&!r[5])return!1;let n=+r[1],o=+r[2],i=+r[3];if(n>23||o>59||i>60)return!1;if(r[5]){let f=+r[6],d=+r[7];if(f>23||d>59)return!1}if(i<60)return!0;let a=r[5]==="-"?-1:1,m=+(r[6]||0),c=+(r[7]||0);return((n*60+o-a*(m*60+c))%1440+1440)%1440===1439}var RR=/^(?:\[!?(?:(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13}(?:\/(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13})*|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])\](?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*|(?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*)$/;function gs(e){let t=e.indexOf("["),r=t===-1?e:e.slice(0,t);if(t!==-1&&!RR.test(e.slice(t)))return!1;let n=r.split(/T/i);return n.length===2&&zn(n[0])&&Wn(n[1])}var PR=/^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 ys(e){return PR.test(e)}var AR=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;function xs(e){return AR.test(e)}var ud=/^(?!-).*(?<!-)$/,cd=/^(?!..--)/,pd=/^[a-zA-Z0-9-]*$/,uG=new RegExp("^\\p{ASCII}*$","u"),Vn=/[^\p{ASCII}]/u;var OR=/[0-9]/,fd=/[\u{0660}-\u{0669}]/u,MR=/[\u{06f0}-\u{06f9}]/u,vR=/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,FR=/[\u{002d}\u{002b}]/u,hu=new RegExp("\\p{Mn}","u"),LR=new RegExp("\\p{Mc}","u"),cG=new RegExp("\\p{Me}","u"),dd=/[\p{Mn}\p{Mc}\p{Me}]/u,Iu=new RegExp("\\p{L}","u"),jR=new RegExp("\\p{Nd}","u"),ld=new RegExp("\\p{Script=Greek}","u"),hs=new RegExp("\\p{Script=Hebrew}","u"),gd=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,yd=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,bu=/[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u,xd=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,DR=/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,NR=/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u,hd=new RegExp([OR,MR].map(e=>e.source).join("|"),"u"),Id=new RegExp([Iu,FR,vR,jR,hu,LR,DR,NR].map(e=>e.source).join("|"),"u");function bd(e){return ud.test(e)&&cd.test(e)&&pd.test(e)}var Yt=36,Yo=1,Qo=26,UR=38,_R=700,Ed=72,Sd=128;function $u(){throw null}function Is(e){return e.toLowerCase().startsWith("xn--")}function kd(e,t,r){e=r?Math.floor(e/_R):e>>1,e+=Math.floor(e/t);let n=0;for(;e>(Yt-Yo)*Qo>>1;)e=Math.floor(e/(Yt-Yo)),n+=Yt;return n+Math.floor((Yt-Yo+1)*e/(e+UR))}function bs(e){let t=[],r=Sd,n=0,o=Ed,i=e.lastIndexOf("-");if(i>0)for(let m=0;m<i;m++){let c=e.charCodeAt(m);c>=128&&$u(),t.push(c)}let a=i<0?0:i+1;for(;a<e.length;){let m=n,c=1,p=Yt;for(;;){a>=e.length&&$u();let d=e.charCodeAt(a++),g;d>=97&&d<=122?g=d-97:d>=48&&d<=57?g=d-48+26:$u(),n+=g*c;let y=p<=o?Yo:p>=o+Qo?Qo:p-o;if(g<y)break;c*=Yt-y,p+=Yt}let f=t.length+1;o=kd(n-m,f,m===0),r+=Math.floor(n/f),n%=f,t.splice(n,0,r),n++}return String.fromCodePoint(...t)}function $d(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var BR=new RegExp(Vn.source,"gu");function Td(e){let t=e.replace(BR,""),r=t.length,n=r>0?[t,"-"]:[],o=Array.from(e,p=>p.codePointAt(0)),i=Sd,a=0,m=Ed,c=r;for(;c<o.length;){let p=1/0;for(let f of o)f>=i&&f<p&&(p=f);a+=(p-i)*(c+1),i=p;for(let f of o)if(f<i&&a++,f===i){let d=a;for(let g=Yt;;g+=Yt){let y=g<=m?Yo:g>=m+Qo?Qo:g-m;if(d<y)break;let I=y+(d-y)%(Yt-y);n.push($d(I)),d=Math.floor((d-y)/(Yt-y))}n.push($d(d)),m=kd(a,c+1,c===r),a=0,c++}a++,i++}return n.join("")}var GR=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,wd=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,KR=/^(?:R|AL|AN)$/;function Cd(e){if(Is(e))try{return $s(bs(e.slice(4).toLowerCase()))}catch{return!1}return $s(e)}function Rd(e){let t=String.fromCodePoint(e);return hd.test(t)?"EN":fd.test(t)?"AN":hu.test(t)?"NSM":hs.test(t)?"R":yd.test(t)?"AL":Iu.test(t)?"L":"ON"}function $s(e){for(let t of e)if(KR.test(Rd(t.codePointAt(0))))return!0;return!1}function Es(e){let t=!1,r=wd,n=!1,o=!1,i=!0;for(let a of e){let m=Rd(a.codePointAt(0));if(i){if(m!=="L"&&m!=="R"&&m!=="AL")return!1;t=m==="R"||m==="AL",r=t?GR:wd,i=!1}if(!r.test(m))return!1;m==="EN"?n=!0:m==="AN"&&(o=!0)}return!(t&&n&&o)}function HR(e){return Vn.test(e)&&Td(e).length+4>63}function zR(e){return e[0]==="-"||e[e.length-1]==="-"?!0:e.slice(2).join("").startsWith("--")}function Ss(e){if(HR(e)||$s(e)&&!Es(e))return!1;let t=[...e],r=t.map(i=>i.codePointAt(0)),n=r.length;if(zR(t)||dd.test(t[0]))return!1;let o=!1;for(let i=0;i<n;i++){let a=r[i],m=t[i];if(xd.test(m)||!Id.test(m))return!1;gd.test(m)&&(o=!0);let c=r[i-1],p=r[i+1];switch(a){case 183:if(c!==108||p!==108)return!1;break;case 885:if(!p||!ld.test(t[i+1]))return!1;break;case 1523:case 1524:if(!c||!hs.test(t[i-1]))return!1;break;case 8204:if(!c||c<128&&!bu.test(t[i-1]))return!1;break;case 8205:if(!c||!bu.test(t[i-1]))return!1;break;case 12539:break}}return!(e.includes("\u30FB")&&!o)}function ks(e){if(!Is(e))return!1;try{let t=e.slice(4).toLowerCase();if(t.lastIndexOf("-")===0)return!1;let r=bs(t);return Vn.test(r)?Ss(r):!1}catch{return!1}}function WR(e){return e.length>0&&e.length<=63}function VR(e){return WR(e)&&(ks(e)||bd(e))}function Md(e){return e.length===0||e.length>253||e.charCodeAt(e.length-1)===46?!1:e.split(".").every(t=>VR(t))}function JR(e){return e.length>0&&e.length<=63}function YR(e){return JR(e)&&(ks(e)||Ss(e))}function QR(e){return e.replace(/[\uff01-\uff5e]/g,t=>String.fromCharCode(t.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}function vd(e){if(e.length===0||e.includes(" "))return!1;let t=QR(e);if(t.length>253)return!1;let r=t.split("."),n=r.some(o=>Cd(o));return r.every(o=>YR(o)&&(!n||Es(o)))}function Ts(e){return Md(e)}var XR=/^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function ws(e){return XR.test(e.normalize("NFC"))}function Cs(e){return vd(e)}var ZR=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function Rs(e){return ZR.test(e)}var e0=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;function Ps(e){return e0.test(e)}var t0=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,r0=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function As(e){return!t0.test(e)&&!r0.test(e)&&URL.canParse(e,"http://example.com")}var n0=/[\x00-\x20<>\^`{|}\\]/,o0=/%(?![0-9a-fA-F]{2})/;function Os(e){return n0.test(e)||o0.test(e)?!1:URL.canParse(e)}var i0=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function Ms(e){return i0.test(e)}var s0=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function vs(e){return s0.test(e)}function Fs(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var a0=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function Ls(e){return a0.test(e)}var m0=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function js(e){return m0.test(e)}var u0=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function Ds(e){return u0.test(e)}var c0=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Ns(e){return c0.test(e)}function qs(e){return URL.canParse(e)}var p0=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function Us(e){return p0.test(e)}var le=new Map;function Ld(){le.clear()}function f0(){return[...le.entries()]}function d0(e,t){le.set(e,t)}function l0(e){return le.has(e)}function g0(e){return le.get(e)}function y0(e,t){return le.get(e)?.(t)??!0}function jd(){Ld(),le.set("date-time",gs),le.set("date",zn),le.set("duration",ys),le.set("email",xs),le.set("hostname",Ts),le.set("idn-email",ws),le.set("idn-hostname",Cs),le.set("ipv4",Rs),le.set("ipv6",Ps),le.set("iri-reference",As),le.set("iri",Os),le.set("json-pointer-uri-fragment",Ms),le.set("json-pointer",vs),le.set("regex",Fs),le.set("relative-json-pointer",Ls),le.set("time",Wn),le.set("uri-reference",js),le.set("uri-template",Ds),le.set("uri",Ns),le.set("url",qs),le.set("uuid",Us)}jd();function Su(e,t,r,n){return Xo.Test(r.format,n)}function Dd(e,t,r,n,o,i){return Su(e,t,o,i)||t.AddError("format",r,n,{format:o.format})}function Nd(e,t,r,n){let o=fs(r)?r.then:!0,i=os(r)?r.else:!0;return Q(e,t,r.if,n)?Q(e,t,o,n):Q(e,t,i,n)}function qd(e,t,r,n,o,i){let a=fs(o)?o.then:!0,m=os(o)?o.else:!0,c=new et,p=ce(e,c,`${r}/if`,n,o.if,i)?ce(e,c,`${r}/then`,n,a,i)||t.AddError("if",r,n,{failingKeyword:"then"}):ce(e,t,`${r}/else`,n,m,i)||t.AddError("if",r,n,{failingKeyword:"else"});return p&&t.Merge([c]),p}function x0(e,t,r,n){return s.Every(r.items,0,(o,i)=>s.IsLessEqualThan(n.length,i)||Ot(e,t,o,n[i])&&t.AddIndex(i))}function h0(e,t,r,n,o,i){return s.EveryAll(o.items,0,(a,m)=>{let c=`${r}/items/${m}`,p=`${n}/${m}`;return s.IsLessEqualThan(i.length,m)||Mt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function I0(e,t,r,n){let o=hn(r)?r.prefixItems.length:0;return s.Every(n,o,(i,a)=>Ot(e,t,r.items,i)&&t.AddIndex(a))}function b0(e,t,r,n,o,i){let a=hn(o)?o.prefixItems.length:0;return s.EveryAll(i,a,(m,c)=>{let p=`${r}/items`,f=`${n}/${c}`;return Mt(e,t,p,f,o.items,m)&&t.AddIndex(c)})}function Ud(e,t,r,n){return ss(r)?x0(e,t,r,n):I0(e,t,r,n)}function _d(e,t,r,n,o,i){return ss(o)?h0(e,t,r,n,o,i):b0(e,t,r,n,o,i)}function $0(e){return Gr(e)}function ku(e,t,r,n){if(!$0(r))return!0;let o=s.Counted(n,i=>Q(e,t,r.contains,i));return s.IsLessEqualThan(o,r.maxContains)}function Bd(e,t,r,n,o,i){let a=yn(o)?o.minContains:1;return ku(e,t,o,i)||t.AddError("contains",r,n,{minContains:a,maxContains:o.maxContains})}function Tu(e,t,r,n){return s.IsLessEqualThan(n,r.maximum)}function Gd(e,t,r,n,o,i){return Tu(e,t,o,i)||t.AddError("maximum",r,n,{comparison:"<=",limit:o.maximum})}function wu(e,t,r,n){return s.IsLessEqualThan(n.length,r.maxItems)}function Kd(e,t,r,n,o,i){return wu(e,t,o,i)||t.AddError("maxItems",r,n,{limit:o.maxItems})}function Cu(e,t,r,n){return s.IsMaxLength(n,r.maxLength)}function Hd(e,t,r,n,o,i){return Cu(e,t,o,i)||t.AddError("maxLength",r,n,{limit:o.maxLength})}function Ru(e,t,r,n){return s.IsLessEqualThan(s.Keys(n).length,r.maxProperties)}function zd(e,t,r,n,o,i){return Ru(e,t,o,i)||t.AddError("maxProperties",r,n,{limit:o.maxProperties})}function E0(e){return Gr(e)}function Pu(e,t,r,n){if(!E0(r))return!0;let o=s.Counted(n,(i,a)=>Q(e,t,r.contains,i)&&t.AddIndex(a));return s.IsGreaterEqualThan(o,r.minContains)}function Wd(e,t,r,n,o,i){return Pu(e,t,o,i)||t.AddError("contains",r,n,{minContains:o.minContains})}function Au(e,t,r,n){return s.IsGreaterEqualThan(n,r.minimum)}function Vd(e,t,r,n,o,i){return Au(e,t,o,i)||t.AddError("minimum",r,n,{comparison:">=",limit:o.minimum})}function Ou(e,t,r,n){return s.IsGreaterEqualThan(n.length,r.minItems)}function Jd(e,t,r,n,o,i){return Ou(e,t,o,i)||t.AddError("minItems",r,n,{limit:o.minItems})}function Mu(e,t,r,n){return s.IsMinLength(n,r.minLength)}function Yd(e,t,r,n,o,i){return Mu(e,t,o,i)||t.AddError("minLength",r,n,{limit:o.minLength})}function vu(e,t,r,n){return s.IsGreaterEqualThan(s.Keys(n).length,r.minProperties)}function Qd(e,t,r,n,o,i){return vu(e,t,o,i)||t.AddError("minProperties",r,n,{limit:o.minProperties})}function Fu(e,t,r,n){return s.IsMultipleOf(n,r.multipleOf)}function Xd(e,t,r,n,o,i){return Fu(e,t,o,i)||t.AddError("multipleOf",r,n,{multipleOf:o.multipleOf})}function Lu(e,t,r,n){let o=new ct;return!Q(e,o,r.not,n)&&t.Merge([o])}function Zd(e,t,r,n,o,i){return Lu(e,t,o,i)||t.AddError("not",r,n,{})}function el(e,t,r,n){let o=r.oneOf.reduce((i,a)=>{let m=new ct;return Q(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,1)&&t.Merge(o)}function tl(e,t,r,n,o,i){let a=[],m=[],c=o.oneOf.reduce((f,d,g)=>{let y=new et,I=`${r}/oneOf/${g}`,h=ce(e,y,I,n,d,i);return h&&m.push(g),h||a.push(y),h?[...f,y]:f},[]),p=s.IsEqual(c.length,1)&&t.Merge(c);return!p&&s.IsEqual(m.length,0)&&a.forEach(f=>t.AddErrors(f.GetErrors())),p||t.AddError("oneOf",r,n,{passingSchemas:m})}function ju(e,t,r,n){return(s.IsString(r.pattern)?zr(r.pattern):r.pattern).test(n)}function rl(e,t,r,n,o,i){return ju(e,t,o,i)||t.AddError("pattern",r,n,{pattern:o.pattern})}function nl(e,t,r,n){return s.Every(s.Entries(r.patternProperties),0,([o,i])=>{let a=zr(o);return s.Every(s.Entries(n),0,([m,c])=>!a.test(m)||Ot(e,t,i,c)&&t.AddKey(m))})}function ol(e,t,r,n,o,i){return s.EveryAll(s.Entries(o.patternProperties),0,([a,m])=>{let c=`${r}/patternProperties/${$t(a)}`,p=zr(a);return s.EveryAll(s.Entries(i),0,([f,d])=>{let g=`${n}/${$t(f)}`;return!p.test(f)||Mt(e,t,c,g,m,d)&&t.AddKey(f)})})}function il(e,t,r,n){return s.IsEqual(n.length,0)||s.Every(r.prefixItems,0,(o,i)=>s.IsLessEqualThan(n.length,i)||Ot(e,t,o,n[i])&&t.AddIndex(i))}function sl(e,t,r,n,o,i){return s.IsEqual(i.length,0)||s.EveryAll(o.prefixItems,0,(a,m)=>{let c=`${r}/prefixItems/${m}`,p=`${n}/${m}`;return s.IsLessEqualThan(i.length,m)||Mt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function Du(e,t){return e.includes(t)||Me.Get().exactOptionalPropertyTypes}function Nu(e,t){return s.IsUndefined(e[t])}function al(e,t,r,n){let o=In(r)?r.required:[];return s.Every(s.Entries(r.properties),0,([a,m])=>{let c=!s.HasPropertyKey(n,a)||Ot(e,t,m,n[a])&&t.AddKey(a);return Du(o,a)?c:Nu(n,a)||c})}function ml(e,t,r,n,o,i){let a=In(o)?o.required:[];return s.EveryAll(s.Entries(o.properties),0,([c,p])=>{let f=`${r}/properties/${$t(c)}`,d=`${n}/${$t(c)}`,g=()=>!s.HasPropertyKey(i,c)||Mt(e,t,f,d,p,i[c])&&t.AddKey(c);return Du(a,c)?g():Nu(i,c)||g()})}function ul(e,t,r,n){return s.Every(s.Keys(n),0,(o,i)=>Q(e,t,r.propertyNames,o))}function cl(e,t,r,n,o,i){let a=[];return s.EveryAll(s.Keys(i),0,(c,p)=>{let f=`${n}/${$t(c)}`,d=`${r}/propertyNames`,g=ce(e,t,d,f,o.propertyNames,c);return g||a.push(c),g})||t.AddError("propertyNames",r,n,{propertyNames:a})}function pl(e,t,r,n){let o=Bt.RecursiveRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return L(o)&&Q(i,t,o,n)}function fl(e,t,r,n,o,i){let a=Bt.RecursiveRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return L(a)&&ce(m,t,r,n,a,i)}function dl(e,t,r,n){let o=Bt.Ref(e,r),i=o.schema??!1,a=new ct,m=L(i)&&Q(o.stack,a,i,n);return m&&t.Merge([a]),m}function ll(e,t,r,n,o,i){let a=Bt.Ref(e,o),m=a.schema??!1,c=new et,p=L(m)&&ce(a.stack,c,r,n,m,i);return p&&t.Merge([c]),p||t.AddErrors(c.GetErrors()),p}function gl(e,t,r,n){return s.Every(r.required,0,o=>s.HasPropertyKey(n,o))}function yl(e,t,r,n,o,i){let a=[];return s.EveryAll(o.required,0,c=>{let p=s.HasPropertyKey(i,c);return p||a.push(c),p})||t.AddError("required",r,n,{requiredProperties:a})}function qu(e,t,r,n,o){return s.IsEqual(r,"object")?s.IsObjectNotArray(o):s.IsEqual(r,"array")?s.IsArray(o):s.IsEqual(r,"boolean")?s.IsBoolean(o):s.IsEqual(r,"integer")?s.IsInteger(o):s.IsEqual(r,"number")?s.IsNumber(o):s.IsEqual(r,"null")?s.IsNull(o):s.IsEqual(r,"string")?s.IsString(o):s.IsEqual(r,"bigint")?s.IsBigInt(o):s.IsEqual(r,"constructor")?s.IsConstructor(o):s.IsEqual(r,"function")?s.IsFunction(o):s.IsEqual(r,"symbol")?s.IsSymbol(o):s.IsEqual(r,"undefined")?s.IsUndefined(o):s.IsEqual(r,"void")?s.IsUndefined(o):!0}function xl(e,t,r,n,o){return s.Some(r,i=>qu(e,t,i,n,o))}function hl(e,t,r,n){return s.IsArray(r.type)?xl(e,t,r.type,r,n):qu(e,t,r.type,r,n)}function Il(e,t,r,n,o,i){return(s.IsArray(o.type)?xl(e,t,o.type,o,i):qu(e,t,o.type,o,i))||t.AddError("type",r,n,{type:o.type})}function bl(e,t,r,n){let o=t.GetIndices();return s.Every(n,0,(i,a)=>(o.has(a)||Q(e,t,r.unevaluatedItems,i))&&t.AddIndex(a))}function $l(e,t,r,n,o,i){let a=t.GetIndices(),m=[];return s.EveryAll(i,0,(p,f)=>{let d=new et,g=(a.has(f)||ce(e,d,r,n,o.unevaluatedItems,p))&&t.AddIndex(f);return g||m.push(f),g})||t.AddError("unevaluatedItems",r,n,{unevaluatedItems:m})}function El(e,t,r,n){let o=t.GetKeys();return s.Every(s.Entries(n),0,([i,a])=>o.has(i)||Q(e,t,r.unevaluatedProperties,a)&&t.AddKey(i))}function Sl(e,t,r,n,o,i){let a=t.GetKeys(),m=[];return s.EveryAll(s.Entries(i),0,([p,f])=>{let d=new et,g=a.has(p)||ce(e,d,r,n,o.unevaluatedProperties,f)&&t.AddKey(p);return g||m.push(p),g})||t.AddError("unevaluatedProperties",r,n,{unevaluatedProperties:m})}var Pr={};At(Pr,{Hash:()=>Pl,HashCode:()=>D0});function $e(){throw new Error("Unreachable")}function S0(e){let t=new Set,r=e;for(;r&&r!==Object.prototype;){for(let n of Reflect.ownKeys(r))n!=="constructor"&&typeof n!="symbol"&&t.add(n);r=Object.getPrototypeOf(r)}return[...t]}function k0(e){return typeof e=="number"}var St={Array:0,BigInt:1,Boolean:2,Date:3,Constructor:4,Function:5,Null:6,Number:7,Object:8,RegExp:9,String:10,Symbol:11,TypeArray:12,Undefined:13},Bs=8997,Zo=33826,Gs=40164,Ks=52210,wl=new Float64Array(1),Cl=new DataView(wl.buffer),Rl=new Uint8Array(wl.buffer);function Ge(e){let t=Bs^e,r=t*435,n=Zo*435+(r>>>16),o=Gs*435+(n>>>16)+(t<<8),i=Ks*435+(o>>>16)+(Zo<<8);Bs=r&65535,Zo=n&65535,Gs=o&65535,Ks=i&65535}function T0(e){Ge(St.Array);for(let t of e)Wr(t)}function w0(e){Ge(St.BigInt),Cl.setBigInt64(0,e);for(let t of Rl)Ge(t)}function kl(e){Ge(St.Boolean),Ge(e?1:0)}function C0(e){Ge(St.Constructor),Wr(e.toString())}function R0(e){Ge(St.Date),Wr(e.getTime())}function P0(e){Ge(St.Function),Wr(e.toString())}function A0(e){Ge(St.Null)}function Tl(e){Ge(St.Number),Cl.setFloat64(0,e,!0);for(let t of Rl)Ge(t)}function O0(e){Ge(St.Object);for(let t of S0(e).sort())Wr(t),Wr(e[t])}function M0(e){Ge(St.RegExp),Uu(e.toString())}var v0=new TextEncoder;function Uu(e){Ge(St.String);for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>127){for(let n of v0.encode(e.slice(t)))Ge(n);return}Ge(r)}}function F0(e){Ge(St.Symbol),Wr(e.toString())}function L0(e){Ge(St.TypeArray);let t=new Uint8Array(e.buffer);for(let r=0;r<t.length;r++)Ge(t[r])}function j0(e){return Ge(St.Undefined)}function Wr(e){return De.IsTypeArray(e)?L0(e):De.IsDate(e)?R0(e):De.IsRegExp(e)?M0(e):De.IsBoolean(e)?kl(e.valueOf()):De.IsString(e)?Uu(e.valueOf()):De.IsNumber(e)?Tl(e.valueOf()):k0(e)?Tl(e):s.IsArray(e)?T0(e):s.IsBoolean(e)?kl(e):s.IsBigInt(e)?w0(e):s.IsConstructor(e)?C0(e):s.IsNull(e)?A0(e):s.IsObject(e)?O0(e):s.IsString(e)?Uu(e):s.IsSymbol(e)?F0(e):s.IsUndefined(e)?j0(e):s.IsFunction(e)?P0(e):$e()}function _s(e){return e.toString(16).padStart(4,"0")}function D0(e){return BigInt(`0x${Pl(e)}`)}function Pl(e){return Bs=8997,Zo=33826,Gs=40164,Ks=52210,Wr(e),`${_s(Ks)}${_s(Gs)}${_s(Zo)}${_s(Bs)}`}function Al(e){return!s.IsEqual(e.uniqueItems,!1)}function Ol(e,t,r,n){if(!Al(r))return!0;let o=new Set(n.map(Pr.Hash)).size,i=n.length;return s.IsEqual(o,i)}function Ml(e,t,r,n,o,i){if(!Al(o))return!0;let a=new Set,m=i.reduce((p,f,d)=>{let g=Pr.Hash(f);return a.has(g)?[...p,d]:(a.add(g),p)},[]);return s.IsEqual(m.length,0)||t.AddError("uniqueItems",r,n,{duplicateItems:m})}function Ot(e,t,r,n){return t.Push()&&Q(e,t,r,n)&&t.Pop()}function Q(e,t,r,n){let o=Kn(e,r);return ln(r)?iu(o,t,r,n):(!tu(r)||hl(o,t,r,n))&&(!(s.IsObject(n)&&!s.IsArray(n))||(!In(r)||gl(o,t,r,n))&&(!_t(r)||Lf(o,t,r,n))&&(!zm(r)||Kf(o,t,r,n))&&(!Wm(r)||zf(o,t,r,n))&&(!rs(r)||Vf(o,t,r,n))&&(!Un(r)||nl(o,t,r,n))&&(!_n(r)||al(o,t,r,n))&&(!us(r)||ul(o,t,r,n))&&(!Uo(r)||vu(o,t,r,n))&&(!Zm(r)||Ru(o,t,r,n)))&&(!s.IsArray(n)||(!Zi(r)||Mf(o,t,r,n))&&(!Gr(r)||au(o,t,r,n))&&(!gn(r)||Ud(o,t,r,n))&&(!yn(r)||Pu(o,t,r,n))&&(!Qm(r)||ku(o,t,r,n))&&(!xn(r)||Ou(o,t,r,n))&&(!No(r)||wu(o,t,r,n))&&(!hn(r)||il(o,t,r,n))&&(!Hr(r)||Ol(o,t,r,n)))&&(!s.IsString(n)||(!qo(r)||Mu(o,t,r,n))&&(!Xm(r)||Cu(o,t,r,n))&&(!Do(r)||Su(o,t,r,n))&&(!_o(r)||ju(o,t,r,n)))&&(!(s.IsNumber(n)||s.IsBigInt(n))||(!wr(r)||xu(o,t,r,n))&&(!Jm(r)||yu(o,t,r,n))&&(!Cr(r)||Au(o,t,r,n))&&(!Ym(r)||Tu(o,t,r,n))&&(!eu(r)||Fu(o,t,r,n)))&&(!ps(r)||dl(o,t,r,n))&&(!cs(r)||pl(o,t,r,n))&&(!ns(r)||od(o,t,r,n))&&(!Hm(r)||su(o,t,r,n))&&(!Vm(r)||gu(o,t,r,n))&&(!is(r)||Nd(o,t,r,n))&&(!as(r)||Lu(o,t,r,n))&&(!es(r)||Df(o,t,r,n))&&(!ts(r)||qf(o,t,r,n))&&(!ms(r)||el(o,t,r,n))&&(!Go(r)||!s.IsArray(n)||bl(o,t,r,n))&&(!Ko(r)||!s.IsObject(n)||El(o,t,r,n))&&(!Xi(r)||Tf(o,t,r,n))}function Mt(e,t,r,n,o,i){return t.Push()&&ce(e,t,r,n,o,i)&&t.Pop()}function ce(e,t,r,n,o,i){if(t.AtCapacity())return!1;let a=Kn(e,o);return ln(o)?_f(a,t,r,n,o,i):!!(+(!tu(o)||Il(a,t,r,n,o,i))&+(!(s.IsObject(i)&&!s.IsArray(i))||!!(+(!In(o)||yl(a,t,r,n,o,i))&+(!_t(o)||jf(a,t,r,n,o,i))&+(!zm(o)||Hf(a,t,r,n,o,i))&+(!Wm(o)||Wf(a,t,r,n,o,i))&+(!rs(o)||Jf(a,t,r,n,o,i))&+(!Un(o)||ol(a,t,r,n,o,i))&+(!_n(o)||ml(a,t,r,n,o,i))&+(!us(o)||cl(a,t,r,n,o,i))&+(!Uo(o)||Qd(a,t,r,n,o,i))&+(!Zm(o)||zd(a,t,r,n,o,i))))&+(!s.IsArray(i)||!!(+(!Zi(o)||vf(a,t,r,n,o,i))&+(!Gr(o)||Gf(a,t,r,n,o,i))&+(!gn(o)||_d(a,t,r,n,o,i))&+(!yn(o)||Wd(a,t,r,n,o,i))&+(!Qm(o)||Bd(a,t,r,n,o,i))&+(!xn(o)||Jd(a,t,r,n,o,i))&+(!No(o)||Kd(a,t,r,n,o,i))&+(!hn(o)||sl(a,t,r,n,o,i))&+(!Hr(o)||Ml(a,t,r,n,o,i))))&+(!s.IsString(i)||!!(+(!qo(o)||Yd(a,t,r,n,o,i))&+(!Xm(o)||Hd(a,t,r,n,o,i))&+(!Do(o)||Dd(a,t,r,n,o,i))&+(!_o(o)||rl(a,t,r,n,o,i))))&+(!(s.IsNumber(i)||s.IsBigInt(i))||!!(+(!wr(o)||md(a,t,r,n,o,i))&+(!Jm(o)||ad(a,t,r,n,o,i))&+(!Cr(o)||Vd(a,t,r,n,o,i))&+(!Ym(o)||Gd(a,t,r,n,o,i))&+(!eu(o)||Xd(a,t,r,n,o,i))))&+(!ps(o)||ll(a,t,r,n,o,i))&+(!cs(o)||fl(a,t,r,n,o,i))&+(!ns(o)||id(a,t,r,n,o,i))&+(!Hm(o)||Bf(a,t,r,n,o,i))&+(!Vm(o)||sd(a,t,r,n,o,i))&+(!is(o)||qd(a,t,r,n,o,i))&+(!as(o)||Zd(a,t,r,n,o,i))&+(!es(o)||Nf(a,t,r,n,o,i))&+(!ts(o)||Uf(a,t,r,n,o,i))&+(!ms(o)||tl(a,t,r,n,o,i))&+(!Go(o)||!s.IsArray(i)||$l(a,t,r,n,o,i))&+(!Ko(o)||!s.IsObject(i)||Sl(a,t,r,n,o,i)))&&(!Xi(o)||wf(a,t,r,n,o,i))}function Fl(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"}}var N0=Fl;function Ll(){return N0}var l={};At(l,{Assign:()=>U0,Clone:()=>_0,Create:()=>G0,Discard:()=>K0,Metrics:()=>Qt,Update:()=>V0});var Qt={assign:0,create:0,clone:0,discard:0,update:0};function vt(e){return[...s.Keys(e),...s.Symbols(e)]}function jl(e,t){if(!t.has(e)){t.add(e);for(let r of vt(e)){let n=Object.getOwnPropertyDescriptor(e,r);!n||!("value"in n)||s.IsObject(n.value)&&jl(n.value,t)}Object.freeze(e)}}function Vr(e){return Me.Get().immutableTypes&&jl(e,new WeakSet),e}function U0(e,t){Qt.assign+=1;let r={},n=vt(t),o=vt(e);for(let i of o)n.includes(i)||Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i));for(let i of n)Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i));return Vr(r)}function _0(e){Qt.clone+=1;let t={};for(let r of vt(e)){if(s.IsUnsafePropertyKey(r))continue;let n=Object.getOwnPropertyDescriptor(e,r);s.IsEqual(n.enumerable,!0)?t[r]=n.value:Object.defineProperty(t,r,n)}return t}function Dl(e,t){return{...e,...t}}function B0(e,t){for(let r of Object.keys(t))Object.defineProperty(e,r,{configurable:!0,writable:!0,enumerable:!1,value:t[r]});return e}function G0(e,t,r={}){Qt.create+=1;let n=Dl(t,r),o=Me.Get().enumerableKind?Dl(n,e):B0(n,e);return Vr(o)}function K0(e,t){Qt.discard+=1;let r={};for(let n of vt(e)){if(t.includes(n))continue;let o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o)}return Vr(r)}function H0(e,t,r,n){for(let o of vt(e)){if(s.IsUnsafePropertyKey(o)||t.includes(o)||r.includes(o))continue;let i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,i)}}function z0(e,t,r){let n=Me.Get().enumerableKind;for(let o of t)s.IsUnsafePropertyKey(o)||Object.defineProperty(r,o,{configurable:!0,writable:!0,enumerable:n,value:e[o]})}function W0(e,t,r){for(let n of t)s.IsUnsafePropertyKey(n)||Object.defineProperty(r,n,{configurable:!0,enumerable:!0,writable:!0,value:e[n]})}function V0(e,t,r){Qt.update+=1;let n={},o=vt(t),i=vt(r);return H0(e,o,i,n),z0(t,o,n),W0(r,i,n),Vr(n)}function Hs(...e){let[t,r,n]=B.Match(e,{3:(f,d,g)=>[f,d,g],2:(f,d)=>[{},f,d]}),o=Gn(t,r),i=new et,a=ce(o,i,"#","",r,n),m=i.GetErrors(),c=Ll(),p=m.map(f=>({...f,message:c(f)}));return[a,p]}var ql=0;function zs(){let e=Qi();ql=e.maxErrors,e.maxErrors=e.maxParseErrors}function Ws(){let e=Qi();e.maxErrors=ql}function Bu(...e){let[t,r,n]=B.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),o=Gn(t,r),i=new ct;return Q(o,i,r,n)}function K(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return Bu(t,r,n)}function Xt(...e){let[t,r,n]=B.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),[o,i]=Hs(t,r,n);return i}var Ar=class extends Error{constructor(t,r,n){super(t),Object.defineProperty(this,"cause",{value:{source:t,errors:n,value:r},writable:!1,configurable:!1,enumerable:!1})}};function Vs(...e){let[t,r,n]=B.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]});if(!K(t,r,n))throw new Ar("Assert",n,Xt(t,r,n))}function w(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function ye(e){return s.IsObject(e)}function R(e,t,r){return l.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:r},{})}function Jr(e){return w(e,"Deferred")}function ur(e,t){return l.Update(e,{"~readonly":!0},t)}function Ul(e,t,r,n){let o=$(e,t,r);return ur(o,n)}function cr(e,t){return l.Update(e,{"~optional":!0},t)}function _l(e,t,r,n){let o=$(e,t,r);return cr(o,n)}function yt(e,t){return l.Create({"~kind":"Array"},{type:"array",items:e},t)}function W(e){return w(e,"Array")}function Jn(e){return l.Discard(e,["~kind","type","items"])}function pr(e,t,r={}){return l.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},r)}function Ee(e){return w(e,"Constructor")}function Bl(e){return l.Discard(e,["~kind","type","parameters","instanceType"])}function fr(e,t,r={}){return l.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},r)}function Se(e){return w(e,"Function")}function Gl(e){return l.Discard(e,["~kind","type","parameters","returnType"])}function Be(e,t){return l.Create({"~kind":"Ref"},{$ref:e},t)}function te(e){return w(e,"Ref")}function Yr(e,t){return l.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function Yn(e){return w(e,"Generic")}function Qn(e){return l.Create({"~kind":"Any"},{},e)}function Ie(e){return w(e,"Any")}var Kl="(?!)";function ie(e){return l.Create({"~kind":"Never"},{not:{}},e)}function xt(e){return w(e,"Never")}function dr(e,t={}){return R("AddOptional",[e],t)}function Js(e,t={}){return cr(e,t)}function Hl(e){return Js(e)}function ve(e){return ye(e)&&s.HasPropertyKey(e,"~optional")}function zl(e){return s.Keys(e).filter(t=>!ve(e[t]))}function Ys(e){return s.Keys(e)}function Qs(e){return s.Values(e)}function M(e,t={}){let r=zl(e),n=r.length>0?{required:r}:{};return l.Create({"~kind":"Object"},{type:"object",...n,properties:e},t)}function A(e){return w(e,"Object")}function Wl(e){return l.Discard(e,["~kind","type","properties","required"])}function Ne(e){return l.Create({"~kind":"Unknown"},{},e)}function Fe(e){return w(e,"Unknown")}function lr(e,t,r){let n=s.Keys(e).reduce((o,i)=>({...o,[i]:l.Update(e[i],{},{$id:i})}),{});return l.Create({"~kind":"Cyclic"},{$defs:n,$ref:t},r)}function me(e){return w(e,"Cyclic")}function Vl(e){return l.Update(e,{"~unsafe":null},{})}function Xs(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}function ei(...e){let[t,r]=B.Match(e,{2:(n,o)=>[n,o,o],1:n=>[n,Ne(),Ne()]});return l.Create({"~kind":"Infer"},{type:"infer",name:t,extends:r},{})}function Le(e){return w(e,"Infer")}function $n(e,t,r,n={}){return l.Create({"~kind":"Dependent"},{if:e,then:t,else:r},n)}function ke(e){return w(e,"Dependent")}function Jl(e){return l.Discard(e,["~kind","if","then","else"])}function Yl(e){return s.IsObjectNotArray(e)}function Ql(e){return s.Keys(e).filter(r=>isNaN(r)).reduce((r,n)=>[...r,e[n]],[])}function Xl(e){return s.IsString(e)||s.IsNumber(e)}function Zl(e,t){let r=Yl(e)?Ql(e):e;return l.Create({"~kind":"Enum"},{enum:r},t)}function Te(e){return w(e,"Enum")}function ot(e,t={}){return l.Create({"~kind":"Intersect"},{allOf:e},t)}function O(e){return w(e,"Intersect")}function eg(e){return l.Discard(e,["~kind","allOf"])}var ti=class{constructor(t,r){this.type=t,this.decode=r}Encode(t){let r=this.type,n=pt(r)?a=>this.decode(r["~codec"].decode(a)):this.decode,o=pt(r)?a=>r["~codec"].encode(t(a)):t,i={decode:n,encode:o};return l.Update(this.type,{"~codec":i},{})}},ri=class{constructor(t){this.type=t}Decode(t){return new ti(this.type,t)}};function Zs(e){return new ri(e)}function tg(e,t){return Zs(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function rg(e,t){return Zs(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function pt(e){return ye(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function ng(e){return Xn(e)}function En(e){return ye(e)&&s.HasPropertyKey(e,"~immutable")}function gr(e,t={}){return R("AddReadonly",[e],t)}function ea(e,t={}){return ur(e,t)}function og(e){return ea(e)}function Or(e){return ye(e)&&s.HasPropertyKey(e,"~readonly")}function Q0(e,t){let r=ni(e)?[...e["~refine"],t]:[t];return l.Update(e,{"~refine":r},{})}function ig(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[o,i,()=>"Refine Error"]});return Q0(t,{check:r,error:n})}function X0(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"check")&&s.HasPropertyKey(e,"error")&&s.IsFunction(e.check)&&s.IsFunction(e.error)}function ni(e){return ye(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>X0(t))}var sg="-?(?:0|[1-9][0-9]*)n";function oi(e){return l.Create({"~kind":"BigInt"},{type:"bigint"},e)}function kt(e){return w(e,"BigInt")}function ta(e){return l.Create({"~kind":"Boolean"},{type:"boolean"},e)}function ft(e){return w(e,"Boolean")}function ii(e){return l.Create({"~kind":"Identifier"},{name:e})}function ag(e){return w(e,"Identifier")}var ra="-?(?:0|[1-9][0-9]*)";function Sn(e){return l.Create({"~kind":"Integer"},{type:"integer"},e)}function Ke(e){return w(e,"Integer")}var Gu=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function Z0(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new Gu(e)})()}function G(e,t){return l.Create({"~kind":"Literal"},{type:Z0(e),const:e},t)}function na(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function mg(e){return H(e)&&s.IsBigInt(e.const)}function ug(e){return H(e)&&s.IsBoolean(e.const)}function oa(e){return H(e)&&s.IsNumber(e.const)}function ia(e){return H(e)&&s.IsString(e.const)}function H(e){return w(e,"Literal")}function Zn(e){return l.Create({"~kind":"Null"},{type:"null"},e)}function yr(e){return w(e,"Null")}var sa="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function Tt(e){return l.Create({"~kind":"Number"},{type:"number"},e)}function xe(e){return w(e,"Number")}function eo(e){return l.Create({"~kind":"Symbol"},{type:"symbol"},e)}function xr(e){return w(e,"Symbol")}function kn(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[o,i,i],1:o=>[o,Ne(),Ne()]});return l.Create({"~kind":"Parameter"},{name:t,extends:r,equals:n},{})}function cg(e){return w(e,"Parameter")}var aa=".*";function tt(e){return l.Create({"~kind":"String"},{type:"string"},e)}function qe(e){return w(e,"String")}function j(e,t={}){return l.Create({"~kind":"Union"},{anyOf:e},t)}function S(e){return w(e,"Union")}function pg(e){return l.Discard(e,["~kind","anyOf"])}function si(e){let t=fg(e);return s.IsEqual(t.length,2)?t[0]:[]}function eP(e){return!0}function dg(e){return s.ShiftLeft(e,(t,r)=>tP(t)?dg(r):!1,()=>!0)}function lg(e){return s.IsEqual(e.length,0)?!1:dg(e)}function tP(e){return S(e)?lg(e.anyOf):H(e)?eP(e.const):!1}function ma(e){return lg(e)}function ua(e){return l.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function gg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>gg(o,t,[...r,`${n}${t}`]),()=>r)}function rP(e,t){return s.IsEqual(e.length,0)?[`${t}`]:gg(e,t)}function yg(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>yg(e,o,[...r,...xg(e,n)]),()=>r)}function xg(e,t){return S(t)?yg(e,t.anyOf):H(t)?rP(e,t.const):$e()}function hg(e,t){return s.ShiftLeft(t,(r,n)=>hg(xg(e,r),n),()=>e)}function nP(e){return e.map(t=>G(t))}function oP(e){let t=hg([],e),r=nP(t);return j(r)}function iP(e){return s.IsEqual(e.length,0)?$e():s.IsEqual(e.length,1)&&H(e[0])?e[0]:oP(e)}function Ku(e){let t=si(e);return s.IsEqual(t.length,0)?tt():ma(t)?iP(t):ua(e)}function to(e){let t=Ku(e);return ue(t)?tt():t}function ht(e,t){let r="object",n={[e]:t};return l.Create({"~kind":"Record"},{type:r,patternProperties:n})}function Ig(e){return ht(Zt,e)}function bg(e){return M({true:e,false:e})}function we(e,t={}){let[r,n,o]=[e,e.length,!1];return l.Create({"~kind":"Tuple"},{type:"array",additionalItems:o,items:r,minItems:n},t)}function q(e){return w(e,"Tuple")}function $g(e){return l.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Hu(e){return e.reduceRight((r,n,o)=>({[o]:n,...r}),{})}function Eg(e){let t=Hu(e.items);return M(t)}function sP(e){return l.Discard(e,["~optional"])}function Tn(e,t){return l.Update(sP(e),{},t)}function Sg(e,t,r,n){let o=$(e,t,r);return Tn(o,n)}function aP(e){return l.Discard(e,["~readonly"])}function ro(e,t){return l.Update(aP(e),{},t)}function kg(e,t,r,n){let o=$(e,t,r);return ro(o,n)}function ca(e,t){let r=Or(e)&&Or(t),n=ve(e)&&ve(t),o=Ce([e,t]),i=ro(Tn(o,{}),{});return r&&n?ur(cr(i,{}),{}):r?ur(i,{}):n?cr(i,{}):i}function Tg(e,t){let r=Or(e)||Or(t),n=ve(e)||ve(t),o=ro(Tn(e,{}),{}),i=ro(Tn(t,{}),{}),a=It([o,i]);return r&&n?ur(cr(a,{}),{}):r?ur(a,{}):n?cr(a,{}):a}function mP(e,t,r){return r in e?r in t?ca(e[r],t[r]):e[r]:r in t?t[r]:ie()}function uP(e,t){return[...new Set([...s.Keys(e),...s.Keys(t)])].reduce((o,i)=>({...o,[i]:mP(e,t,i)}),{})}function wg(e){return A(e)?e.properties:q(e)?Hu(e.items):{}}function Cg(e,t){let r=wg(e),n=wg(t),o=uP(r,n);return M(o)}function cP(e,t){let r=no(e,t);return s.IsEqual(r,mi)?e:s.IsEqual(r,ui)||s.IsEqual(r,ai)?t:ie()}function Rg(e){return A(e)||q(e)}function pP(e,t){let r=Rg(e),n=Rg(t);return r&&n?Cg(e,t):r&&!n?e:!r&&n?t:cP(e,t)}function Pg(e,t){return xt(e)||Ie(e)?e:Fe(e)||xt(t)||Ie(t)?t:Fe(t)?e:pP(e,t)}function fP(e,t){return S(e)||S(t)}function dP(e,t){let r=Gt(e),n=Gt(t);return fP(r,n)?Ce([r,n]):Pg(r,n)}function Ag(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>Ag(e,o,[...r,dP(n,e)]),()=>s.IsEqual(r.length,0)?[e]:r)}function Og(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>Og(o,t,[...r,...ci([n],t)]),()=>r)}function ci(e,t=[]){return s.ShiftLeft(e,(r,n)=>S(r)?ci(n,Og(r.anyOf,t)):ci(n,Ag(r,t)),()=>t)}function lP(e,t){let r=rt({},e,t);return F.IsExtendsTrueLike(r)?[]:[e]}function Mg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>Mg(o,t,[...r,...lP(n,t)]),()=>r)}function pa(e,t){let r=Gt(e),n=S(r)?r.anyOf:[r],o=Mg(n,t);return It(o)}function er(e,t,r){let n=Ce([e,t]),o=pa(r,e);return It([n,o])}function dt(e,t=[]){return s.ShiftLeft(e,(r,n)=>dt(n,[...t,G(r)]),()=>It(t))}function Ce(e){let t=ci(e),r=zu(t);return It(r)}function it(e){let t=to(e);return Gt(t)}function It(e){let t=zu(e);return Qr(t)}function Gt(e){return ke(e)?er(e.if,e.then,e.else):Te(e)?dt(e.enum):O(e)?Ce(e.allOf):ue(e)?it(e.pattern):S(e)?It(e.anyOf):e}function Qr(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?ie():j(e)}function vg(e,t){let r=dt(e);return Xr(r,t)}function Fg(e,t){return ht(Zr,t)}function Lg(e,t){let r=Ce(e);return Xr(r,t)}function jg(e,t){return s.IsString(e)||s.IsNumber(e)?M({[e]:t}):s.IsEqual(e,!1)?M({false:t}):s.IsEqual(e,!0)?M({true:t}):M({})}function Dg(e,t){return ht(oo,t)}function Ng(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?ht(e.pattern.toString(),t):ht(Zt,t)}function qg(e,t){let r=si(e);return ma(r)?Xr(it(e),t):ht(e,t)}function gP(e){return S(e)?en(e.anyOf):[e]}function en(e,t=[]){return s.ShiftLeft(e,(r,n)=>en(n,[...t,...gP(r)]),()=>t)}function yP(e){return e.some(t=>qe(t)||xe(t)||Ke(t))}function xP(e,t){return s.IsEqual(yP(e),!0)?ht(Zt,t):void 0}function hP(e,t){return e.reduce((r,n)=>H(n)&&(s.IsString(n.const)||s.IsNumber(n.const))?{...r,[n.const]:t}:r,{})}function IP(e,t){let r=hP(e,t);return M(r)}function Ug(e,t){let r=en(e),n=xP(r,t);return ye(n)?n:IP(r,t)}function Xr(e,t){return Ie(e)?Ig(t):ft(e)?bg(t):Te(e)?vg(e.enum,t):Ke(e)?Fg(e,t):O(e)?Lg(e.allOf,t):H(e)?jg(e.const,t):xe(e)?Dg(e,t):S(e)?Ug(e.anyOf,t):qe(e)?Ng(e,t):ue(e)?qg(e.pattern,t):M({})}function Wu(e,t,r){return U([e])?l.Update(Xr(e,t),{},r):fa(e,t,r)}function _g(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return Wu(i,a,o)}var Zr=`^${ra}$`,oo=`^${sa}$`,Zt=`^${aa}$`;function fa(e,t,r={}){return R("Record",[e,t],r)}function io(e,t,r={}){return Wu(e,t,r)}function Bg(e,t){return ht(e,t)}function da(e){return s.IsEqual(e,Zt)?tt():s.IsEqual(e,Zr)?Sn():s.IsEqual(e,oo)?Tt():Ku(e)}function je(e){return s.Keys(e.patternProperties)[0]}function so(e){let t=je(e);return da(t)}function pe(e){return e.patternProperties[je(e)]}function ne(e){return w(e,"Record")}function wn(e){return l.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function tn(e){return w(e,"Rest")}function la(e){return l.Create({"~kind":"This"},{$ref:"#"},e)}function ga(e){return w(e,"This")}function ao(e){return l.Create({"~kind":"Undefined"},{type:"undefined"},e)}function Kt(e){return w(e,"Undefined")}function ya(e){return l.Create({"~kind":"Void"},{type:"void"},e)}function wt(e){return w(e,"Void")}function $P(e,t){return s.IsEqual(e,"Array")?yt(t[0]):s.IsEqual(e,"Capitalize")?ha(t[0]):s.IsEqual(e,"ConstructorParameters")?Sa(t[0]):s.IsEqual(e,"Evaluate")?Hx(t[0]):s.IsEqual(e,"Exclude")?ka(t[0],t[1]):s.IsEqual(e,"Extract")?Ta(t[0],t[1]):s.IsEqual(e,"Index")?li(t[0],t[1]):s.IsEqual(e,"InstanceType")?wa(t[0]):s.IsEqual(e,"Lowercase")?Ia(t[0]):s.IsEqual(e,"NonNullable")?Ca(t[0]):s.IsEqual(e,"Omit")?Ra(t[0],t[1]):s.IsEqual(e,"Parameters")?Pa(t[0]):s.IsEqual(e,"Partial")?Aa(t[0]):s.IsEqual(e,"Pick")?Oa(t[0],t[1]):s.IsEqual(e,"Readonly")?Ma(t[0]):s.IsEqual(e,"KeyOf")?gi(t[0]):s.IsEqual(e,"Record")?fa(t[0],t[1]):s.IsEqual(e,"Required")?va(t[0]):s.IsEqual(e,"ReturnType")?Fa(t[0]):s.IsEqual(e,"Uncapitalize")?ba(t[0]):s.IsEqual(e,"Uppercase")?$a(t[0]):di(Be(e),t)}function Cn(){throw Error("Unreachable")}function Wg(e,t=[]){return s.ShiftLeft(e,(r,n)=>Wg(n,[...t,r[1]]),()=>t)}function Mr(e){return s.IsEqual(e.length,3)?[e[0],...Wg(e[1])]:[]}function Vg(e){return kn(e[0],e[2],e[4])}function Jg(e){return kn(e[0],e[2],e[2])}function Yg(e){return kn(e[0],Ne(),e[2])}function Qg(e){return kn(e,Ne(),Ne())}function Xg(e){return Mr(e)}function Zg(e){return e[1]}function ey(e){return Mr(e)}function ty(e){return e[1]}function ry(e){return $P(e[0],e[1])}function ny(e){return null}function oy(e){return tt()}function iy(e){return Tt()}function sy(e){return ta()}function ay(e){return ao()}function my(e){return Zn()}function uy(e){return Sn()}function cy(e){return oi()}function py(e){return Ne()}function fy(e){return Qn()}function dy(e){return M({})}function ly(e){return ie()}function gy(e){return eo()}function yy(e){return ya()}function xy(e){return la()}function hy(e){return G(BigInt(e))}function Iy(e){return G(s.IsEqual(e,"true"))}function by(e){return G(parseFloat(e))}function $y(e){return G(e)}function Ey(e){return e[1]}function Sy(e){return G(e)}function ky(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function Ty(e){return e[1]}function wy(e){return xa(e)}function Cy(e){return s.IsEqual(e.length,6)?$n(e[1],e[3],e[5]):$n(e[1],e[3],Ne())}function Ry(e){return e.length>0}function Py(e){return e.reduce((t,r)=>s.IsEqual(r.length,3)?[...t,[r[1]]]:[...t,[]],[])}function Ay(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function Oy(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function My(e){return s.IsEqual(e.length,2)?e[1]:[]}function Gg(e,t){return t.reduce((r,n)=>{let o=n;return s.IsEqual(o.length,1)?li(r,o[0]):s.IsEqual(o.length,0)?yt(r):Cn()},e)}function Kg(e,t){return s.IsEqual(t.length,3)?Ea(e,t[0],t[1],t[2]):e}function EP(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:La(e,t)}function vy(e){let[t,r,n,o,i]=e;return EP(Kg(t?gi(Gg(r,n)):Gg(r,n),o),i)}function Vu(e,t){return s.IsEqual(t.length,3)?(()=>{let[r,n,o]=t,i=Vu(n,o);if(s.IsEqual(r,"&"))return O(i)?ot([e,...i.allOf]):ot([e,i]);if(s.IsEqual(r,"|"))return S(i)?j([e,...i.anyOf]):j([e,i]);Cn()})():e}function Fy(e){let[t,r]=e;return Vu(t,r)}function Ly(e){let[t,r]=e;return Vu(t,r)}function jy(e){return Gx(e[1])}function Dy(e){return e[1]}function Ny(e){return Yr(e[0],e[2])}function qy(e){return s.IsEqual(e.length,4)?ei(e[1],e[3]):s.IsEqual(e.length,2)?ei(e[1],Ne()):Cn()}function Uy(e){return`${e}`}function _y(e){return Ke(e[3])?Zr:xe(e[3])?oo:xr(e[3])?Zt:qe(e[3])?Zt:Cn()}function By(e){return e.length>0}function Gy(e){return e.length>0}function Ky(e){let[t,r,n,o,i]=e;return{[r]:t&&n?gr(dr(i)):t&&!n?gr(i):!t&&n?dr(i):i}}function Hy(e){return Mr(e)}function zy(e){return e.reduce((t,r)=>s.HasPropertyKey(r,Zr)||s.HasPropertyKey(r,oo)||s.HasPropertyKey(r,Zt)?[t[0],l.Assign(t[1],r)]:[l.Assign(t[0],r),t[1]],[{},{}])}function Wy(e){return zy(e[1])}function Vy(e){let[t,r]=e,n=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return M(t,n)}function Jy(e){return s.IsEqual(e.length,5)?gr(dr(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?gr(e[3]):dr(e[3]):Cn()}function Yy(e){if(!s.IsArray(e)||!s.IsEqual(e.length,3))return e;let[t,r,n]=e;return t&&n?gr(dr(r)):t&&!n?gr(r):!t&&n?dr(r):r}function Qy(e){return s.IsEqual(e.length,2)?wn(e[1]):s.IsEqual(e.length,1)?e[0]:Cn()}function Xy(e){return Mr(e)}function Zy(e){return we(e[1])}function ex(e){return gr(dr(e[4]))}function tx(e){return gr(e[3])}function rx(e){return dr(e[3])}function nx(e){return e[2]}function ox(e){return s.IsEqual(e.length,2)?wn(e[1]):s.IsEqual(e.length,1)?e[0]:Cn()}function ix(e){return Mr(e)}function sx(e){return fr(e[1],e[4])}function ax(e){return pr(e[2],e[5])}function Hg(e,t){return s.IsEqual(e,"remove")?Kx(t):s.IsEqual(e,"add")?gr(t):t}function mx(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function zg(e,t){return s.IsEqual(e,"remove")?Bx(t):s.IsEqual(e,"add")?dr(t):t}function ux(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function cx(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function px(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?pi(ii(e[3]),e[5],e[6][0],Hg(e[1],zg(e[8],e[10]))):pi(ii(e[3]),e[5],Be(e[3]),Hg(e[1],zg(e[8],e[10])))}function fx(e){return Be(e)}function dx(e){return BigInt(e)}function lx(e){return parseFloat(e)}function gx(e){return s.IsEqual(e,"true")}function yx(e){return null}function xx(e){return{[e[0]]:e[2]}}function hx(e){return Mr(e)}function SP(e){return e.reduce((t,r)=>l.Assign(t,r),{})}function Ix(e){return SP(e[1])}function bx(e){return Mr(e)}function $x(e){return e[1]}function Ex(e){return oi()}function Sx(e){return tt()}function kx(e){return Tt()}function Tx(e){return Sn()}function wx(e){return ie()}function Cx(e){return G(e)}function Rx(e){return j(e[1])}function Px(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function Ax(e){return[e[0],...e[1]]}function Ox(e){return e[1]}function Mx(e){return Mr(e)}function vx(e){return s.IsEqual(e.length,2)?e[1]:[]}function Fx(e){let t=e[2],r=e[3],[n,o]=e[4],i=s.IsEqual(s.Keys(o).length,0)?{}:{patternProperties:o};return{[e[1]]:Yr(t,fi(r,n,i))}}function Lx(e){let t=e[2],[r,n]=e[3],o=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return{[e[1]]:fi(t,r,o)}}function jx(e){return{[e[1]]:Yr(e[2],e[4])}}function Dx(e){return{[e[1]]:e[3]}}function Nx(e){return null}function qx(e){return Mr(e)}function Ux(e){return e[1]}function _x(e){let[t,r]=[e[0],e[1]];return zx(l.Assign(t,zy(r)[0]))}function yi(e){return Y(e.length,2)}function V(e,t,r){return yi(e)?t(e[0],e[1]):r()}function wP(e,t){return Y(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function be(e,t){for(let r=0;r<e.length;r++){let n=wP(e[r],t);if(yi(n))return n}return[]}function Ju(e,t){return Array.from({length:t-e+1},(r,n)=>String.fromCharCode(e+n))}var Wx=[...Ju(97,122),...Ju(65,90)],Yu="0",Qu=Ju(49,57),mo=[Yu,...Qu],Vx=" ",uo=`
|
|
2
|
-
`;var rn="_",ja=".",Jx="$",Da="-";var Yx="//",Qx="/*",RP="*/";function Xx(e){let t=e.indexOf(RP);return Y(t,-1)?"":e.slice(t+2)}function Zx(e){let t=e.indexOf(uo);return Y(t,-1)?"":e.slice(t)}function PP(e){return e.replace(/^[ \t\r\f\v]+/,"")}function Na(e){let t=PP(e);return t.startsWith(Qx)?Na(Xx(t.slice(2))):t.startsWith(Yx)?Na(Zx(t.slice(2))):t}function Qe(e){let t=e.trimStart();return t.startsWith(Qx)?Qe(Xx(t.slice(2))):t.startsWith(Yx)?Qe(Zx(t.slice(2))):t}function qa(e,t){return V(be([e],t),(r,n)=>[r,n],()=>["",t])}function AP(e,t){return e.includes(t)}function co(e,t,r,n=""){return V(be(e,r),(o,i)=>AP(t,o)?co(e,t,i,n):co(e,t,i,`${n}${o}`),()=>[n,r])}function OP(e){return be(Qu,e)}var MP=[...mo,rn];function vP(e){return co(MP,[rn],e)}function FP(e){return V(be([Yu],e),(t,r)=>[t,r],()=>V(OP(e),(t,r)=>V(vP(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[]))}function Ua(e){return FP(Qe(e))}function LP(e){return qa(Da,e)}function jP(e){return V(LP(e),(t,r)=>V(Ua(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function eh(e){return jP(Qe(e))}function DP(e){return V(eh(e),(t,r)=>V(be(["n"],r),(n,o)=>[`${t}`,o],()=>[]),()=>[])}function Xu(e){return DP(e)}function Zu(e,t){return be([e],t)}function x(e,t){return Y(e,"")?["",t]:e.startsWith(uo)?Zu(e,Na(t)):e.startsWith(Vx)?Zu(e,t):Zu(e,Qe(t))}var th=[...Wx,rn,Jx];function NP(e){return be(th,e)}var qP=[...th,...mo];function rh(e,t=""){return V(be(qP,e),(r,n)=>rh(n,`${t}${r}`),()=>[t,e])}function UP(e){return V(NP(e),(t,r)=>V(rh(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function Re(e){return UP(Qe(e))}var _P=[...mo,rn];function BP(e){return yi(be([ja],e))}function nh(e){return V(co(_P,[rn],e),(t,r)=>Y(t,"")?[]:[t,r],()=>[])}function GP(e){return V(be([ja],e),(t,r)=>V(nh(r),(n,o)=>[`0${t}${n}`,o],()=>[]),()=>[])}function KP(e){return V(Ua(e),(t,r)=>V(be([ja],r),(n,o)=>V(nh(o),(i,a)=>[`${t}${n}${i}`,a],()=>[`${t}`,o]),()=>[`${t}`,r]),()=>[])}function HP(e){return BP(e)?GP(e):KP(e)}function oh(e){return HP(Qe(e))}function zP(e){return qa(Da,e)}function WP(e){return V(zP(e),(t,r)=>V(oh(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function _a(e){return WP(Qe(e))}function VP(e){return Y(e,"")?[]:[e.slice(0,1),e.slice(1)]}function ih(e,t){return Yi(e,(r,n)=>t.startsWith(r)?!0:ih(n,t),()=>!1)}function nn(e,t,r=""){return V(VP(t),(n,o)=>ih(e,t)?[r,t]:nn(e,o,`${r}${n}`),()=>[])}function JP(e,t,r){return V(be([e],r),(n,o)=>V(nn([t],o),(i,a)=>V(be([t],a),(m,c)=>[`${i}`,c],()=>[]),()=>[]),()=>[])}function YP(e,t,r){return V(be([e],r),(n,o)=>V(nn([uo,t],o),(i,a)=>V(be([t],a),(m,c)=>[`${i}`,c],()=>[]),()=>[]),()=>[])}function sh(e,t,r,n){return r?JP(e,t,Qe(n)):YP(e,t,Qe(n))}function QP(e,t){return be(e,t)}function XP(e,t){return sh(e,e,!1,t)}function ZP(e,t){return V(QP(e,t),(r,n)=>XP(r,`${r}${n}`),()=>[])}function Ba(e,t){return ZP(e,Qe(t))}function ah(e,t){return V(nn(e,t),(r,n)=>Y(r,"")?[]:[r,n],()=>[])}var u=(e,t,r=()=>[])=>e.length===2?t(e):r(),tA=e=>u(u(Re(e),([t,r])=>u(x("extends",r),([n,o])=>u(X(o),([i,a])=>u(x("=",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Vg(t),r]),rA=e=>u(u(Re(e),([t,r])=>u(x("extends",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Jg(t),r]),nA=e=>u(u(Re(e),([t,r])=>u(x("=",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Yg(t),r]),oA=e=>u(Re(e),([t,r])=>[Qg(t),r]),ch=e=>u(u(tA(e),([t,r])=>[t,r],()=>u(rA(e),([t,r])=>[t,r],()=>u(nA(e),([t,r])=>[t,r],()=>u(oA(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),ph=(e,t=[])=>u(u(x(",",e),([r,n])=>u(ch(n),([o,i])=>[[r,o],i])),([r,n])=>ph(n,[...t,r]),()=>[t,e]),iA=e=>u(u(u(ch(e),([t,r])=>u(ph(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Xg(t),r]),rc=e=>u(u(x("<",e),([t,r])=>u(iA(r),([n,o])=>u(x(">",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Zg(t),r]),fh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(X(n),([o,i])=>[[r,o],i])),([r,n])=>fh(n,[...t,r]),()=>[t,e]),sA=e=>u(u(u(X(e),([t,r])=>u(fh(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ey(t),r]),aA=e=>u(u(x("<",e),([t,r])=>u(sA(r),([n,o])=>u(x(">",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[ty(t),r]),mA=e=>u(u(Re(e),([t,r])=>u(aA(r),([n,o])=>[[t,n],o])),([t,r])=>[ry(t),r]),dh=e=>u(u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ny(t),r]),lh=e=>u(x("string",e),([t,r])=>[oy(t),r]),gh=e=>u(x("number",e),([t,r])=>[iy(t),r]),uA=e=>u(x("boolean",e),([t,r])=>[sy(t),r]),cA=e=>u(x("undefined",e),([t,r])=>[ay(t),r]),pA=e=>u(x("null",e),([t,r])=>[my(t),r]),yh=e=>u(x("integer",e),([t,r])=>[uy(t),r]),fA=e=>u(x("bigint",e),([t,r])=>[cy(t),r]),dA=e=>u(x("unknown",e),([t,r])=>[py(t),r]),lA=e=>u(x("any",e),([t,r])=>[fy(t),r]),gA=e=>u(x("object",e),([t,r])=>[dy(t),r]),yA=e=>u(x("never",e),([t,r])=>[ly(t),r]),xh=e=>u(x("symbol",e),([t,r])=>[gy(t),r]),xA=e=>u(x("void",e),([t,r])=>[yy(t),r]),hA=e=>u(x("this",e),([t,r])=>[xy(t),r]),IA=e=>u(u(x("${",e),([t,r])=>u(X(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Ey(t),r]),ec=e=>u(nn(["${","`"],e),([t,r])=>[Sy(t),r]),hh=e=>u(u(u(ec(e),([t,r])=>u(IA(r),([n,o])=>u(hh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(u(ec(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(ec(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[ky(t),r]),nc=e=>u(u(x("`",e),([t,r])=>u(hh(r),([n,o])=>u(x("`",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Ty(t),r]),bA=e=>u(nc(e),([t,r])=>[wy(t),r]),$A=e=>u(u(u(x("if",e),([t,r])=>u(X(r),([n,o])=>u(x("then",o),([i,a])=>u(X(a),([m,c])=>u(x("else",c),([p,f])=>u(X(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[t,r],()=>u(u(x("if",e),([t,r])=>u(X(r),([n,o])=>u(x("then",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>[])),([t,r])=>[Cy(t),r]),EA=e=>u(Xu(e),([t,r])=>[hy(t),r]),SA=e=>u(u(x("true",e),([t,r])=>[t,r],()=>u(x("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[Iy(t),r]),kA=e=>u(_a(e),([t,r])=>[by(t),r]),TA=e=>u(Ba(["'",'"'],e),([t,r])=>[$y(t),r]),wA=e=>u(u(u(x("keyof",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ry(t),r]),Ih=(e,t=[])=>u(u(u(x("[",e),([r,n])=>u(X(n),([o,i])=>u(x("]",i),([a,m])=>[[r,o,a],m]))),([r,n])=>[r,n],()=>u(u(x("[",e),([r,n])=>u(x("]",n),([o,i])=>[[r,o],i])),([r,n])=>[r,n],()=>[])),([r,n])=>Ih(n,[...t,r]),()=>[t,e]),CA=e=>u(Ih(e),([t,r])=>[Py(t),r]),RA=e=>u(u(u(x("extends",e),([t,r])=>u(X(r),([n,o])=>u(x("?",o),([i,a])=>u(X(a),([m,c])=>u(x(":",c),([p,f])=>u(X(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ay(t),r]),PA=e=>u(u(u(x("(",e),([t,r])=>u(X(r),([n,o])=>u(x(")",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(lh(e),([t,r])=>[t,r],()=>u(gh(e),([t,r])=>[t,r],()=>u(uA(e),([t,r])=>[t,r],()=>u(cA(e),([t,r])=>[t,r],()=>u(pA(e),([t,r])=>[t,r],()=>u(yh(e),([t,r])=>[t,r],()=>u(fA(e),([t,r])=>[t,r],()=>u(dA(e),([t,r])=>[t,r],()=>u(lA(e),([t,r])=>[t,r],()=>u(gA(e),([t,r])=>[t,r],()=>u(yA(e),([t,r])=>[t,r],()=>u(xh(e),([t,r])=>[t,r],()=>u(xA(e),([t,r])=>[t,r],()=>u(hA(e),([t,r])=>[t,r],()=>u(EA(e),([t,r])=>[t,r],()=>u(SA(e),([t,r])=>[t,r],()=>u(kA(e),([t,r])=>[t,r],()=>u(TA(e),([t,r])=>[t,r],()=>u(bA(e),([t,r])=>[t,r],()=>u($A(e),([t,r])=>[t,r],()=>u(UA(e),([t,r])=>[t,r],()=>u(GA(e),([t,r])=>[t,r],()=>u(JA(e),([t,r])=>[t,r],()=>u(VA(e),([t,r])=>[t,r],()=>u(ZA(e),([t,r])=>[t,r],()=>u(mA(e),([t,r])=>[t,r],()=>u(eO(e),([t,r])=>[t,r],()=>[])))))))))))))))))))))))))))),([t,r])=>[Oy(t),r]),AA=e=>u(u(u(x("with",e),([t,r])=>u(jh(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[My(t),r]),bh=e=>u(u(wA(e),([t,r])=>u(PA(r),([n,o])=>u(CA(o),([i,a])=>u(RA(a),([m,c])=>u(AA(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[vy(t),r]),$h=e=>u(u(u(x("&",e),([t,r])=>u(bh(r),([n,o])=>u($h(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),Eh=e=>u(u(bh(e),([t,r])=>u($h(r),([n,o])=>[[t,n],o])),([t,r])=>[Fy(t),r]),Sh=e=>u(u(u(x("|",e),([t,r])=>u(Eh(r),([n,o])=>u(Sh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),Ga=e=>u(u(Eh(e),([t,r])=>u(Sh(r),([n,o])=>[[t,n],o])),([t,r])=>[Ly(t),r]),OA=e=>u(u(x("readonly",e),([t,r])=>u(Ga(r),([n,o])=>[[t,n],o])),([t,r])=>[jy(t),r]),MA=e=>u(u(x("|",e),([t,r])=>u(Ga(r),([n,o])=>[[t,n],o])),([t,r])=>[Dy(t),r]),vA=e=>u(u(rc(e),([t,r])=>u(x("=",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Ny(t),r]),FA=e=>u(u(u(x("infer",e),([t,r])=>u(Re(r),([n,o])=>u(x("extends",o),([i,a])=>u(Ga(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(x("infer",e),([t,r])=>u(Re(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>[])),([t,r])=>[qy(t),r]),X=e=>u(u(FA(e),([t,r])=>[t,r],()=>u(MA(e),([t,r])=>[t,r],()=>u(OA(e),([t,r])=>[t,r],()=>u(Ga(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),LA=e=>u(_a(e),([t,r])=>[Uy(t),r]),jA=e=>u(Re(e),([t,r])=>[t,r]),DA=e=>u(Ba(["'",'"'],e),([t,r])=>[t,r]),NA=e=>u(u(x("[",e),([t,r])=>u(Re(r),([n,o])=>u(x(":",o),([i,a])=>u(u(yh(a),([m,c])=>[m,c],()=>u(gh(a),([m,c])=>[m,c],()=>u(lh(a),([m,c])=>[m,c],()=>u(xh(a),([m,c])=>[m,c],()=>[])))),([m,c])=>u(x("]",c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[_y(t),r]),kh=e=>u(u(LA(e),([t,r])=>[t,r],()=>u(jA(e),([t,r])=>[t,r],()=>u(DA(e),([t,r])=>[t,r],()=>u(NA(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),Th=e=>u(u(u(x("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[By(t),r]),wh=e=>u(u(u(x("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Gy(t),r]),Ch=e=>u(u(Th(e),([t,r])=>u(kh(r),([n,o])=>u(wh(o),([i,a])=>u(x(":",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Ky(t),r]),Ka=e=>u(u(u(x(",",e),([t,r])=>u(x(`
|
|
3
|
-
`,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>u(x(`
|
|
4
|
-
`,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(",",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(x(`
|
|
5
|
-
`,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))))),([t,r])=>[t,r]),Rh=(e,t=[])=>u(u(Ka(e),([r,n])=>u(Ch(n),([o,i])=>[[r,o],i])),([r,n])=>Rh(n,[...t,r]),()=>[t,e]),qA=e=>u(u(u(Ch(e),([t,r])=>u(Rh(r),([n,o])=>u(u(Ka(o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Hy(t),r]),oc=e=>u(u(x("{",e),([t,r])=>u(qA(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Wy(t),r]),UA=e=>u(oc(e),([t,r])=>[Vy(t),r]),_A=e=>u(u(u(Re(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(x("readonly",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[t,r],()=>u(u(Re(e),([t,r])=>u(x(":",r),([n,o])=>u(x("readonly",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(Re(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(Re(e),([t,r])=>u(x(":",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>[])))),([t,r])=>[Jy(t),r]),mh=e=>u(u(_A(e),([t,r])=>[t,r],()=>u(u(Th(e),([t,r])=>u(X(r),([n,o])=>u(wh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>[])),([t,r])=>[Yy(t),r]),Ph=e=>u(u(u(x("...",e),([t,r])=>u(mh(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(mh(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[Qy(t),r]),Ah=(e,t=[])=>u(u(x(",",e),([r,n])=>u(Ph(n),([o,i])=>[[r,o],i])),([r,n])=>Ah(n,[...t,r]),()=>[t,e]),BA=e=>u(u(u(Ph(e),([t,r])=>u(Ah(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Xy(t),r]),GA=e=>u(u(x("[",e),([t,r])=>u(BA(r),([n,o])=>u(x("]",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Zy(t),r]),KA=e=>u(u(Re(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(x("readonly",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[ex(t),r]),HA=e=>u(u(Re(e),([t,r])=>u(x(":",r),([n,o])=>u(x("readonly",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[tx(t),r]),zA=e=>u(u(Re(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[rx(t),r]),WA=e=>u(u(Re(e),([t,r])=>u(x(":",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[nx(t),r]),uh=e=>u(u(KA(e),([t,r])=>[t,r],()=>u(HA(e),([t,r])=>[t,r],()=>u(zA(e),([t,r])=>[t,r],()=>u(WA(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),Oh=e=>u(u(u(x("...",e),([t,r])=>u(uh(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(uh(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[ox(t),r]),Mh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(Oh(n),([o,i])=>[[r,o],i])),([r,n])=>Mh(n,[...t,r]),()=>[t,e]),vh=e=>u(u(u(Oh(e),([t,r])=>u(Mh(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ix(t),r]),VA=e=>u(u(x("(",e),([t,r])=>u(vh(r),([n,o])=>u(x(")",o),([i,a])=>u(x("=>",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[sx(t),r]),JA=e=>u(u(x("new",e),([t,r])=>u(x("(",r),([n,o])=>u(vh(o),([i,a])=>u(x(")",a),([m,c])=>u(x("=>",c),([p,f])=>u(X(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[ax(t),r]),YA=e=>u(u(u(x("+",e),([t,r])=>u(x("readonly",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("-",e),([t,r])=>u(x("readonly",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[mx(t),r]),QA=e=>u(u(u(x("+",e),([t,r])=>u(x("?",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("-",e),([t,r])=>u(x("?",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[ux(t),r]),XA=e=>u(u(u(x("as",e),([t,r])=>u(X(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[cx(t),r]),ZA=e=>u(u(x("{",e),([t,r])=>u(YA(r),([n,o])=>u(x("[",o),([i,a])=>u(Re(a),([m,c])=>u(x("in",c),([p,f])=>u(X(f),([d,g])=>u(XA(g),([y,I])=>u(x("]",I),([h,E])=>u(QA(E),([b,C])=>u(x(":",C),([k,z])=>u(X(z),([oe,ee])=>u(dh(ee),([_,qt])=>u(x("}",qt),([lt,ir])=>[[t,n,i,m,p,d,y,h,b,k,oe,_,lt],ir]))))))))))))),([t,r])=>[px(t),r]),eO=e=>u(Re(e),([t,r])=>[fx(t),r]),tO=e=>u(Xu(e),([t,r])=>[dx(t),r]),rO=e=>u(_a(e),([t,r])=>[lx(t),r]),nO=e=>u(u(x("true",e),([t,r])=>[t,r],()=>u(x("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[gx(t),r]),oO=e=>u(Ba(['"',"'"],e),([t,r])=>[t,r]),iO=e=>u(x("null",e),([t,r])=>[yx(t),r]),sO=e=>u(x("undefined",e),([t,r])=>[void 0,r]),Fh=e=>u(u(kh(e),([t,r])=>u(x(":",r),([n,o])=>u(ic(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[xx(t),r]),Lh=(e,t=[])=>u(u(Ka(e),([r,n])=>u(Fh(n),([o,i])=>[[r,o],i])),([r,n])=>Lh(n,[...t,r]),()=>[t,e]),aO=e=>u(u(u(Fh(e),([t,r])=>u(Lh(r),([n,o])=>u(u(Ka(o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[hx(t),r]),jh=e=>u(u(x("{",e),([t,r])=>u(aO(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Ix(t),r]),Dh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(ic(n),([o,i])=>[[r,o],i])),([r,n])=>Dh(n,[...t,r]),()=>[t,e]),mO=e=>u(u(u(ic(e),([t,r])=>u(Dh(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[bx(t),r]),uO=e=>u(u(x("[",e),([t,r])=>u(mO(r),([n,o])=>u(x("]",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[$x(t),r]),ic=e=>u(u(tO(e),([t,r])=>[t,r],()=>u(rO(e),([t,r])=>[t,r],()=>u(nO(e),([t,r])=>[t,r],()=>u(oO(e),([t,r])=>[t,r],()=>u(iO(e),([t,r])=>[t,r],()=>u(sO(e),([t,r])=>[t,r],()=>u(jh(e),([t,r])=>[t,r],()=>u(uO(e),([t,r])=>[t,r],()=>[])))))))),([t,r])=>[t,r]),cO=e=>u(x("-?(?:0|[1-9][0-9]*)n",e),([t,r])=>[Ex(t),r]),pO=e=>u(x(".*",e),([t,r])=>[Sx(t),r]),fO=e=>u(x("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([t,r])=>[kx(t),r]),dO=e=>u(x("-?(?:0|[1-9][0-9]*)",e),([t,r])=>[Tx(t),r]),lO=e=>u(x("(?!)",e),([t,r])=>[wx(t),r]),gO=e=>u(ah(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,r])=>[Cx(t),r]),yO=e=>u(u(cO(e),([t,r])=>[t,r],()=>u(pO(e),([t,r])=>[t,r],()=>u(fO(e),([t,r])=>[t,r],()=>u(dO(e),([t,r])=>[t,r],()=>u(lO(e),([t,r])=>[t,r],()=>u(xO(e),([t,r])=>[t,r],()=>u(gO(e),([t,r])=>[t,r],()=>[]))))))),([t,r])=>[t,r]),xO=e=>u(u(x("(",e),([t,r])=>u(sc(r),([n,o])=>u(x(")",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Rx(t),r]),Nh=e=>u(u(u(tc(e),([t,r])=>u(x("|",r),([n,o])=>u(Nh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(u(tc(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[]))),([t,r])=>[Px(t),r]),tc=e=>u(u(yO(e),([t,r])=>u(sc(r),([n,o])=>[[t,n],o])),([t,r])=>[Ax(t),r]),sc=e=>u(u(Nh(e),([t,r])=>[t,r],()=>u(tc(e),([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),fg=e=>u(u(x("^",e),([t,r])=>u(sc(r),([n,o])=>u(x("$",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Ox(t),r]),qh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(X(n),([o,i])=>[[r,o],i])),([r,n])=>qh(n,[...t,r]),()=>[t,e]),hO=e=>u(u(u(X(e),([t,r])=>u(qh(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Mx(t),r]),Uh=e=>u(u(u(x("extends",e),([t,r])=>u(hO(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[vx(t),r]),IO=e=>u(u(x("interface",e),([t,r])=>u(Re(r),([n,o])=>u(rc(o),([i,a])=>u(Uh(a),([m,c])=>u(oc(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Fx(t),r]),bO=e=>u(u(x("interface",e),([t,r])=>u(Re(r),([n,o])=>u(Uh(o),([i,a])=>u(oc(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[Lx(t),r]),$O=e=>u(u(x("type",e),([t,r])=>u(Re(r),([n,o])=>u(rc(o),([i,a])=>u(x("=",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[jx(t),r]),EO=e=>u(u(x("type",e),([t,r])=>u(Re(r),([n,o])=>u(x("=",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[Dx(t),r]),SO=e=>u(u(u(x("export",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Nx(t),r]),_h=e=>u(u(u(x(";",e),([t,r])=>u(x(`
|
|
6
|
-
`,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(x(`
|
|
7
|
-
`,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]),Bh=(e,t=[])=>u(u(_h(e),([r,n])=>u(ac(n),([o,i])=>[[r,o],i])),([r,n])=>Bh(n,[...t,r]),()=>[t,e]),kO=e=>u(u(u(ac(e),([t,r])=>u(Bh(r),([n,o])=>u(u(_h(o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[qx(t),r]),ac=e=>u(u(SO(e),([t,r])=>u(u(IO(r),([n,o])=>[n,o],()=>u(bO(r),([n,o])=>[n,o],()=>u($O(r),([n,o])=>[n,o],()=>u(EO(r),([n,o])=>[n,o],()=>[])))),([n,o])=>u(dh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Ux(t),r]),TO=e=>u(u(ac(e),([t,r])=>u(kO(r),([n,o])=>[[t,n],o])),([t,r])=>[_x(t),r]),Gh=e=>u(u(TO(e),([t,r])=>[t,r],()=>u(vA(e),([t,r])=>[t,r],()=>u(X(e),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]);function Kh(e){let t=nc(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:$e()}function CO(e){return e.join("|")}function RO(e){return e.slice(1,e.length-1)}function PO(e,t,r){return on(t,`${r}${e}`)}function AO(e,t){return on(e,`${t}${sg}`)}function OO(e,t){return on(e,`${t}${ra}`)}function MO(e,t){return on(e,`${t}${sa}`)}function vO(e,t){return xi(j([G("false"),G("true")]),e,t)}function FO(e,t){return on(e,`${t}${aa}`)}function LO(e,t,r){return on(t,`${r}${RO(e)}`)}function jO(e,t,r){let n=hi(e,{});return xi(n,t,r)}function DO(e,t,r){let n=dt(e);return xi(n,t,r)}function Hh(e,t,r,n=[]){return s.ShiftLeft(e,(o,i)=>Hh(i,t,r,[...n,xi(o,[],"")]),()=>on(t,`${r}(${CO(n)})`))}function xi(e,t,r){return Te(e)?DO(e.enum,t,r):Ke(e)?OO(t,r):H(e)?PO(e.const,t,r):kt(e)?AO(t,r):ft(e)?vO(t,r):xe(e)?MO(t,r):qe(e)?FO(t,r):ue(e)?LO(e.pattern,t,r):Wh(e)?jO(e.parameters[0],t,r):S(e)?Hh(e.anyOf,t,r):Kl}function on(e,t){return s.ShiftLeft(e,(r,n)=>xi(r,n,t),()=>t)}function NO(e){return`^${on(e,"")}$`}function zh(e){let t=NO(e);return ua(t)}function hi(e,t){return U(e)?l.Update(zh(e),{},t):xa(e,t)}function Vh(e,t,r,n){let o=Ft(e,t,r);return hi(o,n)}function xa(e,t={}){return R("TemplateLiteral",[e],t)}function Wh(e){return ye(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"TemplateLiteral")}function Jh(e){return hi(e,{})}function qO(e){let t=Kh(e);return Jh(t)}function Yh(e,t={}){let r=s.IsString(e)?qO(e):Jh(e);return l.Update(r,{},t)}function ue(e){return w(e,"TemplateLiteral")}var F={};At(F,{ExtendsFalse:()=>N,ExtendsTrue:()=>T,ExtendsUnion:()=>mc,IsExtendsFalse:()=>UO,IsExtendsTrue:()=>Xh,IsExtendsTrueLike:()=>hr,IsExtendsUnion:()=>Qh,Match:()=>Pe});function mc(e){return l.Create({"~kind":"ExtendsUnion"},{inferred:e})}function Qh(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsUnion")&&s.IsObject(e.inferred)}function T(e){return l.Create({"~kind":"ExtendsTrue"},{inferred:e})}function Xh(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function N(){return l.Create({"~kind":"ExtendsFalse"},{})}function UO(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function hr(e){return Qh(e)||Xh(e)}function Pe(e,t,r){return hr(e)?t(e.inferred):r()}function _O(e,t,r,n){return Pe(J(e,r,n),o=>T(l.Assign(l.Assign(e,o),{[t]:r})),()=>N())}function BO(e,t){return T(e)}function GO(e,t,r,n,o){return Pe(J(e,t,r),i=>Pe(J(i,t,n),a=>T(a),()=>N()),()=>Pe(J(e,t,o),i=>T(i),()=>N()))}function KO(e,t,r){let n=dt(r);return J(e,t,n)}function Zh(e,t,r){return s.ShiftLeft(r,(n,o)=>Pe(J(e,t,n),i=>Zh(i,t,o),()=>N()),()=>T(e))}function HO(e,t,r){let n=it(r);return J(e,t,n)}function eI(e,t,r){return s.ShiftLeft(r,(n,o)=>Pe(J(e,t,n),i=>T(i),()=>eI(e,t,o)),()=>N())}function re(e,t,r){return Ie(r)?BO(e,t):ke(r)?GO(e,t,r.if,r.then,r.else):Te(r)?KO(e,t,r.enum):Le(r)?_O(e,r.name,t,r.extends):O(r)?Zh(e,t,r.allOf):ue(r)?HO(e,t,r.pattern):S(r)?eI(e,t,r.anyOf):Fe(r)?T(e):N()}function tI(e,t,r){return Le(r)?re(e,t,r):Ie(r)?T(e):Fe(r)?T(e):mc(e)}function zO(e,t){let r=En(e),n=En(t);return r&&n||!r&&n?!0:!(r&&!n)}function rI(e,t,r,n){return W(n)?zO(t,n)?J(e,r,n.items):N():re(e,t,n)}function nI(e,t,r){return kt(r)?T(e):re(e,t,r)}function oI(e,t,r){return ft(r)?T(e):re(e,t,r)}function WO(e,t,r,n,o){let i=Le(n)?t:n,a=Le(n)?n:t,m=ve(t),c=ve(n);return!m&&c?N():Pe(J(e,i,a),p=>Ii(p,r,o),()=>N())}function VO(e,t,r,n){return s.ShiftLeft(n,(o,i)=>WO(e,t,r,o,i),()=>ve(t)?T(e):N())}function JO(e,t,r){return s.ShiftLeft(t,(n,o)=>VO(e,n,o,r),()=>T(e))}function Ii(e,t,r){return JO(e,t,r)}function Ha(e,t,r){return wt(r)?T(e):J(e,t,r)}function iI(e,t,r,n){return Ie(n)?T(e):Fe(n)?T(e):Ee(n)?Pe(Ii(e,t,n.parameters),o=>Ha(o,r,n.instanceType),()=>N()):N()}function sI(e,t,r,n,o){return Pe(J(e,t,o),()=>J(e,r,o),()=>J(e,n,o))}function aI(e,t,r){let n=dt(t);return J(e,n,r)}function mI(e,t,r,n){return Ie(n)?T(e):Fe(n)?T(e):Se(n)?Pe(Ii(e,t,n.parameters),o=>Ha(o,r,n.returnType),()=>N()):N()}function uI(e,t,r){return Ke(r)?T(e):xe(r)?T(e):re(e,t,r)}function cI(e,t,r){let n=Ce(t);return J(e,n,r)}function za(e,t,r){return t===r?T(e):N()}function YO(e,t,r){return H(r)?za(e,t,r.const):kt(r)?T(e):re(e,G(t),r)}function QO(e,t,r){return H(r)?za(e,t,r.const):ft(r)?T(e):re(e,G(t),r)}function XO(e,t,r){return H(r)?za(e,t,r.const):xe(r)?T(e):re(e,G(t),r)}function ZO(e,t,r){return H(r)?za(e,t,r.const):qe(r)?T(e):re(e,G(t),r)}function pI(e,t,r){return s.IsBigInt(t.const)?YO(e,t.const,r):s.IsBoolean(t.const)?QO(e,t.const,r):s.IsNumber(t.const)?XO(e,t.const,r):s.IsString(t.const)?ZO(e,t.const,r):$e()}function fI(e,t,r){return Le(r)?re(e,t,r):T(e)}function dI(e,t,r){return yr(r)?T(e):re(e,t,r)}function lI(e,t,r){return xe(r)?T(e):re(e,t,r)}function eM(e,t,r){return ve(t)?ve(r)?T(e):N():T(e)}function tM(e,t,r){return Le(r)&&xt(r.extends)?N():Pe(J(e,t,r),n=>eM(n,t,r),()=>N())}function rM(e,t){return e.reduce((r,n)=>n in t?hr(t[n])?{...r,...t[n].inferred}:$e():$e(),{})}function nM(e,t,r){let n={};for(let a of s.Keys(r))n[a]=a in t?tM({},t[a],r[a]):ve(r[a])?Le(r[a])?T(l.Assign(e,{[r[a].name]:r[a].extends})):T(e):N();let o=s.Values(n).every(a=>hr(a)),i=o?rM(s.Keys(n),n):{};return o?T(i):N()}function oM(e,t,r){let n=nM(e,t,r);return hr(n)?T(l.Assign(e,n.inferred)):N()}function iM(e,t,r){return oM(e,t,r)}function sM(e,t){return s.Keys(t).reduce((r,n)=>({...r,[n]:s.HasPropertyKey(e,n)?S(r[n])?j([...r[n].anyOf,t[n]]):j([e[n],t[n]]):t[n]}),e)}function gI(e,t,r,n){return s.ShiftLeft(t,(o,i)=>Pe(J({},e[o],r),a=>gI(e,i,r,sM(n,a)),()=>N()),()=>T(n))}function aM(e,t,r,n){let o=s.Keys(t);return gI(t,o,n,e)}function yI(e,t,r){return ne(r)?aM(e,t,je(r),pe(r)):A(r)?iM(e,t,r.properties):re(e,M(t),r)}function mM(e,t){return s.IsEqual(s.Keys(t).length,0)?T(e):N()}function uM(e,t,r,n,o){return J(e,r,o)}function xI(e,t,r,n){return ne(n)?uM(e,da(t),r,da(je(n)),pe(n)):A(n)?mM(e,n.properties):Ie(n)?T(e):Fe(n)?T(e):N()}function hI(e,t,r){return qe(r)?T(e):re(e,t,r)}function II(e,t,r){return xr(r)?T(e):re(e,t,r)}function bI(e,t,r){let n=it(t);return J(e,n,r)}function uc(e,t){return l.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function bi(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"name")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"Inferrable")&&s.IsString(e.name)&&s.IsObject(e.type)}function cc(e){return tn(e)?Le(e.items)?W(e.items.extends)?uc(e.items.name,e.items.extends.items):Fe(e.items.extends)?uc(e.items.name,e.items.extends):void 0:$e():void 0}function Wa(e){return Le(e)?uc(e.name,e.extends):void 0}function $I(e,t){let r=[];for(let n of e){if(!hr(J({},n,t)))return;r.push(n)}return r}function EI(e,t,r,n){let o=$I(r,n);return s.IsArray(o)?T(l.Assign(e,{[t]:we(o)})):N()}function Va(e,t,r,n){let o=$I(r,n);return s.IsArray(o)?T(l.Assign(e,{[t]:j(o)})):N()}function cM(e){return[...e].reverse()}function pc(e,t){return t?cM(e):e}function pM(e){let t=e.length>0?e[0]:void 0,r=ye(t)?cc(t):void 0;return ye(r)}function fM(e,t,r,n,o,i){return Pe(J(e,r,o),a=>SI(a,t,n,i),()=>N())}function dM(e,t,r,n,o){let i=cc(n);return bi(i)?EI(e,i.name,pc(r,t),i.type):s.ShiftLeft(r,(a,m)=>fM(e,t,a,m,n,o),()=>N())}function lM(e,t,r,n){return s.ShiftLeft(n,(o,i)=>dM(e,t,r,o,i),()=>s.IsEqual(r.length,0)?T(e):N())}function SI(e,t,r,n){return lM(e,t,r,n)}function gM(e,t,r){let n=sn(e,de([],[]),r),o=pM(n);return SI(e,o,pc(t,o),pc(n,o))}function yM(e,t,r){for(let n of t){let o=J(e,n,r);if(!hr(o))return o;e=o.inferred}return T(e)}function xM(e,t,r){let n=Wa(r);return bi(n)?Va(e,n.name,t,n.type):yM(e,t,r)}function kI(e,t,r){let n=sn(e,de([],[]),t);return q(r)?gM(e,n,r.items):W(r)?xM(e,n,r.items):re(e,we(n),r)}function TI(e,t,r){return wt(r)?T(e):Kt(r)?T(e):re(e,t,r)}function wI(e,t,r){return s.ShiftLeft(r,(n,o)=>Pe(J(e,t,n),i=>T(i),()=>wI(e,t,o)),()=>N())}function fc(e,t,r){return s.ShiftLeft(t,(n,o)=>Pe(wI(e,n,r),i=>fc(i,o,r),()=>N()),()=>T(e))}function CI(e,t,r){let n=Wa(r);return bi(n)?Va(e,n.name,t,n.type):S(r)?fc(e,t,r.anyOf):fc(e,t,[r])}function RI(e,t,r){return Le(r)?re(e,t,r):Ie(r)?T(e):Fe(r)?T(e):N()}function PI(e,t,r){return wt(r)?T(e):re(e,t,r)}function J(e,t,r){return Ie(t)?tI(e,t,r):W(t)?rI(e,t,t.items,r):kt(t)?nI(e,t,r):ft(t)?oI(e,t,r):Ee(t)?iI(e,t.parameters,t.instanceType,r):ke(t)?sI(e,t.if,t.then,t.else,r):Te(t)?aI(e,t.enum,r):Se(t)?mI(e,t.parameters,t.returnType,r):Ke(t)?uI(e,t,r):O(t)?cI(e,t.allOf,r):H(t)?pI(e,t,r):xt(t)?fI(e,t,r):yr(t)?dI(e,t,r):xe(t)?lI(e,t,r):A(t)?yI(e,t.properties,r):ne(t)?xI(e,je(t),pe(t),r):qe(t)?hI(e,t,r):xr(t)?II(e,t,r):ue(t)?bI(e,t.pattern,r):q(t)?kI(e,t.items,r):Kt(t)?TI(e,t,r):S(t)?CI(e,t.anyOf,r):Fe(t)?RI(e,t,r):wt(t)?PI(e,t,r):N()}function hM(e,t){return Ce([...e,M(t)])}function dc(e,t,r){return U(e)?l.Update(hM(e,t),{},r):fi(e,t,r)}function AI(e,t,r,n,o){let i=Ft(e,t,r),a=$i(e,t,n);return dc(i,a,o)}function fi(e,t,r={}){return R("Interface",[e,t],r)}function po(e){return ye(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function OI(e,t,r={}){return dc(e,t,r)}function IM(e,t,r){return e.includes(r)?!0:Ei([...e,r],t,t[r])}function MI(e,t,r){let n=Qs(r);return Rn(e,t,n)}function Rn(e,t,r){return s.ShiftLeft(r,(n,o)=>Ei(e,t,n)?!0:Rn(e,t,o),()=>!1)}function Ei(e,t,r){return te(r)?IM(e,t,r.$ref):W(r)?Ei(e,t,r.items):Ee(r)?Rn(e,t,[...r.parameters,r.instanceType]):Se(r)?Rn(e,t,[...r.parameters,r.returnType]):po(r)?MI(e,t,r.parameters[1]):O(r)?Rn(e,t,r.allOf):A(r)?MI(e,t,r.properties):S(r)?Rn(e,t,r.anyOf):q(r)?Rn(e,t,r.items):ne(r)?Ei(e,t,pe(r)):!1}function vI(e,t,r){return Ei(e,t,r)}function bM(e,t){return t.reduce((r,n)=>vI([n],e,e[n])?[...r,n]:r,[])}function FI(e){let t=Ys(e);return bM(e,t)}function $M(e,t,r){return r.includes(t)?r:t in e?Si(e,e[t],[...r,t]):$e()}function LI(e,t,r){let n=Qs(t);return fo(e,n,r)}function fo(e,t,r){return t.reduce((n,o)=>Si(e,o,n),r)}function Si(e,t,r){return te(t)?$M(e,t.$ref,r):W(t)?Si(e,t.items,r):Ee(t)?fo(e,[...t.parameters,t.instanceType],r):Se(t)?fo(e,[...t.parameters,t.returnType],r):po(t)?LI(e,t.parameters[1],r):O(t)?fo(e,t.allOf,r):A(t)?LI(e,t.properties,r):S(t)?fo(e,t.anyOf,r):q(t)?fo(e,t.items,r):ne(t)?Si(e,pe(t),r):r}function jI(e,t,r){return Si(e,r,[t])}function EM(e){return Qn()}function SM(e){return s.Keys(e).reduce((t,r)=>({...t,[r]:Pn(e[r])}),{})}function ki(e){return e.reduce((t,r)=>[...t,Pn(r)],[])}function Pn(e){return te(e)?EM(e.$ref):W(e)?yt(Pn(e.items),Jn(e)):Ee(e)?pr(ki(e.parameters),Pn(e.instanceType)):Se(e)?fr(ki(e.parameters),Pn(e.returnType)):O(e)?ot(ki(e.allOf)):A(e)?M(SM(e.properties)):ne(e)?io(so(e),Pn(pe(e))):S(e)?j(ki(e.anyOf)):q(e)?we(ki(e.items)):e}function kM(e,t){return t in e?Pn(e[t]):Ne()}function DI(e){return kM(e.$defs,e.$ref)}function TM(e,t,r){let n=Ft(e,de([],[]),t),o=$i({},de([],[]),r);return Ce([...n,M(o)])}function wM(e,t){return s.Keys(e).filter(n=>t.includes(n)).reduce((n,o)=>{let i=e[o],a=po(i)?TM(e,i.parameters[0],i.parameters[1]):i;return{...n,[o]:a}},{})}function NI(e,t,r){let n=jI(e,t,r),o=wM(e,n);return lr(o,t)}function qI(e,t){return t in e?te(e[t])?qI(e,e[t].$ref):e[t]:ie()}function Ir(e,t){return qI(e,t)}function UI(e){return me(e)?DI(e):Xs(e)?Ne():e}function rt(e,t,r){let n=UI(t),o=UI(r);return J(e,n,o)}var ai=0,Ti=1,mi=2,ui=3;function no(e,t){let r=[rt({},e,t),rt({},t,e)];return F.IsExtendsTrueLike(r[0])&&F.IsExtendsTrueLike(r[1])?ai:F.IsExtendsTrueLike(r[0])&&F.IsExtendsFalse(r[1])?mi:F.IsExtendsFalse(r[0])&&F.IsExtendsTrueLike(r[1])?ui:Ti}function lc(e,t,r=[],n=t){return s.ShiftLeft(t,(o,i)=>{let a=no(e,o);return s.IsEqual(a,mi)||s.IsEqual(a,ai)?n:s.IsEqual(a,Ti)?lc(e,i,[...r,o],n):lc(e,i,r,n)},()=>[...r,e])}function CM(e,t,r){let n=Gt(e);return Ie(n)?[n]:Fe(n)?[n]:xt(n)?Ja(t,r):A(n)?Ja(t,[...r,n]):Ja(t,lc(n,r))}function Ja(e,t=[]){return s.ShiftLeft(e,(r,n)=>CM(r,n,t),()=>t)}function zu(e){let t=Ja(e);return en(t)}function gc(e,t){return l.Update(Gt(e),{},t)}function _I(e,t,r,n){let o=$(e,t,r);return gc(o,n)}function wi(e,t=[]){return Jr(e)&&s.IsEqual(e.action,"Conditional")?te(e.parameters[0])?wi(e.parameters[2],wi(e.parameters[3],[...t,e.parameters[0].$ref])):wi(e.parameters[2],wi(e.parameters[3],t)):Jr(e)&&s.IsEqual(e.action,"Mapped")&&Jr(e.parameters[1])&&s.IsEqual(e.parameters[1].action,"KeyOf")&&te(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function RM(e,t){return e.reduce((r,n)=>[...r,t.includes(n.name)],[])}function KI(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>s.ShiftLeft(t,(i,a)=>KI(o,a,[...r,[i,n]]),()=>r),()=>r)}function PM(e){return ue(e)?it(e.pattern):Te(e)?dt(e.enum):e}function AM(e){let t=PM(e);return S(t)?[...t.anyOf]:[t]}function OM(e,t){return e.reduce((r,n)=>[...r,[...n,t]],[])}function BI(e,t){return t.reduce((r,n)=>[...r,...OM(e,n)],[])}function GI(e){return e.reduce((t,r)=>s.IsEqual(r[0],!0)?BI(t,AM(r[1])):BI(t,[r[1]]),[[]])}function HI(e,t,r){let n=wi(r),o=RM(e,n),i=KI(t,o);return Jr(r)&&s.IsEqual(r.action,"Conditional")||Jr(r)&&s.IsEqual(r.action,"Mapped")?GI(i):[t]}function MM(){return["(not-resolvable)",ie()]}function vM(){return["(not-generic)",ie()]}function FM(e,t,r){return[e,Yr(t,r)]}function LM(e,t,r){return t in e?zI(e,t,e[t],r):MM()}function zI(e,t,r,n){return Yn(r)?FM(t,r.parameters,r.expression):te(r)?LM(e,r.$ref,n):vM()}function WI(e,t,r){return zI(e,"(anonymous)",t,r)}function jM(e,t,r){if(Le(t)||lo(t)||F.IsExtendsTrueLike(rt({},t,r)))return;let n={parameter:e,expect:r,actual:t};throw new Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:n})}function VI(e,t,r,n,o){let i=$(e,t,o);return jM(r,i,n),l.Assign(e,{[r]:i})}function DM(e,t,r,n,o){let i=$(e,t,r.extends),a=$(e,t,r.equals);return s.ShiftLeft(o,(m,c)=>yc(VI(e,t,r.name,i,m),t,n,c),()=>yc(VI(e,t,r.name,i,a),t,n,[]))}function yc(e,t,r,n){return s.ShiftLeft(r,(o,i)=>DM(e,t,o,i,n),()=>e)}function JI(e,t,r,n){return yc(e,t,r,n)}var xc=0,hc=0;function NM(){if(!s.IsLessThan(hc,Me.Get().maxInstantiationCount))throw Error("Type instantiation is excessively deep and possibly infinite")}function qM(){NM(),hc++,xc++}function UM(){xc--,s.IsEqual(xc,0)&&(hc=0)}function _M(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function BM(e,t){return s.IsEqual(_M(e),t)}function GM(e,t,r,n,o,i){qM();try{let a=JI(e,t,n,i),m=$(a,de([...t.callstack,r.$ref],t.visited),o);return $(a,de([],[]),m)}finally{UM()}}function KM(e,t,r,n,o,i){return i.reduce((a,m)=>{let c=GM(e,t,r,n,o,m);return[...a,c]},[])}function HM(e,t,r,n,o,i){let a=HI(n,i,o),m=KM(e,t,r,n,o,a);return s.IsEqual(m.length,1)?m[0]:It(m)}function Ya(e,t,r,n){let o=Ft(e,t,n),i=WI(e,r,n),a=i[0],m=i[1];return Yn(m)?BM(t,a)?di(Be(a),o):HM(e,t,Be(a),m.parameters,m.expression,o):di(r,o)}function di(e,t){return l.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function YI(e,t){return Ya({},de([],[]),e,t)}function lo(e){return w(e,"Call")}function zM(e){return l.Discard(e,["~immutable"])}function QI(e,t){return l.Update(zM(e),{},t)}function XI(e,t,r,n){let o=$(e,t,r);return QI(o,n)}function ZI(e,t){return e(t)}function eb(e,t){return s.IsString(t)?G(ZI(e,t)):G(t)}function tb(e,t){let r=it(t);return vr(e,r)}function rb(e,t){let r=t.map(n=>vr(e,n));return j(r)}function vr(e,t){return H(t)?eb(e,t.const):ue(t)?tb(e,t.pattern):S(t)?rb(e,t.anyOf):t}function ha(e,t={}){return R("Capitalize",[e],t)}function nb(e,t={}){return Ic(e,t)}function Ia(e,t={}){return R("Lowercase",[e],t)}function ob(e,t={}){return bc(e,t)}function ba(e,t={}){return R("Uncapitalize",[e],t)}function ib(e,t={}){return $c(e,t)}function $a(e,t={}){return R("Uppercase",[e],t)}function sb(e,t={}){return Ec(e,t)}var WM=e=>e[0].toUpperCase()+e.slice(1),VM=e=>e.toLowerCase(),JM=e=>e[0].toLowerCase()+e.slice(1),YM=e=>e.toUpperCase();function Ic(e,t){return U([e])?l.Update(vr(WM,e),{},t):ha(e,t)}function bc(e,t){return U([e])?l.Update(vr(VM,e),{},t):Ia(e,t)}function $c(e,t){return U([e])?l.Update(vr(JM,e),{},t):ba(e,t)}function Ec(e,t){return U([e])?l.Update(vr(YM,e),{},t):$a(e,t)}function ab(e,t,r,n){let o=$(e,t,r);return Ic(o,n)}function mb(e,t,r,n){let o=$(e,t,r);return bc(o,n)}function ub(e,t,r,n){let o=$(e,t,r);return $c(o,n)}function cb(e,t,r,n){let o=$(e,t,r);return Ec(o,n)}function Ea(e,t,r,n,o={}){return R("Conditional",[e,t,r,n],o)}function pb(e,t,r,n,o={}){return Sc({},de([],[]),e,t,r,n,o)}function QM(e,t,r,n,o,i){let a=rt(e,r,n);return F.IsExtendsUnion(a)?j([$(a.inferred,t,o),$(e,t,i)]):F.IsExtendsTrue(a)?$(a.inferred,t,o):$(e,t,i)}function Sc(e,t,r,n,o,i,a){return U([r,n])?l.Update(QM(e,t,r,n,o,i),{},a):Ea(r,n,o,i,a)}function fb(e,t,r,n,o,i,a){let m=$(e,t,r),c=$(e,t,n);return Sc(e,t,m,c,o,i,a)}function Sa(e,t={}){return R("ConstructorParameters",[e],t)}function db(e,t={}){return kc(e,t)}function XM(e){let t=Ee(e)?e.parameters:[],r=sn({},de([],[]),t);return we(r)}function kc(e,t){return U([e])?l.Update(XM(e),{},t):Sa(e,t)}function lb(e,t,r,n){let o=$(e,t,r);return kc(o,n)}function ka(e,t,r={}){return R("Exclude",[e,t],r)}function gb(e,t,r={}){return Ci(e,t,r)}function Ci(e,t,r){return U([e,t])?l.Update(pa(e,t),{},r):ka(e,t,r)}function yb(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return Ci(i,a,o)}function Ta(e,t,r={}){return R("Extract",[e,t],r)}function xb(e,t,r={}){return Tc(e,t,r)}function ZM(e,t){let r=rt({},e,t);return F.IsExtendsTrueLike(r)?[e]:[]}function hb(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>hb(o,t,[...r,...ZM(n,t)]),()=>r)}function Ib(e,t){let r=Gt(e),n=S(r)?r.anyOf:[r],o=hb(n,t);return It(o)}function Tc(e,t,r){return U([e,t])?l.Update(Ib(e,t),{},r):Ta(e,t,r)}function bb(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return Tc(i,a,o)}function ev(e){return e.reduce((t,r)=>na(r)?[...t,G(r)]:t,[])}function go(e){let t=ev(e);return j(t)}function li(e,t,r={}){return R("Index",[e,t],r)}function $b(e,t,r={}){let n=s.IsArray(t)?go(t):t;return wc(e,n,r)}function Eb(e,t){let r=Ir(e,t);return Lt(r)}function Sb(e,t,r){let n=er(e,t,r);return Lt(n)}function tv(e,t){let r=s.Keys(e).filter(f=>!s.HasPropertyKey(t,f)),n=s.Keys(t).filter(f=>!s.HasPropertyKey(e,f)),o=s.Keys(e).filter(f=>s.HasPropertyKey(t,f)),i=r.reduce((f,d)=>({...f,[d]:e[d]}),{}),a=n.reduce((f,d)=>({...f,[d]:t[d]}),{}),m=o.reduce((f,d)=>({...f,[d]:ca(e[d],t[d])}),{}),c=l.Assign(i,a);return l.Assign(c,m)}function kb(e){return e.reduce((t,r)=>tv(t,Lt(r)),{})}function Tb(e){let t=Eg(we(e));return Lt(t)}function rv(e,t){return s.Keys(e).filter(o=>o in t).reduce((o,i)=>({...o,[i]:Tg(e[i],t[i])}),{})}function wb(e,t){return s.ShiftLeft(e,(r,n)=>wb(n,rv(t,Lt(r))),()=>t)}function Cb(e){return s.ShiftLeft(e,(t,r)=>wb(r,Lt(t)),()=>$e())}function Lt(e){return me(e)?Eb(e.$defs,e.$ref):ke(e)?Sb(e.if,e.then,e.else):O(e)?kb(e.allOf):S(e)?Cb(e.anyOf):q(e)?Tb(e.items):A(e)?e.properties:{}}function yo(e){let t=Lt(e);return M(t)}var nv=new RegExp("^(?:0|[1-9][0-9]*)$");function xo(e){let t=`${e}`;return nv.test(t)?parseInt(t):e}function ov(e){return G(xo(e))}function Rb(e){return e.map(t=>Pb(t))}function Pb(e){return O(e)?ot(Rb(e.allOf)):S(e)?j(Rb(e.anyOf)):H(e)?ov(e.const):e}function Ab(e,t){let r=Pb(t),n=rt({},r,Tt());return F.IsExtendsTrueLike(n)?e:H(t)&&s.IsEqual(t.const,"length")?Tt():ie()}function Ob(e,t){let r=Ir(e,t);return Ct(r)}function Mb(e,t,r){let n=er(e,t,r);return Ct(n)}function vb(e){let t=dt(e);return Ct(t)}function Fb(e){let t=Ce(e);return Ct(t)}function Lb(e){return[`${e}`]}function jb(e){let t=it(e);return Ct(t)}function Db(e){return e.reduce((t,r)=>[...t,...Ct(r)],[])}function Ct(e){return me(e)?Ob(e.$defs,e.$ref):ke(e)?Mb(e.if,e.then,e.else):Te(e)?vb(e.enum):O(e)?Fb(e.allOf):H(e)?Lb(e.const):ue(e)?jb(e.pattern):S(e)?Db(e.anyOf):[]}function ho(e){return Ct(e)}function Ri(e,t){return t.map(r=>Pi(e,r))}function Pi(e,t){return W(t)?yt(Pi(e,t.items)):Ee(t)?pr(Ri(e,t.parameters),Pi(e,t.instanceType)):Se(t)?fr(Ri(e,t.parameters),Pi(e,t.returnType)):q(t)?we(Ri(e,t.items)):S(t)?j(Ri(e,t.anyOf)):O(t)?ot(Ri(e,t.allOf)):ga(t)?M(e):t}function Nb(e,t){return Pi(e,t)}function iv(e,t){let r=t in e?e[t]:ie();return Nb(e,r)}function qb(e,t){return t.reduce((r,n)=>[...r,iv(e,n)],[])}function sv(e,t){let r=ho(t),n=qb(e,r);return It(n)}var av=new RegExp(Zr);function mv(e){return e.filter(r=>av.test(r))}function uv(e){let t=Ys(e),r=mv(t),n=qb(e,r);return It(n)}function Ub(e,t){return xe(t)?uv(e):sv(e,t)}function cv(e){return G(xo(e))}function _b(e){return e.map(t=>Cc(t))}function Cc(e){return O(e)?ot(_b(e.allOf)):S(e)?j(_b(e.anyOf)):H(e)?cv(e.const):e}function pv(e,t){return e.reduceRight((r,n,o)=>{let i=rt({},G(o),t);return F.IsExtendsTrueLike(i)?[n,...r]:r},[])}function fv(e,t){let r=Cc(t),n=pv(e,r);return Qr(n)}function dv(e){return Qr(e)}function Bb(e,t){return H(t)&&s.IsEqual(t.const,"length")?G(e.length):xe(t)||Ke(t)?dv(e):fv(e,t)}function Gb(e,t){return W(e)?Ab(e.items,t):A(e)?Ub(e.properties,t):q(e)?Bb(e.items,t):ie()}function lv(e){return me(e)||ke(e)||O(e)||S(e)?yo(e):e}function wc(e,t,r){return U([e,t])?l.Update(Gb(lv(e),t),{},r):li(e,t,r)}function Kb(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return wc(i,a,o)}function wa(e,t={}){return R("InstanceType",[e],t)}function Hb(e,t={}){return Rc(e,t)}function gv(e){return Ee(e)?e.instanceType:ie()}function Rc(e,t){return U([e])?l.Update(gv(e),{},t):wa(e,t)}function zb(e,t,r,n={}){let o=$(e,t,r);return Rc(o,n)}function gi(e,t={}){return R("KeyOf",[e],t)}function Wb(e,t={}){return Pc(e,t)}function Vb(){return j([Tt(),tt(),eo()])}function Jb(e){return Tt()}function yv(e){return e.reduce((r,n)=>na(n)?[...r,G(xo(n))]:$e(),[])}function Yb(e){let t=s.Keys(e),r=yv(t);return Qr(r)}function Qb(e){return so(e)}function Xb(e){let t=e.map((r,n)=>G(n));return Qr(t)}function Zb(e){return Ie(e)?Vb():W(e)?Jb(e.items):A(e)?Yb(e.properties):ne(e)?Qb(e):q(e)?Xb(e.items):ie()}function xv(e){return me(e)||ke(e)||O(e)||S(e)?yo(e):e}function Pc(e,t){return U([e])?l.Update(Zb(xv(e)),{},t):gi(e,t)}function e$(e,t,r,n){let o=$(e,t,r);return Pc(o,n)}function pi(e,t,r,n,o={}){return R("Mapped",[e,t,r,n],o)}function t$(e,t,r,n,o={}){return Ac({},de([],[]),e,t,r,n,o)}function hv(e){let t=it(e);return Qa(t)}function Iv(e){return e.reduce((t,r)=>[...t,...Qa(r)],[])}function bv(e){let t=dt(e);return Qa(t)}function $v(e){return s.IsNumber(e)?[G(`${e}`)]:[G(e)]}function Qa(e){return Te(e)?bv(e.enum):H(e)?$v(e.const):ue(e)?hv(e.pattern):S(e)?Iv(e.anyOf):[e]}function r$(e){return Qa(e)}function Ev(e){return ue(e)?it(e.pattern):e}function Sv(e,t,r,n,o,i){let a=l.Assign(e,{[r.name]:n}),m=$(a,t,o),c=Ev(m),p=$(a,t,i);return oa(c)||ia(c)?{[c.const]:p}:{}}function kv(e,t,r,n,o,i){return n.reduce((a,m)=>[...a,Sv(e,t,r,m,o,i)],[])}function Tv(e){return e.reduce((t,r)=>[...t,M(r)],[])}function n$(e,t,r,n,o,i){let a=r$(n),m=kv(e,t,r,a,o,i),c=Tv(m);return Ce(c)}function Ac(e,t,r,n,o,i,a){return U([n])?l.Update(n$(e,t,r,n,o,i),{},a):pi(r,n,o,i,a)}function o$(e,t,r,n,o,i,a){let m=$(e,t,n);return Ac(e,t,r,m,o,i,a)}function wv(e,t,r){let n=l.Assign(e,t);return s.Keys(t).filter(i=>r.includes(i)).reduce((i,a)=>({...i,[a]:NI(n,a,t[a])}),{})}function Cv(e,t,r){let n=l.Assign(e,t);return s.Keys(t).filter(i=>!r.includes(i)).reduce((i,a)=>({...i,[a]:$(n,de([],[]),t[a])}),{})}function Rv(e,t,r){let n=FI(t),o=wv(e,t,n),i=Cv(e,t,n),a={...o,...i};return l.Update(a,{},r)}function Xa(e,t,r,n){return Rv(e,r,n)}function Ca(e,t={}){return R("NonNullable",[e],t)}function i$(e,t={}){return Oc(e,t)}function Pv(e){let t=j([Zn(),ao()]);return Ci(e,t,{})}function Oc(e,t){return U([e])?l.Update(Pv(e),{},t):Ca(e,t)}function s$(e,t,r,n){let o=$(e,t,r);return Oc(o,n)}function Ra(e,t,r={}){return R("Omit",[e,t],r)}function a$(e,t,r={}){let n=s.IsArray(t)?go(t):t;return Mc(e,n,r)}function Za(e){let t=yo(e);return A(t)?t.properties:$e()}function Av(e,t){return s.Keys(e).reduce((n,o)=>t.includes(o)?n:{...n,[o]:e[o]},{})}function m$(e,t){let r=Za(e),n=ho(t),o=Av(r,n);return M(o)}function Mc(e,t,r){return U([e,t])?l.Update(m$(e,t),{},r):Ra(e,t,r)}function u$(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return Mc(i,a,o)}function Pa(e,t={}){return R("Parameters",[e],t)}function c$(e,t={}){return vc(e,t)}function Ov(e){let t=Se(e)?e.parameters:[],r=sn({},de([],[]),t);return we(r)}function vc(e,t){return U([e])?l.Update(Ov(e),{},t):Pa(e,t)}function p$(e,t,r,n){let o=$(e,t,r);return vc(o,n)}function Aa(e,t={}){return R("Partial",[e],t)}function f$(e,t={}){return Fc(e,t)}function d$(e,t){let r=Ir(e,t),n=br(r);return lr(l.Assign(e,{[t]:n}),t)}function l$(e,t,r){let n=er(e,t,r);return br(n)}function g$(e){let t=Ce(e);return br(t)}function y$(e){let t=e.map(r=>br(r));return j(t)}function x$(e){let t=s.Keys(e).reduce((n,o)=>({...n,[o]:Js(e[o])}),{});return M(t)}function br(e){return me(e)?d$(e.$defs,e.$ref):ke(e)?l$(e.if,e.then,e.else):O(e)?g$(e.allOf):S(e)?y$(e.anyOf):A(e)?x$(e.properties):M({})}function Fc(e,t){return U([e])?l.Update(br(e),{},t):Aa(e,t)}function h$(e,t,r,n){let o=$(e,t,r);return Fc(o,n)}function Oa(e,t,r={}){return R("Pick",[e,t],r)}function I$(e,t,r={}){let n=s.IsArray(t)?go(t):t;return Lc(e,n,r)}function Mv(e,t){return s.Keys(e).reduce((n,o)=>t.includes(o)?l.Assign(n,{[o]:e[o]}):n,{})}function b$(e,t){let r=Za(e),n=ho(t),o=Mv(r,n);return M(o)}function Lc(e,t,r){return U([e,t])?l.Update(b$(e,t),{},r):Oa(e,t,r)}function $$(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return Lc(i,a,o)}function Ma(e,t={}){return R("ReadonlyObject",[e],t)}function jc(e,t={}){return Dc(e,t)}var E$=jc;function S$(e){return Xn(yt(e))}function k$(e,t){let r=Ir(e,t),n=$r(r);return lr(l.Assign(e,{[t]:n}),t)}function T$(e,t,r){let n=er(e,t,r);return $r(n)}function w$(e){let t=Ce(e);return $r(t)}function C$(e){let t=s.Keys(e).reduce((n,o)=>({...n,[o]:ea(e[o])}),{});return M(t)}function R$(e){return Xn(we(e))}function P$(e){let t=e.map(r=>$r(r));return j(t)}function $r(e){return W(e)?S$(e.items):me(e)?k$(e.$defs,e.$ref):ke(e)?T$(e.if,e.then,e.else):O(e)?w$(e.allOf):A(e)?C$(e.properties):q(e)?R$(e.items):S(e)?P$(e.anyOf):e}function Dc(e,t){return U([e])?l.Update($r(e),{},t):Ma(e)}function A$(e,t,r,n){let o=$(e,t,r);return Dc(o,n)}function O$(e,t,r,n){return t.visited.includes(n)?r:n in e?$(e,de(t.callstack,[...t.visited,n]),e[n]):r}function M$(e,t){let r=Ir(e,t),n=Er(r);return lr(l.Assign(e,{[t]:n}),t)}function v$(e,t,r){let n=er(e,t,r);return Er(n)}function F$(e){let t=Ce(e);return Er(t)}function L$(e){let t=e.map(r=>Er(r));return j(t)}function Bx(e,t={}){return R("RemoveOptional",[e],t)}function j$(e,t={}){return Tn(e,t)}function D$(e){let t=s.Keys(e).reduce((n,o)=>({...n,[o]:j$(e[o])}),{});return M(t)}function Er(e){return me(e)?M$(e.$defs,e.$ref):ke(e)?v$(e.if,e.then,e.else):O(e)?F$(e.allOf):S(e)?L$(e.anyOf):A(e)?D$(e.properties):M({})}function va(e,t={}){return R("Required",[e],t)}function N$(e,t={}){return Nc(e,t)}function Nc(e,t){return U([e])?l.Update(Er(e),{},t):va(e,t)}function q$(e,t,r,n){let o=$(e,t,r);return Nc(o,n)}function Fa(e,t={}){return R("ReturnType",[e],t)}function U$(e,t={}){return qc(e,t)}function vv(e){return Se(e)?e.returnType:ie()}function qc(e,t){return U([e])?l.Update(vv(e),{},t):Fa(e,t)}function _$(e,t,r,n={}){let o=$(e,t,r);return qc(o,n)}function La(e,t){return R("With",[e,t],{})}function em(e,t){return Uc(e,t)}function Uc(e,t){return U([e])?l.Update(e,{},t):La(e,t)}function B$(e,t,r,n){let o=$(e,t,r);return Uc(o,n)}function Fv(e){return tn(e)?q(e.items)?_c(e.items.items):Le(e.items)?[e]:te(e.items)?[e]:[ie()]:[e]}function _c(e){return e.reduce((r,n)=>[...r,...Fv(n)],[])}function de(e,t){return{callstack:e,visited:t}}function U(e){return s.ShiftLeft(e,(t,r)=>te(t)?!1:U(r),()=>!0)}function $i(e,t,r){return s.Keys(r).reduce((n,o)=>({...n,[o]:$(e,t,r[o])}),{})}function sn(e,t,r){let n=Ft(e,t,r);return _c(n)}function Ft(e,t,r){return r.map(n=>$(e,t,n))}function Lv(e,t){let r=ve(e)?cr(t,{}):t,n=Or(e)?ur(r,{}):r;return En(e)?Ai(n,{}):n}function jv(e,t,r,n,o){return s.IsEqual(r,"AddImmutable")?G$(e,t,n[0],o):s.IsEqual(r,"RemoveImmutable")?XI(e,t,n[0],o):s.IsEqual(r,"AddReadonly")?Ul(e,t,n[0],o):s.IsEqual(r,"RemoveReadonly")?kg(e,t,n[0],o):s.IsEqual(r,"AddOptional")?_l(e,t,n[0],o):s.IsEqual(r,"RemoveOptional")?Sg(e,t,n[0],o):s.IsEqual(r,"Capitalize")?ab(e,t,n[0],o):s.IsEqual(r,"Conditional")?fb(e,t,n[0],n[1],n[2],n[3],o):s.IsEqual(r,"ConstructorParameters")?lb(e,t,n[0],o):s.IsEqual(r,"Evaluate")?_I(e,t,n[0],o):s.IsEqual(r,"Exclude")?yb(e,t,n[0],n[1],o):s.IsEqual(r,"Extract")?bb(e,t,n[0],n[1],o):s.IsEqual(r,"Index")?Kb(e,t,n[0],n[1],o):s.IsEqual(r,"InstanceType")?zb(e,t,n[0],o):s.IsEqual(r,"Interface")?AI(e,t,n[0],n[1],o):s.IsEqual(r,"KeyOf")?e$(e,t,n[0],o):s.IsEqual(r,"Lowercase")?mb(e,t,n[0],o):s.IsEqual(r,"Mapped")?o$(e,t,n[0],n[1],n[2],n[3],o):s.IsEqual(r,"Module")?Xa(e,t,n[0],o):s.IsEqual(r,"NonNullable")?s$(e,t,n[0],o):s.IsEqual(r,"Pick")?$$(e,t,n[0],n[1],o):s.IsEqual(r,"Parameters")?p$(e,t,n[0],o):s.IsEqual(r,"Partial")?h$(e,t,n[0],o):s.IsEqual(r,"Omit")?u$(e,t,n[0],n[1],o):s.IsEqual(r,"ReadonlyObject")?A$(e,t,n[0],o):s.IsEqual(r,"Record")?_g(e,t,n[0],n[1],o):s.IsEqual(r,"Required")?q$(e,t,n[0],o):s.IsEqual(r,"ReturnType")?_$(e,t,n[0],o):s.IsEqual(r,"TemplateLiteral")?Vh(e,t,n[0],o):s.IsEqual(r,"Uncapitalize")?ub(e,t,n[0],o):s.IsEqual(r,"Uppercase")?cb(e,t,n[0],o):s.IsEqual(r,"With")?B$(e,t,n[0],n[1]):R(r,n,o)}function Dv(e,t,r){let n=te(r)?O$(e,t,r,r.$ref):W(r)?yt($(e,t,r.items),Jn(r)):lo(r)?Ya(e,t,r.target,r.arguments):Ee(r)?pr(Ft(e,t,r.parameters),$(e,t,r.instanceType),Bl(r)):Se(r)?fr(Ft(e,t,r.parameters),$(e,t,r.returnType),Gl(r)):ke(r)?$n($(e,t,r.if),$(e,t,r.then),$(e,t,r.else),Jl(r)):O(r)?ot(Ft(e,t,r.allOf),eg(r)):A(r)?M($i(e,t,r.properties),Wl(r)):ne(r)?Bg(je(r),$(e,t,pe(r))):tn(r)?wn($(e,t,r.items)):q(r)?we(sn(e,t,r.items),$g(r)):S(r)?j(Ft(e,t,r.anyOf),pg(r)):r;return Lv(r,n)}function $(e,t,r){return Jr(r)?jv(e,t,r.action,r.parameters,r.options):Dv(e,t,r)}function jt(e,t){return $(e,de([],[]),t)}function Ai(e,t){return l.Update(e,{"~immutable":!0},t)}function G$(e,t,r,n){let o=$(e,t,r);return Ai(o,n)}function Gx(e,t={}){return R("AddImmutable",[e],t)}function Xn(e,t={}){return Ai(e,t)}function Kx(e,t={}){return R("RemoveReadonly",[e],t)}function Hx(e,t={}){return R("Evaluate",[e],t)}function He(e,t={}){return gc(e,t)}function zx(e,t={}){return R("Module",[e],t)}function K$(e,t={}){return Xa({},de([],[]),e,t)}function Nv(e,t){let r=no(e,t);return s.IsEqual(r,ui)||s.IsEqual(r,Ti)?1:0}function H$(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>s.IsEqual(Nv(e,n),1)?H$(e,o,[...r,n]):[...r,e,...t],()=>[...r,e])}function z$(e,t=[]){return s.ShiftLeft(e,(r,n)=>z$(n,H$(r,t)),()=>t)}function W$(e){return z$(e)}function V$(...e){let[t,r,n]=B.Match(e,{2:(a,m)=>s.IsString(a)?[{},a,m]:[a,m,{}],3:(a,m,c)=>[a,m,c],1:a=>[{},a,{}]}),o=Gh(r),i=s.IsArray(o)&&s.IsEqual(o.length,2)?$(t,de([],[]),o[0]):ie();return l.Update(i,{},n)}function J$(e,t,r){return s.IsArray(r)?r.map(n=>ze(e,t.items,n)):r}function Y$(e,t,r){return ze({...e,...t.$defs},Be(t.$ref),r)}function qv(e,t){let r=s.HasPropertyKey(t,"unevaluatedProperties")?{additionalProperties:t.unevaluatedProperties}:{},n=jt(e,t),o=He(n);return A(o)?em(o,r):o}function Q$(e,t,r){let n=qv(e,t);return ze(e,n,r)}function tm(e){return s.HasPropertyKey(e,"additionalProperties")?e.additionalProperties:void 0}function X$(e,t,r){if(!s.IsObject(r)||s.IsArray(r))return r;let n=tm(t);for(let o of s.Keys(r)){if(s.HasPropertyKey(t.properties,o)&&ye(t.properties[o])){r[o]=ze(e,t.properties[o],r[o]);continue}if(s.IsBoolean(n)&&s.IsEqual(n,!0)||ye(n)&&K(e,n,r[o])){r[o]=ze(e,n,r[o]);continue}delete r[o]}return r}function Z$(e,t,r){if(!s.IsObject(r))return r;let n=tm(t),[o,i]=[new RegExp(je(t)),pe(t)];for(let a of s.Keys(r)){if(o.test(a)){r[a]=ze(e,i,r[a]);continue}if(s.IsBoolean(n)&&s.IsEqual(n,!0)||ye(n)&&K(e,n,r[a])){r[a]=ze(e,n,r[a]);continue}delete r[a]}return r}function eE(e,t,r){return s.HasPropertyKey(e,t.$ref)?ze(e,e[t.$ref],r):r}function tE(e,t,r){if(!s.IsArray(r))return r;let n=Math.min(r.length,t.items.length);for(let o=0;o<n;o++)r[o]=ze(e,t.items[o],r[o]);return s.IsGreaterThan(r.length,n)?r.slice(0,n):r}function Uv(e){return s.HasPropertyKey(e,"~kind")||s.HasPropertyKey(e,"~unsafe")}function _v(e){let t={};for(let r of s.Keys(e)){if(s.IsUnsafePropertyKey(r))continue;let n=Object.getOwnPropertyDescriptor(e,r);n.value=On(n.value),s.IsEqual(n.enumerable,!0)?t[r]=n.value:Object.defineProperty(t,r,n)}return t}function Bv(e){let t={};for(let r of s.Keys(e))s.IsUnsafePropertyKey(r)||(t[r]=On(e[r]));for(let r of s.Symbols(e))t[r]=On(e[r]);return t}function Gv(e){return s.IsClassInstance(e)?e:Uv(e)?_v(e):Bv(e)}function Kv(e){return e.map(t=>On(t))}function Hv(e){return e.slice()}function zv(e){return new RegExp(e.source,e.flags)}function Wv(e){return new Map(On([...e.entries()]))}function Vv(e){return new Set(On([...e.values()]))}function On(e){return De.IsTypeArray(e)?Hv(e):De.IsRegExp(e)?zv(e):De.IsMap(e)?Wv(e):De.IsSet(e)?Vv(e):s.IsArray(e)?Kv(e):s.IsObject(e)?Gv(e):e}function rE(e){return On(e)}function fe(e){return rE(e)}function nE(e,t,r){for(let n of t.anyOf){let o=ze(e,n,fe(r));if(K(e,n,o))return o}return r}function ze(e,t,r){return W(t)?J$(e,t,r):me(t)?Y$(e,t,r):O(t)?Q$(e,t,r):A(t)?X$(e,t,r):ne(t)?Z$(e,t,r):te(t)?eE(e,t,r):q(t)?tE(e,t,r):S(t)?nE(e,t,r):r}function Jv(e,t){return l.Assign(e,t)}function Yv(e){let t={};for(let r of Sf.Keys(e))t[r]=Oi(e[r]);return t}function Qv(e){return tt({pattern:je(e)})}function Xv(e){return Bc(W$(e))}function Bc(e){return e.map(t=>Oi(t))}function Oi(e){let t=W(e)?yt(Oi(e.items),Jn(e)):O(e)?ot(Bc(e.allOf)):S(e)?j(Xv(e.anyOf)):A(e)?M(Yv(e.properties)):ne(e)?io(Qv(e),Oi(pe(e))):q(e)?we(Bc(e.items)):e;return Jv(e,t)}function Io(e){return Oi(e)}function tr(...e){let[t,r,n]=B.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]}),o=Me.Get().unionPrioritySort?Io(r):r;return ze(t,o,n)}var Z={};At(Z,{Fail:()=>Mn,IsOk:()=>Gc,Ok:()=>P,TryArray:()=>Zv,TryBigInt:()=>Kc,TryBoolean:()=>pF,TryNull:()=>yF,TryNumber:()=>bF,TryString:()=>$F,TryUndefined:()=>wF});function Gc(e){return s.IsObject(e)&&s.HasPropertyKey(e,"value")}function P(e){return{value:e}}function Mn(){}function Zv(e){return s.IsArray(e)?P(e):P([e])}function eF(e){return s.IsEqual(e,!0)?P(BigInt(1)):P(BigInt(0))}var tF=/^-?(0|[1-9]\d*)n$/,rF=/^-?(0|[1-9]\d*)\.\d+$/,nF=/^-?(0|[1-9]\d*)$/;function oF(e){return tF.test(e)}function iF(e){return rF.test(e)}function sF(e){return nF.test(e)}function aF(e){let t=e.toLowerCase();return oF(e)?P(BigInt(e.slice(0,e.length-1))):iF(e)?P(BigInt(e.split(".")[0])):sF(e)?P(BigInt(e)):s.IsEqual(t,"false")?P(BigInt(0)):s.IsEqual(t,"true")?P(BigInt(1)):void 0}function Kc(e){return s.IsBigInt(e)?P(e):s.IsBoolean(e)?eF(e):s.IsNumber(e)?P(BigInt(Math.trunc(e))):s.IsNull(e)?P(BigInt(0)):s.IsString(e)?aF(e):s.IsUndefined(e)?P(BigInt(0)):void 0}function mF(e){return s.IsEqual(e,BigInt(0))?P(!1):s.IsEqual(e,BigInt(1))?P(!0):void 0}function uF(e){return s.IsEqual(e,0)?P(!1):s.IsEqual(e,1)?P(!0):void 0}function cF(e){return s.IsEqual(e.toLowerCase(),"false")?P(!1):s.IsEqual(e.toLowerCase(),"true")?P(!0):s.IsEqual(e,"0")?P(!1):s.IsEqual(e,"1")?P(!0):void 0}function pF(e){return s.IsBigInt(e)?mF(e):s.IsBoolean(e)?P(e):s.IsNumber(e)?uF(e):s.IsNull(e)?P(!1):s.IsString(e)?cF(e):s.IsUndefined(e)?P(!1):void 0}function fF(e){return s.IsEqual(e,BigInt(0))?P(null):void 0}function dF(e){return s.IsEqual(e,!1)?P(null):void 0}function lF(e){return s.IsEqual(e,0)?P(null):void 0}function gF(e){let t=e.toLowerCase();return s.IsEqual(t,"undefined")||s.IsEqual(t,"null")||s.IsEqual(e,"")||s.IsEqual(e,"0")?P(null):void 0}function yF(e){return s.IsBigInt(e)?fF(e):s.IsBoolean(e)?dF(e):s.IsNumber(e)?lF(e):s.IsNull(e)?P(null):s.IsString(e)?gF(e):s.IsUndefined(e)?P(null):void 0}var oE=BigInt(Number.MAX_SAFE_INTEGER),iE=BigInt(Number.MIN_SAFE_INTEGER);function xF(e){return e<=oE&&e>=iE?P(Number(e)):void 0}function hF(e){return P(e?1:0)}function IF(e){let t=+e;if(s.IsNumber(t))return P(t);let r=e.toLowerCase();if(s.IsEqual(r,"false"))return P(0);if(s.IsEqual(r,"true"))return P(1);let n=Kc(e);return Gc(n)?n.value<=oE&&n.value>=iE?P(Number(n.value)):void 0:void 0}function bF(e){return s.IsBigInt(e)?xF(e):s.IsBoolean(e)?hF(e):s.IsNumber(e)?P(e):s.IsNull(e)?P(0):s.IsString(e)?IF(e):s.IsUndefined(e)?P(0):void 0}function $F(e){return s.IsBigInt(e)?P(e.toString()):s.IsBoolean(e)?P(e.toString()):s.IsNumber(e)?P(e.toString()):s.IsNull(e)?P("null"):s.IsString(e)?P(e):s.IsUndefined(e)?P(""):void 0}function EF(e){return s.IsEqual(e,BigInt(0))?P(void 0):void 0}function SF(e){return s.IsEqual(e,!1)?P(void 0):void 0}function kF(e){return s.IsEqual(e,0)?P(void 0):void 0}function TF(e){let t=e.toLowerCase();return s.IsEqual(t,"undefined")||s.IsEqual(t,"null")||s.IsEqual(e,"")||s.IsEqual(e,"0")?P(void 0):void 0}function wF(e){return s.IsBigInt(e)?EF(e):s.IsBoolean(e)?SF(e):s.IsNumber(e)?kF(e):s.IsNull(e)?P(void 0):s.IsString(e)?TF(e):s.IsUndefined(e)?P(e):void 0}function sE(e,t,r){return Z.TryArray(r).value.map(o=>Ae(e,t.items,o))}function aE(e,t,r){let n=Z.TryBigInt(r);return Z.IsOk(n)?n.value:r}function mE(e,t,r){let n=Z.TryBoolean(r);return Z.IsOk(n)?n.value:r}function uE(e,t,r){return Ae({...e,...t.$defs},Be(t.$ref),r)}function cE(e,t,r){return Ae(e,He(t),r)}function pE(e,t,r){let n=Z.TryNumber(r);return Z.IsOk(n)?Math.trunc(n.value):r}function fE(e,t,r){let n=jt(e,t),o=He(n);return Ae(e,o,r)}function CF(e,t,r){let n=Z.TryBigInt(r);return Z.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function RF(e,t,r){let n=Z.TryBoolean(r);return Z.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function PF(e,t,r){let n=Z.TryNumber(r);return Z.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function AF(e,t,r){let n=Z.TryString(r);return Z.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function dE(e,t,r){return s.IsEqual(t.const,r)?r:mg(t)?CF(e,t,r):ug(t)?RF(e,t,r):oa(t)?PF(e,t,r):ia(t)?AF(e,t,r):$e()}function lE(e,t,r){let n=Z.TryNull(r);return Z.IsOk(n)?n.value:r}function gE(e,t,r){let n=Z.TryNumber(r);return Z.IsOk(n)?n.value:r}function rm(e,t,r,n){let o=s.Keys(n);for(let[i,a]of t)for(let m of o)i.test(m)||(n[m]=Ae(e,r,n[m]));return n}function Mi(e,t,r){return ve(e)&&s.IsUndefined(r[t])}function OF(e,t,r){let n=s.EntriesRegExp(t.properties),o=s.Keys(r);for(let[i,a]of n)for(let m of o)!i.test(m)||Mi(a,m,r)||(r[m]=Ae(e,a,r[m]));return s.HasPropertyKey(t,"additionalProperties")&&s.IsObject(t.additionalProperties)?rm(e,n,t.additionalProperties,r):r}function yE(e,t,r){return s.IsObjectNotArray(r)?OF(e,t,r):r}function MF(e,t,r){let n=s.EntriesRegExp(t.patternProperties),o=s.Keys(r);for(let[i,a]of n)for(let m of o)i.test(m)&&(r[m]=Ae(e,a,r[m]));return s.HasPropertyKey(t,"additionalProperties")&&s.IsObject(t.additionalProperties)?rm(e,n,t.additionalProperties,r):r}function xE(e,t,r){return s.IsObjectNotArray(r)?MF(e,t,r):r}function hE(e,t,r){return s.HasPropertyKey(e,t.$ref)?Ae(e,e[t.$ref],r):r}function IE(e,t,r){let n=Z.TryString(r);return Z.IsOk(n)?n.value:r}function bE(e,t,r){return Ae(e,He(t),r)}function $E(e,t,r){if(!s.IsArray(r))return r;for(let n=0;n<Math.min(t.items.length,r.length);n++)r[n]=Ae(e,t.items[n],r[n]);return r}function EE(e,t,r){let n=Z.TryUndefined(r);return Z.IsOk(n)?n.value:r}function SE(e,t,r){if(t.anyOf.some(a=>K(e,a,r)))return r;let i=t.anyOf.map(a=>Ae(e,a,fe(r))).find(a=>K(e,t,a));return s.IsUndefined(i)?r:i}function kE(e,t,r){let n=Z.TryUndefined(r);return Z.IsOk(n)?void 0:r}function Ae(e,t,r){return W(t)?sE(e,t,r):kt(t)?aE(e,t,r):ft(t)?mE(e,t,r):me(t)?uE(e,t,r):Te(t)?cE(e,t,r):Ke(t)?pE(e,t,r):O(t)?fE(e,t,r):H(t)?dE(e,t,r):yr(t)?lE(e,t,r):xe(t)?gE(e,t,r):A(t)?yE(e,t,r):ne(t)?xE(e,t,r):te(t)?hE(e,t,r):qe(t)?IE(e,t,r):ue(t)?bE(e,t,r):q(t)?$E(e,t,r):Kt(t)?EE(e,t,r):S(t)?SE(e,t,r):wt(t)?kE(e,t,r):r}function Sr(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return Ae(t,r,n)}function TE(e,t,r){if(!s.IsArray(r))return r;for(let n=0;n<r.length;n++)r[n]=We(e,t.items,r[n]);return r}function wE(e,t,r){return We({...e,...t.$defs},Be(t.$ref),r)}function CE(e,t){return s.IsUndefined(t)?s.IsFunction(e.default)?e.default():fe(e.default):t}function RE(e,t,r){let n=jt(e,t),o=He(n);return We(e,o,r)}function PE(e,t,r){if(!s.IsObject(r))return r;let n=s.Keys(t.properties);for(let o of n){let i=We(e,t.properties[o],r[o]);s.IsUndefined(i)&&(ve(t.properties[o])||!s.HasPropertyKey(t.properties[o],"default"))||(r[o]=i)}if(!_t(t)||s.IsBoolean(t.additionalProperties))return r;for(let o of s.Keys(r))n.includes(o)||(r[o]=We(e,t.additionalProperties,r[o]));return r}function AE(e,t,r){if(!s.IsObject(r))return r;let[n,o]=[new RegExp(je(t)),pe(t)];for(let i of s.Keys(r))n.test(i)&&bt(o)&&(r[i]=We(e,o,r[i]));if(!_t(t))return r;for(let i of s.Keys(r))n.test(i)||(r[i]=We(e,t.additionalProperties,r[i]));return r}function OE(e,t,r){return s.HasPropertyKey(e,t.$ref)?We(e,e[t.$ref],r):r}function ME(e,t,r){if(!s.IsArray(r))return r;let[n,o]=[t.items,Math.max(t.items.length,r.length)];for(let i=0;i<o;i++)i<n.length&&(r[i]=We(e,n[i],r[i]));return r}function vE(e,t,r){for(let n of t.anyOf){let o=We(e,n,fe(r));if(K(e,n,o))return o}return r}function We(e,t,r){let n=bt(t)?CE(t,r):r;return W(t)?TE(e,t,n):me(t)?wE(e,t,n):O(t)?RE(e,t,n):A(t)?PE(e,t,n):ne(t)?AE(e,t,n):te(t)?OE(e,t,n):q(t)?ME(e,t,n):S(t)?vE(e,t,n):n}function an(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return We(t,r,n)}function bo(e){return(...t)=>{let[r,n,o]=B.Match(t,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]});return e.reduce((i,a)=>a(r,n,i),o)}}function vF(e,t,r){return t["~codec"].decode(r)}function FF(e,t,r){return t["~codec"].encode(r)}function ge(e,t,r,n){return pt(r)?s.IsEqual(e,"Decode")?vF(t,r,n):FF(t,r,n):n}function LF(e,t,r,n){if(!s.IsArray(n))return n;for(let o=0;o<n.length;o++)n[o]=he(e,t,r.items,n[o]);return ge(e,t,r,n)}function jF(e,t,r,n){let o=ge(e,t,r,n);if(!s.IsArray(o))return o;for(let i=0;i<o.length;i++)o[i]=he(e,t,r.items,o[i]);return o}function FE(e,t,r,n){return s.IsEqual(e,"Decode")?LF(e,t,r,n):jF(e,t,r,n)}function LE(e,t,r,n){return n=he(e,{...t,...r.$defs},Be(r.$ref),n),ge(e,t,r,n)}function jE(e){return e.reduce((t,r)=>({...t,...r}),{})}function DE(e,t){for(let r of t)if(!s.IsDeepEqual(e,r))return r;return e}function DF(e,t,r,n){if(s.IsEqual(r.allOf.length,0))return ge(e,t,r,n);let o=r.allOf.map(m=>he(e,t,m,tr(m,fe(n)))),a=o.every(m=>s.IsObject(m))?jE(o):DE(n,o);return ge(e,t,r,a)}function NF(e,t,r,n){if(s.IsEqual(r.allOf.length,0))return ge(e,t,r,n);let o=ge(e,t,r,n),i=r.allOf.map(m=>he(e,t,m,tr(m,fe(o))));return i.every(m=>s.IsObject(m))?jE(i):DE(o,i)}function NE(e,t,r,n){return s.IsEqual(e,"Decode")?DF(e,t,r,n):NF(e,t,r,n)}function qF(e,t,r,n){if(!s.IsObjectNotArray(n))return n;for(let o of s.Keys(r.properties))!s.HasPropertyKey(n,o)||Mi(r.properties[o],o,n)||(n[o]=he(e,t,r.properties[o],n[o]));return ge(e,t,r,n)}function UF(e,t,r,n){let o=ge(e,t,r,n);if(!s.IsObjectNotArray(o))return o;for(let i of s.Keys(r.properties))!s.HasPropertyKey(o,i)||Mi(r.properties[i],i,o)||(o[i]=he(e,t,r.properties[i],o[i]));return o}function qE(e,t,r,n){return s.IsEqual(e,"Decode")?qF(e,t,r,n):UF(e,t,r,n)}function _F(e,t,r,n){if(!s.IsObjectNotArray(n))return n;let o=new RegExp(je(r));for(let i of s.Keys(n))o.test(i)&&(n[i]=he(e,t,pe(r),n[i]));return ge(e,t,r,n)}function BF(e,t,r,n){let o=ge(e,t,r,n);if(!s.IsObjectNotArray(o))return o;let i=new RegExp(je(r));for(let a of s.Keys(o))i.test(a)&&(o[a]=he(e,t,pe(r),o[a]));return o}function UE(e,t,r,n){return s.IsEqual(e,"Decode")?_F(e,t,r,n):BF(e,t,r,n)}function _E(e,t,r,n){return s.HasPropertyKey(t,r.$ref)?he(e,t,t[r.$ref],n):n}function BE(e,t,r,n){return s.IsEqual(e,"Decode")?ge(e,t,r,_E(e,t,r,n)):_E(e,t,r,ge(e,t,r,n))}function GF(e,t,r,n){if(!s.IsArray(n))return n;for(let o=0;o<Math.min(r.items.length,n.length);o++)n[o]=he(e,t,r.items[o],n[o]);return ge(e,t,r,n)}function KF(e,t,r,n){let o=ge(e,t,r,n);if(!s.IsArray(o))return n;for(let i=0;i<Math.min(r.items.length,o.length);i++)o[i]=he(e,t,r.items[i],o[i]);return o}function GE(e,t,r,n){return s.IsEqual(e,"Decode")?GF(e,t,r,n):KF(e,t,r,n)}function HF(e,t,r,n){for(let o of r.anyOf){if(!K(t,o,n))continue;let i=he(e,t,o,n);return ge(e,t,r,i)}return n}function zF(e,t,r,n){let o=ge(e,t,r,n);for(let i of r.anyOf){let a=he(e,t,i,fe(o));if(K(t,i,a))return a}return o}function KE(e,t,r,n){return s.IsEqual(e,"Decode")?HF(e,t,r,n):zF(e,t,r,n)}function he(e,t,r,n){return W(r)?FE(e,t,r,n):me(r)?LE(e,t,r,n):O(r)?NE(e,t,r,n):A(r)?qE(e,t,r,n):ne(r)?UE(e,t,r,n):te(r)?BE(e,t,r,n):q(r)?GE(e,t,r,n):S(r)?KE(e,t,r,n):ge(e,t,r,n)}var Hc=class extends Ar{constructor(t,r){super("Decode",t,r)}};function WF(e,t,r){if(!K(e,t,r))throw new Hc(r,Xt(e,t,r));return r}function VF(e,t,r){let n=Me.Get().unionPrioritySort?Io(t):t;return he("Decode",e,n,r)}var JF=bo([(e,t,r)=>fe(r),(e,t,r)=>an(e,t,r),(e,t,r)=>Sr(e,t,r),(e,t,r)=>tr(e,t,r),(e,t,r)=>WF(e,t,r),(e,t,r)=>VF(e,t,r)]);function HE(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return JF(t,r,n)}var zc=class extends Ar{constructor(t,r){super("Encode",t,r)}};function YF(e,t,r){if(!K(e,t,r))throw new zc(r,Xt(e,t,r));return r}function QF(e,t,r){let n=Me.Get().unionPrioritySort?Io(t):t;return he("Encode",e,n,r)}var XF=bo([(e,t,r)=>fe(r),(e,t,r)=>QF(e,t,r),(e,t,r)=>an(e,t,r),(e,t,r)=>Sr(e,t,r),(e,t,r)=>tr(e,t,r),(e,t,r)=>YF(e,t,r)]);function zE(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return XF(t,r,n)}function ZF(e,t){return pt(t)||mn(e,t.items)}function e1(e,t){return pt(t)||WE({...e,...t.$defs},Be(t.$ref))}function t1(e,t){return pt(t)||t.allOf.some(r=>mn(e,r))}function r1(e,t){return pt(t)||s.Keys(t.properties).some(r=>mn(e,t.properties[r]))}function n1(e,t){return pt(t)||mn(e,pe(t))}function WE(e,t){return Wc.has(t.$ref)?!1:(Wc.add(t.$ref),pt(t)||s.HasPropertyKey(e,t.$ref)&&mn(e,e[t.$ref]))}function o1(e,t){return pt(t)||t.items.some(r=>mn(e,r))}function i1(e,t){return pt(t)||t.anyOf.some(r=>mn(e,r))}function mn(e,t){return W(t)?ZF(e,t):me(t)?e1(e,t):O(t)?t1(e,t):A(t)?r1(e,t):ne(t)?n1(e,t):te(t)?WE(e,t):q(t)?o1(e,t):S(t)?i1(e,t):pt(t)}var Wc=new Set;function VE(...e){let[t,r]=B.Match(e,{2:(n,o)=>[n,o],1:n=>[{},n]});return Wc.clear(),mn(t,r)}var Ht=class extends Error{constructor(t,r){super(r),this.type=t}};function JE(e,t){return s.IsFunction(t.default)?t.default(t):s.IsObject(t.default)?fe(t.default):t.default}function YE(e,t){if(Hr(t)&&!bt(t))throw new Ht(t,"Arrays with uniqueItems constraints must specify a default annotation");let r=xn(t)?t.minItems:0;return Array.from({length:r},()=>Oe(e,t.items))}function QE(e,t){return wr(t)?BigInt(t.exclusiveMinimum)+BigInt(1):Cr(t)?BigInt(t.minimum):BigInt(0)}function XE(e,t){return!1}function ZE(e,t){let r=Oe(e,t.instanceType);return class{constructor(){Object.assign(this,r)}}}function eS(e,t){return Oe({...e,...t.$defs},Be(t.$ref))}function tS(e,t){return Oe(e,He(t))}function rS(e,t){let r=Oe(e,t.returnType);return()=>r}function nS(e,t){return wr(t)&&s.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Cr(t)?t.minimum:0}function oS(e,t){let r=jt(e,t),n=He(r);return Oe(e,n)}function iS(e,t){return t.const}function sS(e,t){throw new Ht(t,"Cannot create TNever types")}function aS(e,t){return null}function mS(e,t){return wr(t)&&s.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Cr(t)?t.minimum:0}function uS(e,t){return(s.IsUndefined(t.required)?[]:t.required).reduce((n,o)=>({...n,[o]:Oe(e,t.properties[o])}),{})}function cS(e,t){if(Uo(t)&&!bt(t))throw new Ht(t,"Record with the minProperties constraint must have a default annotation");return{}}function pS(e,t){return s.HasPropertyKey(e,t.$ref)?Oe(e,e[t.$ref]):(()=>{throw new Ht(t,"Unable to deref Ref")})()}function fS(e,t){if((_o(t)||Do(t))&&!bt(t))throw Error("Strings with format or pattern constraints must specify default");let n=qo(t)?t.minLength:0;return"".padEnd(n)}function dS(e,t){return Symbol()}function lS(e,t){let r=to(t.pattern);if(qe(r))throw new Ht(t,"Unable to create TemplateLiteral due to infinite type expansion");return Oe(e,r)}function gS(e,t){return Array.from({length:t.minItems},(r,n)=>Oe(e,t.items[n]))}function yS(e,t){if(s.IsEqual(t.anyOf.length,0))throw Error("Unable to create Union with no variants");return Oe(e,t.anyOf[0])}function Oe(e,t){return bt(t)?JE(e,t):W(t)?YE(e,t):kt(t)?QE(e,t):ft(t)?XE(e,t):Ee(t)?ZE(e,t):me(t)?eS(e,t):Te(t)?tS(e,t):Se(t)?rS(e,t):Ke(t)?nS(e,t):O(t)?oS(e,t):H(t)?iS(e,t):xt(t)?sS(e,t):yr(t)?aS(e,t):xe(t)?mS(e,t):A(t)?uS(e,t):ne(t)?cS(e,t):te(t)?pS(e,t):qe(t)?fS(e,t):xr(t)?dS(e,t):ue(t)?lS(e,t):q(t)?gS(e,t):Kt(t)?void 0:S(t)?yS(e,t):wt(t)?void 0:void 0}function Xe(...e){let[t,r]=B.Match(e,{2:(n,o)=>[n,o],1:n=>[{},n]});return Oe(t,r)}function nm(e,t){return s.IsDeepEqual(e,t)}function om(e){return Pr.Hash(e)}var im=class extends Ar{constructor(t,r){super("Parse",t,r)}};function s1(e,t,r){zs();let n=Xt(e,t,r);if(Ws(),!K(e,t,r))throw new im(r,n);return r}var a1=bo([(e,t,r)=>fe(r),(e,t,r)=>an(e,t,r),(e,t,r)=>Sr(e,t,r),(e,t,r)=>tr(e,t,r),(e,t,r)=>s1(e,t,r)]);function xS(...e){let[t,r,n]=B.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]});if(K(t,r,n))return n;if(Me.Get().correctiveParse)return a1(t,r,n);zs();let i=Xt(t,r,n);throw Ws(),new im(n,i)}function sm(e,t){return{type:"update",path:e,value:t}}function IS(e,t){return{type:"insert",path:e,value:t}}function bS(e){return{type:"delete",path:e}}function hS(e){if(!(s.IsObject(e)&&s.IsEqual(s.Symbols(e).length,0)))throw new Error("Cannot create diffs for objects with symbols keys")}function*m1(e,t,r){if(!s.IsObject(r)||s.IsArray(r))return yield sm(e,r);hS(t),hS(r);let n=s.Keys(t),o=s.Keys(r);for(let i of o)s.HasPropertyKey(t,i)||s.IsUnsafePropertyKey(i)||(yield IS(`${e}/${i}`,r[i]));for(let i of n)s.HasPropertyKey(r,i)&&(s.IsUnsafePropertyKey(i)||nm(t,r)||(yield*am(`${e}/${i}`,t[i],r[i])));for(let i of n)s.HasPropertyKey(r,i)||s.IsUnsafePropertyKey(i)||(yield bS(`${e}/${i}`))}function*u1(e,t,r){if(!s.IsArray(r))return yield sm(e,r);for(let n=0;n<Math.min(t.length,r.length);n++)yield*am(`${e}/${n}`,t[n],r[n]);for(let n=0;n<r.length;n++)n<t.length||(yield IS(`${e}/${n}`,r[n]));for(let n=t.length-1;n>=0;n--)n<r.length||(yield bS(`${e}/${n}`))}function*c1(e,t,r){let n=globalThis.Object.getPrototypeOf(t).constructor.name,o=globalThis.Object.getPrototypeOf(r).constructor.name;if(De.IsTypeArray(r)&&s.IsEqual(t.length,r.length)&&s.IsEqual(n,o))for(let a=0;a<Math.min(t.length,r.length);a++)yield*am(`${e}/${a}`,t[a],r[a]);else return yield sm(e,r)}function*p1(e,t,r){t!==r&&(yield sm(e,r))}function*am(e,t,r){return De.IsTypeArray(t)?yield*c1(e,t,r):s.IsArray(t)?yield*u1(e,t,r):s.IsObject(t)?yield*m1(e,t,r):yield*p1(e,t,r)}function $S(e,t){return[...am("",e,t)]}var f1=M({type:G("insert"),path:tt(),value:Ne()}),d1=Object({type:G("update"),path:tt(),value:Ne()}),l1=M({type:G("delete"),path:tt()}),dRe=j([f1,d1,l1]);function g1(e){return e.length>0&&e[0].path===""&&e[0].type==="update"}function y1(e){return e.length===0}function ES(e,t){if(g1(t))return fe(t[0].value);if(y1(t))return fe(e);let r=fe(e);for(let n of t)switch(n.type){case"insert":{mr.Set(r,n.path,n.value);break}case"update":{mr.Set(r,n.path,n.value);break}case"delete":{mr.Delete(r,n.path);break}}return r}var Fr=class extends Error{constructor(t,r,n,o){super(o),this.context=t,this.type=r,this.value=n}};function x1(e){let[t,r]=[new Set,[]];for(let n of e){let o=om(n);t.has(o)||(t.add(o),r.push(n))}return r}function SS(e,t,r){if(K(e,t,r))return r;let n=s.IsArray(r)?r:Xe(e,t),o=xn(t)&&n.length<t.minItems?[...n,...Array.from({length:t.minItems-n.length},()=>Xe(e,t))]:n,a=(No(t)&&o.length>t.maxItems?o.slice(0,t.maxItems):o).map(c=>Ue(e,t.items,c));if(!Hr(t)||Hr(t)&&!s.IsEqual(t.uniqueItems,!0))return a;let m=x1(a);if(!K(e,t,m))throw new Fr(e,t,r,"Failed to repair Array due to uniqueItems constraint");return m}function kS(e,t,r){return Ue(e,He(t),r)}function TS(e,t,r){let n=jt(e,t),o=He(n);return Ue(e,o,r)}function wS(e,t,r){if(K(e,t,r))return r;if(!s.IsObjectNotArray(r))return Xe(e,t);let n=new Set(s.IsUndefined(t.required)?[]:t.required),o={};for(let[a,m]of s.Entries(t.properties))!n.has(a)&&s.IsUndefined(r[a])||(o[a]=a in r?Ue(e,m,r[a]):Xe(e,m));let i=s.Keys(t.properties);if(_t(t)&&s.IsObject(t.additionalProperties))for(let a of s.Keys(r))i.includes(a)||(o[a]=Ue(e,t.additionalProperties,r[a]));return o}function CS(e,t,r){if(K(e,t,r))return r;if(s.IsNull(r)||!s.IsObject(r)||s.IsArray(r))return Xe(e,t);let n=new RegExp(je(t)),o=pe(t),i=new Set,a={};for(let[m,c]of s.Entries(r))n.test(m)&&(a[m]=Ue(e,o,c),i.add(m));if(_t(t))for(let m of s.Keys(r))i.has(m)||(a[m]=Ue(e,t.additionalProperties,r[m]));return a}function RS(e,t,r){return s.HasPropertyKey(e,t.$ref)?Ue(e,e[t.$ref],r):(()=>{throw new Fr(e,t,r,"Unable to de-reference target type")})()}function PS(e,t,r){let n=to(t.pattern);return Ue(e,n,r)}function AS(e,t,r){return K(e,t,r)?r:s.IsArray(r)?t.items.map((n,o)=>Ue(e,n,r[o])):Xe(e,t)}function OS(e,t,r){return te(t)?s.HasPropertyKey(e,t.$ref)?OS(e,e[t.$ref],r):(()=>{throw new Error("Unable to Deref target")})():t}function h1(e,t,r){if(!(A(t)&&s.IsObject(r)))return 0;let n=s.Keys(r);return s.Entries(t.properties).reduce((i,[a,m])=>{let c=H(m)&&s.IsEqual(m.const,r[a])?100:0,p=K(e,m,r[a])?10:0,f=n.includes(a)?1:0;return i+(c+p+f)},0)}function MS(e,t,r){let n=t.anyOf.map(a=>OS(e,a,r)),[o,i]=[n[0],0];for(let a of n){let m=h1(e,a,r);m>i&&(o=a,i=m)}return o}function I1(e,t,r){let n=j(en(t.anyOf)),o=MS(e,n,r);return Ue(e,o,r)}function vS(e,t,r){return K(e,t,r)?fe(r):bt(t)?Xe(e,t):I1(e,t,r)}function FS(e,t,r){if(K(e,t,r))return r;let n=Sr(e,t,r);return K(e,t,n)?n:Xe(e,t)}function b1(e,t,r){if(De.IsDate(r)||De.IsMap(r)||De.IsSet(r)||De.IsTypeArray(r)||s.IsConstructor(r)||s.IsFunction(r))throw new Fr(e,t,r,"Value is not repairable")}function $1(e,t,r){if(Ee(t)||Se(t)||xt(t))throw new Fr(e,t,r,"Type is not repairable")}function E1(e,t,r){return s.IsUndefined(r)&&!Kt(t)?Xe(e,t):r}function S1(e,t,r){return ni(t)?K(e,t,r)?r:Xe(e,t):r}function Ue(e,t,r){b1(e,t,r),$1(e,t,r);let n=E1(e,t,r),o=W(t)?SS(e,t,n):Te(t)?kS(e,t,n):O(t)?TS(e,t,n):A(t)?wS(e,t,n):ne(t)?CS(e,t,n):te(t)?RS(e,t,n):ue(t)?PS(e,t,n):q(t)?AS(e,t,n):S(t)?vS(e,t,n):FS(e,t,n);return S1(e,t,o)}function LS(...e){let[t,r,n]=B.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]}),o=Ue(t,r,n);return Vs(t,r,o),o}var $o={};At($o,{Assert:()=>Vs,Check:()=>K,Clean:()=>tr,Clone:()=>fe,Convert:()=>Sr,Create:()=>Xe,Decode:()=>HE,Default:()=>an,Diff:()=>$S,Encode:()=>zE,Equal:()=>nm,Errors:()=>Xt,HasCodec:()=>VE,Hash:()=>om,Parse:()=>xS,Patch:()=>ES,Pointer:()=>mr,Repair:()=>LS});var R1=C1(Ye,"hooks.json"),jS=64*1024,qS=30,DS=["PreToolUse","PostToolUse","UserPromptSubmit","SessionStart","Stop","PreCompact","SessionEnd"];function jPe(e,t){if(t===null||typeof t!="object"||Array.isArray(t))return"the rewrite is not a JSON object";if(!(e===null||typeof e!="object"))try{if($o.Check(e,t))return;let r=[...$o.Errors(e,t)][0];if(!r)return"the rewrite does not match the tool's schema";let n="instancePath"in r?String(r.instancePath):"";return`the rewrite does not match the tool's schema${n&&n!=="/"?` at \`${n}\``:""}: ${r.message}`}catch(r){return`the tool's schema could not be checked: ${r instanceof Error?r.message:String(r)}`}}function DPe(e=R1){let t=[],r={hooks:{}};try{if(!T1(e))return{config:r,diagnostics:t};let n=w1(e,"utf8");if(Buffer.byteLength(n,"utf8")>jS)return t.push({source:e,message:`skipped: larger than ${jS} bytes`}),{config:r,diagnostics:t};let o=JSON.parse(n),i=P1(o);for(let a of i.diagnostics)t.push({source:e,message:a});return{config:i.config,diagnostics:t}}catch(n){return t.push({source:e,message:`unreadable: ${n instanceof Error?n.message:String(n)}`}),{config:r,diagnostics:t}}}function P1(e){let t=[],r={hooks:{}};if(e===null||typeof e!="object"||Array.isArray(e))return{config:r,diagnostics:["expected a JSON object with a `hooks` key"]};let n=e.hooks;if(n===void 0)return{config:r,diagnostics:["no `hooks` key"]};if(n===null||typeof n!="object"||Array.isArray(n))return{config:r,diagnostics:["`hooks` must be an object keyed by event name"]};for(let[o,i]of Object.entries(n)){if(!DS.includes(o)){t.push(`unknown event \`${o}\` \u2014 supported: ${DS.join(", ")}`);continue}if(!Array.isArray(i)){t.push(`\`${o}\` must be an array of matchers`);continue}let a=[];for(let m of i){let c=A1(m,o,t);c&&a.push(c)}a.length&&(r.hooks[o]=a)}return{config:r,diagnostics:t}}function A1(e,t,r){if(e===null||typeof e!="object"||Array.isArray(e)){r.push(`\`${t}\`: a matcher must be an object`);return}let n=e,o=Array.isArray(n.hooks)?n.hooks:void 0;if(!o){r.push(`\`${t}\`: a matcher needs a \`hooks\` array`);return}let i=[];for(let m of o){if(m===null||typeof m!="object")continue;let c=m,p=typeof c.type=="string"?c.type:"command";if(p!=="command"){r.push(`\`${t}\`: only \`type: "command"\` is supported, got \`${p}\``);continue}if(typeof c.command!="string"||!c.command.trim()){r.push(`\`${t}\`: a hook needs a non-empty \`command\``);continue}let f=typeof c.timeout=="number"&&Number.isFinite(c.timeout)&&c.timeout>0?c.timeout:void 0;i.push({type:"command",command:c.command,timeout:f,...c.async===!0?{async:!0}:{},...c.once===!0?{once:!0}:{}})}return i.length?{matcher:typeof n.matcher=="string"?n.matcher:void 0,hooks:i}:void 0}function O1(e,t,r){let n=e.hooks[t];return n?n.filter(o=>{let i=o.matcher?.trim();if(!i||i==="*")return!0;if(r===void 0)return!1;let a=r.toLowerCase();return i.split("|").map(m=>m.trim().toLowerCase()).filter(Boolean).includes(a)}):[]}function NS(e,t,r={cwd:process.cwd()}){let n=r.timeoutS??qS;return new Promise(o=>{let i="",a="",m=!1,c=!1,p=k1(e,{cwd:r.cwd,shell:!0,stdio:["pipe","pipe","pipe"]});p.stdin?.on("error",()=>{}),p.stdout?.on("error",()=>{}),p.stderr?.on("error",()=>{});let f=setTimeout(()=>{m=!0,p.kill("SIGKILL")},n*1e3);p.stdout?.on("data",g=>{i+=g.toString("utf8")}),p.stderr?.on("data",g=>{a+=g.toString("utf8")});let d=g=>{c||(c=!0,clearTimeout(f),o({code:g,stdout:i,stderr:a,timedOut:m}))};p.on("error",g=>{a+=g.message,d(null)}),p.on("close",g=>d(g));try{p.stdin?.end(JSON.stringify(t))}catch{}})}function M1(e){let{code:t,stdout:r,stderr:n,timedOut:o}=e,i=n.trim();if(o)return{block:!1,error:`timed out after ${qS}s and was killed`};let a=v1(r),m=a?.hookSpecificOutput,c=typeof m?.additionalContext=="string"?m.additionalContext:typeof a?.additionalContext=="string"?a.additionalContext:void 0,p=typeof m?.permissionDecision=="string"?m.permissionDecision:void 0,f=typeof m?.permissionDecisionReason=="string"?m.permissionDecisionReason:void 0,d=m?.updatedInput,g=d!==null&&typeof d=="object"&&!Array.isArray(d)?d:void 0;return p==="deny"||p==="block"?{block:!0,reason:f||i||"denied by a hook",context:c}:p==="allow"?{block:!1,context:c,updatedInput:g}:t===2?{block:!0,reason:i||"blocked by a hook",context:c}:t!==0?{block:!1,context:c,updatedInput:g,error:`exited ${t===null?"without a status":t}${i?`: ${i}`:""}`}:!a&&r.trim()?{block:!1,context:r.trim()}:{block:!1,context:c,updatedInput:g}}function v1(e){let t=e.trim();if(t.startsWith("{"))try{let r=JSON.parse(t);return r&&typeof r=="object"&&!Array.isArray(r)?r:void 0}catch{return}}var Vc=new Set;function NPe(){Vc.clear()}async function qPe(e,t,r,n){let o=O1(e,t,r.tool_name);if(!o.length)return{outcome:{block:!1},ran:0};let i=[],a=0,m,c,p;for(let f of o)for(let d of f.hooks){if(d.once){let I=`${t}\0${d.command}`;if(Vc.has(I))continue;Vc.add(I)}if(a+=1,d.async){NS(d.command,r,{cwd:n.cwd,timeoutS:d.timeout}).catch(()=>{});continue}let g=await NS(d.command,r,{cwd:n.cwd,timeoutS:d.timeout}),y=M1(g);y.context&&i.push(y.context),y.error&&(c=y.error),y.updatedInput&&(p=y.updatedInput),y.block&&!m&&(m=y)}return m?{outcome:{block:!0,reason:m.reason,context:i.join(`
|
|
8
|
-
|
|
9
|
-
`)||void 0},ran:a}:{outcome:{block:!1,context:i.join(`
|
|
10
|
-
|
|
11
|
-
`)||void 0,error:c,updatedInput:p},ran:a}}import{existsSync as US,readFileSync as F1}from"node:fs";function L1(e){return`${e}/.howtocode/mcp.json`}function Jc(e,t){if(!US(e))return{};try{let n=JSON.parse(F1(e,"utf8"))?.mcpServers;return!n||typeof n!="object"||Array.isArray(n)?{}:n}catch(r){return t.push(`${e}: ${r instanceof Error?r.message:String(r)}`),{}}}function KPe(e){let t=[];return Jc(Gi(e??Ye),t)}function HPe(e){let t=[],r=Jc(Gi(e.agentDir??Ye),t),n=L1(e.cwd),o=e.projectTrusted&&US(n)?n:void 0,i=o?Jc(o,t):{},a=Gi(e.agentDir??Ye),m=new Map;for(let[c,p]of Object.entries(r))m.set(c,{name:c,config:p,source:a,scope:"global"});for(let[c,p]of Object.entries(i))m.set(c,{name:c,config:p,source:o,scope:"project"});return{servers:[...m.values()],errors:t,projectConfig:o}}import{mkdirSync as j1,readdirSync as D1,readFileSync as N1,renameSync as q1,unlinkSync as _S,writeFileSync as U1}from"node:fs";import{join as BS}from"node:path";var _1=180*1e3,JPe="presence";function GS(e,t){return BS(e.dir,`${t.replace(/[^A-Za-z0-9._-]/g,"_")}.json`)}function B1(e,t=Date.now()){let r;try{r=D1(e.dir)}catch{return[]}let n=[];for(let o of r){if(!o.endsWith(".json"))continue;let i=BS(e.dir,o),a;try{a=N1(i,"utf8")}catch{continue}let m;try{m=JSON.parse(a)}catch{Yc(i);continue}if(typeof m?.id!="string"||typeof m?.cwd!="string"||typeof m?.at!="number"){Yc(i);continue}if(t-m.at>=_1){Yc(i);continue}n.push({id:m.id,cwd:m.cwd,host:typeof m.host=="string"?m.host:"",pid:typeof m.pid=="number"?m.pid:0,at:m.at,...typeof m.activity=="string"&&m.activity?{activity:m.activity}:{}})}return n.sort((o,i)=>i.at-o.at)}function YPe(e,t){j1(e.dir,{recursive:!0});let r=GS(e,t.id),n=`${r}.${process.pid}.tmp`;U1(n,JSON.stringify(t,null,2)),q1(n,r)}function QPe(e,t){try{_S(GS(e,t))}catch{}}function KS(e,t,r,n=Date.now()){return B1(e,n).filter(o=>o.cwd===t&&o.id!==r)}function Yc(e){try{_S(e)}catch{}}import{Type as Ze}from"@netrodev/hxf-ai";import{defineTool as mm}from"@netrodev/hxf-coding-agent";import{relative as X1,join as Z1}from"node:path";import{mkdirSync as eL,writeFileSync as tL}from"node:fs";import{existsSync as eAe,mkdirSync as G1,readFileSync as K1,renameSync as H1,writeFileSync as z1}from"node:fs";import{dirname as W1,isAbsolute as V1,join as WS,relative as J1,resolve as HS,sep as zS}from"node:path";var Y1=1800*1e3,Q1=WS(".howtocode","claims.json");function VS(e){return WS(e,Q1)}function Xc(e,t){try{let r=K1(VS(e),"utf8"),n=JSON.parse(r);return(Array.isArray(n.claims)?[...n.claims]:[]).filter(i=>typeof i?.path=="string"&&typeof i?.holder=="string"&&typeof i?.at=="number"&&t-i.at<Y1)}catch{return[]}}function JS(e,t){let r=VS(e);G1(W1(r),{recursive:!0});let n=`${r}.${process.pid}.tmp`;z1(n,JSON.stringify({version:1,claims:[...t]},null,2)),H1(n,r)}function YS(e,t){return V1(t)?HS(t):HS(e,t)}function QS(e,t){if(e===t)return!0;let r=n=>n.endsWith(zS)?n:n+zS;return e.startsWith(r(t))||t.startsWith(r(e))}function XS(e){let t=e.now??Date.now(),r=Xc(e.root,t),n=[],o=[],i=[];for(let a of e.paths){if(!a.trim())continue;let m=YS(e.root,a.trim()),c=r.find(p=>p.holder!==e.holder&&QS(p.path,m));if(c){o.push({path:Qc(e.root,m),by:c.holder,reason:c.reason||"no reason given"});continue}n.push(Qc(e.root,m)),i.push({path:m,holder:e.holder,reason:e.reason,at:t})}if(i.length>0){let a=r.filter(m=>m.holder!==e.holder||!i.some(c=>c.path===m.path));JS(e.root,[...a,...i])}return{granted:n,conflicts:o}}function ZS(e,t,r){let n=Date.now(),o=Xc(e,n),i=r?.length?r.map(c=>YS(e,c.trim())).filter(Boolean):void 0,a=[],m=[];for(let c of o){let p=c.holder===t,f=i===void 0||i.some(d=>QS(c.path,d));p&&f?m.push(Qc(e,c.path)):a.push(c)}return JS(e,a),m}function Zc(e,t=Date.now()){return Xc(e,t)}function Qc(e,t){let r=J1(e,t);return r&&!r.startsWith("..")?r:t}var ep;function uAe(e){ep=e}var cAe=mm({name:"think",label:"think",description:"Private scratchpad. The text is not shown to the user. Use it before a non-obvious step.",promptSnippet:"think: private notes, not shown to the user",parameters:Ze.Object({thoughts:Ze.String({description:"Private notes"})}),async execute(){return{content:[{type:"text",text:"noted"}],details:{recorded:!0}}}}),pAe=mm({name:"ask",label:"ask",description:"Ask the user one question and wait for a selected answer. Use this instead of guessing when a choice blocks the task.",promptSnippet:"ask: ask the user to pick one option",parameters:Ze.Object({question:Ze.String(),options:Ze.Array(Ze.String(),{minItems:2})}),async execute(e,t){if(!ep)return{content:[{type:"text",text:"cancelled"}],details:{answer:"cancelled"}};let r=await ep(t.question,t.options);return{content:[{type:"text",text:r}],details:{answer:r}}}}),vi;function fAe(e){vi=e}var dAe=mm({name:"sessions",label:"sessions",description:"See the other HowToCode sessions working in this workspace, what they hold, and what they are doing. Use it to find who is blocking a claim, or to tell another session to release a file. Send a message with message + to.",promptSnippet:"sessions: other CLI sessions, and who holds what",parameters:Ze.Object({message:Ze.Optional(Ze.String({description:"Message text to leave for another session."})),to:Ze.Optional(Ze.String({description:"Session id to send the message to. Use `all` for every other session."}))}),async execute(e,t){let r=vi,n=r?.presenceDir?.();if(!r||!n)return{content:[{type:"text",text:"the session registry is unavailable here"}],details:{}};let o=r.selfId?.()??"",i=r.root(),a=KS({dir:n},i);if(t.message&&t.message.trim()){let c=t.to?.trim()||"all",p=a.filter(f=>f.id!==o&&(c==="all"||f.id===c));if(p.length===0)return{content:[{type:"text",text:"no other session in this workspace to message"}],details:{sent:0}};for(let f of p){let d=Z1(n,`${f.id.replace(/[^A-Za-z0-9._-]/g,"_")}.inbox`);try{eL(n,{recursive:!0}),tL(d,`${JSON.stringify({from:o,at:Date.now(),text:t.message.trim()})}
|
|
12
|
-
`,{flag:"a"})}catch{}}return{content:[{type:"text",text:`left a message for ${p.map(f=>f.id).join(", ")}`}],details:{sent:p.length}}}if(a.length===0)return{content:[{type:"text",text:"no other session in this workspace"}],details:{sessions:[]}};let m=a.map(c=>{let p=c.id===o?"this session":c.id,f=Zc(i).filter(y=>y.holder===`session:${c.id}`),d=c.activity?` \u2014 ${c.activity}`:"",g=f.length>0?`
|
|
13
|
-
holds:
|
|
14
|
-
${f.map(y=>` ${tk(i,y.path)} \u2014 ${y.reason}`).join(`
|
|
15
|
-
`)}`:"";return` ${p} (pid ${c.pid}${c.id===o?"":`, seen ${Math.round((Date.now()-c.at)/1e3)}s ago`})${d}${g}`});return{content:[{type:"text",text:`sessions in ${i}:
|
|
16
|
-
${m.join(`
|
|
17
|
-
`)}`}],details:{sessions:a}}}});function rL(e){let t=[];if(e.granted.length>0&&t.push(`claimed: ${e.granted.join(", ")}`),e.conflicts.length>0){t.push(""),t.push("refused \u2014 another agent is working on these:");for(let r of e.conflicts)t.push(` ${r.path} \u2014 held by ${r.by}: ${r.reason}`);t.push(""),t.push("Wait for the holder to release it, or work on something else. Do not edit a refused path.")}return t.length===0&&t.push("nothing to claim"),{text:t.join(`
|
|
18
|
-
`),isError:e.conflicts.length>0}}var ek=mm({name:"claim",label:"claim",description:"Claim files or directories before editing them, so a parallel agent cannot overwrite your work. Refused paths are held by someone else \u2014 do not edit them. Pass no paths to list every claim in this workspace.",promptSnippet:"claim: reserve files before editing",parameters:Ze.Object({paths:Ze.Optional(Ze.Array(Ze.String(),{description:"Files or directories to claim. Omit to list the current claims."})),reason:Ze.Optional(Ze.String({description:"Why you are taking them, shown to a refused agent."})),release:Ze.Optional(Ze.Boolean({description:"Release these paths instead of claiming them. Omit paths to release everything you hold."}))}),async execute(e,t){if(!vi)return{content:[{type:"text",text:"claims are unavailable in this session"}],details:{},isError:!0};let r=vi.root(),n=vi.holder();if(t.release){let m=ZS(r,n,t.paths);return{content:[{type:"text",text:m.length>0?`released: ${m.join(", ")}`:"you held nothing matching that"}],details:{released:m}}}if(!t.paths||t.paths.length===0){let m=Zc(r);return m.length===0?{content:[{type:"text",text:"no active claims in this workspace"}],details:{claims:[]}}:{content:[{type:"text",text:m.map(p=>`${p.holder===n?"(you) ":""}${tk(r,p.path)} \u2014 ${p.reason}`).join(`
|
|
19
|
-
`)}],details:{claims:m}}}let o=XS({root:r,holder:n,reason:t.reason??"no reason given",paths:t.paths}),{text:i,isError:a}=rL(o);return{content:[{type:"text",text:i}],isError:a,details:o}}});function tk(e,t){let r=X1(e,t);return r&&!r.startsWith("..")?r:t}import{StringEnum as nL}from"@netrodev/hxf-ai";import{defineTool as oL}from"@netrodev/hxf-coding-agent";var v={};At(v,{Any:()=>Qn,Array:()=>yt,BigInt:()=>oi,Boolean:()=>ta,Call:()=>YI,Capitalize:()=>nb,Codec:()=>Zs,Conditional:()=>pb,Constructor:()=>pr,ConstructorParameters:()=>db,Cyclic:()=>lr,Decode:()=>tg,DecodeBuilder:()=>ri,Dependent:()=>$n,Encode:()=>rg,EncodeBuilder:()=>ti,Enum:()=>Zl,Evaluate:()=>He,Exclude:()=>gb,Extends:()=>rt,ExtendsResult:()=>F,Extract:()=>xb,Function:()=>fr,Generic:()=>Yr,Identifier:()=>ii,Immutable:()=>ng,Index:()=>$b,Infer:()=>ei,InstanceType:()=>Hb,Instantiate:()=>jt,Integer:()=>Sn,Interface:()=>OI,Intersect:()=>ot,IsAny:()=>Ie,IsArray:()=>W,IsBigInt:()=>kt,IsBoolean:()=>ft,IsCall:()=>lo,IsCodec:()=>pt,IsConstructor:()=>Ee,IsCyclic:()=>me,IsDependent:()=>ke,IsEnum:()=>Te,IsEnumValue:()=>Xl,IsFunction:()=>Se,IsGeneric:()=>Yn,IsIdentifier:()=>ag,IsImmutable:()=>En,IsInfer:()=>Le,IsInteger:()=>Ke,IsIntersect:()=>O,IsKind:()=>w,IsLiteral:()=>H,IsNever:()=>xt,IsNull:()=>yr,IsNumber:()=>xe,IsObject:()=>A,IsOptional:()=>ve,IsParameter:()=>cg,IsReadonly:()=>Or,IsRecord:()=>ne,IsRef:()=>te,IsRefine:()=>ni,IsRest:()=>tn,IsSchema:()=>ye,IsString:()=>qe,IsSymbol:()=>xr,IsTemplateLiteral:()=>ue,IsThis:()=>ga,IsTuple:()=>q,IsUndefined:()=>Kt,IsUnion:()=>S,IsUnknown:()=>Fe,IsUnsafe:()=>Xs,IsVoid:()=>wt,KeyOf:()=>Wb,Literal:()=>G,Lowercase:()=>ob,Mapped:()=>t$,Module:()=>K$,Never:()=>ie,NonNullable:()=>i$,Null:()=>Zn,Number:()=>Tt,Object:()=>M,Omit:()=>a$,Optional:()=>Hl,Parameter:()=>kn,Parameters:()=>c$,Partial:()=>f$,Pick:()=>I$,Readonly:()=>og,ReadonlyObject:()=>jc,ReadonlyType:()=>E$,Record:()=>io,RecordKey:()=>so,RecordPattern:()=>je,RecordValue:()=>pe,Ref:()=>Be,Refine:()=>ig,Required:()=>N$,Rest:()=>wn,ReturnType:()=>U$,Script:()=>V$,String:()=>tt,Symbol:()=>eo,TemplateLiteral:()=>Yh,This:()=>la,Tuple:()=>we,Uncapitalize:()=>ib,Undefined:()=>ao,Union:()=>j,Unknown:()=>Ne,Unsafe:()=>Vl,Uppercase:()=>sb,Void:()=>ya,With:()=>em});var iL={pending:"[ ]",in_progress:"[>]",completed:"[x]",dropped:"[-]"},sL=v.Object({op:nL(["init","start","done","drop","view"],{description:"init replaces the list; start/done/drop move one task; view reads it"}),items:v.Optional(v.Array(v.String(),{description:"Task labels for init. 5-10 words each, specific enough to execute without re-planning"})),task:v.Optional(v.String({description:"Exact label of the task to start, complete or drop"}))});function rk(e){if(e.length===0)return"Todo list is empty.";let t=e.filter(o=>o.status==="completed").length,r=e.map(o=>`${iL[o.status]} ${o.content}`),n=e.filter(o=>o.status==="pending"||o.status==="in_progress").length;return[`${t}/${e.length} done, ${n} open`,...r].join(`
|
|
20
|
-
`)}function aL(e,t,r,n){let o=e.map(i=>({...i}));switch(t){case"init":return!r||r.length===0?{todos:o,error:"init needs a non-empty items array"}:{todos:r.map(i=>({content:i,status:"pending"}))};case"view":return{todos:o};case"start":case"done":case"drop":{if(!n)return{todos:o,error:`${t} needs task`};let i=o.find(a=>a.content===n);if(!i)return{todos:o,error:`no task matches ${JSON.stringify(n)}`};if(t==="start"){for(let a of o)a.status==="in_progress"&&(a.status="pending");i.status="in_progress"}else i.status=t==="done"?"completed":"dropped";return{todos:o}}default:return{todos:o,error:`unknown op ${JSON.stringify(t)}`}}}function mL(e){let t=[];for(let r of e.sessionManager.getBranch()){if(r.type!=="message")continue;let n=r.message;if(n.role!=="toolResult"||n.toolName!=="todo")continue;let o=n.details;o?.todos&&(t=o.todos)}return t}var nk=oL({name:"todo",label:"todo",description:"Track the plan for this task. Use `init` once with the whole plan (investigation through verification), then `start`/`done` as you go. Keep the list current so progress stays visible; do not re-init unless the plan materially changes.",promptSnippet:"todo: record and advance the plan for the current task",parameters:sL,async execute(e,t,r,n,o){let i=mL(o),{todos:a,error:m}=aL(i,t.op,t.items,t.task),c={op:t.op,todos:a,...m?{error:m}:{}};return{content:[{type:"text",text:m?`Error: ${m}
|
|
21
|
-
${rk(a)}`:rk(a)}],details:c,...m?{isError:!0}:{}}}});import{StringEnum as uL}from"@netrodev/hxf-ai";import{defineTool as cL}from"@netrodev/hxf-coding-agent";var kr=new Map,ok=2e3,ik=80;function _Oe(){kr.clear()}function sk(){return kr.size===0?"":["<shared-notes>","Working notes recorded with the `context` tool. They survive compaction and are visible to every agent on this task.",...[...kr].map(([t,r])=>`- ${t}: ${r}`),"</shared-notes>"].join(`
|
|
22
|
-
`)}function pL(e,t,r){if(e==="list")return kr.size===0?{text:"No notes."}:{text:[...kr].map(([n,o])=>`${n} = ${o}`).join(`
|
|
23
|
-
`)};if(!t)return{text:"Error: key is required",error:"key required"};if(t.length>ik)return{text:`Error: key longer than ${ik} characters`,error:"key too long"};if(e==="forget")return{text:kr.delete(t)?`Removed ${t}`:`No note named ${t}`};if(e==="set"){if(!r)return{text:"Error: value is required for set",error:"value required"};let n=r.length>ok?`${r.slice(0,ok)}\u2026`:r;return kr.set(t,n),{text:`Recorded ${t} (${kr.size} note${kr.size===1?"":"s"} held)`}}return{text:`Error: unknown op ${JSON.stringify(e)}`,error:"unknown op"}}var ak=cL({name:"context",label:"context",description:"Record a durable working note (a decision, a file's role, a fact you would otherwise re-derive). Notes survive context compaction and are visible to every agent on this task, including subagents. Use `set` to write, `list` to read, `forget` to remove.",promptSnippet:"context: durable notes shared with every agent on this task",parameters:v.Object({op:uL(["set","list","forget"],{description:"set writes a note, list reads all, forget removes one"}),key:v.Optional(v.String({description:"Short lookup key, e.g. 'auth-entrypoint'"})),value:v.Optional(v.String({description:"The fact to keep (for set)"}))}),async execute(e,t){let{text:r,error:n}=pL(t.op,t.key,t.value);return{content:[{type:"text",text:r}],details:{op:t.op,notes:Object.fromEntries(kr)},...n?{isError:!0}:{}}}});import{StringEnum as fL}from"@netrodev/hxf-ai";import{defineTool as dL}from"@netrodev/hxf-coding-agent";var mk="howtocode.goal",zOe="howtocode.goal.continue",uk=400,um=25,ck={active:"\u25CF",paused:"\u2016",done:"\u2713",cleared:"\u25CB"};function lL(e){if(!e||e.status==="cleared")return"No goal set.";let t=e.budget??um,r=[`${ck[e.status]} ${e.status}`,`${e.used}/${t} continuations`];return e.note&&r.push(e.note),`${r.join(" \xB7 ")}
|
|
24
|
-
${e.text}`}function WOe(e){if(!e||e.status==="cleared"||e.status==="done")return"";let t=e.budget??um,r=e.text.length>48?`${e.text.slice(0,47)}\u2026`:e.text;return`goal ${ck[e.status]} ${e.used}/${t} \xB7 ${r}`}function VOe(e){let t=["<goal>",e.text,`Status: ${e.status}.`];return e.status==="active"&&t.push("Work toward this goal until it is genuinely met. When it is, call the `goal` tool with",'op="complete" and a note naming the evidence; a command you ran or a file you checked.',"If you are blocked and cannot proceed, say so plainly instead of repeating an attempt."),t.push("</goal>"),t.join(`
|
|
25
|
-
`)}function JOe(e){return["[goal] The goal is still open and you stopped without closing it:",` ${e.text}`,"","Continue from where you left off. Do not repeat work you already did. If the goal is met,",'call the `goal` tool with op="complete" and a note naming the evidence. Do not call it',"complete to escape a hard problem: if you cannot make progress, state what is blocking you.",`Continuations used: ${e.used}/${e.budget??um}.`].join(`
|
|
26
|
-
`)}var pk;function YOe(){return pk}function gL(e){pk=e}function QOe(e){if(!e)return{action:"stop",reason:"no goal",close:!1};if(e.status==="done")return{action:"stop",reason:"goal complete",close:!1};if(e.status==="cleared")return{action:"stop",reason:"goal cleared",close:!1};if(e.status==="paused")return{action:"stop",reason:"goal paused",close:!1};let t=e.budget??um;return e.used>=t?{action:"stop",reason:`budget exhausted (${t} continuations)`,close:!0}:{action:"continue"}}function yL(e,t,r,n,o){switch(t){case"view":return{goal:e};case"set":return r?.trim()?r.length>uk?{goal:e,error:`text longer than ${uk} characters`}:n!==void 0&&(!Number.isInteger(n)||n<1)?{goal:e,error:"budget must be a positive integer"}:{goal:{text:r.trim(),status:"active",used:0,...n===void 0?{}:{budget:n}}}:{goal:e,error:"set needs text"};case"pause":case"resume":case"complete":case"clear":return!e||e.status==="cleared"?{goal:e,error:"no goal to change"}:t==="resume"?e.status==="done"?{goal:e,error:"goal is complete; set a new one instead"}:{goal:{...e,status:"active",note:void 0}}:t==="pause"?{goal:{...e,status:"paused"}}:t==="clear"?{goal:{...e,status:"cleared"}}:o?.trim()?{goal:{...e,status:"done",note:o.trim()}}:{goal:e,error:"complete needs a note naming the evidence (a command you ran or a file you checked)"};default:return{goal:e,error:`unknown op ${JSON.stringify(t)}`}}}function xL(e){let t;for(let r of e.sessionManager.getBranch()){if(r.type==="custom"&&r.customType===mk){t=r.data;continue}if(r.type==="custom_message"&&r.customType===mk){t=r.details??t;continue}if(r.type!=="message")continue;let n=r.message;if(n.role!=="toolResult"||n.toolName!=="goal")continue;let o=n.details;o?.goal&&(t=o.goal)}return t}var hL=v.Object({op:fL(["set","view","pause","resume","complete","clear"],{description:"set starts a goal; complete closes it with evidence; pause/resume/clear manage it; view reads it"}),text:v.Optional(v.String({description:"The goal, in one sentence, as the user would state it (for set)"})),budget:v.Optional(v.Number({description:"Optional cap on automatic continuations before the run stops"})),note:v.Optional(v.String({description:"Evidence that the goal is met (required for complete)"}))}),XOe=dL({name:"goal",label:"goal",description:"Track the goal for this session. The goal is already shown in your context every request, so you rarely need `view`. Call `complete` only when the goal is genuinely met, and pass a note naming the evidence. When a goal is active the harness continues the run if you stop without closing it, so closing it is how you stop.",promptSnippet:"goal: the session's objective, and how to close it",parameters:hL,async execute(e,t,r,n,o){let i=xL(o),{goal:a,error:m}=yL(i,t.op,t.text,t.budget,t.note);gL(a);let c=lL(a);return{content:[{type:"text",text:m?`Error: ${m}
|
|
27
|
-
${c}`:c}],details:{op:t.op,goal:a},...m?{isError:!0}:{}}}});import{existsSync as np,mkdirSync as fk,readFileSync as dk}from"node:fs";import{dirname as lk,join as gk}from"node:path";import{defineTool as yk}from"@netrodev/hxf-coding-agent";function cm(){return{state:"inactive",wasActive:!1}}function IL(e){return e?e.state==="pending"?{...e,state:"inactive"}:{...e}:cm()}function iMe(e){return e.state!=="inactive"?e:{...e,state:"pending"}}function bL(e){return e.state!=="pending"?e:{state:"active",wasActive:!0}}function $L(e){return e.state!=="inactive"?e:{state:"active",wasActive:!0}}function EL(e){return e.state!=="active"?e:{...e,state:"inactive"}}function sMe(e){return e.state==="inactive"?e:{...e,state:"inactive"}}function pm(e){return e.state==="active"}function SL(e,t){return e===t}function kL(e,t){return["<plan-mode>","Plan mode is active. Do not make any edits or writes to the system.",t?`A plan file exists at ${e}. Read it and refine it with the \`edit\` tool.`:`No plan is written yet. Write yours to ${e} with the \`write\` tool.`,"That file is the only path you may edit.","Explore first: read, search, and run read-only commands until the approach is clear.","End your turn with either `ask` to clarify a requirement, or `exit_plan_mode` to present","the plan for approval. Do not start implementing before the plan is approved.","</plan-mode>"].join(`
|
|
28
|
-
`)}function TL(e){return`Rejected: file edits are not allowed in plan mode. The only editable file is the plan file (${e}). Present the plan with exit_plan_mode first.`}var st,at=cm(),rp;function aMe(){return at}function mMe(){return st}function uMe(){return pm(at)}function xk(){if(!(!st||!np(st)))try{let e=dk(st,"utf8");return e.trim()?e:void 0}catch{return}}function hk(){return xk()!==void 0}function cMe(){return at.state==="inactive"?"":at.state==="pending"?"plan pending":hk()?"plan \u25CF ready":"plan \u25CF planning"}function Ik(){return rp?gk(rp,"plan_mode.json"):void 0}function wL(){let e=Ik();if(e)try{fk(lk(e),{recursive:!0}),sr(e,JSON.stringify(at))}catch{}}function CL(){let e=Ik();if(!e||!np(e))return cm();try{return IL(JSON.parse(dk(e,"utf8")))}catch{return cm()}}function RL(e){rp=e,st=gk(e,"plan.md"),at=CL()}function op(e){return at=e,wL(),at}function pMe(){return e=>{e.on("tool_call",async t=>{if(!pm(at)||t.toolName!=="edit"&&t.toolName!=="write")return;let r=t.input?.path;if(typeof r=="string"&&!(!st||SL(r,st)))return{block:!0,reason:TL(st)}})}}function fMe(){return e=>{e.on("session_start",async(t,r)=>{RL(r.sessionManager.getSessionDir())}),e.on("before_agent_start",async()=>{at.state==="pending"&&op(bL(at))}),e.on("context_with_system",async t=>{if(!pm(at)||!st)return;let r=t.messages[0];if(!r||r.role!=="system")return;let n=kL(st,hk()),o=`${typeof r.content=="string"?r.content:""}
|
|
29
|
-
|
|
30
|
-
${n}`;return{messages:t.messages.map(a=>a===r?{...r,content:o}:a)}})}}var tp=2e4;function PL(){if(st){try{fk(lk(st),{recursive:!0}),np(st)||sr(st,"")}catch{return}return st}}var dMe=yk({name:"enter_plan_mode",label:"enter_plan_mode",description:"Enter plan mode to design an approach before writing code. Use it when a task has genuine ambiguity; several reasonable designs, or a restructuring where the wrong approach wastes significant effort. Do not use it for a clear fix, a rename, or a task that follows existing conventions. The user must approve entering.",promptSnippet:"enter_plan_mode: design first when the approach is genuinely ambiguous",parameters:v.Object({}),async execute(e,t,r,n,o){if(at.state!=="inactive")return{content:[{type:"text",text:`Plan mode is already ${at.state}.`}],details:{}};if(!o.hasUI)return{content:[{type:"text",text:"Plan mode needs an interactive session: there is no one to approve the plan. Proceed normally."}],details:{},isError:!0};if(!await o.ui.confirm("Enter plan mode?","The agent will explore and design an approach before editing anything."))return{content:[{type:"text",text:"The user declined plan mode. Proceed normally."}],details:{}};op($L(at));let a=PL();return{content:[{type:"text",text:["Plan mode is active. Edits are blocked except for the plan file.",a?`Write your plan to ${a}.`:"Write your plan to the session plan file."].join(`
|
|
31
|
-
`)}],details:{planFile:a}}}}),lMe=yk({name:"exit_plan_mode",label:"exit_plan_mode",description:"Present your plan for approval when you have finished planning. The plan is read from the plan file on disk, so write the file first. If the user asks for changes, stay in plan mode and revise it.",promptSnippet:"exit_plan_mode: present the written plan for approval",parameters:v.Object({}),executionMode:"sequential",async execute(e,t,r,n,o){if(!pm(at))return{content:[{type:"text",text:"Plan mode is not active."}],details:{},isError:!0};let i=xk();if(!i)return{content:[{type:"text",text:`No plan has been written yet. Write it to ${st??"the plan file"} before exiting plan mode.`}],details:{},isError:!0};if(!o.hasUI)return{content:[{type:"text",text:"Plan approval needs an interactive session."}],details:{},isError:!0};let a=i.length>tp?`${i.slice(0,tp)}
|
|
32
|
-
\u2026 (${i.length-tp} more characters)`:i;return await o.ui.confirm("Approve this plan?",a)?(op(EL(at)),{content:[{type:"text",text:"Plan approved. You may now implement it."}],details:{approved:!0,planFile:st}}):{content:[{type:"text",text:"The user did not approve the plan. Stay in plan mode, revise the plan file with the feedback, and present it again."}],details:{approved:!1}}}});function Eo(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>{let r=t;return r.type==="text"&&typeof r.text=="string"?r.text:""}).join(`
|
|
33
|
-
`):e==null?"":String(e)}function fm(e,t){if(Array.isArray(e)){let r=e.map(o=>({...o})),n=r.filter(o=>o.type==="text");if(n.length>0){n[0].text=t;for(let o of n.slice(1))o.text="";return r}return[...r,{type:"text",text:t}]}return t}function bk(){return e=>{e.on("context_with_system",async t=>{let r=sk();if(!r)return;let n=t.messages[0];if(!n||n.role!=="system")return;let o=`${Eo(n.content)}
|
|
34
|
-
|
|
35
|
-
${r}`;return{messages:t.messages.map(a=>a===n?{...n,content:fm(n.content,o)}:a)}})}}import{Type as vn}from"@netrodev/hxf-ai";import{defineTool as AL}from"@netrodev/hxf-coding-agent";var So="[Compressed conversation section]";function Fi(e){return Math.round(e.length/4)}function ip(e){let t=e.prune.messages.nextBlockId;return!Number.isInteger(t)||t<1?(e.prune.messages.nextBlockId=2,1):(e.prune.messages.nextBlockId=t+1,t)}function sp(e){let t=e.prune.messages.nextRunId;return!Number.isInteger(t)||t<1?(e.prune.messages.nextRunId=2,1):(e.prune.messages.nextRunId=t+1,t)}function ap(e,t,r="xml"){let n=Mo(Nn(e,r),void 0,r),o=t.trim();return o.length===0?`${So}
|
|
36
|
-
${n}`:`${So}
|
|
37
|
-
${o}
|
|
38
|
-
|
|
39
|
-
${n}`}function Lr(e){return e.prune.messages.blocks.filter(t=>t.active).map(t=>({blockId:t.blockId,anchorIndex:t.anchorIndex,coveredIndices:t.coveredIndices,summary:t.summary}))}function mp(e,t,r,n,o,i,a){let m=e.prune.messages,c=[...new Set(a.filter(E=>Number.isInteger(E)&&E>0))],p=new Set;for(let E of m.blocks)if(E.active)for(let b of E.coveredIndices)p.add(b);let f=new Set(r.indices);for(let E of c){let b=m.blocks.find(C=>C.blockId===E);if(b)for(let C of b.coveredIndices)f.add(C)}let d=[...f].sort((E,b)=>E-b),g=d.filter(E=>!p.has(E)),y=0;for(let E of g)y+=r.tokenByIndex.get(E)??0;let I={blockId:o,runId:t.runId,active:!0,deactivatedByUser:!1,mode:t.mode,topic:t.topic,startId:t.startId,endId:t.endId,anchorIndex:n,compressedTokens:y,summaryTokens:Fi(i),coveredIndices:d,consumedBlockIds:c,parentBlockIds:[],createdAt:Date.now(),summary:i};m.blocks.push(I);let h=Date.now();for(let E of c){let b=m.blocks.find(C=>C.blockId===E);!b||!b.active||(b.active=!1,b.deactivatedAt=h,b.deactivatedByBlockId=o,b.parentBlockIds.includes(o)||b.parentBlockIds.push(o))}return e.stats.totalCompressTokens+=y,{compressedTokens:y,coveredIndices:d,newlyCoveredIndices:g}}function Ek(e,t="xml"){let r=[],n=t==="compact"?/@b([1-9]\d*)@/gi:/\(b(\d+)\)/gi,o;for(;(o=n.exec(e))!==null;){let i=Number.parseInt(o[1],10);Number.isInteger(i)&&r.push({raw:o[0],blockId:i,startIndex:o.index,endIndex:o.index+o[0].length})}return r}function Sk(e){if(typeof e.topic!="string"||e.topic.trim().length===0)throw new Error("topic is required and must be a non-empty string");if(!Array.isArray(e.content)||e.content.length===0)throw new Error("content is required and must be a non-empty array");for(let t=0;t<e.content.length;t++){let r=e.content[t],n=`content[${t}]`;if(typeof r?.startId!="string"||r.startId.trim().length===0)throw new Error(`${n}.startId is required and must be a non-empty string`);if(typeof r?.endId!="string"||r.endId.trim().length===0)throw new Error(`${n}.endId is required and must be a non-empty string`);if(typeof r?.summary!="string"||r.summary.trim().length===0)throw new Error(`${n}.summary is required and must be a non-empty string`)}}function up(e,t,r,n){let o=new Set,i=new Map;for(let d of r)o.add(d.index),i.set(d.index,d.tokenCount??0);let a=$k(e,o,t.startId,"startId",n),m=$k(e,o,t.endId,"endId",n);if(a.index>m.index)throw new Error(`startId ${a.ref} appears after endId ${m.ref} in the conversation. Start must come before end.`);let c=[];for(let d of r)d.index>=a.index&&d.index<=m.index&&c.push(d.index);let p=new Set(c),f=e.prune.messages.blocks.filter(d=>d.active&&p.has(d.anchorIndex)).map(d=>d.blockId);return{startIdx:a.index,endIdx:m.index,indices:c,requiredBlockIds:f,tokenByIndex:i}}function $k(e,t,r,n,o){let i=qm(r,o);if(i===null){let m=o==="compact"?"@4@":"mNNNN",c=o==="compact"?"@b1@":"bN";throw new Error(`${n} is invalid. Use an injected message ID (${m}) or block ID (${c}).`)}let a;if(i.kind==="message")a=i.index;else{let m=e.prune.messages.blocks.find(c=>c.blockId===i.blockId&&c.active);a=m?m.anchorIndex:-1}if(a<0||!t.has(a))throw new Error(`${n} ${i.ref} is not available in the current conversation context. Choose an injected ID visible in context.`);return{ref:i.ref,index:a}}function kk(e,t,r,n="xml"){let i=[...e.map((m,c)=>{let p={startId:m.startId.trim(),endId:m.endId.trim(),summary:m.summary};return{index:c,entry:p,selection:up(t,p,r,n)}})].sort((m,c)=>m.selection.startIdx-c.selection.startIdx||m.selection.endIdx-c.selection.endIdx||m.index-c.index),a=[];for(let m=1;m<i.length;m++){let c=i[m-1],p=i[m];!c||!p||p.selection.startIdx>c.selection.endIdx||a.push(`content[${c.index}] (${c.entry.startId}..${c.entry.endId}) overlaps content[${p.index}] (${p.entry.startId}..${p.entry.endId}). Overlapping ranges cannot be compressed in the same batch.`)}if(a.length>0)throw new Error(a.length===1?a[0]:a.map(m=>`- ${m}`).join(`
|
|
40
|
-
`))}function Tk(e,t,r,n="xml"){let o=new Set(t.prune.messages.blocks.filter(i=>i.active).map(i=>i.blockId));return e.map((i,a)=>{let m={startId:i.startId.trim(),endId:i.endId.trim(),summary:i.summary},c=up(t,m,r,n),p=new Set(c.requiredBlockIds),f=Ek(m.summary,n),d=new Set,g=`content[${a}]`;for(let y of f){if(d.has(y.blockId))throw new Error(`${g}.summary duplicates placeholder ${y.raw}`);if(d.add(y.blockId),!p.has(y.blockId))throw new Error(o.has(y.blockId)?`${g}.summary references ${y.raw}, which is outside the selected range`:`${g}.summary references ${y.raw}, which is not an active compressed block`)}for(let y of c.requiredBlockIds)if(!d.has(y)){let I=n==="compact"?`@b${y}@`:`(b${y})`;throw new Error(`${g}.summary is missing the required placeholder ${I}`)}return f})}function wk(e,t,r,n="xml"){return e.map((o,i)=>{let a={startId:o.startId.trim(),endId:o.endId.trim(),summary:o.summary},m=up(t,a,r,n);return{index:i,entry:a,selection:m,anchorIndex:m.startIdx}})}function OL(e){let t=e.match(/^\s*\[Compressed conversation(?: section)?(?: b\d+)?\]/i);return t?e.slice(t[0].length).replace(/^(?:\r?\n)+/,"").replace(/(?:\r?\n)*<dcp-message-id>b\d+<\/dcp-message-id>\s*$/i,"").replace(/(?:\r?\n)*@b[1-9]\d*@\s*$/i,"").replace(/(?:\r?\n)+$/,""):e}function ML(e,t,r){if(t.length===0)return{expanded:e,consumedBlockIds:[]};let n="",o=0,i=[];for(let a of t){let m=r.prune.messages.blocks.find(c=>c.blockId===a.blockId&&c.active);if(!m)throw new Error(`Compressed block not found: ${a.raw}`);n+=e.slice(o,a.startIndex),n+=OL(m.summary),o=a.endIndex,i.push(a.blockId)}return n+=e.slice(o),{expanded:n,consumedBlockIds:i}}function Ck(e,t,r,n="xml"){Sk(e),kk(e.content,t,r,n);let o=Tk(e.content,t,r,n),i=wk(e.content,t,r,n),a=sp(t),m=[];for(let[c,p]of i.entries()){let f=o[c]??[],{expanded:d,consumedBlockIds:g}=ML(p.entry.summary,f,t),y=ip(t),I=ap(y,d,n),h=mp(t,{topic:e.topic,startId:p.entry.startId,endId:p.entry.endId,mode:"range",runId:a},p.selection,p.anchorIndex,y,I,g);m.push({blockId:y,runId:a,coveredCount:h.coveredIndices.length,compressedTokens:h.compressedTokens,summaryTokens:Fi(I),expandedSummary:d})}return m}function vL(e){let t=e.format??"xml",r=Dn(1,t),n=Nn(2,t);return AL({name:"compress",label:"compress",description:`Collapse conversation ranges into stored compressed summaries, each marked with "${So}". Copy startId and endId from the injected IDs in context (message IDs like ${r}, block IDs like ${n}); startId must come before endId. Ranges in one call must not overlap, and each summary must reference every required block placeholder exactly once.`,promptSnippet:"compress: replace a conversation range with a stored summary",parameters:vn.Object({topic:vn.String({description:"Short label (3-5 words) for display - e.g., 'Auth System Exploration'"}),content:vn.Array(vn.Object({startId:vn.String({description:`Message or block ID marking the beginning of range (e.g. ${r}, ${n})`}),endId:vn.String({description:`Message or block ID marking the end of range (e.g. ${Dn(12,t)}, ${Nn(5,t)})`}),summary:vn.String({description:"Complete technical summary replacing all content in range"})}),{description:"One or more ranges to compress, each with start/end boundaries and a summary"})}),async execute(o,i){try{let a=Ck(i,e.state(),e.messages(),t),m=a.map(g=>g.blockId),c=a.reduce((g,y)=>g+y.coveredCount,0),p=a.reduce((g,y)=>g+y.compressedTokens,0),f=a.reduce((g,y)=>g+y.summaryTokens,0),d=Math.max(0,p-f);return{content:[{type:"text",text:`Compressed ${c} messages into ${So}`+(p>0?` - ${p} tokens replaced by ${f}, saving ${d}.`:".")}],details:{blockIds:m,runId:a[0]?.runId,messages:c,compressedTokens:p,summaryTokens:f}}}catch(a){let m=a instanceof Error?a.message:String(a);return{content:[{type:"text",text:m}],details:{error:m},isError:!0}}}})}import{existsSync as Rk,mkdirSync as FL,readFileSync as Pk,unlinkSync as LL}from"node:fs";import{dirname as jL,join as Ak}from"node:path";function cp(e){try{let t=Ak(e,".howtocode","dcp.json");if(!Rk(t))return;let r=JSON.parse(Pk(t,"utf8"));if(typeof r!="object"||r===null)return;let n=r.enabled;return typeof n=="boolean"?n:void 0}catch{return}}function pp(e){if(e.env!==void 0){let t=e.env.trim().toLowerCase();return{enabled:t!=="0"&&t!=="false",source:"env"}}return e.config!==void 0?{enabled:e.config,source:"config"}:e.runtime!==void 0?{enabled:e.runtime,source:"session"}:{enabled:!0,source:"default"}}function Ok(){return{messageIds:Nm(),prune:{tools:{},messages:{blocks:[],nextBlockId:1,nextRunId:1}},stats:{totalPruneTokens:0,totalCompressTokens:0}}}function lm(e){let t=e.replace(/[^A-Za-z0-9._-]/g,"_")||"session";return Ak(Ye,"dcp",`${t}.json`)}function DL(e){if(typeof e!="object"||e===null)return!1;let t=e,r=t.prune?.messages,n=t.messageIds;return typeof t.prune=="object"&&t.prune!==null&&typeof t.prune.tools=="object"&&t.prune.tools!==null&&typeof r=="object"&&r!==null&&Array.isArray(r.blocks)&&Number.isInteger(r.nextBlockId)&&Number.isInteger(r.nextRunId)&&typeof n=="object"&&n!==null&&Number.isInteger(n.nextRef)&&typeof n.keyToRef=="object"&&n.keyToRef!==null&&typeof n.refToKey=="object"&&n.refToKey!==null&&typeof t.stats=="object"&&t.stats!==null&&Number.isFinite(t.stats.totalPruneTokens)&&Number.isFinite(t.stats.totalCompressTokens)}var dm=new Map;function Li(e){let t=dm.get(e);if(t)return t;let r;try{let o=lm(e);if(Rk(o)){let i=JSON.parse(Pk(o,"utf8"));DL(i)&&(r=i)}}catch{r=void 0}let n=r??Ok();return dm.set(e,n),n}function un(e){let t=dm.get(e);if(!t)return;let r=lm(e);FL(jL(r),{recursive:!0}),sr(r,JSON.stringify(t))}function NL(e){dm.delete(e);try{LL(lm(e))}catch{}}function rr(e){return e.replaceAll("\\","/")}function qL(e){return/[\\.^$+{}()|\[\]]/.test(e)?`\\${e}`:e}function fp(e,t){if(!t)return!1;let r=rr(e),n=rr(t),o="^";for(let i=0;i<n.length;i++){let a=n[i];if(a==="*"){if(n[i+1]==="*"){if(n[i+2]==="/"){o+="(?:.*/)?",i+=2;continue}o+=".*",i++;continue}o+="[^/]*";continue}if(a==="?"){o+="[^/]";continue}if(a==="/"){o+="/";continue}o+=qL(a)}return o+="$",new RegExp(o).test(r)}function gm(e,t){if(typeof t!="object"||t===null)return[];let r=[],n=t;if((e==="apply_patch"||e==="patch")&&typeof n.patchText=="string"){let o=/\*\*\* (?:Add|Delete|Update) File: ([^\n\r]+)/g,i;for(;(i=o.exec(n.patchText))!==null;)r.push(i[1].trim())}if(e==="multiedit"&&(typeof n.filePath=="string"&&r.push(n.filePath),Array.isArray(n.edits)))for(let o of n.edits)o&&typeof o=="object"&&typeof o.filePath=="string"&&r.push(o.filePath);return typeof n.filePath=="string"&&r.push(n.filePath),["read","write","edit"].includes(e)&&typeof n.path=="string"&&r.push(n.path),[...new Set(r)].filter(o=>o.length>0)}function Mk(e,t){return e.length===0||t.length===0?!1:e.some(r=>t.some(n=>fp(r,n)))}var UL=/[*?]/,Fn=["todo","goal","context","task"];function vk(e,t){if(!e||t.length===0)return!1;let r=new Set,n=[];for(let o of t)UL.test(o)?n.push(o):r.add(o);return r.has(e)?!0:n.some(o=>fp(e,o))}function ym(e,t,r,n,o){let i=[{tool:e,input:t}];if(e==="execute"&&Array.isArray(o?.toolCalls))for(let a of o.toolCalls)a&&typeof a=="object"&&typeof a.tool=="string"&&i.push({tool:a.tool,input:a.input});return i.some(a=>vk(a.tool,r)||Mk(gm(a.tool,a.input),n))}function lp(e,t){return t==null?e:`${e}::${JSON.stringify(dp(_L(t)))}`}function _L(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t={};for(let[r,n]of Object.entries(e))n!=null&&(t[r]=n);return t}function dp(e){if(typeof e!="object"||e===null)return e;if(Array.isArray(e))return e.map(dp);let t={};for(let r of Object.keys(e).sort())t[r]=dp(e[r]);return t}var ko="[Output removed to save context - information superseded or no longer needed]",gp="[input removed due to failed tool call]",Lk="[questions removed - see output for user's answers]",jk=2e3,xm=["ask","question"],Fk=["read","grep","ls"],BL=["edit","write","multiedit","apply_patch","patch"];function GL(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function KL(e){if(!e)return{total:0,count:0};let t=0,r=0;for(let n of Object.values(e))typeof n=="string"&&(t+=n.length,r++);return{total:t,count:r}}function HL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yp(e,t,r){let n=r?.bigOutputChars??jk,o=new Map,i=[];for(let h=0;h<e.length;h++){let E=e[h];if(E.role==="assistant")for(let b of E.content)b.type==="toolCall"&&o.set(b.id,{name:b.name,args:b.arguments,callIndex:h});else if(E.role==="toolResult"){let b=o.get(E.toolCallId),C=E.toolName;i.push({index:h,callId:E.toolCallId,tool:C,isError:E.isError,text:GL(E.content),paths:b?gm(C,b.args):[],signature:lp(C,b?.args),callIndex:b?.callIndex??-1})}}let a=t.planFile?rr(t.planFile):void 0,m=h=>h.index===0||Fn.includes(h.tool)||a!==void 0&&h.paths.some(E=>rr(E)===a),c=h=>h.callIndex<0||h.callIndex===0||Fn.includes(h.tool)||a!==void 0&&h.paths.some(E=>rr(E)===a),p=[],f=new Set,d=h=>{let E=`${h.kind}:${h.callId}`;f.has(E)||(f.add(E),p.push(h))},g=new Map;for(let h of i)if(!(h.isError||!Fk.includes(h.tool)&&!BL.includes(h.tool)))for(let E of h.paths){let b=rr(E),C=g.get(b);(C===void 0||h.index>C)&&g.set(b,h.index)}for(let h of i){if(h.isError||!Fk.includes(h.tool)||m(h)||h.text===ko)continue;h.paths.some(b=>(g.get(rr(b))??-1)>h.index)&&d({kind:"output",reason:"superseded-read",callId:h.callId,messageIndex:h.index,savedChars:Math.max(0,h.text.length-ko.length)})}let y=new Map;for(let h of i){if(h.isError)continue;let E=y.get(h.signature);(E===void 0||h.index>E)&&y.set(h.signature,h.index)}for(let h of i){if(!h.isError||m(h))continue;let E=y.get(h.signature);if(!(E===void 0||E<=h.index)&&(d({kind:"output",reason:"error-then-success",callId:h.callId,messageIndex:h.index,savedChars:Math.max(0,h.text.length-ko.length)}),!c(h))){let b=o.get(h.callId)?.args,{total:C,count:k}=KL(b);k>0&&d({kind:"failed-input",reason:"error-then-success",callId:h.callId,messageIndex:h.callIndex,savedChars:Math.max(0,C-k*gp.length)})}}if(t.files.length>0||t.identifiers.length>0){let h=[...t.files.map(rr),...a?[a]:[]],E=h.map(k=>k.split("/").pop()??"").filter(k=>k.length>0),b=t.identifiers.map(k=>new RegExp(`(?<![\\w.-])${HL(k)}(?![\\w.-])`)),C=k=>{let z=rr(k);return h.some(oe=>z.includes(oe))||E.some(oe=>k.includes(oe))?!0:b.some(oe=>oe.test(k))};for(let k of i)m(k)||xm.includes(k.tool)||k.text.length<=n||C(k.text)||d({kind:"output",reason:"unrelated-big-output",callId:k.callId,messageIndex:k.index,savedChars:Math.max(0,k.text.length-ko.length)})}let I=0;for(let h of p)I+=h.savedChars;return{ops:p,savedChars:I}}function xp(e,t){let r=new Set,n=new Set,o=new Set;for(let i of t)i.kind==="output"?r.add(i.callId):i.kind==="question-input"?n.add(i.callId):o.add(i.callId);return qk(Nk(Dk(e,r),n),o)}function Dk(e,t){return t.size===0?[...e]:e.map((r,n)=>n===0||r.role!=="toolResult"||!t.has(r.toolCallId)||xm.includes(r.toolName)?r:{...r,content:[{type:"text",text:ko}]})}function Nk(e,t){if(t.size===0)return[...e];let r=new Set;for(let n of e)n.role==="toolResult"&&!n.isError&&t.has(n.toolCallId)&&r.add(n.toolCallId);return r.size===0?[...e]:e.map((n,o)=>{if(o===0||n.role!=="assistant")return n;let i=!1,a=n.content.map(m=>{if(m.type!=="toolCall"||!r.has(m.id)||!xm.includes(m.name))return m;let c={...m.arguments},p=!1;for(let f of["question","questions","options"])f in c&&(c[f]=Lk,p=!0);return p?(i=!0,{...m,arguments:c}):m});return i?{...n,content:a}:n})}function qk(e,t){if(t.size===0)return[...e];let r=new Set;for(let n of e)n.role==="toolResult"&&n.isError&&t.has(n.toolCallId)&&r.add(n.toolCallId);return r.size===0?[...e]:e.map((n,o)=>{if(o===0||n.role!=="assistant")return n;let i=!1,a=n.content.map(m=>{if(m.type!=="toolCall"||!r.has(m.id))return m;let c={},p=!1;for(let[f,d]of Object.entries(m.arguments))typeof d=="string"?(c[f]=gp,p=!0):c[f]=d;return p?(i=!0,{...m,arguments:c}):m});return i?{...n,content:a}:n})}function hp(e,t,r){if(t.length===0)return[...e];let n=Br(r,e),o=new Map;for(let d=0;d<n.length;d++){let g=n[d];g!==null&&o.set(g,d)}let i=new Set,a=new Map;for(let d of t){let g=[];for(let I of d.coveredIndices){let h=o.get(I);h!==void 0&&(i.add(h),g.push(h))}let y=o.get(d.anchorIndex)??(g.length>0?Math.min(...g):void 0);if(d.summary&&y!==void 0){let I=a.get(y);I?I.push(d.summary):a.set(y,[d.summary])}}let m=new Map,c=new Map;for(let d=0;d<e.length;d++){let g=e[d];if(g)if(g.role==="assistant"&&Array.isArray(g.content))for(let y of g.content)y.type==="toolCall"&&m.set(d,y.id);else g.role==="toolResult"&&c.set(g.toolCallId,d)}let p=[...i];for(;p.length>0;){let d=p.pop(),g=m.get(d);if(g!==void 0){let I=c.get(g);I!==void 0&&!i.has(I)&&(i.add(I),p.push(I))}let y=e[d];if(y?.role==="toolResult")for(let[I,h]of m)h===y.toolCallId&&!i.has(I)&&(i.add(I),p.push(I))}let f=[];for(let d=0;d<e.length;d++){let g=a.get(d);if(g){let y=e[d];for(let I of g){let h={role:"user",content:I,timestamp:y.timestamp};f.push(h)}}i.has(d)||f.push(e[d])}return f}var Ip={thresholdChars:8192,headChars:4096,tailChars:1024};function zL(e,t={}){let r=t.thresholdChars??Ip.thresholdChars,n=t.headChars??Ip.headChars,o=t.tailChars??Ip.tailChars;if(e.length<=r||n+o>=e.length)return{text:e,prunedChars:0};let i=n,a=e.charCodeAt(i-1);a>=55296&&a<=56319&&(i-=1);let m=e.length-o,c=e.charCodeAt(m);c>=56320&&c<=57343&&(m+=1);let p=e.slice(0,i),f=e.slice(m),d=m-i,g=`
|
|
41
|
-
|
|
42
|
-
[... ${d} characters pruned from the middle ...]
|
|
43
|
-
|
|
44
|
-
`;return{text:p+g+f,prunedChars:d-g.length}}function Uk(e,t={}){let r=0,n=0,o=!1,i=e.map(a=>{let m=a;if(m.role!=="toolResult"||!Array.isArray(m.content))return a;let c=m.content,p=!1,f=c.map(d=>{if(!d||typeof d!="object")return d;let g=d;if(g.type!=="text"||typeof g.text!="string")return d;let y=zL(g.text,t);return y.prunedChars<=0?d:(p=!0,r+=y.prunedChars,{...d,text:y.text})});return p?(o=!0,n+=1,{...a,content:f}):a});return{messages:o?i:e,savedChars:r,prunedResults:n}}function bp(e="xml"){let t=e==="compact",r=t?"@4@":"mNNNN",n=t?"@b1@":"bN",o=t?"@b1@":"(bN)";return`COMPRESSING A RANGE OF THIS CONVERSATION
|
|
45
|
-
|
|
46
|
-
This is what the \`compress\` tool is for, and how a range must be summarised when it is used. Reach for it when the conversation has grown long enough that its older turns cost more than they are worth - never as a way to answer the user, and never on a range they did not ask about. Nothing here is a standing instruction to summarise: it is the contract the tool's output is held to.
|
|
47
|
-
|
|
48
|
-
THE SUMMARY
|
|
49
|
-
Your summary must be EXHAUSTIVE. Capture file paths, function signatures, decisions made, constraints discovered, key findings... EVERYTHING that maintains context integrity. This is not a brief note - it is an authoritative record so faithful that the original conversation adds no value.
|
|
50
|
-
|
|
51
|
-
USER INTENT FIDELITY
|
|
52
|
-
When the compressed range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
|
|
53
|
-
Directly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.
|
|
54
|
-
|
|
55
|
-
Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
|
|
56
|
-
|
|
57
|
-
COMPRESSED BLOCK PLACEHOLDERS
|
|
58
|
-
When the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:
|
|
59
|
-
|
|
60
|
-
- \`${o}\`
|
|
61
|
-
|
|
62
|
-
Compressed block sections in context are clearly marked with a header:
|
|
63
|
-
|
|
64
|
-
- \`[Compressed conversation section]\`
|
|
65
|
-
|
|
66
|
-
${t?"Compressed block IDs look like `@b1@`, distinct from raw message IDs like `@4@`.":"Compressed block IDs always use the `bN` form (never `mNNNN`) and are represented in the same XML metadata tag format."}
|
|
67
|
-
|
|
68
|
-
Rules:
|
|
69
|
-
|
|
70
|
-
- Include every required block placeholder exactly once.
|
|
71
|
-
- Do not invent placeholders for blocks outside the selected range.
|
|
72
|
-
- Treat \`${o}\` placeholders as RESERVED TOKENS. Do not emit \`${o}\` text anywhere except intentional placeholders.
|
|
73
|
-
- If you need to mention a block in prose, use plain text like \`compressed ${t?"block 1":"bN"}\` (not as a placeholder).
|
|
74
|
-
- Preflight check before finalizing: the set of \`${o}\` placeholders in your summary must exactly match the required set, with no duplicates.
|
|
75
|
-
|
|
76
|
-
These placeholders are semantic references. They will be replaced with the full stored compressed block content when the tool processes your output.
|
|
77
|
-
|
|
78
|
-
FLOW PRESERVATION WITH PLACEHOLDERS
|
|
79
|
-
When you use compressed block placeholders, write the surrounding summary text so it still reads correctly AFTER placeholder expansion.
|
|
80
|
-
|
|
81
|
-
- Treat each placeholder as a stand-in for a full conversation segment, not a short label.
|
|
82
|
-
- Ensure transitions before and after each placeholder preserve chronology and causality.
|
|
83
|
-
- Do not write text that depends on the placeholder staying literal (for example, "as noted in \`${t?"@b2@":"(b2)"}\`").
|
|
84
|
-
- Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
|
|
85
|
-
|
|
86
|
-
BOUNDARY IDS
|
|
87
|
-
You specify boundaries by ID using the injected IDs visible in the conversation:
|
|
88
|
-
|
|
89
|
-
- \`${r}\` IDs identify raw messages
|
|
90
|
-
- \`${n}\` IDs identify previously compressed blocks
|
|
91
|
-
|
|
92
|
-
${t?"Each message has an ID like `@4@`. Copy the whole marker, including both `@` characters, into `startId` and `endId`.":"Each message has an ID inside XML metadata tags like `<dcp-message-id>...</dcp-message-id>`."}
|
|
93
|
-
The same ID tag appears in every tool output of the message it belongs to \u2014 each unique ID identifies one complete message.
|
|
94
|
-
Treat these tags as boundary metadata only, not as tool result content.
|
|
95
|
-
|
|
96
|
-
Rules:
|
|
97
|
-
|
|
98
|
-
- Pick \`startId\` and \`endId\` directly from injected IDs in context.
|
|
99
|
-
- IDs must exist in the current visible context.
|
|
100
|
-
- \`startId\` must appear before \`endId\`.
|
|
101
|
-
- Do not invent IDs. Use only IDs that are present in context.
|
|
102
|
-
|
|
103
|
-
BATCHING
|
|
104
|
-
When multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the \`content\` array of a single tool call. Each entry should have its own \`startId\`, \`endId\`, and \`summary\`.
|
|
105
|
-
`}function $p(e,t,r,n){let o=new Map;if(t.idState){let m=Br(t.idState,t.messages);for(let c=0;c<m.length;c++){let p=m[c];p!==null&&o.set(p,c)}}let i=new Set;for(let m of Lr(r))if(!(n!==void 0&&m.blockId===n))for(let c of m.coveredIndices)i.add(c);let a=[];if(t.idState)for(let m of e.indices){if(i.has(m))continue;let c=o.get(m);c!==void 0&&a.push(c)}return a}function _k(e){if(typeof e.content=="string")return e.content.trim()?[e.content]:[];let t=[];for(let r of e.content)r.type==="text"&&r.text.trim()&&t.push(r.text);return t}function Bk(e,t,r,n,o,i){if(!o)return e;let a=[];for(let p of $p(t,r,n,i)){let f=r.messages[p];if(!f||f.role!=="user")continue;let d=_k(f)[0];d!==void 0&&a.push(d)}if(a.length===0)return e;let m=`
|
|
106
|
-
|
|
107
|
-
The following user messages were sent in this conversation verbatim:`,c=a.map(p=>`
|
|
108
|
-
${p}`).join("");return e+m+c}function Gk(e,t,r,n,o,i){if(!o)return e;let a=[];for(let p of $p(t,r,n,i)){let f=r.messages[p];if(!(!f||f.role!=="user"))for(let d of _k(f))a.push(...Kk(d))}if(a.length===0)return e;let m=`
|
|
109
|
-
|
|
110
|
-
The following protected prompt information was included in this conversation verbatim:`,c=a.map(p=>`
|
|
111
|
-
${p}`).join("");return e+m+c}function Kk(e){let t=[],r=/<protect>([\s\S]*?)<\/protect>/gi;for(let n of e.matchAll(r)){let o=n[1]?.trim();o&&t.push(o)}return t}function Hk(e,t,r,n,o=[],i=[],a){let m=new Map,c=[];for(let y of $p(t,r,n,a)){let I=r.messages[y];if(I){if(I.role==="assistant"){for(let h of I.content)h.type==="toolCall"&&m.set(h.id,h.arguments);continue}if(I.role==="toolResult"){if(I.isError)continue;let h=I.content.filter(E=>E.type==="text").map(E=>E.text).join("");h.trim()&&c.push({toolCallId:I.toolCallId,toolName:I.toolName,text:h})}}}if(c.length===0)return e;let p=[...new Set([...Fn,...o])],f=[...i],d=[];for(let y of c){let I=m.get(y.toolCallId);ym(y.toolName,I,p,f)&&d.push(`
|
|
112
|
-
### Tool: ${y.toolName}
|
|
113
|
-
${y.text}`)}return d.length===0?e:e+`
|
|
114
|
-
|
|
115
|
-
The following protected tools were used in this conversation as well:`+d.join("")}function zk(e,t,r){if(t.protectedEnriched)return;let n=t.coveredIndices;if(n.length>0){let o={startIdx:Math.min(...n),endIdx:Math.max(...n),indices:[...n],requiredBlockIds:[],tokenByIndex:new Map},i={messages:r,idState:e.messageIds},a=Hk(Gk(Bk(t.summary,o,i,e,!0,t.blockId),o,i,e,!0,t.blockId),o,i,e,[],[],t.blockId);t.summary=a,t.summaryTokens=Fi(a)}t.protectedEnriched=!0}function Wk(e,t){let r=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o===null)continue;let i=t[n],a=i&&"content"in i?Eo(i.content):"";r.push({index:o,tokenCount:Math.round(a.length/4)})}return r}var WL="COMPRESSED BLOCK PLACEHOLDERS",Ep=new Map;function VL(e){return Ep.get(e)??[]}function JL(e){Ep.delete(e)}var Vk;function YL(){return Vk}function QL(e={}){return t=>{t.on("context_with_system",async(r,n)=>{let o=n?.sessionManager?.getSessionId()??"dcp-sessionless",i=Li(o);if(i.enabled===!1)return;let a=r.messages,m=a[0];if(!m||m.role!=="system")return;_m(i.messageIds,a);let c=Br(i.messageIds,a);Ep.set(o,Wk(c,a)),Vk=o;let p=XL(a),f=hp(p,Lr(i),i.messageIds),d=Uk(f);d.prunedResults>0&&(f=[...d.messages]);let g=e.keepSet?.()??{files:[],identifiers:[]},y=yp(f,g);if(y.ops.length>0){f=xp(f,y.ops);for(let h of y.ops)i.prune.tools[h.callId]=(i.prune.tools[h.callId]??0)+h.savedChars;i.stats.totalPruneTokens=Object.values(i.prune.tools).reduce((h,E)=>h+E,0)}for(let h of i.prune.messages.blocks)h.active&&!h.protectedEnriched&&zk(i,h,a);un(o);let I=f.map((h,E)=>{if(E!==0||!("content"in h))return h;let b=Eo(h.content);return b.includes(WL)?h:{...h,content:fm(h.content,`${b}
|
|
116
|
-
|
|
117
|
-
${bp()}`)}});return{messages:ej(I,i.messageIds)}})}}function XL(e){return e.map(t=>{if(t.role!=="assistant"||!("content"in t))return t;let r=ZL(t.content);return r===t.content?t:{...t,content:r}})}function ZL(e){if(typeof e=="string")return Um(e);if(!Array.isArray(e))return e;let t=!1,r=e.map(n=>{if(!n||typeof n!="object"||!("type"in n)||n.type!=="text")return n;let o="text"in n&&typeof n.text=="string"?n.text:"",i=Um(o);return i===o?n:(t=!0,{...n,text:i})});return t?r:e}function ej(e,t){let r=Br(t,e);return e.map((n,o)=>{let i=r[o];if(i==null||!("content"in n))return n;let a=Mo(Dn(i));return Eo(n.content).includes(a)?n:{...n,content:tj(n.content,a)}})}function tj(e,t){if(typeof e=="string")return e+t;if(!Array.isArray(e))return e;let r=!1,n=e.map(o=>{if(!o||typeof o!="object"||!("type"in o)||o.type!=="text")return o;r=!0;let i="text"in o&&typeof o.text=="string"?o.text:"";return{...o,text:i+t}});return r?n:[...n,{type:"text",text:t.trimStart()}]}var Jk={on:"turn the transform on for this session",off:"turn it off; the full transcript is sent unchanged",status:"the switch, the block count, and the tokens saved",blocks:"list the active compressed blocks",stats:"prune and compress totals for this session",context:"what the next request will carry, and what was saved",decompress:"reopen one block by id, e.g. /dcp decompress b2",sweep:"drop blocks no longer referenced by the ref state"};function Sp(e){return e<1e3?`${e}`:`${(e/1e3).toFixed(1)}k`}function rj(e,t,r){let[n]=e.trim().split(/\s+/),o=n===void 0||n===""?"status":n,i=Li(r);switch(o){case"on":return i.enabled=!0,un(r),"dcp: on";case"off":return i.enabled=!1,un(r),"dcp: off; the full transcript is sent unchanged";case"blocks":{let a=Lr(i);return a.length===0?"dcp: no active blocks":a.map(m=>{let c=String(m.anchorIndex).padStart(4,"0");return`b${m.blockId} covers ${m.coveredIndices.length} message(s), anchored at m${c}`}).join(`
|
|
118
|
-
`)}case"status":{let a=pp({runtime:i.enabled,config:cp(t)}),m=Lr(i),c=Object.values(i.prune.tools).reduce((p,f)=>p+f,0);return[`dcp: ${a.enabled?"on":"off"} (source: ${a.source})`,`messages tracked: ${Object.keys(i.messageIds.keyToRef).length}`,`active blocks: ${m.length}`,`pruned tool calls: ${Object.keys(i.prune.tools).length} (${Sp(c)} chars)`,`compressed tokens total: ${i.stats.totalCompressTokens}`].join(`
|
|
119
|
-
`)}case"stats":{let a=i.prune.messages.blocks,m=a.filter(p=>p.active).length,c=Object.values(i.prune.tools).reduce((p,f)=>p+f,0);return[`blocks: ${m} active of ${a.length} total`,`compressed tokens: ${i.stats.totalCompressTokens}`,`pruned tool calls: ${Object.keys(i.prune.tools).length} (${Sp(c)} chars)`,`messages tracked: ${Object.keys(i.messageIds.keyToRef).length}`,`refs allocated: ${i.messageIds.nextRef-1}`].join(`
|
|
120
|
-
`)}case"context":{let a=Lr(i),m=new Set;for(let f of a)for(let d of f.coveredIndices)m.add(d);let c=Object.keys(i.messageIds.keyToRef).length,p=Object.values(i.prune.tools).reduce((f,d)=>f+d,0);return[`messages tracked: ${c}`,`messages replaced by a block: ${m.size}`,`messages sent: ${Math.max(0,c-m.size)}`,`active blocks: ${a.length}`,`compressed tokens total: ${i.stats.totalCompressTokens}`,`pruned tool calls: ${Object.keys(i.prune.tools).length} (${Sp(p)} chars)`].join(`
|
|
121
|
-
`)}case"decompress":{let a=e.trim().split(/\s+/)[1],m=a===void 0?null:/^b?(\d+)$/i.exec(a);if(!m)return"dcp: give a block id, e.g. /dcp decompress b2";let c=Number(m[1]),p=i.prune.messages.blocks,f=p.find(g=>g.blockId===c);if(!f)return`dcp: no block b${c}`;let d=p.filter(g=>g.active&&g.consumedBlockIds.includes(c));if(d.length>0){let g=d.map(y=>`b${y.blockId}`).join(", ");return`dcp: b${c} was consumed by ${g}; decompress that one first`}if(!f.active)return`dcp: b${c} is already open`;f.active=!1,f.deactivatedByUser=!0,f.deactivatedAt=Date.now();for(let g of f.parentBlockIds){let y=p.find(I=>I.blockId===g);y&&(y.consumedBlockIds=y.consumedBlockIds.filter(I=>I!==c))}return un(r),`dcp: b${c} reopened; ${f.coveredIndices.length} message(s) are back`}case"sweep":{let a=new Set(Object.keys(i.messageIds.refToKey).map(Number)),m=i.prune.messages.blocks,c=m.length,p=m.filter(d=>d.active&&!d.coveredIndices.some(g=>a.has(g)));for(let d of p)d.active=!1,d.deactivatedAt=Date.now();i.prune.messages.blocks=m.filter(d=>d.active||d.deactivatedByUser);let f=c-i.prune.messages.blocks.length;return un(r),p.length===0?"dcp: nothing to sweep":`dcp: ${p.length} orphaned block(s) closed, ${f} dropped from state`}default:return`dcp: unknown subcommand '${o}'. try: ${Object.keys(Jk).join(", ")}`}}import{Type as Im}from"@netrodev/hxf-ai";import{defineTool as rT}from"@netrodev/hxf-coding-agent";import{promises as nj}from"node:dns";var oj=/^(127\.|10\.|192\.168\.|169\.254\.|0\.)/;function kp(e){if(oj.test(e))return!0;let t=/^172\.(\d+)\./.exec(e);if(!t)return!1;let r=Number(t[1]);return r>=16&&r<=31}function Tp(e){let t=/^100\.(\d+)\.(\d+)\.(\d+)$/.exec(e);if(t){let n=Number(t[1]);return n>=64&&n<=127}let r=/^198\.(\d+)\./.exec(e);return r!==null&&(Number(r[1])===18||Number(r[1])===19)}function Qk(e){let t=e.toLowerCase().replace(/^\[|\]$/g,"").split("%")[0];if(t==="localhost"||t.endsWith(".localhost"))return!0;let r=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(t);if(r){let o=r[1];return kp(o)||Tp(o)||o==="0.0.0.0"}let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(t);if(n){let o=Number.parseInt(n[1],16),i=Number.parseInt(n[2],16),a=`${o>>8&255}.${o&255}.${i>>8&255}.${i&255}`;return kp(a)||Tp(a)||a==="0.0.0.0"}return t.includes(":")?!!(t==="::1"||t==="::"||/^f[cd][0-9a-f]{2}:/.test(t)||/^fe[89ab][0-9a-f]:/.test(t)):t==="0.0.0.0"?!0:kp(t)||Tp(t)}var wp=8e4,Cp=8;function hm(e){let t;try{t=new URL(e)}catch{return{ok:!1,reason:"not a URL"}}if(t.protocol!=="http:"&&t.protocol!=="https:")return{ok:!1,reason:`refused protocol ${t.protocol}`};let r=t.hostname.toLowerCase();return r==="localhost"||r.endsWith(".localhost")||r==="::1"||r==="[::1]"?{ok:!1,reason:"refused loopback host"}:Qk(r)?{ok:!1,reason:"refused private address"}:{ok:!0,url:t}}function Xk(e){let t=e.replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<noscript[\s\S]*?<\/noscript>/gi," ").replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim();return t.length>wp?t.slice(0,wp):t}function ij(e){let t=[],r=/class="result__a"[^>]*href="([^"]+)"[^>]*>([\s\S]*?)<\/a>/gi,n;for(;(n=r.exec(e))&&t.length<Cp;){let o=n[1]??"",i=Xk(n[2]??""),a=o,m=/[?&]uddg=([^&]+)/.exec(o);if(m)try{a=decodeURIComponent(m[1])}catch{a=o}else o.startsWith("//")&&(a=`https:${o}`);let c=hm(a);!c.ok||!i||t.push({title:i,url:c.url.toString(),snippet:""})}return t}var Zk="HowToCode (https://howtofix.id)";async function eT(e,t={}){let r=e.trim();if(!r)return{ok:!1,error:"empty query"};let n=t.fetchFn??fetch,o=t.timeoutMs??15e3,i={"user-agent":t.userAgent??Zk,accept:"text/html, application/json"};try{if(t.braveKey){let p=`https://api.search.brave.com/res/v1/web/search?q=${encodeURIComponent(r)}&count=${Cp}`,f=await n(p,{headers:{...i,accept:"application/json","x-subscription-token":t.braveKey},signal:AbortSignal.timeout(o)});return f.ok?{ok:!0,hits:sj(await f.json()),provider:"brave"}:{ok:!1,error:`brave ${f.status}`}}let a=`https://html.duckduckgo.com/html/?q=${encodeURIComponent(r)}`,m=await n(a,{headers:i,signal:AbortSignal.timeout(o)});return m.ok?{ok:!0,hits:ij(await m.text()),provider:"ddg"}:{ok:!1,error:`search ${m.status}`}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}function sj(e){let t=[];if(e&&typeof e=="object"&&"web"in e){let n=e.web;n&&typeof n=="object"&&"results"in n&&Array.isArray(n.results)&&(t=n.results)}let r=[];for(let n of t){if(!n||typeof n!="object"||!("url"in n)||!("title"in n))continue;let o=n.url,i=n.title;if(typeof o!="string"||typeof i!="string")continue;let a=hm(o);if(!a.ok)continue;let m="description"in n?n.description:void 0;if(r.push({title:i,url:a.url.toString(),snippet:typeof m=="string"?m:""}),r.length>=Cp)break}return r}var Yk=5,aj=new Set([301,302,303,307,308]);async function mj(e,t){let r=e.toLowerCase().replace(/^\[|\]$/g,"");if(r.includes(":")||/^[\d.]+$/.test(r))return{ok:!0};let n;try{n=await t(r)}catch(i){return{ok:!1,error:`could not resolve ${e}: ${i instanceof Error?i.message:String(i)}`}}if(n.length===0)return{ok:!1,error:`could not resolve ${e}`};let o=n.find(i=>Qk(i));return o!==void 0?{ok:!1,error:`refused ${e}: resolves to private address ${o}`}:{ok:!0}}async function tT(e,t={}){let r=hm(e);if(!r.ok)return{ok:!1,error:r.reason};let n=t.fetchFn??fetch,o=t.lookup??(m=>nj.lookup(m,{all:!0}).then(c=>c.map(p=>p.address))),i=AbortSignal.timeout(t.timeoutMs??2e4),a={"user-agent":t.userAgent??Zk,accept:"text/html, text/plain, application/json"};try{let m=r.url;for(let c=0;c<=Yk;c++){let p=hm(m.toString());if(!p.ok)return{ok:!1,error:`redirect refused: ${p.reason}`};let f=await mj(p.url.hostname,o);if(!f.ok)return{ok:!1,error:f.error};let d=await n(p.url,{headers:a,signal:i,redirect:"manual"});if(aj.has(d.status)){let h=d.headers.get("location");if(!h)return{ok:!1,error:`HTTP ${d.status} without a location`};try{m=new URL(h,p.url)}catch{return{ok:!1,error:"redirect location is not a URL"}}continue}if(!d.ok)return{ok:!1,error:`HTTP ${d.status}`};let g=d.headers.get("content-type")??"",y=await d.text(),I=/html/i.test(g)?Xk(y):y.slice(0,wp);return{ok:!0,url:m.toString(),contentType:g,text:I}}return{ok:!1,error:`too many redirects (max ${Yk})`}}catch(m){return{ok:!1,error:m instanceof Error?m.message:String(m)}}}function uj(e){return e.length===0?"no results":e.map((t,r)=>`${r+1}. ${t.title}
|
|
122
|
-
${t.url}${t.snippet?`
|
|
123
|
-
${t.snippet}`:""}`).join(`
|
|
124
|
-
`)}var nT=rT({name:"web_search",label:"web_search",description:"Search the public web. Use for current docs, changelogs, error messages, and anything not in this repo. Returns titles, URLs, and snippets. Follow a URL with web_fetch.",promptSnippet:"web_search: search the public web",parameters:Im.Object({query:Im.String({description:"Search query"})}),async execute(e,t){let r=await eT(t.query,{braveKey:process.env.BRAVE_API_KEY});return r.ok?{content:[{type:"text",text:uj(r.hits)}],details:{count:r.hits.length,provider:r.provider}}:{content:[{type:"text",text:r.error}],details:{error:r.error},isError:!0}}}),oT=rT({name:"web_fetch",label:"web_fetch",description:"Fetch a public http(s) URL and return its text. HTML is stripped to visible text. Local, loopback, and private addresses are refused.",promptSnippet:"web_fetch: read a public URL as text",parameters:Im.Object({url:Im.String({description:"http(s) URL"})}),async execute(e,t){let r=await tT(t.url);return r.ok?{content:[{type:"text",text:r.text}],details:{url:r.url,contentType:r.contentType,chars:r.text.length}}:{content:[{type:"text",text:r.error}],details:{error:r.error},isError:!0}}});import{spawn as cj}from"node:child_process";import{existsSync as bm,readFileSync as aT}from"node:fs";import{delimiter as mT,isAbsolute as uT,join as $m}from"node:path";import{fileURLToPath as pj,pathToFileURL as jr}from"node:url";function iT(e){let t=JSON.stringify(e);return`Content-Length: ${Buffer.byteLength(t,"utf8")}\r
|
|
125
|
-
\r
|
|
126
|
-
${t}`}var fj=32*1024*1024;function dj(e){let t=[],r=0;for(;r<e.length;){let n=e.indexOf(`\r
|
|
127
|
-
\r
|
|
128
|
-
`,r);if(n===-1)break;let o=e.subarray(r,n).toString("utf8"),i=/Content-Length:\s*(\d+)/i.exec(o);if(!i)break;let a=Number(i[1]);if(!Number.isSafeInteger(a)||a<0||a>fj)throw new Error(`lsp frame of ${i[1]} bytes refused`);let m=n+4,c=m+a;if(c>e.length)break;let p=e.subarray(m,c).toString("utf8");try{let f=JSON.parse(p);f&&typeof f=="object"&&t.push(f)}catch{}r=c}return{messages:t,rest:e.subarray(r)}}var Rp=class{constructor(t){this.io=t;t.stdout.on("data",r=>{if(this.broken)return;this.buffer=Buffer.concat([this.buffer,r]);let n;try{n=dj(this.buffer)}catch(o){this.buffer=Buffer.alloc(0),this.fail(o instanceof Error?o:new Error(String(o)));return}this.buffer=n.rest;for(let o of n.messages)this.dispatch(o)}),t.stdin.on("error",r=>{this.fail(r instanceof Error?r:new Error(String(r)))})}io;nextId=1;pending=new Map;buffer=Buffer.alloc(0);broken=null;opened=new Set;versions=new Map;diagnosticsByUri=new Map;diagnosticsWaiters=new Map;fail(t){if(!this.broken){this.broken=t;for(let[r,n]of this.pending)this.pending.delete(r),n.reject(t)}}dispatch(t){if(t.method==="textDocument/publishDiagnostics"){let n=t.params;if(n?.uri){let o=Array.isArray(n.diagnostics)?n.diagnostics:[];this.diagnosticsByUri.set(n.uri,o);let i=this.diagnosticsWaiters.get(n.uri);if(i){this.diagnosticsWaiters.delete(n.uri);for(let a of i)a(o)}}return}if(t.id===void 0)return;let r=this.pending.get(Number(t.id));r&&(this.pending.delete(Number(t.id)),t.error?r.reject(new Error(t.error.message)):r.resolve(t.result))}request(t,r,n=1e4){if(this.broken)return Promise.reject(this.broken);let o=this.nextId++,i=iT({jsonrpc:"2.0",id:o,method:t,params:r}),{promise:a,resolve:m,reject:c}=Promise.withResolvers(),p=setTimeout(()=>{this.pending.delete(o),c(new Error(`lsp ${t} timed out`))},n);this.pending.set(o,{resolve:f=>{clearTimeout(p),m(f)},reject:f=>{clearTimeout(p),c(f)}});try{this.io.stdin.write(i)}catch(f){let d=f instanceof Error?f:new Error(String(f));this.pending.delete(o),clearTimeout(p),c(d),this.fail(d)}return a}notify(t,r){if(!this.broken)try{this.io.stdin.write(iT({jsonrpc:"2.0",method:t,params:r}))}catch(n){this.fail(n instanceof Error?n:new Error(String(n)))}}async initialize(){await this.request("initialize",{processId:null,rootUri:jr(this.io.root).toString(),capabilities:{textDocument:{hover:{},definition:{},references:{},documentSymbol:{},publishDiagnostics:{}}}}),this.notify("initialized",{})}async hover(t,r,n){return(await this.request("textDocument/hover",{textDocument:{uri:jr(t).toString()},position:{line:r,character:n}}))?.contents?.value}async definition(t,r,n){let o=await this.request("textDocument/definition",{textDocument:{uri:jr(t).toString()},position:{line:r,character:n}});return Array.isArray(o)?o[0]:o??void 0}async references(t,r,n){let o=await this.request("textDocument/references",{textDocument:{uri:jr(t).toString()},position:{line:r,character:n},context:{includeDeclaration:!0}});return Array.isArray(o)?o:[]}async documentSymbols(t){let r=await this.request("textDocument/documentSymbol",{textDocument:{uri:jr(t).toString()}});return Array.isArray(r)?r:[]}diagnostics(t,r=2e3){let n=jr(t).toString(),o=this.diagnosticsByUri.get(n);if(o)return Promise.resolve(o);let{promise:i,resolve:a}=Promise.withResolvers(),m=setTimeout(()=>{let p=this.diagnosticsWaiters.get(n);if(p){this.diagnosticsWaiters.delete(n);for(let f of p)f(this.diagnosticsByUri.get(n)??[])}},r),c=this.diagnosticsWaiters.get(n)??[];return c.push(p=>{clearTimeout(m),a(p)}),this.diagnosticsWaiters.set(n,c),i}async ensureOpen(t,r,n){let o=jr(t).toString();this.opened.has(o)||(this.versions.set(o,1),this.notify("textDocument/didOpen",{textDocument:{uri:o,languageId:n,version:1,text:r}}),this.opened.add(o))}isOpen(t){return this.opened.has(jr(t).toString())}notifyChange(t,r,n){let o=jr(t).toString();if(!this.opened.has(o)){this.versions.set(o,1),this.opened.add(o),this.notify("textDocument/didOpen",{textDocument:{uri:o,languageId:n,version:1,text:r}});return}let i=(this.versions.get(o)??1)+1;this.versions.set(o,i),this.diagnosticsByUri.delete(o),this.notify("textDocument/didChange",{textDocument:{uri:o,version:i},contentChanges:[{text:r}]})}dispose(){for(let[t,r]of this.pending)r.reject(new Error("lsp client disposed")),this.pending.delete(t);for(let[t,r]of this.diagnosticsWaiters){let n=this.diagnosticsByUri.get(t)??[];this.diagnosticsWaiters.delete(t);for(let o of r)o(n)}}},lj=[{command:"typescript-language-server",args:["--stdio"],languageId:"typescript",match:e=>/\.(ts|tsx|js|jsx|mts|cts)$/.test(e)},{command:"rust-analyzer",args:[],languageId:"rust",match:e=>e.endsWith(".rs")},{command:"gopls",args:[],languageId:"go",match:e=>e.endsWith(".go")},{command:"pylsp",args:[],languageId:"python",match:e=>e.endsWith(".py")}];function cT(e){return lj.find(t=>t.match(e))}var Dr=new Map;async function pT(e,t){let r=Dr.get(e.command);if(r)return await r.ready,r.client;let n=cj(e.command,e.args,{cwd:t,stdio:["pipe","pipe","ignore"]}),o=n.stdin,i=n.stdout;if(!o||!i)throw n.kill(),new Error(`${e.command}: stdio pipes unavailable`);let a=new Rp({stdin:o,stdout:i,root:t});n.on("error",()=>{let c=Dr.get(e.command);c?.child===n&&Dr.delete(e.command),c?.client.dispose()}),n.on("exit",()=>{Dr.get(e.command)?.child===n&&Dr.delete(e.command),a.dispose()});let m=a.initialize().catch(c=>{throw Dr.delete(e.command),n.kill(),c});return Dr.set(e.command,{client:a,child:n,ready:m}),await m,a}function gj(){for(let[e,t]of Dr)Dr.delete(e),t.client.dispose(),t.child.kill()}process.on("exit",gj);async function Mve(e,t,r={}){let n=cT(e);if(!n)return{diagnostics:[],unavailable:"no language server configured for this file type"};if(!(n.command.includes("/")?bm(n.command):(process.env.PATH??"").split(mT).some(i=>bm($m(i,n.command)))))return{diagnostics:[],unavailable:`${n.command} is not on PATH`};try{let i=uT(e)?e:$m(t,e),a=await pT(n,t);return a.notifyChange(i,aT(i,"utf8"),n.languageId),{diagnostics:(await a.diagnostics(i,r.waitMs??1500)).map(c=>`${c.range.start.line+1}:${c.range.start.character+1} ${fT[c.severity??3]??"info"} ${c.message}`)}}catch(i){return{diagnostics:[],unavailable:i instanceof Error?i.message:String(i)}}}var fT={1:"error",2:"warning",3:"info",4:"hint"};function sT(e){let t=e.uri;try{t=pj(e.uri)}catch{}let r=e.range?.start;return r?`${t}:${r.line+1}:${r.character+1}`:t}function dT(e,t=0){let r=[];for(let n of e){let o=(n.selectionRange??n.range)?.start.line;r.push(`${" ".repeat(t)}${n.name}${o===void 0?"":` :${o+1}`}`),n.children&&r.push(...dT(n.children,t+1))}return r}async function lT(e){try{let t=cT(e.file);if(!t)return{ok:!1,error:`no language server configured for ${e.file}`};if((e.action==="definition"||e.action==="references"||e.action==="hover")&&(e.line===void 0||!Number.isInteger(e.line)||e.line<1))return{ok:!1,error:`line required (1-based) for ${e.action}`};if(!(t.command.includes("/")?bm(t.command):(process.env.PATH??"").split(mT).some(p=>bm($m(p,t.command)))))return{ok:!1,error:`${t.command} is not on PATH. Install it to use lsp on ${e.file}.`};let o=uT(e.file)?e.file:$m(e.root,e.file),i=aT(o,"utf8"),a=await pT(t,e.root);await a.ensureOpen(o,i,t.languageId);let m=(e.line??1)-1,c=0;if(e.symbol){let p=(i.split(`
|
|
129
|
-
`)[m]??"").indexOf(e.symbol);p>=0&&(c=p)}switch(e.action){case"definition":{let p=await a.definition(o,m,c);return p?{ok:!0,text:sT(p),count:1}:{ok:!0,text:"no definition found",count:0}}case"references":{let f=(await a.references(o,m,c)).map(sT);return{ok:!0,text:f.length>0?f.join(`
|
|
130
|
-
`):"no references found",count:f.length}}case"hover":{let p=(await a.hover(o,m,c))?.trim();return{ok:!0,text:p||"no hover at that position"}}case"symbols":{let p=dT(await a.documentSymbols(o));return{ok:!0,text:p.length>0?p.join(`
|
|
131
|
-
`):"no symbols in this file",count:p.length}}case"diagnostics":{let f=(await a.diagnostics(o)).map(d=>`${d.range.start.line+1}:${d.range.start.character+1} ${fT[d.severity??3]??"info"} ${d.message}`);return{ok:!0,text:f.length>0?f.join(`
|
|
132
|
-
`):"no diagnostics",count:f.length}}}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}import{StringEnum as yj}from"@netrodev/hxf-ai";import{defineTool as xj}from"@netrodev/hxf-coding-agent";var gT=xj({name:"lsp",label:"lsp",description:"Language-server query: definition, references, hover, symbols, or diagnostics for a file. Line is 1-based. Does not edit. If the server binary is missing the result says so; do not pretend grep is a substitute without telling the user.",promptSnippet:"lsp: definition, references, hover, symbols, diagnostics",parameters:v.Object({action:yj(["diagnostics","definition","references","hover","symbols"],{description:"Which language-server query to run"}),file:v.String({description:"File to query, relative to the project root"}),line:v.Optional(v.Number({description:"1-based line (definition, references, hover)"})),symbol:v.Optional(v.String({description:"Substring to locate on that line when column is omitted"}))}),async execute(e,t,r,n,o){let i=await lT({action:t.action,file:t.file,line:t.line,symbol:t.symbol,root:o.cwd});return i.ok?{content:[{type:"text",text:i.text}],details:{action:t.action,count:i.count}}:{content:[{type:"text",text:i.error}],details:{error:i.error},isError:!0}}});import{defineTool as Vj}from"@netrodev/hxf-coding-agent";import{API as hj}from"typescript/unstable/async";import{SyntaxKind as Dt,visitEachChild as yT}from"typescript/unstable/ast";var xT=new Set([Dt.FunctionDeclaration,Dt.FunctionExpression,Dt.ArrowFunction,Dt.MethodDeclaration,Dt.Constructor,Dt.GetAccessor,Dt.SetAccessor]);function wo(e){return xT.has(e)}var Ij=new Set([Dt.AmpersandAmpersandToken,Dt.BarBarToken,Dt.QuestionQuestionToken]);function Em(e){if(e.kind!==Dt.BinaryExpression)return!1;let t=Ve(e,"operatorToken");return t!==void 0&&Ij.has(t.kind)}function Ve(e,t){let r=e[t];if(r&&typeof r=="object"&&typeof r.kind=="number")return r}function ji(e,t){let r=e[t];return Array.isArray(r)?r:[]}function hT(e,t){return ji(e,"modifiers").some(r=>r.kind===t)}function To(e){if(!e)return;let t=e.text;return typeof t=="string"?t:void 0}function bj(e,t){return e.getLineAndCharacterOfPosition(t).line+1}function Pp(e,t){let r=e.getLineAndCharacterOfPosition(t.getStart(e)),n=e.getLineAndCharacterOfPosition(t.end);return{startLine:r.line+1,startColumn:r.character+1,endLine:n.line+1,endColumn:n.character+1}}function Sm(e,t){t(e),yT(e,r=>(Sm(r,t),r))}function Di(e,t){t(e),yT(e,r=>(wo(r.kind)||Di(r,t),r))}var $j=xT;function Ej(e){let t=To(Ve(e,"name"));if(t)return t;let r=Ve(e,"parent");for(;r&&!$j.has(r.kind);){if(r.kind===Dt.VariableDeclaration||r.kind===Dt.PropertyAssignment){let n=To(Ve(r,"name"));if(n)return n}r=Ve(r,"parent")}return"<anonymous>"}function Sj(e){let t=[];return Sm(e,r=>{if(!wo(r.kind))return;let n=Pp(e,r);t.push({name:Ej(r),node:r,startLine:n.startLine,endLine:n.endLine})}),t}async function IT(e){let t=new Map;if(e.length===0)return t;let r=new hj({cwd:process.cwd()});try{let n=await r.updateSnapshot({openFiles:[...e]});for(let o of e)try{let i=await n.getDefaultProjectForFile(o);if(!i){t.set(o,{ok:!1,error:"no TypeScript project contains this file"});continue}let a=await i.program.getSourceFile(o);if(!a){t.set(o,{ok:!1,error:"the compiler could not read this file"});continue}let m=await i.program.getSyntacticDiagnostics(o);if(m.length>0){let c=m[0],p=bj(a,c.pos);t.set(o,{ok:!1,error:`line ${p}: ${c.text} (TS${c.code})`});continue}t.set(o,{ok:!0,sourceFile:a,functions:Sj(a)})}catch(i){t.set(o,{ok:!1,error:i instanceof Error?i.message:String(i)})}}finally{await r.close()}return t}import{SyntaxKind as Tr,visitEachChild as bT}from"typescript/unstable/ast";var kj=new Set([Tr.IfStatement,Tr.SwitchStatement,Tr.ForStatement,Tr.ForInStatement,Tr.ForOfStatement,Tr.WhileStatement,Tr.DoStatement,Tr.CatchClause]);function $T(e){let t=0,r=(o,i)=>{if(!wo(o.kind)){if(o.kind===Tr.IfStatement){n(o,i,!1);return}if(kj.has(o.kind)){t+=1+i,bT(o,a=>(r(a,i+1),a));return}Em(o)&&(t+=1),bT(o,a=>(r(a,i),a))}},n=(o,i,a)=>{a||(t+=1+i);let m=Ve(o,"expression");m&&r(m,i);let c=Ve(o,"thenStatement");c&&r(c,i+1);let p=Ve(o,"alternate");p&&(t+=1,p.kind===Tr.IfStatement?n(p,i,!0):r(p,i+1))};return r(e,0),t}import{SyntaxKind as Nr}from"typescript/unstable/ast";var Tj=new Set([Nr.IfStatement,Nr.ConditionalExpression,Nr.WhileStatement,Nr.DoStatement,Nr.ForStatement,Nr.ForInStatement,Nr.ForOfStatement,Nr.CatchClause,Nr.CaseClause]);function ET(e){let t=1;return Di(e,r=>{(Tj.has(r.kind)||Em(r))&&(t+=1)}),t}import{SyntaxKind as se}from"typescript/unstable/ast";var wj=new Set([se.BinaryExpression,se.PrefixUnaryExpression,se.PostfixUnaryExpression,se.ConditionalExpression,se.CallExpression,se.NewExpression,se.PropertyAccessExpression,se.ElementAccessExpression,se.AwaitExpression,se.YieldExpression,se.SpreadElement,se.IfStatement,se.WhileStatement,se.DoStatement,se.ForStatement,se.ForInStatement,se.ForOfStatement,se.SwitchStatement,se.ReturnStatement,se.ThrowStatement,se.TryStatement,se.BreakStatement,se.ContinueStatement]),Cj=new Set([se.StringLiteral,se.NumericLiteral,se.BigIntLiteral,se.RegularExpressionLiteral,se.NoSubstitutionTemplateLiteral]);function Ap(e,t){e.set(t,(e.get(t)??0)+1)}function ST(e){let t=new Map,r=new Map;Di(e,i=>{if(wj.has(i.kind)){let m=Ve(i,"operatorToken");Ap(t,se[i.kind]+(m?`:${se[m.kind]}`:""));return}let a=To(i);a!==void 0&&(i.kind===se.Identifier||i.kind===se.PrivateIdentifier?Ap(r,`id:${a}`):Cj.has(i.kind)&&Ap(r,`lit:${a}`))});let n=t.size+r.size;if(n===0)return 0;let o=0;for(let i of t.values())o+=i;for(let i of r.values())o+=i;return Math.round(o*Math.log2(n)*100)/100}function kT(e){return e.endLine-e.startLine+1}function TT(e,t,r){let n=171-5.2*Math.log(Math.max(e,1))-.23*t-16.2*Math.log(Math.max(r,1));return Math.round(Math.max(0,n*100/171)*10)/10}import{SyntaxKind as nr,visitEachChild as Rj}from"typescript/unstable/ast";var Pj=new Set([nr.IfStatement,nr.SwitchStatement,nr.WhileStatement,nr.DoStatement,nr.ForStatement,nr.ForInStatement,nr.ForOfStatement,nr.TryStatement,nr.CatchClause]);function wT(e){let t=0,r=(n,o)=>{if(wo(n.kind))return;let i=o;if(Pj.has(n.kind)&&(i=o+1,i>t&&(t=i)),n.kind===nr.IfStatement){let a=Ve(n,"expression");a&&r(a,i);let m=Ve(n,"thenStatement");m&&r(m,i);let c=Ve(n,"alternate");c&&r(c,c.kind===nr.IfStatement?o:i);return}Rj(n,a=>(r(a,i),a))};return r(e,0),t}import{spawnSync as Aj}from"node:child_process";import{mkdirSync as iFe,readdirSync as Oj,readFileSync as Mj,statSync as vj,writeFileSync as sFe}from"node:fs";import{extname as vp,join as vT,relative as FT,resolve as Fj}from"node:path";import{SyntaxKind as km}from"typescript/unstable/ast";var CT={"god-function":"split it into smaller functions, one job each",incomprehensible:"extract helpers and simplify the flow before touching it",bloated:"long but linear; extract helpers","deeply-tangled":"nesting, not branching; flatten with early returns",fragile:"many branches; add guard clauses and tests around it"};function RT(e,t){let r=[];return t.cyclomatic>=1&&t.length>=1&&t.nesting>=1&&r.push({id:"god-function",label:"God Function",reason:`high cyclomatic complexity (${e.cyclomatic}), long body (${e.length} lines), and deep nesting (${e.nesting}) \u2014 likely doing too many things`}),t.cognitive>=1&&t.halstead>=1&&t.mi>=1&&r.push({id:"incomprehensible",label:"Incomprehensible",reason:`high cognitive complexity (${e.cognitive}) and Halstead volume (${e.halstead}) with MI ${e.mi} \u2014 very hard to understand`}),t.length>=1&&t.halstead>=1&&t.cyclomatic===0&&r.push({id:"bloated",label:"Bloated",reason:`large function (${e.length} lines) with high vocabulary (Halstead ${e.halstead}) but low branching \u2014 consider extracting helpers`}),t.nesting>=1&&t.cognitive>=1&&t.cyclomatic===0&&r.push({id:"deeply-tangled",label:"Deeply Tangled",reason:`nesting depth ${e.nesting} drives cognitive complexity ${e.cognitive} \u2014 flatten with early returns or extracted helpers`}),t.cyclomatic>=1&&t.mi>=1&&t.length===0&&r.push({id:"fragile",label:"Fragile",reason:`high cyclomatic complexity (${e.cyclomatic}) with MI ${e.mi} \u2014 many branches, hard to change safely`}),r}var Lj=["ok","warn","error"],Dp=["cyclomatic","cognitive","nesting","length","halstead","mi","parameters","booleanParameters"];var qr={cyclomatic:{warn:15,error:25},cognitive:{warn:12,error:20},nesting:{warn:4,error:5},length:{warn:60,error:120},halstead:{warn:500,error:1e3},mi:{warn:65,error:20},fileLines:{warn:400,error:800},exports:{warn:20,error:30},parameters:{warn:5,error:8}};function LT(){let e={cyclomatic:{...qr.cyclomatic},cognitive:{...qr.cognitive},nesting:{...qr.nesting},length:{...qr.length},halstead:{...qr.halstead},mi:{...qr.mi},fileLines:{...qr.fileLines},exports:{...qr.exports},parameters:{...qr.parameters}};return{ignore:[],thresholds:e,ci:{failBelow:65,mode:"advisory"}}}var jj=["cyclomatic","cognitive","nesting","length","halstead","mi","fileLines","exports","parameters"];function Op(e){return typeof e=="number"&&Number.isFinite(e)}function Np(e){let t=LT(),r;try{r=JSON.parse(Mj(vT(e,".howtocode","quality.json"),"utf8"))}catch{return t}if(typeof r!="object"||r===null)return t;let n=r;if(typeof n.enabled=="boolean"&&(t.enabled=n.enabled),Array.isArray(n.ignore)&&(t.ignore=n.ignore.filter(o=>typeof o=="string")),typeof n.thresholds=="object"&&n.thresholds!==null){let o=n.thresholds;for(let i of jj){let a=o[i];if(typeof a!="object"||a===null)continue;let m=a;Op(m.warn)&&(t.thresholds[i].warn=m.warn),Op(m.error)&&(t.thresholds[i].error=m.error)}}if(typeof n.ci=="object"&&n.ci!==null){let o=n.ci;Op(o.failBelow)&&(t.ci.failBelow=o.failBelow),(o.mode==="advisory"||o.mode==="blocking")&&(t.ci.mode=o.mode)}return t}function jT(e,t){let r=process.env.HOWTOCODE_QUALITY;if(r!==void 0){let o=r.trim().toLowerCase();return o==="0"||o==="false"?{enabled:!1,source:"env"}:{enabled:!0,source:"env"}}let n=Np(e).enabled;return n!==void 0?{enabled:n,source:"config"}:t!==void 0?{enabled:t,source:"runtime"}:{enabled:!0,source:"default"}}function cn(e,t){return e>t.error?2:e>t.warn?1:0}function DT(e,t){return e<t.error?2:e<t.warn?1:0}function Dj(e){let t=[];for(let r of ji(e.node,"parameters"))Ve(r,"type")?.kind===km.BooleanKeyword&&t.push(To(Ve(r,"name"))??"<pattern>");return t}function Nj(e,t,r,n){let o=n.thresholds,i=Ve(e.node,"body")??e.node,a={cyclomatic:ET(i),cognitive:$T(i),nesting:wT(i),length:kT(e),halstead:ST(i),mi:0};a.mi=TT(a.halstead,a.cyclomatic,a.length);let m=Dj(e),c=ji(e.node,"parameters").length,p={cyclomatic:{value:a.cyclomatic,rank:cn(a.cyclomatic,o.cyclomatic)},cognitive:{value:a.cognitive,rank:cn(a.cognitive,o.cognitive)},nesting:{value:a.nesting,rank:cn(a.nesting,o.nesting)},length:{value:a.length,rank:cn(a.length,o.length)},halstead:{value:a.halstead,rank:cn(a.halstead,o.halstead)},mi:{value:a.mi,rank:DT(a.mi,o.mi)},parameters:{value:c,rank:cn(c,o.parameters)},booleanParameters:{value:m.length,rank:m.length>0?1:0}},f={cyclomatic:p.cyclomatic.rank,cognitive:p.cognitive.rank,nesting:p.nesting.rank,length:p.length.rank,halstead:p.halstead.rank,mi:p.mi.rank},d=Pp(t,e.node),g=0;for(let y of Dp)p[y].rank>g&&(g=p[y].rank);return{path:r,name:e.name,startLine:d.startLine,endLine:d.endLine,startColumn:d.startColumn,endColumn:d.endColumn,metrics:p,booleanParameterNames:m,smells:RT(a,f),worstRank:g}}function qj(e){let t=0;return Sm(e,r=>{if(r.kind===km.ExportDeclaration){let n=Ve(r,"exportClause"),o=n?ji(n,"elements"):[];t+=o.length>0?o.length:1;return}if(r.kind===km.ExportAssignment){t+=1;return}hT(r,km.ExportKeyword)&&(t+=1)}),t}function Uj(e){if(e.length===0)return 0;let t=1;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(t+=1);return e.charCodeAt(e.length-1)===10&&(t-=1),t}var PT={value:0,rank:0};function AT(e,t){return{path:e,ok:!1,error:t,lines:0,metrics:{lines:PT,exports:PT,mi:{value:100,rank:0}},functions:[]}}function Mp(e,t,r,n,o,i,a){i.rank!==0&&e.push({path:t.path,metric:o,detail:o==="booleanParameters"?r?.booleanParameterNames.join(", ")??String(i.value):`${i.value} (limit ${a})`,rank:i.rank,line:n.line,endLine:n.endLine,startColumn:n.startColumn,endColumn:n.endColumn,...r?{function:r.name}:{}})}async function NT(e,t=LT()){let r=await IT(e),n=new Map,o=[],i=t.thresholds;for(let a of e){let m=r.get(a);if(!m){let E=AT(a,"internal: file missing from the parse result");n.set(a,E),o.push({path:a,metric:"parse error",detail:E.error??"",rank:2,line:1,endLine:1,startColumn:1,endColumn:1});continue}if(!m.ok){let E=AT(a,m.error);n.set(a,E),o.push({path:a,metric:"parse error",detail:m.error,rank:2,line:1,endLine:1,startColumn:1,endColumn:1});continue}let{sourceFile:c}=m,p=m.functions.map(E=>Nj(E,c,a,t)),f=Uj(c.text),d=qj(c),g=p.reduce((E,b)=>E+b.metrics.length.value,0),y=g===0?100:Math.round(p.reduce((E,b)=>E+b.metrics.mi.value*b.metrics.length.value,0)/g*10)/10,I={path:a,ok:!0,lines:f,metrics:{lines:{value:f,rank:cn(f,i.fileLines)},exports:{value:d,rank:cn(d,i.exports)},mi:{value:y,rank:DT(y,i.mi)}},functions:p};n.set(a,I);let h={line:1,endLine:Math.max(f,1),startColumn:1,endColumn:1};Mp(o,I,void 0,h,"file lines",I.metrics.lines,i.fileLines.warn),Mp(o,I,void 0,h,"exports",I.metrics.exports,i.exports.warn);for(let E of p){let b={line:E.startLine,endLine:E.endLine,startColumn:E.startColumn,endColumn:E.endColumn};for(let C of Dp)Mp(o,I,E,b,C,E.metrics[C],qT(C,i));for(let C of E.smells)o.push({path:a,metric:"smell",detail:`${C.label}: ${C.reason}`,rank:1,line:E.startLine,endLine:E.endLine,startColumn:E.startColumn,endColumn:E.endColumn,function:E.name})}}return{files:n,findings:o}}function qp(e){let t=0,r=0;for(let n of e.files.values())if(n.ok)for(let o of n.functions)t+=o.metrics.length.value,r+=o.metrics.mi.value*o.metrics.length.value;return t===0?100:Math.round(r/t*10)/10}function Up(e){let t=0,r=0,n=0,o=0;for(let i of e.files.values())i.ok||(t+=1),r+=i.functions.length;for(let i of e.findings)i.rank>=2?o+=1:n+=1;return{files:e.files.size,errorFiles:t,functions:r,findings:e.findings.length,warn:n,error:o,score:qp(e)}}var _j=["ok","\u26A0","\u2717"],Bj=[["cyclomatic","cyclomatic"],["cognitive","cognitive"],["nesting","nesting"],["length","length"],["halstead","halstead"],["mi","MI"],["parameters","parameters"],["booleanParameters","boolean params"]];function qT(e,t){return e==="mi"?t.mi.warn:e==="booleanParameters"?t.parameters.warn:t[e].warn}function Fp(e,t,r,n){return`${e}${t.padEnd(15)} ${r.value} (limit ${n}) ${Lj[r.rank]}`}function Gj(e,t){let r=[` ${e.name.padEnd(30)} L${e.startLine}-${e.endLine}`];for(let[n,o]of Bj){let i=e.metrics[n];if(i.rank!==0){if(n==="booleanParameters"){r.push(` ${o.padEnd(15)} ${e.booleanParameterNames.join(", ")} warn`);continue}r.push(Fp(" ",o,i,qT(n,t.thresholds)))}}if(e.smells.length>0){r.push(` ${"smells".padEnd(15)} ${e.smells.map(n=>n.id).join(", ")}`);for(let n of e.smells)r.push(` \u2192 ${CT[n.id]??n.label}`)}return r}function OT(e){let t=e.smells.length;for(let r of Dp)e.metrics[r].rank>0&&(t+=1);return t}function Kj(e,t){let r=[];for(let o of e.files.values())for(let i of o.functions)i.worstRank>0&&r.push(i);r.sort((o,i)=>{if(o.worstRank!==i.worstRank)return i.worstRank-o.worstRank;let a=OT(i)-OT(o);if(a!==0)return a;let m=i.metrics.cyclomatic.value-o.metrics.cyclomatic.value;return m!==0?m:`${o.path}:${o.name}`.localeCompare(`${i.path}:${i.name}`)});let n=new Map;for(let o of r.slice(0,t)){let i=n.get(o.path)??new Set;i.add(`${o.name}@${o.startLine}`),n.set(o.path,i)}return n}function UT(e,t,r={}){let n=Up(e),o=r.top&&r.top>0?Kj(e,r.top):void 0,i=[...e.files.values()].filter(p=>!o||(o.get(p.path)?.size??0)>0),a=Math.max(40,...i.map(p=>p.path.length)),m=[];for(let p of i){if(!p.ok){m.push(`${p.path.padEnd(a)} parse error`),m.push(` ${p.error}`);continue}m.push(`${p.path.padEnd(a)} MI ${p.metrics.mi.value} ${_j[p.metrics.mi.rank]}`),p.metrics.lines.rank>0&&m.push(Fp(" ","file lines",p.metrics.lines,t.thresholds.fileLines.warn)),p.metrics.exports.rank>0&&m.push(Fp(" ","exports",p.metrics.exports,t.thresholds.exports.warn));for(let f of p.functions)o&&!o.get(p.path)?.has(`${f.name}@${f.startLine}`)||f.worstRank===0&&f.smells.length===0||m.push(...Gj(f,t))}m.length>0&&m.push("");let c=n.errorFiles>0?`, ${n.errorFiles} parse error(s)`:"";return m.push(`${n.findings} findings in ${n.files} files${c} \xB7 ${n.functions} functions \xB7 score ${n.score}`),m.join(`
|
|
133
|
-
`)}var Lp=new Set([".ts",".tsx",".mts",".cts"]),Hj=new Set(["node_modules","dist","coverage"]);function jp(e,t,r){for(let n of Oj(e,{withFileTypes:!0})){let o=vT(e,n.name);if(n.isDirectory()){if(n.name.startsWith(".")||Hj.has(n.name))continue;jp(o,t,r);continue}n.isFile()&&Lp.has(vp(n.name))&&r.push(FT(t,o))}}function MT(e,t){let r=Aj("git",["-C",e,...t],{encoding:"utf8"});if(r.error||r.status!==0){let n=r.error?r.error.message:r.stderr.trim()||`exit ${r.status}`;throw new Error(`git ${t.join(" ")} failed: ${n}`)}return r.stdout.split(`
|
|
134
|
-
`).filter(n=>n.trim().length>0)}function zj(e,t){let r=MT(e,["diff","--name-only","--diff-filter=ACMR",t]),n=MT(e,["ls-files","--others","--exclude-standard"]);return[...r,...n]}function Wj(e,t){if(!t.includes("*")){let n=t.endsWith("/")?t:`${t}/`;return e===t||e.startsWith(n)}let r=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"\0").replace(/\*/g,"[^/]*").replace(/\u0000/g,".*");return new RegExp(`^${r}$`).test(e)}function _T(e,t,r=[]){let n;if(t.changes)n=zj(e,t.base??"HEAD");else if(t.target){let i=Fj(e,t.target),a=vj(i,{throwIfNoEntry:!1});if(!a)throw new Error(`no such path: ${t.target}`);if(a.isDirectory())n=[],jp(i,e,n);else{if(!Lp.has(vp(i)))throw new Error(`not a TypeScript source file: ${t.target}`);n=[FT(e,i)]}}else n=[],jp(e,e,n);let o=new Set;for(let i of n)Lp.has(vp(i))&&(r.some(a=>Wj(i,a))||o.add(i));return[...o].sort()}var BT=6e3,GT=Vj({name:"quality",label:"quality",description:"Measure code quality: cyclomatic and cognitive complexity, nesting depth, function length, Halstead volume, maintainability index, and compound smells like god-function and deeply-tangled. Read-only. Use it before reporting a task finished, especially on functions you just wrote or changed; it reports concrete numbers with line numbers and a suggested next step, so 'is this too complex' stops being a guess. Defaults to the changed files; pass a path to narrow it further.",promptSnippet:"quality: complexity and maintainability metrics for changed code",parameters:v.Object({path:v.Optional(v.String({description:"One file or directory, relative to the project root. Omit to scan the changed set."})),changes:v.Optional(v.Boolean({description:"Scan only files changed against the base ref. Default true when path is omitted."})),base:v.Optional(v.String({description:"Git ref for `changes`. Defaults to HEAD."})),top:v.Optional(v.Number({description:"Only report the N worst functions."}))}),async execute(e,t,r,n,o){let i=o.cwd??process.cwd(),a=jT(i);if(!a.enabled)return{content:[{type:"text",text:`quality metrics are off (source: ${a.source})`}],details:{off:!0}};let m=Np(i),c=t.changes??t.path===void 0,p=_T(i,{changes:c,base:t.base,target:t.path},m.ignore);if(p.length===0)return{content:[{type:"text",text:c?"no changed files to measure":"no source files found"}],details:{files:0}};let f=await NT(p,m),d=Up(f),g=UT(f,m,{top:t.top});return{content:[{type:"text",text:g.length>BT?`${g.slice(0,BT)}
|
|
135
|
-
\u2026 (truncated; run the quality script for the full report)`:g}],details:{files:d.files,functions:d.functions,findings:d.findings,score:qp(f)}}}});import{availableParallelism as Jj}from"node:os";var Yj=4;function Qj(){let e=pf(Ye).agents;return e!==void 0?e:Math.max(1,Math.min(Yj,Jj()-2))}var _p=0,KT=[];async function Tm(){for(;_p>=Qj();)await new Promise(t=>KT.push(t));_p+=1;let e=!1;return()=>{e||(e=!0,_p-=1,KT.shift()?.())}}function HT(e,t){let r=e.find(o=>`${o.provider}/${o.id}`===t||o.id===t);if(r)return r;let n=t.toLowerCase();return e.find(o=>o.id.toLowerCase().includes(n)||`${o.provider}/${o.id}`.toLowerCase().includes(n))}var Xj=["deepseek","qwen","claude","gpt-5","gpt-4","gemini","glm","mimo","kimi","llama"],Zj=/(image|embedding|embed|whisper|tts|audio|video|rerank|moderation|dall-e|stable-diffusion|sora)/i;function eD(e){let t=r=>{if(Zj.test(r))return 100;let n=Xj.findIndex(o=>r.toLowerCase().includes(o));return n===-1?50:n};return e.map((r,n)=>({id:r,index:n})).sort((r,n)=>t(r.id)-t(n.id)||r.index-n.index).map(r=>r.id)}function jFe(e,t=[]){if(e.length===0)return;let r=e.filter(i=>t.includes(i.provider)),n=r.length>0?r:e,o=eD(n.map(i=>i.id))[0];return n.find(i=>i.id===o)??n[0]}import{mkdirSync as tD,readdirSync as rD,readFileSync as nD,unlinkSync as oD}from"node:fs";import{join as Gp}from"node:path";import{createAgentSession as iD,DefaultResourceLoader as sD,SessionManager as aD}from"@netrodev/hxf-coding-agent";var Bp=["You are one agent on a shared task; siblings may be editing the same working tree right now.","Stay inside the files your assignment names. A file another agent owns is theirs to change: report what you need changed instead of changing it yourself, and never edit a file two agents were both given.","Never run project-wide validation (full builds, whole test suites, formatters, linters) unless your assignment explicitly tells you to.","Siblings' unfinished edits will make those runs fail for reasons that are not yours. Prove your own change with a scoped test, a targeted repro, or a smoke run instead."],mD=`You are a software architect planning an implementation. Your job is to explore the codebase and return a plan, not to write code.
|
|
136
|
-
|
|
137
|
-
## Read-only, by construction
|
|
138
|
-
You have no edit tool, no write tool, and no shell. Do not attempt to modify, create, move, or delete anything \u2014 the call would fail. Your output is text.
|
|
139
|
-
|
|
140
|
-
## Your process
|
|
141
|
-
1. Understand the requirement. If it is ambiguous in a way that changes the design, say so and name the options rather than silently picking one.
|
|
142
|
-
2. Explore: read the files involved, find the existing patterns and conventions with grep/find/ls, and trace the code paths the change touches. Follow the codebase's existing approach instead of inventing a new one.
|
|
143
|
-
3. Design: state the approach you recommend, not every alternative you considered. Note the trade-off that decided it.
|
|
144
|
-
4. Sequence: give the implementation as ordered steps, naming the files and functions to change at each one, and what to verify after each.
|
|
145
|
-
|
|
146
|
-
## Required output
|
|
147
|
-
End your reply with exactly this section, listing the 3-5 files most critical to the implementation, most important first:
|
|
148
|
-
|
|
149
|
-
### Critical Files for Implementation
|
|
150
|
-
- path/to/file.ts
|
|
151
|
-
- path/to/file.ts
|
|
152
|
-
|
|
153
|
-
Keep the plan concrete enough to execute without re-deriving it: name real paths and real function names you saw while exploring. If you could not confirm something, say which part you are unsure of instead of guessing.`,pn=new Map([["scout",{name:"scout",description:"read-only lookup",tools:["read","grep","find","ls","context","web_search","web_fetch","lsp"],prompt:["Inspect only what the task needs. Do not edit.",...Bp].join(`
|
|
154
|
-
`),effort:"low"}],["architect",{name:"architect",description:"designs an implementation plan",tools:["read","grep","find","ls","context","web_search","web_fetch","lsp"],prompt:mD,effort:"high"}],["task",{name:"task",description:"implements the assignment",tools:["read","bash","edit","write","grep","find","ls","context","todo","web_search","web_fetch","lsp"],prompt:["Do the assignment, then report files changed.",...Bp].join(`
|
|
155
|
-
`),effort:"medium"}],["reviewer",{name:"reviewer",description:"finds concrete issues",tools:["read","grep","find","ls","context","web_search","web_fetch","lsp"],prompt:["Return issues with file evidence. Do not edit.",...Bp].join(`
|
|
156
|
-
`),effort:"medium"}]]),e1e=new Set(pn.keys());function uD(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function cD(e){return e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${(e%6e4/1e3).toFixed(1)}s`}function t1e(e){let t=e.status==="parked"?"done":e.status==="error"?"failed":e.status,r=[];return e.model&&r.push(e.model),typeof e.toolUses=="number"&&r.push(`${e.toolUses} tool use${e.toolUses===1?"":"s"}`),typeof e.tokens=="number"&&e.tokens>0&&r.push(uD(e.tokens)),e.startedAt&&e.endedAt&&r.push(cD(e.endedAt-e.startedAt)),`## ${e.agent}#${e.id} ${t}${r.length>0?` (${r.join(" \xB7 ")})`:""}`}var Rt=[],pD=3,zT=8,r1e=6,wm=12;function Cm(e){tD(jn,{recursive:!0}),sr(Gp(jn,`${e.id}.json`),JSON.stringify({...e,session:void 0},null,1))}function Kp(){let e;try{e=rD(jn)}catch{return}for(let t of e)if(t.endsWith(".json"))try{let r=JSON.parse(nD(Gp(jn,t),"utf8"));if(r.status!=="parked"||Rt.some(n=>n.id===r.id))continue;Rt.push({...r,mail:r.mail??[]})}catch{}if(Rt.length>wm){let t=Rt.splice(0,Rt.length-wm);for(let r of t){let n=r.session;r.session=void 0,n&&n.dispose();try{oD(Gp(jn,`${r.id}.json`))}catch{}}}}function n1e(){if(Kp(),Rt.length===0)return"no agents";let e=Rt.map(t=>`${t.id} ${t.agent} ${t.status}${t.model?` model=${t.model}`:""}${t.background?" background":""} requests=${t.requests} ${t.task}`);return Co&&e.unshift("background work in flight"),e.join(`
|
|
157
|
-
`)}function o1e(e){Kp();let t=Rt.find(r=>r.id===e);return t?`${t.agent}#${t.id} ${t.status}
|
|
158
|
-
${t.result??t.task}`:`no agent ${e}`}async function Rm(e){let t=pn.get(e.agent);if(!t)throw new Error(`unknown agent ${e.agent}`);let r=e.worktree||e.cwd||process.cwd(),n=new sD({cwd:r,agentDir:Ye,appendSystemPrompt:[t.prompt],additionalSkillPaths:uf(r),extensionFactories:[cf({interactive:!1}),bk()]});await n.reload();let{session:o}=await iD({cwd:r,agentDir:Ye,sessionManager:aD.inMemory(r),resourceLoader:n,tools:t.tools,customTools:[ak,nk,nT,oT,gT,GT,ek],thinkingLevel:e.effort}),i=fD(e,t);if(i){let a=await o.modelRuntime.getAvailable(),m=HT(a,i);if(!m){o.dispose();let c=e.model?"asked for by the task":t.model?`named by the ${e.agent} definition${t.source?` (${t.source})`:""}`:"inherited from the parent session";throw new Error(`unknown model '${i}' ${c}. /model lists what this account can reach.`)}await o.setModel(m)}return o}async function i1e(e,t){Kp();let r=Rt.find(o=>o.id===e);if(!r)return`no agent ${e}`;let n=r.session??await Rm(r);if(r.session=n,r.status==="running"||n.isStreaming)return r.mail.push(t),Cm(r),`queued for ${e}`;if(r.requests>=zT)return`${e} is out of budget (${r.requests} requests)`;r.status="running";try{await n.prompt(t),r.requests+=1,r.result=vo(n.getLastAssistantText()??"")||r.result,r.status="parked"}catch(o){r.result=o instanceof Error?o.message:String(o),r.status="error"}return Cm(r),`${e} ${r.status}`}function fD(e,t){for(let r of[e.model,t.model,e.parentModel]){let n=r?.trim();if(n)return n}}function WT(e){if(!(!e?.provider||!e.id))return`${e.provider}/${e.id}`}async function s1e(e){let t=pn.get(e.agent);if(!t)throw new Error(`unknown agent ${e.agent}. known: ${[...pn.keys()].join(", ")}`);if(Rt.length>=wm)throw new Error(`${wm} agents is the limit (${Rt.length} live or parked). Finish with the existing ones, or clear them with /agents, before spawning more.`);let r={id:`${Date.now().toString(36)}-${Rt.length+1}`,cwd:e.cwd,agent:t.name,task:e.task.trim(),effort:e.effort||t.effort,model:(e.model||t.model)?.trim()||void 0,parentModel:e.parentModel?.trim()||void 0,background:e.background,status:"queued",requests:0,mail:[],worktree:e.worktree};return Rt.push(r),Cm(r),r}async function dD(e,t){if(!pn.get(e.agent))return;let n=e.session??await Rm(e);e.session=n,e.startedAt=Date.now();try{let o=e.mail.splice(0).join(`
|
|
159
|
-
`);for(await n.prompt(`Task:
|
|
160
|
-
${e.task}${o?`
|
|
161
|
-
|
|
162
|
-
Messages:
|
|
163
|
-
${o}`:""}`),e.requests+=1;e.mail.length>0&&e.requests<zT;)await n.followUp(e.mail.splice(0).join(`
|
|
164
|
-
`)),e.requests+=1;if(t?.aborted)throw new Error("aborted");let i=vo(n.getLastAssistantText()??""),a=n.getSessionStats?.();if(!i&&(a?.toolCalls??0)===0)throw new Error(`agent produced no output (model ${n.model?.provider}/${n.model?.id} answered nothing; 0 tool calls). Check that the provider is reachable and the model is configured.`);e.result=i,e.status="parked"}catch(o){e.result=o instanceof Error?o.message:String(o),e.status="error"}finally{e.endedAt=Date.now();let o=n.getSessionStats?.();e.toolUses=o?.toolCalls,e.tokens=o?.tokens?.total,e.session=void 0,n.dispose(),Cm(e);try{VT?.(e)}catch{}}}var VT;function a1e(e){VT=e}var Co;function m1e(){Co||(Co=lD().catch(()=>{}).finally(()=>{Co=void 0}))}async function lD(e){Co&&await Co.catch(()=>{});let t=()=>Rt.find(n=>n.status==="queued"),r=async()=>{for(;;){if(e?.aborted)throw new Error("aborted");let n=t();if(!n)return;n.status="running";let o=await Tm();try{await dD(n,e)}finally{o()}}};if(await Promise.all(Array.from({length:pD},r)),e?.aborted)throw new Error("aborted")}import{execFile as gD}from"node:child_process";import{cp as yD,readdir as xD,stat as JT}from"node:fs/promises";import{promisify as hD}from"node:util";import{tmpdir as ID}from"node:os";import{join as Pm}from"node:path";var YT=hD(gD);async function zt(e,t){try{let{stdout:r}=await YT("git",t,{cwd:e,encoding:"utf8",maxBuffer:8388608});return{ok:!0,output:r.trim()}}catch(r){let n=r&&typeof r=="object"&&"stderr"in r&&typeof r.stderr=="string"?r.stderr.trim():"",o=r instanceof Error?r.message:String(r);return{ok:!1,output:n||o}}}async function bD(e){return(await zt(e,["rev-parse","--is-inside-work-tree"])).output==="true"}async function g1e(e){return(await zt(e,["status","--porcelain"])).output.length>0}async function y1e(e,t){let r=await zt(e,["add","-A"]);if(!r.ok)return r;let n=await zt(e,["commit","-m",t]);return n.ok?{ok:!0,output:(await zt(e,["log","-1","--oneline"])).output||n.output}:n}async function x1e(e){let t=await zt(e,["reset","--soft","HEAD~1"]);return t.ok?{ok:!0,output:(await zt(e,["log","-1","--oneline"])).output||"reset to the previous commit"}:t}async function h1e(e){let t=(await zt(e,["diff"])).output,r=(await zt(e,["diff","--cached"])).output;return[t,r].filter(Boolean).join(`
|
|
165
|
-
`)}function I1e(e,t=60){let r=e.split(`
|
|
166
|
-
`);if(r.length<=t)return e;let n=r.slice(0,t),o=r.length-t;return[...n,`\u2026 ${o} more line${o===1?"":"s"} not shown \u2014 /copy puts the full diff on the clipboard`].join(`
|
|
167
|
-
`)}var $D=["node_modules","vendor","target",".venv","venv","__pycache__",".pnpm-store","dist","build"],QT=1024*1024*1024;async function XT(e){let t=0,r;try{r=await xD(e,{withFileTypes:!0})}catch{return 0}for(let n of r){let o=Pm(e,n.name);if(n.isDirectory())t+=await XT(o);else if(n.isFile())try{t+=(await JT(o)).size}catch{}if(t>QT)return t}return t}async function ED(e,t){let r=[];for(let n of $D){let o=Pm(e,n),i=Pm(t,n);try{if(!(await JT(o)).isDirectory())continue}catch{continue}if(await XT(o)>QT){r.push(n);continue}await SD(o,i)||r.push(n)}return r}async function SD(e,t){if(process.platform!=="win32")try{return await YT("cp",["-a",e,t],{maxBuffer:8*1024*1024}),!0}catch{}try{return await yD(e,t,{recursive:!0,force:!0,errorOnExist:!1,dereference:!1}),!0}catch{return!1}}async function ZT(e,t){if(!await bD(e))return null;let r=t.replace(/[^A-Za-z0-9._-]/g,"-").slice(0,40)||"agent",n=Pm(ID(),`howtocode-wt-${process.pid}-${Date.now()}-${r}`);if(!(await zt(e,["worktree","add","--detach",n,"HEAD"])).ok)return null;let i=await ED(e,n);return{path:n,skipped:i,async remove(){await zt(e,["worktree","remove","--force",n]),await zt(e,["worktree","prune"])}}}import{detectCapabilities as kD,getTerminalColorMode as TD,parseColor as Ur,styleText as ew}from"@netrodev/hxf-tui";function wD(){let e=process.env.NO_COLOR;if(e!==void 0&&e!=="")return"256color";try{return TD(kD())}catch{return"256color"}}var tw=wD();function CD(){let e=process.env.NO_COLOR;return e!==void 0&&e!==""}var _e={text:Ur("#e6e6e6"),mute:Ur("#8b8b8b"),dim:Ur("#5c5c5c"),user:Ur("#d0d0d0"),accent:Ur("#c4b5fd"),tool:Ur("#6ee7b7"),bad:Ur("#f0a8a4"),warn:Ur("#e6b15a"),line:Ur("#3a3a3a")};function RD(e,t){if(CD()){let{bold:r,dim:n,italic:o,underline:i,strikethrough:a}=t;return!r&&!n&&!o&&!i&&!a?e:ew(e,{bold:r,dim:n,italic:o,underline:i,strikethrough:a},tw)}return ew(e,t,tw)}function mt(e,t,r){return RD(e,{...r,fg:t})}var E1e={heading:e=>mt(e,_e.text,{bold:!0}),link:e=>mt(e,_e.accent,{underline:!0}),linkUrl:e=>mt(e,_e.mute),code:e=>mt(e,_e.text),codeBlock:e=>mt(e,_e.text),codeBlockBorder:e=>mt(e,_e.line),quote:e=>mt(e,_e.mute,{italic:!0}),quoteBorder:e=>mt(e,_e.line),hr:e=>mt(e,_e.line),listBullet:e=>mt(e,_e.mute),bold:e=>mt(e,_e.text,{bold:!0}),italic:e=>mt(e,_e.text,{italic:!0}),strikethrough:e=>mt(e,_e.mute,{strikethrough:!0}),underline:e=>mt(e,_e.text,{underline:!0})};import{truncateToWidth as qi,visibleWidth as or}from"@netrodev/hxf-tui";var rw={text:_e.text,muted:_e.mute,dim:_e.dim,accent:_e.accent,success:_e.tool,error:_e.bad,border:_e.line},ae=(e,t,r=!1)=>r?mt(t,rw[e],{bold:!0}):mt(t,rw[e]),PD=25,AD=15e5,ow=420;function Po(e){let t=Math.max(0,Math.round(e/1e3)),r=Math.floor(t/3600),n=Math.floor(t%3600/60),o=t%60;return r>0?`${r}h${String(n).padStart(2,"0")}m`:n>0?`${n}m${String(o).padStart(2,"0")}s`:`${o}s`}function w1e(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function Wp(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}var Ni=(e,t,r)=>Math.max(t,Math.min(r,e)),Ro=(e,t)=>or(e)>t?qi(e,Math.max(0,t),"\u2026"):e;function Am(e,t,r="left"){if(t<=0)return"";let n=or(e);if(n>t)return qi(e,t);let o=" ".repeat(t-n);return r==="right"?o+e:e+o}function Vp(e,t,r,n=1){if(r<=0)return"";let o=or(t);if(o>=r)return qi(t,r);let i=r-o-n;if(i<=0)return Am(t,r,"right");let a=or(e)>i?qi(e,i):e,m=" ".repeat(r-or(a)-o);return a+m+t}function Hp(e,t,r){let n=Ro(e,Math.max(0,r-2)),o=Math.max(1,r-1-or(n)),i=ae("border","\u250C\u2500 ")+ae("accent",n)+ae("border",` ${"\u2500".repeat(o)}\u2510`),a=ae("border",`\u2514${"\u2500".repeat(r+2)}\u2518`),m=ae("border","\u2502"),c=t.map(p=>`${m} ${Am(p,r)} ${m}`);return[i,...c,a]}function OD(e,t,r,n){let o=n?.gap??1,i=n?.leftWidth??Ni(Math.round(r*.38),28,44),a=r-i-o,m=Math.max(e.rows.length,t.rows.length),c=g=>{let y=[...g];for(;y.length<m;)y.push("");return y},p=Hp(e.title,c(e.rows),i-4),f=Hp(t.title,c(t.rows),a-4),d=" ".repeat(o);return p.map((g,y)=>g+d+(f[y]??Am("",a)))}function iw(e,t,r){switch(e){case"running":return ae(t||r?"accent":"muted","\u25CF");case"failed":return ae("error","\u2717");default:return ae("success","\u2713")}}function sw(e,t,r,n=Date.now(),o=0){return t?n-o<ow?ae("success","\u2713",!0):ae("success","\u2713"):ae(r?"accent":"dim",String(e))}var nw="Workflow";function Jp(e,t=Date.now()){let r=e.phases.map(o=>o.title),n=new Map(e.phases.map(o=>[o.title,o.detail]));for(let o of e.steps){let i=o.phase||nw;r.includes(i)||r.push(i)}return r.map((o,i)=>{let a=e.steps.filter(I=>(I.phase||nw)===o).map(I=>({...I,phaseIndex:i})),m=a.filter(I=>I.status!=="running").length,c=a.filter(I=>I.status==="failed").length,p=a.reduce((I,h)=>{let E=h.endedAt??t;return Math.max(I,E-h.startedAt)},0),f=-1;for(let I=0;I<a.length;I++){let h=a[I];h.status==="running"&&(f<0||h.startedAt>=a[f].startedAt)&&(f=I)}let d=n.get(o),g=a.length>0&&m===a.length&&c===0,y=g?a.reduce((I,h)=>Math.max(I,h.endedAt??0),0):0;return{title:o,...d?{detail:d}:{},agents:a,done:m,failed:c,outputTokens:a.reduce((I,h)=>I+h.outputTokens,0),elapsedMs:p,allDone:g,finishedAt:y,anchor:f}})}function Yp(e){return e.steps.reduce((t,r)=>t+r.outputTokens,0)}function MD(e){return e.steps.reduce((t,r)=>t+(r.toolCalls??0),0)}function aw(e,t=Date.now()){return Math.max(0,(e.endedAt??t)-e.startedAt)}function vD(e){return e.steps.length>PD||Yp(e)>AD}function FD(e){if(e.length===0)return 0;let t=e.map((r,n)=>({group:r,index:n})).filter(r=>r.group.anchor>=0);if(t.length>0)return t.reduce((r,n)=>{let o=n.group.agents[n.group.anchor],i=r.group.agents[r.group.anchor];return o.startedAt>=i.startedAt?n:r}).index;for(let r=e.length-1;r>=0;r--)if(e[r].agents.length>0)return r;return e.length-1}function mw(e,t=Date.now()){let r=Jp(e,t),n=e.steps.length,o=e.steps.filter(p=>p.status!=="running").length,i=e.steps.filter(p=>p.status==="failed").length,a=[e.name],m=r.find(p=>p.anchor>=0);m?a.push(`${m.title} ${m.done}/${m.agents.length}`):r.length>0&&a.push(`${r[r.length-1].title} done`),a.push(`${o}/${n} agents`),a.push(`${Wp(Yp(e))} tok`),a.push(Po(aw(e,t))),i>0&&a.push(`${i} failed`);let c=a.join(" \xB7 ");return vD(e)?`large workflow \xB7 ${c}`:c}var uw=16,LD=12,jD=18,DD=72,ND=24;function cw(e,t){if(e.status==="running"&&e.outputTokens===0)return[`idle ${Po(t-e.startedAt)}`,"idle"];let r=Wp(e.outputTokens),n=e.toolCalls??0,o=Po((e.endedAt??t)-e.startedAt);return[`${r} tok \xB7 ${n} tools \xB7 ${o}`,`${r} tok \xB7 ${n} tools`,`${r} tok`]}var qD=e=>e.status==="running"&&e.outputTokens===0;function zp(e,t,r){if(e.length<=r)return{slice:e,start:0,more:0};let n=Math.max(1,r-1),o=Ni(t-Math.floor(n/2),0,e.length-n),i=e.slice(o,o+n);return{slice:i,start:o,more:e.length-i.length}}function UD(e,t,r,n,o){let i=`${e.done}/${e.agents.length}`,a=r?ae("accent","\u276F"):" ",m=sw(t+1,e.allDone,r,o,e.finishedAt),c=Math.max(0,n-4-or(i)),p=or(e.title)>c?qi(e.title,c,"\u2026"):e.title,f=e.allDone&&o-e.finishedAt<ow,d=ae(f&&!r?"success":r?"accent":"text",p),g=`${a}${m} ${d}`,y=ae(r?"accent":"muted",i);return Vp(g,y,n,1)}function _D(e,t,r,n,o,i){let a=t?ae("accent","\u276F"):" ",m=iw(e.status,t,r),c=ae(t?"accent":"text",Am(e.label,n)),p=`${a}${m} ${c}`,f=Math.max(0,o-or(p)-1),d=cw(e,i).find(y=>or(y)<=f)??"",g=ae(t?"accent":qD(e)?"dim":"muted",d);return Vp(p,g,o,1)}function BD(e,t,r,n){let o=[];return e.forEach((i,a)=>{let c=`${sw(a+1,i.allDone,a===r,n,i.finishedAt)} ${ae(a===r?"accent":"text",i.title)} ${ae("muted",`${i.done}/${i.agents.length}`)}`;o.push(Ro(c,t));let{slice:p,more:f}=zp(i.agents,0,uw);p.forEach((d,g)=>{let y=iw(d.status,!1,g===i.anchor),I=cw(d,n)[0]??"";o.push(Ro(` ${y} ${ae("text",d.label)} ${ae("muted",I)}`,t))}),f>0&&o.push(Ro(` ${ae("dim",`\u2026+${f} more`)}`,t))}),o}function GD(e,t,r){let n=r?.now??Date.now(),o=Jp(e,n),i=e.steps,a=i.filter(lt=>lt.status!=="running").length,m=i.filter(lt=>lt.status==="failed").length,c=[`${a}/${i.length} agents`,`${Wp(Yp(e))} tok`,`${MD(e)} tools`,Po(aw(e,n)),...m>0?[`${m} failed`]:[]].join(" \xB7 "),p=[Vp(ae("accent",e.name,!0),ae("muted",c),t,2),...e.description?[ae("muted",Ro(e.description,t))]:[]],f=r?.footer?[ae("muted",Ro(r.footerText??KD(),t))]:[];if(o.length===0)return[...p,...Hp("Phases",["(no agents yet)"],Math.max(0,t-4)),...f];let d=Ni(r?.selectedPhase??FD(o),0,Math.max(0,o.length-1)),g=Ni(Math.round(t*.38),28,44),y=t-g-1-4;if(t<DD||y<ND)return[...p,...BD(o,t,d,n),...f];let I=o[d],{slice:h,start:E,more:b}=zp(o,d,LD),C=h.map((lt,ir)=>UD(lt,E+ir,E+ir===d,g-4,n));b>0&&C.push(ae("dim",`\u2026+${b} more`));let k=r?.filter?r.filter(I.agents):I.agents,z=k.length?Ni(Math.max(...k.map(lt=>or(lt.label))),6,jD):6,{slice:oe,more:ee}=zp(k,0,r?.agentWindow??uw),_=oe.map((lt,ir)=>_D(lt,!1,ir===I.anchor,z,y,n));ee>0&&_.push(ae("dim",`\u2026+${ee} more`));let qt=OD({title:"Phases",rows:C},{title:`${I.title} \xB7 ${k.length} agents${r?.filterLabel??""}`,rows:_},t,{leftWidth:g,gap:1});return[...p,...qt,...f]}function C1e(e,t=[],r=96,n,o){let i=GD(e,r,{now:e.endedAt??Date.now(),footer:!0,...n===void 0?{}:{selectedPhase:n},...o?.filter?{filter:o.filter}:{},...o?.footerText?{footerText:o.footerText}:{},...o?.filterLabel?{filterLabel:o.filterLabel}:{}}),a=new Set(t);if(o?.drill){let c=Jp(e,e.endedAt??Date.now()),p=c[Math.max(0,Math.min(c.length-1,n??0))];for(let f of p?.agents??[])a.add(f.label)}if(a.size===0)return i;let m=[];for(let c of e.steps)if(a.has(c.label)){for(let p of c.tasks??[]){let f=p.status==="completed"?"[x]":p.status==="in_progress"?"[>]":"[ ]";m.push(` ${ae("muted",f)} ${ae("text",p.content)}`)}c.detail&&m.push(` ${ae("dim",c.detail)}`)}return m.length===0?i:[...i.slice(0,-1),...m,i[i.length-1]]}function KD(){return"\u2191/\u2193 phase \xB7 Enter drill in \xB7 Esc back out \xB7 f filter by status \xB7 p pause \xB7 x stop \xB7 s save script"}import{readFileSync as XD}from"node:fs";import{basename as ZD}from"node:path";import{StringEnum as eN}from"@netrodev/hxf-ai";import{defineTool as tN}from"@netrodev/hxf-coding-agent";var Ln=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function pw(e){return e===null?"null":Array.isArray(e)?"array":Number.isInteger(e)?"integer":typeof e}function HD(e,t){let r=pw(e);return t==="number"?r==="number"||r==="integer":t==="integer"?r==="integer":r===t}function zD(e,t){if(typeof t!="string"||!t.startsWith("#/"))return;let r=e;for(let n of t.slice(2).split("/")){let o=n.replace(/~1/g,"/").replace(/~0/g,"~");if(!Ln(r)&&!Array.isArray(r))return;r=r[o]}return Ln(r)?r:void 0}function fn(e,t,r,n,o){if(!Ln(t))return;if(t.$ref!==void 0){let a=zD(r,t.$ref);a&&fn(e,a,r,n,o);return}if(Array.isArray(t.allOf))for(let a of t.allOf)fn(e,a,r,n,o);for(let a of["anyOf","oneOf"]){let m=t[a];if(!Array.isArray(m)||m.length===0)continue;let c=m.filter(p=>{let f=[];return fn(e,p,r,n,f),f.length===0}).length;a==="anyOf"&&c===0&&o.push({path:n,message:"does not match any allowed shape"}),a==="oneOf"&&c!==1&&o.push({path:n,message:`must match exactly one shape (matched ${c})`})}let i=t.type;if(i!==void 0){let a=Array.isArray(i)?i.map(String):[String(i)];if(!a.some(m=>HD(e,m))){o.push({path:n,message:`expected ${a.join(" or ")}, got ${pw(e)}`});return}}if(Array.isArray(t.enum)&&!t.enum.some(a=>JSON.stringify(a)===JSON.stringify(e))&&o.push({path:n,message:`must be one of ${t.enum.map(a=>JSON.stringify(a)).join(", ")}`}),Ln(e)){let a=Ln(t.properties)?t.properties:{};if(Array.isArray(t.required))for(let m of t.required.map(String))m in e||o.push({path:n?`${n}.${m}`:m,message:"is required"});for(let[m,c]of Object.entries(a))m in e&&fn(e[m],c,r,n?`${n}.${m}`:m,o);if(t.additionalProperties===!1)for(let m of Object.keys(e))m in a||o.push({path:n?`${n}.${m}`:m,message:"is not an allowed property"});else if(Ln(t.additionalProperties))for(let[m,c]of Object.entries(e))m in a||fn(c,t.additionalProperties,r,n?`${n}.${m}`:m,o)}if(Array.isArray(e)&&t.items!==void 0){let a=t.items;Array.isArray(a)?e.forEach((m,c)=>{c<a.length&&fn(m,a[c],r,`${n}[${c}]`,o)}):e.forEach((m,c)=>fn(m,a,r,`${n}[${c}]`,o))}if(typeof e=="string"&&(typeof t.minLength=="number"&&e.length<t.minLength&&o.push({path:n,message:`is shorter than ${t.minLength} characters`}),typeof t.pattern=="string"))try{new RegExp(t.pattern).test(e)||o.push({path:n,message:`does not match ${t.pattern}`})}catch{}typeof e=="number"&&(typeof t.minimum=="number"&&e<t.minimum&&o.push({path:n,message:`is below ${t.minimum}`}),typeof t.maximum=="number"&&e>t.maximum&&o.push({path:n,message:`is above ${t.maximum}`}))}function fw(e,t){if(!Ln(t))return[];let r=[];return fn(e,t,t,"",r),r}function dw(e){return e.map(t=>`- ${t.path||"(root)"}: ${t.message}`).join(`
|
|
168
|
-
`)}function lw(e){let t=e.trim(),r=/```(?:json)?\s*([\s\S]*?)```/.exec(t),n=[t,r?.[1]?.trim()].filter(o=>!!o);for(let o of n){try{return JSON.parse(o)}catch{}for(let i=0;i<o.length;i++){let a=o[i];if(a!=="{"&&a!=="[")continue;let m=a==="{"?"}":"]",c=0,p=!1,f=!1;for(let d=i;d<o.length;d++){let g=o[d];if(p){f?f=!1:g==="\\"?f=!0:g==='"'&&(p=!1);continue}if(g==='"')p=!0;else if(g===a)c++;else if(g===m&&(c--,c===0))try{return JSON.parse(o.slice(i,d+1))}catch{break}}}}}var WD=1e3,VD=4096,gw=100,yw=300*1e3;async function JD(e,t=gw,r=yw){let n=Date.now()+r;for(;e.isPaused?.();){if(e.signal?.aborted||Date.now()>=n)return!1;await new Promise(o=>setTimeout(o,t))}return!0}var Je=class extends Error{constructor(t){super(t),this.name="WorkflowError"}};function YD(e){let t=0,r=[];return async function(){t>=e&&await new Promise(i=>r.push(i)),t++;let o=!1;return()=>{o||(o=!0,t--,r.shift()?.())}}}function xw(e){let t=e.lifetimeCap??WD,r=e.fanoutCap??VD,n=e.concurrency?YD(e.concurrency):null,o=async()=>{let b=await Tm();if(!n)return b;let C=await n();return()=>{C(),b()}},i=0,a=0,m=0,c="",p=b=>e.onEvent?.(b),f=new Map,d=()=>e.onProgress?.([...f.values()]),g=async(b,C)=>{let k=C??{},z=typeof k.label=="string"?k.label:`agent-${i+1}`,oe=typeof k.phase=="string"?k.phase:c,ee=typeof k.agentType=="string"?k.agentType:"task",_=typeof k.effort=="string"?k.effort:void 0,qt=typeof k.model=="string"?k.model:void 0,lt=typeof k.isolation=="string"?k.isolation:void 0,ir=k.schema;if(e.budgetTotal!=null&&a+m>=e.budgetTotal)throw new Je(`budget exhausted: spent ${a+m} of ${e.budgetTotal} output tokens`);if(i>=t)throw new Je(`lifetime cap reached: ${t} agent calls in one run`);i++;let of=i;if(e.isPaused?.()&&!await JD(e,gw,yw))return null;let sf=e.budgetTotal==null?0:Math.max(0,e.budgetTotal-a-m);m+=sf;let Dw=await o();try{if(e.signal?.aborted)return null;p({kind:"agent_start",label:z,phase:oe,ordinal:i}),f.set(of,{label:z,phase:oe,agentType:ee,status:"running",outputTokens:0,...qt?{model:qt}:{},startedAt:Date.now()}),d();let Oo=(dn,_r,Ut)=>{let Wt=f.get(of);Wt&&(Wt.status=dn,Wt.outputTokens=_r.outputTokens,Wt.endedAt=Date.now(),_r.toolCalls!==void 0&&(Wt.toolCalls=_r.toolCalls),_r.model!==void 0&&(Wt.model=_r.model),Ut&&(Wt.detail=Ut)),p({kind:"agent_end",label:z,ok:dn==="ok",outputTokens:_r.outputTokens}),d()},af=ir===void 0?1:2;for(let dn=0;dn<af;dn++){let _r=dn===0?String(b):void 0,Ut=await I(_r??QD(String(b),y),{label:z,phase:oe,agentType:ee,effort:_,model:qt,isolation:lt});if(Ut===null)return Oo("failed",{text:"",outputTokens:0}),null;if(a+=Ut.outputTokens,ir===void 0)return Oo("ok",Ut,Qp(Ut.text)),Ut.text;let Wt=lw(Ut.text),mf=Wt===void 0?[{path:"",message:"reply was not JSON"}]:fw(Wt,ir);if(mf.length===0)return Oo("ok",Ut,Qp(Ut.text)),Wt;if(y=dw(mf),dn===af-1)return Oo("failed",Ut,`schema: ${Qp(y)}`),null}return null}finally{m=Math.max(0,m-sf),Dw()}},y="",I=async(b,C)=>{try{return await e.invoke({prompt:b,...C})}catch{return null}};return{agent:(b,C)=>g(b,C),parallel:async b=>{if(b.length>r)throw new Je(`fan-out cap exceeded: ${b.length} items (max ${r})`);return await Promise.all(b.map(async k=>{try{return await k()}catch{return null}}))},pipeline:async(b,...C)=>{if(b.length>r)throw new Je(`fan-out cap exceeded: ${b.length} items (max ${r})`);return await Promise.all(b.map(async(z,oe)=>{let ee=z;for(let _ of C)try{ee=await _(ee,z,oe)}catch{return null}return ee}))},phase:b=>{c=String(b),p({kind:"phase",title:c})},log:b=>p({kind:"log",message:String(b)}),args:e.args,budget:{total:e.budgetTotal??null,spent:()=>a+m,remaining:()=>e.budgetTotal==null?1/0:Math.max(0,e.budgetTotal-a-m)}}}function QD(e,t){return`${e}
|
|
169
|
-
|
|
170
|
-
Your previous reply did not satisfy the required schema:
|
|
171
|
-
${t}
|
|
172
|
-
|
|
173
|
-
Reply with ONLY a corrected JSON value.`}function Qp(e,t=80){let r=e.split(`
|
|
174
|
-
`).map(n=>n.trim()).find(n=>n.length>0)??"";return r.length>t?`${r.slice(0,t)}\u2026`:r}var Xp="workflow",hw=null;function G1e(e){hw=e}var rN=600*1e3;function nN(e){let t=e.replace(/^(?:\s+|\/\/[^\n]*\n|\/\*[\s\S]*?\*\/)*/,""),r=/^export\s+const\s+meta\s*=\s*/.exec(t);if(!r)throw new Je("a workflow script must start with `export const meta = { name, description }`");let n=e.length-t.length,o=r[0].length,i=0,a=null,m=-1;for(let y=o;y<t.length;y++){let I=t[y];if(a){I==="\\"?y++:I===a&&(a=null);continue}if(I==='"'||I==="'"||I==="`")a=I;else if(I==="{"||I==="[")i++;else if((I==="}"||I==="]")&&(i--,i===0)){m=y+1;break}}if(m===-1)throw new Je("meta is not a closed literal object");let c=t.slice(o,m),p=e.slice(n+m).replace(/^\s*;/,"");if(/^\s*(import|export)\b/m.test(p))throw new Je("a workflow body must not contain import or export declarations");if(/\bimport\s*\(/.test(p))throw new Je("a workflow body must not use dynamic import()");let f;try{f=new Function(`"use strict"; return (${c});`)()}catch(y){throw new Je(`meta must be a literal object: ${y instanceof Error?y.message:String(y)}`)}if(typeof f!="object"||f===null)throw new Je("meta must be an object");let d=f;if(typeof d.name!="string"||!d.name.trim())throw new Je("meta.name is required");if(typeof d.description!="string"||!d.description.trim())throw new Je("meta.description is required");let g=Array.isArray(d.phases)?d.phases.filter(y=>typeof y=="object"&&y!==null).map(y=>({title:String(y.title??""),...typeof y.detail=="string"?{detail:y.detail}:{}})).filter(y=>y.title):void 0;return{meta:{name:d.name,description:d.description,...typeof d.whenToUse=="string"?{whenToUse:d.whenToUse}:{},...g?{phases:g}:{}},body:p}}function oN(e){let t=["agent","parallel","pipeline","phase","log","args","budget"],r=`"use strict"; return (async () => {
|
|
175
|
-
${e}
|
|
176
|
-
})();`,n;try{n=new Function(...t,r)}catch(o){throw new Je(`workflow did not compile: ${o instanceof Error?o.message:String(o)}`)}return n}function iN(e){return vo(e.getLastAssistantText()??"")}function sN(e){return async({prompt:t,agentType:r,effort:n,model:o,isolation:i})=>{let a=pn.get(r)??pn.get("task");if(!a)throw new Je(`no agent named ${r}`);let m=i==="worktree"?await ZT(process.cwd(),r):null,c=await Rm({agent:a.name,effort:n??a.effort,...o?{model:o}:{},...e?{parentModel:e}:{},...m?{worktree:m.path}:{}});try{await c.prompt(`${a.prompt}
|
|
177
|
-
|
|
178
|
-
Task:
|
|
179
|
-
${t}`);let p=c.getSessionStats(),f=aN(c)??o;return{text:iN(c),outputTokens:p.tokens.output,toolCalls:p.toolCalls,...f?{model:f}:{}}}finally{c.dispose(),await m?.remove()}}}function aN(e){return e.model?.id??e.model?.name}var mN=v.Object({code:v.Optional(v.String({description:"The workflow script source"})),path:v.Optional(v.String({description:"Path to a workflow script, instead of code"})),agent:v.Optional(eN(["scout","task","reviewer"],{description:"Default agent profile for calls"})),budget:v.Optional(v.Number({description:"Output-token ceiling for the whole run"}))});function K1e(e){let t=()=>e??hw;return tN({name:"workflow",label:"workflow",description:"Run a JavaScript workflow that orchestrates many agents deterministically. Provide `code` (or `path`). The script starts with `export const meta = { name, description, phases }` and then uses the injected bindings: `agent(prompt, {label, phase, schema, effort, model, agentType, isolation})`, `parallel(thunks)`, `pipeline(items, ...stages)`, `phase(title)`, `log(msg)`, `args`, `budget`. `agent()` resolves null on failure and throws only when the budget or the call cap is exhausted, so null-check every result. `parallel()` takes thunks and never rejects; `pipeline()` has no barrier between items. Use it for fan-out, for builder-verifier loops that converge on a verdict, and for anything needing many agents whose order and count must be deterministic.",promptSnippet:"workflow: orchestrate many agents from one JavaScript script",parameters:mN,executionMode:"sequential",async execute(r,n,o,i,a){let m=n.path?XD(n.path,"utf8"):n.code??"";if(!m.trim())throw new Je("provide code or path");let{meta:c,body:p}=nN(m);if(n.path){let ee=ZD(n.path).replace(/\.(js|mjs|cjs|ts)$/,"");if(ee!==c.name)throw new Je(`meta.name "${c.name}" must match the script filename "${ee}"`)}let f=oN(p),d=Date.now(),g=[],y=0,I=0,h=(ee,_)=>({name:c.name,...c.description?{description:c.description}:{},ok:ee,agents:I,outputTokens:y,startedAt:d,phases:c.phases??[],steps:g,..._?{error:_}:{}}),E=(ee,_)=>{a.ui.setStatus(Xp,_?void 0:mw(ee)),i?.({content:[],details:h(!1)})},b=ee=>{I=ee.length,y=ee.reduce((_,qt)=>_+qt.outputTokens,0),g.splice(0,g.length,...ee.map(_=>({label:_.label,phase:_.phase,agent:_.agentType,status:_.status,outputTokens:_.outputTokens,startedAt:_.startedAt,..._.toolCalls!==void 0?{toolCalls:_.toolCalls}:{},..._.model?{model:_.model}:{},..._.endedAt?{endedAt:_.endedAt}:{},..._.detail?{detail:_.detail}:{},..._.tasks?{tasks:_.tasks}:{}}))),E({name:c.name,...c.description?{description:c.description}:{},phases:c.phases??[],steps:g,startedAt:d},!1)},C=sN(WT(a?.model)),k=xw({invoke:n.agent?uN(C,n.agent):C,budgetTotal:n.budget??null,onProgress:b,...o?{signal:o}:{},...t()?.isPaused?{isPaused:t().isPaused}:{}}),z=new AbortController,oe=setTimeout(()=>z.abort(),rN);o&&o.addEventListener("abort",()=>z.abort(),{once:!0}),t()?.onStop?.(()=>z.abort());try{let ee=await Promise.race([f(k.agent,k.parallel,k.pipeline,k.phase,k.log,k.args,k.budget),new Promise((qt,lt)=>z.signal.addEventListener("abort",()=>lt(new Je("workflow timed out or was aborted"))))]),_=Date.now();return a.ui.setStatus(Xp,void 0),{content:[{type:"text",text:`${c.name}: ${I} agent call(s), ${y} output tokens in ${Po(_-d)}
|
|
180
|
-
|
|
181
|
-
${cN(ee)}`}],details:{...h(!0),endedAt:_}}}catch(ee){let _=ee instanceof Error?ee.message:String(ee);return a.ui.setStatus(Xp,void 0),{content:[{type:"text",text:`${c.name} failed after ${I} agent call(s): ${_}`}],details:{...h(!1,_),endedAt:Date.now()},isError:!0}}finally{clearTimeout(oe),t()?.onStop?.(null)}}})}function uN(e,t){return r=>e({...r,agentType:t})}function cN(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}import{createServer as pN}from"node:http";import{WebSocketServer as fN}from"ws";import{randomBytes as dN}from"node:crypto";var lN=9224,gN=3e4,yN=3e4;async function Iw(e){let t=e.port??lN,r=e.token??dN(16).toString("hex"),n=e.log??(()=>{}),o=Date.now(),i=null,a=!1,m="",c="",p=[],f=1,d=new Map,g=b=>{let{promise:C,resolve:k,reject:z}=Promise.withResolvers();if(!i||i.readyState!==i.OPEN)return z(new Error("Browser relay extension is not connected. Run /browser-relay install and check the toolbar badge.")),C;let oe=f++,ee=setTimeout(()=>{d.delete(oe),z(new Error(`Browser relay RPC timed out: ${b.op}`))},gN);return d.set(oe,{resolve:k,reject:z,timer:ee}),i.send(JSON.stringify({t:"rpc",id:oe,...b})),C},y=(b,C)=>{let k;try{k=JSON.parse(C)}catch{return}switch(k.t){case"hello":a=!0,m=k.browserVersion,c=k.userAgent,p=k.tabs,n(`extension connected: ${k.tabs.length} tabs`);break;case"tabCreated":p=[...p.filter(z=>z.tabId!==k.tab.tabId),k.tab];break;case"tabUpdated":p=p.map(z=>z.tabId===k.tab.tabId?k.tab:z);break;case"tabRemoved":p=p.filter(z=>z.tabId!==k.tabId);break;case"rpcResult":{let z=d.get(k.id);if(!z)return;d.delete(k.id),clearTimeout(z.timer),k.ok?z.resolve(k.result):z.reject(new Error(k.error||`Browser relay RPC failed: ${k.id}`));break}case"ping":b.send(JSON.stringify({t:"pong"}));break;default:break}},I=pN((b,C)=>{let z=new URL(b.url??"/",`http://127.0.0.1:${t}`).pathname.replace(/\/+$/,"")||"/";if(b.method!=="GET"){C.writeHead(405).end("Method not allowed");return}if(z==="/json/version"){let oe=i!==null&&i.readyState===i.OPEN,ee={Browser:m||"HowToCode Browser Relay","Protocol-Version":"1.3","User-Agent":c||"HowToCode",webSocketDebuggerUrl:`ws://127.0.0.1:${t}/cdp`,...oe?{}:{error:"relay extension is not connected",extensionSeen:a,uptimeMs:Date.now()-o}};C.writeHead(oe?200:503,{"content-type":"application/json"}).end(JSON.stringify(ee));return}if(z==="/json"||z==="/json/list"){C.writeHead(200,{"content-type":"application/json"}).end(JSON.stringify(p.map(oe=>({id:String(oe.tabId),type:"page",title:oe.title,url:oe.url,webSocketDebuggerUrl:`ws://127.0.0.1:${t}/cdp?tab=${oe.tabId}`}))));return}if(z==="/health"){C.writeHead(200,{"content-type":"application/json"}).end(JSON.stringify({ok:!0,ready:i!==null,tabs:p.length}));return}C.writeHead(404).end("Not found")}),h=new fN({noServer:!0});I.on("upgrade",(b,C,k)=>{let z=new URL(b.url??"/",`http://127.0.0.1:${t}`),oe=z.pathname.replace(/\/+$/,"")||"/",ee=b.headers.origin;if(oe==="/ext"){if(ee&&!ee.startsWith("chrome-extension://")){C.write(`HTTP/1.1 403 Forbidden\r
|
|
182
|
-
\r
|
|
183
|
-
`),C.destroy();return}if(z.searchParams.get("token")!==r){C.write(`HTTP/1.1 401 Unauthorized\r
|
|
184
|
-
\r
|
|
185
|
-
`),C.destroy();return}}else if(oe==="/cdp"){if(ee){C.write(`HTTP/1.1 403 Forbidden\r
|
|
186
|
-
\r
|
|
187
|
-
`),C.destroy();return}}else{C.write(`HTTP/1.1 404 Not Found\r
|
|
188
|
-
\r
|
|
189
|
-
`),C.destroy();return}h.handleUpgrade(b,C,k,_=>{oe==="/ext"&&(i?.close(),i=_,_.on("message",qt=>y(_,qt.toString())),_.on("close",()=>{i===_&&(i=null)}))})}),await new Promise((b,C)=>{I.once("error",C),I.listen(t,"127.0.0.1",()=>{I.off("error",C);let k=I.address();k&&typeof k=="object"&&(t=k.port),b()})});let E=setInterval(()=>{for(let b of h.clients)b.readyState===b.OPEN&&b.ping()},yN);return E.unref?.(),n(`relay listening on 127.0.0.1:${t}`),{port:t,token:r,state:()=>({extensionConnected:i!==null&&i.readyState===i.OPEN,extensionSeen:a,browserVersion:m,userAgent:c,tabs:p,uptimeMs:Date.now()-o,port:t}),rpc:g,ready:()=>i!==null&&i.readyState===i.OPEN,stop:async()=>{clearInterval(E);for(let b of d.values())clearTimeout(b.timer),b.reject(new Error("Browser relay stopped"));d.clear();for(let b of h.clients)b.terminate();await new Promise(b=>h.close(()=>b())),await new Promise(b=>I.close(()=>b()))}}}import{existsSync as Cw,readFileSync as Rw}from"node:fs";import{randomBytes as xN}from"node:crypto";import{existsSync as Ew,mkdirSync as Sw,readFileSync as Zp,renameSync as hN,writeFileSync as IN,chmodSync as bN}from"node:fs";import{dirname as Tw,join as Ao}from"node:path";import{fileURLToPath as $N}from"node:url";function bw(e,t,r){let n=r?`void chrome.storage.local.get({ token: "" }).then((stored) => { if (!stored.token) return chrome.storage.local.set({ token: ${JSON.stringify(r)} }); });
|
|
190
|
-
`:"";return`const OMP_INSTALL_VERSION = ${JSON.stringify(t)};
|
|
191
|
-
${n}${e}`}function $w(e,t){let r=JSON.parse(e);return`${JSON.stringify({...r,name:"HowToCode Browser Relay",description:"Lets HowToCode CLI drive your existing tabs through a local CDP relay.",homepage_url:"https://howtofix.id",version_name:t,action:{default_title:"HowToCode Browser Relay (click for settings)"}},null," ")}
|
|
192
|
-
`}function Om(e){return e.replaceAll("OMP Browser Relay","HowToCode Browser Relay").replaceAll("omp-browser-relay","howtocode-browser-relay").replaceAll("omp-relay-keepalive","howtocode-relay-keepalive")}var EN=Ao(Tw($N(import.meta.url)),"assets");function Mm(e){let t=Ao(e,"browser-relay");return{extensionDir:Ao(t,"extension"),tokenPath:Ao(t,"token")}}function Ui(e){return Zp(Ao(EN,`${e}.txt`),"utf8")}function kw(e,t){let r=`${e}.${process.pid}.tmp`;IN(r,t),hN(r,e)}function ww(e,t){let{extensionDir:r,tokenPath:n}=Mm(e);Sw(r,{recursive:!0});let o="";Ew(n)?o=Zp(n,"utf8").trim():(o=xN(24).toString("hex"),Sw(Tw(n),{recursive:!0}),kw(n,`${o}
|
|
193
|
-
`),bN(n,384));let i={"manifest.json":$w(Ui("manifest.json"),t),"options.html":Om(Ui("options.html")),"options.js":Om(Ui("options.js")),LICENSE:Ui("LICENSE"),"background.js":Om(bw(Ui("background.js"),t,o))},a=[];for(let[m,c]of Object.entries(i)){let p=Ao(r,m);(Ew(p)?Zp(p,"utf8"):null)!==c&&(kw(p,c),a.push(m))}return{extensionDir:r,tokenPath:n,token:o,wrote:a}}var Bi=null,_i=null;function Pw(){try{return JSON.parse(Rw(new URL("../../package.json",import.meta.url),"utf8")).version??"0.0.0"}catch{return"0.0.0"}}function aLe(){let e=ww(Ye,Pw());return{token:e.token,extensionDir:e.extensionDir,tokenPath:e.tokenPath,wrote:e.wrote}}async function mLe(){if(Bi)return Bi;if(_i)return _i;_i=(async()=>{let{tokenPath:e}=Mm(Ye);if(!Cw(e))throw new Error("Browser relay is not installed. Run /browser-relay install and load the extension in Chrome first.");let t=Rw(e,"utf8").trim();if(!t)throw new Error("Browser relay token file is empty. Run /browser-relay install again.");let r=process.env.HOWTOCODE_BROWSER_RELAY_PORT?.trim(),n=r&&/^\d+$/.test(r)?Number(r):void 0,o=await Iw({token:t,port:n,productVersion:Pw()});return Bi=o,o})();try{return await _i}finally{_i=null}}async function uLe(){let{extensionDir:e,tokenPath:t}=Mm(Ye);return{running:Bi!==null,state:Bi?.state()??null,tokenConfigured:Cw(t),extensionDir:e}}import{execFile as SN,execFileSync as kN}from"node:child_process";import{promisify as TN}from"node:util";import{createHash as Mw}from"node:crypto";import{copyFileSync as wN,existsSync as vm,mkdirSync as Fm,readFileSync as rf,readdirSync as CN,rmSync as RN,statSync as ef}from"node:fs";import{dirname as vw,join as Pt,resolve as Lm}from"node:path";var tf=Pt(Ye,"rewind"),jm="refs/howtocode",Aw=100,Fw=30,Lw="project.json",jw="checkpoints.json",Ow=!1;function PN(e){let t=Lm(e);for(;;){if(vm(Pt(t,".git")))return!0;let r=vw(t);if(r===t)return!1;t=r}}var AN=TN(SN);async function Nt(e,t){let r={...process.env};for(let o of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_COMMON_DIR"])delete r[o];r.GIT_DIR=e.gitDir,r.GIT_WORK_TREE=e.root,r.GIT_AUTHOR_NAME=r.GIT_COMMITTER_NAME="howtocode",r.GIT_AUTHOR_EMAIL=r.GIT_COMMITTER_EMAIL="howtocode@local";let{stdout:n}=await AN("git",t,{cwd:e.root,env:r,encoding:"utf8",maxBuffer:8*1024*1024});return n.trim()}function ON(e){return Mw("sha1").update(e).digest("hex").slice(0,16)}function hLe(e){let t=Lm(e).replace(/\/+$/,"")||"/",r=Pt(tf,ON(t)),n=Pt(r,"git"),o={root:t,gitDir:n,metaFile:Pt(r,jw),disabled:!1};return!vm(Pt(n,"HEAD"))&&!PN(t)?(o.disabled=!0,o):(Fm(r,{recursive:!0}),vm(Pt(n,"HEAD"))||(Fm(n,{recursive:!0}),kN("git",["init","--quiet","--initial-branch=howtocode"],{env:{...process.env,GIT_DIR:n},stdio:["ignore","ignore","pipe"]})),MN(t,n),vN(r,t),Ow||(Ow=!0,LN({keep:r})),o)}function MN(e,t){let r=Pt(e,".git","info","exclude");try{if(!ef(r).isFile())return;Fm(Pt(t,"info"),{recursive:!0}),wN(r,Pt(t,"info","exclude"))}catch{}}function vN(e,t){let r=Pt(e,Lw),n=`${JSON.stringify({version:1,root:t})}
|
|
194
|
-
`;try{if(rf(r,"utf8")===n)return}catch{}try{sr(r,n)}catch{}}function Dm(e){try{let t=JSON.parse(rf(e.metaFile,"utf8"));if(t?.version===1&&t.sessions)return t}catch{}return{version:1,sessions:{}}}function nf(e,t){Fm(vw(e.metaFile),{recursive:!0}),sr(e.metaFile,`${JSON.stringify(t,null,1)}
|
|
195
|
-
`)}function FN(e,t){return e.disabled?[]:[...Dm(e).sessions[t]??[]].sort((r,n)=>r.at-n.at)}async function ILe(e,t,r){if(e.disabled)return null;let n;try{await Nt(e,["add","-A","--ignore-errors","--"]),n=await Nt(e,["write-tree"])}catch{return null}let i=FN(e,t).find(g=>g.tree===n),a=Date.now(),m=`${a.toString(36)}-${Mw("sha1").update(`${n}:${a}`).digest("hex").slice(0,6)}`,c=i?.commit;if(!c){let g=["howtocode checkpoint",`session ${t}`,`created ${new Date(a).toISOString()}`,`prompt ${r.slice(0,200)}`].join(`
|
|
196
|
-
`);c=await Nt(e,["commit-tree",n,"-m",g]),await Nt(e,["update-ref",`${jm}/${m}`,c])}let p={id:m,tree:n,commit:c,prompt:r,at:a},f=Dm(e),d=[...f.sessions[t]??[],p];for(let g of d.slice(0,Math.max(0,d.length-Aw)))try{await Nt(e,["update-ref","-d",`${jm}/${g.id}`])}catch{}return f.sessions[t]=d.slice(-Aw),nf(e,f),p}async function bLe(e,t){let r=[];if(e.disabled)return{ok:!1,output:"checkpoints are off: this directory is not a git repository",removed:r};try{await Nt(e,["read-tree","--reset","-u",t.tree])}catch(n){return{ok:!1,output:n instanceof Error?n.message:String(n),removed:r}}try{let n=await Nt(e,["clean","-fd"]);for(let o of n.split(`
|
|
197
|
-
`)){let i=/^Removing\s+(.+)$/.exec(o.trim());i?.[1]&&r.push(i[1])}}catch{}return{ok:!0,output:`restored ${t.prompt||"the checkpoint"}`,removed:r}}async function $Le(e,t){if(e.disabled)return[];try{await Nt(e,["add","-A","--ignore-errors","--"]);let r=await Nt(e,["write-tree"]);return r===t.tree?[]:(await Nt(e,["diff-tree","-r","--name-status","--no-commit-id",t.tree,r])).split(`
|
|
198
|
-
`).filter(Boolean).map(o=>{let[i,...a]=o.split(" ");return`${i?.[0]??"?"} ${a.at(-1)??""}`})}catch{return[]}}async function ELe(e,t={}){let r={droppedSessions:0,droppedRefs:0};if(e.disabled)return r;let n=(t.now??Date.now())-Fw*24*60*60*1e3,o=Dm(e),i=!1;for(let[a,m]of Object.entries(o.sessions))if(!(a===t.keep||m.reduce((p,f)=>Math.max(p,f.at),0)>=n)){delete o.sessions[a],i=!0,r.droppedSessions+=1;for(let p of m)try{await Nt(e,["update-ref","-d",`${jm}/${p.id}`]),r.droppedRefs+=1}catch{}}if(!i)return r;nf(e,o);try{await Nt(e,["gc","--quiet","--prune=now"])}catch{}return r}function LN(e={}){let t={removedDirs:0,failed:[]},r;try{r=CN(tf,{withFileTypes:!0})}catch{return t}let n=(e.now??Date.now())-Fw*24*60*60*1e3,o=e.keep?Lm(e.keep):void 0;for(let i of r){if(!i.isDirectory())continue;let a=Pt(tf,i.name);if(Lm(a)!==o)try{(jN(a)||DN(a)<n)&&(RN(a,{recursive:!0,force:!0}),t.removedDirs+=1)}catch{t.failed.push(i.name)}}return t}function jN(e){try{let t=JSON.parse(rf(Pt(e,Lw),"utf8"));return typeof t?.root!="string"||t.root.length===0?!1:!vm(t.root)}catch{return!1}}function DN(e){try{return ef(Pt(e,jw)).mtimeMs}catch{return ef(e).mtimeMs}}async function SLe(e,t){if(e.disabled)return;let r=Dm(e);for(let n of r.sessions[t]??[])try{await Nt(e,["update-ref","-d",`${jm}/${n.id}`])}catch{}delete r.sessions[t],nf(e,r)}export{Eo as a,fm as b,R1 as c,jPe as d,DPe as e,NPe as f,qPe as g,KPe as h,HPe as i,_1 as j,JPe as k,YPe as l,QPe as m,uAe as n,cAe as o,pAe as p,fAe as q,dAe as r,ek as s,v as t,nk as u,_Oe as v,ak as w,mk as x,zOe as y,lL as z,WOe as A,VOe as B,JOe as C,YOe as D,gL as E,QOe as F,yL as G,xL as H,XOe as I,iMe as J,sMe as K,aMe as L,mMe as M,uMe as N,cMe as O,op as P,pMe as Q,fMe as R,dMe as S,lMe as T,bk as U,vL as V,Li as W,NL as X,VL as Y,JL as Z,YL as _,QL as $,rj as aa,nT as ba,oT as ca,gj as da,Mve as ea,gT as fa,GT as ga,Yj as ha,Qj as ia,HT as ja,eD as ka,jFe as la,pn as ma,e1e as na,t1e as oa,Rt as pa,r1e as qa,n1e as ra,o1e as sa,i1e as ta,WT as ua,s1e as va,a1e as wa,m1e as xa,lD as ya,bD as za,g1e as Aa,y1e as Ba,x1e as Ca,h1e as Da,I1e as Ea,ZT as Fa,tw as Ga,_e as Ha,RD as Ia,mt as Ja,E1e as Ka,ow as La,Po as Ma,w1e as Na,Jp as Oa,C1e as Pa,G1e as Qa,K1e as Ra,lN as Sa,aLe as Ta,mLe as Ua,uLe as Va,Fw as Wa,hLe as Xa,FN as Ya,ILe as Za,bLe as _a,$Le as $a,ELe as ab,SLe as bb};
|