memindex 1.0.0 → 1.1.0

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.
Files changed (39) hide show
  1. package/.agents/plugins/marketplace.json +12 -0
  2. package/.claude-plugin/marketplace.json +7 -1
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/.qoder-plugin/plugin.json +1 -1
  6. package/README.md +10 -12
  7. package/dist/bug-report/index.js +63 -63
  8. package/dist/npx-cli/index.js +355 -10233
  9. package/dist/opencode-plugin/index.js +35 -35
  10. package/dist/pi-extension/index.js +6 -6
  11. package/integrations/dsh/lib/index.js +28 -28
  12. package/integrations/dsh/package.json +1 -1
  13. package/integrations/openclaw/openclaw.plugin.json +1 -1
  14. package/package.json +5 -8
  15. package/plugin/.claude-plugin/plugin.json +1 -1
  16. package/plugin/.codex-plugin/plugin.json +1 -1
  17. package/plugin/.qoder-plugin/plugin.json +1 -1
  18. package/plugin/hooks.json +49 -0
  19. package/plugin/mcp_config.json +11 -0
  20. package/plugin/modes/personal.json +130 -0
  21. package/plugin/package.json +1 -1
  22. package/plugin/plugin.json +4 -0
  23. package/plugin/scripts/context-generator.cjs +51 -48
  24. package/plugin/scripts/context-generator.cjs.map +3 -3
  25. package/plugin/scripts/mcp-server.cjs +83 -83
  26. package/plugin/scripts/mcp-server.cjs.map +3 -3
  27. package/plugin/scripts/transcript-watcher.cjs +37 -37
  28. package/plugin/scripts/transcript-watcher.cjs.map +3 -3
  29. package/plugin/scripts/windows-hook-launcher.cjs +2 -0
  30. package/plugin/scripts/worker-service.cjs +1149 -668
  31. package/plugin/scripts/worker-service.cjs.map +3 -3
  32. package/plugin/skills/cloud-sync/SKILL.md +91 -0
  33. package/plugin/sqlite/SessionStore.js +317 -181
  34. package/plugin/sqlite/SessionStore.js.map +3 -3
  35. package/plugin/sqlite/observations/files.js +6 -6
  36. package/plugin/sqlite/observations/files.js.map +3 -3
  37. package/plugin/ui/viewer-bundle.js +2 -2
  38. package/plugin/scripts/server-service.cjs +0 -10305
  39. package/plugin/scripts/server-service.cjs.map +0 -6
@@ -1,13 +1,13 @@
1
1
  /*! Pi memory design and text extraction: Copyright (c) 2026 Husni Adil Makmur. MIT: LICENSE.txt. Upstream Apache-2.0: UPSTREAM-LICENSE.txt and UPSTREAM-NOTICE.txt. Bundled TypeBox MIT: TYPEBOX-LICENSE.txt and TYPEBOX-PROVENANCE.json. All files are beside this extension. */
