@zuplo/cli 7.1.10 → 7.2.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 (37) hide show
  1. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
  2. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
  3. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
  4. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/encrypt.d.ts +4 -3
  5. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/types.d.ts +4 -2
  6. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/general/encrypt.js +7 -3
  7. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  8. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +6 -2
  9. package/node_modules/@modelcontextprotocol/client/node_modules/jose/package.json +1 -1
  10. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
  11. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
  12. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
  13. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/encrypt.d.ts +4 -3
  14. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/types.d.ts +4 -2
  15. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/encrypt.js +7 -3
  16. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  17. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +6 -2
  18. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
  19. package/node_modules/@zuplo/core/customer.cli.minified.js +1 -1
  20. package/node_modules/@zuplo/core/index.minified.js +1 -1
  21. package/node_modules/@zuplo/core/package.json +1 -1
  22. package/node_modules/@zuplo/graphql/package.json +1 -1
  23. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  24. package/node_modules/@zuplo/otel/package.json +1 -1
  25. package/node_modules/@zuplo/runtime/out/esm/chunk-GK3X4WPN.js +409 -0
  26. package/node_modules/@zuplo/runtime/out/esm/chunk-GK3X4WPN.js.map +1 -0
  27. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  28. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  29. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  30. package/node_modules/@zuplo/runtime/out/types/index.d.ts +286 -15
  31. package/node_modules/@zuplo/runtime/package.json +1 -1
  32. package/node_modules/default-browser/package.json +1 -1
  33. package/node_modules/default-browser/windows.js +3 -1
  34. package/package.json +6 -6
  35. package/node_modules/@zuplo/runtime/out/esm/chunk-DEKK4CFE.js +0 -382
  36. package/node_modules/@zuplo/runtime/out/esm/chunk-DEKK4CFE.js.map +0 -1
  37. /package/node_modules/@zuplo/runtime/out/esm/{chunk-DEKK4CFE.js.LEGAL.txt → chunk-GK3X4WPN.js.LEGAL.txt} +0 -0
