@aifight/aifight 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/README.md +160 -0
  2. package/dist/bin.mjs +291 -0
  3. package/dist/index.mjs +107 -0
  4. package/dist/schemas/README.md +57 -0
  5. package/dist/schemas/common/README.md +40 -0
  6. package/dist/schemas/common/action.schema.json +19 -0
  7. package/dist/schemas/common/error.schema.json +23 -0
  8. package/dist/schemas/common/event.schema.json +33 -0
  9. package/dist/schemas/common/game_result.schema.json +31 -0
  10. package/dist/schemas/common/player_identity.schema.json +29 -0
  11. package/dist/schemas/common/player_info.schema.json +27 -0
  12. package/dist/schemas/common/rules.schema.json +34 -0
  13. package/dist/schemas/games/README.md +43 -0
  14. package/dist/schemas/games/coup/README.md +104 -0
  15. package/dist/schemas/games/coup/action.schema.json +198 -0
  16. package/dist/schemas/games/coup/event.schema.json +249 -0
  17. package/dist/schemas/games/coup/rules.schema.json +46 -0
  18. package/dist/schemas/games/coup/state.schema.json +123 -0
  19. package/dist/schemas/games/liars_dice/README.md +59 -0
  20. package/dist/schemas/games/liars_dice/action.schema.json +45 -0
  21. package/dist/schemas/games/liars_dice/event.schema.json +120 -0
  22. package/dist/schemas/games/liars_dice/rules.schema.json +36 -0
  23. package/dist/schemas/games/liars_dice/state.schema.json +72 -0
  24. package/dist/schemas/games/texas_holdem/README.md +58 -0
  25. package/dist/schemas/games/texas_holdem/action.schema.json +88 -0
  26. package/dist/schemas/games/texas_holdem/config.schema.json +30 -0
  27. package/dist/schemas/games/texas_holdem/event.schema.json +135 -0
  28. package/dist/schemas/games/texas_holdem/rules.schema.json +39 -0
  29. package/dist/schemas/games/texas_holdem/state.schema.json +98 -0
  30. package/dist/schemas/messages/README.md +98 -0
  31. package/dist/schemas/messages/client_action.schema.json +20 -0
  32. package/dist/schemas/messages/client_join_queue.schema.json +39 -0
  33. package/dist/schemas/messages/client_leave_queue.schema.json +18 -0
  34. package/dist/schemas/messages/client_match_confirm.schema.json +25 -0
  35. package/dist/schemas/messages/client_runtime_status.schema.json +46 -0
  36. package/dist/schemas/messages/server_action_request.schema.json +71 -0
  37. package/dist/schemas/messages/server_error.schema.json +16 -0
  38. package/dist/schemas/messages/server_event.schema.json +30 -0
  39. package/dist/schemas/messages/server_game_over.schema.json +49 -0
  40. package/dist/schemas/messages/server_game_start.schema.json +99 -0
  41. package/dist/schemas/messages/server_game_state.schema.json +33 -0
  42. package/dist/schemas/messages/server_match_cancelled.schema.json +51 -0
  43. package/dist/schemas/messages/server_match_confirm_request.schema.json +37 -0
  44. package/dist/schemas/messages/server_queue_joined.schema.json +26 -0
  45. package/dist/schemas/messages/server_queue_left.schema.json +24 -0
  46. package/dist/schemas/messages/server_readiness_check.schema.json +42 -0
  47. package/dist/schemas/messages/server_welcome.schema.json +49 -0
  48. package/dist/schemas/rest/README.md +85 -0
  49. package/dist/schemas/rest/agent_status_response.schema.json +34 -0
  50. package/dist/schemas/rest/claim_request.schema.json +20 -0
  51. package/dist/schemas/rest/claim_response.schema.json +24 -0
  52. package/dist/schemas/rest/error_response.schema.json +15 -0
  53. package/dist/schemas/rest/register_request.schema.json +35 -0
  54. package/dist/schemas/rest/register_response.schema.json +54 -0
  55. package/dist/types/account/credentials.d.ts +29 -0
  56. package/dist/types/account/errors.d.ts +61 -0
  57. package/dist/types/account/registration.d.ts +26 -0
  58. package/dist/types/agents/agent.d.ts +82 -0
  59. package/dist/types/agents/state-machine.d.ts +96 -0
  60. package/dist/types/bridge/config.d.ts +35 -0
  61. package/dist/types/bridge/hermes-provider.d.ts +9 -0
  62. package/dist/types/bridge/openclaw-provider.d.ts +9 -0
  63. package/dist/types/bridge/pairing.d.ts +18 -0
  64. package/dist/types/bridge/provider.d.ts +18 -0
  65. package/dist/types/bridge/runner.d.ts +30 -0
  66. package/dist/types/bridge/service.d.ts +55 -0
  67. package/dist/types/bridge/update-check.d.ts +23 -0
  68. package/dist/types/cli/agent-resolver.d.ts +25 -0
  69. package/dist/types/cli/argv.d.ts +13 -0
  70. package/dist/types/cli/commands/agent-list.d.ts +2 -0
  71. package/dist/types/cli/commands/agent-status.d.ts +2 -0
  72. package/dist/types/cli/commands/bridge-accept.d.ts +2 -0
  73. package/dist/types/cli/commands/bridge-challenge.d.ts +2 -0
  74. package/dist/types/cli/commands/bridge-connect.d.ts +2 -0
  75. package/dist/types/cli/commands/bridge-register.d.ts +2 -0
  76. package/dist/types/cli/commands/bridge-run.d.ts +7 -0
  77. package/dist/types/cli/commands/bridge-service.d.ts +3 -0
  78. package/dist/types/cli/commands/bridge-set.d.ts +2 -0
  79. package/dist/types/cli/commands/bridge-start.d.ts +2 -0
  80. package/dist/types/cli/commands/bridge-status.d.ts +2 -0
  81. package/dist/types/cli/commands/bridge-uninstall.d.ts +4 -0
  82. package/dist/types/cli/commands/config-init.d.ts +2 -0
  83. package/dist/types/cli/commands/config-probe.d.ts +2 -0
  84. package/dist/types/cli/commands/config-validate.d.ts +2 -0
  85. package/dist/types/cli/commands/daily-off.d.ts +2 -0
  86. package/dist/types/cli/commands/daily-on.d.ts +2 -0
  87. package/dist/types/cli/commands/daily-set.d.ts +2 -0
  88. package/dist/types/cli/commands/daily-show.d.ts +2 -0
  89. package/dist/types/cli/commands/doctor.d.ts +2 -0
  90. package/dist/types/cli/commands/init.d.ts +2 -0
  91. package/dist/types/cli/commands/join.d.ts +2 -0
  92. package/dist/types/cli/commands/leave.d.ts +2 -0
  93. package/dist/types/cli/commands/mcp.d.ts +2 -0
  94. package/dist/types/cli/commands/runtime-management.d.ts +16 -0
  95. package/dist/types/cli/commands/runtime-setup-state.d.ts +21 -0
  96. package/dist/types/cli/commands/runtime-setup.d.ts +23 -0
  97. package/dist/types/cli/commands/serve.d.ts +2 -0
  98. package/dist/types/cli/commands/service/launchd.d.ts +71 -0
  99. package/dist/types/cli/commands/service/platform.d.ts +69 -0
  100. package/dist/types/cli/commands/service/systemd.d.ts +55 -0
  101. package/dist/types/cli/commands/service/types.d.ts +64 -0
  102. package/dist/types/cli/commands/service-install.d.ts +29 -0
  103. package/dist/types/cli/commands/setup.d.ts +2 -0
  104. package/dist/types/cli/commands/shutdown.d.ts +2 -0
  105. package/dist/types/cli/commands/stubs.d.ts +24 -0
  106. package/dist/types/cli/commands/version.d.ts +2 -0
  107. package/dist/types/cli/control-client.d.ts +59 -0
  108. package/dist/types/cli/format.d.ts +52 -0
  109. package/dist/types/cli/main.d.ts +18 -0
  110. package/dist/types/cli/runtime-files.d.ts +11 -0
  111. package/dist/types/cli/shared.d.ts +74 -0
  112. package/dist/types/controlapi/profile-routes.d.ts +49 -0
  113. package/dist/types/controlapi/server.d.ts +3 -0
  114. package/dist/types/controlapi/types.d.ts +136 -0
  115. package/dist/types/daemon/agent-decision-adapter.d.ts +40 -0
  116. package/dist/types/daemon/lifecycle.d.ts +85 -0
  117. package/dist/types/daemon/router.d.ts +97 -0
  118. package/dist/types/daemon/runtime-files-write.d.ts +76 -0
  119. package/dist/types/decision/direct-model/anthropic.d.ts +12 -0
  120. package/dist/types/decision/direct-model/errors.d.ts +59 -0
  121. package/dist/types/decision/direct-model/openai.d.ts +12 -0
  122. package/dist/types/decision/direct-model/types.d.ts +20 -0
  123. package/dist/types/decision/parser-types.d.ts +31 -0
  124. package/dist/types/decision/prompt-builder.d.ts +10 -0
  125. package/dist/types/decision/provider.d.ts +50 -0
  126. package/dist/types/decision/types.d.ts +87 -0
  127. package/dist/types/games/_shared/player-info.d.ts +14 -0
  128. package/dist/types/games/coup/action-parser.d.ts +3 -0
  129. package/dist/types/games/coup/fallback.d.ts +8 -0
  130. package/dist/types/games/coup/state-formatter.d.ts +14 -0
  131. package/dist/types/games/liars_dice/action-parser.d.ts +3 -0
  132. package/dist/types/games/liars_dice/fallback.d.ts +8 -0
  133. package/dist/types/games/liars_dice/state-formatter.d.ts +14 -0
  134. package/dist/types/games/texas_holdem/action-parser.d.ts +3 -0
  135. package/dist/types/games/texas_holdem/fallback.d.ts +8 -0
  136. package/dist/types/games/texas_holdem/state-formatter.d.ts +14 -0
  137. package/dist/types/identity/identity-manager.d.ts +59 -0
  138. package/dist/types/index.d.ts +30 -0
  139. package/dist/types/llm/adapter-registry.d.ts +27 -0
  140. package/dist/types/llm/adapters/anthropic-messages.d.ts +2 -0
  141. package/dist/types/llm/adapters/deepseek-chat-completions.d.ts +2 -0
  142. package/dist/types/llm/adapters/openai-chat-compat.d.ts +2 -0
  143. package/dist/types/llm/adapters/openai-chat-completions.d.ts +2 -0
  144. package/dist/types/llm/adapters/openai-responses.d.ts +2 -0
  145. package/dist/types/llm/adapters/types.d.ts +128 -0
  146. package/dist/types/llm/capabilities/validate-capabilities.d.ts +68 -0
  147. package/dist/types/mcp/control-client.d.ts +54 -0
  148. package/dist/types/mcp/profile-tools.d.ts +10 -0
  149. package/dist/types/mcp/server.d.ts +10 -0
  150. package/dist/types/mcp/tools.d.ts +31 -0
  151. package/dist/types/mcp/types.d.ts +27 -0
  152. package/dist/types/profile/config-schema.d.ts +199 -0
  153. package/dist/types/profile/identity-schema.d.ts +75 -0
  154. package/dist/types/profile/index.d.ts +7 -0
  155. package/dist/types/profile/migrate.d.ts +16 -0
  156. package/dist/types/profile/profile-loader.d.ts +64 -0
  157. package/dist/types/profile/secret-ref.d.ts +82 -0
  158. package/dist/types/profile/soul.d.ts +46 -0
  159. package/dist/types/profile/strategy-schema.d.ts +70 -0
  160. package/dist/types/protocol/schemas.d.ts +11 -0
  161. package/dist/types/protocol/types.d.ts +1333 -0
  162. package/dist/types/reflection/proposal-store.d.ts +50 -0
  163. package/dist/types/reflection/reflection-engine.d.ts +81 -0
  164. package/dist/types/scheduler/daily.d.ts +47 -0
  165. package/dist/types/scheduler/types.d.ts +42 -0
  166. package/dist/types/session/match-session-manager.d.ts +113 -0
  167. package/dist/types/session/session-context-builder.d.ts +68 -0
  168. package/dist/types/store/errors.d.ts +23 -0
  169. package/dist/types/store/paths.d.ts +3 -0
  170. package/dist/types/store/schema.generated.d.ts +1 -0
  171. package/dist/types/store/sqlite.d.ts +36 -0
  172. package/dist/types/wsclient/client.d.ts +220 -0
  173. package/dist/types/wsclient/errors.d.ts +106 -0
  174. package/dist/types/wsclient/frame-handler.d.ts +20 -0
  175. package/dist/types/wsclient/reconnect.d.ts +84 -0
  176. package/package.json +53 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,107 @@
