omo-ai 5.1.13 → 5.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- // omo:Ip8jMHx84o25YCHFHXxaYeJSA5Q1UPMjuu1o5i4Ackg:UPxDo3aLbw2tsFydwCP7Bj5JHXaMHAyNFpu7kcfRK38
2
- import{existsSync as e}from"node:fs";import{dirname as t,join as n}from"node:path";import{fileURLToPath as r,pathToFileURL as i}from"node:url";import{randomUUID as o}from"node:crypto";import{existsSync as u}from"node:fs";import{fileURLToPath as s}from"node:url";import{Worker as a}from"node:worker_threads";var d=1048576,c="gateway-store-worker.mjs";function l(e){let t,n,r={agent_dir:e.agentDir,busy_timeout_ms:e._test?.busyTimeoutMs??5e3,lock_wait_max_ms:e._test?.lockWaitMaxMs??3e4,instance_id:e.instanceId??o(),runtime_instance:e.runtimeInstance??null,legacy_mailbox_directories:e.legacyMailboxDirectories??[],test_hooks:{...void 0===e._test?.beforeDbCommit?{}:{beforeDbCommit:e._test.beforeDbCommit},...void 0===e._test?.afterDbCommit?{}:{afterDbCommit:e._test.afterDbCommit},...void 0===e._test?.announceBarrier?{}:{announceBarrier:e._test.announceBarrier}}},i=e.now??Date.now,d=new Map,l=new Set,f=1,p=!1;function m(e,t){for(let[n,r]of d)r.worker===e&&(d.delete(n),r.reject(t))}function h(e,n){let r=t;if(void 0===r)return Promise.reject(Error("the gateway store is closed"));let i=f++,o=new Promise((e,t)=>d.set(i,{worker:r,resolve:e,reject:t}));return r.ref(),r.postMessage({type:"request",id:i,op:e,args:n}),o}function _(){if(p)return Promise.reject(Error("the gateway store is disposed"));if(void 0!==n)return n;let o=process.execArgv.filter(e=>!e.startsWith("--input-type")),f=new a(function(e=import.meta.url){let t=new URL(`./${c}`,e);return u(s(t))?t:new URL("./store-worker.ts",e)}(e._test?.moduleUrl??e.workerModuleUrl),{execArgv:o});t=f,f.unref(),f.on("message",e=>{if("event"===e.type){for(let t of l)t(e.event);return}let t=d.get(e.id);void 0!==t&&(d.delete(e.id),0===d.size&&f.unref(),e.ok?t.resolve(e.value):t.reject(Object.assign(Error(e.error.message),{workerStack:e.error.stack,...void 0===e.error.code?{}:{code:e.error.code}})))}),f.on("error",e=>m(f,e instanceof Error?e:Error(String(e)))),f.on("exit",e=>{t===f&&(t=void 0,n=void 0),m(f,Error(`the gateway store worker exited (${e})`))}),e._test?.onWorkerStarted?.(f);let _=h("init",{config:r,now:i()});return n=_,_.catch(()=>{n===_&&(n=void 0,t===f&&(t=void 0),f.terminate())}),_}async function g(e,t){return await _(),await h(e,t)}return{busyTimeoutMs:r.busy_timeout_ms,now:i,identity:async()=>(await _()).self,enqueue:e=>g("enqueue",e),reconcile:e=>g("reconcile",e),claim:e=>g("claim",e),recordOutcome:e=>g("record_outcome",e),refuseQueued:e=>g("refuse_queued",e),completeReceipt:e=>g("complete_receipt",e),abandonReceipt:e=>g("abandon_receipt",e),deliveryView:e=>g("delivery_view",e),deliveryReceipt:e=>g("delivery_receipt",e),recoverDelivery:e=>g("recover_delivery",e),list:(e={})=>g("list",e),isReferenced:e=>g("is_referenced",e),journalMode:()=>g("journal_mode"),stats:()=>g("stats"),legacyMigrated:async()=>(await _()).legacy_migrated,toolReceiptBegin:e=>g("tool_receipt_begin",e),toolReceiptSettle:e=>g("tool_receipt_settle",e),bind:e=>g("bind",e),unbind:e=>g("unbind",e),rebind:e=>g("rebind",e),listBindings:e=>g("list_bindings",e),bindingView:e=>g("binding_view",e),registerIncarnation:e=>g("register_incarnation",e),clearEndpoint:e=>g("clear_endpoint",e),sessionOwner:e=>g("session_owner",e),report:e=>g("report",e),emitCompletions:e=>g("emit_completions",e),pendingCompletionArms:e=>g("pending_completion_arms",e),latestCompletionArm:e=>g("latest_completion_arm",e),readOutbox:e=>g("read_outbox",e),ackOutbox:e=>g("ack_outbox",e),claimAnswer:e=>g("claim_answer",e),releaseAnswer:e=>g("release_answer",e),confirmAnswer:e=>g("confirm_answer",e),markPriorDelivered:e=>g("mark_prior_delivered",e),onEvent:e=>(l.add(e),()=>l.delete(e)),resume:e=>t?.postMessage({type:"resume",hook:e}),dispose:async()=>{if(p)return;p=!0;let e=t;void 0!==e&&(await h("close",null).catch(()=>{}),t=void 0,await e.terminate())}}}import{randomUUID as f}from"node:crypto";import{join as p}from"node:path";var m=new Set(["invalid_arguments","caller_context_missing","not_found","ambiguous_target","scope_denied","name_conflict","not_resumable","orphaned","foreign_live_owner","no_active_turn","turn_conflict","not_steerable","message_too_large","queue_full","cursor_invalid","cursor_stale","idempotency_conflict","idempotency_in_progress","idempotency_uncertain","approval_unavailable","approval_route_locked","partial_commit","unsupported","overloaded","transport_closed","host_unavailable","internal_error","model_not_found","model_ambiguous","thinking_level_unsupported","loop_detected","binding_conflict","binding_mismatch","binding_inactive","stale_revision","stale_token","already_answered","answer_in_progress"]);function h(e,t,n,r){if("string"!=typeof(i=e)||!m.has(i))throw Error(`unknown thread error code: ${String(e)}`);var i;return{code:e,message:t,next_action:n,...void 0===r?{}:{details:r}}}var _=["question","select","confirm","input","editor"];var g=new Map([["yes",!0],["y",!0],["true",!0],["no",!1],["n",!1],["false",!1]]);function y(e){return""===e.replace(/[\s\p{Cf}]/gu,"")}function v(e){let t=g.get(e.trim().toLowerCase());return void 0===t?{value:e,answers:{},comment:e}:{value:e,answers:{},comment:e,confirmed:t}}function b(e,t){switch(e){case null:return y(t)?{ok:!1,reason:"The question declared no request kind, so the answer needs text; this one is blank. An input or editor that takes an empty answer must be reported with its request kind."}:{ok:!0,fields:v(t)};case"input":case"editor":return{ok:!0,fields:{value:t}};case"select":return y(t)?{ok:!1,reason:"A select answer names one of its options; the text is blank."}:{ok:!0,fields:{value:t}};case"question":return y(t)?{ok:!1,reason:"A question answer needs text; this one is blank."}:{ok:!0,fields:{answers:{},comment:t}};case"confirm":{let e=g.get(t.trim().toLowerCase());return void 0===e?{ok:!1,reason:"A confirm answer is yes or no (also y/n, true/false; any case, surrounding spaces ignored)."}:{ok:!0,fields:{confirmed:e}}}default:return function(e){throw Error(`unknown extension UI request kind: ${String(e)}`)}(e)}}import{createHash as w,createHmac as k,randomUUID as x,timingSafeEqual as $}from"node:crypto";var A=["discord","telegram","slack","notion","feishu","herdr","custom"],S=["milestone","report","question","completion"],O=["auto","follow_up"],I=31622400,E=32768;function R(e){return{kind:"refused",code:"invalid_arguments",message:e}}function P(e,t){return"string"!=typeof t||0===t.trim().length?R(`${e} must be a non-empty string.`):t.length>256?R(`${e} is longer than 256 characters.`):/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/.test(t)?R(`${e} carries a control character or a line separator.`):t}function q(e,t){return null==t?null:P(e,t)}function M(e){return"object"==typeof e&&null!==e&&"refused"===e.kind}function T(e){if(null===e||"object"!=typeof e)return JSON.stringify(e)??"null";if(Array.isArray(e))return`[${e.map(T).join(",")}]`;let t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${T(t[e])}`).join(",")}}`}import{execFile as C}from"node:child_process";import{createConnection as N}from"node:net";import{randomUUID as j}from"node:crypto";import{existsSync as L,readFileSync as B}from"node:fs";import{resolve as z}from"node:path";import{join as D}from"node:path";var U=["OMO_RPC_SOCKET","SENPI_RPC_SOCKET","PI_RPC_SOCKET","OMO_RPC_SOCKET_PATH"];import{existsSync as F}from"node:fs";import{homedir as W}from"node:os";import{join as G,resolve as K}from"node:path";var J=["OMO_CODING_AGENT_DIR","SENPI_CODING_AGENT_DIR","PI_CODING_AGENT_DIR"],H="settings.json";function V(e){let{env:t,homeDir:n=W(),exists:r=F}=e;for(let e of J){let n=t[e]?.trim();if(n)return K(n)}let i=G(n,".omo"),o=G(i,"agent");return r(G(o,H))?o:r(G(i,H))?i:G(n,".senpi","agent")}import*as Z from"node:fs";import*as X from"node:fs/promises";function Q(e){if(e instanceof Error&&"code"in e)return"string"==typeof e.code?e.code:void 0}function Y(e){for(let t=0;;t+=1)try{return e()}catch(e){if("EINTR"!==Q(e)||t>=128)throw e}}function ee(e){return"function"==typeof e}function te(e){return(...t)=>async function(e){for(let t=0;;t+=1)try{return await e()}catch(e){if("EINTR"!==Q(e)||t>=128)throw e}}(async()=>e(...t))}function ne(e){return(...t)=>Y(()=>e(...t))}function re(e,t){let n="async"===t?te:ne,r=new Map;return new Proxy(e,{get(e,t){if(r.has(t))return r.get(t);let i=Reflect.get(e,t);if(!ee(i))return i;let o=n(i),u=Reflect.get(i,"native");return ee(u)&&Object.assign(o,{native:n(u)}),r.set(t,o),o}})}var ie=re(X,"async"),oe=re(Z,"sync"),{access:ue,chmod:se,copyFile:ae,cp:de,link:ce,lstat:le,mkdir:fe,mkdtemp:pe,readFile:me,readdir:he,realpath:_e,rename:ge,rm:ye,rmdir:ve,stat:be,unlink:we}=ie,{accessSync:ke,chmodSync:xe,fsyncSync:$e,linkSync:Ae,lstatSync:Se,mkdirSync:Oe,readFileSync:Ie,readdirSync:Ee,realpathSync:Re,statSync:Pe,unlinkSync:qe,writeFileSync:Me,writeSync:Te}=oe;function Ce(e){try{return Y(()=>Z.statSync(e)),!0}catch{return!1}}import{createRequire as Ne}from"node:module";import{isAbsolute as je,join as Le,relative as Be}from"node:path";import{createRequire as ze}from"node:module";import{existsSync as De,readFileSync as Ue,realpathSync as Fe,statSync as We}from"node:fs";import{createRequire as Ge}from"node:module";import{delimiter as Ke,dirname as Je,isAbsolute as He,join as Ve,resolve as Ze,sep as Xe}from"node:path";Ge(import.meta.url);function Qe(e){return e.includes("$bunfs")||e.includes("~BUN")||e.includes("%7EBUN")}function Ye(){return typeof Bun<"u"&&Bun.embeddedFiles.length>0}function et(e,t,n){for(let r of(t??"").split(Ke)){if(0===r.length)continue;let t=tt(Ve(r,e));if(null!==t&&(void 0===n||n(t)))return t}return null}function tt(e){try{let t=Fe.native(Ze(e));return We(t).isFile()?t:null}catch{return null}}function nt(e,t){let n=t.engineVersion;if(void 0===n||0===n.length)return!0;let r=function(e){let t=Je(e);for(let e=0;e<=3;e+=1){try{let e=JSON.parse(Ue(Ve(t,"package.json"),"utf8"));if("@code-yeongyu/senpi"===e.name&&"string"==typeof e.version&&e.version.length>0)return e.version}catch{}let e=Je(t);if(e===t)break;t=e}}(e);return void 0===r||(r===n||(t.onWarning?.(`Skipping senpi executable ${e} version ${r}; running engine is ${n}`),!1))}function rt(e){let t="win32"===e.platform?"senpi.exe":"senpi",n=e.parentEnv.SENPI_BIN?.trim();if(void 0!==n&&n.length>0)return n.includes("/")||n.includes(Xe)||He(n)?tt(n):et(n,e.parentEnv.PATH);if(!0===e.isCompiledEngine)return tt(e.execPath);let r=t=>nt(t,e);if(e.isBunBinary){let n=tt(Ve(Je(e.execPath),t));return null!==n&&r(n)?n:null}return et(t,e.parentEnv.PATH,r)}function it(e,t){if("win32"!==t.platform||e.toLowerCase().endsWith(".exe"))return{command:e,prefixArgs:[]};let n=Je(e),r=[Ve(n,"node_modules","@code-yeongyu","senpi","dist","cli.js"),Ve(n,"..","@code-yeongyu","senpi","dist","cli.js")].find(e=>De(e));return void 0===r?null:{command:t.execPath,prefixArgs:[r]}}function ot(e){let t=(e.resolveSenpiExecutable??rt)(e);if(null!==t){if(function(e,t){return!0===t.isCompiledEngine&&tt(t.execPath)===e}(t,e))return{command:t,prefixArgs:[]};let n=it(t,e);if(null!==n)return n}if("win32"!==e.platform)return null;for(let t of["senpi.cmd","senpi"]){let n=et(t,e.parentEnv.PATH);if(null===n)continue;let r=it(n,e);if(null!==r)return r}return null}ze(import.meta.url);var ut=Le("@code-yeongyu","senpi"),st=Le("dist","cli.js");function at(e,t=function(){return{isBunBinary:Qe(import.meta.url),isCompiledEngine:Ye(),execPath:process.execPath,platform:process.platform,argv:process.argv,resolveInstalledCli:pt}}()){let n=ot({isBunBinary:t.isBunBinary,isCompiledEngine:t.isCompiledEngine,execPath:t.execPath,platform:t.platform,parentEnv:e,resolveRpcEntry:()=>""});if(null!==n)return n;let r=t.resolveInstalledCli();if(null!==r)return{command:t.execPath,prefixArgs:[r]};let i=t.argv[1];if(void 0!==i&&je(i)&&Ce(i))return{command:t.execPath,prefixArgs:[i]};throw Error("Unable to resolve a runnable Senpi launcher")}var dt=["OMO_PACKAGE_DIR","SENPI_PACKAGE_DIR","PI_PACKAGE_DIR"];function ct(e){try{return Re.native(e)}catch{return e}}function lt(e,t){let n=Be(ct(e),ct(t));return n.length>0&&!n.startsWith("..")&&!je(n)}function ft(e,t){let n=t.prefixArgs[0]??t.command,r={...e};for(let e of dt){let t=r[e];void 0!==t&&0!==t.length&&(lt(t,n)||delete r[e])}return r}function pt(){let e=Ne(import.meta.url);for(let t of e.resolve.paths(Le(ut,"package.json"))??[]){let e=Le(t,ut,st);if(Ce(e))return e}return null}import{readdirSync as mt,readFileSync as ht}from"node:fs";import{basename as _t,join as gt,resolve as yt}from"node:path";import{execFileSync as vt}from"node:child_process";import{realpathSync as bt}from"node:fs";var wt=/[\u0000-\u0008\u000e-\u001f\u007f]/;function kt(e){return e.normalize("NFKC").trim().toLowerCase().replace(/\s+/g," ")}function xt(e,t,n,r){let i=h(e,t,n,void 0===r?void 0:{candidates:r});return void 0===r?{kind:"error",...i}:{kind:"error",...i,candidates:r}}function $t(e){return{id:e.thread_id,name:e.name,cwd:e.cwd,preview:e.preview??"",updatedAt:e.updated_at,state:e.status}}function At(e){try{return bt(e)}catch{return e}}function St(e){try{let t=vt("git",["-C",e,"rev-parse","--show-toplevel"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3,windowsHide:!0}).trim();return 0===t.length?null:t}catch{return null}}function Ot(){let e=new Map;return t=>{if(e.has(t))return e.get(t)??null;let n=St(t);return e.set(t,n),n}}function It(e,t,n){let r=n(e),i=n(t);return null!==r&&null!==i?At(r)===At(i):At(e)===At(t)}function Et(e){let t=e.trim();if(0===t.length)return[];let n=St(t);return[...new Set((null===n?[t]:[t,n]).flatMap(e=>[e,At(e)]))]}function Rt(e,t,n={}){let r=function(e,t){if("string"!=typeof e)return{ok:!1,error:xt("invalid_arguments",`The ${t} must be a string.`,`Pass a thread_id or a unique name from thread_list as the ${t}.`)};if(wt.test(e))return{ok:!1,error:xt("invalid_arguments",`The ${t} contains control characters.`,"Remove the control characters and retry, or pass an address from thread_list.")};let n=kt(e);return 0===n.length?{ok:!1,error:xt("invalid_arguments",`The ${t} is empty.`,`Pass a thread_id or a unique name from thread_list as the ${t}.`)}:{ok:!0,normalized:n}}(t,"thread address");if(!r.ok)return r.error;let i,o="string"==typeof n.callerWorkspaceRoot?n.callerWorkspaceRoot.trim():"",u=o.length>0,s=Ot(),a=e.find(e=>e.thread_id===t);if(void 0!==a)return!0===n.all_scope?{kind:"ok",entry:a,resolution:"id"}:u?It(a.cwd,o,s)?{kind:"ok",entry:a,resolution:"id"}:xt("scope_denied",`Thread ${a.thread_id} exists outside this workspace.`,"Call thread_list with all_scope to confirm the id, then retry with all_scope set, or target a thread in this workspace."):xt("caller_context_missing","Scoping an id hit needs the caller's workspace root, which this call did not provide.","Set all_scope to address every workspace, or call thread_list from a session that knows its workspace.");if(!0===n.all_scope)i=e;else{if(!u)return xt("caller_context_missing","Scoped address resolution needs the caller's workspace root, which this call did not provide.","Set all_scope to address every workspace, or call thread_list from a session that knows its workspace.");i=e.filter(e=>It(e.cwd,o,s))}let d=i.filter(e=>kt(e.name)===r.normalized);return 1===d.length?{kind:"ok",entry:d[0],resolution:"name"}:d.length>=2?xt("ambiguous_target",`${d.length} visible threads share the name "${t}".`,"Call thread_list and pass the exact thread_id of the intended thread.",function(e){return[...e].sort((e,t)=>e.updated_at===t.updated_at?e.thread_id<t.thread_id?-1:1:null===e.updated_at?1:null===t.updated_at?-1:e.updated_at<t.updated_at?1:-1).slice(0,10).map($t)}(d)):xt("not_found",`No visible thread matches "${t}" in ${!0===n.all_scope?"the daemon-wide scope":"this workspace"}.`,"Call thread_list and pass the thread_id or a unique name it returned.")}import{closeSync as Pt,fstatSync as qt,openSync as Mt,readSync as Tt}from"node:fs";var Ct=65536,Nt=262144;function jt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Lt(e){return"string"==typeof e?e:Array.isArray(e)?e.flatMap(e=>jt(e)&&"text"===e.type&&"string"==typeof e.text?[e.text]:[]).join(" "):""}function Bt(e,t){let n=e?.trim();if(void 0!==n&&n.length>0)return n;let r=t?.replace(/\s+/g," ").trim();return void 0===r||0===r.length?null:[...r].slice(0,60).join("")}function zt(e,t=!1,n=!1){let r=e.split("\n");return t&&r.shift(),n&&r.pop(),r.flatMap(e=>{if(0===e.trim().length)return[];try{let t=JSON.parse(e);return jt(t)?[t]:[]}catch{return[]}})}function Dt(e){let t=null,n=null,r=null,i="";for(let o of e){if(null===t&&"session"===o.type&&"string"==typeof o.id&&(t=o),"session_info"===o.type&&(n="string"==typeof o.name&&o.name.trim().length>0?o.name.trim():null),null===r&&"message"===o.type&&jt(o.message)&&"user"===o.message.role){let e=Lt(o.message.content).trim();e.length>0&&(r=e)}"string"==typeof o.timestamp&&o.timestamp>i&&(i=o.timestamp)}return{header:t,name:n,first_user_text:r,newest_timestamp:i}}function Ut(e,t=Tt){let n;try{n=Mt(e,"r")}catch{return null}try{let e=qt(n),r=e.size,i=Math.min(r,Ct),o=Buffer.alloc(i);t(n,o,0,i,0);let u=r<=Ct,s=zt(o.toString("utf8"),!1,!u),a=s[0];if(void 0===a||"session"!==a.type||"string"!=typeof a.id||"string"!=typeof a.cwd||"string"!=typeof a.timestamp)return null;let d=[];if(!u){let e=Math.max(i,r-Ct),o=Buffer.alloc(r-e+1);t(n,o,0,o.length,e-1),d=zt(o.subarray(1).toString("utf8"),10!==o[0],!1)}let c=Dt([...s,...d]),l=function(e,t,n){if(0===t)return null;let r=Buffer.allocUnsafe(1);if(1!==n(e,r,0,1,t-1)||10!==r[0])return null;let i=t-1,o=0,u=[];for(;i>0&&o<Nt;){let t=Math.min(Ct,i,Nt-o),r=i-t,s=Buffer.allocUnsafe(t);if(n(e,s,0,t,r)!==t)return null;let a=s.lastIndexOf(10);if(u.unshift(-1===a?s:s.subarray(a+1)),-1!==a||0===r)return Buffer.concat(u);o+=t,i=r}return null}(n,r,t),f=qt(n),p=f.size===e.size&&f.mtimeMs===e.mtimeMs?function(e){if(null===e)return null;try{let t=JSON.parse(e.toString("utf8"));return jt(t)&&"string"==typeof t.timestamp&&t.timestamp.length>0?t.timestamp:null}catch{return null}}(l):null;return{durable_id:a.id,cwd:a.cwd,created_at:a.timestamp,updated_at:p,name:c.name,first_user_text:c.first_user_text}}catch{return null}finally{Pt(n)}}function Ft(e,t,n){if("tui"===e)return"tui";if("worker"===t)return"child";let r=_t(n);return r.startsWith("i-")?"desktop":r.startsWith("p-")?"child":"daemon"}function Wt(e){if(e instanceof Error)return e.message;if("string"==typeof e)return e;if("object"==typeof e&&null!==e){let t=e.message;if("string"==typeof t)return t;let n=e.error;if(void 0!==n)return Wt(n)}return String(e)}function Gt(e){return e.list_sessions??e.result}function Kt(e){if(void 0!==e.error)return null;let t=Gt(e);return void 0===t||"kind"in t&&"error"===t.kind?null:"data"in t?t.data.sessions:t.sessions}function Jt(e){if("live_unresponsive"===e.reason)return"live_unresponsive";if(void 0!==e.error)return Wt(e.error);let t=Gt(e);return void 0===t?"host unavailable":"kind"in t&&"error"===t.kind?Wt(t.error):null}function Ht(e,t){return"string"==typeof e&&e.length>0?e:t}function Vt(e,t,n){let r=null===e.source_host?null:{kind:t?.endpoint_kind??"rpc_host",socket:e.source_host,routing_id:null};return{durable_id:e.durable_id,routing_id:null,name:e.name,cwd:e.cwd,status:"resumable",liveness:"resumable",source_host:e.source_host,session_path:e.session_path,created_at:e.created_at,updated_at:e.updated_at,thread_id:e.durable_id,...void 0===n?{}:{error_note:n},endpoint:r,surface:null===r?null:Ft(r.kind,void 0,r.socket),alive:!1,title:Bt(e.name,e.first_user_text)}}function Zt(e){return e.map(e=>({thread_id:e.thread_id,name:e.name??"",status:e.status,cwd:e.cwd,created_at:e.created_at,updated_at:e.updated_at}))}function Xt(e){return e.map(e=>({thread_id:e.thread_id,name:e.name??"",status:e.status,cwd:e.cwd,created_at:e.created_at,updated_at:e.updated_at,endpoint:e.endpoint,liveness:e.alive?"routable":"live_unresponsive"===e.error_note?"live_unresponsive":"dead"}))}function Qt(e){return`--${yt(e).replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}-`}function Yt(e){let t=Ut(e);return null===t?null:{durable_id:t.durable_id,name:t.name,cwd:t.cwd,created_at:t.created_at,updated_at:t.updated_at,session_path:e,source_host:null,...null===t.first_user_text?{}:{first_user_text:t.first_user_text}}}import{createHash as en}from"node:crypto";import{realpathSync as tn}from"node:fs";import{readdir as nn,readFile as rn}from"node:fs/promises";import{basename as on,dirname as un,join as sn}from"node:path";var an=/^[0-9a-f]{16}$/,dn=/^t-[0-9a-f]{16}\.sock$/;function cn(e){return dn.test(on(e))}function ln(e){return e.startsWith("\0")?e:sn(function(e){let t=[],n=e;for(;;)try{return sn(tn(n),...t.reverse())}catch{let r=un(n);if(r===n)return e;t.push(on(n)),n=r}}(un(e)),on(e))}function fn(e){return en("sha256").update(e,"utf8").digest("hex").slice(0,16)}async function pn(e){let t;try{t=await rn(e,"utf8")}catch{return}try{let e=JSON.parse(t);return"object"!=typeof e||null===e||Array.isArray(e)?void 0:e}catch{return}}async function mn(e,t){let n=await pn(e),r=n?.socket;if(void 0!==n&&"string"==typeof r&&""!==r)return function(e,t){return fn(ln(e))===t||fn(e)===t}(r,on(t))?{socket:r,record:n}:void 0}async function hn(e){let t=sn(e,"rpc-host-daemon");if(2!==(await pn(sn(t,"layout.json")))?.layout)return[];let n=(await nn(t,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isDirectory()&&an.test(e.name)).map(e=>sn(t,e.name)).sort();return await Promise.all(n.map(e=>async function(e){let t=await mn(sn(e,"endpoint.json"),e);if(void 0!==t)return{socket:t.socket,dir:e,identity:"endpoint",endpoint_kind:"tui"===t.record.endpoint_kind?"tui":"rpc_host",registry_version:"number"==typeof t.record.registry_version?t.record.registry_version:null};let n=await mn(sn(e,"settings.json"),e);if(void 0!==n)return{socket:n.socket,dir:e,identity:"settings",endpoint_kind:"rpc_host",registry_version:null};let r=await nn(sn(e,"generations")).catch(()=>[]);for(let t of r.sort()){let n=await mn(sn(e,"generations",t,"settings.json"),e);if(void 0!==n)return{socket:n.socket,dir:e,identity:"generation-settings",endpoint_kind:"rpc_host",registry_version:null}}return{socket:null,dir:e,identity:"unknown",endpoint_kind:"rpc_host",registry_version:null}}(e)))}function _n(e,t){if(cn(e))return"tui";let n=ln(e);return t.find(t=>null!==t.socket&&(t.socket===e||ln(t.socket)===n))?.endpoint_kind??"rpc_host"}function gn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var yn=1500,vn=["host","status","--all","--include-workers","--json"],bn={observe:!0},wn=new Set(["get_protocol_info","list_sessions","get_state","get_messages","set_session_name","wake","subscribe","extension_ui_response"]);function kn(e=process.env){return function(e,t){for(let t of U){let n=e[t]?.trim();if(n)return n}return D(t,"rpc","rpc.sock")}(e,V({env:e}))}function xn(e,t){return Array.isArray(e)?e.flatMap(e=>gn(e)&&"string"==typeof e[t]&&""!==e[t]?[e[t]]:[]):[]}function $n(e){if(!gn(e)||!gn(e.session))return[];let t=e.session.path;return"string"==typeof t&&""!==t?[t]:[]}function An(e){let t,n=e?.trim().split("\n").filter(e=>""!==e.trim()).pop();if(void 0!==n){try{t=JSON.parse(n)}catch{return}return gn(t)&&Array.isArray(t.endpoints)?t.endpoints.flatMap(e=>gn(e)?[{socket:"string"==typeof e.socket&&""!==e.socket?e.socket:null,reachable:!0===e.reachable,session_paths:[...new Set([...xn(e.session_rows,"session_path"),...xn(e.claims,"session_path"),...$n(e.owner)])],..."tui"===e.endpoint_kind||"rpc_host"===e.endpoint_kind?{endpoint_kind:e.endpoint_kind}:{},..."boolean"==typeof e.alive?{alive:e.alive}:{},..."live_unresponsive"===e.reason||"dead"===e.reason?{reason:e.reason}:null===e.reason?{reason:null}:{}}]:[]):void 0}}function Sn(e){let t=gn(e)?e.code:void 0;return"ENOENT"===t||"ECONNREFUSED"===t}function On(e){if(!0===e.success&&gn(e.data)&&!0===e.data.released&&"string"==typeof e.data.session_path)return{success:!0,data:e.data};let t="string"==typeof e.error?e.error:"release_failed";return gn(e.errorData)?{success:!1,error:t,errorData:e.errorData}:{success:!1,error:t}}var In=new Set(["started","queued","steered","turn_conflict","held_draft","already_admitted"]);function En(e){return Array.isArray(e.admitted)?{admitted:e.admitted.flatMap(e=>gn(e)&&"string"==typeof e.delivery_id&&"string"==typeof e.kind&&In.has(e.kind)?[{delivery_id:e.delivery_id,kind:e.kind}]:[])}:{admitted:[]}}function Rn(e,t={}){let n,r=t.env??process.env,i=t.exists??L,o=t.connect??(e=>N(e)),u=t.now??Date.now,s=t.statusAll??function(e){return async()=>{let t;try{t=at({...e})}catch{return}return An(await new Promise(n=>{C(t.command,[...t.prefixArgs,...vn],{env:ft({...e},t),timeout:3e4,maxBuffer:16777216,windowsHide:!0},(e,t)=>n("string"==typeof t?t:void 0))}))}}(r),a=t.registry??(()=>hn(V({env:r}))),d=t.readSecret??(e=>B(function(e){return`${e}.secret`}(e))),c=kn(t.env),l=new Map,f=new Map,p=async(e,t,n={},r)=>{let u,s="tui"===(e=>f.get(z(e))??(cn(e)?"tui":"rpc_host"))(e);if(s&&!wn.has(t))throw Error(`unsupported:${t}`);if(!i(e))throw Error(`host_unavailable:${e}`);if(s)try{u=d(e)}catch{throw Error(`host_unavailable:${e}`)}return await async function(e,t,n,r={}){let i=j();return await new Promise((o,u)=>{let s=n(e),a="",d=setTimeout(()=>{s.destroy(),u(Error("thread RPC request timed out"))},r.timeoutMs??6e4),c=(e,t)=>{clearTimeout(d),s.destroy(),void 0===e?o(t):u(e)};s.once("error",e=>c(e)),s.once("close",()=>c(Error(`thread RPC connection closed before the ${String(t.type)} response arrived`))),s.once("connect",()=>{void 0!==r.secret&&s.write(Buffer.from(r.secret)),s.write(`${JSON.stringify({...t,id:i})}\n`)}),s.on("data",e=>{a+=e.toString("utf8");let t=a.indexOf("\n");for(;t>=0;){let e,n=a.slice(0,t);if(a=a.slice(t+1),t=a.indexOf("\n"),""!==n.trim()){try{e=JSON.parse(n)}catch(e){return void c(e instanceof Error?e:Error(String(e)))}if(gn(e)&&e.id===i)return void c(void 0,e)}}})})}(e,{type:t,...n},o,{timeoutMs:r??(s?yn:void 0),secret:u})},m=async(e,t,n={},r)=>function(e,t){if(!1===e.success&&"set_thinking_level"===t&&"string"==typeof e.error&&/^Thinking level .+ is not supported by the active model\.$/.test(e.error))throw Error(`thinking_level_unsupported:${e.error}`);if(!1===e.success&&"unsupported"===e.error)throw Error(`unsupported:${String(t)}`);if(e.success&&void 0===e.data&&("set_session_name"===t||"set_thinking_level"===t))return{};if(!e.success||!gn(e.data))throw Error(`thread RPC request failed: ${JSON.stringify(e.error??e)}`);return e.data}(await p(e,t,n,r),t),h=(e,t={})=>m(c,e,t),_=async()=>{let[e,t]=await Promise.all([s().catch(()=>{}),a().catch(()=>[])]),n=void 0===e?t.flatMap(e=>null===e.socket?[]:[{socket:e.socket,paths:[],kind:e.endpoint_kind,verdict:{}}]):e.flatMap(e=>null===e.socket?[]:[{socket:e.socket,paths:e.session_paths,kind:e.endpoint_kind??_n(e.socket,t),verdict:{...void 0===e.alive?{}:{alive:e.alive},...void 0===e.reason?{}:{reason:e.reason}}}]),r=e=>z(e.socket)===z(c),i=[...new Set(n.filter(r).flatMap(e=>e.paths))];return[{socket:c,paths:i,kind:_n(c,t),verdict:{}},...n.filter(e=>!r(e))]},g=async()=>{(void 0===n||n.expiresAt<=u())&&(n={expiresAt:u()+5e3,endpoints:_()});let e=await n.endpoints;for(let t of e)f.set(z(t.socket),t.kind);return e},y=(e,t,n)=>{let r=[...new Set([...e.paths,...l.get(e.socket)??[]])].flatMap(t=>{let n=function(e,t){let n;try{n=ht(e,"utf8")}catch{return null}let r=Ut(e);if(null===r)return null;let{name:i,first_user_text:o}=Dt(zt(n));return{durable_id:r.durable_id,name:i,cwd:r.cwd,created_at:r.created_at,updated_at:r.updated_at,session_path:e,source_host:t,...null===o?{}:{first_user_text:o}}}(t,e.socket);return null===n?[]:[n]});return{host:{socket:e.socket,error:t instanceof Error?t.message:String(t),endpoint_kind:e.kind,alive:!1,reason:n,legacy:e.socket===c},sessions:[],disk:r,failure:t}},v=async e=>{let t="tui"===e.kind;if(t&&!1===e.verdict.alive)return y(e,Error(e.verdict.reason??"live_unresponsive"),e.verdict.reason??"live_unresponsive");try{let{sessions:n}=await m(e.socket,"list_sessions",t?{}:bn,t?yn:1e4),r=n.map(n=>({...n,socket:e.socket,endpoint_kind:e.kind,...t&&void 0===n.durableSessionId?{durableSessionId:n.sessionId}:{}}));return l.set(e.socket,r.flatMap(e=>"string"==typeof e.sessionPath?[e.sessionPath]:[])),{host:{socket:e.socket,list_sessions:{sessions:r},endpoint_kind:e.kind,alive:!0,reason:null,legacy:e.socket===c},sessions:r,disk:[]}}catch(n){if(t&&!i(e.socket))return y(e,Error("dead"),"dead");let r=n instanceof Error&&"thread RPC request timed out"===n.message;return y(e,n,e.verdict.reason??(r?"live_unresponsive":Sn(n)?"dead":null))}},b=async(e={})=>{let t=await g(),n=await Promise.all(t.map(e=>v(e)));for(let e of[...l.keys()])t.some(t=>t.socket===e)||l.delete(e);if(!0!==e.offline&&n.every(e=>void 0!==e.failure))throw n[0]?.failure;return{sessions:n.flatMap(e=>e.sessions),hosts:n.map(e=>e.host),disk:n.flatMap(e=>e.disk)}},w=(e,t)=>({getMessages:async e=>(await t("get_messages",{sessionId:e})).messages,getState:e=>t("get_state",{sessionId:e}),prompt:(e,n,r)=>t("prompt",{sessionId:e,message:n,...r}),interrupt:(e,n)=>t("interrupt",{sessionId:e,...void 0===n?{}:{turnId:n}}),setSessionName:async(e,n)=>{await t("set_session_name",{sessionId:e,name:n})},setModel:(e,n,r)=>t("set_model",{sessionId:e,provider:n,modelId:r}),getAvailableModels:async e=>{let{models:n}=await t("get_available_models",{sessionId:e});return n.map(({provider:e,id:t,name:n})=>({provider:e,id:t,...void 0===n?{}:{name:n}}))},setThinkingLevel:async(e,n,r)=>{await t("set_thinking_level",{sessionId:e,level:n,..."turn"===r?{scope:r}:{}})},getAvailableThinkingLevels:async e=>(await t("get_available_thinking_levels",{sessionId:e})).levels,wake:async(e,n)=>En(await t("wake",{sessionId:e,delivery_ids:[...n]})),releaseSession:async(t,n)=>On(await p(e??c,"release_session",{sessionId:t,...n}))});return{socket:c,listTarget:async(e,t)=>{f.set(z(t.socket),t.kind);let r=("tui"===t.kind&&void 0!==n&&n.expiresAt>u()?await n.endpoints:void 0)?.find(e=>z(e.socket)===z(t.socket))?.verdict,i=await v({socket:t.socket,paths:[],kind:t.kind,verdict:r??{}}),o=i.sessions.filter(t=>(t.durableSessionId??t.sessionId)===e&&"closed"!==t.status);return{sessions:o,hosts:[void 0===i.failure?{...i.host,list_sessions:{sessions:o}}:i.host],disk:[]}},listSessions:async()=>(await b()).sessions,listView:b,endpoint:e=>w(e,(t,n)=>m(e,t,n)),gateway:{wake:async(e,t)=>{f.set(z(e.socket),e.kind);let n="rpc_host"===e.kind&&null!==e.routing_id?{sessionId:e.routing_id}:{};return En(await m(e.socket,"wake",{...n,delivery_ids:[...t]}))},releaseSession:async(e,t)=>{if("rpc_host"!==e.kind||null===e.routing_id)throw Error("unsupported:release_session");return On(await p(e.socket,"release_session",{sessionId:e.routing_id,...t}))},classifyLiveness:async e=>{let t=(await g()).find(t=>z(t.socket)===z(e.socket));if(!0===t?.verdict.alive)return"routable";if("live_unresponsive"===t?.verdict.reason||"dead"===t?.verdict.reason)return t.verdict.reason;try{return await m(e.socket,"get_protocol_info",{},"tui"===e.kind?yn:1e4),"routable"}catch(e){return e instanceof Error&&e.message.startsWith("host_unavailable:")||Sn(e)?"dead":"live_unresponsive"}},respondUi:async(e,t)=>(f.set(z(e.socket),e.kind),await async function(e,t,n){let r="rpc_host"===t.kind&&null!==t.routing_id?{sessionId:t.routing_id}:{},i=await e(t.socket,"extension_ui_response",{...r,uiRequestId:n.ui_request_id,...n.fields});return!0===i.success?{delivered:!0}:{delivered:!1,error:"string"==typeof i.error?i.error:"refused"}}(p,e,t))},openSession:async e=>{let t=await h("open_session",{...e,retain_on_disconnect:!0}),n=t.sessionId,r=e.name;void 0!==r&&""!==r.trim()&&await h("set_session_name",{sessionId:n,name:r});let{sessions:i}=await h("list_sessions",bn),o=i.find(e=>e.sessionId===n);return{...t.state,...o??{},sessionId:n,socket:c,endpoint_kind:"rpc_host"}},...w(void 0,h)}}import{createHash as Pn,randomUUID as qn}from"node:crypto";var Mn={not_steerable:{code:"not_steerable",next:"Send with delivery auto or follow_up; a steer needs a running turn."},turn_conflict:{code:"turn_conflict",next:"Read the target again and retry with its current turn id, or send with delivery auto."},expired:{code:"not_resumable",next:"The target did not take the message within its lifetime; send it again if it still matters."},binding_closed:{code:"invalid_arguments",next:"The binding this message was queued under was detached or rebound; re-read the binding and send again."}};function Tn(e,t,n,r,i){let o={kind:"ok",thread_id:e.target_durable_id,delivery_id:e.delivery_id,message_seq:e.seq,effective_mode:e.mode_effective??e.mode_requested,endpoint_kind:n,deduplicated:r};if("admitted"===e.state||"applied"===e.state)return"started"===e.admission_kind||"steered"===e.admission_kind?{...o,delivery:{kind:e.admission_kind,turn_id:String(e.turn_epoch??0)}}:{...o,delivery:{kind:"queued",queue_position:Math.max(t,1)}};if("refused"===e.state){let t=Mn[e.reason??""]??{code:"internal_error",next:"Call thread_list and check the target."};return{kind:"error",error:h(t.code,`Delivery ${e.delivery_id} was refused: ${e.reason??"unknown"}.`,t.next,{delivery_id:e.delivery_id})}}return"uncertain"===e.state?{kind:"error",error:h("idempotency_uncertain",`Delivery ${e.delivery_id} may or may not have reached the target.`,"Read the target transcript before deciding whether to send again.",{delivery_id:e.delivery_id})}:{...o,delivery:{kind:i?"queued_offline":"queued",queue_position:Math.max(t,1)}}}var Cn={loop_detected:"Stop relaying here: a direct reply to the session that messaged you is a cycle. That session reads your answer with thread_read; a bound external thread gets it through thread_report, and its questions come back through thread_answer.",overloaded:"Wait before sending to this session again.",queue_full:"Wait for the target to take its queued messages, then send again.",idempotency_conflict:"Retry with a new idempotency_key.",idempotency_in_progress:"Wait for the earlier call to settle, then retry.",idempotency_uncertain:"Read the target transcript before deciding whether to send again; the gateway never resends.",invalid_arguments:"Fix the arguments and send again."};function Nn(e,t,n){return{kind:"error",error:h(e,t,Cn[e]??"Call thread_list and retry after checking the target.",n)}}function jn(e){return t={target:e.target,text:e.text,mode:e.mode,expected_turn_id:e.expected_turn_id,binding:e.binding,author:e.author},Pn("sha256").update(JSON.stringify(t)).digest("hex");var t}function Ln(e){return"object"==typeof e&&null!==e&&"gateway_lock_wait_exceeded"===e.code}var Bn=/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/;function zn(e){return{kind:"refused",code:"invalid_arguments",message:e}}function Dn(e,t,n){return"string"!=typeof t||0===t.trim().length?zn(`author.${e} must be a non-empty string.`):t.length>n?zn(`author.${e} is longer than ${n} characters.`):Bn.test(t)?zn(`author.${e} carries a control character or line break.`):t.trim()}var Un={binding_conflict:"Call thread_bindings to find the binding that holds this thread, then thread_rebind it with its revision, or thread_unbind it first.",binding_mismatch:"Answer through the binding that asked the question; the question stays pending.",binding_inactive:"Bind the thread again with thread_bind.",stale_revision:"Call thread_bindings for the current revision and retry with it.",stale_token:"The question was asked under an earlier binding revision or session runtime; wait for the session to ask again.",already_answered:"Nothing to do: the question has its answer.",answer_in_progress:"Retry after a moment: another answer is still being handed to the session, and the question goes back to pending if that fails.",idempotency_conflict:"Retry with a new idempotency_key.",idempotency_uncertain:"Call thread_bindings or thread_outbox to see the current state before retrying with a new key.",scope_denied:"Report through a binding attached to this session; thread_bindings lists them.",unsupported:"Report only the events the binding subscribes to, through a binding with an outbound direction.",not_found:"Call thread_bindings for the binding ids that exist.",cursor_invalid:"Read thread_outbox again and ack a cursor it returned.",host_unavailable:"Retry when the session is running; the question stays pending.",invalid_arguments:"Fix the arguments and call again."},Fn=new Set(["question_already_resolved","unknown_extension_ui_request","unknown_request"]);function Wn(e,t,n,r){return{kind:"error",error:h(e,t,r??Un[e]??"Call thread_bindings and retry after checking the binding.",n)}}function Gn(e){return"refused"===e.kind?Wn(e.code,e.message,e.details):e}function Kn(e){if(void 0===e)return;let t=function(e){let t=Dn("platform_user_id",e.platform_user_id,256);if("string"!=typeof t)return t;let n=Dn("display",e.display,256);if("string"!=typeof n)return n;if(void 0===e.user_id)return{platform_user_id:t,display:n};let r=Dn("user_id",e.user_id,256);return"string"!=typeof r?r:{platform_user_id:t,display:n,user_id:r}}(e);return"kind"in t?Wn("invalid_arguments",t.message):t}function Jn(e){let t=Buffer.byteLength(e);return t>E?Wn("message_too_large",`The text is ${t} bytes, above the 32768-byte limit.`):void 0}function Hn(e,t,n){return void 0===e.idempotency_key?null:{principal:e.principal,operation:t,idempotency_key:e.idempotency_key,args_hash:(r=n,w("sha256").update(T(r)).digest("hex"))};var r}function Vn(e){let t=e.store,n=e.now??t.now,r=new Set,i=!1;async function o(e){await u(()=>t.releaseAnswer(e))}async function u(e){try{await e()}catch(n){if(!Ln(n)||i)throw n;let o=function(e,t,n){let r,i=!1,o=()=>{r=setTimeout(()=>{r=void 0,i||e().catch(e=>{i||(Ln(e)?o():n(e))})},t()),r.unref?.()};return o(),{cancel:()=>{i=!0,clearTimeout(r)}}}(()=>e().then(()=>{r.delete(o)}),()=>t.busyTimeoutMs,()=>{r.delete(o)});r.add(o)}}return{bind:async e=>{let r=function(e){if(!A.includes(e.platform))return R(`platform must be one of ${A.join(", ")}.`);let t={account_id:P("account_id",e.account_id),chat_id:P("chat_id",e.chat_id),thread_id:P("thread_id",e.thread_id??"@chat"),root_message_id:q("root_message_id",e.root_message_id),progress_message_id:q("progress_message_id",e.progress_message_id),session_durable_id:P("session",e.session_durable_id),policy_id:P("policy_id",e.policy_id??"default")};for(let e of Object.values(t))if(M(e))return e;let n=e.direction??{inbound:!0,outbound:!0};if(!0!==n.inbound&&!0!==n.outbound)return R("A binding needs at least one direction: inbound, outbound, or both.");let r=e.inbound_mode??"auto";if(!O.includes(r))return R(`inbound_mode must be one of ${O.join(", ")}.`);let i=e.outbound_events??(n.outbound?S:[]);if(i.some(e=>!S.includes(e)))return R(`outbound_events may only name ${S.join(", ")}.`);if(new Set(i).size!==i.length)return R("outbound_events must not repeat an event.");if(n.outbound&&0===i.length)return R("An outbound binding needs at least one outbound event.");let o=void 0===e.ttl_seconds?604800:e.ttl_seconds;return null!==o&&(!Number.isInteger(o)||o<1||o>I)?R("ttl_seconds must be an integer from 1 to 31622400, or null for a binding that never expires."):{platform:e.platform,account_id:t.account_id,chat_id:t.chat_id,thread_id:t.thread_id,root_message_id:t.root_message_id,progress_message_id:t.progress_message_id,session_durable_id:t.session_durable_id,direction:{inbound:!0===n.inbound,outbound:!0===n.outbound},inbound_mode:r,outbound_events:S.filter(e=>i.includes(e)),policy_id:t.policy_id,ttl_seconds:o}}(e.binding);return Gn("kind"in r?r:await t.bind({now:n(),receipt:Hn(e,"thread_bind",r),binding:r}))},unbind:async e=>{let r={binding_id:e.binding_id,expected_revision:e.expected_revision};return Gn(await t.unbind({now:n(),receipt:Hn(e,"thread_unbind",r),...r}))},rebind:async e=>{let r={binding_id:e.binding_id,expected_revision:e.expected_revision,session_durable_id:e.session_durable_id};return Gn(await t.rebind({now:n(),receipt:Hn(e,"thread_rebind",r),...r}))},bindings:async e=>Gn(await t.listBindings({now:n(),...e})),report:async e=>{let r=Jn(e.text);if(void 0!==r)return r;let i={session_durable_id:e.session_durable_id,binding_id:e.binding_id??null,origin_delivery_ids:e.origin_delivery_ids??[],origin_local_input:!0===e.origin_local_input,event:e.event,text:e.text,ui_request_id:e.request_id??null,ui_request_kind:e.request_kind??null};return Gn(await t.report({now:n(),receipt:Hn(e,"thread_report",i),...i}))},outbox:async e=>Gn(await t.readOutbox({now:n(),...e})),ack:async e=>Gn(await t.ackOutbox({now:n(),...e})),answer:async r=>{let i=Jn(r.answer);if(void 0!==i)return i;let s=Kn(r.author);if(void 0!==s&&"kind"in s)return s;let a=s??null,d=await t.claimAnswer({now:n(),binding_id:r.binding_id,reply_token:r.reply_token,answer:r.answer,answered_by:a});if("ok"!==d.kind)return Gn(d);let c={reply_token:r.reply_token,claimed_at:d.claimed_at},l=e.endpoints.respondUi,f=null,p="";if(void 0!==l)try{f=await e.locate(d.session_durable_id)}catch(e){p=`: ${e instanceof Error?e.message:String(e)}`}if(void 0===l||null===f)return await o(c),Wn(void 0===l?"unsupported":"host_unavailable",`The session that asked is not reachable to take the answer${p}.`,{session:d.session_durable_id});let m,h=b(d.ui_request_kind,r.answer);if(!h.ok)return await o(c),Wn("invalid_arguments",h.reason,{session:d.session_durable_id,ui_request_kind:d.ui_request_kind});try{m=await l(f,{ui_request_id:d.ui_request_id,fields:h.fields})}catch(e){return await o(c),Wn("host_unavailable",`The answer could not be handed to the session: ${e instanceof Error?e.message:String(e)}`,{session:d.session_durable_id})}if(!m.delivered){let e=d.taken_over;if(null!==e&&Fn.has(m.error))return"question_already_resolved"===m.error?(await u(()=>t.markPriorDelivered({...c,prior:e})),Wn("already_answered",`The session already took an earlier answer to this question (${m.error}).`,{session:d.session_durable_id,reason:m.error})):(await u(()=>t.markPriorDelivered({...c,prior:{answer:null,answered_at:c.claimed_at}})),Wn("already_answered",`The session no longer waits for this question (answered or closed elsewhere) (${m.error}).`,{session:d.session_durable_id,reason:m.error},"Nothing to do: the session no longer waits for this question."));await o(c);let n="invalid_response"===m.error||"question_incomplete"===m.error;return Wn(n?"invalid_arguments":"stale_token",`The session refused the answer: ${m.error}`,{session:d.session_durable_id,reason:m.error},n?`The session could not read this answer (${m.error}); answer again with text it can take. The question stays pending.`:`The session refused the answer (${m.error}): it no longer waits on this question. Read thread_outbox for a newer question and answer that one.`)}return await async function(e){await u(()=>t.confirmAnswer(e))}({...c,answer:r.answer,answered_by:a}),{kind:"ok",binding_id:r.binding_id,cursor:d.cursor,session_durable_id:d.session_durable_id,answered_by:a}},inbound:async r=>{if(void 0!==r.mode&&!O.includes(r.mode))return Wn("invalid_arguments",`A binding message is delivered as ${O.join(" or ")}, never ${String(r.mode)}.`,{mode:r.mode},"Send with mode auto or follow_up, or omit it for the binding's inbound_mode.");let i=Kn(r.author);if(void 0!==i&&"kind"in i)return i;let o=await t.bindingView({now:n(),binding_id:r.binding_id});if(null===o)return Wn("not_found","No binding has this id.",{binding_id:r.binding_id});let u={principal:`binding:${o.binding_id}`,idempotency_key:`event:${r.event_id}`},s=await t.deliveryReceipt({now:n(),...u});if(null!==s&&null!==s.binding_revision&&s.args_hash===jn({target:s.target_durable_id,text:r.text,mode:r.mode??o.inbound_mode,expected_turn_id:null,binding:{binding_id:o.binding_id,revision:s.binding_revision},author:i})){let e=s.completed?{kind:"replay",result:s.result}:await t.recoverDelivery({now:n(),...u,args_hash:s.args_hash});if("replay"===e?.kind){let t=e.result;return"ok"===t.kind?{...t,deduplicated:!0}:t}if("refused"===e?.kind)return Wn(e.code,e.message,e.details)}if("active"!==o.status)return Wn("binding_inactive",`The binding is ${o.status}.`,{binding_id:o.binding_id,status:o.status});if(!o.direction.inbound)return Wn("unsupported","The binding carries no inbound direction.",{binding_id:o.binding_id});let a=r.mode??o.inbound_mode;return"auto"===a&&"follow_up"===o.inbound_mode?Wn("invalid_arguments","The binding delivers at most follow_up; a message cannot ask for more than its binding's inbound_mode.",{binding_id:o.binding_id,mode:a,inbound_mode:o.inbound_mode},"Send with mode follow_up (or omit it), or rebind the thread with inbound_mode auto."):await e.engine.deliver({sender:{kind:"external",origin:{platform:o.platform,account_id:o.account_id,chat_id:o.chat_id,thread_id:o.thread_id,message_id:r.event_id,...void 0===i?{}:{author:i}},binding_id:o.binding_id,binding_revision:o.revision},target:o.session_durable_id,text:r.text,mode:a,all_scope:!0,idempotency_key:`event:${r.event_id}`})},settle:e=>t.emitCompletions({now:n(),...e}),dispose:()=>{i=!0;for(let e of r)e.cancel();r.clear()}}}var Zn="unknown-caller";async function Xn(e,t,n){let r=await e.store.sessionOwner(t);return null===r?await n():null===r.endpoint||void 0===e.host.listTarget?{sessions:[],hosts:[],disk:[]}:await e.host.listTarget(t,r.endpoint)}async function Qn(e,t={}){if(void 0!==e.host.listView)return await e.host.listView(t);let n;try{n=await e.host.listSessions()}catch(n){if(!0!==t.offline)throw n;return{sessions:[],hosts:[{socket:e.host.socket,error:n}],disk:[]}}return{sessions:n,hosts:[{socket:e.host.socket,list_sessions:{sessions:n}}],disk:[]}}function Yn(e,t,n=[]){return function(e,t,n={}){let r=n.assembled_at??(new Date).toISOString(),i=new Map,o=new Map,u=new Map(e.map(e=>[e.socket,e]));for(let t of e){let e=Jt(t);null!==e&&o.set(t.socket,e)}for(let e of t){if(0===e.durable_id.length)continue;let t=null===e.source_host?void 0:o.get(e.source_host);i.set(e.durable_id,Vt(e,null===e.source_host?void 0:u.get(e.source_host),t))}for(let t of e){let e=Kt(t);if(null!==e)for(let o of e){if("closed"===o.status)continue;let e=o.durableSessionId??("tui"===t.endpoint_kind?o.sessionId:void 0);if("string"!=typeof e||0===e.length)continue;let u=i.get(e),s=o.sessionPath??u?.session_path??null,a={name:o.name??null,created:o.created_at??o.createdAt,updated:o.updated_at??o.updatedAt},d=null!==a.name&&"string"==typeof a.created&&"string"==typeof a.updated||null===s?null:n.facts?.(s)??null,c=Ht(a.created,d?.created_at??u?.created_at??r),l=Ht(a.updated,null===d?u?.updated_at??null:d.updated_at),f=a.name??u?.name??d?.name??null;i.set(e,{durable_id:e,routing_id:o.sessionId,name:f,cwd:o.cwd,status:"live",liveness:"live",source_host:t.socket,session_path:s,created_at:c,updated_at:l,thread_id:e,endpoint:{kind:t.endpoint_kind??"rpc_host",socket:t.socket,routing_id:o.sessionId},surface:Ft(t.endpoint_kind,o.kind,t.socket),alive:!1!==t.alive,title:Bt(f,d?.first_user_text)??u?.title??null})}}return[...i.values()].sort((e,t)=>e.updated_at!==t.updated_at?null===e.updated_at?1:null===t.updated_at?-1:e.updated_at<t.updated_at?1:-1:e.durable_id.localeCompare(t.durable_id))}(t.hosts,[...e.diskSessions?.()??[],...t.disk,...n],{facts:Ut})}function er(e,t,n,r){let i=Yn(e,t),o=e.sessionsDirectory?.();if(void 0===o||"self"===n)return i;let u=new Set(i.map(e=>e.durable_id));if(u.has(n))return i;let s=e.callerWorkspaceRoot(),a=Rt(Zt(i),n,{all_scope:r,callerWorkspaceRoot:s}),d="error"!==a.kind||"not_found"!==a.code,c=function(e,t,n={}){let r;try{r=mt(e,{withFileTypes:!0}).filter(e=>(e.isDirectory()||e.isSymbolicLink())&&/^--.*--$/.test(e.name)).map(e=>e.name)}catch{return[]}let i=new Map,o=t=>{let n=i.get(t);if(void 0===n){try{n=mt(gt(e,t)).filter(e=>e.endsWith(".jsonl"))}catch{n=[]}i.set(t,n)}return n},u=`_${t}.jsonl`,s=r.flatMap(n=>o(n).flatMap(r=>{if(!r.endsWith(u))return[];let i=Yt(gt(e,n,r));return null!==i&&i.durable_id===t?[i]:[]}));if(s.length>0||!0===n.id_only)return s;let a=kt(t);if(0===a.length)return[];let d=!0===n.all_scope?void 0:(n.workspaceRoots??[]).map(Qt);return(void 0===d?r:r.filter(e=>d.some(t=>e.startsWith(t)))).flatMap(t=>o(t).flatMap(n=>{let r=Yt(gt(e,t,n));return null!==r&&null!==r.name&&kt(r.name)===a?[r]:[]}))}(o,n,{all_scope:r,workspaceRoots:Et(s),id_only:d}).filter(e=>!u.has(e.durable_id));return 0===c.length?i:Yn(e,t,c)}function tr(e){return{sessionId:e.durable_id,durableSessionId:e.durable_id,...null===e.session_path?{}:{sessionPath:e.session_path},...null===e.source_host?{}:{socket:e.source_host},cwd:e.cwd,thread_id:e.thread_id,name:e.title??"",status:"resumable",created_at:e.created_at,updated_at:e.updated_at,endpoint:e.endpoint,surface:e.surface,alive:e.alive,...void 0===e.error_note?{}:{error_note:e.error_note}}}function nr(e,t){return Zt(Yn(e,t))}function rr(e,t,n,r,i){if("self"===n){let e=r===Zn?void 0:t.find(e=>e.thread_id===r);if(void 0===e)return{kind:"error",...h("caller_context_missing","The caller's durable session id is not in the thread address book.","Call thread_list and pass an explicit thread_id, or retry from a session with caller context.")};n=e.thread_id}return Rt(t,n,{all_scope:i,callerWorkspaceRoot:e.callerWorkspaceRoot()})}function ir(e){return"user"===e||"assistant"===e?e:"toolResult"===e?"tool":"system"}var or={wake:async e=>{throw Error(`host_unavailable:${e.socket}`)}};function ur(e,t){let n=e.store,r=e.now??n.now,i=e.host.gateway??or,o=function(e){let t=e.store,n=e.now??t.now;return{deliver:async function(r){let i=r.mode??"auto";if("steer"===i&&void 0===r.expected_turn_id)return Nn("invalid_arguments","A steer needs expected_turn_id (the target's current turn_epoch).");let o=Buffer.byteLength(r.text);if(o>d)return Nn("message_too_large",`The message is ${o} bytes, above the 1048576-byte limit.`);let u=await e.resolve(r.target,{all_scope:r.all_scope});if("error"===u.kind)return u;let s=u.target,a="routable"===s.liveness?s.endpoint:null;if(null===a&&"refuse"===function(e,t,n,r){return"offline"===e?"steer"===t?{kind:"refuse",reason:"turn_conflict"}:{kind:"queued_offline"}:"steer"===t?"mid_turn"!==e?{kind:"refuse",reason:"not_steerable"}:null===n||null===r||n!==r?{kind:"refuse",reason:"turn_conflict"}:{kind:"admit",deliverAs:"steer",expected_turn_id:n,expect:"steered"}:{kind:"admit",deliverAs:"followUp",expect:"idle"===e?"started":"queued"}}("offline",i,r.expected_turn_id??null,null).kind)return Nn("turn_conflict","The target has no live turn to steer.",{target:s.durable_id});let c=function(e){if("session"===e.kind)return{principal:`session:${e.durable_id}`,rate_principal:`session:${e.durable_id}`,node:e.durable_id,turn:e.turn_id??null,cause:e.cause_delivery_id??null,actor:e.name??e.durable_id,origin:()=>({session:e.durable_id}),binding:null};if("cli"===e.kind){let t=`cli:${e.uid}`;return{principal:t,rate_principal:t,node:t,turn:null,cause:null,actor:e.user,origin:t=>({external:{platform:"cli",account_id:e.user,chat_id:"@cli",thread_id:"@chat",message_id:t}}),binding:null}}let t=`binding:${e.binding_id}`,n=e.origin.author;return{principal:t,rate_principal:void 0===n?t:`${t}#author:${n.platform_user_id}`,node:t,turn:null,cause:null,actor:e.origin.account_id,origin:()=>({external:e.origin}),binding:{binding_id:e.binding_id,revision:e.binding_revision}}}(r.sender),l=qn(),f=r.idempotency_key??`auto:${l}`,p=await t.enqueue({now:n(),delivery_id:l,target_durable_id:s.durable_id,sender_principal:c.principal,rate_principal:c.rate_principal,sender_node:c.node,sender_turn:c.turn,cause_delivery_id:c.cause,claimed_root_id:r.root_id??null,origin:c.origin(l),actor:c.actor,body:r.text,mode:i,expected_turn_id:r.expected_turn_id??null,binding:c.binding,receipt:{idempotency_key:f,args_hash:jn({target:s.durable_id,text:r.text,mode:i,expected_turn_id:r.expected_turn_id??null,binding:c.binding,author:"external"===r.sender.kind?r.sender.origin.author:void 0})},endpoint_kind:a?.kind??null});if("busy"===p.kind)return Nn("overloaded","The gateway store is locked by a suspended writer; nothing was sent.",{budget:"store_lock"});if("refused"===p.kind)return Nn(p.code,p.message,p.details);if("replay"===p.kind){let e=p.result;return"ok"===e.kind?{...e,deduplicated:!0}:e}let m=async e=>(await t.completeReceipt({now:n(),principal:c.principal,idempotency_key:f,result:e}),e);try{if(null===a)return await m(Tn(p.row,p.queue_position,null,!1,!0));let n=!0;try{await e.endpoints.wake(a,[l])}catch{n=!1}let r=await t.deliveryView(l);if(null===r)throw Error(`delivery ${l} vanished after commit`);return await m(Tn(r.row,r.queue_position,a.kind,!1,!n))}catch(e){throw await t.abandonReceipt({now:n(),principal:c.principal,idempotency_key:f,error_note:e instanceof Error?e.message:String(e)}).catch(()=>!1),e}}}}({store:n,endpoints:i,resolve:async(n,r)=>{let i=await Xn(e,n,t);return await function(e,t){return async(n,r)=>{let i=Rt(await e(),n,{all_scope:r.all_scope,callerWorkspaceRoot:t()});if("ok"!==i.kind){let e=void 0===i.candidates?void 0:{candidates:i.candidates};return{kind:"error",error:h(i.code,i.message,i.next_action,e)}}let o=i.entry;return{kind:"ok",target:{durable_id:o.thread_id,endpoint:o.endpoint,liveness:o.liveness}}}}(()=>Xt(er(e,i,n,r.all_scope)),e.callerWorkspaceRoot)(n,r)},now:r}),u=async n=>{let r=(await(async()=>Xt(Yn(e,await t())))()).find(e=>e.thread_id===n);return void 0===r||"routable"!==r.liveness?null:r.endpoint};return{store:n,endpoints:i,engine:o,relay:Vn({store:n,engine:o,endpoints:i,locate:u,now:r}),locate:u}}import{closeSync as sr,openSync as ar,readSync as dr}from"node:fs";import{StringDecoder as cr}from"node:string_decoder";var lr={assign:0,create:0,clone:0,discard:0,update:0};function fr(e){let t=0,n=0,r=0;for(;n<e.length;){let i=e.charCodeAt(n++)>>10;t+=+(13879!=(r<<8|i)),r=i}return t}function pr(e){return Array.isArray(e)}function mr(e){return Sr(typeof e,"bigint")}function hr(e){return Sr(typeof e,"boolean")}function _r(e){if(Ar(e)||!gr(e))return!1;let t=Function.prototype.toString.call(e);return!!/^class\s/.test(t)||!!/\[native code\]/.test(t)}function gr(e){return Sr(typeof e,"function")}function yr(e){return Number.isInteger(e)}function vr(e){return Sr(e,null)}function br(e){return Number.isFinite(e)}function wr(e){return kr(e)&&!pr(e)}function kr(e){return Sr(typeof e,"object")&&!vr(e)}function xr(e){return Sr(typeof e,"string")}function $r(e){return Sr(typeof e,"symbol")}function Ar(e){return Sr(e,void 0)}function Sr(e,t){return e===t}function Or(e,t){return e>t}function Ir(e,t){return e<t}function Er(e,t){return e<=t}function Rr(e,t){return e>=t}function Pr(e){return mr(e)||hr(e)||vr(e)||br(e)||xr(e)||Ar(e)}function qr(e,t){return function(e,t){return e.length<=t||e.length<=t<<1&&fr(e)<=t}(e,t)}function Mr(e,t){return function(e,t){return e.length>=t<<1||e.length>=t&&fr(e)>=t}(e,t)}function Tr(e,t,n){return e.every((e,r)=>r<t||n(e,r))}function Cr(e,t,n){let r=!0;return e.forEach((e,i)=>{i>=t&&!n(e,i)&&(r=!1)}),r}function Nr(e,t){return e.some((e,n)=>t(e,n))}function jr(e,t){return e.reduce((e,n,r)=>t(n,r)?++e:e,0)}function Lr(e,t,n){return Sr(e.length,0)?n():t(e[0],e.slice(1))}function Br(e){return Sr(e,"__proto__")||Sr(e,"constructor")||Sr(e,"prototype")}function zr(e,t){return Br(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Dr(e){return Fr(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function Ur(e){return Object.entries(e)}function Fr(e){return Object.getOwnPropertyNames(e)}function Wr(e){return Object.values(e)}function Gr(e,t){return pr(e)?function(e,t){return pr(t)&&Sr(e.length,t.length)&&e.every((n,r)=>Gr(e[r],t[r]))}(e,t):kr(e)?function(e,t){if(!kr(t))return!1;let n=Fr(e);return Sr(n.length,Fr(t).length)&&n.every(n=>Gr(e[n],t[n]))}(e,t):Sr(e,t)}function Kr(e){return globalThis.ArrayBuffer.isView(e)}function Jr(e){return e instanceof globalThis.RegExp}var Hr={immutableTypes:!1,maxErrors:8,maxParseErrors:1,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function Vr(){return Hr}function Zr(e){return Vr().immutableTypes?Object.freeze(e):e}function Xr(e,t){return lr.assign+=1,Zr({...e,...t})}function Qr(e){let t={};for(let n of Fr(e))Br(n)||(t[n]=ei(e[n]));for(let n of function(e){return Object.getOwnPropertySymbols(e)}(e))t[n]=ei(e[n]);return t}function Yr(e){return function(e){if(!kr(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return!vr(t)&&Sr(typeof t.constructor,"function")&&!(Sr(t.constructor,globalThis.Object)||Sr(t.constructor.name,"Object"))}(e)?e:function(e){return zr(e,"~kind")||zr(e,"~unsafe")}(e)?function(e){let t={};for(let n of Fr(e)){if(Br(n))continue;let r=Object.getOwnPropertyDescriptor(e,n);r.value=ei(r.value),Sr(r.enumerable,!0)?t[n]=r.value:Object.defineProperty(t,n,r)}return t}(e):Qr(e)}function ei(e){return Kr(e)?function(e){return e.slice()}(e):Jr(e)?function(e){return new RegExp(e.source,e.flags)}(e):function(e){return e instanceof globalThis.Map}(e)?function(e){return new Map(ei([...e.entries()]))}(e):function(e){return e instanceof globalThis.Set}(e)?function(e){return new Set(ei([...e.values()]))}(e):pr(e)?function(e){return e.map(e=>ei(e))}(e):kr(e)?Yr(e):e}function ti(e){return lr.clone+=1,ei(e)}function ni(e,t){return{...e,...t}}function ri(e,t,n={}){lr.create+=1;let r=ni(t,n);return Zr(Vr().enumerableKind?ni(r,e):function(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}(r,e))}function ii(e,t){lr.discard+=1;let n={};for(let r of Fr(e)){if(t.includes(r))continue;let i=Object.getOwnPropertyDescriptor(e,r);i.value=ti(i.value),Object.defineProperty(n,r,i)}return Zr(n)}function oi(e,t,n){lr.update+=1;let r=Vr(),i=ti(e);for(let e of Object.keys(t))Object.defineProperty(i,e,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[e]});for(let e of Object.keys(n))Object.defineProperty(i,e,{configurable:!0,enumerable:!0,writable:!0,value:n[e]});return Zr(i)}function ui(e,t){return kr(e)&&zr(e,"~kind")&&Sr(e["~kind"],t)}function si(e){return kr(e)}function ai(e,t,n){return ri({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function di(e){return ui(e,"Deferred")}function ci(e,t){return oi(function(e){return oi(e,{"~readonly":!0},{})}(e),{},t)}function li(e,t){return oi(function(e){return oi(e,{"~optional":!0},{})}(e),{},t)}function fi(e,t){return ri({"~kind":"Array"},{type:"array",items:e},t)}function pi(e){return ui(e,"Array")}function mi(e){return ii(e,["~kind","type","items"])}function hi(e,t,n={}){return ri({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function _i(e){return ui(e,"Constructor")}function gi(e,t,n={}){return ri({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function yi(e){return ui(e,"Function")}function vi(e,t){return ri({"~kind":"Ref"},{$ref:e},t)}function bi(e){return ui(e,"Ref")}function wi(e,t){return ri({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function ki(e){return ui(e,"Generic")}function xi(e){return ui(e,"Any")}var $i,Ai="(?!)";function Si(e){return ri({"~kind":"Never"},{not:{}},e)}function Oi(e){return ui(e,"Never")}function Ii(e,t={}){return li(e,t)}function Ei(e){return Ii(e)}function Ri(e){return si(e)&&zr(e,"~optional")}function Pi(e){return Fr(e)}function qi(e){return Wr(e)}function Mi(e,t={}){let n=function(e){return Fr(e).filter(t=>!Ri(e[t]))}(e);return ri({"~kind":"Object"},{type:"object",...n.length>0?{required:n}:{},properties:e},t)}function Ti(e){return ui(e,"Object")}function Ci(e){return ri({"~kind":"Unknown"},{},e)}function Ni(e){return ui(e,"Unknown")}function ji(e,t,n){return ri({"~kind":"Cyclic"},{$defs:Fr(e).reduce((t,n)=>({...t,[n]:oi(e[n],{},{$id:n})}),{}),$ref:t},n)}function Li(e){return ui(e,"Cyclic")}function Bi(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function zi(e){return ui(e,"Infer")}function Di(e){return ui(e,"Dependent")}function Ui(e){return ui(e,"Enum")}function Fi(e,t={}){return ri({"~kind":"Intersect"},{allOf:e},t)}function Wi(e){return ui(e,"Intersect")}function Gi(){throw Error("Unreachable")}!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"}($i||($i={}));var Ki=BigInt("14695981039346656037"),[Ji,Hi]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Vi=Array.from({length:256}).map((e,t)=>BigInt(t)),Zi=new Float64Array(1),Xi=new DataView(Zi.buffer),Qi=new Uint8Array(Zi.buffer);function Yi(e){Ki=(Ki^=Vi[e])*Ji%Hi}function eo(e){Yi($i.Boolean),Yi(e?1:0)}function to(e){Yi($i.Number),Xi.setFloat64(0,e,!0);for(let e of Qi)Yi(e)}function no(e){Yi($i.Object);for(let t of function(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Reflect.ownKeys(n))"constructor"!==e&&"symbol"!=typeof e&&t.add(e);n=Object.getPrototypeOf(n)}return[...t]}(e).sort())oo(t),oo(e[t])}var ro=new TextEncoder;function io(e){Yi($i.String);for(let t of ro.encode(e))Yi(t)}function oo(e){return Kr(e)?function(e){Yi($i.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e<t.length;e++)Yi(t[e])}(e):function(e){return e instanceof globalThis.Date}(e)?function(e){Yi($i.Date),oo(e.getTime())}(e):Jr(e)?function(e){Yi($i.RegExp),io(e.toString())}(e):function(e){return e instanceof Boolean}(e)?eo(e.valueOf()):function(e){return e instanceof String}(e)?io(e.valueOf()):function(e){return e instanceof Number}(e)?to(e.valueOf()):function(e){return"number"==typeof e}(e)?to(e):pr(e)?function(e){Yi($i.Array);for(let t of e)oo(t)}(e):hr(e)?eo(e):mr(e)?function(e){Yi($i.BigInt),Xi.setBigInt64(0,e);for(let e of Qi)Yi(e)}(e):_r(e)?function(e){Yi($i.Constructor),oo(e.toString())}(e):vr(e)?void Yi($i.Null):kr(e)?no(e):xr(e)?io(e):$r(e)?function(e){Yi($i.Symbol),oo(e.toString())}(e):Ar(e)?Yi($i.Undefined):gr(e)?function(e){Yi($i.Function),oo(e.toString())}(e):Gi()}function uo(e){return function(e){return Ki=BigInt("14695981039346656037"),oo(e),Ki}(e).toString(16).padStart(16,"0")}var so=function(e){switch(e.keyword){case"additionalProperties":return"must not have additional properties";case"anyOf":return"must match a schema in anyOf";case"boolean":return"schema is false";case"const":return"must be equal to constant";case"contains":return"must contain at least 1 valid item";case"dependencies":case"dependentRequired":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"enum":return"must be equal to one of the allowed values";case"exclusiveMaximum":case"exclusiveMinimum":case"maximum":case"minimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"format":return`must match format "${e.params.format}"`;case"if":return`must match "${e.params.failingKeyword}" schema`;case"maxItems":return`must not have more than ${e.params.limit} items`;case"maxLength":return`must not have more than ${e.params.limit} characters`;case"maxProperties":return`must not have more than ${e.params.limit} properties`;case"minItems":return`must not have fewer than ${e.params.limit} items`;case"minLength":return`must not have fewer than ${e.params.limit} characters`;case"minProperties":return`must not have fewer than ${e.params.limit} properties`;case"multipleOf":return`must be multiple of ${e.params.multipleOf}`;case"not":return"must not be valid";case"oneOf":return"must match exactly one schema in oneOf";case"pattern":return`must match pattern "${e.params.pattern}"`;case"propertyNames":return`property names ${e.params.propertyNames.join(", ")} are invalid`;case"required":return`must have required properties ${e.params.requiredProperties.join(", ")}`;case"type":return"string"==typeof e.params.type?`must be ${e.params.type}`:`must be either ${e.params.type.join(" or ")}`;case"unevaluatedItems":return"must not have unevaluated items";case"unevaluatedProperties":return"must not have unevaluated properties";case"uniqueItems":return"must not have duplicate items";case"~refine":return e.params.message;default:return"an unknown validation error occurred"}};function ao(){return so}function co(e){return si(e)&&zr(e,"~immutable")}function lo(e,t={}){return ci(e,t)}function fo(e){return si(e)&&zr(e,"~readonly")}var po="-?(?:0|[1-9][0-9]*)n";function mo(e){return ui(e,"BigInt")}function ho(e){return ri({"~kind":"Boolean"},{type:"boolean"},e)}function _o(e){return ui(e,"Boolean")}var go="-?(?:0|[1-9][0-9]*)";function yo(e){return ri({"~kind":"Integer"},{type:"integer"},e)}function vo(e){return ui(e,"Integer")}class bo extends Error{constructor(e){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:e},writable:!1,configurable:!1,enumerable:!1})}}function wo(e){return mr(e)?"bigint":hr(e)?"boolean":br(e)?"number":xr(e)?"string":(()=>{throw new bo(e)})()}function ko(e,t){return ri({"~kind":"Literal"},{type:wo(e),const:e},t)}function xo(e){return Ao(e)&&br(e.const)}function $o(e){return Ao(e)&&xr(e.const)}function Ao(e){return ui(e,"Literal")}function So(e){return ri({"~kind":"Null"},{type:"null"},e)}function Oo(e){return ui(e,"Null")}var Io="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function Eo(e){return ri({"~kind":"Number"},{type:"number"},e)}function Ro(e){return ui(e,"Number")}function Po(e){return ui(e,"Symbol")}var qo=".*";function Mo(e){return ri({"~kind":"String"},{type:"string"},e)}function To(e){return ui(e,"String")}function Co(e,t={}){return ri({"~kind":"Union"},{anyOf:e},t)}function No(e){return ui(e,"Union")}function jo(e){let t=fs(e);return Sr(t.length,2)?t[0]:[]}function Lo(e){return Lr(e,(e,t)=>{return!!(No(n=e)?Bo(n.anyOf):Ao(n)&&(n.const,1))&&Lo(t);var n},()=>!0)}function Bo(e){return!Sr(e.length,0)&&Lo(e)}function zo(e){return Bo(e)}function Do(e){return ri({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Uo(e,t,n=[]){return Lr(e,(e,r)=>Uo(r,t,[...n,`${e}${t}`]),()=>n)}function Fo(e,t){return Sr(e.length,0)?[`${t}`]:Uo(e,t)}function Wo(e,t,n=[]){return Lr(t,(t,r)=>Wo(e,r,[...n,...Go(e,t)]),()=>n)}function Go(e,t){return No(t)?Wo(e,t.anyOf):Ao(t)?Fo(e,t.const):Gi()}function Ko(e,t){return Lr(t,(t,n)=>Ko(Go(e,t),n),()=>e)}function Jo(e){let t=function(e){return e.map(e=>ko(e))}(Ko([],e));return Co(t)}function Ho(e){let t=jo(e);return Sr(t.length,0)?Mo():zo(t)?function(e){return Sr(e.length,0)?Gi():Sr(e.length,1)&&Ao(e[0])?e[0]:Jo(e)}(t):Do(e)}function Vo(e,t){return ri({"~kind":"Record"},{type:"object",patternProperties:{[e]:t}})}function Zo(e,t={}){let[n,r,i]=[e,e.length,!1];return ri({"~kind":"Tuple"},{type:"array",additionalItems:i,items:n,minItems:r},t)}function Xo(e){return ui(e,"Tuple")}function Qo(e,t){return oi(function(e){return ii(e,["~readonly"])}(e),{},t)}function Yo(e,t){return oi(function(e){return ii(e,["~optional"])}(e),{},t)}function eu(e,t={}){return Yo(e,t)}function tu(e){return e.reduceRight((e,t,n)=>({[n]:t,...e}),{})}function nu(e){return Ti(e)||Xo(e)}function ru(e,t){let n=function(e,t){return!!fo(e)&&!!fo(t)}(e,t),r=function(e,t){return!!Ri(e)&&!!Ri(t)}(e,t),i=function(e,t={}){return Qo(e,t)}(eu(gu([e,t])));return n&&r?lo(Ii(i)):n&&!r?lo(i):!n&&r?Ii(i):i}function iu(e,t,n){return n in e?n in t?ru(e[n],t[n]):e[n]:n in t?t[n]:Si()}function ou(e){return Ti(e)?e.properties:Xo(e)?tu(e.items):{}}function uu(e,t){let n=function(e,t){return[...new Set([...Fr(e),...Fr(t)])].reduce((n,r)=>({...n,[r]:iu(e,t,r)}),{})}(ou(e),ou(t));return Mi(n)}function su(e,t){let n=nu(e),r=nu(t);return n&&r?uu(e,t):n&&!r?e:!n&&r?t:function(e,t){let n=Aa(e,t);return Sr(n,xa)?e:Sr(n,$a)||Sr(n,wa)?t:Si()}(e,t)}function au(e,t){let n=bu(e),r=bu(t);return function(e,t){return No(e)||No(t)}(n,r)?gu([n,r]):function(e,t){return Oi(e)||xi(e)?e:Ni(e)||Oi(t)||xi(t)?t:Ni(t)?e:su(e,t)}(n,r)}function du(e,t,n=[]){return Lr(t,(t,r)=>du(e,r,[...n,au(t,e)]),()=>Sr(n.length,0)?[e]:n)}function cu(e,t,n=[]){return Lr(e,(e,r)=>cu(r,t,[...n,...lu([e],t)]),()=>n)}function lu(e,t=[]){return Lr(e,(e,n)=>No(e)?lu(n,cu(e.anyOf,t)):lu(n,du(e,t)),()=>t)}function fu(e,t){return $s(ba({},e,t))?[]:[e]}function pu(e,t,n=[]){return Lr(e,(e,r)=>pu(r,t,[...n,...fu(e,t)]),()=>n)}function mu(e,t){let n=bu(e);return vu(pu(No(n)?n.anyOf:[n],t))}function hu(e,t,n){return vu([gu([e,t]),mu(n,e)])}function _u(e,t=[]){return Lr(e,(e,n)=>_u(n,[...t,ko(e)]),()=>vu(t))}function gu(e){return vu(Ea(lu(e)))}function yu(e){let t=function(e){let t=Ho(e);return ys(t)?Mo():t}(e);return bu(t)}function vu(e){return wu(Ea(e))}function bu(e){return Di(e)?hu(e.if,e.then,e.else):Ui(e)?_u(e.enum):Wi(e)?gu(e.allOf):ys(e)?yu(e.pattern):No(e)?vu(e.anyOf):e}function wu(e){return Sr(e.length,1)?e[0]:Sr(e.length,0)?Si():Co(e)}function ku(e,t=[]){return Lr(e,(e,n)=>{return ku(n,[...t,...(r=e,No(r)?ku(r.anyOf):[r])]);var r},()=>t)}function xu(e,t){return Sr(function(e){return e.some(e=>To(e)||Ro(e)||vo(e))}(e),!0)?Vo(Eu,t):void 0}function $u(e,t){let n=function(e,t){return e.reduce((e,n)=>Ao(n)&&(xr(n.const)||br(n.const))?{...e,[n.const]:t}:e,{})}(e,t);return Mi(n)}function Au(e,t){return xi(e)?function(e){return Vo(Eu,e)}(t):_o(e)?function(e){return Mi({true:e,false:e})}(t):Ui(e)?function(e,t){return Au(_u(e),t)}(e.enum,t):vo(e)?function(e,t){return Vo(Ou,t)}(0,t):Wi(e)?function(e,t){return Au(gu(e),t)}(e.allOf,t):Ao(e)?function(e,t){return xr(e)||br(e)?Mi({[e]:t}):Sr(e,!1)?Mi({false:t}):Sr(e,!0)?Mi({true:t}):Mi({})}(e.const,t):Ro(e)?function(e,t){return Vo(Iu,t)}(0,t):No(e)?function(e,t){let n=ku(e),r=xu(n,t);return si(r)?r:$u(n,t)}(e.anyOf,t):To(e)?function(e,t){return zr(e,"pattern")&&(xr(e.pattern)||e.pattern instanceof RegExp)?Vo(e.pattern.toString(),t):Vo(Eu,t)}(e,t):ys(e)?function(e,t){return zo(jo(e))?Au(yu(e),t):Vo(e,t)}(e.pattern,t):Mi({})}function Su(e,t,n){return cc([e])?oi(Au(e,t),{},n):function(e,t,n={}){return ai("Record",[e,t],n)}(e,t,n)}var Ou=`^${go}$`,Iu=`^${Io}$`,Eu=`^${qo}$`;function Ru(e,t,n={}){return Su(e,t,n)}function Pu(e){return Sr(e,Eu)?Mo():Sr(e,Ou)?yo():Sr(e,Iu)?Eo():Ho(e)}function qu(e){return Fr(e.patternProperties)[0]}function Mu(e){return Pu(qu(e))}function Tu(e){return e.patternProperties[qu(e)]}function Cu(e){return ui(e,"Record")}function Nu(e){return ui(e,"Rest")}function ju(e){return ui(e,"Undefined")}function Lu(e){return ui(e,"Void")}function Bu(e){return ri({"~kind":"BigInt"},{type:"bigint"},t);var t}function zu(e){return ko(e)}function Du(e){return Co(e[1])}function Uu(e){return 3===e.length?[...e[0],...e[2]]:1===e.length?[...e[0]]:[]}function Fu(e){return[e[0],...e[1]]}function Wu(e){return e[1]}function Gu(e){return Sr(e.length,2)}function Ku(e,t,n){return Gu(e)?t(e[0],e[1]):n()}function Ju(e,t){return Sr(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function Hu(e,t){return Array.from({length:t-e+1},(t,n)=>String.fromCharCode(e+n))}var Vu=[...Hu(97,122),...Hu(65,90)],Zu=["0",...Hu(49,57)];function Xu(e){let t=e.indexOf("*/");return Sr(t,-1)?"":e.slice(t+2)}function Qu(e){let t=e.indexOf("\n");return Sr(t,-1)?"":e.slice(t)}function Yu(e){let t=function(e){return e.replace(/^[ \t\r\f\v]+/,"")}(e);return t.startsWith("/*")?Yu(Xu(t.slice(2))):t.startsWith("//")?Yu(Qu(t.slice(2))):t}function es(e){let t=e.trimStart();return t.startsWith("/*")?es(Xu(t.slice(2))):t.startsWith("//")?es(Qu(t.slice(2))):t}function ts(e,t){return function(e,t){for(let n=0;n<e.length;n++){let r=Ju(e[n],t);if(Gu(r))return r}return[]}([e],t)}function ns(e,t){return Sr(e,"")?["",t]:e.startsWith("\n")?ts(e,Yu(t)):e.startsWith(" ")?ts(e,t):ts(e,es(t))}function rs(e,t){return Lr(e,(e,n)=>!!t.startsWith(e)||rs(n,t),()=>!1)}function is(e,t,n=""){return Ku(function(e){return Sr(e,"")?[]:[e.slice(0,1),e.slice(1)]}(t),(r,i)=>rs(e,t)?[n,t]:is(e,i,`${n}${r}`),()=>[])}var os=(e,t,n=()=>[])=>2===e.length?t(e):n(),us=e=>os(function(e,t){return Ku(is(e,t),(e,t)=>Sr(e,"")?[]:[e,t],()=>[])}(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([e,t])=>[zu(e),t]),ss=e=>os(os((e=>os(ns("-?(?:0|[1-9][0-9]*)n",e),([e,t])=>[Bu(),t]))(e),([e,t])=>[e,t],()=>os((e=>os(ns(".*",e),([e,t])=>[Mo(),t]))(e),([e,t])=>[e,t],()=>os((e=>os(ns("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([e,t])=>[Eo(),t]))(e),([e,t])=>[e,t],()=>os((e=>os(ns("-?(?:0|[1-9][0-9]*)",e),([e,t])=>[yo(),t]))(e),([e,t])=>[e,t],()=>os((e=>os(ns("(?!)",e),([e,t])=>[Si(),t]))(e),([e,t])=>[e,t],()=>os(as(e),([e,t])=>[e,t],()=>os(us(e),([e,t])=>[e,t],()=>[]))))))),([e,t])=>[e,t]),as=e=>os(os(ns("(",e),([e,t])=>os(ls(t),([t,n])=>os(ns(")",n),([n,r])=>[[e,t,n],r]))),([e,t])=>[Du(e),t]),ds=e=>os(os(os(cs(e),([e,t])=>os(ns("|",t),([t,n])=>os(ds(n),([n,r])=>[[e,t,n],r]))),([e,t])=>[e,t],()=>os(os(cs(e),([e,t])=>[[e],t]),([e,t])=>[e,t],()=>os([[],e],([e,t])=>[e,t],()=>[]))),([e,t])=>[Uu(e),t]),cs=e=>os(os(ss(e),([e,t])=>os(ls(t),([t,n])=>[[e,t],n])),([e,t])=>[Fu(e),t]),ls=e=>os(os(ds(e),([e,t])=>[e,t],()=>os(cs(e),([e,t])=>[e,t],()=>[])),([e,t])=>[e,t]),fs=e=>os(os(ns("^",e),([e,t])=>os(ls(t),([t,n])=>os(ns("$",n),([n,r])=>[[e,t,n],r]))),([e,t])=>[Wu(e),t]);function ps(e,t,n,r=[]){return Lr(e,(e,i)=>ps(i,t,n,[...r,ms(e,[],"")]),()=>{return hs(t,`${n}(${e=r,e.join("|")})`);var e})}function ms(e,t,n){return Ui(e)?function(e,t,n){return ms(_u(e),t,n)}(e.enum,t,n):vo(e)?function(e,t){return hs(e,`${t}${go}`)}(t,n):Ao(e)?function(e,t,n){return hs(t,`${n}${e}`)}(e.const,t,n):mo(e)?function(e,t){return hs(e,`${t}${po}`)}(t,n):_o(e)?function(e,t){return ms(Co([ko("false"),ko("true")]),e,t)}(t,n):Ro(e)?function(e,t){return hs(e,`${t}${Io}`)}(t,n):To(e)?function(e,t){return hs(e,`${t}${qo}`)}(t,n):ys(e)?function(e,t,n){return hs(t,`${n}${function(e){return e.slice(1,e.length-1)}(e)}`)}(e.pattern,t,n):si(r=e)&&zr(r,"action")&&Sr(r.action,"TemplateLiteral")?function(e,t,n){return ms(gs(e,{}),t,n)}(e.parameters[0],t,n):No(e)?ps(e.anyOf,t,n):Ai;var r}function hs(e,t){return Lr(e,(e,n)=>ms(e,n,t),()=>t)}function _s(e){let t=function(e){return`^${hs(e,"")}$`}(e);return Do(t)}function gs(e,t){return cc(e)?oi(_s(e),{},t):function(e,t={}){return ai("TemplateLiteral",[e],t)}(e,t)}function ys(e){return ui(e,"TemplateLiteral")}function vs(e){return kr(e)&&zr(e,"~kind")&&zr(e,"inferred")&&Sr(e["~kind"],"ExtendsUnion")&&kr(e.inferred)}function bs(e){return ri({"~kind":"ExtendsTrue"},{inferred:e})}function ws(e){return kr(e)&&zr(e,"~kind")&&zr(e,"inferred")&&Sr(e["~kind"],"ExtendsTrue")&&kr(e.inferred)}function ks(){return ri({"~kind":"ExtendsFalse"},{})}function xs(e){return kr(e)&&zr(e,"~kind")&&Sr(e["~kind"],"ExtendsFalse")}function $s(e){return vs(e)||ws(e)}function As(e,t,n){return $s(e)?t(e.inferred):n()}function Ss(e,t,n){return Lr(n,(n,r)=>As(ta(e,t,n),e=>Ss(e,t,r),()=>ks()),()=>bs(e))}function Os(e,t,n){return Lr(n,(n,r)=>As(ta(e,t,n),e=>bs(e),()=>Os(e,t,r)),()=>ks())}function Is(e,t,n){return xi(n)?function(e){return bs(e)}(e):Di(n)?function(e,t,n,r,i){return As(ta(e,t,n),e=>As(ta(e,t,r),e=>bs(e),()=>ks()),()=>As(ta(e,t,i),e=>bs(e),()=>ks()))}(e,t,n.if,n.then,n.else):Ui(n)?function(e,t,n){return ta(e,t,_u(n))}(e,t,n.enum):zi(n)?function(e,t,n,r){return As(ta(e,n,r),r=>bs(Xr(Xr(e,r),{[t]:n})),()=>ks())}(e,n.name,t,n.extends):Wi(n)?Ss(e,t,n.allOf):ys(n)?function(e,t,n){return ta(e,t,yu(n))}(e,t,n.pattern):No(n)?Os(e,t,n.anyOf):Ni(n)?bs(e):ks()}function Es(e,t,n){return zi(n)?Is(e,t,n):xi(n)||Ni(n)?bs(e):function(e){return ri({"~kind":"ExtendsUnion"},{inferred:e})}(e)}function Rs(e,t,n,r){return pi(r)?function(e,t){let n=co(e),r=co(t);return!(!n||!r)||!(n||!r)||!(n&&!r)}(t,r)?ta(e,n,r.items):ks():Is(e,t,r)}function Ps(e,t,n,r){return Lr(r,(r,i)=>function(e,t,n,r,i){let o=zi(r)?t:r,u=zi(r)?r:t,s=Ri(t),a=Ri(r);return!s&&a?ks():As(ta(e,o,u),e=>qs(e,n,i),()=>ks())}(e,t,n,r,i),()=>Ri(t)?bs(e):ks())}function qs(e,t,n){return function(e,t,n){return Lr(t,(t,r)=>Ps(e,t,r,n),()=>bs(e))}(e,t,n)}function Ms(e,t,n){return Lu(n)?bs(e):ta(e,t,n)}function Ts(e,t,n){return t===n?bs(e):ks()}function Cs(e,t,n){return mr(t.const)?function(e,t,n){return Ao(n)?Ts(e,t,n.const):mo(n)?bs(e):Is(e,ko(t),n)}(e,t.const,n):hr(t.const)?function(e,t,n){return Ao(n)?Ts(e,t,n.const):_o(n)?bs(e):Is(e,ko(t),n)}(e,t.const,n):br(t.const)?function(e,t,n){return Ao(n)?Ts(e,t,n.const):Ro(n)?bs(e):Is(e,ko(t),n)}(e,t.const,n):xr(t.const)?function(e,t,n){return Ao(n)?Ts(e,t,n.const):To(n)?bs(e):Is(e,ko(t),n)}(e,t.const,n):Gi()}function Ns(e,t,n){return zi(n)&&Oi(n.extends)?ks():As(ta(e,t,n),e=>function(e,t,n){return Ri(t)?Ri(n)?bs(e):ks():bs(e)}(e,t,n),()=>ks())}function js(e,t,n){let r={};for(let i of Fr(n))r[i]=i in t?Ns({},t[i],n[i]):Ri(n[i])?zi(n[i])?bs(Xr(e,{[n[i].name]:n[i].extends})):bs(e):ks();let i=Wr(r).every(e=>$s(e)),o=i?function(e,t){return e.reduce((e,n)=>n in t&&$s(t[n])?{...e,...t[n].inferred}:Gi(),{})}(Fr(r),r):{};return i?bs(o):ks()}function Ls(e,t,n){return function(e,t,n){let r=js(e,t,n);return $s(r)?bs(Xr(e,r.inferred)):ks()}(e,t,n)}function Bs(e,t,n,r){return Lr(t,(t,i)=>As(ta({},e[t],n),t=>Bs(e,i,n,function(e,t){return Fr(t).reduce((n,r)=>({...n,[r]:zr(e,r)?No(n[r])?Co([...n[r].anyOf,t[r]]):Co([e[r],t[r]]):t[r]}),e)}(r,t)),()=>ks()),()=>bs(r))}function zs(e,t,n){return Cu(n)?function(e,t,n,r){return Bs(t,Fr(t),r,e)}(e,t,qu(n),Tu(n)):Ti(n)?Ls(e,t,n.properties):Is(e,Mi(t),n)}function Ds(e,t,n,r){return Cu(r)?function(e,t,n,r,i){return ta(e,n,i)}(e,Pu(t),n,Pu(qu(r)),Tu(r)):Ti(r)?function(e,t){return Sr(Fr(t).length,0)?bs(e):ks()}(e,r.properties):xi(r)||Ni(r)?bs(e):ks()}function Us(e,t){return ri({"~kind":"Inferrable"},{name:e,type:t},{})}function Fs(e){return kr(e)&&zr(e,"~kind")&&zr(e,"name")&&zr(e,"type")&&Sr(e["~kind"],"Inferrable")&&xr(e.name)&&kr(e.type)}function Ws(e){return Nu(e)?zi(e.items)?pi(e.items.extends)?Us(e.items.name,e.items.extends.items):Ni(e.items.extends)?Us(e.items.name,e.items.extends):void 0:Gi():void 0}function Gs(e){return zi(e)?Us(e.name,e.extends):void 0}function Ks(e,t){let n=[];for(let r of e){if(!$s(ta({},r,t)))return;n.push(r)}return n}function Js(e,t,n,r){let i=Ks(n,r);return pr(i)?bs(Xr(e,{[t]:Co(i)})):ks()}function Hs(e,t){return t?function(e){return[...e].reverse()}(e):e}function Vs(e,t,n,r,i){let o=Ws(r);return Fs(o)?function(e,t,n,r){let i=Ks(n,r);return pr(i)?bs(Xr(e,{[t]:Zo(i)})):ks()}(e,o.name,Hs(n,t),o.type):Lr(n,(n,o)=>function(e,t,n,r,i,o){return As(ta(e,n,i),e=>Zs(e,t,r,o),()=>ks())}(e,t,n,o,r,i),()=>ks())}function Zs(e,t,n,r){return function(e,t,n,r){return Lr(r,(r,i)=>Vs(e,t,n,r,i),()=>Sr(n.length,0)?bs(e):ks())}(e,t,n,r)}function Xs(e,t,n){let r=fc(e,dc([],[]),n),i=function(e){let t=e.length>0?e[0]:void 0,n=si(t)?Ws(t):void 0;return si(n)}(r);return Zs(e,i,Hs(t,i),Hs(r,i))}function Qs(e,t,n){let r=Gs(n);return Fs(r)?Js(e,r.name,t,r.type):function(e,t,n){for(let r of t){let t=ta(e,r,n);if(!$s(t))return t;e=t.inferred}return bs(e)}(e,t,n)}function Ys(e,t,n){return Lr(n,(n,r)=>As(ta(e,t,n),e=>bs(e),()=>Ys(e,t,r)),()=>ks())}function ea(e,t,n){return Lr(t,(t,r)=>As(Ys(e,t,n),e=>ea(e,r,n),()=>ks()),()=>bs(e))}function ta(e,t,n){return xi(t)?Es(e,t,n):pi(t)?Rs(e,t,t.items,n):mo(t)?function(e,t,n){return mo(n)?bs(e):Is(e,t,n)}(e,t,n):_o(t)?function(e,t,n){return _o(n)?bs(e):Is(e,t,n)}(e,t,n):_i(t)?function(e,t,n,r){return xi(r)||Ni(r)?bs(e):_i(r)?As(qs(e,t,r.parameters),e=>Ms(e,n,r.instanceType),()=>ks()):ks()}(e,t.parameters,t.instanceType,n):Di(t)?function(e,t,n,r,i){return As(ta(e,t,i),()=>ta(e,n,i),()=>ta(e,r,i))}(e,t.if,t.then,t.else,n):Ui(t)?function(e,t,n){return ta(e,_u(t),n)}(e,t.enum,n):yi(t)?function(e,t,n,r){return xi(r)||Ni(r)?bs(e):yi(r)?As(qs(e,t,r.parameters),e=>Ms(e,n,r.returnType),()=>ks()):ks()}(e,t.parameters,t.returnType,n):vo(t)?function(e,t,n){return vo(n)||Ro(n)?bs(e):Is(e,t,n)}(e,t,n):Wi(t)?function(e,t,n){return ta(e,gu(t),n)}(e,t.allOf,n):Ao(t)?Cs(e,t,n):Oi(t)?function(e,t,n){return zi(n)?Is(e,t,n):bs(e)}(e,t,n):Oo(t)?function(e,t,n){return Oo(n)?bs(e):Is(e,t,n)}(e,t,n):Ro(t)?function(e,t,n){return Ro(n)?bs(e):Is(e,t,n)}(e,t,n):Ti(t)?zs(e,t.properties,n):Cu(t)?Ds(e,qu(t),Tu(t),n):To(t)?function(e,t,n){return To(n)?bs(e):Is(e,t,n)}(e,t,n):Po(t)?function(e,t,n){return Po(n)?bs(e):Is(e,t,n)}(e,t,n):ys(t)?function(e,t,n){return ta(e,yu(t),n)}(e,t.pattern,n):Xo(t)?function(e,t,n){let r=fc(e,dc([],[]),t);return Xo(n)?Xs(e,r,n.items):pi(n)?Qs(e,r,n.items):Is(e,Zo(r),n)}(e,t.items,n):ju(t)?function(e,t,n){return Lu(n)||ju(n)?bs(e):Is(e,t,n)}(e,t,n):No(t)?function(e,t,n){let r=Gs(n);return Fs(r)?Js(e,r.name,t,r.type):No(n)?ea(e,t,n.anyOf):ea(e,t,[n])}(e,t.anyOf,n):Ni(t)?function(e,t,n){return zi(n)?Is(e,t,n):xi(n)||Ni(n)?bs(e):ks()}(e,t,n):Lu(t)?function(e,t,n){return Lu(n)?bs(e):Is(e,t,n)}(e,t,n):ks()}function na(e,t,n){return cc(e)?oi(function(e,t){return gu([...e,Mi(t)])}(e,t),{},n):function(e,t,n={}){return ai("Interface",[e,t],n)}(e,t,n)}function ra(e){return si(e)&&zr(e,"action")&&Sr(e.action,"Interface")}function ia(e,t,n){return oa(e,t,qi(n))}function oa(e,t,n){return Lr(n,(n,r)=>!!ua(e,t,n)||oa(e,t,r),()=>!1)}function ua(e,t,n){return bi(n)?function(e,t,n){return!!e.includes(n)||ua([...e,n],t,t[n])}(e,t,n.$ref):pi(n)?ua(e,t,n.items):_i(n)?oa(e,t,[...n.parameters,n.instanceType]):yi(n)?oa(e,t,[...n.parameters,n.returnType]):ra(n)?ia(e,t,n.parameters[1]):Wi(n)?oa(e,t,n.allOf):Ti(n)?ia(e,t,n.properties):No(n)?oa(e,t,n.anyOf):Xo(n)?oa(e,t,n.items):!!Cu(n)&&ua(e,t,Tu(n))}function sa(e,t){return t.reduce((t,n)=>function(e,t,n){return ua(e,t,n)}([n],e,e[n])?[...t,n]:t,[])}function aa(e,t,n){return da(e,qi(t),n)}function da(e,t,n){return t.reduce((t,n)=>ca(e,n,t),n)}function ca(e,t,n){return bi(t)?function(e,t,n){return n.includes(t)?n:t in e?ca(e,e[t],[...n,t]):Gi()}(e,t.$ref,n):pi(t)?ca(e,t.items,n):_i(t)?da(e,[...t.parameters,t.instanceType],n):yi(t)?da(e,[...t.parameters,t.returnType],n):ra(t)?aa(e,t.parameters[1],n):Wi(t)?da(e,t.allOf,n):Ti(t)?aa(e,t.properties,n):No(t)?da(e,t.anyOf,n):Xo(t)?da(e,t.items,n):Cu(t)?ca(e,Tu(t),n):n}function la(e){return ri({"~kind":"Any"},{},t);var t}function fa(e){return e.reduce((e,t)=>[...e,pa(t)],[])}function pa(e){return bi(e)?la(e.$ref):pi(e)?fi(pa(e.items),mi(e)):_i(e)?hi(fa(e.parameters),pa(e.instanceType)):yi(e)?gi(fa(e.parameters),pa(e.returnType)):Wi(e)?Fi(fa(e.allOf)):Ti(e)?Mi(Fr(t=e.properties).reduce((e,n)=>({...e,[n]:pa(t[n])}),{})):Cu(e)?Ru(Mu(e),pa(Tu(e))):No(e)?Co(fa(e.anyOf)):Xo(e)?Zo(fa(e.items)):e;var t}function ma(e){return t=e.$defs,(n=e.$ref)in t?pa(t[n]):Ci();var t,n}function ha(e,t){return Fr(e).filter(e=>t.includes(e)).reduce((t,n)=>{let r=e[n],i=ra(r)?function(e,t,n){return gu([...pc(e,dc([],[]),t),Mi(lc({},dc([],[]),n))])}(e,r.parameters[0],r.parameters[1]):r;return{...t,[n]:i}},{})}function _a(e,t,n){let r=function(e,t,n){return ca(e,n,[t])}(e,t,n);return ji(ha(e,r),t)}function ga(e,t){return t in e?bi(e[t])?ga(e,e[t].$ref):e[t]:Si()}function ya(e,t){return ga(e,t)}function va(e){return Li(e)?ma(e):wr(t=e)&&zr(t,"~unsafe")&&vr(t["~unsafe"])?Ci():e;var t}function ba(e,t,n){return ta(e,va(t),va(n))}var wa=0,ka=1,xa=2,$a=3;function Aa(e,t){let n=[ba({},e,t),ba({},t,e)];return $s(n[0])&&$s(n[1])?wa:$s(n[0])&&xs(n[1])?xa:xs(n[0])&&$s(n[1])?$a:ka}function Sa(e,t,n=[],r=t){return Lr(t,(t,i)=>{let o=Aa(e,t);return Sr(o,xa)||Sr(o,wa)?r:Sr(o,ka)?Sa(e,i,[...n,t],r):Sa(e,i,n,r)},()=>[...n,e])}function Oa(e,t,n){let r=bu(e);return xi(r)||Ni(r)?[r]:Oi(r)?Ia(t,n):Ti(r)?Ia(t,[...n,r]):Ia(t,Sa(r,n))}function Ia(e,t=[]){return Lr(e,(e,n)=>Oa(e,n,t),()=>t)}function Ea(e){return ku(Ia(e))}function Ra(e,t){return oi(bu(e),{},t)}function Pa(e,t=[]){return di(e)&&Sr(e.action,"Conditional")?bi(e.parameters[0])?Pa(e.parameters[2],Pa(e.parameters[3],[...t,e.parameters[0].$ref])):Pa(e.parameters[2],Pa(e.parameters[3],t)):di(e)&&Sr(e.action,"Mapped")&&di(e.parameters[1])&&Sr(e.parameters[1].action,"KeyOf")&&bi(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function qa(e,t,n=[]){return Lr(e,(e,r)=>Lr(t,(t,i)=>qa(r,i,[...n,[t,e]]),()=>n),()=>n)}function Ma(e){let t=function(e){return ys(e)?yu(e.pattern):Ui(e)?_u(e.enum):e}(e);return No(t)?[...t.anyOf]:[t]}function Ta(e,t){return e.reduce((e,n)=>[...e,[...n,t]],[])}function Ca(e,t){return t.reduce((t,n)=>[...t,...Ta(e,n)],[])}function Na(e){return e.reduce((e,t)=>Sr(t[0],!0)?Ca(e,Ma(t[1])):Ca(e,[t[1]]),[[]])}function ja(e,t,n){let r=function(e,t){return e.reduce((e,n)=>[...e,t.includes(n.name)],[])}(e,Pa(n)),i=qa(t,r);return di(n)&&Sr(n.action,"Conditional")||di(n)&&Sr(n.action,"Mapped")?Na(i):[t]}function La(e,t,n){return t in e?Ba(e,t,e[t],n):["(not-resolvable)",Si()]}function Ba(e,t,n,r){return ki(n)?function(e,t,n){return[e,wi(t,n)]}(t,n.parameters,n.expression):bi(n)?La(e,n.$ref,r):["(not-generic)",Si()]}function za(e,t,n,r,i){let o=_c(e,t,i);return function(e,t,n){if(zi(t)||Za(t)||$s(ba({},t,n)))return;throw Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:{parameter:e,expect:n,actual:t}})}(n,o,r),Xr(e,{[n]:o})}function Da(e,t,n,r){return Lr(n,(n,i)=>function(e,t,n,r,i){let o=_c(e,t,n.extends),u=_c(e,t,n.equals);return Lr(i,(i,u)=>Da(za(e,t,n.name,o,i),t,r,u),()=>Da(za(e,t,n.name,o,u),t,r,[]))}(e,t,n,i,r),()=>e)}var Ua=0,Fa=0;function Wa(){(function(){if(!Ir(Fa,Vr().maxInstantiationCount))throw Error("Type instantiation is excessively deep and possibly infinite")})(),Fa++,Ua++}function Ga(e,t){return Sr(function(e){return Or(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}(e),t)}function Ka(e,t,n,r,i,o){Wa();try{let u=function(e,t,n,r){return Da(e,t,n,r)}(e,t,r,o),s=_c(u,dc([...t.callstack,n.$ref],t.visited),i);return _c(u,dc([],[]),s)}finally{Sr(--Ua,0)&&(Fa=0)}}function Ja(e,t,n,r,i,o){let u=function(e,t,n,r,i,o){return o.reduce((o,u)=>[...o,Ka(e,t,n,r,i,u)],[])}(e,t,n,r,i,ja(r,o,i));return Sr(u.length,1)?u[0]:vu(u)}function Ha(e,t,n,r){let i=pc(e,t,r),o=function(e,t,n){return Ba(e,"(anonymous)",t,n)}(e,n,r),u=o[0],s=o[1];return ki(s)?Ga(t,u)?Va(vi(u),i):Ja(e,t,vi(u),s.parameters,s.expression,i):Va(n,i)}function Va(e,t){return ri({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function Za(e){return ui(e,"Call")}function Xa(e,t){return oi(function(e){return ii(e,["~immutable"])}(e),{},t)}function Qa(e,t){return Ao(t)?function(e,t){return xr(t)?ko(function(e,t){return e(t)}(e,t)):ko(t)}(e,t.const):ys(t)?function(e,t){return Qa(e,yu(t))}(e,t.pattern):No(t)?function(e,t){return Co(t.map(t=>Qa(e,t)))}(e,t.anyOf):t}var Ya=e=>e[0].toUpperCase()+e.slice(1),ed=e=>e.toLowerCase(),td=e=>e[0].toLowerCase()+e.slice(1),nd=e=>e.toUpperCase();function rd(e,t){return cc([e])?oi(Qa(Ya,e),{},t):function(e,t={}){return ai("Capitalize",[e],t)}(e,t)}function id(e,t){return cc([e])?oi(Qa(ed,e),{},t):function(e,t={}){return ai("Lowercase",[e],t)}(e,t)}function od(e,t){return cc([e])?oi(Qa(td,e),{},t):function(e,t={}){return ai("Uncapitalize",[e],t)}(e,t)}function ud(e,t){return cc([e])?oi(Qa(nd,e),{},t):function(e,t={}){return ai("Uppercase",[e],t)}(e,t)}function sd(e,t,n,r,i,o,u){return cc([n,r])?oi(function(e,t,n,r,i,o){let u=ba(e,n,r);return vs(u)?Co([_c(u.inferred,t,i),_c(e,t,o)]):ws(u)?_c(u.inferred,t,i):_c(e,t,o)}(e,t,n,r,i,o),{},u):function(e,t,n,r,i={}){return ai("Conditional",[e,t,n,r],i)}(n,r,i,o,u)}function ad(e,t){return cc([e])?oi(function(e){let t=_i(e)?e.parameters:[];return Zo(fc({},dc([],[]),t))}(e),{},t):function(e,t={}){return ai("ConstructorParameters",[e],t)}(e,t)}function dd(e,t,n){return cc([e,t])?oi(mu(e,t),{},n):function(e,t,n={}){return ai("Exclude",[e,t],n)}(e,t,n)}function cd(e,t){return $s(ba({},e,t))?[e]:[]}function ld(e,t,n=[]){return Lr(e,(e,r)=>ld(r,t,[...n,...cd(e,t)]),()=>n)}function fd(e,t){let n=bu(e);return vu(ld(No(n)?n.anyOf:[n],t))}function pd(e,t,n){return cc([e,t])?oi(fd(e,t),{},n):function(e,t,n={}){return ai("Extract",[e,t],n)}(e,t,n)}function md(e){return e.reduce((e,t)=>function(e,t){let n=Fr(e).filter(e=>!zr(t,e)),r=Fr(t).filter(t=>!zr(e,t)),i=Fr(e).filter(e=>zr(t,e)),o=n.reduce((t,n)=>({...t,[n]:e[n]}),{}),u=r.reduce((e,n)=>({...e,[n]:t[n]}),{}),s=i.reduce((n,r)=>({...n,[r]:gu([e[r],t[r]])}),{}),a=Xr(o,u);return Xr(a,s)}(e,gd(t)),{})}function hd(e){return gd(Mi(tu(Zo(e).items)))}function _d(e,t){return Lr(e,(e,n)=>_d(n,function(e,t){return Fr(e).filter(e=>e in t).reduce((n,r)=>({...n,[r]:vu([e[r],t[r]])}),{})}(t,gd(e))),()=>t)}function gd(e){return Li(e)?(i=e.$defs,o=e.$ref,gd(ya(i,o))):Di(e)?(t=e.if,n=e.then,r=e.else,gd(hu(t,n,r))):Wi(e)?md(e.allOf):No(e)?Lr(e.anyOf,(e,t)=>_d(t,gd(e)),()=>Gi()):Xo(e)?hd(e.items):Ti(e)?e.properties:{};var t,n,r,i,o}function yd(e){return Mi(gd(e))}var vd=new RegExp("^(?:0|[1-9][0-9]*)$");function bd(e){let t=`${e}`;return vd.test(t)?parseInt(t):e}function wd(e){return e.map(e=>kd(e))}function kd(e){return Wi(e)?Fi(wd(e.allOf)):No(e)?Co(wd(e.anyOf)):Ao(e)?ko(bd(e.const)):e}function xd(e){return Li(e)?(i=e.$defs,o=e.$ref,xd(ya(i,o))):Di(e)?(t=e.if,n=e.then,r=e.else,xd(hu(t,n,r))):Ui(e)?xd(_u(e.enum)):Wi(e)?xd(gu(e.allOf)):Ao(e)?[`${e.const}`]:ys(e)?xd(yu(e.pattern)):No(e)?function(e){return e.reduce((e,t)=>[...e,...xd(t)],[])}(e.anyOf):[];var t,n,r,i,o}function $d(e){return xd(e)}function Ad(e,t){return t.map(t=>Sd(e,t))}function Sd(e,t){return pi(t)?fi(Sd(e,t.items)):_i(t)?hi(Ad(e,t.parameters),Sd(e,t.instanceType)):yi(t)?gi(Ad(e,t.parameters),Sd(e,t.returnType)):Xo(t)?Zo(Ad(e,t.items)):No(t)?Co(Ad(e,t.anyOf)):Wi(t)?Fi(Ad(e,t.allOf)):ui(t,"This")?Mi(e):t}function Od(e,t){return function(e,t){return Sd(e,t)}(e,t in e?e[t]:Si())}function Id(e,t){return t.reduce((t,n)=>[...t,Od(e,n)],[])}var Ed=new RegExp(Ou);function Rd(e){let t=function(e){return e.filter(e=>Ed.test(e))}(Pi(e));return vu(Id(e,t))}function Pd(e,t){return Ro(t)?Rd(e):function(e,t){return vu(Id(e,$d(t)))}(e,t)}function qd(e){return e.map(e=>Md(e))}function Md(e){return Wi(e)?Fi(qd(e.allOf)):No(e)?Co(qd(e.anyOf)):Ao(e)?ko(bd(e.const)):e}function Td(e,t){let n=function(e,t){return e.reduceRight((e,n,r)=>$s(ba({},ko(r),t))?[n,...e]:e,[])}(e,Md(t));return wu(n)}function Cd(e,t){return Ao(t)&&Sr(t.const,"length")?ko(e.length):Ro(t)||vo(t)?function(e){return wu(e)}(e):Td(e,t)}function Nd(e,t){return pi(e)?function(e,t){return $s(ba({},kd(t),Eo()))?e:Ao(t)&&Sr(t.const,"length")?Eo():Si()}(e.items,t):Ti(e)?Pd(e.properties,t):Xo(e)?Cd(e.items,t):Si()}function jd(e,t,n){return cc([e,t])?oi(Nd(function(e){return Li(e)||Di(e)||Wi(e)||No(e)?yd(e):e}(e),t),{},n):function(e,t,n={}){return ai("Index",[e,t],n)}(e,t,n)}function Ld(e,t){return cc([e])?oi(function(e){return _i(e)?e.instanceType:Si()}(e),{},t):function(e,t={}){return ai("InstanceType",[e],t)}(e,t)}function Bd(e){return e.reduce((e,t)=>{return mr(n=t)||hr(n)||br(n)||xr(n)?[...e,ko(bd(t))]:Gi();var n},[])}function zd(e){return xi(e)?Co([Eo(),Mo(),ri({"~kind":"Symbol"},{type:"symbol"},t)]):pi(e)?(e.items,Eo()):Ti(e)?wu(Bd(Fr(e.properties))):Cu(e)?function(e){return Mu(e)}(e):Xo(e)?wu(e.items.map((e,t)=>ko(t))):Si();var t}function Dd(e,t){return cc([e])?oi(zd(function(e){return Li(e)||Di(e)||Wi(e)||No(e)?yd(e):e}(e)),{},t):function(e,t={}){return ai("KeyOf",[e],t)}(e,t)}function Ud(e){return Ui(e)?Ud(_u(e.enum)):Ao(e)?br(t=e.const)?[ko(`${t}`)]:[ko(t)]:ys(e)?Ud(yu(e.pattern)):No(e)?e.anyOf.reduce((e,t)=>[...e,...Ud(t)],[]):[e];var t}function Fd(e,t,n,r,i,o){let u=Xr(e,{[n.name]:r}),s=function(e){return ys(e)?yu(e.pattern):e}(_c(u,t,i)),a=_c(u,t,o);return xo(s)||$o(s)?{[s.const]:a}:{}}function Wd(e,t,n,r,i,o){let u=function(e){return Ud(e)}(r),s=function(e,t,n,r,i,o){return r.reduce((r,u)=>[...r,Fd(e,t,n,u,i,o)],[])}(e,t,n,u,i,o);return gu(s.reduce((e,t)=>[...e,Mi(t)],[]))}function Gd(e,t,n,r,i,o,u){return cc([r])?oi(Wd(e,t,n,r,i,o),{},u):function(e,t,n,r,i={}){return ai("Mapped",[e,t,n,r],i)}(n,r,i,o,u)}function Kd(e,t,n){let r=function(e){return sa(e,Pi(e))}(t),i=function(e,t,n){let r=Xr(e,t);return Fr(t).filter(e=>n.includes(e)).reduce((e,n)=>({...e,[n]:_a(r,n,t[n])}),{})}(e,t,r),o=function(e,t,n){let r=Xr(e,t);return Fr(t).filter(e=>!n.includes(e)).reduce((e,n)=>({...e,[n]:_c(r,dc([],[]),t[n])}),{})}(e,t,r);return oi({...i,...o},{},n)}function Jd(e,t){return cc([e])?oi(function(e){var t;return dd(e,Co([So(),ri({"~kind":"Undefined"},{type:"undefined"},t)]),{})}(e),{},t):function(e,t={}){return ai("NonNullable",[e],t)}(e,t)}function Hd(e){let t=yd(e);return Ti(t)?t.properties:Gi()}function Vd(e,t){let n=Hd(e),r=$d(t);var i,o;return Mi((o=r,Fr(i=n).reduce((e,t)=>o.includes(t)?e:{...e,[t]:i[t]},{})))}function Zd(e,t,n){return cc([e,t])?oi(Vd(e,t),{},n):function(e,t,n={}){return ai("Omit",[e,t],n)}(e,t,n)}function Xd(e,t){return cc([e])?oi(function(e){let t=yi(e)?e.parameters:[];return Zo(fc({},dc([],[]),t))}(e),{},t):function(e,t={}){return ai("Parameters",[e],t)}(e,t)}function Qd(e){return Li(e)?function(e,t){let n=Qd(ya(e,t));return ji(Xr(e,{[t]:n}),t)}(e.$defs,e.$ref):Di(e)?(n=e.if,r=e.then,i=e.else,Qd(hu(n,r,i))):Wi(e)?Qd(gu(e.allOf)):No(e)?function(e){return Co(e.map(e=>Qd(e)))}(e.anyOf):Ti(e)?Mi(Fr(t=e.properties).reduce((e,n)=>({...e,[n]:Ii(t[n])}),{})):Mi({});var t,n,r,i}function Yd(e,t){return cc([e])?oi(Qd(e),{},t):function(e,t={}){return ai("Partial",[e],t)}(e,t)}function ec(e,t){let n=function(e,t){return Fr(e).reduce((n,r)=>t.includes(r)?Xr(n,{[r]:e[r]}):n,{})}(Hd(e),$d(t));return Mi(n)}function tc(e,t,n){return cc([e,t])?oi(ec(e,t),{},n):function(e,t,n={}){return ai("Pick",[e,t],n)}(e,t,n)}function nc(e){return pi(e)?function(e){return vc(fi(e))}(e.items):Li(e)?function(e,t){let n=nc(ya(e,t));return ji(Xr(e,{[t]:n}),t)}(e.$defs,e.$ref):Di(e)?(n=e.if,r=e.then,i=e.else,nc(hu(n,r,i))):Wi(e)?nc(gu(e.allOf)):Ti(e)?Mi(Fr(t=e.properties).reduce((e,n)=>({...e,[n]:lo(t[n])}),{})):Xo(e)?function(e){return vc(Zo(e))}(e.items):No(e)?function(e){return Co(e.map(e=>nc(e)))}(e.anyOf):e;var t,n,r,i}function rc(e,t){return cc([e])?oi(nc(e),{},t):function(e,t={}){return ai("ReadonlyObject",[e],t)}(e)}function ic(e){return Li(e)?function(e,t){let n=ic(ya(e,t));return ji(Xr(e,{[t]:n}),t)}(e.$defs,e.$ref):Di(e)?(n=e.if,r=e.then,i=e.else,ic(hu(n,r,i))):Wi(e)?ic(gu(e.allOf)):No(e)?function(e){return Co(e.map(e=>ic(e)))}(e.anyOf):Ti(e)?Mi(Fr(t=e.properties).reduce((e,n)=>({...e,[n]:eu(t[n])}),{})):Mi({});var t,n,r,i}function oc(e,t){return cc([e])?oi(ic(e),{},t):function(e,t={}){return ai("Required",[e],t)}(e,t)}function uc(e,t){return cc([e])?oi(function(e){return yi(e)?e.returnType:Si()}(e),{},t):function(e,t={}){return ai("ReturnType",[e],t)}(e,t)}function sc(e,t){return cc([e])?oi(e,{},t):function(e,t){return ai("With",[e,t],{})}(e,t)}function ac(e){return e.reduce((e,t)=>{return[...e,...(n=t,Nu(n)?Xo(n.items)?ac(n.items.items):zi(n.items)||bi(n.items)?[n]:[Si()]:[n])];var n},[])}function dc(e,t){return{callstack:e,visited:t}}function cc(e){return Lr(e,(e,t)=>!bi(e)&&cc(t),()=>!0)}function lc(e,t,n){return Fr(n).reduce((r,i)=>({...r,[i]:_c(e,t,n[i])}),{})}function fc(e,t,n){return ac(pc(e,t,n))}function pc(e,t,n){return n.map(n=>_c(e,t,n))}function mc(e,t,n,r,i){return Sr(n,"AddImmutable")?function(e,t,n,r){let i=_c(e,t,n);return yc(i,r)}(e,t,r[0],i):Sr(n,"RemoveImmutable")?function(e,t,n,r){return Xa(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"AddReadonly")?function(e,t,n,r){return ci(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"RemoveReadonly")?function(e,t,n,r){return Qo(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"AddOptional")?function(e,t,n,r){return li(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"RemoveOptional")?function(e,t,n,r){return Yo(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Capitalize")?function(e,t,n,r){return rd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Conditional")?function(e,t,n,r,i,o,u){return sd(e,t,_c(e,t,n),_c(e,t,r),i,o,u)}(e,t,r[0],r[1],r[2],r[3],i):Sr(n,"ConstructorParameters")?function(e,t,n,r){return ad(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Evaluate")?function(e,t,n,r){return Ra(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Exclude")?function(e,t,n,r,i){return dd(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"Extract")?function(e,t,n,r,i){return pd(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"Index")?function(e,t,n,r,i){return jd(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"InstanceType")?function(e,t,n,r={}){return Ld(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Interface")?function(e,t,n,r,i){return na(pc(e,t,n),lc(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"KeyOf")?function(e,t,n,r){return Dd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Lowercase")?function(e,t,n,r){return id(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Mapped")?function(e,t,n,r,i,o,u){return Gd(e,t,n,_c(e,t,r),i,o,u)}(e,t,r[0],r[1],r[2],r[3],i):Sr(n,"Module")?function(e,t,n,r){return Kd(e,n,r)}(e,0,r[0],i):Sr(n,"NonNullable")?function(e,t,n,r){return Jd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Pick")?function(e,t,n,r,i){return tc(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"Parameters")?function(e,t,n,r){return Xd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Partial")?function(e,t,n,r){return Yd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Omit")?function(e,t,n,r,i){return Zd(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"ReadonlyObject")?function(e,t,n,r){return rc(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Record")?function(e,t,n,r,i){return Su(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"Required")?function(e,t,n,r){return oc(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"ReturnType")?function(e,t,n,r={}){return uc(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"TemplateLiteral")?function(e,t,n,r){return gs(pc(e,t,n),r)}(e,t,r[0],i):Sr(n,"Uncapitalize")?function(e,t,n,r){return od(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Uppercase")?function(e,t,n,r){return ud(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"With")?function(e,t,n,r){return sc(_c(e,t,n),r)}(e,t,r[0],r[1]):ai(n,r,i)}function hc(e,t,n){let r=bi(n)?function(e,t,n,r){return t.visited.includes(r)?n:r in e?_c(e,dc(t.callstack,[...t.visited,r]),e[r]):n}(e,t,n,n.$ref):pi(n)?fi(_c(e,t,n.items),mi(n)):Za(n)?Ha(e,t,n.target,n.arguments):_i(n)?hi(pc(e,t,n.parameters),_c(e,t,n.instanceType),function(e){return ii(e,["~kind","type","parameters","instanceType"])}(n)):yi(n)?gi(pc(e,t,n.parameters),_c(e,t,n.returnType),function(e){return ii(e,["~kind","type","parameters","returnType"])}(n)):Di(n)?function(e,t,n,r={}){return ri({"~kind":"Dependent"},{if:e,then:t,else:n},r)}(_c(e,t,n.if),_c(e,t,n.then),_c(e,t,n.else),function(e){return ii(e,["~kind","if","then","else"])}(n)):Wi(n)?Fi(pc(e,t,n.allOf),function(e){return ii(e,["~kind","allOf"])}(n)):Ti(n)?Mi(lc(e,t,n.properties),function(e){return ii(e,["~kind","type","properties","required"])}(n)):Cu(n)?(i=qu(n),o=_c(e,t,Tu(n)),Vo(i,o)):Nu(n)?function(e){return ri({"~kind":"Rest"},{type:"rest",items:e},{})}(_c(e,t,n.items)):Xo(n)?Zo(fc(e,t,n.items),function(e){return ii(e,["~kind","type","items","minItems","additionalItems"])}(n)):No(n)?Co(pc(e,t,n.anyOf),function(e){return ii(e,["~kind","anyOf"])}(n)):n;var i,o;return function(e,t){let n=Ri(e)?li(t,{}):t,r=fo(e)?ci(n,{}):n;return co(e)?yc(r,{}):r}(n,r)}function _c(e,t,n){return di(n)?mc(e,t,n.action,n.parameters,n.options):hc(e,t,n)}function gc(e,t){return _c(e,dc([],[]),t)}function yc(e,t){return oi(function(e){return oi(e,{"~immutable":!0},{})}(e),{},t)}function vc(e,t={}){return yc(e,t)}function bc(e,t={}){return Ra(e,t)}function wc(e,t,n=[]){return Lr(t,(r,i)=>Sr(function(e,t){let n=Aa(e,t);return Sr(n,$a)||Sr(n,ka)?1:0}(e,r),1)?wc(e,i,[...n,r]):[...n,e,...t],()=>[...n,e])}function kc(e,t=[]){return Lr(e,(e,n)=>kc(n,wc(e,t)),()=>t)}function xc(e){return kc(e)}var $c=131072,Ac=1048576,Sc=Mo({description:"Recipient thread id or unique name as returned by thread_list; a name shared by several threads returns ambiguous_target with candidates."}),Oc=Ei(ho({description:"Address threads in every workspace on this machine instead of only the caller's workspace; left unset, an exact id from another workspace returns scope_denied."})),Ic=Ei(Mo({description:"Caller-chosen key that makes a retried call return the earlier result instead of repeating the side effect; reusing the key with different arguments returns idempotency_conflict."})),Ec=Ei(Mo({description:"Turn id the steer applies to; required with delivery steer, and a changed active turn returns turn_conflict with the message held undelivered."})),Rc=Ei(Mo({maxLength:200,description:"One-line preview shown to the caller when the completion notice arrives."})),Pc=Mo({maxLength:32768,description:"Instruction to deliver to the target thread; longer than 32768 UTF-8 bytes returns message_too_large."}),qc=Mo({minLength:1,description:"Binding id as returned by thread_bind or thread_bindings."}),Mc=yo({minimum:1,description:"Revision the caller last saw for this binding; a binding that moved since returns stale_revision."}),Tc=Mo({description:"Text relayed to or from the external thread; longer than 32768 UTF-8 bytes returns message_too_large."}),Cc=Co([ko("auto"),ko("steer"),ko("follow_up")],{description:"auto steers the running turn when one is active and starts a new turn otherwise; steer requires expected_turn_id and becomes turn_conflict when the active turn changed; follow_up queues the message behind the running turn."}),Nc=Co([ko("discord"),ko("telegram"),ko("slack"),ko("notion"),ko("feishu"),ko("herdr"),ko("custom")],{description:"Chat platform of the external conversation; custom covers any other connector."}),jc=Co([ko("milestone"),ko("report"),ko("question"),ko("completion")]),Lc=Ei(Mo({description:"Thread id or unique name of the session to attach, as returned by thread_list; self or leaving it unset attaches the calling session."}));Mi({name:Ei(Mo({description:"Display label for the new thread; an existing thread with the same normalized name returns name_conflict, and later renames change only the label while thread_id stays the address."})),cwd:Ei(Mo({description:"Working directory the new thread runs in; leaving it unset keeps the thread inside the caller's workspace."})),fork_from:Ei(Mo({description:"Durable id of an existing thread to fork; the new thread starts with that transcript as prior context."})),idempotency_key:Ic}),Mi({all_scope:Ei(ho({description:"List threads from every workspace on this machine; the default scope returns only the caller's workspace."}))}),Mi({thread:Sc,cursor:Ei(Mo({description:"Opaque cursor from an earlier thread_read to continue a truncated transcript; a transcript revision that moved past it returns cursor_stale."})),max_bytes:Ei(yo({minimum:1,maximum:Ac,description:"Byte budget for the returned transcript slice, default 131072 and capped at 1048576; a longer transcript returns truncated with next_cursor."})),all_scope:Oc}),Mi({thread:Sc,message:Pc,delivery:Ei(Cc),expected_turn_id:Ec,summary:Rc,idempotency_key:Ic,all_scope:Oc}),Mi({thread:Sc,turn_id:Ei(Mo({description:"Running turn to stop, defaulting to the newest running turn; interrupting an idle thread returns success with interrupted false."})),all_scope:Oc}),Mi({thread:Mo({description:"Thread id or name to reopen after a pause; the fuzzy resolver also accepts partial names and workspace basenames, and a close runner-up returns ambiguous_target with candidates."}),match:Ei(Co([ko("exact"),ko("fuzzy")],{description:"exact resolves a thread id or a unique name; fuzzy additionally ranks partial names and workspace basenames and returns the top match only when it clearly leads its runner-up."})),message:Pc,delivery:Ei(Cc),expected_turn_id:Ec,summary:Rc,idempotency_key:Ic,all_scope:Oc}),Mi({thread:Sc,name:Mo({minLength:1,maxLength:200,description:"New display label for the thread; the thread keeps its id as its address, and a label already used by another visible thread returns name_conflict."}),all_scope:Oc,idempotency_key:Ic}),Mi({thread:Sc,model:Mo({minLength:1,description:"Model to switch the thread to, as provider/id, an exact model id, or a case-insensitive fragment of the id or display name resolved against the host's model catalog; no match returns model_not_found with the available list, several matches return model_ambiguous with candidates."}),provider:Ei(Mo({description:"Restricts resolution to one provider when the fragment alone would match models from several providers."})),all_scope:Oc,idempotency_key:Ic}),Mi({thread:Sc,level:Co([ko("off"),ko("minimal"),ko("low"),ko("medium"),ko("high"),ko("xhigh"),ko("max")],{description:"Thinking level to apply; a level the thread's active model cannot run returns thinking_level_unsupported with the supported list and leaves the thread unchanged."}),scope:Ei(Co([ko("session"),ko("turn")],{description:"session (default) changes the thread's remembered level for its model; turn changes only the current session level without rewriting the model's remembered level."})),all_scope:Oc,idempotency_key:Ic}),Mi({platform:Nc,account_id:Mo({minLength:1,maxLength:256,description:"Bot or account id the connector speaks as on that platform."}),chat_id:Mo({minLength:1,maxLength:256,description:"Channel, group or direct-chat id on the platform."}),thread_id:Ei(Mo({minLength:1,maxLength:256,description:"Thread id inside the chat; @chat (the default) binds the whole chat on platforms without threads."})),root_message_id:Ei(Mo({minLength:1,maxLength:256,description:"Platform id of the message that started the thread, when there is one."})),progress_message_id:Ei(Mo({minLength:1,maxLength:256,description:"Platform id of an existing progress message that milestone reports edit in place."})),session:Lc,direction:Ei(Mi({inbound:ho(),outbound:ho()},{description:"inbound lets the thread's messages reach the session, outbound lets the session report to the thread; both default to true and at least one is required."})),inbound_mode:Ei(Co([ko("auto"),ko("follow_up")],{description:"How inbound messages are delivered: auto starts a turn when the session is idle and queues behind a running one; follow_up always queues behind the running turn."})),outbound_events:Ei(fi(jc,{maxItems:4,description:"Report kinds this thread receives, each at most once; defaults to all four for an outbound binding."})),policy_id:Ei(Mo({minLength:1,maxLength:256,description:"Connector policy label stored with the binding; default is default."})),ttl_seconds:Ei(Co([yo({minimum:1}),So()],{description:"Lifetime in seconds from now, default 604800 (one week) and never extended; null keeps the binding until it is unbound."})),all_scope:Oc,idempotency_key:Ic}),Mi({binding_id:qc,expected_revision:Mc,idempotency_key:Ic}),Mi({binding_id:qc,expected_revision:Mc,session:Mo({minLength:1,description:"Thread id or unique name of the session that takes the binding over, as returned by thread_list."}),all_scope:Oc,idempotency_key:Ic}),Mi({session:Ei(Mo({minLength:1,description:"Only bindings attached to this session (thread id, unique name, or self)."})),platform:Ei(Nc),account_id:Ei(Mo({minLength:1,description:"Only bindings of this platform account."})),chat_id:Ei(Mo({minLength:1,description:"Only bindings in this chat."})),thread_id:Ei(Mo({minLength:1,description:"Only bindings of this thread id."})),status:Ei(Co([ko("active"),ko("detached"),ko("expired")],{description:"Only bindings in this status; all statuses when unset."})),cursor:Ei(Mo({description:"next_cursor from an earlier thread_bindings call, to continue the same snapshot."})),limit:Ei(yo({minimum:1,maximum:200,description:"Page size, default 50 and at most 200."})),all_scope:Oc}),Mi({binding_id:Ei(Mo({minLength:1,description:"Binding to report to; defaults to the originating binding, the one the message this session is answering now arrived through; refused when that is ambiguous."})),kind:Co([ko("milestone"),ko("report"),ko("question"),ko("completion")],{description:"milestone updates the thread's progress message, report posts a result, question relays a pending question of this session and returns a reply_token, completion is written once when this session's run settles, with the run's real outcome."}),text:Tc,request_id:Ei(Mo({minLength:1,description:"For kind question: the id of this session's pending extension UI request the answer resolves."})),request_kind:Ei(Co([ko("question"),ko("select"),ko("confirm"),ko("input"),ko("editor")],{description:"For kind question: which extension UI request request_id is. It decides the answer forms thread_answer accepts: confirm takes yes/no (any case, surrounding spaces ignored), input and editor take any text including empty, question and select take non-blank text. Without it the answer goes out in every text form at once, so a question, select, input or editor each reads its own and the text must be non-blank; a yes/no word also goes out as the confirm field, so an undeclared confirm reads yes/no too (any other text reads as no)."})),idempotency_key:Ic}),Mi({binding_id:qc,after_cursor:Ei(yo({minimum:0,description:"Read rows after this cursor; unset continues after the binding's acknowledged cursor."})),limit:Ei(yo({minimum:1,maximum:500,description:"Rows per read, default 100 and at most 500."}))}),Mi({binding_id:qc,cursor:yo({minimum:1,description:"Every outbox row up to this cursor is marked delivered; an older cursor changes nothing."}),provider_message_id:Ei(Mo({minLength:1,maxLength:256,description:"Platform id of the message posted for the row at cursor; the first one for a milestone becomes the progress message later milestones edit."}))}),Mi({binding_id:Mo({minLength:1,description:"Binding the answer arrived through; it must be the binding that asked the question."}),reply_token:Mo({minLength:1,description:"reply_token of the question row being answered."}),answer:Tc});function Bc(e){return zr(e,"~refine")&&pr(e["~refine"])&&Tr(e["~refine"],0,e=>kr(e)&&zr(e,"check")&&zr(e,"error")&&gr(e.check)&&gr(e.error))}function zc(e){return kr(e)&&!pr(e)}function Dc(e){return hr(e)}function Uc(e){return zc(e)||Dc(e)}function Fc(e){return zr(e,"additionalItems")&&Uc(e.additionalItems)}function Wc(e){return zr(e,"additionalProperties")&&Uc(e.additionalProperties)}function Gc(e){return zr(e,"allOf")&&pr(e.allOf)&&e.allOf.every(e=>Uc(e))}function Kc(e){return zr(e,"anyOf")&&pr(e.anyOf)&&e.anyOf.every(e=>Uc(e))}function Jc(e){return zr(e,"const")}function Hc(e){return zr(e,"contains")&&Uc(e.contains)}function Vc(e){return zr(e,"default")}function Zc(e){return zr(e,"dependencies")&&kr(e.dependencies)&&Object.values(e.dependencies).every(e=>Uc(e)||pr(e)&&e.every(e=>xr(e)))}function Xc(e){return zr(e,"dependentRequired")&&kr(e.dependentRequired)&&Object.values(e.dependentRequired).every(e=>pr(e)&&e.every(e=>xr(e)))}function Qc(e){return zr(e,"dependentSchemas")&&kr(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(e=>Uc(e))}function Yc(e){return zr(e,"$dynamicAnchor")&&xr(e.$dynamicAnchor)}function el(e){return zr(e,"$dynamicRef")&&xr(e.$dynamicRef)}function tl(e){return zr(e,"else")&&Uc(e.else)}function nl(e){return zr(e,"enum")&&pr(e.enum)}function rl(e){return zr(e,"exclusiveMaximum")&&(br(e.exclusiveMaximum)||mr(e.exclusiveMaximum))}function il(e){return zr(e,"exclusiveMinimum")&&(br(e.exclusiveMinimum)||mr(e.exclusiveMinimum))}function ol(e){return zr(e,"format")&&xr(e.format)}function ul(e){return zr(e,"$id")&&xr(e.$id)}function sl(e){return zr(e,"if")&&Uc(e.if)}function al(e){return zr(e,"items")&&(Uc(e.items)||pr(e.items)&&e.items.every(e=>Uc(e)))}function dl(e){return al(e)&&pr(e.items)}function cl(e){return zr(e,"maximum")&&(br(e.maximum)||mr(e.maximum))}function ll(e){return zr(e,"maxContains")&&br(e.maxContains)}function fl(e){return zr(e,"maxItems")&&br(e.maxItems)}function pl(e){return zr(e,"maxLength")&&br(e.maxLength)}function ml(e){return zr(e,"maxProperties")&&br(e.maxProperties)}function hl(e){return zr(e,"minimum")&&(br(e.minimum)||mr(e.minimum))}function _l(e){return zr(e,"minContains")&&br(e.minContains)}function gl(e){return zr(e,"minItems")&&br(e.minItems)}function yl(e){return zr(e,"minLength")&&br(e.minLength)}function vl(e){return zr(e,"minProperties")&&br(e.minProperties)}function bl(e){return zr(e,"multipleOf")&&(br(e.multipleOf)||mr(e.multipleOf))}function wl(e){return zr(e,"not")&&Uc(e.not)}function kl(e){return zr(e,"oneOf")&&pr(e.oneOf)&&e.oneOf.every(e=>Uc(e))}function xl(e){return zr(e,"pattern")&&(xr(e.pattern)||e.pattern instanceof RegExp)}function $l(e){return zr(e,"patternProperties")&&kr(e.patternProperties)&&Object.values(e.patternProperties).every(e=>Uc(e))}function Al(e){return zr(e,"prefixItems")&&pr(e.prefixItems)&&e.prefixItems.every(e=>Uc(e))}function Sl(e){return zr(e,"properties")&&kr(e.properties)&&Object.values(e.properties).every(e=>Uc(e))}function Ol(e){return zr(e,"propertyNames")&&(kr(e.propertyNames)||Uc(e.propertyNames))}function Il(e){return function(e){return zr(e,"$recursiveAnchor")&&hr(e.$recursiveAnchor)}(e)&&Sr(e.$recursiveAnchor,!0)}function El(e){return zr(e,"$recursiveRef")&&xr(e.$recursiveRef)}function Rl(e){return zr(e,"$ref")&&xr(e.$ref)}function Pl(e){return zr(e,"required")&&pr(e.required)&&e.required.every(e=>xr(e))}function ql(e){return zr(e,"then")&&Uc(e.then)}function Ml(e){return zr(e,"type")&&(xr(e.type)||pr(e.type)&&e.type.every(e=>xr(e)))}function Tl(e){return zr(e,"uniqueItems")&&hr(e.uniqueItems)}function Cl(e){return zr(e,"unevaluatedItems")&&Uc(e.unevaluatedItems)}function Nl(e){return zr(e,"unevaluatedProperties")&&Uc(e.unevaluatedProperties)}class jl{constructor(){let e=new Set,t=new Set;this.stack=[{indices:e,keys:t}]}Push(){let e=new Set,t=new Set;return this.stack.push({indices:e,keys:t}),!0}Pop(){return this.stack.pop(),!0}AddIndex(e){return this.GetIndices().add(e),!0}AddKey(e){return this.GetKeys().add(e),!0}GetIndices(){return this.stack[this.stack.length-1].indices}GetKeys(){return this.stack[this.stack.length-1].keys}Merge(e){for(let t of e)t.GetIndices().forEach(e=>this.GetIndices().add(e)),t.GetKeys().forEach(e=>this.GetKeys().add(e));return!0}}class Ll extends jl{constructor(){super(),this.errors=[]}AtCapacity(){return this.errors.length>=Vr().maxErrors}AddError(e,t,n,r){return this.AddErrorObject({keyword:e,schemaPath:t,instancePath:n,params:r})}AddErrors(e){return e.forEach(e=>this.AddErrorObject(e)),!1}GetErrors(){return this.errors}AddErrorObject(e){return this.AtCapacity()||this.errors.push(e),!1}}var Bl="urn:typebox:root";function zl(e,t){return URL.canParse(e,t)?new URL(e,t):Sr(t,Bl)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Dl(e,t){let n=zc(t)&&ul(t)?zl(t.$id,Bl).href:Bl;return{context:e,schema:t,lexicalSchema:t,lexicalBase:n,resourceBase:n,referenceBase:n,ids:[],useResourceBaseForReference:!0,recursiveAnchor:void 0,dynamicAnchors:[],resourceEntries:new Map,pendingResource:!0,enteredResource:!1}}function Ul(e,t,n=!0){if(Dc(t))return e;if(Array.isArray(t))return t.reduce((e,t)=>Ul(e,t,!1),e);if(!zc(t))return e;if(!n&&ul(t))return e;let r=!n&&Yc(t)?[...e,t]:e;return Object.keys(t).reduce((e,n)=>Ul(e,t[n],!1),r)}function Fl(e,t){return e.resourceEntries.get(t)}function Wl(e,t){return e.enteredResource||void 0!==Fl(e,t)}function Gl(e,t){return ul(t)?[...e.ids,t]:e.ids}function Kl(e,t){return e.recursiveAnchor??(Il(t)?t:void 0)}function Jl(e,t){let n=ul(t)?Ul(e.dynamicAnchors,t):e.dynamicAnchors;return Yc(t)?[...n,t]:n}function Hl(e,t){return!ul(t)&&e.pendingResource}function Vl(e,t){let n=Fl(e,t);return n?n.base:ul(t)?zl(t.$id,e.lexicalBase).href:e.lexicalBase}function Zl(e,t){let n=Fl(e,t);return n?n.base:ul(t)&&e.pendingResource?zl(t.$id,e.resourceBase).href:e.resourceBase}function Xl(e,t){return ul(t)?!function(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}(t):e.useResourceBaseForReference}function Ql(e,t){let n=Wl(e,t),r=Xl(e,t);return n||r?Zl(e,t):Vl(e,t)}function Yl(e,t){let n=Fl(e,t);return n?n.root:ul(t)?t:e.lexicalSchema}function ef(e,t){return function(e,t){return zc(t)&&(ul(t)||Yc(t)||Ar(e.recursiveAnchor)&&Il(t)||!Ar(Fl(e,t)))}(e,t)?{...e,ids:Gl(e,t),dynamicAnchors:Jl(e,t),recursiveAnchor:Kl(e,t),pendingResource:Hl(e,t),lexicalBase:Vl(e,t),resourceBase:Zl(e,t),useResourceBaseForReference:Xl(e,t),referenceBase:Ql(e,t),lexicalSchema:Yl(e,t),enteredResource:Wl(e,t)}:e}function tf(e){return al(e)&&pr(e.items)}function nf(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function rf(e){return new RegExp(e,"u")}function of(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function uf(e){let t=[];return $l(e)&&t.push(...Fr(e.patternProperties)),Sl(e)&&t.push(...Fr(e.properties).map(of)),Sr(t.length,0)?"(?!)":`(${t.join("|")})`}function sf(e,t,n,r){return n}function af(e,t,n,r){return Pr(n.const)?Sr(r,n.const):Gr(r,n.const)}function df(e,t,n,r){return!function(e){return!(_l(e)&&Sr(e.minContains,0))}(n)||!Sr(r.length,0)&&function(e,t){let n=!1;return e.forEach((e,r)=>{t(e,r)&&(n=!0)}),n}(r,(r,i)=>wm(e,t,n.contains,r)&&t.AddIndex(i))}function cf(e,t){return zc(e)&&ul(e)?zl(e.$id,t.href):t}function lf(e){return zl(e,Bl)}function ff(e){return e.href.split("#")[0]}function pf(e,t,n){return hf(e,lf(t),n)}function mf(e,t){if(kr(e)&&Yc(e)&&Sr(e.$dynamicAnchor,t))return e;if(kr(e))for(let n of Fr(e)){let r=mf(e[n],t);if(r)return r}}function hf(e,t,n){if(Sr(e,n))return t.href;let r=cf(e,t);if(pr(e))for(let t of e){let e=hf(t,r,n);if(!Ar(e))return e}else if(kr(e))for(let t of Fr(e)){let i=hf(e[t],r,n);if(!Ar(i))return i}}function _f(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let n=decodeURIComponent(t.hash.slice(1));return n.startsWith("/")?function(e,t){let n=e;for(let e of function(e){let t=e.split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"));return""===t[0]?t.slice(1):t}(t)){if(!kr(n)||Br(e))return;n=n[e]}return n}(e,n):void 0}function gf(e,t,n){if(!function(e){return zr(e,"$anchor")&&xr(e.$anchor)}(e))return;let r=new URL(`#${e.$anchor}`,t.href),i=new URL(n.href,t.href);return Sr(r.href,i.href)?e:void 0}function yf(e,t,n){if(zc(e))return function(e,t,n){if(!ul(e))return;if(Sr(e.$id,n.hash))return e;let r=new URL(n.href,t.href);return Sr(t.pathname,r.pathname)?n.hash.startsWith("#")?_f(e,n):e:void 0}(e,t,n)??gf(e,t,n)??function(e,t,n){if(!Yc(e))return;let r=new URL(`#${e.$dynamicAnchor}`,t.href),i=new URL(n.href,t.href);return Sr(r.href,i.href)?e:void 0}(e,t,n)??_f(e,n)}function vf(e,t,n){let r=cf(e,t);return yf(e,r,n)??function(e,t,n){if(pr(e))return e.reduce((e,r)=>{let i=vf(r,t,n);return Ar(i)?e:i},void 0)}(e,r,n)??function(e,t,n){if(kr(e))return Fr(e).reduce((r,i)=>{if(Sr(i,"const")||Sr(i,"enum"))return r;let o=vf(e[i],t,n);return Ar(o)?r:o},void 0)}(e,r,n)}function bf(e,t,n,r,i){let o=i?function(e,t,n){let r=e.context[t];if(zc(r))return{target:n,base:t,root:r}}(e,r,n):void 0;return Ar(o)?function(e,t,n){if(!t.$ref.startsWith("#"))return;if(!zc(e.schema)||zr(e.schema,"$schema"))return;let r=pf(e.lexicalSchema,e.referenceBase,n);return Ar(r)||Sr(r,e.referenceBase)?void 0:{target:n,base:r,root:e.lexicalSchema}}(e,t,n):o}function wf(e,t,n){if(ul(n))return;let r=function(e,t,n,r){let i=kf(e,t,n,r);return zc(i)&&ul(i)?i:void 0}(e.context,e.schema,e.referenceBase,t);return r&&!e.ids.includes(r)?{resource:r}:void 0}function kf(e,t,n,r){let i=lf(n),o=zl(r,i.href);return function(e,t){return zr(e,t)?e[t]:void 0}(e,r)??function(e,t,n){return vf(e,t,n)}(t,i,o)??function(e,t,n){let r=ff(n);if(!zr(e,r)||Sr(r,ff(t)))return;let i=e[r],o=cf(i,new URL(r));return Sr(n.hash,"")?i:vf(i,o,n)}(e,i,o)}function xf(e,t,n,r){let i=function(e,t){if(!t)return e;let n=new Map(e.resourceEntries);return n.set(t.target,{base:t.base,root:t.root}),{...e,resourceEntries:n}}({...e,pendingResource:t},n);return function(e,t){return t?ef(e,t.resource):e}(i,r)}function $f(e,t){let n=kf(e.context,function(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}(e,t),e.referenceBase,t.$ref);return zc(n)?function(e,t,n){let r=ff(zl(t.$ref,e.referenceBase)),i=!Sr(r,e.resourceBase);return{schema:n,stack:xf(e,!0,bf(e,t,n,r,i),i?wf(e,r,n):void 0)}}(e,t,n):function(e,t){return{schema:t,stack:xf(e,!Ar(t))}}(e,n)}function Af(e,t){let n=function(e){return zc(e.lexicalSchema)&&Il(e.lexicalSchema)}(e)?e.recursiveAnchor:e.lexicalSchema;return kf(e.context,n,e.lexicalBase,t.$recursiveRef)}function Sf(e,t){return zl(t.$dynamicRef,lf(e.lexicalBase).href).hash}function Of(e,t){return e.dynamicAnchors.find(e=>Sr(e.$dynamicAnchor,t))??mf(e.schema,t)}function If(e,t){let n=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,r=kf(e.context,n,e.lexicalBase,t.$dynamicRef);return Ar(r)?function(e,t){let n=Sf(e,t);return Of(e,decodeURIComponent(n.slice(1)))}(e,t):function(e,t,n){return zc(n)&&Yc(n)?function(e){return e.startsWith("#/")}(Sf(e,t))?n:Of(e,n.$dynamicAnchor):n}(e,t,r)}function Ef(e,t,n,r){return Nr(n.enum,e=>Pr(e)?Sr(r,e):Gr(r,e))}function Rf(e,t,n,r){return Ir(r,n.exclusiveMaximum)}function Pf(e,t,n,r){return Or(r,n.exclusiveMinimum)}var qf=[0,31,28,31,30,31,30,31,31,30,31,30,31],Mf=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function Tf(e){let t=Mf.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(2===r&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(n)?29:qf[r])}var Cf=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function Nf(e,t=!0){let n=Cf.exec(e);if(!n)return!1;if(t&&!n[4]&&!n[5])return!1;let r=+n[1],i=+n[2],o=+n[3];if(r>23||i>59||o>60)return!1;if(n[5]){let e=+n[6],t=+n[7];if(e>23||t>59)return!1}return o<60||((60*r+i-("-"===n[5]?-1:1)*(60*+(n[6]||0)+ +(n[7]||0)))%1440+1440)%1440==1439}function jf(e){let t=e.split(/T/i);return 2===t.length&&Tf(t[0])&&Nf(t[1])}var Lf=/^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;function Bf(e){return Lf.test(e)}var zf=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;function Df(e){return zf.test(e)}var Uf=/^(?!-).*(?<!-)$/,Ff=/^(?!..--)/,Wf=/^[a-zA-Z0-9-]*$/,Gf=/[^\p{ASCII}]/u,Kf=/[\u{0660}-\u{0669}]/u,Jf=/\p{Mn}/u,Hf=/[\p{Mn}\p{Mc}\p{Me}]/u,Vf=/\p{L}/u,Zf=/\p{Script=Greek}/u,Xf=/\p{Script=Hebrew}/u,Qf=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,Yf=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,ep=/[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u,tp=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,np=new RegExp([/[0-9]/,/[\u{06f0}-\u{06f9}]/u].map(e=>e.source).join("|"),"u"),rp=new RegExp([Vf,/[\u{002d}\u{002b}]/u,/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,/\p{Nd}/u,Jf,/\p{Mc}/u,/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u].map(e=>e.source).join("|"),"u");var ip=36;function op(){throw null}function up(e){return e.toLowerCase().startsWith("xn--")}function sp(e,t,n){e=n?Math.floor(e/700):e>>1,e+=Math.floor(e/t);let r=0;for(;e>455;)e=Math.floor(e/35),r+=ip;return r+Math.floor(36*e/(e+38))}function ap(e){let t=[],n=128,r=0,i=72,o=e.lastIndexOf("-");if(o>0)for(let n=0;n<o;n++){let r=e.charCodeAt(n);r>=128&&op(),t.push(r)}let u=o<0?0:o+1;for(;u<e.length;){let o=r,s=1,a=ip;for(;;){u>=e.length&&op();let t,n=e.charCodeAt(u++);n>=97&&n<=122?t=n-97:n>=48&&n<=57?t=n-48+26:op(),r+=t*s;let o=a<=i?1:a>=i+26?26:a-i;if(t<o)break;s*=ip-o,a+=ip}let d=t.length+1;i=sp(r-o,d,0===o),n+=Math.floor(r/d),r%=d,t.splice(r,0,n),r++}return String.fromCodePoint(...t)}function dp(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var cp=new RegExp(Gf.source,"gu");var lp=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,fp=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,pp=/^(?:R|AL|AN)$/;function mp(e){let t=String.fromCodePoint(e);return np.test(t)?"EN":Kf.test(t)?"AN":Jf.test(t)?"NSM":Xf.test(t)?"R":Yf.test(t)?"AL":Vf.test(t)?"L":"ON"}function hp(e){for(let t of e)if(pp.test(mp(t.codePointAt(0))))return!0;return!1}function _p(e){let t=!1,n=fp,r=!1,i=!1,o=!0;for(let u of e){let e=mp(u.codePointAt(0));if(o){if("L"!==e&&"R"!==e&&"AL"!==e)return!1;t="R"===e||"AL"===e,n=t?lp:fp,o=!1}if(!n.test(e))return!1;"EN"===e?r=!0:"AN"===e&&(i=!0)}return!(t&&r&&i)}function gp(e){return Gf.test(e)&&function(e){let t=e.replace(cp,""),n=t.length,r=n>0?[t,"-"]:[],i=Array.from(e,e=>e.codePointAt(0)),o=128,u=0,s=72,a=n;for(;a<i.length;){let e=1/0;for(let t of i)t>=o&&t<e&&(e=t);u+=(e-o)*(a+1),o=e;for(let e of i)if(e<o&&u++,e===o){let e=u;for(let t=ip;;t+=ip){let n=t<=s?1:t>=s+26?26:t-s;if(e<n)break;let i=n+(e-n)%(ip-n);r.push(dp(i)),e=Math.floor((e-n)/(ip-n))}r.push(dp(e)),s=sp(u,a+1,a===n),u=0,a++}u++,o++}return r.join("")}(e).length+4>63}function yp(e){if(gp(e))return!1;if(hp(e)&&!_p(e))return!1;let t=[...e],n=t.map(e=>e.codePointAt(0)),r=n.length;if(function(e){return"-"===e[0]||"-"===e[e.length-1]||e.slice(2).join("").startsWith("--")}(t))return!1;if(Hf.test(t[0]))return!1;let i=!1;for(let e=0;e<r;e++){let r=n[e],o=t[e];if(tp.test(o))return!1;if(!rp.test(o))return!1;Qf.test(o)&&(i=!0);let u=n[e-1],s=n[e+1];switch(r){case 183:if(108!==u||108!==s)return!1;break;case 885:if(!s||!Zf.test(t[e+1]))return!1;break;case 1523:case 1524:if(!u||!Xf.test(t[e-1]))return!1;break;case 8204:if(!u||u<128&&!ep.test(t[e-1]))return!1;break;case 8205:if(!u||!ep.test(t[e-1]))return!1}}return!(e.includes("・")&&!i)}function vp(e){if(!up(e))return!1;try{let t=e.slice(4).toLowerCase();if(0===t.lastIndexOf("-"))return!1;let n=ap(t);return!!Gf.test(n)&&yp(n)}catch{return!1}}function bp(e){return function(e){return e.length>0&&e.length<=63}(e)&&(vp(e)||function(e){return Uf.test(e)&&Ff.test(e)&&Wf.test(e)}(e))}function wp(e){if(0===e.length||e.includes(" "))return!1;let t=function(e){return e.replace(/[\uff01-\uff5e]/g,e=>String.fromCharCode(e.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}(e);if(t.length>253)return!1;let n=t.split("."),r=n.some(e=>function(e){if(up(e))try{return hp(ap(e.slice(4).toLowerCase()))}catch{return!1}return hp(e)}(e));return n.every(e=>function(e){return function(e){return e.length>0&&e.length<=63}(e)&&(vp(e)||yp(e))}(e)&&(!r||_p(e)))}function kp(e){return function(e){return!(0===e.length||e.length>253)&&46!==e.charCodeAt(e.length-1)&&e.split(".").every(e=>bp(e))}(e)}var xp=/^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function $p(e){return xp.test(e.normalize("NFC"))}function Ap(e){return wp(e)}var Sp=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function Op(e){return Sp.test(e)}var Ip=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;function Ep(e){return Ip.test(e)}var Rp=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,Pp=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function qp(e){return!Rp.test(e)&&!Pp.test(e)&&URL.canParse(e,"http://example.com")}var Mp=/[\x00-\x20<>\^`{|}\\]/,Tp=/%(?![0-9a-fA-F]{2})/;function Cp(e){return!Mp.test(e)&&(!Tp.test(e)&&URL.canParse(e))}var Np=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function jp(e){return Np.test(e)}var Lp=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function Bp(e){return Lp.test(e)}function zp(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var Dp=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function Up(e){return Dp.test(e)}var Fp=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Wp(e){return Fp.test(e)}var Gp=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function Kp(e){return Gp.test(e)}var Jp=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Hp(e){return Jp.test(e)}function Vp(e){return URL.canParse(e)}var Zp=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function Xp(e){return Zp.test(e)}var Qp=new Map;function Yp(e,t,n,r){return function(e,t){return Qp.get(e)?.(t)??!0}(n.format,r)}function em(e,t,n,r){return dl(n)?function(e,t,n,r){return Tr(n.items,0,(n,i)=>Er(r.length,i)||bm(e,t,n,r[i])&&t.AddIndex(i))}(e,t,n,r):function(e,t,n,r){return Tr(r,Al(n)?n.prefixItems.length:0,(r,i)=>bm(e,t,n.items,r)&&t.AddIndex(i))}(e,t,n,r)}function tm(e,t,n,r,i,o){return dl(i)?function(e,t,n,r,i,o){return Cr(i.items,0,(i,u)=>{let s=`${n}/items/${u}`,a=`${r}/${u}`;return Er(o.length,u)||km(e,t,s,a,i,o[u])&&t.AddIndex(u)})}(e,t,n,r,i,o):function(e,t,n,r,i,o){return Cr(o,Al(i)?i.prefixItems.length:0,(o,u)=>km(e,t,`${n}/items`,`${r}/${u}`,i.items,o)&&t.AddIndex(u))}(e,t,n,r,i,o)}function nm(e,t,n,r){if(!function(e){return Hc(e)}(n))return!0;return Er(jr(r,r=>wm(e,t,n.contains,r)),n.maxContains)}function rm(e,t,n,r){return Er(r,n.maximum)}function im(e,t,n,r){return Er(r.length,n.maxItems)}function om(e,t,n,r){return qr(r,n.maxLength)}function um(e,t,n,r){return Er(Fr(r).length,n.maxProperties)}function sm(e,t,n,r){if(!function(e){return Hc(e)}(n))return!0;return Rr(jr(r,(r,i)=>wm(e,t,n.contains,r)&&t.AddIndex(i)),n.minContains)}function am(e,t,n,r){return Rr(r,n.minimum)}function dm(e,t,n,r){return Rr(r.length,n.minItems)}function cm(e,t,n,r){return Mr(r,n.minLength)}function lm(e,t,n,r){return Rr(Fr(r).length,n.minProperties)}function fm(e,t,n,r){return function(e,t){if(mr(e)||mr(t))return BigInt(e)%BigInt(t)===0n;if(!br(e))return!0;if(yr(e)&&1/t%1==0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t),Math.abs(n+t))<1e-10}(r,n.multipleOf)}function pm(e,t,n,r){let i=new jl;return!wm(e,i,n.not,r)&&t.Merge([i])}function mm(e,t,n,r){return(xr(n.pattern)?rf(n.pattern):n.pattern).test(r)}function hm(e,t){return e.includes(t)||Vr().exactOptionalPropertyTypes}function _m(e,t){return Ar(e[t])}function gm(e,t,n,r,i){return Sr(n,"object")?wr(i):Sr(n,"array")?pr(i):Sr(n,"boolean")?hr(i):Sr(n,"integer")?yr(i):Sr(n,"number")?br(i):Sr(n,"null")?vr(i):Sr(n,"string")?xr(i):Sr(n,"bigint")?mr(i):Sr(n,"constructor")?_r(i):Sr(n,"function")?gr(i):Sr(n,"symbol")?$r(i):Sr(n,"undefined")?Ar(i):!Sr(n,"void")||Ar(i)}function ym(e,t,n,r,i){return Nr(n,e=>gm(0,0,e,0,i))}function vm(e){return!Sr(e.uniqueItems,!1)}function bm(e,t,n,r){return t.Push()&&wm(e,t,n,r)&&t.Pop()}function wm(e,t,n,r){let i=ef(e,n);return Dc(n)?sf(0,0,n):(!Ml(n)||function(e,t,n,r){return pr(n.type)?ym(0,0,n.type,0,r):gm(0,0,n.type,0,r)}(0,0,n,r))&&(!(kr(r)&&!pr(r))||(!Pl(n)||function(e,t,n,r){return Tr(n.required,0,e=>zr(r,e))}(0,0,n,r))&&(!Wc(n)||function(e,t,n,r){let i=rf(uf(n));return Tr(Fr(r),0,(o,u)=>i.test(o)||bm(e,t,n.additionalProperties,r[o])&&t.AddKey(o))}(i,t,n,r))&&(!Zc(n)||function(e,t,n,r){let i=Sr(Fr(r).length,0),o=Tr(Ur(n.dependencies),0,([n,i])=>!zr(r,n)||(pr(i)?i.every(e=>zr(r,e)):wm(e,t,i,r)));return i||o}(i,t,n,r))&&(!Xc(n)||function(e,t,n,r){let i=Sr(Fr(r).length,0),o=Tr(Ur(n.dependentRequired),0,([e,t])=>!zr(r,e)||t.every(e=>zr(r,e)));return i||o}(0,0,n,r))&&(!Qc(n)||function(e,t,n,r){let i=Sr(Fr(r).length,0),o=Tr(Ur(n.dependentSchemas),0,([n,i])=>!zr(r,n)||wm(e,t,i,r));return i||o}(i,t,n,r))&&(!$l(n)||function(e,t,n,r){return Tr(Ur(n.patternProperties),0,([n,i])=>{let o=rf(n);return Tr(Ur(r),0,([n,r])=>!o.test(n)||bm(e,t,i,r)&&t.AddKey(n))})}(i,t,n,r))&&(!Sl(n)||function(e,t,n,r){let i=Pl(n)?n.required:[];return Tr(Ur(n.properties),0,([n,o])=>{let u=!zr(r,n)||bm(e,t,o,r[n])&&t.AddKey(n);return hm(i,n)?u:_m(r,n)||u})}(i,t,n,r))&&(!Ol(n)||function(e,t,n,r){return Tr(Fr(r),0,(r,i)=>wm(e,t,n.propertyNames,r))}(i,t,n,r))&&(!vl(n)||lm(0,0,n,r))&&(!ml(n)||um(0,0,n,r)))&&(!pr(r)||(!Fc(n)||function(e,t,n,r){return!tf(n)||Tr(r,0,(r,i)=>Ir(i,n.items.length)||bm(e,t,n.additionalItems,r)&&t.AddIndex(i))}(i,t,n,r))&&(!Hc(n)||df(i,t,n,r))&&(!al(n)||em(i,t,n,r))&&(!_l(n)||sm(i,t,n,r))&&(!ll(n)||nm(i,t,n,r))&&(!gl(n)||dm(0,0,n,r))&&(!fl(n)||im(0,0,n,r))&&(!Al(n)||function(e,t,n,r){return Sr(r.length,0)||Tr(n.prefixItems,0,(n,i)=>Er(r.length,i)||bm(e,t,n,r[i])&&t.AddIndex(i))}(i,t,n,r))&&(!Tl(n)||function(e,t,n,r){return!vm(n)||Sr(new Set(r.map(uo)).size,r.length)}(0,0,n,r)))&&(!xr(r)||(!yl(n)||cm(0,0,n,r))&&(!pl(n)||om(0,0,n,r))&&(!ol(n)||Yp(0,0,n,r))&&(!xl(n)||mm(0,0,n,r)))&&(!(br(r)||mr(r))||(!il(n)||Pf(0,0,n,r))&&(!rl(n)||Rf(0,0,n,r))&&(!hl(n)||am(0,0,n,r))&&(!cl(n)||rm(0,0,n,r))&&(!bl(n)||fm(0,0,n,r)))&&(!Rl(n)||function(e,t,n,r){let i=$f(e,n),o=i.schema??!1,u=new jl,s=Uc(o)&&wm(i.stack,u,o,r);return s&&t.Merge([u]),s}(i,t,n,r))&&(!El(n)||function(e,t,n,r){let i=Af(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Uc(i)&&wm(o,t,i,r)}(i,t,n,r))&&(!el(n)||function(e,t,n,r){let i=If(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Uc(i)&&wm(o,t,i,r)}(i,t,n,r))&&(!Jc(n)||af(0,0,n,r))&&(!nl(n)||Ef(0,0,n,r))&&(!sl(n)||function(e,t,n,r){let i=!ql(n)||n.then,o=!tl(n)||n.else;return wm(e,t,n.if,r)?wm(e,t,i,r):wm(e,t,o,r)}(i,t,n,r))&&(!wl(n)||pm(i,t,n,r))&&(!Gc(n)||function(e,t,n,r){let i=n.allOf.reduce((t,n)=>{let i=new jl;return wm(e,i,n,r)?[...t,i]:t},[]);return Sr(i.length,n.allOf.length)&&t.Merge(i)}(i,t,n,r))&&(!Kc(n)||function(e,t,n,r){let i=n.anyOf.reduce((t,n)=>{let i=new jl;return wm(e,i,n,r)?[...t,i]:t},[]);return Or(i.length,0)&&t.Merge(i)}(i,t,n,r))&&(!kl(n)||function(e,t,n,r){let i=n.oneOf.reduce((t,n)=>{let i=new jl;return wm(e,i,n,r)?[...t,i]:t},[]);return Sr(i.length,1)&&t.Merge(i)}(i,t,n,r))&&(!Cl(n)||!pr(r)||function(e,t,n,r){let i=t.GetIndices();return Tr(r,0,(r,o)=>(i.has(o)||wm(e,t,n.unevaluatedItems,r))&&t.AddIndex(o))}(i,t,n,r))&&(!Nl(n)||!kr(r)||function(e,t,n,r){let i=t.GetKeys();return Tr(Ur(r),0,([r,o])=>i.has(r)||wm(e,t,n.unevaluatedProperties,o)&&t.AddKey(r))}(i,t,n,r))&&(!Bc(n)||function(e,t,n,r){return Tr(n["~refine"],0,(e,t)=>e.check(r))}(0,0,n,r))}function km(e,t,n,r,i,o){return t.Push()&&xm(e,t,n,r,i,o)&&t.Pop()}function xm(e,t,n,r,i,o){if(t.AtCapacity())return!1;let u=ef(e,i);return Dc(i)?function(e,t,n,r,i){return sf(0,0,i)||t.AddError("boolean",n,r,{})}(0,t,n,r,i):!!(+(!Ml(i)||function(e,t,n,r,i,o){return(pr(i.type)?ym(0,0,i.type,0,o):gm(0,0,i.type,0,o))||t.AddError("type",n,r,{type:i.type})}(0,t,n,r,i,o))&+!(kr(o)&&!pr(o)&&!(+(!Pl(i)||function(e,t,n,r,i,o){let u=[];return Cr(i.required,0,e=>{let t=zr(o,e);return t||u.push(e),t})||t.AddError("required",n,r,{requiredProperties:u})}(0,t,n,r,i,o))&+(!Wc(i)||function(e,t,n,r,i,o){let u=rf(uf(i)),s=[];return Cr(Fr(o),0,(a,d)=>{let c=`${n}/additionalProperties`,l=`${r}/${nf(a)}`,f=u.test(a)||km(e,t,c,l,i.additionalProperties,o[a])&&t.AddKey(a);return f||s.push(a),f})||t.AddError("additionalProperties",n,r,{additionalProperties:s})}(u,t,n,r,i,o))&+(!Zc(i)||function(e,t,n,r,i,o){let u=Sr(Fr(o).length,0),s=Cr(Ur(i.dependencies),0,([i,u])=>{let s=`${n}/dependencies/${nf(i)}`;return!zr(o,i)||(pr(u)?u.every(e=>zr(o,e)||t.AddError("dependencies",n,r,{property:i,dependencies:u})):xm(e,t,s,r,u,o))});return u||s}(u,t,n,r,i,o))&+(!Xc(i)||function(e,t,n,r,i,o){let u=Sr(Fr(o).length,0),s=Cr(Ur(i.dependentRequired),0,([e,i])=>!zr(o,e)||Cr(i,0,u=>zr(o,u)||t.AddError("dependentRequired",n,r,{property:e,dependencies:i})));return u||s}(0,t,n,r,i,o))&+(!Qc(i)||function(e,t,n,r,i,o){let u=Sr(Fr(o).length,0),s=Cr(Ur(i.dependentSchemas),0,([i,u])=>{let s=`${n}/dependentSchemas/${nf(i)}`;return!zr(o,i)||xm(e,t,s,r,u,o)});return u||s}(u,t,n,r,i,o))&+(!$l(i)||function(e,t,n,r,i,o){return Cr(Ur(i.patternProperties),0,([i,u])=>{let s=`${n}/patternProperties/${nf(i)}`,a=rf(i);return Cr(Ur(o),0,([n,i])=>{let o=`${r}/${nf(n)}`;return!a.test(n)||km(e,t,s,o,u,i)&&t.AddKey(n)})})}(u,t,n,r,i,o))&+(!Sl(i)||function(e,t,n,r,i,o){let u=Pl(i)?i.required:[];return Cr(Ur(i.properties),0,([i,s])=>{let a=`${n}/properties/${nf(i)}`,d=`${r}/${nf(i)}`,c=()=>!zr(o,i)||km(e,t,a,d,s,o[i])&&t.AddKey(i);return hm(u,i)?c():_m(o,i)||c()})}(u,t,n,r,i,o))&+(!Ol(i)||function(e,t,n,r,i,o){let u=[];return Cr(Fr(o),0,(o,s)=>{let a=`${r}/${nf(o)}`,d=xm(e,t,`${n}/propertyNames`,a,i.propertyNames,o);return d||u.push(o),d})||t.AddError("propertyNames",n,r,{propertyNames:u})}(u,t,n,r,i,o))&+(!vl(i)||function(e,t,n,r,i,o){return lm(0,0,i,o)||t.AddError("minProperties",n,r,{limit:i.minProperties})}(0,t,n,r,i,o))&+(!ml(i)||function(e,t,n,r,i,o){return um(0,0,i,o)||t.AddError("maxProperties",n,r,{limit:i.maxProperties})}(0,t,n,r,i,o))))&+(!pr(o)||!!(+(!Fc(i)||function(e,t,n,r,i,o){return!tf(i)||Tr(o,0,(o,u)=>{let s=`${n}/additionalItems`,a=`${r}/${u}`;return Ir(u,i.items.length)||km(e,t,s,a,i.additionalItems,o)&&t.AddIndex(u)})}(u,t,n,r,i,o))&+(!Hc(i)||function(e,t,n,r,i,o){return df(e,t,i,o)||t.AddError("contains",n,r,{minContains:1})}(u,t,n,r,i,o))&+(!al(i)||tm(u,t,n,r,i,o))&+(!_l(i)||function(e,t,n,r,i,o){return sm(e,t,i,o)||t.AddError("contains",n,r,{minContains:i.minContains})}(u,t,n,r,i,o))&+(!ll(i)||function(e,t,n,r,i,o){let u=_l(i)?i.minContains:1;return nm(e,t,i,o)||t.AddError("contains",n,r,{minContains:u,maxContains:i.maxContains})}(u,t,n,r,i,o))&+(!gl(i)||function(e,t,n,r,i,o){return dm(0,0,i,o)||t.AddError("minItems",n,r,{limit:i.minItems})}(0,t,n,r,i,o))&+(!fl(i)||function(e,t,n,r,i,o){return im(0,0,i,o)||t.AddError("maxItems",n,r,{limit:i.maxItems})}(0,t,n,r,i,o))&+(!Al(i)||function(e,t,n,r,i,o){return Sr(o.length,0)||Cr(i.prefixItems,0,(i,u)=>{let s=`${n}/prefixItems/${u}`,a=`${r}/${u}`;return Er(o.length,u)||km(e,t,s,a,i,o[u])&&t.AddIndex(u)})}(u,t,n,r,i,o))&+(!Tl(i)||function(e,t,n,r,i,o){if(!vm(i))return!0;let u=new Set,s=o.reduce((e,t,n)=>{let r=uo(t);return u.has(r)?[...e,n]:(u.add(r),e)},[]);return Sr(s.length,0)||t.AddError("uniqueItems",n,r,{duplicateItems:s})}(0,t,n,r,i,o))))&+(!xr(o)||!!(+(!yl(i)||function(e,t,n,r,i,o){return cm(0,0,i,o)||t.AddError("minLength",n,r,{limit:i.minLength})}(0,t,n,r,i,o))&+(!pl(i)||function(e,t,n,r,i,o){return om(0,0,i,o)||t.AddError("maxLength",n,r,{limit:i.maxLength})}(0,t,n,r,i,o))&+(!ol(i)||function(e,t,n,r,i,o){return Yp(0,0,i,o)||t.AddError("format",n,r,{format:i.format})}(0,t,n,r,i,o))&+(!xl(i)||function(e,t,n,r,i,o){return mm(0,0,i,o)||t.AddError("pattern",n,r,{pattern:i.pattern})}(0,t,n,r,i,o))))&+(!(br(o)||mr(o))||!!(+(!il(i)||function(e,t,n,r,i,o){return Pf(0,0,i,o)||t.AddError("exclusiveMinimum",n,r,{comparison:">",limit:i.exclusiveMinimum})}(0,t,n,r,i,o))&+(!rl(i)||function(e,t,n,r,i,o){return Rf(0,0,i,o)||t.AddError("exclusiveMaximum",n,r,{comparison:"<",limit:i.exclusiveMaximum})}(0,t,n,r,i,o))&+(!hl(i)||function(e,t,n,r,i,o){return am(0,0,i,o)||t.AddError("minimum",n,r,{comparison:">=",limit:i.minimum})}(0,t,n,r,i,o))&+(!cl(i)||function(e,t,n,r,i,o){return rm(0,0,i,o)||t.AddError("maximum",n,r,{comparison:"<=",limit:i.maximum})}(0,t,n,r,i,o))&+(!bl(i)||function(e,t,n,r,i,o){return fm(0,0,i,o)||t.AddError("multipleOf",n,r,{multipleOf:i.multipleOf})}(0,t,n,r,i,o))))&+(!Rl(i)||function(e,t,n,r,i,o){let u=$f(e,i),s=u.schema??!1,a=new Ll,d=Uc(s)&&xm(u.stack,a,n,r,s,o);return d&&t.Merge([a]),d||t.AddErrors(a.GetErrors()),d}(u,t,n,r,i,o))&+(!El(i)||function(e,t,n,r,i,o){let u=Af(e,i)??!1,s=u?{...e,pendingResource:!0}:e;return Uc(u)&&xm(s,t,n,r,u,o)}(u,t,n,r,i,o))&+(!el(i)||function(e,t,n,r,i,o){let u=If(e,i)??!1,s=u?{...e,pendingResource:!0}:e;return Uc(u)&&xm(s,t,n,r,u,o)}(u,t,n,r,i,o))&+(!Jc(i)||function(e,t,n,r,i,o){return af(0,0,i,o)||t.AddError("const",n,r,{allowedValue:i.const})}(0,t,n,r,i,o))&+(!nl(i)||function(e,t,n,r,i,o){return Ef(0,0,i,o)||t.AddError("enum",n,r,{allowedValues:i.enum})}(0,t,n,r,i,o))&+(!sl(i)||function(e,t,n,r,i,o){let u=!ql(i)||i.then,s=!tl(i)||i.else,a=new Ll,d=xm(e,a,`${n}/if`,r,i.if,o)?xm(e,a,`${n}/then`,r,u,o)||t.AddError("if",n,r,{failingKeyword:"then"}):xm(e,t,`${n}/else`,r,s,o)||t.AddError("if",n,r,{failingKeyword:"else"});return d&&t.Merge([a]),d}(u,t,n,r,i,o))&+(!wl(i)||function(e,t,n,r,i,o){return pm(e,t,i,o)||t.AddError("not",n,r,{})}(u,t,n,r,i,o))&+(!Gc(i)||function(e,t,n,r,i,o){let u=[],s=i.allOf.reduce((t,i,s)=>{let a=`${n}/allOf/${s}`,d=new Ll,c=xm(e,d,a,r,i,o);return c||u.push(d),c?[...t,d]:t},[]),a=Sr(s.length,i.allOf.length)&&t.Merge(s);return a||u.forEach(e=>t.AddErrors(e.GetErrors())),a}(u,t,n,r,i,o))&+(!Kc(i)||function(e,t,n,r,i,o){let u=[],s=i.anyOf.reduce((t,i,s)=>{let a=new Ll,d=xm(e,a,`${n}/anyOf/${s}`,r,i,o);return d||u.push(a),d?[...t,a]:t},[]),a=Or(s.length,0)&&t.Merge(s);return a||u.forEach(e=>t.AddErrors(e.GetErrors())),a||t.AddError("anyOf",n,r,{})}(u,t,n,r,i,o))&+(!kl(i)||function(e,t,n,r,i,o){let u=[],s=[],a=i.oneOf.reduce((t,i,a)=>{let d=new Ll,c=xm(e,d,`${n}/oneOf/${a}`,r,i,o);return c&&s.push(a),c||u.push(d),c?[...t,d]:t},[]),d=Sr(a.length,1)&&t.Merge(a);return!d&&Sr(s.length,0)&&u.forEach(e=>t.AddErrors(e.GetErrors())),d||t.AddError("oneOf",n,r,{passingSchemas:s})}(u,t,n,r,i,o))&+(!Cl(i)||!pr(o)||function(e,t,n,r,i,o){let u=t.GetIndices(),s=[];return Cr(o,0,(o,a)=>{let d=new Ll,c=(u.has(a)||xm(e,d,n,r,i.unevaluatedItems,o))&&t.AddIndex(a);return c||s.push(a),c})||t.AddError("unevaluatedItems",n,r,{unevaluatedItems:s})}(u,t,n,r,i,o))&+(!Nl(i)||!kr(o)||function(e,t,n,r,i,o){let u=t.GetKeys(),s=[];return Cr(Ur(o),0,([o,a])=>{let d=new Ll,c=u.has(o)||xm(e,d,n,r,i.unevaluatedProperties,a)&&t.AddKey(o);return c||s.push(o),c})||t.AddError("unevaluatedProperties",n,r,{unevaluatedProperties:s})}(u,t,n,r,i,o)))&&(!Bc(i)||function(e,t,n,r,i,o){return Cr(i["~refine"],0,(e,i)=>e.check(o)||t.AddError("~refine",n,r,{index:i,message:e.error(o)}))}(0,t,n,r,i,o))}Qp.clear(),Qp.set("date-time",jf),Qp.set("date",Tf),Qp.set("duration",Bf),Qp.set("email",Df),Qp.set("hostname",kp),Qp.set("idn-email",$p),Qp.set("idn-hostname",Ap),Qp.set("ipv4",Op),Qp.set("ipv6",Ep),Qp.set("iri-reference",qp),Qp.set("iri",Cp),Qp.set("json-pointer-uri-fragment",jp),Qp.set("json-pointer",Bp),Qp.set("regex",zp),Qp.set("relative-json-pointer",Up),Qp.set("time",Nf),Qp.set("uri-reference",Wp),Qp.set("uri-template",Kp),Qp.set("uri",Hp),Qp.set("url",Vp),Qp.set("uuid",Xp);var $m=0;function Am(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return function(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return wm(Dl(t,n),new jl,n,r)}(t,n,r)}function Sm(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]}),[i,o]=function(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]}),i=Dl(t,n),o=new Ll,u=xm(i,o,"#","",n,r),s=o.GetErrors(),a=ao();return[u,s.map(e=>({...e,message:a(e)}))]}(t,n,r);return o}class Om extends Error{constructor(e,t,n){super(e),Object.defineProperty(this,"cause",{value:{source:e,errors:n,value:t},writable:!1,configurable:!1,enumerable:!1})}}function Im(e,t){let n=zr(t,"unevaluatedProperties")?{additionalProperties:t.unevaluatedProperties}:{},r=bc(gc(e,t));return Ti(r)?function(e,t){return sc(e,t)}(r,n):r}function Em(e){return zr(e,"additionalProperties")?e.additionalProperties:void 0}function Rm(e){return ti(e)}function Pm(e,t,n){return pi(t)?function(e,t,n){return pr(n)?n.map(n=>Pm(e,t.items,n)):n}(e,t,n):Li(t)?function(e,t,n){return Pm({...e,...t.$defs},vi(t.$ref),n)}(e,t,n):Wi(t)?function(e,t,n){return Pm(e,Im(e,t),n)}(e,t,n):Ti(t)?function(e,t,n){if(!kr(n)||pr(n))return n;let r=Em(t);for(let i of Fr(n))zr(t.properties,i)?n[i]=Pm(e,t.properties[i],n[i]):hr(r)&&Sr(r,!0)||si(r)&&Am(e,r,n[i])?n[i]=Pm(e,r,n[i]):delete n[i];return n}(e,t,n):Cu(t)?function(e,t,n){if(!kr(n))return n;let r=Em(t),[i,o]=[new RegExp(qu(t)),Tu(t)];for(let t of Fr(n))i.test(t)?n[t]=Pm(e,o,n[t]):hr(r)&&Sr(r,!0)||si(r)&&Am(e,r,n[t])?n[t]=Pm(e,r,n[t]):delete n[t];return n}(e,t,n):bi(t)?function(e,t,n){return zr(e,t.$ref)?Pm(e,e[t.$ref],n):n}(e,t,n):Xo(t)?function(e,t,n){if(!pr(n))return n;let r=Math.min(n.length,t.items.length);for(let i=0;i<r;i++)n[i]=Pm(e,t.items[i],n[i]);return Or(n.length,r)?n.slice(0,r):n}(e,t,n):No(t)?function(e,t,n){for(let r of t.anyOf){let t=Pm(e,r,Rm(n));if(Am(e,r,t))return t}return n}(e,t,n):n}function qm(e){return e.map(e=>Mm(e))}function Mm(e){return function(e,t){for(let n of Fr(e))zr(t,n)||(t[n]=e[n]);return t}(e,pi(e)?fi(Mm(e.items),mi(e)):Wi(e)?Fi(qm(e.allOf)):No(e)?Co(qm(xc(e.anyOf))):Ti(e)?Mi(function(e){let t={};for(let n of Fr(e))t[n]=Mm(e[n]);return t}(e.properties)):Cu(e)?Ru(Mu(e),Mm(Tu(e))):Xo(e)?Zo(qm(e.items)):e)}function Tm(e){return Mm(e)}function Cm(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return Pm(t,Vr().unionPrioritySort?Tm(n):n,r)}function Nm(e){return kr(e)&&zr(e,"value")}function jm(e){return{value:e}}var Lm=/^-?(0|[1-9]\d*)n$/,Bm=/^-?(0|[1-9]\d*)\.\d+$/,zm=/^-?(0|[1-9]\d*)$/;function Dm(e){let t=e.toLowerCase();return function(e){return Lm.test(e)}(e)?jm(BigInt(e.slice(0,e.length-1))):function(e){return Bm.test(e)}(e)?jm(BigInt(e.split(".")[0])):function(e){return zm.test(e)}(e)?jm(BigInt(e)):Sr(t,"false")?jm(BigInt(0)):Sr(t,"true")?jm(BigInt(1)):void 0}function Um(e){return mr(e)?jm(e):hr(e)?function(e){return Sr(e,!0)?jm(BigInt(1)):jm(BigInt(0))}(e):br(e)?jm(BigInt(Math.trunc(e))):vr(e)?jm(BigInt(0)):xr(e)?Dm(e):Ar(e)?jm(BigInt(0)):void 0}function Fm(e){return mr(e)?function(e){return Sr(e,BigInt(0))?jm(!1):Sr(e,BigInt(1))?jm(!0):void 0}(e):hr(e)?jm(e):br(e)?function(e){return Sr(e,0)?jm(!1):Sr(e,1)?jm(!0):void 0}(e):vr(e)?jm(!1):xr(e)?function(e){return Sr(e.toLowerCase(),"false")?jm(!1):Sr(e.toLowerCase(),"true")?jm(!0):Sr(e,"0")?jm(!1):Sr(e,"1")?jm(!0):void 0}(e):Ar(e)?jm(!1):void 0}function Wm(e){return mr(e)?function(e){return Sr(e,BigInt(0))?jm(null):void 0}(e):hr(e)?function(e){return Sr(e,!1)?jm(null):void 0}(e):br(e)?function(e){return Sr(e,0)?jm(null):void 0}(e):vr(e)?jm(null):xr(e)?function(e){let t=e.toLowerCase();return Sr(t,"undefined")||Sr(t,"null")||Sr(e,"")||Sr(e,"0")?jm(null):void 0}(e):Ar(e)?jm(null):void 0}var Gm=BigInt(Number.MAX_SAFE_INTEGER),Km=BigInt(Number.MIN_SAFE_INTEGER);function Jm(e){return mr(e)?function(e){return e<=Gm&&e>=Km?jm(Number(e)):void 0}(e):hr(e)?function(e){return jm(e?1:0)}(e):br(e)?jm(e):vr(e)?jm(0):xr(e)?function(e){let t=+e;if(br(t))return jm(t);let n=e.toLowerCase();if(Sr(n,"false"))return jm(0);if(Sr(n,"true"))return jm(1);let r=Um(e);return Nm(r)&&r.value<=Gm&&r.value>=Km?jm(Number(r.value)):void 0}(e):Ar(e)?jm(0):void 0}function Hm(e){return mr(e)||hr(e)||br(e)?jm(e.toString()):vr(e)?jm("null"):xr(e)?jm(e):Ar(e)?jm(""):void 0}function Vm(e){return mr(e)?function(e){return Sr(e,BigInt(0))?jm(void 0):void 0}(e):hr(e)?function(e){return Sr(e,!1)?jm(void 0):void 0}(e):br(e)?function(e){return Sr(e,0)?jm(void 0):void 0}(e):vr(e)?jm(void 0):xr(e)?function(e){let t=e.toLowerCase();return Sr(t,"undefined")||Sr(t,"null")||Sr(e,"")||Sr(e,"0")?jm(void 0):void 0}(e):Ar(e)?jm(e):void 0}function Zm(e,t,n){return function(e){return pr(e)?jm(e):jm([e])}(n).value.map(n=>nh(e,t.items,n))}function Xm(e,t,n){return Sr(t.const,n)?n:function(e){return Ao(e)&&mr(e.const)}(t)?function(e,t,n){let r=Um(n);return Nm(r)&&Sr(t.const,r.value)?r.value:n}(0,t,n):function(e){return Ao(e)&&hr(e.const)}(t)?function(e,t,n){let r=Fm(n);return Nm(r)&&Sr(t.const,r.value)?r.value:n}(0,t,n):xo(t)?function(e,t,n){let r=Jm(n);return Nm(r)&&Sr(t.const,r.value)?r.value:n}(0,t,n):$o(t)?function(e,t,n){let r=Hm(n);return Nm(r)&&Sr(t.const,r.value)?r.value:n}(0,t,n):Gi()}function Qm(e,t,n,r){let i=Fr(r);for(let[o,u]of t)for(let t of i)o.test(t)||(r[t]=nh(e,n,r[t]));return r}function Ym(e,t,n){return Ri(e)&&Ar(n[t])}function eh(e,t,n){return wr(n)?function(e,t,n){let r=Dr(t.properties),i=Fr(n);for(let[t,o]of r)for(let r of i)t.test(r)&&!Ym(o,r,n)&&(n[r]=nh(e,o,n[r]));return zr(t,"additionalProperties")&&kr(t.additionalProperties)?Qm(e,r,t.additionalProperties,n):n}(e,t,n):n}function th(e,t,n){return wr(n)?function(e,t,n){let r=Dr(t.patternProperties),i=Fr(n);for(let[t,o]of r)for(let r of i)t.test(r)&&(n[r]=nh(e,o,n[r]));return zr(t,"additionalProperties")&&kr(t.additionalProperties)?Qm(e,r,t.additionalProperties,n):n}(e,t,n):n}function nh(e,t,n){return pi(t)?Zm(e,t,n):mo(t)?function(e,t,n){let r=Um(n);return Nm(r)?r.value:n}(0,0,n):_o(t)?function(e,t,n){let r=Fm(n);return Nm(r)?r.value:n}(0,0,n):Li(t)?function(e,t,n){return nh({...e,...t.$defs},vi(t.$ref),n)}(e,t,n):Ui(t)?function(e,t,n){return nh(e,bc(t),n)}(e,t,n):vo(t)?function(e,t,n){let r=Jm(n);return Nm(r)?Math.trunc(r.value):n}(0,0,n):Wi(t)?function(e,t,n){return nh(e,bc(gc(e,t)),n)}(e,t,n):Ao(t)?Xm(0,t,n):Oo(t)?function(e,t,n){let r=Wm(n);return Nm(r)?r.value:n}(0,0,n):Ro(t)?function(e,t,n){let r=Jm(n);return Nm(r)?r.value:n}(0,0,n):Ti(t)?eh(e,t,n):Cu(t)?th(e,t,n):bi(t)?function(e,t,n){return zr(e,t.$ref)?nh(e,e[t.$ref],n):n}(e,t,n):To(t)?function(e,t,n){let r=Hm(n);return Nm(r)?r.value:n}(0,0,n):ys(t)?function(e,t,n){return nh(e,bc(t),n)}(e,t,n):Xo(t)?function(e,t,n){if(!pr(n))return n;for(let r=0;r<Math.min(t.items.length,n.length);r++)n[r]=nh(e,t.items[r],n[r]);return n}(e,t,n):ju(t)?function(e,t,n){let r=Vm(n);return Nm(r)?r.value:n}(0,0,n):No(t)?function(e,t,n){if(t.anyOf.some(t=>Am(e,t,n)))return n;let r=t.anyOf.map(t=>nh(e,t,Rm(n))).find(n=>Am(e,t,n));return Ar(r)?n:r}(e,t,n):Lu(t)?function(e,t,n){return Nm(Vm(n))?void 0:n}(0,0,n):n}function rh(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return nh(t,n,r)}function ih(e,t,n){let r=Vc(t)?function(e,t){return Ar(t)?gr(e.default)?e.default():Rm(e.default):t}(t,n):n;return pi(t)?function(e,t,n){if(!pr(n))return n;for(let r=0;r<n.length;r++)n[r]=ih(e,t.items,n[r]);return n}(e,t,r):Li(t)?function(e,t,n){return ih({...e,...t.$defs},vi(t.$ref),n)}(e,t,r):Wi(t)?function(e,t,n){return ih(e,bc(gc(e,t)),n)}(e,t,r):Ti(t)?function(e,t,n){if(!kr(n))return n;let r=Fr(t.properties);for(let i of r){let r=ih(e,t.properties[i],n[i]);(!Ar(r)||!Ri(t.properties[i])&&zr(t.properties[i],"default"))&&(n[i]=r)}if(!Wc(t)||hr(t.additionalProperties))return n;for(let i of Fr(n))r.includes(i)||(n[i]=ih(e,t.additionalProperties,n[i]));return n}(e,t,r):Cu(t)?function(e,t,n){if(!kr(n))return n;let[r,i]=[new RegExp(qu(t)),Tu(t)];for(let t of Fr(n))r.test(t)&&Vc(i)&&(n[t]=ih(e,i,n[t]));if(!Wc(t))return n;for(let i of Fr(n))r.test(i)||(n[i]=ih(e,t.additionalProperties,n[i]));return n}(e,t,r):bi(t)?function(e,t,n){return zr(e,t.$ref)?ih(e,e[t.$ref],n):n}(e,t,r):Xo(t)?function(e,t,n){if(!pr(n))return n;let[r,i]=[t.items,Math.max(t.items.length,n.length)];for(let t=0;t<i;t++)t<r.length&&(n[t]=ih(e,r[t],n[t]));return n}(e,t,r):No(t)?function(e,t,n){for(let r of t.anyOf){let t=ih(e,r,Rm(n));if(Am(e,r,t))return t}return n}(e,t,r):r}function oh(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return ih(t,n,r)}function uh(e){return(...t)=>{let[n,r,i]=Bi(t,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return e.reduce((e,t)=>t(n,r,e),i)}}function sh(e,t,n,r){return function(e){return si(e)&&zr(e,"~codec")&&kr(e["~codec"])&&zr(e["~codec"],"encode")&&zr(e["~codec"],"decode")}(n)?Sr(e,"Decode")?function(e,t,n){return t["~codec"].decode(n)}(0,n,r):function(e,t,n){return t["~codec"].encode(n)}(0,n,r):r}function ah(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(!pr(r))return r;for(let i=0;i<r.length;i++)r[i]=gh(e,t,n.items,r[i]);return sh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);if(!pr(i))return i;for(let r=0;r<i.length;r++)i[r]=gh(e,t,n.items,i[r]);return i}(e,t,n,r)}function dh(e){return e.reduce((e,t)=>({...e,...t}),{})}function ch(e,t){for(let n of t)if(!Gr(e,n))return n;return e}function lh(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(Sr(n.allOf.length,0))return sh(e,0,n,r);let i=n.allOf.map(n=>gh(e,t,n,Cm(n,Rm(r)))),o=i.every(e=>kr(e))?dh(i):ch(r,i);return sh(e,0,n,o)}(e,t,n,r):function(e,t,n,r){if(Sr(n.allOf.length,0))return sh(e,0,n,r);let i=sh(e,0,n,r),o=n.allOf.map(n=>gh(e,t,n,Cm(n,Rm(i))));return o.every(e=>kr(e))?dh(o):ch(i,o)}(e,t,n,r)}function fh(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(!wr(r))return r;for(let i of Fr(n.properties))zr(r,i)&&!Ym(n.properties[i],i,r)&&(r[i]=gh(e,t,n.properties[i],r[i]));return sh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);if(!wr(i))return i;for(let r of Fr(n.properties))zr(i,r)&&!Ym(n.properties[r],r,i)&&(i[r]=gh(e,t,n.properties[r],i[r]));return i}(e,t,n,r)}function ph(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(!wr(r))return r;let i=new RegExp(qu(n));for(let o of Fr(r))i.test(o)&&(r[o]=gh(e,t,Tu(n),r[o]));return sh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);if(!wr(i))return i;let o=new RegExp(qu(n));for(let r of Fr(i))o.test(r)&&(i[r]=gh(e,t,Tu(n),i[r]));return i}(e,t,n,r)}function mh(e,t,n,r){return zr(t,n.$ref)?gh(e,t,t[n.$ref],r):r}function hh(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(!pr(r))return r;for(let i=0;i<Math.min(n.items.length,r.length);i++)r[i]=gh(e,t,n.items[i],r[i]);return sh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);if(!pr(i))return r;for(let r=0;r<Math.min(n.items.length,i.length);r++)i[r]=gh(e,t,n.items[r],i[r]);return i}(e,t,n,r)}function _h(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){for(let i of n.anyOf)if(Am(t,i,r))return sh(e,0,n,gh(e,t,i,r));return r}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);for(let r of n.anyOf){let n=gh(e,t,r,Rm(i));if(Am(t,r,n))return n}return i}(e,t,n,r)}function gh(e,t,n,r){return pi(n)?ah(e,t,n,r):Li(n)?function(e,t,n,r){return sh(e,0,n,r=gh(e,{...t,...n.$defs},vi(n.$ref),r))}(e,t,n,r):Wi(n)?lh(e,t,n,r):Ti(n)?fh(e,t,n,r):Cu(n)?ph(e,t,n,r):bi(n)?function(e,t,n,r){return Sr(e,"Decode")?sh(e,0,n,mh(e,t,n,r)):mh(e,t,n,sh(e,0,n,r))}(e,t,n,r):Xo(n)?hh(e,t,n,r):No(n)?_h(e,t,n,r):sh(e,0,n,r)}class yh extends Om{constructor(e,t){super("Decode",e,t)}}uh([(e,t,n)=>Rm(n),(e,t,n)=>oh(e,t,n),(e,t,n)=>rh(e,t,n),(e,t,n)=>Cm(e,t,n),(e,t,n)=>function(e,t,n){if(!Am(e,t,n))throw new yh(n,Sm(e,t,n));return n}(e,t,n),(e,t,n)=>function(e,t,n){return gh("Decode",e,Vr().unionPrioritySort?Tm(t):t,n)}(e,t,n)]);class vh extends Om{constructor(e,t){super("Encode",e,t)}}uh([(e,t,n)=>Rm(n),(e,t,n)=>function(e,t,n){return gh("Encode",e,Vr().unionPrioritySort?Tm(t):t,n)}(e,t,n),(e,t,n)=>oh(e,t,n),(e,t,n)=>rh(e,t,n),(e,t,n)=>Cm(e,t,n),(e,t,n)=>function(e,t,n){if(!Am(e,t,n))throw new vh(n,Sm(e,t,n));return n}(e,t,n)]);class bh extends Om{constructor(e,t){super("Parse",e,t)}}function wh(e,t,n){!function(){let e=Vr();$m=e.maxErrors,e.maxErrors=e.maxParseErrors}();let r=Sm(e,t,n);if(Vr().maxErrors=$m,!Am(e,t,n))throw new bh(n,r);return n}uh([(e,t,n)=>Rm(n),(e,t,n)=>oh(e,t,n),(e,t,n)=>rh(e,t,n),(e,t,n)=>Cm(e,t,n),(e,t,n)=>wh(e,t,n)]),Co([Mi({type:ko("insert"),path:Mo(),value:Ci()}),Object({type:ko("update"),path:Mo(),value:Ci()}),Mi({type:ko("delete"),path:Mo()})]);var kh=200;function xh(e,t,n){return{kind:"error",error:h(e,t,n)}}function $h(e){return Number.isSafeInteger(e)&&e>0}function Ah(e){return Buffer.from(`t1:${e.revision}:${e.offset}`,"utf8").toString("base64url")}function Sh(e,t={}){let n=t.mode??"tail";if("status"!==n&&"tail"!==n&&"page"!==n)return xh("invalid_arguments",`Unknown read mode "${String(n)}".`,'Retry with mode set to "status", "tail", or "page", or call thread_list to confirm the thread first.');if(void 0!==t.tail_items){if(!$h(t.tail_items))return xh("invalid_arguments",`tail_items must be a positive whole number; received ${String(t.tail_items)}.`,"Retry with tail_items between 1 and 200, or omit it to take the default 60.");if(t.tail_items>kh)return xh("invalid_arguments",`tail_items ${t.tail_items} exceeds the 200-item cap.`,"Retry with tail_items at most 200, then page backward with the returned cursor if you need more.")}if(void 0!==t.max_bytes){if(!$h(t.max_bytes))return xh("invalid_arguments",`max_bytes must be a positive whole number; received ${String(t.max_bytes)}.`,"Retry with max_bytes between 1 and 1048576, or omit it to take the default 131072.");if(t.max_bytes>Ac)return xh("message_too_large",`max_bytes ${t.max_bytes} exceeds the 1048576-byte hard cap.`,"Re-read with max_bytes at most 1048576 and follow next_cursor for the rest of the transcript.")}let r,i,o,u=t.max_bytes??$c,s=t.tail_items??60,a=null;if(void 0!==t.cursor&&(a=function(e){if("string"!=typeof e||0===e.length)return null;let t;try{t=Buffer.from(e,"base64url").toString("utf8")}catch{return null}let n=t.split(":");if(3!==n.length)return null;let[r,i,o]=n;if("t1"!==r)return null;if(!/^\d+\.[0-9a-z]+$/.test(i))return null;let u=Number(o);return!Number.isSafeInteger(u)||u<0?null:{revision:i,offset:u}}(t.cursor),null===a))return xh("cursor_invalid","The cursor is not a cursor this reader issued.","Re-read the thread without a cursor to get a fresh next_cursor, or call thread_list to confirm the thread address.");if("live"===e.kind)i="live_host",o=!1,r={entries:e.entries(),skippedLines:0};else{i="session_jsonl",o=!0!==e.live_host_present;let t=function(e){let t;try{t=ar(e,"r")}catch{return"missing"}try{let e=[],n=0,r="",i=new cr("utf8"),o=Buffer.allocUnsafe(65536),u=t=>{let r,i=t.trim();if(0!==i.length){try{r=JSON.parse(i)}catch{return void(n+=1)}"object"!=typeof r||null===r||Array.isArray(r)?n+=1:e.push(r)}};for(;;){let e=dr(t,o,0,o.length,null);if(0===e)break;r+=i.write(o.subarray(0,e));let n=0,s=r.indexOf("\n",n);for(;-1!==s;)u(r.slice(n,s)),n=s+1,s=r.indexOf("\n",n);r=r.slice(n)}return u(r+i.end()),{entries:e,skippedLines:n}}catch{return{entries:[],skippedLines:0}}finally{void 0!==t&&sr(t)}}(e.path);if("missing"===t)return xh("not_found",`No session transcript exists at ${e.path}.`,"Call thread_list to get a current thread_id, then read that thread instead.");r=t}let d=r.entries,c=function(e){let t=2166136261;for(let n of e){let e=`${String(n.id??"")}|${String(n.timestamp??"")}`;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619)}return`${e.length}.${(t>>>0).toString(36)}`}(d);if(null!==a&&a.revision!==c)return xh("cursor_stale","The transcript changed after this cursor was issued, so its position no longer names the same entries.","Re-read the thread without a cursor to restart from a current revision.");let l={kind:"ok",source:i,source_incomplete:o,mode:n,total_items:d.length,max_bytes:u,skipped_lines:r.skippedLines};if("status"===n)return{...l,items:[],truncated:!1,next_cursor:null,encoded_bytes:0};let f="tail"===n?Math.max(0,d.length-s):a?.offset??0,p=d.slice(f),m=[],h=0,_=0;for(let e of p){let t=Buffer.byteLength(JSON.stringify(e),"utf8");if(m.length>0&&h+t>u)break;m.push(e),h+=t,_+=1}let g=f+_,y=g<d.length;return{...l,items:m,truncated:y,next_cursor:y?Ah({revision:c,offset:g}):null,encoded_bytes:h}}function Oh(e,t,n){let r=function(e,t){let n="string"==typeof t?t.trim():"";if(0===n.length)return[];let r=Ot();return e.filter(e=>It(e.cwd,n,r))}(nr(e,t),e.callerWorkspaceRoot()),i=e=>!0===n||r.some(t=>t.thread_id===e),o=t.sessions.filter(e=>i(e.durableSessionId??e.sessionId)),u=Yn(e,t),s=u.filter(e=>void 0!==e.error_note&&"live"!==e.status&&i(e.thread_id)),a=new Map(u.map((e,t)=>[e.thread_id,t]));return{kind:"ok",threads:[...o.map(e=>function(e,t){let n=e.durableSessionId??e.sessionId,{name:r,createdAt:i,updatedAt:o,created_at:u,updated_at:s,...a}=e,d=t?.created_at??e.created_at??e.createdAt??(new Date).toISOString();return{...a,thread_id:n,name:t?.title??Bt(e.name,null)??"",status:"closed"===e.status?"resumable":"live",created_at:d,updated_at:void 0===t?e.updated_at??e.updatedAt??d:t.updated_at,...void 0===t?{}:{endpoint:t.endpoint,surface:t.surface,alive:t.alive}}}(e,(e=>u.find(t=>t.thread_id===(e.durableSessionId??e.sessionId)&&t.source_host===(e.socket??t.source_host)))(e))),...s.map(tr)].sort((e,t)=>(a.get(e.thread_id)??Number.MAX_SAFE_INTEGER)-(a.get(t.thread_id)??Number.MAX_SAFE_INTEGER)),scope:!0===n?"all":"workspace"}}async function Ih(e,t,n,r){let i=rr(e,nr(e,t),n.thread,r,n.all_scope);if("error"===i.kind)return{kind:"error",error:i};let o=(u=t,s=i.entry.thread_id,u.sessions.find(e=>(e.durableSessionId??e.sessionId)===s));var u,s;if(void 0===o)return function(e,t,n,r){let i=Yn(e,t).find(e=>e.thread_id===n);if(void 0===i||void 0===i.error_note||null===i.session_path)return o="not_resumable",u="The thread has no live owner.",s="Retry when the target is live.",{kind:"error",error:h(o,u,s,a)};var o,u,s,a;let d=Sh({kind:"jsonl",path:i.session_path,live_host_present:!1},{mode:"tail",max_bytes:r.max_bytes,cursor:r.cursor});if("error"===d.kind)return{kind:"error",error:d.error};let c=d.items.flatMap(e=>{let t=e.message;return"message"!==e.type||"object"!=typeof t||null===t||Array.isArray(t)?[]:"user"===t.role||"assistant"===t.role||"toolResult"===t.role?[t]:[]}).map((e,t)=>({seq:t+1,role:ir(e.role),content:JSON.stringify(e.content??e)}));return{kind:"ok",thread_id:n,items:c,truncated:d.truncated,...null===d.next_cursor?{}:{next_cursor:d.next_cursor},source:d.source,source_incomplete:d.source_incomplete,error_note:i.error_note}}(e,t,i.entry.thread_id,n);let a=await function(e,t){return void 0!==t.socket&&void 0!==e.host.endpoint?e.host.endpoint(t.socket):e.host}(e,o).getMessages(function(e){return e.sessionId}(o)),d=Sh({kind:"live",entries:()=>a},{mode:"tail",max_bytes:n.max_bytes,cursor:n.cursor});return"error"===d.kind?{kind:"error",error:d.error}:{kind:"ok",thread_id:i.entry.thread_id,items:d.items.map((e,t)=>({seq:t+1,role:ir(e.role),content:JSON.stringify(e.content??e)})),truncated:d.truncated,...null===d.next_cursor?{}:{next_cursor:d.next_cursor},source:d.source}}function Eh(e,t,n,r){return{kind:"error",error:h(e,t,n,r)}}function Rh(e){let t=e instanceof Error?e.message:String(e);return t.startsWith("host_unavailable:")?Eh("host_unavailable",`The thread host is unavailable at ${t.slice(17)}.`,"Retry when a host or terminal session is running."):t.startsWith("unsupported:")?Eh("unsupported",`The target's endpoint does not accept ${t.slice(12)}.`,"Use thread read to follow the session.",{command:t.slice(12)}):Eh("internal_error",`Thread operation failed: ${t}`,"Run omo thread list and retry after checking the target.")}async function Ph(e){try{return await e()}catch(e){return Rh(e)}}function qh(e){let t=`cli:${e.uid}`,n={...e.env??process.env,OMO_CODING_AGENT_DIR:e.agentDir},r=e.engineStatusAll,i=e.host??Rn(0,{env:n,...void 0===r?{}:{statusAll:async()=>An(await r())}}),o=e.store??l({agentDir:e.agentDir,...void 0===e.workerModuleUrl?{}:{workerModuleUrl:e.workerModuleUrl}}),u=e.now??o.now,s={host:i,store:o,stateDirectory:e.agentDir,sessionsDirectory:()=>p(e.agentDir,"sessions"),callerSessionId:()=>Zn,callerWorkspaceRoot:()=>e.cwd,now:u},a=()=>Qn(s),{engine:d,relay:c,endpoints:m,locate:h}=ur(s,()=>Qn(s,{offline:!0}));async function g(e,t){let n=await async function(e,t,n,r,i){return rr(e,Zt(er(e,await Xn(e,n,()=>t({offline:!0})),n,i)),n,r,i)}(s,e=>Qn(s,e),e,Zn,t);return"error"===n.kind?{kind:"error",error:n}:{id:n.entry.thread_id}}return{principal:t,list:e=>Ph(async()=>Oh(s,await a(),e.all_scope)),read:e=>Ph(async()=>Ih(s,await a(),{thread:e.thread,max_bytes:e.max_bytes,cursor:e.cursor,all_scope:e.all_scope},Zn)),send:t=>Ph(async()=>void 0!==t.binding_id?await async function(e){if(void 0!==e.thread){let t=await o.bindingView({now:u(),binding_id:e.binding_id});if(null===t||t.session_durable_id!==e.thread){let n=await g(e.thread,e.all_scope);if("kind"in n)return n;if(null!==t&&t.session_durable_id!==n.id)return Eh("invalid_arguments",`Binding ${t.binding_id} delivers to session ${t.session_durable_id}, not ${n.id}.`,"Drop the target (the binding names its session) or pass the binding of that session.",{binding_id:t.binding_id,session:t.session_durable_id})}}return void 0!==e.expected_turn_id?Eh("invalid_arguments","A binding message never steers, so it takes no expected_turn_id.","Drop expected_turn_id."):"steer"===e.mode?Eh("invalid_arguments","A binding message is delivered as auto or follow_up, never steer.","Send with mode auto or follow_up, or omit it for the binding's inbound_mode."):await c.inbound({binding_id:e.binding_id,event_id:e.idempotency_key??f(),text:e.text,...void 0===e.author?{}:{author:e.author},...void 0===e.mode?{}:{mode:e.mode}})}({...t,binding_id:t.binding_id}):void 0===t.thread?Eh("invalid_arguments","A send without a binding needs a target session.","Pass the target session, or --binding to deliver through a binding."):void 0!==t.author?Eh("invalid_arguments","An author names a human in a bound external thread; a send without a binding has none.","Pass binding_id with the author, or drop the author."):await d.deliver({sender:{kind:"cli",uid:e.uid,user:e.user},target:t.thread,text:t.text,...void 0===t.mode?{}:{mode:t.mode},...void 0===t.expected_turn_id?{}:{expected_turn_id:t.expected_turn_id},...void 0===t.all_scope?{}:{all_scope:t.all_scope},...void 0===t.idempotency_key?{}:{idempotency_key:t.idempotency_key}})),bind:e=>Ph(async()=>{let n=await g(e.session,e.all_scope);return"kind"in n?n:await c.bind({principal:t,...Mh(e),binding:{...e.binding,session_durable_id:n.id}})}),unbind:e=>Ph(()=>c.unbind({principal:t,...Mh(e),binding_id:e.binding_id,expected_revision:e.expected_revision})),rebind:e=>Ph(async()=>{let n=await g(e.session,e.all_scope);return"kind"in n?n:await c.rebind({principal:t,...Mh(e),binding_id:e.binding_id,expected_revision:e.expected_revision,session_durable_id:n.id})}),bindings:e=>Ph(async()=>{let{session:t,all_scope:n,cursor:r,limit:i,...o}=e,u=void 0===t?void 0:await g(t,n);return void 0!==u&&"kind"in u?u:await c.bindings({filter:{...o,...void 0===u?{}:{session_durable_id:u.id}},...void 0===r?{}:{cursor:r},...void 0===i?{}:{limit:i}})}),report:e=>Ph(async()=>{let n=S.find(t=>t===e.kind);if(void 0===n)return Eh("invalid_arguments",`The report kind must be one of ${S.join(", ")}.`,"Pass milestone, report, question or completion.");let r=e.request_kind;if(void 0!==r&&("string"!=typeof(i=r)||!_.includes(i)))return Eh("invalid_arguments",`The request kind must be one of ${_.join(", ")}.`,"Pass question, select, confirm, input or editor.");var i;let o=await g(e.session,e.all_scope);if("kind"in o)return o;let u=await c.report({principal:t,...Mh(e),session_durable_id:o.id,event:n,text:e.text,...void 0===e.binding_id?{}:{binding_id:e.binding_id},...void 0===e.request_id?{}:{request_id:e.request_id},...void 0===r?{}:{request_kind:r}});if("ok"!==u.kind)return u;let{arm_seq:s,...a}=u;return a.armed&&await async function(e){let t=await h(e).catch(()=>null);null!==t&&await m.wake(t,[]).catch(()=>{})}(o.id),a}),outbox:e=>Ph(()=>c.outbox(e)),ack:e=>Ph(()=>c.ack(e)),answer:e=>Ph(()=>c.answer({binding_id:e.binding_id,reply_token:e.reply_token,answer:e.answer,...void 0===e.author?{}:{author:e.author}})),locate:e=>Ph(async()=>{let t=await a(),n=rr(s,nr(s,t),e.thread,Zn,e.all_scope);if("error"===n.kind)return{kind:"error",error:n};let r=Yn(s,t).filter(e=>e.thread_id===n.entry.thread_id),i=r.find(e=>e.alive)??r[0];if(void 0===i)return Eh("not_found",`Thread ${n.entry.thread_id} is not in the address book.`,"Run omo thread list --all-scope.");let{thread_id:o,title:u,cwd:d,status:c,session_path:l,endpoint:f,surface:p,alive:m}=i;return{kind:"ok",thread:{thread_id:o,title:u,cwd:d,status:c,session_path:l,endpoint:f,surface:p,alive:m}}}),release:async(e,t)=>{let n=i.gateway?.releaseSession;if(void 0===n||null===e.endpoint)return{success:!1,error:"release_unsupported"};try{return await n(e.endpoint,{reason:"takeover",...t})}catch(e){let t=Rh(e);return{success:!1,error:t.error.code,errorData:{hint:t.error.message}}}},dispose:()=>(c.dispose(),o.dispose())}}function Mh(e){return void 0===e.idempotency_key?{}:{idempotency_key:e.idempotency_key}}var Th="5.1.13",Ch=i(n(t(r(import.meta.url)),"..","..","extensions","omo.js")),Nh=e(r(new URL(`./${c}`,Ch)));function jh(e){return qh(void 0===e.workerModuleUrl&&Nh?{...e,workerModuleUrl:Ch}:e)}export{Th as SDK_VERSION,jh as createThreadSdk,Ut as readSessionFacts};
1
+ // omo:qaFU9GeKaVpwzEDSYuf8eA62CtwtU__PGjiNrI7OWGQ:vLfCNZK8mpsYRGJgzKkQ33PBGMAZnA35oVo8lcVAgFM
2
+ var e,t=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(e){n=[e]}if(n)throw n[0];return t},n=1048576;import{join as r}from"node:path";var i=t(()=>{e=["OMO_RPC_SOCKET","SENPI_RPC_SOCKET","PI_RPC_SOCKET","OMO_RPC_SOCKET_PATH"]});import{existsSync as o}from"node:fs";import{homedir as u}from"node:os";import{join as s,resolve as a}from"node:path";function d(e){let{env:t,homeDir:n=u(),exists:r=o}=e;for(let e of c){let n=t[e]?.trim();if(n)return a(n)}let i=s(n,".omo"),d=s(i,"agent");return r(s(d,l))?d:r(s(i,l))?i:s(n,".senpi","agent")}var c,l="settings.json",f=t(()=>{c=["OMO_CODING_AGENT_DIR","SENPI_CODING_AGENT_DIR","PI_CODING_AGENT_DIR"]});function p(e){if(e instanceof Error&&"code"in e)return"string"==typeof e.code?e.code:void 0}function m(e){for(let t=0;;t+=1)try{return e()}catch(e){if("EINTR"!==p(e)||t>=128)throw e}}var h,_,g,y,v,b,w,k,x,$,A,S,O,I,E,R,P,M,C,T,q,N,j,L,B,D,z,U,F,W;import*as G from"node:fs";import*as K from"node:fs/promises";function J(e){return"function"==typeof e}function H(e){return(...t)=>async function(e){for(let t=0;;t+=1)try{return await e()}catch(e){if("EINTR"!==p(e)||t>=128)throw e}}(async()=>e(...t))}function V(e){return(...t)=>m(()=>e(...t))}function Z(e,t){let n="async"===t?H:V,r=new Map;return new Proxy(e,{get(e,t){if(r.has(t))return r.get(t);let i=Reflect.get(e,t);if(!J(i))return i;let o=n(i),u=Reflect.get(i,"native");return J(u)&&Object.assign(o,{native:n(u)}),r.set(t,o),o}})}function X(e){try{return m(()=>G.statSync(e)),!0}catch{return!1}}var Q=t(()=>{h=Z(K,"async"),_=Z(G,"sync"),({access:g,chmod:y,copyFile:v,cp:b,link:w,lstat:k,mkdir:x,mkdtemp:$,readFile:A,readdir:S,realpath:O,rm:I,rmdir:E,stat:R,unlink:P}=h),({accessSync:M,chmodSync:C,fsyncSync:T,linkSync:q,lstatSync:N,mkdirSync:j,readFileSync:L,readdirSync:B,realpathSync:D,statSync:z,unlinkSync:U,writeFileSync:F,writeSync:W}=_)});import{existsSync as Y,readFileSync as ee,realpathSync as te,statSync as ne}from"node:fs";import{createRequire as re}from"node:module";import{delimiter as ie,dirname as oe,isAbsolute as ue,join as se,resolve as ae,sep as de}from"node:path";function ce(e){return e.includes("$bunfs")||e.includes("~BUN")||e.includes("%7EBUN")}function le(){return typeof Bun<"u"&&Bun.embeddedFiles.length>0}function fe(e,t,n){for(let r of(t??"").split(ie)){if(0===r.length)continue;let t=pe(se(r,e));if(null!==t&&(void 0===n||n(t)))return t}return null}function pe(e){try{let t=te.native(ae(e));return ne(t).isFile()?t:null}catch{return null}}function me(e,t){let n=t.engineVersion;if(void 0===n||0===n.length)return!0;let r=function(e){let t=oe(e);for(let e=0;e<=be;e+=1){try{let e=JSON.parse(ee(se(t,"package.json"),"utf8"));if(e.name===ve&&"string"==typeof e.version&&e.version.length>0)return e.version}catch{}let e=oe(t);if(e===t)break;t=e}}(e);return void 0===r||(r===n||(t.onWarning?.(`Skipping senpi executable ${e} version ${r}; running engine is ${n}`),!1))}function he(e){let t="win32"===e.platform?"senpi.exe":"senpi",n=e.parentEnv[ye]?.trim();if(void 0!==n&&n.length>0)return n.includes("/")||n.includes(de)||ue(n)?pe(n):fe(n,e.parentEnv.PATH);if(!0===e.isCompiledEngine)return pe(e.execPath);let r=t=>me(t,e);if(e.isBunBinary){let n=pe(se(oe(e.execPath),t));return null!==n&&r(n)?n:null}return fe(t,e.parentEnv.PATH,r)}function _e(e,t){if("win32"!==t.platform||e.toLowerCase().endsWith(".exe"))return{command:e,prefixArgs:[]};let n=oe(e),r=[se(n,"node_modules","@code-yeongyu","senpi","dist","cli.js"),se(n,"..","@code-yeongyu","senpi","dist","cli.js")].find(e=>Y(e));return void 0===r?null:{command:t.execPath,prefixArgs:[r]}}function ge(e){let t=(e.resolveSenpiExecutable??he)(e);if(null!==t){if(function(e,t){return!0===t.isCompiledEngine&&pe(t.execPath)===e}(t,e))return{command:t,prefixArgs:[]};let n=_e(t,e);if(null!==n)return n}if("win32"!==e.platform)return null;for(let t of["senpi.cmd","senpi"]){let n=fe(t,e.parentEnv.PATH);if(null===n)continue;let r=_e(n,e);if(null!==r)return r}return null}var ye="SENPI_BIN",ve="@code-yeongyu/senpi",be=3,we=t(()=>{re(import.meta.url)});import{createRequire as ke}from"node:module";var xe,$e,Ae,Se=t(()=>{we(),ke(import.meta.url)});import{createRequire as Oe}from"node:module";import{isAbsolute as Ie,join as Ee,relative as Re}from"node:path";function Pe(e,t=function(){return{isBunBinary:ce(import.meta.url),isCompiledEngine:le(),execPath:process.execPath,platform:process.platform,argv:process.argv,resolveInstalledCli:qe}}()){let n=ge({isBunBinary:t.isBunBinary,isCompiledEngine:t.isCompiledEngine,execPath:t.execPath,platform:t.platform,parentEnv:e,resolveRpcEntry:()=>""});if(null!==n)return n;let r=t.resolveInstalledCli();if(null!==r)return{command:t.execPath,prefixArgs:[r]};let i=t.argv[1];if(void 0!==i&&Ie(i)&&X(i))return{command:t.execPath,prefixArgs:[i]};throw Error("Unable to resolve a runnable Senpi launcher")}function Me(e){try{return D.native(e)}catch{return e}}function Ce(e,t){let n=Re(Me(e),Me(t));return n.length>0&&!n.startsWith("..")&&!Ie(n)}function Te(e,t){let n=t.prefixArgs[0]??t.command,r={...e};for(let e of Ae){let t=r[e];void 0!==t&&0!==t.length&&(Ce(t,n)||delete r[e])}return r}function qe(){let e=Oe(import.meta.url);for(let t of e.resolve.paths(Ee(xe,"package.json"))??[]){let e=Ee(t,xe,$e);if(X(e))return e}return null}var Ne,je=t(()=>{Q(),Se(),xe=Ee("@code-yeongyu","senpi"),$e=Ee("dist","cli.js"),Ae=["OMO_PACKAGE_DIR","SENPI_PACKAGE_DIR","PI_PACKAGE_DIR"]});function Le(e,t,n,r){if("string"!=typeof(i=e)||!Ne.has(i))throw Error(`unknown thread error code: ${String(e)}`);var i;return{code:e,message:t,next_action:n,...void 0===r?{}:{details:r}}}var Be=t(()=>{Ne=new Set(["invalid_arguments","caller_context_missing","not_found","ambiguous_target","scope_denied","name_conflict","not_resumable","orphaned","foreign_live_owner","no_active_turn","turn_conflict","not_steerable","message_too_large","queue_full","cursor_invalid","cursor_stale","idempotency_conflict","idempotency_in_progress","idempotency_uncertain","approval_unavailable","approval_route_locked","partial_commit","unsupported","overloaded","transport_closed","host_unavailable","internal_error","model_not_found","model_ambiguous","thinking_level_unsupported","loop_detected","binding_conflict","binding_mismatch","binding_inactive","stale_revision","stale_token","already_answered","answer_in_progress"])});import{execFileSync as De}from"node:child_process";import{realpathSync as ze}from"node:fs";function Ue(e){return e.normalize("NFKC").trim().toLowerCase().replace(/\s+/g," ")}function Fe(e,t,n,r){let i=Le(e,t,n,void 0===r?void 0:{candidates:r});return void 0===r?{kind:"error",...i}:{kind:"error",...i,candidates:r}}function We(e){return{id:e.thread_id,name:e.name,cwd:e.cwd,preview:e.preview??"",updatedAt:e.updated_at,state:e.status}}function Ge(e){try{return ze(e)}catch{return e}}function Ke(e){try{let t=De("git",["-C",e,"rev-parse","--show-toplevel"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3,windowsHide:!0}).trim();return 0===t.length?null:t}catch{return null}}function Je(){let e=new Map;return t=>{if(e.has(t))return e.get(t)??null;let n=Ke(t);return e.set(t,n),n}}function He(e,t,n){let r=n(e),i=n(t);return null!==r&&null!==i?Ge(r)===Ge(i):Ge(e)===Ge(t)}function Ve(e){let t=e.trim();if(0===t.length)return[];let n=Ke(t);return[...new Set((null===n?[t]:[t,n]).flatMap(e=>[e,Ge(e)]))]}function Ze(e,t,n={}){let r=function(e,t){if("string"!=typeof e)return{ok:!1,error:Fe("invalid_arguments",`The ${t} must be a string.`,`Pass a thread_id or a unique name from thread_list as the ${t}.`)};if(Xe.test(e))return{ok:!1,error:Fe("invalid_arguments",`The ${t} contains control characters.`,"Remove the control characters and retry, or pass an address from thread_list.")};let n=Ue(e);return 0===n.length?{ok:!1,error:Fe("invalid_arguments",`The ${t} is empty.`,`Pass a thread_id or a unique name from thread_list as the ${t}.`)}:{ok:!0,normalized:n}}(t,"thread address");if(!r.ok)return r.error;let i,o="string"==typeof n.callerWorkspaceRoot?n.callerWorkspaceRoot.trim():"",u=o.length>0,s=Je(),a=e.find(e=>e.thread_id===t);if(void 0!==a)return!0===n.all_scope?{kind:"ok",entry:a,resolution:"id"}:u?He(a.cwd,o,s)?{kind:"ok",entry:a,resolution:"id"}:Fe("scope_denied",`Thread ${a.thread_id} exists outside this workspace.`,"Call thread_list with all_scope to confirm the id, then retry with all_scope set, or target a thread in this workspace."):Fe("caller_context_missing","Scoping an id hit needs the caller's workspace root, which this call did not provide.","Set all_scope to address every workspace, or call thread_list from a session that knows its workspace.");if(!0===n.all_scope)i=e;else{if(!u)return Fe("caller_context_missing","Scoped address resolution needs the caller's workspace root, which this call did not provide.","Set all_scope to address every workspace, or call thread_list from a session that knows its workspace.");i=e.filter(e=>He(e.cwd,o,s))}let d=i.filter(e=>Ue(e.name)===r.normalized);return 1===d.length?{kind:"ok",entry:d[0],resolution:"name"}:d.length>=2?Fe("ambiguous_target",`${d.length} visible threads share the name "${t}".`,"Call thread_list and pass the exact thread_id of the intended thread.",function(e){return[...e].sort((e,t)=>e.updated_at===t.updated_at?e.thread_id<t.thread_id?-1:1:null===e.updated_at?1:null===t.updated_at?-1:e.updated_at<t.updated_at?1:-1).slice(0,Qe).map(We)}(d)):Fe("not_found",`No visible thread matches "${t}" in ${!0===n.all_scope?"the daemon-wide scope":"this workspace"}.`,"Call thread_list and pass the thread_id or a unique name it returned.")}var Xe,Qe=10,Ye=t(()=>{Be(),Xe=/[\u0000-\u0008\u000e-\u001f\u007f]/});import{closeSync as et,fstatSync as tt,openSync as nt,readSync as rt}from"node:fs";function it(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ot(e){return"string"==typeof e?e:Array.isArray(e)?e.flatMap(e=>it(e)&&"text"===e.type&&"string"==typeof e.text?[e.text]:[]).join(" "):""}function ut(e,t){let n=e?.trim();if(void 0!==n&&n.length>0)return n;let r=t?.replace(/\s+/g," ").trim();return void 0===r||0===r.length?null:[...r].slice(0,ft).join("")}function st(e,t=!1,n=!1){let r=e.split("\n");return t&&r.shift(),n&&r.pop(),r.flatMap(e=>{if(0===e.trim().length)return[];try{let t=JSON.parse(e);return it(t)?[t]:[]}catch{return[]}})}function at(e){let t=null,n=null,r=null,i="";for(let o of e){if(null===t&&"session"===o.type&&"string"==typeof o.id&&(t=o),"session_info"===o.type&&(n="string"==typeof o.name&&o.name.trim().length>0?o.name.trim():null),null===r&&"message"===o.type&&it(o.message)&&"user"===o.message.role){let e=ot(o.message.content).trim();e.length>0&&(r=e)}"string"==typeof o.timestamp&&o.timestamp>i&&(i=o.timestamp)}return{header:t,name:n,first_user_text:r,newest_timestamp:i}}function dt(e,t=rt){let n;try{n=nt(e,"r")}catch{return null}try{let e=tt(n),r=e.size,i=Math.min(r,lt),o=Buffer.alloc(i);t(n,o,0,i,0);let u=r<=lt,s=st(o.toString("utf8"),!1,!u),a=s[0];if(void 0===a||"session"!==a.type||"string"!=typeof a.id||"string"!=typeof a.cwd||"string"!=typeof a.timestamp)return null;let d=[];if(!u){let e=Math.max(i,r-lt),o=Buffer.alloc(r-e+1);t(n,o,0,o.length,e-1),d=st(o.subarray(1).toString("utf8"),10!==o[0],!1)}let c=at([...s,...d]),l=function(e,t,n){if(0===t)return null;let r=Buffer.allocUnsafe(1);if(1!==n(e,r,0,1,t-1)||10!==r[0])return null;let i=t-1,o=0,u=[];for(;i>0&&o<ct;){let t=Math.min(lt,i,ct-o),r=i-t,s=Buffer.allocUnsafe(t);if(n(e,s,0,t,r)!==t)return null;let a=s.lastIndexOf(10);if(u.unshift(-1===a?s:s.subarray(a+1)),-1!==a||0===r)return Buffer.concat(u);o+=t,i=r}return null}(n,r,t),f=tt(n),p=f.size===e.size&&f.mtimeMs===e.mtimeMs?function(e){if(null===e)return null;try{let t=JSON.parse(e.toString("utf8"));return it(t)&&"string"==typeof t.timestamp&&t.timestamp.length>0?t.timestamp:null}catch{return null}}(l):null;return{durable_id:a.id,cwd:a.cwd,created_at:a.timestamp,updated_at:p,name:c.name,first_user_text:c.first_user_text}}catch{return null}finally{et(n)}}var ct,lt=65536,ft=60,pt=t(()=>{ct=4*lt});import{readdirSync as mt,readFileSync as ht}from"node:fs";import{basename as _t,join as gt,resolve as yt}from"node:path";function vt(e,t,n){if("tui"===e)return"tui";if("worker"===t)return"child";let r=_t(n);return r.startsWith("i-")?"desktop":r.startsWith("p-")?"child":"daemon"}function bt(e){if(e instanceof Error)return e.message;if("string"==typeof e)return e;if("object"==typeof e&&null!==e){let t=e.message;if("string"==typeof t)return t;let n=e.error;if(void 0!==n)return bt(n)}return String(e)}function wt(e){return e.list_sessions??e.result}function kt(e){if(void 0!==e.error)return null;let t=wt(e);return void 0===t||"kind"in t&&"error"===t.kind?null:"data"in t?t.data.sessions:t.sessions}function xt(e){if("live_unresponsive"===e.reason)return"live_unresponsive";if(void 0!==e.error)return bt(e.error);let t=wt(e);return void 0===t?"host unavailable":"kind"in t&&"error"===t.kind?bt(t.error):null}function $t(e,t){return"string"==typeof e&&e.length>0?e:t}function At(e,t,n){let r=null===e.source_host?null:{kind:t?.endpoint_kind??"rpc_host",socket:e.source_host,routing_id:null};return{durable_id:e.durable_id,routing_id:null,name:e.name,cwd:e.cwd,status:"resumable",liveness:"resumable",source_host:e.source_host,session_path:e.session_path,created_at:e.created_at,updated_at:e.updated_at,thread_id:e.durable_id,...void 0===n?{}:{error_note:n},endpoint:r,surface:null===r?null:vt(r.kind,void 0,r.socket),alive:!1,title:ut(e.name,e.first_user_text)}}function St(e){return e.map(e=>({thread_id:e.thread_id,name:e.name??"",status:e.status,cwd:e.cwd,created_at:e.created_at,updated_at:e.updated_at}))}function Ot(e){return e.map(e=>({thread_id:e.thread_id,name:e.name??"",status:e.status,cwd:e.cwd,created_at:e.created_at,updated_at:e.updated_at,endpoint:e.endpoint,liveness:e.alive?"routable":"live_unresponsive"===e.error_note?"live_unresponsive":"dead"}))}function It(e){return`--${yt(e).replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}-`}function Et(e){let t=dt(e);return null===t?null:{durable_id:t.durable_id,name:t.name,cwd:t.cwd,created_at:t.created_at,updated_at:t.updated_at,session_path:e,source_host:null,...null===t.first_user_text?{}:{first_user_text:t.first_user_text}}}var Rt=t(()=>{Ye(),pt()});import{createHash as Pt}from"node:crypto";import{realpathSync as Mt}from"node:fs";import{readdir as Ct,readFile as Tt}from"node:fs/promises";import{basename as qt,dirname as Nt,join as jt}from"node:path";function Lt(e){return Kt.test(qt(e))}function Bt(e){return e.startsWith("\0")?e:jt(function(e){let t=[],n=e;for(;;)try{return jt(Mt(n),...t.reverse())}catch{let r=Nt(n);if(r===n)return e;t.push(qt(n)),n=r}}(Nt(e)),qt(e))}function Dt(e){return Pt("sha256").update(e,"utf8").digest("hex").slice(0,16)}async function zt(e){let t;try{t=await Tt(e,"utf8")}catch{return}try{let e=JSON.parse(t);return"object"!=typeof e||null===e||Array.isArray(e)?void 0:e}catch{return}}async function Ut(e,t){let n=await zt(e),r=n?.socket;if(void 0!==n&&"string"==typeof r&&""!==r)return function(e,t){return Dt(Bt(e))===t||Dt(e)===t}(r,qt(t))?{socket:r,record:n}:void 0}async function Ft(e){let t=jt(e,"rpc-host-daemon");if((await zt(jt(t,"layout.json")))?.layout!==Jt)return[];let n=(await Ct(t,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isDirectory()&&Gt.test(e.name)).map(e=>jt(t,e.name)).sort();return await Promise.all(n.map(e=>async function(e){let t=await Ut(jt(e,"endpoint.json"),e);if(void 0!==t)return{socket:t.socket,dir:e,identity:"endpoint",endpoint_kind:"tui"===t.record.endpoint_kind?"tui":"rpc_host",registry_version:"number"==typeof t.record.registry_version?t.record.registry_version:null};let n=await Ut(jt(e,"settings.json"),e);if(void 0!==n)return{socket:n.socket,dir:e,identity:"settings",endpoint_kind:"rpc_host",registry_version:null};let r=await Ct(jt(e,"generations")).catch(()=>[]);for(let t of r.sort()){let n=await Ut(jt(e,"generations",t,"settings.json"),e);if(void 0!==n)return{socket:n.socket,dir:e,identity:"generation-settings",endpoint_kind:"rpc_host",registry_version:null}}return{socket:null,dir:e,identity:"unknown",endpoint_kind:"rpc_host",registry_version:null}}(e)))}function Wt(e,t){if(Lt(e))return"tui";let n=Bt(e);return t.find(t=>null!==t.socket&&(t.socket===e||Bt(t.socket)===n))?.endpoint_kind??"rpc_host"}var Gt,Kt,Jt=2,Ht=t(()=>{Gt=/^[0-9a-f]{16}$/,Kt=/^t-[0-9a-f]{16}\.sock$/});import{execFile as Vt}from"node:child_process";import{createConnection as Zt}from"node:net";import{randomUUID as Xt}from"node:crypto";import{existsSync as Qt,readFileSync as Yt}from"node:fs";import{resolve as en}from"node:path";function tn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function nn(t=process.env){return function(t,n){for(let n of e){let e=t[n]?.trim();if(e)return e}return r(n,"rpc","rpc.sock")}(t,d({env:t}))}function rn(e,t){return Array.isArray(e)?e.flatMap(e=>tn(e)&&"string"==typeof e[t]&&""!==e[t]?[e[t]]:[]):[]}function on(e){if(!tn(e)||!tn(e.session))return[];let t=e.session.path;return"string"==typeof t&&""!==t?[t]:[]}function un(e){let t,n=e?.trim().split("\n").filter(e=>""!==e.trim()).pop();if(void 0!==n){try{t=JSON.parse(n)}catch{return}return tn(t)&&Array.isArray(t.endpoints)?t.endpoints.flatMap(e=>tn(e)?[{socket:"string"==typeof e.socket&&""!==e.socket?e.socket:null,reachable:!0===e.reachable,session_paths:[...new Set([...rn(e.session_rows,"session_path"),...rn(e.claims,"session_path"),...on(e.owner)])],..."tui"===e.endpoint_kind||"rpc_host"===e.endpoint_kind?{endpoint_kind:e.endpoint_kind}:{},..."boolean"==typeof e.alive?{alive:e.alive}:{},..."live_unresponsive"===e.reason||"dead"===e.reason?{reason:e.reason}:null===e.reason?{reason:null}:{}}]:[]):void 0}}function sn(e){let t=tn(e)?e.code:void 0;return"ENOENT"===t||"ECONNREFUSED"===t}function an(e){if(!0===e.success&&tn(e.data)&&!0===e.data.released&&"string"==typeof e.data.session_path)return{success:!0,data:e.data};let t="string"==typeof e.error?e.error:"release_failed";return tn(e.errorData)?{success:!1,error:t,errorData:e.errorData}:{success:!1,error:t}}function dn(e){return Array.isArray(e.admitted)?{admitted:e.admitted.flatMap(e=>tn(e)&&"string"==typeof e.delivery_id&&"string"==typeof e.kind&&mn.has(e.kind)?[{delivery_id:e.delivery_id,kind:e.kind}]:[])}:{admitted:[]}}function cn(e,t={}){let n,r=t.env??process.env,i=t.exists??Qt,o=t.connect??(e=>Zt(e)),u=t.now??Date.now,s=t.statusAll??function(e){return async()=>{let t;try{t=Pe({...e})}catch{return}return un(await new Promise(n=>{Vt(t.command,[...t.prefixArgs,...ln],{env:Te({...e},t),timeout:bn,maxBuffer:16777216,windowsHide:!0},(e,t)=>n("string"==typeof t?t:void 0))}))}}(r),a=t.registry??(()=>Ft(d({env:r}))),c=t.readSecret??(e=>Yt(function(e){return`${e}.secret`}(e))),l=nn(t.env),f=new Map,p=new Map,m=async(e,t,n={},r)=>{let u,s="tui"===(e=>p.get(en(e))??(Lt(e)?"tui":"rpc_host"))(e);if(s&&!pn.has(t))throw Error(`unsupported:${t}`);if(!i(e))throw Error(`host_unavailable:${e}`);if(s)try{u=c(e)}catch{throw Error(`host_unavailable:${e}`)}return await async function(e,t,n,r={}){let i=Xt();return await new Promise((o,u)=>{let s=n(e),a="",d=setTimeout(()=>{s.destroy(),u(Error("thread RPC request timed out"))},r.timeoutMs??_n),c=(e,t)=>{clearTimeout(d),s.destroy(),void 0===e?o(t):u(e)};s.once("error",e=>c(e)),s.once("close",()=>c(Error(`thread RPC connection closed before the ${String(t.type)} response arrived`))),s.once("connect",()=>{void 0!==r.secret&&s.write(Buffer.from(r.secret)),s.write(`${JSON.stringify({...t,id:i})}\n`)}),s.on("data",e=>{a+=e.toString("utf8");let t=a.indexOf("\n");for(;t>=0;){let e,n=a.slice(0,t);if(a=a.slice(t+1),t=a.indexOf("\n"),""!==n.trim()){try{e=JSON.parse(n)}catch(e){return void c(e instanceof Error?e:Error(String(e)))}if(tn(e)&&e.id===i)return void c(void 0,e)}}})})}(e,{type:t,...n},o,{timeoutMs:r??(s?yn:void 0),secret:u})},h=async(e,t,n={},r)=>function(e,t){if(!1===e.success&&"set_thinking_level"===t&&"string"==typeof e.error&&/^Thinking level .+ is not supported by the active model\.$/.test(e.error))throw Error(`thinking_level_unsupported:${e.error}`);if(!1===e.success&&"unsupported"===e.error)throw Error(`unsupported:${String(t)}`);if(e.success&&void 0===e.data&&("set_session_name"===t||"set_thinking_level"===t))return{};if(!e.success||!tn(e.data))throw Error(`thread RPC request failed: ${JSON.stringify(e.error??e)}`);return e.data}(await m(e,t,n,r),t),_=(e,t={})=>h(l,e,t),g=async()=>{let[e,t]=await Promise.all([s().catch(()=>{}),a().catch(()=>[])]),n=void 0===e?t.flatMap(e=>null===e.socket?[]:[{socket:e.socket,paths:[],kind:e.endpoint_kind,verdict:{}}]):e.flatMap(e=>null===e.socket?[]:[{socket:e.socket,paths:e.session_paths,kind:e.endpoint_kind??Wt(e.socket,t),verdict:{...void 0===e.alive?{}:{alive:e.alive},...void 0===e.reason?{}:{reason:e.reason}}}]),r=e=>en(e.socket)===en(l),i=[...new Set(n.filter(r).flatMap(e=>e.paths))];return[{socket:l,paths:i,kind:Wt(l,t),verdict:{}},...n.filter(e=>!r(e))]},y=async()=>{(void 0===n||n.expiresAt<=u())&&(n={expiresAt:u()+vn,endpoints:g()});let e=await n.endpoints;for(let t of e)p.set(en(t.socket),t.kind);return e},v=(e,t,n)=>{let r=[...new Set([...e.paths,...f.get(e.socket)??[]])].flatMap(t=>{let n=function(e,t){let n;try{n=ht(e,"utf8")}catch{return null}let r=dt(e);if(null===r)return null;let{name:i,first_user_text:o}=at(st(n));return{durable_id:r.durable_id,name:i,cwd:r.cwd,created_at:r.created_at,updated_at:r.updated_at,session_path:e,source_host:t,...null===o?{}:{first_user_text:o}}}(t,e.socket);return null===n?[]:[n]});return{host:{socket:e.socket,error:t instanceof Error?t.message:String(t),endpoint_kind:e.kind,alive:!1,reason:n,legacy:e.socket===l},sessions:[],disk:r,failure:t}},b=async e=>{let t="tui"===e.kind;if(t&&!1===e.verdict.alive)return v(e,Error(e.verdict.reason??"live_unresponsive"),e.verdict.reason??"live_unresponsive");try{let{sessions:n}=await h(e.socket,"list_sessions",t?{}:fn,t?yn:gn),r=n.map(n=>({...n,socket:e.socket,endpoint_kind:e.kind,...t&&void 0===n.durableSessionId?{durableSessionId:n.sessionId}:{}}));return f.set(e.socket,r.flatMap(e=>"string"==typeof e.sessionPath?[e.sessionPath]:[])),{host:{socket:e.socket,list_sessions:{sessions:r},endpoint_kind:e.kind,alive:!0,reason:null,legacy:e.socket===l},sessions:r,disk:[]}}catch(n){if(t&&!i(e.socket))return v(e,Error("dead"),"dead");let r=n instanceof Error&&"thread RPC request timed out"===n.message;return v(e,n,e.verdict.reason??(r?"live_unresponsive":sn(n)?"dead":null))}},w=async(e={})=>{let t=await y(),n=await Promise.all(t.map(e=>b(e)));for(let e of[...f.keys()])t.some(t=>t.socket===e)||f.delete(e);if(!0!==e.offline&&n.every(e=>void 0!==e.failure))throw n[0]?.failure;return{sessions:n.flatMap(e=>e.sessions),hosts:n.map(e=>e.host),disk:n.flatMap(e=>e.disk)}},k=(e,t)=>({getMessages:async e=>(await t("get_messages",{sessionId:e})).messages,getState:e=>t("get_state",{sessionId:e}),prompt:(e,n,r)=>t("prompt",{sessionId:e,message:n,...r}),interrupt:(e,n)=>t("interrupt",{sessionId:e,...void 0===n?{}:{turnId:n}}),setSessionName:async(e,n)=>{await t("set_session_name",{sessionId:e,name:n})},setModel:(e,n,r)=>t("set_model",{sessionId:e,provider:n,modelId:r}),getAvailableModels:async e=>{let{models:n}=await t("get_available_models",{sessionId:e});return n.map(({provider:e,id:t,name:n})=>({provider:e,id:t,...void 0===n?{}:{name:n}}))},setThinkingLevel:async(e,n,r)=>{await t("set_thinking_level",{sessionId:e,level:n,..."turn"===r?{scope:r}:{}})},getAvailableThinkingLevels:async e=>(await t("get_available_thinking_levels",{sessionId:e})).levels,wake:async(e,n)=>dn(await t("wake",{sessionId:e,delivery_ids:[...n]})),releaseSession:async(t,n)=>an(await m(e??l,"release_session",{sessionId:t,...n}))});return{socket:l,listTarget:async(e,t)=>{p.set(en(t.socket),t.kind);let r=("tui"===t.kind&&void 0!==n&&n.expiresAt>u()?await n.endpoints:void 0)?.find(e=>en(e.socket)===en(t.socket))?.verdict,i=await b({socket:t.socket,paths:[],kind:t.kind,verdict:r??{}}),o=i.sessions.filter(t=>(t.durableSessionId??t.sessionId)===e&&"closed"!==t.status);return{sessions:o,hosts:[void 0===i.failure?{...i.host,list_sessions:{sessions:o}}:i.host],disk:[]}},listSessions:async()=>(await w()).sessions,listView:w,endpoint:e=>k(e,(t,n)=>h(e,t,n)),gateway:{wake:async(e,t)=>{p.set(en(e.socket),e.kind);let n="rpc_host"===e.kind&&null!==e.routing_id?{sessionId:e.routing_id}:{};return dn(await h(e.socket,"wake",{...n,delivery_ids:[...t]}))},releaseSession:async(e,t)=>{if("rpc_host"!==e.kind||null===e.routing_id)throw Error("unsupported:release_session");return an(await m(e.socket,"release_session",{sessionId:e.routing_id,...t}))},classifyLiveness:async e=>{let t=(await y()).find(t=>en(t.socket)===en(e.socket));if(!0===t?.verdict.alive)return"routable";if("live_unresponsive"===t?.verdict.reason||"dead"===t?.verdict.reason)return t.verdict.reason;try{return await h(e.socket,"get_protocol_info",{},"tui"===e.kind?yn:gn),"routable"}catch(e){return e instanceof Error&&e.message.startsWith("host_unavailable:")||sn(e)?"dead":"live_unresponsive"}},respondUi:async(e,t)=>(p.set(en(e.socket),e.kind),await async function(e,t,n){let r="rpc_host"===t.kind&&null!==t.routing_id?{sessionId:t.routing_id}:{},i=await e(t.socket,"extension_ui_response",{...r,uiRequestId:n.ui_request_id,...n.fields});return!0===i.success?{delivered:!0}:{delivered:!1,error:"string"==typeof i.error?i.error:"refused"}}(m,e,t))},openSession:async e=>{let t=await _("open_session",{...e,retain_on_disconnect:!0}),n=t.sessionId,r=e.name;void 0!==r&&""!==r.trim()&&await _("set_session_name",{sessionId:n,name:r});let{sessions:i}=await _("list_sessions",fn),o=i.find(e=>e.sessionId===n);return{...t.state,...o??{},sessionId:n,socket:l,endpoint_kind:"rpc_host"}},...k(void 0,_)}}var ln,fn,pn,mn,hn,_n=6e4,gn=1e4,yn=1500,vn=5e3,bn=3e4,wn=t(()=>{i(),f(),je(),Rt(),Ht(),ln=["host","status","--all","--include-workers","--json"],fn={observe:!0},pn=new Set(["get_protocol_info","list_sessions","get_state","get_messages","set_session_name","wake","subscribe","extension_ui_response"]),mn=new Set(["started","queued","steered","turn_conflict","held_draft","already_admitted"])});function kn(e,t,n,r,i){let o={kind:"ok",thread_id:e.target_durable_id,delivery_id:e.delivery_id,message_seq:e.seq,effective_mode:e.mode_effective??e.mode_requested,endpoint_kind:n,deduplicated:r};if("admitted"===e.state||"applied"===e.state)return"started"===e.admission_kind||"steered"===e.admission_kind?{...o,delivery:{kind:e.admission_kind,turn_id:String(e.turn_epoch??0)}}:{...o,delivery:{kind:"queued",queue_position:Math.max(t,1)}};if("refused"===e.state){let t=hn[e.reason??""]??{code:"internal_error",next:"Call thread_list and check the target."};return{kind:"error",error:Le(t.code,`Delivery ${e.delivery_id} was refused: ${e.reason??"unknown"}.`,t.next,{delivery_id:e.delivery_id})}}return"uncertain"===e.state?{kind:"error",error:Le("idempotency_uncertain",`Delivery ${e.delivery_id} may or may not have reached the target.`,"Read the target transcript before deciding whether to send again.",{delivery_id:e.delivery_id})}:{...o,delivery:{kind:i?"queued_offline":"queued",queue_position:Math.max(t,1)}}}var xn,$n=t(()=>{Be(),hn={not_steerable:{code:"not_steerable",next:"Send with delivery auto or follow_up; a steer needs a running turn."},turn_conflict:{code:"turn_conflict",next:"Read the target again and retry with its current turn id, or send with delivery auto."},expired:{code:"not_resumable",next:"The target did not take the message within its lifetime; send it again if it still matters."},binding_closed:{code:"invalid_arguments",next:"The binding this message was queued under was detached or rebound; re-read the binding and send again."}}});import{createHash as An,randomUUID as Sn}from"node:crypto";function On(e,t){return async(n,r)=>{let i=Ze(await e(),n,{all_scope:r.all_scope,callerWorkspaceRoot:t()});if("ok"!==i.kind){let e=void 0===i.candidates?void 0:{candidates:i.candidates};return{kind:"error",error:Le(i.code,i.message,i.next_action,e)}}let o=i.entry;return{kind:"ok",target:{durable_id:o.thread_id,endpoint:o.endpoint,liveness:o.liveness}}}}function In(e,t,n){return{kind:"error",error:Le(e,t,xn[e]??"Call thread_list and retry after checking the target.",n)}}function En(e){return t={target:e.target,text:e.text,mode:e.mode,expected_turn_id:e.expected_turn_id,binding:e.binding,author:e.author},An("sha256").update(JSON.stringify(t)).digest("hex");var t}var Rn,Pn,Mn=t(()=>{Ye(),Be(),$n(),xn={loop_detected:"Stop relaying here: a direct reply to the session that messaged you is a cycle. That session reads your answer with thread_read; a bound external thread gets it through thread_report, and its questions come back through thread_answer.",overloaded:"Wait before sending to this session again.",queue_full:"Wait for the target to take its queued messages, then send again.",idempotency_conflict:"Retry with a new idempotency_key.",idempotency_in_progress:"Wait for the earlier call to settle, then retry.",idempotency_uncertain:"Read the target transcript before deciding whether to send again; the gateway never resends.",invalid_arguments:"Fix the arguments and send again."}});function Cn(e){return""===e.replace(/[\s\p{Cf}]/gu,"")}function Tn(e){let t=Pn.get(e.trim().toLowerCase());return void 0===t?{value:e,answers:{},comment:e}:{value:e,answers:{},comment:e,confirmed:t}}function qn(e,t){switch(e){case null:return Cn(t)?{ok:!1,reason:"The question declared no request kind, so the answer needs text; this one is blank. An input or editor that takes an empty answer must be reported with its request kind."}:{ok:!0,fields:Tn(t)};case"input":case"editor":return{ok:!0,fields:{value:t}};case"select":return Cn(t)?{ok:!1,reason:"A select answer names one of its options; the text is blank."}:{ok:!0,fields:{value:t}};case"question":return Cn(t)?{ok:!1,reason:"A question answer needs text; this one is blank."}:{ok:!0,fields:{answers:{},comment:t}};case"confirm":{let e=Pn.get(t.trim().toLowerCase());return void 0===e?{ok:!1,reason:"A confirm answer is yes or no (also y/n, true/false; any case, surrounding spaces ignored)."}:{ok:!0,fields:{confirmed:e}}}default:return function(e){throw Error(`unknown extension UI request kind: ${String(e)}`)}(e)}}var Nn=t(()=>{Rn=["question","select","confirm","input","editor"],Pn=new Map([["yes",!0],["y",!0],["true",!0],["no",!1],["n",!1],["false",!1]])});import{createHash as jn,createHmac as Ln,randomUUID as Bn,timingSafeEqual as Dn}from"node:crypto";function zn(e){return{kind:"refused",code:"invalid_arguments",message:e}}function Un(e,t){return"string"!=typeof t||0===t.trim().length?zn(`${e} must be a non-empty string.`):t.length>er?zn(`${e} is longer than ${er} characters.`):/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/.test(t)?zn(`${e} carries a control character or a line separator.`):t}function Fn(e,t){return null==t?null:Un(e,t)}function Wn(e){return"object"==typeof e&&null!==e&&"refused"===e.kind}function Gn(e){if(null===e||"object"!=typeof e)return JSON.stringify(e)??"null";if(Array.isArray(e))return`[${e.map(Gn).join(",")}]`;let t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${Gn(t[e])}`).join(",")}}`}var Kn,Jn,Hn,Vn=604800,Zn=31622400,Xn="@chat",Qn="default",Yn=32768,er=256,tr=t(()=>{Kn=["discord","telegram","slack","notion","feishu","herdr","custom"],Jn=["milestone","report","question","completion"],Hn=["auto","follow_up"]});function nr(e){return"object"==typeof e&&null!==e&&"gateway_lock_wait_exceeded"===e.code}var rr,ir=t(()=>{tr(),or()}),or=t(()=>{ir(),$n()}),ur=t(()=>{or()}),sr=t(()=>{tr(),Nn(),or(),ir(),ur()});function ar(e){return{kind:"refused",code:"invalid_arguments",message:e}}function dr(e,t,n){return"string"!=typeof t||0===t.trim().length?ar(`author.${e} must be a non-empty string.`):t.length>n?ar(`author.${e} is longer than ${n} characters.`):rr.test(t)?ar(`author.${e} carries a control character or line break.`):t.trim()}var cr,lr,fr=t(()=>{rr=/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/});function pr(e,t,n,r){return{kind:"error",error:Le(e,t,r??cr[e]??"Call thread_bindings and retry after checking the binding.",n)}}function mr(e){return"refused"===e.kind?pr(e.code,e.message,e.details):e}function hr(e){if(void 0===e)return;let t=function(e){let t=dr("platform_user_id",e.platform_user_id,256);if("string"!=typeof t)return t;let n=dr("display",e.display,256);if("string"!=typeof n)return n;if(void 0===e.user_id)return{platform_user_id:t,display:n};let r=dr("user_id",e.user_id,256);return"string"!=typeof r?r:{platform_user_id:t,display:n,user_id:r}}(e);return"kind"in t?pr("invalid_arguments",t.message):t}function _r(e){let t=Buffer.byteLength(e);return t>Yn?pr("message_too_large",`The text is ${t} bytes, above the 32768-byte limit.`):void 0}function gr(e,t,n){return void 0===e.idempotency_key?null:{principal:e.principal,operation:t,idempotency_key:e.idempotency_key,args_hash:(r=n,jn("sha256").update(Gn(r)).digest("hex"))};var r}function yr(e){let t=e.store,n=e.now??t.now,r=new Set,i=!1;async function o(e){await u(()=>t.releaseAnswer(e))}async function u(e){try{await e()}catch(n){if(!nr(n)||i)throw n;let o=function(e,t,n){let r,i=!1,o=()=>{r=setTimeout(()=>{r=void 0,i||e().catch(e=>{i||(nr(e)?o():n(e))})},t()),r.unref?.()};return o(),{cancel:()=>{i=!0,clearTimeout(r)}}}(()=>e().then(()=>{r.delete(o)}),()=>t.busyTimeoutMs,()=>{r.delete(o)});r.add(o)}}return{bind:async e=>{let r=function(e){if(!Kn.includes(e.platform))return zn(`platform must be one of ${Kn.join(", ")}.`);let t={account_id:Un("account_id",e.account_id),chat_id:Un("chat_id",e.chat_id),thread_id:Un("thread_id",e.thread_id??Xn),root_message_id:Fn("root_message_id",e.root_message_id),progress_message_id:Fn("progress_message_id",e.progress_message_id),session_durable_id:Un("session",e.session_durable_id),policy_id:Un("policy_id",e.policy_id??Qn)};for(let e of Object.values(t))if(Wn(e))return e;let n=e.direction??{inbound:!0,outbound:!0};if(!0!==n.inbound&&!0!==n.outbound)return zn("A binding needs at least one direction: inbound, outbound, or both.");let r=e.inbound_mode??"auto";if(!Hn.includes(r))return zn(`inbound_mode must be one of ${Hn.join(", ")}.`);let i=e.outbound_events??(n.outbound?Jn:[]);if(i.some(e=>!Jn.includes(e)))return zn(`outbound_events may only name ${Jn.join(", ")}.`);if(new Set(i).size!==i.length)return zn("outbound_events must not repeat an event.");if(n.outbound&&0===i.length)return zn("An outbound binding needs at least one outbound event.");let o=void 0===e.ttl_seconds?Vn:e.ttl_seconds;return null!==o&&(!Number.isInteger(o)||o<1||o>Zn)?zn(`ttl_seconds must be an integer from 1 to ${Zn}, or null for a binding that never expires.`):{platform:e.platform,account_id:t.account_id,chat_id:t.chat_id,thread_id:t.thread_id,root_message_id:t.root_message_id,progress_message_id:t.progress_message_id,session_durable_id:t.session_durable_id,direction:{inbound:!0===n.inbound,outbound:!0===n.outbound},inbound_mode:r,outbound_events:Jn.filter(e=>i.includes(e)),policy_id:t.policy_id,ttl_seconds:o}}(e.binding);return mr("kind"in r?r:await t.bind({now:n(),receipt:gr(e,"thread_bind",r),binding:r}))},unbind:async e=>{let r={binding_id:e.binding_id,expected_revision:e.expected_revision};return mr(await t.unbind({now:n(),receipt:gr(e,"thread_unbind",r),...r}))},rebind:async e=>{let r={binding_id:e.binding_id,expected_revision:e.expected_revision,session_durable_id:e.session_durable_id};return mr(await t.rebind({now:n(),receipt:gr(e,"thread_rebind",r),...r}))},bindings:async e=>mr(await t.listBindings({now:n(),...e})),report:async e=>{let r=_r(e.text);if(void 0!==r)return r;let i={session_durable_id:e.session_durable_id,binding_id:e.binding_id??null,origin_delivery_ids:e.origin_delivery_ids??[],origin_local_input:!0===e.origin_local_input,event:e.event,text:e.text,ui_request_id:e.request_id??null,ui_request_kind:e.request_kind??null};return mr(await t.report({now:n(),receipt:gr(e,"thread_report",i),...i}))},outbox:async e=>mr(await t.readOutbox({now:n(),...e})),ack:async e=>mr(await t.ackOutbox({now:n(),...e})),answer:async r=>{let i=_r(r.answer);if(void 0!==i)return i;let s=hr(r.author);if(void 0!==s&&"kind"in s)return s;let a=s??null,d=await t.claimAnswer({now:n(),binding_id:r.binding_id,reply_token:r.reply_token,answer:r.answer,answered_by:a});if("ok"!==d.kind)return mr(d);let c={reply_token:r.reply_token,claimed_at:d.claimed_at},l=e.endpoints.respondUi,f=null,p="";if(void 0!==l)try{f=await e.locate(d.session_durable_id)}catch(e){p=`: ${e instanceof Error?e.message:String(e)}`}if(void 0===l||null===f)return await o(c),pr(void 0===l?"unsupported":"host_unavailable",`The session that asked is not reachable to take the answer${p}.`,{session:d.session_durable_id});let m,h=qn(d.ui_request_kind,r.answer);if(!h.ok)return await o(c),pr("invalid_arguments",h.reason,{session:d.session_durable_id,ui_request_kind:d.ui_request_kind});try{m=await l(f,{ui_request_id:d.ui_request_id,fields:h.fields})}catch(e){return await o(c),pr("host_unavailable",`The answer could not be handed to the session: ${e instanceof Error?e.message:String(e)}`,{session:d.session_durable_id})}if(!m.delivered){let e=d.taken_over;if(null!==e&&lr.has(m.error))return"question_already_resolved"===m.error?(await u(()=>t.markPriorDelivered({...c,prior:e})),pr("already_answered",`The session already took an earlier answer to this question (${m.error}).`,{session:d.session_durable_id,reason:m.error})):(await u(()=>t.markPriorDelivered({...c,prior:{answer:null,answered_at:c.claimed_at}})),pr("already_answered",`The session no longer waits for this question (answered or closed elsewhere) (${m.error}).`,{session:d.session_durable_id,reason:m.error},"Nothing to do: the session no longer waits for this question."));await o(c);let n="invalid_response"===m.error||"question_incomplete"===m.error;return pr(n?"invalid_arguments":"stale_token",`The session refused the answer: ${m.error}`,{session:d.session_durable_id,reason:m.error},n?`The session could not read this answer (${m.error}); answer again with text it can take. The question stays pending.`:`The session refused the answer (${m.error}): it no longer waits on this question. Read thread_outbox for a newer question and answer that one.`)}return await async function(e){await u(()=>t.confirmAnswer(e))}({...c,answer:r.answer,answered_by:a}),{kind:"ok",binding_id:r.binding_id,cursor:d.cursor,session_durable_id:d.session_durable_id,answered_by:a}},inbound:async r=>{if(void 0!==r.mode&&!Hn.includes(r.mode))return pr("invalid_arguments",`A binding message is delivered as ${Hn.join(" or ")}, never ${String(r.mode)}.`,{mode:r.mode},"Send with mode auto or follow_up, or omit it for the binding's inbound_mode.");let i=hr(r.author);if(void 0!==i&&"kind"in i)return i;let o=await t.bindingView({now:n(),binding_id:r.binding_id});if(null===o)return pr("not_found","No binding has this id.",{binding_id:r.binding_id});let u={principal:`binding:${o.binding_id}`,idempotency_key:`event:${r.event_id}`},s=await t.deliveryReceipt({now:n(),...u});if(null!==s&&null!==s.binding_revision&&s.args_hash===En({target:s.target_durable_id,text:r.text,mode:r.mode??o.inbound_mode,expected_turn_id:null,binding:{binding_id:o.binding_id,revision:s.binding_revision},author:i})){let e=s.completed?{kind:"replay",result:s.result}:await t.recoverDelivery({now:n(),...u,args_hash:s.args_hash});if("replay"===e?.kind){let t=e.result;return"ok"===t.kind?{...t,deduplicated:!0}:t}if("refused"===e?.kind)return pr(e.code,e.message,e.details)}if("active"!==o.status)return pr("binding_inactive",`The binding is ${o.status}.`,{binding_id:o.binding_id,status:o.status});if(!o.direction.inbound)return pr("unsupported","The binding carries no inbound direction.",{binding_id:o.binding_id});let a=r.mode??o.inbound_mode;return"auto"===a&&"follow_up"===o.inbound_mode?pr("invalid_arguments","The binding delivers at most follow_up; a message cannot ask for more than its binding's inbound_mode.",{binding_id:o.binding_id,mode:a,inbound_mode:o.inbound_mode},"Send with mode follow_up (or omit it), or rebind the thread with inbound_mode auto."):await e.engine.deliver({sender:{kind:"external",origin:{platform:o.platform,account_id:o.account_id,chat_id:o.chat_id,thread_id:o.thread_id,message_id:r.event_id,...void 0===i?{}:{author:i}},binding_id:o.binding_id,binding_revision:o.revision},target:o.session_durable_id,text:r.text,mode:a,all_scope:!0,idempotency_key:`event:${r.event_id}`})},settle:e=>t.emitCompletions({now:n(),...e}),dispose:()=>{i=!0;for(let e of r)e.cancel();r.clear()}}}var vr=t(()=>{Be(),Nn(),tr(),Mn(),sr(),fr(),cr={binding_conflict:"Call thread_bindings to find the binding that holds this thread, then thread_rebind it with its revision, or thread_unbind it first.",binding_mismatch:"Answer through the binding that asked the question; the question stays pending.",binding_inactive:"Bind the thread again with thread_bind.",stale_revision:"Call thread_bindings for the current revision and retry with it.",stale_token:"The question was asked under an earlier binding revision or session runtime; wait for the session to ask again.",already_answered:"Nothing to do: the question has its answer.",answer_in_progress:"Retry after a moment: another answer is still being handed to the session, and the question goes back to pending if that fails.",idempotency_conflict:"Retry with a new idempotency_key.",idempotency_uncertain:"Call thread_bindings or thread_outbox to see the current state before retrying with a new key.",scope_denied:"Report through a binding attached to this session; thread_bindings lists them.",unsupported:"Report only the events the binding subscribes to, through a binding with an outbound direction.",not_found:"Call thread_bindings for the binding ids that exist.",cursor_invalid:"Read thread_outbox again and ack a cursor it returned.",host_unavailable:"Retry when the session is running; the question stays pending.",invalid_arguments:"Fix the arguments and call again."},lr=new Set(["question_already_resolved","unknown_extension_ui_request","unknown_request"])}),br="unknown-caller";async function wr(e,t,n){let r=await e.store.sessionOwner(t);return null===r?await n():null===r.endpoint||void 0===e.host.listTarget?{sessions:[],hosts:[],disk:[]}:await e.host.listTarget(t,r.endpoint)}async function kr(e,t={}){if(void 0!==e.host.listView)return await e.host.listView(t);let n;try{n=await e.host.listSessions()}catch(n){if(!0!==t.offline)throw n;return{sessions:[],hosts:[{socket:e.host.socket,error:n}],disk:[]}}return{sessions:n,hosts:[{socket:e.host.socket,list_sessions:{sessions:n}}],disk:[]}}function xr(e,t,n=[]){return function(e,t,n={}){let r=n.assembled_at??(new Date).toISOString(),i=new Map,o=new Map,u=new Map(e.map(e=>[e.socket,e]));for(let t of e){let e=xt(t);null!==e&&o.set(t.socket,e)}for(let e of t){if(0===e.durable_id.length)continue;let t=null===e.source_host?void 0:o.get(e.source_host);i.set(e.durable_id,At(e,null===e.source_host?void 0:u.get(e.source_host),t))}for(let t of e){let e=kt(t);if(null!==e)for(let o of e){if("closed"===o.status)continue;let e=o.durableSessionId??("tui"===t.endpoint_kind?o.sessionId:void 0);if("string"!=typeof e||0===e.length)continue;let u=i.get(e),s=o.sessionPath??u?.session_path??null,a={name:o.name??null,created:o.created_at??o.createdAt,updated:o.updated_at??o.updatedAt},d=null!==a.name&&"string"==typeof a.created&&"string"==typeof a.updated||null===s?null:n.facts?.(s)??null,c=$t(a.created,d?.created_at??u?.created_at??r),l=$t(a.updated,null===d?u?.updated_at??null:d.updated_at),f=a.name??u?.name??d?.name??null;i.set(e,{durable_id:e,routing_id:o.sessionId,name:f,cwd:o.cwd,status:"live",liveness:"live",source_host:t.socket,session_path:s,created_at:c,updated_at:l,thread_id:e,endpoint:{kind:t.endpoint_kind??"rpc_host",socket:t.socket,routing_id:o.sessionId},surface:vt(t.endpoint_kind,o.kind,t.socket),alive:!1!==t.alive,title:ut(f,d?.first_user_text)??u?.title??null})}}return[...i.values()].sort((e,t)=>e.updated_at!==t.updated_at?null===e.updated_at?1:null===t.updated_at?-1:e.updated_at<t.updated_at?1:-1:e.durable_id.localeCompare(t.durable_id))}(t.hosts,[...e.diskSessions?.()??[],...t.disk,...n],{facts:dt})}function $r(e,t,n,r){let i=xr(e,t),o=e.sessionsDirectory?.();if(void 0===o||"self"===n)return i;let u=new Set(i.map(e=>e.durable_id));if(u.has(n))return i;let s=e.callerWorkspaceRoot(),a=Ze(St(i),n,{all_scope:r,callerWorkspaceRoot:s}),d="error"!==a.kind||"not_found"!==a.code,c=function(e,t,n={}){let r;try{r=mt(e,{withFileTypes:!0}).filter(e=>(e.isDirectory()||e.isSymbolicLink())&&/^--.*--$/.test(e.name)).map(e=>e.name)}catch{return[]}let i=new Map,o=t=>{let n=i.get(t);if(void 0===n){try{n=mt(gt(e,t)).filter(e=>e.endsWith(".jsonl"))}catch{n=[]}i.set(t,n)}return n},u=`_${t}.jsonl`,s=r.flatMap(n=>o(n).flatMap(r=>{if(!r.endsWith(u))return[];let i=Et(gt(e,n,r));return null!==i&&i.durable_id===t?[i]:[]}));if(s.length>0||!0===n.id_only)return s;let a=Ue(t);if(0===a.length)return[];let d=!0===n.all_scope?void 0:(n.workspaceRoots??[]).map(It);return(void 0===d?r:r.filter(e=>d.some(t=>e.startsWith(t)))).flatMap(t=>o(t).flatMap(n=>{let r=Et(gt(e,t,n));return null!==r&&null!==r.name&&Ue(r.name)===a?[r]:[]}))}(o,n,{all_scope:r,workspaceRoots:Ve(s),id_only:d}).filter(e=>!u.has(e.durable_id));return 0===c.length?i:xr(e,t,c)}function Ar(e){return{sessionId:e.durable_id,durableSessionId:e.durable_id,...null===e.session_path?{}:{sessionPath:e.session_path},...null===e.source_host?{}:{socket:e.source_host},cwd:e.cwd,thread_id:e.thread_id,name:e.title??"",status:"resumable",created_at:e.created_at,updated_at:e.updated_at,endpoint:e.endpoint,surface:e.surface,alive:e.alive,...void 0===e.error_note?{}:{error_note:e.error_note}}}function Sr(e,t){return St(xr(e,t))}function Or(e,t,n,r,i){if("self"===n){let e=r===br?void 0:t.find(e=>e.thread_id===r);if(void 0===e)return{kind:"error",...Le("caller_context_missing","The caller's durable session id is not in the thread address book.","Call thread_list and pass an explicit thread_id, or retry from a session with caller context.")};n=e.thread_id}return Ze(t,n,{all_scope:i,callerWorkspaceRoot:e.callerWorkspaceRoot()})}function Ir(e){return"user"===e||"assistant"===e?e:"toolResult"===e?"tool":"system"}var Er,Rr=t(()=>{Rt(),Ye(),Be(),pt()});function Pr(e,t){return async(n,r)=>{let i=await t();return await On(()=>Ot($r(e,i,n,r.all_scope)),e.callerWorkspaceRoot)(n,r)}}function Mr(e,t){let r=e.store,i=e.now??r.now,o=e.host.gateway??Er,u=function(e){let t=e.store,r=e.now??t.now;return{deliver:async function(i){let o=i.mode??"auto";if("steer"===o&&void 0===i.expected_turn_id)return In("invalid_arguments","A steer needs expected_turn_id (the target's current turn_epoch).");let u=Buffer.byteLength(i.text);if(u>n)return In("message_too_large",`The message is ${u} bytes, above the 1048576-byte limit.`);let s=await e.resolve(i.target,{all_scope:i.all_scope});if("error"===s.kind)return s;let a=s.target,d="routable"===a.liveness?a.endpoint:null;if(null===d&&"refuse"===function(e,t,n,r){return"offline"===e?"steer"===t?{kind:"refuse",reason:"turn_conflict"}:{kind:"queued_offline"}:"steer"===t?"mid_turn"!==e?{kind:"refuse",reason:"not_steerable"}:null===n||null===r||n!==r?{kind:"refuse",reason:"turn_conflict"}:{kind:"admit",deliverAs:"steer",expected_turn_id:n,expect:"steered"}:{kind:"admit",deliverAs:"followUp",expect:"idle"===e?"started":"queued"}}("offline",o,i.expected_turn_id??null,null).kind)return In("turn_conflict","The target has no live turn to steer.",{target:a.durable_id});let c=function(e){if("session"===e.kind)return{principal:`session:${e.durable_id}`,rate_principal:`session:${e.durable_id}`,node:e.durable_id,turn:e.turn_id??null,cause:e.cause_delivery_id??null,actor:e.name??e.durable_id,origin:()=>({session:e.durable_id}),binding:null};if("cli"===e.kind){let t=`cli:${e.uid}`;return{principal:t,rate_principal:t,node:t,turn:null,cause:null,actor:e.user,origin:t=>({external:{platform:"cli",account_id:e.user,chat_id:"@cli",thread_id:"@chat",message_id:t}}),binding:null}}let t=`binding:${e.binding_id}`,n=e.origin.author;return{principal:t,rate_principal:void 0===n?t:`${t}#author:${n.platform_user_id}`,node:t,turn:null,cause:null,actor:e.origin.account_id,origin:()=>({external:e.origin}),binding:{binding_id:e.binding_id,revision:e.binding_revision}}}(i.sender),l=Sn(),f=i.idempotency_key??`auto:${l}`,p=await t.enqueue({now:r(),delivery_id:l,target_durable_id:a.durable_id,sender_principal:c.principal,rate_principal:c.rate_principal,sender_node:c.node,sender_turn:c.turn,cause_delivery_id:c.cause,claimed_root_id:i.root_id??null,origin:c.origin(l),actor:c.actor,body:i.text,mode:o,expected_turn_id:i.expected_turn_id??null,binding:c.binding,receipt:{idempotency_key:f,args_hash:En({target:a.durable_id,text:i.text,mode:o,expected_turn_id:i.expected_turn_id??null,binding:c.binding,author:"external"===i.sender.kind?i.sender.origin.author:void 0})},endpoint_kind:d?.kind??null});if("busy"===p.kind)return In("overloaded","The gateway store is locked by a suspended writer; nothing was sent.",{budget:"store_lock"});if("refused"===p.kind)return In(p.code,p.message,p.details);if("replay"===p.kind){let e=p.result;return"ok"===e.kind?{...e,deduplicated:!0}:e}let m=async e=>(await t.completeReceipt({now:r(),principal:c.principal,idempotency_key:f,result:e}),e);try{if(null===d)return await m(kn(p.row,p.queue_position,null,!1,!0));let n=!0;try{await e.endpoints.wake(d,[l])}catch{n=!1}let r=await t.deliveryView(l);if(null===r)throw Error(`delivery ${l} vanished after commit`);return await m(kn(r.row,r.queue_position,d.kind,!1,!n))}catch(e){throw await t.abandonReceipt({now:r(),principal:c.principal,idempotency_key:f,error_note:e instanceof Error?e.message:String(e)}).catch(()=>!1),e}}}}({store:r,endpoints:o,resolve:async(n,r)=>{let i=await wr(e,n,t);return await On(()=>Ot($r(e,i,n,r.all_scope)),e.callerWorkspaceRoot)(n,r)},now:i}),s=async n=>{let r=(await(async()=>Ot(xr(e,await t())))()).find(e=>e.thread_id===n);return void 0===r||"routable"!==r.liveness?null:r.endpoint};return{store:r,endpoints:o,engine:u,relay:yr({store:r,engine:u,endpoints:o,locate:s,now:i}),locate:s}}var Cr=t(()=>{Rt(),Mn(),vr(),Rr(),Er={wake:async e=>{throw Error(`host_unavailable:${e.socket}`)}}});import{join as Tr}from"node:path";var qr=t(()=>{wn(),Cr(),Rr()});import{existsSync as Nr}from"node:fs";import{dirname as jr,join as Lr}from"node:path";import{fileURLToPath as Br,pathToFileURL as Dr}from"node:url";import{randomUUID as zr}from"node:crypto";import{existsSync as Ur}from"node:fs";import{fileURLToPath as Fr}from"node:url";import{Worker as Wr}from"node:worker_threads";var Gr="gateway-store-worker.mjs";function Kr(e){let t,n,r={agent_dir:e.agentDir,busy_timeout_ms:e._test?.busyTimeoutMs??5e3,lock_wait_max_ms:e._test?.lockWaitMaxMs??3e4,instance_id:e.instanceId??zr(),runtime_instance:e.runtimeInstance??null,legacy_mailbox_directories:e.legacyMailboxDirectories??[],test_hooks:{...void 0===e._test?.beforeDbCommit?{}:{beforeDbCommit:e._test.beforeDbCommit},...void 0===e._test?.afterDbCommit?{}:{afterDbCommit:e._test.afterDbCommit},...void 0===e._test?.announceBarrier?{}:{announceBarrier:e._test.announceBarrier}}},i=e.now??Date.now,o=new Map,u=new Set,s=1,a=!1,d=e.resolveTarget,c=new Map,l=async(t,n)=>(void 0===d&&(await Promise.resolve().then(()=>qr()),d=function(e){let t={host:cn(0,{env:{...process.env,OMO_CODING_AGENT_DIR:e}}),stateDirectory:e,sessionsDirectory:()=>Tr(e,"sessions"),callerSessionId:()=>br,callerWorkspaceRoot:()=>e};return Pr(t,()=>kr(t,{offline:!0}))}(e.agentDir)),await d(t,n));function f(e,t){for(let[n,r]of o)r.worker===e&&(o.delete(n),r.reject(t))}function p(e,n){let r=t;if(void 0===r)return Promise.reject(Error("the gateway store is closed"));let i=s++,u=new Promise((e,t)=>o.set(i,{worker:r,resolve:e,reject:t}));r.ref();try{r.postMessage({type:"request",id:i,op:e,args:n})}catch(e){let t=o.get(i);o.delete(i),0===o.size&&r.unref(),t?.reject(e instanceof Error?e:Error(String(e)))}return u}function m(){if(a)return Promise.reject(Error("the gateway store is disposed"));if(void 0!==n)return n;let s=process.execArgv.filter(e=>!e.startsWith("--input-type")),d=new Wr(function(e=import.meta.url){let t=new URL(`./${Gr}`,e);return Ur(Fr(t))?t:new URL("./store-worker.ts",e)}(e._test?.moduleUrl??e.workerModuleUrl),{execArgv:s});t=d,d.unref(),d.on("message",e=>{if("resolve"===e.type)return void l(e.address,e.request).then(n=>{t===d&&d.postMessage({type:"resolution",id:e.id,ok:!0,value:n})},n=>{t===d&&d.postMessage({type:"resolution",id:e.id,ok:!1,error:n instanceof Error?n.message:String(n)})});if("event"===e.type){for(let t of u)t(e.event);return}let n=o.get(e.id);void 0!==n&&(o.delete(e.id),0===o.size&&d.unref(),e.ok?n.resolve(e.value):n.reject(Object.assign(Error(e.error.message),{workerStack:e.error.stack,...void 0===e.error.code?{}:{code:e.error.code}})))}),d.on("error",e=>f(d,e instanceof Error?e:Error(String(e)))),d.on("exit",e=>{t===d&&(t=void 0,n=void 0),f(d,Error(`the gateway store worker exited (${e})`))}),e._test?.onWorkerStarted?.(d);let m=p("init",{config:r,now:i()}).then(async e=>{for(let[e,t]of c)(await p("extension_register",{extension:t,now:i()})).retained||c.delete(e);return e});return n=m,m.catch(()=>{n===m&&(n=void 0,t===d&&(t=void 0),d.terminate())}),m}async function h(e,t){return await m(),await p(e,t)}function _(e){if(e instanceof Error&&"code"in e&&"gateway_schema_too_new"===e.code)return{kind:"refused",code:"gateway_schema_too_new",message:e.message};throw e}return{registerStoreExtension:async function(e){let t;try{t=await h("extension_register",{extension:e,now:i()})}catch(e){return _(e)}return t.retained&&c.set(e.name,structuredClone(e)),t.result},extensionCall:async(e,t,n)=>{let r;try{r=structuredClone(n)}catch(e){return{kind:"refused",code:"invalid_arguments",message:`Extension arguments are not cloneable: ${e instanceof Error?e.message:String(e)}`}}return await async function(e,t){try{return await h(e,t)}catch(e){return _(e)}}("extension_call",{name:e,op:t,args:r,now:i()})},busyTimeoutMs:r.busy_timeout_ms,now:i,identity:async()=>(await m()).self,enqueue:e=>h("enqueue",e),reconcile:e=>h("reconcile",e),claim:e=>h("claim",e),recordOutcome:e=>h("record_outcome",e),refuseQueued:e=>h("refuse_queued",e),completeReceipt:e=>h("complete_receipt",e),abandonReceipt:e=>h("abandon_receipt",e),deliveryView:e=>h("delivery_view",e),deliveryReceipt:e=>h("delivery_receipt",e),recoverDelivery:e=>h("recover_delivery",e),list:(e={})=>h("list",e),isReferenced:e=>h("is_referenced",e),journalMode:()=>h("journal_mode"),stats:()=>h("stats"),legacyMigrated:async()=>(await m()).legacy_migrated,toolReceiptBegin:e=>h("tool_receipt_begin",e),toolReceiptSettle:e=>h("tool_receipt_settle",e),bind:e=>h("bind",e),unbind:e=>h("unbind",e),rebind:e=>h("rebind",e),listBindings:e=>h("list_bindings",e),bindingView:e=>h("binding_view",e),registerIncarnation:e=>h("register_incarnation",e),clearEndpoint:e=>h("clear_endpoint",e),sessionOwner:e=>h("session_owner",e),report:e=>h("report",e),emitCompletions:e=>h("emit_completions",e),pendingCompletionArms:e=>h("pending_completion_arms",e),latestCompletionArm:e=>h("latest_completion_arm",e),readOutbox:e=>h("read_outbox",e),ackOutbox:e=>h("ack_outbox",e),claimAnswer:e=>h("claim_answer",e),releaseAnswer:e=>h("release_answer",e),confirmAnswer:e=>h("confirm_answer",e),markPriorDelivered:e=>h("mark_prior_delivered",e),onEvent:e=>(u.add(e),()=>u.delete(e)),resume:e=>t?.postMessage({type:"resume",hook:e}),dispose:async()=>{if(a)return;a=!0;let e=t;void 0!==e&&(await p("close",null).catch(()=>{}),t=void 0,await e.terminate())}}}Be(),Nn(),tr();import{randomUUID as Jr}from"node:crypto";import{join as Hr}from"node:path";wn(),Cr(),Rr(),Ye();import{closeSync as Vr,openSync as Zr,readSync as Xr}from"node:fs";import{StringDecoder as Qr}from"node:string_decoder";var Yr={assign:0,create:0,clone:0,discard:0,update:0};function ei(e){let t=0,n=0,r=0;for(;n<e.length;){let i=e.charCodeAt(n++)>>10;t+=+(13879!=(r<<8|i)),r=i}return t}function ti(e){return Array.isArray(e)}function ni(e){return mi(typeof e,"bigint")}function ri(e){return mi(typeof e,"boolean")}function ii(e){if(pi(e)||!oi(e))return!1;let t=Function.prototype.toString.call(e);return!!/^class\s/.test(t)||!!/\[native code\]/.test(t)}function oi(e){return mi(typeof e,"function")}function ui(e){return Number.isInteger(e)}function si(e){return mi(e,null)}function ai(e){return Number.isFinite(e)}function di(e){return ci(e)&&!ti(e)}function ci(e){return mi(typeof e,"object")&&!si(e)}function li(e){return mi(typeof e,"string")}function fi(e){return mi(typeof e,"symbol")}function pi(e){return mi(e,void 0)}function mi(e,t){return e===t}function hi(e,t){return e>t}function _i(e,t){return e<t}function gi(e,t){return e<=t}function yi(e,t){return e>=t}function vi(e){return ni(e)||ri(e)||si(e)||ai(e)||li(e)||pi(e)}function bi(e,t){return function(e,t){return e.length<=t||e.length<=t<<1&&ei(e)<=t}(e,t)}function wi(e,t){return function(e,t){return e.length>=t<<1||e.length>=t&&ei(e)>=t}(e,t)}function ki(e,t,n){return e.every((e,r)=>r<t||n(e,r))}function xi(e,t,n){let r=!0;return e.forEach((e,i)=>{i>=t&&!n(e,i)&&(r=!1)}),r}function $i(e,t){return e.some((e,n)=>t(e,n))}function Ai(e,t){return e.reduce((e,n,r)=>t(n,r)?++e:e,0)}function Si(e,t,n){return mi(e.length,0)?n():t(e[0],e.slice(1))}function Oi(e){return mi(e,"__proto__")||mi(e,"constructor")||mi(e,"prototype")}function Ii(e,t){return Oi(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Ei(e){return Pi(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function Ri(e){return Object.entries(e)}function Pi(e){return Object.getOwnPropertyNames(e)}function Mi(e){return Object.values(e)}function Ci(e,t){return ti(e)?function(e,t){return ti(t)&&mi(e.length,t.length)&&e.every((n,r)=>Ci(e[r],t[r]))}(e,t):ci(e)?function(e,t){if(!ci(t))return!1;let n=Pi(e);return mi(n.length,Pi(t).length)&&n.every(n=>Ci(e[n],t[n]))}(e,t):mi(e,t)}function Ti(e){return globalThis.ArrayBuffer.isView(e)}function qi(e){return e instanceof globalThis.RegExp}var Ni={immutableTypes:!1,maxErrors:8,maxParseErrors:1,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function ji(){return Ni}function Li(e){return ji().immutableTypes?Object.freeze(e):e}function Bi(e,t){return Yr.assign+=1,Li({...e,...t})}function Di(e){let t={};for(let n of Pi(e))Oi(n)||(t[n]=Ui(e[n]));for(let n of function(e){return Object.getOwnPropertySymbols(e)}(e))t[n]=Ui(e[n]);return t}function zi(e){return function(e){if(!ci(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return!si(t)&&mi(typeof t.constructor,"function")&&!(mi(t.constructor,globalThis.Object)||mi(t.constructor.name,"Object"))}(e)?e:function(e){return Ii(e,"~kind")||Ii(e,"~unsafe")}(e)?function(e){let t={};for(let n of Pi(e)){if(Oi(n))continue;let r=Object.getOwnPropertyDescriptor(e,n);r.value=Ui(r.value),mi(r.enumerable,!0)?t[n]=r.value:Object.defineProperty(t,n,r)}return t}(e):Di(e)}function Ui(e){return Ti(e)?function(e){return e.slice()}(e):qi(e)?function(e){return new RegExp(e.source,e.flags)}(e):function(e){return e instanceof globalThis.Map}(e)?function(e){return new Map(Ui([...e.entries()]))}(e):function(e){return e instanceof globalThis.Set}(e)?function(e){return new Set(Ui([...e.values()]))}(e):ti(e)?function(e){return e.map(e=>Ui(e))}(e):ci(e)?zi(e):e}function Fi(e){return Yr.clone+=1,Ui(e)}function Wi(e,t){return{...e,...t}}function Gi(e,t,n={}){Yr.create+=1;let r=Wi(t,n);return Li(ji().enumerableKind?Wi(r,e):function(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}(r,e))}function Ki(e,t){Yr.discard+=1;let n={};for(let r of Pi(e)){if(t.includes(r))continue;let i=Object.getOwnPropertyDescriptor(e,r);i.value=Fi(i.value),Object.defineProperty(n,r,i)}return Li(n)}function Ji(e,t,n){Yr.update+=1;let r=ji(),i=Fi(e);for(let e of Object.keys(t))Object.defineProperty(i,e,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[e]});for(let e of Object.keys(n))Object.defineProperty(i,e,{configurable:!0,enumerable:!0,writable:!0,value:n[e]});return Li(i)}function Hi(e,t){return ci(e)&&Ii(e,"~kind")&&mi(e["~kind"],t)}function Vi(e){return ci(e)}function Zi(e,t,n){return Gi({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function Xi(e){return Hi(e,"Deferred")}function Qi(e,t){return Ji(function(e){return Ji(e,{"~readonly":!0},{})}(e),{},t)}function Yi(e,t){return Ji(function(e){return Ji(e,{"~optional":!0},{})}(e),{},t)}function eo(e,t){return Gi({"~kind":"Array"},{type:"array",items:e},t)}function to(e){return Hi(e,"Array")}function no(e){return Ki(e,["~kind","type","items"])}function ro(e,t,n={}){return Gi({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function io(e){return Hi(e,"Constructor")}function oo(e,t,n={}){return Gi({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function uo(e){return Hi(e,"Function")}function so(e,t){return Gi({"~kind":"Ref"},{$ref:e},t)}function ao(e){return Hi(e,"Ref")}function co(e,t){return Gi({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function lo(e){return Hi(e,"Generic")}function fo(e){return Hi(e,"Any")}var po,mo="(?!)";function ho(e){return Gi({"~kind":"Never"},{not:{}},e)}function _o(e){return Hi(e,"Never")}function go(e,t={}){return Yi(e,t)}function yo(e){return go(e)}function vo(e){return Vi(e)&&Ii(e,"~optional")}function bo(e){return Pi(e)}function wo(e){return Mi(e)}function ko(e,t={}){let n=function(e){return Pi(e).filter(t=>!vo(e[t]))}(e);return Gi({"~kind":"Object"},{type:"object",...n.length>0?{required:n}:{},properties:e},t)}function xo(e){return Hi(e,"Object")}function $o(e){return Gi({"~kind":"Unknown"},{},e)}function Ao(e){return Hi(e,"Unknown")}function So(e,t,n){return Gi({"~kind":"Cyclic"},{$defs:Pi(e).reduce((t,n)=>({...t,[n]:Ji(e[n],{},{$id:n})}),{}),$ref:t},n)}function Oo(e){return Hi(e,"Cyclic")}function Io(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function Eo(e){return Hi(e,"Infer")}function Ro(e){return Hi(e,"Dependent")}function Po(e){return Hi(e,"Enum")}function Mo(e,t={}){return Gi({"~kind":"Intersect"},{allOf:e},t)}function Co(e){return Hi(e,"Intersect")}function To(){throw Error("Unreachable")}!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"}(po||(po={}));var qo=BigInt("14695981039346656037"),[No,jo]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Lo=Array.from({length:256}).map((e,t)=>BigInt(t)),Bo=new Float64Array(1),Do=new DataView(Bo.buffer),zo=new Uint8Array(Bo.buffer);function Uo(e){qo=(qo^=Lo[e])*No%jo}function Fo(e){Uo(po.Boolean),Uo(e?1:0)}function Wo(e){Uo(po.Number),Do.setFloat64(0,e,!0);for(let e of zo)Uo(e)}function Go(e){Uo(po.Object);for(let t of function(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Reflect.ownKeys(n))"constructor"!==e&&"symbol"!=typeof e&&t.add(e);n=Object.getPrototypeOf(n)}return[...t]}(e).sort())Ho(t),Ho(e[t])}var Ko=new TextEncoder;function Jo(e){Uo(po.String);for(let t of Ko.encode(e))Uo(t)}function Ho(e){return Ti(e)?function(e){Uo(po.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e<t.length;e++)Uo(t[e])}(e):function(e){return e instanceof globalThis.Date}(e)?function(e){Uo(po.Date),Ho(e.getTime())}(e):qi(e)?function(e){Uo(po.RegExp),Jo(e.toString())}(e):function(e){return e instanceof Boolean}(e)?Fo(e.valueOf()):function(e){return e instanceof String}(e)?Jo(e.valueOf()):function(e){return e instanceof Number}(e)?Wo(e.valueOf()):function(e){return"number"==typeof e}(e)?Wo(e):ti(e)?function(e){Uo(po.Array);for(let t of e)Ho(t)}(e):ri(e)?Fo(e):ni(e)?function(e){Uo(po.BigInt),Do.setBigInt64(0,e);for(let e of zo)Uo(e)}(e):ii(e)?function(e){Uo(po.Constructor),Ho(e.toString())}(e):si(e)?void Uo(po.Null):ci(e)?Go(e):li(e)?Jo(e):fi(e)?function(e){Uo(po.Symbol),Ho(e.toString())}(e):pi(e)?Uo(po.Undefined):oi(e)?function(e){Uo(po.Function),Ho(e.toString())}(e):To()}function Vo(e){return function(e){return qo=BigInt("14695981039346656037"),Ho(e),qo}(e).toString(16).padStart(16,"0")}var Zo=function(e){switch(e.keyword){case"additionalProperties":return"must not have additional properties";case"anyOf":return"must match a schema in anyOf";case"boolean":return"schema is false";case"const":return"must be equal to constant";case"contains":return"must contain at least 1 valid item";case"dependencies":case"dependentRequired":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"enum":return"must be equal to one of the allowed values";case"exclusiveMaximum":case"exclusiveMinimum":case"maximum":case"minimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"format":return`must match format "${e.params.format}"`;case"if":return`must match "${e.params.failingKeyword}" schema`;case"maxItems":return`must not have more than ${e.params.limit} items`;case"maxLength":return`must not have more than ${e.params.limit} characters`;case"maxProperties":return`must not have more than ${e.params.limit} properties`;case"minItems":return`must not have fewer than ${e.params.limit} items`;case"minLength":return`must not have fewer than ${e.params.limit} characters`;case"minProperties":return`must not have fewer than ${e.params.limit} properties`;case"multipleOf":return`must be multiple of ${e.params.multipleOf}`;case"not":return"must not be valid";case"oneOf":return"must match exactly one schema in oneOf";case"pattern":return`must match pattern "${e.params.pattern}"`;case"propertyNames":return`property names ${e.params.propertyNames.join(", ")} are invalid`;case"required":return`must have required properties ${e.params.requiredProperties.join(", ")}`;case"type":return"string"==typeof e.params.type?`must be ${e.params.type}`:`must be either ${e.params.type.join(" or ")}`;case"unevaluatedItems":return"must not have unevaluated items";case"unevaluatedProperties":return"must not have unevaluated properties";case"uniqueItems":return"must not have duplicate items";case"~refine":return e.params.message;default:return"an unknown validation error occurred"}};function Xo(){return Zo}function Qo(e){return Vi(e)&&Ii(e,"~immutable")}function Yo(e,t={}){return Qi(e,t)}function eu(e){return Vi(e)&&Ii(e,"~readonly")}var tu="-?(?:0|[1-9][0-9]*)n";function nu(e){return Hi(e,"BigInt")}function ru(e){return Gi({"~kind":"Boolean"},{type:"boolean"},e)}function iu(e){return Hi(e,"Boolean")}var ou="-?(?:0|[1-9][0-9]*)";function uu(e){return Gi({"~kind":"Integer"},{type:"integer"},e)}function su(e){return Hi(e,"Integer")}class au extends Error{constructor(e){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:e},writable:!1,configurable:!1,enumerable:!1})}}function du(e){return ni(e)?"bigint":ri(e)?"boolean":ai(e)?"number":li(e)?"string":(()=>{throw new au(e)})()}function cu(e,t){return Gi({"~kind":"Literal"},{type:du(e),const:e},t)}function lu(e){return pu(e)&&ai(e.const)}function fu(e){return pu(e)&&li(e.const)}function pu(e){return Hi(e,"Literal")}function mu(e){return Gi({"~kind":"Null"},{type:"null"},e)}function hu(e){return Hi(e,"Null")}var _u="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function gu(e){return Gi({"~kind":"Number"},{type:"number"},e)}function yu(e){return Hi(e,"Number")}function vu(e){return Hi(e,"Symbol")}var bu=".*";function wu(e){return Gi({"~kind":"String"},{type:"string"},e)}function ku(e){return Hi(e,"String")}function xu(e,t={}){return Gi({"~kind":"Union"},{anyOf:e},t)}function $u(e){return Hi(e,"Union")}function Au(e){let t=ea(e);return mi(t.length,2)?t[0]:[]}function Su(e){return Si(e,(e,t)=>{return!!($u(n=e)?Ou(n.anyOf):pu(n)&&(n.const,1))&&Su(t);var n},()=>!0)}function Ou(e){return!mi(e.length,0)&&Su(e)}function Iu(e){return Ou(e)}function Eu(e){return Gi({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Ru(e,t,n=[]){return Si(e,(e,r)=>Ru(r,t,[...n,`${e}${t}`]),()=>n)}function Pu(e,t){return mi(e.length,0)?[`${t}`]:Ru(e,t)}function Mu(e,t,n=[]){return Si(t,(t,r)=>Mu(e,r,[...n,...Cu(e,t)]),()=>n)}function Cu(e,t){return $u(t)?Mu(e,t.anyOf):pu(t)?Pu(e,t.const):To()}function Tu(e,t){return Si(t,(t,n)=>Tu(Cu(e,t),n),()=>e)}function qu(e){let t=function(e){return e.map(e=>cu(e))}(Tu([],e));return xu(t)}function Nu(e){let t=Au(e);return mi(t.length,0)?wu():Iu(t)?function(e){return mi(e.length,0)?To():mi(e.length,1)&&pu(e[0])?e[0]:qu(e)}(t):Eu(e)}function ju(e,t){return Gi({"~kind":"Record"},{type:"object",patternProperties:{[e]:t}})}function Lu(e,t={}){let[n,r,i]=[e,e.length,!1];return Gi({"~kind":"Tuple"},{type:"array",additionalItems:i,items:n,minItems:r},t)}function Bu(e){return Hi(e,"Tuple")}function Du(e,t){return Ji(function(e){return Ki(e,["~readonly"])}(e),{},t)}function zu(e,t){return Ji(function(e){return Ki(e,["~optional"])}(e),{},t)}function Uu(e,t={}){return zu(e,t)}function Fu(e){return e.reduceRight((e,t,n)=>({[n]:t,...e}),{})}function Wu(e){return xo(e)||Bu(e)}function Gu(e,t){let n=function(e,t){return!!eu(e)&&!!eu(t)}(e,t),r=function(e,t){return!!vo(e)&&!!vo(t)}(e,t),i=function(e,t={}){return Du(e,t)}(Uu(os([e,t])));return n&&r?Yo(go(i)):n&&!r?Yo(i):!n&&r?go(i):i}function Ku(e,t,n){return n in e?n in t?Gu(e[n],t[n]):e[n]:n in t?t[n]:ho()}function Ju(e){return xo(e)?e.properties:Bu(e)?Fu(e.items):{}}function Hu(e,t){let n=function(e,t){return[...new Set([...Pi(e),...Pi(t)])].reduce((n,r)=>({...n,[r]:Ku(e,t,r)}),{})}(Ju(e),Ju(t));return ko(n)}function Vu(e,t){let n=Wu(e),r=Wu(t);return n&&r?Hu(e,t):n&&!r?e:!n&&r?t:function(e,t){let n=pd(e,t);return mi(n,ld)?e:mi(n,fd)||mi(n,dd)?t:ho()}(e,t)}function Zu(e,t){let n=as(e),r=as(t);return function(e,t){return $u(e)||$u(t)}(n,r)?os([n,r]):function(e,t){return _o(e)||fo(e)?e:Ao(e)||_o(t)||fo(t)?t:Ao(t)?e:Vu(e,t)}(n,r)}function Xu(e,t,n=[]){return Si(t,(t,r)=>Xu(e,r,[...n,Zu(t,e)]),()=>mi(n.length,0)?[e]:n)}function Qu(e,t,n=[]){return Si(e,(e,r)=>Qu(r,t,[...n,...Yu([e],t)]),()=>n)}function Yu(e,t=[]){return Si(e,(e,n)=>$u(e)?Yu(n,Qu(e.anyOf,t)):Yu(n,Xu(e,t)),()=>t)}function es(e,t){return fa(ad({},e,t))?[]:[e]}function ts(e,t,n=[]){return Si(e,(e,r)=>ts(r,t,[...n,...es(e,t)]),()=>n)}function ns(e,t){let n=as(e);return ss(ts($u(n)?n.anyOf:[n],t))}function rs(e,t,n){return ss([os([e,t]),ns(n,e)])}function is(e,t=[]){return Si(e,(e,n)=>is(n,[...t,cu(e)]),()=>ss(t))}function os(e){return ss(gd(Yu(e)))}function us(e){let t=function(e){let t=Nu(e);return ua(t)?wu():t}(e);return as(t)}function ss(e){return ds(gd(e))}function as(e){return Ro(e)?rs(e.if,e.then,e.else):Po(e)?is(e.enum):Co(e)?os(e.allOf):ua(e)?us(e.pattern):$u(e)?ss(e.anyOf):e}function ds(e){return mi(e.length,1)?e[0]:mi(e.length,0)?ho():xu(e)}function cs(e,t=[]){return Si(e,(e,n)=>{return cs(n,[...t,...(r=e,$u(r)?cs(r.anyOf):[r])]);var r},()=>t)}function ls(e,t){return mi(function(e){return e.some(e=>ku(e)||yu(e)||su(e))}(e),!0)?ju(gs,t):void 0}function fs(e,t){let n=function(e,t){return e.reduce((e,n)=>pu(n)&&(li(n.const)||ai(n.const))?{...e,[n.const]:t}:e,{})}(e,t);return ko(n)}function ps(e,t){return fo(e)?function(e){return ju(gs,e)}(t):iu(e)?function(e){return ko({true:e,false:e})}(t):Po(e)?function(e,t){return ps(is(e),t)}(e.enum,t):su(e)?function(e,t){return ju(hs,t)}(0,t):Co(e)?function(e,t){return ps(os(e),t)}(e.allOf,t):pu(e)?function(e,t){return li(e)||ai(e)?ko({[e]:t}):mi(e,!1)?ko({false:t}):mi(e,!0)?ko({true:t}):ko({})}(e.const,t):yu(e)?function(e,t){return ju(_s,t)}(0,t):$u(e)?function(e,t){let n=cs(e),r=ls(n,t);return Vi(r)?r:fs(n,t)}(e.anyOf,t):ku(e)?function(e,t){return Ii(e,"pattern")&&(li(e.pattern)||e.pattern instanceof RegExp)?ju(e.pattern.toString(),t):ju(gs,t)}(e,t):ua(e)?function(e,t){return Iu(Au(e))?ps(us(e),t):ju(e,t)}(e.pattern,t):ko({})}function ms(e,t,n){return Qc([e])?Ji(ps(e,t),{},n):function(e,t,n={}){return Zi("Record",[e,t],n)}(e,t,n)}var hs=`^${ou}$`,_s=`^${_u}$`,gs=`^${bu}$`;function ys(e,t,n={}){return ms(e,t,n)}function vs(e){return mi(e,gs)?wu():mi(e,hs)?uu():mi(e,_s)?gu():Nu(e)}function bs(e){return Pi(e.patternProperties)[0]}function ws(e){return vs(bs(e))}function ks(e){return e.patternProperties[bs(e)]}function xs(e){return Hi(e,"Record")}function $s(e){return Hi(e,"Rest")}function As(e){return Hi(e,"Undefined")}function Ss(e){return Hi(e,"Void")}function Os(e){return Gi({"~kind":"BigInt"},{type:"bigint"},t);var t}function Is(e){return cu(e)}function Es(e){return xu(e[1])}function Rs(e){return 3===e.length?[...e[0],...e[2]]:1===e.length?[...e[0]]:[]}function Ps(e){return[e[0],...e[1]]}function Ms(e){return e[1]}function Cs(e){return mi(e.length,2)}function Ts(e,t,n){return Cs(e)?t(e[0],e[1]):n()}function qs(e,t){return mi(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function Ns(e,t){return Array.from({length:t-e+1},(t,n)=>String.fromCharCode(e+n))}var js=[...Ns(97,122),...Ns(65,90)],Ls=["0",...Ns(49,57)];function Bs(e){let t=e.indexOf("*/");return mi(t,-1)?"":e.slice(t+2)}function Ds(e){let t=e.indexOf("\n");return mi(t,-1)?"":e.slice(t)}function zs(e){let t=function(e){return e.replace(/^[ \t\r\f\v]+/,"")}(e);return t.startsWith("/*")?zs(Bs(t.slice(2))):t.startsWith("//")?zs(Ds(t.slice(2))):t}function Us(e){let t=e.trimStart();return t.startsWith("/*")?Us(Bs(t.slice(2))):t.startsWith("//")?Us(Ds(t.slice(2))):t}function Fs(e,t){return function(e,t){for(let n=0;n<e.length;n++){let r=qs(e[n],t);if(Cs(r))return r}return[]}([e],t)}function Ws(e,t){return mi(e,"")?["",t]:e.startsWith("\n")?Fs(e,zs(t)):e.startsWith(" ")?Fs(e,t):Fs(e,Us(t))}function Gs(e,t){return Si(e,(e,n)=>!!t.startsWith(e)||Gs(n,t),()=>!1)}function Ks(e,t,n=""){return Ts(function(e){return mi(e,"")?[]:[e.slice(0,1),e.slice(1)]}(t),(r,i)=>Gs(e,t)?[n,t]:Ks(e,i,`${n}${r}`),()=>[])}var Js=(e,t,n=()=>[])=>2===e.length?t(e):n(),Hs=e=>Js(function(e,t){return Ts(Ks(e,t),(e,t)=>mi(e,"")?[]:[e,t],()=>[])}(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([e,t])=>[Is(e),t]),Vs=e=>Js(Js((e=>Js(Ws("-?(?:0|[1-9][0-9]*)n",e),([e,t])=>[Os(),t]))(e),([e,t])=>[e,t],()=>Js((e=>Js(Ws(".*",e),([e,t])=>[wu(),t]))(e),([e,t])=>[e,t],()=>Js((e=>Js(Ws("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([e,t])=>[gu(),t]))(e),([e,t])=>[e,t],()=>Js((e=>Js(Ws("-?(?:0|[1-9][0-9]*)",e),([e,t])=>[uu(),t]))(e),([e,t])=>[e,t],()=>Js((e=>Js(Ws("(?!)",e),([e,t])=>[ho(),t]))(e),([e,t])=>[e,t],()=>Js(Zs(e),([e,t])=>[e,t],()=>Js(Hs(e),([e,t])=>[e,t],()=>[]))))))),([e,t])=>[e,t]),Zs=e=>Js(Js(Ws("(",e),([e,t])=>Js(Ys(t),([t,n])=>Js(Ws(")",n),([n,r])=>[[e,t,n],r]))),([e,t])=>[Es(e),t]),Xs=e=>Js(Js(Js(Qs(e),([e,t])=>Js(Ws("|",t),([t,n])=>Js(Xs(n),([n,r])=>[[e,t,n],r]))),([e,t])=>[e,t],()=>Js(Js(Qs(e),([e,t])=>[[e],t]),([e,t])=>[e,t],()=>Js([[],e],([e,t])=>[e,t],()=>[]))),([e,t])=>[Rs(e),t]),Qs=e=>Js(Js(Vs(e),([e,t])=>Js(Ys(t),([t,n])=>[[e,t],n])),([e,t])=>[Ps(e),t]),Ys=e=>Js(Js(Xs(e),([e,t])=>[e,t],()=>Js(Qs(e),([e,t])=>[e,t],()=>[])),([e,t])=>[e,t]),ea=e=>Js(Js(Ws("^",e),([e,t])=>Js(Ys(t),([t,n])=>Js(Ws("$",n),([n,r])=>[[e,t,n],r]))),([e,t])=>[Ms(e),t]);function ta(e,t,n,r=[]){return Si(e,(e,i)=>ta(i,t,n,[...r,na(e,[],"")]),()=>{return ra(t,`${n}(${e=r,e.join("|")})`);var e})}function na(e,t,n){return Po(e)?function(e,t,n){return na(is(e),t,n)}(e.enum,t,n):su(e)?function(e,t){return ra(e,`${t}${ou}`)}(t,n):pu(e)?function(e,t,n){return ra(t,`${n}${e}`)}(e.const,t,n):nu(e)?function(e,t){return ra(e,`${t}${tu}`)}(t,n):iu(e)?function(e,t){return na(xu([cu("false"),cu("true")]),e,t)}(t,n):yu(e)?function(e,t){return ra(e,`${t}${_u}`)}(t,n):ku(e)?function(e,t){return ra(e,`${t}${bu}`)}(t,n):ua(e)?function(e,t,n){return ra(t,`${n}${function(e){return e.slice(1,e.length-1)}(e)}`)}(e.pattern,t,n):Vi(r=e)&&Ii(r,"action")&&mi(r.action,"TemplateLiteral")?function(e,t,n){return na(oa(e,{}),t,n)}(e.parameters[0],t,n):$u(e)?ta(e.anyOf,t,n):mo;var r}function ra(e,t){return Si(e,(e,n)=>na(e,n,t),()=>t)}function ia(e){let t=function(e){return`^${ra(e,"")}$`}(e);return Eu(t)}function oa(e,t){return Qc(e)?Ji(ia(e),{},t):function(e,t={}){return Zi("TemplateLiteral",[e],t)}(e,t)}function ua(e){return Hi(e,"TemplateLiteral")}function sa(e){return ci(e)&&Ii(e,"~kind")&&Ii(e,"inferred")&&mi(e["~kind"],"ExtendsUnion")&&ci(e.inferred)}function aa(e){return Gi({"~kind":"ExtendsTrue"},{inferred:e})}function da(e){return ci(e)&&Ii(e,"~kind")&&Ii(e,"inferred")&&mi(e["~kind"],"ExtendsTrue")&&ci(e.inferred)}function ca(){return Gi({"~kind":"ExtendsFalse"},{})}function la(e){return ci(e)&&Ii(e,"~kind")&&mi(e["~kind"],"ExtendsFalse")}function fa(e){return sa(e)||da(e)}function pa(e,t,n){return fa(e)?t(e.inferred):n()}function ma(e,t,n){return Si(n,(n,r)=>pa(Fa(e,t,n),e=>ma(e,t,r),()=>ca()),()=>aa(e))}function ha(e,t,n){return Si(n,(n,r)=>pa(Fa(e,t,n),e=>aa(e),()=>ha(e,t,r)),()=>ca())}function _a(e,t,n){return fo(n)?function(e){return aa(e)}(e):Ro(n)?function(e,t,n,r,i){return pa(Fa(e,t,n),e=>pa(Fa(e,t,r),e=>aa(e),()=>ca()),()=>pa(Fa(e,t,i),e=>aa(e),()=>ca()))}(e,t,n.if,n.then,n.else):Po(n)?function(e,t,n){return Fa(e,t,is(n))}(e,t,n.enum):Eo(n)?function(e,t,n,r){return pa(Fa(e,n,r),r=>aa(Bi(Bi(e,r),{[t]:n})),()=>ca())}(e,n.name,t,n.extends):Co(n)?ma(e,t,n.allOf):ua(n)?function(e,t,n){return Fa(e,t,us(n))}(e,t,n.pattern):$u(n)?ha(e,t,n.anyOf):Ao(n)?aa(e):ca()}function ga(e,t,n){return Eo(n)?_a(e,t,n):fo(n)||Ao(n)?aa(e):function(e){return Gi({"~kind":"ExtendsUnion"},{inferred:e})}(e)}function ya(e,t,n,r){return to(r)?function(e,t){let n=Qo(e),r=Qo(t);return!(!n||!r)||!(n||!r)||!(n&&!r)}(t,r)?Fa(e,n,r.items):ca():_a(e,t,r)}function va(e,t,n,r){return Si(r,(r,i)=>function(e,t,n,r,i){let o=Eo(r)?t:r,u=Eo(r)?r:t,s=vo(t),a=vo(r);return!s&&a?ca():pa(Fa(e,o,u),e=>ba(e,n,i),()=>ca())}(e,t,n,r,i),()=>vo(t)?aa(e):ca())}function ba(e,t,n){return function(e,t,n){return Si(t,(t,r)=>va(e,t,r,n),()=>aa(e))}(e,t,n)}function wa(e,t,n){return Ss(n)?aa(e):Fa(e,t,n)}function ka(e,t,n){return t===n?aa(e):ca()}function xa(e,t,n){return ni(t.const)?function(e,t,n){return pu(n)?ka(e,t,n.const):nu(n)?aa(e):_a(e,cu(t),n)}(e,t.const,n):ri(t.const)?function(e,t,n){return pu(n)?ka(e,t,n.const):iu(n)?aa(e):_a(e,cu(t),n)}(e,t.const,n):ai(t.const)?function(e,t,n){return pu(n)?ka(e,t,n.const):yu(n)?aa(e):_a(e,cu(t),n)}(e,t.const,n):li(t.const)?function(e,t,n){return pu(n)?ka(e,t,n.const):ku(n)?aa(e):_a(e,cu(t),n)}(e,t.const,n):To()}function $a(e,t,n){return Eo(n)&&_o(n.extends)?ca():pa(Fa(e,t,n),e=>function(e,t,n){return vo(t)?vo(n)?aa(e):ca():aa(e)}(e,t,n),()=>ca())}function Aa(e,t,n){let r={};for(let i of Pi(n))r[i]=i in t?$a({},t[i],n[i]):vo(n[i])?Eo(n[i])?aa(Bi(e,{[n[i].name]:n[i].extends})):aa(e):ca();let i=Mi(r).every(e=>fa(e)),o=i?function(e,t){return e.reduce((e,n)=>n in t&&fa(t[n])?{...e,...t[n].inferred}:To(),{})}(Pi(r),r):{};return i?aa(o):ca()}function Sa(e,t,n){return function(e,t,n){let r=Aa(e,t,n);return fa(r)?aa(Bi(e,r.inferred)):ca()}(e,t,n)}function Oa(e,t,n,r){return Si(t,(t,i)=>pa(Fa({},e[t],n),t=>Oa(e,i,n,function(e,t){return Pi(t).reduce((n,r)=>({...n,[r]:Ii(e,r)?$u(n[r])?xu([...n[r].anyOf,t[r]]):xu([e[r],t[r]]):t[r]}),e)}(r,t)),()=>ca()),()=>aa(r))}function Ia(e,t,n){return xs(n)?function(e,t,n,r){return Oa(t,Pi(t),r,e)}(e,t,bs(n),ks(n)):xo(n)?Sa(e,t,n.properties):_a(e,ko(t),n)}function Ea(e,t,n,r){return xs(r)?function(e,t,n,r,i){return Fa(e,n,i)}(e,vs(t),n,vs(bs(r)),ks(r)):xo(r)?function(e,t){return mi(Pi(t).length,0)?aa(e):ca()}(e,r.properties):fo(r)||Ao(r)?aa(e):ca()}function Ra(e,t){return Gi({"~kind":"Inferrable"},{name:e,type:t},{})}function Pa(e){return ci(e)&&Ii(e,"~kind")&&Ii(e,"name")&&Ii(e,"type")&&mi(e["~kind"],"Inferrable")&&li(e.name)&&ci(e.type)}function Ma(e){return $s(e)?Eo(e.items)?to(e.items.extends)?Ra(e.items.name,e.items.extends.items):Ao(e.items.extends)?Ra(e.items.name,e.items.extends):void 0:To():void 0}function Ca(e){return Eo(e)?Ra(e.name,e.extends):void 0}function Ta(e,t){let n=[];for(let r of e){if(!fa(Fa({},r,t)))return;n.push(r)}return n}function qa(e,t,n,r){let i=Ta(n,r);return ti(i)?aa(Bi(e,{[t]:xu(i)})):ca()}function Na(e,t){return t?function(e){return[...e].reverse()}(e):e}function ja(e,t,n,r,i){let o=Ma(r);return Pa(o)?function(e,t,n,r){let i=Ta(n,r);return ti(i)?aa(Bi(e,{[t]:Lu(i)})):ca()}(e,o.name,Na(n,t),o.type):Si(n,(n,o)=>function(e,t,n,r,i,o){return pa(Fa(e,n,i),e=>La(e,t,r,o),()=>ca())}(e,t,n,o,r,i),()=>ca())}function La(e,t,n,r){return function(e,t,n,r){return Si(r,(r,i)=>ja(e,t,n,r,i),()=>mi(n.length,0)?aa(e):ca())}(e,t,n,r)}function Ba(e,t,n){let r=el(e,Xc([],[]),n),i=function(e){let t=e.length>0?e[0]:void 0,n=Vi(t)?Ma(t):void 0;return Vi(n)}(r);return La(e,i,Na(t,i),Na(r,i))}function Da(e,t,n){let r=Ca(n);return Pa(r)?qa(e,r.name,t,r.type):function(e,t,n){for(let r of t){let t=Fa(e,r,n);if(!fa(t))return t;e=t.inferred}return aa(e)}(e,t,n)}function za(e,t,n){return Si(n,(n,r)=>pa(Fa(e,t,n),e=>aa(e),()=>za(e,t,r)),()=>ca())}function Ua(e,t,n){return Si(t,(t,r)=>pa(za(e,t,n),e=>Ua(e,r,n),()=>ca()),()=>aa(e))}function Fa(e,t,n){return fo(t)?ga(e,t,n):to(t)?ya(e,t,t.items,n):nu(t)?function(e,t,n){return nu(n)?aa(e):_a(e,t,n)}(e,t,n):iu(t)?function(e,t,n){return iu(n)?aa(e):_a(e,t,n)}(e,t,n):io(t)?function(e,t,n,r){return fo(r)||Ao(r)?aa(e):io(r)?pa(ba(e,t,r.parameters),e=>wa(e,n,r.instanceType),()=>ca()):ca()}(e,t.parameters,t.instanceType,n):Ro(t)?function(e,t,n,r,i){return pa(Fa(e,t,i),()=>Fa(e,n,i),()=>Fa(e,r,i))}(e,t.if,t.then,t.else,n):Po(t)?function(e,t,n){return Fa(e,is(t),n)}(e,t.enum,n):uo(t)?function(e,t,n,r){return fo(r)||Ao(r)?aa(e):uo(r)?pa(ba(e,t,r.parameters),e=>wa(e,n,r.returnType),()=>ca()):ca()}(e,t.parameters,t.returnType,n):su(t)?function(e,t,n){return su(n)||yu(n)?aa(e):_a(e,t,n)}(e,t,n):Co(t)?function(e,t,n){return Fa(e,os(t),n)}(e,t.allOf,n):pu(t)?xa(e,t,n):_o(t)?function(e,t,n){return Eo(n)?_a(e,t,n):aa(e)}(e,t,n):hu(t)?function(e,t,n){return hu(n)?aa(e):_a(e,t,n)}(e,t,n):yu(t)?function(e,t,n){return yu(n)?aa(e):_a(e,t,n)}(e,t,n):xo(t)?Ia(e,t.properties,n):xs(t)?Ea(e,bs(t),ks(t),n):ku(t)?function(e,t,n){return ku(n)?aa(e):_a(e,t,n)}(e,t,n):vu(t)?function(e,t,n){return vu(n)?aa(e):_a(e,t,n)}(e,t,n):ua(t)?function(e,t,n){return Fa(e,us(t),n)}(e,t.pattern,n):Bu(t)?function(e,t,n){let r=el(e,Xc([],[]),t);return Bu(n)?Ba(e,r,n.items):to(n)?Da(e,r,n.items):_a(e,Lu(r),n)}(e,t.items,n):As(t)?function(e,t,n){return Ss(n)||As(n)?aa(e):_a(e,t,n)}(e,t,n):$u(t)?function(e,t,n){let r=Ca(n);return Pa(r)?qa(e,r.name,t,r.type):$u(n)?Ua(e,t,n.anyOf):Ua(e,t,[n])}(e,t.anyOf,n):Ao(t)?function(e,t,n){return Eo(n)?_a(e,t,n):fo(n)||Ao(n)?aa(e):ca()}(e,t,n):Ss(t)?function(e,t,n){return Ss(n)?aa(e):_a(e,t,n)}(e,t,n):ca()}function Wa(e,t,n){return Qc(e)?Ji(function(e,t){return os([...e,ko(t)])}(e,t),{},n):function(e,t,n={}){return Zi("Interface",[e,t],n)}(e,t,n)}function Ga(e){return Vi(e)&&Ii(e,"action")&&mi(e.action,"Interface")}function Ka(e,t,n){return Ja(e,t,wo(n))}function Ja(e,t,n){return Si(n,(n,r)=>!!Ha(e,t,n)||Ja(e,t,r),()=>!1)}function Ha(e,t,n){return ao(n)?function(e,t,n){return!!e.includes(n)||Ha([...e,n],t,t[n])}(e,t,n.$ref):to(n)?Ha(e,t,n.items):io(n)?Ja(e,t,[...n.parameters,n.instanceType]):uo(n)?Ja(e,t,[...n.parameters,n.returnType]):Ga(n)?Ka(e,t,n.parameters[1]):Co(n)?Ja(e,t,n.allOf):xo(n)?Ka(e,t,n.properties):$u(n)?Ja(e,t,n.anyOf):Bu(n)?Ja(e,t,n.items):!!xs(n)&&Ha(e,t,ks(n))}function Va(e,t){return t.reduce((t,n)=>function(e,t,n){return Ha(e,t,n)}([n],e,e[n])?[...t,n]:t,[])}function Za(e,t,n){return Xa(e,wo(t),n)}function Xa(e,t,n){return t.reduce((t,n)=>Qa(e,n,t),n)}function Qa(e,t,n){return ao(t)?function(e,t,n){return n.includes(t)?n:t in e?Qa(e,e[t],[...n,t]):To()}(e,t.$ref,n):to(t)?Qa(e,t.items,n):io(t)?Xa(e,[...t.parameters,t.instanceType],n):uo(t)?Xa(e,[...t.parameters,t.returnType],n):Ga(t)?Za(e,t.parameters[1],n):Co(t)?Xa(e,t.allOf,n):xo(t)?Za(e,t.properties,n):$u(t)?Xa(e,t.anyOf,n):Bu(t)?Xa(e,t.items,n):xs(t)?Qa(e,ks(t),n):n}function Ya(e){return Gi({"~kind":"Any"},{},t);var t}function ed(e){return e.reduce((e,t)=>[...e,td(t)],[])}function td(e){return ao(e)?Ya(e.$ref):to(e)?eo(td(e.items),no(e)):io(e)?ro(ed(e.parameters),td(e.instanceType)):uo(e)?oo(ed(e.parameters),td(e.returnType)):Co(e)?Mo(ed(e.allOf)):xo(e)?ko(Pi(t=e.properties).reduce((e,n)=>({...e,[n]:td(t[n])}),{})):xs(e)?ys(ws(e),td(ks(e))):$u(e)?xu(ed(e.anyOf)):Bu(e)?Lu(ed(e.items)):e;var t}function nd(e){return t=e.$defs,(n=e.$ref)in t?td(t[n]):$o();var t,n}function rd(e,t){return Pi(e).filter(e=>t.includes(e)).reduce((t,n)=>{let r=e[n],i=Ga(r)?function(e,t,n){return os([...tl(e,Xc([],[]),t),ko(Yc({},Xc([],[]),n))])}(e,r.parameters[0],r.parameters[1]):r;return{...t,[n]:i}},{})}function id(e,t,n){let r=function(e,t,n){return Qa(e,n,[t])}(e,t,n);return So(rd(e,r),t)}function od(e,t){return t in e?ao(e[t])?od(e,e[t].$ref):e[t]:ho()}function ud(e,t){return od(e,t)}function sd(e){return Oo(e)?nd(e):di(t=e)&&Ii(t,"~unsafe")&&si(t["~unsafe"])?$o():e;var t}function ad(e,t,n){return Fa(e,sd(t),sd(n))}var dd=0,cd=1,ld=2,fd=3;function pd(e,t){let n=[ad({},e,t),ad({},t,e)];return fa(n[0])&&fa(n[1])?dd:fa(n[0])&&la(n[1])?ld:la(n[0])&&fa(n[1])?fd:cd}function md(e,t,n=[],r=t){return Si(t,(t,i)=>{let o=pd(e,t);return mi(o,ld)||mi(o,dd)?r:mi(o,cd)?md(e,i,[...n,t],r):md(e,i,n,r)},()=>[...n,e])}function hd(e,t,n){let r=as(e);return fo(r)||Ao(r)?[r]:_o(r)?_d(t,n):xo(r)?_d(t,[...n,r]):_d(t,md(r,n))}function _d(e,t=[]){return Si(e,(e,n)=>hd(e,n,t),()=>t)}function gd(e){return cs(_d(e))}function yd(e,t){return Ji(as(e),{},t)}function vd(e,t=[]){return Xi(e)&&mi(e.action,"Conditional")?ao(e.parameters[0])?vd(e.parameters[2],vd(e.parameters[3],[...t,e.parameters[0].$ref])):vd(e.parameters[2],vd(e.parameters[3],t)):Xi(e)&&mi(e.action,"Mapped")&&Xi(e.parameters[1])&&mi(e.parameters[1].action,"KeyOf")&&ao(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function bd(e,t,n=[]){return Si(e,(e,r)=>Si(t,(t,i)=>bd(r,i,[...n,[t,e]]),()=>n),()=>n)}function wd(e){let t=function(e){return ua(e)?us(e.pattern):Po(e)?is(e.enum):e}(e);return $u(t)?[...t.anyOf]:[t]}function kd(e,t){return e.reduce((e,n)=>[...e,[...n,t]],[])}function xd(e,t){return t.reduce((t,n)=>[...t,...kd(e,n)],[])}function $d(e){return e.reduce((e,t)=>mi(t[0],!0)?xd(e,wd(t[1])):xd(e,[t[1]]),[[]])}function Ad(e,t,n){let r=function(e,t){return e.reduce((e,n)=>[...e,t.includes(n.name)],[])}(e,vd(n)),i=bd(t,r);return Xi(n)&&mi(n.action,"Conditional")||Xi(n)&&mi(n.action,"Mapped")?$d(i):[t]}function Sd(e,t,n){return t in e?Od(e,t,e[t],n):["(not-resolvable)",ho()]}function Od(e,t,n,r){return lo(n)?function(e,t,n){return[e,co(t,n)]}(t,n.parameters,n.expression):ao(n)?Sd(e,n.$ref,r):["(not-generic)",ho()]}function Id(e,t,n,r,i){let o=il(e,t,i);return function(e,t,n){if(Eo(t)||Ld(t)||fa(ad({},t,n)))return;throw Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:{parameter:e,expect:n,actual:t}})}(n,o,r),Bi(e,{[n]:o})}function Ed(e,t,n,r){return Si(n,(n,i)=>function(e,t,n,r,i){let o=il(e,t,n.extends),u=il(e,t,n.equals);return Si(i,(i,u)=>Ed(Id(e,t,n.name,o,i),t,r,u),()=>Ed(Id(e,t,n.name,o,u),t,r,[]))}(e,t,n,i,r),()=>e)}var Rd=0,Pd=0;function Md(){(function(){if(!_i(Pd,ji().maxInstantiationCount))throw Error("Type instantiation is excessively deep and possibly infinite")})(),Pd++,Rd++}function Cd(e,t){return mi(function(e){return hi(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}(e),t)}function Td(e,t,n,r,i,o){Md();try{let u=function(e,t,n,r){return Ed(e,t,n,r)}(e,t,r,o),s=il(u,Xc([...t.callstack,n.$ref],t.visited),i);return il(u,Xc([],[]),s)}finally{mi(--Rd,0)&&(Pd=0)}}function qd(e,t,n,r,i,o){let u=function(e,t,n,r,i,o){return o.reduce((o,u)=>[...o,Td(e,t,n,r,i,u)],[])}(e,t,n,r,i,Ad(r,o,i));return mi(u.length,1)?u[0]:ss(u)}function Nd(e,t,n,r){let i=tl(e,t,r),o=function(e,t,n){return Od(e,"(anonymous)",t,n)}(e,n,r),u=o[0],s=o[1];return lo(s)?Cd(t,u)?jd(so(u),i):qd(e,t,so(u),s.parameters,s.expression,i):jd(n,i)}function jd(e,t){return Gi({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function Ld(e){return Hi(e,"Call")}function Bd(e,t){return Ji(function(e){return Ki(e,["~immutable"])}(e),{},t)}function Dd(e,t){return pu(t)?function(e,t){return li(t)?cu(function(e,t){return e(t)}(e,t)):cu(t)}(e,t.const):ua(t)?function(e,t){return Dd(e,us(t))}(e,t.pattern):$u(t)?function(e,t){return xu(t.map(t=>Dd(e,t)))}(e,t.anyOf):t}var zd=e=>e[0].toUpperCase()+e.slice(1),Ud=e=>e.toLowerCase(),Fd=e=>e[0].toLowerCase()+e.slice(1),Wd=e=>e.toUpperCase();function Gd(e,t){return Qc([e])?Ji(Dd(zd,e),{},t):function(e,t={}){return Zi("Capitalize",[e],t)}(e,t)}function Kd(e,t){return Qc([e])?Ji(Dd(Ud,e),{},t):function(e,t={}){return Zi("Lowercase",[e],t)}(e,t)}function Jd(e,t){return Qc([e])?Ji(Dd(Fd,e),{},t):function(e,t={}){return Zi("Uncapitalize",[e],t)}(e,t)}function Hd(e,t){return Qc([e])?Ji(Dd(Wd,e),{},t):function(e,t={}){return Zi("Uppercase",[e],t)}(e,t)}function Vd(e,t,n,r,i,o,u){return Qc([n,r])?Ji(function(e,t,n,r,i,o){let u=ad(e,n,r);return sa(u)?xu([il(u.inferred,t,i),il(e,t,o)]):da(u)?il(u.inferred,t,i):il(e,t,o)}(e,t,n,r,i,o),{},u):function(e,t,n,r,i={}){return Zi("Conditional",[e,t,n,r],i)}(n,r,i,o,u)}function Zd(e,t){return Qc([e])?Ji(function(e){let t=io(e)?e.parameters:[];return Lu(el({},Xc([],[]),t))}(e),{},t):function(e,t={}){return Zi("ConstructorParameters",[e],t)}(e,t)}function Xd(e,t,n){return Qc([e,t])?Ji(ns(e,t),{},n):function(e,t,n={}){return Zi("Exclude",[e,t],n)}(e,t,n)}function Qd(e,t){return fa(ad({},e,t))?[e]:[]}function Yd(e,t,n=[]){return Si(e,(e,r)=>Yd(r,t,[...n,...Qd(e,t)]),()=>n)}function ec(e,t){let n=as(e);return ss(Yd($u(n)?n.anyOf:[n],t))}function tc(e,t,n){return Qc([e,t])?Ji(ec(e,t),{},n):function(e,t,n={}){return Zi("Extract",[e,t],n)}(e,t,n)}function nc(e){return e.reduce((e,t)=>function(e,t){let n=Pi(e).filter(e=>!Ii(t,e)),r=Pi(t).filter(t=>!Ii(e,t)),i=Pi(e).filter(e=>Ii(t,e)),o=n.reduce((t,n)=>({...t,[n]:e[n]}),{}),u=r.reduce((e,n)=>({...e,[n]:t[n]}),{}),s=i.reduce((n,r)=>({...n,[r]:os([e[r],t[r]])}),{}),a=Bi(o,u);return Bi(a,s)}(e,oc(t)),{})}function rc(e){return oc(ko(Fu(Lu(e).items)))}function ic(e,t){return Si(e,(e,n)=>ic(n,function(e,t){return Pi(e).filter(e=>e in t).reduce((n,r)=>({...n,[r]:ss([e[r],t[r]])}),{})}(t,oc(e))),()=>t)}function oc(e){return Oo(e)?(i=e.$defs,o=e.$ref,oc(ud(i,o))):Ro(e)?(t=e.if,n=e.then,r=e.else,oc(rs(t,n,r))):Co(e)?nc(e.allOf):$u(e)?Si(e.anyOf,(e,t)=>ic(t,oc(e)),()=>To()):Bu(e)?rc(e.items):xo(e)?e.properties:{};var t,n,r,i,o}function uc(e){return ko(oc(e))}var sc=new RegExp("^(?:0|[1-9][0-9]*)$");function ac(e){let t=`${e}`;return sc.test(t)?parseInt(t):e}function dc(e){return e.map(e=>cc(e))}function cc(e){return Co(e)?Mo(dc(e.allOf)):$u(e)?xu(dc(e.anyOf)):pu(e)?cu(ac(e.const)):e}function lc(e){return Oo(e)?(i=e.$defs,o=e.$ref,lc(ud(i,o))):Ro(e)?(t=e.if,n=e.then,r=e.else,lc(rs(t,n,r))):Po(e)?lc(is(e.enum)):Co(e)?lc(os(e.allOf)):pu(e)?[`${e.const}`]:ua(e)?lc(us(e.pattern)):$u(e)?function(e){return e.reduce((e,t)=>[...e,...lc(t)],[])}(e.anyOf):[];var t,n,r,i,o}function fc(e){return lc(e)}function pc(e,t){return t.map(t=>mc(e,t))}function mc(e,t){return to(t)?eo(mc(e,t.items)):io(t)?ro(pc(e,t.parameters),mc(e,t.instanceType)):uo(t)?oo(pc(e,t.parameters),mc(e,t.returnType)):Bu(t)?Lu(pc(e,t.items)):$u(t)?xu(pc(e,t.anyOf)):Co(t)?Mo(pc(e,t.allOf)):Hi(t,"This")?ko(e):t}function hc(e,t){return function(e,t){return mc(e,t)}(e,t in e?e[t]:ho())}function _c(e,t){return t.reduce((t,n)=>[...t,hc(e,n)],[])}var gc=new RegExp(hs);function yc(e){let t=function(e){return e.filter(e=>gc.test(e))}(bo(e));return ss(_c(e,t))}function vc(e,t){return yu(t)?yc(e):function(e,t){return ss(_c(e,fc(t)))}(e,t)}function bc(e){return e.map(e=>wc(e))}function wc(e){return Co(e)?Mo(bc(e.allOf)):$u(e)?xu(bc(e.anyOf)):pu(e)?cu(ac(e.const)):e}function kc(e,t){let n=function(e,t){return e.reduceRight((e,n,r)=>fa(ad({},cu(r),t))?[n,...e]:e,[])}(e,wc(t));return ds(n)}function xc(e,t){return pu(t)&&mi(t.const,"length")?cu(e.length):yu(t)||su(t)?function(e){return ds(e)}(e):kc(e,t)}function $c(e,t){return to(e)?function(e,t){return fa(ad({},cc(t),gu()))?e:pu(t)&&mi(t.const,"length")?gu():ho()}(e.items,t):xo(e)?vc(e.properties,t):Bu(e)?xc(e.items,t):ho()}function Ac(e,t,n){return Qc([e,t])?Ji($c(function(e){return Oo(e)||Ro(e)||Co(e)||$u(e)?uc(e):e}(e),t),{},n):function(e,t,n={}){return Zi("Index",[e,t],n)}(e,t,n)}function Sc(e,t){return Qc([e])?Ji(function(e){return io(e)?e.instanceType:ho()}(e),{},t):function(e,t={}){return Zi("InstanceType",[e],t)}(e,t)}function Oc(e){return e.reduce((e,t)=>{return ni(n=t)||ri(n)||ai(n)||li(n)?[...e,cu(ac(t))]:To();var n},[])}function Ic(e){return fo(e)?xu([gu(),wu(),Gi({"~kind":"Symbol"},{type:"symbol"},t)]):to(e)?(e.items,gu()):xo(e)?ds(Oc(Pi(e.properties))):xs(e)?function(e){return ws(e)}(e):Bu(e)?ds(e.items.map((e,t)=>cu(t))):ho();var t}function Ec(e,t){return Qc([e])?Ji(Ic(function(e){return Oo(e)||Ro(e)||Co(e)||$u(e)?uc(e):e}(e)),{},t):function(e,t={}){return Zi("KeyOf",[e],t)}(e,t)}function Rc(e){return Po(e)?Rc(is(e.enum)):pu(e)?ai(t=e.const)?[cu(`${t}`)]:[cu(t)]:ua(e)?Rc(us(e.pattern)):$u(e)?e.anyOf.reduce((e,t)=>[...e,...Rc(t)],[]):[e];var t}function Pc(e,t,n,r,i,o){let u=Bi(e,{[n.name]:r}),s=function(e){return ua(e)?us(e.pattern):e}(il(u,t,i)),a=il(u,t,o);return lu(s)||fu(s)?{[s.const]:a}:{}}function Mc(e,t,n,r,i,o){let u=function(e){return Rc(e)}(r),s=function(e,t,n,r,i,o){return r.reduce((r,u)=>[...r,Pc(e,t,n,u,i,o)],[])}(e,t,n,u,i,o);return os(s.reduce((e,t)=>[...e,ko(t)],[]))}function Cc(e,t,n,r,i,o,u){return Qc([r])?Ji(Mc(e,t,n,r,i,o),{},u):function(e,t,n,r,i={}){return Zi("Mapped",[e,t,n,r],i)}(n,r,i,o,u)}function Tc(e,t,n){let r=function(e){return Va(e,bo(e))}(t),i=function(e,t,n){let r=Bi(e,t);return Pi(t).filter(e=>n.includes(e)).reduce((e,n)=>({...e,[n]:id(r,n,t[n])}),{})}(e,t,r),o=function(e,t,n){let r=Bi(e,t);return Pi(t).filter(e=>!n.includes(e)).reduce((e,n)=>({...e,[n]:il(r,Xc([],[]),t[n])}),{})}(e,t,r);return Ji({...i,...o},{},n)}function qc(e,t){return Qc([e])?Ji(function(e){var t;return Xd(e,xu([mu(),Gi({"~kind":"Undefined"},{type:"undefined"},t)]),{})}(e),{},t):function(e,t={}){return Zi("NonNullable",[e],t)}(e,t)}function Nc(e){let t=uc(e);return xo(t)?t.properties:To()}function jc(e,t){let n=Nc(e),r=fc(t);var i,o;return ko((o=r,Pi(i=n).reduce((e,t)=>o.includes(t)?e:{...e,[t]:i[t]},{})))}function Lc(e,t,n){return Qc([e,t])?Ji(jc(e,t),{},n):function(e,t,n={}){return Zi("Omit",[e,t],n)}(e,t,n)}function Bc(e,t){return Qc([e])?Ji(function(e){let t=uo(e)?e.parameters:[];return Lu(el({},Xc([],[]),t))}(e),{},t):function(e,t={}){return Zi("Parameters",[e],t)}(e,t)}function Dc(e){return Oo(e)?function(e,t){let n=Dc(ud(e,t));return So(Bi(e,{[t]:n}),t)}(e.$defs,e.$ref):Ro(e)?(n=e.if,r=e.then,i=e.else,Dc(rs(n,r,i))):Co(e)?Dc(os(e.allOf)):$u(e)?function(e){return xu(e.map(e=>Dc(e)))}(e.anyOf):xo(e)?ko(Pi(t=e.properties).reduce((e,n)=>({...e,[n]:go(t[n])}),{})):ko({});var t,n,r,i}function zc(e,t){return Qc([e])?Ji(Dc(e),{},t):function(e,t={}){return Zi("Partial",[e],t)}(e,t)}function Uc(e,t){let n=function(e,t){return Pi(e).reduce((n,r)=>t.includes(r)?Bi(n,{[r]:e[r]}):n,{})}(Nc(e),fc(t));return ko(n)}function Fc(e,t,n){return Qc([e,t])?Ji(Uc(e,t),{},n):function(e,t,n={}){return Zi("Pick",[e,t],n)}(e,t,n)}function Wc(e){return to(e)?function(e){return sl(eo(e))}(e.items):Oo(e)?function(e,t){let n=Wc(ud(e,t));return So(Bi(e,{[t]:n}),t)}(e.$defs,e.$ref):Ro(e)?(n=e.if,r=e.then,i=e.else,Wc(rs(n,r,i))):Co(e)?Wc(os(e.allOf)):xo(e)?ko(Pi(t=e.properties).reduce((e,n)=>({...e,[n]:Yo(t[n])}),{})):Bu(e)?function(e){return sl(Lu(e))}(e.items):$u(e)?function(e){return xu(e.map(e=>Wc(e)))}(e.anyOf):e;var t,n,r,i}function Gc(e,t){return Qc([e])?Ji(Wc(e),{},t):function(e,t={}){return Zi("ReadonlyObject",[e],t)}(e)}function Kc(e){return Oo(e)?function(e,t){let n=Kc(ud(e,t));return So(Bi(e,{[t]:n}),t)}(e.$defs,e.$ref):Ro(e)?(n=e.if,r=e.then,i=e.else,Kc(rs(n,r,i))):Co(e)?Kc(os(e.allOf)):$u(e)?function(e){return xu(e.map(e=>Kc(e)))}(e.anyOf):xo(e)?ko(Pi(t=e.properties).reduce((e,n)=>({...e,[n]:Uu(t[n])}),{})):ko({});var t,n,r,i}function Jc(e,t){return Qc([e])?Ji(Kc(e),{},t):function(e,t={}){return Zi("Required",[e],t)}(e,t)}function Hc(e,t){return Qc([e])?Ji(function(e){return uo(e)?e.returnType:ho()}(e),{},t):function(e,t={}){return Zi("ReturnType",[e],t)}(e,t)}function Vc(e,t){return Qc([e])?Ji(e,{},t):function(e,t){return Zi("With",[e,t],{})}(e,t)}function Zc(e){return e.reduce((e,t)=>{return[...e,...(n=t,$s(n)?Bu(n.items)?Zc(n.items.items):Eo(n.items)||ao(n.items)?[n]:[ho()]:[n])];var n},[])}function Xc(e,t){return{callstack:e,visited:t}}function Qc(e){return Si(e,(e,t)=>!ao(e)&&Qc(t),()=>!0)}function Yc(e,t,n){return Pi(n).reduce((r,i)=>({...r,[i]:il(e,t,n[i])}),{})}function el(e,t,n){return Zc(tl(e,t,n))}function tl(e,t,n){return n.map(n=>il(e,t,n))}function nl(e,t,n,r,i){return mi(n,"AddImmutable")?function(e,t,n,r){let i=il(e,t,n);return ul(i,r)}(e,t,r[0],i):mi(n,"RemoveImmutable")?function(e,t,n,r){return Bd(il(e,t,n),r)}(e,t,r[0],i):mi(n,"AddReadonly")?function(e,t,n,r){return Qi(il(e,t,n),r)}(e,t,r[0],i):mi(n,"RemoveReadonly")?function(e,t,n,r){return Du(il(e,t,n),r)}(e,t,r[0],i):mi(n,"AddOptional")?function(e,t,n,r){return Yi(il(e,t,n),r)}(e,t,r[0],i):mi(n,"RemoveOptional")?function(e,t,n,r){return zu(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Capitalize")?function(e,t,n,r){return Gd(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Conditional")?function(e,t,n,r,i,o,u){return Vd(e,t,il(e,t,n),il(e,t,r),i,o,u)}(e,t,r[0],r[1],r[2],r[3],i):mi(n,"ConstructorParameters")?function(e,t,n,r){return Zd(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Evaluate")?function(e,t,n,r){return yd(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Exclude")?function(e,t,n,r,i){return Xd(il(e,t,n),il(e,t,r),i)}(e,t,r[0],r[1],i):mi(n,"Extract")?function(e,t,n,r,i){return tc(il(e,t,n),il(e,t,r),i)}(e,t,r[0],r[1],i):mi(n,"Index")?function(e,t,n,r,i){return Ac(il(e,t,n),il(e,t,r),i)}(e,t,r[0],r[1],i):mi(n,"InstanceType")?function(e,t,n,r={}){return Sc(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Interface")?function(e,t,n,r,i){return Wa(tl(e,t,n),Yc(e,t,r),i)}(e,t,r[0],r[1],i):mi(n,"KeyOf")?function(e,t,n,r){return Ec(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Lowercase")?function(e,t,n,r){return Kd(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Mapped")?function(e,t,n,r,i,o,u){return Cc(e,t,n,il(e,t,r),i,o,u)}(e,t,r[0],r[1],r[2],r[3],i):mi(n,"Module")?function(e,t,n,r){return Tc(e,n,r)}(e,0,r[0],i):mi(n,"NonNullable")?function(e,t,n,r){return qc(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Pick")?function(e,t,n,r,i){return Fc(il(e,t,n),il(e,t,r),i)}(e,t,r[0],r[1],i):mi(n,"Parameters")?function(e,t,n,r){return Bc(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Partial")?function(e,t,n,r){return zc(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Omit")?function(e,t,n,r,i){return Lc(il(e,t,n),il(e,t,r),i)}(e,t,r[0],r[1],i):mi(n,"ReadonlyObject")?function(e,t,n,r){return Gc(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Record")?function(e,t,n,r,i){return ms(il(e,t,n),il(e,t,r),i)}(e,t,r[0],r[1],i):mi(n,"Required")?function(e,t,n,r){return Jc(il(e,t,n),r)}(e,t,r[0],i):mi(n,"ReturnType")?function(e,t,n,r={}){return Hc(il(e,t,n),r)}(e,t,r[0],i):mi(n,"TemplateLiteral")?function(e,t,n,r){return oa(tl(e,t,n),r)}(e,t,r[0],i):mi(n,"Uncapitalize")?function(e,t,n,r){return Jd(il(e,t,n),r)}(e,t,r[0],i):mi(n,"Uppercase")?function(e,t,n,r){return Hd(il(e,t,n),r)}(e,t,r[0],i):mi(n,"With")?function(e,t,n,r){return Vc(il(e,t,n),r)}(e,t,r[0],r[1]):Zi(n,r,i)}function rl(e,t,n){let r=ao(n)?function(e,t,n,r){return t.visited.includes(r)?n:r in e?il(e,Xc(t.callstack,[...t.visited,r]),e[r]):n}(e,t,n,n.$ref):to(n)?eo(il(e,t,n.items),no(n)):Ld(n)?Nd(e,t,n.target,n.arguments):io(n)?ro(tl(e,t,n.parameters),il(e,t,n.instanceType),function(e){return Ki(e,["~kind","type","parameters","instanceType"])}(n)):uo(n)?oo(tl(e,t,n.parameters),il(e,t,n.returnType),function(e){return Ki(e,["~kind","type","parameters","returnType"])}(n)):Ro(n)?function(e,t,n,r={}){return Gi({"~kind":"Dependent"},{if:e,then:t,else:n},r)}(il(e,t,n.if),il(e,t,n.then),il(e,t,n.else),function(e){return Ki(e,["~kind","if","then","else"])}(n)):Co(n)?Mo(tl(e,t,n.allOf),function(e){return Ki(e,["~kind","allOf"])}(n)):xo(n)?ko(Yc(e,t,n.properties),function(e){return Ki(e,["~kind","type","properties","required"])}(n)):xs(n)?(i=bs(n),o=il(e,t,ks(n)),ju(i,o)):$s(n)?function(e){return Gi({"~kind":"Rest"},{type:"rest",items:e},{})}(il(e,t,n.items)):Bu(n)?Lu(el(e,t,n.items),function(e){return Ki(e,["~kind","type","items","minItems","additionalItems"])}(n)):$u(n)?xu(tl(e,t,n.anyOf),function(e){return Ki(e,["~kind","anyOf"])}(n)):n;var i,o;return function(e,t){let n=vo(e)?Yi(t,{}):t,r=eu(e)?Qi(n,{}):n;return Qo(e)?ul(r,{}):r}(n,r)}function il(e,t,n){return Xi(n)?nl(e,t,n.action,n.parameters,n.options):rl(e,t,n)}function ol(e,t){return il(e,Xc([],[]),t)}function ul(e,t){return Ji(function(e){return Ji(e,{"~immutable":!0},{})}(e),{},t)}function sl(e,t={}){return ul(e,t)}function al(e,t={}){return yd(e,t)}function dl(e,t,n=[]){return Si(t,(r,i)=>mi(function(e,t){let n=pd(e,t);return mi(n,fd)||mi(n,cd)?1:0}(e,r),1)?dl(e,i,[...n,r]):[...n,e,...t],()=>[...n,e])}function cl(e,t=[]){return Si(e,(e,n)=>cl(n,dl(e,t)),()=>t)}function ll(e){return cl(e)}tr();var fl=131072,pl=1048576,ml=wu({description:"Recipient thread id or unique name as returned by thread_list; a name shared by several threads returns ambiguous_target with candidates."}),hl=yo(ru({description:"Address threads in every workspace on this machine instead of only the caller's workspace; left unset, an exact id from another workspace returns scope_denied."})),_l=yo(wu({description:"Caller-chosen key that makes a retried call return the earlier result instead of repeating the side effect; reusing the key with different arguments returns idempotency_conflict."})),gl=yo(wu({description:"Turn id the steer applies to; required with delivery steer, and a changed active turn returns turn_conflict with the message held undelivered."})),yl=yo(wu({maxLength:200,description:"One-line preview shown to the caller when the completion notice arrives."})),vl=wu({maxLength:32768,description:"Instruction to deliver to the target thread; longer than 32768 UTF-8 bytes returns message_too_large."}),bl=wu({minLength:1,description:"Binding id as returned by thread_bind or thread_bindings."}),wl=uu({minimum:1,description:"Revision the caller last saw for this binding; a binding that moved since returns stale_revision."}),kl=wu({description:"Text relayed to or from the external thread; longer than 32768 UTF-8 bytes returns message_too_large."}),xl=xu([cu("auto"),cu("steer"),cu("follow_up")],{description:"auto steers the running turn when one is active and starts a new turn otherwise; steer requires expected_turn_id and becomes turn_conflict when the active turn changed; follow_up queues the message behind the running turn."}),$l=xu([cu("discord"),cu("telegram"),cu("slack"),cu("notion"),cu("feishu"),cu("herdr"),cu("custom")],{description:"Chat platform of the external conversation; custom covers any other connector."}),Al=xu([cu("milestone"),cu("report"),cu("question"),cu("completion")]),Sl=yo(wu({description:"Thread id or unique name of the session to attach, as returned by thread_list; self or leaving it unset attaches the calling session."}));ko({name:yo(wu({description:"Display label for the new thread; an existing thread with the same normalized name returns name_conflict, and later renames change only the label while thread_id stays the address."})),cwd:yo(wu({description:"Working directory the new thread runs in; leaving it unset keeps the thread inside the caller's workspace."})),fork_from:yo(wu({description:"Durable id of an existing thread to fork; the new thread starts with that transcript as prior context."})),idempotency_key:_l}),ko({all_scope:yo(ru({description:"List threads from every workspace on this machine; the default scope returns only the caller's workspace."}))}),ko({thread:ml,cursor:yo(wu({description:"Opaque cursor from an earlier thread_read to continue a truncated transcript; a transcript revision that moved past it returns cursor_stale."})),max_bytes:yo(uu({minimum:1,maximum:pl,description:"Byte budget for the returned transcript slice, default 131072 and capped at 1048576; a longer transcript returns truncated with next_cursor."})),all_scope:hl}),ko({thread:ml,message:vl,delivery:yo(xl),expected_turn_id:gl,summary:yl,idempotency_key:_l,all_scope:hl}),ko({thread:ml,turn_id:yo(wu({description:"Running turn to stop, defaulting to the newest running turn; interrupting an idle thread returns success with interrupted false."})),all_scope:hl}),ko({thread:wu({description:"Thread id or name to reopen after a pause; the fuzzy resolver also accepts partial names and workspace basenames, and a close runner-up returns ambiguous_target with candidates."}),match:yo(xu([cu("exact"),cu("fuzzy")],{description:"exact resolves a thread id or a unique name; fuzzy additionally ranks partial names and workspace basenames and returns the top match only when it clearly leads its runner-up."})),message:vl,delivery:yo(xl),expected_turn_id:gl,summary:yl,idempotency_key:_l,all_scope:hl}),ko({thread:ml,name:wu({minLength:1,maxLength:200,description:"New display label for the thread; the thread keeps its id as its address, and a label already used by another visible thread returns name_conflict."}),all_scope:hl,idempotency_key:_l}),ko({thread:ml,model:wu({minLength:1,description:"Model to switch the thread to, as provider/id, an exact model id, or a case-insensitive fragment of the id or display name resolved against the host's model catalog; no match returns model_not_found with the available list, several matches return model_ambiguous with candidates."}),provider:yo(wu({description:"Restricts resolution to one provider when the fragment alone would match models from several providers."})),all_scope:hl,idempotency_key:_l}),ko({thread:ml,level:xu([cu("off"),cu("minimal"),cu("low"),cu("medium"),cu("high"),cu("xhigh"),cu("max")],{description:"Thinking level to apply; a level the thread's active model cannot run returns thinking_level_unsupported with the supported list and leaves the thread unchanged."}),scope:yo(xu([cu("session"),cu("turn")],{description:"session (default) changes the thread's remembered level for its model; turn changes only the current session level without rewriting the model's remembered level."})),all_scope:hl,idempotency_key:_l}),ko({platform:$l,account_id:wu({minLength:1,maxLength:256,description:"Bot or account id the connector speaks as on that platform."}),chat_id:wu({minLength:1,maxLength:256,description:"Channel, group or direct-chat id on the platform."}),thread_id:yo(wu({minLength:1,maxLength:256,description:"Thread id inside the chat; @chat (the default) binds the whole chat on platforms without threads."})),root_message_id:yo(wu({minLength:1,maxLength:256,description:"Platform id of the message that started the thread, when there is one."})),progress_message_id:yo(wu({minLength:1,maxLength:256,description:"Platform id of an existing progress message that milestone reports edit in place."})),session:Sl,direction:yo(ko({inbound:ru(),outbound:ru()},{description:"inbound lets the thread's messages reach the session, outbound lets the session report to the thread; both default to true and at least one is required."})),inbound_mode:yo(xu([cu("auto"),cu("follow_up")],{description:"How inbound messages are delivered: auto starts a turn when the session is idle and queues behind a running one; follow_up always queues behind the running turn."})),outbound_events:yo(eo(Al,{maxItems:4,description:"Report kinds this thread receives, each at most once; defaults to all four for an outbound binding."})),policy_id:yo(wu({minLength:1,maxLength:256,description:"Connector policy label stored with the binding; default is default."})),ttl_seconds:yo(xu([uu({minimum:1}),mu()],{description:"Lifetime in seconds from now, default 604800 (one week) and never extended; null keeps the binding until it is unbound."})),all_scope:hl,idempotency_key:_l}),ko({binding_id:bl,expected_revision:wl,idempotency_key:_l}),ko({binding_id:bl,expected_revision:wl,session:wu({minLength:1,description:"Thread id or unique name of the session that takes the binding over, as returned by thread_list."}),all_scope:hl,idempotency_key:_l}),ko({session:yo(wu({minLength:1,description:"Only bindings attached to this session (thread id, unique name, or self)."})),platform:yo($l),account_id:yo(wu({minLength:1,description:"Only bindings of this platform account."})),chat_id:yo(wu({minLength:1,description:"Only bindings in this chat."})),thread_id:yo(wu({minLength:1,description:"Only bindings of this thread id."})),status:yo(xu([cu("active"),cu("detached"),cu("expired")],{description:"Only bindings in this status; all statuses when unset."})),cursor:yo(wu({description:"next_cursor from an earlier thread_bindings call, to continue the same snapshot."})),limit:yo(uu({minimum:1,maximum:200,description:"Page size, default 50 and at most 200."})),all_scope:hl}),ko({binding_id:yo(wu({minLength:1,description:"Binding to report to; defaults to the originating binding, the one the message this session is answering now arrived through; refused when that is ambiguous."})),kind:xu([cu("milestone"),cu("report"),cu("question"),cu("completion")],{description:"milestone updates the thread's progress message, report posts a result, question relays a pending question of this session and returns a reply_token, completion is written once when this session's run settles, with the run's real outcome."}),text:kl,request_id:yo(wu({minLength:1,description:"For kind question: the id of this session's pending extension UI request the answer resolves."})),request_kind:yo(xu([cu("question"),cu("select"),cu("confirm"),cu("input"),cu("editor")],{description:"For kind question: which extension UI request request_id is. It decides the answer forms thread_answer accepts: confirm takes yes/no (any case, surrounding spaces ignored), input and editor take any text including empty, question and select take non-blank text. Without it the answer goes out in every text form at once, so a question, select, input or editor each reads its own and the text must be non-blank; a yes/no word also goes out as the confirm field, so an undeclared confirm reads yes/no too (any other text reads as no)."})),idempotency_key:_l}),ko({binding_id:bl,after_cursor:yo(uu({minimum:0,description:"Read rows after this cursor; unset continues after the binding's acknowledged cursor."})),limit:yo(uu({minimum:1,maximum:500,description:"Rows per read, default 100 and at most 500."}))}),ko({binding_id:bl,cursor:uu({minimum:1,description:"Every outbox row up to this cursor is marked delivered; an older cursor changes nothing."}),provider_message_id:yo(wu({minLength:1,maxLength:256,description:"Platform id of the message posted for the row at cursor; the first one for a milestone becomes the progress message later milestones edit."}))}),ko({binding_id:wu({minLength:1,description:"Binding the answer arrived through; it must be the binding that asked the question."}),reply_token:wu({minLength:1,description:"reply_token of the question row being answered."}),answer:kl});function Ol(e){return Ii(e,"~refine")&&ti(e["~refine"])&&ki(e["~refine"],0,e=>ci(e)&&Ii(e,"check")&&Ii(e,"error")&&oi(e.check)&&oi(e.error))}function Il(e){return ci(e)&&!ti(e)}function El(e){return ri(e)}function Rl(e){return Il(e)||El(e)}function Pl(e){return Ii(e,"additionalItems")&&Rl(e.additionalItems)}function Ml(e){return Ii(e,"additionalProperties")&&Rl(e.additionalProperties)}function Cl(e){return Ii(e,"allOf")&&ti(e.allOf)&&e.allOf.every(e=>Rl(e))}function Tl(e){return Ii(e,"anyOf")&&ti(e.anyOf)&&e.anyOf.every(e=>Rl(e))}function ql(e){return Ii(e,"const")}function Nl(e){return Ii(e,"contains")&&Rl(e.contains)}function jl(e){return Ii(e,"default")}function Ll(e){return Ii(e,"dependencies")&&ci(e.dependencies)&&Object.values(e.dependencies).every(e=>Rl(e)||ti(e)&&e.every(e=>li(e)))}function Bl(e){return Ii(e,"dependentRequired")&&ci(e.dependentRequired)&&Object.values(e.dependentRequired).every(e=>ti(e)&&e.every(e=>li(e)))}function Dl(e){return Ii(e,"dependentSchemas")&&ci(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(e=>Rl(e))}function zl(e){return Ii(e,"$dynamicAnchor")&&li(e.$dynamicAnchor)}function Ul(e){return Ii(e,"$dynamicRef")&&li(e.$dynamicRef)}function Fl(e){return Ii(e,"else")&&Rl(e.else)}function Wl(e){return Ii(e,"enum")&&ti(e.enum)}function Gl(e){return Ii(e,"exclusiveMaximum")&&(ai(e.exclusiveMaximum)||ni(e.exclusiveMaximum))}function Kl(e){return Ii(e,"exclusiveMinimum")&&(ai(e.exclusiveMinimum)||ni(e.exclusiveMinimum))}function Jl(e){return Ii(e,"format")&&li(e.format)}function Hl(e){return Ii(e,"$id")&&li(e.$id)}function Vl(e){return Ii(e,"if")&&Rl(e.if)}function Zl(e){return Ii(e,"items")&&(Rl(e.items)||ti(e.items)&&e.items.every(e=>Rl(e)))}function Xl(e){return Zl(e)&&ti(e.items)}function Ql(e){return Ii(e,"maximum")&&(ai(e.maximum)||ni(e.maximum))}function Yl(e){return Ii(e,"maxContains")&&ai(e.maxContains)}function ef(e){return Ii(e,"maxItems")&&ai(e.maxItems)}function tf(e){return Ii(e,"maxLength")&&ai(e.maxLength)}function nf(e){return Ii(e,"maxProperties")&&ai(e.maxProperties)}function rf(e){return Ii(e,"minimum")&&(ai(e.minimum)||ni(e.minimum))}function of(e){return Ii(e,"minContains")&&ai(e.minContains)}function uf(e){return Ii(e,"minItems")&&ai(e.minItems)}function sf(e){return Ii(e,"minLength")&&ai(e.minLength)}function af(e){return Ii(e,"minProperties")&&ai(e.minProperties)}function df(e){return Ii(e,"multipleOf")&&(ai(e.multipleOf)||ni(e.multipleOf))}function cf(e){return Ii(e,"not")&&Rl(e.not)}function lf(e){return Ii(e,"oneOf")&&ti(e.oneOf)&&e.oneOf.every(e=>Rl(e))}function ff(e){return Ii(e,"pattern")&&(li(e.pattern)||e.pattern instanceof RegExp)}function pf(e){return Ii(e,"patternProperties")&&ci(e.patternProperties)&&Object.values(e.patternProperties).every(e=>Rl(e))}function mf(e){return Ii(e,"prefixItems")&&ti(e.prefixItems)&&e.prefixItems.every(e=>Rl(e))}function hf(e){return Ii(e,"properties")&&ci(e.properties)&&Object.values(e.properties).every(e=>Rl(e))}function _f(e){return Ii(e,"propertyNames")&&(ci(e.propertyNames)||Rl(e.propertyNames))}function gf(e){return function(e){return Ii(e,"$recursiveAnchor")&&ri(e.$recursiveAnchor)}(e)&&mi(e.$recursiveAnchor,!0)}function yf(e){return Ii(e,"$recursiveRef")&&li(e.$recursiveRef)}function vf(e){return Ii(e,"$ref")&&li(e.$ref)}function bf(e){return Ii(e,"required")&&ti(e.required)&&e.required.every(e=>li(e))}function wf(e){return Ii(e,"then")&&Rl(e.then)}function kf(e){return Ii(e,"type")&&(li(e.type)||ti(e.type)&&e.type.every(e=>li(e)))}function xf(e){return Ii(e,"uniqueItems")&&ri(e.uniqueItems)}function $f(e){return Ii(e,"unevaluatedItems")&&Rl(e.unevaluatedItems)}function Af(e){return Ii(e,"unevaluatedProperties")&&Rl(e.unevaluatedProperties)}class Sf{constructor(){let e=new Set,t=new Set;this.stack=[{indices:e,keys:t}]}Push(){let e=new Set,t=new Set;return this.stack.push({indices:e,keys:t}),!0}Pop(){return this.stack.pop(),!0}AddIndex(e){return this.GetIndices().add(e),!0}AddKey(e){return this.GetKeys().add(e),!0}GetIndices(){return this.stack[this.stack.length-1].indices}GetKeys(){return this.stack[this.stack.length-1].keys}Merge(e){for(let t of e)t.GetIndices().forEach(e=>this.GetIndices().add(e)),t.GetKeys().forEach(e=>this.GetKeys().add(e));return!0}}class Of extends Sf{constructor(){super(),this.errors=[]}AtCapacity(){return this.errors.length>=ji().maxErrors}AddError(e,t,n,r){return this.AddErrorObject({keyword:e,schemaPath:t,instancePath:n,params:r})}AddErrors(e){return e.forEach(e=>this.AddErrorObject(e)),!1}GetErrors(){return this.errors}AddErrorObject(e){return this.AtCapacity()||this.errors.push(e),!1}}var If="urn:typebox:root";function Ef(e,t){return URL.canParse(e,t)?new URL(e,t):mi(t,If)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Rf(e,t){let n=Il(t)&&Hl(t)?Ef(t.$id,If).href:If;return{context:e,schema:t,lexicalSchema:t,lexicalBase:n,resourceBase:n,referenceBase:n,ids:[],useResourceBaseForReference:!0,recursiveAnchor:void 0,dynamicAnchors:[],resourceEntries:new Map,pendingResource:!0,enteredResource:!1}}function Pf(e,t,n=!0){if(El(t))return e;if(Array.isArray(t))return t.reduce((e,t)=>Pf(e,t,!1),e);if(!Il(t))return e;if(!n&&Hl(t))return e;let r=!n&&zl(t)?[...e,t]:e;return Object.keys(t).reduce((e,n)=>Pf(e,t[n],!1),r)}function Mf(e,t){return e.resourceEntries.get(t)}function Cf(e,t){return e.enteredResource||void 0!==Mf(e,t)}function Tf(e,t){return Hl(t)?[...e.ids,t]:e.ids}function qf(e,t){return e.recursiveAnchor??(gf(t)?t:void 0)}function Nf(e,t){let n=Hl(t)?Pf(e.dynamicAnchors,t):e.dynamicAnchors;return zl(t)?[...n,t]:n}function jf(e,t){return!Hl(t)&&e.pendingResource}function Lf(e,t){let n=Mf(e,t);return n?n.base:Hl(t)?Ef(t.$id,e.lexicalBase).href:e.lexicalBase}function Bf(e,t){let n=Mf(e,t);return n?n.base:Hl(t)&&e.pendingResource?Ef(t.$id,e.resourceBase).href:e.resourceBase}function Df(e,t){return Hl(t)?!function(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}(t):e.useResourceBaseForReference}function zf(e,t){let n=Cf(e,t),r=Df(e,t);return n||r?Bf(e,t):Lf(e,t)}function Uf(e,t){let n=Mf(e,t);return n?n.root:Hl(t)?t:e.lexicalSchema}function Ff(e,t){return function(e,t){return Il(t)&&(Hl(t)||zl(t)||pi(e.recursiveAnchor)&&gf(t)||!pi(Mf(e,t)))}(e,t)?{...e,ids:Tf(e,t),dynamicAnchors:Nf(e,t),recursiveAnchor:qf(e,t),pendingResource:jf(e,t),lexicalBase:Lf(e,t),resourceBase:Bf(e,t),useResourceBaseForReference:Df(e,t),referenceBase:zf(e,t),lexicalSchema:Uf(e,t),enteredResource:Cf(e,t)}:e}function Wf(e){return Zl(e)&&ti(e.items)}function Gf(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Kf(e){return new RegExp(e,"u")}function Jf(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function Hf(e){let t=[];return pf(e)&&t.push(...Pi(e.patternProperties)),hf(e)&&t.push(...Pi(e.properties).map(Jf)),mi(t.length,0)?"(?!)":`(${t.join("|")})`}function Vf(e,t,n,r){return n}function Zf(e,t,n,r){return vi(n.const)?mi(r,n.const):Ci(r,n.const)}function Xf(e,t,n,r){return!function(e){return!(of(e)&&mi(e.minContains,0))}(n)||!mi(r.length,0)&&function(e,t){let n=!1;return e.forEach((e,r)=>{t(e,r)&&(n=!0)}),n}(r,(r,i)=>dh(e,t,n.contains,r)&&t.AddIndex(i))}function Qf(e,t){return Il(e)&&Hl(e)?Ef(e.$id,t.href):t}function Yf(e){return Ef(e,If)}function ep(e){return e.href.split("#")[0]}function tp(e,t,n){return rp(e,Yf(t),n)}function np(e,t){if(ci(e)&&zl(e)&&mi(e.$dynamicAnchor,t))return e;if(ci(e))for(let n of Pi(e)){let r=np(e[n],t);if(r)return r}}function rp(e,t,n){if(mi(e,n))return t.href;let r=Qf(e,t);if(ti(e))for(let t of e){let e=rp(t,r,n);if(!pi(e))return e}else if(ci(e))for(let t of Pi(e)){let i=rp(e[t],r,n);if(!pi(i))return i}}function ip(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let n=decodeURIComponent(t.hash.slice(1));return n.startsWith("/")?function(e,t){let n=e;for(let e of function(e){let t=e.split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"));return""===t[0]?t.slice(1):t}(t)){if(!ci(n)||Oi(e))return;n=n[e]}return n}(e,n):void 0}function op(e,t,n){if(!function(e){return Ii(e,"$anchor")&&li(e.$anchor)}(e))return;let r=new URL(`#${e.$anchor}`,t.href),i=new URL(n.href,t.href);return mi(r.href,i.href)?e:void 0}function up(e,t,n){if(Il(e))return function(e,t,n){if(!Hl(e))return;if(mi(e.$id,n.hash))return e;let r=new URL(n.href,t.href);return mi(t.pathname,r.pathname)?n.hash.startsWith("#")?ip(e,n):e:void 0}(e,t,n)??op(e,t,n)??function(e,t,n){if(!zl(e))return;let r=new URL(`#${e.$dynamicAnchor}`,t.href),i=new URL(n.href,t.href);return mi(r.href,i.href)?e:void 0}(e,t,n)??ip(e,n)}function sp(e,t,n){let r=Qf(e,t);return up(e,r,n)??function(e,t,n){if(ti(e))return e.reduce((e,r)=>{let i=sp(r,t,n);return pi(i)?e:i},void 0)}(e,r,n)??function(e,t,n){if(ci(e))return Pi(e).reduce((r,i)=>{if(mi(i,"const")||mi(i,"enum"))return r;let o=sp(e[i],t,n);return pi(o)?r:o},void 0)}(e,r,n)}function ap(e,t,n,r,i){let o=i?function(e,t,n){let r=e.context[t];if(Il(r))return{target:n,base:t,root:r}}(e,r,n):void 0;return pi(o)?function(e,t,n){if(!t.$ref.startsWith("#"))return;if(!Il(e.schema)||Ii(e.schema,"$schema"))return;let r=tp(e.lexicalSchema,e.referenceBase,n);return pi(r)||mi(r,e.referenceBase)?void 0:{target:n,base:r,root:e.lexicalSchema}}(e,t,n):o}function dp(e,t,n){if(Hl(n))return;let r=function(e,t,n,r){let i=cp(e,t,n,r);return Il(i)&&Hl(i)?i:void 0}(e.context,e.schema,e.referenceBase,t);return r&&!e.ids.includes(r)?{resource:r}:void 0}function cp(e,t,n,r){let i=Yf(n),o=Ef(r,i.href);return function(e,t){return Ii(e,t)?e[t]:void 0}(e,r)??function(e,t,n){return sp(e,t,n)}(t,i,o)??function(e,t,n){let r=ep(n);if(!Ii(e,r)||mi(r,ep(t)))return;let i=e[r],o=Qf(i,new URL(r));return mi(n.hash,"")?i:sp(i,o,n)}(e,i,o)}function lp(e,t,n,r){let i=function(e,t){if(!t)return e;let n=new Map(e.resourceEntries);return n.set(t.target,{base:t.base,root:t.root}),{...e,resourceEntries:n}}({...e,pendingResource:t},n);return function(e,t){return t?Ff(e,t.resource):e}(i,r)}function fp(e,t){let n=cp(e.context,function(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}(e,t),e.referenceBase,t.$ref);return Il(n)?function(e,t,n){let r=ep(Ef(t.$ref,e.referenceBase)),i=!mi(r,e.resourceBase);return{schema:n,stack:lp(e,!0,ap(e,t,n,r,i),i?dp(e,r,n):void 0)}}(e,t,n):function(e,t){return{schema:t,stack:lp(e,!pi(t))}}(e,n)}function pp(e,t){let n=function(e){return Il(e.lexicalSchema)&&gf(e.lexicalSchema)}(e)?e.recursiveAnchor:e.lexicalSchema;return cp(e.context,n,e.lexicalBase,t.$recursiveRef)}function mp(e,t){return Ef(t.$dynamicRef,Yf(e.lexicalBase).href).hash}function hp(e,t){return e.dynamicAnchors.find(e=>mi(e.$dynamicAnchor,t))??np(e.schema,t)}function _p(e,t){let n=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,r=cp(e.context,n,e.lexicalBase,t.$dynamicRef);return pi(r)?function(e,t){let n=mp(e,t);return hp(e,decodeURIComponent(n.slice(1)))}(e,t):function(e,t,n){return Il(n)&&zl(n)?function(e){return e.startsWith("#/")}(mp(e,t))?n:hp(e,n.$dynamicAnchor):n}(e,t,r)}function gp(e,t,n,r){return $i(n.enum,e=>vi(e)?mi(r,e):Ci(r,e))}function yp(e,t,n,r){return _i(r,n.exclusiveMaximum)}function vp(e,t,n,r){return hi(r,n.exclusiveMinimum)}var bp=[0,31,28,31,30,31,30,31,31,30,31,30,31],wp=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function kp(e){let t=wp.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(2===r&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(n)?29:bp[r])}var xp=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function $p(e,t=!0){let n=xp.exec(e);if(!n)return!1;if(t&&!n[4]&&!n[5])return!1;let r=+n[1],i=+n[2],o=+n[3];if(r>23||i>59||o>60)return!1;if(n[5]){let e=+n[6],t=+n[7];if(e>23||t>59)return!1}return o<60||((60*r+i-("-"===n[5]?-1:1)*(60*+(n[6]||0)+ +(n[7]||0)))%1440+1440)%1440==1439}function Ap(e){let t=e.split(/T/i);return 2===t.length&&kp(t[0])&&$p(t[1])}var Sp=/^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;function Op(e){return Sp.test(e)}var Ip=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;function Ep(e){return Ip.test(e)}var Rp=/^(?!-).*(?<!-)$/,Pp=/^(?!..--)/,Mp=/^[a-zA-Z0-9-]*$/,Cp=/[^\p{ASCII}]/u,Tp=/[\u{0660}-\u{0669}]/u,qp=/\p{Mn}/u,Np=/[\p{Mn}\p{Mc}\p{Me}]/u,jp=/\p{L}/u,Lp=/\p{Script=Greek}/u,Bp=/\p{Script=Hebrew}/u,Dp=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,zp=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,Up=/[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u,Fp=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,Wp=new RegExp([/[0-9]/,/[\u{06f0}-\u{06f9}]/u].map(e=>e.source).join("|"),"u"),Gp=new RegExp([jp,/[\u{002d}\u{002b}]/u,/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,/\p{Nd}/u,qp,/\p{Mc}/u,/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u].map(e=>e.source).join("|"),"u");var Kp=36;function Jp(){throw null}function Hp(e){return e.toLowerCase().startsWith("xn--")}function Vp(e,t,n){e=n?Math.floor(e/700):e>>1,e+=Math.floor(e/t);let r=0;for(;e>455;)e=Math.floor(e/35),r+=Kp;return r+Math.floor(36*e/(e+38))}function Zp(e){let t=[],n=128,r=0,i=72,o=e.lastIndexOf("-");if(o>0)for(let n=0;n<o;n++){let r=e.charCodeAt(n);r>=128&&Jp(),t.push(r)}let u=o<0?0:o+1;for(;u<e.length;){let o=r,s=1,a=Kp;for(;;){u>=e.length&&Jp();let t,n=e.charCodeAt(u++);n>=97&&n<=122?t=n-97:n>=48&&n<=57?t=n-48+26:Jp(),r+=t*s;let o=a<=i?1:a>=i+26?26:a-i;if(t<o)break;s*=Kp-o,a+=Kp}let d=t.length+1;i=Vp(r-o,d,0===o),n+=Math.floor(r/d),r%=d,t.splice(r,0,n),r++}return String.fromCodePoint(...t)}function Xp(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var Qp=new RegExp(Cp.source,"gu");var Yp=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,em=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,tm=/^(?:R|AL|AN)$/;function nm(e){let t=String.fromCodePoint(e);return Wp.test(t)?"EN":Tp.test(t)?"AN":qp.test(t)?"NSM":Bp.test(t)?"R":zp.test(t)?"AL":jp.test(t)?"L":"ON"}function rm(e){for(let t of e)if(tm.test(nm(t.codePointAt(0))))return!0;return!1}function im(e){let t=!1,n=em,r=!1,i=!1,o=!0;for(let u of e){let e=nm(u.codePointAt(0));if(o){if("L"!==e&&"R"!==e&&"AL"!==e)return!1;t="R"===e||"AL"===e,n=t?Yp:em,o=!1}if(!n.test(e))return!1;"EN"===e?r=!0:"AN"===e&&(i=!0)}return!(t&&r&&i)}function om(e){return Cp.test(e)&&function(e){let t=e.replace(Qp,""),n=t.length,r=n>0?[t,"-"]:[],i=Array.from(e,e=>e.codePointAt(0)),o=128,u=0,s=72,a=n;for(;a<i.length;){let e=1/0;for(let t of i)t>=o&&t<e&&(e=t);u+=(e-o)*(a+1),o=e;for(let e of i)if(e<o&&u++,e===o){let e=u;for(let t=Kp;;t+=Kp){let n=t<=s?1:t>=s+26?26:t-s;if(e<n)break;let i=n+(e-n)%(Kp-n);r.push(Xp(i)),e=Math.floor((e-n)/(Kp-n))}r.push(Xp(e)),s=Vp(u,a+1,a===n),u=0,a++}u++,o++}return r.join("")}(e).length+4>63}function um(e){if(om(e))return!1;if(rm(e)&&!im(e))return!1;let t=[...e],n=t.map(e=>e.codePointAt(0)),r=n.length;if(function(e){return"-"===e[0]||"-"===e[e.length-1]||e.slice(2).join("").startsWith("--")}(t))return!1;if(Np.test(t[0]))return!1;let i=!1;for(let e=0;e<r;e++){let r=n[e],o=t[e];if(Fp.test(o))return!1;if(!Gp.test(o))return!1;Dp.test(o)&&(i=!0);let u=n[e-1],s=n[e+1];switch(r){case 183:if(108!==u||108!==s)return!1;break;case 885:if(!s||!Lp.test(t[e+1]))return!1;break;case 1523:case 1524:if(!u||!Bp.test(t[e-1]))return!1;break;case 8204:if(!u||u<128&&!Up.test(t[e-1]))return!1;break;case 8205:if(!u||!Up.test(t[e-1]))return!1}}return!(e.includes("・")&&!i)}function sm(e){if(!Hp(e))return!1;try{let t=e.slice(4).toLowerCase();if(0===t.lastIndexOf("-"))return!1;let n=Zp(t);return!!Cp.test(n)&&um(n)}catch{return!1}}function am(e){return function(e){return e.length>0&&e.length<=63}(e)&&(sm(e)||function(e){return Rp.test(e)&&Pp.test(e)&&Mp.test(e)}(e))}function dm(e){if(0===e.length||e.includes(" "))return!1;let t=function(e){return e.replace(/[\uff01-\uff5e]/g,e=>String.fromCharCode(e.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}(e);if(t.length>253)return!1;let n=t.split("."),r=n.some(e=>function(e){if(Hp(e))try{return rm(Zp(e.slice(4).toLowerCase()))}catch{return!1}return rm(e)}(e));return n.every(e=>function(e){return function(e){return e.length>0&&e.length<=63}(e)&&(sm(e)||um(e))}(e)&&(!r||im(e)))}function cm(e){return function(e){return!(0===e.length||e.length>253)&&46!==e.charCodeAt(e.length-1)&&e.split(".").every(e=>am(e))}(e)}var lm=/^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function fm(e){return lm.test(e.normalize("NFC"))}function pm(e){return dm(e)}var mm=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function hm(e){return mm.test(e)}var _m=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;function gm(e){return _m.test(e)}var ym=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,vm=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function bm(e){return!ym.test(e)&&!vm.test(e)&&URL.canParse(e,"http://example.com")}var wm=/[\x00-\x20<>\^`{|}\\]/,km=/%(?![0-9a-fA-F]{2})/;function xm(e){return!wm.test(e)&&(!km.test(e)&&URL.canParse(e))}var $m=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function Am(e){return $m.test(e)}var Sm=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function Om(e){return Sm.test(e)}function Im(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var Em=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function Rm(e){return Em.test(e)}var Pm=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Mm(e){return Pm.test(e)}var Cm=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function Tm(e){return Cm.test(e)}var qm=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Nm(e){return qm.test(e)}function jm(e){return URL.canParse(e)}var Lm=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function Bm(e){return Lm.test(e)}var Dm=new Map;function zm(e,t,n,r){return function(e,t){return Dm.get(e)?.(t)??!0}(n.format,r)}function Um(e,t,n,r){return Xl(n)?function(e,t,n,r){return ki(n.items,0,(n,i)=>gi(r.length,i)||ah(e,t,n,r[i])&&t.AddIndex(i))}(e,t,n,r):function(e,t,n,r){return ki(r,mf(n)?n.prefixItems.length:0,(r,i)=>ah(e,t,n.items,r)&&t.AddIndex(i))}(e,t,n,r)}function Fm(e,t,n,r,i,o){return Xl(i)?function(e,t,n,r,i,o){return xi(i.items,0,(i,u)=>{let s=`${n}/items/${u}`,a=`${r}/${u}`;return gi(o.length,u)||ch(e,t,s,a,i,o[u])&&t.AddIndex(u)})}(e,t,n,r,i,o):function(e,t,n,r,i,o){return xi(o,mf(i)?i.prefixItems.length:0,(o,u)=>ch(e,t,`${n}/items`,`${r}/${u}`,i.items,o)&&t.AddIndex(u))}(e,t,n,r,i,o)}function Wm(e,t,n,r){if(!function(e){return Nl(e)}(n))return!0;return gi(Ai(r,r=>dh(e,t,n.contains,r)),n.maxContains)}function Gm(e,t,n,r){return gi(r,n.maximum)}function Km(e,t,n,r){return gi(r.length,n.maxItems)}function Jm(e,t,n,r){return bi(r,n.maxLength)}function Hm(e,t,n,r){return gi(Pi(r).length,n.maxProperties)}function Vm(e,t,n,r){if(!function(e){return Nl(e)}(n))return!0;return yi(Ai(r,(r,i)=>dh(e,t,n.contains,r)&&t.AddIndex(i)),n.minContains)}function Zm(e,t,n,r){return yi(r,n.minimum)}function Xm(e,t,n,r){return yi(r.length,n.minItems)}function Qm(e,t,n,r){return wi(r,n.minLength)}function Ym(e,t,n,r){return yi(Pi(r).length,n.minProperties)}function eh(e,t,n,r){return function(e,t){if(ni(e)||ni(t))return BigInt(e)%BigInt(t)===0n;if(!ai(e))return!0;if(ui(e)&&1/t%1==0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t),Math.abs(n+t))<1e-10}(r,n.multipleOf)}function th(e,t,n,r){let i=new Sf;return!dh(e,i,n.not,r)&&t.Merge([i])}function nh(e,t,n,r){return(li(n.pattern)?Kf(n.pattern):n.pattern).test(r)}function rh(e,t){return e.includes(t)||ji().exactOptionalPropertyTypes}function ih(e,t){return pi(e[t])}function oh(e,t,n,r,i){return mi(n,"object")?di(i):mi(n,"array")?ti(i):mi(n,"boolean")?ri(i):mi(n,"integer")?ui(i):mi(n,"number")?ai(i):mi(n,"null")?si(i):mi(n,"string")?li(i):mi(n,"bigint")?ni(i):mi(n,"constructor")?ii(i):mi(n,"function")?oi(i):mi(n,"symbol")?fi(i):mi(n,"undefined")?pi(i):!mi(n,"void")||pi(i)}function uh(e,t,n,r,i){return $i(n,e=>oh(0,0,e,0,i))}function sh(e){return!mi(e.uniqueItems,!1)}function ah(e,t,n,r){return t.Push()&&dh(e,t,n,r)&&t.Pop()}function dh(e,t,n,r){let i=Ff(e,n);return El(n)?Vf(0,0,n):(!kf(n)||function(e,t,n,r){return ti(n.type)?uh(0,0,n.type,0,r):oh(0,0,n.type,0,r)}(0,0,n,r))&&(!(ci(r)&&!ti(r))||(!bf(n)||function(e,t,n,r){return ki(n.required,0,e=>Ii(r,e))}(0,0,n,r))&&(!Ml(n)||function(e,t,n,r){let i=Kf(Hf(n));return ki(Pi(r),0,(o,u)=>i.test(o)||ah(e,t,n.additionalProperties,r[o])&&t.AddKey(o))}(i,t,n,r))&&(!Ll(n)||function(e,t,n,r){let i=mi(Pi(r).length,0),o=ki(Ri(n.dependencies),0,([n,i])=>!Ii(r,n)||(ti(i)?i.every(e=>Ii(r,e)):dh(e,t,i,r)));return i||o}(i,t,n,r))&&(!Bl(n)||function(e,t,n,r){let i=mi(Pi(r).length,0),o=ki(Ri(n.dependentRequired),0,([e,t])=>!Ii(r,e)||t.every(e=>Ii(r,e)));return i||o}(0,0,n,r))&&(!Dl(n)||function(e,t,n,r){let i=mi(Pi(r).length,0),o=ki(Ri(n.dependentSchemas),0,([n,i])=>!Ii(r,n)||dh(e,t,i,r));return i||o}(i,t,n,r))&&(!pf(n)||function(e,t,n,r){return ki(Ri(n.patternProperties),0,([n,i])=>{let o=Kf(n);return ki(Ri(r),0,([n,r])=>!o.test(n)||ah(e,t,i,r)&&t.AddKey(n))})}(i,t,n,r))&&(!hf(n)||function(e,t,n,r){let i=bf(n)?n.required:[];return ki(Ri(n.properties),0,([n,o])=>{let u=!Ii(r,n)||ah(e,t,o,r[n])&&t.AddKey(n);return rh(i,n)?u:ih(r,n)||u})}(i,t,n,r))&&(!_f(n)||function(e,t,n,r){return ki(Pi(r),0,(r,i)=>dh(e,t,n.propertyNames,r))}(i,t,n,r))&&(!af(n)||Ym(0,0,n,r))&&(!nf(n)||Hm(0,0,n,r)))&&(!ti(r)||(!Pl(n)||function(e,t,n,r){return!Wf(n)||ki(r,0,(r,i)=>_i(i,n.items.length)||ah(e,t,n.additionalItems,r)&&t.AddIndex(i))}(i,t,n,r))&&(!Nl(n)||Xf(i,t,n,r))&&(!Zl(n)||Um(i,t,n,r))&&(!of(n)||Vm(i,t,n,r))&&(!Yl(n)||Wm(i,t,n,r))&&(!uf(n)||Xm(0,0,n,r))&&(!ef(n)||Km(0,0,n,r))&&(!mf(n)||function(e,t,n,r){return mi(r.length,0)||ki(n.prefixItems,0,(n,i)=>gi(r.length,i)||ah(e,t,n,r[i])&&t.AddIndex(i))}(i,t,n,r))&&(!xf(n)||function(e,t,n,r){return!sh(n)||mi(new Set(r.map(Vo)).size,r.length)}(0,0,n,r)))&&(!li(r)||(!sf(n)||Qm(0,0,n,r))&&(!tf(n)||Jm(0,0,n,r))&&(!Jl(n)||zm(0,0,n,r))&&(!ff(n)||nh(0,0,n,r)))&&(!(ai(r)||ni(r))||(!Kl(n)||vp(0,0,n,r))&&(!Gl(n)||yp(0,0,n,r))&&(!rf(n)||Zm(0,0,n,r))&&(!Ql(n)||Gm(0,0,n,r))&&(!df(n)||eh(0,0,n,r)))&&(!vf(n)||function(e,t,n,r){let i=fp(e,n),o=i.schema??!1,u=new Sf,s=Rl(o)&&dh(i.stack,u,o,r);return s&&t.Merge([u]),s}(i,t,n,r))&&(!yf(n)||function(e,t,n,r){let i=pp(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Rl(i)&&dh(o,t,i,r)}(i,t,n,r))&&(!Ul(n)||function(e,t,n,r){let i=_p(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Rl(i)&&dh(o,t,i,r)}(i,t,n,r))&&(!ql(n)||Zf(0,0,n,r))&&(!Wl(n)||gp(0,0,n,r))&&(!Vl(n)||function(e,t,n,r){let i=!wf(n)||n.then,o=!Fl(n)||n.else;return dh(e,t,n.if,r)?dh(e,t,i,r):dh(e,t,o,r)}(i,t,n,r))&&(!cf(n)||th(i,t,n,r))&&(!Cl(n)||function(e,t,n,r){let i=n.allOf.reduce((t,n)=>{let i=new Sf;return dh(e,i,n,r)?[...t,i]:t},[]);return mi(i.length,n.allOf.length)&&t.Merge(i)}(i,t,n,r))&&(!Tl(n)||function(e,t,n,r){let i=n.anyOf.reduce((t,n)=>{let i=new Sf;return dh(e,i,n,r)?[...t,i]:t},[]);return hi(i.length,0)&&t.Merge(i)}(i,t,n,r))&&(!lf(n)||function(e,t,n,r){let i=n.oneOf.reduce((t,n)=>{let i=new Sf;return dh(e,i,n,r)?[...t,i]:t},[]);return mi(i.length,1)&&t.Merge(i)}(i,t,n,r))&&(!$f(n)||!ti(r)||function(e,t,n,r){let i=t.GetIndices();return ki(r,0,(r,o)=>(i.has(o)||dh(e,t,n.unevaluatedItems,r))&&t.AddIndex(o))}(i,t,n,r))&&(!Af(n)||!ci(r)||function(e,t,n,r){let i=t.GetKeys();return ki(Ri(r),0,([r,o])=>i.has(r)||dh(e,t,n.unevaluatedProperties,o)&&t.AddKey(r))}(i,t,n,r))&&(!Ol(n)||function(e,t,n,r){return ki(n["~refine"],0,(e,t)=>e.check(r))}(0,0,n,r))}function ch(e,t,n,r,i,o){return t.Push()&&lh(e,t,n,r,i,o)&&t.Pop()}function lh(e,t,n,r,i,o){if(t.AtCapacity())return!1;let u=Ff(e,i);return El(i)?function(e,t,n,r,i){return Vf(0,0,i)||t.AddError("boolean",n,r,{})}(0,t,n,r,i):!!(+(!kf(i)||function(e,t,n,r,i,o){return(ti(i.type)?uh(0,0,i.type,0,o):oh(0,0,i.type,0,o))||t.AddError("type",n,r,{type:i.type})}(0,t,n,r,i,o))&+!(ci(o)&&!ti(o)&&!(+(!bf(i)||function(e,t,n,r,i,o){let u=[];return xi(i.required,0,e=>{let t=Ii(o,e);return t||u.push(e),t})||t.AddError("required",n,r,{requiredProperties:u})}(0,t,n,r,i,o))&+(!Ml(i)||function(e,t,n,r,i,o){let u=Kf(Hf(i)),s=[];return xi(Pi(o),0,(a,d)=>{let c=`${n}/additionalProperties`,l=`${r}/${Gf(a)}`,f=u.test(a)||ch(e,t,c,l,i.additionalProperties,o[a])&&t.AddKey(a);return f||s.push(a),f})||t.AddError("additionalProperties",n,r,{additionalProperties:s})}(u,t,n,r,i,o))&+(!Ll(i)||function(e,t,n,r,i,o){let u=mi(Pi(o).length,0),s=xi(Ri(i.dependencies),0,([i,u])=>{let s=`${n}/dependencies/${Gf(i)}`;return!Ii(o,i)||(ti(u)?u.every(e=>Ii(o,e)||t.AddError("dependencies",n,r,{property:i,dependencies:u})):lh(e,t,s,r,u,o))});return u||s}(u,t,n,r,i,o))&+(!Bl(i)||function(e,t,n,r,i,o){let u=mi(Pi(o).length,0),s=xi(Ri(i.dependentRequired),0,([e,i])=>!Ii(o,e)||xi(i,0,u=>Ii(o,u)||t.AddError("dependentRequired",n,r,{property:e,dependencies:i})));return u||s}(0,t,n,r,i,o))&+(!Dl(i)||function(e,t,n,r,i,o){let u=mi(Pi(o).length,0),s=xi(Ri(i.dependentSchemas),0,([i,u])=>{let s=`${n}/dependentSchemas/${Gf(i)}`;return!Ii(o,i)||lh(e,t,s,r,u,o)});return u||s}(u,t,n,r,i,o))&+(!pf(i)||function(e,t,n,r,i,o){return xi(Ri(i.patternProperties),0,([i,u])=>{let s=`${n}/patternProperties/${Gf(i)}`,a=Kf(i);return xi(Ri(o),0,([n,i])=>{let o=`${r}/${Gf(n)}`;return!a.test(n)||ch(e,t,s,o,u,i)&&t.AddKey(n)})})}(u,t,n,r,i,o))&+(!hf(i)||function(e,t,n,r,i,o){let u=bf(i)?i.required:[];return xi(Ri(i.properties),0,([i,s])=>{let a=`${n}/properties/${Gf(i)}`,d=`${r}/${Gf(i)}`,c=()=>!Ii(o,i)||ch(e,t,a,d,s,o[i])&&t.AddKey(i);return rh(u,i)?c():ih(o,i)||c()})}(u,t,n,r,i,o))&+(!_f(i)||function(e,t,n,r,i,o){let u=[];return xi(Pi(o),0,(o,s)=>{let a=`${r}/${Gf(o)}`,d=lh(e,t,`${n}/propertyNames`,a,i.propertyNames,o);return d||u.push(o),d})||t.AddError("propertyNames",n,r,{propertyNames:u})}(u,t,n,r,i,o))&+(!af(i)||function(e,t,n,r,i,o){return Ym(0,0,i,o)||t.AddError("minProperties",n,r,{limit:i.minProperties})}(0,t,n,r,i,o))&+(!nf(i)||function(e,t,n,r,i,o){return Hm(0,0,i,o)||t.AddError("maxProperties",n,r,{limit:i.maxProperties})}(0,t,n,r,i,o))))&+(!ti(o)||!!(+(!Pl(i)||function(e,t,n,r,i,o){return!Wf(i)||ki(o,0,(o,u)=>{let s=`${n}/additionalItems`,a=`${r}/${u}`;return _i(u,i.items.length)||ch(e,t,s,a,i.additionalItems,o)&&t.AddIndex(u)})}(u,t,n,r,i,o))&+(!Nl(i)||function(e,t,n,r,i,o){return Xf(e,t,i,o)||t.AddError("contains",n,r,{minContains:1})}(u,t,n,r,i,o))&+(!Zl(i)||Fm(u,t,n,r,i,o))&+(!of(i)||function(e,t,n,r,i,o){return Vm(e,t,i,o)||t.AddError("contains",n,r,{minContains:i.minContains})}(u,t,n,r,i,o))&+(!Yl(i)||function(e,t,n,r,i,o){let u=of(i)?i.minContains:1;return Wm(e,t,i,o)||t.AddError("contains",n,r,{minContains:u,maxContains:i.maxContains})}(u,t,n,r,i,o))&+(!uf(i)||function(e,t,n,r,i,o){return Xm(0,0,i,o)||t.AddError("minItems",n,r,{limit:i.minItems})}(0,t,n,r,i,o))&+(!ef(i)||function(e,t,n,r,i,o){return Km(0,0,i,o)||t.AddError("maxItems",n,r,{limit:i.maxItems})}(0,t,n,r,i,o))&+(!mf(i)||function(e,t,n,r,i,o){return mi(o.length,0)||xi(i.prefixItems,0,(i,u)=>{let s=`${n}/prefixItems/${u}`,a=`${r}/${u}`;return gi(o.length,u)||ch(e,t,s,a,i,o[u])&&t.AddIndex(u)})}(u,t,n,r,i,o))&+(!xf(i)||function(e,t,n,r,i,o){if(!sh(i))return!0;let u=new Set,s=o.reduce((e,t,n)=>{let r=Vo(t);return u.has(r)?[...e,n]:(u.add(r),e)},[]);return mi(s.length,0)||t.AddError("uniqueItems",n,r,{duplicateItems:s})}(0,t,n,r,i,o))))&+(!li(o)||!!(+(!sf(i)||function(e,t,n,r,i,o){return Qm(0,0,i,o)||t.AddError("minLength",n,r,{limit:i.minLength})}(0,t,n,r,i,o))&+(!tf(i)||function(e,t,n,r,i,o){return Jm(0,0,i,o)||t.AddError("maxLength",n,r,{limit:i.maxLength})}(0,t,n,r,i,o))&+(!Jl(i)||function(e,t,n,r,i,o){return zm(0,0,i,o)||t.AddError("format",n,r,{format:i.format})}(0,t,n,r,i,o))&+(!ff(i)||function(e,t,n,r,i,o){return nh(0,0,i,o)||t.AddError("pattern",n,r,{pattern:i.pattern})}(0,t,n,r,i,o))))&+(!(ai(o)||ni(o))||!!(+(!Kl(i)||function(e,t,n,r,i,o){return vp(0,0,i,o)||t.AddError("exclusiveMinimum",n,r,{comparison:">",limit:i.exclusiveMinimum})}(0,t,n,r,i,o))&+(!Gl(i)||function(e,t,n,r,i,o){return yp(0,0,i,o)||t.AddError("exclusiveMaximum",n,r,{comparison:"<",limit:i.exclusiveMaximum})}(0,t,n,r,i,o))&+(!rf(i)||function(e,t,n,r,i,o){return Zm(0,0,i,o)||t.AddError("minimum",n,r,{comparison:">=",limit:i.minimum})}(0,t,n,r,i,o))&+(!Ql(i)||function(e,t,n,r,i,o){return Gm(0,0,i,o)||t.AddError("maximum",n,r,{comparison:"<=",limit:i.maximum})}(0,t,n,r,i,o))&+(!df(i)||function(e,t,n,r,i,o){return eh(0,0,i,o)||t.AddError("multipleOf",n,r,{multipleOf:i.multipleOf})}(0,t,n,r,i,o))))&+(!vf(i)||function(e,t,n,r,i,o){let u=fp(e,i),s=u.schema??!1,a=new Of,d=Rl(s)&&lh(u.stack,a,n,r,s,o);return d&&t.Merge([a]),d||t.AddErrors(a.GetErrors()),d}(u,t,n,r,i,o))&+(!yf(i)||function(e,t,n,r,i,o){let u=pp(e,i)??!1,s=u?{...e,pendingResource:!0}:e;return Rl(u)&&lh(s,t,n,r,u,o)}(u,t,n,r,i,o))&+(!Ul(i)||function(e,t,n,r,i,o){let u=_p(e,i)??!1,s=u?{...e,pendingResource:!0}:e;return Rl(u)&&lh(s,t,n,r,u,o)}(u,t,n,r,i,o))&+(!ql(i)||function(e,t,n,r,i,o){return Zf(0,0,i,o)||t.AddError("const",n,r,{allowedValue:i.const})}(0,t,n,r,i,o))&+(!Wl(i)||function(e,t,n,r,i,o){return gp(0,0,i,o)||t.AddError("enum",n,r,{allowedValues:i.enum})}(0,t,n,r,i,o))&+(!Vl(i)||function(e,t,n,r,i,o){let u=!wf(i)||i.then,s=!Fl(i)||i.else,a=new Of,d=lh(e,a,`${n}/if`,r,i.if,o)?lh(e,a,`${n}/then`,r,u,o)||t.AddError("if",n,r,{failingKeyword:"then"}):lh(e,t,`${n}/else`,r,s,o)||t.AddError("if",n,r,{failingKeyword:"else"});return d&&t.Merge([a]),d}(u,t,n,r,i,o))&+(!cf(i)||function(e,t,n,r,i,o){return th(e,t,i,o)||t.AddError("not",n,r,{})}(u,t,n,r,i,o))&+(!Cl(i)||function(e,t,n,r,i,o){let u=[],s=i.allOf.reduce((t,i,s)=>{let a=`${n}/allOf/${s}`,d=new Of,c=lh(e,d,a,r,i,o);return c||u.push(d),c?[...t,d]:t},[]),a=mi(s.length,i.allOf.length)&&t.Merge(s);return a||u.forEach(e=>t.AddErrors(e.GetErrors())),a}(u,t,n,r,i,o))&+(!Tl(i)||function(e,t,n,r,i,o){let u=[],s=i.anyOf.reduce((t,i,s)=>{let a=new Of,d=lh(e,a,`${n}/anyOf/${s}`,r,i,o);return d||u.push(a),d?[...t,a]:t},[]),a=hi(s.length,0)&&t.Merge(s);return a||u.forEach(e=>t.AddErrors(e.GetErrors())),a||t.AddError("anyOf",n,r,{})}(u,t,n,r,i,o))&+(!lf(i)||function(e,t,n,r,i,o){let u=[],s=[],a=i.oneOf.reduce((t,i,a)=>{let d=new Of,c=lh(e,d,`${n}/oneOf/${a}`,r,i,o);return c&&s.push(a),c||u.push(d),c?[...t,d]:t},[]),d=mi(a.length,1)&&t.Merge(a);return!d&&mi(s.length,0)&&u.forEach(e=>t.AddErrors(e.GetErrors())),d||t.AddError("oneOf",n,r,{passingSchemas:s})}(u,t,n,r,i,o))&+(!$f(i)||!ti(o)||function(e,t,n,r,i,o){let u=t.GetIndices(),s=[];return xi(o,0,(o,a)=>{let d=new Of,c=(u.has(a)||lh(e,d,n,r,i.unevaluatedItems,o))&&t.AddIndex(a);return c||s.push(a),c})||t.AddError("unevaluatedItems",n,r,{unevaluatedItems:s})}(u,t,n,r,i,o))&+(!Af(i)||!ci(o)||function(e,t,n,r,i,o){let u=t.GetKeys(),s=[];return xi(Ri(o),0,([o,a])=>{let d=new Of,c=u.has(o)||lh(e,d,n,r,i.unevaluatedProperties,a)&&t.AddKey(o);return c||s.push(o),c})||t.AddError("unevaluatedProperties",n,r,{unevaluatedProperties:s})}(u,t,n,r,i,o)))&&(!Ol(i)||function(e,t,n,r,i,o){return xi(i["~refine"],0,(e,i)=>e.check(o)||t.AddError("~refine",n,r,{index:i,message:e.error(o)}))}(0,t,n,r,i,o))}Dm.clear(),Dm.set("date-time",Ap),Dm.set("date",kp),Dm.set("duration",Op),Dm.set("email",Ep),Dm.set("hostname",cm),Dm.set("idn-email",fm),Dm.set("idn-hostname",pm),Dm.set("ipv4",hm),Dm.set("ipv6",gm),Dm.set("iri-reference",bm),Dm.set("iri",xm),Dm.set("json-pointer-uri-fragment",Am),Dm.set("json-pointer",Om),Dm.set("regex",Im),Dm.set("relative-json-pointer",Rm),Dm.set("time",$p),Dm.set("uri-reference",Mm),Dm.set("uri-template",Tm),Dm.set("uri",Nm),Dm.set("url",jm),Dm.set("uuid",Bm);var fh=0;function ph(...e){let[t,n,r]=Io(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return function(...e){let[t,n,r]=Io(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return dh(Rf(t,n),new Sf,n,r)}(t,n,r)}function mh(...e){let[t,n,r]=Io(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]}),[i,o]=function(...e){let[t,n,r]=Io(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]}),i=Rf(t,n),o=new Of,u=lh(i,o,"#","",n,r),s=o.GetErrors(),a=Xo();return[u,s.map(e=>({...e,message:a(e)}))]}(t,n,r);return o}class hh extends Error{constructor(e,t,n){super(e),Object.defineProperty(this,"cause",{value:{source:e,errors:n,value:t},writable:!1,configurable:!1,enumerable:!1})}}function _h(e,t){let n=Ii(t,"unevaluatedProperties")?{additionalProperties:t.unevaluatedProperties}:{},r=al(ol(e,t));return xo(r)?function(e,t){return Vc(e,t)}(r,n):r}function gh(e){return Ii(e,"additionalProperties")?e.additionalProperties:void 0}function yh(e){return Fi(e)}function vh(e,t,n){return to(t)?function(e,t,n){return ti(n)?n.map(n=>vh(e,t.items,n)):n}(e,t,n):Oo(t)?function(e,t,n){return vh({...e,...t.$defs},so(t.$ref),n)}(e,t,n):Co(t)?function(e,t,n){return vh(e,_h(e,t),n)}(e,t,n):xo(t)?function(e,t,n){if(!ci(n)||ti(n))return n;let r=gh(t);for(let i of Pi(n))Ii(t.properties,i)?n[i]=vh(e,t.properties[i],n[i]):ri(r)&&mi(r,!0)||Vi(r)&&ph(e,r,n[i])?n[i]=vh(e,r,n[i]):delete n[i];return n}(e,t,n):xs(t)?function(e,t,n){if(!ci(n))return n;let r=gh(t),[i,o]=[new RegExp(bs(t)),ks(t)];for(let t of Pi(n))i.test(t)?n[t]=vh(e,o,n[t]):ri(r)&&mi(r,!0)||Vi(r)&&ph(e,r,n[t])?n[t]=vh(e,r,n[t]):delete n[t];return n}(e,t,n):ao(t)?function(e,t,n){return Ii(e,t.$ref)?vh(e,e[t.$ref],n):n}(e,t,n):Bu(t)?function(e,t,n){if(!ti(n))return n;let r=Math.min(n.length,t.items.length);for(let i=0;i<r;i++)n[i]=vh(e,t.items[i],n[i]);return hi(n.length,r)?n.slice(0,r):n}(e,t,n):$u(t)?function(e,t,n){for(let r of t.anyOf){let t=vh(e,r,yh(n));if(ph(e,r,t))return t}return n}(e,t,n):n}function bh(e){return e.map(e=>wh(e))}function wh(e){return function(e,t){for(let n of Pi(e))Ii(t,n)||(t[n]=e[n]);return t}(e,to(e)?eo(wh(e.items),no(e)):Co(e)?Mo(bh(e.allOf)):$u(e)?xu(bh(ll(e.anyOf))):xo(e)?ko(function(e){let t={};for(let n of Pi(e))t[n]=wh(e[n]);return t}(e.properties)):xs(e)?ys(ws(e),wh(ks(e))):Bu(e)?Lu(bh(e.items)):e)}function kh(e){return wh(e)}function xh(...e){let[t,n,r]=Io(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return vh(t,ji().unionPrioritySort?kh(n):n,r)}function $h(e){return ci(e)&&Ii(e,"value")}function Ah(e){return{value:e}}var Sh=/^-?(0|[1-9]\d*)n$/,Oh=/^-?(0|[1-9]\d*)\.\d+$/,Ih=/^-?(0|[1-9]\d*)$/;function Eh(e){let t=e.toLowerCase();return function(e){return Sh.test(e)}(e)?Ah(BigInt(e.slice(0,e.length-1))):function(e){return Oh.test(e)}(e)?Ah(BigInt(e.split(".")[0])):function(e){return Ih.test(e)}(e)?Ah(BigInt(e)):mi(t,"false")?Ah(BigInt(0)):mi(t,"true")?Ah(BigInt(1)):void 0}function Rh(e){return ni(e)?Ah(e):ri(e)?function(e){return mi(e,!0)?Ah(BigInt(1)):Ah(BigInt(0))}(e):ai(e)?Ah(BigInt(Math.trunc(e))):si(e)?Ah(BigInt(0)):li(e)?Eh(e):pi(e)?Ah(BigInt(0)):void 0}function Ph(e){return ni(e)?function(e){return mi(e,BigInt(0))?Ah(!1):mi(e,BigInt(1))?Ah(!0):void 0}(e):ri(e)?Ah(e):ai(e)?function(e){return mi(e,0)?Ah(!1):mi(e,1)?Ah(!0):void 0}(e):si(e)?Ah(!1):li(e)?function(e){return mi(e.toLowerCase(),"false")?Ah(!1):mi(e.toLowerCase(),"true")?Ah(!0):mi(e,"0")?Ah(!1):mi(e,"1")?Ah(!0):void 0}(e):pi(e)?Ah(!1):void 0}function Mh(e){return ni(e)?function(e){return mi(e,BigInt(0))?Ah(null):void 0}(e):ri(e)?function(e){return mi(e,!1)?Ah(null):void 0}(e):ai(e)?function(e){return mi(e,0)?Ah(null):void 0}(e):si(e)?Ah(null):li(e)?function(e){let t=e.toLowerCase();return mi(t,"undefined")||mi(t,"null")||mi(e,"")||mi(e,"0")?Ah(null):void 0}(e):pi(e)?Ah(null):void 0}var Ch=BigInt(Number.MAX_SAFE_INTEGER),Th=BigInt(Number.MIN_SAFE_INTEGER);function qh(e){return ni(e)?function(e){return e<=Ch&&e>=Th?Ah(Number(e)):void 0}(e):ri(e)?function(e){return Ah(e?1:0)}(e):ai(e)?Ah(e):si(e)?Ah(0):li(e)?function(e){let t=+e;if(ai(t))return Ah(t);let n=e.toLowerCase();if(mi(n,"false"))return Ah(0);if(mi(n,"true"))return Ah(1);let r=Rh(e);return $h(r)&&r.value<=Ch&&r.value>=Th?Ah(Number(r.value)):void 0}(e):pi(e)?Ah(0):void 0}function Nh(e){return ni(e)||ri(e)||ai(e)?Ah(e.toString()):si(e)?Ah("null"):li(e)?Ah(e):pi(e)?Ah(""):void 0}function jh(e){return ni(e)?function(e){return mi(e,BigInt(0))?Ah(void 0):void 0}(e):ri(e)?function(e){return mi(e,!1)?Ah(void 0):void 0}(e):ai(e)?function(e){return mi(e,0)?Ah(void 0):void 0}(e):si(e)?Ah(void 0):li(e)?function(e){let t=e.toLowerCase();return mi(t,"undefined")||mi(t,"null")||mi(e,"")||mi(e,"0")?Ah(void 0):void 0}(e):pi(e)?Ah(e):void 0}function Lh(e,t,n){return function(e){return ti(e)?Ah(e):Ah([e])}(n).value.map(n=>Wh(e,t.items,n))}function Bh(e,t,n){return mi(t.const,n)?n:function(e){return pu(e)&&ni(e.const)}(t)?function(e,t,n){let r=Rh(n);return $h(r)&&mi(t.const,r.value)?r.value:n}(0,t,n):function(e){return pu(e)&&ri(e.const)}(t)?function(e,t,n){let r=Ph(n);return $h(r)&&mi(t.const,r.value)?r.value:n}(0,t,n):lu(t)?function(e,t,n){let r=qh(n);return $h(r)&&mi(t.const,r.value)?r.value:n}(0,t,n):fu(t)?function(e,t,n){let r=Nh(n);return $h(r)&&mi(t.const,r.value)?r.value:n}(0,t,n):To()}function Dh(e,t,n,r){let i=Pi(r);for(let[o,u]of t)for(let t of i)o.test(t)||(r[t]=Wh(e,n,r[t]));return r}function zh(e,t,n){return vo(e)&&pi(n[t])}function Uh(e,t,n){return di(n)?function(e,t,n){let r=Ei(t.properties),i=Pi(n);for(let[t,o]of r)for(let r of i)t.test(r)&&!zh(o,r,n)&&(n[r]=Wh(e,o,n[r]));return Ii(t,"additionalProperties")&&ci(t.additionalProperties)?Dh(e,r,t.additionalProperties,n):n}(e,t,n):n}function Fh(e,t,n){return di(n)?function(e,t,n){let r=Ei(t.patternProperties),i=Pi(n);for(let[t,o]of r)for(let r of i)t.test(r)&&(n[r]=Wh(e,o,n[r]));return Ii(t,"additionalProperties")&&ci(t.additionalProperties)?Dh(e,r,t.additionalProperties,n):n}(e,t,n):n}function Wh(e,t,n){return to(t)?Lh(e,t,n):nu(t)?function(e,t,n){let r=Rh(n);return $h(r)?r.value:n}(0,0,n):iu(t)?function(e,t,n){let r=Ph(n);return $h(r)?r.value:n}(0,0,n):Oo(t)?function(e,t,n){return Wh({...e,...t.$defs},so(t.$ref),n)}(e,t,n):Po(t)?function(e,t,n){return Wh(e,al(t),n)}(e,t,n):su(t)?function(e,t,n){let r=qh(n);return $h(r)?Math.trunc(r.value):n}(0,0,n):Co(t)?function(e,t,n){return Wh(e,al(ol(e,t)),n)}(e,t,n):pu(t)?Bh(0,t,n):hu(t)?function(e,t,n){let r=Mh(n);return $h(r)?r.value:n}(0,0,n):yu(t)?function(e,t,n){let r=qh(n);return $h(r)?r.value:n}(0,0,n):xo(t)?Uh(e,t,n):xs(t)?Fh(e,t,n):ao(t)?function(e,t,n){return Ii(e,t.$ref)?Wh(e,e[t.$ref],n):n}(e,t,n):ku(t)?function(e,t,n){let r=Nh(n);return $h(r)?r.value:n}(0,0,n):ua(t)?function(e,t,n){return Wh(e,al(t),n)}(e,t,n):Bu(t)?function(e,t,n){if(!ti(n))return n;for(let r=0;r<Math.min(t.items.length,n.length);r++)n[r]=Wh(e,t.items[r],n[r]);return n}(e,t,n):As(t)?function(e,t,n){let r=jh(n);return $h(r)?r.value:n}(0,0,n):$u(t)?function(e,t,n){if(t.anyOf.some(t=>ph(e,t,n)))return n;let r=t.anyOf.map(t=>Wh(e,t,yh(n))).find(n=>ph(e,t,n));return pi(r)?n:r}(e,t,n):Ss(t)?function(e,t,n){return $h(jh(n))?void 0:n}(0,0,n):n}function Gh(...e){let[t,n,r]=Io(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return Wh(t,n,r)}function Kh(e,t,n){let r=jl(t)?function(e,t){return pi(t)?oi(e.default)?e.default():yh(e.default):t}(t,n):n;return to(t)?function(e,t,n){if(!ti(n))return n;for(let r=0;r<n.length;r++)n[r]=Kh(e,t.items,n[r]);return n}(e,t,r):Oo(t)?function(e,t,n){return Kh({...e,...t.$defs},so(t.$ref),n)}(e,t,r):Co(t)?function(e,t,n){return Kh(e,al(ol(e,t)),n)}(e,t,r):xo(t)?function(e,t,n){if(!ci(n))return n;let r=Pi(t.properties);for(let i of r){let r=Kh(e,t.properties[i],n[i]);(!pi(r)||!vo(t.properties[i])&&Ii(t.properties[i],"default"))&&(n[i]=r)}if(!Ml(t)||ri(t.additionalProperties))return n;for(let i of Pi(n))r.includes(i)||(n[i]=Kh(e,t.additionalProperties,n[i]));return n}(e,t,r):xs(t)?function(e,t,n){if(!ci(n))return n;let[r,i]=[new RegExp(bs(t)),ks(t)];for(let t of Pi(n))r.test(t)&&jl(i)&&(n[t]=Kh(e,i,n[t]));if(!Ml(t))return n;for(let i of Pi(n))r.test(i)||(n[i]=Kh(e,t.additionalProperties,n[i]));return n}(e,t,r):ao(t)?function(e,t,n){return Ii(e,t.$ref)?Kh(e,e[t.$ref],n):n}(e,t,r):Bu(t)?function(e,t,n){if(!ti(n))return n;let[r,i]=[t.items,Math.max(t.items.length,n.length)];for(let t=0;t<i;t++)t<r.length&&(n[t]=Kh(e,r[t],n[t]));return n}(e,t,r):$u(t)?function(e,t,n){for(let r of t.anyOf){let t=Kh(e,r,yh(n));if(ph(e,r,t))return t}return n}(e,t,r):r}function Jh(...e){let[t,n,r]=Io(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return Kh(t,n,r)}function Hh(e){return(...t)=>{let[n,r,i]=Io(t,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return e.reduce((e,t)=>t(n,r,e),i)}}function Vh(e,t,n,r){return function(e){return Vi(e)&&Ii(e,"~codec")&&ci(e["~codec"])&&Ii(e["~codec"],"encode")&&Ii(e["~codec"],"decode")}(n)?mi(e,"Decode")?function(e,t,n){return t["~codec"].decode(n)}(0,n,r):function(e,t,n){return t["~codec"].encode(n)}(0,n,r):r}function Zh(e,t,n,r){return mi(e,"Decode")?function(e,t,n,r){if(!ti(r))return r;for(let i=0;i<r.length;i++)r[i]=o_(e,t,n.items,r[i]);return Vh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=Vh(e,0,n,r);if(!ti(i))return i;for(let r=0;r<i.length;r++)i[r]=o_(e,t,n.items,i[r]);return i}(e,t,n,r)}function Xh(e){return e.reduce((e,t)=>({...e,...t}),{})}function Qh(e,t){for(let n of t)if(!Ci(e,n))return n;return e}function Yh(e,t,n,r){return mi(e,"Decode")?function(e,t,n,r){if(mi(n.allOf.length,0))return Vh(e,0,n,r);let i=n.allOf.map(n=>o_(e,t,n,xh(n,yh(r)))),o=i.every(e=>ci(e))?Xh(i):Qh(r,i);return Vh(e,0,n,o)}(e,t,n,r):function(e,t,n,r){if(mi(n.allOf.length,0))return Vh(e,0,n,r);let i=Vh(e,0,n,r),o=n.allOf.map(n=>o_(e,t,n,xh(n,yh(i))));return o.every(e=>ci(e))?Xh(o):Qh(i,o)}(e,t,n,r)}function e_(e,t,n,r){return mi(e,"Decode")?function(e,t,n,r){if(!di(r))return r;for(let i of Pi(n.properties))Ii(r,i)&&!zh(n.properties[i],i,r)&&(r[i]=o_(e,t,n.properties[i],r[i]));return Vh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=Vh(e,0,n,r);if(!di(i))return i;for(let r of Pi(n.properties))Ii(i,r)&&!zh(n.properties[r],r,i)&&(i[r]=o_(e,t,n.properties[r],i[r]));return i}(e,t,n,r)}function t_(e,t,n,r){return mi(e,"Decode")?function(e,t,n,r){if(!di(r))return r;let i=new RegExp(bs(n));for(let o of Pi(r))i.test(o)&&(r[o]=o_(e,t,ks(n),r[o]));return Vh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=Vh(e,0,n,r);if(!di(i))return i;let o=new RegExp(bs(n));for(let r of Pi(i))o.test(r)&&(i[r]=o_(e,t,ks(n),i[r]));return i}(e,t,n,r)}function n_(e,t,n,r){return Ii(t,n.$ref)?o_(e,t,t[n.$ref],r):r}function r_(e,t,n,r){return mi(e,"Decode")?function(e,t,n,r){if(!ti(r))return r;for(let i=0;i<Math.min(n.items.length,r.length);i++)r[i]=o_(e,t,n.items[i],r[i]);return Vh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=Vh(e,0,n,r);if(!ti(i))return r;for(let r=0;r<Math.min(n.items.length,i.length);r++)i[r]=o_(e,t,n.items[r],i[r]);return i}(e,t,n,r)}function i_(e,t,n,r){return mi(e,"Decode")?function(e,t,n,r){for(let i of n.anyOf)if(ph(t,i,r))return Vh(e,0,n,o_(e,t,i,r));return r}(e,t,n,r):function(e,t,n,r){let i=Vh(e,0,n,r);for(let r of n.anyOf){let n=o_(e,t,r,yh(i));if(ph(t,r,n))return n}return i}(e,t,n,r)}function o_(e,t,n,r){return to(n)?Zh(e,t,n,r):Oo(n)?function(e,t,n,r){return Vh(e,0,n,r=o_(e,{...t,...n.$defs},so(n.$ref),r))}(e,t,n,r):Co(n)?Yh(e,t,n,r):xo(n)?e_(e,t,n,r):xs(n)?t_(e,t,n,r):ao(n)?function(e,t,n,r){return mi(e,"Decode")?Vh(e,0,n,n_(e,t,n,r)):n_(e,t,n,Vh(e,0,n,r))}(e,t,n,r):Bu(n)?r_(e,t,n,r):$u(n)?i_(e,t,n,r):Vh(e,0,n,r)}class u_ extends hh{constructor(e,t){super("Decode",e,t)}}Hh([(e,t,n)=>yh(n),(e,t,n)=>Jh(e,t,n),(e,t,n)=>Gh(e,t,n),(e,t,n)=>xh(e,t,n),(e,t,n)=>function(e,t,n){if(!ph(e,t,n))throw new u_(n,mh(e,t,n));return n}(e,t,n),(e,t,n)=>function(e,t,n){return o_("Decode",e,ji().unionPrioritySort?kh(t):t,n)}(e,t,n)]);class s_ extends hh{constructor(e,t){super("Encode",e,t)}}Hh([(e,t,n)=>yh(n),(e,t,n)=>function(e,t,n){return o_("Encode",e,ji().unionPrioritySort?kh(t):t,n)}(e,t,n),(e,t,n)=>Jh(e,t,n),(e,t,n)=>Gh(e,t,n),(e,t,n)=>xh(e,t,n),(e,t,n)=>function(e,t,n){if(!ph(e,t,n))throw new s_(n,mh(e,t,n));return n}(e,t,n)]);class a_ extends hh{constructor(e,t){super("Parse",e,t)}}function d_(e,t,n){!function(){let e=ji();fh=e.maxErrors,e.maxErrors=e.maxParseErrors}();let r=mh(e,t,n);if(ji().maxErrors=fh,!ph(e,t,n))throw new a_(n,r);return n}Hh([(e,t,n)=>yh(n),(e,t,n)=>Jh(e,t,n),(e,t,n)=>Gh(e,t,n),(e,t,n)=>xh(e,t,n),(e,t,n)=>d_(e,t,n)]),xu([ko({type:cu("insert"),path:wu(),value:$o()}),Object({type:cu("update"),path:wu(),value:$o()}),ko({type:cu("delete"),path:wu()})]);Be(),Be();var c_=200;function l_(e,t,n){return{kind:"error",error:Le(e,t,n)}}function f_(e){return Number.isSafeInteger(e)&&e>0}function p_(e){return Buffer.from(`t1:${e.revision}:${e.offset}`,"utf8").toString("base64url")}function m_(e,t={}){let n=t.mode??"tail";if("status"!==n&&"tail"!==n&&"page"!==n)return l_("invalid_arguments",`Unknown read mode "${String(n)}".`,'Retry with mode set to "status", "tail", or "page", or call thread_list to confirm the thread first.');if(void 0!==t.tail_items){if(!f_(t.tail_items))return l_("invalid_arguments",`tail_items must be a positive whole number; received ${String(t.tail_items)}.`,"Retry with tail_items between 1 and 200, or omit it to take the default 60.");if(t.tail_items>c_)return l_("invalid_arguments",`tail_items ${t.tail_items} exceeds the 200-item cap.`,"Retry with tail_items at most 200, then page backward with the returned cursor if you need more.")}if(void 0!==t.max_bytes){if(!f_(t.max_bytes))return l_("invalid_arguments",`max_bytes must be a positive whole number; received ${String(t.max_bytes)}.`,"Retry with max_bytes between 1 and 1048576, or omit it to take the default 131072.");if(t.max_bytes>pl)return l_("message_too_large",`max_bytes ${t.max_bytes} exceeds the 1048576-byte hard cap.`,"Re-read with max_bytes at most 1048576 and follow next_cursor for the rest of the transcript.")}let r,i,o,u=t.max_bytes??fl,s=t.tail_items??60,a=null;if(void 0!==t.cursor&&(a=function(e){if("string"!=typeof e||0===e.length)return null;let t;try{t=Buffer.from(e,"base64url").toString("utf8")}catch{return null}let n=t.split(":");if(3!==n.length)return null;let[r,i,o]=n;if("t1"!==r)return null;if(!/^\d+\.[0-9a-z]+$/.test(i))return null;let u=Number(o);return!Number.isSafeInteger(u)||u<0?null:{revision:i,offset:u}}(t.cursor),null===a))return l_("cursor_invalid","The cursor is not a cursor this reader issued.","Re-read the thread without a cursor to get a fresh next_cursor, or call thread_list to confirm the thread address.");if("live"===e.kind)i="live_host",o=!1,r={entries:e.entries(),skippedLines:0};else{i="session_jsonl",o=!0!==e.live_host_present;let t=function(e){let t;try{t=Zr(e,"r")}catch{return"missing"}try{let e=[],n=0,r="",i=new Qr("utf8"),o=Buffer.allocUnsafe(65536),u=t=>{let r,i=t.trim();if(0!==i.length){try{r=JSON.parse(i)}catch{return void(n+=1)}"object"!=typeof r||null===r||Array.isArray(r)?n+=1:e.push(r)}};for(;;){let e=Xr(t,o,0,o.length,null);if(0===e)break;r+=i.write(o.subarray(0,e));let n=0,s=r.indexOf("\n",n);for(;-1!==s;)u(r.slice(n,s)),n=s+1,s=r.indexOf("\n",n);r=r.slice(n)}return u(r+i.end()),{entries:e,skippedLines:n}}catch{return{entries:[],skippedLines:0}}finally{void 0!==t&&Vr(t)}}(e.path);if("missing"===t)return l_("not_found",`No session transcript exists at ${e.path}.`,"Call thread_list to get a current thread_id, then read that thread instead.");r=t}let d=r.entries,c=function(e){let t=2166136261;for(let n of e){let e=`${String(n.id??"")}|${String(n.timestamp??"")}`;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619)}return`${e.length}.${(t>>>0).toString(36)}`}(d);if(null!==a&&a.revision!==c)return l_("cursor_stale","The transcript changed after this cursor was issued, so its position no longer names the same entries.","Re-read the thread without a cursor to restart from a current revision.");let l={kind:"ok",source:i,source_incomplete:o,mode:n,total_items:d.length,max_bytes:u,skipped_lines:r.skippedLines};if("status"===n)return{...l,items:[],truncated:!1,next_cursor:null,encoded_bytes:0};let f="tail"===n?Math.max(0,d.length-s):a?.offset??0,p=d.slice(f),m=[],h=0,_=0;for(let e of p){let t=Buffer.byteLength(JSON.stringify(e),"utf8");if(m.length>0&&h+t>u)break;m.push(e),h+=t,_+=1}let g=f+_,y=g<d.length;return{...l,items:m,truncated:y,next_cursor:y?p_({revision:c,offset:g}):null,encoded_bytes:h}}function h_(e,t,n){let r=function(e,t){let n="string"==typeof t?t.trim():"";if(0===n.length)return[];let r=Je();return e.filter(e=>He(e.cwd,n,r))}(Sr(e,t),e.callerWorkspaceRoot()),i=e=>!0===n||r.some(t=>t.thread_id===e),o=t.sessions.filter(e=>i(e.durableSessionId??e.sessionId)),u=xr(e,t),s=u.filter(e=>void 0!==e.error_note&&"live"!==e.status&&i(e.thread_id)),a=new Map(u.map((e,t)=>[e.thread_id,t]));return{kind:"ok",threads:[...o.map(e=>function(e,t){let n=e.durableSessionId??e.sessionId,{name:r,createdAt:i,updatedAt:o,created_at:u,updated_at:s,...a}=e,d=t?.created_at??e.created_at??e.createdAt??(new Date).toISOString();return{...a,thread_id:n,name:t?.title??ut(e.name,null)??"",status:"closed"===e.status?"resumable":"live",created_at:d,updated_at:void 0===t?e.updated_at??e.updatedAt??d:t.updated_at,...void 0===t?{}:{endpoint:t.endpoint,surface:t.surface,alive:t.alive}}}(e,(e=>u.find(t=>t.thread_id===(e.durableSessionId??e.sessionId)&&t.source_host===(e.socket??t.source_host)))(e))),...s.map(Ar)].sort((e,t)=>(a.get(e.thread_id)??Number.MAX_SAFE_INTEGER)-(a.get(t.thread_id)??Number.MAX_SAFE_INTEGER)),scope:!0===n?"all":"workspace"}}async function __(e,t,n,r){let i=Or(e,Sr(e,t),n.thread,r,n.all_scope);if("error"===i.kind)return{kind:"error",error:i};let o=(u=t,s=i.entry.thread_id,u.sessions.find(e=>(e.durableSessionId??e.sessionId)===s));var u,s;if(void 0===o)return function(e,t,n,r){let i=xr(e,t).find(e=>e.thread_id===n);if(void 0===i||void 0===i.error_note||null===i.session_path)return o="not_resumable",u="The thread has no live owner.",s="Retry when the target is live.",{kind:"error",error:Le(o,u,s,a)};var o,u,s,a;let d=m_({kind:"jsonl",path:i.session_path,live_host_present:!1},{mode:"tail",max_bytes:r.max_bytes,cursor:r.cursor});if("error"===d.kind)return{kind:"error",error:d.error};let c=d.items.flatMap(e=>{let t=e.message;return"message"!==e.type||"object"!=typeof t||null===t||Array.isArray(t)?[]:"user"===t.role||"assistant"===t.role||"toolResult"===t.role?[t]:[]}).map((e,t)=>({seq:t+1,role:Ir(e.role),content:JSON.stringify(e.content??e)}));return{kind:"ok",thread_id:n,items:c,truncated:d.truncated,...null===d.next_cursor?{}:{next_cursor:d.next_cursor},source:d.source,source_incomplete:d.source_incomplete,error_note:i.error_note}}(e,t,i.entry.thread_id,n);let a=await function(e,t){return void 0!==t.socket&&void 0!==e.host.endpoint?e.host.endpoint(t.socket):e.host}(e,o).getMessages(function(e){return e.sessionId}(o)),d=m_({kind:"live",entries:()=>a},{mode:"tail",max_bytes:n.max_bytes,cursor:n.cursor});return"error"===d.kind?{kind:"error",error:d.error}:{kind:"ok",thread_id:i.entry.thread_id,items:d.items.map((e,t)=>({seq:t+1,role:Ir(e.role),content:JSON.stringify(e.content??e)})),truncated:d.truncated,...null===d.next_cursor?{}:{next_cursor:d.next_cursor},source:d.source}}function g_(e,t,n,r){return{kind:"error",error:Le(e,t,n,r)}}function y_(e){let t=e instanceof Error?e.message:String(e);return t.startsWith("host_unavailable:")?g_("host_unavailable",`The thread host is unavailable at ${t.slice(17)}.`,"Retry when a host or terminal session is running."):t.startsWith("unsupported:")?g_("unsupported",`The target's endpoint does not accept ${t.slice(12)}.`,"Use thread read to follow the session.",{command:t.slice(12)}):g_("internal_error",`Thread operation failed: ${t}`,"Run omo thread list and retry after checking the target.")}async function v_(e){try{return await e()}catch(e){return y_(e)}}function b_(e){let t=`cli:${e.uid}`,n={...e.env??process.env,OMO_CODING_AGENT_DIR:e.agentDir},r=e.engineStatusAll,i=e.host??cn(0,{env:n,...void 0===r?{}:{statusAll:async()=>un(await r())}}),o=e.store??Kr({agentDir:e.agentDir,resolveTarget:(e,t)=>p(e,t),...void 0===e.workerModuleUrl?{}:{workerModuleUrl:e.workerModuleUrl}}),u=e.now??o.now,s={host:i,store:o,stateDirectory:e.agentDir,sessionsDirectory:()=>Hr(e.agentDir,"sessions"),callerSessionId:()=>br,callerWorkspaceRoot:()=>e.cwd,now:u},a=()=>kr(s),{engine:d,relay:c,endpoints:l,locate:f}=Mr(s,()=>kr(s,{offline:!0})),p=Pr(s,()=>kr(s,{offline:!0}));async function m(e,t){let n=await async function(e,t,n,r,i){return Or(e,St($r(e,await wr(e,n,()=>t({offline:!0})),n,i)),n,r,i)}(s,e=>kr(s,e),e,br,t);return"error"===n.kind?{kind:"error",error:n}:{id:n.entry.thread_id}}return{registerStoreExtension:o.registerStoreExtension,extensionCall:o.extensionCall,principal:t,list:e=>v_(async()=>h_(s,await a(),e.all_scope)),read:e=>v_(async()=>__(s,await a(),{thread:e.thread,max_bytes:e.max_bytes,cursor:e.cursor,all_scope:e.all_scope},br)),send:t=>v_(async()=>void 0!==t.binding_id?await async function(e){if(void 0!==e.thread){let t=await o.bindingView({now:u(),binding_id:e.binding_id});if(null===t||t.session_durable_id!==e.thread){let n=await m(e.thread,e.all_scope);if("kind"in n)return n;if(null!==t&&t.session_durable_id!==n.id)return g_("invalid_arguments",`Binding ${t.binding_id} delivers to session ${t.session_durable_id}, not ${n.id}.`,"Drop the target (the binding names its session) or pass the binding of that session.",{binding_id:t.binding_id,session:t.session_durable_id})}}return void 0!==e.expected_turn_id?g_("invalid_arguments","A binding message never steers, so it takes no expected_turn_id.","Drop expected_turn_id."):"steer"===e.mode?g_("invalid_arguments","A binding message is delivered as auto or follow_up, never steer.","Send with mode auto or follow_up, or omit it for the binding's inbound_mode."):await c.inbound({binding_id:e.binding_id,event_id:e.idempotency_key??Jr(),text:e.text,...void 0===e.author?{}:{author:e.author},...void 0===e.mode?{}:{mode:e.mode}})}({...t,binding_id:t.binding_id}):void 0===t.thread?g_("invalid_arguments","A send without a binding needs a target session.","Pass the target session, or --binding to deliver through a binding."):void 0!==t.author?g_("invalid_arguments","An author names a human in a bound external thread; a send without a binding has none.","Pass binding_id with the author, or drop the author."):await d.deliver({sender:{kind:"cli",uid:e.uid,user:e.user},target:t.thread,text:t.text,...void 0===t.mode?{}:{mode:t.mode},...void 0===t.expected_turn_id?{}:{expected_turn_id:t.expected_turn_id},...void 0===t.all_scope?{}:{all_scope:t.all_scope},...void 0===t.idempotency_key?{}:{idempotency_key:t.idempotency_key}})),bind:e=>v_(async()=>{let n=await m(e.session,e.all_scope);return"kind"in n?n:await c.bind({principal:t,...w_(e),binding:{...e.binding,session_durable_id:n.id}})}),unbind:e=>v_(()=>c.unbind({principal:t,...w_(e),binding_id:e.binding_id,expected_revision:e.expected_revision})),rebind:e=>v_(async()=>{let n=await m(e.session,e.all_scope);return"kind"in n?n:await c.rebind({principal:t,...w_(e),binding_id:e.binding_id,expected_revision:e.expected_revision,session_durable_id:n.id})}),bindings:e=>v_(async()=>{let{session:t,all_scope:n,cursor:r,limit:i,...o}=e,u=void 0===t?void 0:await m(t,n);return void 0!==u&&"kind"in u?u:await c.bindings({filter:{...o,...void 0===u?{}:{session_durable_id:u.id}},...void 0===r?{}:{cursor:r},...void 0===i?{}:{limit:i}})}),report:e=>v_(async()=>{let n=Jn.find(t=>t===e.kind);if(void 0===n)return g_("invalid_arguments",`The report kind must be one of ${Jn.join(", ")}.`,"Pass milestone, report, question or completion.");let r=e.request_kind;if(void 0!==r&&("string"!=typeof(i=r)||!Rn.includes(i)))return g_("invalid_arguments",`The request kind must be one of ${Rn.join(", ")}.`,"Pass question, select, confirm, input or editor.");var i;let o=await m(e.session,e.all_scope);if("kind"in o)return o;let u=await c.report({principal:t,...w_(e),session_durable_id:o.id,event:n,text:e.text,...void 0===e.binding_id?{}:{binding_id:e.binding_id},...void 0===e.request_id?{}:{request_id:e.request_id},...void 0===r?{}:{request_kind:r}});if("ok"!==u.kind)return u;let{arm_seq:s,...a}=u;return a.armed&&await async function(e){let t=await f(e).catch(()=>null);null!==t&&await l.wake(t,[]).catch(()=>{})}(o.id),a}),outbox:e=>v_(()=>c.outbox(e)),ack:e=>v_(()=>c.ack(e)),answer:e=>v_(()=>c.answer({binding_id:e.binding_id,reply_token:e.reply_token,answer:e.answer,...void 0===e.author?{}:{author:e.author}})),locate:e=>v_(async()=>{let t=await a(),n=Or(s,Sr(s,t),e.thread,br,e.all_scope);if("error"===n.kind)return{kind:"error",error:n};let r=xr(s,t).filter(e=>e.thread_id===n.entry.thread_id),i=r.find(e=>e.alive)??r[0];if(void 0===i)return g_("not_found",`Thread ${n.entry.thread_id} is not in the address book.`,"Run omo thread list --all-scope.");let{thread_id:o,title:u,cwd:d,status:c,session_path:l,endpoint:f,surface:p,alive:m}=i;return{kind:"ok",thread:{thread_id:o,title:u,cwd:d,status:c,session_path:l,endpoint:f,surface:p,alive:m}}}),release:async(e,t)=>{let n=i.gateway?.releaseSession;if(void 0===n||null===e.endpoint)return{success:!1,error:"release_unsupported"};try{return await n(e.endpoint,{reason:"takeover",...t})}catch(e){let t=y_(e);return{success:!1,error:t.error.code,errorData:{hint:t.error.message}}}},dispose:()=>(c.dispose(),o.dispose())}}function w_(e){return void 0===e.idempotency_key?{}:{idempotency_key:e.idempotency_key}}Rr(),pt();var k_="5.1.14",x_=Dr(Lr(jr(Br(import.meta.url)),"..","..","extensions","omo.js")),$_=Nr(Br(new URL(`./${Gr}`,x_)));function A_(e){return b_(void 0===e.workerModuleUrl&&$_?{...e,workerModuleUrl:x_}:e)}export{k_ as SDK_VERSION,A_ as createThreadSdk,dt as readSessionFacts};