@yukino.js/yukino 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{anthropic-LB4T3BEN.js → anthropic-5FTO3Q7W.js} +1 -1
- package/dist/browser/dist/static/{highlight-KNDEBJWF.js → highlight-7IMT657L.js} +9 -9
- package/dist/browser/dist/static/index.css +2 -2
- package/dist/browser/dist/static/index.js +81 -75
- package/dist/browser/dist/static/webapi-433PWHPB.js +4 -0
- package/dist/{chunk-NPIMUWFO.js → chunk-3FNHYMQD.js} +1 -1
- package/dist/{chunk-D6YQITPD.js → chunk-4UBQFHOG.js} +1 -1
- package/dist/{chunk-N7G2FDAI.js → chunk-5JFKXDO6.js} +1 -1
- package/dist/chunk-6YD572HB.js +4 -0
- package/dist/{chunk-XDERLDVW.js → chunk-7R67JSKQ.js} +1 -1
- package/dist/{chunk-FNQMXCCE.js → chunk-D5XGRVMZ.js} +1 -1
- package/dist/{chunk-WKKH2UE5.js → chunk-FOFOAOHI.js} +1 -1
- package/dist/{chunk-QYUIIFJY.js → chunk-GQKXEVHQ.js} +1 -1
- package/dist/{chunk-5D3QKHYQ.js → chunk-HNVICTWL.js} +1 -1
- package/dist/{chunk-ENUOAMFA.js → chunk-HQ6FH7CR.js} +1 -1
- package/dist/{chunk-FCZRCSNM.js → chunk-I2KB6I3D.js} +2 -2
- package/dist/chunk-KBRCX7GE.js +30 -0
- package/dist/chunk-LLPVYWAK.js +10 -0
- package/dist/{chunk-XXTMMEVY.js → chunk-TVVVY2T4.js} +173 -173
- package/dist/{chunk-6SWKDCK3.js → chunk-WXCPYSJ3.js} +1 -1
- package/dist/{chunk-57IGGFHK.js → chunk-XB5QPPSI.js} +1 -1
- package/dist/{chunk-CEP5W4VW.js → chunk-YWUBKWGK.js} +1 -1
- package/dist/{devtools-UVGRIXO2.js → devtools-BODX7K3L.js} +1 -1
- package/dist/{esm-HB7M3TZY.js → esm-4BJKCG42.js} +1 -1
- package/dist/{esm-63A57VQM.js → esm-AWTGQAUK.js} +1 -1
- package/dist/{esm-FURF4AWD.js → esm-JKMLEWEU.js} +1 -1
- package/dist/{esm-46K5BSA6.js → esm-MG7NDA4I.js} +1 -1
- package/dist/{esm-73AG4F4H.js → esm-NCNRWOJD.js} +1 -1
- package/dist/{esm-QAEO3U72.js → esm-QVP2GBDR.js} +1 -1
- package/dist/esm-ZR7DS25X.js +225 -0
- package/dist/file-type-Z4DPJWZH.js +12 -0
- package/dist/getMachineId-bsd-RSPO2LUX.js +4 -0
- package/dist/getMachineId-bsd-YMN7H6LU.js +4 -0
- package/dist/getMachineId-darwin-AOWQPOSH.js +5 -0
- package/dist/getMachineId-darwin-FEQVNOUN.js +5 -0
- package/dist/{getMachineId-win-2ZKMVYDE.js → getMachineId-win-H5SABCRW.js} +1 -1
- package/dist/{getMachineId-win-JOM5JSRW.js → getMachineId-win-RV3BPBHF.js} +1 -1
- package/dist/image-worker.js +1 -1
- package/dist/lib/{chunk-ZNDE6BQM.js → chunk-IOPSBIYR.js} +1 -1
- package/dist/lib/index.d.ts +802 -802
- package/dist/lib/index.js +19 -17
- package/dist/lib/{providers-RONNZOUT.js → providers-U3O7GOPH.js} +1 -1
- package/dist/{main-V4RKN5MY.js → main-BIBLUWZX.js} +219 -213
- package/dist/main.js +2 -2
- package/dist/{openai-UOCUBMFA.js → openai-AYEJOJTA.js} +1 -1
- package/dist/{providers-NYJNJO7D.js → providers-USI6GYZC.js} +9 -9
- package/dist/{server-XFB4HEJU.js → server-RGAJNHA4.js} +1 -1
- package/dist/{server-7QJH5UCM.js → server-XHQ7YJGI.js} +2 -2
- package/dist/{src-CHQYSTW5.js → src-E2NOTM6J.js} +1 -1
- package/dist/{src-HH6MC5CF.js → src-EBGRLYAR.js} +1 -1
- package/dist/{src-YWYPK5QA.js → src-HBBKRA75.js} +1 -1
- package/dist/src-P77FB5XW.js +12 -0
- package/dist/{turndown.es-NQ3KDXM7.js → turndown.es-E6SHSU5B.js} +13 -13
- package/package.json +2 -2
- package/dist/browser/dist/static/webapi-HZESKPJE.js +0 -4
- package/dist/chunk-5AOJ5ZSQ.js +0 -30
- package/dist/chunk-VM4YKTHC.js +0 -10
- package/dist/chunk-WKTO7XPO.js +0 -4
- package/dist/esm-6D27H27M.js +0 -225
- package/dist/file-type-PSFVPAEH.js +0 -12
- package/dist/getMachineId-bsd-2MDOCJCH.js +0 -4
- package/dist/getMachineId-bsd-L5XEQF74.js +0 -4
- package/dist/getMachineId-darwin-SMQEPEZ2.js +0 -5
- package/dist/getMachineId-darwin-V3OSZDJX.js +0 -5
- package/dist/src-P2WNZ6IY.js +0 -12
- /package/dist/{chunk-HKQWGX5S.js → chunk-UJIMMEIV.js} +0 -0
- /package/dist/{getMachineId-linux-OWR5YFVH.js → getMachineId-linux-337SESKP.js} +0 -0
- /package/dist/{getMachineId-linux-C4WJW6ZL.js → getMachineId-linux-P6HXMSZR.js} +0 -0
- /package/dist/{getMachineId-unsupported-M7AEHRA4.js → getMachineId-unsupported-52TDEFNE.js} +0 -0
- /package/dist/{getMachineId-unsupported-J7U5FNFT.js → getMachineId-unsupported-FWRH7XFO.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yukino.js/yukino",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "Yukino is a terminal-based AI coding agent. It provides an interactive UI (terminal user interface) for conversing with large language models, executing code, manipulating files, and orchestrating multi-agent workflows, all from the command line.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"a2a",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
53
53
|
"url": "https://github.com/hangtiancheng/yukino-code.git",
|
|
54
|
-
"directory": "
|
|
54
|
+
"directory": "packages/yukino"
|
|
55
55
|
},
|
|
56
56
|
"bin": {
|
|
57
57
|
"yukino": "dist/main.js"
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{b as Nr,d as E,e as u,f as P,g as k}from"./chunk-OR5FHECQ.js";var se=new TextEncoder,Ue=new TextDecoder,_e=new TextDecoder("utf-8",{fatal:!0}),At=2**32;function M(...t){let e=t.reduce((o,{length:i})=>o+i,0),r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function rr(t,e,r){if(e<0||e>=At)throw new RangeError(`value must be >= 0 and <= ${At-1}. Received ${e}`);t.set([e>>>24,e>>>16,e>>>8,e&255],r)}function nr(t){let e=Math.floor(t/At),r=t%At,n=new Uint8Array(8);return rr(n,e,0),rr(n,r,4),n}function Jt(t){let e=new Uint8Array(4);return rr(e,t),e}var Kn=/[^\x00-\x7f]/;function R(t){if(typeof t=="string"&&t.length>=128){if(Kn.test(t))throw new TypeError("non-ASCII string encountered in encode()");return se.encode(t)}let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);if(n>127)throw new TypeError("non-ASCII string encountered in encode()");e[r]=n}return e}function Kt(t,e=!1){if(Uint8Array.prototype.toBase64)return t.toBase64({alphabet:e?"base64url":"base64",omitPadding:e});let r=32768,n=[];for(let i=0;i<t.length;i+=r)n.push(String.fromCharCode.apply(null,t.subarray(i,i+r)));let o=btoa(n.join(""));return e?o.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"):o}function Ct(t,e=!1){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(t,{alphabet:e?"base64url":"base64"});if(e){if(t.includes("+")||t.includes("/"))throw new TypeError("Invalid base64url");t=t.replace(/-/g,"+").replace(/_/g,"/")}let r=atob(t),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n}async function Wt(t,e){let r=`SHA-${t.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(r,e))}var Mr={};Nr(Mr,{JOSEAlgNotAllowed:()=>ce,JOSEError:()=>H,JOSENotSupported:()=>A,JWEDecryptionFailed:()=>ee,JWEInvalid:()=>p,JWKInvalid:()=>Ce,JWKSInvalid:()=>fe,JWKSMultipleMatchingKeys:()=>Re,JWKSNoMatchingKey:()=>le,JWKSTimeout:()=>De,JWSInvalid:()=>l,JWSSignatureVerificationFailed:()=>te,JWTClaimValidationFailed:()=>G,JWTExpired:()=>Ke,JWTInvalid:()=>I});var H=class extends Error{constructor(r,n){super(r,n);E(this,"code","ERR_JOSE_GENERIC");this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};E(H,"code","ERR_JOSE_GENERIC");var G=class extends H{constructor(r,n,o="unspecified",i="unspecified"){super(r,{cause:{claim:o,reason:i,payload:n}});E(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");E(this,"claim");E(this,"reason");E(this,"payload");this.claim=o,this.reason=i,this.payload=n}};E(G,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");var Ke=class extends H{constructor(r,n,o="unspecified",i="unspecified"){super(r,{cause:{claim:o,reason:i,payload:n}});E(this,"code","ERR_JWT_EXPIRED");E(this,"claim");E(this,"reason");E(this,"payload");this.claim=o,this.reason=i,this.payload=n}};E(Ke,"code","ERR_JWT_EXPIRED");var ce=class extends H{constructor(){super(...arguments);E(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}};E(ce,"code","ERR_JOSE_ALG_NOT_ALLOWED");var A=class extends H{constructor(){super(...arguments);E(this,"code","ERR_JOSE_NOT_SUPPORTED")}};E(A,"code","ERR_JOSE_NOT_SUPPORTED");var ee=class extends H{constructor(r="decryption operation failed",n){super(r,n);E(this,"code","ERR_JWE_DECRYPTION_FAILED")}};E(ee,"code","ERR_JWE_DECRYPTION_FAILED");var p=class extends H{constructor(){super(...arguments);E(this,"code","ERR_JWE_INVALID")}};E(p,"code","ERR_JWE_INVALID");var l=class extends H{constructor(){super(...arguments);E(this,"code","ERR_JWS_INVALID")}};E(l,"code","ERR_JWS_INVALID");var I=class extends H{constructor(){super(...arguments);E(this,"code","ERR_JWT_INVALID")}};E(I,"code","ERR_JWT_INVALID");var Ce=class extends H{constructor(){super(...arguments);E(this,"code","ERR_JWK_INVALID")}};E(Ce,"code","ERR_JWK_INVALID");var fe=class extends H{constructor(){super(...arguments);E(this,"code","ERR_JWKS_INVALID")}};E(fe,"code","ERR_JWKS_INVALID");var le=class extends H{constructor(r="no applicable key found in the JSON Web Key Set",n){super(r,n);E(this,"code","ERR_JWKS_NO_MATCHING_KEY")}};E(le,"code","ERR_JWKS_NO_MATCHING_KEY");var jr,Br,Re=class extends(Br=H,jr=Symbol.asyncIterator,Br){constructor(r="multiple matching keys found in the JSON Web Key Set",n){super(r,n);E(this,jr,async function*(){});E(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}};E(Re,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");var De=class extends H{constructor(r="request timed out",n){super(r,n);E(this,"code","ERR_JWKS_TIMEOUT")}};E(De,"code","ERR_JWKS_TIMEOUT");var te=class extends H{constructor(r="signature verification failed",n){super(r,n);E(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}};E(te,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");var or={};Nr(or,{decode:()=>re,encode:()=>W});var Cn="The input to be decoded is not correctly encoded.";function re(t){try{return Ct(typeof t=="string"?t:Ue.decode(t),!0)}catch(e){throw new TypeError(Cn,{cause:e})}}function W(t){return Kt(typeof t=="string"?se.encode(t):t,!0)}function O(t,e){if(!(t instanceof Uint8Array))throw new TypeError(`${e} must be an instance of Uint8Array`)}function b(t){if(typeof t!="object"||t===null||Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);return e===null||Object.getPrototypeOf(e)===null}function Pt(t){return b(t)&&Array.isArray(t.keys)&&Array.from(t.keys).every(b)}function he(...t){let e=new Set;for(let r of t)if(r)for(let n of Object.keys(r)){if(e.has(n))return!1;e.add(n)}return!0}function K(t,e){if(t!==void 0)throw new TypeError(`${e} can only be called once`)}function N(t,e,r){try{return re(t)}catch(n){throw new r(`Failed to base64url decode the ${e}`,{cause:n})}}function It(t,e,r){try{return R(t)}catch(n){throw new r(`The ${e} is not a valid base64url string`,{cause:n})}}function we(t,e,r){let n;try{n=JSON.parse(_e.decode(re(t)))}catch(o){throw new e(r,{cause:o})}if(!b(n))throw new e(r);return n}var Ne={__proto__:null,b64:!0},Tt={__proto__:null};function ct(t,e){if(e!==void 0&&(!Array.isArray(e)||e.some(r=>typeof r!="string")))throw new TypeError(`"${t}" option must be an array of strings`);return e===void 0?void 0:new Set(e)}function kt(t,e){let{crit:r}=e??{};if(Array.isArray(r)&&new Set(r).size!==r.length)throw new t('"crit" (Critical) Header Parameter MUST NOT contain duplicate values')}function ne(t,e,r,n,o){if(o.crit!==void 0&&n?.crit===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return[];if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(a=>typeof a!="string"||a.length===0))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i=r===void 0?e:{__proto__:null,...r,...e};for(let a of n.crit){if(!(a in i))throw new A(`Extension Header Parameter "${a}" is not recognized`);if(!Object.hasOwn(o,a)||o[a]===void 0)throw new t(`Extension Header Parameter "${a}" is missing`);if(i[a]&&(!Object.hasOwn(n,a)||n[a]===void 0))throw new t(`Extension Header Parameter "${a}" MUST be integrity protected`)}return n.crit}function je(t,e){if(e.includes("b64")){let r=t.b64;if(typeof r!="boolean")throw new l('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return r}return!0}function We(t,e){let r,n;try{r=JSON.stringify(e),n=JSON.parse(r)}catch(o){throw new t("JOSE Header is not valid JSON",{cause:o})}if(!b(n))throw new t("JOSE Header is not a JSON object");return[n,r]}var Wn=t=>t[Symbol.toStringTag],Pn=(t,e,r)=>{let{alg:n}=t;if(e.use!==void 0){let o=r==="sign"||r==="verify"?"sig":"enc";if(e.use!==o)throw new TypeError(`Invalid key for this operation, its "use" must be "${o}" when present`)}if(e.alg!==void 0&&e.alg!==n)throw new TypeError(`Invalid key for this operation, its "alg" must be "${n}" when present`);if(Array.isArray(e.key_ops)){let o=r==="encrypt"||r==="decrypt"?t.ops?.[r==="encrypt"?0:1]:r;if(o&&!e.key_ops.includes(o))throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${o}" when present`)}};async function F(t,e,r){let{alg:n,secret:o}=t,i=r==="decrypt"||r==="sign";if(o&&e instanceof Uint8Array)return e;let a,s;if(b(e)){if(a=dt(e),typeof a.kty!="string")throw Lr(n,e,o);if(!(o?a.kty==="oct"&&typeof a.k=="string":a.kty!=="oct"&&(i?a.kty==="AKP"&&typeof a.priv=="string"||typeof a.d=="string":a.d===void 0&&a.priv===void 0)))throw new TypeError(o?'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present':`JSON Web Key for this operation must be a ${i?"private":"public"} JWK`);if(Pn(t,a,r),a.kty==="oct")return re(a.k);if(!Object.isFrozen(e)){let{key_ops:d}=e;Array.isArray(d)&&Object.freeze(d),Object.freeze(e)}}else{if(!ar(e))throw Lr(n,e,o);let d=o?"secret":i?"private":"public";if(e.type!==d&&(o||["secret","public","private"].includes(e.type)))throw new TypeError(`${Wn(e)} instances must be of type "${d}" for the ${n} algorithm`);if(oe(e))return e;if(s=e,s.type==="secret")return s.export()}ir||(ir=new WeakMap);let y=e,c=ir.get(y);if(c?.[n])return c[n];if(c||ir.set(y,c={}),s&&typeof s.toCryptoKey=="function"){let d=s.type==="public",m=In[s.asymmetricKeyDetails?.namedCurve],f=t.resolve?.({crv:m,asymmetricKeyType:s.asymmetricKeyType})??t.subtle;return c[n]=s.toCryptoKey(f,d,t.usages[d?0:1])}return a??(a=s.export({format:"jwk"})),a.alg=n,c[n]=await ie(t,a)}var ir,In={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"};function Ht(t){if(!oe(t))throw new Error("CryptoKey instance expected")}var oe=t=>{if(t?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return t instanceof CryptoKey}catch{return!1}},pt=t=>t?.[Symbol.toStringTag]==="KeyObject",ar=t=>oe(t)||pt(t);function $r(t,e,...r){if(r.length>2){let n=r.pop();t+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?t+=`one of type ${r[0]} or ${r[1]}.`:t+=`of type ${r[0]}.`;return e==null?t+=` Received ${e}`:typeof e=="function"&&e.name?t+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&e.constructor?.name&&(t+=` Received an instance of ${e.constructor.name}`),t}var X=(t,...e)=>$r("Key must be ",t,...e);function Lr(t,e,r){let n=["CryptoKey","KeyObject","JSON Web Key"];return r&&n.push("Uint8Array"),new TypeError($r(`Key for the ${t} algorithm must be `,e,...n))}var xt=(t,e="algorithm.name")=>new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`);function sr(t,e){if(e&&!t.usages.includes(e))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${e}.`)}function Be(t,e){let{modulusLength:r}=e.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}function cr(t,e,r){let n=t.algorithm;if(n.name!==e.name)throw xt(e.name);if(e.hash&&n.hash?.name!==e.hash)throw xt(e.hash,"algorithm.hash");if(e.namedCurve&&n.namedCurve!==e.namedCurve)throw xt(e.namedCurve,"algorithm.namedCurve");if(e.length!==void 0&&n.length!==e.length)throw xt(e.length,"algorithm.length");sr(t,r)}function Me(t){return{__proto__:null,...t}}function dt(t){let e=Me(t);if(e.ext!==void 0&&typeof e.ext!="boolean")throw new TypeError('"ext" (Extractable) Parameter must be a boolean');if(e.key_ops!==void 0){let r=e.key_ops,n=Array.isArray(r)?[...r]:void 0;if(!n||n.some(o=>typeof o!="string")||new Set(n).size!==n.length)throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');e.key_ops=n}return e}function ge(t){if(t!==void 0&&typeof t!="boolean")throw new TypeError('"extractable" option must be a boolean');return t}async function ie(t,e,r){if(!t.kty.includes(e.kty))throw new A('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');let n=t.resolve?.({kty:e.kty,crv:e.crv})??t.subtle,o=!!(e.d||e.priv),i={...e,ext:r??e.ext};return i.kty!=="AKP"&&delete i.alg,delete i.use,crypto.subtle.importKey("jwk",i,n,i.ext??!o,e.key_ops??t.usages[o?1:0])}async function q(t,e,r,n=!1){return t instanceof Uint8Array&&(t=await crypto.subtle.importKey("raw",t,e,n,[r])),cr(t,e,r),t}var Pe=t=>crypto.getRandomValues(new Uint8Array(t.cekBits>>3));function Ot(t,e){let r=t.byteLength<<3;if(r!==e)throw new p(`Invalid Content Encryption Key length. Expected ${e} bits, got ${r} bits`)}var Tn=t=>crypto.getRandomValues(new Uint8Array(t.ivBits>>3));function Vr(t,e){if(e.length<<3!==t.ivBits)throw new p("Invalid Initialization Vector length")}async function Gr(t,e,r){if(!(e instanceof Uint8Array))throw new TypeError(X(e,"Uint8Array"));let n=t.cekBits>>1,o=await crypto.subtle.importKey("raw",e.subarray(n>>3),"AES-CBC",!1,[r]),i=await crypto.subtle.importKey("raw",e.subarray(0,n>>3),{hash:`SHA-${n<<1}`,name:"HMAC"},!1,["sign"]);return[o,i,n]}async function zr(t,e,r){return new Uint8Array((await crypto.subtle.sign("HMAC",t,e)).slice(0,r>>3))}async function kn(t,e,r,n,o){let[i,a,s]=await Gr(t,r,"encrypt"),y=new Uint8Array(await crypto.subtle.encrypt({iv:n,name:"AES-CBC"},i,e)),c=nr(o.length*8),d=M(o,n,y,c),m=await zr(a,d,s);return{ciphertext:y,tag:m,iv:n}}async function xn(t,e){let r={name:"HMAC",hash:"SHA-256"},n=await crypto.subtle.generateKey(r,!1,["sign","verify"]),o=await crypto.subtle.sign(r,n,t);return crypto.subtle.verify(r,n,o,e)}async function Hn(t,e,r,n,o,i){let[a,s,y]=await Gr(t,e,"decrypt"),c=nr(i.length*8),d=M(i,n,r,c),m=await zr(s,d,y);try{if(await xn(o,m))return new Uint8Array(await crypto.subtle.decrypt({iv:n,name:"AES-CBC"},a,r))}catch{}throw new ee}async function Ut(t,e,r,n,o){if(!oe(r)&&!(r instanceof Uint8Array))throw new TypeError(X(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(n?Vr(t,n):n=Tn(t),r instanceof Uint8Array&&Ot(r,t.cekBits),t.cbc)return kn(t,e,r,n,o);let i=await q(r,t.subtle,"encrypt"),a=new Uint8Array(await crypto.subtle.encrypt({additionalData:o,iv:n,name:"AES-GCM",tagLength:128},i,e));return{ciphertext:a.subarray(0,-16),tag:a.subarray(-16),iv:n}}async function _t(t,e,r,n,o,i){if(!oe(e)&&!(e instanceof Uint8Array))throw new TypeError(X(e,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!n)throw new p("JWE Initialization Vector missing");if(!o)throw new p("JWE Authentication Tag missing");if(!t.cbc&&o.length!==16)throw new p("Invalid Authentication Tag length");if(Vr(t,n),e instanceof Uint8Array&&Ot(e,t.cekBits),t.cbc)return Hn(t,e,r,n,o,i);let a=await q(e,t.subtle,"decrypt");try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,M(r,o)))}catch{throw new ee}}function ut(t){let e={__proto__:null};for(let r in t)e[r]={...t[r],alg:r};return e}var On=[["encrypt","wrapKey"],["decrypt","unwrapKey"]],Un=[[],["deriveBits"]],Nt=[[],[]];function Rt(t){return{kty:["RSA"],mode:"key-encryption",subtle:{name:"RSA-OAEP",hash:`SHA-${t}`},usages:On,ops:["wrapKey","unwrapKey"]}}function Dt(t){return{kty:["EC","OKP"],mode:t,subtle:{name:"ECDH"},resolve:({kty:e,crv:r,asymmetricKeyType:n})=>{if(r==="X25519"||n==="x25519")return{name:"X25519"};if(e==="OKP")throw new A('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');return{name:"ECDH",namedCurve:r}},usages:Un,ops:[void 0,"deriveBits"]}}function Le(t,e=!1){return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:e?"AES-GCM":"AES-KW",length:t},usages:Nt,ops:e?["encrypt","decrypt"]:["wrapKey","unwrapKey"]}}function pr(){return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:"PBKDF2"},usages:Nt,ops:["deriveBits","deriveBits"]}}var pe=ut({dir:{kty:["oct"],mode:"direct-encryption",secret:!0,subtle:{name:"AES-GCM"},usages:Nt,ops:["encrypt","decrypt"]},"RSA-OAEP":Rt(1),"RSA-OAEP-256":Rt(256),"RSA-OAEP-384":Rt(384),"RSA-OAEP-512":Rt(512),"ECDH-ES":Dt("direct-key-agreement"),"ECDH-ES+A128KW":Dt("key-agreement-with-key-wrapping"),"ECDH-ES+A192KW":Dt("key-agreement-with-key-wrapping"),"ECDH-ES+A256KW":Dt("key-agreement-with-key-wrapping"),A128KW:Le(128),A192KW:Le(192),A256KW:Le(256),A128GCMKW:Le(128,!0),A192GCMKW:Le(192,!0),A256GCMKW:Le(256,!0),"PBES2-HS256+A128KW":pr(),"PBES2-HS384+A192KW":pr(),"PBES2-HS512+A256KW":pr()}),_n=["encrypt","decrypt"];function $e(t,e=!1){return{kty:["oct"],secret:!0,subtle:{name:e?"AES-CBC":"AES-GCM",length:t},usages:Nt,ops:_n,cekBits:t,ivBits:e?128:96,cbc:e}}var Rn=ut({A128GCM:$e(128),A192GCM:$e(192),A256GCM:$e(256),"A128CBC-HS256":$e(256,!0),"A192CBC-HS384":$e(384,!0),"A256CBC-HS512":$e(512,!0)});function Fr(t,e){throw new A(`Invalid or unsupported "${t}" (JWE ${e}) header value`)}function Y(t){return(typeof t=="string"?pe[t]:void 0)??Fr("alg","Algorithm")}function Z(t){return t.mode==="key-wrapping"||t.mode==="key-encryption"||t.mode==="key-agreement-with-key-wrapping"}function Ie(t){return(typeof t=="string"?Rn[t]:void 0)??Fr("enc","Encryption Algorithm")}function Xr(t,e){if(t.algorithm.name!=="ECDH"&&t.algorithm.name!=="X25519")throw new TypeError("CryptoKey does not support this operation, its algorithm.name must be ECDH or X25519");sr(t,e)}async function Dn(t,e,r){let n=await q(e,Y(t).subtle,"wrapKey",!0),o=await crypto.subtle.importKey("raw",r,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",o,n,"AES-KW"))}async function Nn(t,e,r){let n=await q(e,Y(t).subtle,"unwrapKey",!0),o=await crypto.subtle.unwrapKey("raw",r,n,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",o))}function Yr(t,e,r){cr(e,Y(t).subtle,r),Be(t,e)}async function Zr(t,e,r,n){if(!(t instanceof Uint8Array)||t.length<8)throw new p("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(r)||Math.sign(r)!==1)throw new p("PBES2 Count Input must be a positive integer");let o=M(R(e),Uint8Array.of(0),t),i=parseInt(e.slice(13,16),10),a={hash:`SHA-${e.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:o},s=await q(n,Y(e).subtle,"deriveBits");return new Uint8Array(await crypto.subtle.deriveBits(a,s,i))}function dr(t){return M(Jt(t.length),t)}async function jn(t,e,r){let n=e>>3,o=32,i=Math.ceil(n/o),a=new Uint8Array(i*o);for(let s=1;s<=i;s++){let y=await Wt("sha256",M(Jt(s),t,r));a.set(y,(s-1)*o)}return a.slice(0,n)}async function Qr(t,e,r,n,o=new Uint8Array,i=new Uint8Array){Xr(t),Xr(e,"deriveBits");let a=M(dr(R(r)),dr(o),dr(i),Jt(n)),s=new Uint8Array(await crypto.subtle.deriveBits({name:t.algorithm.name,public:t},e,t.algorithm.name==="X25519"?256:Math.ceil(parseInt(t.algorithm.namedCurve.slice(-3),10)/8)<<3));return jn(s,n,a)}function en(t){Ht(t);let e=t.algorithm.namedCurve;if(e!=="P-256"&&e!=="P-384"&&e!=="P-521"&&t.algorithm.name!=="X25519")throw new A("ECDH with the provided key is not allowed or not supported by your javascript runtime")}function jt(t,e){let r=t[e];if(r!==void 0){if(typeof r!="string")throw new p(`JOSE Header "${e}" (Agreement Party${e==="apu"?"U":"V"}Info) invalid`);return N(r,e,p)}}function tn(t,e){if(!(t===void 0||e===void 0||t.byteLength!==e.byteLength)){for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return;throw new p('JOSE Header "apu" and "apv" values must be distinct')}}function Bn(t){if(t===void 0)throw new p("JWE Encrypted Key missing")}function qr(t){if(t!==void 0)throw new p("Encountered unexpected JWE Encrypted Key")}function Mn(t){if(t!==void 0&&t!==1/0&&(!Number.isSafeInteger(t)||t<1))throw new TypeError("maxPBES2Count must be a positive safe integer or Infinity")}async function rn(t,e,r,n,o,i){let{alg:a}=t,s=t.mode;if(s==="direct-encryption")return qr(n),r;let y=s==="direct-key-agreement";switch(y?qr(n):Bn(n),t.subtle.name){case"ECDH":{let{epk:c}=o;if(!b(c)||["d","k","p","q","dp","dq","qi","oth","priv"].some(h=>Object.hasOwn(c,h)))throw new p('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');en(r);let d=await ie(t,c),m=jt(o,"apu"),f=jt(o,"apv");tn(m,f);let w=await Qr(d,r,y?e.alg:a,y?e.cekBits:parseInt(a.slice(-5,-2),10),m,f);if(y)return w;r=w;break}case"RSA-OAEP":return Ht(r),Yr(a,r,"decrypt"),new Uint8Array(await crypto.subtle.decrypt("RSA-OAEP",r,n));case"PBKDF2":{if(typeof o.p2c!="number")throw new p('JOSE Header "p2c" (PBES2 Count) missing or invalid');Mn(i);let c=i??1e4;if(o.p2c>c)throw new p('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if(typeof o.p2s!="string")throw new p('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let d=N(o.p2s,"p2s",p);r=await Zr(d,a,o.p2c,r);break}case"AES-GCM":{if(typeof o.iv!="string")throw new p('JOSE Header "iv" (Initialization Vector) missing or invalid');if(typeof o.tag!="string")throw new p('JOSE Header "tag" (Authentication Tag) missing or invalid');let c=N(o.iv,"iv",p),d=N(o.tag,"tag",p);if(c.byteLength!==12)throw new p("Invalid Initialization Vector length");if(d.byteLength!==16)throw new p("Invalid Authentication Tag length");return _t(Ie(a.slice(0,-2)),r,n,c,d,new Uint8Array)}}return Nn(a.slice(-6),r,n)}async function Bt(t,e,r,n,o,i={}){let{alg:a,mode:s}=t,y=Z(t);if(o!==void 0&&!y)throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${a}`);let c=await F(s==="direct-encryption"?e:t,r,"encrypt");if(s==="direct-encryption")return[c,void 0,void 0];let d=y?o??Pe(e):void 0;d&&Ot(d,e.cekBits);let m,f;switch(t.subtle.name){case"ECDH":{en(c);let{apu:w,apv:h}=i;w!==void 0&&O(w,'"apu"'),h!==void 0&&O(h,'"apv"');let J=w??jt(n,"apu"),C=h??jt(n,"apv");tn(J,C);let g;i.epk!==void 0?g=await F(t,i.epk,"decrypt"):g=(await crypto.subtle.generateKey(c.algorithm,!0,["deriveBits"])).privateKey;let v=crypto.subtle,S=g;if(!S.extractable){if(typeof v.getPublicKey!="function")throw new TypeError('CryptoKey for "epk" must be extractable');S=await v.getPublicKey(g,[])}let{x:T,y:x,crv:D,kty:j}=await v.exportKey("jwk",S),U=s==="direct-key-agreement",ae=await Qr(c,g,U?e.alg:a,U?e.cekBits:parseInt(a.slice(-5,-2),10),J,C),$={x:T,crv:D,kty:j};if(j==="EC"&&($.y=x),f={epk:$},w!==void 0&&(f.apu=W(w)),h!==void 0&&(f.apv=W(h)),U)return[ae,void 0,f];c=ae;break}case"RSA-OAEP":{Ht(c),Yr(a,c,"encrypt"),m=new Uint8Array(await crypto.subtle.encrypt("RSA-OAEP",c,d));break}case"PBKDF2":{let{p2c:w=2048,p2s:h=crypto.getRandomValues(new Uint8Array(16))}=i;c=await Zr(h,a,w,c),f={p2c:w,p2s:W(h)};break}case"AES-GCM":{let w=i.iv===void 0?crypto.getRandomValues(new Uint8Array(12)):i.iv;if(!(w instanceof Uint8Array))throw new TypeError('"iv" must be an instance of Uint8Array');let h=await Ut(Ie(a.slice(0,-2)),d,c,w,new Uint8Array);m=h.ciphertext,f={iv:W(h.iv),tag:W(h.tag)}}}if(m??(m=await Dn(a.slice(-6),c,d)),!(m instanceof Uint8Array)||!m.byteLength)throw new TypeError("JWE key management algorithm did not produce an Encrypted Key");return[d,m,f]}function Mt(t,e){if(t.zip!==void 0&&t.zip!=="DEF")throw new A('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(t.zip!==void 0&&!e?.zip)throw new p('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.')}function nn(t){if(typeof globalThis[t]>"u")throw new A(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${t} API.`)}async function on(t,e,r=1/0){let n=t.writable.getWriter();n.write(e).catch(()=>{}),n.close().catch(()=>{});let o=[],i=0,a=t.readable.getReader();for(;;){let{value:s,done:y}=await a.read();if(y)break;if(o.push(s),i+=s.byteLength,r!==1/0&&i>r)throw new p("Decompressed plaintext exceeded the configured limit")}return M(...o)}async function an(t){return nn("CompressionStream"),on(new CompressionStream("deflate-raw"),t)}async function sn(t,e){return nn("DecompressionStream"),on(new DecompressionStream("deflate-raw"),t,e)}function Lt(t){let{aad:e,ciphertext:r,iv:n,protected:o,tag:i,unprotected:a}=t;if(n!==void 0&&(typeof n!="string"||!n))throw new p("JWE Initialization Vector incorrect type");if(typeof r!="string")throw new p("JWE Ciphertext missing or incorrect type");if(i!==void 0&&(typeof i!="string"||!i))throw new p("JWE Authentication Tag incorrect type");if(o!==void 0&&typeof o!="string")throw new p("JWE Protected Header incorrect type");if(e!==void 0&&(typeof e!="string"||!e))throw new p("JWE AAD incorrect type");if(a!==void 0&&!b(a))throw new p("JWE Shared Unprotected Header incorrect type");return{aad:e,ciphertext:r,iv:n,protected:o,tag:i,unprotected:a===void 0?void 0:{...a}}}function $t(t){let e,r;try{let{header:n}=t;if(b(n)){r=n.alg;let i=Object.keys(n);i.includes("alg")||(r=void 0),e=Object.fromEntries(i.map(a=>[a,a==="alg"?r:n[a]]))}else e=n;let{encrypted_key:o}=t;return[{encrypted_key:o,header:e},r]}catch(n){return[void 0,r,n]}}function Vt(t){let{encrypted_key:e,header:r}=t;if(e!==void 0&&typeof e!="string")throw new p("JWE Encrypted Key incorrect type");if(r!==void 0&&!b(r))throw new p("JWE Per-Recipient Unprotected Header incorrect type");if(t.protected===void 0&&r===void 0&&t.unprotected===void 0)throw new p("JOSE Header missing")}function ur(t){let{protected:e,ciphertext:r,iv:n,tag:o,aad:i}=t,a;return e!==void 0&&(a=we(e,p,"JWE Protected Header is invalid")),[a,N(r,"ciphertext",p),n!==void 0?N(n,"iv",p):void 0,o!==void 0?N(o,"tag",p):void 0,It((e??"")+(i!==void 0?`.${i}`:""),"aad",p)]}function Ee(t){return[t&&ct("keyManagementAlgorithms",t.keyManagementAlgorithms),t&&ct("contentEncryptionAlgorithms",t.contentEncryptionAlgorithms),t?.crit,t?.maxPBES2Count,t?.maxDecompressedLength]}async function yt(t,e,r,n=ur(t)){let[o,i,a,s,y]=n,{header:c,unprotected:d,aad:m}=t,f;if(c!==void 0||d!==void 0){if(!he(o,c,d))throw new p("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");f={...o,...c,...d}}else f=o??{};let[w,h,J,C,g]=e,{encrypted_key:v}=t;ne(p,Tt,J,o,f),Mt(f,o);let{alg:S,enc:T}=f;if(typeof S!="string"||!S)throw new p("missing JWE Algorithm (alg) in JWE Header");let x=pe[S];if(v===""&&(!x||!Z(x)))throw new p("JWE Encrypted Key incorrect type");let D=x?.mode==="integrated-encryption";if(!D&&(typeof T!="string"||!T))throw new p("missing JWE Encryption Algorithm (enc) in JWE Header");if(w&&!w.has(S)||!w&&S.startsWith("PBES2"))throw new ce('"alg" (Algorithm) Header Parameter value not allowed');let j;if(D){if(T!==void 0)throw new p('JWE "enc" (Encryption Algorithm) Header Parameter must not be present for integrated encryption');if(a?.byteLength)throw new p("JWE Initialization Vector must be empty for integrated encryption");if(s?.byteLength)throw new p("JWE Authentication Tag must be empty for integrated encryption")}else{if(h&&!h.has(T))throw new ce('"enc" (Encryption Algorithm) Header Parameter value not allowed');j=Ie(T)}let U;if(v!==void 0)try{U=N(v,"encrypted_key",p)}catch(B){if(!x||!Z(x))throw B;U=new Uint8Array}let ae=!1;typeof r=="function"&&(r=await r(o,t),ae=!0);let $=x??Y(S);Z($)&&U===void 0&&(U=new Uint8Array);let Je=await F($.mode==="direct-encryption"?j:$,r,"decrypt"),V;if($.mode==="integrated-encryption")V=await $.decrypt(Je,U,i,y,o,f);else{let B=j,Q;try{Q=await rn($,B,Je,U,f,C),Z($)&&Q instanceof Uint8Array&&Q.byteLength<<3!==B.cekBits&&(Q=Pe(B))}catch(St){if(St instanceof TypeError||St instanceof p||St instanceof A)throw St;Q=Pe(B)}V=await _t(B,Q,i,a,s,y)}if(f.zip==="DEF"){let B=g??25e4;if(B===0)throw new A('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');if(B!==1/0&&(!Number.isSafeInteger(B)||B<1))throw new TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");V=await sn(V,B).catch(Q=>{throw Q instanceof p?Q:new p("Failed to decompress plaintext",{cause:Q})})}return{plaintext:V,...o&&{protectedHeader:o},...m!==void 0&&{additionalAuthenticatedData:N(m,"aad",p)},...d&&{sharedUnprotectedHeader:d},...c&&{unprotectedHeader:c},...ae&&{key:Je}}}async function Gt(t,e,r){if(t instanceof Uint8Array&&(t=Ue.decode(t)),typeof t!="string")throw new p("Compact JWE must be a string or Uint8Array");let{0:n,1:o,2:i,3:a,4:s,length:y}=t.split(".");if(y!==5)throw new p("Invalid Compact JWE");return yt({ciphertext:a,iv:i||void 0,protected:n,tag:s||void 0,encrypted_key:o||void 0},e,r)}async function Ln(t,e,r){return Gt(t,Ee(r),e)}async function $n(t,e,r){if(!b(t))throw new p("Flattened JWE must be an object");let n=Lt(t),[o,,i]=$t(t);if(!o)throw i;let a={...n,...o};return Vt(a),yt(a,Ee(r),e)}async function Vn(t,e,r){if(!b(t))throw new p("General JWE must be an object");let n=t.recipients;if(!Array.isArray(n))throw new p("JWE Recipients missing or incorrect type");let o=Array.from(n);if(!o.every(b))throw new p("JWE Recipients missing or incorrect type");if(!o.length)throw new p("JWE Recipients has no members");let i,a,s;try{i=Ee(r),a=Lt(t),s=ur(a)}catch{throw new ee}let y=o.map(c=>$t(c));if(o.length>1)for(let[,c]of y){let d=s[0]?.alg??c??a.unprotected?.alg,m=typeof d=="string"?pe[d]:void 0;if(m&&!Z(m))throw new p(`"${d}" alg may only have a single recipient`)}for(let[c]of y)if(c)try{let d={...a,...c};return Vt(d),await yt(d,i,e,s)}catch{}throw new ee}function zt(t,e,r){if(!he(t,e,r))throw new p("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint")}function yr(t,e,r=!1){if(!t[1]&&!t[2]&&!t[3])throw new p("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");e!==void 0&&(t[8]=e?.crit);let[,n,o,i,a,s,y,c,d]=t;if(a!==void 0&&O(a,"JWE Additional Authenticated Data"),s!==void 0&&O(s,"JWE Content Encryption Key"),y!==void 0&&O(y,"JWE Initialization Vector"),!r&&n!==void 0&&(n=We(p,n)[0],t[1]=n),o!==void 0&&(o=We(p,o)[0],t[2]=o),!r&&i!==void 0&&(i=We(p,i)[0],t[3]=i),c!==void 0&&!b(c))throw new TypeError("JWE Key Management Parameters must be an object");zt(n,o,i);let m={...n,...o,...i};kt(p,n),ne(p,Tt,d,n,m),Mt(m,n);let{alg:f,enc:w}=m;if(typeof f!="string"||!f)throw new p('JWE "alg" (Algorithm) Header Parameter missing or invalid');let h=pe[f];if(h?.mode==="integrated-encryption"){if(w!==void 0)throw new p('JWE "enc" (Encryption Algorithm) Header Parameter must not be present for integrated encryption');if(s!==void 0)throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${f}`);if(y!==void 0)throw new TypeError(`setInitializationVector cannot be called with JWE "alg" (Algorithm) Header ${f}`);return[m,void 0,h]}if(typeof w!="string"||!w)throw new p('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');return[m,Ie(w),h]}async function mr(t,e,r){let[n,o,i]=e,[a,s,y,c,d,m,f,w,,h]=t,J=s,C=y,g=i??Y(n.alg),v,S,T;g.mode==="integrated-encryption"?T=await F(g,r,"encrypt"):[T,v,S]=await Bt(g,o,r,n,m,w),S&&(h?C=C?{...C,...S}:S:J=J?{...J,...S}:S,zt(J,C,c));let x=J?W(JSON.stringify(J)):"",D=d?.byteLength?W(d):void 0,j=R(D?`${x}.${D}`:x),U=a;n.zip==="DEF"&&(U=await an(U).catch(B=>{throw new p("Failed to compress plaintext",{cause:B})}));let ae,$,Je;g.mode==="integrated-encryption"?[v,ae]=await g.encrypt(T,U,j,J,n,w):{ciphertext:ae,tag:$,iv:Je}=await Ut(o,U,T,f,j);let V={ciphertext:W(ae)};return Je&&(V.iv=W(Je)),$&&(V.tag=W($)),v?.byteLength&&(V.encrypted_key=W(v)),D&&(V.aad=D),J&&(V.protected=x),c&&(V.unprotected=c),C&&(V.header=C),V}async function Ve(t,e,r){return mr(t,yr(t,r),e)}function Ft(t){return[t.protected,t.encrypted_key,t.iv,t.ciphertext,t.tag].join(".")}var Te,fr=class{constructor(e,r,n){P(this,Te);E(this,"state");k(this,Te,e),this.state=[void 0,void 0,r,n]}setUnprotectedHeader(e){return K(this.state[0],"setUnprotectedHeader"),this.state[0]=e,this}setKeyManagementParameters(e){return K(this.state[1],"setKeyManagementParameters"),this.state[1]=e,this}addRecipient(...e){return u(this,Te).addRecipient(...e)}encrypt(...e){return u(this,Te).encrypt(...e)}done(){return u(this,Te)}};Te=new WeakMap;var Ge,ke,ze,Fe,mt,lr=class{constructor(e){P(this,Ge);P(this,ke,[]);P(this,ze);P(this,Fe);P(this,mt);k(this,Ge,e)}addRecipient(e,r){let n=new fr(this,e,r?.crit);return u(this,ke).push(n),n}setProtectedHeader(e){return K(u(this,ze),"setProtectedHeader"),k(this,ze,e),this}setSharedUnprotectedHeader(e){return K(u(this,Fe),"setSharedUnprotectedHeader"),k(this,Fe,e),this}setAdditionalAuthenticatedData(e){return k(this,mt,e),this}async encrypt(){if(!u(this,ke).length)throw new p("at least one recipient must be added");O(u(this,Ge),"plaintext");let e=u(this,ke).length>1,r,n=u(this,ze),o=u(this,Fe),i=[];for(let h of u(this,ke)){let[J,C,g,v]=h.state,S=[u(this,Ge),n,J,o,u(this,mt),void 0,void 0,C,v,e],T=yr(S,void 0,i.length>0);i.length||(n=S[1],o=S[3]),i.push([S,T,g]);let[{alg:x,enc:D},,j]=T;if(e&&j&&!Z(j))throw new p(`"${x}" alg may only have a single recipient`);if(!r)r=D;else if(r!==D)throw new p('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}for(let[,h]of i)h[2]??(h[2]=Y(h[0].alg));let[a,s,y]=i[0],c=e?Pe(s[1]):void 0;a[5]=c;let{encrypted_key:d,header:m,...f}=await mr(a,s,y),w={...f,recipients:[{}]};d&&(w.recipients[0].encrypted_key=d),m&&(w.recipients[0].header=m);for(let h=1;h<i.length;h++){let[J,[C,g,v],S]=i[h],T=J[2],[,x,D]=await Bt(v,g,S,C,c,J[7]),j={encrypted_key:W(x)};if(T||D){let U={...T,...D};D&&zt(J[1],U,J[3]),j.header=U}w.recipients.push(j)}return w}};Ge=new WeakMap,ke=new WeakMap,ze=new WeakMap,Fe=new WeakMap,mt=new WeakMap;var ft=[["verify"],["sign"]];function hr(t){let e={name:"HMAC",hash:`SHA-${t}`};return{kty:["oct"],secret:!0,subtle:e,signing:e,usages:ft}}function Xe(t,e){let r={name:e?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:`SHA-${t}`};return{kty:["RSA"],subtle:r,signing:e?{...r,saltLength:e}:r,usages:ft,minRsaBits:2048}}function wr(t,e){return{kty:["EC"],crv:t,subtle:{name:"ECDSA",namedCurve:t},signing:{name:"ECDSA",hash:`SHA-${e}`},usages:ft}}function cn(){let t={name:"Ed25519"};return{kty:["OKP"],crv:"Ed25519",subtle:t,signing:t,usages:ft}}function gr(t){let e={name:`ML-DSA-${t}`};return{kty:["AKP"],subtle:e,signing:e,usages:ft}}var lt=ut({HS256:hr(256),HS384:hr(384),HS512:hr(512),RS256:Xe(256),RS384:Xe(384),RS512:Xe(512),PS256:Xe(256,32),PS384:Xe(384,48),PS512:Xe(512,64),ES256:wr("P-256",256),ES384:wr("P-384",384),ES512:wr("P-521",512),EdDSA:cn(),Ed25519:cn(),"ML-DSA-44":gr(44),"ML-DSA-65":gr(65),"ML-DSA-87":gr(87)});function qe(t){let e=typeof t=="string"?lt[t]:void 0;if(!e)throw new A(`alg ${t} is not supported either by JOSE or your javascript runtime`);return e}function Xt(t,e){let r=t.protected,n=t.header,o=b(n)?{...n}:n,i=e?e[0]:t.payload;!e&&i instanceof Uint8Array&&(i=new Uint8Array(i));let a=t.signature,s={payload:i,signature:a};if(r!==void 0&&(s.protected=r),n!==void 0&&(s.header=o),r===void 0&&o===void 0)throw new l('Flattened JWS must have either of the "protected" or "header" members');if(r!==void 0&&typeof r!="string")throw new l("JWS Protected Header incorrect type");if(i===void 0)throw new l("JWS Payload missing");if(typeof a!="string")throw new l("JWS Signature missing or incorrect type");if(o!==void 0&&!b(o))throw new l("JWS Unprotected Header incorrect type");return s}function be(t){return[t&&ct("algorithms",t.algorithms),t?.crit]}function Er(t){return t===void 0?{}:we(t,l,"JWS Protected Header is invalid")}function qt(t){let e=/[\p{Cs}\p{Cn}]/u.exec(t)?.[0];if(e!==void 0)throw new l(/\p{Cs}/u.test(e)?"JWS Payload must be a well-formed Unicode string":"JWS Payload must not contain unassigned Unicode code points");return se.encode(t)}function Gn(t){try{return R(t)}catch(e){throw new l("JWS Compact Serialization payload must use only ASCII characters",{cause:e})}}async function ht(t,e,r,n,o){let{protected:i,header:a,payload:s}=t,y=o??Er(i);if(!he(y,a))throw new l("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let c={...y,...a},d=je(y,ne(l,Ne,e[1],y,c)),{alg:m}=c;if(typeof m!="string"||!m)throw new l('JWS "alg" (Algorithm) Header Parameter missing or invalid');if(e[0]&&!e[0].has(m))throw new ce('"alg" (Algorithm) Header Parameter value not allowed');if(d){if(typeof s!="string")throw new l("JWS Payload must be a string")}else if(typeof s!="string"&&!(s instanceof Uint8Array))throw new l("JWS Payload must be a string or an Uint8Array instance");let f=d||typeof s!="string"?s:n(s),w=!1;typeof r=="function"&&(r=await r(y,t),w=!0);let h=qe(m),J=M(i!==void 0?R(i):new Uint8Array,R("."),typeof f=="string"?e[2]??(e[2]=It(f,"payload",l)):f),C=N(t.signature,"signature",l),g=await F(h,r,"verify"),v=await q(g,h.subtle,"verify");h.minRsaBits&&Be(h.alg,v);let S=!1;try{S=await crypto.subtle.verify(h.signing,v,C,J)}catch(x){throw new te(void 0,{cause:x})}if(!S)throw new te;let T={payload:typeof f=="string"?N(f,"payload",l):f};return i!==void 0&&(T.protectedHeader=y),a!==void 0&&(T.unprotectedHeader=a),w?[{...T,key:g},d]:[T,d]}async function Yt(t,e,r){if(t instanceof Uint8Array&&(t=Ue.decode(t)),typeof t!="string")throw new l("Compact JWS must be a string or Uint8Array");let{0:n,1:o,2:i,length:a}=t.split(".");if(a!==3)throw new l("Invalid Compact JWS");return ht({payload:o,protected:n,signature:i},e,r,Gn)}async function zn(t,e,r){let[n]=await Yt(t,be(r),e);return n}async function Fn(t,e,r){if(!b(t))throw new l("Flattened JWS must be an object");let n=Xt(t),[o]=await ht(n,be(r),e,qt);return o}function Xn(t,e){try{let r=Xt(t,[e]),n=Er(r.protected),{b64:o,crit:i}=n;return[r,n,Array.isArray(i)&&i.includes("b64")?typeof o=="boolean"?o?1:2:0:1]}catch{return}}async function qn(t,e,r){if(!b(t))throw new l("General JWS must be an object");let{signatures:n,payload:o}=t;if(!Array.isArray(n))throw new l("JWS Signatures missing or incorrect type");let i=Array.from(n);if(!i.every(b))throw new l("JWS Signatures missing or incorrect type");let a;try{if(o===void 0)throw new Error;a=be(r)}catch{throw new te}let s=o instanceof Uint8Array?new Uint8Array(o):o,y=i.map(d=>Xn(d,s)).filter(d=>d!==void 0),c=0;for(let[,,d]of y)if(c|=d,c===3)throw new l("inconsistent use of JWS Unencoded Payload (RFC7797)");for(let d of y)try{let[m]=await ht(d[0],a,e,qt,d[1]);return m}catch{}throw new te}var wt=t=>Math.floor(t.getTime()/1e3),Yn={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},Zn=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Ye="check_failed";function br(){throw new TypeError("Invalid time period format")}function Zt(t){typeof t!="string"&&br();let e=Zn.exec(t);(!e||e[4]&&e[1])&&br();let r=parseFloat(e[2]),n=Math.round(r*Yn[e[3][0].toLowerCase()]);return Number.isFinite(n)||br(),e[1]==="-"||e[4]==="ago"?-n:n}function Ze(t,e){if(!Number.isFinite(e))throw new TypeError(`Invalid ${t} input`);return e}function vr(t,e){if(typeof e!="string")throw new TypeError(`"${t}" claim must be a string`)}function Qn(t){if(typeof t!="string"&&(!Array.isArray(t)||Array.from(t).some(e=>typeof e!="string")))throw new TypeError('"aud" claim must be a string or an array of strings')}function Sr(t,e){return typeof t=="number"?Ze(e,t):t instanceof Date?Ze(e,wt(t)):wt(new Date)+Zt(t)}var pn=t=>{let e=t.toLowerCase();return t.includes("/")?e:`application/${e}`},eo=(t,e)=>typeof t=="string"?e.includes(t):Array.isArray(t)?e.some(r=>t.includes(r)):!1;function Ar(t,e,r=!1){let n=t[e];if(!(n===void 0&&!r)){if(typeof n!="number")throw new G(`"${e}" claim must be a number`,t,e,"invalid");return n}}function Jr(t,e){throw new G(`unexpected "${e}" claim value`,t,e,Ye)}function Qe(t,e,r={}){let n;try{n=JSON.parse(_e.decode(e))}catch(v){throw new I("JWT Claims Set must be a top-level JSON object",{cause:v})}if(!b(n))throw new I("JWT Claims Set must be a top-level JSON object");let{typ:o}=r;if(o!==void 0&&(typeof t.typ!="string"||pn(t.typ)!==pn(o)))throw new G('unexpected "typ" JWT header value',n,"typ",Ye);let{requiredClaims:i=[],issuer:a,subject:s,audience:y,maxTokenAge:c}=r,d=[...i];c!==void 0&&d.push("iat"),y!==void 0&&d.push("aud"),s!==void 0&&d.push("sub"),a!==void 0&&d.push("iss");for(let v of new Set(d.reverse()))if(!Object.hasOwn(n,v))throw new G(`missing required "${v}" claim`,n,v,"missing");a!==void 0&&!(Array.isArray(a)?a:[a]).includes(n.iss)&&Jr(n,"iss"),s!==void 0&&n.sub!==s&&Jr(n,"sub"),y!==void 0&&!eo(n.aud,typeof y=="string"?[y]:y)&&Jr(n,"aud");let{clockTolerance:m}=r,f=0;if(typeof m=="string")f=Zt(m);else if(m!==void 0){if(typeof m!="number")throw new TypeError("Invalid clockTolerance option type");f=m}Ze("clockTolerance option",f);let{currentDate:w}=r,h=Ze("currentDate option",wt(w===void 0?new Date:w)),J=Ar(n,"iat",c!==void 0),C=Ar(n,"nbf");if(C!==void 0&&C>h+f)throw new G('"nbf" claim timestamp check failed',n,"nbf",Ye);let g=Ar(n,"exp");if(g!==void 0&&g<=h-f)throw new Ke('"exp" claim timestamp check failed',n,"exp",Ye);if(c!==void 0){let v=h-J,S=Ze("maxTokenAge option",typeof c=="number"?c:Zt(c));if(v-f>S)throw new Ke('"iat" claim timestamp check failed (too far in the past)',n,"iat",Ye);if(v<-f)throw new G('"iat" claim timestamp check failed (it should be in the past)',n,"iat",Ye)}return n}var dn;function de(t){return dn.get(t)}function et(t){let e=de(t);for(let r of["iat","nbf","exp"]){let n=e[r];if(typeof n=="number"&&!Number.isFinite(n))throw new TypeError(`"${r}" claim must be a finite number`)}return se.encode(JSON.stringify(e))}function Qt(t,e){return de(t)[e]}var ve=class{constructor(e={}){if(!b(e))throw new TypeError("JWT Claims Set MUST be an object");(dn||(dn=new WeakMap)).set(this,structuredClone(e))}setIssuer(e){return vr("iss",e),de(this).iss=e,this}setSubject(e){return vr("sub",e),de(this).sub=e,this}setAudience(e){return Qn(e),de(this).aud=e,this}setJti(e){return vr("jti",e),de(this).jti=e,this}setNotBefore(e){return de(this).nbf=Sr(e,"setNotBefore"),this}setExpirationTime(e){return de(this).exp=Sr(e,"setExpirationTime"),this}setIssuedAt(e){let r=de(this);return e===void 0?r.iat=wt(new Date):typeof e=="string"?r.iat=Ze("setIssuedAt",wt(new Date)+Zt(e)):r.iat=Sr(e,"setIssuedAt"),this}};async function to(t,e,r){let[n,o]=await Yt(t,be(r),e);if(!o)throw new I("JWTs MUST NOT use unencoded payload");let i=Qe(n.protectedHeader,n.payload,r);return{...n,payload:i}}async function ro(t,e,r){let{plaintext:n,...o}=await Gt(t,Ee(r),e),{protectedHeader:i}=o,a=Qe(i,n,r);for(let s of["iss","sub","aud"])if(i[s]!==void 0&&(s==="aud"?JSON.stringify(i.aud)!==JSON.stringify(a.aud):i[s]!==a[s]))throw new G(`replicated "${s}" claim header parameter mismatch`,a,s,"mismatch");return{payload:a,...o}}var z,Kr=class{constructor(e){P(this,z);O(e,"plaintext"),k(this,z,[e])}setContentEncryptionKey(e){return K(u(this,z)[5],"setContentEncryptionKey"),u(this,z)[5]=e,this}setInitializationVector(e){return K(u(this,z)[6],"setInitializationVector"),u(this,z)[6]=e,this}setProtectedHeader(e){return K(u(this,z)[1],"setProtectedHeader"),u(this,z)[1]=e,this}setKeyManagementParameters(e){return K(u(this,z)[7],"setKeyManagementParameters"),u(this,z)[7]=e,this}async encrypt(e,r){return Ft(await Ve([...u(this,z)],e,r))}};z=new WeakMap;var _,Cr=class{constructor(e){P(this,_);O(e,"plaintext"),k(this,_,[e])}setKeyManagementParameters(e){return K(u(this,_)[7],"setKeyManagementParameters"),u(this,_)[7]=e,this}setProtectedHeader(e){return K(u(this,_)[1],"setProtectedHeader"),u(this,_)[1]=e,this}setSharedUnprotectedHeader(e){return K(u(this,_)[3],"setSharedUnprotectedHeader"),u(this,_)[3]=e,this}setUnprotectedHeader(e){return K(u(this,_)[2],"setUnprotectedHeader"),u(this,_)[2]=e,this}setAdditionalAuthenticatedData(e){return u(this,_)[4]=e,this}setContentEncryptionKey(e){return K(u(this,_)[5],"setContentEncryptionKey"),u(this,_)[5]=e,this}setInitializationVector(e){return K(u(this,_)[6],"setInitializationVector"),u(this,_)[6]=e,this}async encrypt(e,r){return Ve([...u(this,_)],e,r)}};_=new WeakMap;async function gt(t,e,r){let[n,o,i,a]=t,s="";if(o!==void 0){let g=We(l,o);o=g[0],s=W(g[1])}if(i!==void 0&&(i=We(l,i)[0]),!o&&!i)throw new l("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!he(o,i))throw new l("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let y={...o,...i};kt(l,o);let c=je(o,ne(l,Ne,a,o,y));c||r?.();let{alg:d}=y;if(typeof d!="string"||!d)throw new l('JWS "alg" (Algorithm) Header Parameter missing or invalid');let m=qe(d),f="",w=n,h;if(c){let g=t[4];g?(f=g[0]??(g[0]=W(n)),w=g[1]??(g[1]=R(f))):(f=W(n),h=se.encode(`${s}.${f}`))}h??(h=M(R(s),R("."),w));let J=await q(await F(m,e,"sign"),m.subtle,"sign");m.minRsaBits&&Be(m.alg,J);let C={signature:W(new Uint8Array(await crypto.subtle.sign(m.signing,J,h))),payload:f};return o&&(C.protected=s),i&&(C.header=i),[C,c]}async function er(t,e,r,n,o){let[i]=await gt([t,e,void 0,r],n,o);return`${i.protected}.${i.payload}.${i.signature}`}var Et,tt,Wr=class{constructor(e){P(this,Et);P(this,tt);O(e,"payload"),k(this,Et,e)}setProtectedHeader(e){return K(u(this,tt),"setProtectedHeader"),k(this,tt,e),this}async sign(e,r){return er(u(this,Et),u(this,tt),r?.crit,e,()=>{throw new TypeError("use the flattened module for creating JWS with b64: false")})}};Et=new WeakMap,tt=new WeakMap;var ue,Pr=class{constructor(e){P(this,ue);O(e,"payload"),k(this,ue,[e])}setProtectedHeader(e){return K(u(this,ue)[1],"setProtectedHeader"),u(this,ue)[1]=e,this}setUnprotectedHeader(e){return K(u(this,ue)[2],"setUnprotectedHeader"),u(this,ue)[2]=e,this}async sign(e,r){let n=[...u(this,ue)];n[3]=r?.crit;let[o]=await gt(n,e);return o}};ue=new WeakMap;var xe,Ir=class{constructor(e,r,n){P(this,xe);E(this,"state");k(this,xe,e),this.state=[void 0,void 0,r,n?.crit]}setProtectedHeader(e){return K(this.state[0],"setProtectedHeader"),this.state[0]=e,this}setUnprotectedHeader(e){return K(this.state[1],"setUnprotectedHeader"),this.state[1]=e,this}addSignature(...e){return u(this,xe).addSignature(...e)}sign(...e){return u(this,xe).sign(...e)}done(){return u(this,xe)}};xe=new WeakMap;var rt,nt,Tr=class{constructor(e){P(this,rt);P(this,nt,[]);k(this,rt,e)}addSignature(e,r){let n=new Ir(this,e,r);return u(this,nt).push(n),n}async sign(){if(!u(this,nt).length)throw new l("at least one signature must be added");O(u(this,rt),"payload");let e={signatures:[],payload:""},r=[],n;for(let o of u(this,nt)){let[i,a,s,y]=o.state,[{payload:c,...d},m]=await gt([u(this,rt),i,a,y,r],s);if(n===void 0)n=m,e.payload=c;else if(n!==m)throw new l("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(d)}return e}};rt=new WeakMap,nt=new WeakMap;var no=ve,ot,kr=class extends no{constructor(){super(...arguments);P(this,ot)}setProtectedHeader(r){return K(u(this,ot),"setProtectedHeader"),k(this,ot,r),this}async sign(r,n){return er(et(this),u(this,ot),n?.crit,r,()=>{throw new I("JWTs MUST NOT use unencoded payload")})}};ot=new WeakMap;var oo=ve,L,it,at,st,xr=class extends oo{constructor(){super(...arguments);P(this,L,[void 0]);P(this,it);P(this,at);P(this,st)}setProtectedHeader(r){return K(u(this,L)[1],"setProtectedHeader"),u(this,L)[1]=r,this}setKeyManagementParameters(r){return K(u(this,L)[7],"setKeyManagementParameters"),u(this,L)[7]=r,this}setContentEncryptionKey(r){return K(u(this,L)[5],"setContentEncryptionKey"),u(this,L)[5]=r,this}setInitializationVector(r){return K(u(this,L)[6],"setInitializationVector"),u(this,L)[6]=r,this}replicateIssuerAsHeader(){return k(this,it,!0),this}replicateSubjectAsHeader(){return k(this,at,!0),this}replicateAudienceAsHeader(){return k(this,st,!0),this}async encrypt(r,n){let o=et(this);u(this,L)[1]&&(u(this,it)||u(this,at)||u(this,st))&&(u(this,L)[1]={...u(this,L)[1],iss:u(this,it)?Qt(this,"iss"):void 0,sub:u(this,at)?Qt(this,"sub"):void 0,aud:u(this,st)?Qt(this,"aud"):void 0});let i=[...u(this,L)];return i[0]=o,Ft(await Ve(i,r,n))}};L=new WeakMap,it=new WeakMap,at=new WeakMap,st=new WeakMap;var Se='"alg" (Algorithm)';function He(t='JWK "alg" (Algorithm) Parameter'){throw new A(`Invalid or unsupported ${t} value`)}function Oe(t,e){return(typeof t=="string"?lt[t]??pe[t]:void 0)??He(e)}var io=(t,e)=>{let r=(t.match(/.{1,64}/g)||[]).join(`
|
|
2
|
-
`);return`-----BEGIN ${e}-----
|
|
3
|
-
${r}
|
|
4
|
-
-----END ${e}-----`},yn=async(t,e,r)=>{if(pt(r)){if(r.type!==t)throw new TypeError(`key is not a ${t} key`);return r.export({format:"pem",type:e})}if(!oe(r))throw new TypeError(X(r,"CryptoKey","KeyObject"));if(!r.extractable)throw new TypeError("CryptoKey is not extractable");if(r.type!==t)throw new TypeError(`key is not a ${t} key`);return io(Kt(new Uint8Array(await crypto.subtle.exportKey(e,r))),`${t.toUpperCase()} KEY`)},mn=t=>yn("public","spki",t),fn=t=>yn("private","pkcs8",t),bt=(t,e)=>{if(t.byteLength!==e.length)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},ln=t=>({data:t,pos:0}),Hr=t=>{let e=t.data[t.pos++];if(e===void 0)throw new Error("Unexpected end of ASN.1 input");return e},ye=t=>{let e=Hr(t);if(e&128){let r=e&127,n=0;for(let o=0;o<r;o++)n=n<<8|Hr(t);return n}return e},un=(t,e=1)=>{for(;e-- >0;){t.pos++;let r=ye(t);t.pos+=r}},Ae=(t,e,r)=>{if(Hr(t)!==e)throw new Error(r)},hn=(t,e)=>{if(e<0||t.pos+e>t.data.length)throw new Error("Unexpected end of ASN.1 input");let r=t.data.subarray(t.pos,t.pos+e);return t.pos+=e,r},ao=t=>{Ae(t,6,"Expected algorithm OID");let e=ye(t);return hn(t,e)};function so(t,e){if(Ae(t,48,`Invalid ${e==="spki"?"SPKI":"PKCS#8"} structure`),ye(t),e==="pkcs8"){Ae(t,2,"Expected version field");let r=ye(t);t.pos+=r}Ae(t,48,"Expected algorithm identifier"),ye(t)}var co=t=>{let e=ao(t);if(bt(e,[43,101,110]))return"X25519";if(!bt(e,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");Ae(t,6,"Expected curve OID");let r=ye(t),n=hn(t,r);if(bt(n,[42,134,72,206,61,3,1,7]))return"P-256";if(bt(n,[43,129,4,0,34]))return"P-384";if(bt(n,[43,129,4,0,35]))return"P-521";throw new Error("Unsupported named curve")},Or=async(t,e,r,n)=>{let o=ge(n?.extractable),i=Oe(r,Se);i.secret&&He(Se);let a=t==="spki",s;if(i.resolve)try{let y=ln(e);so(y,t),s=i.resolve({crv:co(y)})}catch(y){throw new A("Invalid or unsupported key format",{cause:y})}else s=i.subtle;return crypto.subtle.importKey(t,e,s,o??a,i.usages[a?0:1])},Ur=(t,e)=>Ct(t.replace(e,"")),wn=(t,e,r)=>{let n=Ur(t,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);return Or("pkcs8",n,e,r)},gn=(t,e,r)=>{let n=Ur(t,/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g);return Or("spki",n,e,r)};function po(t){let e=ln(t);Ae(e,48,"Invalid certificate structure");let r=ye(e);if(r<0||e.pos+r>e.data.length)throw new Error("Unexpected end of ASN.1 input");Ae(e,48,"Invalid tbsCertificate structure"),ye(e),t[e.pos]===160?un(e,6):un(e,5);let n=e.pos;Ae(e,48,"Invalid SPKI structure");let o=ye(e);return t.subarray(n,n+o+(e.pos-n))}var En=(t,e,r)=>{let n;try{let o=Ur(t,/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g);n=po(o)}catch(o){throw new TypeError("Failed to parse the X.509 certificate",{cause:o})}return Or("spki",n,e,r)};function uo(t){return mn(t)}function yo(t){return fn(t)}async function _r(t){if(pt(t))if(t.type==="secret")t=t.export();else return t.export({format:"jwk"});if(t instanceof Uint8Array)return{kty:"oct",k:W(t)};if(!oe(t))throw new TypeError(X(t,"CryptoKey","KeyObject","Uint8Array"));if(!t.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");let e=await crypto.subtle.exportKey("jwk",t);delete e.ext,delete e.key_ops,delete e.use,e.kty!=="AKP"&&delete e.alg;for(let r of Object.keys(e))e[r]===void 0&&delete e[r];return e}var me=(t,e)=>{if(typeof t!="string"||!t)throw new Ce(`${e} missing or invalid`)};async function bn(t,e){let r;if(b(t)){if(r=Me(t),typeof r.kty!="string")throw new TypeError(X(t,"CryptoKey","KeyObject","JSON Web Key"))}else if(ar(t))r=Me(await _r(t));else throw new TypeError(X(t,"CryptoKey","KeyObject","JSON Web Key"));if(e??(e="sha256"),e!=="sha256"&&e!=="sha384"&&e!=="sha512")throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let n;switch(r.kty){case"AKP":me(r.alg,'"alg" (Algorithm) Parameter'),me(r.pub,'"pub" (Public key) Parameter'),n={alg:r.alg,kty:r.kty,pub:r.pub};break;case"EC":me(r.crv,'"crv" (Curve) Parameter'),me(r.x,'"x" (X Coordinate) Parameter'),me(r.y,'"y" (Y Coordinate) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x,y:r.y};break;case"OKP":me(r.crv,'"crv" (Subtype of Key Pair) Parameter'),me(r.x,'"x" (Public Key) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x};break;case"RSA":me(r.e,'"e" (Exponent) Parameter'),me(r.n,'"n" (Modulus) Parameter'),n={e:r.e,kty:r.kty,n:r.n};break;case"oct":if(typeof r.k!="string")throw new Ce('"k" (Key Value) Parameter missing or invalid');n={k:r.k,kty:r.kty};break;default:throw new A('"kty" (Key Type) Parameter missing or unsupported')}let o=R(JSON.stringify(n));return W(await Wt(e,o))}async function mo(t,e){e??(e="sha256");let r=await bn(t,e);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${e.slice(-3)}:${r}`}async function fo(t,e){let r={...t,...e?.header};if(!b(r.jwk))throw new l('"jwk" (JSON Web Key) Header Parameter must be a JSON object');let n;try{n=dt(r.jwk)}catch(a){throw new l("Invalid Embedded JWK",{cause:a})}let o=qe(r.alg);if(n.use!==void 0&&n.use!=="sig")throw new l('Invalid Embedded JWK, its "use" must be "sig" when present');if(n.alg!==void 0&&n.alg!==o.alg)throw new l(`Invalid Embedded JWK, its "alg" must be "${o.alg}" when present`);let i=await ie(o,n,!0);if(i.type!=="public")throw new l('"jwk" (JSON Web Key) Header Parameter must be a public key');return i}function lo(t,e,r,n){let{kty:o,key_ops:i,ext:a,kid:s,alg:y,use:c,crv:d}=t;return(a===void 0||typeof a=="boolean")&&(i===void 0||Array.isArray(i)&&i.every((m,f)=>typeof m=="string"&&i.indexOf(m)===f)&&i.includes("verify"))&&e.kty.includes(o)&&(n===void 0||typeof n=="string"&&n===s)&&(y===void 0?o!=="AKP":r===y)&&(c===void 0||c==="sig")&&(!e.crv||d===e.crv)}async function vn(t,e,r){let n=t.get(e)||t.set(e,{}).get(e),{alg:o}=r;if(n[o]===void 0){let i=ie(r,e,!0).then(a=>{if(a.type!=="public")throw new fe("JSON Web Key Set members must be public keys");return n[o]=a,a}).catch(a=>{throw n[o]===i&&delete n[o],a});n[o]=i}return n[o]}function tr(t){let e;try{e=structuredClone(t)}catch(o){throw new fe("JSON Web Key Set malformed",{cause:o})}if(!Pt(e))throw new fe("JSON Web Key Set malformed");let r=e.keys.map(o=>{let i=Me(o);return Array.isArray(i.key_ops)&&(i.key_ops=[...i.key_ops]),i}),n=new WeakMap;return Object.defineProperty(async(o,i)=>{let{alg:a,kid:s}={...o,...i?.header},y=typeof a=="string"?lt[a]:void 0;if(!y||y.secret)throw new A('Unsupported "alg" value for a JSON Web Key Set');let c=e.keys.filter((f,w)=>lo(r[w],y,a,s)),{0:d,length:m}=c;if(!m)throw new le;if(m!==1){let f=new Re;throw f[Symbol.asyncIterator]=async function*(){for(let w of c)try{yield await vn(n,w,y)}catch{}},f}return vn(n,d,y)},"jwks",{value:()=>structuredClone(e)})}function ho(){return typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel"}var Rr;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(Rr="jose/v6.2.14");var An=Symbol();async function wo(t,e,r,n=fetch){let o=await n(t,{method:"GET",signal:r,redirect:"manual",headers:e}).catch(i=>{throw i.name==="TimeoutError"?new De(void 0,{cause:i}):i});if(o.status!==200)throw new H("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await o.json()}catch(i){throw new H("Failed to parse the JSON Web Key Set HTTP response as JSON",{cause:i})}}var Jn=Symbol();function vt(t,e){return Number.isFinite(t)&&Date.now()<t+e}function Sn(t,e,r){if(Number.isNaN(t))throw new TypeError(`"${r}" option must not be NaN`);return typeof t=="number"?t:e}function go(t,e){if(!(t instanceof URL))throw new TypeError("url must be an instance of URL");let r=new URL(t.href).href,n=e??{},o=n.timeoutDuration;if(typeof o=="number"&&(!Number.isInteger(o)||o<0))throw new TypeError('"timeoutDuration" option must be a non-negative integer');let i=typeof o=="number"?o:5e3,a=Sn(n.cooldownDuration,3e4,"cooldownDuration"),s=Sn(n.cacheMaxAge,6e5,"cacheMaxAge"),y=new Headers(n.headers);Rr&&!y.has("User-Agent")&&y.set("User-Agent",Rr),y.has("accept")||y.set("accept","application/json, application/jwk-set+json");let c=n[An],d=n[Jn],m,f,w=0,h=0,J;if(d&&typeof d=="object"){let{uat:g,jwks:v}=d;vt(g,s)&&Pt(v)&&(m=g,J=tr(v))}let C=async()=>{if(f&&ho()&&(f=void 0),!f){let g=++w,v=f=wo(r,y,AbortSignal.timeout(i),c).then(S=>{let T=tr(S);if(g<=h)return;J=T;let x=Date.now();d&&(d.uat=x,d.jwks=S),m=x,h=g}).finally(()=>{f===v&&(f=void 0)})}await f};return Object.defineProperties(async(g,v)=>{(!J||!vt(m,s))&&await C();try{return await J(g,v)}catch(S){if(S instanceof le&&!vt(m,a))return await C(),J(g,v);throw S}},{coolingDown:{get:()=>vt(m,a),enumerable:!0},fresh:{get:()=>vt(m,s),enumerable:!0},reload:{value:C,enumerable:!0},reloading:{get:()=>!!f,enumerable:!0},jwks:{value:()=>J?.jwks(),enumerable:!0}})}var Eo=ve,Dr=class extends Eo{encode(){let e=W(JSON.stringify({alg:"none"})),r=W(et(this));return`${e}.${r}.`}static decode(e,r){if(typeof e!="string")throw new I("Unsecured JWT must be a string");let{0:n,1:o,2:i,length:a}=e.split(".");if(a!==3||i!=="")throw new I("Invalid Unsecured JWT");let s,y;try{s=we(n,l,"JWS Protected Header is invalid");let c=ne(l,Ne,void 0,s,s);y=je(s,c)}catch(c){throw c instanceof l?new I("Invalid Unsecured JWT",{cause:c}):c}if(s.alg!=="none")throw new I("Invalid Unsecured JWT");if(!y)throw new I("JWTs MUST NOT use unencoded payload");return{payload:Qe(s,N(o,"payload",I),r),header:s}}};async function bo(t,e,r){if(typeof t!="string"||t.indexOf("-----BEGIN PUBLIC KEY-----")!==0)throw new TypeError('"spki" must be SPKI formatted string');return gn(t,e,r)}async function vo(t,e,r){if(typeof t!="string"||t.indexOf("-----BEGIN CERTIFICATE-----")!==0)throw new TypeError('"x509" must be X.509 formatted string');return En(t,e,r)}async function So(t,e,r){if(typeof t!="string"||t.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return wn(t,e,r)}async function Ao(t,e,r){if(!b(t))throw new TypeError("JWK must be an object");let n=dt(t),o=ge(r?.extractable),{alg:i}=n;if(e??(e=i),n.kty!=="oct"&&!e)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');switch(n.kty){case"oct":if(typeof n.k!="string")throw new TypeError('missing "k" (Key Value) Parameter value');return re(n.k);case"AKP":{if(typeof i!="string"||!i)throw new TypeError('missing "alg" (Algorithm) Parameter value');if(e!==i)throw new TypeError("JWK alg and alg option value mismatch");return ie(Oe(e),n,o)}case"RSA":case"EC":case"OKP":return ie(Oe(e),n,o);default:throw new A('Unsupported "kty" (Key Type) Parameter value')}}function Jo(t){let e;if(typeof t=="string"){let n=t.split(".");(n.length===3||n.length===5)&&([e]=n)}else if(typeof t=="object"&&t)if("protected"in t)e=t.protected;else throw new TypeError("Token does not contain a Protected Header");let r="Invalid Token or Protected Header formatting";if(typeof e!="string"||!e)throw new TypeError(r);return we(e,TypeError,r)}function Ko(t){if(typeof t!="string")throw new I("JWTs must use Compact JWS serialization, JWT must be a string");let{1:e,length:r}=t.split(".");if(r===5)throw new I("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new I("Invalid JWT");if(!e)throw new I("JWTs must contain a payload");let n;try{n=re(e)}catch(i){throw new I("Failed to base64url decode the payload",{cause:i})}let o;try{o=JSON.parse(_e.decode(n))}catch(i){throw new I("Failed to parse the decoded payload as JSON",{cause:i})}if(!b(o))throw new I("Invalid JWT Claims Set");return o}function Co(t){let e=t?.modulusLength??2048;if(typeof e!="number"||!Number.isInteger(e)||e<2048)throw new A("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return e}async function Wo(t,e){let r=ge(e?.extractable),n=Oe(t,Se);n.secret&&He(Se);let o;if(n.resolve){let i=e?.crv??"P-256";if(!["P-256","P-384","P-521","X25519"].includes(i))throw new A("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, and X25519");o=n.resolve({crv:i})}else{if(n.crv!==void 0&&e?.crv!==void 0&&e.crv!==n.crv)throw new A(`Invalid or unsupported crv option provided, the only supported value for ${t} is ${n.crv}`);o=n.kty[0]==="RSA"?{...n.subtle,publicExponent:Uint8Array.of(1,0,1),modulusLength:Co(e)}:n.subtle}return crypto.subtle.generateKey(o,r??!1,[...n.usages[1],...n.usages[0]])}async function Po(t,e){let r=ge(e?.extractable),n,o,i;switch(t){case"HS256":case"HS384":case"HS512":n=+t.slice(-3),o={name:"HMAC",hash:`SHA-${n}`,length:n},i=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return crypto.getRandomValues(new Uint8Array(+t.slice(-3)>>3));case"A128KW":case"A192KW":case"A256KW":n=+t.slice(1,4),o={name:"AES-KW",length:n},i=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":n=+t.slice(1,4),o={name:"AES-GCM",length:n},i=["encrypt","decrypt"];break;default:He(Se)}return crypto.subtle.generateKey(o,r??!1,i)}var Dc="WebCryptoAPI";export{Kr as CompactEncrypt,Wr as CompactSign,fo as EmbeddedJWK,xr as EncryptJWT,Cr as FlattenedEncrypt,Pr as FlattenedSign,lr as GeneralEncrypt,Tr as GeneralSign,kr as SignJWT,Dr as UnsecuredJWT,or as base64url,bn as calculateJwkThumbprint,mo as calculateJwkThumbprintUri,Ln as compactDecrypt,zn as compactVerify,tr as createLocalJWKSet,go as createRemoteJWKSet,Dc as cryptoRuntime,An as customFetch,Ko as decodeJwt,Jo as decodeProtectedHeader,Mr as errors,_r as exportJWK,yo as exportPKCS8,uo as exportSPKI,$n as flattenedDecrypt,Fn as flattenedVerify,Vn as generalDecrypt,qn as generalVerify,Wo as generateKeyPair,Po as generateSecret,Ao as importJWK,So as importPKCS8,bo as importSPKI,vo as importX509,Jn as jwksCache,ro as jwtDecrypt,to as jwtVerify};
|
package/dist/chunk-5AOJ5ZSQ.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
-
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{a as Kt,b as zt,c as Xt,d as Yt,e as Jt,f as Qt,g as Zt,h as er,i as tr,j as rr,k as nr,l as ir,m as sr,n as or,o as lr,p as cr,q as fr,r as ar,s as he,u as ur,v as qe}from"./chunk-WLJL66O5.js";import{a as I,c as R,e as ls}from"./chunk-7MKA3SHV.js";var ze=R((ru,Ir)=>{"use strict";var fe=e=>e&&typeof e.message=="string",Ke=e=>{if(!e)return;let t=e.cause;if(typeof t=="function"){let r=e.cause();return fe(r)?r:void 0}else return fe(t)?t:void 0},xr=(e,t)=>{if(!fe(e))return"";let r=e.stack||"";if(t.has(e))return r+`
|
|
5
|
-
causes have become circular...`;let n=Ke(e);return n?(t.add(e),r+`
|
|
6
|
-
caused by: `+xr(n,t)):r},gs=e=>xr(e,new Set),Lr=(e,t,r)=>{if(!fe(e))return"";let n=r?"":e.message||"";if(t.has(e))return n+": ...";let i=Ke(e);if(i){t.add(e);let s=typeof e.cause=="function";return n+(s?"":": ")+Lr(i,t,s)}else return n},ys=e=>Lr(e,new Set);Ir.exports={isErrorLike:fe,getErrorCause:Ke,stackWithCauses:gs,messageWithCauses:ys}});var Xe=R((nu,Pr)=>{"use strict";var Es=Symbol("circular-ref-tag"),me=Symbol("pino-raw-err-ref"),Nr=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},aggregateErrors:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[me]},set:function(e){this[me]=e}}});Object.defineProperty(Nr,me,{writable:!0,value:{}});Pr.exports={pinoErrProto:Nr,pinoErrorSymbols:{seen:Es,rawSymbol:me}}});var vr=R((iu,Dr)=>{"use strict";Dr.exports=Je;var{messageWithCauses:_s,stackWithCauses:Ss,isErrorLike:Mr}=ze(),{pinoErrProto:bs,pinoErrorSymbols:ws}=Xe(),{seen:Ye}=ws,{toString:Rs}=Object.prototype;function Je(e){if(!Mr(e))return e;e[Ye]=void 0;let t=Object.create(bs);t.type=Rs.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,t.message=_s(e),t.stack=Ss(e),Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(r=>Je(r)));for(let r in e)if(t[r]===void 0){let n=e[r];Mr(n)?r!=="cause"&&!Object.prototype.hasOwnProperty.call(n,Ye)&&(t[r]=Je(n)):t[r]=n}return delete e[Ye],t.raw=e,t}});var Cr=R((su,kr)=>{"use strict";kr.exports=ye;var{isErrorLike:Qe}=ze(),{pinoErrProto:Os,pinoErrorSymbols:Ts}=Xe(),{seen:ge}=Ts,{toString:As}=Object.prototype;function ye(e){if(!Qe(e))return e;e[ge]=void 0;let t=Object.create(Os);t.type=As.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,t.message=e.message,t.stack=e.stack,Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(r=>ye(r))),Qe(e.cause)&&!Object.prototype.hasOwnProperty.call(e.cause,ge)&&(t.cause=ye(e.cause));for(let r in e)if(t[r]===void 0){let n=e[r];Qe(n)?Object.prototype.hasOwnProperty.call(n,ge)||(t[r]=ye(n)):t[r]=n}return delete e[ge],t.raw=e,t}});var Fr=R((ou,$r)=>{"use strict";$r.exports={mapHttpRequest:xs,reqSerializer:Ur};var Ze=Symbol("pino-raw-req-ref"),Br=Object.create({},{id:{enumerable:!0,writable:!0,value:""},method:{enumerable:!0,writable:!0,value:""},url:{enumerable:!0,writable:!0,value:""},query:{enumerable:!0,writable:!0,value:""},params:{enumerable:!0,writable:!0,value:""},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:""},remotePort:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[Ze]},set:function(e){this[Ze]=e}}});Object.defineProperty(Br,Ze,{writable:!0,value:{}});function Ur(e){let t=e.info||e.socket,r=Object.create(Br);if(r.id=typeof e.id=="function"?e.id():e.id||(e.info?e.info.id:void 0),r.method=e.method,e.originalUrl)r.url=e.originalUrl;else{let n=e.path;r.url=typeof n=="string"?n:e.url?e.url.path||e.url:void 0}return e.query&&(r.query=e.query),e.params&&(r.params=e.params),r.headers=e.headers,r.remoteAddress=t&&t.remoteAddress,r.remotePort=t&&t.remotePort,r.raw=e.raw||e,r}function xs(e){return{req:Ur(e)}}});var Vr=R((lu,Wr)=>{"use strict";Wr.exports={mapHttpResponse:Ls,resSerializer:qr};var et=Symbol("pino-raw-res-ref"),jr=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[et]},set:function(e){this[et]=e}}});Object.defineProperty(jr,et,{writable:!0,value:{}});function qr(e){let t=Object.create(jr);return t.statusCode=e.headersSent?e.statusCode:null,t.headers=e.getHeaders?e.getHeaders():e._headers,t.raw=e,t}function Ls(e){return{res:qr(e)}}});var rt=R((cu,Gr)=>{"use strict";var tt=vr(),Is=Cr(),Ee=Fr(),_e=Vr();Gr.exports={err:tt,errWithCause:Is,mapHttpRequest:Ee.mapHttpRequest,mapHttpResponse:_e.mapHttpResponse,req:Ee.reqSerializer,res:_e.resSerializer,wrapErrorSerializer:function(t){return t===tt?t:function(n){return t(tt(n))}},wrapRequestSerializer:function(t){return t===Ee.reqSerializer?t:function(n){return t(Ee.reqSerializer(n))}},wrapResponseSerializer:function(t){return t===_e.resSerializer?t:function(n){return t(_e.resSerializer(n))}}}});var nt=R((fu,zr)=>{"use strict";var Hr=I("util"),Kr=Hr.getCallSites??Hr.getCallSite;function Ns(e,t){return t}zr.exports=function(){if(Kr)return Kr().slice(2).map(s=>s.scriptName);let t=Error.prepareStackTrace;Error.prepareStackTrace=Ns;let r=new Error().stack;if(Error.prepareStackTrace=t,!Array.isArray(r))return;let n=r.slice(2),i=[];for(let s of n)s&&i.push(s.getFileName());return i}});var en=R((au,Zr)=>{"use strict";function it(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array){let t=[];for(let r=0;r<e.length;r++)t[r]=it(e[r]);return t}if(typeof e=="object"){let t=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=it(e[r]));return t}return e}function Xr(e){let t=[],r="",n=!1,i=!1,s="";for(let f=0;f<e.length;f++){let o=e[f];!n&&o==="."?r&&(t.push(r),r=""):o==="["?(r&&(t.push(r),r=""),n=!0):o==="]"&&n?(t.push(r),r="",n=!1,i=!1):(o==='"'||o==="'")&&n?i?o===s?(i=!1,s=""):r+=o:(i=!0,s=o):r+=o}return r&&t.push(r),t}function Yr(e,t,r){let n=e;for(let s=0;s<t.length-1;s++){let f=t[s];if(typeof n!="object"||n===null||!(f in n)||typeof n[f]!="object"||n[f]===null)return!1;n=n[f]}let i=t[t.length-1];if(i==="*"){if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]=r;else if(typeof n=="object"&&n!==null)for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]=r)}else typeof n=="object"&&n!==null&&i in n&&Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=r);return!0}function Jr(e,t){let r=e;for(let i=0;i<t.length-1;i++){let s=t[i];if(typeof r!="object"||r===null||!(s in r)||typeof r[s]!="object"||r[s]===null)return!1;r=r[s]}let n=t[t.length-1];if(n==="*"){if(Array.isArray(r))for(let i=0;i<r.length;i++)r[i]=void 0;else if(typeof r=="object"&&r!==null)for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&delete r[i]}else typeof r=="object"&&r!==null&&n in r&&Object.prototype.hasOwnProperty.call(r,n)&&delete r[n];return!0}var Se=Symbol("PATH_NOT_FOUND");function Ps(e,t){let r=e;for(let n of t){if(r==null||typeof r!="object"||r===null||!(n in r))return Se;r=r[n]}return r}function Ms(e,t){let r=e;for(let n of t){if(r==null||typeof r!="object"||r===null)return;r=r[n]}return r}function Ds(e,t,r,n=!1){for(let i of t){let s=Xr(i);if(s.includes("*"))Qr(e,s,r,i,n);else if(n)Jr(e,s);else{let f=Ps(e,s);if(f===Se)continue;let o=typeof r=="function"?r(f,s):r;Yr(e,s,o)}}}function Qr(e,t,r,n,i=!1){let s=t.indexOf("*");if(s===t.length-1){let f=t.slice(0,-1),o=e;for(let l of f){if(o==null||typeof o!="object"||o===null)return;o=o[l]}if(Array.isArray(o))if(i)for(let l=0;l<o.length;l++)o[l]=void 0;else for(let l=0;l<o.length;l++){let u=[...f,l.toString()],h=typeof r=="function"?r(o[l],u):r;o[l]=h}else if(typeof o=="object"&&o!==null)if(i){let l=[];for(let u in o)Object.prototype.hasOwnProperty.call(o,u)&&l.push(u);for(let u of l)delete o[u]}else for(let l in o){let u=[...f,l],h=typeof r=="function"?r(o[l],u):r;o[l]=h}}else vs(e,t,r,s,n,i)}function vs(e,t,r,n,i,s=!1){let f=t.slice(0,n),o=t.slice(n+1),l=[];function u(h,d){if(d===f.length){if(Array.isArray(h))for(let g=0;g<h.length;g++)l[d]=g.toString(),u(h[g],d+1);else if(typeof h=="object"&&h!==null)for(let g in h)l[d]=g,u(h[g],d+1)}else if(d<f.length){let g=f[d];h&&typeof h=="object"&&h!==null&&g in h&&(l[d]=g,u(h[g],d+1))}else if(o.includes("*"))Qr(h,o,typeof r=="function"?(p,c)=>{let y=[...l.slice(0,d),...c];return r(p,y)}:r,i,s);else if(s)Jr(h,o);else{let g=typeof r=="function"?r(Ms(h,o),[...l.slice(0,d),...o]):r;Yr(h,o,g)}}if(f.length===0)u(e,0);else{let h=e;for(let d=0;d<f.length;d++){let g=f[d];if(h==null||typeof h!="object"||h===null)return;h=h[g],l[d]=g}h!=null&&u(h,f.length)}}function ks(e){if(e.length===0)return null;let t=new Map;for(let r of e){let n=Xr(r),i=t;for(let s=0;s<n.length;s++){let f=n[s];i.has(f)||i.set(f,new Map),i=i.get(f)}}return t}function Cs(e,t){if(!t)return e;function r(n,i,s=0){if(!i||i.size===0||n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(n.getTime());if(Array.isArray(n)){let o=[];for(let l=0;l<n.length;l++){let u=l.toString();i.has(u)||i.has("*")?o[l]=r(n[l],i.get(u)||i.get("*")):o[l]=n[l]}return o}let f=Object.create(Object.getPrototypeOf(n));for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i.has(o)||i.has("*")?f[o]=r(n[o],i.get(o)||i.get("*")):f[o]=n[o]);return f}return r(e,t)}function Bs(e){if(typeof e!="string")throw new Error("Paths must be (non-empty) strings");if(e==="")throw new Error("Invalid redaction path ()");if(e.includes(".."))throw new Error(`Invalid redaction path (${e})`);if(e.includes(","))throw new Error(`Invalid redaction path (${e})`);let t=0,r=!1,n="";for(let i=0;i<e.length;i++){let s=e[i];if((s==='"'||s==="'")&&t>0)r?s===n&&(r=!1,n=""):(r=!0,n=s);else if(s==="["&&!r)t++;else if(s==="]"&&!r&&(t--,t<0))throw new Error(`Invalid redaction path (${e})`)}if(t!==0)throw new Error(`Invalid redaction path (${e})`)}function Us(e){if(!Array.isArray(e))throw new TypeError("paths must be an array");for(let t of e)Bs(t)}function $s(e={}){let{paths:t=[],censor:r="[REDACTED]",serialize:n=JSON.stringify,strict:i=!0,remove:s=!1}=e;Us(t);let f=ks(t);return function(l){if(i&&(l===null||typeof l!="object")&&(l==null||typeof l!="object"))return n?n(l):l;let u=Cs(l,f),h=l,d=r;return typeof r=="function"&&(d=r),Ds(u,t,d,s),n===!1?(u.restore=function(){return it(h)},u):typeof n=="function"?n(u):JSON.stringify(u)}}Zr.exports=$s});var H=R((uu,tn)=>{"use strict";var Fs=Symbol("pino.setLevel"),js=Symbol("pino.getLevel"),qs=Symbol("pino.levelVal"),Ws=Symbol("pino.levelComp"),Vs=Symbol("pino.useLevelLabels"),Gs=Symbol("pino.useOnlyCustomLevels"),Hs=Symbol("pino.mixin"),Ks=Symbol("pino.lsCache"),zs=Symbol("pino.chindings"),Xs=Symbol("pino.asJson"),Ys=Symbol("pino.write"),Js=Symbol("pino.redactFmt"),Qs=Symbol("pino.time"),Zs=Symbol("pino.timeSliceIndex"),eo=Symbol("pino.stream"),to=Symbol("pino.stringify"),ro=Symbol("pino.stringifySafe"),no=Symbol("pino.stringifiers"),io=Symbol("pino.end"),so=Symbol("pino.formatOpts"),oo=Symbol("pino.messageKey"),lo=Symbol("pino.errorKey"),co=Symbol("pino.nestedKey"),fo=Symbol("pino.nestedKeyStr"),ao=Symbol("pino.mixinMergeStrategy"),uo=Symbol("pino.msgPrefix"),ho=Symbol("pino.wildcardFirst"),po=Symbol.for("pino.serializers"),mo=Symbol.for("pino.formatters"),go=Symbol.for("pino.hooks"),yo=Symbol.for("pino.metadata"),Eo=Symbol.for("pino.transport.usesMultistream");tn.exports={setLevelSym:Fs,getLevelSym:js,levelValSym:qs,levelCompSym:Ws,useLevelLabelsSym:Vs,mixinSym:Hs,lsCacheSym:Ks,chindingsSym:zs,asJsonSym:Xs,writeSym:Ys,serializersSym:po,redactFmtSym:Js,timeSym:Qs,timeSliceIndexSym:Zs,streamSym:eo,stringifySym:to,stringifySafeSym:ro,stringifiersSym:no,endSym:io,formatOptsSym:so,messageKeySym:oo,errorKeySym:lo,nestedKeySym:co,wildcardFirstSym:ho,needsMetadataGsym:yo,useOnlyCustomLevelsSym:Gs,formattersSym:mo,hooksSym:go,nestedKeyStrSym:fo,mixinMergeStrategySym:ao,msgPrefixSym:uo,transportUsesMultistreamSym:Eo}});var ot=R((du,on)=>{"use strict";var rn=en(),{redactFmtSym:_o,wildcardFirstSym:be}=H(),st=/[^.[\]]+|\[([^[\]]*?)\]/g,nn="[Redacted]",sn=!1;function So(e,t){let{paths:r,censor:n,remove:i}=bo(e),s=r.reduce((l,u)=>{st.lastIndex=0;let h=st.exec(u),d=st.exec(u),g=h[1]!==void 0?h[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,"$1"):h[0];if(g==="*"&&(g=be),d===null)return l[g]=null,l;if(l[g]===null)return l;let{index:p}=d,c=`${u.substr(p,u.length-1)}`;return l[g]=l[g]||[],g!==be&&l[g].length===0&&l[g].push(...l[be]||[]),g===be&&Object.keys(l).forEach(function(y){l[y]&&l[y].push(c)}),l[g].push(c),l},Object.create(null)),f=Object.assign(Object.create(null),{[_o]:rn({paths:r,censor:n,serialize:t,strict:sn,remove:i})}),o=(...l)=>t(typeof n=="function"?n(...l):n);return[...Object.keys(s),...Object.getOwnPropertySymbols(s)].reduce((l,u)=>{if(s[u]===null)l[u]=h=>o(h,[u]);else{let h=typeof n=="function"?(d,g)=>n(d,[u,...g]):n;l[u]=rn({paths:s[u],censor:h,serialize:t,strict:sn,remove:i})}return l},f)}function bo(e){if(Array.isArray(e))return e={paths:e,censor:nn},e;let{paths:t,censor:r=nn,remove:n}=e;if(Array.isArray(t)===!1)throw Error("pino \u2013 redact must contain an array of strings");return n===!0&&(r=void 0),{paths:t,censor:r,remove:n}}on.exports=So});var fn=R((hu,cn)=>{"use strict";var wo=()=>"",Ro=()=>`,"time":${Date.now()}`,Oo=()=>`,"time":${Math.round(Date.now()/1e3)}`,To=()=>`,"time":"${new Date(Date.now()).toISOString()}"`,Ao=1000000n,ln=1000000000n,xo=BigInt(Date.now())*Ao,Lo=process.hrtime.bigint(),Io=()=>{let e=process.hrtime.bigint()-Lo,t=xo+e,r=t/ln,n=t%ln,i=Number(r*1000n+n/1000000n),s=new Date(i),f=s.getUTCFullYear(),o=(s.getUTCMonth()+1).toString().padStart(2,"0"),l=s.getUTCDate().toString().padStart(2,"0"),u=s.getUTCHours().toString().padStart(2,"0"),h=s.getUTCMinutes().toString().padStart(2,"0"),d=s.getUTCSeconds().toString().padStart(2,"0");return`,"time":"${f}-${o}-${l}T${u}:${h}:${d}.${n.toString().padStart(9,"0")}Z"`};cn.exports={nullTime:wo,epochTime:Ro,unixTime:Oo,isoTime:To,isoTimeNano:Io}});var un=R((pu,an)=>{"use strict";function No(e){try{return JSON.stringify(e)}catch{return'"[Circular]"'}}an.exports=Po;function Po(e,t,r){var n=r&&r.stringify||No,i=1;if(typeof e=="object"&&e!==null){var s=t.length+i;if(s===1)return e;var f=new Array(s);f[0]=n(e);for(var o=1;o<s;o++)f[o]=n(t[o]);return f.join(" ")}if(typeof e!="string")return e;var l=t.length;if(l===0)return e;for(var u="",h=1-i,d=-1,g=e&&e.length||0,p=0;p<g;){if(e.charCodeAt(p)===37&&p+1<g){switch(d=d>-1?d:0,e.charCodeAt(p+1)){case 100:case 102:if(h>=l||t[h]==null)break;d<p&&(u+=e.slice(d,p)),u+=Number(t[h]),d=p+2,p++;break;case 105:if(h>=l||t[h]==null)break;d<p&&(u+=e.slice(d,p)),u+=Math.floor(Number(t[h])),d=p+2,p++;break;case 79:case 111:case 106:if(h>=l||t[h]===void 0)break;d<p&&(u+=e.slice(d,p));var c=typeof t[h];if(c==="string"){u+="'"+t[h]+"'",d=p+2,p++;break}if(c==="function"){u+=t[h].name||"<anonymous>",d=p+2,p++;break}u+=n(t[h]),d=p+2,p++;break;case 115:if(h>=l)break;d<p&&(u+=e.slice(d,p)),u+=String(t[h]),d=p+2,p++;break;case 37:d<p&&(u+=e.slice(d,p)),u+="%",d=p+2,p++,h--;break}++h}++p}return d===-1?e:(d<g&&(u+=e.slice(d)),u)}});var ct=R((mu,lt)=>{"use strict";if(typeof SharedArrayBuffer<"u"&&typeof Atomics<"u"){let t=function(r){if((r>0&&r<1/0)===!1)throw typeof r!="number"&&typeof r!="bigint"?TypeError("sleep: ms must be a number"):RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");Atomics.wait(e,0,0,Number(r))},e=new Int32Array(new SharedArrayBuffer(4));lt.exports=t}else{let e=function(t){if((t>0&&t<1/0)===!1)throw typeof t!="number"&&typeof t!="bigint"?TypeError("sleep: ms must be a number"):RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");let n=Date.now()+Number(t);for(;n>Date.now(););};lt.exports=e}});var _n=R((gu,En)=>{"use strict";var A=I("fs"),Mo=I("events"),Do=I("util").inherits,dn=I("path"),at=ct(),vo=I("assert"),we=100,Re=Buffer.allocUnsafe(0),ko=16*1024,hn="buffer",pn="utf8",[Co,Bo]=(process.versions.node||"0.0").split(".").map(Number),Uo=Co>=22&&Bo>=7;function mn(e,t){t._opening=!0,t._writing=!0,t._asyncDrainScheduled=!1;function r(s,f){if(s){t._reopening=!1,t._writing=!1,t._opening=!1,t.sync?process.nextTick(()=>{t.listenerCount("error")>0&&t.emit("error",s)}):t.emit("error",s);return}let o=t._reopening;t.fd=f,t.file=e,t._reopening=!1,t._opening=!1,t._writing=!1,t.sync?process.nextTick(()=>t.emit("ready")):t.emit("ready"),!t.destroyed&&(!t._writing&&t._len>t.minLength||t._flushPending?t._actualWrite():o&&process.nextTick(()=>t.emit("drain")))}let n=t.append?"a":"w",i=t.mode;if(t.sync)try{t.mkdir&&A.mkdirSync(dn.dirname(e),{recursive:!0});let s=A.openSync(e,n,i);r(null,s)}catch(s){throw r(s),s}else t.mkdir?A.mkdir(dn.dirname(e),{recursive:!0},s=>{if(s)return r(s);A.open(e,n,i,r)}):A.open(e,n,i,r)}function U(e){if(!(this instanceof U))return new U(e);let{fd:t,dest:r,minLength:n,maxLength:i,maxWrite:s,periodicFlush:f,sync:o,append:l=!0,mkdir:u,retryEAGAIN:h,fsync:d,contentMode:g,mode:p}=e||{};t=t||r,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._flushPending=!1,this._hwm=Math.max(n||0,16387),this.file=null,this.destroyed=!1,this.minLength=n||0,this.maxLength=i||0,this.maxWrite=s||ko,this._periodicFlush=f||0,this._periodicFlushTimer=void 0,this.sync=o||!1,this.writable=!0,this._fsync=d||!1,this.append=l||!1,this.mode=p,this.retryEAGAIN=h||(()=>!0),this.mkdir=u||!1;let c,y;if(g===hn)this._writingBuf=Re,this.write=jo,this.flush=Wo,this.flushSync=Go,this._actualWrite=Ko,c=()=>A.writeSync(this.fd,this._writingBuf),y=()=>A.write(this.fd,this._writingBuf,this.release);else if(g===void 0||g===pn)this._writingBuf="",this.write=Fo,this.flush=qo,this.flushSync=Vo,this._actualWrite=Ho,c=()=>Buffer.isBuffer(this._writingBuf)?A.writeSync(this.fd,this._writingBuf):A.writeSync(this.fd,this._writingBuf,"utf8"),y=()=>Buffer.isBuffer(this._writingBuf)?A.write(this.fd,this._writingBuf,this.release):A.write(this.fd,this._writingBuf,"utf8",this.release);else throw new Error(`SonicBoom supports "${pn}" and "${hn}", but passed ${g}`);if(typeof t=="number")this.fd=t,process.nextTick(()=>this.emit("ready"));else if(typeof t=="string")mn(t,this);else throw new Error("SonicBoom supports only file descriptors and files");if(this.minLength>=this.maxWrite)throw new Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(m,S)=>{if(m){if((m.code==="EAGAIN"||m.code==="EBUSY")&&this.retryEAGAIN(m,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{at(we),this.release(void 0,0)}catch(b){this.release(b)}else setTimeout(y,we);else this._writing=!1,this.emit("error",m);return}this.emit("write",S);let E=ft(this._writingBuf,this._len,S);if(this._len=E.len,this._writingBuf=E.writingBuf,this._writingBuf.length){if(!this.sync){y();return}try{do{let b=c(),T=ft(this._writingBuf,this._len,b);this._len=T.len,this._writingBuf=T.writingBuf}while(this._writingBuf.length)}catch(b){this.release(b);return}}this._fsync&&A.fsyncSync(this.fd);let _=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):_>this.minLength?this._actualWrite():this._ending?_>0?this._actualWrite():(this._writing=!1,Oe(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick($o,this)):this.emit("drain"))},this.on("newListener",function(m){m==="drain"&&(this._asyncDrainScheduled=!1)}),this._periodicFlush!==0&&(this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.unref())}function ft(e,t,r){return typeof e=="string"&&(e=Buffer.from(e)),t=Math.max(t-r,0),e=e.subarray(r),{writingBuf:e,len:t}}function $o(e){e.listenerCount("drain")>0&&(e._asyncDrainScheduled=!1,e.emit("drain"))}Do(U,Mo);function gn(e,t){return e.length===0?Re:e.length===1?e[0]:Buffer.concat(e,t)}function Fo(e){if(this.destroyed)throw new Error("SonicBoom destroyed");e=""+e;let t=Buffer.byteLength(e),r=this._len+t,n=this._bufs;return this.maxLength&&r>this.maxLength?(this.emit("drop",e),this._len<this._hwm):(n.length===0||Buffer.byteLength(n[n.length-1])+t>this.maxWrite?n.push(e):n[n.length-1]+=e,this._len=r,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function jo(e){if(this.destroyed)throw new Error("SonicBoom destroyed");let t=this._len+e.length,r=this._bufs,n=this._lens;return this.maxLength&&t>this.maxLength?(this.emit("drop",e),this._len<this._hwm):(r.length===0||n[n.length-1]+e.length>this.maxWrite?(r.push([e]),n.push(e.length)):(r[r.length-1].push(e),n[n.length-1]+=e.length),this._len=t,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function yn(e){this._flushPending=!0;let t=()=>{if(this._fsync)this._flushPending=!1,e();else try{A.fsync(this.fd,n=>{this._flushPending=!1,e(n)})}catch(n){e(n)}this.off("error",r)},r=n=>{this._flushPending=!1,e(n),this.off("drain",t)};this.once("drain",t),this.once("error",r)}function qo(e){if(e!=null&&typeof e!="function")throw new Error("flush cb must be a function");if(this.destroyed){let t=new Error("SonicBoom destroyed");if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&yn.call(this,e),!this._writing&&(this._bufs.length===0&&this._bufs.push(""),this._actualWrite())}function Wo(e){if(e!=null&&typeof e!="function")throw new Error("flush cb must be a function");if(this.destroyed){let t=new Error("SonicBoom destroyed");if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&yn.call(this,e),!this._writing&&(this._bufs.length===0&&(this._bufs.push([]),this._lens.push(0)),this._actualWrite())}U.prototype.reopen=function(e){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.reopen(e)});return}if(this._ending)return;if(!this.file)throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");if(e&&(this.file=e),this._reopening=!0,this._writing)return;let t=this.fd;this.once("ready",()=>{t!==this.fd&&A.close(t,r=>{if(r)return this.emit("error",r)})}),mn(this.file,this)};U.prototype.end=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.end()});return}this._ending||(this._ending=!0,!this._writing&&(this._len>0&&this.fd>=0?this._actualWrite():Oe(this)))};function Vo(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this.fd<0)throw new Error("sonic boom is not ready yet");!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf="");let e="";for(;this._bufs.length||e.length;){e.length<=0&&(e=this._bufs[0]);try{let t=Buffer.isBuffer(e)?A.writeSync(this.fd,e):A.writeSync(this.fd,e,"utf8"),r=ft(e,this._len,t);e=r.writingBuf,this._len=r.len,e.length<=0&&this._bufs.shift()}catch(t){if((t.code==="EAGAIN"||t.code==="EBUSY")&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;at(we)}}try{A.fsyncSync(this.fd)}catch{}}function Go(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this.fd<0)throw new Error("sonic boom is not ready yet");!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift([this._writingBuf]),this._writingBuf=Re);let e=Re;for(;this._bufs.length||e.length;){e.length<=0&&(e=gn(this._bufs[0],this._lens[0]));try{let t=A.writeSync(this.fd,e);e=e.subarray(t),this._len=Math.max(this._len-t,0),e.length<=0&&(this._bufs.shift(),this._lens.shift())}catch(t){if((t.code==="EAGAIN"||t.code==="EBUSY")&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;at(we)}}}U.prototype.destroy=function(){this.destroyed||Oe(this)};function Ho(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||"",this.sync)try{let t=Buffer.isBuffer(this._writingBuf)?A.writeSync(this.fd,this._writingBuf):A.writeSync(this.fd,this._writingBuf,"utf8");e(null,t)}catch(t){e(t)}else A.write(this.fd,this._writingBuf,e)}function Ko(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:gn(this._bufs.shift(),this._lens.shift()),this.sync)try{let t=A.writeSync(this.fd,this._writingBuf);e(null,t)}catch(t){e(t)}else Uo&&(this._writingBuf=Buffer.from(this._writingBuf)),A.write(this.fd,this._writingBuf,e)}function Oe(e){if(e.fd===-1){e.once("ready",Oe.bind(null,e));return}e._periodicFlushTimer!==void 0&&clearInterval(e._periodicFlushTimer),e.destroyed=!0,e._bufs=[],e._lens=[],vo(typeof e.fd=="number",`sonic.fd must be a number, got ${typeof e.fd}`);try{A.fsync(e.fd,t)}catch{}function t(){e.fd!==1&&e.fd!==2?A.close(e.fd,r):r()}function r(n){if(n){e.emit("error",n);return}e._ending&&!e._writing&&e.emit("finish"),e.emit("close")}}U.SonicBoom=U;U.default=U;En.exports=U});var ut=R((yu,On)=>{"use strict";var $={exit:[],beforeExit:[]},Sn={exit:Yo,beforeExit:Jo},Z;function zo(){Z===void 0&&(Z=new FinalizationRegistry(Qo))}function Xo(e){$[e].length>0||process.on(e,Sn[e])}function bn(e){$[e].length>0||(process.removeListener(e,Sn[e]),$.exit.length===0&&$.beforeExit.length===0&&(Z=void 0))}function Yo(){wn("exit")}function Jo(){wn("beforeExit")}function wn(e){for(let t of $[e]){let r=t.deref(),n=t.fn;r!==void 0&&n(r,e)}$[e]=[]}function Qo(e){for(let t of["exit","beforeExit"]){let r=$[t].indexOf(e);$[t].splice(r,r+1),bn(t)}}function Rn(e,t,r){if(t===void 0)throw new Error("the object can't be undefined");Xo(e);let n=new WeakRef(t);n.fn=r,zo(),Z.register(t,n),$[e].push(n)}function Zo(e,t){Rn("exit",e,t)}function el(e,t){Rn("beforeExit",e,t)}function tl(e){if(Z!==void 0){Z.unregister(e);for(let t of["exit","beforeExit"])$[t]=$[t].filter(r=>{let n=r.deref();return n&&n!==e}),bn(t)}}On.exports={register:Zo,registerBeforeExit:el,unregister:tl}});var Tn=R((Eu,rl)=>{rl.exports={name:"thread-stream",version:"4.2.0",description:"A streaming way to send data to a Node.js Worker Thread",main:"index.js",types:"index.d.ts",engines:{node:">=20"},dependencies:{"real-require":"^1.0.0"},devDependencies:{"@types/node":"^25.0.2","@yao-pkg/pkg":"^6.0.0",borp:"^1.0.0",desm:"^1.3.0",eslint:"^9.39.1",fastbench:"^1.0.1",neostandard:"^0.13.0","pino-elasticsearch":"^9.0.0","sonic-boom":"^5.0.0","ts-node":"^10.8.0",typescript:"~5.7.3"},scripts:{build:"tsc --noEmit",lint:"eslint",test:'npm run lint && npm run build && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',"test:ci":'npm run lint && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',"test:yarn":'npm run transpile && borp --pattern "test/*.test.js"',transpile:"sh ./test/ts/transpile.sh"},repository:{type:"git",url:"git+https://github.com/mcollina/thread-stream.git"},keywords:["worker","thread","threads","stream"],author:"Matteo Collina <hello@matteocollina.com>",license:"MIT",bugs:{url:"https://github.com/mcollina/thread-stream/issues"},homepage:"https://github.com/mcollina/thread-stream#readme"}});var xn=R((_u,An)=>{"use strict";function nl(e,t,r,n,i){let s=n===1/0?1/0:Date.now()+n,f=()=>{let o=Atomics.load(e,t);if(o===r){i(null,"ok");return}if(s!==1/0&&Date.now()>s){i(null,"timed-out");return}let l=s===1/0?1e4:Math.min(1e4,Math.max(1,s-Date.now())),u=Atomics.waitAsync(e,t,o,l);u.async?u.value.then(f):setImmediate(f)};f()}function il(e,t,r,n,i){let s=n===1/0?1/0:Date.now()+n,f=()=>{if(Atomics.load(e,t)!==r){i(null,"ok");return}if(s!==1/0&&Date.now()>s){i(null,"timed-out");return}let l=s===1/0?1e4:Math.min(1e4,Math.max(1,s-Date.now())),u=Atomics.waitAsync(e,t,r,l);u.async?u.value.then(h=>{if(h==="ok"){i(null,"ok");return}f()}):setImmediate(f)};f()}An.exports={wait:nl,waitDiff:il}});var In=R((Su,Ln)=>{"use strict";Ln.exports={WRITE_INDEX:4,READ_INDEX:8,SEQ_INDEX:2}});var jn=R((bu,Fn)=>{"use strict";var{version:sl}=Tn(),{EventEmitter:ol}=I("events"),{Worker:ll}=I("worker_threads"),{join:cl}=I("path"),{pathToFileURL:fl}=I("url"),{wait:al}=xn(),{WRITE_INDEX:q,READ_INDEX:K,SEQ_INDEX:dt}=In(),ul=I("buffer"),dl=I("assert"),a=Symbol("kImpl"),hl=ul.constants.MAX_STRING_LENGTH;function Nn(){}function gt(e,t){Atomics.add(e[a].state,dt,1),t(),Atomics.add(e[a].state,dt,1),Atomics.notify(e[a].state,dt)}function Pn(e){gt(e,()=>{Atomics.store(e[a].state,K,0),Atomics.store(e[a].state,q,0)})}var ae=class{constructor(t){this._value=t}deref(){return this._value}},Te=class{register(){}unregister(){}},pl=process.env.NODE_V8_COVERAGE?Te:global.FinalizationRegistry||Te,ml=process.env.NODE_V8_COVERAGE?ae:global.WeakRef||ae,Mn=new pl(e=>{e.exited||e.terminate()});function gl(e,t){let{filename:r,workerData:n}=t,s=("__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{})["thread-stream-worker"]||cl(__dirname,"lib","worker.js"),f=new ll(s,{...t.workerOpts,name:t.workerOpts?.name||"thread-stream",trackUnmanagedFds:!1,workerData:{filename:r.indexOf("file://")===0?r:fl(r).href,dataBuf:e[a].dataBuf,stateBuf:e[a].stateBuf,workerData:{$context:{threadStreamVersion:sl},...n}}});return f.stream=new ae(e),f.on("message",yl),f.on("exit",kn),Mn.register(e,f),f}function Dn(e){dl(!e[a].sync),e[a].needDrain&&(e[a].needDrain=!1,e.emit("drain"))}function vn(e){for(;;){let t=Atomics.load(e[a].state,q),r=e[a].data.length-t;if(r>0){if(e[a].bufLen===0){e[a].flushing=!1,e[a].ending?yt(e):e[a].needDrain&&process.nextTick(Dn,e);return}Un(e,r,Nn);continue}if(r===0){if(t===0&&e[a].bufLen===0)return;Ae(e,()=>{e.destroyed||(Pn(e),vn(e))});return}C(e,new Error("overwritten"));return}}function yl(e){let t=this.stream.deref();if(t===void 0){this.exited=!0,this.terminate();return}if(e?.code!=null)switch(e.code){case"READY":this.stream=new ml(t),Ae(t,()=>{t[a].ready=!0,t.emit("ready")});break;case"ERROR":C(t,e.err);break;case"EVENT":Array.isArray(e.args)?t.emit(e.name,...e.args):t.emit(e.name,e.args);break;case"FLUSHED":{if(e.context!=="thread-stream"){C(t,new Error("this should not happen: "+e.code));break}let r=t[a].flushCallbacks.get(e.id);r&&(t[a].flushCallbacks.delete(e.id),process.nextTick(r));break}case"WARNING":process.emitWarning(e.err);break;default:C(t,new Error("this should not happen: "+e.code))}}function kn(e){let t=this.stream.deref();t!==void 0&&(Mn.unregister(t),t.worker.exited=!0,t.worker.off("exit",kn),C(t,e!==0?new Error("the worker thread exited"):null))}var pt=class extends ol{constructor(t={}){if(super(),t.bufferSize<4)throw new Error("bufferSize must at least fit a 4-byte utf-8 char");this[a]={},this[a].stateBuf=new SharedArrayBuffer(128),this[a].state=new Int32Array(this[a].stateBuf),this[a].dataBuf=new SharedArrayBuffer(t.bufferSize||4*1024*1024),this[a].data=Buffer.from(this[a].dataBuf),this[a].sync=t.sync||!1,this[a].ending=!1,this[a].ended=!1,this[a].needDrain=!1,this[a].destroyed=!1,this[a].flushing=!1,this[a].ready=!1,this[a].finished=!1,this[a].errored=null,this[a].closed=!1,this[a].buf=[],this[a].bufHead=0,this[a].bufLen=0,this[a].flushCallbacks=new Map,this[a].nextFlushId=0,this.worker=gl(this,t),this.on("message",(r,n)=>{this.worker.postMessage(r,n)})}write(t){let r=Buffer.isBuffer(t)?t:Buffer.from(t);if(this[a].destroyed)return mt(this,new Error("the worker has exited")),!1;if(this[a].ending)return mt(this,new Error("the worker is ending")),!1;if(this[a].flushing&&this[a].bufLen+r.length>=hl)try{ht(this),this[a].flushing=!0}catch(n){return C(this,n),!1}if(this[a].buf.push(r),this[a].bufLen+=r.length,this[a].sync)try{return ht(this),!0}catch(n){return C(this,n),!1}return this[a].flushing||(this[a].flushing=!0,setImmediate(vn,this)),this[a].needDrain=this[a].data.length-this[a].bufLen-Atomics.load(this[a].state,q)<=0,!this[a].needDrain}end(){this[a].destroyed||(this[a].ending=!0,yt(this))}flush(t){t=typeof t=="function"?t:Nn,Cn(this,r=>{if(r){process.nextTick(t,r);return}Bn(this,t)})}flushSync(){this[a].destroyed||(ht(this),$n(this))}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[a].ready}get destroyed(){return this[a].destroyed}get closed(){return this[a].closed}get writable(){return!this[a].destroyed&&!this[a].ending}get writableEnded(){return this[a].ending}get writableFinished(){return this[a].finished}get writableNeedDrain(){return this[a].needDrain}get writableObjectMode(){return!1}get writableErrored(){return this[a].errored}};function Cn(e,t){if(e[a].destroyed){process.nextTick(t,new Error("the worker has exited"));return}if(!e[a].sync&&(e[a].flushing||e[a].bufLen>0)){setImmediate(Cn,e,t);return}Ae(e,t)}function Ae(e,t){let r=Atomics.load(e[a].state,q);al(e[a].state,K,r,1/0,(n,i)=>{if(n){C(e,n),t(n);return}if(i!=="ok"){Ae(e,t);return}t()})}function Bn(e,t){if(e[a].destroyed){process.nextTick(t,new Error("the worker has exited"));return}if(!e[a].ready){let n=()=>{s(),Bn(e,t)},i=()=>{s(),process.nextTick(t,new Error("the worker has exited"))},s=()=>{e.off("ready",n),e.off("close",i)};e.once("ready",n),e.once("close",i);return}let r=++e[a].nextFlushId;e[a].flushCallbacks.set(r,t);try{e.worker.postMessage({code:"FLUSH",context:"thread-stream",id:r})}catch(n){e[a].flushCallbacks.delete(r),C(e,n),process.nextTick(t,n)}}function El(e,t){let r=e[a].flushCallbacks;if(r.size===0)return;let n=t||new Error("the worker has exited");for(let i of r.values())process.nextTick(i,n);r.clear()}function mt(e,t){setImmediate(()=>{e.emit("error",t)})}function C(e,t){e[a].destroyed||(e[a].destroyed=!0,El(e,t),t&&(e[a].errored=t,mt(e,t)),e.worker.exited?setImmediate(()=>{e[a].closed=!0,e.emit("close")}):e.worker.terminate().catch(()=>{}).then(()=>{e[a].closed=!0,e.emit("close")}))}function Un(e,t,r){let i=Atomics.load(e[a].state,q),s=t;for(;s>0&&e[a].bufLen!==0;){let f=e[a].bufHead,o=e[a].buf[f];if(o.length<=s){o.copy(e[a].data,i),i+=o.length,s-=o.length,e[a].bufLen-=o.length,e[a].bufHead=f+1,e[a].bufHead===e[a].buf.length?(e[a].buf.length=0,e[a].bufHead=0):e[a].bufHead>=1024&&e[a].bufHead*2>=e[a].buf.length&&(e[a].buf.splice(0,e[a].bufHead),e[a].bufHead=0);continue}o.copy(e[a].data,i,0,s),e[a].buf[f]=o.subarray(s),e[a].bufLen-=s,i+=s,s=0}return gt(e,()=>{Atomics.store(e[a].state,q,i)}),r(),!0}function yt(e){if(!(e[a].ended||!e[a].ending||e[a].flushing)){e[a].ended=!0;try{e.flushSync();let t=Atomics.load(e[a].state,K);gt(e,()=>{Atomics.store(e[a].state,q,-1)});let r=0;for(;t!==-1;){if(Atomics.wait(e[a].state,K,t,1e3),t=Atomics.load(e[a].state,K),t===-2){C(e,new Error("end() failed"));return}if(++r===10){C(e,new Error("end() took too long (10s)"));return}}process.nextTick(()=>{e[a].finished=!0,e.emit("finish")})}catch(t){C(e,t)}}}function ht(e){let t=()=>{e[a].ending?yt(e):e[a].needDrain&&process.nextTick(Dn,e)};for(e[a].flushing=!1;e[a].bufLen!==0;){let r=Atomics.load(e[a].state,q),n=e[a].data.length-r;if(n===0){$n(e),Pn(e);continue}else if(n<0)throw new Error("overwritten");Un(e,n,t)}}function $n(e){if(e[a].flushing)throw new Error("unable to flush while flushing");let t=Atomics.load(e[a].state,q),r=0;for(;;){let n=Atomics.load(e[a].state,K);if(n===-2)throw Error("_flushSync failed");if(n!==t)Atomics.wait(e[a].state,K,n,1e3);else break;if(++r===10)throw new Error("_flushSync took too long (10s)")}}Fn.exports=pt});var St=R((wu,Vn)=>{"use strict";var{createRequire:_l}=I("module"),{existsSync:Sl}=I("fs"),bl=nt(),{join:Et,isAbsolute:Wn,sep:wl}=I("path"),{fileURLToPath:Rl}=I("url"),Ol=ct(),_t=ut(),Tl=jn(),{transportUsesMultistreamSym:Al}=H();function xl(e){_t.register(e,Ml),_t.registerBeforeExit(e,Dl),e.on("close",function(){_t.unregister(e)})}function Ll(){let e=process.execArgv;for(let t=0;t<e.length;t++){let r=e[t];if(r==="--import"||r==="--require"||r==="-r"||r.startsWith("--import=")||r.startsWith("--require=")||r.startsWith("-r="))return!0}return!1}function Il(e){let t=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!t)return e;let r=[],n=!1;for(let i=0;i<t.length;i++){let s=t[i];if(s==="--require"||s==="-r"||s==="--import"){let f=t[i+1];if(f&&qn(f)){n=!0,i++;continue}r.push(s),f&&(r.push(f),i++);continue}if(s.startsWith("--require=")||s.startsWith("-r=")||s.startsWith("--import=")){let f=s.slice(s.indexOf("=")+1);if(qn(f)){n=!0;continue}}r.push(s)}return n?r.join(" "):e}function qn(e){let t=Nl(e);if(!t)return!1;let r=t;if(r.startsWith("file://"))try{r=Rl(r)}catch{return!1}return Wn(r)&&!Sl(r)}function Nl(e){let t=e[0],r=e[e.length-1];return t==='"'&&r==='"'||t==="'"&&r==="'"?e.slice(1,-1):e}function Pl(e,t,r,n,i){if(!r.execArgv&&Ll()&&I.main===void 0&&(r={...r,execArgv:[]}),!r.env&&process.env.NODE_OPTIONS){let l=Il(process.env.NODE_OPTIONS);l!==process.env.NODE_OPTIONS&&(r={...r,env:{...process.env,NODE_OPTIONS:l}})}r={...r,name:i};let s=new Tl({filename:e,workerData:t,workerOpts:r,sync:n});s.on("ready",f),s.on("close",function(){process.removeListener("exit",o)}),process.on("exit",o);function f(){process.removeListener("exit",o),s.unref(),r.autoEnd!==!1&&xl(s)}function o(){s.closed||(s.flushSync(),Ol(100),s.end())}return s}function Ml(e){e.ref(),e.flushSync(),e.end(),e.once("close",function(){e.unref()})}function Dl(e){e.flushSync()}function vl(e){let{pipeline:t,targets:r,levels:n,dedupe:i,worker:s={},caller:f=bl(),sync:o=!1}=e,l={...e.options},u=!1,h=typeof f=="string"?[f]:f,d=typeof globalThis=="object"&&Object.prototype.hasOwnProperty.call(globalThis,"__bundlerPathsOverrides")&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides=="object"?globalThis.__bundlerPathsOverrides:Object.create(null),g=e.target;if(g&&r)throw new Error("only one of target or targets can be specified");if(r){g=d["pino-worker"]||Et(__dirname,"worker.js"),l.targets=r.filter(E=>E.target).map(E=>({...E,target:y(E.target)})),l.pipelines=r.filter(E=>E.pipeline).map(E=>E.pipeline.map(_=>({..._,level:E.level,target:y(_.target)})));let m=l.targets.some(E=>E.level!=null),S=l.pipelines.some(E=>E.some(_=>_.level!=null));u=l.targets.length+l.pipelines.length>1||m||S}else t&&(g=d["pino-worker"]||Et(__dirname,"worker.js"),l.pipelines=[t.map(m=>({...m,target:y(m.target)}))]);n&&(l.levels=n),i&&(l.dedupe=i),l.pinoWillSendConfig=!0;let p=r||t?"pino.transport":g,c=Pl(y(g),l,s,o,p);return u&&(c[Al]=!0),c;function y(m){if(m=d[m]||m,Wn(m)||m.indexOf("file://")===0)return m;if(m==="pino/file")return Et(__dirname,"..","file.js");let S;for(let E of h)try{let _=E==="node:repl"?process.cwd()+wl:E;S=_l(_).resolve(m);break}catch{continue}if(!S)throw new Error(`unable to determine transport target for "${m}"`);return S}}Vn.exports=vl});var Ne=R((Ou,ni)=>{"use strict";var kl=I("diagnostics_channel"),Gn=un(),{mapHttpRequest:Cl,mapHttpResponse:Bl}=rt(),bt=_n(),Hn=ut(),{lsCacheSym:Ul,chindingsSym:Jn,writeSym:Kn,serializersSym:Qn,formatOptsSym:zn,endSym:$l,stringifiersSym:Zn,stringifySym:ei,stringifySafeSym:wt,wildcardFirstSym:ti,nestedKeySym:Fl,formattersSym:ri,messageKeySym:jl,errorKeySym:ql,nestedKeyStrSym:Wl,msgPrefixSym:xe}=H(),{isMainThread:Vl}=I("worker_threads"),Gl=St(),[Hl]=process.versions.node.split(".").map(e=>Number(e)),Xn=kl.tracingChannel("pino_asJson"),Le=Hl>=25?e=>JSON.stringify(e):zl;function ee(){}function Kl(e,t){if(!t)return r;return function(...i){t.call(this,i,r,e)};function r(n,...i){if(typeof n=="object"){let s=n;n!==null&&(n.method&&n.headers&&n.socket?n=Cl(n):typeof n.setHeader=="function"&&(n=Bl(n)));let f;s===null&&i.length===0?f=[null]:(s=i.shift(),f=i),typeof this[xe]=="string"&&s!==void 0&&s!==null&&(s=this[xe]+s),this[Kn](n,Gn(s,f,this[zn]),e)}else{let s=n===void 0?i.shift():n;typeof this[xe]=="string"&&s!==void 0&&s!==null&&(s=this[xe]+s),this[Kn](null,Gn(s,i,this[zn]),e)}}}function zl(e){let t="",r=0,n=!1,i=255,s=e.length;if(s>100)return JSON.stringify(e);for(var f=0;f<s&&i>=32;f++)i=e.charCodeAt(f),(i===34||i===92)&&(t+=e.slice(r,f)+"\\",r=f,n=!0);return n?t+=e.slice(r):t=e,i<32?JSON.stringify(e):'"'+t+'"'}function Xl(e,t,r,n){if(Xn.hasSubscribers===!1)return Yn.call(this,e,t,r,n);let i={instance:this,arguments};return Xn.traceSync(Yn,i,this,e,t,r,n)}function Yn(e,t,r,n){let i=this[ei],s=this[wt],f=this[Zn],o=this[$l],l=this[Jn],u=this[Qn],h=this[ri],d=this[jl],g=this[ql],p=this[Ul][r]+n;p=p+l;let c;h.log&&(e=h.log(e));let y=f[ti],m="";for(let E in e)if(c=e[E],Object.prototype.hasOwnProperty.call(e,E)&&c!==void 0){u[E]?c=u[E](c):E===g&&u.err&&(c=u.err(c));let _=f[E]||y;switch(typeof c){case"undefined":case"function":continue;case"number":Number.isFinite(c)===!1&&(c=null);case"boolean":_&&(c=_(c));break;case"string":c=(_||Le)(c);break;default:c=(_||i)(c,s)}if(c===void 0)continue;let b=Le(E);m+=","+b+":"+c}let S="";if(t!==void 0){c=u[d]?u[d](t):t;let E=f[d]||y;switch(typeof c){case"function":break;case"number":Number.isFinite(c)===!1&&(c=null);case"boolean":E&&(c=E(c)),S=',"'+d+'":'+c;break;case"string":c=(E||Le)(c),S=',"'+d+'":'+c;break;default:c=(E||i)(c,s),S=',"'+d+'":'+c}}return this[Fl]&&m?p+this[Wl]+m.slice(1)+"}"+S+o:p+m+S+o}function Yl(e,t){let r,n=e[Jn],i=e[ei],s=e[wt],f=e[Zn],o=f[ti],l=e[Qn],u=e[ri].bindings;t=u(t);for(let h in t)if(r=t[h],((h.length<5||h!=="level"&&h!=="serializers"&&h!=="formatters"&&h!=="customLevels")&&t.hasOwnProperty(h)&&r!==void 0)===!0){if(r=l[h]?l[h](r):r,r=(f[h]||o||i)(r,s),r===void 0)continue;n+=","+Le(h)+":"+r}return n}function Jl(e){return e.write!==e.constructor.prototype.write}function Ie(e){let t=new bt(e);return t.on("error",r),!e.sync&&Vl&&(Hn.register(t,Ql),t.on("close",function(){Hn.unregister(t)})),t;function r(n){if(n.code==="EPIPE"){t.write=ee,t.end=ee,t.flushSync=ee,t.destroy=ee;return}t.removeListener("error",r),t.emit("error",n)}}function Ql(e,t){e.destroyed||(t==="beforeExit"?(e.flush(),e.on("drain",function(){e.end()})):e.flushSync())}function Zl(e){return function(r,n,i={},s){if(typeof i=="string")s=Ie({dest:i}),i={};else if(typeof s=="string"){if(i&&i.transport)throw Error("only one of option.transport or stream can be specified");s=Ie({dest:s})}else if(i instanceof bt||i.writable||i._writableState)s=i,i={};else if(i.transport){if(i.transport instanceof bt||i.transport.writable||i.transport._writableState)throw Error("option.transport do not allow stream, please pass to option directly. e.g. pino(transport)");if(i.transport.targets&&i.transport.targets.length&&i.formatters&&typeof i.formatters.level=="function")throw Error("option.transport.targets do not allow custom level formatters");let l;i.customLevels&&(l=i.useOnlyCustomLevels?i.customLevels:Object.assign({},i.levels,i.customLevels)),s=Gl({caller:n,...i.transport,levels:l})}if(i=Object.assign({},e,i),i.serializers=Object.assign(Object.create(null),e.serializers,i.serializers),i.formatters=Object.assign({},e.formatters,i.formatters),i.prettyPrint)throw new Error("prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)");let{enabled:f,onChild:o}=i;return f===!1&&(i.level="silent"),o||(i.onChild=ee),s||(Jl(process.stdout)?s=process.stdout:s=Ie({fd:process.stdout.fd||1})),{opts:i,stream:s}}}function ec(e,t){try{return JSON.stringify(e)}catch{try{return(t||this[wt])(e)}catch{return'"[unable to serialize, circular reference is too complex to analyze]"'}}}function tc(e,t,r){return{level:e,bindings:t,log:r}}function rc(e){let t=Number(e);return typeof e=="string"&&Number.isFinite(t)?t:e===void 0?1:e}ni.exports={noop:ee,buildSafeSonicBoom:Ie,asChindings:Yl,asJson:Xl,genLog:Kl,createArgsNormalizer:Zl,stringify:ec,buildFormatters:tc,normalizeDestFileDescriptor:rc}});var Pe=R((Tu,ii)=>{"use strict";var nc={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},ic={ASC:"ASC",DESC:"DESC"};ii.exports={DEFAULT_LEVELS:nc,SORTING_ORDER:ic}});var Tt=R((Au,ci)=>{"use strict";var{lsCacheSym:sc,levelValSym:Rt,useOnlyCustomLevelsSym:oc,streamSym:lc,formattersSym:cc,hooksSym:fc,levelCompSym:si}=H(),{noop:ac,genLog:z}=Ne(),{DEFAULT_LEVELS:j,SORTING_ORDER:oi}=Pe(),li={fatal:e=>{let t=z(j.fatal,e);return function(...r){let n=this[lc];if(t.call(this,...r),typeof n.flushSync=="function")try{n.flushSync()}catch{}}},error:e=>z(j.error,e),warn:e=>z(j.warn,e),info:e=>z(j.info,e),debug:e=>z(j.debug,e),trace:e=>z(j.trace,e)},Ot=Object.keys(j).reduce((e,t)=>(e[j[t]]=t,e),{}),uc=Object.keys(Ot).reduce((e,t)=>(e[t]='{"level":'+Number(t),e),{});function dc(e){let t=e[cc].level,{labels:r}=e.levels,n={};for(let i in r){let s=t(r[i],Number(i));n[i]=JSON.stringify(s).slice(0,-1)}return e[sc]=n,e}function hc(e,t){if(t)return!1;switch(e){case"fatal":case"error":case"warn":case"info":case"debug":case"trace":return!0;default:return!1}}function pc(e){let{labels:t,values:r}=this.levels;if(typeof e=="number"){if(t[e]===void 0)throw Error("unknown level value"+e);e=t[e]}if(r[e]===void 0)throw Error("unknown level "+e);let n=this[Rt],i=this[Rt]=r[e],s=this[oc],f=this[si],o=this[fc].logMethod;for(let l in r){if(f(r[l],i)===!1){this[l]=ac;continue}this[l]=hc(l,s)?li[l](o):z(r[l],o)}this.emit("level-change",e,i,t[n],n,this)}function mc(e){let{levels:t,levelVal:r}=this;return t&&t.labels?t.labels[r]:""}function gc(e){let{values:t}=this.levels,r=t[e];return r!==void 0&&this[si](r,this[Rt])}function yc(e,t,r){return e===oi.DESC?t<=r:t>=r}function Ec(e){return typeof e=="string"?yc.bind(null,e):e}function _c(e=null,t=!1){let r=e?Object.keys(e).reduce((s,f)=>(s[e[f]]=f,s),{}):null,n=Object.assign(Object.create(Object.prototype,{Infinity:{value:"silent"}}),t?null:Ot,r),i=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),t?null:j,e);return{labels:n,values:i}}function Sc(e,t,r){if(typeof e=="number"){if(![].concat(Object.keys(t||{}).map(s=>t[s]),r?[]:Object.keys(Ot).map(s=>+s),1/0).includes(e))throw Error(`default level:${e} must be included in custom levels`);return}let n=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),r?null:j,t);if(!(e in n))throw Error(`default level:${e} must be included in custom levels`)}function bc(e,t){let{labels:r,values:n}=e;for(let i in t){if(i in n)throw Error("levels cannot be overridden");if(t[i]in r)throw Error("pre-existing level values cannot be used for new levels")}}function wc(e){if(typeof e!="function"&&!(typeof e=="string"&&Object.values(oi).includes(e)))throw new Error('Levels comparison should be one of "ASC", "DESC" or "function" type')}ci.exports={initialLsCache:uc,genLsCache:dc,levelMethods:li,getLevel:mc,setLevel:pc,isLevelEnabled:gc,mappings:_c,assertNoLevelCollisions:bc,assertDefaultLevelFound:Sc,genLevelComparison:Ec,assertLevelComparison:wc}});var At=R((xu,fi)=>{"use strict";fi.exports={version:"10.4.0"}});var yi=R((Iu,gi)=>{"use strict";var{EventEmitter:Rc}=I("events"),{lsCacheSym:Oc,levelValSym:Tc,setLevelSym:Lt,getLevelSym:ai,chindingsSym:De,mixinSym:Ac,asJsonSym:di,writeSym:xc,mixinMergeStrategySym:Lc,timeSym:Ic,timeSliceIndexSym:Nc,streamSym:hi,serializersSym:X,formattersSym:ue,errorKeySym:Pc,messageKeySym:Mc,useOnlyCustomLevelsSym:Dc,needsMetadataGsym:vc,redactFmtSym:kc,stringifySym:Cc,formatOptsSym:Bc,stringifiersSym:Uc,msgPrefixSym:It,hooksSym:$c}=H(),{getLevel:Fc,setLevel:jc,isLevelEnabled:qc,mappings:Wc,initialLsCache:Vc,genLsCache:Gc,assertNoLevelCollisions:Hc}=Tt(),{asChindings:Nt,asJson:Kc,buildFormatters:xt,stringify:ui,noop:pi}=Ne(),{version:zc}=At(),Xc=ot(),Yc=class{},mi={constructor:Yc,child:Jc,bindings:Qc,setBindings:Zc,flush:rf,isLevelEnabled:qc,version:zc,get level(){return this[ai]()},set level(e){this[Lt](e)},get levelVal(){return this[Tc]},set levelVal(e){throw Error("levelVal is read-only")},get msgPrefix(){return this[It]},get[Symbol.toStringTag](){return"Pino"},[Oc]:Vc,[xc]:tf,[di]:Kc,[ai]:Fc,[Lt]:jc};Object.setPrototypeOf(mi,Rc.prototype);gi.exports=function(){return Object.create(mi)};var Me=e=>e;function Jc(e,t){if(!e)throw Error("missing bindings for child Pino");let r=this[X],n=this[ue],i=Object.create(this);if(t==null)return i[ue].bindings!==Me&&(i[ue]=xt(n.level,Me,n.log)),i[De]=Nt(i,e),this.onChild!==pi&&this.onChild(i),i;if(t.hasOwnProperty("serializers")===!0){i[X]=Object.create(null);for(let u in r)i[X][u]=r[u];let o=Object.getOwnPropertySymbols(r);for(var s=0;s<o.length;s++){let u=o[s];i[X][u]=r[u]}for(let u in t.serializers)i[X][u]=t.serializers[u];let l=Object.getOwnPropertySymbols(t.serializers);for(var f=0;f<l.length;f++){let u=l[f];i[X][u]=t.serializers[u]}}else i[X]=r;if(t.hasOwnProperty("formatters")){let{level:o,bindings:l,log:u}=t.formatters;i[ue]=xt(o||n.level,l||Me,u||n.log)}else i[ue]=xt(n.level,Me,n.log);if(t.hasOwnProperty("customLevels")===!0&&(Hc(this.levels,t.customLevels),i.levels=Wc(t.customLevels,i[Dc]),Gc(i)),typeof t.redact=="object"&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;let o=Xc(i.redact,ui),l={stringify:o[kc]};i[Cc]=ui,i[Uc]=o,i[Bc]=l}if(typeof t.msgPrefix=="string"&&(i[It]=(this[It]||"")+t.msgPrefix),i[De]=Nt(i,e),t.level!==void 0&&t.level!==this.level||t.hasOwnProperty("customLevels")){let o=t.level||this.level;i[Lt](o)}return this.onChild(i),i}function Qc(){let t=`{${this[De].substr(1)}}`,r=JSON.parse(t);return delete r.pid,delete r.hostname,r}function Zc(e){let t=Nt(this,e);this[De]=t}function ef(e,t){return Object.assign(t,e)}function tf(e,t,r){let n=this[Ic](),i=this[Ac],s=this[Pc],f=this[Mc],o=this[Lc]||ef,l,u=this[$c].streamWrite;e==null?l={}:e instanceof Error?(l={[s]:e},t===void 0&&(t=e.message)):(l=e,t===void 0&&e[f]===void 0&&e[s]&&(t=e[s].message)),i&&(l=o(l,i(l,r,this)));let h=this[di](l,t,r,n),d=this[hi];d[vc]===!0&&(d.lastLevel=r,d.lastObj=l,d.lastMsg=t,d.lastTime=n.slice(this[Nc]),d.lastLogger=this),d.write(u?u(h):h)}function rf(e){if(e!=null&&typeof e!="function")throw Error("callback must be a function");let t=this[hi];typeof t.flush=="function"?t.flush(e||pi):e&&e()}});var bi=R((vt,Si)=>{"use strict";var{hasOwnProperty:de}=Object.prototype,J=Dt();J.configure=Dt;J.stringify=J;J.default=J;vt.stringify=J;vt.configure=Dt;Si.exports=J;var nf=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function W(e){return e.length<5e3&&!nf.test(e)?`"${e}"`:JSON.stringify(e)}function Pt(e,t){if(e.length>200||t)return e.sort(t);for(let r=1;r<e.length;r++){let n=e[r],i=r;for(;i!==0&&e[i-1]>n;)e[i]=e[i-1],i--;e[i]=n}return e}var sf=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function Mt(e){return sf.call(e)!==void 0&&e.length!==0}function Ei(e,t,r){e.length<r&&(r=e.length);let n=t===","?"":" ",i=`"0":${n}${e[0]}`;for(let s=1;s<r;s++)i+=`${t}"${s}":${n}${e[s]}`;return i}function of(e){if(de.call(e,"circularValue")){let t=e.circularValue;if(typeof t=="string")return`"${t}"`;if(t==null)return t;if(t===Error||t===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function lf(e){let t;if(de.call(e,"deterministic")&&(t=e.deterministic,typeof t!="boolean"&&typeof t!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return t===void 0?!0:t}function cf(e,t){let r;if(de.call(e,t)&&(r=e[t],typeof r!="boolean"))throw new TypeError(`The "${t}" argument must be of type boolean`);return r===void 0?!0:r}function _i(e,t){let r;if(de.call(e,t)){if(r=e[t],typeof r!="number")throw new TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw new TypeError(`The "${t}" argument must be an integer`);if(r<1)throw new RangeError(`The "${t}" argument must be >= 1`)}return r===void 0?1/0:r}function Y(e){return e===1?"1 item":`${e} items`}function ff(e){let t=new Set;for(let r of e)(typeof r=="string"||typeof r=="number")&&t.add(String(r));return t}function af(e){if(de.call(e,"strict")){let t=e.strict;if(typeof t!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(t)return r=>{let n=`Object can not safely be stringified. Received type ${typeof r}`;throw typeof r!="function"&&(n+=` (${r.toString()})`),new Error(n)}}}function Dt(e){e={...e};let t=af(e);t&&(e.bigint===void 0&&(e.bigint=!1),"circularValue"in e||(e.circularValue=Error));let r=of(e),n=cf(e,"bigint"),i=lf(e),s=typeof i=="function"?i:void 0,f=_i(e,"maximumDepth"),o=_i(e,"maximumBreadth");function l(p,c,y,m,S,E){let _=c[p];switch(typeof _=="object"&&_!==null&&typeof _.toJSON=="function"&&(_=_.toJSON(p)),_=m.call(c,p,_),typeof _){case"string":return W(_);case"object":{if(_===null)return"null";if(y.indexOf(_)!==-1)return r;let b="",T=",",L=E;if(Array.isArray(_)){if(_.length===0)return"[]";if(f<y.length+1)return'"[Array]"';y.push(_),S!==""&&(E+=S,b+=`
|
|
7
|
-
${E}`,T=`,
|
|
8
|
-
${E}`);let M=Math.min(_.length,o),v=0;for(;v<M-1;v++){let G=l(String(v),_,y,m,S,E);b+=G!==void 0?G:"null",b+=T}let k=l(String(v),_,y,m,S,E);if(b+=k!==void 0?k:"null",_.length-1>o){let G=_.length-o-1;b+=`${T}"... ${Y(G)} not stringified"`}return S!==""&&(b+=`
|
|
9
|
-
${L}`),y.pop(),`[${b}]`}let O=Object.keys(_),x=O.length;if(x===0)return"{}";if(f<y.length+1)return'"[Object]"';let w="",P="";S!==""&&(E+=S,T=`,
|
|
10
|
-
${E}`,w=" ");let D=Math.min(x,o);i&&!Mt(_)&&(O=Pt(O,s)),y.push(_);for(let M=0;M<D;M++){let v=O[M],k=l(v,_,y,m,S,E);k!==void 0&&(b+=`${P}${W(v)}:${w}${k}`,P=T)}if(x>o){let M=x-o;b+=`${P}"...":${w}"${Y(M)} not stringified"`,P=T}return S!==""&&P.length>1&&(b=`
|
|
11
|
-
${E}${b}
|
|
12
|
-
${L}`),y.pop(),`{${b}}`}case"number":return isFinite(_)?String(_):t?t(_):"null";case"boolean":return _===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(_);default:return t?t(_):void 0}}function u(p,c,y,m,S,E){switch(typeof c=="object"&&c!==null&&typeof c.toJSON=="function"&&(c=c.toJSON(p)),typeof c){case"string":return W(c);case"object":{if(c===null)return"null";if(y.indexOf(c)!==-1)return r;let _=E,b="",T=",";if(Array.isArray(c)){if(c.length===0)return"[]";if(f<y.length+1)return'"[Array]"';y.push(c),S!==""&&(E+=S,b+=`
|
|
13
|
-
${E}`,T=`,
|
|
14
|
-
${E}`);let x=Math.min(c.length,o),w=0;for(;w<x-1;w++){let D=u(String(w),c[w],y,m,S,E);b+=D!==void 0?D:"null",b+=T}let P=u(String(w),c[w],y,m,S,E);if(b+=P!==void 0?P:"null",c.length-1>o){let D=c.length-o-1;b+=`${T}"... ${Y(D)} not stringified"`}return S!==""&&(b+=`
|
|
15
|
-
${_}`),y.pop(),`[${b}]`}y.push(c);let L="";S!==""&&(E+=S,T=`,
|
|
16
|
-
${E}`,L=" ");let O="";for(let x of m){let w=u(x,c[x],y,m,S,E);w!==void 0&&(b+=`${O}${W(x)}:${L}${w}`,O=T)}return S!==""&&O.length>1&&(b=`
|
|
17
|
-
${E}${b}
|
|
18
|
-
${_}`),y.pop(),`{${b}}`}case"number":return isFinite(c)?String(c):t?t(c):"null";case"boolean":return c===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(c);default:return t?t(c):void 0}}function h(p,c,y,m,S){switch(typeof c){case"string":return W(c);case"object":{if(c===null)return"null";if(typeof c.toJSON=="function"){if(c=c.toJSON(p),typeof c!="object")return h(p,c,y,m,S);if(c===null)return"null"}if(y.indexOf(c)!==-1)return r;let E=S;if(Array.isArray(c)){if(c.length===0)return"[]";if(f<y.length+1)return'"[Array]"';y.push(c),S+=m;let w=`
|
|
19
|
-
${S}`,P=`,
|
|
20
|
-
${S}`,D=Math.min(c.length,o),M=0;for(;M<D-1;M++){let k=h(String(M),c[M],y,m,S);w+=k!==void 0?k:"null",w+=P}let v=h(String(M),c[M],y,m,S);if(w+=v!==void 0?v:"null",c.length-1>o){let k=c.length-o-1;w+=`${P}"... ${Y(k)} not stringified"`}return w+=`
|
|
21
|
-
${E}`,y.pop(),`[${w}]`}let _=Object.keys(c),b=_.length;if(b===0)return"{}";if(f<y.length+1)return'"[Object]"';S+=m;let T=`,
|
|
22
|
-
${S}`,L="",O="",x=Math.min(b,o);Mt(c)&&(L+=Ei(c,T,o),_=_.slice(c.length),x-=c.length,O=T),i&&(_=Pt(_,s)),y.push(c);for(let w=0;w<x;w++){let P=_[w],D=h(P,c[P],y,m,S);D!==void 0&&(L+=`${O}${W(P)}: ${D}`,O=T)}if(b>o){let w=b-o;L+=`${O}"...": "${Y(w)} not stringified"`,O=T}return O!==""&&(L=`
|
|
23
|
-
${S}${L}
|
|
24
|
-
${E}`),y.pop(),`{${L}}`}case"number":return isFinite(c)?String(c):t?t(c):"null";case"boolean":return c===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(c);default:return t?t(c):void 0}}function d(p,c,y){switch(typeof c){case"string":return W(c);case"object":{if(c===null)return"null";if(typeof c.toJSON=="function"){if(c=c.toJSON(p),typeof c!="object")return d(p,c,y);if(c===null)return"null"}if(y.indexOf(c)!==-1)return r;let m="",S=c.length!==void 0;if(S&&Array.isArray(c)){if(c.length===0)return"[]";if(f<y.length+1)return'"[Array]"';y.push(c);let L=Math.min(c.length,o),O=0;for(;O<L-1;O++){let w=d(String(O),c[O],y);m+=w!==void 0?w:"null",m+=","}let x=d(String(O),c[O],y);if(m+=x!==void 0?x:"null",c.length-1>o){let w=c.length-o-1;m+=`,"... ${Y(w)} not stringified"`}return y.pop(),`[${m}]`}let E=Object.keys(c),_=E.length;if(_===0)return"{}";if(f<y.length+1)return'"[Object]"';let b="",T=Math.min(_,o);S&&Mt(c)&&(m+=Ei(c,",",o),E=E.slice(c.length),T-=c.length,b=","),i&&(E=Pt(E,s)),y.push(c);for(let L=0;L<T;L++){let O=E[L],x=d(O,c[O],y);x!==void 0&&(m+=`${b}${W(O)}:${x}`,b=",")}if(_>o){let L=_-o;m+=`${b}"...":"${Y(L)} not stringified"`}return y.pop(),`{${m}}`}case"number":return isFinite(c)?String(c):t?t(c):"null";case"boolean":return c===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(c);default:return t?t(c):void 0}}function g(p,c,y){if(arguments.length>1){let m="";if(typeof y=="number"?m=" ".repeat(Math.min(y,10)):typeof y=="string"&&(m=y.slice(0,10)),c!=null){if(typeof c=="function")return l("",{"":p},[],c,m,"");if(Array.isArray(c))return u("",p,[],ff(c),m,"")}if(m.length!==0)return h("",p,[],m,"")}return d("",p,[])}return g}});var Ti=R((Nu,Oi)=>{"use strict";var kt=Symbol.for("pino.metadata"),{DEFAULT_LEVELS:Ri}=Pe(),uf=Ri.info;function df(e,t){e=e||[],t=t||{dedupe:!1};let r=Object.create(Ri);r.silent=1/0,t.levels&&typeof t.levels=="object"&&Object.keys(t.levels).forEach(d=>{r[d]=t.levels[d]});let n={write:i,add:o,remove:l,emit:s,flushSync:f,end:u,minLevel:0,lastId:0,streams:[],clone:h,[kt]:!0,streamLevels:r};return Array.isArray(e)?e.forEach(o,n):o.call(n,e),e=null,n;function i(d){let g,p=typeof this.lastLevel=="string"?(this.streamLevels||r)[this.lastLevel]:this.lastLevel,{streams:c}=this,y=0,m;for(let S=hf(c.length,t.dedupe);mf(S,c.length,t.dedupe);S=pf(S,t.dedupe))if(g=c[S],g.level<=p){if(y!==0&&y!==g.level)break;if(m=g.stream,m[kt]){let{lastTime:E,lastMsg:_,lastObj:b,lastLogger:T}=this;m.lastLevel=p,m.lastTime=E,m.lastMsg=_,m.lastObj=b,m.lastLogger=T}m.write(d),t.dedupe&&(y=g.level)}else if(!t.dedupe)break}function s(...d){for(let{stream:g}of this.streams)typeof g.emit=="function"&&g.emit(...d)}function f(){for(let{stream:d}of this.streams)typeof d.flushSync=="function"&&d.flushSync()}function o(d){if(!d)return this;let g=typeof d.write=="function"||d.stream,p=d.write?d:d.stream;if(!g)throw Error("stream object needs to implement either StreamEntry or DestinationStream interface");let{streams:c,streamLevels:y}=this,m;typeof d.levelVal=="number"?m=d.levelVal:typeof d.level=="string"?m=y[d.level]:typeof d.level=="number"?m=d.level:m=uf;let S={stream:p,level:m,levelVal:void 0,id:++n.lastId};return c.unshift(S),c.sort(wi),this.minLevel=c[0].level,this}function l(d){let{streams:g}=this,p=g.findIndex(c=>c.id===d);return p>=0&&(g.splice(p,1),g.sort(wi),this.minLevel=g.length>0?g[0].level:-1),this}function u(){for(let{stream:d}of this.streams)typeof d.flushSync=="function"&&d.flushSync(),d.end()}function h(d){let g=new Array(this.streams.length);for(let p=0;p<g.length;p++)g[p]={level:d,stream:this.streams[p].stream};return{write:i,add:o,remove:l,emit:s,flushSync:f,end:u,minLevel:d,streams:g,clone:h,[kt]:!0,streamLevels:r}}}function wi(e,t){return e.level-t.level}function hf(e,t){return t?e-1:0}function pf(e,t){return t?e-1:e+1}function mf(e,t,r){return r?e>=0:e<t}Oi.exports=df});var $i=R((Pu,B)=>{"use strict";var gf=I("os"),Di=rt(),yf=nt(),Ef=ot(),vi=fn(),_f=yi(),ki=H(),{configure:Sf}=bi(),{assertDefaultLevelFound:bf,mappings:Ci,genLsCache:wf,genLevelComparison:Rf,assertLevelComparison:Of}=Tt(),{DEFAULT_LEVELS:Bi,SORTING_ORDER:Tf}=Pe(),{createArgsNormalizer:Af,asChindings:xf,buildSafeSonicBoom:Ai,buildFormatters:Lf,stringify:Ct,normalizeDestFileDescriptor:xi,noop:If}=Ne(),{version:Nf}=At(),{chindingsSym:Li,redactFmtSym:Pf,serializersSym:Ii,timeSym:Mf,timeSliceIndexSym:Df,streamSym:vf,stringifySym:Ni,stringifySafeSym:Bt,stringifiersSym:Pi,setLevelSym:kf,endSym:Cf,formatOptsSym:Bf,messageKeySym:Uf,errorKeySym:$f,nestedKeySym:Ff,mixinSym:jf,levelCompSym:qf,useOnlyCustomLevelsSym:Wf,formattersSym:Mi,hooksSym:Vf,nestedKeyStrSym:Gf,mixinMergeStrategySym:Hf,msgPrefixSym:Kf,transportUsesMultistreamSym:zf}=ki,{epochTime:Ui,nullTime:Xf}=vi,{pid:Yf}=process,Jf=gf.hostname(),Qf=Di.err,Zf={level:"info",levelComparison:Tf.ASC,levels:Bi,messageKey:"msg",errorKey:"err",nestedKey:null,enabled:!0,base:{pid:Yf,hostname:Jf},serializers:Object.assign(Object.create(null),{err:Qf}),formatters:Object.assign(Object.create(null),{bindings(e){return e},level(e,t){return{level:t}}}),hooks:{logMethod:void 0,streamWrite:void 0},timestamp:Ui,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100},ea=Af(Zf),ta=Object.assign(Object.create(null),Di);function Ut(...e){let t={},{opts:r,stream:n}=ea(t,yf(),...e);r.level&&typeof r.level=="string"&&Bi[r.level.toLowerCase()]!==void 0&&(r.level=r.level.toLowerCase());let{redact:i,crlf:s,serializers:f,timestamp:o,messageKey:l,errorKey:u,nestedKey:h,base:d,name:g,level:p,customLevels:c,levelComparison:y,mixin:m,mixinMergeStrategy:S,useOnlyCustomLevels:E,formatters:_,hooks:b,depthLimit:T,edgeLimit:L,onChild:O,msgPrefix:x}=r,w=Sf({maximumDepth:T,maximumBreadth:L}),P=Lf(_.level,_.bindings,_.log),D=Ct.bind({[Bt]:w}),M=i?Object.assign(Object.create(null),Ef(i,D)):Object.create(null),v=i?{stringify:M[Pf]}:{stringify:D},k="}"+(s?`\r
|
|
25
|
-
`:`
|
|
26
|
-
`),G=xf.bind(null,{[Li]:"",[Ii]:f,[Pi]:M,[Ni]:Ct,[Bt]:w,[Mi]:P}),$e="";d!==null&&(g===void 0?$e=G(d):$e=G(Object.assign({},d,{name:g})));let Gt=o instanceof Function?o:o?Ui:Xf,ss=Gt().indexOf(":")+1;if(E&&!c)throw Error("customLevels is required if useOnlyCustomLevels is set true");if(m&&typeof m!="function")throw Error(`Unknown mixin type "${typeof m}" - expected "function"`);if(x&&typeof x!="string")throw Error(`Unknown msgPrefix type "${typeof x}" - expected "string"`);bf(p,c,E);let ne=Ci(c,E);if(n&&n[zf]===!0){let ie=typeof p=="string"?p:void 0;(!ie||ne[ie]===void 0)&&(ie=Object.keys(ne)[0]);let Ht=ne[ie],Fe=!1;try{let je=_.level(ie,Ht);Fe=je&&typeof je=="object"&&je.level===Ht}catch{Fe=!1}Fe||process.emitWarning('custom formatters.level detected with multiple transport targets/pipelines; ensure logs include a numeric "level" field or they may be dropped',{code:"PINO_TRANSPORT_MULTI_TARGETS_LEVEL_FORMATTER"})}typeof n.emit=="function"&&n.emit("message",{code:"PINO_CONFIG",config:{levels:ne,messageKey:l,errorKey:u}}),Of(y);let os=Rf(y);return Object.assign(t,{levels:ne,[qf]:os,[Wf]:E,[vf]:n,[Mf]:Gt,[Df]:ss,[Ni]:Ct,[Bt]:w,[Pi]:M,[Cf]:k,[Bf]:v,[Uf]:l,[$f]:u,[Ff]:h,[Gf]:h?`,${JSON.stringify(h)}:{`:"",[Ii]:f,[jf]:m,[Hf]:S,[Li]:$e,[Mi]:P,[Vf]:b,silent:If,onChild:O,[Kf]:x}),Object.setPrototypeOf(t,_f()),wf(t),t[kf](p),t}B.exports=Ut;B.exports.destination=(e=process.stdout.fd)=>typeof e=="object"?(e.dest=xi(e.dest||process.stdout.fd),Ai(e)):Ai({dest:xi(e),minLength:0});B.exports.transport=St();B.exports.multistream=Ti();B.exports.levels=Ci();B.exports.stdSerializers=ta;B.exports.stdTimeFunctions=Object.assign({},vi);B.exports.symbols=ki;B.exports.version=Nf;B.exports.default=Ut;B.exports.pino=Ut});import{closeSync as le,constants as N,fchmodSync as Sr,fstatSync as fs,ftruncateSync as as,lstatSync as yr,mkdirSync as Er,openSync as br,readFileSync as _r,writeFileSync as us}from"fs";import{open as ds}from"fs/promises";import{homedir as wr}from"os";import{dirname as Rr,join as He,relative as Or,resolve as Tr,sep as Ar}from"path";var se=".yukino",We="sessions",dr="artifacts",hr="projects",pr=/^[A-Za-z0-9_-]+$/u,mr="Invalid session ID";var Ve="Private state must be a regular file",gr=new Set(["worktrees","skills","agents","prompts","AGENTS.md"]);function Ja(e){let t=He(wr(),se),r=Tr(e);if(!qe(t,r))return!1;let n=Or(t,r).split(Ar)[0];return!gr.has(n)}function pe(e,t){let r=Tr(e),n=He(wr(),se);if(!qe(n,r)){Er(r,{recursive:!0,mode:448});return}let i=Or(n,r).split(Ar).filter(Boolean),s=n;for(let f=-1;f<i.length;f++){f>=0&&(s=He(s,i[f]));let o=yr(s,{throwIfNoEntry:!1});if(o?.isSymbolicLink()||o&&!o.isDirectory())throw new Error(`Private state directory must be a real directory: ${s}`);if(!o)try{Er(s,{mode:448})}catch(l){if(!(l instanceof Error)||!("code"in l)||l.code!=="EEXIST")throw l;let u=yr(s);if(u.isSymbolicLink()||!u.isDirectory())throw l}if(process.platform!=="win32"){let l=br(s,N.O_RDONLY|N.O_DIRECTORY|N.O_NOFOLLOW);try{Sr(l,448)}finally{le(l)}}}}function hs(e){if(typeof e=="number")return e;switch(e){case"r":return N.O_RDONLY;case"w":return N.O_WRONLY|N.O_CREAT|N.O_TRUNC;case"wx":return N.O_WRONLY|N.O_CREAT|N.O_TRUNC|N.O_EXCL;case"a":return N.O_WRONLY|N.O_CREAT|N.O_APPEND;default:throw new Error(`Unsupported private file flag: ${e}`)}}function ce(e,t,r=384){pe(Rr(e));let n=hs(t),i=br(e,n&~N.O_TRUNC|N.O_NOFOLLOW|N.O_NONBLOCK,384);try{if(!fs(i).isFile())throw new Error(Ve);return process.platform!=="win32"&&Sr(i,384),n&N.O_TRUNC&&as(i,0),i}catch(s){throw le(i),s}}function Qa(e){le(ce(e,"r"))}function ps(e,t,r){let n=typeof r=="string"?{encoding:r}:r,i=ce(e,n?.flag??"w");try{us(i,t,n)}finally{le(i)}}function Za(e,t,r="utf8"){ps(e,t,{flag:"a",encoding:r})}function eu(e,t){let r=ce(e,"r");try{return t?_r(r,t):_r(r)}finally{le(r)}}async function tu(e,t,r="utf8"){pe(Rr(e));let n=await ds(e,N.O_WRONLY|N.O_CREAT|N.O_NOFOLLOW|N.O_NONBLOCK,384);try{if(!(await n.stat()).isFile())throw new Error(Ve);process.platform!=="win32"&&await n.chmod(384),await n.truncate(0),await n.writeFile(t,r)}finally{await n.close()}}var te=ls($i(),1);import{closeSync as ca}from"fs";import{readdir as Ft,stat as fa,unlink as aa}from"fs/promises";import{join as Be,dirname as ua}from"path";var ve="warn",Fi="silent",ke="logs",$t=".jsonl";var ji=/[^a-zA-Z0-9_-]/g,qi="unnamed";var Wi=new Set(["name","message","stack","cause"]);import{createHash as na}from"crypto";import{homedir as ia}from"os";import{join as Vi}from"path";function sa(){return Vi(ia(),se)}function Q(...e){return Vi(sa(),...e)}function Bu(e,...t){if(!pr.test(e))throw new Error(mr);return Q(We,dr,e,...t)}function Gi(e){return na("sha256").update(ur(e)).digest("hex")}function Uu(e,...t){return Q(hr,Gi(e),...t)}function $u(e){return Q(We,Gi(e))}var ju="text",qu="shutdown_request",Wu="shutdown_response",Vu="plan_approval_request",Gu="plan_approval_response",Hu="leader",Ku=/^[a-zA-Z0-9_-]+$/,zu=/[^a-zA-Z0-9]/g,Xu=new Set(["SendMessage","TodoWrite"]),Yu=new Set(["Workflow","Goal","Agent","SendMessage","TaskStop","SyntheticOutput","TeamCreate","TeamDelete","TeamList","TodoWrite"]),Ju=5e3,Qu=1e4,Zu=5,ed=80,td=500,rd=500,nd=500,id=200,sd=200,od=5,ld="config.json",Hi="teams",cd="inboxes",fd="team:",ad="Working",ud="Stopped",dd="*",hd="(The teammate returned no plan.)",pd="No active team.",md="No active team found for this sender.",gd="Multiple teams match. Specify team_name; use TeamList to see available teams.",yd="Teammates can only access their own team.",Ed="Only the leader can approve or reject teammate plans.",_d="plan_approval_response requires request_id, approve, and review feedback in content.",Sd="Only the leader can request teammate shutdown.",bd="shutdown_response requires 'approve'.",wd="Error: pass exactly one of teammate or task_id",Rd="Only the leader can stop teammates.",Od="Invalid mailbox member name",Td="Cannot load an unreadable teammate mailbox; original contents were preserved",Ad="Invalid shared task ID counter",xd="Cannot load an unreadable shared task board",Ld="Team name must not be empty or whitespace.",Id="No active team task board",Nd="Only an active teammate in plan mode can submit a plan.",Pd="A non-empty plan is required for review.",Md="This teammate already has a plan awaiting review.",Dd="Teammate plans are automatically approved outside coordinator mode.",vd="No matching pending plan approval request for this teammate.",kd="This plan approval request already has a leader response.",Cd="Plan approval responses require the leader's review feedback.";function Bd(e){return`Invalid teammate name '${e}'`}function Ud(e){return`Teammate '${e}' already exists`}function $d(e){return`Teammate '${e}' is already running`}function Fd(e){return`Stop teammate '${e}' before removing it`}function jd(e,t){return`Member '${e}' not found in team '${t}'`}function qd(e,t){return`Teammate '${e}' is ${t} and cannot receive work`}function Wd(e){return`Teammate '${e}' is not available for assignment`}function Vd(e){return`Team '${e}' created. Use Agent with kind="teammate" and team_name="${e}" to add teammates.`}function Gd(e){return`Team '${e}' already exists. Choose a different name, or target the existing team with team_name='${e}'.`}function Hd(e){return`Team '${e}' not found.`}function Kd(e){return`Team '${e}' deleted.`}function zd(e){return`Message sent to '${e}'.`}function Xd(e){return`Message broadcast to ${String(e)} teammate(s).`}function Yd(e,t){return`${e} sent to '${t}'.`}function Jd(e){return`Unsupported message type ${e}.`}function Qd(e){return`Teammate '${e}' not found.`}function Zd(e,t){return`Plan ${e?"approval":"revision feedback"} sent to '${t}'.`}function eh(e){return`Error: background task '${e}' not found`}function th(e,t){return`Background task '${e}' is ${t}, nothing to stop`}function rh(e){return`Background task '${e}' stopped.`}function nh(e,t){return`Teammate '${e}' in team '${t}' is not running, nothing to stop`}function ih(e,t){return`Teammate '${e}' in team '${t}' stopped.`}function sh(e,t){return`Error: teammate '${e}' not found. Known teammates: ${t}`}var V=null,re=null,Ce=null,zi=null;function da(e){let t=e.logDir??Q(ke);return Be(t,`${e.sessionId}${$t}`)}function ph(e){return e.replace(ji,"_")||qi}function ha(e){if(typeof e!="object"||e===null)return;let t=Reflect.get(e,"flushSync");typeof t=="function"&&t.call(e)}function mh(e){V&&pa();let t=da(e);pe(ua(t),{recursive:!0});let r=ce(t,"a");Ce=r,zi=t,re=te.default.destination(r);let n={level:ve,base:{sessionId:e.sessionId,mode:e.mode},serializers:{err:ga}};return e.stdout?V=(0,te.default)(n,te.default.multistream([{stream:re,level:ve},{stream:process.stdout,level:ve}])):V=(0,te.default)(n,re),e.skipCleanup||ma().catch(()=>{}),V}function jt(){return V}function pa(){if(zi=null,V){try{V.flush()}catch{}V=null}if(re&&(ha(re),re=null),Ce!==null){try{ca(Ce)}catch{}Ce=null}}var Xi=(0,te.default)({level:Fi}),gh=new Proxy(Xi,{get(e,t,r){let i=jt()??e,s=Reflect.get(i,t,r);return typeof s=="function"?s.bind(i):s},set(e,t,r){return Reflect.set(jt()??e,t,r)}});function Yi(e){let t=null,r=null,n=()=>{let i=jt();return i?((t===null||r!==i)&&(t=i.child(e),r=i),t):null};return new Proxy(Xi,{get(i,s,f){let o=n()??i,l=Reflect.get(o,s,f);return typeof l=="function"?l.bind(o):l},set(i,s,f){return Reflect.set(n()??i,s,f)}})}async function Ki(e){let t;try{t=(await Ft(e)).filter(s=>s.endsWith($t))}catch{return 0}let r=Date.now(),n=720*60*60*1e3,i=0;for(let s of t){let f=Be(e,s);try{let o=await fa(f);r-o.mtimeMs>n&&(await aa(f),i++)}catch{}}return i}async function ma(){let e=0;e+=await Ki(Q(ke));let t=Q(Hi),r;try{r=await Ft(t)}catch{return e}for(let n of r){let i;try{i=await Ft(Be(t,n))}catch{continue}for(let s of i)e+=await Ki(Be(t,n,s,ke))}return e}function Ji(e,t){let r={type:e.name,message:e.message,stack:e.stack},n=Object.getOwnPropertyDescriptor(e,"cause");if(n&&t<5){let i=n.value;i instanceof Error?r.cause=Ji(i,t+1):i!==void 0&&(r.cause={message:Qi(i)})}for(let i of Object.keys(e)){if(Wi.has(i))continue;let s=Object.getOwnPropertyDescriptor(e,i);if(s){let f=s.value;r[i]=f}}return r}function Qi(e){if(typeof e=="string")return e;try{let t=JSON.stringify(e);if(t!==void 0)return t}catch{}try{return String(e)}catch{return Object.prototype.toString.call(e)}}function ga(e){return e instanceof Error?Ji(e,0):{message:Qi(e),value:e}}import{readdirSync as Ea,lstatSync as _a,statSync as Sa}from"fs";import{join as ba}from"path";var Eh="tool-results",_h=".txt";var wh=120,Rh=600,Oh=3e3,Th=2e3,Ah=50*1024,xh=10*1024*1024,Lh=500,Ih=2e3,Nh=8*1024,Ph=1e4,Mh=25,Dh=25*1024*1024,vh=2e3,kh=1e4,F="\\p{L}\\p{M}\\p{N}_",Ch=new Map([["w",`[${F}]`],["W",`[^${F}]`],["d","\\p{Nd}"],["D","\\P{Nd}"],["b",`(?:(?<![${F}])(?=[${F}])|(?<=[${F}])(?![${F}]))`],["B",`(?:(?<=[${F}])(?=[${F}])|(?<![${F}])(?![${F}]))`]]),Bh=new Map([["w",F],["d","\\p{Nd}"]]),Uh=50*1024,$h=10*1024*1024,Fh=3e4,jh=2e3,qh=5*1024*1024*1024,Wh=500,Vh=["Bash","PowerShell"],Zi=new Set([".agents",".git",".yukino",".next",".venv",".mypy_cache","__pycache__","dist","node_modules"]),Gh=new Set(["image/jpeg","image/png","image/gif","image/webp"]),Hh=["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot","zoom","click","drag","keypress","move"],Kh=["click","double_click","drag","keypress","move","screenshot","scroll","type","wait"],zh=100,Xh=15e3,Yh=32*1024*1024,Jh=1366,Qh=900,Zh="Error: send either action (Anthropic-style, one action per call) or actions (OpenAI-style batch), not both.",ep="Error: action (Anthropic-style) or actions (OpenAI-style batch) is required.",tp="Error: the computer is being controlled by another Yukino call. Retry after it finishes.",rp=3,np=200,ip=10*1024*1024,sp=6e4,op=1e5,lp=900*1e3,cp=50*1024*1024,fp=new Map([["grep",new Map([[1,"no matches found"],[2,"error while searching"]])],["rg",new Map([[1,"no matches found"],[2,"error while searching"]])],["findstr",new Map([[1,"no matches found"],[2,"error while searching"]])],["diff",new Map([[1,"files differ"],[2,"trouble reading files"]])],["cmp",new Map([[1,"files differ"],[2,"trouble reading files"]])],["test",new Map([[1,"condition is false"],[2,"expression error"]])],["[",new Map([[1,"condition is false"],[2,"expression error"]])],["expr",new Map([[1,"expression is null or zero"],[2,"syntax error"]])],["find",new Map([[1,"partial success \u2014 some inputs could not be processed"]])],["robocopy",new Map([[1,"success \u2014 files copied"],[2,"success \u2014 extra files or directories detected"],[4,"success \u2014 mismatched files detected"],[8,"some files failed to copy"],[16,"serious error \u2014 no files copied"]])]]),ap=new Map([[126,"command found but not executable"],[127,"command not found"],[129,"terminated by SIGHUP"],[130,"terminated by SIGINT (Ctrl+C)"],[137,"killed by SIGKILL (often OOM)"],[141,"downstream consumer exited early (SIGPIPE)"],[143,"terminated by SIGTERM"]]),up=/^[+-]?\d+$/,dp=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/,hp="Error: command is required",pp="Error: timeout must be a finite number greater than 0 seconds",mp="Error: command interrupted",gp="Error: sandbox is enabled but unavailable; command was not executed",yp="Error: operation interrupted",Ep="Error: file_path is required",_p="Error: content is required",Sp="Error: offset must be >= 0 and limit must be >= 1",bp="Error: pattern is required",wp="Error: the pattern timed out while matching (likely catastrophic backtracking). Simplify it \u2014 avoid nested quantifiers such as (a+)+ \u2014 or narrow the path/include filter.",Rp="Error: url is required",Op="Error: fetch interrupted",Tp="Error: output is required",Ap="Error: query is required",xp="Error: slug must contain only alphanumeric, hyphen, underscore",Lp="Error: a runtime permission checker is required for worktree sessions",Ip="Error: must have 1-4 questions",Np="Error: file has not been read yet, read it first before editing.",Pp="Error: file was deleted or is no longer accessible; read it again before editing.",Mp="Error: file has been modified since last read, read it again before editing.",Dp="Tool execution was cancelled before it started.",vp="Plan mode is unavailable because no permission context exists.",kp="EnterPlanMode cannot be used from delegated agents.",Cp="You are not in plan mode. Continue within the user's requested scope and current permissions, or call EnterPlanMode first when the task genuinely needs planning. AskUserQuestion is for clarification, not approval.",Bp="You are not in plan mode. This tool is only for exiting plan mode after writing a plan.",Up="No non-empty plan file found. Write your plan to the declared plan file before calling ExitPlanMode.",$p="No leader plan approval handler is available for this teammate.",Fp="McpCall requires a 'tool' name",jp="McpCall requires an 'arguments' object matching the target schema",qp="Goals belong to the main session and are unavailable to delegated agents.",Wp="Updating a goal requires status and reason.",Vp="Goal update accepts only 'in_progress', 'complete', or 'blocked'. A goal is active as soon as the user sets it. Only the user can pause or resume a goal.",Gp="Goal expects action 'get' or 'update'. Updating requires status 'in_progress', 'complete', or 'blocked' and a non-empty reason; no other fields are accepted.";var es=Yi({module:"file-scan"});function Qp(e,t=lr){let r=[],n=0,i=Math.max(cr,t*fr),s=(f,o)=>{if(r.length>=t||n>=i)return;let l;try{l=Ea(f)}catch(u){es.error({err:u},"cwd scan failed");return}for(let u of l){if(r.length>=t||n>=i)return;if(n++,u.startsWith(".")||Zi.has(u))continue;let h=ba(f,u),d=o?`${o}/${u}`:u,g=!1;try{let p=_a(h);if(p.isSymbolicLink()){Sa(h).isFile()&&r.push(d);continue}if(!p.isDirectory()&&!p.isFile())continue;g=p.isDirectory()}catch(p){es.error({err:p},"cwd scan failed");continue}g?s(h,d):r.push(d)}};return s(e,""),r}function Zp(e,t,r=ar){let n=t.toLowerCase();if(!n)return e.slice(0,r);let i=e.filter(f=>f.toLowerCase().startsWith(n)),s=e.filter(f=>!f.toLowerCase().startsWith(n)&&f.toLowerCase().includes(n));return[...i,...s].slice(0,r)}import{stripVTControlCharacters as ja}from"util";import{lookup as Ra}from"dns/promises";import{request as Oa}from"http";import{request as Ta}from"https";import{BlockList as rs,isIP as qt}from"net";import{Readable as Aa}from"stream";var ns=new rs,is=new rs;for(let[e,t]of Zt)ns.addSubnet(e,t,"ipv4");for(let[e,t]of er)is.addSubnet(e,t,"ipv6");function xa(e){let t=qt(e);return t===4?!ns.check(e,"ipv4"):t===6?!is.check(e,"ipv6"):!1}var La=async e=>await Ra(e,{all:!0,order:"verbatim"});function Ia(e){return e.hostname.startsWith("[")&&e.hostname.endsWith("]")?e.hostname.slice(1,-1):e.hostname}async function Na(e,t){let r=e instanceof URL?e:new URL(e);if(r.protocol!=="http:"&&r.protocol!=="https:")throw new Error(tr);if(r.username||r.password)throw new Error(rr);let n=Ia(r),i=qt(n),f=(i?[{address:n,family:i}]:await t(n)).map(o=>({address:o.address,family:qt(o.address)}));if(f.length===0||f.some(o=>o.family!==4&&o.family!==6||!xa(o.address)))throw new Error(nr);return{url:r,addresses:f}}function Pa(e){let t=new Headers;for(let[r,n]of Object.entries(e))if(Array.isArray(n))for(let i of n)t.append(r,i);else n!==void 0&&t.set(r,n);return t}function Ma(e,t,r){let n=(s,f,o)=>{if(f.all){o(null,[r]);return}o(null,r.address,r.family)},i=e.protocol==="https:"?Ta:Oa;return new Promise((s,f)=>{let o=i(e,{headers:Object.fromEntries(new Headers(t.headers).entries()),lookup:n,method:t.method??"GET",signal:t.signal??void 0},l=>{let u=l.statusCode??500,h=Yt.has(u);s(new Response(h?null:Aa.toWeb(l),{headers:Pa(l.headers),status:u,statusText:l.statusMessage}))});o.once("error",f),o.end()})}async function Da(e,t,r){let n;for(let i of r)try{return await Ma(e,t,i)}catch(s){t.signal?.throwIfAborted(),n=s}throw n instanceof Error?n:new Error(ir,{cause:n})}function va(e){let t=(e.method??"GET").toUpperCase();if(t!=="GET"&&t!=="HEAD")throw new Error(`fetchPublicHttpUrl only supports GET or HEAD, received '${t}'`);if(e.body!==void 0&&e.body!==null)throw new Error(or)}async function om(e,t,r={}){va(t);let n=r.fetcher??globalThis.fetch,i=r.lookup??La,s=new URL(e);for(let f=0;;f++){let o=await Na(s,i);t.signal?.throwIfAborted();let l=r.fetcher?await n(o.url,{...t,redirect:"manual"}):await Da(o.url,t,o.addresses);if(!Xt.has(l.status))return l;if(await l.body?.cancel(),f>=5)throw new Error(`Skill download exceeded ${String(5)} redirects`);let u=l.headers.get("location");if(!u)throw new Error(sr);s=new URL(u,s)}}function Ca(){return Object.entries(process.env).flatMap(([e,t])=>Jt.test(e)&&t&&t.length>3?[t,encodeURIComponent(t)]:[])}function cm(e,t=Ca(),r=Kt){let n=e.replace(Qt,`$1${r}`);for(let i of[...t].filter(Boolean).sort((s,f)=>f.length-s.length))n=n.replaceAll(i,r);return n}import{randomBytes as Ua}from"crypto";function am(){let e=Date.now().toString(36),t=Ua(6).toString("hex");return`${e}-${t}`}function um(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function gm(e){return ja(e).replace(/\r\n?/gu,`
|
|
27
|
-
`).replace(new RegExp("\\p{Cc}","gu"),t=>t===`
|
|
28
|
-
`||t===" "?t:"")}function qa(e){if(typeof e=="string")return e;let t=[];for(let r of e)if(r.type==="text"&&typeof r.text=="string")t.push(r.text);else if(r.type==="image"&&Vt(r.source)){let n=r.source.type==="base64"&&typeof r.source.media_type=="string"?r.source.media_type:"image";t.push(`[Image: ${n}]`)}else if(r.type==="tool_reference"&&typeof r.tool_name=="string")t.push(`[Tool reference: ${r.tool_name}]`);else if(r.type==="search_result"){let n=typeof r.title=="string"?r.title:"search result",i=typeof r.source=="string"?` (${r.source})`:"",s=Array.isArray(r.content)?qa(r.content.filter(Vt)):"";t.push(`${n}${i}${s?`
|
|
29
|
-
${s}`:""}`)}else if(r.type==="document"){let n=typeof r.title=="string"?r.title:"document";t.push(`[Document: ${n}]`)}return t.join(`
|
|
30
|
-
`)}function Vt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ym(e){return Vt(e)?e:Array.isArray(e)?Object.fromEntries(e.entries()):{}}function Wa(e){return typeof e=="string"?e:String(e)}function Em(e){return e instanceof Error?e.message:Wa(e)}function _m(e){return typeof e=="object"&&e!==null}function Va(e){let t;if(typeof e=="number")t=e;else if(typeof e=="string"){let r=e.trim();if(!zt.test(r))return;t=Number(r)}else return;if(Number.isFinite(t))return Math.trunc(t)}function Sm(e,t,r){return Va(e[t])??r}function Ue(e,t,r){let n=e[t];return typeof n=="string"?n:r??""}function bm(e,t,r){let n=e[t];if(typeof n=="boolean")return n;if(typeof n=="string"){let i=n.trim().toLowerCase();if(i==="true"||i==="1")return!0;if(i==="false"||i==="0")return!1}if(typeof n=="number"){if(n===1)return!0;if(n===0)return!1}return r??!1}function wm(e){return e.command?Ue(e,"command"):e.file_path?Wt(Ue(e,"file_path"),he):e.pattern?Wt(Ue(e,"pattern"),he):e.description?Wt(Ue(e,"description"),he):""}function Wt(e,t){return e.length>t?`${e.slice(0,t)}\u2026`:e}export{se as a,pr as b,mr as c,Ja as d,pe as e,ce as f,Qa as g,ps as h,Za as i,eu as j,tu as k,sa as l,Q as m,Bu as n,Gi as o,Uu as p,$u as q,ju as r,qu as s,Wu as t,Vu as u,Gu as v,Hu as w,Ku as x,zu as y,Xu as z,Yu as A,Ju as B,Qu as C,Zu as D,ed as E,td as F,rd as G,nd as H,id as I,sd as J,od as K,ld as L,Hi as M,cd as N,fd as O,ad as P,ud as Q,dd as R,hd as S,pd as T,md as U,gd as V,yd as W,Ed as X,_d as Y,Sd as Z,bd as _,wd as $,Rd as aa,Od as ba,Td as ca,Ad as da,xd as ea,Ld as fa,Id as ga,Nd as ha,Pd as ia,Md as ja,Dd as ka,vd as la,kd as ma,Cd as na,Bd as oa,Ud as pa,$d as qa,Fd as ra,jd as sa,qd as ta,Wd as ua,Vd as va,Gd as wa,Hd as xa,Kd as ya,zd as za,Xd as Aa,Yd as Ba,Jd as Ca,Qd as Da,Zd as Ea,eh as Fa,th as Ga,rh as Ha,nh as Ia,ih as Ja,sh as Ka,ph as La,mh as Ma,pa as Na,gh as Oa,Yi as Pa,Eh as Qa,_h as Ra,wh as Sa,Rh as Ta,Oh as Ua,Th as Va,Ah as Wa,xh as Xa,Lh as Ya,Ih as Za,Nh as _a,Ph as $a,Mh as ab,Dh as bb,vh as cb,kh as db,Ch as eb,Bh as fb,Uh as gb,$h as hb,Fh as ib,jh as jb,qh as kb,Wh as lb,Vh as mb,Zi as nb,Gh as ob,Hh as pb,Kh as qb,zh as rb,Xh as sb,Yh as tb,Jh as ub,Qh as vb,Zh as wb,ep as xb,tp as yb,rp as zb,np as Ab,ip as Bb,sp as Cb,op as Db,lp as Eb,cp as Fb,fp as Gb,ap as Hb,up as Ib,dp as Jb,hp as Kb,pp as Lb,mp as Mb,gp as Nb,yp as Ob,Ep as Pb,_p as Qb,Sp as Rb,bp as Sb,wp as Tb,Rp as Ub,Op as Vb,Tp as Wb,Ap as Xb,xp as Yb,Lp as Zb,Ip as _b,Np as $b,Pp as ac,Mp as bc,Dp as cc,vp as dc,kp as ec,Cp as fc,Bp as gc,Up as hc,$p as ic,Fp as jc,jp as kc,qp as lc,Wp as mc,Vp as nc,Gp as oc,Qp as pc,Zp as qc,om as rc,Ca as sc,cm as tc,am as uc,um as vc,gm as wc,qa as xc,Vt as yc,ym as zc,Wa as Ac,Em as Bc,_m as Cc,Sm as Dc,Ue as Ec,bm as Fc,wm as Gc};
|
package/dist/chunk-VM4YKTHC.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
-
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{a as p,c as S,e as N}from"./chunk-7MKA3SHV.js";var T=S((Es,Ve)=>{"use strict";var $e=["nodebuffer","arraybuffer","fragments"],je=typeof Blob<"u";je&&$e.push("blob");Ve.exports={BINARY_TYPES:$e,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:je,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var X=S((vs,se)=>{"use strict";var{EMPTY_BUFFER:Yt}=T(),xe=Buffer[Symbol.species];function Kt(t,e){if(t.length===0)return Yt;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),s=0;for(let i=0;i<t.length;i++){let n=t[i];r.set(n,s),s+=n.length}return s<e?new xe(r.buffer,r.byteOffset,s):r}function ze(t,e,r,s,i){for(let n=0;n<i;n++)r[s+n]=t[n]^e[n&3]}function He(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Xt(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Se(t){if(Se.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new xe(t):ArrayBuffer.isView(t)?e=new xe(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Se.readOnly=!1),e}se.exports={concat:Kt,mask:ze,toArrayBuffer:Xt,toBuffer:Se,unmask:He};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=p("bufferutil");se.exports.mask=function(e,r,s,i,n){n<48?ze(e,r,s,i,n):t.mask(e,r,s,i,n)},se.exports.unmask=function(e,r){e.length<32?He(e,r):t.unmask(e,r)}}catch{}});var Xe=S((bs,Ke)=>{"use strict";var Ye=Symbol("kDone"),Ee=Symbol("kRun"),ve=class{constructor(e){this[Ye]=()=>{this.pending--,this[Ee]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ee]()}[Ee](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ye])}}};Ke.exports=ve});var G=S((ws,et)=>{"use strict";var Z=p("zlib"),Ze=X(),Zt=Xe(),{kStatusCode:Qe}=T(),Qt=Buffer[Symbol.species],Jt=Buffer.from([0,0,255,255]),ne=Symbol("permessage-deflate"),k=Symbol("total-length"),W=Symbol("callback"),P=Symbol("buffers"),q=Symbol("error"),ie,be=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ie){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ie=new Zt(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[W];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,s=e.find(i=>!(r.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>i.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&(typeof i.client_max_window_bits=="number"?r.clientMaxWindowBits>i.client_max_window_bits:!i.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(s.server_no_context_takeover=!0),r.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(s.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?s.client_max_window_bits=r.clientMaxWindowBits:(s.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(s=>{let i=r[s];if(i.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(i=i[0],s==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else if(s==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else throw new Error(`Unknown parameter "${s}"`);r[s]=i})}),e}decompress(e,r,s){ie.add(i=>{this._decompress(e,r,(n,o)=>{i(),s(n,o)})})}compress(e,r,s){ie.add(i=>{this._compress(e,r,(n,o)=>{i(),s(n,o)})})}_decompress(e,r,s){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Z.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ne]=this,this._inflate[k]=0,this._inflate[P]=[],this._inflate.on("error",tr),this._inflate.on("data",Je)}this._inflate[W]=s,this._inflate.write(e),r&&this._inflate.write(Jt),this._inflate.flush(()=>{let n=this._inflate[q];if(n){this._inflate.close(),this._inflate=null,s(n);return}let o=Ze.concat(this._inflate[P],this._inflate[k]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[k]=0,this._inflate[P]=[],r&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),s(null,o)})}_compress(e,r,s){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Z.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[k]=0,this._deflate[P]=[],this._deflate.on("data",er)}this._deflate[W]=s,this._deflate.write(e),this._deflate.flush(Z.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Ze.concat(this._deflate[P],this._deflate[k]);r&&(n=new Qt(n.buffer,n.byteOffset,n.length-4)),this._deflate[W]=null,this._deflate[k]=0,this._deflate[P]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),s(null,n)})}};et.exports=be;function er(t){this[P].push(t),this[k]+=t.length}function Je(t){if(this[k]+=t.length,this[ne]._maxPayload<1||this[k]<=this[ne]._maxPayload){this[P].push(t);return}this[q]=new RangeError("Max payload size exceeded"),this[q].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[q][Qe]=1009,this.removeListener("data",Je),this.reset()}function tr(t){if(this[ne]._inflate=null,this[q]){this[W](this[q]);return}t[Qe]=1007,this[W](t)}});var $=S((Os,oe)=>{"use strict";var{isUtf8:tt}=p("buffer"),{hasBlob:rr}=T(),sr=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function ir(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function we(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function nr(t){return rr&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}oe.exports={isBlob:nr,isValidStatusCode:ir,isValidUTF8:we,tokenChars:sr};if(tt)oe.exports.isValidUTF8=function(t){return t.length<24?we(t):tt(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=p("utf-8-validate");oe.exports.isValidUTF8=function(e){return e.length<32?we(e):t(e)}}catch{}});var Le=S((Ts,ft)=>{"use strict";var{Writable:or}=p("stream"),rt=G(),{BINARY_TYPES:ar,EMPTY_BUFFER:st,kStatusCode:fr,kWebSocket:lr}=T(),{concat:Oe,toArrayBuffer:hr,unmask:cr}=X(),{isValidStatusCode:ur,isValidUTF8:it}=$(),ae=Buffer[Symbol.species],v=0,nt=1,ot=2,at=3,Te=4,ke=5,fe=6,Ce=class extends or{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||ar[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[lr]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=v}_write(e,r,s){if(this._opcode===8&&this._state==v)return s();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){s(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=new ae(s.buffer,s.byteOffset+e,s.length-e),new ae(s.buffer,s.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let s=this._buffers[0],i=r.length-e;e>=s.length?r.set(this._buffers.shift(),i):(r.set(new Uint8Array(s.buffer,s.byteOffset,e),i),this._buffers[0]=new ae(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case v:this.getInfo(e);break;case nt:this.getPayloadLength16(e);break;case ot:this.getPayloadLength64(e);break;case at:this.getMask();break;case Te:this.getData(e);break;case ke:case fe:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let s=(r[0]&64)===64;if(s&&!this._extensions[rt.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=nt:this._payloadLength===127?this._state=ot:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),s=r.readUInt32BE(0);if(s>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=s*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=at:this._state=Te}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Te}getData(e){let r=st;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&cr(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let s=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(s);return}if(this._compressed){this._state=ke,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[rt.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return r(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(o);return}this._fragments.push(n)}this.dataMessage(r),this._state===v&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=v;return}let r=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Oe(s,r):this._binaryType==="arraybuffer"?i=hr(Oe(s,r)):this._binaryType==="blob"?i=new Blob(s):i=s,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!0),this._state=v,this.startLoop(e)}))}else{let i=Oe(s,r);if(!this._skipUTF8Validation&&!it(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===ke||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!1),this._state=v,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,st),this.end();else{let s=e.readUInt16BE(0);if(!ur(s)){let n=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(n);return}let i=new ae(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!it(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(n);return}this._loop=!1,this.emit("conclude",s,i),this.end()}this._state=v;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=v):(this._state=fe,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=v,this.startLoop(r)}))}createError(e,r,s,i,n){this._loop=!1,this._errored=!0;let o=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(o,this.createError),o.code=n,o[fr]=i,o}};ft.exports=Ce});var Be=S((Cs,ct)=>{"use strict";var{Duplex:ks}=p("stream"),{randomFillSync:dr}=p("crypto"),{types:{isUint8Array:_r}}=p("util"),lt=G(),{EMPTY_BUFFER:mr,kWebSocket:pr,NOOP:gr}=T(),{isBlob:j,isValidStatusCode:yr}=$(),{mask:ht,toBuffer:R}=X(),b=Symbol("kByteLength"),xr=Buffer.alloc(4),le=8*1024,U,V=le,w=0,Sr=1,Er=2,Ne=class t{constructor(e,r,s){this._extensions=r||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=w,this.onerror=gr,this[pr]=void 0}static frame(e,r){let s,i=!1,n=2,o=!1;r.mask&&(s=r.maskBuffer||xr,r.generateMask?r.generateMask(s):(V===le&&(U===void 0&&(U=Buffer.alloc(le)),dr(U,0,le),V=0),s[0]=U[V++],s[1]=U[V++],s[2]=U[V++],s[3]=U[V++]),o=(s[0]|s[1]|s[2]|s[3])===0,n=6);let f;typeof e=="string"?(!r.mask||o)&&r[b]!==void 0?f=r[b]:(e=Buffer.from(e),f=e.length):(f=e.length,i=r.mask&&r.readOnly&&!o);let l=f;f>=65536?(n+=8,l=127):f>125&&(n+=2,l=126);let a=Buffer.allocUnsafe(i?f+n:n);return a[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(a[0]|=64),a[1]=l,l===126?a.writeUInt16BE(f,2):l===127&&(a[2]=a[3]=0,a.writeUIntBE(f,4,6)),r.mask?(a[1]|=128,a[n-4]=s[0],a[n-3]=s[1],a[n-2]=s[2],a[n-1]=s[3],o?[a,e]:i?(ht(e,s,a,n,f),[a]):(ht(e,s,e,0,f),[a,e])):[a,e]}close(e,r,s,i){let n;if(e===void 0)n=mr;else{if(typeof e!="number"||!yr(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let f=Buffer.byteLength(r);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");if(n=Buffer.allocUnsafe(2+f),n.writeUInt16BE(e,0),typeof r=="string")n.write(r,2);else if(_r(r))n.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[b]:n.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==w?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==w?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}pong(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==w?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}send(e,r,s){let i=this._extensions[lt.extensionName],n=r.binary?2:1,o=r.compress,f,l;typeof e=="string"?(f=Buffer.byteLength(e),l=!1):j(e)?(f=e.size,l=!1):(e=R(e),f=e.length,l=R.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=f>=i._threshold),this._compress=o):(o=!1,n=0),r.fin&&(this._firstFragment=!0);let a={[b]:f,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,this._compress,a,s]):this.getBlobData(e,this._compress,a,s):this._state!==w?this.enqueue([this.dispatch,e,this._compress,a,s]):this.dispatch(e,this._compress,a,s)}getBlobData(e,r,s,i){this._bufferedBytes+=s[b],this._state=Er,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Pe,this,f,i);return}this._bufferedBytes-=s[b];let o=R(n);r?this.dispatch(o,r,s,i):(this._state=w,this.sendFrame(t.frame(o,s),i),this.dequeue())}).catch(n=>{process.nextTick(vr,this,n,i)})}dispatch(e,r,s,i){if(!r){this.sendFrame(t.frame(e,s),i);return}let n=this._extensions[lt.extensionName];this._bufferedBytes+=s[b],this._state=Sr,n.compress(e,s.fin,(o,f)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Pe(this,l,i);return}this._bufferedBytes-=s[b],this._state=w,s.readOnly=!1,this.sendFrame(t.frame(f,s),i),this.dequeue()})}dequeue(){for(;this._state===w&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][b],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][b],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};ct.exports=Ne;function Pe(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let i=t._queue[s],n=i[i.length-1];typeof n=="function"&&n(e)}}function vr(t,e,r){Pe(t,e,r),t.onerror(e)}});var St=S((Ls,xt)=>{"use strict";var{kForOnEventAttribute:Q,kListener:Re}=T(),ut=Symbol("kCode"),dt=Symbol("kData"),_t=Symbol("kError"),mt=Symbol("kMessage"),pt=Symbol("kReason"),z=Symbol("kTarget"),gt=Symbol("kType"),yt=Symbol("kWasClean"),C=class{constructor(e){this[z]=null,this[gt]=e}get target(){return this[z]}get type(){return this[gt]}};Object.defineProperty(C.prototype,"target",{enumerable:!0});Object.defineProperty(C.prototype,"type",{enumerable:!0});var I=class extends C{constructor(e,r={}){super(e),this[ut]=r.code===void 0?0:r.code,this[pt]=r.reason===void 0?"":r.reason,this[yt]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[ut]}get reason(){return this[pt]}get wasClean(){return this[yt]}};Object.defineProperty(I.prototype,"code",{enumerable:!0});Object.defineProperty(I.prototype,"reason",{enumerable:!0});Object.defineProperty(I.prototype,"wasClean",{enumerable:!0});var H=class extends C{constructor(e,r={}){super(e),this[_t]=r.error===void 0?null:r.error,this[mt]=r.message===void 0?"":r.message}get error(){return this[_t]}get message(){return this[mt]}};Object.defineProperty(H.prototype,"error",{enumerable:!0});Object.defineProperty(H.prototype,"message",{enumerable:!0});var J=class extends C{constructor(e,r={}){super(e),this[dt]=r.data===void 0?null:r.data}get data(){return this[dt]}};Object.defineProperty(J.prototype,"data",{enumerable:!0});var br={addEventListener(t,e,r={}){for(let i of this.listeners(t))if(!r[Q]&&i[Re]===e&&!i[Q])return;let s;if(t==="message")s=function(n,o){let f=new J("message",{data:o?n:n.toString()});f[z]=this,he(e,this,f)};else if(t==="close")s=function(n,o){let f=new I("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[z]=this,he(e,this,f)};else if(t==="error")s=function(n){let o=new H("error",{error:n,message:n.message});o[z]=this,he(e,this,o)};else if(t==="open")s=function(){let n=new C("open");n[z]=this,he(e,this,n)};else return;s[Q]=!!r[Q],s[Re]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Re]===e&&!r[Q]){this.removeListener(t,r);break}}};xt.exports={CloseEvent:I,ErrorEvent:H,Event:C,EventTarget:br,MessageEvent:J};function he(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ce=S((Ns,Et)=>{"use strict";var{tokenChars:ee}=$();function O(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function wr(t){let e=Object.create(null),r=Object.create(null),s=!1,i=!1,n=!1,o,f,l=-1,a=-1,h=-1,c=0;for(;c<t.length;c++)if(a=t.charCodeAt(c),o===void 0)if(h===-1&&ee[a]===1)l===-1&&(l=c);else if(c!==0&&(a===32||a===9))h===-1&&l!==-1&&(h=c);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);a===44?(O(e,g,r),r=Object.create(null)):o=g,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(f===void 0)if(h===-1&&ee[a]===1)l===-1&&(l=c);else if(a===32||a===9)h===-1&&l!==-1&&(h=c);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c),O(r,t.slice(l,h),!0),a===44&&(O(e,o,r),r=Object.create(null),o=void 0),l=h=-1}else if(a===61&&l!==-1&&h===-1)f=t.slice(l,c),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(ee[a]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);l===-1?l=c:s||(s=!0),i=!1}else if(n)if(ee[a]===1)l===-1&&(l=c);else if(a===34&&l!==-1)n=!1,h=c;else if(a===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(a===34&&t.charCodeAt(c-1)===61)n=!0;else if(h===-1&&ee[a]===1)l===-1&&(l=c);else if(l!==-1&&(a===32||a===9))h===-1&&(h=c);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);s&&(g=g.replace(/\\/g,""),s=!1),O(r,f,g),a===44&&(O(e,o,r),r=Object.create(null),o=void 0),f=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(l===-1||n||a===32||a===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=c);let _=t.slice(l,h);return o===void 0?O(e,_,r):(f===void 0?O(r,_,!0):s?O(r,f,_.replace(/\\/g,"")):O(r,f,_),O(e,o,r)),e}function Or(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(i=>{let n=s[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Et.exports={format:Or,parse:wr}});var me=S((Rs,Rt)=>{"use strict";var Tr=p("events"),kr=p("https"),Cr=p("http"),wt=p("net"),Lr=p("tls"),{randomBytes:Nr,createHash:Pr}=p("crypto"),{Duplex:Ps,Readable:Bs}=p("stream"),{URL:Ue}=p("url"),B=G(),Br=Le(),Rr=Be(),{isBlob:Ur}=$(),{BINARY_TYPES:vt,CLOSE_TIMEOUT:Ir,EMPTY_BUFFER:ue,GUID:Dr,kForOnEventAttribute:Ie,kListener:Mr,kStatusCode:Ar,kWebSocket:y,NOOP:Ot}=T(),{EventTarget:{addEventListener:Fr,removeEventListener:Wr}}=St(),{format:qr,parse:Gr}=ce(),{toBuffer:$r}=X(),Tt=Symbol("kAborted"),De=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],jr=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,d=class t extends Tr{constructor(e,r,s){super(),this._binaryType=vt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ue,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?!s||s.protocols===void 0?r=[]:Array.isArray(s.protocols)?r=s.protocols:r=[s.protocols]:Array.isArray(r)||(typeof r=="object"&&r!==null?(s=r,s.protocols===void 0?r=[]:Array.isArray(s.protocols)?r=s.protocols:r=[s.protocols]):r=[r]),kt(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){vt.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,s){let i=new Br({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:s.maxBufferedChunks,maxFragments:s.maxFragments,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),n=new Rr(e,this._extensions,s.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[y]=this,n[y]=this,e[y]=this,i.on("conclude",Hr),i.on("drain",Yr),i.on("error",Kr),i.on("message",Xr),i.on("ping",Zr),i.on("pong",Qr),n.onerror=Jr,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Nt),e.on("data",_e),e.on("end",Pt),e.on("error",Bt),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[B.extensionName]&&this._extensions[B.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._sender.close(e,r,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._readyState=t.CLOSING,Lt(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Me(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||ue,r,s)}pong(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Me(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||ue,r,s)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(s=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Me(this,e,s);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[B.extensionName]||(i.compress=!1),this._sender.send(e||ue,i,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(d,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});Object.defineProperty(d.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(d.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(d.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ie])return e[Mr];return null},set(e){for(let r of this.listeners(t))if(r[Ie]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Ie]:!0})}})});d.prototype.addEventListener=Fr;d.prototype.removeEventListener=Wr;Rt.exports=d;function kt(t,e,r,s){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Ir,protocolVersion:De[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,protocols:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,t._closeTimeout=i.closeTimeout,!De.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${De.join(", ")})`);let n;if(e instanceof Ue)n=e;else try{n=new Ue(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",f=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!f?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let u=new SyntaxError(l);if(t._redirects===0)throw u;de(t,u);return}let a=o?443:80,h=Nr(16).toString("base64"),c=o?kr.request:Cr.request,_=new Set,g;if(i.createConnection=i.createConnection||(o?zr:Vr),i.defaultPort=i.defaultPort||a,i.port=n.port||a,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(g=new B({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=qr({[B.extensionName]:g.offer()})),r.length){for(let u of r){if(typeof u!="string"||!jr.test(u)||_.has(u))throw new SyntaxError("An invalid or duplicated subprotocol was specified");_.add(u)}i.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),f){let u=i.path.split(":");i.socketPath=u[0],i.path=u[1]}let m;if(i.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=o,t._originalHostOrSocketPath=f?i.socketPath:n.host;let u=s&&s.headers;if(s={...s,headers:{}},u)for(let[x,A]of Object.entries(u))s.headers[x.toLowerCase()]=A}else if(t.listenerCount("redirect")===0){let u=f?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!u||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,u||delete i.headers.host,i.auth=void 0)}i.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),m=t._req=c(i),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=c(i);i.timeout&&m.on("timeout",()=>{E(t,m,"Opening handshake has timed out")}),m.on("error",u=>{m===null||m[Tt]||(m=t._req=null,de(t,u))}),m.on("response",u=>{let x=u.headers.location,A=u.statusCode;if(x&&i.followRedirects&&A>=300&&A<400){if(++t._redirects>i.maxRedirects){E(t,m,"Maximum redirects exceeded");return}m.abort();let Y;try{Y=new Ue(x,e)}catch{let F=new SyntaxError(`Invalid URL: ${x}`);de(t,F);return}kt(t,Y,r,s)}else t.emit("unexpected-response",m,u)||E(t,m,`Unexpected server response: ${u.statusCode}`)}),m.on("upgrade",(u,x,A)=>{if(t.emit("upgrade",u),t.readyState!==d.CONNECTING)return;m=t._req=null;let Y=u.headers.upgrade;if(Y===void 0||Y.toLowerCase()!=="websocket"){E(t,x,"Invalid Upgrade header");return}let We=Pr("sha1").update(h+Dr).digest("base64");if(u.headers["sec-websocket-accept"]!==We){E(t,x,"Invalid Sec-WebSocket-Accept header");return}let F=u.headers["sec-websocket-protocol"],K;if(F!==void 0?_.size?_.has(F)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":_.size&&(K="Server sent no subprotocol"),K){E(t,x,K);return}F&&(t._protocol=F);let qe=u.headers["sec-websocket-extensions"];if(qe!==void 0){if(!g){E(t,x,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ge;try{ge=Gr(qe)}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}let Ge=Object.keys(ge);if(Ge.length!==1||Ge[0]!==B.extensionName){E(t,x,"Server indicated an extension that was not requested");return}try{g.accept(ge[B.extensionName])}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[B.extensionName]=g}t.setSocket(x,A,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(m,t):m.end()}function de(t,e){t._readyState=d.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Vr(t){return t.path=t.socketPath,wt.connect(t)}function zr(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=wt.isIP(t.host)?"":t.host),Lr.connect(t)}function E(t,e,r){t._readyState=d.CLOSING;let s=new Error(r);Error.captureStackTrace(s,E),e.setHeader?(e[Tt]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(de,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Me(t,e,r){if(e){let s=Ur(e)?e.size:$r(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${L[t.readyState]})`);process.nextTick(r,s)}}function Hr(t,e){let r=this[y];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[y]!==void 0&&(r._socket.removeListener("data",_e),process.nextTick(Ct,r._socket),t===1005?r.close():r.close(t,e))}function Yr(){let t=this[y];t.isPaused||t._socket.resume()}function Kr(t){let e=this[y];e._socket[y]!==void 0&&(e._socket.removeListener("data",_e),process.nextTick(Ct,e._socket),e.close(t[Ar])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function bt(){this[y].emitClose()}function Xr(t,e){this[y].emit("message",t,e)}function Zr(t){let e=this[y];e._autoPong&&e.pong(t,!this._isServer,Ot),e.emit("ping",t)}function Qr(t){this[y].emit("pong",t)}function Ct(t){t.resume()}function Jr(t){let e=this[y];e.readyState!==d.CLOSED&&(e.readyState===d.OPEN&&(e._readyState=d.CLOSING,Lt(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Lt(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Nt(){let t=this[y];if(this.removeListener("close",Nt),this.removeListener("data",_e),this.removeListener("end",Pt),t._readyState=d.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",bt),t._receiver.on("finish",bt))}function _e(t){this[y]._receiver.write(t)||this.pause()}function Pt(){let t=this[y];t._readyState=d.CLOSING,t._receiver.end(),this.end()}function Bt(){let t=this[y];this.removeListener("error",Bt),this.on("error",Ot),t&&(t._readyState=d.CLOSING,this.destroy())}});var Mt=S((Is,Dt)=>{"use strict";var Us=me(),{Duplex:es}=p("stream");function Ut(t){t.emit("close")}function ts(){!this.destroyed&&this._writableState.finished&&this.destroy()}function It(t){this.removeListener("error",It),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function rs(t,e){let r=!0,s=new es({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let f=!o&&s._readableState.objectMode?n.toString():n;s.push(f)||t.pause()}),t.once("error",function(n){s.destroyed||(r=!1,s.destroy(n))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(Ut,s);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(Ut,s)}),r&&t.terminate()},s._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},s._read=function(){t.isPaused&&t.resume()},s._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(i,n,o)});return}t.send(i,o)},s.on("end",ts),s.on("error",It),s}Dt.exports=rs});var Ae=S((Ds,At)=>{"use strict";var{tokenChars:ss}=$();function is(t){let e=new Set,r=-1,s=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(s===-1&&ss[o]===1)r===-1&&(r=i);else if(i!==0&&(o===32||o===9))s===-1&&r!==-1&&(s=i);else if(o===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${i}`);s===-1&&(s=i);let f=t.slice(r,s);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(r,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}At.exports={parse:is}});var Vt=S((As,jt)=>{"use strict";var ns=p("events"),pe=p("http"),{Duplex:Ms}=p("stream"),{createHash:os}=p("crypto"),Ft=ce(),D=G(),as=Ae(),fs=me(),{CLOSE_TIMEOUT:ls,GUID:hs,kWebSocket:cs}=T(),us=/^[+/0-9A-Za-z]{22}==$/,Wt=0,qt=1,$t=2,Fe=class extends ns{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:ls,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:fs,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pe.createServer((s,i)=>{let n=pe.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=ds(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Wt}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===$t){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(te,this);return}if(e&&this.once("close",e),this._state!==qt)if(this._state=qt,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(te,this):process.nextTick(te,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{te(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,s,i){r.on("error",Gt);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){M(this,e,r,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){M(this,e,r,400,"Invalid Upgrade header");return}if(n===void 0||!us.test(n)){M(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){M(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){re(r,400);return}let l=e.headers["sec-websocket-protocol"],a=new Set;if(l!==void 0)try{a=as.parse(l)}catch{M(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&h!==void 0){let _=new D({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let g=Ft.parse(h);g[D.extensionName]&&(_.accept(g[D.extensionName]),c[D.extensionName]=_)}catch{M(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let _={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(_,(g,m,u,x)=>{if(!g)return re(r,m||401,u,x);this.completeUpgrade(c,n,a,e,r,s,i)});return}if(!this.options.verifyClient(_))return re(r,401)}this.completeUpgrade(c,n,a,e,r,s,i)}completeUpgrade(e,r,s,i,n,o,f){if(!n.readable||!n.writable)return n.destroy();if(n[cs])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Wt)return re(n,503);let a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${os("sha1").update(r+hs).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(s.size){let c=this.options.handleProtocols?this.options.handleProtocols(s,i):s.values().next().value;c&&(a.push(`Sec-WebSocket-Protocol: ${c}`),h._protocol=c)}if(e[D.extensionName]){let c=e[D.extensionName].params,_=Ft.format({[D.extensionName]:[c]});a.push(`Sec-WebSocket-Extensions: ${_}`),h._extensions=e}this.emit("headers",a,i),n.write(a.concat(`\r
|
|
5
|
-
`).join(`\r
|
|
6
|
-
`)),n.removeListener("error",Gt),h.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(te,this)})),f(h,i)}};jt.exports=Fe;function ds(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let s of Object.keys(e))t.removeListener(s,e[s])}}function te(t){t._state=$t,t.emit("close")}function Gt(){this.destroy()}function re(t,e,r,s){r=r||pe.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${pe.STATUS_CODES[e]}\r
|
|
7
|
-
`+Object.keys(s).map(i=>`${i}: ${s[i]}`).join(`\r
|
|
8
|
-
`)+`\r
|
|
9
|
-
\r
|
|
10
|
-
`+r)}function M(t,e,r,s,i,n){if(t.listenerCount("wsClientError")){let o=new Error(i);Error.captureStackTrace(o,M),t.emit("wsClientError",o,r,e)}else re(r,s,i,n)}});var _s=N(Mt(),1),ms=N(ce(),1),ps=N(G(),1),gs=N(Le(),1),ys=N(Be(),1),xs=N(Ae(),1),zt=N(me(),1),Ss=N(Vt(),1);var Fs=zt.default;export{zt as a,Ss as b,Fs as c};
|
package/dist/chunk-WKTO7XPO.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
-
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{sc as _,tc as s,yc as O}from"./chunk-5AOJ5ZSQ.js";var L="yukino",N="@yukino.js/yukino",I="none",S="console",l="otlp",u="prometheus",x="grpc",k="http/json",i="http/protobuf",a=i,y="agent",P="generation",M="tool",C="DEFAULT",U="ERROR",d="error.type",f="yukino.mode",D="session.hash",V="token.type",B="yukino.agent.runs",m="yukino.agent.duration",G="yukino.llm.requests",g="yukino.llm.tokens",h="yukino.llm.time_to_first_token",H="yukino.llm.duration",K="yukino.tool.calls",F="yukino.tool.duration",X="yukino.agent.run",b="yukino.llm.generate",j="yukino.tool.execute",v="yukino.error",w="yukino.llm.error",Y="yukino.tool.error",$="ms",W=0,q="Tool returned an error",r="[redacted]",R=/(?:authorization|api[_-]?key|password|secret|credential|(?:^|[_-])token(?:$|[_-])|access[_-]?token|refresh[_-]?token|private[_-]?key|(?:^|[_-])dsn(?:$|[_-])|^(?:cookie|set-cookie)$)/iu;import{homedir as A}from"os";function to(c){let p=_(),T=o=>{o=s(o,p,r);let t=A();return t&&t!=="/"&&(o=o.replaceAll(t,"~").replaceAll(encodeURIComponent(t),"~")),o},E=new WeakSet,n=o=>{if(!(typeof o!="object"||o===null||E.has(o))){if(E.add(o),Array.isArray(o))for(let t=0;t<o.length;t++){let e=o[t];typeof e=="string"?o[t]=T(e):n(e)}else if(O(o))for(let[t,e]of Object.entries(o))R.test(t)?o[t]=r:typeof e=="string"?o[t]=T(e):n(e)}};n(c)}export{L as a,N as b,I as c,S as d,l as e,u as f,x as g,k as h,i,a as j,y as k,P as l,M as m,C as n,U as o,d as p,f as q,D as r,V as s,B as t,m as u,G as v,g as w,h as x,H as y,K as z,F as A,X as B,b as C,j as D,v as E,w as F,Y as G,$ as H,W as I,q as J,to as K};
|