@@ -35,9 +35,10 @@ export declare class CompactEncrypt {
35
35
  */
36
36
  setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
37
37
  /**
38
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
39
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
40
- * parameters.
38
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
39
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
40
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
41
+ * appropriate JOSE Header.
41
42
  *
42
43
  * @param parameters JWE Key Management parameters.
43
44
  */
@@ -9,9 +9,10 @@ export declare class FlattenedEncrypt {
9
9
  */
10
10
  constructor(plaintext: Uint8Array);
11
11
  /**
12
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
13
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
14
- * parameters.
12
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
13
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
14
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
15
+ * appropriate JOSE Header.
15
16
  *
16
17
  * @param parameters JWE Key Management parameters.
17
18
  */
@@ -8,9 +8,10 @@ export interface Recipient {
8
8
  */
9
9
  setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): Recipient;
10
10
  /**
11
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
12
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
13
- * parameters.
11
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
12
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
13
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
14
+ * appropriate JOSE Header.
14
15
  *
15
16
  * @param parameters JWE Key Management parameters.
16
17
  */
@@ -23,9 +23,10 @@ export declare class EncryptJWT implements types.ProduceJWT {
23
23
  */
24
24
  setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
25
25
  /**
26
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
27
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
28
- * parameters.
26
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
27
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
28
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
29
+ * appropriate JOSE Header.
29
30
  *
30
31
  * @param parameters JWE Key Management parameters.
31
32
  */
@@ -417,11 +417,13 @@ export interface JWEKeyManagementHeaderParameters {
417
417
  * used in ECDH's ConcatKDF.
418
418
  */
419
419
  apv?: Uint8Array
420
+
420
421
  /**
421
- * @deprecated You should not use this parameter. It is only intended for testing and vector
422
- * validation purposes.
422
+ * PBES2 "p2c" (PBES2 Count). This will be used as a JOSE Header Parameter and as the PBKDF2
423
+ * iteration count.
423
424
  */
424
425
  p2c?: number
426
+
425
427
  /**
426
428
  * @deprecated You should not use this parameter. It is only intended for testing and vector
427
429
  * validation purposes.
@@ -5,7 +5,7 @@ import { generateCek } from '../../lib/content_encryption.js';
5
5
  import { encryptKeyManagement } from '../../lib/key_management.js';
6
6
  import { encode as b64u } from '../../util/base64url.js';
7
7
  import { validateCritDuplicates } from '../../lib/options.js';
8
- import { checkEncryptHeaders, encryptJWE } from '../../lib/jwe_encrypt.js';
8
+ import { checkDisjoint, checkEncryptHeaders, encryptJWE } from '../../lib/jwe_encrypt.js';
9
9
  import { prepareKey } from '../../lib/key.js';
10
10
  import { jweAlgorithm } from '../../lib/jwe_algorithms.js';
11
11
  class IndividualRecipient {
@@ -158,8 +158,12 @@ export class GeneralEncrypt {
158
158
  const k = await prepareKey(jweAlgorithm(alg), key, 'encrypt');
159
159
  const [, encryptedKey, parameters] = await encryptKeyManagement(alg, encEntry, k, cek, keyManagementParameters);
160
160
  target.encrypted_key = b64u(encryptedKey);
161
- if (unprotectedHeader || parameters)
162
- target.header = { ...unprotectedHeader, ...parameters };
161
+ if (unprotectedHeader || parameters) {
162
+ const header = { ...unprotectedHeader, ...parameters };
163
+ if (parameters)
164
+ checkDisjoint(this.#protectedHeader, header, this.#unprotectedHeader);
165
+ target.header = header;
166
+ }
163
167
  }
164
168
  return jwe;
165
169
  }
@@ -9,7 +9,7 @@ function isCloudflareWorkers() {
9
9
  let USER_AGENT;
10
10
  if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
11
11
  const NAME = 'jose';
12
- const VERSION = 'v6.2.8';
12
+ const VERSION = 'v6.2.9';
13
13
  USER_AGENT = `${NAME}/${VERSION}`;
14
14
  }
15
15
  export const customFetch = Symbol();
@@ -8,11 +8,14 @@ import { validateCrit, JWE_RECOGNIZED } from './options.js';
8
8
  import { prepareKey } from './key.js';
9
9
  import { jweAlgorithm, jweEncryption } from './jwe_algorithms.js';
10
10
  import { compress } from './deflate.js';
11
- export function checkEncryptHeaders(input) {
12
- const [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, , , , , crit] = input;
11
+ export function checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader) {
13
12
  if (!isDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader)) {
14
13
  throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');
15
14
  }
15
+ }
16
+ export function checkEncryptHeaders(input) {
17
+ const [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, , , , , crit] = input;
18
+ checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader);
16
19
  const joseHeader = {
17
20
  ...protectedHeader,
18
21
  ...unprotectedHeader,
@@ -52,6 +55,7 @@ export async function encryptJWE(input, checked, key) {
52
55
  else {
53
56
  protectedHeader = protectedHeader ? { ...protectedHeader, ...parameters } : parameters;
54
57
  }
58
+ checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader);
55
59
  }
56
60
  let protectedHeaderS;
57
61
  let protectedHeaderB;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jose",
3
- "version": "6.2.8",
3
+ "version": "6.2.9",
4
4
  "description": "JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
5
5
  "keywords": [
6
6
  "akp",
@@ -35,9 +35,10 @@ export declare class CompactEncrypt {
35
35
  */
36
36
  setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
37
37
  /**
38
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
39
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
40
- * parameters.
38
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
39
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
40
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
41
+ * appropriate JOSE Header.
41
42
  *
42
43
  * @param parameters JWE Key Management parameters.
43
44
  */
@@ -9,9 +9,10 @@ export declare class FlattenedEncrypt {
9
9
  */
10
10
  constructor(plaintext: Uint8Array);
11
11
  /**
12
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
13
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
14
- * parameters.
12
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
13
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
14
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
15
+ * appropriate JOSE Header.
15
16
  *
16
17
  * @param parameters JWE Key Management parameters.
17
18
  */
@@ -8,9 +8,10 @@ export interface Recipient {
8
8
  */
9
9
  setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): Recipient;
10
10
  /**
11
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
12
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
13
- * parameters.
11
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
12
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
13
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
14
+ * appropriate JOSE Header.
14
15
  *
15
16
  * @param parameters JWE Key Management parameters.
16
17
  */
@@ -23,9 +23,10 @@ export declare class EncryptJWT implements types.ProduceJWT {
23
23
  */
24
24
  setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
25
25
  /**
26
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
27
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
28
- * parameters.
26
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
27
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
28
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
29
+ * appropriate JOSE Header.
29
30
  *
30
31
  * @param parameters JWE Key Management parameters.
31
32
  */
@@ -417,11 +417,13 @@ export interface JWEKeyManagementHeaderParameters {
417
417
  * used in ECDH's ConcatKDF.
418
418
  */
419
419
  apv?: Uint8Array
420
+
420
421
  /**
421
- * @deprecated You should not use this parameter. It is only intended for testing and vector
422
- * validation purposes.
422
+ * PBES2 "p2c" (PBES2 Count). This will be used as a JOSE Header Parameter and as the PBKDF2
423
+ * iteration count.
423
424
  */
424
425
  p2c?: number
426
+
425
427
  /**
426
428
  * @deprecated You should not use this parameter. It is only intended for testing and vector
427
429
  * validation purposes.
@@ -5,7 +5,7 @@ import { generateCek } from '../../lib/content_encryption.js';
5
5
  import { encryptKeyManagement } from '../../lib/key_management.js';
6
6
  import { encode as b64u } from '../../util/base64url.js';
7
7
  import { validateCritDuplicates } from '../../lib/options.js';
8
- import { checkEncryptHeaders, encryptJWE } from '../../lib/jwe_encrypt.js';
8
+ import { checkDisjoint, checkEncryptHeaders, encryptJWE } from '../../lib/jwe_encrypt.js';
9
9
  import { prepareKey } from '../../lib/key.js';
10
10
  import { jweAlgorithm } from '../../lib/jwe_algorithms.js';
11
11
  class IndividualRecipient {
@@ -158,8 +158,12 @@ export class GeneralEncrypt {
158
158
  const k = await prepareKey(jweAlgorithm(alg), key, 'encrypt');
159
159
  const [, encryptedKey, parameters] = await encryptKeyManagement(alg, encEntry, k, cek, keyManagementParameters);
160
160
  target.encrypted_key = b64u(encryptedKey);
161
- if (unprotectedHeader || parameters)
162
- target.header = { ...unprotectedHeader, ...parameters };
161
+ if (unprotectedHeader || parameters) {
162
+ const header = { ...unprotectedHeader, ...parameters };
163
+ if (parameters)
164
+ checkDisjoint(this.#protectedHeader, header, this.#unprotectedHeader);
165
+ target.header = header;
166
+ }
163
167
  }
164
168
  return jwe;
165
169
  }
@@ -9,7 +9,7 @@ function isCloudflareWorkers() {
9
9
  let USER_AGENT;
10
10
  if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
11
11
  const NAME = 'jose';
12
- const VERSION = 'v6.2.8';
12
+ const VERSION = 'v6.2.9';
13
13
  USER_AGENT = `${NAME}/${VERSION}`;
14
14
  }
15
15
  export const customFetch = Symbol();
@@ -8,11 +8,14 @@ import { validateCrit, JWE_RECOGNIZED } from './options.js';
8
8
  import { prepareKey } from './key.js';
9
9
  import { jweAlgorithm, jweEncryption } from './jwe_algorithms.js';
10
10
  import { compress } from './deflate.js';
11
- export function checkEncryptHeaders(input) {
12
- const [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, , , , , crit] = input;
11
+ export function checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader) {
13
12
  if (!isDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader)) {
14
13
  throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');
15
14
  }
15
+ }
16
+ export function checkEncryptHeaders(input) {
17
+ const [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, , , , , crit] = input;
18
+ checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader);
16
19
  const joseHeader = {
17
20
  ...protectedHeader,
18
21
  ...unprotectedHeader,
@@ -52,6 +55,7 @@ export async function encryptJWE(input, checked, key) {
52
55
  else {
53
56
  protectedHeader = protectedHeader ? { ...protectedHeader, ...parameters } : parameters;
54
57
  }
58
+ checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader);
55
59
  }
56
60
  let protectedHeaderS;
57
61
  let protectedHeaderB;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jose",
3
- "version": "6.2.8",
3
+ "version": "6.2.9",
4
4
  "description": "JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
5
5
  "keywords": [
6
6
  "akp",
@@ -572,7 +572,7 @@ globstar while`,s,fe,o,ae,rt),this.matchOne(s.slice(fe),o.slice(ae),f))return th
572
572
  `),stderr:x.join(`
573
573
  `),exitCode:P},"Tar process logs")}}t(aZt,"tarFolder");async function oZt({tarFilePath:s,outputDir:o,logger:f}){let d=[],y=[],x;try{await new Promise((P,F)=>{let W=fit("sh",["-c",`tar -xvf ${s} -C ${o};`]);W.stdout.on("data",V=>{let ye=V.toString().trim();ye.length>0&&d.push(ye.trim())}),W.stderr.on("data",V=>{let ye=V.toString().trim();ye.length>0&&y.push(ye.trim())}),W.on("close",V=>{x=V,V===0?P():F(new Error(`tar process exited with code ${V}`))}),W.on("error",V=>{F(V)})})}catch(P){throw new Error("Failed to untar file",{cause:P})}finally{f.info({stdout:d.join(`
574
574
  `),stderr:y.join(`
575
- `),exitCode:x},"Untar process logs")}}t(oZt,"untarFile");async function cZt(s){if(await sAe(s))return await qN.rm(s,{recursive:!0})}t(cZt,"deleteFolder");var ru=aAe;var vlt=Pp(Fst(),1);var Lst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-fallback-model-v2","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"];var JV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,x){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Ler=/[$_\p{ID_Start}]/u,Rer=/[$_\u200C\u200D\p{ID_Continue}]/u,zAe=".*";function Mer(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(Mer,"Re");function jst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],x=t(function(P){if(!o)throw new TypeError(P);f.push({type:"INVALID_CHAR",index:d,value:s[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:s[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:s[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:s[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:s[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:s[d++]});continue}if(y===":"){let P="",F=d+1;for(;F<s.length;){let W=s.substr(F,1);if(F===d+1&&Ler.test(W)||F!==d+1&&Rer.test(W)){P+=s[F++];continue}break}if(!P){x(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:P}),d=F;continue}if(y==="("){let P=1,F="",W=d+1,V=!1;if(s[W]==="?"){x(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!Mer(s[W],!1)){x(`Invalid character '${s[W]}' at ${W}.`),V=!0;break}if(s[W]==="\\"){F+=s[W++]+s[W++];continue}if(s[W]===")"){if(P--,P===0){W++;break}}else if(s[W]==="("&&(P++,s[W+1]!=="?")){x(`Capturing groups are not allowed at ${W}`),V=!0;break}F+=s[W++]}if(V)continue;if(P){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=W;continue}f.push({type:"CHAR",index:d,value:s[d++]})}return f.push({type:"END",index:d,value:""}),f}t(jst,"v");function Bst(s,o={}){let f=jst(s);o.delimiter??="/#?",o.prefixes??="./";let d=`[^${_T(o.delimiter)}]+?`,y=[],x=0,P=0,F="",W=new Set,V=t(yn=>{if(P<f.length&&f[P].type===yn)return f[P++].value},"a"),ye=t(()=>V("OTHER_MODIFIER")??V("ASTERISK"),"f"),fe=t(yn=>{let sn=V(yn);if(sn!==void 0)return sn;let{type:In,index:xr}=f[P];throw new TypeError(`Unexpected ${In} at ${xr}, expected ${yn}`)},"d"),ae=t(()=>{let yn="",sn;for(;sn=V("CHAR")??V("ESCAPED_CHAR");)yn+=sn;return yn},"T"),rt=t(yn=>yn,"Se"),Ue=o.encodePart||rt,je="",$t=t(yn=>{je+=yn},"U"),Bt=t(()=>{je.length&&(y.push(new JV(3,"","",Ue(je),"",3)),je="")},"$"),Ir=t((yn,sn,In,xr,gr)=>{let gs=3;switch(gr){case"?":gs=1;break;case"*":gs=0;break;case"+":gs=2;break}if(!sn&&!In&&gs===3){$t(yn);return}if(Bt(),!sn&&!In){if(!yn)return;y.push(new JV(3,"","",Ue(yn),"",gs));return}let si;In?In==="*"?si=zAe:si=In:si=d;let fc=2;si===d?(fc=1,si=""):si===zAe&&(fc=0,si="");let Ci;if(sn?Ci=sn:In&&(Ci=x++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new JV(fc,Ci,Ue(yn),si,Ue(xr),gs))},"V");for(;P<f.length;){let yn=V("CHAR"),sn=V("NAME"),In=V("REGEX");if(!sn&&!In&&(In=V("ASTERISK")),sn||In){let gr=yn??"";o.prefixes.indexOf(gr)===-1&&($t(gr),gr=""),Bt();let gs=ye();Ir(gr,sn,In,"",gs);continue}let xr=yn??V("ESCAPED_CHAR");if(xr){$t(xr);continue}if(V("OPEN")){let gr=ae(),gs=V("NAME"),si=V("REGEX");!gs&&!si&&(si=V("ASTERISK"));let fc=ae();fe("CLOSE");let Ci=ye();Ir(gr,gs,si,fc,Ci);continue}Bt(),fe("END")}return y}t(Bst,"D");function _T(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(_T,"S");function Rst(s){return s&&s.ignoreCase?"ui":"u"}t(Rst,"X");function jer(s,o,f){return Ust(Bst(s,f),o,f)}t(jer,"Z");function Y9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(Y9,"k");function Ust(s,o,f={}){f.delimiter??="/#?",f.prefixes??="./",f.sensitive??=!1,f.strict??=!1,f.end??=!0,f.start??=!0,f.endsWith="";let d=f.start?"^":"";for(let F of s){if(F.type===3){F.modifier===3?d+=_T(F.value):d+=`(?:${_T(F.value)})${Y9(F.modifier)}`;continue}o&&o.push(F.name);let W=`[^${_T(f.delimiter)}]+?`,V=F.value;if(F.type===1?V=W:F.type===0&&(V=zAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${V})${Y9(F.modifier)}`:d+=`((?:${V})${Y9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${_T(F.prefix)}(${V})${_T(F.suffix)})`,d+=Y9(F.modifier);continue}d+=`(?:${_T(F.prefix)}`,d+=`((?:${V})(?:`,d+=_T(F.suffix),d+=_T(F.prefix),d+=`(?:${V}))*)${_T(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${_T(f.endsWith)}]|$`,x=`[${_T(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Rst(f));f.strict||(d+=`(?:${x}(?=${y}))?`);let P=!1;if(s.length){let F=s[s.length-1];F.type===3&&F.modifier===3&&(P=f.delimiter.indexOf(F)>-1)}return P||(d+=`(?=${x}|${y})`),new RegExp(d,Rst(f))}t(Ust,"F");var YN={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Ber={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Uer={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function zer(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(zer,"J");function zst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(zst,"Q");function $er(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t($er,"Ee");function $st(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t($st,"W");var Jst=["ftp","file","http","https","ws","wss"];function Wst(s){if(!s)return!0;for(let o of Jst)if(s.test(o))return!0;return!1}t(Wst,"N");function Jer(s,o){if(s=zst(s,"#"),o||s==="")return s;let f=new URL("https://example.com");return f.hash=s,f.hash?f.hash.substring(1,f.hash.length):""}t(Jer,"te");function Wer(s,o){if(s=zst(s,"?"),o||s==="")return s;let f=new URL("https://example.com");return f.search=s,f.search?f.search.substring(1,f.search.length):""}t(Wer,"re");function qer(s,o){return o||s===""?s:$st(s)?Hst(s):Vst(s)}t(qer,"ne");function Ver(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(Ver,"se");function Her(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(Her,"ie");function Ger(s,o,f){if(f||s==="")return s;if(o&&!Jst.includes(o))return new URL(`${o}:${s}`).pathname;let d=s[0]=="/";return s=new URL(d?s:"/-"+s,"https://example.com").pathname,d||(s=s.substring(2,s.length)),s}t(Ger,"ae");function Yer(s,o,f){return qst(o)===s&&(s=""),f||s===""?s:Gst(s)}t(Yer,"oe");function Ker(s,o){return s=$er(s,":"),o||s===""?s:$Ae(s)}t(Ker,"ce");function qst(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(qst,"_");function $Ae(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t($Ae,"y");function Xer(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(Xer,"le");function Zer(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(Zer,"fe");function Vst(s){if(s==="")return s;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(s))throw new TypeError(`Invalid hostname '${s}'`);let o=new URL("https://example.com");return o.hostname=s,o.hostname}t(Vst,"z");function Hst(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(Hst,"j");function Gst(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(Gst,"K");function Qer(s){if(s==="")return s;let o=new URL("https://example.com");return o.pathname=s[0]!=="/"?"/-"+s:s,s[0]!=="/"?o.pathname.substring(2,o.pathname.length):o.pathname}t(Qer,"he");function etr(s){return s===""?s:new URL(`data:${s}`).pathname}t(etr,"ue");function ttr(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(ttr,"de");function rtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(rtr,"pe");var ntr=class{static{t(this,"H")}#e;#r=[];#t={};#n=0;#s=1;#m=0;#c=0;#u=0;#f=0;#p=!1;constructor(s){this.#e=s}get result(){return this.#t}parse(){for(this.#r=jst(this.#e,!0);this.#n<this.#r.length;this.#n+=this.#s){if(this.#s=1,this.#r[this.#n].type==="END"){if(this.#c===0){this.#o(),this.#g()?this.#a(9,1):this.#E()?this.#a(8,1):this.#a(7,0);continue}else if(this.#c===2){this.#h(5);continue}this.#a(10,0);break}if(this.#u>0)if(this.#l())this.#u-=1;else continue;if(this.#A()){this.#u+=1;continue}switch(this.#c){case 0:this.#y()&&this.#h(1);break;case 1:if(this.#y()){this.#D();let s=7,o=1;this.#b()?(s=2,o=3):this.#p&&(s=2),this.#a(s,o)}break;case 2:this.#v()?this.#h(3):(this.#S()||this.#E()||this.#g())&&this.#h(5);break;case 3:this.#C()?this.#a(4,1):this.#v()&&this.#a(5,1);break;case 4:this.#v()&&this.#a(5,1);break;case 5:this.#O()?this.#f+=1:this.#N()&&(this.#f-=1),this.#k()&&!this.#f?this.#a(6,1):this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 6:this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 7:this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 8:this.#g()&&this.#a(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#a(s,o){switch(this.#c){case 0:break;case 1:this.#t.protocol=this.#w();break;case 2:break;case 3:this.#t.username=this.#w();break;case 4:this.#t.password=this.#w();break;case 5:this.#t.hostname=this.#w();break;case 6:this.#t.port=this.#w();break;case 7:this.#t.pathname=this.#w();break;case 8:this.#t.search=this.#w();break;case 9:this.#t.hash=this.#w();break;case 10:break}this.#c!==0&&s!==10&&([1,2,3,4].includes(this.#c)&&[6,7,8,9].includes(s)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#c)&&[8,9].includes(s)&&(this.#t.pathname??=this.#p?"/":""),[1,2,3,4,5,6,7].includes(this.#c)&&s===9&&(this.#t.search??="")),this.#i(s,o)}#i(s,o){this.#c=s,this.#m=this.#n+o,this.#n+=o,this.#s=0}#o(){this.#n=this.#m,this.#s=0}#h(s){this.#o(),this.#c=s}#d(s){return s<0&&(s=this.#r.length-s),s<this.#r.length?this.#r[s]:this.#r[this.#r.length-1]}#_(s,o){let f=this.#d(s);return f.value===o&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#y(){return this.#_(this.#n,":")}#b(){return this.#_(this.#n+1,"/")&&this.#_(this.#n+2,"/")}#v(){return this.#_(this.#n,"@")}#C(){return this.#_(this.#n,":")}#k(){return this.#_(this.#n,":")}#S(){return this.#_(this.#n,"/")}#E(){if(this.#_(this.#n,"?"))return!0;if(this.#r[this.#n].value!=="?")return!1;let s=this.#d(this.#n-1);return s.type!=="NAME"&&s.type!=="REGEX"&&s.type!=="CLOSE"&&s.type!=="ASTERISK"}#g(){return this.#_(this.#n,"#")}#A(){return this.#r[this.#n].type=="OPEN"}#l(){return this.#r[this.#n].type=="CLOSE"}#O(){return this.#_(this.#n,"[")}#N(){return this.#_(this.#n,"]")}#w(){let s=this.#r[this.#n],o=this.#d(this.#m).index;return this.#e.substring(o,s.index)}#D(){let s={};Object.assign(s,YN),s.encodePart=$Ae;let o=jer(this.#w(),void 0,s);this.#p=Wst(o)}},UAe=["protocol","username","password","hostname","port","pathname","search","hash"],GN="*";function Mst(s,o){if(typeof s!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(s,o);return{protocol:f.protocol.substring(0,f.protocol.length-1),username:f.username,password:f.password,hostname:f.hostname,port:f.port,pathname:f.pathname,search:f.search!==""?f.search.substring(1,f.search.length):void 0,hash:f.hash!==""?f.hash.substring(1,f.hash.length):void 0}}t(Mst,"ge");function UP(s,o){return o?$V(s):s}t(UP,"b");function zV(s,o,f){let d;if(typeof o.baseURL=="string")try{d=new URL(o.baseURL),o.protocol===void 0&&(s.protocol=UP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&(s.username=UP(d.username,f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&o.password===void 0&&(s.password=UP(d.password,f)),o.protocol===void 0&&o.hostname===void 0&&(s.hostname=UP(d.hostname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&(s.port=UP(d.port,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&(s.pathname=UP(d.pathname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&(s.search=UP(d.search.substring(1,d.search.length),f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&o.hash===void 0&&(s.hash=UP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${o.baseURL}'.`)}if(typeof o.protocol=="string"&&(s.protocol=Ker(o.protocol,f)),typeof o.username=="string"&&(s.username=Her(o.username,f)),typeof o.password=="string"&&(s.password=Ver(o.password,f)),typeof o.hostname=="string"&&(s.hostname=qer(o.hostname,f)),typeof o.port=="string"&&(s.port=Yer(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!zer(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=UP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=Ger(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=Wer(o.search,f)),typeof o.hash=="string"&&(s.hash=Jer(o.hash,f)),s}t(zV,"w");function $V(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t($V,"C");function itr(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(itr,"Oe");function str(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${itr(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let P=0;P<s.length;++P){let F=s[P];if(F.type===3){if(F.modifier===3){x+=$V(F.value);continue}x+=`{${$V(F.value)}}${Y9(F.modifier)}`;continue}let W=F.hasCustomName(),V=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!o.prefixes.includes(F.prefix)),ye=P>0?s[P-1]:null,fe=P<s.length-1?s[P+1]:null;if(!V&&W&&F.type===1&&F.modifier===3&&fe&&!fe.prefix.length&&!fe.suffix.length)if(fe.type===3){let ae=fe.value.length>0?fe.value[0]:"";V=y.test(ae)}else V=!fe.hasCustomName();if(!V&&!F.prefix.length&&ye&&ye.type===3){let ae=ye.value[ye.value.length-1];V=o.prefixes.includes(ae)}V&&(x+="{"),x+=$V(F.prefix),W&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?W||(x+=`(${d})`):F.type===0&&(!W&&(!ye||ye.type===3||ye.modifier!==3||V||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=$V(F.suffix),V&&(x+="}"),F.modifier!==3&&(x+=Y9(F.modifier))}return x}t(str,"ke");var Yst=class{static{t(this,"me")}#e;#r={};#t={};#n={};#s={};#m=!1;constructor(s={},o,f){try{let d;if(typeof o=="string"?d=o:f=o,typeof s=="string"){let F=new ntr(s);if(F.parse(),s=F.result,d===void 0&&typeof s.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");s.baseURL=d}else{if(!s||typeof s!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(d)throw new TypeError("parameter 1 is not of type 'string'.")}typeof f>"u"&&(f={ignoreCase:!1});let y={ignoreCase:f.ignoreCase===!0},x={pathname:GN,protocol:GN,username:GN,password:GN,hostname:GN,port:GN,search:GN,hash:GN};this.#e=zV(x,s,!0),qst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let P;for(P of UAe){if(!(P in this.#e))continue;let F={},W=this.#e[P];switch(this.#t[P]=[],P){case"protocol":Object.assign(F,YN),F.encodePart=$Ae;break;case"username":Object.assign(F,YN),F.encodePart=Xer;break;case"password":Object.assign(F,YN),F.encodePart=Zer;break;case"hostname":Object.assign(F,Ber),$st(W)?F.encodePart=Hst:F.encodePart=Vst;break;case"port":Object.assign(F,YN),F.encodePart=Gst;break;case"pathname":Wst(this.#r.protocol)?(Object.assign(F,Uer,y),F.encodePart=Qer):(Object.assign(F,YN,y),F.encodePart=etr);break;case"search":Object.assign(F,YN,y),F.encodePart=ttr;break;case"hash":Object.assign(F,YN,y),F.encodePart=rtr;break}try{this.#s[P]=Bst(W,F),this.#r[P]=Ust(this.#s[P],this.#t[P],F),this.#n[P]=str(this.#s[P],F),this.#m=this.#m||this.#s[P].some(V=>V.type===2)}catch{throw new TypeError(`invalid ${P} pattern '${this.#e[P]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return!1;try{typeof s=="object"?f=zV(f,s,!1):f=zV(f,Mst(s,o),!1)}catch{return!1}let d;for(d of UAe)if(!this.#r[d].exec(f[d]))return!1;return!0}exec(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return;try{typeof s=="object"?f=zV(f,s,!1):f=zV(f,Mst(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of UAe){let x=this.#r[y].exec(f[y]);if(!x)return null;let P={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let V=x[F+1];P[W]=V}d[y]={input:f[y]??"",groups:P}}return d}static compareComponent(s,o,f){let d=t((F,W)=>{for(let V of["type","modifier","prefix","value","suffix"]){if(F[V]<W[V])return-1;if(F[V]!==W[V])return 1}return 0},"o"),y=new JV(3,"","","","",3),x=new JV(0,"","","","",3),P=t((F,W)=>{let V=0;for(;V<Math.min(F.length,W.length);++V){let ye=d(F[V],W[V]);if(ye)return ye}return F.length===W.length?0:d(F[V]??y,W[V]??y)},"s");return!o.#n[s]&&!f.#n[s]?0:o.#n[s]&&!f.#n[s]?P(o.#s[s],[x]):!o.#n[s]&&f.#n[s]?P([x],f.#s[s]):P(o.#s[s],f.#s[s])}get protocol(){return this.#n.protocol}get username(){return this.#n.username}get password(){return this.#n.password}get hostname(){return this.#n.hostname}get port(){return this.#n.port}get pathname(){return this.#n.pathname}get search(){return this.#n.search}get hash(){return this.#n.hash}get hasRegExpGroups(){return this.#m}};globalThis.URLPattern||(globalThis.URLPattern=Yst);import{AssertionError as atr}from"node:assert";function zP(s,o){if(s===!1)throw new atr({message:o})}t(zP,"assert");var Wo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(Wo||(Wo={}));function K9(s){return s.type===Wo.Object}t(K9,"isAstObject");function $P(s){return s.type===Wo.Property}t($P,"isAstProperty");function JAe(s){return s.type===Wo.Array}t(JAe,"isAstArray");function dO(s){return s.type===Wo.Literal}t(dO,"isAstLiteral");function KN(s){if(s===void 0)throw new Error("Node is undefined");if(!K9(s))throw new Error("Node is not object")}t(KN,"assertAstObject");import{findNodeAtLocation as otr,getNodeValue as ctr,printParseErrorCode as ltr,visit as utr}from"jsonc-parser";var ftr={DEFAULT:{allowTrailingComma:!1}};function WV(s,o=[],f=ftr.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(W){d.type==="property"&&(d.length=W-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function x(W){return d.children?.push(W),W}t(x,"onValue"),utr(s,{onObjectBegin:t((W,V,ye)=>{d=x({type:"object",offset:W,length:-1,line:V+1,column:ye+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,V,ye,fe,ae)=>{d=x({type:"property",offset:V,length:-1,line:fe+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:W,offset:V,length:ye,line:fe,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((W,V)=>{y(W+V),d.length=W+V-d.offset,d=d.parent,y(W+V)},"onObjectEnd"),onArrayBegin:t((W,V,ye,fe)=>{d=x({type:"array",offset:W,length:-1,line:ye+1,column:fe+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((W,V)=>{d.length=W+V-d.offset,d=d.parent,y(W+V)},"onArrayEnd"),onLiteralValue:t((W,V,ye,fe,ae)=>{x({type:_tr(W),offset:V,length:ye,line:fe+1,column:ae+1,parent:d,value:W}),y(V+ye)},"onLiteralValue"),onSeparator:t((W,V)=>{d.type==="property"&&(W===":"?d.colonOffset=V:W===","&&y(V))},"onSeparator"),onError:t((W,V,ye,fe,ae)=>{o.push({error:W,offset:V,length:ye,line:fe+1,column:ae+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(WV,"parse");function _tr(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(_tr,"getNodeType");function WAe(s,o){return otr(s,o)}t(WAe,"findNodeAtLocation");function qV(s){return ctr(s)}t(qV,"getNodeValue");function Kst(s){return ltr(s)}t(Kst,"printParseErrorCode");var VV=class{static{t(this,"AstAdapter")}parse(o){let d=WV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:Wo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:Wo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){zP(o.children?.length===2,"Invalid property node");let d={type:Wo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:Wo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:Wo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var PS={createLiteral:t((s,o)=>({type:Wo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:Wo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:Wo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:Wo.Property,parent:f,name:null,value:o};return d.name={value:s,type:Wo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:Wo.Array,parent:o,children:[]};for(let d of s)f.children.push(PS.createLiteral(d,f));return f},"createArrayOfLiterals")};var ptr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,HV=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case Wo.Array:return this.generateArray(o,f);case Wo.Object:return this.generateObject(o,f);case Wo.Property:return this.generateProperty(o,f);case Wo.Literal:return this.generateLiteral(o,f);case Wo.FunctionCall:return this.generateFunctionCall(o,f);case Wo.Identifier:return this.generateIdentifier(o,f);case Wo.Raw:return this.generateRaw(o,f);case Wo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,x)=>{this.generateSource(o,d),y<x.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=ptr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import dtr from"node:fs/promises";import{parse as mtr}from"@swc/core";var Xst=t(async s=>{let o=new Set;try{let f=await dtr.readFile(s,"utf-8");(await mtr(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"getJSFileExports");var Zst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var qAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Qst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var VAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var HAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var clt=Pp(Zce(),1),llt=Pp(rle(),1);var nle=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new clt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,llt.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let x={details:{}},P=y.instancePath.split("/");if(P.length>2){let W=P[1],V=P[2]?parseInt(P[2],10):0,ye=P[3],fe=Number.isNaN(V)?void 0:f[W][V][ye];x={details:{property:W,index:V,field:ye,fieldValue:fe}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let W=y.instancePath.split("/"),V=W[W.length-1];y.message=`Value of property '${V}' must be '${y.params.type}'`}let F=Object.assign(y,x);d.push(F)}),d}};var aI=nle.instance;aI.addSchema(VAe,"route-configuration.schema.json");aI.addSchema(Qst,"policy-configuration.schema.json");aI.addSchema(qAe,"policies.schema.json");aI.addSchema(HAe,"open-api-route-configuration.schema.json");aI.addSchema(Zst,"fragments.schema.json");var B6r=aI.compile(VAe),ult=aI.compile(HAe),lIe=aI.compile(qAe);var ile=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=lIe(o),this.results}};var sle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=ult(o),this.results}};import Ucr from"node:path";var uIe=/\$import\((.*)\)/,EH=/\$env\((.*?)\)/g;var Bk=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},Bcr=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),VP=t((s,o)=>{if(!s)return!1;let f=Bcr(s);return o.split("/").every((x,P)=>{let F=f[P];return F?x==="*"||$P(F)&&F.name.value===x?!0:x==="{}"?F.type===Wo.Object:x==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var ale=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),K9(o)?o.children.forEach(f=>{this.visitor(f)}):JAe(o)?o.children.forEach(f=>{this.visitor(f)}):$P(o)&&this.visitor(o.value)}},flt=t(s=>{let o=new RegExp(EH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(EH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),_lt=t((s,o,f)=>d=>{if(dO(d)&&typeof d.value=="string"&&d.parent&&JAe(d.parent)){if(!s.some(P=>VP(d.parent,P))){EH.test(d.value)&&o.push(new Bk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let x=flt(d.value);if(x){let P=d.parent,F=P.children.indexOf(d);if(F!==-1)if(x.type==="raw"){let W={type:Wo.Raw,parent:P,value:x.value};P.children[F]=W}else P.children[F]=PS.createTemplateString(x.value,d)}return}if(!$P(d)||!dO(d.value)||typeof d.value.value!="string")return;if(!s.some(x=>VP(d,x))){EH.test(d.value.value)&&o.push(new Bk("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=flt(d.value.value);if(y)if(y.type==="raw"){let x={type:Wo.Raw,parent:null,value:y.value};d.value=x}else d.value=PS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var CH="config/routes.json",zcr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],$cr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","handler/{}/options/{}/onOpen/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],plt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Jcr="handler/{}/options/{}/rewritePattern",Wcr="handler/{}/options/{}/baseUrl",ole=class extends ale{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!$P(o)||!dO(o.value)||typeof o.value.value!="string")&&VP(o,Jcr)){if(!o.parent||!K9(o.parent)){this.errors.push(new Bk("Invalid node, expected object",CH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:dlt(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!$P(o)||!dO(o.value)||typeof o.value.value!="string")&&VP(o,Wcr)){if(!o.parent||!K9(o.parent)){this.errors.push(new Bk("Invalid node, expected object",CH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:dlt(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!$P(o)||!dO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!$cr.some(F=>VP(o,F))&&!plt.some(F=>VP(o,F))){if(uIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Bk("An $import() statement is not expected at this location.",CH,o.location,f))}return}let d=uIe.exec(f);if(plt.some(F=>VP(o,F))&&!d)return;if(!d){this.errors.push(new Bk("Invalid $import() statement",CH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Ucr.posix.join("..",y));let x=this.getImportName(y),P={type:Wo.Identifier,parent:o.parent,value:x};o.value=P}replaceEnvStatements=_lt(zcr,this.errors,CH)};function dlt(s){return`(request, context) => {
575
+ `),exitCode:x},"Untar process logs")}}t(oZt,"untarFile");async function cZt(s){if(await sAe(s))return await qN.rm(s,{recursive:!0})}t(cZt,"deleteFolder");var ru=aAe;var vlt=Pp(Fst(),1);var Lst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-dlp","ai-gateway-fallback-model-v2","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"];var JV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,x){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Ler=/[$_\p{ID_Start}]/u,Rer=/[$_\u200C\u200D\p{ID_Continue}]/u,zAe=".*";function Mer(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(Mer,"Re");function jst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],x=t(function(P){if(!o)throw new TypeError(P);f.push({type:"INVALID_CHAR",index:d,value:s[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:s[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:s[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:s[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:s[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:s[d++]});continue}if(y===":"){let P="",F=d+1;for(;F<s.length;){let W=s.substr(F,1);if(F===d+1&&Ler.test(W)||F!==d+1&&Rer.test(W)){P+=s[F++];continue}break}if(!P){x(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:P}),d=F;continue}if(y==="("){let P=1,F="",W=d+1,V=!1;if(s[W]==="?"){x(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!Mer(s[W],!1)){x(`Invalid character '${s[W]}' at ${W}.`),V=!0;break}if(s[W]==="\\"){F+=s[W++]+s[W++];continue}if(s[W]===")"){if(P--,P===0){W++;break}}else if(s[W]==="("&&(P++,s[W+1]!=="?")){x(`Capturing groups are not allowed at ${W}`),V=!0;break}F+=s[W++]}if(V)continue;if(P){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=W;continue}f.push({type:"CHAR",index:d,value:s[d++]})}return f.push({type:"END",index:d,value:""}),f}t(jst,"v");function Bst(s,o={}){let f=jst(s);o.delimiter??="/#?",o.prefixes??="./";let d=`[^${_T(o.delimiter)}]+?`,y=[],x=0,P=0,F="",W=new Set,V=t(yn=>{if(P<f.length&&f[P].type===yn)return f[P++].value},"a"),ye=t(()=>V("OTHER_MODIFIER")??V("ASTERISK"),"f"),fe=t(yn=>{let sn=V(yn);if(sn!==void 0)return sn;let{type:In,index:xr}=f[P];throw new TypeError(`Unexpected ${In} at ${xr}, expected ${yn}`)},"d"),ae=t(()=>{let yn="",sn;for(;sn=V("CHAR")??V("ESCAPED_CHAR");)yn+=sn;return yn},"T"),rt=t(yn=>yn,"Se"),Ue=o.encodePart||rt,je="",$t=t(yn=>{je+=yn},"U"),Bt=t(()=>{je.length&&(y.push(new JV(3,"","",Ue(je),"",3)),je="")},"$"),Ir=t((yn,sn,In,xr,gr)=>{let gs=3;switch(gr){case"?":gs=1;break;case"*":gs=0;break;case"+":gs=2;break}if(!sn&&!In&&gs===3){$t(yn);return}if(Bt(),!sn&&!In){if(!yn)return;y.push(new JV(3,"","",Ue(yn),"",gs));return}let si;In?In==="*"?si=zAe:si=In:si=d;let fc=2;si===d?(fc=1,si=""):si===zAe&&(fc=0,si="");let Ci;if(sn?Ci=sn:In&&(Ci=x++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new JV(fc,Ci,Ue(yn),si,Ue(xr),gs))},"V");for(;P<f.length;){let yn=V("CHAR"),sn=V("NAME"),In=V("REGEX");if(!sn&&!In&&(In=V("ASTERISK")),sn||In){let gr=yn??"";o.prefixes.indexOf(gr)===-1&&($t(gr),gr=""),Bt();let gs=ye();Ir(gr,sn,In,"",gs);continue}let xr=yn??V("ESCAPED_CHAR");if(xr){$t(xr);continue}if(V("OPEN")){let gr=ae(),gs=V("NAME"),si=V("REGEX");!gs&&!si&&(si=V("ASTERISK"));let fc=ae();fe("CLOSE");let Ci=ye();Ir(gr,gs,si,fc,Ci);continue}Bt(),fe("END")}return y}t(Bst,"D");function _T(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(_T,"S");function Rst(s){return s&&s.ignoreCase?"ui":"u"}t(Rst,"X");function jer(s,o,f){return Ust(Bst(s,f),o,f)}t(jer,"Z");function Y9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(Y9,"k");function Ust(s,o,f={}){f.delimiter??="/#?",f.prefixes??="./",f.sensitive??=!1,f.strict??=!1,f.end??=!0,f.start??=!0,f.endsWith="";let d=f.start?"^":"";for(let F of s){if(F.type===3){F.modifier===3?d+=_T(F.value):d+=`(?:${_T(F.value)})${Y9(F.modifier)}`;continue}o&&o.push(F.name);let W=`[^${_T(f.delimiter)}]+?`,V=F.value;if(F.type===1?V=W:F.type===0&&(V=zAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${V})${Y9(F.modifier)}`:d+=`((?:${V})${Y9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${_T(F.prefix)}(${V})${_T(F.suffix)})`,d+=Y9(F.modifier);continue}d+=`(?:${_T(F.prefix)}`,d+=`((?:${V})(?:`,d+=_T(F.suffix),d+=_T(F.prefix),d+=`(?:${V}))*)${_T(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${_T(f.endsWith)}]|$`,x=`[${_T(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Rst(f));f.strict||(d+=`(?:${x}(?=${y}))?`);let P=!1;if(s.length){let F=s[s.length-1];F.type===3&&F.modifier===3&&(P=f.delimiter.indexOf(F)>-1)}return P||(d+=`(?=${x}|${y})`),new RegExp(d,Rst(f))}t(Ust,"F");var YN={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Ber={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Uer={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function zer(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(zer,"J");function zst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(zst,"Q");function $er(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t($er,"Ee");function $st(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t($st,"W");var Jst=["ftp","file","http","https","ws","wss"];function Wst(s){if(!s)return!0;for(let o of Jst)if(s.test(o))return!0;return!1}t(Wst,"N");function Jer(s,o){if(s=zst(s,"#"),o||s==="")return s;let f=new URL("https://example.com");return f.hash=s,f.hash?f.hash.substring(1,f.hash.length):""}t(Jer,"te");function Wer(s,o){if(s=zst(s,"?"),o||s==="")return s;let f=new URL("https://example.com");return f.search=s,f.search?f.search.substring(1,f.search.length):""}t(Wer,"re");function qer(s,o){return o||s===""?s:$st(s)?Hst(s):Vst(s)}t(qer,"ne");function Ver(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(Ver,"se");function Her(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(Her,"ie");function Ger(s,o,f){if(f||s==="")return s;if(o&&!Jst.includes(o))return new URL(`${o}:${s}`).pathname;let d=s[0]=="/";return s=new URL(d?s:"/-"+s,"https://example.com").pathname,d||(s=s.substring(2,s.length)),s}t(Ger,"ae");function Yer(s,o,f){return qst(o)===s&&(s=""),f||s===""?s:Gst(s)}t(Yer,"oe");function Ker(s,o){return s=$er(s,":"),o||s===""?s:$Ae(s)}t(Ker,"ce");function qst(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(qst,"_");function $Ae(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t($Ae,"y");function Xer(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(Xer,"le");function Zer(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(Zer,"fe");function Vst(s){if(s==="")return s;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(s))throw new TypeError(`Invalid hostname '${s}'`);let o=new URL("https://example.com");return o.hostname=s,o.hostname}t(Vst,"z");function Hst(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(Hst,"j");function Gst(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(Gst,"K");function Qer(s){if(s==="")return s;let o=new URL("https://example.com");return o.pathname=s[0]!=="/"?"/-"+s:s,s[0]!=="/"?o.pathname.substring(2,o.pathname.length):o.pathname}t(Qer,"he");function etr(s){return s===""?s:new URL(`data:${s}`).pathname}t(etr,"ue");function ttr(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(ttr,"de");function rtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(rtr,"pe");var ntr=class{static{t(this,"H")}#e;#r=[];#t={};#n=0;#s=1;#m=0;#c=0;#u=0;#f=0;#p=!1;constructor(s){this.#e=s}get result(){return this.#t}parse(){for(this.#r=jst(this.#e,!0);this.#n<this.#r.length;this.#n+=this.#s){if(this.#s=1,this.#r[this.#n].type==="END"){if(this.#c===0){this.#o(),this.#g()?this.#a(9,1):this.#E()?this.#a(8,1):this.#a(7,0);continue}else if(this.#c===2){this.#h(5);continue}this.#a(10,0);break}if(this.#u>0)if(this.#l())this.#u-=1;else continue;if(this.#A()){this.#u+=1;continue}switch(this.#c){case 0:this.#y()&&this.#h(1);break;case 1:if(this.#y()){this.#D();let s=7,o=1;this.#b()?(s=2,o=3):this.#p&&(s=2),this.#a(s,o)}break;case 2:this.#v()?this.#h(3):(this.#S()||this.#E()||this.#g())&&this.#h(5);break;case 3:this.#C()?this.#a(4,1):this.#v()&&this.#a(5,1);break;case 4:this.#v()&&this.#a(5,1);break;case 5:this.#O()?this.#f+=1:this.#N()&&(this.#f-=1),this.#k()&&!this.#f?this.#a(6,1):this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 6:this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 7:this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 8:this.#g()&&this.#a(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#a(s,o){switch(this.#c){case 0:break;case 1:this.#t.protocol=this.#w();break;case 2:break;case 3:this.#t.username=this.#w();break;case 4:this.#t.password=this.#w();break;case 5:this.#t.hostname=this.#w();break;case 6:this.#t.port=this.#w();break;case 7:this.#t.pathname=this.#w();break;case 8:this.#t.search=this.#w();break;case 9:this.#t.hash=this.#w();break;case 10:break}this.#c!==0&&s!==10&&([1,2,3,4].includes(this.#c)&&[6,7,8,9].includes(s)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#c)&&[8,9].includes(s)&&(this.#t.pathname??=this.#p?"/":""),[1,2,3,4,5,6,7].includes(this.#c)&&s===9&&(this.#t.search??="")),this.#i(s,o)}#i(s,o){this.#c=s,this.#m=this.#n+o,this.#n+=o,this.#s=0}#o(){this.#n=this.#m,this.#s=0}#h(s){this.#o(),this.#c=s}#d(s){return s<0&&(s=this.#r.length-s),s<this.#r.length?this.#r[s]:this.#r[this.#r.length-1]}#_(s,o){let f=this.#d(s);return f.value===o&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#y(){return this.#_(this.#n,":")}#b(){return this.#_(this.#n+1,"/")&&this.#_(this.#n+2,"/")}#v(){return this.#_(this.#n,"@")}#C(){return this.#_(this.#n,":")}#k(){return this.#_(this.#n,":")}#S(){return this.#_(this.#n,"/")}#E(){if(this.#_(this.#n,"?"))return!0;if(this.#r[this.#n].value!=="?")return!1;let s=this.#d(this.#n-1);return s.type!=="NAME"&&s.type!=="REGEX"&&s.type!=="CLOSE"&&s.type!=="ASTERISK"}#g(){return this.#_(this.#n,"#")}#A(){return this.#r[this.#n].type=="OPEN"}#l(){return this.#r[this.#n].type=="CLOSE"}#O(){return this.#_(this.#n,"[")}#N(){return this.#_(this.#n,"]")}#w(){let s=this.#r[this.#n],o=this.#d(this.#m).index;return this.#e.substring(o,s.index)}#D(){let s={};Object.assign(s,YN),s.encodePart=$Ae;let o=jer(this.#w(),void 0,s);this.#p=Wst(o)}},UAe=["protocol","username","password","hostname","port","pathname","search","hash"],GN="*";function Mst(s,o){if(typeof s!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(s,o);return{protocol:f.protocol.substring(0,f.protocol.length-1),username:f.username,password:f.password,hostname:f.hostname,port:f.port,pathname:f.pathname,search:f.search!==""?f.search.substring(1,f.search.length):void 0,hash:f.hash!==""?f.hash.substring(1,f.hash.length):void 0}}t(Mst,"ge");function UP(s,o){return o?$V(s):s}t(UP,"b");function zV(s,o,f){let d;if(typeof o.baseURL=="string")try{d=new URL(o.baseURL),o.protocol===void 0&&(s.protocol=UP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&(s.username=UP(d.username,f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&o.password===void 0&&(s.password=UP(d.password,f)),o.protocol===void 0&&o.hostname===void 0&&(s.hostname=UP(d.hostname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&(s.port=UP(d.port,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&(s.pathname=UP(d.pathname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&(s.search=UP(d.search.substring(1,d.search.length),f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&o.hash===void 0&&(s.hash=UP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${o.baseURL}'.`)}if(typeof o.protocol=="string"&&(s.protocol=Ker(o.protocol,f)),typeof o.username=="string"&&(s.username=Her(o.username,f)),typeof o.password=="string"&&(s.password=Ver(o.password,f)),typeof o.hostname=="string"&&(s.hostname=qer(o.hostname,f)),typeof o.port=="string"&&(s.port=Yer(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!zer(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=UP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=Ger(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=Wer(o.search,f)),typeof o.hash=="string"&&(s.hash=Jer(o.hash,f)),s}t(zV,"w");function $V(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t($V,"C");function itr(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(itr,"Oe");function str(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${itr(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let P=0;P<s.length;++P){let F=s[P];if(F.type===3){if(F.modifier===3){x+=$V(F.value);continue}x+=`{${$V(F.value)}}${Y9(F.modifier)}`;continue}let W=F.hasCustomName(),V=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!o.prefixes.includes(F.prefix)),ye=P>0?s[P-1]:null,fe=P<s.length-1?s[P+1]:null;if(!V&&W&&F.type===1&&F.modifier===3&&fe&&!fe.prefix.length&&!fe.suffix.length)if(fe.type===3){let ae=fe.value.length>0?fe.value[0]:"";V=y.test(ae)}else V=!fe.hasCustomName();if(!V&&!F.prefix.length&&ye&&ye.type===3){let ae=ye.value[ye.value.length-1];V=o.prefixes.includes(ae)}V&&(x+="{"),x+=$V(F.prefix),W&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?W||(x+=`(${d})`):F.type===0&&(!W&&(!ye||ye.type===3||ye.modifier!==3||V||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=$V(F.suffix),V&&(x+="}"),F.modifier!==3&&(x+=Y9(F.modifier))}return x}t(str,"ke");var Yst=class{static{t(this,"me")}#e;#r={};#t={};#n={};#s={};#m=!1;constructor(s={},o,f){try{let d;if(typeof o=="string"?d=o:f=o,typeof s=="string"){let F=new ntr(s);if(F.parse(),s=F.result,d===void 0&&typeof s.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");s.baseURL=d}else{if(!s||typeof s!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(d)throw new TypeError("parameter 1 is not of type 'string'.")}typeof f>"u"&&(f={ignoreCase:!1});let y={ignoreCase:f.ignoreCase===!0},x={pathname:GN,protocol:GN,username:GN,password:GN,hostname:GN,port:GN,search:GN,hash:GN};this.#e=zV(x,s,!0),qst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let P;for(P of UAe){if(!(P in this.#e))continue;let F={},W=this.#e[P];switch(this.#t[P]=[],P){case"protocol":Object.assign(F,YN),F.encodePart=$Ae;break;case"username":Object.assign(F,YN),F.encodePart=Xer;break;case"password":Object.assign(F,YN),F.encodePart=Zer;break;case"hostname":Object.assign(F,Ber),$st(W)?F.encodePart=Hst:F.encodePart=Vst;break;case"port":Object.assign(F,YN),F.encodePart=Gst;break;case"pathname":Wst(this.#r.protocol)?(Object.assign(F,Uer,y),F.encodePart=Qer):(Object.assign(F,YN,y),F.encodePart=etr);break;case"search":Object.assign(F,YN,y),F.encodePart=ttr;break;case"hash":Object.assign(F,YN,y),F.encodePart=rtr;break}try{this.#s[P]=Bst(W,F),this.#r[P]=Ust(this.#s[P],this.#t[P],F),this.#n[P]=str(this.#s[P],F),this.#m=this.#m||this.#s[P].some(V=>V.type===2)}catch{throw new TypeError(`invalid ${P} pattern '${this.#e[P]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return!1;try{typeof s=="object"?f=zV(f,s,!1):f=zV(f,Mst(s,o),!1)}catch{return!1}let d;for(d of UAe)if(!this.#r[d].exec(f[d]))return!1;return!0}exec(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return;try{typeof s=="object"?f=zV(f,s,!1):f=zV(f,Mst(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of UAe){let x=this.#r[y].exec(f[y]);if(!x)return null;let P={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let V=x[F+1];P[W]=V}d[y]={input:f[y]??"",groups:P}}return d}static compareComponent(s,o,f){let d=t((F,W)=>{for(let V of["type","modifier","prefix","value","suffix"]){if(F[V]<W[V])return-1;if(F[V]!==W[V])return 1}return 0},"o"),y=new JV(3,"","","","",3),x=new JV(0,"","","","",3),P=t((F,W)=>{let V=0;for(;V<Math.min(F.length,W.length);++V){let ye=d(F[V],W[V]);if(ye)return ye}return F.length===W.length?0:d(F[V]??y,W[V]??y)},"s");return!o.#n[s]&&!f.#n[s]?0:o.#n[s]&&!f.#n[s]?P(o.#s[s],[x]):!o.#n[s]&&f.#n[s]?P([x],f.#s[s]):P(o.#s[s],f.#s[s])}get protocol(){return this.#n.protocol}get username(){return this.#n.username}get password(){return this.#n.password}get hostname(){return this.#n.hostname}get port(){return this.#n.port}get pathname(){return this.#n.pathname}get search(){return this.#n.search}get hash(){return this.#n.hash}get hasRegExpGroups(){return this.#m}};globalThis.URLPattern||(globalThis.URLPattern=Yst);import{AssertionError as atr}from"node:assert";function zP(s,o){if(s===!1)throw new atr({message:o})}t(zP,"assert");var Wo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(Wo||(Wo={}));function K9(s){return s.type===Wo.Object}t(K9,"isAstObject");function $P(s){return s.type===Wo.Property}t($P,"isAstProperty");function JAe(s){return s.type===Wo.Array}t(JAe,"isAstArray");function dO(s){return s.type===Wo.Literal}t(dO,"isAstLiteral");function KN(s){if(s===void 0)throw new Error("Node is undefined");if(!K9(s))throw new Error("Node is not object")}t(KN,"assertAstObject");import{findNodeAtLocation as otr,getNodeValue as ctr,printParseErrorCode as ltr,visit as utr}from"jsonc-parser";var ftr={DEFAULT:{allowTrailingComma:!1}};function WV(s,o=[],f=ftr.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(W){d.type==="property"&&(d.length=W-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function x(W){return d.children?.push(W),W}t(x,"onValue"),utr(s,{onObjectBegin:t((W,V,ye)=>{d=x({type:"object",offset:W,length:-1,line:V+1,column:ye+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,V,ye,fe,ae)=>{d=x({type:"property",offset:V,length:-1,line:fe+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:W,offset:V,length:ye,line:fe,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((W,V)=>{y(W+V),d.length=W+V-d.offset,d=d.parent,y(W+V)},"onObjectEnd"),onArrayBegin:t((W,V,ye,fe)=>{d=x({type:"array",offset:W,length:-1,line:ye+1,column:fe+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((W,V)=>{d.length=W+V-d.offset,d=d.parent,y(W+V)},"onArrayEnd"),onLiteralValue:t((W,V,ye,fe,ae)=>{x({type:_tr(W),offset:V,length:ye,line:fe+1,column:ae+1,parent:d,value:W}),y(V+ye)},"onLiteralValue"),onSeparator:t((W,V)=>{d.type==="property"&&(W===":"?d.colonOffset=V:W===","&&y(V))},"onSeparator"),onError:t((W,V,ye,fe,ae)=>{o.push({error:W,offset:V,length:ye,line:fe+1,column:ae+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(WV,"parse");function _tr(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(_tr,"getNodeType");function WAe(s,o){return otr(s,o)}t(WAe,"findNodeAtLocation");function qV(s){return ctr(s)}t(qV,"getNodeValue");function Kst(s){return ltr(s)}t(Kst,"printParseErrorCode");var VV=class{static{t(this,"AstAdapter")}parse(o){let d=WV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:Wo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:Wo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){zP(o.children?.length===2,"Invalid property node");let d={type:Wo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:Wo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:Wo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var PS={createLiteral:t((s,o)=>({type:Wo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:Wo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:Wo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:Wo.Property,parent:f,name:null,value:o};return d.name={value:s,type:Wo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:Wo.Array,parent:o,children:[]};for(let d of s)f.children.push(PS.createLiteral(d,f));return f},"createArrayOfLiterals")};var ptr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,HV=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case Wo.Array:return this.generateArray(o,f);case Wo.Object:return this.generateObject(o,f);case Wo.Property:return this.generateProperty(o,f);case Wo.Literal:return this.generateLiteral(o,f);case Wo.FunctionCall:return this.generateFunctionCall(o,f);case Wo.Identifier:return this.generateIdentifier(o,f);case Wo.Raw:return this.generateRaw(o,f);case Wo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,x)=>{this.generateSource(o,d),y<x.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=ptr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import dtr from"node:fs/promises";import{parse as mtr}from"@swc/core";var Xst=t(async s=>{let o=new Set;try{let f=await dtr.readFile(s,"utf-8");(await mtr(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"getJSFileExports");var Zst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var qAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Qst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var VAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var HAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var clt=Pp(Zce(),1),llt=Pp(rle(),1);var nle=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new clt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,llt.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let x={details:{}},P=y.instancePath.split("/");if(P.length>2){let W=P[1],V=P[2]?parseInt(P[2],10):0,ye=P[3],fe=Number.isNaN(V)?void 0:f[W][V][ye];x={details:{property:W,index:V,field:ye,fieldValue:fe}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let W=y.instancePath.split("/"),V=W[W.length-1];y.message=`Value of property '${V}' must be '${y.params.type}'`}let F=Object.assign(y,x);d.push(F)}),d}};var aI=nle.instance;aI.addSchema(VAe,"route-configuration.schema.json");aI.addSchema(Qst,"policy-configuration.schema.json");aI.addSchema(qAe,"policies.schema.json");aI.addSchema(HAe,"open-api-route-configuration.schema.json");aI.addSchema(Zst,"fragments.schema.json");var B6r=aI.compile(VAe),ult=aI.compile(HAe),lIe=aI.compile(qAe);var ile=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=lIe(o),this.results}};var sle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=ult(o),this.results}};import Ucr from"node:path";var uIe=/\$import\((.*)\)/,EH=/\$env\((.*?)\)/g;var Bk=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},Bcr=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),VP=t((s,o)=>{if(!s)return!1;let f=Bcr(s);return o.split("/").every((x,P)=>{let F=f[P];return F?x==="*"||$P(F)&&F.name.value===x?!0:x==="{}"?F.type===Wo.Object:x==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var ale=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),K9(o)?o.children.forEach(f=>{this.visitor(f)}):JAe(o)?o.children.forEach(f=>{this.visitor(f)}):$P(o)&&this.visitor(o.value)}},flt=t(s=>{let o=new RegExp(EH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(EH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),_lt=t((s,o,f)=>d=>{if(dO(d)&&typeof d.value=="string"&&d.parent&&JAe(d.parent)){if(!s.some(P=>VP(d.parent,P))){EH.test(d.value)&&o.push(new Bk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let x=flt(d.value);if(x){let P=d.parent,F=P.children.indexOf(d);if(F!==-1)if(x.type==="raw"){let W={type:Wo.Raw,parent:P,value:x.value};P.children[F]=W}else P.children[F]=PS.createTemplateString(x.value,d)}return}if(!$P(d)||!dO(d.value)||typeof d.value.value!="string")return;if(!s.some(x=>VP(d,x))){EH.test(d.value.value)&&o.push(new Bk("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=flt(d.value.value);if(y)if(y.type==="raw"){let x={type:Wo.Raw,parent:null,value:y.value};d.value=x}else d.value=PS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var CH="config/routes.json",zcr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],$cr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","handler/{}/options/{}/onOpen/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],plt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Jcr="handler/{}/options/{}/rewritePattern",Wcr="handler/{}/options/{}/baseUrl",ole=class extends ale{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!$P(o)||!dO(o.value)||typeof o.value.value!="string")&&VP(o,Jcr)){if(!o.parent||!K9(o.parent)){this.errors.push(new Bk("Invalid node, expected object",CH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:dlt(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!$P(o)||!dO(o.value)||typeof o.value.value!="string")&&VP(o,Wcr)){if(!o.parent||!K9(o.parent)){this.errors.push(new Bk("Invalid node, expected object",CH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:dlt(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!$P(o)||!dO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!$cr.some(F=>VP(o,F))&&!plt.some(F=>VP(o,F))){if(uIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Bk("An $import() statement is not expected at this location.",CH,o.location,f))}return}let d=uIe.exec(f);if(plt.some(F=>VP(o,F))&&!d)return;if(!d){this.errors.push(new Bk("Invalid $import() statement",CH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Ucr.posix.join("..",y));let x=this.getImportName(y),P={type:Wo.Identifier,parent:o.parent,value:x};o.value=P}replaceEnvStatements=_lt(zcr,this.errors,CH)};function dlt(s){return`(request, context) => {
576
576
  const { params, url, query, method, headers } = request;
577
577
  const { host, hostname, origin, pathname, port, search } = new URL(url);
578
578
  const e = encodeURIComponent;