1
+ import { createRequire } from "module"; const require = createRequire(import.meta.url);
2
+ var Ud=Object.create;var sa=Object.defineProperty;var Wd=Object.getOwnPropertyDescriptor;var Vd=Object.getOwnPropertyNames;var Hd=Object.getPrototypeOf,zd=Object.prototype.hasOwnProperty;var F=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Kd=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Vd(e))!zd.call(t,s)&&s!==r&&sa(t,s,{get:()=>e[s],enumerable:!(n=Wd(e,s))||n.enumerable});return t};var oe=(t,e,r)=>(r=t!=null?Ud(Hd(t)):{},Kd(e||!t||!t.__esModule?sa(r,"default",{value:t,enumerable:!0}):r,t));var $r=_(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.regexpCode=A.getEsmExportName=A.getProperty=A.safeStringify=A.stringify=A.strConcat=A.addCodeArg=A.str=A._=A.nil=A._Code=A.Name=A.IDENTIFIER=A._CodeOrName=void 0;var Er=class{};A._CodeOrName=Er;A.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ht=class extends Er{constructor(e){if(super(),!A.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};A.Name=ht;var ie=class extends Er{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof ht&&(r[n.str]=(r[n.str]||0)+1),r),{})}};A._Code=ie;A.nil=new ie("");function la(t,...e){let r=[t[0]],n=0;for(;n<e.length;)ks(r,e[n]),r.push(t[++n]);return new ie(r)}A._=la;var $s=new ie("+");function ua(t,...e){let r=[Sr(t[0])],n=0;for(;n<e.length;)r.push($s),ks(r,e[n]),r.push($s,Sr(t[++n]));return Xd(r),new ie(r)}A.str=ua;function ks(t,e){e instanceof ie?t.push(...e._items):e instanceof ht?t.push(e):t.push(ef(e))}A.addCodeArg=ks;function Xd(t){let e=1;for(;e<t.length-1;){if(t[e]===$s){let r=Qd(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Qd(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof ht||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof ht))return`"${t}${e.slice(1)}`}function Zd(t,e){return e.emptyStr()?t:t.emptyStr()?e:ua`${t}${e}`}A.strConcat=Zd;function ef(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Sr(Array.isArray(t)?t.join(","):t)}function tf(t){return new ie(Sr(t))}A.stringify=tf;function Sr(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}A.safeStringify=Sr;function rf(t){return typeof t=="string"&&A.IDENTIFIER.test(t)?new ie(`.${t}`):la`[${t}]`}A.getProperty=rf;function nf(t){if(typeof t=="string"&&A.IDENTIFIER.test(t))return new ie(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}A.getEsmExportName=nf;function sf(t){return new ie(t.toString())}A.regexpCode=sf});var Rs=_(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.ValueScope=ee.ValueScopeName=ee.Scope=ee.varKinds=ee.UsedValueState=void 0;var Z=$r(),Ps=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},mn;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(mn||(ee.UsedValueState=mn={}));ee.varKinds={const:new Z.Name("const"),let:new Z.Name("let"),var:new Z.Name("var")};var yn=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Z.Name?e:this.name(e)}name(e){return new Z.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};ee.Scope=yn;var gn=class extends Z.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Z._)`.${new Z.Name(r)}[${n}]`}};ee.ValueScopeName=gn;var of=(0,Z._)`\n`,Ts=class extends yn{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?of:Z.nil}}get(){return this._scope}name(e){return new gn(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(e),{prefix:o}=s,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let u=a.get(i);if(u)return u}else a=this._values[o]=new Map;a.set(i,s);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,s.setValue(r,{property:o,itemIndex:l}),s}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Z._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(e,r,n={},s){let o=Z.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,mn.Started);let u=r(l);if(u){let d=this.opts.es5?ee.varKinds.var:ee.varKinds.const;o=(0,Z._)`${o}${d} ${l} = ${u};${this.opts._n}`}else if(u=s?.(l))o=(0,Z._)`${o}${u}${this.opts._n}`;else throw new Ps(l);c.set(l,mn.Completed)})}return o}};ee.ValueScope=Ts});var P=_(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.or=T.and=T.not=T.CodeGen=T.operators=T.varKinds=T.ValueScopeName=T.ValueScope=T.Scope=T.Name=T.regexpCode=T.stringify=T.getProperty=T.nil=T.strConcat=T.str=T._=void 0;var x=$r(),he=Rs(),Ge=$r();Object.defineProperty(T,"_",{enumerable:!0,get:function(){return Ge._}});Object.defineProperty(T,"str",{enumerable:!0,get:function(){return Ge.str}});Object.defineProperty(T,"strConcat",{enumerable:!0,get:function(){return Ge.strConcat}});Object.defineProperty(T,"nil",{enumerable:!0,get:function(){return Ge.nil}});Object.defineProperty(T,"getProperty",{enumerable:!0,get:function(){return Ge.getProperty}});Object.defineProperty(T,"stringify",{enumerable:!0,get:function(){return Ge.stringify}});Object.defineProperty(T,"regexpCode",{enumerable:!0,get:function(){return Ge.regexpCode}});Object.defineProperty(T,"Name",{enumerable:!0,get:function(){return Ge.Name}});var wn=Rs();Object.defineProperty(T,"Scope",{enumerable:!0,get:function(){return wn.Scope}});Object.defineProperty(T,"ValueScope",{enumerable:!0,get:function(){return wn.ValueScope}});Object.defineProperty(T,"ValueScopeName",{enumerable:!0,get:function(){return wn.ValueScopeName}});Object.defineProperty(T,"varKinds",{enumerable:!0,get:function(){return wn.varKinds}});T.operators={GT:new x._Code(">"),GTE:new x._Code(">="),LT:new x._Code("<"),LTE:new x._Code("<="),EQ:new x._Code("==="),NEQ:new x._Code("!=="),NOT:new x._Code("!"),OR:new x._Code("||"),AND:new x._Code("&&"),ADD:new x._Code("+")};var De=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},xs=class extends De{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?he.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Ut(this.rhs,e,r)),this}get names(){return this.rhs instanceof x._CodeOrName?this.rhs.names:{}}},_n=class extends De{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof x.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Ut(this.rhs,e,r),this}get names(){let e=this.lhs instanceof x.Name?{}:{...this.lhs.names};return bn(e,this.rhs)}},Os=class extends _n{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Ns=class extends De{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},As=class extends De{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Cs=class extends De{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Is=class extends De{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Ut(this.code,e,r),this}get names(){return this.code instanceof x._CodeOrName?this.code.names:{}}},kr=class extends De{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(e,r)||(af(e,o.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>yt(e,r.names),{})}},je=class extends kr{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Ms=class extends kr{},Bt=class extends je{};Bt.kind="else";var pt=class t extends je{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Bt(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(da(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Ut(this.condition,e,r),this}get names(){let e=super.names;return bn(e,this.condition),this.else&&yt(e,this.else.names),e}};pt.kind="if";var mt=class extends je{};mt.kind="for";var Ls=class extends mt{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Ut(this.iteration,e,r),this}get names(){return yt(super.names,this.iteration.names)}},Ds=class extends mt{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?he.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return`for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=bn(super.names,this.from);return bn(e,this.to)}},vn=class extends mt{constructor(e,r,n,s){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=s}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Ut(this.iterable,e,r),this}get names(){return yt(super.names,this.iterable.names)}},Pr=class extends je{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Pr.kind="func";var Tr=class extends kr{render(e){return"return "+super.render(e)}};Tr.kind="return";var js=class extends je{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,s;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(s=this.finally)===null||s===void 0||s.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&yt(e,this.catch.names),this.finally&&yt(e,this.finally.names),e}},Rr=class extends je{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Rr.kind="catch";var xr=class extends je{render(e){return"finally"+super.render(e)}};xr.kind="finally";var qs=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
3
+ `:""},this._extScope=e,this._scope=new he.Scope({parent:e}),this._nodes=[new Ms]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new xs(e,o,n)),o}const(e,r,n){return this._def(he.varKinds.const,e,r,n)}let(e,r,n){return this._def(he.varKinds.let,e,r,n)}var(e,r,n){return this._def(he.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new _n(e,r,n))}add(e,r){return this._leafNode(new Os(e,T.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==x.nil&&this._leafNode(new Is(e)),this}object(...e){let r=["{"];for(let[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,x.addCodeArg)(r,s));return r.push("}"),new x._Code(r)}if(e,r,n){if(this._blockNode(new pt(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new pt(e))}else(){return this._elseNode(new Bt)}endIf(){return this._endBlockNode(pt,Bt)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ls(e),r)}forRange(e,r,n,s,o=this.opts.es5?he.varKinds.var:he.varKinds.let){let i=this._scope.toName(e);return this._for(new Ds(o,i,r,n),()=>s(i))}forOf(e,r,n,s=he.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof x.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,x._)`${i}.length`,a=>{this.var(o,(0,x._)`${i}[${a}]`),n(o)})}return this._for(new vn("of",s,o,r),()=>n(o))}forIn(e,r,n,s=this.opts.es5?he.varKinds.var:he.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,x._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new vn("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(mt)}label(e){return this._leafNode(new Ns(e))}break(e){return this._leafNode(new As(e))}return(e){let r=new Tr;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Tr)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new js;if(this._blockNode(s),this.code(e),r){let o=this.name("e");this._currNode=s.catch=new Rr(o),r(o)}return n&&(this._currNode=s.finally=new xr,this.code(n)),this._endBlockNode(Rr,xr)}throw(e){return this._leafNode(new Cs(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=x.nil,n,s){return this._blockNode(new Pr(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(Pr)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof pt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};T.CodeGen=qs;function yt(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function bn(t,e){return e instanceof x._CodeOrName?yt(t,e.names):t}function Ut(t,e,r){if(t instanceof x.Name)return n(t);if(!s(t))return t;return new x._Code(t._items.reduce((o,i)=>(i instanceof x.Name&&(i=n(i)),i instanceof x._Code?o.push(...i._items):o.push(i),o),[]));function n(o){let i=r[o.str];return i===void 0||e[o.str]!==1?o:(delete e[o.str],i)}function s(o){return o instanceof x._Code&&o._items.some(i=>i instanceof x.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function af(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function da(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,x._)`!${Fs(t)}`}T.not=da;var cf=fa(T.operators.AND);function lf(...t){return t.reduce(cf)}T.and=lf;var uf=fa(T.operators.OR);function df(...t){return t.reduce(uf)}T.or=df;function fa(t){return(e,r)=>e===x.nil?r:r===x.nil?e:(0,x._)`${Fs(e)} ${t} ${Fs(r)}`}function Fs(t){return t instanceof x.Name?t:(0,x._)`(${t})`}});var O=_(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.checkStrictMode=R.getErrorPath=R.Type=R.useFunc=R.setEvaluated=R.evaluatedPropsToName=R.mergeEvaluated=R.eachItem=R.unescapeJsonPointer=R.escapeJsonPointer=R.escapeFragment=R.unescapeFragment=R.schemaRefOrVal=R.schemaHasRulesButRef=R.schemaHasRules=R.checkUnknownRules=R.alwaysValidSchema=R.toHash=void 0;var I=P(),ff=$r();function hf(t){let e={};for(let r of t)e[r]=!0;return e}R.toHash=hf;function pf(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(ma(t,e),!ya(e,t.self.RULES.all))}R.alwaysValidSchema=pf;function ma(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let s=n.RULES.keywords;for(let o in e)s[o]||va(t,`unknown keyword: "${o}"`)}R.checkUnknownRules=ma;function ya(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}R.schemaHasRules=ya;function mf(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}R.schemaHasRulesButRef=mf;function yf({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,I._)`${r}`}return(0,I._)`${t}${e}${(0,I.getProperty)(n)}`}R.schemaRefOrVal=yf;function gf(t){return ga(decodeURIComponent(t))}R.unescapeFragment=gf;function _f(t){return encodeURIComponent(Us(t))}R.escapeFragment=_f;function Us(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}R.escapeJsonPointer=Us;function ga(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}R.unescapeJsonPointer=ga;function vf(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}R.eachItem=vf;function ha({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,o,i,a)=>{let c=i===void 0?o:i instanceof I.Name?(o instanceof I.Name?t(s,o,i):e(s,o,i),i):o instanceof I.Name?(e(s,i,o),o):r(o,i);return a===I.Name&&!(c instanceof I.Name)?n(s,c):c}}R.mergeEvaluated={props:ha({mergeNames:(t,e,r)=>t.if((0,I._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,I._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,I._)`${r} || {}`).code((0,I._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,I._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,I._)`${r} || {}`),Ws(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:_a}),items:ha({mergeNames:(t,e,r)=>t.if((0,I._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,I._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,I._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,I._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function _a(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,I._)`{}`);return e!==void 0&&Ws(t,r,e),r}R.evaluatedPropsToName=_a;function Ws(t,e,r){Object.keys(r).forEach(n=>t.assign((0,I._)`${e}${(0,I.getProperty)(n)}`,!0))}R.setEvaluated=Ws;var pa={};function bf(t,e){return t.scopeValue("func",{ref:e,code:pa[e.code]||(pa[e.code]=new ff._Code(e.code))})}R.useFunc=bf;var Bs;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Bs||(R.Type=Bs={}));function wf(t,e,r){if(t instanceof I.Name){let n=e===Bs.Num;return r?n?(0,I._)`"[" + ${t} + "]"`:(0,I._)`"['" + ${t} + "']"`:n?(0,I._)`"/" + ${t}`:(0,I._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,I.getProperty)(t).toString():"/"+Us(t)}R.getErrorPath=wf;function va(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}R.checkStrictMode=va});var qe=_(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});var z=P(),Ef={data:new z.Name("data"),valCxt:new z.Name("valCxt"),instancePath:new z.Name("instancePath"),parentData:new z.Name("parentData"),parentDataProperty:new z.Name("parentDataProperty"),rootData:new z.Name("rootData"),dynamicAnchors:new z.Name("dynamicAnchors"),vErrors:new z.Name("vErrors"),errors:new z.Name("errors"),this:new z.Name("this"),self:new z.Name("self"),scope:new z.Name("scope"),json:new z.Name("json"),jsonPos:new z.Name("jsonPos"),jsonLen:new z.Name("jsonLen"),jsonPart:new z.Name("jsonPart")};Vs.default=Ef});var Or=_(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.extendErrors=K.resetErrorsCount=K.reportExtraError=K.reportError=K.keyword$DataError=K.keywordError=void 0;var N=P(),En=O(),X=qe();K.keywordError={message:({keyword:t})=>(0,N.str)`must pass "${t}" keyword validation`};K.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,N.str)`"${t}" keyword must be ${e} ($data)`:(0,N.str)`"${t}" keyword is invalid ($data)`};function Sf(t,e=K.keywordError,r,n){let{it:s}=t,{gen:o,compositeRule:i,allErrors:a}=s,c=Ea(t,e,r);n??(i||a)?ba(o,c):wa(s,(0,N._)`[${c}]`)}K.reportError=Sf;function $f(t,e=K.keywordError,r){let{it:n}=t,{gen:s,compositeRule:o,allErrors:i}=n,a=Ea(t,e,r);ba(s,a),o||i||wa(n,X.default.vErrors)}K.reportExtraError=$f;function kf(t,e){t.assign(X.default.errors,e),t.if((0,N._)`${X.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,N._)`${X.default.vErrors}.length`,e),()=>t.assign(X.default.vErrors,null)))}K.resetErrorsCount=kf;function Pf({gen:t,keyword:e,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",s,X.default.errors,a=>{t.const(i,(0,N._)`${X.default.vErrors}[${a}]`),t.if((0,N._)`${i}.instancePath === undefined`,()=>t.assign((0,N._)`${i}.instancePath`,(0,N.strConcat)(X.default.instancePath,o.errorPath))),t.assign((0,N._)`${i}.schemaPath`,(0,N.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,N._)`${i}.schema`,r),t.assign((0,N._)`${i}.data`,n))})}K.extendErrors=Pf;function ba(t,e){let r=t.const("err",e);t.if((0,N._)`${X.default.vErrors} === null`,()=>t.assign(X.default.vErrors,(0,N._)`[${r}]`),(0,N._)`${X.default.vErrors}.push(${r})`),t.code((0,N._)`${X.default.errors}++`)}function wa(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,N._)`new ${t.ValidationError}(${e})`):(r.assign((0,N._)`${n}.errors`,e),r.return(!1))}var gt={keyword:new N.Name("keyword"),schemaPath:new N.Name("schemaPath"),params:new N.Name("params"),propertyName:new N.Name("propertyName"),message:new N.Name("message"),schema:new N.Name("schema"),parentSchema:new N.Name("parentSchema")};function Ea(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,N._)`{}`:Tf(t,e,r)}function Tf(t,e,r={}){let{gen:n,it:s}=t,o=[Rf(s,r),xf(t,r)];return Of(t,e,o),n.object(...o)}function Rf({errorPath:t},{instancePath:e}){let r=e?(0,N.str)`${t}${(0,En.getErrorPath)(e,En.Type.Str)}`:t;return[X.default.instancePath,(0,N.strConcat)(X.default.instancePath,r)]}function xf({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,N.str)`${e}/${t}`;return r&&(s=(0,N.str)`${s}${(0,En.getErrorPath)(r,En.Type.Str)}`),[gt.schemaPath,s]}function Of(t,{params:e,message:r},n){let{keyword:s,data:o,schemaValue:i,it:a}=t,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;n.push([gt.keyword,s],[gt.params,typeof e=="function"?e(t):e||(0,N._)`{}`]),c.messages&&n.push([gt.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([gt.schema,i],[gt.parentSchema,(0,N._)`${u}${d}`],[X.default.data,o]),l&&n.push([gt.propertyName,l])}});var $a=_(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.boolOrEmptySchema=Wt.topBoolOrEmptySchema=void 0;var Nf=Or(),Af=P(),Cf=qe(),If={message:"boolean schema is false"};function Mf(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Sa(t,!1):typeof r=="object"&&r.$async===!0?e.return(Cf.default.data):(e.assign((0,Af._)`${n}.errors`,null),e.return(!0))}Wt.topBoolOrEmptySchema=Mf;function Lf(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Sa(t)):r.var(e,!0)}Wt.boolOrEmptySchema=Lf;function Sa(t,e){let{gen:r,data:n}=t,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,Nf.reportError)(s,If,void 0,e)}});var Hs=_(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.getRules=Vt.isJSONType=void 0;var Df=["string","number","integer","boolean","null","object","array"],jf=new Set(Df);function qf(t){return typeof t=="string"&&jf.has(t)}Vt.isJSONType=qf;function Ff(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Vt.getRules=Ff});var zs=_(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.shouldUseRule=Ye.shouldUseGroup=Ye.schemaHasRulesForType=void 0;function Bf({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&ka(t,n)}Ye.schemaHasRulesForType=Bf;function ka(t,e){return e.rules.some(r=>Pa(t,r))}Ye.shouldUseGroup=ka;function Pa(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Ye.shouldUseRule=Pa});var Nr=_(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.reportTypeError=G.checkDataTypes=G.checkDataType=G.coerceAndCheckDataType=G.getJSONTypes=G.getSchemaTypes=G.DataType=void 0;var Uf=Hs(),Wf=zs(),Vf=Or(),k=P(),Ta=O(),Ht;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Ht||(G.DataType=Ht={}));function Hf(t){let e=Ra(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}G.getSchemaTypes=Hf;function Ra(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(Uf.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}G.getJSONTypes=Ra;function zf(t,e){let{gen:r,data:n,opts:s}=t,o=Kf(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,Wf.schemaHasRulesForType)(t,e[0]));if(i){let a=Gs(e,n,s.strictNumbers,Ht.Wrong);r.if(a,()=>{o.length?Gf(t,e,o):Ys(t)})}return i}G.coerceAndCheckDataType=zf;var xa=new Set(["string","number","integer","boolean","null"]);function Kf(t,e){return e?t.filter(r=>xa.has(r)||e==="array"&&r==="array"):[]}function Gf(t,e,r){let{gen:n,data:s,opts:o}=t,i=n.let("dataType",(0,k._)`typeof ${s}`),a=n.let("coerced",(0,k._)`undefined`);o.coerceTypes==="array"&&n.if((0,k._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,k._)`${s}[0]`).assign(i,(0,k._)`typeof ${s}`).if(Gs(e,s,o.strictNumbers),()=>n.assign(a,s))),n.if((0,k._)`${a} !== undefined`);for(let l of r)(xa.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Ys(t),n.endIf(),n.if((0,k._)`${a} !== undefined`,()=>{n.assign(s,a),Yf(t,a)});function c(l){switch(l){case"string":n.elseIf((0,k._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,k._)`"" + ${s}`).elseIf((0,k._)`${s} === null`).assign(a,(0,k._)`""`);return;case"number":n.elseIf((0,k._)`${i} == "boolean" || ${s} === null
4
+ || (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,k._)`+${s}`);return;case"integer":n.elseIf((0,k._)`${i} === "boolean" || ${s} === null
5
+ || (${i} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,k._)`+${s}`);return;case"boolean":n.elseIf((0,k._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,k._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":n.elseIf((0,k._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(a,null);return;case"array":n.elseIf((0,k._)`${i} === "string" || ${i} === "number"
6
+ || ${i} === "boolean" || ${s} === null`).assign(a,(0,k._)`[${s}]`)}}}function Yf({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,k._)`${e} !== undefined`,()=>t.assign((0,k._)`${e}[${r}]`,n))}function Ks(t,e,r,n=Ht.Correct){let s=n===Ht.Correct?k.operators.EQ:k.operators.NEQ,o;switch(t){case"null":return(0,k._)`${e} ${s} null`;case"array":o=(0,k._)`Array.isArray(${e})`;break;case"object":o=(0,k._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,k._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,k._)`typeof ${e} ${s} ${t}`}return n===Ht.Correct?o:(0,k.not)(o);function i(a=k.nil){return(0,k.and)((0,k._)`typeof ${e} == "number"`,a,r?(0,k._)`isFinite(${e})`:k.nil)}}G.checkDataType=Ks;function Gs(t,e,r,n){if(t.length===1)return Ks(t[0],e,r,n);let s,o=(0,Ta.toHash)(t);if(o.array&&o.object){let i=(0,k._)`typeof ${e} != "object"`;s=o.null?i:(0,k._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=k.nil;o.number&&delete o.integer;for(let i in o)s=(0,k.and)(s,Ks(i,e,r,n));return s}G.checkDataTypes=Gs;var Jf={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,k._)`{type: ${t}}`:(0,k._)`{type: ${e}}`};function Ys(t){let e=Xf(t);(0,Vf.reportError)(e,Jf)}G.reportTypeError=Ys;function Xf(t){let{gen:e,data:r,schema:n}=t,s=(0,Ta.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var Na=_(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.assignDefaults=void 0;var zt=P(),Qf=O();function Zf(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)Oa(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Oa(t,o,s.default))}Sn.assignDefaults=Zf;function Oa(t,e,r){let{gen:n,compositeRule:s,data:o,opts:i}=t;if(r===void 0)return;let a=(0,zt._)`${o}${(0,zt.getProperty)(e)}`;if(s){(0,Qf.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,zt._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,zt._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,zt._)`${a} = ${(0,zt.stringify)(r)}`)}});var ae=_(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.validateUnion=C.validateArray=C.usePattern=C.callValidateCode=C.schemaProperties=C.allSchemaProperties=C.noPropertyInData=C.propertyInData=C.isOwnProperty=C.hasPropFunc=C.reportMissingProp=C.checkMissingProp=C.checkReportMissingProp=void 0;var M=P(),Js=O(),Je=qe(),eh=O();function th(t,e){let{gen:r,data:n,it:s}=t;r.if(Qs(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,M._)`${e}`},!0),t.error()})}C.checkReportMissingProp=th;function rh({gen:t,data:e,it:{opts:r}},n,s){return(0,M.or)(...n.map(o=>(0,M.and)(Qs(t,e,o,r.ownProperties),(0,M._)`${s} = ${o}`)))}C.checkMissingProp=rh;function nh(t,e){t.setParams({missingProperty:e},!0),t.error()}C.reportMissingProp=nh;function Aa(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,M._)`Object.prototype.hasOwnProperty`})}C.hasPropFunc=Aa;function Xs(t,e,r){return(0,M._)`${Aa(t)}.call(${e}, ${r})`}C.isOwnProperty=Xs;function sh(t,e,r,n){let s=(0,M._)`${e}${(0,M.getProperty)(r)} !== undefined`;return n?(0,M._)`${s} && ${Xs(t,e,r)}`:s}C.propertyInData=sh;function Qs(t,e,r,n){let s=(0,M._)`${e}${(0,M.getProperty)(r)} === undefined`;return n?(0,M.or)(s,(0,M.not)(Xs(t,e,r))):s}C.noPropertyInData=Qs;function Ca(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}C.allSchemaProperties=Ca;function oh(t,e){return Ca(e).filter(r=>!(0,Js.alwaysValidSchema)(t,e[r]))}C.schemaProperties=oh;function ih({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:i},a,c,l){let u=l?(0,M._)`${t}, ${e}, ${n}${s}`:e,d=[[Je.default.instancePath,(0,M.strConcat)(Je.default.instancePath,o)],[Je.default.parentData,i.parentData],[Je.default.parentDataProperty,i.parentDataProperty],[Je.default.rootData,Je.default.rootData]];i.opts.dynamicRef&&d.push([Je.default.dynamicAnchors,Je.default.dynamicAnchors]);let f=(0,M._)`${u}, ${r.object(...d)}`;return c!==M.nil?(0,M._)`${a}.call(${c}, ${f})`:(0,M._)`${a}(${f})`}C.callValidateCode=ih;var ah=(0,M._)`new RegExp`;function ch({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,o=s(r,n);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,M._)`${s.code==="new RegExp"?ah:(0,eh.useFunc)(t,s)}(${r}, ${n})`})}C.usePattern=ch;function lh(t){let{gen:e,data:r,keyword:n,it:s}=t,o=e.name("valid");if(s.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(o,!0),i(()=>e.break()),o;function i(a){let c=e.const("len",(0,M._)`${r}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:n,dataProp:l,dataPropType:Js.Type.Num},o),e.if((0,M.not)(o),a)})}}C.validateArray=lh;function uh(t){let{gen:e,schema:r,keyword:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Js.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,l)=>{let u=t.subschema({keyword:n,schemaProp:l,compositeRule:!0},a);e.assign(i,(0,M._)`${i} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,M.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}C.validateUnion=uh});var La=_(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.validateKeywordUsage=Pe.validSchemaType=Pe.funcKeywordCode=Pe.macroKeywordCode=void 0;var Q=P(),_t=qe(),dh=ae(),fh=Or();function hh(t,e){let{gen:r,keyword:n,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=Ma(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let l=r.name("valid");t.subschema({schema:a,schemaPath:Q.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}Pe.macroKeywordCode=hh;function ph(t,e){var r;let{gen:n,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;yh(c,e);let l=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,u=Ma(n,s,l),d=n.let("valid");t.block$data(d,f),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function f(){if(e.errors===!1)m(),e.modifying&&Ia(t),y(()=>t.error());else{let g=e.async?p():h();e.modifying&&Ia(t),y(()=>mh(t,g))}}function p(){let g=n.let("ruleErrs",null);return n.try(()=>m((0,Q._)`await `),b=>n.assign(d,!1).if((0,Q._)`${b} instanceof ${c.ValidationError}`,()=>n.assign(g,(0,Q._)`${b}.errors`),()=>n.throw(b))),g}function h(){let g=(0,Q._)`${u}.errors`;return n.assign(g,null),m(Q.nil),g}function m(g=e.async?(0,Q._)`await `:Q.nil){let b=c.opts.passContext?_t.default.this:_t.default.self,E=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Q._)`${g}${(0,dh.callValidateCode)(t,u,b,E)}`,e.modifying)}function y(g){var b;n.if((0,Q.not)((b=e.valid)!==null&&b!==void 0?b:d),g)}}Pe.funcKeywordCode=ph;function Ia(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Q._)`${n.parentData}[${n.parentDataProperty}]`))}function mh(t,e){let{gen:r}=t;r.if((0,Q._)`Array.isArray(${e})`,()=>{r.assign(_t.default.vErrors,(0,Q._)`${_t.default.vErrors} === null ? ${e} : ${_t.default.vErrors}.concat(${e})`).assign(_t.default.errors,(0,Q._)`${_t.default.vErrors}.length`),(0,fh.extendErrors)(t)},()=>t.error())}function yh({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Ma(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Q.stringify)(r)})}function gh(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}Pe.validSchemaType=gh;function _h({schema:t,opts:e,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let i=s.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Pe.validateKeywordUsage=_h});var ja=_(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.extendSubschemaMode=Xe.extendSubschemaData=Xe.getSubschema=void 0;var Te=P(),Da=O();function vh(t,{keyword:e,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Te._)`${t.schemaPath}${(0,Te.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Te._)`${t.schemaPath}${(0,Te.getProperty)(e)}${(0,Te.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Da.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:i,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Xe.getSubschema=vh;function bh(t,e,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:i}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,f=a.let("data",(0,Te._)`${e.data}${(0,Te.getProperty)(r)}`,!0);c(f),t.errorPath=(0,Te.str)`${l}${(0,Da.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Te._)`${r}`,t.dataPathArr=[...u,t.parentDataProperty]}if(s!==void 0){let l=s instanceof Te.Name?s:a.let("data",s,!0);c(l),i!==void 0&&(t.propertyName=i)}o&&(t.dataTypes=o);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l]}}Xe.extendSubschemaData=bh;function wh(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(t.compositeRule=n),s!==void 0&&(t.createErrors=s),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}Xe.extendSubschemaMode=wh});var Zs=_((Gb,qa)=>{"use strict";qa.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var i=o[s];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Ba=_((Yb,Fa)=>{"use strict";var Qe=Fa.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};$n(e,n,s,t,"",t)};Qe.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Qe.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Qe.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Qe.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function $n(t,e,r,n,s,o,i,a,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,o,i,a,c,l);for(var u in n){var d=n[u];if(Array.isArray(d)){if(u in Qe.arrayKeywords)for(var f=0;f<d.length;f++)$n(t,e,r,d[f],s+"/"+u+"/"+f,o,s,u,n,f)}else if(u in Qe.propsKeywords){if(d&&typeof d=="object")for(var p in d)$n(t,e,r,d[p],s+"/"+u+"/"+Eh(p),o,s,u,n,p)}else(u in Qe.keywords||t.allKeys&&!(u in Qe.skipKeywords))&&$n(t,e,r,d,s+"/"+u,o,s,u,n)}r(n,s,o,i,a,c,l)}}function Eh(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Ar=_(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.getSchemaRefs=te.resolveUrl=te.normalizeId=te._getFullPath=te.getFullPath=te.inlineRef=void 0;var Sh=O(),$h=Zs(),kh=Ba(),Ph=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Th(t,e=!0){return typeof t=="boolean"?!0:e===!0?!eo(t):e?Ua(t)<=e:!1}te.inlineRef=Th;var Rh=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function eo(t){for(let e in t){if(Rh.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(eo)||typeof r=="object"&&eo(r))return!0}return!1}function Ua(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!Ph.has(r)&&(typeof t[r]=="object"&&(0,Sh.eachItem)(t[r],n=>e+=Ua(n)),e===1/0))return 1/0}return e}function Wa(t,e="",r){r!==!1&&(e=Kt(e));let n=t.parse(e);return Va(t,n)}te.getFullPath=Wa;function Va(t,e){return t.serialize(e).split("#")[0]+"#"}te._getFullPath=Va;var xh=/#\/?$/;function Kt(t){return t?t.replace(xh,""):""}te.normalizeId=Kt;function Oh(t,e,r){return r=Kt(r),t.resolve(e,r)}te.resolveUrl=Oh;var Nh=/^[a-z_][-a-z0-9._]*$/i;function Ah(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=Kt(t[r]||e),o={"":s},i=Wa(n,s,!1),a={},c=new Set;return kh(t,{allKeys:!0},(d,f,p,h)=>{if(h===void 0)return;let m=i+f,y=o[h];typeof d[r]=="string"&&(y=g.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),o[f]=y;function g(E){let S=this.opts.uriResolver.resolve;if(E=Kt(y?S(y,E):E),c.has(E))throw u(E);c.add(E);let v=this.refs[E];return typeof v=="string"&&(v=this.refs[v]),typeof v=="object"?l(d,v.schema,E):E!==Kt(m)&&(E[0]==="#"?(l(d,a[E],E),a[E]=d):this.refs[E]=m),E}function b(E){if(typeof E=="string"){if(!Nh.test(E))throw new Error(`invalid anchor "${E}"`);g.call(this,`#${E}`)}}}),a;function l(d,f,p){if(f!==void 0&&!$h(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}te.getSchemaRefs=Ah});var Mr=_(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.getData=Ze.KeywordCxt=Ze.validateFunctionCode=void 0;var Ya=$a(),Ha=Nr(),ro=zs(),kn=Nr(),Ch=Na(),Ir=La(),to=ja(),w=P(),$=qe(),Ih=Ar(),Fe=O(),Cr=Or();function Mh(t){if(Qa(t)&&(Za(t),Xa(t))){jh(t);return}Ja(t,()=>(0,Ya.topBoolOrEmptySchema)(t))}Ze.validateFunctionCode=Mh;function Ja({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},o){s.code.es5?t.func(e,(0,w._)`${$.default.data}, ${$.default.valCxt}`,n.$async,()=>{t.code((0,w._)`"use strict"; ${za(r,s)}`),Dh(t,s),t.code(o)}):t.func(e,(0,w._)`${$.default.data}, ${Lh(s)}`,n.$async,()=>t.code(za(r,s)).code(o))}function Lh(t){return(0,w._)`{${$.default.instancePath}="", ${$.default.parentData}, ${$.default.parentDataProperty}, ${$.default.rootData}=${$.default.data}${t.dynamicRef?(0,w._)`, ${$.default.dynamicAnchors}={}`:w.nil}}={}`}function Dh(t,e){t.if($.default.valCxt,()=>{t.var($.default.instancePath,(0,w._)`${$.default.valCxt}.${$.default.instancePath}`),t.var($.default.parentData,(0,w._)`${$.default.valCxt}.${$.default.parentData}`),t.var($.default.parentDataProperty,(0,w._)`${$.default.valCxt}.${$.default.parentDataProperty}`),t.var($.default.rootData,(0,w._)`${$.default.valCxt}.${$.default.rootData}`),e.dynamicRef&&t.var($.default.dynamicAnchors,(0,w._)`${$.default.valCxt}.${$.default.dynamicAnchors}`)},()=>{t.var($.default.instancePath,(0,w._)`""`),t.var($.default.parentData,(0,w._)`undefined`),t.var($.default.parentDataProperty,(0,w._)`undefined`),t.var($.default.rootData,$.default.data),e.dynamicRef&&t.var($.default.dynamicAnchors,(0,w._)`{}`)})}function jh(t){let{schema:e,opts:r,gen:n}=t;Ja(t,()=>{r.$comment&&e.$comment&&tc(t),Wh(t),n.let($.default.vErrors,null),n.let($.default.errors,0),r.unevaluated&&qh(t),ec(t),zh(t)})}function qh(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,w._)`${r}.evaluated`),e.if((0,w._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,w._)`${t.evaluated}.props`,(0,w._)`undefined`)),e.if((0,w._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,w._)`${t.evaluated}.items`,(0,w._)`undefined`))}function za(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,w._)`/*# sourceURL=${r} */`:w.nil}function Fh(t,e){if(Qa(t)&&(Za(t),Xa(t))){Bh(t,e);return}(0,Ya.boolOrEmptySchema)(t,e)}function Xa({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Qa(t){return typeof t.schema!="boolean"}function Bh(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&tc(t),Vh(t),Hh(t);let o=n.const("_errs",$.default.errors);ec(t,o),n.var(e,(0,w._)`${o} === ${$.default.errors}`)}function Za(t){(0,Fe.checkUnknownRules)(t),Uh(t)}function ec(t,e){if(t.opts.jtd)return Ka(t,[],!1,e);let r=(0,Ha.getSchemaTypes)(t.schema),n=(0,Ha.coerceAndCheckDataType)(t,r);Ka(t,r,!n,e)}function Uh(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Fe.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Wh(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Fe.checkStrictMode)(t,"default is ignored in the schema root")}function Vh(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,Ih.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function Hh(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function tc({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===!0)t.code((0,w._)`${$.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let i=(0,w.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,w._)`${$.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function zh(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=t;r.$async?e.if((0,w._)`${$.default.errors} === 0`,()=>e.return($.default.data),()=>e.throw((0,w._)`new ${s}(${$.default.vErrors})`)):(e.assign((0,w._)`${n}.errors`,$.default.vErrors),o.unevaluated&&Kh(t),e.return((0,w._)`${$.default.errors} === 0`))}function Kh({gen:t,evaluated:e,props:r,items:n}){r instanceof w.Name&&t.assign((0,w._)`${e}.props`,r),n instanceof w.Name&&t.assign((0,w._)`${e}.items`,n)}function Ka(t,e,r,n){let{gen:s,schema:o,data:i,allErrors:a,opts:c,self:l}=t,{RULES:u}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Fe.schemaHasRulesButRef)(o,u))){s.block(()=>nc(t,"$ref",u.all.$ref.definition));return}c.jtd||Gh(t,e),s.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,ro.shouldUseGroup)(o,f)&&(f.type?(s.if((0,kn.checkDataType)(f.type,i,c.strictNumbers)),Ga(t,f),e.length===1&&e[0]===f.type&&r&&(s.else(),(0,kn.reportTypeError)(t)),s.endIf()):Ga(t,f),a||s.if((0,w._)`${$.default.errors} === ${n||0}`))}}function Ga(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,Ch.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,ro.shouldUseRule)(n,o)&&nc(t,o.keyword,o.definition,e.type)})}function Gh(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Yh(t,e),t.opts.allowUnionTypes||Jh(t,e),Xh(t,t.dataTypes))}function Yh(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{rc(t.dataTypes,r)||no(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Zh(t,e)}}function Jh(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&no(t,"use allowUnionTypes to allow union type keyword")}function Xh(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,ro.shouldUseRule)(t.schema,s)){let{type:o}=s.definition;o.length&&!o.some(i=>Qh(e,i))&&no(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function Qh(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function rc(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Zh(t,e){let r=[];for(let n of t.dataTypes)rc(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function no(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Fe.checkStrictMode)(t,e,t.opts.strictTypes)}var Pn=class{constructor(e,r,n){if((0,Ir.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Fe.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",sc(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Ir.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",$.default.errors))}result(e,r,n){this.failResult((0,w.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,w.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,w._)`${r} !== undefined && (${(0,w.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Cr.reportExtraError:Cr.reportError)(this,this.def.error,r)}$dataError(){(0,Cr.reportError)(this,this.def.$dataError||Cr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Cr.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=w.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=w.nil,r=w.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:i}=this;n.if((0,w.or)((0,w._)`${s} === undefined`,r)),e!==w.nil&&n.assign(e,!0),(o.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==w.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,w.or)(i(),a());function i(){if(n.length){if(!(r instanceof w.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,w._)`${(0,kn.checkDataTypes)(c,r,o.opts.strictNumbers,kn.DataType.Wrong)}`}return w.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,w._)`!${c}(${r})`}return w.nil}}subschema(e,r){let n=(0,to.getSubschema)(this.it,e);(0,to.extendSubschemaData)(n,this.it,e),(0,to.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return Fh(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Fe.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Fe.mergeEvaluated.items(s,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(e,w.Name)),!0}};Ze.KeywordCxt=Pn;function nc(t,e,r,n){let s=new Pn(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,Ir.funcKeywordCode)(s,r):"macro"in r?(0,Ir.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,Ir.funcKeywordCode)(s,r)}var ep=/^\/(?:[^~]|~0|~1)*$/,tp=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function sc(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,o;if(t==="")return $.default.rootData;if(t[0]==="/"){if(!ep.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=$.default.rootData}else{let l=tp.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(s=l[2],s==="#"){if(u>=e)throw new Error(c("property/index",u));return n[e-u]}if(u>e)throw new Error(c("data",u));if(o=r[e-u],!s)return o}let i=o,a=s.split("/");for(let l of a)l&&(o=(0,w._)`${o}${(0,w.getProperty)((0,Fe.unescapeJsonPointer)(l))}`,i=(0,w._)`${i} && ${o}`);return i;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}Ze.getData=sc});var Tn=_(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});var so=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};oo.default=so});var Lr=_(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});var io=Ar(),ao=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,io.resolveUrl)(e,r,n),this.missingSchema=(0,io.normalizeId)((0,io.getFullPath)(e,this.missingRef))}};co.default=ao});var xn=_(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.resolveSchema=ce.getCompilingSchema=ce.resolveRef=ce.compileSchema=ce.SchemaEnv=void 0;var pe=P(),rp=Tn(),vt=qe(),me=Ar(),oc=O(),np=Mr(),Gt=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,me.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};ce.SchemaEnv=Gt;function uo(t){let e=ic.call(this,t);if(e)return e;let r=(0,me.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new pe.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),a;t.$async&&(a=i.scopeValue("Error",{ref:rp.default,code:(0,pe._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let l={gen:i,allErrors:this.opts.allErrors,data:vt.default.data,parentData:vt.default.parentData,parentDataProperty:vt.default.parentDataProperty,dataNames:[vt.default.data],dataPathArr:[pe.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,pe.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:pe.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,pe._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,np.validateFunctionCode)(l),i.optimize(this.opts.code.optimize);let d=i.toString();u=`${i.scopeRefs(vt.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let p=new Function(`${vt.default.self}`,`${vt.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:h,items:m}=l;p.evaluated={props:h instanceof pe.Name?void 0:h,items:m instanceof pe.Name?void 0:m,dynamicProps:h instanceof pe.Name,dynamicItems:m instanceof pe.Name},p.source&&(p.source.evaluated=(0,pe.stringify)(p.evaluated))}return t.validate=p,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t)}}ce.compileSchema=uo;function sp(t,e,r){var n;r=(0,me.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let o=ap.call(this,t,r);if(o===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(o=new Gt({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=op.call(this,o)}ce.resolveRef=sp;function op(t){return(0,me.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:uo.call(this,t)}function ic(t){for(let e of this._compilations)if(ip(e,t))return e}ce.getCompilingSchema=ic;function ip(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function ap(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Rn.call(this,t,e)}function Rn(t,e){let r=this.opts.uriResolver.parse(e),n=(0,me._getFullPath)(this.opts.uriResolver,r),s=(0,me.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return lo.call(this,r,t);let o=(0,me.normalizeId)(n),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){let a=Rn.call(this,t,i);return typeof a?.schema!="object"?void 0:lo.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||uo.call(this,i),o===(0,me.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,l=a[c];return l&&(s=(0,me.resolveUrl)(this.opts.uriResolver,s,l)),new Gt({schema:a,schemaId:c,root:t,baseId:s})}return lo.call(this,r,i)}}ce.resolveSchema=Rn;var cp=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function lo(t,{baseId:e,schema:r,root:n}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,oc.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!cp.has(a)&&l&&(e=(0,me.resolveUrl)(this.opts.uriResolver,e,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,oc.schemaHasRulesButRef)(r,this.RULES)){let a=(0,me.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=Rn.call(this,n,a)}let{schemaId:i}=this.opts;if(o=o||new Gt({schema:r,schemaId:i,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var ac=_((tw,lp)=>{lp.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var ho=_((rw,dc)=>{"use strict";var up=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),lc=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function fo(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var dp=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function cc(t){return t.length=0,!0}function fp(t,e,r){if(t.length){let n=fo(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function hp(t){let e=0,r={error:!1,address:"",zone:""},n=[],s=[],o=!1,i=!1,a=fp;for(let c=0;c<t.length;c++){let l=t[c];if(!(l==="["||l==="]"))if(l===":"){if(o===!0&&(i=!0),!a(s,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(o=!0),n.push(":");continue}else if(l==="%"){if(!a(s,n,r))break;a=cc}else{s.push(l);continue}}return s.length&&(a===cc?r.zone=s.join(""):i?n.push(s.join("")):n.push(fo(s))),r.address=n.join(""),r}function uc(t){if(pp(t,":")<2)return{host:t,isIPV6:!1};let e=hp(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function pp(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function mp(t){let e=t,r=[],n=-1,s=0;for(;s=e.length;){if(s===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(s===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(s===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}function yp(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function gp(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!lc(r)){let n=uc(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}dc.exports={nonSimpleDomain:dp,recomposeAuthority:gp,normalizeComponentEncoding:yp,removeDotSegments:mp,isIPv4:lc,isUUID:up,normalizeIPv6:uc,stringArrayToHexStripped:fo}});var yc=_((nw,mc)=>{"use strict";var{isUUID:_p}=ho(),vp=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,bp=["http","https","ws","wss","urn","urn:uuid"];function wp(t){return bp.indexOf(t)!==-1}function po(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function fc(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function hc(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function Ep(t){return t.secure=po(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function Sp(t){if((t.port===(po(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function $p(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(vp);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let s=`${n}:${e.nid||t.nid}`,o=mo(s);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function kp(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),s=`${r}:${e.nid||n}`,o=mo(s);o&&(t=o.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function Pp(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!_p(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Tp(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var pc={scheme:"http",domainHost:!0,parse:fc,serialize:hc},Rp={scheme:"https",domainHost:pc.domainHost,parse:fc,serialize:hc},On={scheme:"ws",domainHost:!0,parse:Ep,serialize:Sp},xp={scheme:"wss",domainHost:On.domainHost,parse:On.parse,serialize:On.serialize},Op={scheme:"urn",parse:$p,serialize:kp,skipNormalize:!0},Np={scheme:"urn:uuid",parse:Pp,serialize:Tp,skipNormalize:!0},Nn={http:pc,https:Rp,ws:On,wss:xp,urn:Op,"urn:uuid":Np};Object.setPrototypeOf(Nn,null);function mo(t){return t&&(Nn[t]||Nn[t.toLowerCase()])||void 0}mc.exports={wsIsSecure:po,SCHEMES:Nn,isValidSchemeName:wp,getSchemeHandler:mo}});var vc=_((sw,Cn)=>{"use strict";var{normalizeIPv6:Ap,removeDotSegments:Dr,recomposeAuthority:Cp,normalizeComponentEncoding:An,isIPv4:Ip,nonSimpleDomain:Mp}=ho(),{SCHEMES:Lp,getSchemeHandler:gc}=yc();function Dp(t,e){return typeof t=="string"?t=Re(Be(t,e),e):typeof t=="object"&&(t=Be(Re(t,e),e)),t}function jp(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=_c(Be(t,n),Be(e,n),n,!0);return n.skipEscape=!0,Re(s,n)}function _c(t,e,r,n){let s={};return n||(t=Be(Re(t,r),r),e=Be(Re(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Dr(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Dr(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=Dr(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?s.path="/"+e.path:t.path?s.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=Dr(s.path)),s.query=e.query):(s.path=t.path,e.query!==void 0?s.query=e.query:s.query=t.query),s.userinfo=t.userinfo,s.host=t.host,s.port=t.port),s.scheme=t.scheme),s.fragment=e.fragment,s}function qp(t,e,r){return typeof t=="string"?(t=unescape(t),t=Re(An(Be(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=Re(An(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=Re(An(Be(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=Re(An(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function Re(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),s=[],o=gc(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let i=Cp(r);if(i!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(i),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=Dr(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),s.push(a)}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var Fp=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Be(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let o=t.match(Fp);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host)if(Ip(n.host)===!1){let c=Ap(n.host);n.host=c.host.toLowerCase(),s=c.isIPV6}else s=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let i=gc(r.scheme||n.scheme);if(!r.unicodeSupport&&(!i||!i.unicodeSupport)&&n.host&&(r.domainHost||i&&i.domainHost)&&s===!1&&Mp(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!i||i&&!i.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),i&&i.parse&&i.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var yo={SCHEMES:Lp,normalize:Dp,resolve:jp,resolveComponent:_c,equal:qp,serialize:Re,parse:Be};Cn.exports=yo;Cn.exports.default=yo;Cn.exports.fastUri=yo});var wc=_(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var bc=vc();bc.code='require("ajv/dist/runtime/uri").default';go.default=bc});var xc=_(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.CodeGen=V.Name=V.nil=V.stringify=V.str=V._=V.KeywordCxt=void 0;var Bp=Mr();Object.defineProperty(V,"KeywordCxt",{enumerable:!0,get:function(){return Bp.KeywordCxt}});var Yt=P();Object.defineProperty(V,"_",{enumerable:!0,get:function(){return Yt._}});Object.defineProperty(V,"str",{enumerable:!0,get:function(){return Yt.str}});Object.defineProperty(V,"stringify",{enumerable:!0,get:function(){return Yt.stringify}});Object.defineProperty(V,"nil",{enumerable:!0,get:function(){return Yt.nil}});Object.defineProperty(V,"Name",{enumerable:!0,get:function(){return Yt.Name}});Object.defineProperty(V,"CodeGen",{enumerable:!0,get:function(){return Yt.CodeGen}});var Up=Tn(),Pc=Lr(),Wp=Hs(),jr=xn(),Vp=P(),qr=Ar(),In=Nr(),vo=O(),Ec=ac(),Hp=wc(),Tc=(t,e)=>new RegExp(t,e);Tc.code="new RegExp";var zp=["removeAdditional","useDefaults","coerceTypes"],Kp=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Gp={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},Yp={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Sc=200;function Jp(t){var e,r,n,s,o,i,a,c,l,u,d,f,p,h,m,y,g,b,E,S,v,D,B,$e,ke;let Le=t.strict,br=(e=t.code)===null||e===void 0?void 0:e.optimize,ra=br===!0||br===void 0?1:br||0,na=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Tc,Bd=(s=t.uriResolver)!==null&&s!==void 0?s:Hp.default;return{strictSchema:(i=(o=t.strictSchema)!==null&&o!==void 0?o:Le)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Le)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:Le)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:Le)!==null&&f!==void 0?f:"log",strictRequired:(h=(p=t.strictRequired)!==null&&p!==void 0?p:Le)!==null&&h!==void 0?h:!1,code:t.code?{...t.code,optimize:ra,regExp:na}:{optimize:ra,regExp:na},loopRequired:(m=t.loopRequired)!==null&&m!==void 0?m:Sc,loopEnum:(y=t.loopEnum)!==null&&y!==void 0?y:Sc,meta:(g=t.meta)!==null&&g!==void 0?g:!0,messages:(b=t.messages)!==null&&b!==void 0?b:!0,inlineRefs:(E=t.inlineRefs)!==null&&E!==void 0?E:!0,schemaId:(S=t.schemaId)!==null&&S!==void 0?S:"$id",addUsedSchema:(v=t.addUsedSchema)!==null&&v!==void 0?v:!0,validateSchema:(D=t.validateSchema)!==null&&D!==void 0?D:!0,validateFormats:(B=t.validateFormats)!==null&&B!==void 0?B:!0,unicodeRegExp:($e=t.unicodeRegExp)!==null&&$e!==void 0?$e:!0,int32range:(ke=t.int32range)!==null&&ke!==void 0?ke:!0,uriResolver:Bd}}var Fr=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Jp(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new Vp.ValueScope({scope:{},prefixes:Kp,es5:r,lines:n}),this.logger=rm(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,Wp.getRules)(),$c.call(this,Gp,e,"NOT SUPPORTED"),$c.call(this,Yp,e,"DEPRECATED","warn"),this._metaOpts=em.call(this),e.formats&&Qp.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&Zp.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),Xp.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=Ec;n==="id"&&(s={...Ec},s.id=s.$id,delete s.$id),r&&e&&this.addMetaSchema(s,s[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let s=n(r);return"$async"in n||(this.errors=n.errors),s}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,e,r);async function s(u,d){await o.call(this,u.$schema);let f=this._addSchema(u,d);return f.validate||i.call(this,f)}async function o(u){u&&!this.getSchema(u)&&await s.call(this,{$ref:u},!0)}async function i(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof Pc.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function c(u){let d=await l.call(this,u);this.refs[u]||await o.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}async function l(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=n(u))}finally{delete this._loading[u]}}}addSchema(e,r,n,s=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,s);return this}let o;if(typeof e=="object"){let{schemaId:i}=this.opts;if(o=e[i],o!==void 0&&typeof o!="string")throw new Error(`schema ${i} must be string`)}return r=(0,qr.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,s,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let s=this.validate(n,e);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(e){let r;for(;typeof(r=kc.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new jr.SchemaEnv({schema:{},schemaId:n});if(r=jr.resolveSchema.call(this,s,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=kc.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,qr.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(sm.call(this,n,r),!r)return(0,vo.eachItem)(n,o=>_o.call(this,o)),this;im.call(this,r);let s={...r,type:(0,In.getJSONTypes)(r.type),schemaType:(0,In.getJSONTypes)(r.schemaType)};return(0,vo.eachItem)(n,s.type.length===0?o=>_o.call(this,o,s):o=>s.type.forEach(i=>_o.call(this,o,s,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let s=n.rules.findIndex(o=>o.keyword===e);s>=0&&n.rules.splice(s,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let s of r){let o=s.split("/").slice(1),i=e;for(let a of o)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:l}=c.definition,u=i[a];l&&u&&(i[a]=Rc(u))}}return e}_removeAllSchemas(e,r){for(let n in e){let s=e[n];(!r||r.test(n))&&(typeof s=="string"?delete e[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete e[n]))}}_addSchema(e,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,qr.normalizeId)(i||n);let l=qr.getSchemaRefs.call(this,e,n);return c=new jr.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:l}),this._cache.set(c.schema,c),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),s&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):jr.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{jr.compileSchema.call(this,e)}finally{this.opts=r}}};Fr.ValidationError=Up.default;Fr.MissingRefError=Pc.default;V.default=Fr;function $c(t,e,r,n="error"){for(let s in t){let o=s;o in e&&this.logger[n](`${r}: option ${s}. ${t[o]}`)}}function kc(t){return t=(0,qr.normalizeId)(t),this.schemas[t]||this.refs[t]}function Xp(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function Qp(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function Zp(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function em(){let t={...this.opts};for(let e of zp)delete t[e];return t}var tm={log(){},warn(){},error(){}};function rm(t){if(t===!1)return tm;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var nm=/^[a-z_$][a-z0-9_$:-]*$/i;function sm(t,e){let{RULES:r}=this;if((0,vo.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!nm.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function _o(t,e,r){var n;let s=e?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,i=s?o.post:o.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},o.rules.push(i)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,In.getJSONTypes)(e.type),schemaType:(0,In.getJSONTypes)(e.schemaType)}};e.before?om.call(this,i,a,e.before):i.rules.push(a),o.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function om(t,e,r){let n=t.rules.findIndex(s=>s.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function im(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Rc(e)),t.validateSchema=this.compile(e,!0))}var am={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Rc(t){return{anyOf:[t,am]}}});var Oc=_(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});var cm={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};bo.default=cm});var Ic=_(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.callRef=bt.getValidate=void 0;var lm=Lr(),Nc=ae(),re=P(),Jt=qe(),Ac=xn(),Mn=O(),um={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:s,schemaEnv:o,validateName:i,opts:a,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return d();let u=Ac.resolveRef.call(c,l,s,r);if(u===void 0)throw new lm.default(n.opts.uriResolver,s,r);if(u instanceof Ac.SchemaEnv)return f(u);return p(u);function d(){if(o===l)return Ln(t,i,o,o.$async);let h=e.scopeValue("root",{ref:l});return Ln(t,(0,re._)`${h}.validate`,l,l.$async)}function f(h){let m=Cc(t,h);Ln(t,m,h,h.$async)}function p(h){let m=e.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,re.stringify)(h)}:{ref:h}),y=e.name("valid"),g=t.subschema({schema:h,dataTypes:[],schemaPath:re.nil,topSchemaRef:m,errSchemaPath:r},y);t.mergeEvaluated(g),t.ok(y)}}};function Cc(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,re._)`${r.scopeValue("wrapper",{ref:e})}.validate`}bt.getValidate=Cc;function Ln(t,e,r,n){let{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,l=c.passContext?Jt.default.this:re.nil;n?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=s.let("valid");s.try(()=>{s.code((0,re._)`await ${(0,Nc.callValidateCode)(t,e,l)}`),p(e),i||s.assign(h,!0)},m=>{s.if((0,re._)`!(${m} instanceof ${o.ValidationError})`,()=>s.throw(m)),f(m),i||s.assign(h,!1)}),t.ok(h)}function d(){t.result((0,Nc.callValidateCode)(t,e,l),()=>p(e),()=>f(e))}function f(h){let m=(0,re._)`${h}.errors`;s.assign(Jt.default.vErrors,(0,re._)`${Jt.default.vErrors} === null ? ${m} : ${Jt.default.vErrors}.concat(${m})`),s.assign(Jt.default.errors,(0,re._)`${Jt.default.vErrors}.length`)}function p(h){var m;if(!o.opts.unevaluated)return;let y=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(o.props=Mn.mergeEvaluated.props(s,y.props,o.props));else{let g=s.var("props",(0,re._)`${h}.evaluated.props`);o.props=Mn.mergeEvaluated.props(s,g,o.props,re.Name)}if(o.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(o.items=Mn.mergeEvaluated.items(s,y.items,o.items));else{let g=s.var("items",(0,re._)`${h}.evaluated.items`);o.items=Mn.mergeEvaluated.items(s,g,o.items,re.Name)}}}bt.callRef=Ln;bt.default=um});var Mc=_(wo=>{"use strict";Object.defineProperty(wo,"__esModule",{value:!0});var dm=Oc(),fm=Ic(),hm=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",dm.default,fm.default];wo.default=hm});var Lc=_(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});var Dn=P(),et=Dn.operators,jn={maximum:{okStr:"<=",ok:et.LTE,fail:et.GT},minimum:{okStr:">=",ok:et.GTE,fail:et.LT},exclusiveMaximum:{okStr:"<",ok:et.LT,fail:et.GTE},exclusiveMinimum:{okStr:">",ok:et.GT,fail:et.LTE}},pm={message:({keyword:t,schemaCode:e})=>(0,Dn.str)`must be ${jn[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Dn._)`{comparison: ${jn[t].okStr}, limit: ${e}}`},mm={keyword:Object.keys(jn),type:"number",schemaType:"number",$data:!0,error:pm,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,Dn._)`${r} ${jn[e].fail} ${n} || isNaN(${r})`)}};Eo.default=mm});var Dc=_(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});var Br=P(),ym={message:({schemaCode:t})=>(0,Br.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Br._)`{multipleOf: ${t}}`},gm={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:ym,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,Br._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,Br._)`${i} !== parseInt(${i})`;t.fail$data((0,Br._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};So.default=gm});var qc=_($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});function jc(t){let e=t.length,r=0,n=0,s;for(;n<e;)r++,s=t.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=t.charCodeAt(n),(s&64512)===56320&&n++);return r}$o.default=jc;jc.code='require("ajv/dist/runtime/ucs2length").default'});var Fc=_(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});var wt=P(),_m=O(),vm=qc(),bm={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,wt.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,wt._)`{limit: ${t}}`},wm={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:bm,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,o=e==="maxLength"?wt.operators.GT:wt.operators.LT,i=s.opts.unicode===!1?(0,wt._)`${r}.length`:(0,wt._)`${(0,_m.useFunc)(t.gen,vm.default)}(${r})`;t.fail$data((0,wt._)`${i} ${o} ${n}`)}};ko.default=wm});var Bc=_(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});var Em=ae(),Sm=O(),Xt=P(),$m={message:({schemaCode:t})=>(0,Xt.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Xt._)`{pattern: ${t}}`},km={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:$m,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,l=c.code==="new RegExp"?(0,Xt._)`new RegExp`:(0,Sm.useFunc)(e,c),u=e.let("valid");e.try(()=>e.assign(u,(0,Xt._)`${l}(${o}, ${a}).test(${r})`),()=>e.assign(u,!1)),t.fail$data((0,Xt._)`!${u}`)}else{let c=(0,Em.usePattern)(t,s);t.fail$data((0,Xt._)`!${c}.test(${r})`)}}};Po.default=km});var Uc=_(To=>{"use strict";Object.defineProperty(To,"__esModule",{value:!0});var Ur=P(),Pm={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Ur.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Ur._)`{limit: ${t}}`},Tm={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Pm,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?Ur.operators.GT:Ur.operators.LT;t.fail$data((0,Ur._)`Object.keys(${r}).length ${s} ${n}`)}};To.default=Tm});var Wc=_(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});var Wr=ae(),Vr=P(),Rm=O(),xm={message:({params:{missingProperty:t}})=>(0,Vr.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Vr._)`{missingProperty: ${t}}`},Om={keyword:"required",type:"object",schemaType:"array",$data:!0,error:xm,code(t){let{gen:e,schema:r,schemaCode:n,data:s,$data:o,it:i}=t,{opts:a}=i;if(!o&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?l():u(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:h}=t.it;for(let m of r)if(p?.[m]===void 0&&!h.has(m)){let y=i.schemaEnv.baseId+i.errSchemaPath,g=`required property "${m}" is not defined at "${y}" (strictRequired)`;(0,Rm.checkStrictMode)(i,g,i.opts.strictRequired)}}function l(){if(c||o)t.block$data(Vr.nil,d);else for(let p of r)(0,Wr.checkReportMissingProp)(t,p)}function u(){let p=e.let("missing");if(c||o){let h=e.let("valid",!0);t.block$data(h,()=>f(p,h)),t.ok(h)}else e.if((0,Wr.checkMissingProp)(t,r,p)),(0,Wr.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,Wr.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function f(p,h){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(h,(0,Wr.propertyInData)(e,s,p,a.ownProperties)),e.if((0,Vr.not)(h),()=>{t.error(),e.break()})},Vr.nil)}}};Ro.default=Om});var Vc=_(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});var Hr=P(),Nm={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Hr.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Hr._)`{limit: ${t}}`},Am={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Nm,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?Hr.operators.GT:Hr.operators.LT;t.fail$data((0,Hr._)`${r}.length ${s} ${n}`)}};xo.default=Am});var qn=_(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});var Hc=Zs();Hc.code='require("ajv/dist/runtime/equal").default';Oo.default=Hc});var zc=_(Ao=>{"use strict";Object.defineProperty(Ao,"__esModule",{value:!0});var No=Nr(),H=P(),Cm=O(),Im=qn(),Mm={message:({params:{i:t,j:e}})=>(0,H.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,H._)`{i: ${t}, j: ${e}}`},Lm={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Mm,code(t){let{gen:e,data:r,$data:n,schema:s,parentSchema:o,schemaCode:i,it:a}=t;if(!n&&!s)return;let c=e.let("valid"),l=o.items?(0,No.getSchemaTypes)(o.items):[];t.block$data(c,u,(0,H._)`${i} === false`),t.ok(c);function u(){let h=e.let("i",(0,H._)`${r}.length`),m=e.let("j");t.setParams({i:h,j:m}),e.assign(c,!0),e.if((0,H._)`${h} > 1`,()=>(d()?f:p)(h,m))}function d(){return l.length>0&&!l.some(h=>h==="object"||h==="array")}function f(h,m){let y=e.name("item"),g=(0,No.checkDataTypes)(l,y,a.opts.strictNumbers,No.DataType.Wrong),b=e.const("indices",(0,H._)`{}`);e.for((0,H._)`;${h}--;`,()=>{e.let(y,(0,H._)`${r}[${h}]`),e.if(g,(0,H._)`continue`),l.length>1&&e.if((0,H._)`typeof ${y} == "string"`,(0,H._)`${y} += "_"`),e.if((0,H._)`typeof ${b}[${y}] == "number"`,()=>{e.assign(m,(0,H._)`${b}[${y}]`),t.error(),e.assign(c,!1).break()}).code((0,H._)`${b}[${y}] = ${h}`)})}function p(h,m){let y=(0,Cm.useFunc)(e,Im.default),g=e.name("outer");e.label(g).for((0,H._)`;${h}--;`,()=>e.for((0,H._)`${m} = ${h}; ${m}--;`,()=>e.if((0,H._)`${y}(${r}[${h}], ${r}[${m}])`,()=>{t.error(),e.assign(c,!1).break(g)})))}}};Ao.default=Lm});var Kc=_(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});var Co=P(),Dm=O(),jm=qn(),qm={message:"must be equal to constant",params:({schemaCode:t})=>(0,Co._)`{allowedValue: ${t}}`},Fm={keyword:"const",$data:!0,error:qm,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,Co._)`!${(0,Dm.useFunc)(e,jm.default)}(${r}, ${s})`):t.fail((0,Co._)`${o} !== ${r}`)}};Io.default=Fm});var Gc=_(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});var zr=P(),Bm=O(),Um=qn(),Wm={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,zr._)`{allowedValues: ${t}}`},Vm={keyword:"enum",schemaType:"array",$data:!0,error:Wm,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let a=s.length>=i.opts.loopEnum,c,l=()=>c??(c=(0,Bm.useFunc)(e,Um.default)),u;if(a||n)u=e.let("valid"),t.block$data(u,d);else{if(!Array.isArray(s))throw new Error("ajv implementation error");let p=e.const("vSchema",o);u=(0,zr.or)(...s.map((h,m)=>f(p,m)))}t.pass(u);function d(){e.assign(u,!1),e.forOf("v",o,p=>e.if((0,zr._)`${l()}(${r}, ${p})`,()=>e.assign(u,!0).break()))}function f(p,h){let m=s[h];return typeof m=="object"&&m!==null?(0,zr._)`${l()}(${r}, ${p}[${h}])`:(0,zr._)`${r} === ${m}`}}};Mo.default=Vm});var Yc=_(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});var Hm=Lc(),zm=Dc(),Km=Fc(),Gm=Bc(),Ym=Uc(),Jm=Wc(),Xm=Vc(),Qm=zc(),Zm=Kc(),ey=Gc(),ty=[Hm.default,zm.default,Km.default,Gm.default,Ym.default,Jm.default,Xm.default,Qm.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Zm.default,ey.default];Lo.default=ty});var jo=_(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.validateAdditionalItems=void 0;var Et=P(),Do=O(),ry={message:({params:{len:t}})=>(0,Et.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Et._)`{limit: ${t}}`},ny={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:ry,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Do.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Jc(t,n)}};function Jc(t,e){let{gen:r,schema:n,data:s,keyword:o,it:i}=t;i.items=!0;let a=r.const("len",(0,Et._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Et._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Do.alwaysValidSchema)(i,n)){let l=r.var("valid",(0,Et._)`${a} <= ${e.length}`);r.if((0,Et.not)(l),()=>c(l)),t.ok(l)}function c(l){r.forRange("i",e.length,a,u=>{t.subschema({keyword:o,dataProp:u,dataPropType:Do.Type.Num},l),i.allErrors||r.if((0,Et.not)(l),()=>r.break())})}}Kr.validateAdditionalItems=Jc;Kr.default=ny});var qo=_(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.validateTuple=void 0;var Xc=P(),Fn=O(),sy=ae(),oy={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Qc(t,"additionalItems",e);r.items=!0,!(0,Fn.alwaysValidSchema)(r,e)&&t.ok((0,sy.validateArray)(t))}};function Qc(t,e,r=t.schema){let{gen:n,parentSchema:s,data:o,keyword:i,it:a}=t;u(s),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Fn.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),l=n.const("len",(0,Xc._)`${o}.length`);r.forEach((d,f)=>{(0,Fn.alwaysValidSchema)(a,d)||(n.if((0,Xc._)`${l} > ${f}`,()=>t.subschema({keyword:i,schemaProp:f,dataProp:f},c)),t.ok(c))});function u(d){let{opts:f,errSchemaPath:p}=a,h=r.length,m=h===d.minItems&&(h===d.maxItems||d[e]===!1);if(f.strictTuples&&!m){let y=`"${i}" is ${h}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,Fn.checkStrictMode)(a,y,f.strictTuples)}}}Gr.validateTuple=Qc;Gr.default=oy});var Zc=_(Fo=>{"use strict";Object.defineProperty(Fo,"__esModule",{value:!0});var iy=qo(),ay={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,iy.validateTuple)(t,"items")};Fo.default=ay});var tl=_(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});var el=P(),cy=O(),ly=ae(),uy=jo(),dy={message:({params:{len:t}})=>(0,el.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,el._)`{limit: ${t}}`},fy={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:dy,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,cy.alwaysValidSchema)(n,e)&&(s?(0,uy.validateAdditionalItems)(t,s):t.ok((0,ly.validateArray)(t)))}};Bo.default=fy});var rl=_(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});var le=P(),Bn=O(),hy={message:({params:{min:t,max:e}})=>e===void 0?(0,le.str)`must contain at least ${t} valid item(s)`:(0,le.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,le._)`{minContains: ${t}}`:(0,le._)`{minContains: ${t}, maxContains: ${e}}`},py={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:hy,code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t,i,a,{minContains:c,maxContains:l}=n;o.opts.next?(i=c===void 0?1:c,a=l):i=1;let u=e.const("len",(0,le._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Bn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Bn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Bn.alwaysValidSchema)(o,r)){let m=(0,le._)`${u} >= ${i}`;a!==void 0&&(m=(0,le._)`${m} && ${u} <= ${a}`),t.pass(m);return}o.items=!0;let d=e.name("valid");a===void 0&&i===1?p(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,le._)`${s}.length > 0`,f)):(e.let(d,!1),f()),t.result(d,()=>t.reset());function f(){let m=e.name("_valid"),y=e.let("count",0);p(m,()=>e.if(m,()=>h(y)))}function p(m,y){e.forRange("i",0,u,g=>{t.subschema({keyword:"contains",dataProp:g,dataPropType:Bn.Type.Num,compositeRule:!0},m),y()})}function h(m){e.code((0,le._)`${m}++`),a===void 0?e.if((0,le._)`${m} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,le._)`${m} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,le._)`${m} >= ${i}`,()=>e.assign(d,!0)))}}};Uo.default=py});var ol=_(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.validateSchemaDeps=xe.validatePropertyDeps=xe.error=void 0;var Wo=P(),my=O(),Yr=ae();xe.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Wo.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Wo._)`{property: ${t},
7
+ missingProperty: ${n},
8
+ depsCount: ${e},
9
+ deps: ${r}}`};var yy={keyword:"dependencies",type:"object",schemaType:"object",error:xe.error,code(t){let[e,r]=gy(t);nl(t,e),sl(t,r)}};function gy({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let s=Array.isArray(t[n])?e:r;s[n]=t[n]}return[e,r]}function nl(t,e=t.schema){let{gen:r,data:n,it:s}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Yr.propertyInData)(r,n,i,s.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),s.allErrors?r.if(c,()=>{for(let l of a)(0,Yr.checkReportMissingProp)(t,l)}):(r.if((0,Wo._)`${c} && (${(0,Yr.checkMissingProp)(t,a,o)})`),(0,Yr.reportMissingProp)(t,o),r.else())}}xe.validatePropertyDeps=nl;function sl(t,e=t.schema){let{gen:r,data:n,keyword:s,it:o}=t,i=r.name("valid");for(let a in e)(0,my.alwaysValidSchema)(o,e[a])||(r.if((0,Yr.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:s,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}xe.validateSchemaDeps=sl;xe.default=yy});var al=_(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});var il=P(),_y=O(),vy={message:"property name must be valid",params:({params:t})=>(0,il._)`{propertyName: ${t.propertyName}}`},by={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:vy,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,_y.alwaysValidSchema)(s,r))return;let o=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,il.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};Vo.default=by});var zo=_(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});var Un=ae(),ye=P(),wy=qe(),Wn=O(),Ey={message:"must NOT have additional properties",params:({params:t})=>(0,ye._)`{additionalProperty: ${t.additionalProperty}}`},Sy={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Ey,code(t){let{gen:e,schema:r,parentSchema:n,data:s,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,Wn.alwaysValidSchema)(i,r))return;let l=(0,Un.allSchemaProperties)(n.properties),u=(0,Un.allSchemaProperties)(n.patternProperties);d(),t.ok((0,ye._)`${o} === ${wy.default.errors}`);function d(){e.forIn("key",s,y=>{!l.length&&!u.length?h(y):e.if(f(y),()=>h(y))})}function f(y){let g;if(l.length>8){let b=(0,Wn.schemaRefOrVal)(i,n.properties,"properties");g=(0,Un.isOwnProperty)(e,b,y)}else l.length?g=(0,ye.or)(...l.map(b=>(0,ye._)`${y} === ${b}`)):g=ye.nil;return u.length&&(g=(0,ye.or)(g,...u.map(b=>(0,ye._)`${(0,Un.usePattern)(t,b)}.test(${y})`))),(0,ye.not)(g)}function p(y){e.code((0,ye._)`delete ${s}[${y}]`)}function h(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(y);return}if(r===!1){t.setParams({additionalProperty:y}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Wn.alwaysValidSchema)(i,r)){let g=e.name("valid");c.removeAdditional==="failing"?(m(y,g,!1),e.if((0,ye.not)(g),()=>{t.reset(),p(y)})):(m(y,g),a||e.if((0,ye.not)(g),()=>e.break()))}}function m(y,g,b){let E={keyword:"additionalProperties",dataProp:y,dataPropType:Wn.Type.Str};b===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(E,g)}}};Ho.default=Sy});var ul=_(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});var $y=Mr(),cl=ae(),Ko=O(),ll=zo(),ky={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&ll.default.code(new $y.KeywordCxt(o,ll.default,"additionalProperties"));let i=(0,cl.allSchemaProperties)(r);for(let d of i)o.definedProperties.add(d);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=Ko.mergeEvaluated.props(e,(0,Ko.toHash)(i),o.props));let a=i.filter(d=>!(0,Ko.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,cl.propertyInData)(e,s,d,o.opts.ownProperties)),u(d),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Go.default=ky});var pl=_(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});var dl=ae(),Vn=P(),fl=O(),hl=O(),Py={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:s,it:o}=t,{opts:i}=o,a=(0,dl.allSchemaProperties)(r),c=a.filter(m=>(0,fl.alwaysValidSchema)(o,r[m]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let l=i.strictSchema&&!i.allowMatchingProperties&&s.properties,u=e.name("valid");o.props!==!0&&!(o.props instanceof Vn.Name)&&(o.props=(0,hl.evaluatedPropsToName)(e,o.props));let{props:d}=o;f();function f(){for(let m of a)l&&p(m),o.allErrors?h(m):(e.var(u,!0),h(m),e.if(u))}function p(m){for(let y in l)new RegExp(m).test(y)&&(0,fl.checkStrictMode)(o,`property ${y} matches pattern ${m} (use allowMatchingProperties)`)}function h(m){e.forIn("key",n,y=>{e.if((0,Vn._)`${(0,dl.usePattern)(t,m)}.test(${y})`,()=>{let g=c.includes(m);g||t.subschema({keyword:"patternProperties",schemaProp:m,dataProp:y,dataPropType:hl.Type.Str},u),o.opts.unevaluated&&d!==!0?e.assign((0,Vn._)`${d}[${y}]`,!0):!g&&!o.allErrors&&e.if((0,Vn.not)(u),()=>e.break())})})}}};Yo.default=Py});var ml=_(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});var Ty=O(),Ry={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,Ty.alwaysValidSchema)(n,r)){t.fail();return}let s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Jo.default=Ry});var yl=_(Xo=>{"use strict";Object.defineProperty(Xo,"__esModule",{value:!0});var xy=ae(),Oy={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:xy.validateUnion,error:{message:"must match a schema in anyOf"}};Xo.default=Oy});var gl=_(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});var Hn=P(),Ny=O(),Ay={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Hn._)`{passingSchemas: ${t.passing}}`},Cy={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Ay,code(t){let{gen:e,schema:r,parentSchema:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(i,()=>t.reset(),()=>t.error(!0));function l(){o.forEach((u,d)=>{let f;(0,Ny.alwaysValidSchema)(s,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Hn._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Hn._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),f&&t.mergeEvaluated(f,Hn.Name)})})}}};Qo.default=Cy});var _l=_(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});var Iy=O(),My={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=e.name("valid");r.forEach((o,i)=>{if((0,Iy.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};Zo.default=My});var wl=_(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});var zn=P(),bl=O(),Ly={message:({params:t})=>(0,zn.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,zn._)`{failingKeyword: ${t.ifClause}}`},Dy={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Ly,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,bl.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=vl(n,"then"),o=vl(n,"else");if(!s&&!o)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&o){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else s?e.if(a,l("then")):e.if((0,zn.not)(a),l("else"));t.pass(i,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let f=t.subschema({keyword:u},a);e.assign(i,a),t.mergeValidEvaluated(f,i),d?e.assign(d,(0,zn._)`${u}`):t.setParams({ifClause:u})}}}};function vl(t,e){let r=t.schema[e];return r!==void 0&&!(0,bl.alwaysValidSchema)(t,r)}ei.default=Dy});var El=_(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});var jy=O(),qy={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,jy.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};ti.default=qy});var Sl=_(ri=>{"use strict";Object.defineProperty(ri,"__esModule",{value:!0});var Fy=jo(),By=Zc(),Uy=qo(),Wy=tl(),Vy=rl(),Hy=ol(),zy=al(),Ky=zo(),Gy=ul(),Yy=pl(),Jy=ml(),Xy=yl(),Qy=gl(),Zy=_l(),eg=wl(),tg=El();function rg(t=!1){let e=[Jy.default,Xy.default,Qy.default,Zy.default,eg.default,tg.default,zy.default,Ky.default,Hy.default,Gy.default,Yy.default];return t?e.push(By.default,Wy.default):e.push(Fy.default,Uy.default),e.push(Vy.default),e}ri.default=rg});var $l=_(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});var q=P(),ng={message:({schemaCode:t})=>(0,q.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,q._)`{format: ${t}}`},sg={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:ng,code(t,e){let{gen:r,data:n,$data:s,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;s?f():p();function f(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),m=r.const("fDef",(0,q._)`${h}[${i}]`),y=r.let("fType"),g=r.let("format");r.if((0,q._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(y,(0,q._)`${m}.type || "string"`).assign(g,(0,q._)`${m}.validate`),()=>r.assign(y,(0,q._)`"string"`).assign(g,m)),t.fail$data((0,q.or)(b(),E()));function b(){return c.strictSchema===!1?q.nil:(0,q._)`${i} && !${g}`}function E(){let S=u.$async?(0,q._)`(${m}.async ? await ${g}(${n}) : ${g}(${n}))`:(0,q._)`${g}(${n})`,v=(0,q._)`(typeof ${g} == "function" ? ${S} : ${g}.test(${n}))`;return(0,q._)`${g} && ${g} !== true && ${y} === ${e} && !${v}`}}function p(){let h=d.formats[o];if(!h){b();return}if(h===!0)return;let[m,y,g]=E(h);m===e&&t.pass(S());function b(){if(c.strictSchema===!1){d.logger.warn(v());return}throw new Error(v());function v(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function E(v){let D=v instanceof RegExp?(0,q.regexpCode)(v):c.code.formats?(0,q._)`${c.code.formats}${(0,q.getProperty)(o)}`:void 0,B=r.scopeValue("formats",{key:o,ref:v,code:D});return typeof v=="object"&&!(v instanceof RegExp)?[v.type||"string",v.validate,(0,q._)`${B}.validate`]:["string",v,B]}function S(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!u.$async)throw new Error("async format in sync schema");return(0,q._)`await ${g}(${n})`}return typeof y=="function"?(0,q._)`${g}(${n})`:(0,q._)`${g}.test(${n})`}}}};ni.default=sg});var kl=_(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});var og=$l(),ig=[og.default];si.default=ig});var Pl=_(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.contentVocabulary=Qt.metadataVocabulary=void 0;Qt.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Qt.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Rl=_(oi=>{"use strict";Object.defineProperty(oi,"__esModule",{value:!0});var ag=Mc(),cg=Yc(),lg=Sl(),ug=kl(),Tl=Pl(),dg=[ag.default,cg.default,(0,lg.default)(),ug.default,Tl.metadataVocabulary,Tl.contentVocabulary];oi.default=dg});var Ol=_(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.DiscrError=void 0;var xl;(function(t){t.Tag="tag",t.Mapping="mapping"})(xl||(Kn.DiscrError=xl={}))});var Al=_(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});var Zt=P(),ii=Ol(),Nl=xn(),fg=Lr(),hg=O(),pg={message:({params:{discrError:t,tagName:e}})=>t===ii.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Zt._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},mg={keyword:"discriminator",type:"object",schemaType:"object",error:pg,code(t){let{gen:e,data:r,schema:n,parentSchema:s,it:o}=t,{oneOf:i}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,Zt._)`${r}${(0,Zt.getProperty)(a)}`);e.if((0,Zt._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:ii.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=f();e.if(!1);for(let h in p)e.elseIf((0,Zt._)`${l} === ${h}`),e.assign(c,d(p[h]));e.else(),t.error(!1,{discrError:ii.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let h=e.name("valid"),m=t.subschema({keyword:"oneOf",schemaProp:p},h);return t.mergeEvaluated(m,Zt.Name),h}function f(){var p;let h={},m=g(s),y=!0;for(let S=0;S<i.length;S++){let v=i[S];if(v?.$ref&&!(0,hg.schemaHasRulesButRef)(v,o.self.RULES)){let B=v.$ref;if(v=Nl.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,B),v instanceof Nl.SchemaEnv&&(v=v.schema),v===void 0)throw new fg.default(o.opts.uriResolver,o.baseId,B)}let D=(p=v?.properties)===null||p===void 0?void 0:p[a];if(typeof D!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(m||g(v)),b(D,S)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return h;function g({required:S}){return Array.isArray(S)&&S.includes(a)}function b(S,v){if(S.const)E(S.const,v);else if(S.enum)for(let D of S.enum)E(D,v);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function E(S,v){if(typeof S!="string"||S in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[S]=v}}}};ai.default=mg});var Cl=_((zw,yg)=>{yg.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var Yn=_((L,ci)=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.MissingRefError=L.ValidationError=L.CodeGen=L.Name=L.nil=L.stringify=L.str=L._=L.KeywordCxt=L.Ajv=void 0;var gg=xc(),_g=Rl(),vg=Al(),Il=Cl(),bg=["/properties"],Gn="http://json-schema.org/draft-07/schema",er=class extends gg.default{_addVocabularies(){super._addVocabularies(),_g.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(vg.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Il,bg):Il;this.addMetaSchema(e,Gn,!1),this.refs["http://json-schema.org/schema"]=Gn}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Gn)?Gn:void 0)}};L.Ajv=er;ci.exports=L=er;ci.exports.Ajv=er;Object.defineProperty(L,"__esModule",{value:!0});L.default=er;var wg=Mr();Object.defineProperty(L,"KeywordCxt",{enumerable:!0,get:function(){return wg.KeywordCxt}});var tr=P();Object.defineProperty(L,"_",{enumerable:!0,get:function(){return tr._}});Object.defineProperty(L,"str",{enumerable:!0,get:function(){return tr.str}});Object.defineProperty(L,"stringify",{enumerable:!0,get:function(){return tr.stringify}});Object.defineProperty(L,"nil",{enumerable:!0,get:function(){return tr.nil}});Object.defineProperty(L,"Name",{enumerable:!0,get:function(){return tr.Name}});Object.defineProperty(L,"CodeGen",{enumerable:!0,get:function(){return tr.CodeGen}});var Eg=Tn();Object.defineProperty(L,"ValidationError",{enumerable:!0,get:function(){return Eg.default}});var Sg=Lr();Object.defineProperty(L,"MissingRefError",{enumerable:!0,get:function(){return Sg.default}})});var Ul=_(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.formatNames=Ne.fastFormats=Ne.fullFormats=void 0;function Oe(t,e){return{validate:t,compare:e}}Ne.fullFormats={date:Oe(jl,fi),time:Oe(ui(!0),hi),"date-time":Oe(Ml(!0),Fl),"iso-time":Oe(ui(),ql),"iso-date-time":Oe(Ml(),Bl),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:xg,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[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,1}[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|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\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})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\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,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?: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)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:Lg,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:Og,int32:{type:"number",validate:Cg},int64:{type:"number",validate:Ig},float:{type:"number",validate:Dl},double:{type:"number",validate:Dl},password:!0,binary:!0};Ne.fastFormats={...Ne.fullFormats,date:Oe(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,fi),time:Oe(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,hi),"date-time":Oe(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Fl),"iso-time":Oe(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,ql),"iso-date-time":Oe(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Bl),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};Ne.formatNames=Object.keys(Ne.fullFormats);function $g(t){return t%4===0&&(t%100!==0||t%400===0)}var kg=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Pg=[0,31,28,31,30,31,30,31,31,30,31,30,31];function jl(t){let e=kg.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],s=+e[3];return n>=1&&n<=12&&s>=1&&s<=(n===2&&$g(r)?29:Pg[n])}function fi(t,e){if(t&&e)return t>e?1:t<e?-1:0}var li=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function ui(t){return function(r){let n=li.exec(r);if(!n)return!1;let s=+n[1],o=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||t&&!a)return!1;if(s<=23&&o<=59&&i<60)return!0;let d=o-u*c,f=s-l*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function hi(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function ql(t,e){if(!(t&&e))return;let r=li.exec(t),n=li.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var di=/t|\s/i;function Ml(t){let e=ui(t);return function(n){let s=n.split(di);return s.length===2&&jl(s[0])&&e(s[1])}}function Fl(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function Bl(t,e){if(!(t&&e))return;let[r,n]=t.split(di),[s,o]=e.split(di),i=fi(r,s);if(i!==void 0)return i||hi(n,o)}var Tg=/\/|:/,Rg=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[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,1}[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|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\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})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\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 xg(t){return Tg.test(t)&&Rg.test(t)}var Ll=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function Og(t){return Ll.lastIndex=0,Ll.test(t)}var Ng=-(2**31),Ag=2**31-1;function Cg(t){return Number.isInteger(t)&&t<=Ag&&t>=Ng}function Ig(t){return Number.isInteger(t)}function Dl(){return!0}var Mg=/[^\\]\\Z/;function Lg(t){if(Mg.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var Wl=_(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.formatLimitDefinition=void 0;var Dg=Yn(),ge=P(),tt=ge.operators,Jn={formatMaximum:{okStr:"<=",ok:tt.LTE,fail:tt.GT},formatMinimum:{okStr:">=",ok:tt.GTE,fail:tt.LT},formatExclusiveMaximum:{okStr:"<",ok:tt.LT,fail:tt.GTE},formatExclusiveMinimum:{okStr:">",ok:tt.GT,fail:tt.LTE}},jg={message:({keyword:t,schemaCode:e})=>(0,ge.str)`should be ${Jn[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ge._)`{comparison: ${Jn[t].okStr}, limit: ${e}}`};rr.formatLimitDefinition={keyword:Object.keys(Jn),type:"string",schemaType:"string",$data:!0,error:jg,code(t){let{gen:e,data:r,schemaCode:n,keyword:s,it:o}=t,{opts:i,self:a}=o;if(!i.validateFormats)return;let c=new Dg.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?l():u();function l(){let f=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=e.const("fmt",(0,ge._)`${f}[${c.schemaCode}]`);t.fail$data((0,ge.or)((0,ge._)`typeof ${p} != "object"`,(0,ge._)`${p} instanceof RegExp`,(0,ge._)`typeof ${p}.compare != "function"`,d(p)))}function u(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${s}": format "${f}" does not define "compare" function`);let h=e.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,ge._)`${i.code.formats}${(0,ge.getProperty)(f)}`:void 0});t.fail$data(d(h))}function d(f){return(0,ge._)`${f}.compare(${r}, ${n}) ${Jn[s].fail} 0`}},dependencies:["format"]};var qg=t=>(t.addKeyword(rr.formatLimitDefinition),t);rr.default=qg});var yi=_((Jr,zl)=>{"use strict";Object.defineProperty(Jr,"__esModule",{value:!0});var nr=Ul(),Fg=Wl(),pi=P(),Vl=new pi.Name("fullFormats"),Bg=new pi.Name("fastFormats"),mi=(t,e={keywords:!0})=>{if(Array.isArray(e))return Hl(t,e,nr.fullFormats,Vl),t;let[r,n]=e.mode==="fast"?[nr.fastFormats,Bg]:[nr.fullFormats,Vl],s=e.formats||nr.formatNames;return Hl(t,s,r,n),e.keywords&&(0,Fg.default)(t),t};mi.get=(t,e="full")=>{let n=(e==="fast"?nr.fastFormats:nr.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function Hl(t,e,r,n){var s,o;(s=(o=t.opts.code).formats)!==null&&s!==void 0||(o.formats=(0,pi._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}zl.exports=Jr=mi;Object.defineProperty(Jr,"__esModule",{value:!0});Jr.default=mi});var Ue=_((gE,du)=>{"use strict";var lu=["nodebuffer","arraybuffer","fragments"],uu=typeof Blob<"u";uu&&lu.push("blob");du.exports={BINARY_TYPES:lu,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:uu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var rn=_((_E,ns)=>{"use strict";var{EMPTY_BUFFER:p_}=Ue(),$i=Buffer[Symbol.species];function m_(t,e){if(t.length===0)return p_;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let s=0;s<t.length;s++){let o=t[s];r.set(o,n),n+=o.length}return n<e?new $i(r.buffer,r.byteOffset,n):r}function fu(t,e,r,n,s){for(let o=0;o<s;o++)r[n+o]=t[o]^e[o&3]}function hu(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function y_(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ki(t){if(ki.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new $i(t):ArrayBuffer.isView(t)?e=new $i(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ki.readOnly=!1),e}ns.exports={concat:m_,mask:fu,toArrayBuffer:y_,toBuffer:ki,unmask:hu};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=F("bufferutil");ns.exports.mask=function(e,r,n,s,o){o<48?fu(e,r,n,s,o):t.mask(e,r,n,s,o)},ns.exports.unmask=function(e,r){e.length<32?hu(e,r):t.unmask(e,r)}}catch{}});var yu=_((vE,mu)=>{"use strict";var pu=Symbol("kDone"),Pi=Symbol("kRun"),Ti=class{constructor(e){this[pu]=()=>{this.pending--,this[Pi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Pi]()}[Pi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[pu])}}};mu.exports=Ti});var fr=_((bE,bu)=>{"use strict";var nn=F("zlib"),gu=rn(),g_=yu(),{kStatusCode:_u}=Ue(),__=Buffer[Symbol.species],v_=Buffer.from([0,0,255,255]),os=Symbol("permessage-deflate"),We=Symbol("total-length"),ur=Symbol("callback"),st=Symbol("buffers"),dr=Symbol("error"),ss,Ri=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ss){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ss=new g_(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[ur];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,n=e.find(s=>!(r.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>s.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(n=>{let s=r[n];if(s.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(s=s[0],n==="client_max_window_bits"){if(s!==!0){let o=+s;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else if(n==="server_max_window_bits"){let o=+s;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=o}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=s})}),e}decompress(e,r,n){ss.add(s=>{this._decompress(e,r,(o,i)=>{s(),n(o,i)})})}compress(e,r,n){ss.add(s=>{this._compress(e,r,(o,i)=>{s(),n(o,i)})})}_decompress(e,r,n){let s=this._isServer?"client":"server";if(!this._inflate){let o=`${s}_max_window_bits`,i=typeof this.params[o]!="number"?nn.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=nn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:i}),this._inflate[os]=this,this._inflate[We]=0,this._inflate[st]=[],this._inflate.on("error",w_),this._inflate.on("data",vu)}this._inflate[ur]=n,this._inflate.write(e),r&&this._inflate.write(v_),this._inflate.flush(()=>{let o=this._inflate[dr];if(o){this._inflate.close(),this._inflate=null,n(o);return}let i=gu.concat(this._inflate[st],this._inflate[We]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[We]=0,this._inflate[st]=[],r&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),n(null,i)})}_compress(e,r,n){let s=this._isServer?"server":"client";if(!this._deflate){let o=`${s}_max_window_bits`,i=typeof this.params[o]!="number"?nn.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=nn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),this._deflate[We]=0,this._deflate[st]=[],this._deflate.on("data",b_)}this._deflate[ur]=n,this._deflate.write(e),this._deflate.flush(nn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=gu.concat(this._deflate[st],this._deflate[We]);r&&(o=new __(o.buffer,o.byteOffset,o.length-4)),this._deflate[ur]=null,this._deflate[We]=0,this._deflate[st]=[],r&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),n(null,o)})}};bu.exports=Ri;function b_(t){this[st].push(t),this[We]+=t.length}function vu(t){if(this[We]+=t.length,this[os]._maxPayload<1||this[We]<=this[os]._maxPayload){this[st].push(t);return}this[dr]=new RangeError("Max payload size exceeded"),this[dr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[dr][_u]=1009,this.removeListener("data",vu),this.reset()}function w_(t){if(this[os]._inflate=null,this[dr]){this[ur](this[dr]);return}t[_u]=1007,this[ur](t)}});var hr=_((wE,is)=>{"use strict";var{isUtf8:wu}=F("buffer"),{hasBlob:E_}=Ue(),S_=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function $_(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function xi(t){let e=t.length,r=0;for(;r<e;)if(!(t[r]&128))r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function k_(t){return E_&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}is.exports={isBlob:k_,isValidStatusCode:$_,isValidUTF8:xi,tokenChars:S_};if(wu)is.exports.isValidUTF8=function(t){return t.length<24?xi(t):wu(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=F("utf-8-validate");is.exports.isValidUTF8=function(e){return e.length<32?xi(e):t(e)}}catch{}});var Ii=_((EE,Ru)=>{"use strict";var{Writable:P_}=F("stream"),Eu=fr(),{BINARY_TYPES:T_,EMPTY_BUFFER:Su,kStatusCode:R_,kWebSocket:x_}=Ue(),{concat:Oi,toArrayBuffer:O_,unmask:N_}=rn(),{isValidStatusCode:A_,isValidUTF8:$u}=hr(),as=Buffer[Symbol.species],de=0,ku=1,Pu=2,Tu=3,Ni=4,Ai=5,cs=6,Ci=class extends P_{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||T_[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[x_]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=de}_write(e,r,n){if(this._opcode===8&&this._state==de)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new as(n.buffer,n.byteOffset+e,n.length-e),new as(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],s=r.length-e;e>=n.length?r.set(this._buffers.shift(),s):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),s),this._buffers[0]=new as(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case de:this.getInfo(e);break;case ku:this.getPayloadLength16(e);break;case Pu:this.getPayloadLength64(e);break;case Tu:this.getMask();break;case Ni:this.getData(e);break;case Ai:case cs:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if(r[0]&48){let s=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(s);return}let n=(r[0]&64)===64;if(n&&!this._extensions[Eu.extensionName]){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(!this._fragmented){let s=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let s=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(s);return}if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let s=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(s);return}}else{let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let s=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(s);return}}else if(this._masked){let s=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(s);return}this._payloadLength===126?this._state=ku:this._payloadLength===127?this._state=Pu:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let s=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(s);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Tu:this._state=Ni}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Ni}getData(e){let r=Su;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&N_(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Ai,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Eu.extensionName].decompress(e,this._fin,(s,o)=>{if(s)return r(s);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(i);return}this._fragments.push(o)}this.dataMessage(r),this._state===de&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=de;return}let r=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=Oi(n,r):this._binaryType==="arraybuffer"?s=O_(Oi(n,r)):this._binaryType==="blob"?s=new Blob(n):s=n,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=de):(this._state=cs,setImmediate(()=>{this.emit("message",s,!0),this._state=de,this.startLoop(e)}))}else{let s=Oi(n,r);if(!this._skipUTF8Validation&&!$u(s)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(o);return}this._state===Ai||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=de):(this._state=cs,setImmediate(()=>{this.emit("message",s,!1),this._state=de,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Su),this.end();else{let n=e.readUInt16BE(0);if(!A_(n)){let o=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(o);return}let s=new as(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!$u(s)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(o);return}this._loop=!1,this.emit("conclude",n,s),this.end()}this._state=de;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=de):(this._state=cs,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=de,this.startLoop(r)}))}createError(e,r,n,s,o){this._loop=!1,this._errored=!0;let i=new e(n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(i,this.createError),i.code=o,i[R_]=s,i}};Ru.exports=Ci});var Di=_(($E,Nu)=>{"use strict";var{Duplex:SE}=F("stream"),{randomFillSync:C_}=F("crypto"),xu=fr(),{EMPTY_BUFFER:I_,kWebSocket:M_,NOOP:L_}=Ue(),{isBlob:pr,isValidStatusCode:D_}=hr(),{mask:Ou,toBuffer:Pt}=rn(),fe=Symbol("kByteLength"),j_=Buffer.alloc(4),ls=8*1024,Tt,mr=ls,_e=0,q_=1,F_=2,Mi=class t{constructor(e,r,n){this._extensions=r||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=_e,this.onerror=L_,this[M_]=void 0}static frame(e,r){let n,s=!1,o=2,i=!1;r.mask&&(n=r.maskBuffer||j_,r.generateMask?r.generateMask(n):(mr===ls&&(Tt===void 0&&(Tt=Buffer.alloc(ls)),C_(Tt,0,ls),mr=0),n[0]=Tt[mr++],n[1]=Tt[mr++],n[2]=Tt[mr++],n[3]=Tt[mr++]),i=(n[0]|n[1]|n[2]|n[3])===0,o=6);let a;typeof e=="string"?(!r.mask||i)&&r[fe]!==void 0?a=r[fe]:(e=Buffer.from(e),a=e.length):(a=e.length,s=r.mask&&r.readOnly&&!i);let c=a;a>=65536?(o+=8,c=127):a>125&&(o+=2,c=126);let l=Buffer.allocUnsafe(s?a+o:o);return l[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(a,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(a,4,6)),r.mask?(l[1]|=128,l[o-4]=n[0],l[o-3]=n[1],l[o-2]=n[2],l[o-1]=n[3],i?[l,e]:s?(Ou(e,n,l,o,a),[l]):(Ou(e,n,e,0,a),[l,e])):[l,e]}close(e,r,n,s){let o;if(e===void 0)o=I_;else{if(typeof e!="number"||!D_(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(e,0);else{let a=Buffer.byteLength(r);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+a),o.writeUInt16BE(e,0),typeof r=="string"?o.write(r,2):o.set(r,2)}}let i={[fe]:o.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==_e?this.enqueue([this.dispatch,o,!1,i,s]):this.sendFrame(t.frame(o,i),s)}ping(e,r,n){let s,o;if(typeof e=="string"?(s=Buffer.byteLength(e),o=!1):pr(e)?(s=e.size,o=!1):(e=Pt(e),s=e.length,o=Pt.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[fe]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};pr(e)?this._state!==_e?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):this._state!==_e?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}pong(e,r,n){let s,o;if(typeof e=="string"?(s=Buffer.byteLength(e),o=!1):pr(e)?(s=e.size,o=!1):(e=Pt(e),s=e.length,o=Pt.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[fe]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};pr(e)?this._state!==_e?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):this._state!==_e?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}send(e,r,n){let s=this._extensions[xu.extensionName],o=r.binary?2:1,i=r.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):pr(e)?(a=e.size,c=!1):(e=Pt(e),a=e.length,c=Pt.readOnly),this._firstFragment?(this._firstFragment=!1,i&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(i=a>=s._threshold),this._compress=i):(i=!1,o=0),r.fin&&(this._firstFragment=!0);let l={[fe]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:c,rsv1:i};pr(e)?this._state!==_e?this.enqueue([this.getBlobData,e,this._compress,l,n]):this.getBlobData(e,this._compress,l,n):this._state!==_e?this.enqueue([this.dispatch,e,this._compress,l,n]):this.dispatch(e,this._compress,l,n)}getBlobData(e,r,n,s){this._bufferedBytes+=n[fe],this._state=F_,e.arrayBuffer().then(o=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(Li,this,a,s);return}this._bufferedBytes-=n[fe];let i=Pt(o);r?this.dispatch(i,r,n,s):(this._state=_e,this.sendFrame(t.frame(i,n),s),this.dequeue())}).catch(o=>{process.nextTick(B_,this,o,s)})}dispatch(e,r,n,s){if(!r){this.sendFrame(t.frame(e,n),s);return}let o=this._extensions[xu.extensionName];this._bufferedBytes+=n[fe],this._state=q_,o.compress(e,n.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");Li(this,c,s);return}this._bufferedBytes-=n[fe],this._state=_e,n.readOnly=!1,this.sendFrame(t.frame(a,n),s),this.dequeue()})}dequeue(){for(;this._state===_e&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][fe],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][fe],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Nu.exports=Mi;function Li(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let s=t._queue[n],o=s[s.length-1];typeof o=="function"&&o(e)}}function B_(t,e,r){Li(t,e,r),t.onerror(e)}});var Fu=_((kE,qu)=>{"use strict";var{kForOnEventAttribute:sn,kListener:ji}=Ue(),Au=Symbol("kCode"),Cu=Symbol("kData"),Iu=Symbol("kError"),Mu=Symbol("kMessage"),Lu=Symbol("kReason"),yr=Symbol("kTarget"),Du=Symbol("kType"),ju=Symbol("kWasClean"),Ve=class{constructor(e){this[yr]=null,this[Du]=e}get target(){return this[yr]}get type(){return this[Du]}};Object.defineProperty(Ve.prototype,"target",{enumerable:!0});Object.defineProperty(Ve.prototype,"type",{enumerable:!0});var Rt=class extends Ve{constructor(e,r={}){super(e),this[Au]=r.code===void 0?0:r.code,this[Lu]=r.reason===void 0?"":r.reason,this[ju]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Au]}get reason(){return this[Lu]}get wasClean(){return this[ju]}};Object.defineProperty(Rt.prototype,"code",{enumerable:!0});Object.defineProperty(Rt.prototype,"reason",{enumerable:!0});Object.defineProperty(Rt.prototype,"wasClean",{enumerable:!0});var gr=class extends Ve{constructor(e,r={}){super(e),this[Iu]=r.error===void 0?null:r.error,this[Mu]=r.message===void 0?"":r.message}get error(){return this[Iu]}get message(){return this[Mu]}};Object.defineProperty(gr.prototype,"error",{enumerable:!0});Object.defineProperty(gr.prototype,"message",{enumerable:!0});var on=class extends Ve{constructor(e,r={}){super(e),this[Cu]=r.data===void 0?null:r.data}get data(){return this[Cu]}};Object.defineProperty(on.prototype,"data",{enumerable:!0});var U_={addEventListener(t,e,r={}){for(let s of this.listeners(t))if(!r[sn]&&s[ji]===e&&!s[sn])return;let n;if(t==="message")n=function(o,i){let a=new on("message",{data:i?o:o.toString()});a[yr]=this,us(e,this,a)};else if(t==="close")n=function(o,i){let a=new Rt("close",{code:o,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[yr]=this,us(e,this,a)};else if(t==="error")n=function(o){let i=new gr("error",{error:o,message:o.message});i[yr]=this,us(e,this,i)};else if(t==="open")n=function(){let o=new Ve("open");o[yr]=this,us(e,this,o)};else return;n[sn]=!!r[sn],n[ji]=e,r.once?this.once(t,n):this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[ji]===e&&!r[sn]){this.removeListener(t,r);break}}};qu.exports={CloseEvent:Rt,ErrorEvent:gr,Event:Ve,EventTarget:U_,MessageEvent:on};function us(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ds=_((PE,Bu)=>{"use strict";var{tokenChars:an}=hr();function Ce(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function W_(t){let e=Object.create(null),r=Object.create(null),n=!1,s=!1,o=!1,i,a,c=-1,l=-1,u=-1,d=0;for(;d<t.length;d++)if(l=t.charCodeAt(d),i===void 0)if(u===-1&&an[l]===1)c===-1&&(c=d);else if(d!==0&&(l===32||l===9))u===-1&&c!==-1&&(u=d);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);u===-1&&(u=d);let p=t.slice(c,u);l===44?(Ce(e,p,r),r=Object.create(null)):i=p,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);else if(a===void 0)if(u===-1&&an[l]===1)c===-1&&(c=d);else if(l===32||l===9)u===-1&&c!==-1&&(u=d);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);u===-1&&(u=d),Ce(r,t.slice(c,u),!0),l===44&&(Ce(e,i,r),r=Object.create(null),i=void 0),c=u=-1}else if(l===61&&c!==-1&&u===-1)a=t.slice(c,d),c=u=-1;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(s){if(an[l]!==1)throw new SyntaxError(`Unexpected character at index ${d}`);c===-1?c=d:n||(n=!0),s=!1}else if(o)if(an[l]===1)c===-1&&(c=d);else if(l===34&&c!==-1)o=!1,u=d;else if(l===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(l===34&&t.charCodeAt(d-1)===61)o=!0;else if(u===-1&&an[l]===1)c===-1&&(c=d);else if(c!==-1&&(l===32||l===9))u===-1&&(u=d);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);u===-1&&(u=d);let p=t.slice(c,u);n&&(p=p.replace(/\\/g,""),n=!1),Ce(r,a,p),l===44&&(Ce(e,i,r),r=Object.create(null),i=void 0),a=void 0,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);if(c===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=d);let f=t.slice(c,u);return i===void 0?Ce(e,f,r):(a===void 0?Ce(r,f,!0):n?Ce(r,a,f.replace(/\\/g,"")):Ce(r,a,f),Ce(e,i,r)),e}function V_(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(n=>[e].concat(Object.keys(n).map(s=>{let o=n[s];return Array.isArray(o)||(o=[o]),o.map(i=>i===!0?s:`${s}=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Bu.exports={format:V_,parse:W_}});var ms=_((xE,Zu)=>{"use strict";var H_=F("events"),z_=F("https"),K_=F("http"),Vu=F("net"),G_=F("tls"),{randomBytes:Y_,createHash:J_}=F("crypto"),{Duplex:TE,Readable:RE}=F("stream"),{URL:qi}=F("url"),ot=fr(),X_=Ii(),Q_=Di(),{isBlob:Z_}=hr(),{BINARY_TYPES:Uu,CLOSE_TIMEOUT:e0,EMPTY_BUFFER:fs,GUID:t0,kForOnEventAttribute:Fi,kListener:r0,kStatusCode:n0,kWebSocket:U,NOOP:Hu}=Ue(),{EventTarget:{addEventListener:s0,removeEventListener:o0}}=Fu(),{format:i0,parse:a0}=ds(),{toBuffer:c0}=rn(),zu=Symbol("kAborted"),Bi=[8,13],He=["CONNECTING","OPEN","CLOSING","CLOSED"],l0=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,j=class t extends H_{constructor(e,r,n){super(),this._binaryType=Uu[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=fs,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),Ku(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Uu.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,n){let s=new X_({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),o=new Q_(e,this._extensions,n.generateMask);this._receiver=s,this._sender=o,this._socket=e,s[U]=this,o[U]=this,e[U]=this,s.on("conclude",f0),s.on("drain",h0),s.on("error",p0),s.on("message",m0),s.on("ping",y0),s.on("pong",g0),o.onerror=_0,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Ju),e.on("data",ps),e.on("end",Xu),e.on("error",Qu),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[ot.extensionName]&&this._extensions[ot.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ne(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Yu(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ui(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||fs,r,n)}pong(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ui(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||fs,r,n)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ui(this,e,n);return}let s={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[ot.extensionName]||(s.compress=!1),this._sender.send(e||fs,s,n)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ne(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(j,"CONNECTING",{enumerable:!0,value:He.indexOf("CONNECTING")});Object.defineProperty(j.prototype,"CONNECTING",{enumerable:!0,value:He.indexOf("CONNECTING")});Object.defineProperty(j,"OPEN",{enumerable:!0,value:He.indexOf("OPEN")});Object.defineProperty(j.prototype,"OPEN",{enumerable:!0,value:He.indexOf("OPEN")});Object.defineProperty(j,"CLOSING",{enumerable:!0,value:He.indexOf("CLOSING")});Object.defineProperty(j.prototype,"CLOSING",{enumerable:!0,value:He.indexOf("CLOSING")});Object.defineProperty(j,"CLOSED",{enumerable:!0,value:He.indexOf("CLOSED")});Object.defineProperty(j.prototype,"CLOSED",{enumerable:!0,value:He.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(j.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(j.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Fi])return e[r0];return null},set(e){for(let r of this.listeners(t))if(r[Fi]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Fi]:!0})}})});j.prototype.addEventListener=s0;j.prototype.removeEventListener=o0;Zu.exports=j;function Ku(t,e,r,n){let s={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:e0,protocolVersion:Bi[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=s.autoPong,t._closeTimeout=s.closeTimeout,!Bi.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${Bi.join(", ")})`);let o;if(e instanceof qi)o=e;else try{o=new qi(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),t._url=o.href;let i=o.protocol==="wss:",a=o.protocol==="ws+unix:",c;if(o.protocol!=="ws:"&&!i&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!o.pathname?c="The URL's pathname is empty":o.hash&&(c="The URL contains a fragment identifier"),c){let m=new SyntaxError(c);if(t._redirects===0)throw m;hs(t,m);return}let l=i?443:80,u=Y_(16).toString("base64"),d=i?z_.request:K_.request,f=new Set,p;if(s.createConnection=s.createConnection||(i?d0:u0),s.defaultPort=s.defaultPort||l,s.port=o.port||l,s.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},s.path=o.pathname+o.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(p=new ot({...s.perMessageDeflate,isServer:!1,maxPayload:s.maxPayload}),s.headers["Sec-WebSocket-Extensions"]=i0({[ot.extensionName]:p.offer()})),r.length){for(let m of r){if(typeof m!="string"||!l0.test(m)||f.has(m))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(m)}s.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(o.username||o.password)&&(s.auth=`${o.username}:${o.password}`),a){let m=s.path.split(":");s.socketPath=m[0],s.path=m[1]}let h;if(s.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?s.socketPath:o.host;let m=n&&n.headers;if(n={...n,headers:{}},m)for(let[y,g]of Object.entries(m))n.headers[y.toLowerCase()]=g}else if(t.listenerCount("redirect")===0){let m=a?t._originalIpc?s.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:o.host===t._originalHostOrSocketPath;(!m||t._originalSecure&&!i)&&(delete s.headers.authorization,delete s.headers.cookie,m||delete s.headers.host,s.auth=void 0)}s.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),h=t._req=d(s),t._redirects&&t.emit("redirect",t.url,h)}else h=t._req=d(s);s.timeout&&h.on("timeout",()=>{ne(t,h,"Opening handshake has timed out")}),h.on("error",m=>{h===null||h[zu]||(h=t._req=null,hs(t,m))}),h.on("response",m=>{let y=m.headers.location,g=m.statusCode;if(y&&s.followRedirects&&g>=300&&g<400){if(++t._redirects>s.maxRedirects){ne(t,h,"Maximum redirects exceeded");return}h.abort();let b;try{b=new qi(y,e)}catch{let S=new SyntaxError(`Invalid URL: ${y}`);hs(t,S);return}Ku(t,b,r,n)}else t.emit("unexpected-response",h,m)||ne(t,h,`Unexpected server response: ${m.statusCode}`)}),h.on("upgrade",(m,y,g)=>{if(t.emit("upgrade",m),t.readyState!==j.CONNECTING)return;h=t._req=null;let b=m.headers.upgrade;if(b===void 0||b.toLowerCase()!=="websocket"){ne(t,y,"Invalid Upgrade header");return}let E=J_("sha1").update(u+t0).digest("base64");if(m.headers["sec-websocket-accept"]!==E){ne(t,y,"Invalid Sec-WebSocket-Accept header");return}let S=m.headers["sec-websocket-protocol"],v;if(S!==void 0?f.size?f.has(S)||(v="Server sent an invalid subprotocol"):v="Server sent a subprotocol but none was requested":f.size&&(v="Server sent no subprotocol"),v){ne(t,y,v);return}S&&(t._protocol=S);let D=m.headers["sec-websocket-extensions"];if(D!==void 0){if(!p){ne(t,y,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=a0(D)}catch{ne(t,y,"Invalid Sec-WebSocket-Extensions header");return}let $e=Object.keys(B);if($e.length!==1||$e[0]!==ot.extensionName){ne(t,y,"Server indicated an extension that was not requested");return}try{p.accept(B[ot.extensionName])}catch{ne(t,y,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[ot.extensionName]=p}t.setSocket(y,g,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),s.finishRequest?s.finishRequest(h,t):h.end()}function hs(t,e){t._readyState=j.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function u0(t){return t.path=t.socketPath,Vu.connect(t)}function d0(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Vu.isIP(t.host)?"":t.host),G_.connect(t)}function ne(t,e,r){t._readyState=j.CLOSING;let n=new Error(r);Error.captureStackTrace(n,ne),e.setHeader?(e[zu]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(hs,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Ui(t,e,r){if(e){let n=Z_(e)?e.size:c0(e).length;t._socket?t._sender._bufferedBytes+=n:t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${He[t.readyState]})`);process.nextTick(r,n)}}function f0(t,e){let r=this[U];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[U]!==void 0&&(r._socket.removeListener("data",ps),process.nextTick(Gu,r._socket),t===1005?r.close():r.close(t,e))}function h0(){let t=this[U];t.isPaused||t._socket.resume()}function p0(t){let e=this[U];e._socket[U]!==void 0&&(e._socket.removeListener("data",ps),process.nextTick(Gu,e._socket),e.close(t[n0])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Wu(){this[U].emitClose()}function m0(t,e){this[U].emit("message",t,e)}function y0(t){let e=this[U];e._autoPong&&e.pong(t,!this._isServer,Hu),e.emit("ping",t)}function g0(t){this[U].emit("pong",t)}function Gu(t){t.resume()}function _0(t){let e=this[U];e.readyState!==j.CLOSED&&(e.readyState===j.OPEN&&(e._readyState=j.CLOSING,Yu(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Yu(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Ju(){let t=this[U];if(this.removeListener("close",Ju),this.removeListener("data",ps),this.removeListener("end",Xu),t._readyState=j.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[U]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Wu),t._receiver.on("finish",Wu))}function ps(t){this[U]._receiver.write(t)||this.pause()}function Xu(){let t=this[U];t._readyState=j.CLOSING,t._receiver.end(),this.end()}function Qu(){let t=this[U];this.removeListener("error",Qu),this.on("error",Hu),t&&(t._readyState=j.CLOSING,this.destroy())}});var nd=_((NE,rd)=>{"use strict";var OE=ms(),{Duplex:v0}=F("stream");function ed(t){t.emit("close")}function b0(){!this.destroyed&&this._writableState.finished&&this.destroy()}function td(t){this.removeListener("error",td),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function w0(t,e){let r=!0,n=new v0({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(o,i){let a=!i&&n._readableState.objectMode?o.toString():o;n.push(a)||t.pause()}),t.once("error",function(o){n.destroyed||(r=!1,n.destroy(o))}),t.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(s,o){if(t.readyState===t.CLOSED){o(s),process.nextTick(ed,n);return}let i=!1;t.once("error",function(c){i=!0,o(c)}),t.once("close",function(){i||o(s),process.nextTick(ed,n)}),r&&t.terminate()},n._final=function(s){if(t.readyState===t.CONNECTING){t.once("open",function(){n._final(s)});return}t._socket!==null&&(t._socket._writableState.finished?(s(),n._readableState.endEmitted&&n.destroy()):(t._socket.once("finish",function(){s()}),t.close()))},n._read=function(){t.isPaused&&t.resume()},n._write=function(s,o,i){if(t.readyState===t.CONNECTING){t.once("open",function(){n._write(s,o,i)});return}t.send(s,i)},n.on("end",b0),n.on("error",td),n}rd.exports=w0});var Wi=_((AE,sd)=>{"use strict";var{tokenChars:E0}=hr();function S0(t){let e=new Set,r=-1,n=-1,s=0;for(s;s<t.length;s++){let i=t.charCodeAt(s);if(n===-1&&E0[i]===1)r===-1&&(r=s);else if(s!==0&&(i===32||i===9))n===-1&&r!==-1&&(n=s);else if(i===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${s}`);n===-1&&(n=s);let a=t.slice(r,n);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let o=t.slice(r,s);if(e.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return e.add(o),e}sd.exports={parse:S0}});var dd=_((IE,ud)=>{"use strict";var $0=F("events"),ys=F("http"),{Duplex:CE}=F("stream"),{createHash:k0}=F("crypto"),od=ds(),xt=fr(),P0=Wi(),T0=ms(),{CLOSE_TIMEOUT:R0,GUID:x0,kWebSocket:O0}=Ue(),N0=/^[+/0-9A-Za-z]{22}==$/,id=0,ad=1,ld=2,Vi=class extends $0{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:R0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:T0,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=ys.createServer((n,s)=>{let o=ys.STATUS_CODES[426];s.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),s.end(o)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=A0(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,o,i)=>{this.handleUpgrade(s,o,i,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=id}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===ld){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(cn,this);return}if(e&&this.once("close",e),this._state!==ad)if(this._state=ad,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(cn,this):process.nextTick(cn,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{cn(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,n,s){r.on("error",cd);let o=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Ot(this,e,r,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){Ot(this,e,r,400,"Invalid Upgrade header");return}if(o===void 0||!N0.test(o)){Ot(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){Ot(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ln(r,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=P0.parse(c)}catch{Ot(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],d={};if(this.options.perMessageDeflate&&u!==void 0){let f=new xt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let p=od.parse(u);p[xt.extensionName]&&(f.accept(p[xt.extensionName]),d[xt.extensionName]=f)}catch{Ot(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(f,(p,h,m,y)=>{if(!p)return ln(r,h||401,m,y);this.completeUpgrade(d,o,l,e,r,n,s)});return}if(!this.options.verifyClient(f))return ln(r,401)}this.completeUpgrade(d,o,l,e,r,n,s)}completeUpgrade(e,r,n,s,o,i,a){if(!o.readable||!o.writable)return o.destroy();if(o[O0])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>id)return ln(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${k0("sha1").update(r+x0).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let d=this.options.handleProtocols?this.options.handleProtocols(n,s):n.values().next().value;d&&(l.push(`Sec-WebSocket-Protocol: ${d}`),u._protocol=d)}if(e[xt.extensionName]){let d=e[xt.extensionName].params,f=od.format({[xt.extensionName]:[d]});l.push(`Sec-WebSocket-Extensions: ${f}`),u._extensions=e}this.emit("headers",l,s),o.write(l.concat(`\r
10
+ `).join(`\r
11
+ `)),o.removeListener("error",cd),u.setSocket(o,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(cn,this)})),a(u,s)}};ud.exports=Vi;function A0(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function cn(t){t._state=ld,t.emit("close")}function cd(){this.destroy()}function ln(t,e,r,n){r=r||ys.STATUS_CODES[e],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${ys.STATUS_CODES[e]}\r
12
+ `+Object.keys(n).map(s=>`${s}: ${n[s]}`).join(`\r
13
+ `)+`\r
14
+ \r
15
+ `+r)}function Ot(t,e,r,n,s,o){if(t.listenerCount("wsClientError")){let i=new Error(s);Error.captureStackTrace(i,Ot),t.emit("wsClientError",i,r,e)}else ln(r,n,s,o)}});import wr from"node:fs";import qt from"node:path";import{fileURLToPath as Gd}from"node:url";var oa=["./schemas","../../../protocol/schema","../../protocol/schema"],pn=null;function Ft(t=Yd()){if(pn)return pn;for(let e of oa){let r=qt.resolve(t,e);if(ia(r)&&ia(qt.join(r,"messages")))return pn=r,pn}throw new Error(`@aifight/aifight: cannot locate protocol/schema tree. Searched relative to ${t}: ${oa.join(", ")}. Run build.sh to populate dist/schemas/ before packaging.`)}function Yd(){return qt.dirname(Gd(import.meta.url))}function ia(t){try{return wr.statSync(t).isDirectory()}catch{return!1}}var ws={welcome:"messages/server_welcome.schema.json",queue_joined:"messages/server_queue_joined.schema.json",queue_left:"messages/server_queue_left.schema.json",match_confirm_request:"messages/server_match_confirm_request.schema.json",match_cancelled:"messages/server_match_cancelled.schema.json",game_start:"messages/server_game_start.schema.json",readiness_check:"messages/server_readiness_check.schema.json",action_request:"messages/server_action_request.schema.json",event:"messages/server_event.schema.json",game_state:"messages/server_game_state.schema.json",game_over:"messages/server_game_over.schema.json",error:"messages/server_error.schema.json",join_queue:"messages/client_join_queue.schema.json",leave_queue:"messages/client_leave_queue.schema.json",match_confirm:"messages/client_match_confirm.schema.json",action:"messages/client_action.schema.json",runtime_status:"messages/client_runtime_status.schema.json"};function Es(){return Object.keys(ws)}function Jd(t){let e=ws[t];if(!e)throw new Error(`@aifight/aifight: unknown message type '${t}'. Known: ${Object.keys(ws).join(", ")}`);let r=Ft(),n=qt.join(r,e),s=wr.readFileSync(n,"utf8");return JSON.parse(s)}function ft(){let t=Ft(),e=new Map;return ca(t,r=>{if(!r.endsWith(".schema.json"))return;let n=wr.readFileSync(r,"utf8"),s=JSON.parse(n);typeof s.$id=="string"&&s.$id!==""&&e.set(s.$id,s)}),e}function ca(t,e){for(let r of wr.readdirSync(t,{withFileTypes:!0})){let n=qt.join(t,r.name);r.isDirectory()?ca(n,e):r.isFile()&&e(n)}}var aa={register_request:"rest/register_request.schema.json",register_response:"rest/register_response.schema.json",error_response:"rest/error_response.schema.json"};function Ss(t){let e=aa[t];if(!e)throw new Error(`@aifight/aifight: unknown REST schema '${t}'. Known: ${Object.keys(aa).join(", ")}`);let r=Ft(),n=qt.join(r,e),s=wr.readFileSync(n,"utf8");return JSON.parse(s)}var Kl=oe(Yn(),1),Gl=oe(yi(),1);var sr=class extends Error{},St=class extends sr{kind="network";cause;constructor(e,r){super(e),this.name="RegisterNetworkError",this.cause=r}},Xr=class extends sr{kind="http";status;body;constructor(e,r,n){super(n),this.name="RegisterHttpError",this.status=e,this.body=r}},$t=class extends sr{kind="schema";ajvErrors;constructor(e,r){super(r),this.name="RegisterSchemaError",this.ajvErrors=e}},or=class extends Error{},ir=class extends or{kind="keychain-unavailable";cause;constructor(e,r){super(e),this.name="CredentialsKeychainUnavailableError",this.cause=r}},ue=class extends or{kind="crypto";op;cause;constructor(e,r,n){super(r),this.name="CredentialsCryptoError",this.op=e,this.cause=n}},Ae=class extends or{kind="corrupt";constructor(e){super(e),this.name="CredentialsCorruptError"}};var Ug=3e4,kt="/api/agents/register",Wg="https://aifight.ai/protocol/v1/rest/register_response.schema.json",ar=null;function Vg(){if(ar)return ar;let t=new Kl.default({strict:!1,allErrors:!0});(0,Gl.default)(t);let e=ft();for(let[s,o]of e)t.getSchema(s)||t.addSchema(o,s);let r=t.getSchema(Wg);if(r)return ar=r,ar;let n=Ss("register_response");return ar=t.compile(n),ar}async function Hg(t){let e=t.fetchImpl??globalThis.fetch,r=t.timeoutMs??Ug,n=t.baseUrl.replace(/\/+$/,"")+kt,s=AbortSignal.timeout(r),o=t.signal?AbortSignal.any([s,t.signal]):s,i;try{i=await e(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.request),signal:o})}catch(p){if(s.aborted)throw new St(`POST ${kt} timed out after ${r}ms`,p);if(t.signal?.aborted)throw new St(`POST ${kt} aborted by caller`,p);let h=p instanceof Error?p.message:String(p);throw new St(`POST ${kt} failed: ${h}`,p)}let a=await i.text(),c,l=null;if(a.length>0)try{c=JSON.parse(a)}catch(p){l=p instanceof Error?p:new Error(String(p))}if(i.status!==201){let p=c&&typeof c=="object"&&c!==null&&"error"in c?c:a;throw new Xr(i.status,p,`POST ${kt} returned HTTP ${i.status}`)}if(l!==null)throw new $t([],`POST ${kt} returned 201 with non-JSON body: ${l.message}`);if(typeof c!="object"||c===null)throw new $t([],`POST ${kt} returned 201 with non-object body`);let u=Vg();if(!u(c)){let p=(u.errors??[]).map(h=>({instancePath:h.instancePath,message:h.message??void 0}));throw new $t(p,"register_response schema validation failed")}let f=c;return{response:f,apiKey:f.agent.api_key,claimToken:f.claim_token,agentId:f.agent.id,claimUrl:f.claim_url}}import Gg from"better-sqlite3";var Yl=`-- runtime/src/store/schema.sql
16
+ -- AUTO-APPLIED by src/store/sqlite.ts as the v1 migration step.
17
+ -- DO NOT edit this file by hand \u2014 this is v1's BYTE SOURCE (bundled
18
+ -- into SCHEMA_SQL_V1 by bundle-schema.mjs). M1-05 appended a v2
19
+ -- migration step inside sqlite.ts that re-creates the agents table
20
+ -- with BLOB columns for encrypted api_key / claim_token. Current DB
21
+ -- state after full migration: see sqlite.ts's "Current schema (v2)"
22
+ -- header comment.
23
+ --
24
+ -- Tracked via \`PRAGMA user_version\`. This file defines user_version = 1;
25
+ -- sqlite.ts's MIGRATIONS array brings it to 2.
26
+ --
27
+ -- OUT-OF-SCOPE for this file (DO NOT add here):
28
+ -- * notifications \u2014 v1.1.1 durable event stream (M2 when broker lands)
29
+ -- * match_history \u2014 M1-15 / M1-21
30
+ -- * schedules \u2014 M1-15
31
+ -- * encrypted column DDL \u2014 lives in sqlite.ts's v2 migration step,
32
+ -- NOT here (mutating this file would break SCHEMA_SQL_V1's byte
33
+ -- identity and thus the v1 migration contract).
34
+ --
35
+ -- When adding a new migration in a later TED, APPEND a new migration
36
+ -- step to sqlite.ts's MIGRATIONS array; DO NOT mutate this file's v1
37
+ -- block. Past installs will keep their v1 body and only run the delta.
38
+
39
+ CREATE TABLE IF NOT EXISTS agents (
40
+ id TEXT NOT NULL PRIMARY KEY, -- UUID v4 from server
41
+ name TEXT NOT NULL UNIQUE, -- Public agent name
42
+ api_key TEXT NOT NULL, -- v1 plaintext; v2 migration re-creates as BLOB
43
+ claim_token TEXT NOT NULL, -- v1 plaintext; v2 migration re-creates as BLOB
44
+ model TEXT NOT NULL DEFAULT '',
45
+ created_at INTEGER NOT NULL, -- unix ms
46
+ updated_at INTEGER NOT NULL -- unix ms
47
+ );
48
+
49
+ CREATE INDEX IF NOT EXISTS idx_agents_name ON agents(name);
50
+ `;var rt=class extends Error{},cr=class extends rt{kind="open";path;cause;constructor(e,r,n){super(n),this.name="StoreOpenError",this.path=e,this.cause=r}},lr=class extends rt{kind="migration";fromVersion;toVersion;cause;constructor(e,r,n,s){super(s),this.name="StoreMigrationError",this.fromVersion=e,this.toVersion=r,this.cause=n}},nt=class extends rt{kind="query";sql;cause;constructor(e,r,n){super(n),this.name="StoreQueryError",this.sql=e,this.cause=r}};import Jl from"node:fs";import zg from"node:os";import gi from"node:path";var Kg=gi.join(".aifight","runtime");function Qr(){let t=process.env.AIFIGHT_RUNTIME_HOME;return t&&t.length>0?t:gi.join(zg.homedir(),Kg)}function _i(){return gi.join(Qr(),"state.db")}function Zr(){let t=Qr();if(Jl.mkdirSync(t,{recursive:!0}),process.platform!=="win32")try{Jl.chmodSync(t,448)}catch{}}var vi=[{version:1,up:t=>{t.exec(Yl)}},{version:2,up:t=>{let e=t.prepare("SELECT COUNT(*) AS n FROM agents").get().n;if(e>0)throw new Error(`M1-05 migration refuses to upgrade a populated agents table (${e} rows). These rows were written in schema v1 with TEXT plaintext columns and cannot be silently reinterpreted as encrypted BLOBs. Remediation: back up the DB file, then DELETE FROM agents, then re-open to trigger migration. For a real re-encrypt migration, open a new TED.`);t.exec(`
51
+ CREATE TABLE agents_new (
52
+ id TEXT NOT NULL PRIMARY KEY,
53
+ name TEXT NOT NULL UNIQUE,
54
+ api_key BLOB NOT NULL,
55
+ claim_token BLOB NOT NULL,
56
+ model TEXT NOT NULL DEFAULT '',
57
+ created_at INTEGER NOT NULL,
58
+ updated_at INTEGER NOT NULL
59
+ );
60
+ INSERT INTO agents_new SELECT * FROM agents;
61
+ DROP TABLE agents;
62
+ ALTER TABLE agents_new RENAME TO agents;
63
+ DROP INDEX IF EXISTS idx_agents_name;
64
+ CREATE INDEX idx_agents_name ON agents(name);
65
+ `)}}],Yg=vi[vi.length-1].version;function Xl(t){return t.pragma("user_version",{simple:!0})}function Jg(t,e){let r=Xl(t);if(r>e)throw new lr(r,e,void 0,`DB user_version ${r} is newer than runtime target ${e}; downgrade not supported`);for(let n of vi)if(n.version>r&&n.version<=e)try{t.transaction(()=>{n.up(t),t.pragma(`user_version = ${n.version}`)})()}catch(s){throw new lr(r,n.version,s,`migration v${r} \u2192 v${n.version} failed: ${s instanceof Error?s.message:String(s)}`)}return Xl(t)}function Xg(t={}){let e=t.targetVersion??Yg,r=t.path??_i();!(r===":memory:")&&!t.skipEnsureHome&&t.path===void 0&&Zr();let s;try{s=new Gg(r)}catch(d){throw new cr(r,d,`failed to open SQLite at ${r}: ${d instanceof Error?d.message:String(d)}`)}let o,i,a,c,l;try{s.pragma("journal_mode = WAL"),s.pragma("foreign_keys = ON"),s.pragma("busy_timeout = 5000"),s.pragma("synchronous = NORMAL"),o=Jg(s,e),i=s.prepare(`SELECT id, name, api_key, claim_token, model, created_at, updated_at
66
+ FROM agents WHERE name = ?`),a=s.prepare(`SELECT id, name, api_key, claim_token, model, created_at, updated_at
67
+ FROM agents ORDER BY name ASC`),c=s.prepare("DELETE FROM agents WHERE name = ?"),l=s.prepare(`INSERT INTO agents (id, name, api_key, claim_token, model, created_at, updated_at)
68
+ VALUES (@id, @name, @api_key, @claim_token, @model, @created_at, @updated_at)
69
+ ON CONFLICT(name) DO UPDATE SET
70
+ api_key = excluded.api_key,
71
+ claim_token = excluded.claim_token,
72
+ model = excluded.model,
73
+ updated_at = excluded.updated_at
74
+ RETURNING id, name, api_key, claim_token, model, created_at, updated_at`)}catch(d){throw s.open&&s.close(),d instanceof rt?d:new cr(r,d,`failed to initialize DB at ${r}: ${d instanceof Error?d.message:String(d)}`)}return{path:r,schemaVersion:o,close(){s.open&&s.close()},getAgentByName(d){try{return i.get(d)}catch(f){throw new nt("SELECT agents WHERE name = ?",f,`getAgentByName('${d}') failed: ${f instanceof Error?f.message:String(f)}`)}},upsertAgent(d){let f=Date.now(),p={id:d.id,name:d.name,api_key:d.api_key,claim_token:d.claim_token,model:d.model,created_at:d.created_at??f,updated_at:d.updated_at??f};try{let h=l.get(p);if(h===void 0)throw new Error("RETURNING yielded no row \u2014 should be impossible");return h}catch(h){throw new nt("INSERT agents ON CONFLICT(name) ...",h,`upsertAgent(name='${d.name}') failed: ${h instanceof Error?h.message:String(h)}`)}},listAgents(){try{return a.all()}catch(d){throw new nt("SELECT agents ORDER BY name",d,`listAgents() failed: ${d instanceof Error?d.message:String(d)}`)}},deleteAgent(d){try{return c.run(d).changes>0}catch(f){throw new nt("DELETE agents WHERE name = ?",f,`deleteAgent('${d}') failed: ${f instanceof Error?f.message:String(f)}`)}},raw(){return s}}}import{Entry as ts}from"@napi-rs/keyring";import{createCipheriv as Qg,createDecipheriv as Zg,randomBytes as Si,randomUUID as tu,scryptSync as ru}from"node:crypto";import{chmodSync as Ql,existsSync as e_,readFileSync as t_,writeFileSync as r_}from"node:fs";import{join as n_}from"node:path";var en="AIFIGHT_KEYCHAIN_V1:",tn="AIFIGHT_CRYPTO_V1:",nu="aifight-runtime",s_="master.key",bi=32,Xn=16,Qn=12,wi=16,o_=36,su=32,Zl=Buffer.byteLength(en,"ascii"),eu=Buffer.byteLength(tn,"ascii"),Zn=null,Ei=null;function rs(){let t=process.env.AIFIGHT_KEYCHAIN_SERVICE;return t&&t.length>0?t:nu}function i_(){let t=new ts(rs(),"probe-"+tu()),e=!1;try{return t.setPassword("probe"),e=!0,{ok:!0}}catch(r){return{ok:!1,message:r instanceof Error?r.message:String(r)}}finally{if(e)try{t.deletePassword()}catch{}}}function ou(){if(process.env.AIFIGHT_FORCE_FALLBACK==="1")return{backend:"fallback-crypto",keychainProbeMessage:"AIFIGHT_FORCE_FALLBACK=1"};if(Zn===null){let t=i_();Zn=t.ok?{backend:"keychain"}:{backend:"fallback-crypto",keychainProbeMessage:t.message}}return Zn}function iu(){return ou().backend==="keychain"}function a_(){return n_(Qr(),s_)}function au(){if(Ei!==null)return Ei;try{Zr()}catch(r){throw new ue("kdf",`failed to create runtime home for master key: ${r instanceof Error?r.message:String(r)}`,r)}let t=a_(),e;if(e_(t)){try{e=t_(t)}catch(r){throw new ue("kdf",`failed to read master key at ${t}: ${r instanceof Error?r.message:String(r)}`,r)}if(e.length!==bi)throw new ue("kdf",`master key at ${t} is ${e.length} bytes, expected ${bi}`);if(process.platform!=="win32")try{Ql(t,384)}catch(r){throw new ue("kdf",`failed to enforce 0600 permissions on existing master key at ${t}: ${r instanceof Error?r.message:String(r)}`,r)}}else{e=Si(bi);try{r_(t,e,{mode:384}),process.platform!=="win32"&&Ql(t,384)}catch(r){throw new ue("kdf",`failed to persist master key at ${t}: ${r instanceof Error?r.message:String(r)}`,r)}}return Ei=e,e}function c_(t){let e=au(),r=Si(Xn),n=Si(Qn),s;try{s=ru(e,r,su)}catch(a){throw new ue("kdf",`scrypt key derivation failed: ${a instanceof Error?a.message:String(a)}`,a)}let o,i;try{let a=Qg("aes-256-gcm",s,n);o=Buffer.concat([a.update(t,"utf8"),a.final()]),i=a.getAuthTag()}catch(a){throw new ue("encrypt",`AES-256-GCM encrypt failed: ${a instanceof Error?a.message:String(a)}`,a)}return Buffer.concat([Buffer.from(tn,"ascii"),r,n,i,o])}function l_(t){if(iu()){let e=tu();try{return new ts(rs(),e).setPassword(t),Buffer.concat([Buffer.from(en,"ascii"),Buffer.from(e,"ascii")])}catch(r){Zn={backend:"fallback-crypto",keychainProbeMessage:`runtime keychain write failed: ${r instanceof Error?r.message:String(r)}`}}}return c_(t)}function es(t,e){let r=Buffer.byteLength(e,"ascii");return t.length<r?!1:t.subarray(0,r).toString("ascii")===e}function cu(t){let e=Zl+o_;if(t.length!==e)throw new Ae(`keychain BLOB wrong length: expected ${e} bytes, got ${t.length}`);return t.subarray(Zl,e).toString("ascii")}function u_(t){let e=cu(t),r;try{r=new ts(rs(),e).getPassword()}catch(n){throw new ir(`keychain unavailable while reading entry for ${e}: ${n instanceof Error?n.message:String(n)}`,n)}if(r==null)throw new Ae(`keychain entry missing (uuid=${e}); BLOB row exists but keychain has no matching row`);return r}function d_(t){let e=eu+Xn+Qn+wi;if(t.length<e)throw new Ae(`fallback BLOB too short: expected at least ${e} bytes, got ${t.length}`);let r=eu,n=t.subarray(r,r+Xn);r+=Xn;let s=t.subarray(r,r+Qn);r+=Qn;let o=t.subarray(r,r+wi);r+=wi;let i=t.subarray(r),a=au(),c;try{c=ru(a,n,su)}catch(l){throw new ue("kdf",`scrypt key derivation failed during decrypt: ${l instanceof Error?l.message:String(l)}`,l)}try{let l=Zg("aes-256-gcm",c,s);return l.setAuthTag(o),Buffer.concat([l.update(i),l.final()]).toString("utf8")}catch(l){throw new Ae(`AES-GCM auth tag mismatch (fallback BLOB tampered or wrong master key): ${l instanceof Error?l.message:String(l)}`)}}function f_(t){if(es(t,en))return u_(t);if(es(t,tn))return d_(t);throw new Ae("unknown format version (blob does not start with a known AIFIGHT_* prefix)")}function h_(t){if(es(t,en)){let e=cu(t);try{new ts(rs(),e).deletePassword()}catch(r){throw new ir(`keychain unavailable while deleting entry for ${e}: ${r instanceof Error?r.message:String(r)}`,r)}return}if(!es(t,tn))throw new Ae("unknown format version in deleteFromStorage")}var C0=oe(nd(),1),I0=oe(ds(),1),M0=oe(fr(),1),L0=oe(Ii(),1),D0=oe(Di(),1),j0=oe(Wi(),1),Hi=oe(ms(),1),q0=oe(dd(),1);var Y=class extends Error{},it=class extends Y{kind="connect";cause;constructor(e,r){super(e),this.name="WSConnectError",this.cause=r}},at=class extends Y{kind="handshake";statusCode;responseBody;cause;constructor(e,r,n,s){super(n),this.name="WSHandshakeError",this.statusCode=e,this.responseBody=r,this.cause=s}},Nt=class extends Y{kind="welcome-timeout";constructor(e){super(e),this.name="WSWelcomeTimeoutError"}},ct=class extends Y{kind="welcome-invalid";ajvErrors;constructor(e,r){super(r),this.name="WSWelcomeInvalidError",this.ajvErrors=e}},At=class extends Y{kind="protocol-version";clientVersion;serverVersion;constructor(e,r,n){super(n),this.name="WSProtocolVersionError",this.clientVersion=e,this.serverVersion=r}},Ct=class extends Y{kind="closed";constructor(e){super(e),this.name="WSClosedError"}},se=class extends Y{kind="schema";messageType;ajvErrors;constructor(e,r,n){super(n),this.name="WSSchemaError",this.messageType=e,this.ajvErrors=r}},Ie=class extends Y{kind="outbound-schema";messageType;ajvErrors;constructor(e,r,n){super(n),this.name="WSOutboundSchemaError",this.messageType=e,this.ajvErrors=r}},ze=class extends Y{kind="unknown-message";messageType;constructor(e,r){super(r),this.name="WSUnknownMessageError",this.messageType=e}},Ke=class extends Y{kind="aborted";cause;constructor(e,r){super(e),this.name="WSAbortedError",this.cause=r}};var fd=oe(Yn(),1),hd=oe(yi(),1);var Ki=new Set(["join_queue","leave_queue","match_confirm","action","runtime_status"]),Gi=new Set(["welcome","queue_joined","queue_left","match_confirm_request","match_cancelled","game_start","readiness_check","action_request","event","game_state","game_over","error"]),pd="https://aifight.ai/protocol/v1/messages/";function F0(t){return`${pd}client_${t}.schema.json`}function B0(t){return`${pd}server_${t}.schema.json`}var zi=null;function md(){if(zi)return zi;let t=new fd.default({strict:!1,allErrors:!0});(0,hd.default)(t);for(let[e,r]of ft())t.getSchema(e)||t.addSchema(r,e);return zi=t,t}function yd(t){return(t.errors??[]).map(r=>({instancePath:r.instancePath,message:r.message??void 0}))}function gd(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function _d(t){if(!gd(t))throw new Ie("<unknown>",[],"serializeClientMessage: envelope must be a plain object");let e=t.type;if(typeof e!="string"||e.length===0)throw new Ie("<unknown>",[],"serializeClientMessage: envelope is missing a string `type` field");if(Gi.has(e))throw new Ie(e,[],`serializeClientMessage: '${e}' is a server-only message type and cannot be sent by the client`);if(!Ki.has(e))throw new Ie(e,[],`serializeClientMessage: unknown client message type '${e}' (known: ${[...Ki].join(", ")})`);let r=md(),n=F0(e),s=r.getSchema(n);if(!s)throw new Ie(e,[],`serializeClientMessage: schema not registered for $id ${n} (packaging bug \u2014 loadAllSchemas did not include this file)`);if(!s(t))throw new Ie(e,yd(s),`serializeClientMessage: '${e}' envelope failed schema validation`);return JSON.stringify(t)}function Yi(t){let e=typeof t=="string"?t:t.toString("utf8"),r;try{r=JSON.parse(e)}catch(c){let l=c instanceof Error?c.message:String(c);throw new se("<unknown>",[],`parseServerFrame: malformed JSON: ${l}`)}if(!gd(r))throw new se("<unknown>",[],"parseServerFrame: frame must be a JSON object");let n=r.type;if(typeof n!="string"||n.length===0)throw new se("<unknown>",[],"parseServerFrame: frame is missing a string `type` field");if(!Gi.has(n))throw Ki.has(n)?new ze(n,`parseServerFrame: '${n}' is a client-only message type and was not expected on the inbound channel`):new ze(n,`parseServerFrame: unknown server message type '${n}' (known: ${[...Gi].join(", ")})`);let s=md(),o=B0(n),i=s.getSchema(o);if(!i)throw new se(n,[],`parseServerFrame: schema not registered for $id ${o} (packaging bug)`);if(!i(r))throw new se(n,yd(i),`parseServerFrame: '${n}' frame failed schema validation`);return r}var U0=1e4,W0=25e3;function vd(t){if(t===void 0)return"(no reason)";if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return String(t)}catch{return"(unstringifiable reason)"}}var Ji=class{#e;#t="connected";#n=null;#a=null;#o=null;#c=new Set;#l=new Set;#i=new Set;#p=!1;#u=null;#s=null;#r=null;welcome;constructor(e,r,n){this.#e=e,this.welcome=r,this.#e.on("message",o=>{this.#m(o)}),this.#e.on("error",()=>{}),this.#e.once("close",(o,i)=>{let a=i?.toString("utf8")??"",c=this.#u??"server";this.#y({code:o,reason:a,initiator:c}),this.#t="closed",this.#_(),this.#r&&(this.#r(),this.#r=null)});let s=n.pingIntervalMs??W0;s>0&&(this.#n=setInterval(()=>{try{this.#e.ping()}catch{this.#n&&(clearInterval(this.#n),this.#n=null)}},s)),n.signal&&(this.#a=n.signal,this.#o=()=>{if(this.#t!=="closed"){this.#u="abort",this.#y({code:0,reason:"aborted",initiator:"abort"}),this.#t="closed",this.#_();try{this.#e.terminate()}catch{}}},n.signal.addEventListener("abort",this.#o,{once:!0}))}get state(){return this.#t}onMessage(e){return this.#c.add(e),()=>{this.#c.delete(e)}}onError(e){return this.#l.add(e),()=>{this.#l.delete(e)}}onClose(e){return this.#i.add(e),()=>{this.#i.delete(e)}}#m(e){if(this.#t!=="connected")return;let r=typeof e=="string"||Buffer.isBuffer(e)?e:Buffer.from(e),n;try{n=Yi(r)}catch(s){if(s instanceof se||s instanceof ze)this.#d(s);else{let o=s instanceof Error?s.message:String(s);this.#d(new se("<unknown>",[],`unexpected frame parse error: ${o}`))}return}this.#h(n)}#h(e){let r=[...this.#c];for(let n of r)this.#g(()=>n(e))}#d(e){let r=[...this.#l];for(let n of r)this.#g(()=>n(e))}#y(e){if(this.#p)return;this.#p=!0;let r=[...this.#i];for(let n of r)this.#g(()=>n(e))}#g(e){try{let r=e();r&&typeof r.then=="function"&&r.then(void 0,()=>{})}catch{}}send(e){if(this.#t!=="connected")throw new Ct(`cannot send: client state is "${this.#t}" (expected "connected")`);let r=_d(e);this.#e.send(r)}#_(){this.#n&&(clearInterval(this.#n),this.#n=null),this.#a&&this.#o&&(this.#a.removeEventListener("abort",this.#o),this.#a=null,this.#o=null)}async close(e=1e3,r=""){if(this.#t!=="closed"){if(this.#t==="closing"){this.#s&&await this.#s;return}this.#u="client",this.#t="closing",this.#_(),this.#s=new Promise(n=>{this.#r=n});try{this.#e.close(e,r)}catch{this.#y({code:e,reason:r,initiator:"client"}),this.#t="closed",this.#r&&(this.#r(),this.#r=null)}await this.#s}}};async function Xi(t){let e=t.welcomeTimeoutMs??U0;return t.signal?.aborted?Promise.reject(new Ke(`createWSClient aborted before start: ${vd(t.signal.reason)}`,t.signal.reason)):new Promise((r,n)=>{let s;try{s=new Hi.default(t.url,{headers:{"X-API-Key":t.apiKey}})}catch(u){let d=u instanceof Error?u.message:String(u);n(new it(`failed to construct WebSocket for ${t.url}: ${d}`,u));return}let o=!1,i=null,a=null,c=()=>{i&&(clearTimeout(i),i=null),t.signal&&a&&(t.signal.removeEventListener("abort",a),a=null),s.removeAllListeners(),s.on("error",()=>{})},l=u=>{o||(o=!0,c(),u())};t.signal&&(a=()=>{l(()=>{try{s.terminate()}catch{}n(new Ke(`createWSClient aborted during handshake: ${vd(t.signal.reason)}`,t.signal.reason))})},t.signal.addEventListener("abort",a,{once:!0})),s.once("error",u=>{l(()=>{try{s.terminate()}catch{}n(new it(`WebSocket connect failed for ${t.url}: ${u.message}`,u))})}),s.once("unexpected-response",(u,d)=>{let f="";d.setEncoding("utf8"),d.on("data",p=>{f+=p}),d.on("end",()=>{let p=d.statusCode??0,h=d.statusMessage??"";try{u.destroy()}catch{}l(()=>n(new at(p,f,`HTTP upgrade rejected: ${p} ${h}`.trim())))}),d.on("error",p=>{let h=d.statusCode??0;l(()=>n(new at(h,f,`HTTP upgrade response read failed: ${p.message}`,p)))})}),s.once("open",()=>{i=setTimeout(()=>{l(()=>{try{s.terminate()}catch{}n(new Nt(`welcome did not arrive within ${e}ms after WebSocket open`))})},e)}),s.once("message",u=>{let d=typeof u=="string"||Buffer.isBuffer(u)?u:Buffer.from(u),f;try{f=Yi(d)}catch(b){let E=[],S="first frame failed to parse";b instanceof se?(E=b.ajvErrors,S=b.messageType==="welcome"?`welcome failed schema validation: ${b.message}`:`first frame parse failure (${b.messageType}): ${b.message}`):b instanceof ze?S=`first frame had unknown server message type '${b.messageType}': ${b.message}`:b instanceof Error&&(S=`first frame parse error: ${b.message}`),l(()=>{try{s.terminate()}catch{}n(new ct(E,S))});return}if(f.type!=="welcome"){l(()=>{try{s.terminate()}catch{}n(new ct([],`expected first frame to be 'welcome', got '${f.type}'`))});return}let p=f,h=p.data.server_protocol_version,m=b=>b.startsWith("v")?b.slice(1):b,y=m(t.expectedProtocolVersion).split(".")[0],g=m(h).split(".")[0];if(y!==g){l(()=>{try{s.terminate()}catch{}n(new At(t.expectedProtocolVersion,h,`protocol major version mismatch: client expected '${t.expectedProtocolVersion}', server is '${h}'`))});return}l(()=>{let b=new Ji(s,p,{pingIntervalMs:t.pingIntervalMs,signal:t.signal});r(b)})})})}var _r=class extends Error{name="ReconnectStoppedError";kind;cause;constructor(e,r,n){super(n),this.kind=e,this.cause=r}},V0=1e3,H0=2,z0=3e4,K0="full",G0=5*60*1e3,Y0=15*60*1e3,J0=new Set([1001,1006,1011,1012]);function X0(t,e,r,n){let s=e*Math.pow(r,Math.max(0,t-1));return Math.min(s,n)}function Q0(t,e){switch(e){case"none":return t;case"full":return Math.floor(Math.random()*t);case"equal":return Math.floor(t/2+Math.random()*t/2)}}function Z0(t){return t.code>=4e3&&t.code<5e3?!1:J0.has(t.code)}function ev(t){if(t instanceof Ke||t instanceof ct||t instanceof At)return!1;if(t instanceof it||t instanceof Nt)return!0;if(t instanceof at){let e=t.statusCode;return e===401||e===403||e===404?!1:e===408||e===429||e>=500&&e<600}return!1}function tv(t){return t>=Y0?"error":t>=G0?"warning":"info"}var Qi=class{state="connecting";attempt=0;welcome=null;#e;#t=null;#n=new Set;#a=new Set;#o=new Set;#c=new Set;#l=0;#i=0;#p=null;#u=null;#s=!1;#r=null;#m=!1;#h=null;#d=[];constructor(e){this.#e=e}send(e){if(this.state!=="connected"||this.#t===null)throw new Ct(`cannot send while ReconnectingWSClient.state="${this.state}"`);this.#t.send(e)}onMessage(e){this.#n.add(e);let r=null;return this.#t!==null&&this.state==="connected"&&(r=this.#t.onMessage(e)),()=>{this.#n.delete(e),r&&r()}}onError(e){this.#a.add(e);let r=null;return this.#t!==null&&this.state==="connected"&&(r=this.#t.onError(e)),()=>{this.#a.delete(e),r&&r()}}onClose(e){return this.#o.add(e),()=>{this.#o.delete(e)}}onReconnect(e){return this.#c.add(e),()=>{this.#c.delete(e)}}async close(e,r){this.state!=="closed"&&(this.#r={code:e,reason:r},this.#h&&this.#h("close"),this.#t!==null?await this.#t.close(e,r).catch(()=>{}):this.#m||this.#f({kind:"caller-close",code:e??1e3,closeReason:r,cause:void 0}))}begin(e,r){this.#p=e,this.#u=r,this.#y()}async#y(){if(this.#l=Date.now(),this.#e.signal?.aborted){this.#w("signal",void 0,"ReconnectingWSClient pre-aborted by signal");return}for(;this.state!=="closed";){this.attempt++,this.state="connecting",this.#v("attempt-start",this.attempt);let e,r=!1;try{let a=await Xi({url:this.#e.url,apiKey:this.#e.apiKey,expectedProtocolVersion:this.#e.expectedProtocolVersion,welcomeTimeoutMs:this.#e.welcomeTimeoutMs,pingIntervalMs:this.#e.pingIntervalMs,signal:this.#e.signal});r=!0,this.#t=a,this.welcome=a.welcome,this.#E(a),this.state="connected";let c=this.attempt;this.attempt=0,this.#i=0,this.#v("attempt-success",c),this.#s||(this.#s=!0,this.#p?.());let l=await this.#_(a);if(this.#b(),this.#t=null,this.#r){this.#f({kind:"caller-close",code:this.#r.code??l.code,closeReason:this.#r.reason??l.reason,cause:void 0});return}if(this.#e.signal?.aborted){this.#f({kind:"signal",cause:void 0});return}if(!Z0(l)){let u=new _r("fatal-close",void 0,`close code ${l.code} not in retry whitelist`);this.#f({kind:"fatal-close",code:l.code,closeReason:l.reason,cause:u});return}this.#i=1,this.state="backoff",this.#l=Date.now()}catch(a){if(r)throw a;if(a instanceof Y&&(e=a),!ev(a)){let c=a instanceof Y?a:void 0,l=a instanceof Ke?"signal":"fatal-error",u=a instanceof Error?a.message:"non-retriable error";this.#w(l,c,u);return}this.#i++,this.state="backoff"}let n=X0(this.#i,this.#e.initialBackoffMs??V0,this.#e.backoffFactor??H0,this.#e.maxBackoffMs??z0),s=Q0(n,this.#e.jitter??K0),o=this.attempt===0?1:this.attempt;if(this.#v("attempt-failure",o,s,e),this.#e.maxAttempts!==void 0&&this.#i>=this.#e.maxAttempts){this.#w("max-attempts",e,`exhausted maxAttempts=${this.#e.maxAttempts}`);return}let i=await this.#g(s);if(i==="abort"){this.#f({kind:"signal",cause:void 0}),this.#s||(this.#s=!0,this.#u?.(new _r("signal",void 0,"ReconnectingWSClient aborted during backoff")));return}if(i==="close"){this.#f({kind:"caller-close",code:this.#r?.code??1e3,closeReason:this.#r?.reason,cause:void 0});return}}}#g(e){return new Promise(r=>{let n=!1,s=c=>{n||(n=!0,clearTimeout(o),i&&a&&i.removeEventListener("abort",a),this.#h=null,r(c))},o=setTimeout(()=>s("timeout"),e),i=this.#e.signal,a=null;if(i){if(i.aborted){s("abort");return}a=()=>s("abort"),i.addEventListener("abort",a)}this.#h=c=>s(c)})}#_(e){return new Promise(r=>{let n=e.onClose(s=>{try{n()}catch{}r(s)})})}#E(e){this.#b();for(let r of this.#n)this.#d.push(e.onMessage(r));for(let r of this.#a)this.#d.push(e.onError(r))}#b(){for(let e of this.#d)try{e()}catch{}this.#d.length=0}#v(e,r,n,s){let o=Date.now()-this.#l,i=e==="give-up"?"error":e==="attempt-failure"?tv(o):"info",a={type:e,attempt:r,nextDelayMs:n,cause:s,elapsedMs:o,severity:i},c=[...this.#c];for(let l of c)try{l(a)}catch{}}#w(e,r,n){let s=new _r(e,r,n);this.#f({kind:e,cause:e==="fatal-error"||e==="max-attempts"?s:void 0}),this.#s||(this.#s=!0,this.#u?.(s))}#f(e){if(this.#m)return;this.#m=!0,this.state="closed",this.#b(),this.#t=null,this.#v("give-up",this.attempt,void 0,e.cause);let r=[...this.#o];for(let n of r)try{n(e)}catch{}}};async function rv(t){let e=new Qi(t);return await new Promise((r,n)=>{e.begin(r,n)}),e}var nv=["check","call","fold","raise","allin"];function bd(t){let{legalActions:e}=t;if(e.length===0)throw new Error("Texas Hold'em fallback requires at least one legal action");for(let r of nv){let n=e.find(s=>s.type===r);if(n)return n}return e[0]}function wd(t){let{publicState:e,legalActions:r}=t;if(r.length===0)throw new Error("Liar's Dice fallback requires at least one legal action");let n=r.find(o=>o.type==="bid"),s=r.find(o=>o.type==="challenge");if(n){let o=sv(n.data);if(o)return o.maxQuantity!==void 0&&o.minQuantity>o.maxQuantity?s??r[0]:{type:"bid",data:{quantity:o.minQuantity,face:o.minFace}};let i=ov(e);if(i)return typeof e.total_dice=="number"&&i.quantity>e.total_dice?s??r[0]:{type:"bid",data:i}}return s||r[0]}function sv(t){let e=iv(t);if(!e)return;let r=Zi(e,"min_quantity"),n=Zi(e,"min_face");if(!(r===void 0||n===void 0))return{minQuantity:r,minFace:n,maxQuantity:Zi(e,"max_quantity")}}function ov(t){let e=t.current_bid;if(!e)return typeof t.total_dice!="number"?void 0:{quantity:1,face:1};if(!(typeof e.quantity!="number"||typeof e.face!="number"))return e.face<6?{quantity:e.quantity,face:e.face+1}:{quantity:e.quantity+1,face:1}}function iv(t){return t!==null&&typeof t=="object"?t:void 0}function Zi(t,e){let r=t[e];return typeof r=="number"?r:void 0}var av=["income","foreign_aid","coup","tax","steal","assassinate","exchange"],cv=["pass","challenge"],lv=["pass","block"],uv=["lose_card"],dv=["return_cards"];function Ed(t){let{publicState:e,legalActions:r}=t;if(r.length===0)throw new Error("Coup fallback requires at least one legal action");switch(e.phase){case"action":return un(r,av);case"challenge_action":case"challenge_block":return un(r,cv);case"block":return un(r,lv);case"lose_influence":return un(r,uv);case"exchange_return":return un(r,dv);case"done":throw new Error("Coup fallback should not run when phase is done");default:return r[0]}}function un(t,e){for(let r of e){let n=t.find(s=>s.type===r);if(n)return n}return t[0]}var fv=/^```(?:json)?\s*\n?([\s\S]*?)\n?```\s*$/;function Sd(t,e,r=500){let n=t.trim(),s=mv(n),o;try{o=JSON.parse(s)}catch{return It("json_parse",n,r)}if(!gs(o))return It("missing_fields",n,r);let i=o.action;if(typeof i!="string")return It("missing_fields",n,r);let a=typeof o.summary=="string"?o.summary:void 0,c=o.data;if(c!=null&&!gs(c))return It("missing_fields",n,r);let l=gs(c)?c:void 0;if(!hv.has(i))return It("unknown_action_type",n,r);let u=e.find(d=>d.type===i);if(!u)return It("action_not_legal",n,r);if(i==="raise"){let d=pv(u,l);return d?a!==void 0?{kind:"ok",action:d,summary:a}:{kind:"ok",action:d}:It("data_validation",n,r)}return a!==void 0?{kind:"ok",action:u,summary:a}:{kind:"ok",action:u}}var hv=new Set(["fold","check","call","raise","allin"]);function pv(t,e){if(!e)return;let r=e.amount;if(typeof r!="number"||!Number.isFinite(r))return;let n=gs(t.data)?t.data:void 0,s=ea(n,"amount"),o=ea(n,"min")??s,i=ea(n,"max")??s;if(!(o!==void 0&&r<o)&&!(i!==void 0&&r>i))return{type:"raise",data:{amount:r}}}function mv(t){let e=t.match(fv);return e?e[1].trim():t}function gs(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ea(t,e){if(!t)return;let r=t[e];return typeof r=="number"&&Number.isFinite(r)?r:void 0}function It(t,e,r){return{kind:"invalid",reason:t,rawSnippet:e.length>r?e.slice(0,r):e}}var yv=/^```(?:json)?\s*\n?([\s\S]*?)\n?```\s*$/;function $d(t,e,r=500){let n=t.trim(),s=vv(n),o;try{o=JSON.parse(s)}catch{return Mt("json_parse",n,r)}if(!_s(o))return Mt("missing_fields",n,r);let i=o.action;if(typeof i!="string")return Mt("missing_fields",n,r);let a=typeof o.summary=="string"?o.summary:void 0,c=o.data;if(c!=null&&!_s(c))return Mt("missing_fields",n,r);let l=_s(c)?c:void 0;if(!gv.has(i))return Mt("unknown_action_type",n,r);let u=e.find(d=>d.type===i);if(!u)return Mt("action_not_legal",n,r);if(i==="bid"){let d=_v(u,l);return d?a!==void 0?{kind:"ok",action:d,summary:a}:{kind:"ok",action:d}:Mt("data_validation",n,r)}return a!==void 0?{kind:"ok",action:u,summary:a}:{kind:"ok",action:u}}var gv=new Set(["bid","challenge"]);function _v(t,e){if(!e)return;let r=e.quantity,n=e.face;if(typeof r!="number"||!Number.isFinite(r)||!Number.isInteger(r)||typeof n!="number"||!Number.isFinite(n)||!Number.isInteger(n)||n<1||n>6||r<1)return;let s=_s(t.data)?t.data:void 0,o=ta(s,"min_quantity"),i=ta(s,"min_face"),a=ta(s,"max_quantity");if(!(o!==void 0&&r<o)&&!(a!==void 0&&r>a)&&!(o!==void 0&&i!==void 0&&r===o&&n<i))return{type:"bid",data:{quantity:r,face:n}}}function vv(t){let e=t.match(yv);return e?e[1].trim():t}function _s(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ta(t,e){if(!t)return;let r=t[e];return typeof r=="number"&&Number.isFinite(r)?r:void 0}function Mt(t,e,r){return{kind:"invalid",reason:t,rawSnippet:e.length>r?e.slice(0,r):e}}var bv=/^```(?:json)?\s*\n?([\s\S]*?)\n?```\s*$/,wv=new Set(["income","foreign_aid","coup","tax","assassinate","steal","exchange","challenge","pass","block","lose_card","return_cards"]);function Pd(t,e,r=500){let n=t.trim(),s=Sv(n),o;try{o=JSON.parse(s)}catch{return Lt("json_parse",n,r)}if(!vr(o))return Lt("missing_fields",n,r);let i=o.action;if(typeof i!="string")return Lt("missing_fields",n,r);let a=typeof o.summary=="string"?o.summary:void 0,c=o.data;if(c!=null&&!vr(c))return Lt("missing_fields",n,r);let l=vr(c)?c:void 0;if(!wv.has(i))return Lt("unknown_action_type",n,r);let u=e.filter(f=>f.type===i);if(u.length===0)return Lt("action_not_legal",n,r);let d=Ev(i,u,l);return d?a!==void 0?{kind:"ok",action:d,summary:a}:{kind:"ok",action:d}:Lt("data_validation",n,r)}function Ev(t,e,r){switch(t){case"coup":case"assassinate":case"steal":{let n=r?.target;return typeof n!="string"?void 0:e.find(s=>kd(s.data,"target")===n)}case"block":{let n=r?.role;return typeof n!="string"?void 0:e.find(s=>kd(s.data,"role")===n)}case"lose_card":{let n=r?.card_index;return typeof n!="number"||!Number.isFinite(n)||!Number.isInteger(n)?void 0:e.find(s=>$v(s.data,"card_index")===n)}case"return_cards":{let n=r?.return_indices;return!Array.isArray(n)||!n.every(s=>typeof s=="number"&&Number.isFinite(s)&&Number.isInteger(s))?void 0:e.find(s=>{let o=kv(s.data,"return_indices");return o!==void 0&&Pv(o,n)})}default:return e[0]}}function Sv(t){let e=t.match(bv);return e?e[1].trim():t}function vr(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function kd(t,e){if(!vr(t))return;let r=t[e];return typeof r=="string"?r:void 0}function $v(t,e){if(!vr(t))return;let r=t[e];return typeof r=="number"&&Number.isFinite(r)?r:void 0}function kv(t,e){if(!vr(t))return;let r=t[e];if(Array.isArray(r)&&r.every(n=>typeof n=="number"&&Number.isFinite(n)))return r}function Pv(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function Lt(t,e,r){return{kind:"invalid",reason:t,rawSnippet:e.length>r?e.slice(0,r):e}}function lt(t,e){if(t===null||typeof t!="object")return;let n=t[e];if(typeof n=="number"&&Number.isFinite(n))return n}function Td(t,e){if(t===null||typeof t!="object")return;let n=t[e];if(Array.isArray(n)){for(let s of n)if(typeof s!="string")return;return n}}var Tv="(no events since your last turn)";function Rd(t){return{stateBlock:Rv(t),recentEventsBlock:Ov(t)}}function Rv(t){let{publicState:e,players:r,yourPlayerId:n}=t,s=[],o=typeof e.phase=="string"?e.phase:"(unknown)";if(s.push(`Phase: ${o}`),typeof e.current_turn=="string"&&e.current_turn.length>0&&s.push(`Current turn (actor): ${ve(e.current_turn,r,n)}`),typeof e.pending_action=="string"&&e.pending_action.length>0){let c=`Pending action: ${e.pending_action}`;typeof e.pending_target=="string"&&e.pending_target.length>0&&(c+=` | target: ${ve(e.pending_target,r,n)}`),typeof e.claimed_role=="string"&&e.claimed_role.length>0&&(c+=` | claimed_role: ${e.claimed_role}`),s.push(c)}if(typeof e.blocker=="string"&&e.blocker.length>0){let c=`Blocker: ${ve(e.blocker,r,n)}`;typeof e.block_role=="string"&&e.block_role.length>0&&(c+=` claiming role ${e.block_role}`),s.push(c)}if(typeof e.influence_loser=="string"&&e.influence_loser.length>0&&s.push(`Influence loser: ${ve(e.influence_loser,r,n)}`),Array.isArray(e.your_cards)&&s.push(`Your unrevealed cards: [${e.your_cards.join(", ")}]`),Array.isArray(e.your_revealed)&&s.push(`Your revealed cards: [${e.your_revealed.join(", ")}]`),typeof e.coins=="number"&&s.push(`Your coins: ${e.coins}`),e.phase==="exchange_return"&&Array.isArray(e.all_exchange_options)){let c=e.all_exchange_options.map((l,u)=>`${u}=${l}`).join(", ");c.length>0&&s.push(`Exchange options (indexed): ${c}`)}let i=e.turn_log;if(i&&typeof i=="object"&&!Array.isArray(i)){let c=[],l=i;typeof l.action=="string"&&c.push(`action=${l.action}`),typeof l.actor=="string"&&c.push(`actor=${ve(l.actor,r,n)}`),typeof l.target=="string"&&c.push(`target=${ve(l.target,r,n)}`),typeof l.claimed_role=="string"&&c.push(`claimed_role=${l.claimed_role}`),typeof l.challenger=="string"&&c.push(`challenger=${ve(l.challenger,r,n)}`),typeof l.challenge_result=="string"&&c.push(`challenge_result=${l.challenge_result}`),typeof l.blocker=="string"&&c.push(`blocker=${ve(l.blocker,r,n)}`),typeof l.block_role=="string"&&c.push(`block_role=${l.block_role}`),typeof l.block_challenger=="string"&&c.push(`block_challenger=${ve(l.block_challenger,r,n)}`),typeof l.block_challenge_result=="string"&&c.push(`block_challenge_result=${l.block_challenge_result}`),c.length>0&&s.push(`Turn log: ${c.join(" | ")}`)}let a=r.filter(c=>c.id!==n);if(a.length>0){s.push("Opponents:");for(let c of a)s.push(` ${xv(c)}`)}return s.join(`
75
+ `)}function xv(t){let r=`${t.name??`Player ${t.id}`} (${t.id}): status=${t.status}`,n=lt(t.data,"coins");n!==void 0&&(r+=` | coins=${n}`);let s=lt(t.data,"hidden_cards");s!==void 0&&(r+=` | hidden_cards=${s}`);let o=Td(t.data,"revealed");return o!==void 0&&(r+=` | revealed=[${o.join(", ")}]`),r}function ve(t,e,r){return t===r?`you (${t})`:`${e.find(o=>o.id===t)?.name??`Player ${t}`} (${t})`}function Ov(t){let{recentEvents:e,players:r,yourPlayerId:n}=t;return e.length===0?Tv:e.map(s=>Nv(s,r,n)).join(`
76
+ `)}function Nv(t,e,r){let n=t.data??{},s=typeof t.player=="string"?t.player:void 0,o=s?ve(s,e,r):"(unknown)",i=a=>ve(a,e,r);switch(t.type){case"action":{let a=typeof n.action=="string"?n.action:"(unknown)",c=typeof n.target=="string"?n.target:void 0,l=typeof n.claimed_role=="string"?n.claimed_role:void 0,u=`${o} attempts: ${a}`;return c&&(u+=` (target: ${i(c)})`),l&&(u+=` (claims ${l})`),u}case"challenge_pass":{let a=typeof n.player=="string"?n.player:s;return`${a?i(a):o} passed (no challenge)`}case"challenge":{let a=typeof n.challenger=="string"?n.challenger:s,c=typeof n.actor=="string"?n.actor:void 0,l=typeof n.claimed_role=="string"?n.claimed_role:void 0,u=a?i(a):o,d=c?i(c):"(unknown)",f=`${u} challenged ${d}'s claim`;return l&&(f+=` of ${l}`),f}case"challenge_result":{let a=typeof n.result=="string"?n.result:"(unknown)",c=typeof n.actor=="string"?n.actor:void 0,l=typeof n.challenger=="string"?n.challenger:void 0,u=typeof n.revealed_card=="string"?n.revealed_card:void 0,d=a==="success"?`${c?i(c):"actor"} was lying, loses influence`:a==="fail"?`${l?i(l):"challenger"} was wrong, loses influence`:"(unknown outcome)",f=`Challenge result: ${a} \u2014 ${d}`;return u&&(f+=` (revealed card: ${u})`),f}case"block_pass":{let a=typeof n.player=="string"?n.player:s;return`${a?i(a):o} passed (no block)`}case"block":{let a=typeof n.blocker=="string"?n.blocker:s,c=typeof n.claimed_role=="string"?n.claimed_role:void 0,l=typeof n.action=="string"?n.action:void 0,d=`${a?i(a):o} blocks`;return l&&(d+=` ${l}`),c&&(d+=` claiming ${c}`),d}case"block_challenge_pass":{let a=typeof n.player=="string"?n.player:s;return`${a?i(a):o} passed (no challenge to block)`}case"block_accepted":{let a=typeof n.blocker=="string"?n.blocker:void 0;return a?`Block accepted (blocker: ${i(a)})`:"Block accepted"}case"challenge_block":{let a=typeof n.challenger=="string"?n.challenger:s,c=typeof n.blocker=="string"?n.blocker:void 0,l=typeof n.claimed_role=="string"?n.claimed_role:void 0,u=a?i(a):o,d=c?i(c):"(unknown)",f=`${u} challenged ${d}'s block`;return l&&(f+=` (claimed ${l})`),f}case"challenge_block_result":{let a=typeof n.result=="string"?n.result:"(unknown)",c=typeof n.blocker=="string"?n.blocker:void 0,l=typeof n.challenger=="string"?n.challenger:void 0,u=typeof n.revealed_card=="string"?n.revealed_card:void 0,d=a==="success"?`${c?i(c):"blocker"} was lying, loses influence`:a==="fail"?`${l?i(l):"challenger"} was wrong, loses influence`:"(unknown outcome)",f=`Block challenge result: ${a} \u2014 ${d}`;return u&&(f+=` (revealed card: ${u})`),f}case"influence_lost":{let a=typeof n.player=="string"?n.player:s,c=typeof n.card=="string"?n.card:void 0,u=`${a?i(a):o} revealed`;return c&&(u+=` ${c}`),u+=" (lost influence)",u}case"player_eliminated":{let a=typeof n.player=="string"?n.player:s;return`${a?i(a):o} eliminated`}case"exchange_draw":{let a=typeof n.drawn_count=="number"?n.drawn_count:void 0,c=`${o} drew exchange cards`;return a!==void 0&&(c+=` (count: ${a})`),c}case"exchange_complete":{let a=typeof n.player=="string"?n.player:s,c=typeof n.returned_count=="number"?n.returned_count:void 0,u=`${a?i(a):o} completed exchange`;return c!==void 0&&(u+=` (returned: ${c})`),u}case"action_resolved":{let a=typeof n.action=="string"?n.action:"(unknown)",c=typeof n.coins_now=="number"?n.coins_now:void 0,l=typeof n.target=="string"?n.target:void 0,u=typeof n.stolen=="number"?n.stolen:void 0,d=`${o} resolved: ${a}`;return l&&(d+=` (target: ${i(l)})`),u!==void 0&&(d+=` | stolen=${u}`),c!==void 0&&(d+=` | coins_now=${c}`),d}case"game_over":{let a=typeof n.winner=="string"?n.winner:"";return`Game over. Winner: ${a.length>0?i(a):"(no surviving player)"}`}case"player_disconnected":{let a=typeof n.player=="string"?n.player:s;return`${a?i(a):o} disconnected`}default:return`(unhandled event: ${t.type})`}}var Av="(no events since your last turn)";function xd(t){return{stateBlock:Cv(t),recentEventsBlock:Mv(t)}}function Cv(t){let{publicState:e,players:r,yourPlayerId:n}=t,s=[],o=typeof e.phase=="string"?e.phase:"(unknown)";if(typeof e.round=="number"?s.push(`Round ${e.round} | Phase: ${o}`):s.push(`Phase: ${o}`),typeof e.total_dice=="number"&&s.push(`Total dice in play: ${e.total_dice}`),Array.isArray(e.your_dice)){let c=e.your_dice.filter(u=>typeof u=="number"),l=typeof e.your_dice_count=="number"?e.your_dice_count:c.length;s.push(`Your dice: [${c.join(" ")}] (count: ${l})`)}else typeof e.your_dice_count=="number"&&s.push(`Your dice: (eliminated or not visible) (count: ${e.your_dice_count})`);let i=e.current_bid;if(i&&typeof i=="object"){let c=typeof i.quantity=="number"?i.quantity:void 0,l=typeof i.face=="number"?i.face:void 0,u=typeof i.bidder=="string"?i.bidder:void 0;if(c!==void 0&&l!==void 0&&u!==void 0){let d=Dt(u,r,n);s.push(`Current bid: quantity=${c} face=${l} by ${d}`)}else s.push("Current bid: (incomplete bid data)")}else s.push("Current bid: (none \u2014 you may bid any opening bid)");typeof e.current_turn=="string"&&e.current_turn.length>0&&s.push(`Current turn: ${Dt(e.current_turn,r,n)}`);let a=r.filter(c=>c.id!==n);if(a.length>0){s.push("Opponents:");for(let c of a)s.push(` ${Iv(c)}`)}return s.join(`
77
+ `)}function Iv(t){let r=`${t.name??`Player ${t.id}`} (${t.id}): status=${t.status}`,n=lt(t.data,"dice_count");return n!==void 0&&(r+=` | dice_count=${n}`),r}function Dt(t,e,r){return t===r?`you (${t})`:`${e.find(o=>o.id===t)?.name??`Player ${t}`} (${t})`}function Mv(t){let{recentEvents:e,players:r,yourPlayerId:n}=t;return e.length===0?Av:e.map(s=>Lv(s,r,n)).join(`
78
+ `)}function Lv(t,e,r){let n=t.data??{},s=typeof t.player=="string"?t.player:void 0,o=s?Dt(s,e,r):"(unknown)";switch(t.type){case"bid":{let i=typeof n.quantity=="number"?n.quantity:void 0,a=typeof n.face=="number"?n.face:void 0;return i!==void 0&&a!==void 0?`${o} bid: quantity ${i} face ${a}`:`${o} bid: (incomplete data)`}case"challenge":{let i=typeof n.challenger=="string"?n.challenger:void 0,a=typeof n.bidder=="string"?n.bidder:void 0,c=typeof n.bid_quantity=="number"?n.bid_quantity:void 0,l=typeof n.bid_face=="number"?n.bid_face:void 0,u=typeof n.actual_count=="number"?n.actual_count:void 0,d=typeof n.bid_met=="boolean"?n.bid_met:void 0,f=typeof n.loser=="string"?n.loser:void 0,p=n.all_dice,h=i?Dt(i,e,r):o,m=a?Dt(a,e,r):"(unknown)",y=f?Dt(f,e,r):"(unknown)",g=c!==void 0&&l!==void 0?`${c} ${l}s`:"the bid",b=u!==void 0?`Actual count: ${u}`:"",E=d!==void 0?`bid_met=${d}`:"",S=`${y} loses 1 die`,v=`${h} challenged ${m}'s bid (${g}).`,D=[b,E,S].filter(B=>B.length>0).join(" \u2192 ");if(D.length>0&&(v+=` ${D}.`),p&&typeof p=="object"&&!Array.isArray(p)){let B=Object.entries(p).map(([$e,ke])=>{if(!Array.isArray(ke))return null;let Le=ke.filter(br=>typeof br=="number");return`${$e}=[${Le.join(",")}]`}).filter($e=>$e!==null).join(", ");B.length>0&&(v+=` Revealed dice: ${B}`)}return v}case"player_eliminated":return`${o} eliminated`;case"round_start":{let i=typeof n.round=="number"?n.round:void 0,a=n.dice_counts,l=`${i!==void 0?`Round ${i} began`:"New round began"}.`;if(a&&typeof a=="object"&&!Array.isArray(a)){let u=Object.entries(a).map(([d,f])=>typeof f=="number"?`${d}=${f}`:null).filter(d=>d!==null).join(", ");u.length>0&&(l+=` Dice counts: ${u}`)}return l}case"game_over":{let i=typeof n.winner=="string"?n.winner:"";return`Game over. Winner: ${i.length>0?Dt(i,e,r):"(no single winner)"}`}case"player_disconnected":return`${o} disconnected`;default:return`(unhandled event: ${t.type})`}}var Dv="(no events since your last turn)";function Od(t){return{stateBlock:jv(t),recentEventsBlock:Fv(t)}}function jv(t){let{publicState:e,players:r,yourPlayerId:n}=t,s=[],o=typeof e.phase=="string"?e.phase:"(unknown)";if(typeof e.hand_num=="number"&&typeof e.max_hands=="number"?s.push(`Hand ${e.hand_num} of ${e.max_hands} | Phase: ${o}`):s.push(`Phase: ${o}`),typeof e.small_blind=="number"&&typeof e.big_blind=="number"&&s.push(`Blinds: ${e.small_blind}/${e.big_blind}`),Array.isArray(e.your_hand)&&e.your_hand.length===2){let[l,u]=e.your_hand;typeof l=="string"&&typeof u=="string"&&s.push(`Your hand: ${l} ${u}`)}if(Array.isArray(e.community_cards)&&e.community_cards.length>0){let l=e.community_cards.filter(u=>typeof u=="string");s.push(`Board: ${l.join(" ")}`)}else s.push("Board: (no community cards yet)");typeof e.your_position=="string"&&e.your_position.length>0&&s.push(`Your position: ${e.your_position}`),typeof e.your_chips=="number"&&typeof e.your_bet=="number"?s.push(`Your chips: ${e.your_chips} | Your current bet: ${e.your_bet}`):typeof e.your_chips=="number"&&s.push(`Your chips: ${e.your_chips}`);let i=typeof e.pot=="number"?e.pot:void 0,a=typeof e.current_bet=="number"?e.current_bet:void 0;if(i!==void 0&&a!==void 0){let l=`Pot: ${i} | Current bet to match: ${a}`;typeof e.your_bet=="number"&&a>e.your_bet&&(l+=` | Need to call: ${a-e.your_bet}`),s.push(l)}if(Array.isArray(e.action_order)&&e.action_order.length>0){let l=e.action_order.filter(u=>typeof u=="string").map(u=>dn(u,r,n)).join(" \u2192 ");l.length>0&&s.push(`Action order: ${l}`)}let c=r.filter(l=>l.id!==n);if(c.length>0){s.push("Opponents:");for(let l of c)s.push(` ${qv(l)}`)}return s.join(`
79
+ `)}function qv(t){let r=`${t.name??`Player ${t.id}`} (${t.id}): status=${t.status}`,n=lt(t.data,"chips");n!==void 0&&(r+=` | chips=${n}`);let s=lt(t.data,"bet");return s!==void 0&&(r+=` | bet=${s}`),r}function dn(t,e,r){return t===r?`you (${t})`:`${e.find(o=>o.id===t)?.name??`Player ${t}`} (${t})`}function Fv(t){let{recentEvents:e,players:r,yourPlayerId:n}=t;return e.length===0?Dv:e.map(s=>Bv(s,r,n)).join(`
80
+ `)}function Bv(t,e,r){let n=t.data??{},s=typeof t.player=="string"?t.player:void 0,o=s?dn(s,e,r):"(unknown)";switch(t.type){case"new_hand":{let i=typeof n.hand_num=="number"?n.hand_num:void 0,a=typeof n.dealer=="string"?n.dealer:void 0,c=a?dn(a,e,r):"(unknown)",l=typeof n.small_blind=="number"?n.small_blind:void 0,u=typeof n.big_blind=="number"?n.big_blind:void 0,d=i!==void 0?`Hand ${i} began`:"New hand began",f=l!==void 0&&u!==void 0?` | blinds: ${l}/${u}`:"";return`${d} | dealer: ${c}${f}`}case"player_action":{let i=typeof n.action=="string"?n.action:"(unknown action)",a=typeof n.amount=="number"?n.amount:void 0,c=typeof n.total_bet=="number"?n.total_bet:void 0,l=`${o} ${i}`;return a!==void 0&&(l+=` ${a}`),c!==void 0&&(l+=` (total bet ${c})`),l}case"community_cards":{let i=Array.isArray(n.cards)?n.cards.filter(l=>typeof l=="string"):[],a=typeof n.phase=="string"?n.phase:void 0;return`${a?a.charAt(0).toUpperCase()+a.slice(1):"Community cards"}: ${i.join(" ")}`}case"cards_dealt":return s!==r?`${o} was dealt cards`:`You were dealt: ${(Array.isArray(n.cards)?n.cards.filter(a=>typeof a=="string"):[]).join(" ")}`;case"hand_result":{let i=Array.isArray(n.winners)?n.winners.filter(d=>typeof d=="string"):[],a=i.length>0?i.map(d=>dn(d,e,r)).join(", "):"(unknown)",c=typeof n.pot=="number"?n.pot:void 0,l=typeof n.reason=="string"?n.reason:void 0,u=`Hand winners: ${a}`;return c!==void 0&&(u+=` | pot ${c}`),l&&(u+=` (${l})`),u}case"match_result":{let i=typeof n.winner=="string"?n.winner:"";return`Match over. Winner: ${i.length>0?dn(i,e,r):"(no single winner)"}`}case"player_disconnected":{let i=typeof n.reason=="string"?n.reason:"(no reason)";return`${o} disconnected \u2014 reason: ${i}`}default:return`(unhandled event: ${t.type})`}}var Uv=16384,Nd="[... older events truncated to fit prompt budget ...]",vs="[... state truncated ...]",Wv=`Output format:
81
+ Respond with a single JSON object exactly matching this schema:
82
+ {"action": "<one of the legal action types>", "data": {<action-specific parameters>}, "summary": "<short reasoning, max 200 chars>"}
83
+ Do not wrap in markdown code blocks. Do not output any text outside the JSON object.`,Vv=`Constraints:
84
+ - Choose only from the legal_actions listed in the user message.
85
+ - Do not include chain-of-thought reasoning; the summary field is brief.
86
+ - The match is anonymous; do not assume opponent identities.`,Hv="Reminder: respond with a single JSON object as specified in the system prompt.",zv="Recent events (incremental since your last turn):",Ad="Current state:",Kv="Legal actions:",Gv="(none \u2014 no action required this turn)";function Cd(t,e){let r=e?.userPromptCharCap??Uv,n=Yv(t),s=Jv(t),o=Qv(t,n.stateBlock,n.recentEventsBlock,r);return{systemPrompt:s,userPrompt:o}}function Yv(t){switch(t.game){case"texas_holdem":return Od({publicState:t.publicState,privateState:t.privateState,rules:t.rules,players:t.players,recentEvents:t.recentEvents,yourPlayerId:t.playerId});case"liars_dice":return xd({publicState:t.publicState,privateState:t.privateState,rules:t.rules,players:t.players,recentEvents:t.recentEvents,yourPlayerId:t.playerId});case"coup":return Rd({publicState:t.publicState,privateState:t.privateState,rules:t.rules,players:t.players,recentEvents:t.recentEvents,yourPlayerId:t.playerId});default:{let e=t.game;throw new Error(`buildPrompt: unsupported game: ${e}`)}}}function Jv(t){let e=[];t.strategyProfile.systemPrompt.length>0&&e.push(t.strategyProfile.systemPrompt),e.push(Xv(t.rules));let r=t.strategyProfile.gameSpecific?.[t.game]?.extraPrompt;return r&&r.length>0&&e.push(r),e.push(Wv),e.push(Vv),e.join(`
87
+
88
+ `)}function Xv(t){if(t===null||typeof t!="object")return"Game Rules \u2014 (unknown game)";let e=t,r=typeof e.name=="string"?e.name:"(unknown game)",n=typeof e.summary=="string"?e.summary:"",s=Array.isArray(e.key_rules)?e.key_rules.filter(a=>typeof a=="string"):[],o=[`Game Rules \u2014 ${r}:`];if(n.length>0&&o.push(n),s.length>0){o.push(""),o.push("Key rules:");for(let a of s)o.push(`- ${a}`)}let i=e.available_actions;if(i&&typeof i=="object"&&!Array.isArray(i)){let a=Object.entries(i).filter(c=>typeof c[1]=="string");if(a.length>0){o.push(""),o.push("Available actions:");for(let[c,l]of a)o.push(`- ${c}: ${l}`)}}return o.join(`
89
+ `)}function Qv(t,e,r,n){let s=`Match: ${t.game} | match_id: ${t.matchId} | you are ${t.playerId}`,o=Zv(t.game,t.legalActions),i=`${Kv}
90
+ ${o}`,a=(m,y)=>{let g=[s];return m.length>0&&g.push(`${zv}
91
+ ${m}`),y.length>0&&g.push(`${Ad}
92
+ ${y}`),g.push(i,Hv),g.join(`
93
+
94
+ `)},c=a(r,e);if(c.length<=n)return c;let l=r,u=r.split(`
95
+ `);for(let m=1;m<=u.length;m++){let y=u.slice(m);if(l=y.length>0?`${Nd}
96
+ ${y.join(`
97
+ `)}`:Nd,c=a(l,e),c.length<=n)return c}let d=rb(t.game,e);if(c=a(l,d),c.length<=n)return c;let f=a(l,"").length,p=`
98
+
99
+ ${Ad}
100
+ `,h=n-f-p.length;if(h>=vs.length){let m=Math.max(0,h-vs.length-1),y=m>0?`${d.slice(0,m)}
101
+ ${vs}`:vs;if(c=a(l,y),c.length<=n)return c}return c=a(l,""),c.length<=n||(c=a("",""),c.length<=n)?c:c.slice(0,n)}function Zv(t,e){return e.length===0?Gv:e.map((r,n)=>`${n+1}. ${eb(r)}`).join(`
102
+ `)}function eb(t){let e=typeof t.type=="string"?t.type:"(unknown)",r=tb(t.data);return r.length===0?`${e} \u2014 no parameters`:`${e} \u2014 ${r}`}function tb(t){if(t==null||typeof t!="object")return"";let e=t,r=Object.keys(e);if(r.length===0)return"";let n=[];for(let s of r){let o=e[s];if(typeof o=="number"||typeof o=="string"||typeof o=="boolean")n.push(`${s}=${o}`);else if(Array.isArray(o)){let i=o.filter(a=>typeof a=="number"||typeof a=="string").map(a=>String(a)).join(",");n.push(`${s}=[${i}]`)}}return n.length===0?"":`data: {${n.join(", ")}}`}function rb(t,e){let r=nb(t),n=e.split(`
103
+ `),s=[];for(let o of n){let i=o.trimStart();for(let a of r)if(i.startsWith(a)){s.push(o);break}}return s.join(`
104
+ `)}function nb(t){switch(t){case"texas_holdem":return["Phase:","Hand ","Your hand:","Board:","Your chips:","Pot:"];case"liars_dice":return["Phase:","Round ","Your dice:","Current bid:"];case"coup":return["Phase:","Your unrevealed cards:","Your coins:","Pending action:"]}}var jt=class extends Error{provider;cause;constructor(e,r,n){super(r),this.provider=e,this.cause=n}},ut=class extends jt{name="DirectModelNetworkError";kind="direct_model_network";constructor(e,r,n){super(e,r,n)}},Me=class extends jt{name="DirectModelHttpError";kind="direct_model_http";status;bodySnippet;constructor(e,r,n,s,o){super(e,n,o),this.status=r,this.bodySnippet=s}},be=class extends jt{name="DirectModelAbortedError";kind="direct_model_aborted";constructor(e,r,n){super(e,r,n)}},we=class extends jt{name="DirectModelInvalidResponseError";kind="direct_model_invalid_response";responseSnippet;constructor(e,r,n,s){super(e,r,s),this.responseSnippet=n}},J=class extends jt{name="DirectModelUnsupportedError";kind="direct_model_unsupported";field;constructor(e,r,n){super(e,n),this.field=r}},Md=2048,Id="[REDACTED]";function fn(t,e){let r=t;for(let n of e){if(!n)continue;let s=r.indexOf(n);for(;s>=0;)r=r.slice(0,s)+Id+r.slice(s+n.length),s=r.indexOf(n,s+Id.length)}return r}function sb(t,e=Md){if(e<=0)return"";if(t.length<=e)return t;let r=e,n="";for(let s=0;s<8;s++){let i=`...[truncated ${t.length-r} chars]`,a=Math.max(0,e-i.length);if(i===n&&a===r)break;n=i,r=a}return e<n.length?n.slice(0,e):t.slice(0,r)+n}function dt(t,e){if(t===void 0||t==="")return;let r=fn(t,e);return sb(r,Md)}var Ee="anthropic",ob="https://api.anthropic.com",ib="2023-06-01";function Dd(t){if(!t.apiKey)throw new J(Ee,"apiKey","apiKey must be a non-empty string");if(!t.model)throw new J(Ee,"model","model must be a non-empty string");let e=t.apiKey,r=t.model,n=(t.baseURL??ob).replace(/\/+$/,""),s=t.anthropicVersion??ib,o=t.fetchImpl??globalThis.fetch;if(typeof o!="function")throw new J(Ee,"fetchImpl","fetch is unavailable; pass fetchImpl explicitly");let i=`${n}/v1/messages`,a=[e];return{provider:Ee,model:r,generate:async l=>{if(!Number.isFinite(l.maxTokens)||l.maxTokens<=0)throw new J(Ee,"maxTokens","maxTokens must be a positive integer");let u=l.signal;if(u?.aborted)throw new be(Ee,"request aborted before send",u.reason);let d={model:r,system:l.systemPrompt,messages:[{role:"user",content:l.userPrompt}],max_tokens:l.maxTokens};l.temperature!==void 0&&(d.temperature=l.temperature);let f={"x-api-key":e,"anthropic-version":s,"content-type":"application/json"},p=performance.now(),h;try{h=await o(i,{method:"POST",headers:f,body:JSON.stringify(d),signal:u})}catch(v){if(ab(v))throw new be(Ee,"request aborted",v);let D=fn(cb(v),a);throw new ut(Ee,`fetch failed: ${D}`,v)}let m=Math.max(0,performance.now()-p);if(!h.ok){let v=await Ld(h),D=dt(v,a);throw new Me(Ee,h.status,`Anthropic returned HTTP ${h.status}`,D,h)}let y=await Ld(h),g;try{g=JSON.parse(y)}catch(v){throw new we(Ee,"response body is not valid JSON",dt(y,a),v)}let b=lb(g);if(b===null)throw new we(Ee,"response missing content[0].text or content[0].type !== 'text'",dt(y,a));let{inputTokens:E,outputTokens:S}=ub(g);return{text:b,inputTokens:E,outputTokens:S,latencyMs:m,raw:g}}}}function ab(t){if(t===null||typeof t!="object")return!1;let e=t;return e.name==="AbortError"||e.code==="ABORT_ERR"||e.code===20}function cb(t){if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return String(t)}catch{return"unknown"}}async function Ld(t){try{return await t.text()}catch{return""}}function lb(t){if(!bs(t))return null;let e=t.content;if(!Array.isArray(e)||e.length===0)return null;let r=e[0];if(!bs(r)||r.type!=="text")return null;let n=r.text;return typeof n!="string"?null:n}function ub(t){if(!bs(t))return{};let e=t.usage;if(!bs(e))return{};let r=e.input_tokens,n=e.output_tokens;return{inputTokens:typeof r=="number"?r:void 0,outputTokens:typeof n=="number"?n:void 0}}function bs(t){return typeof t=="object"&&t!==null}var Se="openai",db="https://api.openai.com/v1";function qd(t){if(!t.apiKey)throw new J(Se,"apiKey","apiKey must be a non-empty string");if(!t.model)throw new J(Se,"model","model must be a non-empty string");let e=t.apiKey,r=t.model,n=(t.baseURL??db).replace(/\/+$/,""),s=t.organization,o=t.fetchImpl??globalThis.fetch;if(typeof o!="function")throw new J(Se,"fetchImpl","fetch is unavailable; pass fetchImpl explicitly");let i=`${n}/chat/completions`,a=[e];return{provider:Se,model:r,generate:async l=>{if(!Number.isFinite(l.maxTokens)||l.maxTokens<=0)throw new J(Se,"maxTokens","maxTokens must be a positive integer");let u=l.signal;if(u?.aborted)throw new be(Se,"request aborted before send",u.reason);let d={model:r,messages:[{role:"system",content:l.systemPrompt},{role:"user",content:l.userPrompt}],max_completion_tokens:l.maxTokens};l.temperature!==void 0&&(d.temperature=l.temperature);let f={Authorization:`Bearer ${e}`,"content-type":"application/json"};s&&(f["OpenAI-Organization"]=s);let p=performance.now(),h;try{h=await o(i,{method:"POST",headers:f,body:JSON.stringify(d),signal:u})}catch(v){if(fb(v))throw new be(Se,"request aborted",v);let D=fn(hb(v),a);throw new ut(Se,`fetch failed: ${D}`,v)}let m=Math.max(0,performance.now()-p);if(!h.ok){let v=await jd(h),D=dt(v,a);throw new Me(Se,h.status,`OpenAI returned HTTP ${h.status}`,D,h)}let y=await jd(h),g;try{g=JSON.parse(y)}catch(v){throw new we(Se,"response body is not valid JSON",dt(y,a),v)}let b=pb(g);if(b===null)throw new we(Se,"response missing choices[0].message.content (or content is not a string)",dt(y,a));let{inputTokens:E,outputTokens:S}=mb(g);return{text:b,inputTokens:E,outputTokens:S,latencyMs:m,raw:g}}}}function fb(t){if(t===null||typeof t!="object")return!1;let e=t;return e.name==="AbortError"||e.code==="ABORT_ERR"||e.code===20}function hb(t){if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return String(t)}catch{return"unknown"}}async function jd(t){try{return await t.text()}catch{return""}}function pb(t){if(!hn(t))return null;let e=t.choices;if(!Array.isArray(e)||e.length===0)return null;let r=e[0];if(!hn(r))return null;let n=r.message;if(!hn(n))return null;let s=n.content;return typeof s!="string"?null:s}function mb(t){if(!hn(t))return{};let e=t.usage;if(!hn(e))return{};let r=e.prompt_tokens,n=e.completion_tokens;return{inputTokens:typeof r=="number"?r:void 0,outputTokens:typeof n=="number"?n:void 0}}function hn(t){return typeof t=="object"&&t!==null}var W=class extends Error{name="DecisionProviderError";kind;cause;constructor(e,r,n){super(r),this.kind=e,this.cause=n}},yb=2,gb=500;function _b(t){let e=t.retryBudget??yb,r=t.parseRetryHintCharCap??gb;if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw new W("fatal_caller_bug",`retryBudget must be a non-negative integer (got ${String(t.retryBudget)})`);if(!Number.isFinite(r)||!Number.isInteger(r)||r<=0)throw new W("fatal_caller_bug",`parseRetryHintCharCap must be a positive integer (got ${String(t.parseRetryHintCharCap)})`);let n=new Map;function s(c,l){let u=`${c}:${l}`,d=n.get(u);if(d)return d;let f;try{f=t.apiKeyResolver(c,l)}catch(h){throw new W("fatal_unsupported",`apiKeyResolver threw for ${c}:${l}`,h)}if(typeof f!="string"||!f)throw new W("fatal_unsupported",`apiKeyResolver returned empty key for ${c}:${l}`);let p;try{c==="anthropic"?p=(t.clientFactory?.anthropic??Dd)({apiKey:f,model:l,fetchImpl:t.fetchImpl}):p=(t.clientFactory?.openai??qd)({apiKey:f,model:l,fetchImpl:t.fetchImpl})}catch(h){throw h instanceof J?new W("fatal_unsupported",h.message,h):new W("fatal_caller_bug",`clientFactory.${c} threw unexpected error`,h)}return n.set(u,p),p}async function o(c){if(typeof c.decisionBudgetMs!="number"||!Number.isFinite(c.decisionBudgetMs)||c.decisionBudgetMs<=0)throw new W("fatal_caller_bug","decisionBudgetMs must be a positive finite number");if(!bb(c.game))throw new W("fatal_caller_bug",`unsupported game: ${String(c.game)}`);let l=new AbortController,u=setTimeout(()=>{l.abort()},c.decisionBudgetMs);try{return await i(c,l.signal)}finally{clearTimeout(u)}}async function i(c,l){if(l.aborted)throw new W("fatal_aborted","decisionBudgetMs already elapsed before decide started");let u=s(c.strategyProfile.provider,c.strategyProfile.model),d=Cd(c),f,p,h=0,m;for(let g=0;g<=e;g++){if(l.aborted)throw new W("fatal_aborted","decisionBudgetMs elapsed mid-attempt");let b=g===0?d.userPrompt:d.userPrompt+`
105
+
106
+ `+Tb(g,f,p,r),E;try{E=await u.generate({systemPrompt:d.systemPrompt,userPrompt:b,temperature:c.strategyProfile.temperature,maxTokens:c.strategyProfile.maxTokens,signal:l})}catch(v){if($b(v))throw kb(v);if(Sb(v)){f=`direct_model_${v.kind}`,p=Pb(v);continue}throw new W("fatal_caller_bug","client.generate threw unexpected error",v)}h+=E.latencyMs,m=E;let S=wb(c.game,E.text,c.legalActions,r);if(S.kind==="ok")return vb(c,S,E,h,g);f=`parse_${S.reason}`,p=S.rawSnippet}let y;try{y=Eb(c)}catch(g){throw new W("fatal_caller_bug",g instanceof Error?`fallback dispatch failed: ${g.message}`:"fallback dispatch failed",g)}return{action:y.type,params:Fd(y.data),summary:`(fallback: ${f??"unknown"})`,providerMetadata:{provider:c.strategyProfile.provider,model:c.strategyProfile.model,inputTokens:m?.inputTokens,outputTokens:m?.outputTokens,latencyMs:h,retries:e,fallback:!0}}}async function a(){if(!t.healthCheckProfile)return!1;try{return await s(t.healthCheckProfile.provider,t.healthCheckProfile.model).generate({systemPrompt:"ping",userPrompt:"respond with the word OK",maxTokens:10}),!0}catch{return!1}}return{name:t.name,decide:o,healthCheck:a}}function vb(t,e,r,n,s){let o=Fd(e.action.data),i={action:e.action.type,providerMetadata:{provider:t.strategyProfile.provider,model:t.strategyProfile.model,inputTokens:r.inputTokens,outputTokens:r.outputTokens,latencyMs:n,retries:s,fallback:!1}};return o!==void 0&&e.summary!==void 0?{...i,params:o,summary:e.summary}:o!==void 0?{...i,params:o}:e.summary!==void 0?{...i,summary:e.summary}:i}function bb(t){return t==="texas_holdem"||t==="liars_dice"||t==="coup"}function wb(t,e,r,n){switch(t){case"texas_holdem":return Sd(e,r,n);case"liars_dice":return $d(e,r,n);case"coup":return Pd(e,r,n)}}function Eb(t){switch(t.game){case"texas_holdem":return bd({publicState:t.publicState,legalActions:t.legalActions,yourPlayerId:t.playerId});case"liars_dice":return wd({publicState:t.publicState,legalActions:t.legalActions,yourPlayerId:t.playerId});case"coup":return Ed({publicState:t.publicState,legalActions:t.legalActions,yourPlayerId:t.playerId})}}function Fd(t){if(t!=null&&typeof t=="object"&&!Array.isArray(t))return t}function Sb(t){return t instanceof we||t instanceof ut?!0:t instanceof Me?t.status===429||t.status>=500:!1}function $b(t){return t instanceof be||t instanceof J?!0:t instanceof Me?!(t.status===429||t.status>=500):!1}function kb(t){return t instanceof be?new W("fatal_aborted",t.message,t):t instanceof J?new W("fatal_unsupported",t.message,t):new W("fatal_http",t.message,t)}function Pb(t){if(t instanceof Me)return t.bodySnippet;if(t instanceof we)return t.responseSnippet}function Tb(t,e,r,n){let s=[];if(s.push(`Retry attempt ${t}: previous output failed validation.`),e&&s.push(`Reason: ${e}.`),r!==void 0&&r!==""){let o=r.length>n?r.slice(0,n):r;s.push(`Previous output (truncated to ${n} chars): ${o}`)}return s.push("Please retry. Respond with a single JSON object exactly matching the schema in the system prompt."),s.join(`
107
+ `)}var Rb="0.1.0-alpha.1",TS="v1.0.0";function xS(){let t=Ft(),e=ft(),r=Es();return{ok:!0,runtimeVersion:Rb,schemaCount:e.size,messageTypeCount:r.length,schemasRoot:t}}export{tn as AIFIGHT_CRYPTO_V1_PREFIX,en as AIFIGHT_KEYCHAIN_V1_PREFIX,nu as AIFIGHT_RUNTIME_SERVICE,Ae as CredentialsCorruptError,ue as CredentialsCryptoError,or as CredentialsError,ir as CredentialsKeychainUnavailableError,W as DecisionProviderError,TS as PROTOCOL_VERSION,Rb as RUNTIME_VERSION,_r as ReconnectStoppedError,sr as RegisterError,Xr as RegisterHttpError,St as RegisterNetworkError,$t as RegisterSchemaError,rt as StoreError,lr as StoreMigrationError,cr as StoreOpenError,nt as StoreQueryError,Ke as WSAbortedError,Y as WSClientError,Ct as WSClosedError,it as WSConnectError,at as WSHandshakeError,Ie as WSOutboundSchemaError,At as WSProtocolVersionError,se as WSSchemaError,ze as WSUnknownMessageError,ct as WSWelcomeInvalidError,Nt as WSWelcomeTimeoutError,_b as createDirectModelProvider,rv as createReconnectingWSClient,Xi as createWSClient,f_ as decryptFromStorage,h_ as deleteFromStorage,l_ as encryptForStorage,Zr as ensureRuntimeHome,Ft as findSchemasRoot,ou as getCredentialsBackend,_i as getDefaultDbPath,Qr as getRuntimeHome,xS as hello,iu as isKeychainAvailable,ft as loadAllSchemas,Ss as loadRestSchema,Jd as loadSchema,Es as messageTypes,Xg as openDatabase,Hg as registerAgent};