2
- var ud=Object.defineProperty;var qt=(e,t)=>{for(var r in t)ud(e,r,{get:t[r],enumerable:!0})};var p={};qt(p,{Assign:()=>cd,Clone:()=>xr,Create:()=>Wd,Discard:()=>Xd,Metrics:()=>ve,Update:()=>Zd});var ve={assign:0,create:0,clone:0,discard:0,update:0};function cd(e,t){return ve.assign+=1,{...e,...t}}var s={};qt(s,{Entries:()=>qd,EntriesRegExp:()=>jd,Every:()=>Cd,EveryAll:()=>Md,GraphemeCount:()=>wd,HasPropertyKey:()=>Sd,IsArray:()=>fr,IsAsyncIterator:()=>yd,IsBigInt:()=>lr,IsBoolean:()=>Va,IsClassInstance:()=>Od,IsConstructor:()=>gd,IsDeepEqual:()=>ta,IsEqual:()=>L,IsFunction:()=>Ja,IsGreaterEqualThan:()=>Xa,IsGreaterThan:()=>Td,IsInteger:()=>Qn,IsIterator:()=>$d,IsLessEqualThan:()=>Wa,IsLessThan:()=>Ed,IsMaxLength:()=>Rd,IsMinLength:()=>vd,IsMultipleOf:()=>kd,IsNull:()=>pn,IsNumber:()=>un,IsObject:()=>Tt,IsObjectNotArray:()=>bd,IsString:()=>At,IsSymbol:()=>hd,IsUndefined:()=>ea,IsValueLike:()=>Pd,Keys:()=>mn,Symbols:()=>Ad,Values:()=>Ld});function Ze(e,t,r){return e>=t&&e<=r}function Ka(e){return Ze(e,127462,127487)}function dd(e){return Ze(e,65024,65039)}function ld(e){return Ze(e,768,879)||Ze(e,6832,6911)||Ze(e,7616,7679)||Ze(e,65056,65071)}function sn(e){return e>65535?2:1}function Ga(e,t){for(;t<e.length;){let r=e.codePointAt(t);if(ld(r)||dd(r))t+=sn(r);else break}return t}function Yn(e,t){let r=e.codePointAt(t),n=t+sn(r);for(n=Ga(e,n);n<e.length-1&&e[n]==="\u200D";){let a=e.codePointAt(n+1);n+=1+sn(a),n=Ga(e,n)}return Ka(r)&&n<e.length&&Ka(e.codePointAt(n))&&(n+=sn(e.codePointAt(n))),n}function _a(e){return Ze(e,55296,56319)||Ze(e,768,879)||e===8205}function za(e){let t=0,r=0;for(;r<e.length;)r=Yn(e,r),t++;return t}function fd(e,t){if(t===0)return!0;let r=0,n=0;for(;n<e.length;)if(n=Yn(e,n),r++,r>=t)return!0;return!1}function xd(e,t){let r=0,n=0;for(;n<e.length;)if(n=Yn(e,n),r++,r>t)return!1;return!0}function Ba(e,t){if(t===0)return!0;let r=0;for(;r<e.length;){if(_a(e.charCodeAt(r)))return fd(e,t);if(r++,r>=t)return!0}return!1}function Ha(e,t){let r=0;for(;r<e.length;){if(_a(e.charCodeAt(r)))return xd(e,t);if(r++,r>t)return!1}return!0}function fr(e){return Array.isArray(e)}function yd(e){return Tt(e)&&Symbol.asyncIterator in e}function lr(e){return L(typeof e,"bigint")}function Va(e){return L(typeof e,"boolean")}function gd(e){if(ea(e)||!Ja(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function Ja(e){return L(typeof e,"function")}function Qn(e){return Number.isInteger(e)}function $d(e){return Tt(e)&&Symbol.iterator in e}function pn(e){return L(e,null)}function un(e){return Number.isFinite(e)}function bd(e){return Tt(e)&&!fr(e)}function Tt(e){return L(typeof e,"object")&&!pn(e)}function At(e){return L(typeof e,"string")}function hd(e){return L(typeof e,"symbol")}function ea(e){return L(e,void 0)}function L(e,t){return e===t}function Td(e,t){return e>t}function Ed(e,t){return e<t}function Wa(e,t){return e<=t}function Xa(e,t){return e>=t}function kd(e,t){if(lr(e)||lr(t))return BigInt(e)%BigInt(t)===0n;let r=1e-10;if(!un(e)||Qn(e)&&1/t%1===0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t))<r}function Od(e){if(!Tt(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return pn(t)?!1:L(typeof t.constructor,"function")&&!(L(t.constructor,globalThis.Object)||L(t.constructor.name,"Object"))}function Pd(e){return lr(e)||Va(e)||pn(e)||un(e)||At(e)||ea(e)}function wd(e){return za(e)}function Rd(e,t){return Ha(e,t)}function vd(e,t){return Ba(e,t)}function Cd(e,t,r){for(let n=t;n<e.length;n++)if(!r(e[n],n))return!1;return!0}function Md(e,t,r){let n=!0;for(let a=t;a<e.length;a++)r(e[a],a)||(n=!1);return n}function Sd(e,t){return L(t,"__proto__")||L(t,"constructor")?Object.prototype.hasOwnProperty.call(e,t):t in e}function jd(e){return mn(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function qd(e){return Object.entries(e)}function mn(e){return Object.getOwnPropertyNames(e)}function Ad(e){return Object.getOwnPropertySymbols(e)}function Ld(e){return Object.values(e)}function Nd(e,t){if(!Tt(t))return!1;let r=mn(e);return L(r.length,mn(t).length)&&r.every(n=>ta(e[n],t[n]))}function Fd(e,t){return fr(t)&&L(e.length,t.length)&&e.every((r,n)=>ta(e[n],t[n]))}function ta(e,t){return fr(e)?Fd(e,t):Tt(e)?Nd(e,t):L(e,t)}function Kd(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~guard")}function Gd(e){return e.map(t=>ra(t))}function _d(e){let t={},r=Object.getOwnPropertyDescriptors(e);for(let n of Object.keys(r)){let a=r[n];s.HasPropertyKey(a,"value")&&Object.defineProperty(t,n,{...a,value:ra(a.value)})}return t}function zd(e){return new RegExp(e.source,e.flags)}function ra(e){return e instanceof RegExp?zd(e):Kd(e)?e:s.IsArray(e)?Gd(e):s.IsObject(e)?_d(e):e}function xr(e){return ve.clone+=1,ra(e)}var Be={};qt(Be,{Get:()=>Vd,Reset:()=>Bd,Set:()=>Hd});var Ye={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1};function Bd(){Ye.immutableTypes=!1,Ye.maxErrors=8,Ye.useAcceleration=!0,Ye.exactOptionalPropertyTypes=!1,Ye.enumerableKind=!1,Ye.correctiveParse=!1}function Hd(e){for(let t of s.Keys(e)){let r=e[t];r!==void 0&&Object.defineProperty(Ye,t,{value:r})}}function Vd(){return Ye}function Jd(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 Ya(e,t){return{...e,...t}}function Wd(e,t,r={}){ve.create+=1;let n=Be.Get(),a=Ya(t,r),i=n.enumerableKind?Ya(a,e):Jd(a,e);return n.immutableTypes?Object.freeze(i):i}function Xd(e,t){ve.discard+=1;let r={},n=Object.getOwnPropertyDescriptors(xr(e)),a=new Set(t);for(let i of Object.keys(n))a.has(i)||Object.defineProperty(r,i,n[i]);return r}function Zd(e,t,r){ve.update+=1;let n=Be.Get(),a=xr(e);for(let i of Object.keys(t))Object.defineProperty(a,i,{configurable:!0,writable:!0,enumerable:n.enumerableKind,value:t[i]});for(let i of Object.keys(r))Object.defineProperty(a,i,{configurable:!0,enumerable:!0,writable:!0,value:r[i]});return a}function f(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function k(e){return s.IsObject(e)}function Qa(e){return p.Create({"~kind":"OptionalAddAction"},{type:e},{})}function eo(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"OptionalAddAction")&&k(e.type)}function to(e){return p.Create({"~kind":"OptionalRemoveAction"},{type:e},{})}function ro(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"OptionalRemoveAction")&&k(e.type)}function no(e){return p.Create({"~kind":"ReadonlyAddAction"},{type:e},{})}function ao(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"ReadonlyAddAction")&&k(e.type)}function oo(e){return p.Create({"~kind":"ReadonlyRemoveAction"},{type:e},{})}function so(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"ReadonlyRemoveAction")&&k(e.type)}function $(e,t,r){return p.Create({"~kind":"Deferred"},{action:e,parameters:t,options:r},{})}function Qe(e){return f(e,"Deferred")}function na(e){return p.Update(e,{"~immutable":!0},{})}function et(e){return na(e)}function Et(e){return k(e)&&s.HasPropertyKey(e,"~immutable")}function Lt(e){return p.Discard(e,["~optional"])}function xe(e){return p.Update(e,{"~optional":!0},{})}function cn(e){return xe(e)}function pe(e){return k(e)&&s.HasPropertyKey(e,"~optional")}function dn(e){return p.Discard(e,["~readonly"])}function Ie(e){return p.Update(e,{"~readonly":!0},{})}function ln(e){return Ie(e)}function kt(e){return k(e)&&s.HasPropertyKey(e,"~readonly")}function Ce(e,t){return p.Create({"~kind":"Array"},{type:"array",items:e},t)}function z(e){return f(e,"Array")}function fn(e){return p.Discard(e,["~kind","type","items"])}function Ae(e,t){return p.Create({"~kind":"AsyncIterator"},{type:"asyncIterator",iteratorItems:e},t)}function ge(e){return f(e,"AsyncIterator")}function io(e){return p.Discard(e,["~kind","type","iteratorItems"])}function mo(e){return{enumerable:Be.Get().enumerableKind,writable:!1,configurable:!1,value:e}}var xn=class{constructor(){globalThis.Object.defineProperty(this,"~kind",mo("Base")),globalThis.Object.defineProperty(this,"~guard",mo({check:t=>this.Check(t),errors:t=>this.Errors(t)}))}Check(t){return!0}Errors(t){return[]}Convert(t){return t}Clean(t){return t}Default(t){return t}Create(){throw new Error("Create not implemented")}Clone(){throw Error("Clone not implemented")}};function In(e){return f(e,"Base")}function tt(e,t,r={}){return p.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},r)}function ae(e){return f(e,"Constructor")}function po(e){return p.Discard(e,["~kind","type","parameters","instanceType"])}function rt(e,t,r={}){return p.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},r)}function oe(e){return f(e,"Function")}function uo(e){return p.Discard(e,["~kind","type","parameters","returnType"])}function He(e,t){return p.Create({"~kind":"Ref"},{$ref:e},t)}function X(e){return f(e,"Ref")}function nt(e,t){return p.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function Nt(e){return f(e,"Generic")}function Ft(e){return p.Create({"~kind":"Any"},{},e)}function Z(e){return f(e,"Any")}var co="(?!)";function S(e){return p.Create({"~kind":"Never"},{not:{}},e)}function at(e){return f(e,"Never")}function lo(e){return s.Keys(e).filter(t=>!pe(e[t]))}function fo(e){return s.Keys(e)}function yn(e){return s.Values(e)}function E(e,t={}){let r=lo(e),n=r.length>0?{required:r}:{};return p.Create({"~kind":"Object"},{type:"object",...n,properties:e},t)}function F(e){return f(e,"Object")}function xo(e){return p.Discard(e,["~kind","type","properties","required"])}function O(e,t={}){return p.Create({"~kind":"Union"},{anyOf:e},t)}function y(e){return f(e,"Union")}function Io(e){return p.Discard(e,["~kind","anyOf"])}function ue(e){return p.Create({"~kind":"Unknown"},{},e)}function re(e){return f(e,"Unknown")}function Le(e,t,r){let n=s.Keys(e).reduce((a,i)=>({...a,[i]:p.Update(e[i],{},{$id:i})}),{});return p.Create({"~kind":"Cyclic"},{$defs:n,$ref:t},r)}function se(e){return f(e,"Cyclic")}var ot={};qt(ot,{Match:()=>Yd});function Yd(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function Ir(...e){let[t,r]=ot.Match(e,{2:(n,a)=>[n,a,a],1:n=>[n,ue(),ue()]});return p.Create({"~kind":"Infer"},{type:"infer",name:t,extends:r},{})}function V(e){return f(e,"Infer")}function yo(e){return s.IsObjectNotArray(e)}function go(e){return s.Keys(e).filter(r=>isNaN(r)).reduce((r,n)=>[...r,e[n]],[])}function $o(e,t){let r=yo(e)?go(e):e;return p.Create({"~kind":"Enum"},{enum:r},t)}function ie(e){return f(e,"Enum")}function Te(e,t={}){return p.Create({"~kind":"Intersect"},{allOf:e},t)}function M(e){return f(e,"Intersect")}function bo(e){return p.Discard(e,["~kind","allOf"])}function K(){throw new Error("Unreachable")}var ho;(function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"})(ho||(ho={}));var ih=BigInt("14695981039346656037"),[mh,ph]=[BigInt("1099511628211"),BigInt("18446744073709551616")],uh=Array.from({length:256}).map((e,t)=>BigInt(t)),To=new Float64Array(1),ch=new DataView(To.buffer),dh=new Uint8Array(To.buffer);var lh=new TextEncoder;var yr=class{constructor(t,r){this.type=t,this.decode=r}Encode(t){let r=this.type,n=gn(r)?m=>this.decode(r["~codec"].decode(m)):this.decode,a=gn(r)?m=>r["~codec"].encode(t(m)):t,i={decode:n,encode:a};return p.Update(this.type,{"~codec":i},{})}},gr=class{constructor(t){this.type=t}Decode(t){return new yr(this.type,t)}};function $n(e){return new gr(e)}function ko(e,t){return $n(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function Oo(e,t){return $n(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function gn(e){return k(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function rl(e,t){let r=aa(e)?[...e["~refine"],t]:[t];return p.Update(e,{"~refine":r},{})}function Po(e,t,r="error"){return rl(e,{refine:t,message:r})}function aa(e){return k(e)&&s.HasPropertyKey(e,"~refine")}var wo="-?(?:0|[1-9][0-9]*)n";function $r(e){return p.Create({"~kind":"BigInt"},{type:"bigint"},e)}function Ne(e){return f(e,"BigInt")}function bn(e){return p.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Oe(e){return f(e,"Boolean")}function br(e){return p.Create({"~kind":"Identifier"},{name:e})}function Ro(e){return f(e,"Identifier")}var hn="-?(?:0|[1-9][0-9]*)";function Ot(e){return p.Create({"~kind":"Integer"},{type:"integer"},e)}function ce(e){return f(e,"Integer")}function Fe(e,t){return p.Create({"~kind":"Iterator"},{type:"iterator",iteratorItems:e},t)}function $e(e){return f(e,"Iterator")}function vo(e){return p.Discard(e,["~kind","type","iteratorItems"])}var oa=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function nl(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new oa(e)})()}function q(e,t){return p.Create({"~kind":"Literal"},{type:nl(e),const:e},t)}function Tn(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function En(e){return D(e)&&s.IsNumber(e.const)}function kn(e){return D(e)&&s.IsString(e.const)}function D(e){return f(e,"Literal")}function st(e){return p.Create({"~kind":"Null"},{type:"null"},e)}function Dt(e){return f(e,"Null")}var On="-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?";function be(e){return p.Create({"~kind":"Number"},{type:"number"},e)}function Y(e){return f(e,"Number")}function Ut(e){return p.Create({"~kind":"Symbol"},{type:"symbol"},e)}function it(e){return f(e,"Symbol")}function Pt(...e){let[t,r,n]=ot.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,i],1:a=>[a,ue(),ue()]});return p.Create({"~kind":"Parameter"},{name:t,extends:r,equals:n},{})}function Co(e){return f(e,"Parameter")}function De(e,t){return p.Create({"~kind":"Promise"},{type:"promise",item:e},t)}function de(e){return f(e,"Promise")}function Mo(e){return p.Discard(e,["~kind","type","item"])}var Pn=".*";function Pe(e){return p.Create({"~kind":"String"},{type:"string"},e)}function le(e){return f(e,"String")}function hr(e){let t=So(e);return s.IsEqual(t.length,2)?t[0]:[]}function al(e){return!0}function jo(e){let[t,...r]=e;return k(t)?ol(t)?jo(r):!1:!0}function qo(e){return s.IsEqual(e.length,0)?!1:jo(e)}function ol(e){return y(e)?qo(e.anyOf):D(e)?al(e.const):!1}function wn(e){return qo(e)}function Rn(e){return p.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Ao(e,t,r=[]){let[n,...a]=e;return s.IsString(n)?Ao(a,t,[...r,`${n}${t}`]):r}function sl(e,t){return s.IsEqual(e.length,0)?[`${t}`]:Ao(e,t)}function Lo(e,t,r=[]){let[n,...a]=t;return k(n)?Lo(e,a,[...r,...No(e,n)]):r}function No(e,t){return y(t)?Lo(e,t.anyOf):D(t)?sl(e,t.const):K()}function Fo(e,t){let[r,...n]=t;return k(r)?Fo(No(e,r),n):e}function il(e){return e.map(t=>q(t))}function ml(e){let t=Fo([],e),r=il(t);return O(r)}function pl(e){return s.IsEqual(e.length,0)?K():s.IsEqual(e.length,1)&&D(e[0])?e[0]:ml(e)}function sa(e){let t=hr(e);return s.IsEqual(t.length,0)?Pe():wn(t)?pl(t):Rn(e)}function he(e){let t=sa(e);return Q(t)?Pe():t}function ye(e,t){let r="object",n={[e]:t};return p.Create({"~kind":"Record"},{type:r,patternProperties:n})}var Kt=`^${hn}$`,Gt=`^${On}$`,Me=`^${Pn}$`;function Tr(e,t,r={}){return $("Record",[e,t],r)}function ul(e,t,r={}){return g({},Tr(e,t,r))}function vn(e,t,r={}){return ul(e,t,r)}function Do(e,t){return ye(e,t)}function _t(e){return s.Keys(e.patternProperties)[0]}function zt(e){let t=_t(e);return s.IsEqual(t,Me)?Pe():s.IsEqual(t,Kt)?Ot():s.IsEqual(t,Gt)?be():sa(t)}function Ue(e){return e.patternProperties[_t(e)]}function we(e){return f(e,"Record")}function wt(e){return p.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function mt(e){return f(e,"Rest")}function Cn(e){return p.Create({"~kind":"This"},{$ref:"#"},e)}function Uo(e){return f(e,"This")}function ee(e,t={}){let[r,n,a]=[e,e.length,!1];return p.Create({"~kind":"Tuple"},{type:"array",additionalItems:a,items:r,minItems:n},t)}function U(e){return f(e,"Tuple")}function Ko(e){return p.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Bt(e){return p.Create({"~kind":"Undefined"},{type:"undefined"},e)}function Ht(e){return f(e,"Undefined")}function Go(e){return p.Create({"~kind":"Unsafe"},{},e)}function _o(e){return f(e,"Unsafe")}function Mn(e){return p.Create({"~kind":"Void"},{type:"void"},e)}function Ke(e){return f(e,"Void")}function dl(e,t){return s.IsEqual(e,"Array")?Ce(t[0]):s.IsEqual(e,"AsyncIterator")?Ae(t[0]):s.IsEqual(e,"Iterator")?Fe(t[0]):s.IsEqual(e,"Promise")?De(t[0]):s.IsEqual(e,"Awaited")?Gr(t[0]):s.IsEqual(e,"Capitalize")?Or(t[0]):s.IsEqual(e,"ConstructorParameters")?Cr(t[0]):s.IsEqual(e,"Evaluate")?ma(t[0]):s.IsEqual(e,"Exclude")?Mr(t[0],t[1]):s.IsEqual(e,"Extract")?Sr(t[0],t[1]):s.IsEqual(e,"Index")?Wt(t[0],t[1]):s.IsEqual(e,"InstanceType")?jr(t[0]):s.IsEqual(e,"Lowercase")?Pr(t[0]):s.IsEqual(e,"NonNullable")?qr(t[0]):s.IsEqual(e,"Omit")?Ar(t[0],t[1]):s.IsEqual(e,"Options")?Zt(t[0],t[1]):s.IsEqual(e,"Parameters")?Lr(t[0]):s.IsEqual(e,"Partial")?Nr(t[0]):s.IsEqual(e,"Pick")?Fr(t[0],t[1]):s.IsEqual(e,"Readonly")?Dr(t[0]):s.IsEqual(e,"KeyOf")?Xt(t[0]):s.IsEqual(e,"Record")?Tr(t[0],t[1]):s.IsEqual(e,"Required")?Ur(t[0]):s.IsEqual(e,"ReturnType")?Kr(t[0]):s.IsEqual(e,"Uncapitalize")?wr(t[0]):s.IsEqual(e,"Uppercase")?Rr(t[0]):kr(He(e),t)}function Rt(){throw Error("Unreachable")}var ll=(e,t=[])=>e.reduce((r,n)=>s.IsArray(n)&&s.IsEqual(n.length,2)?[...r,n[0]]:[...r,n],[]),Ve=e=>{let[t,r]=e;return ll([...t,...r])};function Jo(e){return Pt(e[0],e[2],e[4])}function Wo(e){return Pt(e[0],e[2],e[2])}function Xo(e){return Pt(e[0],ue(),e[2])}function Zo(e){return Pt(e,ue(),ue())}function Yo(e){return Ve(e)}function Qo(e){return e[1]}function es(e){return Ve(e)}function ts(e){return e[1]}function rs(e){return dl(e[0],e[1])}function ns(e){return null}function as(e){return Pe()}function os(e){return be()}function ss(e){return bn()}function is(e){return Bt()}function ms(e){return st()}function ps(e){return Ot()}function us(e){return $r()}function cs(e){return ue()}function ds(e){return Ft()}function ls(e){return E({})}function fs(e){return S()}function xs(e){return Ut()}function Is(e){return Mn()}function ys(e){return Cn()}function gs(e){return e[1]}function $s(e){return q(e)}function bs(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function hs(e){return e[1]}function Ts(e){return Er(e)}function Es(e){return q(BigInt(e))}function ks(e){return q(s.IsEqual(e,"true"))}function Os(e){return q(parseFloat(e))}function Ps(e){return q(e)}function ws(e){return e.length>0}function Rs(e){return e.reduce((t,r)=>s.IsEqual(r.length,3)?[...t,[r[1]]]:[...t,[]],[])}function vs(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function Cs(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}var zo=(e,t)=>t.reduce((r,n)=>{let a=n;return s.IsEqual(a.length,1)?Wt(r,a[0]):s.IsEqual(a.length,0)?Ce(r):Rt()},e),Bo=(e,t)=>s.IsEqual(t.length,3)?vr(e,t[0],t[1],t[2]):e;function Ms(e){let[t,r,n,a]=e;return Bo(t?Xt(zo(r,n)):zo(r,n),a)}function ia(e,t){return s.IsEqual(t.length,3)?(()=>{let[r,n,a]=t,i=ia(n,a);if(s.IsEqual(r,"&"))return M(i)?Te([e,...i.allOf]):Te([e,i]);if(s.IsEqual(r,"|"))return y(i)?O([e,...i.anyOf]):O([e,i]);Rt()})():e}function Ss(e){let[t,r]=e;return ia(t,r)}function js(e){let[t,r]=e;return ia(t,r)}function qs(e){return na(e[1])}function As(e){return e[1]}function Ls(e){return nt(e[0],e[2])}function Ns(e){return s.IsEqual(e.length,4)?Ir(e[1],e[3]):s.IsEqual(e.length,2)?Ir(e[1],ue()):Rt()}function Fs(e){return`${e}`}function Ds(e){return ce(e[3])?Kt:Y(e[3])?Gt:it(e[3])?Me:le(e[3])?Me:Rt()}function Us(e){return e.length>0}function Ks(e){return e.length>0}function Gs(e){let[t,r,n,a,i]=e;return{[r]:t&&n?Ie(xe(i)):t&&!n?Ie(i):!t&&n?xe(i):i}}function _s(e){return Ve(e)}function zs(e){return e.reduce((t,r)=>s.HasPropertyKey(r,Kt)||s.HasPropertyKey(r,Gt)||s.HasPropertyKey(r,Me)?[t[0],p.Assign(t[1],r)]:[p.Assign(t[0],r),t[1]],[{},{}])}function Bs(e){return zs(e[1])}function Hs(e){let[t,r]=e,n=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return E(t,n)}function Vs(e){return s.IsEqual(e.length,5)?Ie(xe(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?Ie(e[3]):xe(e[3]):Rt()}function Js(e){return Ie(xe(e[1]))}function Ws(e){return Ie(e[1])}function Xs(e){return xe(e[0])}function Zs(e){return s.IsEqual(e.length,2)?wt(e[1]):s.IsEqual(e.length,1)?e[0]:Rt()}function Ys(e){return Ve(e)}function Qs(e){return ee(e[1])}function ei(e){return Ie(xe(e[4]))}function ti(e){return Ie(e[3])}function ri(e){return xe(e[3])}function ni(e){return e[2]}function ai(e){return s.IsEqual(e.length,2)?wt(e[1]):s.IsEqual(e.length,1)?e[0]:Rt()}function oi(e){return Ve(e)}function si(e){return rt(e[1],e[4])}function ii(e){return tt(e[2],e[5])}function Ho(e,t){return s.IsEqual(e,"remove")?oo(t):s.IsEqual(e,"add")?no(t):t}function mi(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 Vo(e,t){return s.IsEqual(e,"remove")?to(t):s.IsEqual(e,"add")?Qa(t):t}function pi(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 ui(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function ci(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?Vt(br(e[3]),e[5],e[6][0],Ho(e[1],Vo(e[8],e[10]))):Vt(br(e[3]),e[5],He(e[3]),Ho(e[1],Vo(e[8],e[10])))}function di(e){return He(e)}function li(e){return Zt(e[2],e[4])}function fi(e){return parseFloat(e)}function xi(e){return s.IsEqual(e,"true")}function Ii(e){return null}function yi(e){return{[e[0]]:e[2]}}function gi(e){return Ve(e)}function fl(e){return e.reduce((t,r)=>p.Assign(t,r),{})}function $i(e){return fl(e[1])}function bi(e){return Ve(e)}function hi(e){return e[1]}function Ti(e){return $r()}function Ei(e){return Pe()}function ki(e){return be()}function Oi(e){return Ot()}function Pi(e){return S()}function wi(e){return q(e)}function Ri(e){return O(e[1])}function vi(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function Ci(e){return[e[0],...e[1]]}function Mi(e){return e[1]}function Si(e){return Ve(e)}function ji(e){return s.IsEqual(e.length,2)?e[1]:[]}function qi(e){let t=e[2],r=e[3],[n,a]=e[4],i=s.IsEqual(s.Keys(a).length,0)?{}:{patternProperties:a};return{[e[1]]:nt(t,Jt(r,n,i))}}function Ai(e){let t=e[2],[r,n]=e[3],a=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return{[e[1]]:Jt(t,r,a)}}function Li(e){return{[e[1]]:nt(e[2],e[4])}}function Ni(e){return{[e[1]]:e[3]}}function Fi(e){return null}function Di(e){return zs(Ve(e))}function Ui(e){return e[1]}function Ki(e){let t=e[0],r=e[1];return pa(p.Assign(t,r[0]))}function _r(e){return L(e.length,2)}function w(e,t,r){return _r(e)?t(e[0],e[1]):r()}function yl(e,t){return L(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function G(e,t){for(let r=0;r<e.length;r++){let n=yl(e[r],t);if(_r(n))return n}return[]}function ua(e,t){return Array.from({length:t-e+1},(r,n)=>String.fromCharCode(e+n))}var Gi=[...ua(97,122),...ua(65,90)],ca="0",da=ua(49,57),Yt=[ca,...da],_i=" ",Qt=`
3
- `;var pt="_",Sn=".",zi="$",jn="-";var Bi="//",Hi="/*",$l="*/";function Vi(e){let t=e.indexOf($l);return L(t,-1)?"":e.slice(t+2)}function Ji(e){let t=e.indexOf(Qt);return L(t,-1)?"":e.slice(t)}function bl(e){return e.replace(/^[ \t\r\f\v]+/,"")}function qn(e){let t=bl(e);return t.startsWith(Hi)?qn(Vi(t.slice(2))):t.startsWith(Bi)?qn(Ji(t.slice(2))):t}function ne(e){let t=e.trimStart();return t.startsWith(Hi)?ne(Vi(t.slice(2))):t.startsWith(Bi)?ne(Ji(t.slice(2))):t}function An(e,t){return w(G([e],t),(r,n)=>[r,n],()=>["",t])}function hl(e,t){return e.includes(t)}function er(e,t,r,n=""){return w(G(e,r),(a,i)=>hl(t,a)?er(e,t,i,n):er(e,t,i,`${n}${a}`),()=>[n,r])}function Tl(e){return G(da,e)}var El=[...Yt,pt];function kl(e){return er(El,[pt],e)}function Ol(e){return w(G([ca],e),(t,r)=>[t,r],()=>w(Tl(e),(t,r)=>w(kl(r),(n,a)=>[`${t}${n}`,a],()=>[]),()=>[]))}function Ln(e){return Ol(ne(e))}function Pl(e){return An(jn,e)}function wl(e){return w(Pl(e),(t,r)=>w(Ln(r),(n,a)=>[`${t}${n}`,a],()=>[]),()=>[])}function Wi(e){return wl(ne(e))}function Rl(e){return w(Wi(e),(t,r)=>w(G(["n"],r),(n,a)=>[`${t}`,a],()=>[]),()=>[])}function Xi(e){return Rl(e)}function la(e,t){return G([e],t)}function u(e,t){return L(e,"")?["",t]:e.startsWith(Qt)?la(e,qn(t)):e.startsWith(_i)?la(e,t):la(e,ne(t))}var Zi=[...Gi,pt,zi];function vl(e){return G(Zi,e)}var Cl=[...Zi,...Yt];function Yi(e,t=""){return w(G(Cl,e),(r,n)=>Yi(n,`${t}${r}`),()=>[t,e])}function Ml(e){return w(vl(e),(t,r)=>w(Yi(r),(n,a)=>[`${t}${n}`,a],()=>[]),()=>[])}function B(e){return Ml(ne(e))}var Sl=[...Yt,pt];function jl(e){return _r(G([Sn],e))}function Qi(e){return w(er(Sl,[pt],e),(t,r)=>L(t,"")?[]:[t,r],()=>[])}function ql(e){return w(G([Sn],e),(t,r)=>w(Qi(r),(n,a)=>[`0${t}${n}`,a],()=>[]),()=>[])}function Al(e){return w(Ln(e),(t,r)=>w(G([Sn],r),(n,a)=>w(Qi(a),(i,m)=>[`${t}${n}${i}`,m],()=>[`${t}`,a]),()=>[`${t}`,r]),()=>[])}function Ll(e){return jl(e)?ql(e):Al(e)}function em(e){return Ll(ne(e))}function Nl(e){return An(jn,e)}function Fl(e){return w(Nl(e),(t,r)=>w(em(r),(n,a)=>[`${t}${n}`,a],()=>[]),()=>[])}function Nn(e){return Fl(ne(e))}function Dl(e){return L(e,"")?[]:[e.slice(0,1),e.slice(1)]}function tm(e,t){let[r,...n]=e;return At(r)?t.startsWith(r)?!0:tm(n,t):!1}function ut(e,t,r=""){return w(Dl(t),(n,a)=>tm(e,t)?[r,t]:ut(e,a,`${r}${n}`),()=>[])}function Ul(e,t,r){return w(G([e],r),(n,a)=>w(ut([t],a),(i,m)=>w(G([t],m),(c,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function Kl(e,t,r){return w(G([e],r),(n,a)=>w(ut([Qt,t],a),(i,m)=>w(G([t],m),(c,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function rm(e,t,r,n){return r?Ul(e,t,ne(n)):Kl(e,t,ne(n))}function Gl(e,t){return G(e,t)}function _l(e,t){return rm(e,e,!1,t)}function zl(e,t){return w(Gl(e,t),(r,n)=>_l(r,`${r}${n}`),()=>[])}function Fn(e,t){return zl(e,ne(t))}function nm(e,t){return w(ut(e,t),(r,n)=>L(r,"")?[]:[r,n],()=>[])}var o=(e,t,r=()=>[])=>e.length===2?t(e):r(),Hl=e=>o(o(B(e),([t,r])=>o(u("extends",r),([n,a])=>o(A(a),([i,m])=>o(u("=",m),([c,l])=>o(A(l),([v,j])=>[[t,n,i,c,v],j]))))),([t,r])=>[Jo(t),r]),Vl=e=>o(o(B(e),([t,r])=>o(u("extends",r),([n,a])=>o(A(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Wo(t),r]),Jl=e=>o(o(B(e),([t,r])=>o(u("=",r),([n,a])=>o(A(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Xo(t),r]),Wl=e=>o(B(e),([t,r])=>[Zo(t),r]),sm=e=>o(o(Hl(e),([t,r])=>[t,r],()=>o(Vl(e),([t,r])=>[t,r],()=>o(Jl(e),([t,r])=>[t,r],()=>o(Wl(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),im=(e,t=[])=>o(o(sm(e),([r,n])=>o(u(",",n),([a,i])=>[[r,a],i])),([r,n])=>im(n,[...t,r]),()=>[t,e]),Xl=e=>o(o(im(e),([t,r])=>o(o(o(sm(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[Yo(t),r]),Ia=e=>o(o(u("<",e),([t,r])=>o(Xl(r),([n,a])=>o(u(">",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Qo(t),r]),mm=(e,t=[])=>o(o(A(e),([r,n])=>o(u(",",n),([a,i])=>[[r,a],i])),([r,n])=>mm(n,[...t,r]),()=>[t,e]),Zl=e=>o(o(mm(e),([t,r])=>o(o(o(A(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[es(t),r]),Yl=e=>o(o(u("<",e),([t,r])=>o(Zl(r),([n,a])=>o(u(">",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[ts(t),r]),Ql=e=>o(o(B(e),([t,r])=>o(Yl(r),([n,a])=>[[t,n],a])),([t,r])=>[rs(t),r]),pm=e=>o(o(o(u(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ns(t),r]),um=e=>o(u("string",e),([t,r])=>[as(t),r]),cm=e=>o(u("number",e),([t,r])=>[os(t),r]),ef=e=>o(u("boolean",e),([t,r])=>[ss(t),r]),tf=e=>o(u("undefined",e),([t,r])=>[is(t),r]),rf=e=>o(u("null",e),([t,r])=>[ms(t),r]),dm=e=>o(u("integer",e),([t,r])=>[ps(t),r]),nf=e=>o(u("bigint",e),([t,r])=>[us(t),r]),af=e=>o(u("unknown",e),([t,r])=>[cs(t),r]),of=e=>o(u("any",e),([t,r])=>[ds(t),r]),sf=e=>o(u("object",e),([t,r])=>[ls(t),r]),mf=e=>o(u("never",e),([t,r])=>[fs(t),r]),lm=e=>o(u("symbol",e),([t,r])=>[xs(t),r]),pf=e=>o(u("void",e),([t,r])=>[Is(t),r]),uf=e=>o(u("this",e),([t,r])=>[ys(t),r]),cf=e=>o(o(um(e),([t,r])=>[t,r],()=>o(cm(e),([t,r])=>[t,r],()=>o(ef(e),([t,r])=>[t,r],()=>o(tf(e),([t,r])=>[t,r],()=>o(rf(e),([t,r])=>[t,r],()=>o(dm(e),([t,r])=>[t,r],()=>o(nf(e),([t,r])=>[t,r],()=>o(af(e),([t,r])=>[t,r],()=>o(of(e),([t,r])=>[t,r],()=>o(sf(e),([t,r])=>[t,r],()=>o(mf(e),([t,r])=>[t,r],()=>o(lm(e),([t,r])=>[t,r],()=>o(pf(e),([t,r])=>[t,r],()=>o(uf(e),([t,r])=>[t,r],()=>[])))))))))))))),([t,r])=>[t,r]),df=e=>o(o(u("${",e),([t,r])=>o(A(r),([n,a])=>o(u("}",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[gs(t),r]),fa=e=>o(ut(["${","`"],e),([t,r])=>[$s(t),r]),fm=e=>o(o(o(fa(e),([t,r])=>o(df(r),([n,a])=>o(fm(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[t,r],()=>o(o(fa(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o(o(fa(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[bs(t),r]),ya=e=>o(o(u("`",e),([t,r])=>o(fm(r),([n,a])=>o(u("`",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[hs(t),r]),lf=e=>o(ya(e),([t,r])=>[Ts(t),r]),ff=e=>o(Xi(e),([t,r])=>[Es(t),r]),xf=e=>o(o(u("true",e),([t,r])=>[t,r],()=>o(u("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[ks(t),r]),If=e=>o(Nn(e),([t,r])=>[Os(t),r]),yf=e=>o(Fn(["'",'"'],e),([t,r])=>[Ps(t),r]),gf=e=>o(o(ff(e),([t,r])=>[t,r],()=>o(xf(e),([t,r])=>[t,r],()=>o(If(e),([t,r])=>[t,r],()=>o(yf(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),$f=e=>o(o(o(u("keyof",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ws(t),r]),xm=(e,t=[])=>o(o(o(u("[",e),([r,n])=>o(A(n),([a,i])=>o(u("]",i),([m,c])=>[[r,a,m],c]))),([r,n])=>[r,n],()=>o(o(u("[",e),([r,n])=>o(u("]",n),([a,i])=>[[r,a],i])),([r,n])=>[r,n],()=>[])),([r,n])=>xm(n,[...t,r]),()=>[t,e]),bf=e=>o(xm(e),([t,r])=>[Rs(t),r]),hf=e=>o(o(o(u("extends",e),([t,r])=>o(A(r),([n,a])=>o(u("?",a),([i,m])=>o(A(m),([c,l])=>o(u(":",l),([v,j])=>o(A(j),([b,C])=>[[t,n,i,c,v,b],C])))))),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[vs(t),r]),Tf=e=>o(o(o(u("(",e),([t,r])=>o(A(r),([n,a])=>o(u(")",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[t,r],()=>o(cf(e),([t,r])=>[t,r],()=>o(qf(e),([t,r])=>[t,r],()=>o(Uf(e),([t,r])=>[t,r],()=>o(lf(e),([t,r])=>[t,r],()=>o(gf(e),([t,r])=>[t,r],()=>o(Hf(e),([t,r])=>[t,r],()=>o(Bf(e),([t,r])=>[t,r],()=>o(Xf(e),([t,r])=>[t,r],()=>o(Yf(e),([t,r])=>[t,r],()=>o(Ql(e),([t,r])=>[t,r],()=>o(Zf(e),([t,r])=>[t,r],()=>[])))))))))))),([t,r])=>[Cs(t),r]),Im=e=>o(o($f(e),([t,r])=>o(Tf(r),([n,a])=>o(bf(a),([i,m])=>o(hf(m),([c,l])=>[[t,n,i,c],l])))),([t,r])=>[Ms(t),r]),ym=e=>o(o(o(u("&",e),([t,r])=>o(Im(r),([n,a])=>o(ym(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),gm=e=>o(o(Im(e),([t,r])=>o(ym(r),([n,a])=>[[t,n],a])),([t,r])=>[Ss(t),r]),$m=e=>o(o(o(u("|",e),([t,r])=>o(gm(r),([n,a])=>o($m(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),Dn=e=>o(o(gm(e),([t,r])=>o($m(r),([n,a])=>[[t,n],a])),([t,r])=>[js(t),r]),Ef=e=>o(o(u("readonly",e),([t,r])=>o(Dn(r),([n,a])=>[[t,n],a])),([t,r])=>[qs(t),r]),kf=e=>o(o(u("|",e),([t,r])=>o(Dn(r),([n,a])=>[[t,n],a])),([t,r])=>[As(t),r]),Of=e=>o(o(Ia(e),([t,r])=>o(u("=",r),([n,a])=>o(A(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Ls(t),r]),Pf=e=>o(o(o(u("infer",e),([t,r])=>o(B(r),([n,a])=>o(u("extends",a),([i,m])=>o(Dn(m),([c,l])=>[[t,n,i,c],l])))),([t,r])=>[t,r],()=>o(o(u("infer",e),([t,r])=>o(B(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>[])),([t,r])=>[Ns(t),r]),A=e=>o(o(Pf(e),([t,r])=>[t,r],()=>o(kf(e),([t,r])=>[t,r],()=>o(Ef(e),([t,r])=>[t,r],()=>o(Dn(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),wf=e=>o(Nn(e),([t,r])=>[Fs(t),r]),Rf=e=>o(B(e),([t,r])=>[t,r]),vf=e=>o(Fn(["'",'"'],e),([t,r])=>[t,r]),Cf=e=>o(o(u("[",e),([t,r])=>o(B(r),([n,a])=>o(u(":",a),([i,m])=>o(o(dm(m),([c,l])=>[c,l],()=>o(cm(m),([c,l])=>[c,l],()=>o(um(m),([c,l])=>[c,l],()=>o(lm(m),([c,l])=>[c,l],()=>[])))),([c,l])=>o(u("]",l),([v,j])=>[[t,n,i,c,v],j]))))),([t,r])=>[Ds(t),r]),bm=e=>o(o(wf(e),([t,r])=>[t,r],()=>o(Rf(e),([t,r])=>[t,r],()=>o(vf(e),([t,r])=>[t,r],()=>o(Cf(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),Mf=e=>o(o(o(u("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Us(t),r]),Sf=e=>o(o(o(u("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ks(t),r]),hm=e=>o(o(Mf(e),([t,r])=>o(bm(r),([n,a])=>o(Sf(a),([i,m])=>o(u(":",m),([c,l])=>o(A(l),([v,j])=>[[t,n,i,c,v],j]))))),([t,r])=>[Gs(t),r]),Tm=e=>o(o(o(u(",",e),([t,r])=>o(u(`
2
+ var Id=Object.defineProperty;var qt=(e,t)=>{for(var r in t)Id(e,r,{get:t[r],enumerable:!0})};var p={};qt(p,{Assign:()=>yd,Clone:()=>xr,Create:()=>tl,Discard:()=>rl,Metrics:()=>ve,Update:()=>nl});var ve={assign:0,create:0,clone:0,discard:0,update:0};function yd(e,t){return ve.assign+=1,{...e,...t}}var i={};qt(i,{Entries:()=>Ud,EntriesRegExp:()=>Fd,Every:()=>Ld,EveryAll:()=>Dd,GraphemeCount:()=>jd,HasPropertyKey:()=>Nd,IsArray:()=>fr,IsAsyncIterator:()=>Ed,IsBigInt:()=>lr,IsBoolean:()=>Xa,IsClassInstance:()=>Md,IsConstructor:()=>kd,IsDeepEqual:()=>na,IsEqual:()=>L,IsFunction:()=>Za,IsGreaterEqualThan:()=>Qa,IsGreaterThan:()=>Rd,IsInteger:()=>ta,IsIterator:()=>Od,IsLessEqualThan:()=>Ya,IsLessThan:()=>vd,IsMaxLength:()=>qd,IsMinLength:()=>Ad,IsMultipleOf:()=>Cd,IsNull:()=>cn,IsNumber:()=>dn,IsObject:()=>ht,IsObjectNotArray:()=>Pd,IsString:()=>At,IsSymbol:()=>wd,IsUndefined:()=>ra,IsValueLike:()=>Sd,Keys:()=>un,Symbols:()=>Kd,Values:()=>_d});function Ze(e,t,r){return e>=t&&e<=r}function za(e){return Ze(e,127462,127487)}function gd(e){return Ze(e,65024,65039)}function $d(e){return Ze(e,768,879)||Ze(e,6832,6911)||Ze(e,7616,7679)||Ze(e,65056,65071)}function pn(e){return e>65535?2:1}function Ba(e,t){for(;t<e.length;){let r=e.codePointAt(t);if($d(r)||gd(r))t+=pn(r);else break}return t}function ea(e,t){let r=e.codePointAt(t),n=t+pn(r);for(n=Ba(e,n);n<e.length-1&&e[n]==="\u200D";){let a=e.codePointAt(n+1);n+=1+pn(a),n=Ba(e,n)}return za(r)&&n<e.length&&za(e.codePointAt(n))&&(n+=pn(e.codePointAt(n))),n}function Ha(e){return Ze(e,55296,56319)||Ze(e,768,879)||e===8205}function Va(e){let t=0,r=0;for(;r<e.length;)r=ea(e,r),t++;return t}function bd(e,t){if(t===0)return!0;let r=0,n=0;for(;n<e.length;)if(n=ea(e,n),r++,r>=t)return!0;return!1}function hd(e,t){let r=0,n=0;for(;n<e.length;)if(n=ea(e,n),r++,r>t)return!1;return!0}function Ja(e,t){if(t===0)return!0;let r=0;for(;r<e.length;){if(Ha(e.charCodeAt(r)))return bd(e,t);if(r++,r>=t)return!0}return!1}function Wa(e,t){let r=0;for(;r<e.length;){if(Ha(e.charCodeAt(r)))return hd(e,t);if(r++,r>t)return!1}return!0}function fr(e){return Array.isArray(e)}function Ed(e){return ht(e)&&Symbol.asyncIterator in e}function lr(e){return L(typeof e,"bigint")}function Xa(e){return L(typeof e,"boolean")}function kd(e){if(ra(e)||!Za(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function Za(e){return L(typeof e,"function")}function ta(e){return Number.isInteger(e)}function Od(e){return ht(e)&&Symbol.iterator in e}function cn(e){return L(e,null)}function dn(e){return Number.isFinite(e)}function Pd(e){return ht(e)&&!fr(e)}function ht(e){return L(typeof e,"object")&&!cn(e)}function At(e){return L(typeof e,"string")}function wd(e){return L(typeof e,"symbol")}function ra(e){return L(e,void 0)}function L(e,t){return e===t}function Rd(e,t){return e>t}function vd(e,t){return e<t}function Ya(e,t){return e<=t}function Qa(e,t){return e>=t}function Cd(e,t){if(lr(e)||lr(t))return BigInt(e)%BigInt(t)===0n;let r=1e-10;if(!dn(e)||ta(e)&&1/t%1===0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t))<r}function Md(e){if(!ht(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return cn(t)?!1:L(typeof t.constructor,"function")&&!(L(t.constructor,globalThis.Object)||L(t.constructor.name,"Object"))}function Sd(e){return lr(e)||Xa(e)||cn(e)||dn(e)||At(e)||ra(e)}function jd(e){return Va(e)}function qd(e,t){return Wa(e,t)}function Ad(e,t){return Ja(e,t)}function Ld(e,t,r){for(let n=t;n<e.length;n++)if(!r(e[n],n))return!1;return!0}function Dd(e,t,r){let n=!0;for(let a=t;a<e.length;a++)r(e[a],a)||(n=!1);return n}function Nd(e,t){return L(t,"__proto__")||L(t,"constructor")?Object.prototype.hasOwnProperty.call(e,t):t in e}function Fd(e){return un(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function Ud(e){return Object.entries(e)}function un(e){return Object.getOwnPropertyNames(e)}function Kd(e){return Object.getOwnPropertySymbols(e)}function _d(e){return Object.values(e)}function Gd(e,t){if(!ht(t))return!1;let r=un(e);return L(r.length,un(t).length)&&r.every(n=>na(e[n],t[n]))}function zd(e,t){return fr(t)&&L(e.length,t.length)&&e.every((r,n)=>na(e[n],t[n]))}function na(e,t){return fr(e)?zd(e,t):ht(e)?Gd(e,t):L(e,t)}function Vd(e){return i.IsObject(e)&&i.HasPropertyKey(e,"~guard")}function Jd(e){return e.map(t=>aa(t))}function Wd(e){let t={},r=Object.getOwnPropertyDescriptors(e);for(let n of Object.keys(r)){let a=r[n];i.HasPropertyKey(a,"value")&&Object.defineProperty(t,n,{...a,value:aa(a.value)})}return t}function Xd(e){return new RegExp(e.source,e.flags)}function aa(e){return e instanceof RegExp?Xd(e):Vd(e)?e:i.IsArray(e)?Jd(e):i.IsObject(e)?Wd(e):e}function xr(e){return ve.clone+=1,aa(e)}var Be={};qt(Be,{Get:()=>Qd,Reset:()=>Zd,Set:()=>Yd});var Ye={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1};function Zd(){Ye.immutableTypes=!1,Ye.maxErrors=8,Ye.useAcceleration=!0,Ye.exactOptionalPropertyTypes=!1,Ye.enumerableKind=!1,Ye.correctiveParse=!1}function Yd(e){for(let t of i.Keys(e)){let r=e[t];r!==void 0&&Object.defineProperty(Ye,t,{value:r})}}function Qd(){return Ye}function el(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 to(e,t){return{...e,...t}}function tl(e,t,r={}){ve.create+=1;let n=Be.Get(),a=to(t,r),s=n.enumerableKind?to(a,e):el(a,e);return n.immutableTypes?Object.freeze(s):s}function rl(e,t){ve.discard+=1;let r={},n=Object.getOwnPropertyDescriptors(xr(e)),a=new Set(t);for(let s of Object.keys(n))a.has(s)||Object.defineProperty(r,s,n[s]);return r}function nl(e,t,r){ve.update+=1;let n=Be.Get(),a=xr(e);for(let s of Object.keys(t))Object.defineProperty(a,s,{configurable:!0,writable:!0,enumerable:n.enumerableKind,value:t[s]});for(let s of Object.keys(r))Object.defineProperty(a,s,{configurable:!0,enumerable:!0,writable:!0,value:r[s]});return a}function f(e,t){return i.IsObject(e)&&i.HasPropertyKey(e,"~kind")&&i.IsEqual(e["~kind"],t)}function k(e){return i.IsObject(e)}function ro(e){return p.Create({"~kind":"OptionalAddAction"},{type:e},{})}function no(e){return i.IsObject(e)&&i.HasPropertyKey(e,"~kind")&&i.HasPropertyKey(e,"type")&&i.IsEqual(e["~kind"],"OptionalAddAction")&&k(e.type)}function ao(e){return p.Create({"~kind":"OptionalRemoveAction"},{type:e},{})}function oo(e){return i.IsObject(e)&&i.HasPropertyKey(e,"~kind")&&i.HasPropertyKey(e,"type")&&i.IsEqual(e["~kind"],"OptionalRemoveAction")&&k(e.type)}function so(e){return p.Create({"~kind":"ReadonlyAddAction"},{type:e},{})}function io(e){return i.IsObject(e)&&i.HasPropertyKey(e,"~kind")&&i.HasPropertyKey(e,"type")&&i.IsEqual(e["~kind"],"ReadonlyAddAction")&&k(e.type)}function mo(e){return p.Create({"~kind":"ReadonlyRemoveAction"},{type:e},{})}function po(e){return i.IsObject(e)&&i.HasPropertyKey(e,"~kind")&&i.HasPropertyKey(e,"type")&&i.IsEqual(e["~kind"],"ReadonlyRemoveAction")&&k(e.type)}function $(e,t,r){return p.Create({"~kind":"Deferred"},{action:e,parameters:t,options:r},{})}function Qe(e){return f(e,"Deferred")}function oa(e){return p.Update(e,{"~immutable":!0},{})}function et(e){return oa(e)}function Tt(e){return k(e)&&i.HasPropertyKey(e,"~immutable")}function Lt(e){return p.Discard(e,["~optional"])}function xe(e){return p.Update(e,{"~optional":!0},{})}function ln(e){return xe(e)}function pe(e){return k(e)&&i.HasPropertyKey(e,"~optional")}function fn(e){return p.Discard(e,["~readonly"])}function Ie(e){return p.Update(e,{"~readonly":!0},{})}function xn(e){return Ie(e)}function Et(e){return k(e)&&i.HasPropertyKey(e,"~readonly")}function Ce(e,t){return p.Create({"~kind":"Array"},{type:"array",items:e},t)}function z(e){return f(e,"Array")}function In(e){return p.Discard(e,["~kind","type","items"])}function Ae(e,t){return p.Create({"~kind":"AsyncIterator"},{type:"asyncIterator",iteratorItems:e},t)}function ge(e){return f(e,"AsyncIterator")}function uo(e){return p.Discard(e,["~kind","type","iteratorItems"])}function co(e){return{enumerable:Be.Get().enumerableKind,writable:!1,configurable:!1,value:e}}var yn=class{constructor(){globalThis.Object.defineProperty(this,"~kind",co("Base")),globalThis.Object.defineProperty(this,"~guard",co({check:t=>this.Check(t),errors:t=>this.Errors(t)}))}Check(t){return!0}Errors(t){return[]}Convert(t){return t}Clean(t){return t}Default(t){return t}Create(){throw new Error("Create not implemented")}Clone(){throw Error("Clone not implemented")}};function gn(e){return f(e,"Base")}function tt(e,t,r={}){return p.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},r)}function ae(e){return f(e,"Constructor")}function lo(e){return p.Discard(e,["~kind","type","parameters","instanceType"])}function rt(e,t,r={}){return p.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},r)}function oe(e){return f(e,"Function")}function fo(e){return p.Discard(e,["~kind","type","parameters","returnType"])}function He(e,t){return p.Create({"~kind":"Ref"},{$ref:e},t)}function X(e){return f(e,"Ref")}function nt(e,t){return p.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function Dt(e){return f(e,"Generic")}function Nt(e){return p.Create({"~kind":"Any"},{},e)}function Z(e){return f(e,"Any")}var xo="(?!)";function S(e){return p.Create({"~kind":"Never"},{not:{}},e)}function at(e){return f(e,"Never")}function Io(e){return i.Keys(e).filter(t=>!pe(e[t]))}function yo(e){return i.Keys(e)}function $n(e){return i.Values(e)}function E(e,t={}){let r=Io(e),n=r.length>0?{required:r}:{};return p.Create({"~kind":"Object"},{type:"object",...n,properties:e},t)}function N(e){return f(e,"Object")}function go(e){return p.Discard(e,["~kind","type","properties","required"])}function O(e,t={}){return p.Create({"~kind":"Union"},{anyOf:e},t)}function y(e){return f(e,"Union")}function $o(e){return p.Discard(e,["~kind","anyOf"])}function ue(e){return p.Create({"~kind":"Unknown"},{},e)}function re(e){return f(e,"Unknown")}function Le(e,t,r){let n=i.Keys(e).reduce((a,s)=>({...a,[s]:p.Update(e[s],{},{$id:s})}),{});return p.Create({"~kind":"Cyclic"},{$defs:n,$ref:t},r)}function se(e){return f(e,"Cyclic")}var ot={};qt(ot,{Match:()=>al});function al(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function Ir(...e){let[t,r]=ot.Match(e,{2:(n,a)=>[n,a,a],1:n=>[n,ue(),ue()]});return p.Create({"~kind":"Infer"},{type:"infer",name:t,extends:r},{})}function V(e){return f(e,"Infer")}function bo(e){return i.IsObjectNotArray(e)}function ho(e){return i.Keys(e).filter(r=>isNaN(r)).reduce((r,n)=>[...r,e[n]],[])}function To(e,t){let r=bo(e)?ho(e):e;return p.Create({"~kind":"Enum"},{enum:r},t)}function ie(e){return f(e,"Enum")}function Te(e,t={}){return p.Create({"~kind":"Intersect"},{allOf:e},t)}function M(e){return f(e,"Intersect")}function Eo(e){return p.Discard(e,["~kind","allOf"])}function K(){throw new Error("Unreachable")}var ko;(function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"})(ko||(ko={}));var Rh=BigInt("14695981039346656037"),[vh,Ch]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Mh=Array.from({length:256}).map((e,t)=>BigInt(t)),Oo=new Float64Array(1),Sh=new DataView(Oo.buffer),jh=new Uint8Array(Oo.buffer);var qh=new TextEncoder;var yr=class{constructor(t,r){this.type=t,this.decode=r}Encode(t){let r=this.type,n=bn(r)?m=>this.decode(r["~codec"].decode(m)):this.decode,a=bn(r)?m=>r["~codec"].encode(t(m)):t,s={decode:n,encode:a};return p.Update(this.type,{"~codec":s},{})}},gr=class{constructor(t){this.type=t}Decode(t){return new yr(this.type,t)}};function hn(e){return new gr(e)}function wo(e,t){return hn(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function Ro(e,t){return hn(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function bn(e){return k(e)&&i.HasPropertyKey(e,"~codec")&&i.IsObject(e["~codec"])&&i.HasPropertyKey(e["~codec"],"encode")&&i.HasPropertyKey(e["~codec"],"decode")}function ml(e,t){let r=sa(e)?[...e["~refine"],t]:[t];return p.Update(e,{"~refine":r},{})}function vo(e,t,r="error"){return ml(e,{refine:t,message:r})}function sa(e){return k(e)&&i.HasPropertyKey(e,"~refine")}var Co="-?(?:0|[1-9][0-9]*)n";function $r(e){return p.Create({"~kind":"BigInt"},{type:"bigint"},e)}function De(e){return f(e,"BigInt")}function Tn(e){return p.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Oe(e){return f(e,"Boolean")}function br(e){return p.Create({"~kind":"Identifier"},{name:e})}function Mo(e){return f(e,"Identifier")}var En="-?(?:0|[1-9][0-9]*)";function kt(e){return p.Create({"~kind":"Integer"},{type:"integer"},e)}function ce(e){return f(e,"Integer")}function Ne(e,t){return p.Create({"~kind":"Iterator"},{type:"iterator",iteratorItems:e},t)}function $e(e){return f(e,"Iterator")}function So(e){return p.Discard(e,["~kind","type","iteratorItems"])}var ia=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function pl(e){return i.IsBigInt(e)?"bigint":i.IsBoolean(e)?"boolean":i.IsNumber(e)?"number":i.IsString(e)?"string":(()=>{throw new ia(e)})()}function q(e,t){return p.Create({"~kind":"Literal"},{type:pl(e),const:e},t)}function kn(e){return i.IsBigInt(e)||i.IsBoolean(e)||i.IsNumber(e)||i.IsString(e)}function On(e){return F(e)&&i.IsNumber(e.const)}function Pn(e){return F(e)&&i.IsString(e.const)}function F(e){return f(e,"Literal")}function st(e){return p.Create({"~kind":"Null"},{type:"null"},e)}function Ft(e){return f(e,"Null")}var wn="-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?";function be(e){return p.Create({"~kind":"Number"},{type:"number"},e)}function Y(e){return f(e,"Number")}function Ut(e){return p.Create({"~kind":"Symbol"},{type:"symbol"},e)}function it(e){return f(e,"Symbol")}function Ot(...e){let[t,r,n]=ot.Match(e,{3:(a,s,m)=>[a,s,m],2:(a,s)=>[a,s,s],1:a=>[a,ue(),ue()]});return p.Create({"~kind":"Parameter"},{name:t,extends:r,equals:n},{})}function jo(e){return f(e,"Parameter")}function Fe(e,t){return p.Create({"~kind":"Promise"},{type:"promise",item:e},t)}function de(e){return f(e,"Promise")}function qo(e){return p.Discard(e,["~kind","type","item"])}var Rn=".*";function Pe(e){return p.Create({"~kind":"String"},{type:"string"},e)}function le(e){return f(e,"String")}function hr(e){let t=Ao(e);return i.IsEqual(t.length,2)?t[0]:[]}function ul(e){return!0}function Lo(e){let[t,...r]=e;return k(t)?cl(t)?Lo(r):!1:!0}function Do(e){return i.IsEqual(e.length,0)?!1:Lo(e)}function cl(e){return y(e)?Do(e.anyOf):F(e)?ul(e.const):!1}function vn(e){return Do(e)}function Cn(e){return p.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function No(e,t,r=[]){let[n,...a]=e;return i.IsString(n)?No(a,t,[...r,`${n}${t}`]):r}function dl(e,t){return i.IsEqual(e.length,0)?[`${t}`]:No(e,t)}function Fo(e,t,r=[]){let[n,...a]=t;return k(n)?Fo(e,a,[...r,...Uo(e,n)]):r}function Uo(e,t){return y(t)?Fo(e,t.anyOf):F(t)?dl(e,t.const):K()}function Ko(e,t){let[r,...n]=t;return k(r)?Ko(Uo(e,r),n):e}function ll(e){return e.map(t=>q(t))}function fl(e){let t=Ko([],e),r=ll(t);return O(r)}function xl(e){return i.IsEqual(e.length,0)?K():i.IsEqual(e.length,1)&&F(e[0])?e[0]:fl(e)}function ma(e){let t=hr(e);return i.IsEqual(t.length,0)?Pe():vn(t)?xl(t):Cn(e)}function he(e){let t=ma(e);return Q(t)?Pe():t}function ye(e,t){let r="object",n={[e]:t};return p.Create({"~kind":"Record"},{type:r,patternProperties:n})}var Kt=`^${En}$`,_t=`^${wn}$`,Me=`^${Rn}$`;function Tr(e,t,r={}){return $("Record",[e,t],r)}function Il(e,t,r={}){return g({},Tr(e,t,r))}function Mn(e,t,r={}){return Il(e,t,r)}function _o(e,t){return ye(e,t)}function Gt(e){return i.Keys(e.patternProperties)[0]}function zt(e){let t=Gt(e);return i.IsEqual(t,Me)?Pe():i.IsEqual(t,Kt)?kt():i.IsEqual(t,_t)?be():ma(t)}function Ue(e){return e.patternProperties[Gt(e)]}function we(e){return f(e,"Record")}function Pt(e){return p.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function mt(e){return f(e,"Rest")}function Sn(e){return p.Create({"~kind":"This"},{$ref:"#"},e)}function Go(e){return f(e,"This")}function ee(e,t={}){let[r,n,a]=[e,e.length,!1];return p.Create({"~kind":"Tuple"},{type:"array",additionalItems:a,items:r,minItems:n},t)}function U(e){return f(e,"Tuple")}function zo(e){return p.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Bt(e){return p.Create({"~kind":"Undefined"},{type:"undefined"},e)}function Ht(e){return f(e,"Undefined")}function Bo(e){return p.Create({"~kind":"Unsafe"},{},e)}function Ho(e){return f(e,"Unsafe")}function jn(e){return p.Create({"~kind":"Void"},{type:"void"},e)}function Ke(e){return f(e,"Void")}function gl(e,t){return i.IsEqual(e,"Array")?Ce(t[0]):i.IsEqual(e,"AsyncIterator")?Ae(t[0]):i.IsEqual(e,"Iterator")?Ne(t[0]):i.IsEqual(e,"Promise")?Fe(t[0]):i.IsEqual(e,"Awaited")?_r(t[0]):i.IsEqual(e,"Capitalize")?Or(t[0]):i.IsEqual(e,"ConstructorParameters")?Cr(t[0]):i.IsEqual(e,"Evaluate")?ua(t[0]):i.IsEqual(e,"Exclude")?Mr(t[0],t[1]):i.IsEqual(e,"Extract")?Sr(t[0],t[1]):i.IsEqual(e,"Index")?Wt(t[0],t[1]):i.IsEqual(e,"InstanceType")?jr(t[0]):i.IsEqual(e,"Lowercase")?Pr(t[0]):i.IsEqual(e,"NonNullable")?qr(t[0]):i.IsEqual(e,"Omit")?Ar(t[0],t[1]):i.IsEqual(e,"Options")?Zt(t[0],t[1]):i.IsEqual(e,"Parameters")?Lr(t[0]):i.IsEqual(e,"Partial")?Dr(t[0]):i.IsEqual(e,"Pick")?Nr(t[0],t[1]):i.IsEqual(e,"Readonly")?Fr(t[0]):i.IsEqual(e,"KeyOf")?Xt(t[0]):i.IsEqual(e,"Record")?Tr(t[0],t[1]):i.IsEqual(e,"Required")?Ur(t[0]):i.IsEqual(e,"ReturnType")?Kr(t[0]):i.IsEqual(e,"Uncapitalize")?wr(t[0]):i.IsEqual(e,"Uppercase")?Rr(t[0]):kr(He(e),t)}function wt(){throw Error("Unreachable")}var $l=(e,t=[])=>e.reduce((r,n)=>i.IsArray(n)&&i.IsEqual(n.length,2)?[...r,n[0]]:[...r,n],[]),Ve=e=>{let[t,r]=e;return $l([...t,...r])};function Zo(e){return Ot(e[0],e[2],e[4])}function Yo(e){return Ot(e[0],e[2],e[2])}function Qo(e){return Ot(e[0],ue(),e[2])}function es(e){return Ot(e,ue(),ue())}function ts(e){return Ve(e)}function rs(e){return e[1]}function ns(e){return Ve(e)}function as(e){return e[1]}function os(e){return gl(e[0],e[1])}function ss(e){return null}function is(e){return Pe()}function ms(e){return be()}function ps(e){return Tn()}function us(e){return Bt()}function cs(e){return st()}function ds(e){return kt()}function ls(e){return $r()}function fs(e){return ue()}function xs(e){return Nt()}function Is(e){return E({})}function ys(e){return S()}function gs(e){return Ut()}function $s(e){return jn()}function bs(e){return Sn()}function hs(e){return e[1]}function Ts(e){return q(e)}function Es(e){return i.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function ks(e){return e[1]}function Os(e){return Er(e)}function Ps(e){return q(BigInt(e))}function ws(e){return q(i.IsEqual(e,"true"))}function Rs(e){return q(parseFloat(e))}function vs(e){return q(e)}function Cs(e){return e.length>0}function Ms(e){return e.reduce((t,r)=>i.IsEqual(r.length,3)?[...t,[r[1]]]:[...t,[]],[])}function Ss(e){return i.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function js(e){return i.IsArray(e)&&i.IsEqual(e.length,3)?e[1]:e}var Vo=(e,t)=>t.reduce((r,n)=>{let a=n;return i.IsEqual(a.length,1)?Wt(r,a[0]):i.IsEqual(a.length,0)?Ce(r):wt()},e),Jo=(e,t)=>i.IsEqual(t.length,3)?vr(e,t[0],t[1],t[2]):e;function qs(e){let[t,r,n,a]=e;return Jo(t?Xt(Vo(r,n)):Vo(r,n),a)}function pa(e,t){return i.IsEqual(t.length,3)?(()=>{let[r,n,a]=t,s=pa(n,a);if(i.IsEqual(r,"&"))return M(s)?Te([e,...s.allOf]):Te([e,s]);if(i.IsEqual(r,"|"))return y(s)?O([e,...s.anyOf]):O([e,s]);wt()})():e}function As(e){let[t,r]=e;return pa(t,r)}function Ls(e){let[t,r]=e;return pa(t,r)}function Ds(e){return oa(e[1])}function Ns(e){return e[1]}function Fs(e){return nt(e[0],e[2])}function Us(e){return i.IsEqual(e.length,4)?Ir(e[1],e[3]):i.IsEqual(e.length,2)?Ir(e[1],ue()):wt()}function Ks(e){return`${e}`}function _s(e){return ce(e[3])?Kt:Y(e[3])?_t:it(e[3])?Me:le(e[3])?Me:wt()}function Gs(e){return e.length>0}function zs(e){return e.length>0}function Bs(e){let[t,r,n,a,s]=e;return{[r]:t&&n?Ie(xe(s)):t&&!n?Ie(s):!t&&n?xe(s):s}}function Hs(e){return Ve(e)}function Vs(e){return e.reduce((t,r)=>i.HasPropertyKey(r,Kt)||i.HasPropertyKey(r,_t)||i.HasPropertyKey(r,Me)?[t[0],p.Assign(t[1],r)]:[p.Assign(t[0],r),t[1]],[{},{}])}function Js(e){return Vs(e[1])}function Ws(e){let[t,r]=e,n=i.IsEqual(i.Keys(r).length,0)?{}:{patternProperties:r};return E(t,n)}function Xs(e){return i.IsEqual(e.length,5)?Ie(xe(e[4])):i.IsEqual(e.length,3)?e[2]:i.IsEqual(e.length,4)?i.IsEqual(e[2],"readonly")?Ie(e[3]):xe(e[3]):wt()}function Zs(e){return Ie(xe(e[1]))}function Ys(e){return Ie(e[1])}function Qs(e){return xe(e[0])}function ei(e){return i.IsEqual(e.length,2)?Pt(e[1]):i.IsEqual(e.length,1)?e[0]:wt()}function ti(e){return Ve(e)}function ri(e){return ee(e[1])}function ni(e){return Ie(xe(e[4]))}function ai(e){return Ie(e[3])}function oi(e){return xe(e[3])}function si(e){return e[2]}function ii(e){return i.IsEqual(e.length,2)?Pt(e[1]):i.IsEqual(e.length,1)?e[0]:wt()}function mi(e){return Ve(e)}function pi(e){return rt(e[1],e[4])}function ui(e){return tt(e[2],e[5])}function Wo(e,t){return i.IsEqual(e,"remove")?mo(t):i.IsEqual(e,"add")?so(t):t}function ci(e){return i.IsEqual(e.length,2)&&i.IsEqual(e[0],"-")?"remove":i.IsEqual(e.length,2)&&i.IsEqual(e[0],"+")||i.IsEqual(e.length,1)?"add":"none"}function Xo(e,t){return i.IsEqual(e,"remove")?ao(t):i.IsEqual(e,"add")?ro(t):t}function di(e){return i.IsEqual(e.length,2)&&i.IsEqual(e[0],"-")?"remove":i.IsEqual(e.length,2)&&i.IsEqual(e[0],"+")||i.IsEqual(e.length,1)?"add":"none"}function li(e){return i.IsEqual(e.length,2)?[e[1]]:[]}function fi(e){return i.IsArray(e[6])&&i.IsEqual(e[6].length,1)?Vt(br(e[3]),e[5],e[6][0],Wo(e[1],Xo(e[8],e[10]))):Vt(br(e[3]),e[5],He(e[3]),Wo(e[1],Xo(e[8],e[10])))}function xi(e){return He(e)}function Ii(e){return Zt(e[2],e[4])}function yi(e){return parseFloat(e)}function gi(e){return i.IsEqual(e,"true")}function $i(e){return null}function bi(e){return{[e[0]]:e[2]}}function hi(e){return Ve(e)}function bl(e){return e.reduce((t,r)=>p.Assign(t,r),{})}function Ti(e){return bl(e[1])}function Ei(e){return Ve(e)}function ki(e){return e[1]}function Oi(e){return $r()}function Pi(e){return Pe()}function wi(e){return be()}function Ri(e){return kt()}function vi(e){return S()}function Ci(e){return q(e)}function Mi(e){return O(e[1])}function Si(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function ji(e){return[e[0],...e[1]]}function qi(e){return e[1]}function Ai(e){return Ve(e)}function Li(e){return i.IsEqual(e.length,2)?e[1]:[]}function Di(e){let t=e[2],r=e[3],[n,a]=e[4],s=i.IsEqual(i.Keys(a).length,0)?{}:{patternProperties:a};return{[e[1]]:nt(t,Jt(r,n,s))}}function Ni(e){let t=e[2],[r,n]=e[3],a=i.IsEqual(i.Keys(n).length,0)?{}:{patternProperties:n};return{[e[1]]:Jt(t,r,a)}}function Fi(e){return{[e[1]]:nt(e[2],e[4])}}function Ui(e){return{[e[1]]:e[3]}}function Ki(e){return null}function _i(e){return Vs(Ve(e))}function Gi(e){return e[1]}function zi(e){let t=e[0],r=e[1];return ca(p.Assign(t,r[0]))}function Gr(e){return L(e.length,2)}function w(e,t,r){return Gr(e)?t(e[0],e[1]):r()}function El(e,t){return L(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function _(e,t){for(let r=0;r<e.length;r++){let n=El(e[r],t);if(Gr(n))return n}return[]}function da(e,t){return Array.from({length:t-e+1},(r,n)=>String.fromCharCode(e+n))}var Bi=[...da(97,122),...da(65,90)],la="0",fa=da(49,57),Yt=[la,...fa],Hi=" ",Qt=`
3
+ `;var pt="_",qn=".",Vi="$",An="-";var Ji="//",Wi="/*",Ol="*/";function Xi(e){let t=e.indexOf(Ol);return L(t,-1)?"":e.slice(t+2)}function Zi(e){let t=e.indexOf(Qt);return L(t,-1)?"":e.slice(t)}function Pl(e){return e.replace(/^[ \t\r\f\v]+/,"")}function Ln(e){let t=Pl(e);return t.startsWith(Wi)?Ln(Xi(t.slice(2))):t.startsWith(Ji)?Ln(Zi(t.slice(2))):t}function ne(e){let t=e.trimStart();return t.startsWith(Wi)?ne(Xi(t.slice(2))):t.startsWith(Ji)?ne(Zi(t.slice(2))):t}function Dn(e,t){return w(_([e],t),(r,n)=>[r,n],()=>["",t])}function wl(e,t){return e.includes(t)}function er(e,t,r,n=""){return w(_(e,r),(a,s)=>wl(t,a)?er(e,t,s,n):er(e,t,s,`${n}${a}`),()=>[n,r])}function Rl(e){return _(fa,e)}var vl=[...Yt,pt];function Cl(e){return er(vl,[pt],e)}function Ml(e){return w(_([la],e),(t,r)=>[t,r],()=>w(Rl(e),(t,r)=>w(Cl(r),(n,a)=>[`${t}${n}`,a],()=>[]),()=>[]))}function Nn(e){return Ml(ne(e))}function Sl(e){return Dn(An,e)}function jl(e){return w(Sl(e),(t,r)=>w(Nn(r),(n,a)=>[`${t}${n}`,a],()=>[]),()=>[])}function Yi(e){return jl(ne(e))}function ql(e){return w(Yi(e),(t,r)=>w(_(["n"],r),(n,a)=>[`${t}`,a],()=>[]),()=>[])}function Qi(e){return ql(e)}function xa(e,t){return _([e],t)}function u(e,t){return L(e,"")?["",t]:e.startsWith(Qt)?xa(e,Ln(t)):e.startsWith(Hi)?xa(e,t):xa(e,ne(t))}var em=[...Bi,pt,Vi];function Al(e){return _(em,e)}var Ll=[...em,...Yt];function tm(e,t=""){return w(_(Ll,e),(r,n)=>tm(n,`${t}${r}`),()=>[t,e])}function Dl(e){return w(Al(e),(t,r)=>w(tm(r),(n,a)=>[`${t}${n}`,a],()=>[]),()=>[])}function B(e){return Dl(ne(e))}var Nl=[...Yt,pt];function Fl(e){return Gr(_([qn],e))}function rm(e){return w(er(Nl,[pt],e),(t,r)=>L(t,"")?[]:[t,r],()=>[])}function Ul(e){return w(_([qn],e),(t,r)=>w(rm(r),(n,a)=>[`0${t}${n}`,a],()=>[]),()=>[])}function Kl(e){return w(Nn(e),(t,r)=>w(_([qn],r),(n,a)=>w(rm(a),(s,m)=>[`${t}${n}${s}`,m],()=>[`${t}`,a]),()=>[`${t}`,r]),()=>[])}function _l(e){return Fl(e)?Ul(e):Kl(e)}function nm(e){return _l(ne(e))}function Gl(e){return Dn(An,e)}function zl(e){return w(Gl(e),(t,r)=>w(nm(r),(n,a)=>[`${t}${n}`,a],()=>[]),()=>[])}function Fn(e){return zl(ne(e))}function Bl(e){return L(e,"")?[]:[e.slice(0,1),e.slice(1)]}function am(e,t){let[r,...n]=e;return At(r)?t.startsWith(r)?!0:am(n,t):!1}function ut(e,t,r=""){return w(Bl(t),(n,a)=>am(e,t)?[r,t]:ut(e,a,`${r}${n}`),()=>[])}function Hl(e,t,r){return w(_([e],r),(n,a)=>w(ut([t],a),(s,m)=>w(_([t],m),(c,l)=>[`${s}`,l],()=>[]),()=>[]),()=>[])}function Vl(e,t,r){return w(_([e],r),(n,a)=>w(ut([Qt,t],a),(s,m)=>w(_([t],m),(c,l)=>[`${s}`,l],()=>[]),()=>[]),()=>[])}function om(e,t,r,n){return r?Hl(e,t,ne(n)):Vl(e,t,ne(n))}function Jl(e,t){return _(e,t)}function Wl(e,t){return om(e,e,!1,t)}function Xl(e,t){return w(Jl(e,t),(r,n)=>Wl(r,`${r}${n}`),()=>[])}function Un(e,t){return Xl(e,ne(t))}function sm(e,t){return w(ut(e,t),(r,n)=>L(r,"")?[]:[r,n],()=>[])}var o=(e,t,r=()=>[])=>e.length===2?t(e):r(),Yl=e=>o(o(B(e),([t,r])=>o(u("extends",r),([n,a])=>o(A(a),([s,m])=>o(u("=",m),([c,l])=>o(A(l),([v,j])=>[[t,n,s,c,v],j]))))),([t,r])=>[Zo(t),r]),Ql=e=>o(o(B(e),([t,r])=>o(u("extends",r),([n,a])=>o(A(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[Yo(t),r]),ef=e=>o(o(B(e),([t,r])=>o(u("=",r),([n,a])=>o(A(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[Qo(t),r]),tf=e=>o(B(e),([t,r])=>[es(t),r]),pm=e=>o(o(Yl(e),([t,r])=>[t,r],()=>o(Ql(e),([t,r])=>[t,r],()=>o(ef(e),([t,r])=>[t,r],()=>o(tf(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),um=(e,t=[])=>o(o(pm(e),([r,n])=>o(u(",",n),([a,s])=>[[r,a],s])),([r,n])=>um(n,[...t,r]),()=>[t,e]),rf=e=>o(o(um(e),([t,r])=>o(o(o(pm(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[ts(t),r]),ga=e=>o(o(u("<",e),([t,r])=>o(rf(r),([n,a])=>o(u(">",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[rs(t),r]),cm=(e,t=[])=>o(o(A(e),([r,n])=>o(u(",",n),([a,s])=>[[r,a],s])),([r,n])=>cm(n,[...t,r]),()=>[t,e]),nf=e=>o(o(cm(e),([t,r])=>o(o(o(A(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[ns(t),r]),af=e=>o(o(u("<",e),([t,r])=>o(nf(r),([n,a])=>o(u(">",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[as(t),r]),of=e=>o(o(B(e),([t,r])=>o(af(r),([n,a])=>[[t,n],a])),([t,r])=>[os(t),r]),dm=e=>o(o(o(u(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ss(t),r]),lm=e=>o(u("string",e),([t,r])=>[is(t),r]),fm=e=>o(u("number",e),([t,r])=>[ms(t),r]),sf=e=>o(u("boolean",e),([t,r])=>[ps(t),r]),mf=e=>o(u("undefined",e),([t,r])=>[us(t),r]),pf=e=>o(u("null",e),([t,r])=>[cs(t),r]),xm=e=>o(u("integer",e),([t,r])=>[ds(t),r]),uf=e=>o(u("bigint",e),([t,r])=>[ls(t),r]),cf=e=>o(u("unknown",e),([t,r])=>[fs(t),r]),df=e=>o(u("any",e),([t,r])=>[xs(t),r]),lf=e=>o(u("object",e),([t,r])=>[Is(t),r]),ff=e=>o(u("never",e),([t,r])=>[ys(t),r]),Im=e=>o(u("symbol",e),([t,r])=>[gs(t),r]),xf=e=>o(u("void",e),([t,r])=>[$s(t),r]),If=e=>o(u("this",e),([t,r])=>[bs(t),r]),yf=e=>o(o(lm(e),([t,r])=>[t,r],()=>o(fm(e),([t,r])=>[t,r],()=>o(sf(e),([t,r])=>[t,r],()=>o(mf(e),([t,r])=>[t,r],()=>o(pf(e),([t,r])=>[t,r],()=>o(xm(e),([t,r])=>[t,r],()=>o(uf(e),([t,r])=>[t,r],()=>o(cf(e),([t,r])=>[t,r],()=>o(df(e),([t,r])=>[t,r],()=>o(lf(e),([t,r])=>[t,r],()=>o(ff(e),([t,r])=>[t,r],()=>o(Im(e),([t,r])=>[t,r],()=>o(xf(e),([t,r])=>[t,r],()=>o(If(e),([t,r])=>[t,r],()=>[])))))))))))))),([t,r])=>[t,r]),gf=e=>o(o(u("${",e),([t,r])=>o(A(r),([n,a])=>o(u("}",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[hs(t),r]),Ia=e=>o(ut(["${","`"],e),([t,r])=>[Ts(t),r]),ym=e=>o(o(o(Ia(e),([t,r])=>o(gf(r),([n,a])=>o(ym(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[t,r],()=>o(o(Ia(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o(o(Ia(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[Es(t),r]),$a=e=>o(o(u("`",e),([t,r])=>o(ym(r),([n,a])=>o(u("`",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[ks(t),r]),$f=e=>o($a(e),([t,r])=>[Os(t),r]),bf=e=>o(Qi(e),([t,r])=>[Ps(t),r]),hf=e=>o(o(u("true",e),([t,r])=>[t,r],()=>o(u("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[ws(t),r]),Tf=e=>o(Fn(e),([t,r])=>[Rs(t),r]),Ef=e=>o(Un(["'",'"'],e),([t,r])=>[vs(t),r]),kf=e=>o(o(bf(e),([t,r])=>[t,r],()=>o(hf(e),([t,r])=>[t,r],()=>o(Tf(e),([t,r])=>[t,r],()=>o(Ef(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),Of=e=>o(o(o(u("keyof",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Cs(t),r]),gm=(e,t=[])=>o(o(o(u("[",e),([r,n])=>o(A(n),([a,s])=>o(u("]",s),([m,c])=>[[r,a,m],c]))),([r,n])=>[r,n],()=>o(o(u("[",e),([r,n])=>o(u("]",n),([a,s])=>[[r,a],s])),([r,n])=>[r,n],()=>[])),([r,n])=>gm(n,[...t,r]),()=>[t,e]),Pf=e=>o(gm(e),([t,r])=>[Ms(t),r]),wf=e=>o(o(o(u("extends",e),([t,r])=>o(A(r),([n,a])=>o(u("?",a),([s,m])=>o(A(m),([c,l])=>o(u(":",l),([v,j])=>o(A(j),([b,C])=>[[t,n,s,c,v,b],C])))))),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ss(t),r]),Rf=e=>o(o(o(u("(",e),([t,r])=>o(A(r),([n,a])=>o(u(")",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[t,r],()=>o(yf(e),([t,r])=>[t,r],()=>o(Uf(e),([t,r])=>[t,r],()=>o(Hf(e),([t,r])=>[t,r],()=>o($f(e),([t,r])=>[t,r],()=>o(kf(e),([t,r])=>[t,r],()=>o(Yf(e),([t,r])=>[t,r],()=>o(Zf(e),([t,r])=>[t,r],()=>o(rx(e),([t,r])=>[t,r],()=>o(ax(e),([t,r])=>[t,r],()=>o(of(e),([t,r])=>[t,r],()=>o(nx(e),([t,r])=>[t,r],()=>[])))))))))))),([t,r])=>[js(t),r]),$m=e=>o(o(Of(e),([t,r])=>o(Rf(r),([n,a])=>o(Pf(a),([s,m])=>o(wf(m),([c,l])=>[[t,n,s,c],l])))),([t,r])=>[qs(t),r]),bm=e=>o(o(o(u("&",e),([t,r])=>o($m(r),([n,a])=>o(bm(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),hm=e=>o(o($m(e),([t,r])=>o(bm(r),([n,a])=>[[t,n],a])),([t,r])=>[As(t),r]),Tm=e=>o(o(o(u("|",e),([t,r])=>o(hm(r),([n,a])=>o(Tm(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),Kn=e=>o(o(hm(e),([t,r])=>o(Tm(r),([n,a])=>[[t,n],a])),([t,r])=>[Ls(t),r]),vf=e=>o(o(u("readonly",e),([t,r])=>o(Kn(r),([n,a])=>[[t,n],a])),([t,r])=>[Ds(t),r]),Cf=e=>o(o(u("|",e),([t,r])=>o(Kn(r),([n,a])=>[[t,n],a])),([t,r])=>[Ns(t),r]),Mf=e=>o(o(ga(e),([t,r])=>o(u("=",r),([n,a])=>o(A(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[Fs(t),r]),Sf=e=>o(o(o(u("infer",e),([t,r])=>o(B(r),([n,a])=>o(u("extends",a),([s,m])=>o(Kn(m),([c,l])=>[[t,n,s,c],l])))),([t,r])=>[t,r],()=>o(o(u("infer",e),([t,r])=>o(B(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>[])),([t,r])=>[Us(t),r]),A=e=>o(o(Sf(e),([t,r])=>[t,r],()=>o(Cf(e),([t,r])=>[t,r],()=>o(vf(e),([t,r])=>[t,r],()=>o(Kn(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),jf=e=>o(Fn(e),([t,r])=>[Ks(t),r]),qf=e=>o(B(e),([t,r])=>[t,r]),Af=e=>o(Un(["'",'"'],e),([t,r])=>[t,r]),Lf=e=>o(o(u("[",e),([t,r])=>o(B(r),([n,a])=>o(u(":",a),([s,m])=>o(o(xm(m),([c,l])=>[c,l],()=>o(fm(m),([c,l])=>[c,l],()=>o(lm(m),([c,l])=>[c,l],()=>o(Im(m),([c,l])=>[c,l],()=>[])))),([c,l])=>o(u("]",l),([v,j])=>[[t,n,s,c,v],j]))))),([t,r])=>[_s(t),r]),Em=e=>o(o(jf(e),([t,r])=>[t,r],()=>o(qf(e),([t,r])=>[t,r],()=>o(Af(e),([t,r])=>[t,r],()=>o(Lf(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),Df=e=>o(o(o(u("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Gs(t),r]),Nf=e=>o(o(o(u("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[zs(t),r]),km=e=>o(o(Df(e),([t,r])=>o(Em(r),([n,a])=>o(Nf(a),([s,m])=>o(u(":",m),([c,l])=>o(A(l),([v,j])=>[[t,n,s,c,v],j]))))),([t,r])=>[Bs(t),r]),Om=e=>o(o(o(u(",",e),([t,r])=>o(u(`
4
4
  `,r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u(";",e),([t,r])=>o(u(`
5
5
  `,r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u(",",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o(o(u(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o(o(u(`
6
- `,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))))),([t,r])=>[t,r]),Em=(e,t=[])=>o(o(hm(e),([r,n])=>o(Tm(n),([a,i])=>[[r,a],i])),([r,n])=>Em(n,[...t,r]),()=>[t,e]),jf=e=>o(o(Em(e),([t,r])=>o(o(o(hm(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[_s(t),r]),ga=e=>o(o(u("{",e),([t,r])=>o(jf(r),([n,a])=>o(u("}",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Bs(t),r]),qf=e=>o(ga(e),([t,r])=>[Hs(t),r]),Af=e=>o(o(o(B(e),([t,r])=>o(u("?",r),([n,a])=>o(u(":",a),([i,m])=>o(u("readonly",m),([c,l])=>o(A(l),([v,j])=>[[t,n,i,c,v],j]))))),([t,r])=>[t,r],()=>o(o(B(e),([t,r])=>o(u(":",r),([n,a])=>o(u("readonly",a),([i,m])=>o(A(m),([c,l])=>[[t,n,i,c],l])))),([t,r])=>[t,r],()=>o(o(B(e),([t,r])=>o(u("?",r),([n,a])=>o(u(":",a),([i,m])=>o(A(m),([c,l])=>[[t,n,i,c],l])))),([t,r])=>[t,r],()=>o(o(B(e),([t,r])=>o(u(":",r),([n,a])=>o(A(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[t,r],()=>[])))),([t,r])=>[Vs(t),r]),Lf=e=>o(o(u("readonly",e),([t,r])=>o(A(r),([n,a])=>o(u("?",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Js(t),r]),Nf=e=>o(o(u("readonly",e),([t,r])=>o(A(r),([n,a])=>[[t,n],a])),([t,r])=>[Ws(t),r]),Ff=e=>o(o(A(e),([t,r])=>o(u("?",r),([n,a])=>[[t,n],a])),([t,r])=>[Xs(t),r]),am=e=>o(o(Af(e),([t,r])=>[t,r],()=>o(Lf(e),([t,r])=>[t,r],()=>o(Nf(e),([t,r])=>[t,r],()=>o(Ff(e),([t,r])=>[t,r],()=>o(A(e),([t,r])=>[t,r],()=>[]))))),([t,r])=>[t,r]),km=e=>o(o(o(u("...",e),([t,r])=>o(am(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(am(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[Zs(t),r]),Om=(e,t=[])=>o(o(km(e),([r,n])=>o(u(",",n),([a,i])=>[[r,a],i])),([r,n])=>Om(n,[...t,r]),()=>[t,e]),Df=e=>o(o(Om(e),([t,r])=>o(o(o(km(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[Ys(t),r]),Uf=e=>o(o(u("[",e),([t,r])=>o(Df(r),([n,a])=>o(u("]",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Qs(t),r]),Kf=e=>o(o(B(e),([t,r])=>o(u("?",r),([n,a])=>o(u(":",a),([i,m])=>o(u("readonly",m),([c,l])=>o(A(l),([v,j])=>[[t,n,i,c,v],j]))))),([t,r])=>[ei(t),r]),Gf=e=>o(o(B(e),([t,r])=>o(u(":",r),([n,a])=>o(u("readonly",a),([i,m])=>o(A(m),([c,l])=>[[t,n,i,c],l])))),([t,r])=>[ti(t),r]),_f=e=>o(o(B(e),([t,r])=>o(u("?",r),([n,a])=>o(u(":",a),([i,m])=>o(A(m),([c,l])=>[[t,n,i,c],l])))),([t,r])=>[ri(t),r]),zf=e=>o(o(B(e),([t,r])=>o(u(":",r),([n,a])=>o(A(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[ni(t),r]),om=e=>o(o(Kf(e),([t,r])=>[t,r],()=>o(Gf(e),([t,r])=>[t,r],()=>o(_f(e),([t,r])=>[t,r],()=>o(zf(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),Pm=e=>o(o(o(u("...",e),([t,r])=>o(om(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(om(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[ai(t),r]),wm=(e,t=[])=>o(o(Pm(e),([r,n])=>o(u(",",n),([a,i])=>[[r,a],i])),([r,n])=>wm(n,[...t,r]),()=>[t,e]),Rm=e=>o(o(wm(e),([t,r])=>o(o(o(Pm(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[oi(t),r]),Bf=e=>o(o(u("(",e),([t,r])=>o(Rm(r),([n,a])=>o(u(")",a),([i,m])=>o(u("=>",m),([c,l])=>o(A(l),([v,j])=>[[t,n,i,c,v],j]))))),([t,r])=>[si(t),r]),Hf=e=>o(o(u("new",e),([t,r])=>o(u("(",r),([n,a])=>o(Rm(a),([i,m])=>o(u(")",m),([c,l])=>o(u("=>",l),([v,j])=>o(A(j),([b,C])=>[[t,n,i,c,v,b],C])))))),([t,r])=>[ii(t),r]),Vf=e=>o(o(o(u("+",e),([t,r])=>o(u("readonly",r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u("-",e),([t,r])=>o(u("readonly",r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[mi(t),r]),Jf=e=>o(o(o(u("+",e),([t,r])=>o(u("?",r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u("-",e),([t,r])=>o(u("?",r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[pi(t),r]),Wf=e=>o(o(o(u("as",e),([t,r])=>o(A(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ui(t),r]),Xf=e=>o(o(u("{",e),([t,r])=>o(Vf(r),([n,a])=>o(u("[",a),([i,m])=>o(B(m),([c,l])=>o(u("in",l),([v,j])=>o(A(j),([b,C])=>o(Wf(C),([x,J])=>o(u("]",J),([Re,Xe])=>o(Jf(Xe),([$t,bt])=>o(u(":",bt),([St,jt])=>o(A(jt),([te,ke])=>o(pm(ke),([dr,ht])=>o(u("}",ht),([md,pd])=>[[t,n,i,c,v,b,x,Re,$t,St,te,dr,md],pd]))))))))))))),([t,r])=>[ci(t),r]),Zf=e=>o(B(e),([t,r])=>[di(t),r]),Yf=e=>o(o(u("Options",e),([t,r])=>o(u("<",r),([n,a])=>o(A(a),([i,m])=>o(u(",",m),([c,l])=>o(Mm(l),([v,j])=>o(u(">",j),([b,C])=>[[t,n,i,c,v,b],C])))))),([t,r])=>[li(t),r]),Qf=e=>o(Nn(e),([t,r])=>[fi(t),r]),ex=e=>o(o(u("true",e),([t,r])=>[t,r],()=>o(u("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[xi(t),r]),tx=e=>o(Fn(['"',"'"],e),([t,r])=>[t,r]),rx=e=>o(u("null",e),([t,r])=>[Ii(t),r]),vm=e=>o(o(bm(e),([t,r])=>o(u(":",r),([n,a])=>o($a(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[yi(t),r]),Cm=(e,t=[])=>o(o(vm(e),([r,n])=>o(Tm(n),([a,i])=>[[r,a],i])),([r,n])=>Cm(n,[...t,r]),()=>[t,e]),nx=e=>o(o(Cm(e),([t,r])=>o(o(o(vm(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[gi(t),r]),Mm=e=>o(o(u("{",e),([t,r])=>o(nx(r),([n,a])=>o(u("}",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[$i(t),r]),Sm=(e,t=[])=>o(o($a(e),([r,n])=>o(u(",",n),([a,i])=>[[r,a],i])),([r,n])=>Sm(n,[...t,r]),()=>[t,e]),ax=e=>o(o(Sm(e),([t,r])=>o(o(o($a(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[bi(t),r]),ox=e=>o(o(u("[",e),([t,r])=>o(ax(r),([n,a])=>o(u("]",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[hi(t),r]),$a=e=>o(o(Qf(e),([t,r])=>[t,r],()=>o(ex(e),([t,r])=>[t,r],()=>o(tx(e),([t,r])=>[t,r],()=>o(rx(e),([t,r])=>[t,r],()=>o(Mm(e),([t,r])=>[t,r],()=>o(ox(e),([t,r])=>[t,r],()=>[])))))),([t,r])=>[t,r]),sx=e=>o(u("-?(?:0|[1-9][0-9]*)n",e),([t,r])=>[Ti(t),r]),ix=e=>o(u(".*",e),([t,r])=>[Ei(t),r]),mx=e=>o(u("-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?",e),([t,r])=>[ki(t),r]),px=e=>o(u("-?(?:0|[1-9][0-9]*)",e),([t,r])=>[Oi(t),r]),ux=e=>o(u("(?!)",e),([t,r])=>[Pi(t),r]),cx=e=>o(nm(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,r])=>[wi(t),r]),dx=e=>o(o(sx(e),([t,r])=>[t,r],()=>o(ix(e),([t,r])=>[t,r],()=>o(mx(e),([t,r])=>[t,r],()=>o(px(e),([t,r])=>[t,r],()=>o(ux(e),([t,r])=>[t,r],()=>o(lx(e),([t,r])=>[t,r],()=>o(cx(e),([t,r])=>[t,r],()=>[]))))))),([t,r])=>[t,r]),lx=e=>o(o(u("(",e),([t,r])=>o(ba(r),([n,a])=>o(u(")",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Ri(t),r]),jm=e=>o(o(o(xa(e),([t,r])=>o(u("|",r),([n,a])=>o(jm(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[t,r],()=>o(o(xa(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[]))),([t,r])=>[vi(t),r]),xa=e=>o(o(dx(e),([t,r])=>o(ba(r),([n,a])=>[[t,n],a])),([t,r])=>[Ci(t),r]),ba=e=>o(o(jm(e),([t,r])=>[t,r],()=>o(xa(e),([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),So=e=>o(o(u("^",e),([t,r])=>o(ba(r),([n,a])=>o(u("$",a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Mi(t),r]),qm=(e,t=[])=>o(o(A(e),([r,n])=>o(u(",",n),([a,i])=>[[r,a],i])),([r,n])=>qm(n,[...t,r]),()=>[t,e]),fx=e=>o(o(qm(e),([t,r])=>o(o(o(A(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[Si(t),r]),Am=e=>o(o(o(u("extends",e),([t,r])=>o(fx(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ji(t),r]),xx=e=>o(o(u("interface",e),([t,r])=>o(B(r),([n,a])=>o(Ia(a),([i,m])=>o(Am(m),([c,l])=>o(ga(l),([v,j])=>[[t,n,i,c,v],j]))))),([t,r])=>[qi(t),r]),Ix=e=>o(o(u("interface",e),([t,r])=>o(B(r),([n,a])=>o(Am(a),([i,m])=>o(ga(m),([c,l])=>[[t,n,i,c],l])))),([t,r])=>[Ai(t),r]),yx=e=>o(o(u("type",e),([t,r])=>o(B(r),([n,a])=>o(Ia(a),([i,m])=>o(u("=",m),([c,l])=>o(A(l),([v,j])=>[[t,n,i,c,v],j]))))),([t,r])=>[Li(t),r]),gx=e=>o(o(u("type",e),([t,r])=>o(B(r),([n,a])=>o(u("=",a),([i,m])=>o(A(m),([c,l])=>[[t,n,i,c],l])))),([t,r])=>[Ni(t),r]),$x=e=>o(o(o(u("export",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Fi(t),r]),bx=e=>o(o(o(u(";",e),([t,r])=>o(u(`
6
+ `,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))))),([t,r])=>[t,r]),Pm=(e,t=[])=>o(o(km(e),([r,n])=>o(Om(n),([a,s])=>[[r,a],s])),([r,n])=>Pm(n,[...t,r]),()=>[t,e]),Ff=e=>o(o(Pm(e),([t,r])=>o(o(o(km(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[Hs(t),r]),ba=e=>o(o(u("{",e),([t,r])=>o(Ff(r),([n,a])=>o(u("}",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[Js(t),r]),Uf=e=>o(ba(e),([t,r])=>[Ws(t),r]),Kf=e=>o(o(o(B(e),([t,r])=>o(u("?",r),([n,a])=>o(u(":",a),([s,m])=>o(u("readonly",m),([c,l])=>o(A(l),([v,j])=>[[t,n,s,c,v],j]))))),([t,r])=>[t,r],()=>o(o(B(e),([t,r])=>o(u(":",r),([n,a])=>o(u("readonly",a),([s,m])=>o(A(m),([c,l])=>[[t,n,s,c],l])))),([t,r])=>[t,r],()=>o(o(B(e),([t,r])=>o(u("?",r),([n,a])=>o(u(":",a),([s,m])=>o(A(m),([c,l])=>[[t,n,s,c],l])))),([t,r])=>[t,r],()=>o(o(B(e),([t,r])=>o(u(":",r),([n,a])=>o(A(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[t,r],()=>[])))),([t,r])=>[Xs(t),r]),_f=e=>o(o(u("readonly",e),([t,r])=>o(A(r),([n,a])=>o(u("?",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[Zs(t),r]),Gf=e=>o(o(u("readonly",e),([t,r])=>o(A(r),([n,a])=>[[t,n],a])),([t,r])=>[Ys(t),r]),zf=e=>o(o(A(e),([t,r])=>o(u("?",r),([n,a])=>[[t,n],a])),([t,r])=>[Qs(t),r]),im=e=>o(o(Kf(e),([t,r])=>[t,r],()=>o(_f(e),([t,r])=>[t,r],()=>o(Gf(e),([t,r])=>[t,r],()=>o(zf(e),([t,r])=>[t,r],()=>o(A(e),([t,r])=>[t,r],()=>[]))))),([t,r])=>[t,r]),wm=e=>o(o(o(u("...",e),([t,r])=>o(im(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(im(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[ei(t),r]),Rm=(e,t=[])=>o(o(wm(e),([r,n])=>o(u(",",n),([a,s])=>[[r,a],s])),([r,n])=>Rm(n,[...t,r]),()=>[t,e]),Bf=e=>o(o(Rm(e),([t,r])=>o(o(o(wm(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[ti(t),r]),Hf=e=>o(o(u("[",e),([t,r])=>o(Bf(r),([n,a])=>o(u("]",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[ri(t),r]),Vf=e=>o(o(B(e),([t,r])=>o(u("?",r),([n,a])=>o(u(":",a),([s,m])=>o(u("readonly",m),([c,l])=>o(A(l),([v,j])=>[[t,n,s,c,v],j]))))),([t,r])=>[ni(t),r]),Jf=e=>o(o(B(e),([t,r])=>o(u(":",r),([n,a])=>o(u("readonly",a),([s,m])=>o(A(m),([c,l])=>[[t,n,s,c],l])))),([t,r])=>[ai(t),r]),Wf=e=>o(o(B(e),([t,r])=>o(u("?",r),([n,a])=>o(u(":",a),([s,m])=>o(A(m),([c,l])=>[[t,n,s,c],l])))),([t,r])=>[oi(t),r]),Xf=e=>o(o(B(e),([t,r])=>o(u(":",r),([n,a])=>o(A(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[si(t),r]),mm=e=>o(o(Vf(e),([t,r])=>[t,r],()=>o(Jf(e),([t,r])=>[t,r],()=>o(Wf(e),([t,r])=>[t,r],()=>o(Xf(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),vm=e=>o(o(o(u("...",e),([t,r])=>o(mm(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(mm(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[ii(t),r]),Cm=(e,t=[])=>o(o(vm(e),([r,n])=>o(u(",",n),([a,s])=>[[r,a],s])),([r,n])=>Cm(n,[...t,r]),()=>[t,e]),Mm=e=>o(o(Cm(e),([t,r])=>o(o(o(vm(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[mi(t),r]),Zf=e=>o(o(u("(",e),([t,r])=>o(Mm(r),([n,a])=>o(u(")",a),([s,m])=>o(u("=>",m),([c,l])=>o(A(l),([v,j])=>[[t,n,s,c,v],j]))))),([t,r])=>[pi(t),r]),Yf=e=>o(o(u("new",e),([t,r])=>o(u("(",r),([n,a])=>o(Mm(a),([s,m])=>o(u(")",m),([c,l])=>o(u("=>",l),([v,j])=>o(A(j),([b,C])=>[[t,n,s,c,v,b],C])))))),([t,r])=>[ui(t),r]),Qf=e=>o(o(o(u("+",e),([t,r])=>o(u("readonly",r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u("-",e),([t,r])=>o(u("readonly",r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[ci(t),r]),ex=e=>o(o(o(u("+",e),([t,r])=>o(u("?",r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u("-",e),([t,r])=>o(u("?",r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[di(t),r]),tx=e=>o(o(o(u("as",e),([t,r])=>o(A(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[li(t),r]),rx=e=>o(o(u("{",e),([t,r])=>o(Qf(r),([n,a])=>o(u("[",a),([s,m])=>o(B(m),([c,l])=>o(u("in",l),([v,j])=>o(A(j),([b,C])=>o(tx(C),([x,J])=>o(u("]",J),([Re,Xe])=>o(ex(Xe),([gt,$t])=>o(u(":",$t),([St,jt])=>o(A(jt),([te,ke])=>o(dm(ke),([dr,bt])=>o(u("}",bt),([fd,xd])=>[[t,n,s,c,v,b,x,Re,gt,St,te,dr,fd],xd]))))))))))))),([t,r])=>[fi(t),r]),nx=e=>o(B(e),([t,r])=>[xi(t),r]),ax=e=>o(o(u("Options",e),([t,r])=>o(u("<",r),([n,a])=>o(A(a),([s,m])=>o(u(",",m),([c,l])=>o(qm(l),([v,j])=>o(u(">",j),([b,C])=>[[t,n,s,c,v,b],C])))))),([t,r])=>[Ii(t),r]),ox=e=>o(Fn(e),([t,r])=>[yi(t),r]),sx=e=>o(o(u("true",e),([t,r])=>[t,r],()=>o(u("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[gi(t),r]),ix=e=>o(Un(['"',"'"],e),([t,r])=>[t,r]),mx=e=>o(u("null",e),([t,r])=>[$i(t),r]),Sm=e=>o(o(Em(e),([t,r])=>o(u(":",r),([n,a])=>o(ha(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[bi(t),r]),jm=(e,t=[])=>o(o(Sm(e),([r,n])=>o(Om(n),([a,s])=>[[r,a],s])),([r,n])=>jm(n,[...t,r]),()=>[t,e]),px=e=>o(o(jm(e),([t,r])=>o(o(o(Sm(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[hi(t),r]),qm=e=>o(o(u("{",e),([t,r])=>o(px(r),([n,a])=>o(u("}",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[Ti(t),r]),Am=(e,t=[])=>o(o(ha(e),([r,n])=>o(u(",",n),([a,s])=>[[r,a],s])),([r,n])=>Am(n,[...t,r]),()=>[t,e]),ux=e=>o(o(Am(e),([t,r])=>o(o(o(ha(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[Ei(t),r]),cx=e=>o(o(u("[",e),([t,r])=>o(ux(r),([n,a])=>o(u("]",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[ki(t),r]),ha=e=>o(o(ox(e),([t,r])=>[t,r],()=>o(sx(e),([t,r])=>[t,r],()=>o(ix(e),([t,r])=>[t,r],()=>o(mx(e),([t,r])=>[t,r],()=>o(qm(e),([t,r])=>[t,r],()=>o(cx(e),([t,r])=>[t,r],()=>[])))))),([t,r])=>[t,r]),dx=e=>o(u("-?(?:0|[1-9][0-9]*)n",e),([t,r])=>[Oi(t),r]),lx=e=>o(u(".*",e),([t,r])=>[Pi(t),r]),fx=e=>o(u("-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?",e),([t,r])=>[wi(t),r]),xx=e=>o(u("-?(?:0|[1-9][0-9]*)",e),([t,r])=>[Ri(t),r]),Ix=e=>o(u("(?!)",e),([t,r])=>[vi(t),r]),yx=e=>o(sm(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,r])=>[Ci(t),r]),gx=e=>o(o(dx(e),([t,r])=>[t,r],()=>o(lx(e),([t,r])=>[t,r],()=>o(fx(e),([t,r])=>[t,r],()=>o(xx(e),([t,r])=>[t,r],()=>o(Ix(e),([t,r])=>[t,r],()=>o($x(e),([t,r])=>[t,r],()=>o(yx(e),([t,r])=>[t,r],()=>[]))))))),([t,r])=>[t,r]),$x=e=>o(o(u("(",e),([t,r])=>o(Ta(r),([n,a])=>o(u(")",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[Mi(t),r]),Lm=e=>o(o(o(ya(e),([t,r])=>o(u("|",r),([n,a])=>o(Lm(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[t,r],()=>o(o(ya(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[]))),([t,r])=>[Si(t),r]),ya=e=>o(o(gx(e),([t,r])=>o(Ta(r),([n,a])=>[[t,n],a])),([t,r])=>[ji(t),r]),Ta=e=>o(o(Lm(e),([t,r])=>[t,r],()=>o(ya(e),([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),Ao=e=>o(o(u("^",e),([t,r])=>o(Ta(r),([n,a])=>o(u("$",a),([s,m])=>[[t,n,s],m]))),([t,r])=>[qi(t),r]),Dm=(e,t=[])=>o(o(A(e),([r,n])=>o(u(",",n),([a,s])=>[[r,a],s])),([r,n])=>Dm(n,[...t,r]),()=>[t,e]),bx=e=>o(o(Dm(e),([t,r])=>o(o(o(A(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[Ai(t),r]),Nm=e=>o(o(o(u("extends",e),([t,r])=>o(bx(r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Li(t),r]),hx=e=>o(o(u("interface",e),([t,r])=>o(B(r),([n,a])=>o(ga(a),([s,m])=>o(Nm(m),([c,l])=>o(ba(l),([v,j])=>[[t,n,s,c,v],j]))))),([t,r])=>[Di(t),r]),Tx=e=>o(o(u("interface",e),([t,r])=>o(B(r),([n,a])=>o(Nm(a),([s,m])=>o(ba(m),([c,l])=>[[t,n,s,c],l])))),([t,r])=>[Ni(t),r]),Ex=e=>o(o(u("type",e),([t,r])=>o(B(r),([n,a])=>o(ga(a),([s,m])=>o(u("=",m),([c,l])=>o(A(l),([v,j])=>[[t,n,s,c,v],j]))))),([t,r])=>[Fi(t),r]),kx=e=>o(o(u("type",e),([t,r])=>o(B(r),([n,a])=>o(u("=",a),([s,m])=>o(A(m),([c,l])=>[[t,n,s,c],l])))),([t,r])=>[Ui(t),r]),Ox=e=>o(o(o(u("export",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ki(t),r]),Px=e=>o(o(o(u(";",e),([t,r])=>o(u(`
7
7
  `,r),([n,a])=>[[t,n],a])),([t,r])=>[t,r],()=>o(o(u(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>o(o(u(`
8
- `,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]),Lm=(e,t=[])=>o(o(ha(e),([r,n])=>o(bx(n),([a,i])=>[[r,a],i])),([r,n])=>Lm(n,[...t,r]),()=>[t,e]),hx=e=>o(o(Lm(e),([t,r])=>o(o(o(ha(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[Di(t),r]),ha=e=>o(o($x(e),([t,r])=>o(o(xx(r),([n,a])=>[n,a],()=>o(Ix(r),([n,a])=>[n,a],()=>o(yx(r),([n,a])=>[n,a],()=>o(gx(r),([n,a])=>[n,a],()=>[])))),([n,a])=>o(pm(a),([i,m])=>[[t,n,i],m]))),([t,r])=>[Ui(t),r]),Tx=e=>o(o(ha(e),([t,r])=>o(hx(r),([n,a])=>[[t,n],a])),([t,r])=>[Ki(t),r]),Nm=e=>o(o(Tx(e),([t,r])=>[t,r],()=>o(Of(e),([t,r])=>[t,r],()=>o(A(e),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]);function Fm(e){let t=ya(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:K()}function Er(e,t={}){return $("TemplateLiteral",[e],t)}function Dm(e){return g({},Er(e,{}))}function kx(e){let t=Fm(e);return Dm(t)}function Um(e,t={}){let r=s.IsString(e)?kx(e):Dm(e);return p.Update(r,{},t)}function Q(e){return f(e,"TemplateLiteral")}var h={};qt(h,{ExtendsFalse:()=>P,ExtendsTrue:()=>I,ExtendsUnion:()=>Ta,IsExtendsFalse:()=>Ox,IsExtendsTrue:()=>Gm,IsExtendsTrueLike:()=>tr,IsExtendsUnion:()=>Km,Match:()=>W,TakeLeft:()=>fe});function Ta(e){return p.Create({"~kind":"ExtendsUnion"},{inferred:e})}function Km(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsUnion")&&s.IsObject(e.inferred)}function I(e){return p.Create({"~kind":"ExtendsTrue"},{inferred:e})}function Gm(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function P(){return p.Create({"~kind":"ExtendsFalse"},{})}function Ox(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function tr(e){return Km(e)||Gm(e)}function W(e,t,r){return tr(e)?t(e.inferred):r()}function fe(e,t,r){return s.IsEqual(e.length,0)?r():t(e[0],e.slice(1))}function Px(e){return s.IsString(e)||s.IsNumber(e)?q(e):s.IsNull(e)?st():S()}function Se(e){return e.map(r=>Px(r))}function zr(e){let t=Se(e);return O(t)}function _m(e){return zr(e.enum)}function wx(e,t,r,n){return W(N(e,r,n),a=>I(p.Assign(p.Assign(e,a),{[t]:r})),()=>P())}function Rx(e,t){return I(e)}function vx(e,t,r){let n=zr(r);return N(e,t,n)}function zm(e,t,r){return fe(r,(n,a)=>W(N(e,t,n),i=>zm(i,t,a),()=>P()),()=>I(e))}function Cx(e,t,r){let n=he(r);return N(e,t,n)}function Bm(e,t,r){return fe(r,(n,a)=>W(N(e,t,n),i=>I(i),()=>Bm(e,t,a)),()=>P())}function R(e,t,r){return Z(r)?Rx(e,t):ie(r)?vx(e,t,r.enum):V(r)?wx(e,r.name,t,r.extends):M(r)?zm(e,t,r.allOf):Q(r)?Cx(e,t,r.pattern):y(r)?Bm(e,t,r.anyOf):re(r)?I(e):P()}function Hm(e,t,r){return V(r)?R(e,t,r):Z(r)?I(e):re(r)?I(e):Ta(e)}function Mx(e,t){let r=Et(e),n=Et(t);return r&&n||!r&&n?!0:!(r&&!n)}function Vm(e,t,r,n){return z(n)?Mx(t,n)?N(e,r,n.items):P():R(e,t,n)}function Jm(e,t,r){return ge(r)?N(e,t,r.iteratorItems):R(e,Ae(t),r)}function Wm(e,t,r){return Ne(r)?I(e):R(e,t,r)}function Xm(e,t,r){return Oe(r)?I(e):R(e,t,r)}function Sx(e,t,r,n,a){let i=V(n)?t:n,m=V(n)?n:t,c=pe(t),l=pe(n);return!c&&l?P():W(N(e,i,m),v=>Br(v,r,a),()=>P())}function jx(e,t,r,n){return fe(n,(a,i)=>Sx(e,t,r,a,i),()=>pe(t)?I(e):P())}function qx(e,t,r){return fe(t,(n,a)=>jx(e,n,a,r),()=>I(e))}function Br(e,t,r){return qx(e,t,r)}function Un(e,t,r){return Ke(r)?I(e):N(e,t,r)}function Zm(e,t,r,n){return Z(n)?I(e):re(n)?I(e):ae(n)?W(Br(e,t,n.parameters),a=>Un(a,r,n.instanceType),()=>P()):P()}function Ym(e,t,r){return N(e,_m(t),r)}function Qm(e,t,r,n){return Z(n)?I(e):re(n)?I(e):oe(n)?W(Br(e,t,n.parameters),a=>Un(a,r,n.returnType),()=>P()):P()}function ep(e,t,r){return ce(r)?I(e):Y(r)?I(e):R(e,t,r)}function tp(e,t,r){let n=_(t);return N(e,n,r)}function rp(e,t,r){return $e(r)?N(e,t,r.iteratorItems):R(e,Fe(t),r)}function Kn(e,t,r){return t===r?I(e):P()}function Ax(e,t,r){return D(r)?Kn(e,t,r.const):Ne(r)?I(e):R(e,q(t),r)}function Lx(e,t,r){return D(r)?Kn(e,t,r.const):Oe(r)?I(e):R(e,q(t),r)}function Nx(e,t,r){return D(r)?Kn(e,t,r.const):Y(r)?I(e):R(e,q(t),r)}function Fx(e,t,r){return D(r)?Kn(e,t,r.const):le(r)?I(e):R(e,q(t),r)}function np(e,t,r){return s.IsBigInt(t.const)?Ax(e,t.const,r):s.IsBoolean(t.const)?Lx(e,t.const,r):s.IsNumber(t.const)?Nx(e,t.const,r):s.IsString(t.const)?Fx(e,t.const,r):K()}function ap(e,t,r){return V(r)?R(e,t,r):I(e)}function op(e,t,r){return Dt(r)?I(e):R(e,t,r)}function sp(e,t,r){return Y(r)?I(e):R(e,t,r)}function Dx(e,t,r){return pe(t)?pe(r)?I(e):P():I(e)}function Ux(e,t,r){return V(r)&&at(r.extends)?P():W(N(e,t,r),n=>Dx(n,t,r),()=>P())}function Kx(e,t){return e.reduce((r,n)=>n in t?tr(t[n])?{...r,...t[n].inferred}:K():K(),{})}function Gx(e,t,r){let n={};for(let m of s.Keys(r))n[m]=m in t?Ux({},t[m],r[m]):pe(r[m])?V(r[m])?I(p.Assign(e,{[r[m].name]:r[m].extends})):I(e):P();let a=s.Values(n).every(m=>tr(m)),i=a?Kx(s.Keys(n),n):{};return a?I(i):P()}function _x(e,t,r){let n=Gx(e,t,r);return tr(n)?I(p.Assign(e,n.inferred)):P()}function zx(e,t,r){return _x(e,t,r)}function ip(e,t,r){return F(r)?zx(e,t,r.properties):R(e,E(t),r)}function mp(e,t,r){return de(r)?N(e,t,r.item):R(e,De(t),r)}function pp(e,t,r){return le(r)?I(e):R(e,t,r)}function up(e,t,r){return it(r)?I(e):R(e,t,r)}function cp(e,t,r){let n=he(t);return N(e,n,r)}function Ea(e,t){return p.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function Hr(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 ka(e){return mt(e)?V(e.items)?z(e.items.extends)?Ea(e.items.name,e.items.extends.items):re(e.items.extends)?Ea(e.items.name,e.items.extends):void 0:K():void 0}function Gn(e){return V(e)?Ea(e.name,e.extends):void 0}function Oa(e,t,r=[]){return fe(e,(n,a)=>W(N({},n,t),()=>Oa(a,t,[...r,n]),()=>{}),()=>r)}function dp(e,t,r,n){let a=Oa(r,n);return s.IsArray(a)?I(p.Assign(e,{[t]:ee(a)})):P()}function _n(e,t,r,n){let a=Oa(r,n);return s.IsArray(a)?I(p.Assign(e,{[t]:O(a)})):P()}function Bx(e){return[...e].reverse()}function Pa(e,t){return t?Bx(e):e}function Hx(e){let t=e.length>0?e[0]:void 0,r=k(t)?ka(t):void 0;return k(r)}function Vx(e,t,r,n,a,i){return W(N(e,r,a),m=>lp(m,t,n,i),()=>P())}function Jx(e,t,r,n,a){let i=ka(n);return Hr(i)?dp(e,i.name,Pa(r,t),i.type):fe(r,(m,c)=>Vx(e,t,m,c,n,a),()=>P())}function Wx(e,t,r,n){return fe(n,(a,i)=>Jx(e,t,r,a,i),()=>s.IsEqual(r.length,0)?I(e):P())}function lp(e,t,r,n){return Wx(e,t,r,n)}function Xx(e,t,r){let n=zn(e,{callstack:[]},r),a=Hx(n);return lp(e,a,Pa(t,a),Pa(n,a))}function fp(e,t,r){let n=Gn(r);return Hr(n)?_n(e,n.name,t,n.type):fe(t,(a,i)=>W(N(e,a,r),m=>fp(m,i,r),()=>P()),()=>I(e))}function xp(e,t,r){let n=zn(e,{callstack:[]},t);return U(r)?Xx(e,n,r.items):z(r)?fp(e,n,r.items):R(e,ee(n),r)}function Ip(e,t,r){return Ke(r)?I(e):Ht(r)?I(e):R(e,t,r)}function yp(e,t,r){return fe(r,(n,a)=>W(N(e,t,n),i=>I(i),()=>yp(e,t,a)),()=>P())}function wa(e,t,r){return fe(t,(n,a)=>W(yp(e,n,r),i=>wa(i,a,r),()=>P()),()=>I(e))}function gp(e,t,r){let n=Gn(r);return Hr(n)?_n(e,n.name,t,n.type):y(r)?wa(e,t,r.anyOf):wa(e,t,[r])}function $p(e,t,r){return V(r)?R(e,t,r):Z(r)?I(e):re(r)?I(e):P()}function bp(e,t,r){return Ke(r)?I(e):R(e,t,r)}function N(e,t,r){return Z(t)?Hm(e,t,r):z(t)?Vm(e,t,t.items,r):ge(t)?Jm(e,t.iteratorItems,r):Ne(t)?Wm(e,t,r):Oe(t)?Xm(e,t,r):ae(t)?Zm(e,t.parameters,t.instanceType,r):ie(t)?Ym(e,t,r):oe(t)?Qm(e,t.parameters,t.returnType,r):ce(t)?ep(e,t,r):M(t)?tp(e,t.allOf,r):$e(t)?rp(e,t.iteratorItems,r):D(t)?np(e,t,r):at(t)?ap(e,t,r):Dt(t)?op(e,t,r):Y(t)?sp(e,t,r):F(t)?ip(e,t.properties,r):de(t)?mp(e,t.item,r):le(t)?pp(e,t,r):it(t)?up(e,t,r):Q(t)?cp(e,t.pattern,r):U(t)?xp(e,t.items,r):Ht(t)?Ip(e,t,r):y(t)?gp(e,t.anyOf,r):re(t)?$p(e,t,r):Ke(t)?bp(e,t,r):P()}function Jt(e,t,r={}){return $("Interface",[e,t],r)}function rr(e){return k(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function hp(e,t,r={}){return g({},Jt(e,t,r))}function Zx(e,t,r){return e.includes(r)?!0:ct([...e,r],t,t[r])}function Tp(e,t,r){let n=yn(r);return vt(e,t,n)}function vt(e,t,r){let[n,...a]=r;return k(n)?ct(e,t,n)?!0:vt(e,t,a):!1}function ct(e,t,r){return X(r)?Zx(e,t,r.$ref):z(r)?ct(e,t,r.items):ge(r)?ct(e,t,r.iteratorItems):ae(r)?vt(e,t,[...r.parameters,r.instanceType]):oe(r)?vt(e,t,[...r.parameters,r.returnType]):rr(r)?Tp(e,t,r.parameters[1]):M(r)?vt(e,t,r.allOf):$e(r)?ct(e,t,r.iteratorItems):F(r)?Tp(e,t,r.properties):de(r)?ct(e,t,r.item):y(r)?vt(e,t,r.anyOf):U(r)?vt(e,t,r.items):we(r)?ct(e,t,Ue(r)):!1}function Bn(e,t,r){return ct(e,t,r)}function Yx(e,t){return t.reduce((r,n)=>n in e?Bn([n],e,e[n])?[...r,n]:r:K(),[])}function Ep(e){let t=fo(e);return Yx(e,t)}function Qx(e,t,r){return r.includes(t)?r:t in e?dt(e,e[t],[...r,t]):K()}function kp(e,t,r){let n=yn(t);return nr(e,n,r)}function nr(e,t,r){return t.reduce((n,a)=>dt(e,a,n),r)}function dt(e,t,r){return X(t)?Qx(e,t.$ref,r):z(t)?dt(e,t.items,r):ge(t)?dt(e,t.iteratorItems,r):ae(t)?nr(e,[...t.parameters,t.instanceType],r):oe(t)?nr(e,[...t.parameters,t.returnType],r):rr(t)?kp(e,t.parameters[1],r):M(t)?nr(e,t.allOf,r):$e(t)?dt(e,t.iteratorItems,r):F(t)?kp(e,t.properties,r):de(t)?dt(e,t.item,r):y(t)?nr(e,t.anyOf,r):U(t)?nr(e,t.items,r):we(t)?dt(e,Ue(t),r):r}function Op(e,t,r){return dt(e,r,[t])}function eI(e){return Ft()}function tI(e){return s.Keys(e).reduce((t,r)=>({...t,[r]:Ge(e[r])}),{})}function Vr(e){return e.reduce((t,r)=>[...t,Ge(r)],[])}function Ge(e){return X(e)?eI(e.$ref):z(e)?Ce(Ge(e.items),fn(e)):ge(e)?Ae(Ge(e.iteratorItems)):ae(e)?tt(Vr(e.parameters),Ge(e.instanceType)):oe(e)?rt(Vr(e.parameters),Ge(e.returnType)):M(e)?Te(Vr(e.allOf)):$e(e)?Fe(Ge(e.iteratorItems)):F(e)?E(tI(e.properties)):de(e)?De(Ge(e.item)):we(e)?vn(zt(e),Ge(Ue(e))):y(e)?O(Vr(e.anyOf)):U(e)?ee(Vr(e.items)):e}function rI(e,t){return t in e?Ge(e[t]):ue()}function Pp(e){return rI(e.$defs,e.$ref)}function Ra(e){return e.reduceRight((r,n,a)=>({[a]:n,...r}),{})}function wp(e){let t=Ra(e.items);return E(t)}function nI(e,t){return kt(e)?!!kt(t):!1}function aI(e,t){return pe(e)?!!pe(t):!1}function oI(e,t){let r=nI(e,t),n=aI(e,t),a=_([e,t]),i=dn(Lt(a));return r&&n?Ie(xe(i)):r&&!n?Ie(i):!r&&n?xe(i):i}function sI(e,t,r){return r in e?r in t?oI(e[r],t[r]):e[r]:r in t?t[r]:S()}function iI(e,t){return[...new Set([...s.Keys(t),...s.Keys(e)])].reduce((n,a)=>({...n,[a]:sI(e,t,a)}),{})}function Rp(e){return F(e)?e.properties:U(e)?Ra(e.items):K()}function vp(e,t){let r=Rp(e),n=Rp(t),a=iI(r,n);return E(a)}function Cp(e,t){let r=Zr(e,t);return s.IsEqual(r,Wr)?e:s.IsEqual(r,Xr)||s.IsEqual(r,Jr)?t:S()}function Mp(e){return F(e)||U(e)}function mI(e,t){let r=y(e),n=y(t);return r||n}function pI(e,t){let r=Ct(e),n=Ct(t),a=mI(r,n),i=Mp(r),m=Mp(n);return a?_([r,n]):i&&m?vp(r,n):i&&!m?r:!i&&m?n:Cp(r,n)}function Sp(e,t,r=[]){let[n,...a]=t;return s.IsUndefined(n)?r.length===0?[e]:r:Sp(e,a,[...r,pI(e,n)])}function jp(e,t,r=[]){let[n,...a]=e;return k(n)?jp(a,t,[...r,...Yr([n],t)]):r}function Yr(e,t=[]){let[r,...n]=e;return k(r)?y(r)?Yr(n,jp(r.anyOf,t)):Yr(n,Sp(r,t)):t}function _(e){let t=Yr(e);return va(t)}function je(e){return va(e)}function Ct(e){return M(e)?_(e.allOf):y(e)?je(e.anyOf):e}function Mt(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?S():O(e)}function uI(e,t,r){let n=Ee(e,{callstack:[]},t),a=Qr({},{callstack:[]},r);return _([...n,E(a)])}function cI(e,t){return s.Keys(e).filter(n=>t.includes(n)).reduce((n,a)=>{let i=e[a],m=rr(i)?uI(e,i.parameters[0],i.parameters[1]):i;return{...n,[a]:m}},{})}function qp(e,t,r){let n=Op(e,t,r),a=cI(e,n);return Le(a,t)}function Ap(e,t){return t in e?X(e[t])?Ap(e,e[t].$ref):e[t]:S()}function _e(e,t){return Ap(e,t)}function Lp(e){return se(e)?Pp(e):e}function me(e,t,r){let n=Lp(t),a=Lp(r);return N(e,n,a)}var Jr="equal",dI="disjoint",Wr="left-inside",Xr="right-inside";function Zr(e,t){let r=[re(e)?h.ExtendsFalse():me({},e,t),re(e)?h.ExtendsTrue({}):me({},t,e)];return h.IsExtendsTrueLike(r[0])&&h.IsExtendsTrueLike(r[1])?Jr:h.IsExtendsTrueLike(r[0])&&h.IsExtendsFalse(r[1])?Wr:h.IsExtendsFalse(r[0])&&h.IsExtendsTrueLike(r[1])?Xr:dI}function lI(e){return y(e)?Je(e.anyOf):[e]}function Je(e){return e.reduce((t,r)=>[...t,...lI(r)],[])}function fI(e,t){return t.filter(r=>Zr(e,r)!==Xr)}function xI(e,t){let r=t.some(n=>{let a=Zr(e,n);return s.IsEqual(a,Wr)||s.IsEqual(a,Jr)});return s.IsEqual(r,!1)}function II(e,t){let r=Ct(e);return Z(r)?[r]:xI(r,t)?[...fI(r,t),r]:t}function yI(e){return e.reduce((t,r)=>F(r)?[...t,r]:at(r)?t:II(r,t),[])}function va(e){let t=yI(e),r=Je(t);return r.length===0?S():r.length===1?r[0]:O(r)}function gI(e,t,r,n){let a=d(e,t,r);return p.Update(Ct(a),{},n)}function Np(e,t,r,n){return gI(e,t,r,n)}function en(e,t=[]){return Qe(e)&&s.IsEqual(e.action,"Conditional")?X(e.parameters[0])?en(e.parameters[2],en(e.parameters[3],[...t,e.parameters[0].$ref])):en(e.parameters[2],en(e.parameters[3],t)):Qe(e)&&s.IsEqual(e.action,"Mapped")&&Qe(e.parameters[1])&&s.IsEqual(e.parameters[1].action,"KeyOf")&&X(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function $I(e,t){return e.reduce((r,n)=>[...r,t.includes(n.name)],[])}function Up(e,t,r=[]){let[n,...a]=e,[i,...m]=t;return s.IsGreaterThan(e.length,0)&&s.IsGreaterThan(t.length,0)?Up(a,m,[...r,[i,n]]):r}function bI(e){return y(e)?[...e.anyOf]:[e]}function hI(e,t){return e.reduce((r,n)=>[...r,[...n,t]],[])}function Fp(e,t){return t.reduce((r,n)=>[...r,...hI(e,n)],[])}function Dp(e){return e.reduce((t,r)=>s.IsEqual(r[0],!0)?Fp(t,bI(r[1])):Fp(t,[r[1]]),[[]])}function Kp(e,t,r){let n=en(r),a=$I(e,n),i=Up(t,a);return Qe(r)&&s.IsEqual(r.action,"Conditional")||Qe(r)&&s.IsEqual(r.action,"Mapped")?Dp(i):[t]}function TI(){return["(not-resolvable)",S()]}function EI(){return["(not-generic)",S()]}function kI(e,t,r){return[e,nt(t,r)]}function OI(e,t,r){return t in e?Gp(e,t,e[t],r):TI()}function Gp(e,t,r,n){return Nt(r)?kI(t,r.parameters,r.expression):X(r)?OI(e,r.$ref,n):EI()}function _p(e,t,r){return Gp(e,"(anonymous)",t,r)}function PI(e,t,r){if(V(t)||ar(t)||h.IsExtendsTrueLike(me({},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 zp(e,t,r,n,a){let i=d(e,t,a);return PI(r,i,n),p.Assign(e,{[r]:i})}function wI(e,t,r,n,a){let i=d(e,t,r.extends),m=d(e,t,r.equals),[c,...l]=a;return k(c)?Ca(zp(e,t,r.name,i,c),t,n,l):Ca(zp(e,t,r.name,i,m),t,n,[])}function Ca(e,t,r,n){let[a,...i]=r;return k(a)?wI(e,t,a,i,n):e}function Bp(e,t,r,n){return Ca(e,t,r,n)}function RI(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function vI(e,t){return s.IsEqual(RI(e),t)}function CI(e,t,r,n,a,i){let m=Bp(e,t,n,i),c=d(m,{callstack:[...t.callstack,r.$ref]},a);return d(e,t,c)}function MI(e,t,r,n,a,i){return i.reduce((m,c)=>[...m,CI(e,t,r,n,a,c)],[])}function SI(e,t,r,n,a,i){let m=Kp(n,i,a),c=MI(e,t,r,n,a,m);return s.IsEqual(c.length,1)?c[0]:je(c)}function Hn(e,t,r,n){let a=Ee(e,t,n),i=_p(e,r,n),m=i[0],c=i[1];return Nt(c)?vI(t,m)?kr(He(m),a):SI(e,t,He(m),c.parameters,c.expression,a):kr(r,a)}function kr(e,t){return p.Create({"~kind":"Call"},{target:e,arguments:t},{})}function Hp(e,t){return Hn({},{callstack:[]},e,t)}function ar(e){return f(e,"Call")}function Vp(e){return de(e)?Vp(e.item):e}function jI(e,t,r,n){let a=d(e,t,r);return p.Update(Vp(a),{},n)}function Jp(e,t,r,n){return T(e,[r])?jI(e,t,r,n):Gr(r,n)}function Wp(e,t){return e(t)}function Xp(e,t){return s.IsString(t)?q(Wp(e,t)):q(t)}function Zp(e,t){let r=he(t);return We(e,r)}function Yp(e,t){let r=t.map(n=>We(e,n));return O(r)}function We(e,t){return D(t)?Xp(e,t.const):Q(t)?Zp(e,t.pattern):y(t)?Yp(e,t.anyOf):t}function Or(e,t={}){return $("Capitalize",[e],t)}function Qp(e,t={}){return g({},Or(e,t))}function Pr(e,t={}){return $("Lowercase",[e],t)}function eu(e,t={}){return g({},Pr(e,t))}function wr(e,t={}){return $("Uncapitalize",[e],t)}function tu(e,t={}){return g({},wr(e,t))}function Rr(e,t={}){return $("Uppercase",[e],t)}function ru(e,t={}){return g({},Rr(e,t))}var qI=e=>e[0].toUpperCase()+e.slice(1),AI=e=>e.toLowerCase(),LI=e=>e[0].toLowerCase()+e.slice(1),NI=e=>e.toUpperCase();function FI(e,t,r,n){let a=d(e,t,r);return p.Update(We(qI,a),{},n)}function nu(e,t,r,n){return T(e,[r])?FI(e,t,r,n):Or(r,n)}function DI(e,t,r,n){let a=d(e,t,r);return p.Update(We(AI,a),{},n)}function au(e,t,r,n){return T(e,[r])?DI(e,t,r,n):Pr(r,n)}function UI(e,t,r,n){let a=d(e,t,r);return p.Update(We(LI,a),{},n)}function ou(e,t,r,n){return T(e,[r])?UI(e,t,r,n):wr(r,n)}function KI(e,t,r,n){let a=d(e,t,r);return p.Update(We(NI,a),{},n)}function su(e,t,r,n){return T(e,[r])?KI(e,t,r,n):Rr(r,n)}function vr(e,t,r,n,a={}){return $("Conditional",[e,t,r,n],a)}function iu(e,t,r,n,a={}){return g({},vr(e,t,r,n,a))}function GI(e,t,r,n,a,i,m){let c=d(e,t,r),l=d(e,t,n),v=me(e,c,l);return p.Update(h.IsExtendsUnion(v)?O([d(v.inferred,t,a),d(e,t,i)]):h.IsExtendsTrue(v)?d(v.inferred,t,a):d(e,t,i),{},m)}function mu(e,t,r,n,a,i,m){return T(e,[r,n])?GI(e,t,r,n,a,i,m):vr(r,n,a,i,m)}function Cr(e,t={}){return $("ConstructorParameters",[e],t)}function pu(e,t={}){return g({},Cr(e,t))}function _I(e){return ae(e)?d({},{callstack:[]},ee(e.parameters)):S()}function zI(e,t,r,n){let a=d(e,t,r);return p.Update(_I(a),{},n)}function uu(e,t,r,n){return T(e,[r])?zI(e,t,r,n):Cr(r,n)}function Mr(e,t,r={}){return $("Exclude",[e,t],r)}function cu(e,t,r={}){return g({},Mr(e,t,r))}function du(e,t){return e.reduce((r,n)=>[...r,...lu(n,t)],[])}function lu(e,t){let r=me({},e,t);return h.IsExtendsTrueLike(r)?[]:[e]}function BI(e,t){let r=ie(e)?du(Se(e.enum),t):y(e)?du(Je(e.anyOf),t):lu(e,t);return je(r)}function HI(e,t,r,n,a){let i=d(e,t,r),m=d(e,t,n);return p.Update(BI(i,m),{},a)}function Vn(e,t,r,n,a){return T(e,[r,n])?HI(e,t,r,n,a):Mr(r,n,a)}function Sr(e,t,r={}){return $("Extract",[e,t],r)}function fu(e,t,r={}){return g({},Sr(e,t,r))}function xu(e,t){return e.reduce((r,n)=>[...r,...Iu(n,t)],[])}function Iu(e,t){let r=me({},e,t);return h.IsExtendsTrueLike(r)?[e]:[]}function VI(e,t){let r=ie(e)?xu(Se(e.enum),t):y(e)?xu(Je(e.anyOf),t):Iu(e,t);return je(r)}function JI(e,t,r,n,a){let i=d(e,t,r),m=d(e,t,n);return p.Update(VI(i,m),{},a)}function yu(e,t,r,n,a){return T(e,[r,n])?JI(e,t,r,n,a):Sr(r,n,a)}var WI=new RegExp("^(?:0|[1-9][0-9]*)$");function or(e){let t=`${e}`;return WI.test(t)?parseInt(t):e}function XI(e){return q(or(e))}function gu(e){return e.map(t=>$u(t))}function $u(e){return M(e)?Te(gu(e.allOf)):y(e)?O(gu(e.anyOf)):D(e)?XI(e.const):e}function bu(e,t){let r=$u(t),n=me({},r,be());return h.IsExtendsTrueLike(n)?e:D(t)&&s.IsEqual(t.const,"length")?be():S()}function hu(e,t){let r=_e(e,t);return ze(r)}function Jn(e){return e.reduce((t,r)=>[...t,...ze(r)],[])}function Tu(e){let t=Se(e);return Jn(t)}function Eu(e){let t=_(e);return ze(t)}function ku(e){return[`${e}`]}function Ou(e){let t=he(e);return ze(t)}function ze(e){return se(e)?hu(e.$defs,e.$ref):ie(e)?Tu(e.enum):M(e)?Eu(e.allOf):D(e)?ku(e.const):Q(e)?Ou(e.pattern):y(e)?Jn(e.anyOf):[]}function sr(e){return ze(e)}function ZI(e,t){return t in e?[e[t]]:[]}function YI(e,t){return t.reduce((r,n)=>[...r,...ZI(e,n)],[])}function Pu(e,t){let r=sr(t),n=YI(e,r);return je(n)}function QI(e){return q(or(e))}function wu(e){return e.map(t=>Ma(t))}function Ma(e){return M(e)?Te(wu(e.allOf)):y(e)?O(wu(e.anyOf)):D(e)?QI(e.const):e}function ey(e,t){return e.reduceRight((r,n,a)=>{let i=me({},q(a),t);return h.IsExtendsTrueLike(i)?[n,...r]:r},[])}function ty(e,t){let r=Ma(t),n=ey(e,r);return Mt(n)}function ry(e){return Mt(e)}function Ru(e,t){return D(t)&&s.IsEqual(t.const,"length")?q(e.length):Y(t)||ce(t)?ry(e):ty(e,t)}function ny(e){return e.reduce((t,r)=>Tn(r)?[...t,q(r)]:t,[])}function ir(e){let t=ny(e);return O(t)}function Wt(e,t,r={}){return $("Index",[e,t],r)}function vu(e,t,r={}){let n=s.IsArray(t)?ir(t):t;return g({},Wt(e,n,r))}function Cu(e,t){let r=_e(e,t);return qe(r)}function ay(e,t){let r=s.Keys(e).filter(j=>!s.HasPropertyKey(t,j)),n=s.Keys(t).filter(j=>!s.HasPropertyKey(e,j)),a=s.Keys(e).filter(j=>s.HasPropertyKey(t,j)),i=r.reduce((j,b)=>({...j,[b]:e[b]}),{}),m=n.reduce((j,b)=>({...j,[b]:t[b]}),{}),c=a.reduce((j,b)=>({...j,[b]:_([e[b],t[b]])}),{}),l=p.Assign(i,m);return p.Assign(l,c)}function Mu(e){return e.reduce((t,r)=>ay(t,qe(r)),{})}function Su(e){let t=wp(ee(e));return qe(t)}function oy(e,t){return s.Keys(e).filter(a=>a in t).reduce((a,i)=>({...a,[i]:je([e[i],t[i]])}),{})}function ju(e,t){let[r,...n]=e;return k(r)?ju(n,oy(t,qe(r))):t}function qu(e){let[t,...r]=e;return k(t)?ju(r,qe(t)):K()}function qe(e){return se(e)?Cu(e.$defs,e.$ref):M(e)?Mu(e.allOf):y(e)?qu(e.anyOf):U(e)?Su(e.items):F(e)?e.properties:{}}function mr(e){let t=qe(e);return E(t)}function sy(e){return se(e)||M(e)||y(e)?mr(e):e}function iy(e,t){let r=sy(e);return z(r)?bu(r.items,t):F(r)?Pu(r.properties,t):U(r)?Ru(r.items,t):S()}function my(e,t,r,n,a){let i=d(e,t,r),m=d(e,t,n);return p.Update(iy(i,m),{},a)}function Au(e,t,r,n,a){return T(e,[r,n])?my(e,t,r,n,a):Wt(r,n,a)}function jr(e,t={}){return $("InstanceType",[e],t)}function Lu(e,t={}){return g({},jr(e,t))}function py(e){return ae(e)?e.instanceType:S()}function uy(e,t,r,n){let a=d(e,t,r);return p.Update(py(a),{},n)}function Nu(e,t,r,n={}){return T(e,[r])?uy(e,t,r,n):jr(r,n)}function cy(e,t,r,n,a){let i=Ee(e,{callstack:[]},r),m=Qr(e,{callstack:[]},n),c=_([...i,E(m)]);return p.Update(c,{},a)}function Fu(e,t,r,n,a){return T(e,r)?cy(e,t,r,n,a):Jt(r,n,a)}function Xt(e,t={}){return $("KeyOf",[e],t)}function Du(e,t={}){return g({},Xt(e,t))}function Uu(){return O([be(),Pe(),Ut()])}function Ku(e){return be()}function dy(e){return e.reduce((r,n)=>Tn(n)?[...r,q(or(n))]:K(),[])}function Gu(e){let t=s.Keys(e),r=dy(t);return Mt(r)}function _u(e){return zt(e)}function zu(e){let t=e.map((r,n)=>q(n));return Mt(t)}function ly(e){return se(e)||M(e)||y(e)?mr(e):e}function fy(e){let t=ly(e);return Z(t)?Uu():z(t)?Ku(t.items):F(t)?Gu(t.properties):we(t)?_u(t):U(t)?zu(t.items):S()}function xy(e,t,r,n){let a=d(e,t,r);return p.Update(fy(a),{},n)}function Bu(e,t,r,n){return T(e,[r])?xy(e,t,r,n):Xt(r,n)}function Vt(e,t,r,n,a={}){return $("Mapped",[e,t,r,n],a)}function Hu(e,t,r,n,a={}){return g({},Vt(e,t,r,n,a))}function Iy(e){let t=he(e);return Sa(t)}function Vu(e){return e.reduce((t,r)=>[...t,...Sa(r)],[])}function Sa(e){return ie(e)?Vu(Se(e.enum)):kn(e)||En(e)?[e]:Q(e)?Iy(e.pattern):y(e)?Vu(e.anyOf):[e]}function Ju(e){return Sa(e)}function yy(e){return Q(e)?he(e.pattern):e}function gy(e,t,r,n,a,i){let m=p.Assign(e,{[r.name]:n}),c=d(m,t,a),l=yy(c),v=d(m,t,i);return En(l)||kn(l)?{[l.const]:v}:{}}function $y(e,t,r,n,a,i){return n.reduce((m,c)=>[...m,gy(e,t,r,c,a,i)],[])}function by(e){return e.reduce((t,r)=>[...t,E(r)],[])}function hy(e,t,r,n,a,i){let m=Ju(n),c=$y(e,t,r,m,a,i),l=by(c);return _(l)}function Ty(e,t,r,n,a,i,m){let c=d(e,t,n);return p.Update(hy(e,t,r,c,a,i),{},m)}function Wu(e,t,r,n,a,i,m){return T(e,[n])?Ty(e,t,r,n,a,i,m):Vt(r,n,a,i,m)}function Ey(e,t){return s.Keys(e).filter(n=>t.includes(n)).reduce((n,a)=>({...n,[a]:qp(e,a,e[a])}),{})}function ky(e,t){return s.Keys(e).filter(n=>!t.includes(n)).reduce((n,a)=>({...n,[a]:d(e,{callstack:[]},e[a])}),{})}function Oy(e,t){let r=Ep(e),n=Ey(e,r),a=ky(e,r),i={...n,...a};return p.Update(i,{},t)}function Xu(e,t,r,n){let a=p.Assign(e,r);return Oy(a,n)}function qr(e,t={}){return $("NonNullable",[e],t)}function Zu(e,t={}){return g({},qr(e,t))}function Py(e){let t=O([st(),Bt()]);return Vn({},{callstack:[]},e,t,{})}function wy(e,t,r,n){let a=d(e,t,r);return p.Update(Py(a),{},n)}function Yu(e,t,r,n){return T(e,[r])?wy(e,t,r,n):qr(r,n)}function Wn(e){let t=mr(e);return F(t)?t.properties:K()}function Ar(e,t,r={}){return $("Omit",[e,t],r)}function Qu(e,t,r={}){let n=s.IsArray(t)?ir(t):t;return g({},Ar(e,n,r))}function Ry(e,t){return s.Keys(e).reduce((n,a)=>t.includes(a)?n:{...n,[a]:e[a]},{})}function vy(e,t){let r=Wn(e),n=sr(t),a=Ry(r,n);return E(a)}function Cy(e,t,r,n,a){let i=d(e,t,r),m=d(e,t,n);return p.Update(vy(i,m),{},a)}function ec(e,t,r,n,a){return T(e,[r,n])?Cy(e,t,r,n,a):Ar(r,n,a)}function Zt(e,t){return $("Options",[e,t],{})}function tc(e,t){return g({},Zt(e,t))}function My(e,t,r,n){let a=d(e,t,r);return p.Update(a,{},n)}function rc(e,t,r,n){return T(e,[r])?My(e,t,r,n):Zt(r,n)}function Lr(e,t={}){return $("Parameters",[e],t)}function nc(e,t={}){return g({},Lr(e,t))}function Sy(e){return oe(e)?d({},{callstack:[]},ee(e.parameters)):S()}function jy(e,t,r,n){let a=d(e,t,r);return p.Update(Sy(a),{},n)}function ac(e,t,r,n){return T(e,[r])?jy(e,t,r,n):Lr(r,n)}function Nr(e,t={}){return $("Partial",[e],t)}function oc(e,t={}){return g({},Nr(e,t))}function sc(e,t){let r=_e(e,t),n=lt(r);return Le(p.Assign(e,{[t]:n}),t)}function ic(e){let t=e.map(r=>lt(r));return _(t)}function mc(e){let t=e.map(r=>lt(r));return O(t)}function pc(e){let t=s.Keys(e).reduce((n,a)=>({...n,[a]:cn(e[a])}),{});return E(t)}function lt(e){return se(e)?sc(e.$defs,e.$ref):M(e)?ic(e.allOf):y(e)?mc(e.anyOf):F(e)?pc(e.properties):E({})}function qy(e,t,r,n){let a=d(e,t,r);return p.Update(lt(a),{},n)}function uc(e,t,r,n){return T(e,[r])?qy(e,t,r,n):Nr(r,n)}function Fr(e,t,r={}){return $("Pick",[e,t],r)}function cc(e,t,r={}){let n=s.IsArray(t)?ir(t):t;return g({},Fr(e,n,r))}function Ay(e,t){return s.Keys(e).reduce((n,a)=>t.includes(a)?p.Assign(n,{[a]:e[a]}):n,{})}function Ly(e,t){let r=Wn(e),n=sr(t),a=Ay(r,n);return E(a)}function Ny(e,t,r,n,a){let i=d(e,t,r),m=d(e,t,n);return p.Update(Ly(i,m),{},a)}function dc(e,t,r,n,a){return T(e,[r,n])?Ny(e,t,r,n,a):Fr(r,n,a)}function Dr(e,t={}){return $("ReadonlyType",[e],t)}function lc(e,t={}){return g({},Dr(e,t))}function fc(e){return et(Ce(e))}function xc(e,t){let r=_e(e,t),n=ft(r);return Le(p.Assign(e,{[t]:n}),t)}function Ic(e){let t=e.map(r=>ft(r));return _(t)}function yc(e){let t=s.Keys(e).reduce((n,a)=>({...n,[a]:ln(e[a])}),{});return E(t)}function gc(e){return et(ee(e))}function $c(e){let t=e.map(r=>ft(r));return O(t)}function ft(e){return z(e)?fc(e.items):se(e)?xc(e.$defs,e.$ref):M(e)?Ic(e.allOf):F(e)?yc(e.properties):U(e)?gc(e.items):y(e)?$c(e.anyOf):e}function Fy(e,t,r,n){let a=d(e,t,r);return p.Update(ft(a),{},n)}function bc(e,t,r,n){return T(e,[r])?Fy(e,t,r,n):Dr(r,n)}function hc(e){return ye(Me,e)}function Tc(e){return E({true:e,false:e})}function Ec(e,t){let r=zr(e);return xt(r,t)}function kc(e,t){return ye(Kt,t)}function Oc(e,t){let r=_(e);return xt(r,t)}function Pc(e,t){return s.IsString(e)||s.IsNumber(e)?E({[e]:t}):s.IsEqual(e,!1)?E({false:t}):s.IsEqual(e,!0)?E({true:t}):E({})}function wc(e,t){return ye(Gt,t)}function Rc(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?ye(e.pattern.toString(),t):ye(Me,t)}function vc(e,t){let r=hr(e);return wn(r)?xt(he(e),t):ye(e,t)}function Dy(e){return e.some(t=>le(t)||Y(t)||ce(t))}function Uy(e,t){return s.IsEqual(Dy(e),!0)?ye(Me,t):void 0}function Ky(e,t){return e.reduce((r,n)=>D(n)&&(s.IsString(n.const)||s.IsNumber(n.const))?{...r,[n.const]:t}:r,{})}function Gy(e,t){let r=Ky(e,t);return E(r)}function Cc(e,t){let r=Je(e),n=Uy(r,t);return k(n)?n:Gy(r,t)}function xt(e,t){return Z(e)?hc(t):Oe(e)?Tc(t):ie(e)?Ec(e.enum,t):ce(e)?kc(e,t):M(e)?Oc(e.allOf,t):D(e)?Pc(e.const,t):Y(e)?wc(e,t):y(e)?Cc(e.anyOf,t):le(e)?Rc(e,t):Q(e)?vc(e.pattern,t):E({})}function _y(e,t,r,n,a){let i=d(e,t,r),m=d(e,t,n);return p.Update(xt(i,m),{},a)}function Mc(e,t,r,n,a){return T(e,[r])?_y(e,t,r,n,a):Tr(r,n,a)}function Sc(e,t,r,n){return n in e?Bn([n],e,e[n])?r:d(e,t,e[n]):r}function jc(e,t){let r=_e(e,t),n=It(r);return Le(p.Assign(e,{[t]:n}),t)}function qc(e){let t=e.map(r=>It(r));return _(t)}function Ac(e){let t=e.map(r=>It(r));return O(t)}function Lc(e){let t=s.Keys(e).reduce((n,a)=>({...n,[a]:Lt(e[a])}),{});return E(t)}function It(e){return se(e)?jc(e.$defs,e.$ref):M(e)?qc(e.allOf):y(e)?Ac(e.anyOf):F(e)?Lc(e.properties):E({})}function Ur(e,t={}){return $("Required",[e],t)}function Nc(e,t={}){return g({},Ur(e,t))}function zy(e,t,r,n){let a=d(e,t,r);return p.Update(It(a),{},n)}function Fc(e,t,r,n){return T(e,[r])?zy(e,t,r,n):Ur(r,n)}function Kr(e,t={}){return $("ReturnType",[e],t)}function Dc(e,t={}){return g({},Kr(e,t))}function By(e){return oe(e)?e.returnType:S()}function Hy(e,t,r,n){let a=d(e,t,r);return p.Update(By(a),{},n)}function Uc(e,t,r,n){return T(e,[r])?Hy(e,t,r,n):Kr(r,n)}function Vy(e){return e.join("|")}function Jy(e){return e.slice(1,e.length-1)}function Wy(e,t,r){return yt(t,`${r}${e}`)}function Xy(e,t){return yt(e,`${t}${wo}`)}function Zy(e,t){return yt(e,`${t}${hn}`)}function Yy(e,t){return yt(e,`${t}${On}`)}function Qy(e,t){return qa(O([q("false"),q("true")]),e,t)}function eg(e,t){return yt(e,`${t}${Pn}`)}function tg(e,t,r){return yt(t,`${r}${Jy(e)}`)}function rg(e,t,r){let n=Se(e);return ja(n,t,r)}function ja(e,t,r,n=[]){let[a,...i]=e;return k(a)?ja(i,t,r,[...n,qa(a,[],"")]):yt(t,`${r}(${Vy(n)})`)}function qa(e,t,r){return ie(e)?rg(e.enum,t,r):ce(e)?Zy(t,r):D(e)?Wy(e.const,t,r):Ne(e)?Xy(t,r):Oe(e)?Qy(t,r):Y(e)?Yy(t,r):le(e)?eg(t,r):Q(e)?tg(e.pattern,t,r):y(e)?ja(e.anyOf,t,r):co}function yt(e,t){let[r,...n]=e;return k(r)?qa(r,n,t):t}function ng(e){return`^${yt(e,"")}$`}function Kc(e){let t=ng(e);return Rn(t)}function ag(e,t,r,n){let a=Ee(e,t,r);return p.Update(Kc(a),{},n)}function Gc(e,t,r,n){return T(e,r)?ag(e,t,r,n):Er(r,n)}function og(e){return mt(e)?U(e.items)?Aa(e.items.items):V(e.items)?[e]:X(e.items)?[e]:[S()]:[e]}function Aa(e){return e.reduce((r,n)=>[...r,...og(n)],[])}function sg(e,t){return t in e}function ig(e,t){return M(t)?T(e,t.allOf):y(t)?T(e,t.anyOf):X(t)?sg(e,t.$ref):!0}function T(e,t){let[r,...n]=t;return k(r)?ig(e,r)?T(e,n):!1:!0}function tn(e,t,r){return so(e)?tn(e.type,"remove",r):ro(e)?tn(e.type,t,"remove"):ao(e)?tn(e.type,"add",r):eo(e)?tn(e.type,t,"add"):[e,t,r]}function mg(e,t){return s.IsEqual(e,"remove")?dn(t):s.IsEqual(e,"add")?Ie(t):t}function pg(e,t){return s.IsEqual(e,"remove")?Lt(t):s.IsEqual(e,"add")?xe(t):t}function Qr(e,t,r){return s.Keys(r).reduce((n,a)=>({...n,[a]:d(e,t,r[a])}),{})}function zn(e,t,r){let n=Ee(e,t,r);return Aa(n)}function Ee(e,t,r){return r.map(n=>d(e,t,n))}function ug(e,t,r,n,a){return s.IsEqual(r,"Awaited")?Jp(e,t,n[0],a):s.IsEqual(r,"Capitalize")?nu(e,t,n[0],a):s.IsEqual(r,"Conditional")?mu(e,t,n[0],n[1],n[2],n[3],a):s.IsEqual(r,"ConstructorParameters")?uu(e,t,n[0],a):s.IsEqual(r,"Evaluate")?Np(e,t,n[0],a):s.IsEqual(r,"Exclude")?Vn(e,t,n[0],n[1],a):s.IsEqual(r,"Extract")?yu(e,t,n[0],n[1],a):s.IsEqual(r,"Index")?Au(e,t,n[0],n[1],a):s.IsEqual(r,"InstanceType")?Nu(e,t,n[0],a):s.IsEqual(r,"Interface")?Fu(e,t,n[0],n[1],a):s.IsEqual(r,"KeyOf")?Bu(e,t,n[0],a):s.IsEqual(r,"Lowercase")?au(e,t,n[0],a):s.IsEqual(r,"Mapped")?Wu(e,t,n[0],n[1],n[2],n[3],a):s.IsEqual(r,"Module")?Xu(e,t,n[0],a):s.IsEqual(r,"NonNullable")?Yu(e,t,n[0],a):s.IsEqual(r,"Pick")?dc(e,t,n[0],n[1],a):s.IsEqual(r,"Options")?rc(e,t,n[0],n[1]):s.IsEqual(r,"Parameters")?ac(e,t,n[0],a):s.IsEqual(r,"Partial")?uc(e,t,n[0],a):s.IsEqual(r,"Omit")?ec(e,t,n[0],n[1],a):s.IsEqual(r,"ReadonlyType")?bc(e,t,n[0],a):s.IsEqual(r,"Record")?Mc(e,t,n[0],n[1],a):s.IsEqual(r,"Required")?Fc(e,t,n[0],a):s.IsEqual(r,"ReturnType")?Uc(e,t,n[0],a):s.IsEqual(r,"TemplateLiteral")?Gc(e,t,n[0],a):s.IsEqual(r,"Uncapitalize")?ou(e,t,n[0],a):s.IsEqual(r,"Uppercase")?su(e,t,n[0],a):$(r,n,a)}function d(e,t,r){let n=Et(r),a=tn(r,kt(r)?"add":"none",pe(r)?"add":"none"),i=In(a[0])?a[0].Clone():a[0],m=X(i)?Sc(e,t,i,i.$ref):z(i)?Ce(d(e,t,i.items),fn(i)):ge(i)?Ae(d(e,t,i.iteratorItems),io(i)):ar(i)?Hn(e,t,i.target,i.arguments):ae(i)?tt(Ee(e,t,i.parameters),d(e,t,i.instanceType),po(i)):Qe(i)?ug(e,t,i.action,i.parameters,i.options):oe(i)?rt(Ee(e,t,i.parameters),d(e,t,i.returnType),uo(i)):M(i)?Te(Ee(e,t,i.allOf),bo(i)):$e(i)?Fe(d(e,t,i.iteratorItems),vo(i)):F(i)?E(Qr(e,t,i.properties),xo(i)):de(i)?De(d(e,t,i.item),Mo(i)):we(i)?Do(_t(i),d(e,t,Ue(i))):mt(i)?wt(d(e,t,i.items)):U(i)?ee(zn(e,t,i.items),Ko(i)):y(i)?O(Ee(e,t,i.anyOf),Io(i)):i,c=n?et(m):m;return mg(a[1],pg(a[2],c))}function g(e,t){return d(e,{callstack:[]},t)}function Gr(e,t={}){return $("Awaited",[e],t)}function _c(e,t={}){return g({},Gr(e,t))}function ma(e,t={}){return $("Evaluate",[e],t)}function zc(e,t={}){return g({},ma(e,t))}function pa(e,t={}){return $("Module",[e],t)}function Bc(e,t={}){return g({},pa(e,t))}function Hc(...e){let[t,r,n]=ot.Match(e,{2:(m,c)=>s.IsString(m)?[{},m,c]:[m,c,{}],3:(m,c,l)=>[m,c,l],1:m=>[{},m,{}]}),a=Nm(r),i=s.IsArray(a)&&s.IsEqual(a.length,2)?d(t,{callstack:[]},a[0]):S();return p.Update(i,{},n)}var H={};qt(H,{Any:()=>Ft,Array:()=>Ce,AsyncIterator:()=>Ae,Awaited:()=>_c,Base:()=>xn,BigInt:()=>$r,Boolean:()=>bn,Call:()=>Hp,Capitalize:()=>Qp,Codec:()=>$n,Conditional:()=>iu,Constructor:()=>tt,ConstructorParameters:()=>pu,Cyclic:()=>Le,Decode:()=>ko,DecodeBuilder:()=>gr,Encode:()=>Oo,EncodeBuilder:()=>yr,Enum:()=>$o,Evaluate:()=>zc,Exclude:()=>cu,Extends:()=>me,ExtendsResult:()=>h,Extract:()=>fu,Function:()=>rt,Generic:()=>nt,Identifier:()=>br,Immutable:()=>et,Index:()=>vu,Infer:()=>Ir,InstanceType:()=>Lu,Instantiate:()=>g,Integer:()=>Ot,Interface:()=>hp,Intersect:()=>Te,IsAny:()=>Z,IsArray:()=>z,IsAsyncIterator:()=>ge,IsBase:()=>In,IsBigInt:()=>Ne,IsBoolean:()=>Oe,IsCall:()=>ar,IsCodec:()=>gn,IsConstructor:()=>ae,IsCyclic:()=>se,IsEnum:()=>ie,IsFunction:()=>oe,IsGeneric:()=>Nt,IsIdentifier:()=>Ro,IsImmutable:()=>Et,IsInfer:()=>V,IsInteger:()=>ce,IsIntersect:()=>M,IsIterator:()=>$e,IsKind:()=>f,IsLiteral:()=>D,IsNever:()=>at,IsNull:()=>Dt,IsNumber:()=>Y,IsObject:()=>F,IsOptional:()=>pe,IsParameter:()=>Co,IsPromise:()=>de,IsReadonly:()=>kt,IsRecord:()=>we,IsRef:()=>X,IsRefine:()=>aa,IsRest:()=>mt,IsSchema:()=>k,IsString:()=>le,IsSymbol:()=>it,IsTemplateLiteral:()=>Q,IsThis:()=>Uo,IsTuple:()=>U,IsUndefined:()=>Ht,IsUnion:()=>y,IsUnknown:()=>re,IsUnsafe:()=>_o,IsVoid:()=>Ke,Iterator:()=>Fe,KeyOf:()=>Du,Literal:()=>q,Lowercase:()=>eu,Mapped:()=>Hu,Module:()=>Bc,Never:()=>S,NonNullable:()=>Zu,Null:()=>st,Number:()=>be,Object:()=>E,Omit:()=>Qu,Optional:()=>cn,Options:()=>tc,Parameter:()=>Pt,Parameters:()=>nc,Partial:()=>oc,Pick:()=>cc,Promise:()=>De,Readonly:()=>ln,ReadonlyType:()=>lc,Record:()=>vn,RecordKey:()=>zt,RecordKeyAsPattern:()=>_t,RecordValue:()=>Ue,Ref:()=>He,Refine:()=>Po,Required:()=>Nc,Rest:()=>wt,ReturnType:()=>Dc,Script:()=>Hc,String:()=>Pe,Symbol:()=>Ut,TemplateLiteral:()=>Um,This:()=>Cn,Tuple:()=>ee,Uncapitalize:()=>tu,Undefined:()=>Bt,Union:()=>O,Unknown:()=>ue,Unsafe:()=>Go,Uppercase:()=>ru,Void:()=>Mn});import{existsSync as ad,readFileSync as _g}from"node:fs";import{homedir as sd}from"node:os";import{join as cr}from"node:path";import{spawn as zg}from"node:child_process";var cg=new Set(["ECONNREFUSED","ConnectionRefused"]);function La(e,t){if(!e||typeof e!="object"||t.has(e))return!1;if(t.add(e),e instanceof Error&&e.message.includes("ECONNREFUSED"))return!0;let r=e;return typeof r.code=="string"&&cg.has(r.code)||La(r.cause,t)?!0:Array.isArray(r.errors)&&r.errors.some(n=>La(n,t))}function Vc(e){return La(e,new Set)?!0:e instanceof Error&&e.message.includes("ECONNREFUSED")}import{homedir as dg}from"os";import{join as lg}from"path";function pr(e,t=process.platform,r=dg()){return typeof e!="string"||e.length===0?e:e==="~"?r:e.startsWith("~/")||t==="win32"&&e.startsWith("~\\")?lg(r,e.slice(2)):e}var ur="MEMINDEX_",fg="AGENT_MEM_",rn=[fg];function Xn(e){return e.startsWith(ur)||rn.some(t=>e.startsWith(t))}function Na(e){if(!e.startsWith(ur))return[];let t=e.slice(ur.length);return rn.map(r=>r+t)}function xg(e=process.env){for(let t of rn)for(let r of Object.keys(e)){if(!r.startsWith(t))continue;let n=ur+r.slice(t.length);e[n]===void 0&&(e[n]=e[r])}}function Jc(e){let t=null;for(let r of rn)for(let n of Object.keys(e)){if(!n.startsWith(r))continue;let a=ur+n.slice(r.length);(t??e)[a]===void 0&&(t??={...e},t[a]=e[n])}return t??e}xg();import{randomBytes as Zc}from"node:crypto";import{constants as Yc,openSync as ed,closeSync as td,readFileSync as Sg,writeFileSync as jg,fstatSync as qg,fchmodSync as Ag,fsyncSync as Lg,linkSync as Ng,unlinkSync as Fg,mkdirSync as Dg}from"node:fs";import{join as Da}from"node:path";import{join as gt,dirname as hg,basename as Tg}from"path";import{homedir as Xc}from"os";import{existsSync as Eg,mkdirSync as VV}from"fs";import{fileURLToPath as kg}from"url";import{closeSync as kV,existsSync as OV,fsyncSync as PV,lstatSync as wV,mkdirSync as RV,openSync as vV,readFileSync as Ig,readlinkSync as CV,realpathSync as MV,renameSync as SV,statSync as jV,unlinkSync as qV,writeSync as AV}from"fs";var bV=Promise.resolve();var NV=process.platform==="win32";function yg(e){return e.replace(/^\uFEFF/,"")}function gg(e){return JSON.parse(yg(e))}function Fa(e){return gg(Ig(e,"utf-8"))}var $g=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function bg(e){let t=e.env;return $g(t)&&Object.keys(t).some(Xn)?"nested":"flat"}function Wc(e){return bg(e)==="nested"?e.env:e}function Og(){return typeof __dirname<"u"?__dirname:hg(kg(import.meta.url))}var e3=Og();function Pg(e){let t=process.env.MEMINDEX_TEST_FORBIDDEN_DATA_DIR;if(t&&e===t)throw new Error(`A test resolved the real data folder ${e}. Point MEMINDEX_DATA_DIR at a temporary directory (and pass env: process.env to any child process the test starts).`);return e}function nn(){return Pg(wg())}function wg(){if(process.env.MEMINDEX_DATA_DIR)return pr(process.env.MEMINDEX_DATA_DIR);let e=gt(Xc(),".memindex"),t=gt(e,"settings.json");try{if(Eg(t)){let r=Fa(t);if(r===null||typeof r!="object"||Array.isArray(r))return e;let n=Jc(Wc(r));if(typeof n.MEMINDEX_DATA_DIR=="string"&&n.MEMINDEX_DATA_DIR)return pr(n.MEMINDEX_DATA_DIR)}}catch{}return e}var Zn=nn(),Rg=gt(Xc(),".claude"),vg=process.env.CLAUDE_CONFIG_DIR||Rg,t3=gt(vg,"plugins","marketplaces","memindex"),r3=gt(Zn,"logs"),n3=gt(Zn,"settings.json"),Cg="memindex.db";var a3=gt(Zn,Cg),Mg=gt(Zn,"observer-sessions"),o3=Tg(Mg);var Ug="X-Memindex-Secret",rd="worker-secret",Kg=/^[a-f0-9]{64}$/;function Qc(e=nn()){let t=ed(Da(e,rd),Yc.O_RDONLY|(Yc.O_NOFOLLOW??0));try{let r=qg(t);if(!r.isFile()||process.getuid&&r.uid!==process.getuid()||process.platform!=="win32"&&(r.mode&63)!==0)throw new Error("Worker secret must be an owner-only file");let n=Sg(t,"utf8");if(!Kg.test(n))throw new Error("Invalid worker secret");return n}finally{td(t)}}function Gg(e=nn()){Dg(e,{recursive:!0,mode:448});let t=Da(e,rd);try{return Qc(e)}catch(a){if(a.code!=="ENOENT")throw a}let r=Da(e,`.worker-secret-${Zc(16).toString("hex")}`),n=ed(r,"wx",384);try{Ag(n,384),jg(n,Zc(32).toString("hex")),Lg(n)}finally{td(n)}try{try{Ng(r,t)}catch(a){if(a.code!=="EEXIST")throw a}}finally{Fg(r)}return Qc(e)}function nd(e,t=nn()){if(!["POST","PUT","PATCH","DELETE"].includes((e.method??"GET").toUpperCase()))return e;let r=new Headers(e.headers);return r.set(Ug,Gg(t)),{...e,headers:r,redirect:"error"}}var Ua=5e3;function od(){let e=pr(process.env.MEMINDEX_DATA_DIR||process.env.AGENT_MEM_DATA_DIR||cr(sd(),".memindex")),t={};try{let c=JSON.parse(_g(cr(e,"settings.json"),"utf8").replace(/^\uFEFF/,"")),l=c?.env;t=l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).some(Xn)?l:c??{}}catch{}let r=c=>typeof t[c]=="string"&&t[c]?String(t[c]):"",n=(c,l)=>process.env[c]||Na(c).map(v=>process.env[v]).find(Boolean)||r(c)||Na(c).map(r).find(Boolean)||l,a=n("MEMINDEX_WORKER_HOST","127.0.0.1"),i=a==="localhost"?"127.0.0.1":a,m=n("MEMINDEX_WORKER_PORT",String(38700+(process.getuid?.()??77)%100));return"http://"+(i.includes(":")&&!i.startsWith("[")?"["+i+"]":i)+":"+m}var an;function Bg(){if(an)return an;let e=cr(process.env.CLAUDE_CONFIG_DIR||cr(sd(),".claude"),"plugins","marketplaces","memindex"),t=cr(e,"plugin","scripts","bun-runner.js"),r=cr(e,"plugin","scripts","worker-service.cjs");return!ad(t)||!ad(r)?Promise.reject(new Error("Run npx memindex install to install the worker.")):(an=new Promise((a,i)=>{let m=zg(process.execPath,[t,r,"start"],{stdio:"ignore",windowsHide:!0,timeout:15e3});m.once("error",i),m.once("close",c=>c===0?a():i(new Error("memindex worker could not start")))}).finally(()=>{an=void 0}),an)}function id(){let e=od();return{reset(){e=od()},async ready(){try{let t=await fetch(e+"/api/health",{signal:AbortSignal.timeout(Ua)});if(t.ok)return;throw new Error("memindex health check returned "+t.status)}catch(t){if(!Vc(t))throw t;await Bg()}},async request(t,r={}){let n=await fetch(e+t,nd({...r,signal:r.signal?AbortSignal.any([r.signal,AbortSignal.timeout(Ua)]):AbortSignal.timeout(Ua)}));if(!n.ok)throw new Error("memindex "+t+" returned "+n.status);return n},async post(t,r){return this.request(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r)})}}}function on(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
9
- `):""}function Hg(e){let t=id(),r,n=!1,a=(b,C)=>{!n&&b.hasUI&&b.ui&&(b.ui.notify("MemIndex is unavailable. Run npx memindex doctor. "+String(C),"warning"),n=!0)},i=(b,C,x)=>(b.queue=b.queue.then(x).catch(J=>a(C,J)),b.queue),m=async(b,C)=>{let x=C.sessionManager.getSessionId();if(!x||!C.cwd){r=void 0;return}let J={id:x,cwd:C.cwd,memory:"",anchored:!1,excluded:!1,queue:Promise.resolve(),lastAssistant:"",needsSummary:!1,initialized:!1};r=J,n=!1,t.reset();try{await t.ready();let Re=new URLSearchParams({cwd:J.cwd,platform_source:"pi"});J.memory=(await(await t.request("/api/context/inject?"+Re)).text()).trim()}catch(Re){a(C,Re)}};e.on("session_start",m),e.on("session_switch",m),e.on("session_fork",m);let c=(b,C)=>{let x=r;if(x)return i(x,C,async()=>{x.entryId=void 0,x.initialized=!1,x.anchored=!1,x.excluded=!0,x.needsSummary=!1,x.lastAssistant=""})};e.on("before_agent_start",c),e.on("session_tree",c),e.on("context_with_system",async(b,C)=>{let x=r,J=b.messages;if(!x)return;if(!Array.isArray(J)||J[0]?.role!=="system"||typeof J[0].content!="string"){await c(b,C);return}let Re=J[0].content,Xe=[...J].reverse().find(te=>te.role==="user"),$t=on(Xe?.content),bt=()=>{if(r!==x||C.sessionManager.getSessionId()!==x.id||C.cwd!==x.cwd||typeof C.sessionManager.getBranch!="function")return;let te=C.sessionManager.getBranch();if(!Array.isArray(te))return;let ke=[...te].reverse().find(dr=>dr.type==="message"&&dr.message?.role==="user");if(!(!ke||typeof ke.id!="string"||!/^[^\s\x00-\x1f\x7f]{1,256}$/.test(ke.id)||!Xe||typeof Xe.timestamp!="number"||!Number.isFinite(Xe.timestamp)||ke.message?.timestamp!==Xe.timestamp||on(ke.message.content)!==$t))return ke};if(await i(x,C,async()=>{try{let te=bt();if(!te||!$t.trim()){x.anchored=!1,x.excluded=!0,x.initialized=!1;return}if(x.entryId!==te.id&&(x.entryId=te.id,x.initialized=!1,x.anchored=!1,x.excluded=!0,x.needsSummary=!1,x.lastAssistant=""),x.initialized)return;if((await(await t.request("/api/sessions/native-prompt-capability")).json()).nativePromptId!==1)throw new Error("Upgrade the worker for native Pi prompt capture.");if(bt()?.id!==te.id)return;let ht=await(await t.post("/api/sessions/init",{contentSessionId:x.id,cwd:x.cwd,prompt:$t,platformSource:"pi",nativePromptId:te.id})).json();if(bt()?.id!==te.id)return;if(ht.skipped===!0&&ht.reason!=="duplicate"){x.initialized=!0,x.excluded=!0;return}if(ht.nativePromptId!==te.id||typeof ht.sessionDbId!="number")throw new Error("The worker did not acknowledge the persisted Pi user-entry ID.");x.initialized=!0,x.anchored=ht.nativePromptCurrent===!0,x.excluded=!x.anchored,x.needsSummary=x.anchored}catch(te){throw x.anchored=!1,x.excluded=!0,x.initialized=!1,te}}),r!==x||!x.anchored||x.excluded||!x.memory)return;let[St,...jt]=J;return{messages:[{...St,content:Re+`
8
+ `,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]),Fm=(e,t=[])=>o(o(Ea(e),([r,n])=>o(Px(n),([a,s])=>[[r,a],s])),([r,n])=>Fm(n,[...t,r]),()=>[t,e]),wx=e=>o(o(Fm(e),([t,r])=>o(o(o(Ea(r),([n,a])=>[[n],a]),([n,a])=>[n,a],()=>o([[],r],([n,a])=>[n,a],()=>[])),([n,a])=>[[t,n],a])),([t,r])=>[_i(t),r]),Ea=e=>o(o(Ox(e),([t,r])=>o(o(hx(r),([n,a])=>[n,a],()=>o(Tx(r),([n,a])=>[n,a],()=>o(Ex(r),([n,a])=>[n,a],()=>o(kx(r),([n,a])=>[n,a],()=>[])))),([n,a])=>o(dm(a),([s,m])=>[[t,n,s],m]))),([t,r])=>[Gi(t),r]),Rx=e=>o(o(Ea(e),([t,r])=>o(wx(r),([n,a])=>[[t,n],a])),([t,r])=>[zi(t),r]),Um=e=>o(o(Rx(e),([t,r])=>[t,r],()=>o(Mf(e),([t,r])=>[t,r],()=>o(A(e),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]);function Km(e){let t=$a(`\`${e}\``);return i.IsEqual(t.length,2)?t[0]:K()}function Er(e,t={}){return $("TemplateLiteral",[e],t)}function _m(e){return g({},Er(e,{}))}function Cx(e){let t=Km(e);return _m(t)}function Gm(e,t={}){let r=i.IsString(e)?Cx(e):_m(e);return p.Update(r,{},t)}function Q(e){return f(e,"TemplateLiteral")}var h={};qt(h,{ExtendsFalse:()=>P,ExtendsTrue:()=>I,ExtendsUnion:()=>ka,IsExtendsFalse:()=>Mx,IsExtendsTrue:()=>Bm,IsExtendsTrueLike:()=>tr,IsExtendsUnion:()=>zm,Match:()=>W,TakeLeft:()=>fe});function ka(e){return p.Create({"~kind":"ExtendsUnion"},{inferred:e})}function zm(e){return i.IsObject(e)&&i.HasPropertyKey(e,"~kind")&&i.HasPropertyKey(e,"inferred")&&i.IsEqual(e["~kind"],"ExtendsUnion")&&i.IsObject(e.inferred)}function I(e){return p.Create({"~kind":"ExtendsTrue"},{inferred:e})}function Bm(e){return i.IsObject(e)&&i.HasPropertyKey(e,"~kind")&&i.HasPropertyKey(e,"inferred")&&i.IsEqual(e["~kind"],"ExtendsTrue")&&i.IsObject(e.inferred)}function P(){return p.Create({"~kind":"ExtendsFalse"},{})}function Mx(e){return i.IsObject(e)&&i.HasPropertyKey(e,"~kind")&&i.IsEqual(e["~kind"],"ExtendsFalse")}function tr(e){return zm(e)||Bm(e)}function W(e,t,r){return tr(e)?t(e.inferred):r()}function fe(e,t,r){return i.IsEqual(e.length,0)?r():t(e[0],e.slice(1))}function Sx(e){return i.IsString(e)||i.IsNumber(e)?q(e):i.IsNull(e)?st():S()}function Se(e){return e.map(r=>Sx(r))}function zr(e){let t=Se(e);return O(t)}function Hm(e){return zr(e.enum)}function jx(e,t,r,n){return W(D(e,r,n),a=>I(p.Assign(p.Assign(e,a),{[t]:r})),()=>P())}function qx(e,t){return I(e)}function Ax(e,t,r){let n=zr(r);return D(e,t,n)}function Vm(e,t,r){return fe(r,(n,a)=>W(D(e,t,n),s=>Vm(s,t,a),()=>P()),()=>I(e))}function Lx(e,t,r){let n=he(r);return D(e,t,n)}function Jm(e,t,r){return fe(r,(n,a)=>W(D(e,t,n),s=>I(s),()=>Jm(e,t,a)),()=>P())}function R(e,t,r){return Z(r)?qx(e,t):ie(r)?Ax(e,t,r.enum):V(r)?jx(e,r.name,t,r.extends):M(r)?Vm(e,t,r.allOf):Q(r)?Lx(e,t,r.pattern):y(r)?Jm(e,t,r.anyOf):re(r)?I(e):P()}function Wm(e,t,r){return V(r)?R(e,t,r):Z(r)?I(e):re(r)?I(e):ka(e)}function Dx(e,t){let r=Tt(e),n=Tt(t);return r&&n||!r&&n?!0:!(r&&!n)}function Xm(e,t,r,n){return z(n)?Dx(t,n)?D(e,r,n.items):P():R(e,t,n)}function Zm(e,t,r){return ge(r)?D(e,t,r.iteratorItems):R(e,Ae(t),r)}function Ym(e,t,r){return De(r)?I(e):R(e,t,r)}function Qm(e,t,r){return Oe(r)?I(e):R(e,t,r)}function Nx(e,t,r,n,a){let s=V(n)?t:n,m=V(n)?n:t,c=pe(t),l=pe(n);return!c&&l?P():W(D(e,s,m),v=>Br(v,r,a),()=>P())}function Fx(e,t,r,n){return fe(n,(a,s)=>Nx(e,t,r,a,s),()=>pe(t)?I(e):P())}function Ux(e,t,r){return fe(t,(n,a)=>Fx(e,n,a,r),()=>I(e))}function Br(e,t,r){return Ux(e,t,r)}function _n(e,t,r){return Ke(r)?I(e):D(e,t,r)}function ep(e,t,r,n){return Z(n)?I(e):re(n)?I(e):ae(n)?W(Br(e,t,n.parameters),a=>_n(a,r,n.instanceType),()=>P()):P()}function tp(e,t,r){return D(e,Hm(t),r)}function rp(e,t,r,n){return Z(n)?I(e):re(n)?I(e):oe(n)?W(Br(e,t,n.parameters),a=>_n(a,r,n.returnType),()=>P()):P()}function np(e,t,r){return ce(r)?I(e):Y(r)?I(e):R(e,t,r)}function ap(e,t,r){let n=G(t);return D(e,n,r)}function op(e,t,r){return $e(r)?D(e,t,r.iteratorItems):R(e,Ne(t),r)}function Gn(e,t,r){return t===r?I(e):P()}function Kx(e,t,r){return F(r)?Gn(e,t,r.const):De(r)?I(e):R(e,q(t),r)}function _x(e,t,r){return F(r)?Gn(e,t,r.const):Oe(r)?I(e):R(e,q(t),r)}function Gx(e,t,r){return F(r)?Gn(e,t,r.const):Y(r)?I(e):R(e,q(t),r)}function zx(e,t,r){return F(r)?Gn(e,t,r.const):le(r)?I(e):R(e,q(t),r)}function sp(e,t,r){return i.IsBigInt(t.const)?Kx(e,t.const,r):i.IsBoolean(t.const)?_x(e,t.const,r):i.IsNumber(t.const)?Gx(e,t.const,r):i.IsString(t.const)?zx(e,t.const,r):K()}function ip(e,t,r){return V(r)?R(e,t,r):I(e)}function mp(e,t,r){return Ft(r)?I(e):R(e,t,r)}function pp(e,t,r){return Y(r)?I(e):R(e,t,r)}function Bx(e,t,r){return pe(t)?pe(r)?I(e):P():I(e)}function Hx(e,t,r){return V(r)&&at(r.extends)?P():W(D(e,t,r),n=>Bx(n,t,r),()=>P())}function Vx(e,t){return e.reduce((r,n)=>n in t?tr(t[n])?{...r,...t[n].inferred}:K():K(),{})}function Jx(e,t,r){let n={};for(let m of i.Keys(r))n[m]=m in t?Hx({},t[m],r[m]):pe(r[m])?V(r[m])?I(p.Assign(e,{[r[m].name]:r[m].extends})):I(e):P();let a=i.Values(n).every(m=>tr(m)),s=a?Vx(i.Keys(n),n):{};return a?I(s):P()}function Wx(e,t,r){let n=Jx(e,t,r);return tr(n)?I(p.Assign(e,n.inferred)):P()}function Xx(e,t,r){return Wx(e,t,r)}function up(e,t,r){return N(r)?Xx(e,t,r.properties):R(e,E(t),r)}function cp(e,t,r){return de(r)?D(e,t,r.item):R(e,Fe(t),r)}function dp(e,t,r){return le(r)?I(e):R(e,t,r)}function lp(e,t,r){return it(r)?I(e):R(e,t,r)}function fp(e,t,r){let n=he(t);return D(e,n,r)}function Oa(e,t){return p.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function Hr(e){return i.IsObject(e)&&i.HasPropertyKey(e,"~kind")&&i.HasPropertyKey(e,"name")&&i.HasPropertyKey(e,"type")&&i.IsEqual(e["~kind"],"Inferrable")&&i.IsString(e.name)&&i.IsObject(e.type)}function Pa(e){return mt(e)?V(e.items)?z(e.items.extends)?Oa(e.items.name,e.items.extends.items):re(e.items.extends)?Oa(e.items.name,e.items.extends):void 0:K():void 0}function zn(e){return V(e)?Oa(e.name,e.extends):void 0}function wa(e,t,r=[]){return fe(e,(n,a)=>W(D({},n,t),()=>wa(a,t,[...r,n]),()=>{}),()=>r)}function xp(e,t,r,n){let a=wa(r,n);return i.IsArray(a)?I(p.Assign(e,{[t]:ee(a)})):P()}function Bn(e,t,r,n){let a=wa(r,n);return i.IsArray(a)?I(p.Assign(e,{[t]:O(a)})):P()}function Zx(e){return[...e].reverse()}function Ra(e,t){return t?Zx(e):e}function Yx(e){let t=e.length>0?e[0]:void 0,r=k(t)?Pa(t):void 0;return k(r)}function Qx(e,t,r,n,a,s){return W(D(e,r,a),m=>Ip(m,t,n,s),()=>P())}function eI(e,t,r,n,a){let s=Pa(n);return Hr(s)?xp(e,s.name,Ra(r,t),s.type):fe(r,(m,c)=>Qx(e,t,m,c,n,a),()=>P())}function tI(e,t,r,n){return fe(n,(a,s)=>eI(e,t,r,a,s),()=>i.IsEqual(r.length,0)?I(e):P())}function Ip(e,t,r,n){return tI(e,t,r,n)}function rI(e,t,r){let n=Hn(e,{callstack:[]},r),a=Yx(n);return Ip(e,a,Ra(t,a),Ra(n,a))}function yp(e,t,r){let n=zn(r);return Hr(n)?Bn(e,n.name,t,n.type):fe(t,(a,s)=>W(D(e,a,r),m=>yp(m,s,r),()=>P()),()=>I(e))}function gp(e,t,r){let n=Hn(e,{callstack:[]},t);return U(r)?rI(e,n,r.items):z(r)?yp(e,n,r.items):R(e,ee(n),r)}function $p(e,t,r){return Ke(r)?I(e):Ht(r)?I(e):R(e,t,r)}function bp(e,t,r){return fe(r,(n,a)=>W(D(e,t,n),s=>I(s),()=>bp(e,t,a)),()=>P())}function va(e,t,r){return fe(t,(n,a)=>W(bp(e,n,r),s=>va(s,a,r),()=>P()),()=>I(e))}function hp(e,t,r){let n=zn(r);return Hr(n)?Bn(e,n.name,t,n.type):y(r)?va(e,t,r.anyOf):va(e,t,[r])}function Tp(e,t,r){return V(r)?R(e,t,r):Z(r)?I(e):re(r)?I(e):P()}function Ep(e,t,r){return Ke(r)?I(e):R(e,t,r)}function D(e,t,r){return Z(t)?Wm(e,t,r):z(t)?Xm(e,t,t.items,r):ge(t)?Zm(e,t.iteratorItems,r):De(t)?Ym(e,t,r):Oe(t)?Qm(e,t,r):ae(t)?ep(e,t.parameters,t.instanceType,r):ie(t)?tp(e,t,r):oe(t)?rp(e,t.parameters,t.returnType,r):ce(t)?np(e,t,r):M(t)?ap(e,t.allOf,r):$e(t)?op(e,t.iteratorItems,r):F(t)?sp(e,t,r):at(t)?ip(e,t,r):Ft(t)?mp(e,t,r):Y(t)?pp(e,t,r):N(t)?up(e,t.properties,r):de(t)?cp(e,t.item,r):le(t)?dp(e,t,r):it(t)?lp(e,t,r):Q(t)?fp(e,t.pattern,r):U(t)?gp(e,t.items,r):Ht(t)?$p(e,t,r):y(t)?hp(e,t.anyOf,r):re(t)?Tp(e,t,r):Ke(t)?Ep(e,t,r):P()}function Jt(e,t,r={}){return $("Interface",[e,t],r)}function rr(e){return k(e)&&i.HasPropertyKey(e,"action")&&i.IsEqual(e.action,"Interface")}function kp(e,t,r={}){return g({},Jt(e,t,r))}function nI(e,t,r){return e.includes(r)?!0:ct([...e,r],t,t[r])}function Op(e,t,r){let n=$n(r);return Rt(e,t,n)}function Rt(e,t,r){let[n,...a]=r;return k(n)?ct(e,t,n)?!0:Rt(e,t,a):!1}function ct(e,t,r){return X(r)?nI(e,t,r.$ref):z(r)?ct(e,t,r.items):ge(r)?ct(e,t,r.iteratorItems):ae(r)?Rt(e,t,[...r.parameters,r.instanceType]):oe(r)?Rt(e,t,[...r.parameters,r.returnType]):rr(r)?Op(e,t,r.parameters[1]):M(r)?Rt(e,t,r.allOf):$e(r)?ct(e,t,r.iteratorItems):N(r)?Op(e,t,r.properties):de(r)?ct(e,t,r.item):y(r)?Rt(e,t,r.anyOf):U(r)?Rt(e,t,r.items):we(r)?ct(e,t,Ue(r)):!1}function Vn(e,t,r){return ct(e,t,r)}function aI(e,t){return t.reduce((r,n)=>n in e?Vn([n],e,e[n])?[...r,n]:r:K(),[])}function Pp(e){let t=yo(e);return aI(e,t)}function oI(e,t,r){return r.includes(t)?r:t in e?dt(e,e[t],[...r,t]):K()}function wp(e,t,r){let n=$n(t);return nr(e,n,r)}function nr(e,t,r){return t.reduce((n,a)=>dt(e,a,n),r)}function dt(e,t,r){return X(t)?oI(e,t.$ref,r):z(t)?dt(e,t.items,r):ge(t)?dt(e,t.iteratorItems,r):ae(t)?nr(e,[...t.parameters,t.instanceType],r):oe(t)?nr(e,[...t.parameters,t.returnType],r):rr(t)?wp(e,t.parameters[1],r):M(t)?nr(e,t.allOf,r):$e(t)?dt(e,t.iteratorItems,r):N(t)?wp(e,t.properties,r):de(t)?dt(e,t.item,r):y(t)?nr(e,t.anyOf,r):U(t)?nr(e,t.items,r):we(t)?dt(e,Ue(t),r):r}function Rp(e,t,r){return dt(e,r,[t])}function sI(e){return Nt()}function iI(e){return i.Keys(e).reduce((t,r)=>({...t,[r]:_e(e[r])}),{})}function Vr(e){return e.reduce((t,r)=>[...t,_e(r)],[])}function _e(e){return X(e)?sI(e.$ref):z(e)?Ce(_e(e.items),In(e)):ge(e)?Ae(_e(e.iteratorItems)):ae(e)?tt(Vr(e.parameters),_e(e.instanceType)):oe(e)?rt(Vr(e.parameters),_e(e.returnType)):M(e)?Te(Vr(e.allOf)):$e(e)?Ne(_e(e.iteratorItems)):N(e)?E(iI(e.properties)):de(e)?Fe(_e(e.item)):we(e)?Mn(zt(e),_e(Ue(e))):y(e)?O(Vr(e.anyOf)):U(e)?ee(Vr(e.items)):e}function mI(e,t){return t in e?_e(e[t]):ue()}function vp(e){return mI(e.$defs,e.$ref)}function Ca(e){return e.reduceRight((r,n,a)=>({[a]:n,...r}),{})}function Cp(e){let t=Ca(e.items);return E(t)}function pI(e,t){return Et(e)?!!Et(t):!1}function uI(e,t){return pe(e)?!!pe(t):!1}function cI(e,t){let r=pI(e,t),n=uI(e,t),a=G([e,t]),s=fn(Lt(a));return r&&n?Ie(xe(s)):r&&!n?Ie(s):!r&&n?xe(s):s}function dI(e,t,r){return r in e?r in t?cI(e[r],t[r]):e[r]:r in t?t[r]:S()}function lI(e,t){return[...new Set([...i.Keys(t),...i.Keys(e)])].reduce((n,a)=>({...n,[a]:dI(e,t,a)}),{})}function Mp(e){return N(e)?e.properties:U(e)?Ca(e.items):K()}function Sp(e,t){let r=Mp(e),n=Mp(t),a=lI(r,n);return E(a)}function jp(e,t){let r=Zr(e,t);return i.IsEqual(r,Wr)?e:i.IsEqual(r,Xr)||i.IsEqual(r,Jr)?t:S()}function qp(e){return N(e)||U(e)}function fI(e,t){let r=y(e),n=y(t);return r||n}function xI(e,t){let r=vt(e),n=vt(t),a=fI(r,n),s=qp(r),m=qp(n);return a?G([r,n]):s&&m?Sp(r,n):s&&!m?r:!s&&m?n:jp(r,n)}function Ap(e,t,r=[]){let[n,...a]=t;return i.IsUndefined(n)?r.length===0?[e]:r:Ap(e,a,[...r,xI(e,n)])}function Lp(e,t,r=[]){let[n,...a]=e;return k(n)?Lp(a,t,[...r,...Yr([n],t)]):r}function Yr(e,t=[]){let[r,...n]=e;return k(r)?y(r)?Yr(n,Lp(r.anyOf,t)):Yr(n,Ap(r,t)):t}function G(e){let t=Yr(e);return Ma(t)}function je(e){return Ma(e)}function vt(e){return M(e)?G(e.allOf):y(e)?je(e.anyOf):e}function Ct(e){return i.IsEqual(e.length,1)?e[0]:i.IsEqual(e.length,0)?S():O(e)}function II(e,t,r){let n=Ee(e,{callstack:[]},t),a=Qr({},{callstack:[]},r);return G([...n,E(a)])}function yI(e,t){return i.Keys(e).filter(n=>t.includes(n)).reduce((n,a)=>{let s=e[a],m=rr(s)?II(e,s.parameters[0],s.parameters[1]):s;return{...n,[a]:m}},{})}function Dp(e,t,r){let n=Rp(e,t,r),a=yI(e,n);return Le(a,t)}function Np(e,t){return t in e?X(e[t])?Np(e,e[t].$ref):e[t]:S()}function Ge(e,t){return Np(e,t)}function Fp(e){return se(e)?vp(e):e}function me(e,t,r){let n=Fp(t),a=Fp(r);return D(e,n,a)}var Jr="equal",gI="disjoint",Wr="left-inside",Xr="right-inside";function Zr(e,t){let r=[re(e)?h.ExtendsFalse():me({},e,t),re(e)?h.ExtendsTrue({}):me({},t,e)];return h.IsExtendsTrueLike(r[0])&&h.IsExtendsTrueLike(r[1])?Jr:h.IsExtendsTrueLike(r[0])&&h.IsExtendsFalse(r[1])?Wr:h.IsExtendsFalse(r[0])&&h.IsExtendsTrueLike(r[1])?Xr:gI}function $I(e){return y(e)?Je(e.anyOf):[e]}function Je(e){return e.reduce((t,r)=>[...t,...$I(r)],[])}function bI(e,t){return t.filter(r=>Zr(e,r)!==Xr)}function hI(e,t){let r=t.some(n=>{let a=Zr(e,n);return i.IsEqual(a,Wr)||i.IsEqual(a,Jr)});return i.IsEqual(r,!1)}function TI(e,t){let r=vt(e);return Z(r)?[r]:hI(r,t)?[...bI(r,t),r]:t}function EI(e){return e.reduce((t,r)=>N(r)?[...t,r]:at(r)?t:TI(r,t),[])}function Ma(e){let t=EI(e),r=Je(t);return r.length===0?S():r.length===1?r[0]:O(r)}function kI(e,t,r,n){let a=d(e,t,r);return p.Update(vt(a),{},n)}function Up(e,t,r,n){return kI(e,t,r,n)}function en(e,t=[]){return Qe(e)&&i.IsEqual(e.action,"Conditional")?X(e.parameters[0])?en(e.parameters[2],en(e.parameters[3],[...t,e.parameters[0].$ref])):en(e.parameters[2],en(e.parameters[3],t)):Qe(e)&&i.IsEqual(e.action,"Mapped")&&Qe(e.parameters[1])&&i.IsEqual(e.parameters[1].action,"KeyOf")&&X(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function OI(e,t){return e.reduce((r,n)=>[...r,t.includes(n.name)],[])}function Gp(e,t,r=[]){let[n,...a]=e,[s,...m]=t;return i.IsGreaterThan(e.length,0)&&i.IsGreaterThan(t.length,0)?Gp(a,m,[...r,[s,n]]):r}function PI(e){return y(e)?[...e.anyOf]:[e]}function wI(e,t){return e.reduce((r,n)=>[...r,[...n,t]],[])}function Kp(e,t){return t.reduce((r,n)=>[...r,...wI(e,n)],[])}function _p(e){return e.reduce((t,r)=>i.IsEqual(r[0],!0)?Kp(t,PI(r[1])):Kp(t,[r[1]]),[[]])}function zp(e,t,r){let n=en(r),a=OI(e,n),s=Gp(t,a);return Qe(r)&&i.IsEqual(r.action,"Conditional")||Qe(r)&&i.IsEqual(r.action,"Mapped")?_p(s):[t]}function RI(){return["(not-resolvable)",S()]}function vI(){return["(not-generic)",S()]}function CI(e,t,r){return[e,nt(t,r)]}function MI(e,t,r){return t in e?Bp(e,t,e[t],r):RI()}function Bp(e,t,r,n){return Dt(r)?CI(t,r.parameters,r.expression):X(r)?MI(e,r.$ref,n):vI()}function Hp(e,t,r){return Bp(e,"(anonymous)",t,r)}function SI(e,t,r){if(V(t)||ar(t)||h.IsExtendsTrueLike(me({},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 Vp(e,t,r,n,a){let s=d(e,t,a);return SI(r,s,n),p.Assign(e,{[r]:s})}function jI(e,t,r,n,a){let s=d(e,t,r.extends),m=d(e,t,r.equals),[c,...l]=a;return k(c)?Sa(Vp(e,t,r.name,s,c),t,n,l):Sa(Vp(e,t,r.name,s,m),t,n,[])}function Sa(e,t,r,n){let[a,...s]=r;return k(a)?jI(e,t,a,s,n):e}function Jp(e,t,r,n){return Sa(e,t,r,n)}function qI(e){return i.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function AI(e,t){return i.IsEqual(qI(e),t)}function LI(e,t,r,n,a,s){let m=Jp(e,t,n,s),c=d(m,{callstack:[...t.callstack,r.$ref]},a);return d(e,t,c)}function DI(e,t,r,n,a,s){return s.reduce((m,c)=>[...m,LI(e,t,r,n,a,c)],[])}function NI(e,t,r,n,a,s){let m=zp(n,s,a),c=DI(e,t,r,n,a,m);return i.IsEqual(c.length,1)?c[0]:je(c)}function Jn(e,t,r,n){let a=Ee(e,t,n),s=Hp(e,r,n),m=s[0],c=s[1];return Dt(c)?AI(t,m)?kr(He(m),a):NI(e,t,He(m),c.parameters,c.expression,a):kr(r,a)}function kr(e,t){return p.Create({"~kind":"Call"},{target:e,arguments:t},{})}function Wp(e,t){return Jn({},{callstack:[]},e,t)}function ar(e){return f(e,"Call")}function Xp(e){return de(e)?Xp(e.item):e}function FI(e,t,r,n){let a=d(e,t,r);return p.Update(Xp(a),{},n)}function Zp(e,t,r,n){return T(e,[r])?FI(e,t,r,n):_r(r,n)}function Yp(e,t){return e(t)}function Qp(e,t){return i.IsString(t)?q(Yp(e,t)):q(t)}function eu(e,t){let r=he(t);return We(e,r)}function tu(e,t){let r=t.map(n=>We(e,n));return O(r)}function We(e,t){return F(t)?Qp(e,t.const):Q(t)?eu(e,t.pattern):y(t)?tu(e,t.anyOf):t}function Or(e,t={}){return $("Capitalize",[e],t)}function ru(e,t={}){return g({},Or(e,t))}function Pr(e,t={}){return $("Lowercase",[e],t)}function nu(e,t={}){return g({},Pr(e,t))}function wr(e,t={}){return $("Uncapitalize",[e],t)}function au(e,t={}){return g({},wr(e,t))}function Rr(e,t={}){return $("Uppercase",[e],t)}function ou(e,t={}){return g({},Rr(e,t))}var UI=e=>e[0].toUpperCase()+e.slice(1),KI=e=>e.toLowerCase(),_I=e=>e[0].toLowerCase()+e.slice(1),GI=e=>e.toUpperCase();function zI(e,t,r,n){let a=d(e,t,r);return p.Update(We(UI,a),{},n)}function su(e,t,r,n){return T(e,[r])?zI(e,t,r,n):Or(r,n)}function BI(e,t,r,n){let a=d(e,t,r);return p.Update(We(KI,a),{},n)}function iu(e,t,r,n){return T(e,[r])?BI(e,t,r,n):Pr(r,n)}function HI(e,t,r,n){let a=d(e,t,r);return p.Update(We(_I,a),{},n)}function mu(e,t,r,n){return T(e,[r])?HI(e,t,r,n):wr(r,n)}function VI(e,t,r,n){let a=d(e,t,r);return p.Update(We(GI,a),{},n)}function pu(e,t,r,n){return T(e,[r])?VI(e,t,r,n):Rr(r,n)}function vr(e,t,r,n,a={}){return $("Conditional",[e,t,r,n],a)}function uu(e,t,r,n,a={}){return g({},vr(e,t,r,n,a))}function JI(e,t,r,n,a,s,m){let c=d(e,t,r),l=d(e,t,n),v=me(e,c,l);return p.Update(h.IsExtendsUnion(v)?O([d(v.inferred,t,a),d(e,t,s)]):h.IsExtendsTrue(v)?d(v.inferred,t,a):d(e,t,s),{},m)}function cu(e,t,r,n,a,s,m){return T(e,[r,n])?JI(e,t,r,n,a,s,m):vr(r,n,a,s,m)}function Cr(e,t={}){return $("ConstructorParameters",[e],t)}function du(e,t={}){return g({},Cr(e,t))}function WI(e){return ae(e)?d({},{callstack:[]},ee(e.parameters)):S()}function XI(e,t,r,n){let a=d(e,t,r);return p.Update(WI(a),{},n)}function lu(e,t,r,n){return T(e,[r])?XI(e,t,r,n):Cr(r,n)}function Mr(e,t,r={}){return $("Exclude",[e,t],r)}function fu(e,t,r={}){return g({},Mr(e,t,r))}function xu(e,t){return e.reduce((r,n)=>[...r,...Iu(n,t)],[])}function Iu(e,t){let r=me({},e,t);return h.IsExtendsTrueLike(r)?[]:[e]}function ZI(e,t){let r=ie(e)?xu(Se(e.enum),t):y(e)?xu(Je(e.anyOf),t):Iu(e,t);return je(r)}function YI(e,t,r,n,a){let s=d(e,t,r),m=d(e,t,n);return p.Update(ZI(s,m),{},a)}function Wn(e,t,r,n,a){return T(e,[r,n])?YI(e,t,r,n,a):Mr(r,n,a)}function Sr(e,t,r={}){return $("Extract",[e,t],r)}function yu(e,t,r={}){return g({},Sr(e,t,r))}function gu(e,t){return e.reduce((r,n)=>[...r,...$u(n,t)],[])}function $u(e,t){let r=me({},e,t);return h.IsExtendsTrueLike(r)?[e]:[]}function QI(e,t){let r=ie(e)?gu(Se(e.enum),t):y(e)?gu(Je(e.anyOf),t):$u(e,t);return je(r)}function ey(e,t,r,n,a){let s=d(e,t,r),m=d(e,t,n);return p.Update(QI(s,m),{},a)}function bu(e,t,r,n,a){return T(e,[r,n])?ey(e,t,r,n,a):Sr(r,n,a)}var ty=new RegExp("^(?:0|[1-9][0-9]*)$");function or(e){let t=`${e}`;return ty.test(t)?parseInt(t):e}function ry(e){return q(or(e))}function hu(e){return e.map(t=>Tu(t))}function Tu(e){return M(e)?Te(hu(e.allOf)):y(e)?O(hu(e.anyOf)):F(e)?ry(e.const):e}function Eu(e,t){let r=Tu(t),n=me({},r,be());return h.IsExtendsTrueLike(n)?e:F(t)&&i.IsEqual(t.const,"length")?be():S()}function ku(e,t){let r=Ge(e,t);return ze(r)}function Xn(e){return e.reduce((t,r)=>[...t,...ze(r)],[])}function Ou(e){let t=Se(e);return Xn(t)}function Pu(e){let t=G(e);return ze(t)}function wu(e){return[`${e}`]}function Ru(e){let t=he(e);return ze(t)}function ze(e){return se(e)?ku(e.$defs,e.$ref):ie(e)?Ou(e.enum):M(e)?Pu(e.allOf):F(e)?wu(e.const):Q(e)?Ru(e.pattern):y(e)?Xn(e.anyOf):[]}function sr(e){return ze(e)}function ny(e,t){return t in e?[e[t]]:[]}function ay(e,t){return t.reduce((r,n)=>[...r,...ny(e,n)],[])}function vu(e,t){let r=sr(t),n=ay(e,r);return je(n)}function oy(e){return q(or(e))}function Cu(e){return e.map(t=>ja(t))}function ja(e){return M(e)?Te(Cu(e.allOf)):y(e)?O(Cu(e.anyOf)):F(e)?oy(e.const):e}function sy(e,t){return e.reduceRight((r,n,a)=>{let s=me({},q(a),t);return h.IsExtendsTrueLike(s)?[n,...r]:r},[])}function iy(e,t){let r=ja(t),n=sy(e,r);return Ct(n)}function my(e){return Ct(e)}function Mu(e,t){return F(t)&&i.IsEqual(t.const,"length")?q(e.length):Y(t)||ce(t)?my(e):iy(e,t)}function py(e){return e.reduce((t,r)=>kn(r)?[...t,q(r)]:t,[])}function ir(e){let t=py(e);return O(t)}function Wt(e,t,r={}){return $("Index",[e,t],r)}function Su(e,t,r={}){let n=i.IsArray(t)?ir(t):t;return g({},Wt(e,n,r))}function ju(e,t){let r=Ge(e,t);return qe(r)}function uy(e,t){let r=i.Keys(e).filter(j=>!i.HasPropertyKey(t,j)),n=i.Keys(t).filter(j=>!i.HasPropertyKey(e,j)),a=i.Keys(e).filter(j=>i.HasPropertyKey(t,j)),s=r.reduce((j,b)=>({...j,[b]:e[b]}),{}),m=n.reduce((j,b)=>({...j,[b]:t[b]}),{}),c=a.reduce((j,b)=>({...j,[b]:G([e[b],t[b]])}),{}),l=p.Assign(s,m);return p.Assign(l,c)}function qu(e){return e.reduce((t,r)=>uy(t,qe(r)),{})}function Au(e){let t=Cp(ee(e));return qe(t)}function cy(e,t){return i.Keys(e).filter(a=>a in t).reduce((a,s)=>({...a,[s]:je([e[s],t[s]])}),{})}function Lu(e,t){let[r,...n]=e;return k(r)?Lu(n,cy(t,qe(r))):t}function Du(e){let[t,...r]=e;return k(t)?Lu(r,qe(t)):K()}function qe(e){return se(e)?ju(e.$defs,e.$ref):M(e)?qu(e.allOf):y(e)?Du(e.anyOf):U(e)?Au(e.items):N(e)?e.properties:{}}function mr(e){let t=qe(e);return E(t)}function dy(e){return se(e)||M(e)||y(e)?mr(e):e}function ly(e,t){let r=dy(e);return z(r)?Eu(r.items,t):N(r)?vu(r.properties,t):U(r)?Mu(r.items,t):S()}function fy(e,t,r,n,a){let s=d(e,t,r),m=d(e,t,n);return p.Update(ly(s,m),{},a)}function Nu(e,t,r,n,a){return T(e,[r,n])?fy(e,t,r,n,a):Wt(r,n,a)}function jr(e,t={}){return $("InstanceType",[e],t)}function Fu(e,t={}){return g({},jr(e,t))}function xy(e){return ae(e)?e.instanceType:S()}function Iy(e,t,r,n){let a=d(e,t,r);return p.Update(xy(a),{},n)}function Uu(e,t,r,n={}){return T(e,[r])?Iy(e,t,r,n):jr(r,n)}function yy(e,t,r,n,a){let s=Ee(e,{callstack:[]},r),m=Qr(e,{callstack:[]},n),c=G([...s,E(m)]);return p.Update(c,{},a)}function Ku(e,t,r,n,a){return T(e,r)?yy(e,t,r,n,a):Jt(r,n,a)}function Xt(e,t={}){return $("KeyOf",[e],t)}function _u(e,t={}){return g({},Xt(e,t))}function Gu(){return O([be(),Pe(),Ut()])}function zu(e){return be()}function gy(e){return e.reduce((r,n)=>kn(n)?[...r,q(or(n))]:K(),[])}function Bu(e){let t=i.Keys(e),r=gy(t);return Ct(r)}function Hu(e){return zt(e)}function Vu(e){let t=e.map((r,n)=>q(n));return Ct(t)}function $y(e){return se(e)||M(e)||y(e)?mr(e):e}function by(e){let t=$y(e);return Z(t)?Gu():z(t)?zu(t.items):N(t)?Bu(t.properties):we(t)?Hu(t):U(t)?Vu(t.items):S()}function hy(e,t,r,n){let a=d(e,t,r);return p.Update(by(a),{},n)}function Ju(e,t,r,n){return T(e,[r])?hy(e,t,r,n):Xt(r,n)}function Vt(e,t,r,n,a={}){return $("Mapped",[e,t,r,n],a)}function Wu(e,t,r,n,a={}){return g({},Vt(e,t,r,n,a))}function Ty(e){let t=he(e);return qa(t)}function Xu(e){return e.reduce((t,r)=>[...t,...qa(r)],[])}function qa(e){return ie(e)?Xu(Se(e.enum)):Pn(e)||On(e)?[e]:Q(e)?Ty(e.pattern):y(e)?Xu(e.anyOf):[e]}function Zu(e){return qa(e)}function Ey(e){return Q(e)?he(e.pattern):e}function ky(e,t,r,n,a,s){let m=p.Assign(e,{[r.name]:n}),c=d(m,t,a),l=Ey(c),v=d(m,t,s);return On(l)||Pn(l)?{[l.const]:v}:{}}function Oy(e,t,r,n,a,s){return n.reduce((m,c)=>[...m,ky(e,t,r,c,a,s)],[])}function Py(e){return e.reduce((t,r)=>[...t,E(r)],[])}function wy(e,t,r,n,a,s){let m=Zu(n),c=Oy(e,t,r,m,a,s),l=Py(c);return G(l)}function Ry(e,t,r,n,a,s,m){let c=d(e,t,n);return p.Update(wy(e,t,r,c,a,s),{},m)}function Yu(e,t,r,n,a,s,m){return T(e,[n])?Ry(e,t,r,n,a,s,m):Vt(r,n,a,s,m)}function vy(e,t){return i.Keys(e).filter(n=>t.includes(n)).reduce((n,a)=>({...n,[a]:Dp(e,a,e[a])}),{})}function Cy(e,t){return i.Keys(e).filter(n=>!t.includes(n)).reduce((n,a)=>({...n,[a]:d(e,{callstack:[]},e[a])}),{})}function My(e,t){let r=Pp(e),n=vy(e,r),a=Cy(e,r),s={...n,...a};return p.Update(s,{},t)}function Qu(e,t,r,n){let a=p.Assign(e,r);return My(a,n)}function qr(e,t={}){return $("NonNullable",[e],t)}function ec(e,t={}){return g({},qr(e,t))}function Sy(e){let t=O([st(),Bt()]);return Wn({},{callstack:[]},e,t,{})}function jy(e,t,r,n){let a=d(e,t,r);return p.Update(Sy(a),{},n)}function tc(e,t,r,n){return T(e,[r])?jy(e,t,r,n):qr(r,n)}function Zn(e){let t=mr(e);return N(t)?t.properties:K()}function Ar(e,t,r={}){return $("Omit",[e,t],r)}function rc(e,t,r={}){let n=i.IsArray(t)?ir(t):t;return g({},Ar(e,n,r))}function qy(e,t){return i.Keys(e).reduce((n,a)=>t.includes(a)?n:{...n,[a]:e[a]},{})}function Ay(e,t){let r=Zn(e),n=sr(t),a=qy(r,n);return E(a)}function Ly(e,t,r,n,a){let s=d(e,t,r),m=d(e,t,n);return p.Update(Ay(s,m),{},a)}function nc(e,t,r,n,a){return T(e,[r,n])?Ly(e,t,r,n,a):Ar(r,n,a)}function Zt(e,t){return $("Options",[e,t],{})}function ac(e,t){return g({},Zt(e,t))}function Dy(e,t,r,n){let a=d(e,t,r);return p.Update(a,{},n)}function oc(e,t,r,n){return T(e,[r])?Dy(e,t,r,n):Zt(r,n)}function Lr(e,t={}){return $("Parameters",[e],t)}function sc(e,t={}){return g({},Lr(e,t))}function Ny(e){return oe(e)?d({},{callstack:[]},ee(e.parameters)):S()}function Fy(e,t,r,n){let a=d(e,t,r);return p.Update(Ny(a),{},n)}function ic(e,t,r,n){return T(e,[r])?Fy(e,t,r,n):Lr(r,n)}function Dr(e,t={}){return $("Partial",[e],t)}function mc(e,t={}){return g({},Dr(e,t))}function pc(e,t){let r=Ge(e,t),n=lt(r);return Le(p.Assign(e,{[t]:n}),t)}function uc(e){let t=e.map(r=>lt(r));return G(t)}function cc(e){let t=e.map(r=>lt(r));return O(t)}function dc(e){let t=i.Keys(e).reduce((n,a)=>({...n,[a]:ln(e[a])}),{});return E(t)}function lt(e){return se(e)?pc(e.$defs,e.$ref):M(e)?uc(e.allOf):y(e)?cc(e.anyOf):N(e)?dc(e.properties):E({})}function Uy(e,t,r,n){let a=d(e,t,r);return p.Update(lt(a),{},n)}function lc(e,t,r,n){return T(e,[r])?Uy(e,t,r,n):Dr(r,n)}function Nr(e,t,r={}){return $("Pick",[e,t],r)}function fc(e,t,r={}){let n=i.IsArray(t)?ir(t):t;return g({},Nr(e,n,r))}function Ky(e,t){return i.Keys(e).reduce((n,a)=>t.includes(a)?p.Assign(n,{[a]:e[a]}):n,{})}function _y(e,t){let r=Zn(e),n=sr(t),a=Ky(r,n);return E(a)}function Gy(e,t,r,n,a){let s=d(e,t,r),m=d(e,t,n);return p.Update(_y(s,m),{},a)}function xc(e,t,r,n,a){return T(e,[r,n])?Gy(e,t,r,n,a):Nr(r,n,a)}function Fr(e,t={}){return $("ReadonlyType",[e],t)}function Ic(e,t={}){return g({},Fr(e,t))}function yc(e){return et(Ce(e))}function gc(e,t){let r=Ge(e,t),n=ft(r);return Le(p.Assign(e,{[t]:n}),t)}function $c(e){let t=e.map(r=>ft(r));return G(t)}function bc(e){let t=i.Keys(e).reduce((n,a)=>({...n,[a]:xn(e[a])}),{});return E(t)}function hc(e){return et(ee(e))}function Tc(e){let t=e.map(r=>ft(r));return O(t)}function ft(e){return z(e)?yc(e.items):se(e)?gc(e.$defs,e.$ref):M(e)?$c(e.allOf):N(e)?bc(e.properties):U(e)?hc(e.items):y(e)?Tc(e.anyOf):e}function zy(e,t,r,n){let a=d(e,t,r);return p.Update(ft(a),{},n)}function Ec(e,t,r,n){return T(e,[r])?zy(e,t,r,n):Fr(r,n)}function kc(e){return ye(Me,e)}function Oc(e){return E({true:e,false:e})}function Pc(e,t){let r=zr(e);return xt(r,t)}function wc(e,t){return ye(Kt,t)}function Rc(e,t){let r=G(e);return xt(r,t)}function vc(e,t){return i.IsString(e)||i.IsNumber(e)?E({[e]:t}):i.IsEqual(e,!1)?E({false:t}):i.IsEqual(e,!0)?E({true:t}):E({})}function Cc(e,t){return ye(_t,t)}function Mc(e,t){return i.HasPropertyKey(e,"pattern")&&(i.IsString(e.pattern)||e.pattern instanceof RegExp)?ye(e.pattern.toString(),t):ye(Me,t)}function Sc(e,t){let r=hr(e);return vn(r)?xt(he(e),t):ye(e,t)}function By(e){return e.some(t=>le(t)||Y(t)||ce(t))}function Hy(e,t){return i.IsEqual(By(e),!0)?ye(Me,t):void 0}function Vy(e,t){return e.reduce((r,n)=>F(n)&&(i.IsString(n.const)||i.IsNumber(n.const))?{...r,[n.const]:t}:r,{})}function Jy(e,t){let r=Vy(e,t);return E(r)}function jc(e,t){let r=Je(e),n=Hy(r,t);return k(n)?n:Jy(r,t)}function xt(e,t){return Z(e)?kc(t):Oe(e)?Oc(t):ie(e)?Pc(e.enum,t):ce(e)?wc(e,t):M(e)?Rc(e.allOf,t):F(e)?vc(e.const,t):Y(e)?Cc(e,t):y(e)?jc(e.anyOf,t):le(e)?Mc(e,t):Q(e)?Sc(e.pattern,t):E({})}function Wy(e,t,r,n,a){let s=d(e,t,r),m=d(e,t,n);return p.Update(xt(s,m),{},a)}function qc(e,t,r,n,a){return T(e,[r])?Wy(e,t,r,n,a):Tr(r,n,a)}function Ac(e,t,r,n){return n in e?Vn([n],e,e[n])?r:d(e,t,e[n]):r}function Lc(e,t){let r=Ge(e,t),n=It(r);return Le(p.Assign(e,{[t]:n}),t)}function Dc(e){let t=e.map(r=>It(r));return G(t)}function Nc(e){let t=e.map(r=>It(r));return O(t)}function Fc(e){let t=i.Keys(e).reduce((n,a)=>({...n,[a]:Lt(e[a])}),{});return E(t)}function It(e){return se(e)?Lc(e.$defs,e.$ref):M(e)?Dc(e.allOf):y(e)?Nc(e.anyOf):N(e)?Fc(e.properties):E({})}function Ur(e,t={}){return $("Required",[e],t)}function Uc(e,t={}){return g({},Ur(e,t))}function Xy(e,t,r,n){let a=d(e,t,r);return p.Update(It(a),{},n)}function Kc(e,t,r,n){return T(e,[r])?Xy(e,t,r,n):Ur(r,n)}function Kr(e,t={}){return $("ReturnType",[e],t)}function _c(e,t={}){return g({},Kr(e,t))}function Zy(e){return oe(e)?e.returnType:S()}function Yy(e,t,r,n){let a=d(e,t,r);return p.Update(Zy(a),{},n)}function Gc(e,t,r,n){return T(e,[r])?Yy(e,t,r,n):Kr(r,n)}function Qy(e){return e.join("|")}function eg(e){return e.slice(1,e.length-1)}function tg(e,t,r){return yt(t,`${r}${e}`)}function rg(e,t){return yt(e,`${t}${Co}`)}function ng(e,t){return yt(e,`${t}${En}`)}function ag(e,t){return yt(e,`${t}${wn}`)}function og(e,t){return La(O([q("false"),q("true")]),e,t)}function sg(e,t){return yt(e,`${t}${Rn}`)}function ig(e,t,r){return yt(t,`${r}${eg(e)}`)}function mg(e,t,r){let n=Se(e);return Aa(n,t,r)}function Aa(e,t,r,n=[]){let[a,...s]=e;return k(a)?Aa(s,t,r,[...n,La(a,[],"")]):yt(t,`${r}(${Qy(n)})`)}function La(e,t,r){return ie(e)?mg(e.enum,t,r):ce(e)?ng(t,r):F(e)?tg(e.const,t,r):De(e)?rg(t,r):Oe(e)?og(t,r):Y(e)?ag(t,r):le(e)?sg(t,r):Q(e)?ig(e.pattern,t,r):y(e)?Aa(e.anyOf,t,r):xo}function yt(e,t){let[r,...n]=e;return k(r)?La(r,n,t):t}function pg(e){return`^${yt(e,"")}$`}function zc(e){let t=pg(e);return Cn(t)}function ug(e,t,r,n){let a=Ee(e,t,r);return p.Update(zc(a),{},n)}function Bc(e,t,r,n){return T(e,r)?ug(e,t,r,n):Er(r,n)}function cg(e){return mt(e)?U(e.items)?Da(e.items.items):V(e.items)?[e]:X(e.items)?[e]:[S()]:[e]}function Da(e){return e.reduce((r,n)=>[...r,...cg(n)],[])}function dg(e,t){return t in e}function lg(e,t){return M(t)?T(e,t.allOf):y(t)?T(e,t.anyOf):X(t)?dg(e,t.$ref):!0}function T(e,t){let[r,...n]=t;return k(r)?lg(e,r)?T(e,n):!1:!0}function tn(e,t,r){return po(e)?tn(e.type,"remove",r):oo(e)?tn(e.type,t,"remove"):io(e)?tn(e.type,"add",r):no(e)?tn(e.type,t,"add"):[e,t,r]}function fg(e,t){return i.IsEqual(e,"remove")?fn(t):i.IsEqual(e,"add")?Ie(t):t}function xg(e,t){return i.IsEqual(e,"remove")?Lt(t):i.IsEqual(e,"add")?xe(t):t}function Qr(e,t,r){return i.Keys(r).reduce((n,a)=>({...n,[a]:d(e,t,r[a])}),{})}function Hn(e,t,r){let n=Ee(e,t,r);return Da(n)}function Ee(e,t,r){return r.map(n=>d(e,t,n))}function Ig(e,t,r,n,a){return i.IsEqual(r,"Awaited")?Zp(e,t,n[0],a):i.IsEqual(r,"Capitalize")?su(e,t,n[0],a):i.IsEqual(r,"Conditional")?cu(e,t,n[0],n[1],n[2],n[3],a):i.IsEqual(r,"ConstructorParameters")?lu(e,t,n[0],a):i.IsEqual(r,"Evaluate")?Up(e,t,n[0],a):i.IsEqual(r,"Exclude")?Wn(e,t,n[0],n[1],a):i.IsEqual(r,"Extract")?bu(e,t,n[0],n[1],a):i.IsEqual(r,"Index")?Nu(e,t,n[0],n[1],a):i.IsEqual(r,"InstanceType")?Uu(e,t,n[0],a):i.IsEqual(r,"Interface")?Ku(e,t,n[0],n[1],a):i.IsEqual(r,"KeyOf")?Ju(e,t,n[0],a):i.IsEqual(r,"Lowercase")?iu(e,t,n[0],a):i.IsEqual(r,"Mapped")?Yu(e,t,n[0],n[1],n[2],n[3],a):i.IsEqual(r,"Module")?Qu(e,t,n[0],a):i.IsEqual(r,"NonNullable")?tc(e,t,n[0],a):i.IsEqual(r,"Pick")?xc(e,t,n[0],n[1],a):i.IsEqual(r,"Options")?oc(e,t,n[0],n[1]):i.IsEqual(r,"Parameters")?ic(e,t,n[0],a):i.IsEqual(r,"Partial")?lc(e,t,n[0],a):i.IsEqual(r,"Omit")?nc(e,t,n[0],n[1],a):i.IsEqual(r,"ReadonlyType")?Ec(e,t,n[0],a):i.IsEqual(r,"Record")?qc(e,t,n[0],n[1],a):i.IsEqual(r,"Required")?Kc(e,t,n[0],a):i.IsEqual(r,"ReturnType")?Gc(e,t,n[0],a):i.IsEqual(r,"TemplateLiteral")?Bc(e,t,n[0],a):i.IsEqual(r,"Uncapitalize")?mu(e,t,n[0],a):i.IsEqual(r,"Uppercase")?pu(e,t,n[0],a):$(r,n,a)}function d(e,t,r){let n=Tt(r),a=tn(r,Et(r)?"add":"none",pe(r)?"add":"none"),s=gn(a[0])?a[0].Clone():a[0],m=X(s)?Ac(e,t,s,s.$ref):z(s)?Ce(d(e,t,s.items),In(s)):ge(s)?Ae(d(e,t,s.iteratorItems),uo(s)):ar(s)?Jn(e,t,s.target,s.arguments):ae(s)?tt(Ee(e,t,s.parameters),d(e,t,s.instanceType),lo(s)):Qe(s)?Ig(e,t,s.action,s.parameters,s.options):oe(s)?rt(Ee(e,t,s.parameters),d(e,t,s.returnType),fo(s)):M(s)?Te(Ee(e,t,s.allOf),Eo(s)):$e(s)?Ne(d(e,t,s.iteratorItems),So(s)):N(s)?E(Qr(e,t,s.properties),go(s)):de(s)?Fe(d(e,t,s.item),qo(s)):we(s)?_o(Gt(s),d(e,t,Ue(s))):mt(s)?Pt(d(e,t,s.items)):U(s)?ee(Hn(e,t,s.items),zo(s)):y(s)?O(Ee(e,t,s.anyOf),$o(s)):s,c=n?et(m):m;return fg(a[1],xg(a[2],c))}function g(e,t){return d(e,{callstack:[]},t)}function _r(e,t={}){return $("Awaited",[e],t)}function Hc(e,t={}){return g({},_r(e,t))}function ua(e,t={}){return $("Evaluate",[e],t)}function Vc(e,t={}){return g({},ua(e,t))}function ca(e,t={}){return $("Module",[e],t)}function Jc(e,t={}){return g({},ca(e,t))}function Wc(...e){let[t,r,n]=ot.Match(e,{2:(m,c)=>i.IsString(m)?[{},m,c]:[m,c,{}],3:(m,c,l)=>[m,c,l],1:m=>[{},m,{}]}),a=Um(r),s=i.IsArray(a)&&i.IsEqual(a.length,2)?d(t,{callstack:[]},a[0]):S();return p.Update(s,{},n)}var H={};qt(H,{Any:()=>Nt,Array:()=>Ce,AsyncIterator:()=>Ae,Awaited:()=>Hc,Base:()=>yn,BigInt:()=>$r,Boolean:()=>Tn,Call:()=>Wp,Capitalize:()=>ru,Codec:()=>hn,Conditional:()=>uu,Constructor:()=>tt,ConstructorParameters:()=>du,Cyclic:()=>Le,Decode:()=>wo,DecodeBuilder:()=>gr,Encode:()=>Ro,EncodeBuilder:()=>yr,Enum:()=>To,Evaluate:()=>Vc,Exclude:()=>fu,Extends:()=>me,ExtendsResult:()=>h,Extract:()=>yu,Function:()=>rt,Generic:()=>nt,Identifier:()=>br,Immutable:()=>et,Index:()=>Su,Infer:()=>Ir,InstanceType:()=>Fu,Instantiate:()=>g,Integer:()=>kt,Interface:()=>kp,Intersect:()=>Te,IsAny:()=>Z,IsArray:()=>z,IsAsyncIterator:()=>ge,IsBase:()=>gn,IsBigInt:()=>De,IsBoolean:()=>Oe,IsCall:()=>ar,IsCodec:()=>bn,IsConstructor:()=>ae,IsCyclic:()=>se,IsEnum:()=>ie,IsFunction:()=>oe,IsGeneric:()=>Dt,IsIdentifier:()=>Mo,IsImmutable:()=>Tt,IsInfer:()=>V,IsInteger:()=>ce,IsIntersect:()=>M,IsIterator:()=>$e,IsKind:()=>f,IsLiteral:()=>F,IsNever:()=>at,IsNull:()=>Ft,IsNumber:()=>Y,IsObject:()=>N,IsOptional:()=>pe,IsParameter:()=>jo,IsPromise:()=>de,IsReadonly:()=>Et,IsRecord:()=>we,IsRef:()=>X,IsRefine:()=>sa,IsRest:()=>mt,IsSchema:()=>k,IsString:()=>le,IsSymbol:()=>it,IsTemplateLiteral:()=>Q,IsThis:()=>Go,IsTuple:()=>U,IsUndefined:()=>Ht,IsUnion:()=>y,IsUnknown:()=>re,IsUnsafe:()=>Ho,IsVoid:()=>Ke,Iterator:()=>Ne,KeyOf:()=>_u,Literal:()=>q,Lowercase:()=>nu,Mapped:()=>Wu,Module:()=>Jc,Never:()=>S,NonNullable:()=>ec,Null:()=>st,Number:()=>be,Object:()=>E,Omit:()=>rc,Optional:()=>ln,Options:()=>ac,Parameter:()=>Ot,Parameters:()=>sc,Partial:()=>mc,Pick:()=>fc,Promise:()=>Fe,Readonly:()=>xn,ReadonlyType:()=>Ic,Record:()=>Mn,RecordKey:()=>zt,RecordKeyAsPattern:()=>Gt,RecordValue:()=>Ue,Ref:()=>He,Refine:()=>vo,Required:()=>Uc,Rest:()=>Pt,ReturnType:()=>_c,Script:()=>Wc,String:()=>Pe,Symbol:()=>Ut,TemplateLiteral:()=>Gm,This:()=>Sn,Tuple:()=>ee,Uncapitalize:()=>au,Undefined:()=>Bt,Union:()=>O,Unknown:()=>ue,Unsafe:()=>Bo,Uppercase:()=>ou,Void:()=>jn});import{existsSync as ud,readFileSync as u$}from"node:fs";import{homedir as dd}from"node:os";import{join as cr}from"node:path";import{spawn as c$}from"node:child_process";var yg=new Set(["ECONNREFUSED","ConnectionRefused"]);function Na(e,t){if(!e||typeof e!="object"||t.has(e))return!1;if(t.add(e),e instanceof Error&&e.message.includes("ECONNREFUSED"))return!0;let r=e;return typeof r.code=="string"&&yg.has(r.code)||Na(r.cause,t)?!0:Array.isArray(r.errors)&&r.errors.some(n=>Na(n,t))}function Xc(e){return Na(e,new Set)?!0:e instanceof Error&&e.message.includes("ECONNREFUSED")}import{homedir as gg}from"os";import{join as $g}from"path";function Mt(e,t=process.platform,r=gg()){return typeof e!="string"||e.length===0?e:e==="~"?r:e.startsWith("~/")||t==="win32"&&e.startsWith("~\\")?$g(r,e.slice(2)):e}var pr="MEMINDEX_",bg="AGENT_MEM_",rn=[bg];function Yn(e){return e.startsWith(pr)||rn.some(t=>e.startsWith(t))}function Fa(e){if(!e.startsWith(pr))return[];let t=e.slice(pr.length);return rn.map(r=>r+t)}function hg(e=process.env){for(let t of rn)for(let r of Object.keys(e)){if(!r.startsWith(t))continue;let n=pr+r.slice(t.length);e[n]===void 0&&(e[n]=e[r])}}function Zc(e){let t=null;for(let r of rn)for(let n of Object.keys(e)){if(!n.startsWith(r))continue;let a=pr+n.slice(r.length);(t??e)[a]===void 0&&(t??={...e},t[a]=e[n])}return t??e}hg();import{randomBytes as ed}from"node:crypto";import{constants as td,openSync as nd,closeSync as ad,readFileSync as Fg,writeFileSync as Ug,fstatSync as Kg,fchmodSync as _g,fsyncSync as Gg,linkSync as zg,unlinkSync as Bg,mkdirSync as Hg}from"node:fs";import{join as Ka}from"node:path";import{join as ur,dirname as vg,basename as Cg}from"path";import{homedir as Mg}from"os";import{fileURLToPath as Sg}from"url";import{existsSync as wg}from"fs";import{homedir as Rg}from"os";import{join as Qc}from"path";import{closeSync as BV,existsSync as HV,fsyncSync as VV,lstatSync as JV,mkdirSync as WV,openSync as XV,readFileSync as Tg,readlinkSync as ZV,realpathSync as YV,renameSync as QV,statSync as e3,unlinkSync as t3,writeSync as r3}from"fs";var KV=Promise.resolve();var a3=process.platform==="win32";function Eg(e){return e.replace(/^\uFEFF/,"")}function kg(e){return JSON.parse(Eg(e))}function Ua(e){return kg(Tg(e,"utf-8"))}var Og=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function Pg(e){let t=e.env;return Og(t)&&Object.keys(t).some(Yn)?"nested":"flat"}function Yc(e){return Pg(e)==="nested"?e.env:e}function nn(e=process.env,t=Rg()){if(e.MEMINDEX_DATA_DIR)return Mt(e.MEMINDEX_DATA_DIR,process.platform,t);let r=Qc(t,".memindex"),n=Qc(r,"settings.json");try{if(wg(n)){let a=Ua(n);if(a===null||typeof a!="object"||Array.isArray(a))return r;let s=Zc(Yc(a));if(typeof s.MEMINDEX_DATA_DIR=="string"&&s.MEMINDEX_DATA_DIR)return Mt(s.MEMINDEX_DATA_DIR,process.platform,t)}}catch{}return r}function jg(){return typeof __dirname<"u"?__dirname:vg(Sg(import.meta.url))}var k3=jg();function qg(e){let t=process.env.MEMINDEX_TEST_FORBIDDEN_DATA_DIR;if(t&&e===t)throw new Error(`A test resolved the real data folder ${e}. Point MEMINDEX_DATA_DIR at a temporary directory (and pass env: process.env to any child process the test starts).`);return e}function an(){return qg(nn())}var Qn=an(),Ag=ur(Mg(),".claude"),Lg=process.env.CLAUDE_CONFIG_DIR||Ag,O3=ur(Lg,"plugins","marketplaces","memindex"),P3=ur(Qn,"logs"),w3=ur(Qn,"settings.json"),Dg="memindex.db";var R3=ur(Qn,Dg),Ng=ur(Qn,"observer-sessions"),v3=Cg(Ng);var Vg="X-Memindex-Secret",od="worker-secret",Jg=/^[a-f0-9]{64}$/;function rd(e=an()){let t=nd(Ka(e,od),td.O_RDONLY|(td.O_NOFOLLOW??0));try{let r=Kg(t);if(!r.isFile()||process.getuid&&r.uid!==process.getuid()||process.platform!=="win32"&&(r.mode&63)!==0)throw new Error("Worker secret must be an owner-only file");let n=Fg(t,"utf8");if(!Jg.test(n))throw new Error("Invalid worker secret");return n}finally{ad(t)}}function Wg(e=an()){Hg(e,{recursive:!0,mode:448});let t=Ka(e,od);try{return rd(e)}catch(a){if(a.code!=="ENOENT")throw a}let r=Ka(e,`.worker-secret-${ed(16).toString("hex")}`),n=nd(r,"wx",384);try{_g(n,384),Ug(n,ed(32).toString("hex")),Gg(n)}finally{ad(n)}try{try{zg(r,t)}catch(a){if(a.code!=="EEXIST")throw a}}finally{Bg(r)}return rd(e)}function sd(e,t=an()){if(!["POST","PUT","PATCH","DELETE"].includes((e.method??"GET").toUpperCase()))return e;let r=new Headers(e.headers);return r.set(Vg,Wg(t)),{...e,headers:r,redirect:"error"}}import{createHash as Xg}from"crypto";import{realpathSync as Zg}from"fs";import{homedir as _a,tmpdir as id}from"os";import{basename as Yg,dirname as Qg,join as e$,resolve as t$,sep as md}from"path";var r$=4e4,n$=9e3,a$=["/tmp","/private/tmp","/var/folders","/private/var/folders"];function on(e){let t=t$(e),r=[],n=t;for(;;)try{return e$(Zg.native(n),...r.reverse())}catch{let a=Qg(n);if(a===n)return t;r.push(Yg(n)),n=a}}function o$(e,t){let r=on(t);return e===r||e.startsWith(r.endsWith(md)?r:r+md)}function s$(e,t=_a()){let r=on(e),n=on(t);return(process.platform==="win32"?[id()]:[id(),...a$]).some(s=>on(s)!==n&&o$(r,s))}function i$(e=process.env,t=_a()){return e.MEMINDEX_TEST_FORBIDDEN_DATA_DIR?!0:s$(nn(e,t),t)}function m$(){return 38700+(process.getuid?.()??77)%100}function p$(e){let t=Xg("sha256").update(on(e)).digest();return r$+t.readUInt32BE(0)%n$}function pd(e=process.env,t=_a()){return i$(e,t)?p$(nn(e,t)):m$()}var Ga=5e3;function cd(){let e=Mt(process.env.MEMINDEX_DATA_DIR||process.env.AGENT_MEM_DATA_DIR||cr(dd(),".memindex")),t={};try{let c=JSON.parse(u$(cr(e,"settings.json"),"utf8").replace(/^\uFEFF/,"")),l=c?.env;t=l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).some(Yn)?l:c??{}}catch{}let r=c=>typeof t[c]=="string"&&t[c]?String(t[c]):"",n=(c,l)=>process.env[c]||Fa(c).map(v=>process.env[v]).find(Boolean)||r(c)||Fa(c).map(r).find(Boolean)||l,a=n("MEMINDEX_WORKER_HOST","127.0.0.1"),s=a==="localhost"?"127.0.0.1":a,m=n("MEMINDEX_WORKER_PORT",String(pd()));return"http://"+(s.includes(":")&&!s.startsWith("[")?"["+s+"]":s)+":"+m}var sn;function d$(){if(sn)return sn;let e=cr(process.env.CLAUDE_CONFIG_DIR||cr(dd(),".claude"),"plugins","marketplaces","memindex"),t=cr(e,"plugin","scripts","bun-runner.js"),r=cr(e,"plugin","scripts","worker-service.cjs");return!ud(t)||!ud(r)?Promise.reject(new Error("Run npx memindex install to install the worker.")):(sn=new Promise((a,s)=>{let m=c$(process.execPath,[t,r,"start"],{stdio:"ignore",windowsHide:!0,timeout:15e3});m.once("error",s),m.once("close",c=>c===0?a():s(new Error("memindex worker could not start")))}).finally(()=>{sn=void 0}),sn)}function ld(){let e=cd();return{reset(){e=cd()},async ready(){try{let t=await fetch(e+"/api/health",{signal:AbortSignal.timeout(Ga)});if(t.ok)return;throw new Error("memindex health check returned "+t.status)}catch(t){if(!Xc(t))throw t;await d$()}},async request(t,r={}){let n=await fetch(e+t,sd({...r,signal:r.signal?AbortSignal.any([r.signal,AbortSignal.timeout(Ga)]):AbortSignal.timeout(Ga)}));if(!n.ok)throw new Error("memindex "+t+" returned "+n.status);return n},async post(t,r){return this.request(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r)})}}}function mn(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
9
+ `):""}function l$(e){let t=ld(),r,n=!1,a=(b,C)=>{!n&&b.hasUI&&b.ui&&(b.ui.notify("MemIndex is unavailable. Run npx memindex doctor. "+String(C),"warning"),n=!0)},s=(b,C,x)=>(b.queue=b.queue.then(x).catch(J=>a(C,J)),b.queue),m=async(b,C)=>{let x=C.sessionManager.getSessionId();if(!x||!C.cwd){r=void 0;return}let J={id:x,cwd:C.cwd,memory:"",anchored:!1,excluded:!1,queue:Promise.resolve(),lastAssistant:"",needsSummary:!1,initialized:!1};r=J,n=!1,t.reset();try{await t.ready();let Re=new URLSearchParams({cwd:J.cwd,platform_source:"pi"});J.memory=(await(await t.request("/api/context/inject?"+Re)).text()).trim()}catch(Re){a(C,Re)}};e.on("session_start",m),e.on("session_switch",m),e.on("session_fork",m);let c=(b,C)=>{let x=r;if(x)return s(x,C,async()=>{x.entryId=void 0,x.initialized=!1,x.anchored=!1,x.excluded=!0,x.needsSummary=!1,x.lastAssistant=""})};e.on("before_agent_start",c),e.on("session_tree",c),e.on("context_with_system",async(b,C)=>{let x=r,J=b.messages;if(!x)return;if(!Array.isArray(J)||J[0]?.role!=="system"||typeof J[0].content!="string"){await c(b,C);return}let Re=J[0].content,Xe=[...J].reverse().find(te=>te.role==="user"),gt=mn(Xe?.content),$t=()=>{if(r!==x||C.sessionManager.getSessionId()!==x.id||C.cwd!==x.cwd||typeof C.sessionManager.getBranch!="function")return;let te=C.sessionManager.getBranch();if(!Array.isArray(te))return;let ke=[...te].reverse().find(dr=>dr.type==="message"&&dr.message?.role==="user");if(!(!ke||typeof ke.id!="string"||!/^[^\s\x00-\x1f\x7f]{1,256}$/.test(ke.id)||!Xe||typeof Xe.timestamp!="number"||!Number.isFinite(Xe.timestamp)||ke.message?.timestamp!==Xe.timestamp||mn(ke.message.content)!==gt))return ke};if(await s(x,C,async()=>{try{let te=$t();if(!te||!gt.trim()){x.anchored=!1,x.excluded=!0,x.initialized=!1;return}if(x.entryId!==te.id&&(x.entryId=te.id,x.initialized=!1,x.anchored=!1,x.excluded=!0,x.needsSummary=!1,x.lastAssistant=""),x.initialized)return;if((await(await t.request("/api/sessions/native-prompt-capability")).json()).nativePromptId!==1)throw new Error("Upgrade the worker for native Pi prompt capture.");if($t()?.id!==te.id)return;let bt=await(await t.post("/api/sessions/init",{contentSessionId:x.id,cwd:x.cwd,prompt:gt,platformSource:"pi",nativePromptId:te.id})).json();if($t()?.id!==te.id)return;if(bt.skipped===!0&&bt.reason!=="duplicate"){x.initialized=!0,x.excluded=!0;return}if(bt.nativePromptId!==te.id||typeof bt.sessionDbId!="number")throw new Error("The worker did not acknowledge the persisted Pi user-entry ID.");x.initialized=!0,x.anchored=bt.nativePromptCurrent===!0,x.excluded=!x.anchored,x.needsSummary=x.anchored}catch(te){throw x.anchored=!1,x.excluded=!0,x.initialized=!1,te}}),r!==x||!x.anchored||x.excluded||!x.memory)return;let[St,...jt]=J;return{messages:[{...St,content:Re+`
10
10
 
11
11
  <memindex-context>
12
12
  `+x.memory+`
13
- </memindex-context>`},...jt]}}),e.on("tool_result",(b,C)=>{let x=r;if(!x||!b.toolName||b.toolName.startsWith("mem_"))return;let J=on(b.content);return i(x,C,async()=>{!x.anchored||x.excluded||await t.post("/api/sessions/observations",{contentSessionId:x.id,cwd:x.cwd,platformSource:"pi",tool_name:b.toolName,tool_input:b.input,tool_response:J.slice(0,1e5),tool_use_id:b.toolCallId})})}),e.on("message_end",b=>{r&&b.message?.role==="assistant"&&(r.lastAssistant=on(b.message.content))});let l=(b,C)=>{let x=r;if(x)return i(x,C,async()=>{!x.anchored||x.excluded||!x.needsSummary||(await t.post("/api/sessions/summarize",{contentSessionId:x.id,cwd:x.cwd,platformSource:"pi",last_assistant_message:x.lastAssistant}),x.needsSummary=!1)})};e.on("agent_end",l),e.on("session_before_compact",l),e.on("session_shutdown",(b,C)=>l(b,C));let v=(b,C,x,J,Re)=>{e.registerTool({name:b,label:C,description:x,parameters:J,async execute(Xe,$t,bt){try{let jt=await(await Re($t,bt)).text(),te=jt;try{let ke=JSON.parse(jt);Array.isArray(ke.content)&&(te=on(ke.content))}catch{}return{content:[{type:"text",text:te}],details:{}}}catch(St){return{content:[{type:"text",text:"Memory request failed: "+String(St)}],details:{}}}}})},j=H.Optional(H.Integer({minimum:1,maximum:50}));v("mem_search","Memory search","Search memory for an index of IDs; use timeline, then fetch only useful observations.",H.Object({query:H.String(),limit:j}),(b,C)=>{let x=new URLSearchParams({query:String(b.query),limit:String(b.limit??10)});return t.request("/api/search?"+x,{signal:C})}),v("mem_timeline","Memory timeline","Inspect the neighborhood of an observation ID or search query. Supply anchor or query.",H.Object({anchor:H.Optional(H.Union([H.Integer(),H.String()])),query:H.Optional(H.String()),depth_before:H.Optional(H.Integer({minimum:0,maximum:50})),depth_after:H.Optional(H.Integer({minimum:0,maximum:50})),project:H.Optional(H.String())}),(b,C)=>{if(b.anchor===void 0==(b.query===void 0))throw new Error("Supply exactly one of anchor or query.");let x=new URLSearchParams(Object.entries(b).filter(([,J])=>J!==void 0).map(([J,Re])=>[J,String(Re)]));return t.request("/api/timeline?"+x,{signal:C})}),v("mem_get_observations","Memory observations","Fetch full records for IDs found by mem_search.",H.Object({ids:H.Array(H.Integer({minimum:1}),{minItems:1,maxItems:100})}),(b,C)=>t.request("/api/observations/batch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b),signal:C}))}export{Hg as default,on as extractTextContent};
13
+ </memindex-context>`},...jt]}}),e.on("tool_result",(b,C)=>{let x=r;if(!x||!b.toolName||b.toolName.startsWith("mem_"))return;let J=mn(b.content);return s(x,C,async()=>{!x.anchored||x.excluded||await t.post("/api/sessions/observations",{contentSessionId:x.id,cwd:x.cwd,platformSource:"pi",tool_name:b.toolName,tool_input:b.input,tool_response:J.slice(0,1e5),tool_use_id:b.toolCallId})})}),e.on("message_end",b=>{r&&b.message?.role==="assistant"&&(r.lastAssistant=mn(b.message.content))});let l=(b,C)=>{let x=r;if(x)return s(x,C,async()=>{!x.anchored||x.excluded||!x.needsSummary||(await t.post("/api/sessions/summarize",{contentSessionId:x.id,cwd:x.cwd,platformSource:"pi",last_assistant_message:x.lastAssistant}),x.needsSummary=!1)})};e.on("agent_end",l),e.on("session_before_compact",l),e.on("session_shutdown",(b,C)=>l(b,C));let v=(b,C,x,J,Re)=>{e.registerTool({name:b,label:C,description:x,parameters:J,async execute(Xe,gt,$t){try{let jt=await(await Re(gt,$t)).text(),te=jt;try{let ke=JSON.parse(jt);Array.isArray(ke.content)&&(te=mn(ke.content))}catch{}return{content:[{type:"text",text:te}],details:{}}}catch(St){return{content:[{type:"text",text:"Memory request failed: "+String(St)}],details:{}}}}})},j=H.Optional(H.Integer({minimum:1,maximum:50}));v("mem_search","Memory search","Search memory for an index of IDs; use timeline, then fetch only useful observations.",H.Object({query:H.String(),limit:j}),(b,C)=>{let x=new URLSearchParams({query:String(b.query),limit:String(b.limit??10)});return t.request("/api/search?"+x,{signal:C})}),v("mem_timeline","Memory timeline","Inspect the neighborhood of an observation ID or search query. Supply anchor or query.",H.Object({anchor:H.Optional(H.Union([H.Integer(),H.String()])),query:H.Optional(H.String()),depth_before:H.Optional(H.Integer({minimum:0,maximum:50})),depth_after:H.Optional(H.Integer({minimum:0,maximum:50})),project:H.Optional(H.String())}),(b,C)=>{if(b.anchor===void 0==(b.query===void 0))throw new Error("Supply exactly one of anchor or query.");let x=new URLSearchParams(Object.entries(b).filter(([,J])=>J!==void 0).map(([J,Re])=>[J,String(Re)]));return t.request("/api/timeline?"+x,{signal:C})}),v("mem_get_observations","Memory observations","Fetch full records for IDs found by mem_search.",H.Object({ids:H.Array(H.Integer({minimum:1}),{minItems:1,maxItems:100})}),(b,C)=>t.request("/api/observations/batch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b),signal:C}))}export{l$ as default,mn as extractTextContent};