@niwa-labs/ncode 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/CHANGELOG.zh-CN.md +5 -0
  3. package/README.md +2 -2
  4. package/chunks/{application-A3S2LMBY.js → application-6B6N6MDM.js} +1 -1
  5. package/chunks/{auth-command-QNQ32TBI.js → auth-command-L57HWPOO.js} +1 -1
  6. package/chunks/{chunk-6LDRLO4Y.js → chunk-3LRARE6Z.js} +1 -1
  7. package/chunks/{chunk-5R2PGOIA.js → chunk-3MLT4F77.js} +1 -1
  8. package/chunks/{chunk-NOGL6Y6L.js → chunk-7F3QKGB7.js} +1 -1
  9. package/chunks/{chunk-LFGHL5A2.js → chunk-ALZZ3WAV.js} +1 -1
  10. package/chunks/{chunk-RD7XROJD.js → chunk-CUPCI2YC.js} +1 -1
  11. package/chunks/{chunk-OOBSLGMR.js → chunk-DBSRTVJC.js} +1 -1
  12. package/chunks/{chunk-XSWWOH4F.js → chunk-GS7TCNDK.js} +1 -1
  13. package/chunks/{chunk-36COWQLE.js → chunk-GZPVFWYD.js} +1 -1
  14. package/chunks/{chunk-CAY2BP2G.js → chunk-JEHPL5Z6.js} +1 -1
  15. package/chunks/{chunk-R7NDEPS3.js → chunk-LC7ZI6EV.js} +1 -1
  16. package/chunks/{chunk-ELHMZ5OD.js → chunk-NWMN2FDO.js} +1 -1
  17. package/chunks/{chunk-MVI24MQ2.js → chunk-O5EROATK.js} +664 -664
  18. package/chunks/{chunk-UMGGEC4N.js → chunk-QIYZZJVO.js} +1 -1
  19. package/chunks/{chunk-PBGCNSGZ.js → chunk-QMBFFQPV.js} +1 -1
  20. package/chunks/{chunk-JLFN6WSO.js → chunk-RZDVNG5Z.js} +1 -1
  21. package/chunks/{chunk-MI4YWYJF.js → chunk-UEPKZSE6.js} +1 -1
  22. package/chunks/{chunk-V4IDVAIA.js → chunk-WHBWI5OQ.js} +1 -1
  23. package/chunks/{chunk-ZPIJSTUE.js → chunk-WUORF7YS.js} +1 -1
  24. package/chunks/{chunk-UNEPZJKK.js → chunk-XWNCITOR.js} +5 -5
  25. package/chunks/{data-dir-OKWMOLNQ.js → data-dir-6RWVCAMB.js} +1 -1
  26. package/chunks/{launcher-4QSNU24J.js → launcher-B3C4PQ6Q.js} +3 -3
  27. package/chunks/{lifecycle-ELQ2EYO3.js → lifecycle-56K655PJ.js} +1 -1
  28. package/chunks/main-W3SJ2POE.js +14 -0
  29. package/chunks/{plugin-command-NGTATXBX.js → plugin-command-EBSKJLM3.js} +1 -1
  30. package/chunks/{profile-command-ZHVREBWO.js → profile-command-HIJDJDEL.js} +1 -1
  31. package/chunks/{provider-command-BGKOLCUG.js → provider-command-VCCPLOXR.js} +1 -1
  32. package/chunks/{run-acp-command-2CJQDXHQ.js → run-acp-command-FBV27QBE.js} +13 -13
  33. package/chunks/run-daemon-command-PZ2TU524.js +2 -0
  34. package/chunks/run-exec-command-K7BC2HEI.js +16 -0
  35. package/chunks/src-7ZMHMWLX.js +2 -0
  36. package/chunks/{telemetry-command-6FE4WQ4Q.js → telemetry-command-ZYOF64Y4.js} +1 -1
  37. package/chunks/{update-4VPIX7FP.js → update-ZKUCGIOR.js} +1 -1
  38. package/cli.js +3 -3
  39. package/matrix-mcp-stdio.js +1 -1
  40. package/mcoded.js +1 -1
  41. package/package.json +1 -1
  42. package/release.json +4 -4
  43. package/chunks/main-TXP74KHK.js +0 -14
  44. package/chunks/run-daemon-command-NDOIPTKF.js +0 -2
  45. package/chunks/run-exec-command-VNT4IKOJ.js +0 -16
  46. package/chunks/src-ED5HBSWE.js +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Ncode changelog
2
2
 
3
+ ## 0.1.1 · 2026-11-22
4
+
5
+ - Disable built-in tools for ACP or exec with `--no-builtin-tools`. ACP clients can also pass `--session-mcp-only` to limit discovery to servers supplied on session creation or load.
6
+ - Based on MCode 0.7.2 with Pi 1.6.0.
7
+
3
8
  ## 0.1.0 · 2026-11-22
4
9
 
5
10
  - Ncode is based on MCode 0.7.2 and runs Pi 1.6.0. `ncode --version` lists all three versions. HTTP requests identify the fork as `ncode/0.1.0`.
@@ -1,5 +1,10 @@
1
1
  # Ncode 更新日志
2
2
 
3
+ ## 0.1.1 · 2026-11-22
4
+
5
+ - ACP 和 exec 支持通过 `--no-builtin-tools` 禁用内置工具。ACP 客户端还可传入 `--session-mcp-only`,仅加载创建或恢复会话时传入的 MCP 服务器。
6
+ - 基于 MCode 0.7.2,内置 Pi 1.6.0。
7
+
3
8
  ## 0.1.0 · 2026-11-22
4
9
 
5
10
  - Ncode 基于 MCode 0.7.2,内置 Pi 1.6.0。`ncode --version` 分行显示三个版本,HTTP 请求通过 `ncode/0.1.0` 标识本客户端。
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # Ncode 0.1.0
1
+ # Ncode 0.1.1
2
2
 
3
3
  Ncode by Niwa Labs for MiniMax. An independent fork of MiniMax Code (MCode), built with Pi, with durable sessions, a local daemon and ACP.
4
- Built locally from source commit 8e781966bdbd2089827a83d316a832f6334075be.
4
+ Built locally from source commit bb58473d6fc6130fcb5bc68225fe43146ac6b502.
5
5
  Install with `npm install --global @niwa-labs/ncode`. Node.js must satisfy the package engines requirement.
6
6
  Keep optional dependencies enabled and allow better-sqlite3 installation scripts.
7
7
  Run `ncode` after installation.
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
2
- import{a}from"./chunk-LFGHL5A2.js";import"./chunk-PGYNNAKS.js";import"./chunk-V6SXVN2Z.js";import"./chunk-7WOIEENL.js";import"./chunk-PIADSVUZ.js";import"./chunk-5R2PGOIA.js";import"./chunk-UQL67NEA.js";import"./chunk-6MFNDZP7.js";import"./chunk-NOGL6Y6L.js";import"./chunk-FK3SSGJE.js";export{a as McodeUpdateApplication};
2
+ import{a}from"./chunk-ALZZ3WAV.js";import"./chunk-PGYNNAKS.js";import"./chunk-V6SXVN2Z.js";import"./chunk-7WOIEENL.js";import"./chunk-PIADSVUZ.js";import"./chunk-3MLT4F77.js";import"./chunk-UQL67NEA.js";import"./chunk-6MFNDZP7.js";import"./chunk-7F3QKGB7.js";import"./chunk-FK3SSGJE.js";export{a as McodeUpdateApplication};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
2
- import{a as n,b as l,c}from"./chunk-OOBSLGMR.js";import"./chunk-PBGCNSGZ.js";import"./chunk-6LDRLO4Y.js";import{d as p}from"./chunk-R7NDEPS3.js";import"./chunk-ZPIJSTUE.js";import"./chunk-V4IDVAIA.js";import"./chunk-TRX2HFTB.js";import"./chunk-UNEPZJKK.js";import"./chunk-ISBSRM3S.js";import"./chunk-5R2PGOIA.js";import"./chunk-UQL67NEA.js";import"./chunk-4GGSPZK3.js";import"./chunk-AUG3KCLV.js";import"./chunk-NOGL6Y6L.js";import"./chunk-FK3SSGJE.js";async function h(r={}){const i=r.createApplication?r.createApplication(r.region):await u(r.region,r.prepareDataDir,r.profile,r.fetchImpl);const t=r.writeError??(e=>process.stderr.write(e));const a=await i.login(e=>{const o=l(e.verificationUriComplete??e.verificationUri);t(`Open: ${o}
2
+ import{a as n,b as l,c}from"./chunk-DBSRTVJC.js";import"./chunk-QMBFFQPV.js";import"./chunk-3LRARE6Z.js";import{d as p}from"./chunk-LC7ZI6EV.js";import"./chunk-WUORF7YS.js";import"./chunk-WHBWI5OQ.js";import"./chunk-TRX2HFTB.js";import"./chunk-XWNCITOR.js";import"./chunk-ISBSRM3S.js";import"./chunk-3MLT4F77.js";import"./chunk-UQL67NEA.js";import"./chunk-4GGSPZK3.js";import"./chunk-AUG3KCLV.js";import"./chunk-7F3QKGB7.js";import"./chunk-FK3SSGJE.js";async function h(r={}){const i=r.createApplication?r.createApplication(r.region):await u(r.region,r.prepareDataDir,r.profile,r.fetchImpl);const t=r.writeError??(e=>process.stderr.write(e));const a=await i.login(e=>{const o=l(e.verificationUriComplete??e.verificationUri);t(`Open: ${o}
3
3
  Code: ${e.userCode}
4
4
  Waiting for authorization\u2026
5
5
  `);if(r.openBrowser===false)return;const g=r.openExternalTarget??n(process.cwd());void g(o).catch(()=>{t("Couldn't open the default browser. Open the authorization URL above manually.\n")})});return a.message}async function A(r={}){const i=r.createApplication?r.createApplication(r.region):await u(r.region,r.prepareDataDir,r.profile,r.fetchImpl);const t=await i.logout();if(t.logoutUrl){const a=r.writeError??(e=>process.stderr.write(e));a(`Finish signing out in your browser:
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
2
- import{a as b}from"./chunk-NOGL6Y6L.js";import{createHash as I}from"node:crypto";var S={cn:{prod:"https://agent.minimaxi.com",staging:"https://matrix-pre.example.invalid",test:"https://matrix-test.example.invalid",dev:"https://matrix-test.example.invalid"},en:{prod:"https://agent.minimax.io",staging:"https://matrix-overseas-pre.example.invalid",test:"https://matrix-overseas-test.example.invalid",dev:"https://matrix-overseas-test.example.invalid"}};var E="/matrix/api/v1/user/get_user_extra_info";var M="/matrix/api/v1/commerce/get_membership_info";var q="/v1/api/user/info";var U="/v1/api/openplatform/coding_plan/remains";var $="/v1/api/user/renewal";var N=3e3;var O=3e4;var B=5e3;var D=1000048;var G={cn:{prod:"https://www.minimaxi.com",staging:"https://open-platform-for-online-test.example.invalid",test:"https://openplatform-test.example.invalid",dev:"https://openplatform-test.example.invalid"},en:{prod:"https://platform.minimax.io",staging:"https://mmx-pre.example.invalid",test:"https://mmx-test.example.invalid",dev:"https://mmx-test.example.invalid"}};var C=class{constructor(e){this.options=e;this.fetchImpl=e.fetchImpl??fetch;this.timeoutMs=e.timeoutMs??N;this.membershipCacheTtlMs=R(e.membershipCacheTtlMs,O);this.quotaCacheTtlMs=R(e.quotaCacheTtlMs,B);this.now=e.now??Date.now;this.timezoneOffsetSeconds=e.timezoneOffsetSeconds??(()=>new Date().getTimezoneOffset()*-60)}options;fetchImpl;timeoutMs;now;timezoneOffsetSeconds;membershipCacheTtlMs;quotaCacheTtlMs;resolvedIdentity;billingContextCache;billingContextRequest;quotaCache;quotaRequest;async getTokenPlanMembership(e){return(await this.resolveTokenPlanBillingContext(e)).membership}async getRealUserID(e){const i=this.options.authContextGetter();const n=i?.accessToken?.trim();if(!n)return void 0;return this.resolveRealUserID(n,i?.realUserID,e)}async getRealUserIDForAuth(e,i){return(await this.getAuthContextForAuth(e,i))?.realUserID}async getAuthContextForAuth(e,i){const n=e.accessToken?.trim();if(!n)return void 0;return{accessToken:n,...await this.fetchAccountIdentity(n,i)}}async getTokenPlanAccountStatus(e,i={}){const n=Boolean(this.options.authContextGetter()?.accessToken?.trim());let r;try{r=await this.resolveTokenPlanBillingContext(e,i.forceRefresh===true)}catch(d){if(e?.aborted)throw d;return n?{quotaState:"unavailable"}:{}}const{membership:o,accessToken:a,personalOpGroupId:s}=r;if(o.hasTokenPlan===false){return{...o,quotaState:"not-subscribed"}}if(!a)return o;if(!s)return{...o,quotaState:"unavailable"};const u=await this.getTokenPlanQuota(a,s,e,i.forceRefresh===true).catch(()=>void 0);return{...o,quotaState:u?"available":"unavailable",...u?{quota:u}:{}}}async resolveTokenPlanBillingContext(e,i=false){const n=this.options.authContextGetter();const r=n?.accessToken?.trim();if(!r)return{membership:{}};const o=r;if(!e){const s=this.billingContextCache;if(!i&&s?.key===o&&s.expiresAtMs>this.now()){return s.value}if(this.billingContextRequest?.key===o){return this.billingContextRequest.promise}}const a=this.resolveTokenPlanBillingContextUncached(r,n?.realUserID,e);if(e)return a;this.billingContextRequest={key:o,promise:a};void a.then(s=>{if(this.billingContextRequest?.promise!==a)return;this.billingContextCache={key:o,expiresAtMs:this.now()+this.membershipCacheTtlMs,value:s}},()=>void 0).then(()=>{if(this.billingContextRequest?.promise===a){this.billingContextRequest=void 0}});return a}async resolveTokenPlanBillingContextUncached(e,i,n){const r=await this.resolveRealUserID(e,i,n);let o;try{const u=await this.postMatrixJson(E,{},e,r,"workspace lookup",n);o=H(u)}catch(u){if(n?.aborted)throw u;const d=await this.postMatrixJson(M,{},e,r,"membership request",n);return{membership:v(d),accessToken:e}}if(!o)return{membership:{},accessToken:e};const a=o.membership;const s=a.opGroupId;try{const u=await this.postMatrixJson(M,{workspace_id:o.workspaceId},e,r,"membership request",n);return{membership:Q(a,v(u)),accessToken:e,...s?{personalOpGroupId:s}:{}}}catch(u){if(n?.aborted)throw u;return{membership:a,accessToken:e,...s?{personalOpGroupId:s}:{}}}}async resolveRealUserID(e,i,n){const r=i?.trim();if(r)return r;const o=this.resolvedIdentity?.realUserID?.trim();if(this.resolvedIdentity?.accessToken===e&&o){return o}return(await this.fetchAccountIdentity(e,n)).realUserID}async fetchAccountIdentity(e,i){const n=this.now();const r=this.buildUrl(q,n);const o=`${r.pathname}${r.search}`;const a=Math.floor(n/1e3);const s=k(i,this.timeoutMs);try{const u=await this.fetchImpl(r,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":b("MiniMaxCode"),Authorization:`Bearer ${e}`,...this.routingHeaders(),yy:h(`${encodeURIComponent(o)}_{}${h(String(n))}ooui`),"x-timestamp":String(a),"x-signature":h(`${a}I*7Cf%WZ#S&%1RlZJ&C2`)},signal:s.signal});if(u.status===401||u.status===403){throw new T(u.status)}if(!u.ok){throw new Error(`MCode account identity request failed with HTTP ${u.status}`)}const d=c(await u.json());if(!d)throw new Error("MCode account identity request returned an invalid response");x(d,"account identity request");const m=c(d.data);const l=c(m?.userInfo)??c(m?.user_info)??c(d.userInfo)??c(d.user_info);const f=g(l,void 0,"realUserID")??g(l,void 0,"real_user_id");if(!f){throw new Error("MCode account identity request returned no account ID")}const y={realUserID:f,...w(l,"userEmail","email","userMail","user_email"),...w(l,"userName","name","userName","user_name"),...w(l,"subUserName","subUserName","sub_user_name")};this.resolvedIdentity={accessToken:e,...y};return y}finally{s.dispose()}}async postMatrixJson(e,i,n,r,o,a){const s=this.now();const u=this.buildUrl(e,s,r);const d=`${u.pathname}${u.search}`;const m=Math.floor(s/1e3);const l=JSON.stringify(i);const f=k(a,this.timeoutMs);try{const y=await this.fetchImpl(u,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":b("MiniMaxCode"),Authorization:`Bearer ${n}`,...this.routingHeaders(),yy:h(`${encodeURIComponent(d)}_${l}${h(String(s))}ooui`),"x-timestamp":String(m),"x-signature":h(`${m}I*7Cf%WZ#S&%1RlZJ&C2${l}`)},body:l,signal:f.signal});if(!y.ok){throw new Error(`MCode ${o} failed with HTTP ${y.status}`)}const _=c(await y.json());if(!_)throw new Error(`MCode ${o} returned an invalid response`);x(_,o);return _}finally{f.dispose()}}async renewAccessToken(e){const i=this.options.authContextGetter();const n=i?.accessToken?.trim();if(!n)return void 0;const r=this.now();const o=this.buildUrl($,r,i?.realUserID);const a=`${o.pathname}${o.search}`;const s=Math.floor(r/1e3);const u=k(e,this.timeoutMs);try{const d=await this.fetchImpl(o,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":b("MiniMaxCode"),Authorization:`Bearer ${n}`,...this.routingHeaders(),yy:h(`${encodeURIComponent(a)}_{}${h(String(r))}ooui`),"x-timestamp":String(s),"x-signature":h(`${s}I*7Cf%WZ#S&%1RlZJ&C2`)},signal:u.signal});if(d.status===401||d.status===403){throw new T(d.status)}if(!d.ok){throw new Error(`MCode token renewal failed with HTTP ${d.status}`)}const m=c(await d.json());if(!m)throw new Error("MCode token renewal returned an invalid response");x(m,"token renewal");const l=g(c(m.data),m,"token");if(!l)throw new Error("MCode token renewal returned no access token");return l}finally{u.dispose()}}buildUrl(e,i,n){const r=new URL(e,S[this.options.region][this.options.buildEnv]);const o=this.options.region==="cn"?"zh":"en";r.search=new URLSearchParams({device_platform:"mcode",biz_id:"3",app_id:"3001",version_code:"22201",unix:String(i),timezone_offset:String(this.timezoneOffsetSeconds()),sys_language:o,lang:o,device_id:"0",os_name:process.platform,browser_name:"mcode",user_id:n?.trim()||"0",client:"mcode"}).toString();return r}routingHeaders(){if(this.options.buildEnv!=="test"&&this.options.buildEnv!=="staging")return{};const e=this.options.routingContextGetter?.()?.bedrockLane?.trim();return e?{lane:e,bedrock_lane:e,"bedrock-lane":e}:{}}async getTokenPlanQuota(e,i,n,r=false){const o=`${e}\0${i??""}`;if(!n){const s=this.quotaCache;if(!r&&s?.key===o&&s.expiresAtMs>this.now()){return s.value}if(this.quotaRequest?.key===o)return this.quotaRequest.promise}const a=this.fetchTokenPlanQuota(e,i,n);if(n)return a;this.quotaRequest={key:o,promise:a};void a.then(s=>{if(this.quotaRequest?.promise!==a)return;this.quotaCache={key:o,expiresAtMs:this.now()+this.quotaCacheTtlMs,value:s}},()=>void 0).then(()=>{if(this.quotaRequest?.promise===a)this.quotaRequest=void 0});return a}async fetchTokenPlanQuota(e,i,n){const r=G[this.options.region][this.options.buildEnv];const o=k(n,this.timeoutMs);try{const a=await this.fetchImpl(`${r}${U}`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...i?{"X-Group-Id":i}:{}},signal:o.signal});if(!a.ok)return void 0;const s=c(await a.json());if(!s)return void 0;const u=c(s.base_resp);if(typeof u?.status_code==="number"&&u.status_code!==0){return void 0}const d=Array.isArray(s.model_remains)?s.model_remains.map(c).filter(f=>f!==void 0):[];const m=d[0];if(!m)return void 0;const l=d.find(f=>/video/iu.test(g(f,void 0,"model_name")??"")&&(p(f.current_interval_total_count)??0)>0);return{fiveHour:P(m,"interval"),weekly:P(m,"weekly"),...l?{video:L(l)}:{}}}finally{o.dispose()}}};function R(t,e){return t!==void 0&&Number.isFinite(t)&&t>=0?t:e}function w(t,e,...i){for(const n of i){const r=g(t,void 0,n);if(r)return{[e]:r}}return{}}var T=class extends Error{constructor(i){super("MiniMax sign-in expired. Run /login, then retry.");this.status=i}status;name="TuiAuthenticationError"};function x(t,e){const i=c(t.statusInfo);if(typeof i?.code==="number"&&i.code!==0){if(i.code===D)throw new T(401);throw new Error(`MCode ${e} failed with status ${i.code}`)}const n=c(t.base_resp);if(typeof n?.status_code==="number"&&n.status_code!==0){throw new Error(`MCode ${e} failed with status ${n.status_code}`)}}function v(t){const e=c(t.data);const i=j(t,e,"has_token_plan");const n=g(t,e,"op_group_id");const r=g(t,e,"token_plan_tier");const o=z(t,e,"token_plan_expires_at");const a=c(t.op_credit_summary)??c(e?.op_credit_summary);const s=g(a,void 0,"total_remaining_amount")??W(t,e,"opcredit_balance");const u=A({tier:r,expiresAtMs:o,creditBalance:s});return{...i!==void 0?{hasTokenPlan:i}:{},...n?{opGroupId:n}:{},...u?{summary:u}:{}}}function H(t){const e=c(t.data);const i=Array.isArray(t.workspaces)?t.workspaces:Array.isArray(e?.workspaces)?e.workspaces:[];for(const n of i){const r=c(n);if(!r||p(r.workspace_type)!==0)continue;const o=F(r.workspace_id);if(o===void 0)continue;return{workspaceId:o,membership:v(r)}}return void 0}function Q(t,e){const i=t.hasTokenPlan===true||e.hasTokenPlan===true?true:t.hasTokenPlan===false||e.hasTokenPlan===false?false:void 0;const n=A({...t.summary,...e.summary});return{...i!==void 0?{hasTokenPlan:i}:{},...t.opGroupId||e.opGroupId?{opGroupId:t.opGroupId??e.opGroupId}:{},...n?{summary:n}:{}}}function F(t){if(typeof t==="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t==="string"&&t.trim())return t.trim();return void 0}function P(t,e){const i=e==="interval"?"current_interval":"current_weekly";const n=p(t[`${i}_status`]);const r=n===3;const o=p(t[`${i}_remaining_percent`]);const a=p(t[`${i}_total_count`]);const s=p(t[`${i}_usage_count`]);const u=o??(a!==void 0&&a>0&&s!==void 0?s/a*100:void 0);const d=p(t[e==="interval"?"end_time":"weekly_end_time"]);return{...r||u===void 0?{}:{remainingPercent:Math.round(Math.min(100,Math.max(0,u)))},...d!==void 0&&d>0?{resetAtMs:d}:{},unlimited:r}}function L(t){const e=p(t.current_interval_status);const i=p(t.current_interval_total_count);const n=p(t.current_interval_usage_count);const r=p(t.end_time);return{...n===void 0?{}:{remainingCount:Math.max(0,n)},...i===void 0?{}:{totalCount:Math.max(0,i)},...r!==void 0&&r>0?{resetAtMs:r}:{},unlimited:e===3}}function k(t,e){const i=new AbortController;const n=setTimeout(()=>i.abort(),e);return{signal:t?AbortSignal.any([t,i.signal]):i.signal,dispose:()=>clearTimeout(n)}}function A(t){return t.tier||t.expiresAtMs||t.creditBalance?t:void 0}function j(t,e,i){const n=t?.[i]??e?.[i];return typeof n==="boolean"?n:void 0}function g(t,e,i){const n=t?.[i]??e?.[i];return typeof n==="string"&&n.trim()?n.trim():void 0}function z(t,e,i){const n=t?.[i]??e?.[i];return typeof n==="number"&&Number.isFinite(n)&&n>0?n:void 0}function p(t){return typeof t==="number"&&Number.isFinite(t)?t:void 0}function W(t,e,i){const n=t?.[i]??e?.[i];return typeof n==="string"||typeof n==="number"?String(n).trim():void 0}function h(t){return I("md5").update(t).digest("hex")}function c(t){return t&&typeof t==="object"&&!Array.isArray(t)?t:void 0}function K(t,e=Date.now()){const i=[t?.fiveHour,t?.weekly].filter(n=>n&&!n.unlimited&&n.remainingPercent!==void 0&&n.remainingPercent<=0).map(n=>n.resetAtMs).filter(n=>typeof n==="number"&&Number.isFinite(n)&&n>e);return i.length?Math.max(...i):void 0}export{C as a,T as b,K as c};
2
+ import{a as b}from"./chunk-7F3QKGB7.js";import{createHash as I}from"node:crypto";var S={cn:{prod:"https://agent.minimaxi.com",staging:"https://matrix-pre.example.invalid",test:"https://matrix-test.example.invalid",dev:"https://matrix-test.example.invalid"},en:{prod:"https://agent.minimax.io",staging:"https://matrix-overseas-pre.example.invalid",test:"https://matrix-overseas-test.example.invalid",dev:"https://matrix-overseas-test.example.invalid"}};var E="/matrix/api/v1/user/get_user_extra_info";var M="/matrix/api/v1/commerce/get_membership_info";var q="/v1/api/user/info";var U="/v1/api/openplatform/coding_plan/remains";var $="/v1/api/user/renewal";var N=3e3;var O=3e4;var B=5e3;var D=1000048;var G={cn:{prod:"https://www.minimaxi.com",staging:"https://open-platform-for-online-test.example.invalid",test:"https://openplatform-test.example.invalid",dev:"https://openplatform-test.example.invalid"},en:{prod:"https://platform.minimax.io",staging:"https://mmx-pre.example.invalid",test:"https://mmx-test.example.invalid",dev:"https://mmx-test.example.invalid"}};var C=class{constructor(e){this.options=e;this.fetchImpl=e.fetchImpl??fetch;this.timeoutMs=e.timeoutMs??N;this.membershipCacheTtlMs=R(e.membershipCacheTtlMs,O);this.quotaCacheTtlMs=R(e.quotaCacheTtlMs,B);this.now=e.now??Date.now;this.timezoneOffsetSeconds=e.timezoneOffsetSeconds??(()=>new Date().getTimezoneOffset()*-60)}options;fetchImpl;timeoutMs;now;timezoneOffsetSeconds;membershipCacheTtlMs;quotaCacheTtlMs;resolvedIdentity;billingContextCache;billingContextRequest;quotaCache;quotaRequest;async getTokenPlanMembership(e){return(await this.resolveTokenPlanBillingContext(e)).membership}async getRealUserID(e){const i=this.options.authContextGetter();const n=i?.accessToken?.trim();if(!n)return void 0;return this.resolveRealUserID(n,i?.realUserID,e)}async getRealUserIDForAuth(e,i){return(await this.getAuthContextForAuth(e,i))?.realUserID}async getAuthContextForAuth(e,i){const n=e.accessToken?.trim();if(!n)return void 0;return{accessToken:n,...await this.fetchAccountIdentity(n,i)}}async getTokenPlanAccountStatus(e,i={}){const n=Boolean(this.options.authContextGetter()?.accessToken?.trim());let r;try{r=await this.resolveTokenPlanBillingContext(e,i.forceRefresh===true)}catch(d){if(e?.aborted)throw d;return n?{quotaState:"unavailable"}:{}}const{membership:o,accessToken:a,personalOpGroupId:s}=r;if(o.hasTokenPlan===false){return{...o,quotaState:"not-subscribed"}}if(!a)return o;if(!s)return{...o,quotaState:"unavailable"};const u=await this.getTokenPlanQuota(a,s,e,i.forceRefresh===true).catch(()=>void 0);return{...o,quotaState:u?"available":"unavailable",...u?{quota:u}:{}}}async resolveTokenPlanBillingContext(e,i=false){const n=this.options.authContextGetter();const r=n?.accessToken?.trim();if(!r)return{membership:{}};const o=r;if(!e){const s=this.billingContextCache;if(!i&&s?.key===o&&s.expiresAtMs>this.now()){return s.value}if(this.billingContextRequest?.key===o){return this.billingContextRequest.promise}}const a=this.resolveTokenPlanBillingContextUncached(r,n?.realUserID,e);if(e)return a;this.billingContextRequest={key:o,promise:a};void a.then(s=>{if(this.billingContextRequest?.promise!==a)return;this.billingContextCache={key:o,expiresAtMs:this.now()+this.membershipCacheTtlMs,value:s}},()=>void 0).then(()=>{if(this.billingContextRequest?.promise===a){this.billingContextRequest=void 0}});return a}async resolveTokenPlanBillingContextUncached(e,i,n){const r=await this.resolveRealUserID(e,i,n);let o;try{const u=await this.postMatrixJson(E,{},e,r,"workspace lookup",n);o=H(u)}catch(u){if(n?.aborted)throw u;const d=await this.postMatrixJson(M,{},e,r,"membership request",n);return{membership:v(d),accessToken:e}}if(!o)return{membership:{},accessToken:e};const a=o.membership;const s=a.opGroupId;try{const u=await this.postMatrixJson(M,{workspace_id:o.workspaceId},e,r,"membership request",n);return{membership:Q(a,v(u)),accessToken:e,...s?{personalOpGroupId:s}:{}}}catch(u){if(n?.aborted)throw u;return{membership:a,accessToken:e,...s?{personalOpGroupId:s}:{}}}}async resolveRealUserID(e,i,n){const r=i?.trim();if(r)return r;const o=this.resolvedIdentity?.realUserID?.trim();if(this.resolvedIdentity?.accessToken===e&&o){return o}return(await this.fetchAccountIdentity(e,n)).realUserID}async fetchAccountIdentity(e,i){const n=this.now();const r=this.buildUrl(q,n);const o=`${r.pathname}${r.search}`;const a=Math.floor(n/1e3);const s=k(i,this.timeoutMs);try{const u=await this.fetchImpl(r,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":b("MiniMaxCode"),Authorization:`Bearer ${e}`,...this.routingHeaders(),yy:h(`${encodeURIComponent(o)}_{}${h(String(n))}ooui`),"x-timestamp":String(a),"x-signature":h(`${a}I*7Cf%WZ#S&%1RlZJ&C2`)},signal:s.signal});if(u.status===401||u.status===403){throw new T(u.status)}if(!u.ok){throw new Error(`MCode account identity request failed with HTTP ${u.status}`)}const d=c(await u.json());if(!d)throw new Error("MCode account identity request returned an invalid response");x(d,"account identity request");const m=c(d.data);const l=c(m?.userInfo)??c(m?.user_info)??c(d.userInfo)??c(d.user_info);const f=g(l,void 0,"realUserID")??g(l,void 0,"real_user_id");if(!f){throw new Error("MCode account identity request returned no account ID")}const y={realUserID:f,...w(l,"userEmail","email","userMail","user_email"),...w(l,"userName","name","userName","user_name"),...w(l,"subUserName","subUserName","sub_user_name")};this.resolvedIdentity={accessToken:e,...y};return y}finally{s.dispose()}}async postMatrixJson(e,i,n,r,o,a){const s=this.now();const u=this.buildUrl(e,s,r);const d=`${u.pathname}${u.search}`;const m=Math.floor(s/1e3);const l=JSON.stringify(i);const f=k(a,this.timeoutMs);try{const y=await this.fetchImpl(u,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":b("MiniMaxCode"),Authorization:`Bearer ${n}`,...this.routingHeaders(),yy:h(`${encodeURIComponent(d)}_${l}${h(String(s))}ooui`),"x-timestamp":String(m),"x-signature":h(`${m}I*7Cf%WZ#S&%1RlZJ&C2${l}`)},body:l,signal:f.signal});if(!y.ok){throw new Error(`MCode ${o} failed with HTTP ${y.status}`)}const _=c(await y.json());if(!_)throw new Error(`MCode ${o} returned an invalid response`);x(_,o);return _}finally{f.dispose()}}async renewAccessToken(e){const i=this.options.authContextGetter();const n=i?.accessToken?.trim();if(!n)return void 0;const r=this.now();const o=this.buildUrl($,r,i?.realUserID);const a=`${o.pathname}${o.search}`;const s=Math.floor(r/1e3);const u=k(e,this.timeoutMs);try{const d=await this.fetchImpl(o,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":b("MiniMaxCode"),Authorization:`Bearer ${n}`,...this.routingHeaders(),yy:h(`${encodeURIComponent(a)}_{}${h(String(r))}ooui`),"x-timestamp":String(s),"x-signature":h(`${s}I*7Cf%WZ#S&%1RlZJ&C2`)},signal:u.signal});if(d.status===401||d.status===403){throw new T(d.status)}if(!d.ok){throw new Error(`MCode token renewal failed with HTTP ${d.status}`)}const m=c(await d.json());if(!m)throw new Error("MCode token renewal returned an invalid response");x(m,"token renewal");const l=g(c(m.data),m,"token");if(!l)throw new Error("MCode token renewal returned no access token");return l}finally{u.dispose()}}buildUrl(e,i,n){const r=new URL(e,S[this.options.region][this.options.buildEnv]);const o=this.options.region==="cn"?"zh":"en";r.search=new URLSearchParams({device_platform:"mcode",biz_id:"3",app_id:"3001",version_code:"22201",unix:String(i),timezone_offset:String(this.timezoneOffsetSeconds()),sys_language:o,lang:o,device_id:"0",os_name:process.platform,browser_name:"mcode",user_id:n?.trim()||"0",client:"mcode"}).toString();return r}routingHeaders(){if(this.options.buildEnv!=="test"&&this.options.buildEnv!=="staging")return{};const e=this.options.routingContextGetter?.()?.bedrockLane?.trim();return e?{lane:e,bedrock_lane:e,"bedrock-lane":e}:{}}async getTokenPlanQuota(e,i,n,r=false){const o=`${e}\0${i??""}`;if(!n){const s=this.quotaCache;if(!r&&s?.key===o&&s.expiresAtMs>this.now()){return s.value}if(this.quotaRequest?.key===o)return this.quotaRequest.promise}const a=this.fetchTokenPlanQuota(e,i,n);if(n)return a;this.quotaRequest={key:o,promise:a};void a.then(s=>{if(this.quotaRequest?.promise!==a)return;this.quotaCache={key:o,expiresAtMs:this.now()+this.quotaCacheTtlMs,value:s}},()=>void 0).then(()=>{if(this.quotaRequest?.promise===a)this.quotaRequest=void 0});return a}async fetchTokenPlanQuota(e,i,n){const r=G[this.options.region][this.options.buildEnv];const o=k(n,this.timeoutMs);try{const a=await this.fetchImpl(`${r}${U}`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...i?{"X-Group-Id":i}:{}},signal:o.signal});if(!a.ok)return void 0;const s=c(await a.json());if(!s)return void 0;const u=c(s.base_resp);if(typeof u?.status_code==="number"&&u.status_code!==0){return void 0}const d=Array.isArray(s.model_remains)?s.model_remains.map(c).filter(f=>f!==void 0):[];const m=d[0];if(!m)return void 0;const l=d.find(f=>/video/iu.test(g(f,void 0,"model_name")??"")&&(p(f.current_interval_total_count)??0)>0);return{fiveHour:P(m,"interval"),weekly:P(m,"weekly"),...l?{video:L(l)}:{}}}finally{o.dispose()}}};function R(t,e){return t!==void 0&&Number.isFinite(t)&&t>=0?t:e}function w(t,e,...i){for(const n of i){const r=g(t,void 0,n);if(r)return{[e]:r}}return{}}var T=class extends Error{constructor(i){super("MiniMax sign-in expired. Run /login, then retry.");this.status=i}status;name="TuiAuthenticationError"};function x(t,e){const i=c(t.statusInfo);if(typeof i?.code==="number"&&i.code!==0){if(i.code===D)throw new T(401);throw new Error(`MCode ${e} failed with status ${i.code}`)}const n=c(t.base_resp);if(typeof n?.status_code==="number"&&n.status_code!==0){throw new Error(`MCode ${e} failed with status ${n.status_code}`)}}function v(t){const e=c(t.data);const i=j(t,e,"has_token_plan");const n=g(t,e,"op_group_id");const r=g(t,e,"token_plan_tier");const o=z(t,e,"token_plan_expires_at");const a=c(t.op_credit_summary)??c(e?.op_credit_summary);const s=g(a,void 0,"total_remaining_amount")??W(t,e,"opcredit_balance");const u=A({tier:r,expiresAtMs:o,creditBalance:s});return{...i!==void 0?{hasTokenPlan:i}:{},...n?{opGroupId:n}:{},...u?{summary:u}:{}}}function H(t){const e=c(t.data);const i=Array.isArray(t.workspaces)?t.workspaces:Array.isArray(e?.workspaces)?e.workspaces:[];for(const n of i){const r=c(n);if(!r||p(r.workspace_type)!==0)continue;const o=F(r.workspace_id);if(o===void 0)continue;return{workspaceId:o,membership:v(r)}}return void 0}function Q(t,e){const i=t.hasTokenPlan===true||e.hasTokenPlan===true?true:t.hasTokenPlan===false||e.hasTokenPlan===false?false:void 0;const n=A({...t.summary,...e.summary});return{...i!==void 0?{hasTokenPlan:i}:{},...t.opGroupId||e.opGroupId?{opGroupId:t.opGroupId??e.opGroupId}:{},...n?{summary:n}:{}}}function F(t){if(typeof t==="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t==="string"&&t.trim())return t.trim();return void 0}function P(t,e){const i=e==="interval"?"current_interval":"current_weekly";const n=p(t[`${i}_status`]);const r=n===3;const o=p(t[`${i}_remaining_percent`]);const a=p(t[`${i}_total_count`]);const s=p(t[`${i}_usage_count`]);const u=o??(a!==void 0&&a>0&&s!==void 0?s/a*100:void 0);const d=p(t[e==="interval"?"end_time":"weekly_end_time"]);return{...r||u===void 0?{}:{remainingPercent:Math.round(Math.min(100,Math.max(0,u)))},...d!==void 0&&d>0?{resetAtMs:d}:{},unlimited:r}}function L(t){const e=p(t.current_interval_status);const i=p(t.current_interval_total_count);const n=p(t.current_interval_usage_count);const r=p(t.end_time);return{...n===void 0?{}:{remainingCount:Math.max(0,n)},...i===void 0?{}:{totalCount:Math.max(0,i)},...r!==void 0&&r>0?{resetAtMs:r}:{},unlimited:e===3}}function k(t,e){const i=new AbortController;const n=setTimeout(()=>i.abort(),e);return{signal:t?AbortSignal.any([t,i.signal]):i.signal,dispose:()=>clearTimeout(n)}}function A(t){return t.tier||t.expiresAtMs||t.creditBalance?t:void 0}function j(t,e,i){const n=t?.[i]??e?.[i];return typeof n==="boolean"?n:void 0}function g(t,e,i){const n=t?.[i]??e?.[i];return typeof n==="string"&&n.trim()?n.trim():void 0}function z(t,e,i){const n=t?.[i]??e?.[i];return typeof n==="number"&&Number.isFinite(n)&&n>0?n:void 0}function p(t){return typeof t==="number"&&Number.isFinite(t)?t:void 0}function W(t,e,i){const n=t?.[i]??e?.[i];return typeof n==="string"||typeof n==="number"?String(n).trim():void 0}function h(t){return I("md5").update(t).digest("hex")}function c(t){return t&&typeof t==="object"&&!Array.isArray(t)?t:void 0}function K(t,e=Date.now()){const i=[t?.fiveHour,t?.weekly].filter(n=>n&&!n.unlimited&&n.remainingPercent!==void 0&&n.remainingPercent<=0).map(n=>n.resetAtMs).filter(n=>typeof n==="number"&&Number.isFinite(n)&&n>e);return i.length?Math.max(...i):void 0}export{C as a,T as b,K as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
2
- import{a as qh}from"./chunk-UQL67NEA.js";import{a as Ns}from"./chunk-NOGL6Y6L.js";import{a as I,c as E,e as ks}from"./chunk-FK3SSGJE.js";var Pn=E((VO,sa)=>{"use strict";var Rt=e=>{return e&&typeof e.message==="string"};var Ln=e=>{if(!e)return;const t=e.cause;if(typeof t==="function"){const r=e.cause();return Rt(r)?r:void 0}else{return Rt(t)?t:void 0}};var ia=(e,t)=>{if(!Rt(e))return"";const r=e.stack||"";if(t.has(e)){return r+"\ncauses have become circular..."}const n=Ln(e);if(n){t.add(e);return r+"\ncaused by: "+ia(n,t)}else{return r}};var ny=e=>ia(e,new Set);var oa=(e,t,r)=>{if(!Rt(e))return"";const n=r?"":e.message||"";if(t.has(e)){return n+": ..."}const i=Ln(e);if(i){t.add(e);const o=typeof e.cause==="function";return n+(o?"":": ")+oa(i,t,o)}else{return n}};var iy=e=>oa(e,new Set);sa.exports={isErrorLike:Rt,getErrorCause:Ln,stackWithCauses:ny,messageWithCauses:iy}});var kn=E((zO,la)=>{"use strict";var oy=Symbol("circular-ref-tag");var or=Symbol("pino-raw-err-ref");var aa=Object.create({},{type:{enumerable:true,writable:true,value:void 0},message:{enumerable:true,writable:true,value:void 0},stack:{enumerable:true,writable:true,value:void 0},aggregateErrors:{enumerable:true,writable:true,value:void 0},raw:{enumerable:false,get:function(){return this[or]},set:function(e){this[or]=e}}});Object.defineProperty(aa,or,{writable:true,value:{}});la.exports={pinoErrProto:aa,pinoErrorSymbols:{seen:oy,rawSymbol:or}}});var fa=E((GO,ca)=>{"use strict";ca.exports=Dn;var{messageWithCauses:sy,stackWithCauses:ay,isErrorLike:ua}=Pn();var{pinoErrProto:ly,pinoErrorSymbols:uy}=kn();var{seen:Nn}=uy;var{toString:cy}=Object.prototype;function Dn(e){if(!ua(e)){return e}e[Nn]=void 0;const t=Object.create(ly);t.type=cy.call(e.constructor)==="[object Function]"?e.constructor.name:e.name;t.message=sy(e);t.stack=ay(e);if(Array.isArray(e.errors)){t.aggregateErrors=e.errors.map(r=>Dn(r))}for(const r in e){if(t[r]===void 0){const n=e[r];if(ua(n)){if(r!=="cause"&&!Object.prototype.hasOwnProperty.call(n,Nn)){t[r]=Dn(n)}}else{t[r]=n}}}delete e[Nn];t.raw=e;return t}});var pa=E((YO,da)=>{"use strict";da.exports=ar;var{isErrorLike:jn}=Pn();var{pinoErrProto:fy,pinoErrorSymbols:dy}=kn();var{seen:sr}=dy;var{toString:py}=Object.prototype;function ar(e){if(!jn(e)){return e}e[sr]=void 0;const t=Object.create(fy);t.type=py.call(e.constructor)==="[object Function]"?e.constructor.name:e.name;t.message=e.message;t.stack=e.stack;if(Array.isArray(e.errors)){t.aggregateErrors=e.errors.map(r=>ar(r))}if(jn(e.cause)&&!Object.prototype.hasOwnProperty.call(e.cause,sr)){t.cause=ar(e.cause)}for(const r in e){if(t[r]===void 0){const n=e[r];if(jn(n)){if(!Object.prototype.hasOwnProperty.call(n,sr)){t[r]=ar(n)}}else{t[r]=n}}}delete e[sr];t.raw=e;return t}});var ma=E((QO,ya)=>{"use strict";ya.exports={mapHttpRequest:hy,reqSerializer:ga};var Bn=Symbol("pino-raw-req-ref");var ha=Object.create({},{id:{enumerable:true,writable:true,value:""},method:{enumerable:true,writable:true,value:""},url:{enumerable:true,writable:true,value:""},query:{enumerable:true,writable:true,value:""},params:{enumerable:true,writable:true,value:""},headers:{enumerable:true,writable:true,value:{}},remoteAddress:{enumerable:true,writable:true,value:""},remotePort:{enumerable:true,writable:true,value:""},raw:{enumerable:false,get:function(){return this[Bn]},set:function(e){this[Bn]=e}}});Object.defineProperty(ha,Bn,{writable:true,value:{}});function ga(e){const t=e.info||e.socket;const r=Object.create(ha);r.id=typeof e.id==="function"?e.id():e.id||(e.info?e.info.id:void 0);r.method=e.method;if(e.originalUrl){r.url=e.originalUrl}else{const n=e.path;r.url=typeof n==="string"?n:e.url?e.url.path||e.url:void 0}if(e.query){r.query=e.query}if(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;return r}function hy(e){return{req:ga(e)}}});var _a=E((JO,Sa)=>{"use strict";Sa.exports={mapHttpResponse:gy,resSerializer:wa};var qn=Symbol("pino-raw-res-ref");var ba=Object.create({},{statusCode:{enumerable:true,writable:true,value:0},headers:{enumerable:true,writable:true,value:""},raw:{enumerable:false,get:function(){return this[qn]},set:function(e){this[qn]=e}}});Object.defineProperty(ba,qn,{writable:true,value:{}});function wa(e){const t=Object.create(ba);t.statusCode=e.headersSent?e.statusCode:null;t.headers=e.getHeaders?e.getHeaders():e._headers;t.raw=e;return t}function gy(e){return{res:wa(e)}}});var Wn=E((XO,Ea)=>{"use strict";var $n=fa();var yy=pa();var lr=ma();var ur=_a();Ea.exports={err:$n,errWithCause:yy,mapHttpRequest:lr.mapHttpRequest,mapHttpResponse:ur.mapHttpResponse,req:lr.reqSerializer,res:ur.resSerializer,wrapErrorSerializer:function e(t){if(t===$n)return t;return function r(n){return t($n(n))}},wrapRequestSerializer:function e(t){if(t===lr.reqSerializer)return t;return function r(n){return t(lr.reqSerializer(n))}},wrapResponseSerializer:function e(t){if(t===ur.resSerializer)return t;return function r(n){return t(ur.resSerializer(n))}}}});var Fn=E((ZO,xa)=>{"use strict";function my(e,t){return t}xa.exports=function e(){const t=Error.prepareStackTrace;Error.prepareStackTrace=my;const r=new Error().stack;Error.prepareStackTrace=t;if(!Array.isArray(r)){return void 0}const n=r.slice(2);const i=[];for(const o of n){if(!o){continue}i.push(o.getFileName())}return i}});var Ca=E((eI,Ma)=>{"use strict";function Un(e){if(e===null||typeof e!=="object"){return e}if(e instanceof Date){return new Date(e.getTime())}if(e instanceof Array){const t=[];for(let r=0;r<e.length;r++){t[r]=Un(e[r])}return t}if(typeof e==="object"){const t=Object.create(Object.getPrototypeOf(e));for(const r in e){if(Object.prototype.hasOwnProperty.call(e,r)){t[r]=Un(e[r])}}return t}return e}function Aa(e){const t=[];let r="";let n=false;let i=false;let o="";for(let s=0;s<e.length;s++){const a=e[s];if(!n&&a==="."){if(r){t.push(r);r=""}}else if(a==="["){if(r){t.push(r);r=""}n=true}else if(a==="]"&&n){t.push(r);r="";n=false;i=false}else if((a==='"'||a==="'")&&n){if(!i){i=true;o=a}else if(a===o){i=false;o=""}else{r+=a}}else{r+=a}}if(r){t.push(r)}return t}function Ra(e,t,r){let n=e;for(let o=0;o<t.length-1;o++){const s=t[o];if(typeof n!=="object"||n===null||!(s in n)){return false}if(typeof n[s]!=="object"||n[s]===null){return false}n=n[s]}const i=t[t.length-1];if(i==="*"){if(Array.isArray(n)){for(let o=0;o<n.length;o++){n[o]=r}}else if(typeof n==="object"&&n!==null){for(const o in n){if(Object.prototype.hasOwnProperty.call(n,o)){n[o]=r}}}}else{if(typeof n==="object"&&n!==null&&i in n&&Object.prototype.hasOwnProperty.call(n,i)){n[i]=r}}return true}function Ta(e,t){let r=e;for(let i=0;i<t.length-1;i++){const o=t[i];if(typeof r!=="object"||r===null||!(o in r)){return false}if(typeof r[o]!=="object"||r[o]===null){return false}r=r[o]}const 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(const i in r){if(Object.prototype.hasOwnProperty.call(r,i)){delete r[i]}}}}else{if(typeof r==="object"&&r!==null&&n in r&&Object.prototype.hasOwnProperty.call(r,n)){delete r[n]}}return true}var cr=Symbol("PATH_NOT_FOUND");function by(e,t){let r=e;for(const n of t){if(r===null||r===void 0){return cr}if(typeof r!=="object"||r===null){return cr}if(!(n in r)){return cr}r=r[n]}return r}function wy(e,t){let r=e;for(const n of t){if(r===null||r===void 0){return void 0}if(typeof r!=="object"||r===null){return void 0}r=r[n]}return r}function Sy(e,t,r,n=false){for(const i of t){const o=Aa(i);if(o.includes("*")){va(e,o,r,i,n)}else{if(n){Ta(e,o)}else{const s=by(e,o);if(s===cr){continue}const a=typeof r==="function"?r(s,o):r;Ra(e,o,a)}}}}function va(e,t,r,n,i=false){const o=t.indexOf("*");if(o===t.length-1){const s=t.slice(0,-1);let a=e;for(const l of s){if(a===null||a===void 0)return;if(typeof a!=="object"||a===null)return;a=a[l]}if(Array.isArray(a)){if(i){for(let l=0;l<a.length;l++){a[l]=void 0}}else{for(let l=0;l<a.length;l++){const u=[...s,l.toString()];const f=typeof r==="function"?r(a[l],u):r;a[l]=f}}}else if(typeof a==="object"&&a!==null){if(i){const l=[];for(const u in a){if(Object.prototype.hasOwnProperty.call(a,u)){l.push(u)}}for(const u of l){delete a[u]}}else{for(const l in a){const u=[...s,l];const f=typeof r==="function"?r(a[l],u):r;a[l]=f}}}}else{_y(e,t,r,o,n,i)}}function _y(e,t,r,n,i,o=false){const s=t.slice(0,n);const a=t.slice(n+1);const l=[];function u(f,c){if(c===s.length){if(Array.isArray(f)){for(let h=0;h<f.length;h++){l[c]=h.toString();u(f[h],c+1)}}else if(typeof f==="object"&&f!==null){for(const h in f){l[c]=h;u(f[h],c+1)}}}else if(c<s.length){const h=s[c];if(f&&typeof f==="object"&&f!==null&&h in f){l[c]=h;u(f[h],c+1)}}else{if(a.includes("*")){const h=typeof r==="function"?(p,d)=>{const g=[...l.slice(0,c),...d];return r(p,g)}:r;va(f,a,h,i,o)}else{if(o){Ta(f,a)}else{const h=typeof r==="function"?r(wy(f,a),[...l.slice(0,c),...a]):r;Ra(f,a,h)}}}}if(s.length===0){u(e,0)}else{let f=e;for(let c=0;c<s.length;c++){const h=s[c];if(f===null||f===void 0)return;if(typeof f!=="object"||f===null)return;f=f[h];l[c]=h}if(f!==null&&f!==void 0){u(f,s.length)}}}function Ey(e){if(e.length===0){return null}const t=new Map;for(const r of e){const n=Aa(r);let i=t;for(let o=0;o<n.length;o++){const s=n[o];if(!i.has(s)){i.set(s,new Map)}i=i.get(s)}}return t}function xy(e,t){if(!t){return e}function r(n,i,o=0){if(!i||i.size===0){return n}if(n===null||typeof n!=="object"){return n}if(n instanceof Date){return new Date(n.getTime())}if(Array.isArray(n)){const a=[];for(let l=0;l<n.length;l++){const u=l.toString();if(i.has(u)||i.has("*")){a[l]=r(n[l],i.get(u)||i.get("*"))}else{a[l]=n[l]}}return a}const s=Object.create(Object.getPrototypeOf(n));for(const a in n){if(Object.prototype.hasOwnProperty.call(n,a)){if(i.has(a)||i.has("*")){s[a]=r(n[a],i.get(a)||i.get("*"))}else{s[a]=n[a]}}}return s}return r(e,t)}function Ay(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;let r=false;let n="";for(let i=0;i<e.length;i++){const o=e[i];if((o==='"'||o==="'")&&t>0){if(!r){r=true;n=o}else if(o===n){r=false;n=""}}else if(o==="["&&!r){t++}else if(o==="]"&&!r){t--;if(t<0){throw new Error(`Invalid redaction path (${e})`)}}}if(t!==0){throw new Error(`Invalid redaction path (${e})`)}}function Ry(e){if(!Array.isArray(e)){throw new TypeError("paths must be an array")}for(const t of e){Ay(t)}}function Ty(e={}){const{paths:t=[],censor:r="[REDACTED]",serialize:n=JSON.stringify,strict:i=true,remove:o=false}=e;Ry(t);const s=Ey(t);return function a(l){if(i&&(l===null||typeof l!=="object")){if(l===null||l===void 0){return n?n(l):l}if(typeof l!=="object"){return n?n(l):l}}const u=xy(l,s);const f=l;let c=r;if(typeof r==="function"){c=r}Sy(u,t,c,o);if(n===false){u.restore=function(){return Un(f)};return u}if(typeof n==="function"){return n(u)}return JSON.stringify(u)}}Ma.exports=Ty});var Ze=E((tI,Oa)=>{"use strict";var vy=Symbol("pino.setLevel");var My=Symbol("pino.getLevel");var Cy=Symbol("pino.levelVal");var Oy=Symbol("pino.levelComp");var Iy=Symbol("pino.useLevelLabels");var Ly=Symbol("pino.useOnlyCustomLevels");var Py=Symbol("pino.mixin");var ky=Symbol("pino.lsCache");var Ny=Symbol("pino.chindings");var Dy=Symbol("pino.asJson");var jy=Symbol("pino.write");var By=Symbol("pino.redactFmt");var qy=Symbol("pino.time");var $y=Symbol("pino.timeSliceIndex");var Wy=Symbol("pino.stream");var Fy=Symbol("pino.stringify");var Uy=Symbol("pino.stringifySafe");var Hy=Symbol("pino.stringifiers");var Ky=Symbol("pino.end");var Vy=Symbol("pino.formatOpts");var zy=Symbol("pino.messageKey");var Gy=Symbol("pino.errorKey");var Yy=Symbol("pino.nestedKey");var Qy=Symbol("pino.nestedKeyStr");var Jy=Symbol("pino.mixinMergeStrategy");var Xy=Symbol("pino.msgPrefix");var Zy=Symbol("pino.wildcardFirst");var em=Symbol.for("pino.serializers");var tm=Symbol.for("pino.formatters");var rm=Symbol.for("pino.hooks");var nm=Symbol.for("pino.metadata");Oa.exports={setLevelSym:vy,getLevelSym:My,levelValSym:Cy,levelCompSym:Oy,useLevelLabelsSym:Iy,mixinSym:Py,lsCacheSym:ky,chindingsSym:Ny,asJsonSym:Dy,writeSym:jy,serializersSym:em,redactFmtSym:By,timeSym:qy,timeSliceIndexSym:$y,streamSym:Wy,stringifySym:Fy,stringifySafeSym:Uy,stringifiersSym:Hy,endSym:Ky,formatOptsSym:Vy,messageKeySym:zy,errorKeySym:Gy,nestedKeySym:Yy,wildcardFirstSym:Zy,needsMetadataGsym:nm,useOnlyCustomLevelsSym:Ly,formattersSym:tm,hooksSym:rm,nestedKeyStrSym:Qy,mixinMergeStrategySym:Jy,msgPrefixSym:Xy}});var Kn=E((rI,ka)=>{"use strict";var Ia=Ca();var{redactFmtSym:im,wildcardFirstSym:fr}=Ze();var Hn=/[^.[\]]+|\[([^[\]]*?)\]/g;var La="[Redacted]";var Pa=false;function om(e,t){const{paths:r,censor:n,remove:i}=sm(e);const o=r.reduce((l,u)=>{Hn.lastIndex=0;const f=Hn.exec(u);const c=Hn.exec(u);let h=f[1]!==void 0?f[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,"$1"):f[0];if(h==="*"){h=fr}if(c===null){l[h]=null;return l}if(l[h]===null){return l}const{index:p}=c;const d=`${u.substr(p,u.length-1)}`;l[h]=l[h]||[];if(h!==fr&&l[h].length===0){l[h].push(...l[fr]||[])}if(h===fr){Object.keys(l).forEach(function(g){if(l[g]){l[g].push(d)}})}l[h].push(d);return l},{});const s={[im]:Ia({paths:r,censor:n,serialize:t,strict:Pa,remove:i})};const a=(...l)=>{return typeof n==="function"?t(n(...l)):t(n)};return[...Object.keys(o),...Object.getOwnPropertySymbols(o)].reduce((l,u)=>{if(o[u]===null){l[u]=f=>a(f,[u])}else{const f=typeof n==="function"?(c,h)=>{return n(c,[u,...h])}:n;l[u]=Ia({paths:o[u],censor:f,serialize:t,strict:Pa,remove:i})}return l},s)}function sm(e){if(Array.isArray(e)){e={paths:e,censor:La};return e}let{paths:t,censor:r=La,remove:n}=e;if(Array.isArray(t)===false){throw Error("pino \u2013 redact must contain an array of strings")}if(n===true)r=void 0;return{paths:t,censor:r,remove:n}}ka.exports=om});var ja=E((nI,Da)=>{"use strict";var am=()=>"";var lm=()=>`,"time":${Date.now()}`;var um=()=>`,"time":${Math.round(Date.now()/1e3)}`;var cm=()=>`,"time":"${new Date(Date.now()).toISOString()}"`;var fm=1000000n;var Na=1000000000n;var dm=BigInt(Date.now())*fm;var pm=process.hrtime.bigint();var hm=()=>{const e=process.hrtime.bigint()-pm;const t=dm+e;const r=t/Na;const n=t%Na;const i=Number(r*1000n+n/1000000n);const o=new Date(i);const s=o.getUTCFullYear();const a=(o.getUTCMonth()+1).toString().padStart(2,"0");const l=o.getUTCDate().toString().padStart(2,"0");const u=o.getUTCHours().toString().padStart(2,"0");const f=o.getUTCMinutes().toString().padStart(2,"0");const c=o.getUTCSeconds().toString().padStart(2,"0");return`,"time":"${s}-${a}-${l}T${u}:${f}:${c}.${n.toString().padStart(9,"0")}Z"`};Da.exports={nullTime:am,epochTime:lm,unixTime:um,isoTime:cm,isoTimeNano:hm}});var qa=E((iI,Ba)=>{"use strict";function gm(e){try{return JSON.stringify(e)}catch(t){return'"[Circular]"'}}Ba.exports=ym;function ym(e,t,r){var n=r&&r.stringify||gm;var i=1;if(typeof e==="object"&&e!==null){var o=t.length+i;if(o===1)return e;var s=new Array(o);s[0]=n(e);for(var a=1;a<o;a++){s[a]=n(t[a])}return s.join(" ")}if(typeof e!=="string"){return e}var l=t.length;if(l===0)return e;var u="";var f=1-i;var c=-1;var h=e&&e.length||0;for(var p=0;p<h;){if(e.charCodeAt(p)===37&&p+1<h){c=c>-1?c:0;switch(e.charCodeAt(p+1)){case 100:case 102:if(f>=l)break;if(t[f]==null)break;if(c<p)u+=e.slice(c,p);u+=Number(t[f]);c=p+2;p++;break;case 105:if(f>=l)break;if(t[f]==null)break;if(c<p)u+=e.slice(c,p);u+=Math.floor(Number(t[f]));c=p+2;p++;break;case 79:case 111:case 106:if(f>=l)break;if(t[f]===void 0)break;if(c<p)u+=e.slice(c,p);var d=typeof t[f];if(d==="string"){u+="'"+t[f]+"'";c=p+2;p++;break}if(d==="function"){u+=t[f].name||"<anonymous>";c=p+2;p++;break}u+=n(t[f]);c=p+2;p++;break;case 115:if(f>=l)break;if(c<p)u+=e.slice(c,p);u+=String(t[f]);c=p+2;p++;break;case 37:if(c<p)u+=e.slice(c,p);u+="%";c=p+2;p++;f--;break}++f}++p}if(c===-1)return e;else if(c<h){u+=e.slice(c)}return u}});var zn=E((oI,Vn)=>{"use strict";if(typeof SharedArrayBuffer!=="undefined"&&typeof Atomics!=="undefined"){let t=function(r){const n=r>0&&r<Infinity;if(n===false){if(typeof r!=="number"&&typeof r!=="bigint"){throw TypeError("sleep: ms must be a number")}throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}Atomics.wait(e,0,0,Number(r))};const e=new Int32Array(new SharedArrayBuffer(4));Vn.exports=t}else{let e=function(t){const r=t>0&&t<Infinity;if(r===false){if(typeof t!=="number"&&typeof t!=="bigint"){throw TypeError("sleep: ms must be a number")}throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}const n=Date.now()+Number(t);while(n>Date.now()){}};Vn.exports=e}});var Qn=E((sI,Va)=>{"use strict";var q=I("fs");var mm=I("events");var bm=I("util").inherits;var $a=I("path");var Yn=zn();var wm=I("assert");var dr=100;var pr=Buffer.allocUnsafe(0);var Sm=16*1024;var Wa="buffer";var Fa="utf8";var[_m,Em]=(process.versions.node||"0.0").split(".").map(Number);var xm=_m>=22&&Em>=7;function Ua(e,t){t._opening=true;t._writing=true;t._asyncDrainScheduled=false;function r(o,s){if(o){t._reopening=false;t._writing=false;t._opening=false;if(t.sync){process.nextTick(()=>{if(t.listenerCount("error")>0){t.emit("error",o)}})}else{t.emit("error",o)}return}const a=t._reopening;t.fd=s;t.file=e;t._reopening=false;t._opening=false;t._writing=false;if(t.sync){process.nextTick(()=>t.emit("ready"))}else{t.emit("ready")}if(t.destroyed){return}if(!t._writing&&t._len>t.minLength||t._flushPending){t._actualWrite()}else if(a){process.nextTick(()=>t.emit("drain"))}}const n=t.append?"a":"w";const i=t.mode;if(t.sync){try{if(t.mkdir)q.mkdirSync($a.dirname(e),{recursive:true});const o=q.openSync(e,n,i);r(null,o)}catch(o){r(o);throw o}}else if(t.mkdir){q.mkdir($a.dirname(e),{recursive:true},o=>{if(o)return r(o);q.open(e,n,i,r)})}else{q.open(e,n,i,r)}}function re(e){if(!(this instanceof re)){return new re(e)}let{fd:t,dest:r,minLength:n,maxLength:i,maxWrite:o,periodicFlush:s,sync:a,append:l=true,mkdir:u,retryEAGAIN:f,fsync:c,contentMode:h,mode:p}=e||{};t=t||r;this._len=0;this.fd=-1;this._bufs=[];this._lens=[];this._writing=false;this._ending=false;this._reopening=false;this._asyncDrainScheduled=false;this._flushPending=false;this._hwm=Math.max(n||0,16387);this.file=null;this.destroyed=false;this.minLength=n||0;this.maxLength=i||0;this.maxWrite=o||Sm;this._periodicFlush=s||0;this._periodicFlushTimer=void 0;this.sync=a||false;this.writable=true;this._fsync=c||false;this.append=l||false;this.mode=p;this.retryEAGAIN=f||(()=>true);this.mkdir=u||false;let d;let g;if(h===Wa){this._writingBuf=pr;this.write=Tm;this.flush=Mm;this.flushSync=Om;this._actualWrite=Lm;d=()=>q.writeSync(this.fd,this._writingBuf);g=()=>q.write(this.fd,this._writingBuf,this.release)}else if(h===void 0||h===Fa){this._writingBuf="";this.write=Rm;this.flush=vm;this.flushSync=Cm;this._actualWrite=Im;d=()=>{if(Buffer.isBuffer(this._writingBuf)){return q.writeSync(this.fd,this._writingBuf)}return q.writeSync(this.fd,this._writingBuf,"utf8")};g=()=>{if(Buffer.isBuffer(this._writingBuf)){return q.write(this.fd,this._writingBuf,this.release)}return q.write(this.fd,this._writingBuf,"utf8",this.release)}}else{throw new Error(`SonicBoom supports "${Fa}" and "${Wa}", but passed ${h}`)}if(typeof t==="number"){this.fd=t;process.nextTick(()=>this.emit("ready"))}else if(typeof t==="string"){Ua(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=(y,m)=>{if(y){if((y.code==="EAGAIN"||y.code==="EBUSY")&&this.retryEAGAIN(y,this._writingBuf.length,this._len-this._writingBuf.length)){if(this.sync){try{Yn(dr);this.release(void 0,0)}catch(S){this.release(S)}}else{setTimeout(g,dr)}}else{this._writing=false;this.emit("error",y)}return}this.emit("write",m);const w=Gn(this._writingBuf,this._len,m);this._len=w.len;this._writingBuf=w.writingBuf;if(this._writingBuf.length){if(!this.sync){g();return}try{do{const S=d();const A=Gn(this._writingBuf,this._len,S);this._len=A.len;this._writingBuf=A.writingBuf}while(this._writingBuf.length)}catch(S){this.release(S);return}}if(this._fsync){q.fsyncSync(this.fd)}const _=this._len;if(this._reopening){this._writing=false;this._reopening=false;this.reopen()}else if(_>this.minLength){this._actualWrite()}else if(this._ending){if(_>0){this._actualWrite()}else{this._writing=false;hr(this)}}else{this._writing=false;if(this.sync){if(!this._asyncDrainScheduled){this._asyncDrainScheduled=true;process.nextTick(Am,this)}}else{this.emit("drain")}}};this.on("newListener",function(y){if(y==="drain"){this._asyncDrainScheduled=false}});if(this._periodicFlush!==0){this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush);this._periodicFlushTimer.unref()}}function Gn(e,t,r){if(typeof e==="string"){e=Buffer.from(e)}t=Math.max(t-r,0);e=e.subarray(r);return{writingBuf:e,len:t}}function Am(e){const t=e.listenerCount("drain")>0;if(!t)return;e._asyncDrainScheduled=false;e.emit("drain")}bm(re,mm);function Ha(e,t){if(e.length===0){return pr}if(e.length===1){return e[0]}return Buffer.concat(e,t)}function Rm(e){if(this.destroyed){throw new Error("SonicBoom destroyed")}e=""+e;const t=Buffer.byteLength(e);const r=this._len+t;const n=this._bufs;if(this.maxLength&&r>this.maxLength){this.emit("drop",e);return this._len<this._hwm}if(n.length===0||Buffer.byteLength(n[n.length-1])+t>this.maxWrite){n.push(e)}else{n[n.length-1]+=e}this._len=r;if(!this._writing&&this._len>=this.minLength){this._actualWrite()}return this._len<this._hwm}function Tm(e){if(this.destroyed){throw new Error("SonicBoom destroyed")}const t=this._len+e.length;const r=this._bufs;const n=this._lens;if(this.maxLength&&t>this.maxLength){this.emit("drop",e);return this._len<this._hwm}if(r.length===0||n[n.length-1]+e.length>this.maxWrite){r.push([e]);n.push(e.length)}else{r[r.length-1].push(e);n[n.length-1]+=e.length}this._len=t;if(!this._writing&&this._len>=this.minLength){this._actualWrite()}return this._len<this._hwm}function Ka(e){this._flushPending=true;const t=()=>{if(!this._fsync){try{q.fsync(this.fd,n=>{this._flushPending=false;e(n)})}catch(n){e(n)}}else{this._flushPending=false;e()}this.off("error",r)};const r=n=>{this._flushPending=false;e(n);this.off("drain",t)};this.once("drain",t);this.once("error",r)}function vm(e){if(e!=null&&typeof e!=="function"){throw new Error("flush cb must be a function")}if(this.destroyed){const t=new Error("SonicBoom destroyed");if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}if(e){Ka.call(this,e)}if(this._writing){return}if(this._bufs.length===0){this._bufs.push("")}this._actualWrite()}function Mm(e){if(e!=null&&typeof e!=="function"){throw new Error("flush cb must be a function")}if(this.destroyed){const t=new Error("SonicBoom destroyed");if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}if(e){Ka.call(this,e)}if(this._writing){return}if(this._bufs.length===0){this._bufs.push([]);this._lens.push(0)}this._actualWrite()}re.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=true;if(this._writing){return}const t=this.fd;this.once("ready",()=>{if(t!==this.fd){q.close(t,r=>{if(r){return this.emit("error",r)}})}});Ua(this.file,this)};re.prototype.end=function(){if(this.destroyed){throw new Error("SonicBoom destroyed")}if(this._opening){this.once("ready",()=>{this.end()});return}if(this._ending){return}this._ending=true;if(this._writing){return}if(this._len>0&&this.fd>=0){this._actualWrite()}else{hr(this)}};function Cm(){if(this.destroyed){throw new Error("SonicBoom destroyed")}if(this.fd<0){throw new Error("sonic boom is not ready yet")}if(!this._writing&&this._writingBuf.length>0){this._bufs.unshift(this._writingBuf);this._writingBuf=""}let e="";while(this._bufs.length||e.length){if(e.length<=0){e=this._bufs[0]}try{const t=Buffer.isBuffer(e)?q.writeSync(this.fd,e):q.writeSync(this.fd,e,"utf8");const r=Gn(e,this._len,t);e=r.writingBuf;this._len=r.len;if(e.length<=0){this._bufs.shift()}}catch(t){const r=t.code==="EAGAIN"||t.code==="EBUSY";if(r&&!this.retryEAGAIN(t,e.length,this._len-e.length)){throw t}Yn(dr)}}try{q.fsyncSync(this.fd)}catch{}}function Om(){if(this.destroyed){throw new Error("SonicBoom destroyed")}if(this.fd<0){throw new Error("sonic boom is not ready yet")}if(!this._writing&&this._writingBuf.length>0){this._bufs.unshift([this._writingBuf]);this._writingBuf=pr}let e=pr;while(this._bufs.length||e.length){if(e.length<=0){e=Ha(this._bufs[0],this._lens[0])}try{const t=q.writeSync(this.fd,e);e=e.subarray(t);this._len=Math.max(this._len-t,0);if(e.length<=0){this._bufs.shift();this._lens.shift()}}catch(t){const r=t.code==="EAGAIN"||t.code==="EBUSY";if(r&&!this.retryEAGAIN(t,e.length,this._len-e.length)){throw t}Yn(dr)}}}re.prototype.destroy=function(){if(this.destroyed){return}hr(this)};function Im(){const e=this.release;this._writing=true;this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||"";if(this.sync){try{const t=Buffer.isBuffer(this._writingBuf)?q.writeSync(this.fd,this._writingBuf):q.writeSync(this.fd,this._writingBuf,"utf8");e(null,t)}catch(t){e(t)}}else{q.write(this.fd,this._writingBuf,e)}}function Lm(){const e=this.release;this._writing=true;this._writingBuf=this._writingBuf.length?this._writingBuf:Ha(this._bufs.shift(),this._lens.shift());if(this.sync){try{const t=q.writeSync(this.fd,this._writingBuf);e(null,t)}catch(t){e(t)}}else{if(xm){this._writingBuf=Buffer.from(this._writingBuf)}q.write(this.fd,this._writingBuf,e)}}function hr(e){if(e.fd===-1){e.once("ready",hr.bind(null,e));return}if(e._periodicFlushTimer!==void 0){clearInterval(e._periodicFlushTimer)}e.destroyed=true;e._bufs=[];e._lens=[];wm(typeof e.fd==="number",`sonic.fd must be a number, got ${typeof e.fd}`);try{q.fsync(e.fd,t)}catch{}function t(){if(e.fd!==1&&e.fd!==2){q.close(e.fd,r)}else{r()}}function r(n){if(n){e.emit("error",n);return}if(e._ending&&!e._writing){e.emit("finish")}e.emit("close")}}re.SonicBoom=re;re.default=re;Va.exports=re});var gr=E((aI,Ja)=>{"use strict";var ne={exit:[],beforeExit:[]};var za={exit:Nm,beforeExit:Dm};var et;function Pm(){if(et===void 0){et=new FinalizationRegistry(jm)}}function km(e){if(ne[e].length>0){return}process.on(e,za[e])}function Ga(e){if(ne[e].length>0){return}process.removeListener(e,za[e]);if(ne.exit.length===0&&ne.beforeExit.length===0){et=void 0}}function Nm(){Ya("exit")}function Dm(){Ya("beforeExit")}function Ya(e){for(const t of ne[e]){const r=t.deref();const n=t.fn;if(r!==void 0){n(r,e)}}ne[e]=[]}function jm(e){for(const t of["exit","beforeExit"]){const r=ne[t].indexOf(e);ne[t].splice(r,r+1);Ga(t)}}function Qa(e,t,r){if(t===void 0){throw new Error("the object can't be undefined")}km(e);const n=new WeakRef(t);n.fn=r;Pm();et.register(t,n);ne[e].push(n)}function Bm(e,t){Qa("exit",e,t)}function qm(e,t){Qa("beforeExit",e,t)}function $m(e){if(et===void 0){return}et.unregister(e);for(const t of["exit","beforeExit"]){ne[t]=ne[t].filter(r=>{const n=r.deref();return n&&n!==e});Ga(t)}}Ja.exports={register:Bm,registerBeforeExit:qm,unregister:$m}});var Xa=E((lI,Wm)=>{Wm.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 el=E((uI,Za)=>{"use strict";var yr=1e4;function Fm(e,t,r,n,i){const o=n===Infinity?Infinity:Date.now()+n;const s=()=>{const a=Atomics.load(e,t);if(a===r){i(null,"ok");return}if(o!==Infinity&&Date.now()>o){i(null,"timed-out");return}const l=o===Infinity?yr:Math.min(yr,Math.max(1,o-Date.now()));const u=Atomics.waitAsync(e,t,a,l);if(u.async){u.value.then(s)}else{setImmediate(s)}};s()}function Um(e,t,r,n,i){const o=n===Infinity?Infinity:Date.now()+n;const s=()=>{const a=Atomics.load(e,t);if(a!==r){i(null,"ok");return}if(o!==Infinity&&Date.now()>o){i(null,"timed-out");return}const l=o===Infinity?yr:Math.min(yr,Math.max(1,o-Date.now()));const u=Atomics.waitAsync(e,t,r,l);if(u.async){u.value.then(f=>{if(f==="ok"){i(null,"ok");return}s()})}else{setImmediate(s)}};s()}Za.exports={wait:Fm,waitDiff:Um}});var rl=E((cI,tl)=>{"use strict";var Hm=2;var Km=4;var Vm=8;tl.exports={WRITE_INDEX:Km,READ_INDEX:Vm,SEQ_INDEX:Hm}});var hl=E((fI,pl)=>{"use strict";var{version:zm}=Xa();var{EventEmitter:Gm}=I("events");var{Worker:Ym}=I("worker_threads");var{join:Qm}=I("path");var{pathToFileURL:Jm}=I("url");var{wait:Xm}=el();var{WRITE_INDEX:he,READ_INDEX:Le,SEQ_INDEX:Jn}=rl();var Zm=I("buffer");var eb=I("assert");var b=Symbol("kImpl");var tb=Zm.constants.MAX_STRING_LENGTH;function nl(){}function ti(e,t){Atomics.add(e[b].state,Jn,1);t();Atomics.add(e[b].state,Jn,1);Atomics.notify(e[b].state,Jn)}function il(e){ti(e,()=>{Atomics.store(e[b].state,Le,0);Atomics.store(e[b].state,he,0)})}var Tt=class{constructor(t){this._value=t}deref(){return this._value}};var mr=class{register(){}unregister(){}};var rb=process.env.NODE_V8_COVERAGE?mr:global.FinalizationRegistry||mr;var nb=process.env.NODE_V8_COVERAGE?Tt:global.WeakRef||Tt;var ol=new rb(e=>{if(e.exited){return}e.terminate()});function ib(e,t){const{filename:r,workerData:n}=t;const i="__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{};const o=i["thread-stream-worker"]||Qm(__dirname,"lib","worker.js");const s=new Ym(o,{...t.workerOpts,name:t.workerOpts?.name||"thread-stream",trackUnmanagedFds:false,workerData:{filename:r.indexOf("file://")===0?r:Jm(r).href,dataBuf:e[b].dataBuf,stateBuf:e[b].stateBuf,workerData:{$context:{threadStreamVersion:zm},...n}}});s.stream=new Tt(e);s.on("message",ob);s.on("exit",ll);ol.register(e,s);return s}function sl(e){eb(!e[b].sync);if(e[b].needDrain){e[b].needDrain=false;e.emit("drain")}}function al(e){while(true){const t=Atomics.load(e[b].state,he);const r=e[b].data.length-t;if(r>0){if(e[b].bufLen===0){e[b].flushing=false;if(e[b].ending){ri(e)}else if(e[b].needDrain){process.nextTick(sl,e)}return}fl(e,r,nl);continue}if(r===0){if(t===0&&e[b].bufLen===0){return}br(e,()=>{if(e.destroyed){return}il(e);al(e)});return}X(e,new Error("overwritten"));return}}function ob(e){const t=this.stream.deref();if(t===void 0){this.exited=true;this.terminate();return}if(e?.code==null){return}switch(e.code){case"READY":this.stream=new nb(t);br(t,()=>{t[b].ready=true;t.emit("ready")});break;case"ERROR":X(t,e.err);break;case"EVENT":if(Array.isArray(e.args)){t.emit(e.name,...e.args)}else{t.emit(e.name,e.args)}break;case"FLUSHED":{if(e.context!=="thread-stream"){X(t,new Error("this should not happen: "+e.code));break}const r=t[b].flushCallbacks.get(e.id);if(r){t[b].flushCallbacks.delete(e.id);process.nextTick(r)}break}case"WARNING":process.emitWarning(e.err);break;default:X(t,new Error("this should not happen: "+e.code))}}function ll(e){const t=this.stream.deref();if(t===void 0){return}ol.unregister(t);t.worker.exited=true;t.worker.off("exit",ll);X(t,e!==0?new Error("the worker thread exited"):null)}var Zn=class extends Gm{constructor(t={}){super();if(t.bufferSize<4){throw new Error("bufferSize must at least fit a 4-byte utf-8 char")}this[b]={};this[b].stateBuf=new SharedArrayBuffer(128);this[b].state=new Int32Array(this[b].stateBuf);this[b].dataBuf=new SharedArrayBuffer(t.bufferSize||4*1024*1024);this[b].data=Buffer.from(this[b].dataBuf);this[b].sync=t.sync||false;this[b].ending=false;this[b].ended=false;this[b].needDrain=false;this[b].destroyed=false;this[b].flushing=false;this[b].ready=false;this[b].finished=false;this[b].errored=null;this[b].closed=false;this[b].buf=[];this[b].bufHead=0;this[b].bufLen=0;this[b].flushCallbacks=new Map;this[b].nextFlushId=0;this.worker=ib(this,t);this.on("message",(r,n)=>{this.worker.postMessage(r,n)})}write(t){const r=Buffer.isBuffer(t)?t:Buffer.from(t);if(this[b].destroyed){ei(this,new Error("the worker has exited"));return false}if(this[b].ending){ei(this,new Error("the worker is ending"));return false}if(this[b].flushing&&this[b].bufLen+r.length>=tb){try{Xn(this);this[b].flushing=true}catch(n){X(this,n);return false}}this[b].buf.push(r);this[b].bufLen+=r.length;if(this[b].sync){try{Xn(this);return true}catch(n){X(this,n);return false}}if(!this[b].flushing){this[b].flushing=true;setImmediate(al,this)}this[b].needDrain=this[b].data.length-this[b].bufLen-Atomics.load(this[b].state,he)<=0;return!this[b].needDrain}end(){if(this[b].destroyed){return}this[b].ending=true;ri(this)}flush(t){t=typeof t==="function"?t:nl;ul(this,r=>{if(r){process.nextTick(t,r);return}cl(this,t)})}flushSync(){if(this[b].destroyed){return}Xn(this);dl(this)}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[b].ready}get destroyed(){return this[b].destroyed}get closed(){return this[b].closed}get writable(){return!this[b].destroyed&&!this[b].ending}get writableEnded(){return this[b].ending}get writableFinished(){return this[b].finished}get writableNeedDrain(){return this[b].needDrain}get writableObjectMode(){return false}get writableErrored(){return this[b].errored}};function ul(e,t){if(e[b].destroyed){process.nextTick(t,new Error("the worker has exited"));return}if(!e[b].sync&&(e[b].flushing||e[b].bufLen>0)){setImmediate(ul,e,t);return}br(e,t)}function br(e,t){const r=Atomics.load(e[b].state,he);Xm(e[b].state,Le,r,Infinity,(n,i)=>{if(n){X(e,n);t(n);return}if(i!=="ok"){br(e,t);return}t()})}function cl(e,t){if(e[b].destroyed){process.nextTick(t,new Error("the worker has exited"));return}if(!e[b].ready){const n=()=>{o();cl(e,t)};const i=()=>{o();process.nextTick(t,new Error("the worker has exited"))};const o=()=>{e.off("ready",n);e.off("close",i)};e.once("ready",n);e.once("close",i);return}const r=++e[b].nextFlushId;e[b].flushCallbacks.set(r,t);try{e.worker.postMessage({code:"FLUSH",context:"thread-stream",id:r})}catch(n){e[b].flushCallbacks.delete(r);X(e,n);process.nextTick(t,n)}}function sb(e,t){const r=e[b].flushCallbacks;if(r.size===0){return}const n=t||new Error("the worker has exited");for(const i of r.values()){process.nextTick(i,n)}r.clear()}function ei(e,t){setImmediate(()=>{e.emit("error",t)})}function X(e,t){if(e[b].destroyed){return}e[b].destroyed=true;sb(e,t);if(t){e[b].errored=t;ei(e,t)}if(!e.worker.exited){e.worker.terminate().catch(()=>{}).then(()=>{e[b].closed=true;e.emit("close")})}else{setImmediate(()=>{e[b].closed=true;e.emit("close")})}}function fl(e,t,r){const n=Atomics.load(e[b].state,he);let i=n;let o=t;while(o>0&&e[b].bufLen!==0){const s=e[b].bufHead;const a=e[b].buf[s];if(a.length<=o){a.copy(e[b].data,i);i+=a.length;o-=a.length;e[b].bufLen-=a.length;e[b].bufHead=s+1;if(e[b].bufHead===e[b].buf.length){e[b].buf.length=0;e[b].bufHead=0}else if(e[b].bufHead>=1024&&e[b].bufHead*2>=e[b].buf.length){e[b].buf.splice(0,e[b].bufHead);e[b].bufHead=0}continue}a.copy(e[b].data,i,0,o);e[b].buf[s]=a.subarray(o);e[b].bufLen-=o;i+=o;o=0}ti(e,()=>{Atomics.store(e[b].state,he,i)});r();return true}function ri(e){if(e[b].ended||!e[b].ending||e[b].flushing){return}e[b].ended=true;try{e.flushSync();let t=Atomics.load(e[b].state,Le);ti(e,()=>{Atomics.store(e[b].state,he,-1)});let r=0;while(t!==-1){Atomics.wait(e[b].state,Le,t,1e3);t=Atomics.load(e[b].state,Le);if(t===-2){X(e,new Error("end() failed"));return}if(++r===10){X(e,new Error("end() took too long (10s)"));return}}process.nextTick(()=>{e[b].finished=true;e.emit("finish")})}catch(t){X(e,t)}}function Xn(e){const t=()=>{if(e[b].ending){ri(e)}else if(e[b].needDrain){process.nextTick(sl,e)}};e[b].flushing=false;while(e[b].bufLen!==0){const r=Atomics.load(e[b].state,he);const n=e[b].data.length-r;if(n===0){dl(e);il(e);continue}else if(n<0){throw new Error("overwritten")}fl(e,n,t)}}function dl(e){if(e[b].flushing){throw new Error("unable to flush while flushing")}const t=Atomics.load(e[b].state,he);let r=0;while(true){const n=Atomics.load(e[b].state,Le);if(n===-2){throw Error("_flushSync failed")}if(n!==t){Atomics.wait(e[b].state,Le,n,1e3)}else{break}if(++r===10){throw new Error("_flushSync took too long (10s)")}}}pl.exports=Zn});var oi=E((dI,ml)=>{"use strict";var{createRequire:ab}=I("module");var{existsSync:lb}=I("node:fs");var ub=Fn();var{join:ni,isAbsolute:yl,sep:cb}=I("node:path");var{fileURLToPath:fb}=I("node:url");var db=zn();var ii=gr();var pb=hl();function hb(e){ii.register(e,wb);ii.registerBeforeExit(e,Sb);e.on("close",function(){ii.unregister(e)})}function gb(){const e=process.execArgv;for(let t=0;t<e.length;t++){const r=e[t];if(r==="--import"||r==="--require"||r==="-r"){return true}if(r.startsWith("--import=")||r.startsWith("--require=")||r.startsWith("-r=")){return true}}return false}function yb(e){const t=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!t){return e}const r=[];let n=false;for(let i=0;i<t.length;i++){const o=t[i];if(o==="--require"||o==="-r"||o==="--import"){const s=t[i+1];if(s&&gl(s)){n=true;i++;continue}r.push(o);if(s){r.push(s);i++}continue}if(o.startsWith("--require=")||o.startsWith("-r=")||o.startsWith("--import=")){const s=o.slice(o.indexOf("=")+1);if(gl(s)){n=true;continue}}r.push(o)}return n?r.join(" "):e}function gl(e){const t=mb(e);if(!t){return false}let r=t;if(r.startsWith("file://")){try{r=fb(r)}catch{return false}}return yl(r)&&!lb(r)}function mb(e){const t=e[0];const r=e[e.length-1];if(t==='"'&&r==='"'||t==="'"&&r==="'"){return e.slice(1,-1)}return e}function bb(e,t,r,n,i){if(!r.execArgv&&gb()&&I.main===void 0){r={...r,execArgv:[]}}if(!r.env&&process.env.NODE_OPTIONS){const l=yb(process.env.NODE_OPTIONS);if(l!==process.env.NODE_OPTIONS){r={...r,env:{...process.env,NODE_OPTIONS:l}}}}r={...r,name:i};const o=new pb({filename:e,workerData:t,workerOpts:r,sync:n});o.on("ready",s);o.on("close",function(){process.removeListener("exit",a)});process.on("exit",a);function s(){process.removeListener("exit",a);o.unref();if(r.autoEnd!==false){hb(o)}}function a(){if(o.closed){return}o.flushSync();db(100);o.end()}return o}function wb(e){e.ref();e.flushSync();e.end();e.once("close",function(){e.unref()})}function Sb(e){e.flushSync()}function _b(e){const{pipeline:t,targets:r,levels:n,dedupe:i,worker:o={},caller:s=ub(),sync:a=false}=e;const l={...e.options};const u=typeof s==="string"?[s]:s;const f=typeof globalThis==="object"&&Object.prototype.hasOwnProperty.call(globalThis,"__bundlerPathsOverrides")&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides==="object"?globalThis.__bundlerPathsOverrides:Object.create(null);let c=e.target;if(c&&r){throw new Error("only one of target or targets can be specified")}if(r){c=f["pino-worker"]||ni(__dirname,"worker.js");l.targets=r.filter(d=>d.target).map(d=>{return{...d,target:p(d.target)}});l.pipelines=r.filter(d=>d.pipeline).map(d=>{return d.pipeline.map(g=>{return{...g,level:d.level,target:p(g.target)}})})}else if(t){c=f["pino-worker"]||ni(__dirname,"worker.js");l.pipelines=[t.map(d=>{return{...d,target:p(d.target)}})]}if(n){l.levels=n}if(i){l.dedupe=i}l.pinoWillSendConfig=true;const h=r||t?"pino.transport":c;return bb(p(c),l,o,a,h);function p(d){d=f[d]||d;if(yl(d)||d.indexOf("file://")===0){return d}if(d==="pino/file"){return ni(__dirname,"..","file.js")}let g;for(const y of u){try{const m=y==="node:repl"?process.cwd()+cb:y;g=ab(m).resolve(d);break}catch(m){continue}}if(!g){throw new Error(`unable to determine transport target for "${d}"`)}return g}}ml.exports=_b});var _r=E((hI,Ol)=>{"use strict";var Eb=I("node:diagnostics_channel");var bl=qa();var{mapHttpRequest:xb,mapHttpResponse:Ab}=Wn();var ai=Qn();var wl=gr();var{lsCacheSym:Rb,chindingsSym:Al,writeSym:Sl,serializersSym:Rl,formatOptsSym:_l,endSym:Tb,stringifiersSym:Tl,stringifySym:vl,stringifySafeSym:li,wildcardFirstSym:Ml,nestedKeySym:vb,formattersSym:Cl,messageKeySym:Mb,errorKeySym:Cb,nestedKeyStrSym:Ob,msgPrefixSym:wr}=Ze();var{isMainThread:Ib}=I("worker_threads");var Lb=oi();var[Pb]=process.versions.node.split(".").map(e=>Number(e));var El=Eb.tracingChannel("pino_asJson");var si=Pb>=25?e=>JSON.stringify(e):Nb;function tt(){}function kb(e,t){if(!t)return r;return function n(...i){t.call(this,i,r,e)};function r(n,...i){if(typeof n==="object"){let o=n;if(n!==null){if(n.method&&n.headers&&n.socket){n=xb(n)}else if(typeof n.setHeader==="function"){n=Ab(n)}}let s;if(o===null&&i.length===0){s=[null]}else{o=i.shift();s=i}if(typeof this[wr]==="string"&&o!==void 0&&o!==null){o=this[wr]+o}this[Sl](n,bl(o,s,this[_l]),e)}else{let o=n===void 0?i.shift():n;if(typeof this[wr]==="string"&&o!==void 0&&o!==null){o=this[wr]+o}this[Sl](null,bl(o,i,this[_l]),e)}}}function Nb(e){let t="";let r=0;let n=false;let i=255;const o=e.length;if(o>100){return JSON.stringify(e)}for(var s=0;s<o&&i>=32;s++){i=e.charCodeAt(s);if(i===34||i===92){t+=e.slice(r,s)+"\\";r=s;n=true}}if(!n){t=e}else{t+=e.slice(r)}return i<32?JSON.stringify(e):'"'+t+'"'}function Db(e,t,r,n){if(El.hasSubscribers===false){return xl.call(this,e,t,r,n)}const i={instance:this,arguments};return El.traceSync(xl,i,this,e,t,r,n)}function xl(e,t,r,n){const i=this[vl];const o=this[li];const s=this[Tl];const a=this[Tb];const l=this[Al];const u=this[Rl];const f=this[Cl];const c=this[Mb];const h=this[Cb];let p=this[Rb][r]+n;p=p+l;let d;if(f.log){e=f.log(e)}const g=s[Ml];let y="";for(const w in e){d=e[w];if(Object.prototype.hasOwnProperty.call(e,w)&&d!==void 0){if(u[w]){d=u[w](d)}else if(w===h&&u.err){d=u.err(d)}const _=s[w]||g;switch(typeof d){case"undefined":case"function":continue;case"number":if(Number.isFinite(d)===false){d=null}case"boolean":if(_)d=_(d);break;case"string":d=(_||si)(d);break;default:d=(_||i)(d,o)}if(d===void 0)continue;const S=si(w);y+=","+S+":"+d}}let m="";if(t!==void 0){d=u[c]?u[c](t):t;const w=s[c]||g;switch(typeof d){case"function":break;case"number":if(Number.isFinite(d)===false){d=null}case"boolean":if(w)d=w(d);m=',"'+c+'":'+d;break;case"string":d=(w||si)(d);m=',"'+c+'":'+d;break;default:d=(w||i)(d,o);m=',"'+c+'":'+d}}if(this[vb]&&y){return p+this[Ob]+y.slice(1)+"}"+m+a}else{return p+y+m+a}}function jb(e,t){let r;let n=e[Al];const i=e[vl];const o=e[li];const s=e[Tl];const a=s[Ml];const l=e[Rl];const u=e[Cl].bindings;t=u(t);for(const f in t){r=t[f];const c=(f.length<5||f!=="level"&&f!=="serializers"&&f!=="formatters"&&f!=="customLevels")&&t.hasOwnProperty(f)&&r!==void 0;if(c===true){r=l[f]?l[f](r):r;r=(s[f]||a||i)(r,o);if(r===void 0)continue;n+=',"'+f+'":'+r}}return n}function Bb(e){return e.write!==e.constructor.prototype.write}function Sr(e){const t=new ai(e);t.on("error",r);if(!e.sync&&Ib){wl.register(t,qb);t.on("close",function(){wl.unregister(t)})}return t;function r(n){if(n.code==="EPIPE"){t.write=tt;t.end=tt;t.flushSync=tt;t.destroy=tt;return}t.removeListener("error",r);t.emit("error",n)}}function qb(e,t){if(e.destroyed){return}if(t==="beforeExit"){e.flush();e.on("drain",function(){e.end()})}else{e.flushSync()}}function $b(e){return function t(r,n,i={},o){if(typeof i==="string"){o=Sr({dest:i});i={}}else if(typeof o==="string"){if(i&&i.transport){throw Error("only one of option.transport or stream can be specified")}o=Sr({dest:o})}else if(i instanceof ai||i.writable||i._writableState){o=i;i={}}else if(i.transport){if(i.transport instanceof ai||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;if(i.customLevels){l=i.useOnlyCustomLevels?i.customLevels:Object.assign({},i.levels,i.customLevels)}o=Lb({caller:n,...i.transport,levels:l})}i=Object.assign({},e,i);i.serializers=Object.assign({},e.serializers,i.serializers);i.formatters=Object.assign({},e.formatters,i.formatters);if(i.prettyPrint){throw new Error("prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)")}const{enabled:s,onChild:a}=i;if(s===false)i.level="silent";if(!a)i.onChild=tt;if(!o){if(!Bb(process.stdout)){o=Sr({fd:process.stdout.fd||1})}else{o=process.stdout}}return{opts:i,stream:o}}}function Wb(e,t){try{return JSON.stringify(e)}catch(r){try{const n=t||this[li];return n(e)}catch(n){return'"[unable to serialize, circular reference is too complex to analyze]"'}}}function Fb(e,t,r){return{level:e,bindings:t,log:r}}function Ub(e){const t=Number(e);if(typeof e==="string"&&Number.isFinite(t)){return t}if(e===void 0){return 1}return e}Ol.exports={noop:tt,buildSafeSonicBoom:Sr,asChindings:jb,asJson:Db,genLog:kb,createArgsNormalizer:$b,stringify:Wb,buildFormatters:Fb,normalizeDestFileDescriptor:Ub}});var Er=E((gI,Il)=>{var Hb={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var Kb={ASC:"ASC",DESC:"DESC"};Il.exports={DEFAULT_LEVELS:Hb,SORTING_ORDER:Kb}});var fi=E((yI,Nl)=>{"use strict";var{lsCacheSym:Vb,levelValSym:ui,useOnlyCustomLevelsSym:zb,streamSym:Gb,formattersSym:Yb,hooksSym:Qb,levelCompSym:Ll}=Ze();var{noop:Jb,genLog:Pe}=_r();var{DEFAULT_LEVELS:ae,SORTING_ORDER:Pl}=Er();var kl={fatal:e=>{const t=Pe(ae.fatal,e);return function(...r){const n=this[Gb];t.call(this,...r);if(typeof n.flushSync==="function"){try{n.flushSync()}catch(i){}}}},error:e=>Pe(ae.error,e),warn:e=>Pe(ae.warn,e),info:e=>Pe(ae.info,e),debug:e=>Pe(ae.debug,e),trace:e=>Pe(ae.trace,e)};var ci=Object.keys(ae).reduce((e,t)=>{e[ae[t]]=t;return e},{});var Xb=Object.keys(ci).reduce((e,t)=>{e[t]='{"level":'+Number(t);return e},{});function Zb(e){const t=e[Yb].level;const{labels:r}=e.levels;const n={};for(const i in r){const o=t(r[i],Number(i));n[i]=JSON.stringify(o).slice(0,-1)}e[Vb]=n;return e}function ew(e,t){if(t){return false}switch(e){case"fatal":case"error":case"warn":case"info":case"debug":case"trace":return true;default:return false}}function tw(e){const{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);const n=this[ui];const i=this[ui]=r[e];const o=this[zb];const s=this[Ll];const a=this[Qb].logMethod;for(const l in r){if(s(r[l],i)===false){this[l]=Jb;continue}this[l]=ew(l,o)?kl[l](a):Pe(r[l],a)}this.emit("level-change",e,i,t[n],n,this)}function rw(e){const{levels:t,levelVal:r}=this;return t&&t.labels?t.labels[r]:""}function nw(e){const{values:t}=this.levels;const r=t[e];return r!==void 0&&this[Ll](r,this[ui])}function iw(e,t,r){if(e===Pl.DESC){return t<=r}return t>=r}function ow(e){if(typeof e==="string"){return iw.bind(null,e)}return e}function sw(e=null,t=false){const r=e?Object.keys(e).reduce((o,s)=>{o[e[s]]=s;return o},{}):null;const n=Object.assign(Object.create(Object.prototype,{Infinity:{value:"silent"}}),t?null:ci,r);const i=Object.assign(Object.create(Object.prototype,{silent:{value:Infinity}}),t?null:ae,e);return{labels:n,values:i}}function aw(e,t,r){if(typeof e==="number"){const i=[].concat(Object.keys(t||{}).map(o=>t[o]),r?[]:Object.keys(ci).map(o=>+o),Infinity);if(!i.includes(e)){throw Error(`default level:${e} must be included in custom levels`)}return}const n=Object.assign(Object.create(Object.prototype,{silent:{value:Infinity}}),r?null:ae,t);if(!(e in n)){throw Error(`default level:${e} must be included in custom levels`)}}function lw(e,t){const{labels:r,values:n}=e;for(const 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 uw(e){if(typeof e==="function"){return}if(typeof e==="string"&&Object.values(Pl).includes(e)){return}throw new Error('Levels comparison should be one of "ASC", "DESC" or "function" type')}Nl.exports={initialLsCache:Xb,genLsCache:Zb,levelMethods:kl,getLevel:rw,setLevel:tw,isLevelEnabled:nw,mappings:sw,assertNoLevelCollisions:lw,assertDefaultLevelFound:aw,genLevelComparison:ow,assertLevelComparison:uw}});var di=E((mI,Dl)=>{"use strict";Dl.exports={version:"10.3.1"}});var Hl=E((wI,Ul)=>{"use strict";var{EventEmitter:cw}=I("node:events");var{lsCacheSym:fw,levelValSym:dw,setLevelSym:hi,getLevelSym:jl,chindingsSym:Ar,mixinSym:pw,asJsonSym:ql,writeSym:hw,mixinMergeStrategySym:gw,timeSym:yw,timeSliceIndexSym:mw,streamSym:$l,serializersSym:ke,formattersSym:vt,errorKeySym:bw,messageKeySym:ww,useOnlyCustomLevelsSym:Sw,needsMetadataGsym:_w,redactFmtSym:Ew,stringifySym:xw,formatOptsSym:Aw,stringifiersSym:Rw,msgPrefixSym:gi,hooksSym:Tw}=Ze();var{getLevel:vw,setLevel:Mw,isLevelEnabled:Cw,mappings:Ow,initialLsCache:Iw,genLsCache:Lw,assertNoLevelCollisions:Pw}=fi();var{asChindings:yi,asJson:kw,buildFormatters:pi,stringify:Bl,noop:Wl}=_r();var{version:Nw}=di();var Dw=Kn();var jw=class bI{};var Fl={constructor:jw,child:Bw,bindings:qw,setBindings:$w,flush:Uw,isLevelEnabled:Cw,version:Nw,get level(){return this[jl]()},set level(e){this[hi](e)},get levelVal(){return this[dw]},set levelVal(e){throw Error("levelVal is read-only")},get msgPrefix(){return this[gi]},get[Symbol.toStringTag](){return"Pino"},[fw]:Iw,[hw]:Fw,[ql]:kw,[jl]:vw,[hi]:Mw};Object.setPrototypeOf(Fl,cw.prototype);Ul.exports=function(){return Object.create(Fl)};var xr=e=>e;function Bw(e,t){if(!e){throw Error("missing bindings for child Pino")}const r=this[ke];const n=this[vt];const i=Object.create(this);if(t==null){if(i[vt].bindings!==xr){i[vt]=pi(n.level,xr,n.log)}i[Ar]=yi(i,e);if(this.onChild!==Wl){this.onChild(i)}return i}if(t.hasOwnProperty("serializers")===true){i[ke]=Object.create(null);for(const u in r){i[ke][u]=r[u]}const a=Object.getOwnPropertySymbols(r);for(var o=0;o<a.length;o++){const u=a[o];i[ke][u]=r[u]}for(const u in t.serializers){i[ke][u]=t.serializers[u]}const l=Object.getOwnPropertySymbols(t.serializers);for(var s=0;s<l.length;s++){const u=l[s];i[ke][u]=t.serializers[u]}}else i[ke]=r;if(t.hasOwnProperty("formatters")){const{level:a,bindings:l,log:u}=t.formatters;i[vt]=pi(a||n.level,l||xr,u||n.log)}else{i[vt]=pi(n.level,xr,n.log)}if(t.hasOwnProperty("customLevels")===true){Pw(this.levels,t.customLevels);i.levels=Ow(t.customLevels,i[Sw]);Lw(i)}if(typeof t.redact==="object"&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;const a=Dw(i.redact,Bl);const l={stringify:a[Ew]};i[xw]=Bl;i[Rw]=a;i[Aw]=l}if(typeof t.msgPrefix==="string"){i[gi]=(this[gi]||"")+t.msgPrefix}i[Ar]=yi(i,e);if(t.level!==void 0&&t.level!==this.level||t.hasOwnProperty("customLevels")){const a=t.level||this.level;i[hi](a)}this.onChild(i);return i}function qw(){const e=this[Ar];const t=`{${e.substr(1)}}`;const r=JSON.parse(t);delete r.pid;delete r.hostname;return r}function $w(e){const t=yi(this,e);this[Ar]=t}function Ww(e,t){return Object.assign(t,e)}function Fw(e,t,r){const n=this[yw]();const i=this[pw];const o=this[bw];const s=this[ww];const a=this[gw]||Ww;let l;const u=this[Tw].streamWrite;if(e===void 0||e===null){l={}}else if(e instanceof Error){l={[o]:e};if(t===void 0){t=e.message}}else{l=e;if(t===void 0&&e[s]===void 0&&e[o]){t=e[o].message}}if(i){l=a(l,i(l,r,this))}const f=this[ql](l,t,r,n);const c=this[$l];if(c[_w]===true){c.lastLevel=r;c.lastObj=l;c.lastMsg=t;c.lastTime=n.slice(this[mw]);c.lastLogger=this}c.write(u?u(f):f)}function Uw(e){if(e!=null&&typeof e!=="function"){throw Error("callback must be a function")}const t=this[$l];if(typeof t.flush==="function"){t.flush(e||Wl)}else if(e)e()}});var Gl=E((Si,zl)=>{"use strict";var{hasOwnProperty:Mt}=Object.prototype;var De=wi();De.configure=wi;De.stringify=De;De.default=De;Si.stringify=De;Si.configure=wi;zl.exports=De;var Hw=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function _e(e){if(e.length<5e3&&!Hw.test(e)){return`"${e}"`}return JSON.stringify(e)}function mi(e,t){if(e.length>200||t){return e.sort(t)}for(let r=1;r<e.length;r++){const n=e[r];let i=r;while(i!==0&&e[i-1]>n){e[i]=e[i-1];i--}e[i]=n}return e}var Kw=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function bi(e){return Kw.call(e)!==void 0&&e.length!==0}function Kl(e,t,r){if(e.length<r){r=e.length}const n=t===","?"":" ";let i=`"0":${n}${e[0]}`;for(let o=1;o<r;o++){i+=`${t}"${o}":${n}${e[o]}`}return i}function Vw(e){if(Mt.call(e,"circularValue")){const 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 zw(e){let t;if(Mt.call(e,"deterministic")){t=e.deterministic;if(typeof t!=="boolean"&&typeof t!=="function"){throw new TypeError('The "deterministic" argument must be of type boolean or comparator function')}}return t===void 0?true:t}function Gw(e,t){let r;if(Mt.call(e,t)){r=e[t];if(typeof r!=="boolean"){throw new TypeError(`The "${t}" argument must be of type boolean`)}}return r===void 0?true:r}function Vl(e,t){let r;if(Mt.call(e,t)){r=e[t];if(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?Infinity:r}function Ne(e){if(e===1){return"1 item"}return`${e} items`}function Yw(e){const t=new Set;for(const r of e){if(typeof r==="string"||typeof r==="number"){t.add(String(r))}}return t}function Qw(e){if(Mt.call(e,"strict")){const 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}`;if(typeof r!=="function")n+=` (${r.toString()})`;throw new Error(n)}}}}function wi(e){e={...e};const t=Qw(e);if(t){if(e.bigint===void 0){e.bigint=false}if(!("circularValue"in e)){e.circularValue=Error}}const r=Vw(e);const n=Gw(e,"bigint");const i=zw(e);const o=typeof i==="function"?i:void 0;const s=Vl(e,"maximumDepth");const a=Vl(e,"maximumBreadth");function l(p,d,g,y,m,w){let _=d[p];if(typeof _==="object"&&_!==null&&typeof _.toJSON==="function"){_=_.toJSON(p)}_=y.call(d,p,_);switch(typeof _){case"string":return _e(_);case"object":{if(_===null){return"null"}if(g.indexOf(_)!==-1){return r}let S="";let A=",";const v=w;if(Array.isArray(_)){if(_.length===0){return"[]"}if(s<g.length+1){return'"[Array]"'}g.push(_);if(m!==""){w+=m;S+=`
2
+ import{a as qh}from"./chunk-UQL67NEA.js";import{a as Ns}from"./chunk-7F3QKGB7.js";import{a as I,c as E,e as ks}from"./chunk-FK3SSGJE.js";var Pn=E((VO,sa)=>{"use strict";var Rt=e=>{return e&&typeof e.message==="string"};var Ln=e=>{if(!e)return;const t=e.cause;if(typeof t==="function"){const r=e.cause();return Rt(r)?r:void 0}else{return Rt(t)?t:void 0}};var ia=(e,t)=>{if(!Rt(e))return"";const r=e.stack||"";if(t.has(e)){return r+"\ncauses have become circular..."}const n=Ln(e);if(n){t.add(e);return r+"\ncaused by: "+ia(n,t)}else{return r}};var ny=e=>ia(e,new Set);var oa=(e,t,r)=>{if(!Rt(e))return"";const n=r?"":e.message||"";if(t.has(e)){return n+": ..."}const i=Ln(e);if(i){t.add(e);const o=typeof e.cause==="function";return n+(o?"":": ")+oa(i,t,o)}else{return n}};var iy=e=>oa(e,new Set);sa.exports={isErrorLike:Rt,getErrorCause:Ln,stackWithCauses:ny,messageWithCauses:iy}});var kn=E((zO,la)=>{"use strict";var oy=Symbol("circular-ref-tag");var or=Symbol("pino-raw-err-ref");var aa=Object.create({},{type:{enumerable:true,writable:true,value:void 0},message:{enumerable:true,writable:true,value:void 0},stack:{enumerable:true,writable:true,value:void 0},aggregateErrors:{enumerable:true,writable:true,value:void 0},raw:{enumerable:false,get:function(){return this[or]},set:function(e){this[or]=e}}});Object.defineProperty(aa,or,{writable:true,value:{}});la.exports={pinoErrProto:aa,pinoErrorSymbols:{seen:oy,rawSymbol:or}}});var fa=E((GO,ca)=>{"use strict";ca.exports=Dn;var{messageWithCauses:sy,stackWithCauses:ay,isErrorLike:ua}=Pn();var{pinoErrProto:ly,pinoErrorSymbols:uy}=kn();var{seen:Nn}=uy;var{toString:cy}=Object.prototype;function Dn(e){if(!ua(e)){return e}e[Nn]=void 0;const t=Object.create(ly);t.type=cy.call(e.constructor)==="[object Function]"?e.constructor.name:e.name;t.message=sy(e);t.stack=ay(e);if(Array.isArray(e.errors)){t.aggregateErrors=e.errors.map(r=>Dn(r))}for(const r in e){if(t[r]===void 0){const n=e[r];if(ua(n)){if(r!=="cause"&&!Object.prototype.hasOwnProperty.call(n,Nn)){t[r]=Dn(n)}}else{t[r]=n}}}delete e[Nn];t.raw=e;return t}});var pa=E((YO,da)=>{"use strict";da.exports=ar;var{isErrorLike:jn}=Pn();var{pinoErrProto:fy,pinoErrorSymbols:dy}=kn();var{seen:sr}=dy;var{toString:py}=Object.prototype;function ar(e){if(!jn(e)){return e}e[sr]=void 0;const t=Object.create(fy);t.type=py.call(e.constructor)==="[object Function]"?e.constructor.name:e.name;t.message=e.message;t.stack=e.stack;if(Array.isArray(e.errors)){t.aggregateErrors=e.errors.map(r=>ar(r))}if(jn(e.cause)&&!Object.prototype.hasOwnProperty.call(e.cause,sr)){t.cause=ar(e.cause)}for(const r in e){if(t[r]===void 0){const n=e[r];if(jn(n)){if(!Object.prototype.hasOwnProperty.call(n,sr)){t[r]=ar(n)}}else{t[r]=n}}}delete e[sr];t.raw=e;return t}});var ma=E((QO,ya)=>{"use strict";ya.exports={mapHttpRequest:hy,reqSerializer:ga};var Bn=Symbol("pino-raw-req-ref");var ha=Object.create({},{id:{enumerable:true,writable:true,value:""},method:{enumerable:true,writable:true,value:""},url:{enumerable:true,writable:true,value:""},query:{enumerable:true,writable:true,value:""},params:{enumerable:true,writable:true,value:""},headers:{enumerable:true,writable:true,value:{}},remoteAddress:{enumerable:true,writable:true,value:""},remotePort:{enumerable:true,writable:true,value:""},raw:{enumerable:false,get:function(){return this[Bn]},set:function(e){this[Bn]=e}}});Object.defineProperty(ha,Bn,{writable:true,value:{}});function ga(e){const t=e.info||e.socket;const r=Object.create(ha);r.id=typeof e.id==="function"?e.id():e.id||(e.info?e.info.id:void 0);r.method=e.method;if(e.originalUrl){r.url=e.originalUrl}else{const n=e.path;r.url=typeof n==="string"?n:e.url?e.url.path||e.url:void 0}if(e.query){r.query=e.query}if(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;return r}function hy(e){return{req:ga(e)}}});var _a=E((JO,Sa)=>{"use strict";Sa.exports={mapHttpResponse:gy,resSerializer:wa};var qn=Symbol("pino-raw-res-ref");var ba=Object.create({},{statusCode:{enumerable:true,writable:true,value:0},headers:{enumerable:true,writable:true,value:""},raw:{enumerable:false,get:function(){return this[qn]},set:function(e){this[qn]=e}}});Object.defineProperty(ba,qn,{writable:true,value:{}});function wa(e){const t=Object.create(ba);t.statusCode=e.headersSent?e.statusCode:null;t.headers=e.getHeaders?e.getHeaders():e._headers;t.raw=e;return t}function gy(e){return{res:wa(e)}}});var Wn=E((XO,Ea)=>{"use strict";var $n=fa();var yy=pa();var lr=ma();var ur=_a();Ea.exports={err:$n,errWithCause:yy,mapHttpRequest:lr.mapHttpRequest,mapHttpResponse:ur.mapHttpResponse,req:lr.reqSerializer,res:ur.resSerializer,wrapErrorSerializer:function e(t){if(t===$n)return t;return function r(n){return t($n(n))}},wrapRequestSerializer:function e(t){if(t===lr.reqSerializer)return t;return function r(n){return t(lr.reqSerializer(n))}},wrapResponseSerializer:function e(t){if(t===ur.resSerializer)return t;return function r(n){return t(ur.resSerializer(n))}}}});var Fn=E((ZO,xa)=>{"use strict";function my(e,t){return t}xa.exports=function e(){const t=Error.prepareStackTrace;Error.prepareStackTrace=my;const r=new Error().stack;Error.prepareStackTrace=t;if(!Array.isArray(r)){return void 0}const n=r.slice(2);const i=[];for(const o of n){if(!o){continue}i.push(o.getFileName())}return i}});var Ca=E((eI,Ma)=>{"use strict";function Un(e){if(e===null||typeof e!=="object"){return e}if(e instanceof Date){return new Date(e.getTime())}if(e instanceof Array){const t=[];for(let r=0;r<e.length;r++){t[r]=Un(e[r])}return t}if(typeof e==="object"){const t=Object.create(Object.getPrototypeOf(e));for(const r in e){if(Object.prototype.hasOwnProperty.call(e,r)){t[r]=Un(e[r])}}return t}return e}function Aa(e){const t=[];let r="";let n=false;let i=false;let o="";for(let s=0;s<e.length;s++){const a=e[s];if(!n&&a==="."){if(r){t.push(r);r=""}}else if(a==="["){if(r){t.push(r);r=""}n=true}else if(a==="]"&&n){t.push(r);r="";n=false;i=false}else if((a==='"'||a==="'")&&n){if(!i){i=true;o=a}else if(a===o){i=false;o=""}else{r+=a}}else{r+=a}}if(r){t.push(r)}return t}function Ra(e,t,r){let n=e;for(let o=0;o<t.length-1;o++){const s=t[o];if(typeof n!=="object"||n===null||!(s in n)){return false}if(typeof n[s]!=="object"||n[s]===null){return false}n=n[s]}const i=t[t.length-1];if(i==="*"){if(Array.isArray(n)){for(let o=0;o<n.length;o++){n[o]=r}}else if(typeof n==="object"&&n!==null){for(const o in n){if(Object.prototype.hasOwnProperty.call(n,o)){n[o]=r}}}}else{if(typeof n==="object"&&n!==null&&i in n&&Object.prototype.hasOwnProperty.call(n,i)){n[i]=r}}return true}function Ta(e,t){let r=e;for(let i=0;i<t.length-1;i++){const o=t[i];if(typeof r!=="object"||r===null||!(o in r)){return false}if(typeof r[o]!=="object"||r[o]===null){return false}r=r[o]}const 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(const i in r){if(Object.prototype.hasOwnProperty.call(r,i)){delete r[i]}}}}else{if(typeof r==="object"&&r!==null&&n in r&&Object.prototype.hasOwnProperty.call(r,n)){delete r[n]}}return true}var cr=Symbol("PATH_NOT_FOUND");function by(e,t){let r=e;for(const n of t){if(r===null||r===void 0){return cr}if(typeof r!=="object"||r===null){return cr}if(!(n in r)){return cr}r=r[n]}return r}function wy(e,t){let r=e;for(const n of t){if(r===null||r===void 0){return void 0}if(typeof r!=="object"||r===null){return void 0}r=r[n]}return r}function Sy(e,t,r,n=false){for(const i of t){const o=Aa(i);if(o.includes("*")){va(e,o,r,i,n)}else{if(n){Ta(e,o)}else{const s=by(e,o);if(s===cr){continue}const a=typeof r==="function"?r(s,o):r;Ra(e,o,a)}}}}function va(e,t,r,n,i=false){const o=t.indexOf("*");if(o===t.length-1){const s=t.slice(0,-1);let a=e;for(const l of s){if(a===null||a===void 0)return;if(typeof a!=="object"||a===null)return;a=a[l]}if(Array.isArray(a)){if(i){for(let l=0;l<a.length;l++){a[l]=void 0}}else{for(let l=0;l<a.length;l++){const u=[...s,l.toString()];const f=typeof r==="function"?r(a[l],u):r;a[l]=f}}}else if(typeof a==="object"&&a!==null){if(i){const l=[];for(const u in a){if(Object.prototype.hasOwnProperty.call(a,u)){l.push(u)}}for(const u of l){delete a[u]}}else{for(const l in a){const u=[...s,l];const f=typeof r==="function"?r(a[l],u):r;a[l]=f}}}}else{_y(e,t,r,o,n,i)}}function _y(e,t,r,n,i,o=false){const s=t.slice(0,n);const a=t.slice(n+1);const l=[];function u(f,c){if(c===s.length){if(Array.isArray(f)){for(let h=0;h<f.length;h++){l[c]=h.toString();u(f[h],c+1)}}else if(typeof f==="object"&&f!==null){for(const h in f){l[c]=h;u(f[h],c+1)}}}else if(c<s.length){const h=s[c];if(f&&typeof f==="object"&&f!==null&&h in f){l[c]=h;u(f[h],c+1)}}else{if(a.includes("*")){const h=typeof r==="function"?(p,d)=>{const g=[...l.slice(0,c),...d];return r(p,g)}:r;va(f,a,h,i,o)}else{if(o){Ta(f,a)}else{const h=typeof r==="function"?r(wy(f,a),[...l.slice(0,c),...a]):r;Ra(f,a,h)}}}}if(s.length===0){u(e,0)}else{let f=e;for(let c=0;c<s.length;c++){const h=s[c];if(f===null||f===void 0)return;if(typeof f!=="object"||f===null)return;f=f[h];l[c]=h}if(f!==null&&f!==void 0){u(f,s.length)}}}function Ey(e){if(e.length===0){return null}const t=new Map;for(const r of e){const n=Aa(r);let i=t;for(let o=0;o<n.length;o++){const s=n[o];if(!i.has(s)){i.set(s,new Map)}i=i.get(s)}}return t}function xy(e,t){if(!t){return e}function r(n,i,o=0){if(!i||i.size===0){return n}if(n===null||typeof n!=="object"){return n}if(n instanceof Date){return new Date(n.getTime())}if(Array.isArray(n)){const a=[];for(let l=0;l<n.length;l++){const u=l.toString();if(i.has(u)||i.has("*")){a[l]=r(n[l],i.get(u)||i.get("*"))}else{a[l]=n[l]}}return a}const s=Object.create(Object.getPrototypeOf(n));for(const a in n){if(Object.prototype.hasOwnProperty.call(n,a)){if(i.has(a)||i.has("*")){s[a]=r(n[a],i.get(a)||i.get("*"))}else{s[a]=n[a]}}}return s}return r(e,t)}function Ay(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;let r=false;let n="";for(let i=0;i<e.length;i++){const o=e[i];if((o==='"'||o==="'")&&t>0){if(!r){r=true;n=o}else if(o===n){r=false;n=""}}else if(o==="["&&!r){t++}else if(o==="]"&&!r){t--;if(t<0){throw new Error(`Invalid redaction path (${e})`)}}}if(t!==0){throw new Error(`Invalid redaction path (${e})`)}}function Ry(e){if(!Array.isArray(e)){throw new TypeError("paths must be an array")}for(const t of e){Ay(t)}}function Ty(e={}){const{paths:t=[],censor:r="[REDACTED]",serialize:n=JSON.stringify,strict:i=true,remove:o=false}=e;Ry(t);const s=Ey(t);return function a(l){if(i&&(l===null||typeof l!=="object")){if(l===null||l===void 0){return n?n(l):l}if(typeof l!=="object"){return n?n(l):l}}const u=xy(l,s);const f=l;let c=r;if(typeof r==="function"){c=r}Sy(u,t,c,o);if(n===false){u.restore=function(){return Un(f)};return u}if(typeof n==="function"){return n(u)}return JSON.stringify(u)}}Ma.exports=Ty});var Ze=E((tI,Oa)=>{"use strict";var vy=Symbol("pino.setLevel");var My=Symbol("pino.getLevel");var Cy=Symbol("pino.levelVal");var Oy=Symbol("pino.levelComp");var Iy=Symbol("pino.useLevelLabels");var Ly=Symbol("pino.useOnlyCustomLevels");var Py=Symbol("pino.mixin");var ky=Symbol("pino.lsCache");var Ny=Symbol("pino.chindings");var Dy=Symbol("pino.asJson");var jy=Symbol("pino.write");var By=Symbol("pino.redactFmt");var qy=Symbol("pino.time");var $y=Symbol("pino.timeSliceIndex");var Wy=Symbol("pino.stream");var Fy=Symbol("pino.stringify");var Uy=Symbol("pino.stringifySafe");var Hy=Symbol("pino.stringifiers");var Ky=Symbol("pino.end");var Vy=Symbol("pino.formatOpts");var zy=Symbol("pino.messageKey");var Gy=Symbol("pino.errorKey");var Yy=Symbol("pino.nestedKey");var Qy=Symbol("pino.nestedKeyStr");var Jy=Symbol("pino.mixinMergeStrategy");var Xy=Symbol("pino.msgPrefix");var Zy=Symbol("pino.wildcardFirst");var em=Symbol.for("pino.serializers");var tm=Symbol.for("pino.formatters");var rm=Symbol.for("pino.hooks");var nm=Symbol.for("pino.metadata");Oa.exports={setLevelSym:vy,getLevelSym:My,levelValSym:Cy,levelCompSym:Oy,useLevelLabelsSym:Iy,mixinSym:Py,lsCacheSym:ky,chindingsSym:Ny,asJsonSym:Dy,writeSym:jy,serializersSym:em,redactFmtSym:By,timeSym:qy,timeSliceIndexSym:$y,streamSym:Wy,stringifySym:Fy,stringifySafeSym:Uy,stringifiersSym:Hy,endSym:Ky,formatOptsSym:Vy,messageKeySym:zy,errorKeySym:Gy,nestedKeySym:Yy,wildcardFirstSym:Zy,needsMetadataGsym:nm,useOnlyCustomLevelsSym:Ly,formattersSym:tm,hooksSym:rm,nestedKeyStrSym:Qy,mixinMergeStrategySym:Jy,msgPrefixSym:Xy}});var Kn=E((rI,ka)=>{"use strict";var Ia=Ca();var{redactFmtSym:im,wildcardFirstSym:fr}=Ze();var Hn=/[^.[\]]+|\[([^[\]]*?)\]/g;var La="[Redacted]";var Pa=false;function om(e,t){const{paths:r,censor:n,remove:i}=sm(e);const o=r.reduce((l,u)=>{Hn.lastIndex=0;const f=Hn.exec(u);const c=Hn.exec(u);let h=f[1]!==void 0?f[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,"$1"):f[0];if(h==="*"){h=fr}if(c===null){l[h]=null;return l}if(l[h]===null){return l}const{index:p}=c;const d=`${u.substr(p,u.length-1)}`;l[h]=l[h]||[];if(h!==fr&&l[h].length===0){l[h].push(...l[fr]||[])}if(h===fr){Object.keys(l).forEach(function(g){if(l[g]){l[g].push(d)}})}l[h].push(d);return l},{});const s={[im]:Ia({paths:r,censor:n,serialize:t,strict:Pa,remove:i})};const a=(...l)=>{return typeof n==="function"?t(n(...l)):t(n)};return[...Object.keys(o),...Object.getOwnPropertySymbols(o)].reduce((l,u)=>{if(o[u]===null){l[u]=f=>a(f,[u])}else{const f=typeof n==="function"?(c,h)=>{return n(c,[u,...h])}:n;l[u]=Ia({paths:o[u],censor:f,serialize:t,strict:Pa,remove:i})}return l},s)}function sm(e){if(Array.isArray(e)){e={paths:e,censor:La};return e}let{paths:t,censor:r=La,remove:n}=e;if(Array.isArray(t)===false){throw Error("pino \u2013 redact must contain an array of strings")}if(n===true)r=void 0;return{paths:t,censor:r,remove:n}}ka.exports=om});var ja=E((nI,Da)=>{"use strict";var am=()=>"";var lm=()=>`,"time":${Date.now()}`;var um=()=>`,"time":${Math.round(Date.now()/1e3)}`;var cm=()=>`,"time":"${new Date(Date.now()).toISOString()}"`;var fm=1000000n;var Na=1000000000n;var dm=BigInt(Date.now())*fm;var pm=process.hrtime.bigint();var hm=()=>{const e=process.hrtime.bigint()-pm;const t=dm+e;const r=t/Na;const n=t%Na;const i=Number(r*1000n+n/1000000n);const o=new Date(i);const s=o.getUTCFullYear();const a=(o.getUTCMonth()+1).toString().padStart(2,"0");const l=o.getUTCDate().toString().padStart(2,"0");const u=o.getUTCHours().toString().padStart(2,"0");const f=o.getUTCMinutes().toString().padStart(2,"0");const c=o.getUTCSeconds().toString().padStart(2,"0");return`,"time":"${s}-${a}-${l}T${u}:${f}:${c}.${n.toString().padStart(9,"0")}Z"`};Da.exports={nullTime:am,epochTime:lm,unixTime:um,isoTime:cm,isoTimeNano:hm}});var qa=E((iI,Ba)=>{"use strict";function gm(e){try{return JSON.stringify(e)}catch(t){return'"[Circular]"'}}Ba.exports=ym;function ym(e,t,r){var n=r&&r.stringify||gm;var i=1;if(typeof e==="object"&&e!==null){var o=t.length+i;if(o===1)return e;var s=new Array(o);s[0]=n(e);for(var a=1;a<o;a++){s[a]=n(t[a])}return s.join(" ")}if(typeof e!=="string"){return e}var l=t.length;if(l===0)return e;var u="";var f=1-i;var c=-1;var h=e&&e.length||0;for(var p=0;p<h;){if(e.charCodeAt(p)===37&&p+1<h){c=c>-1?c:0;switch(e.charCodeAt(p+1)){case 100:case 102:if(f>=l)break;if(t[f]==null)break;if(c<p)u+=e.slice(c,p);u+=Number(t[f]);c=p+2;p++;break;case 105:if(f>=l)break;if(t[f]==null)break;if(c<p)u+=e.slice(c,p);u+=Math.floor(Number(t[f]));c=p+2;p++;break;case 79:case 111:case 106:if(f>=l)break;if(t[f]===void 0)break;if(c<p)u+=e.slice(c,p);var d=typeof t[f];if(d==="string"){u+="'"+t[f]+"'";c=p+2;p++;break}if(d==="function"){u+=t[f].name||"<anonymous>";c=p+2;p++;break}u+=n(t[f]);c=p+2;p++;break;case 115:if(f>=l)break;if(c<p)u+=e.slice(c,p);u+=String(t[f]);c=p+2;p++;break;case 37:if(c<p)u+=e.slice(c,p);u+="%";c=p+2;p++;f--;break}++f}++p}if(c===-1)return e;else if(c<h){u+=e.slice(c)}return u}});var zn=E((oI,Vn)=>{"use strict";if(typeof SharedArrayBuffer!=="undefined"&&typeof Atomics!=="undefined"){let t=function(r){const n=r>0&&r<Infinity;if(n===false){if(typeof r!=="number"&&typeof r!=="bigint"){throw TypeError("sleep: ms must be a number")}throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}Atomics.wait(e,0,0,Number(r))};const e=new Int32Array(new SharedArrayBuffer(4));Vn.exports=t}else{let e=function(t){const r=t>0&&t<Infinity;if(r===false){if(typeof t!=="number"&&typeof t!=="bigint"){throw TypeError("sleep: ms must be a number")}throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}const n=Date.now()+Number(t);while(n>Date.now()){}};Vn.exports=e}});var Qn=E((sI,Va)=>{"use strict";var q=I("fs");var mm=I("events");var bm=I("util").inherits;var $a=I("path");var Yn=zn();var wm=I("assert");var dr=100;var pr=Buffer.allocUnsafe(0);var Sm=16*1024;var Wa="buffer";var Fa="utf8";var[_m,Em]=(process.versions.node||"0.0").split(".").map(Number);var xm=_m>=22&&Em>=7;function Ua(e,t){t._opening=true;t._writing=true;t._asyncDrainScheduled=false;function r(o,s){if(o){t._reopening=false;t._writing=false;t._opening=false;if(t.sync){process.nextTick(()=>{if(t.listenerCount("error")>0){t.emit("error",o)}})}else{t.emit("error",o)}return}const a=t._reopening;t.fd=s;t.file=e;t._reopening=false;t._opening=false;t._writing=false;if(t.sync){process.nextTick(()=>t.emit("ready"))}else{t.emit("ready")}if(t.destroyed){return}if(!t._writing&&t._len>t.minLength||t._flushPending){t._actualWrite()}else if(a){process.nextTick(()=>t.emit("drain"))}}const n=t.append?"a":"w";const i=t.mode;if(t.sync){try{if(t.mkdir)q.mkdirSync($a.dirname(e),{recursive:true});const o=q.openSync(e,n,i);r(null,o)}catch(o){r(o);throw o}}else if(t.mkdir){q.mkdir($a.dirname(e),{recursive:true},o=>{if(o)return r(o);q.open(e,n,i,r)})}else{q.open(e,n,i,r)}}function re(e){if(!(this instanceof re)){return new re(e)}let{fd:t,dest:r,minLength:n,maxLength:i,maxWrite:o,periodicFlush:s,sync:a,append:l=true,mkdir:u,retryEAGAIN:f,fsync:c,contentMode:h,mode:p}=e||{};t=t||r;this._len=0;this.fd=-1;this._bufs=[];this._lens=[];this._writing=false;this._ending=false;this._reopening=false;this._asyncDrainScheduled=false;this._flushPending=false;this._hwm=Math.max(n||0,16387);this.file=null;this.destroyed=false;this.minLength=n||0;this.maxLength=i||0;this.maxWrite=o||Sm;this._periodicFlush=s||0;this._periodicFlushTimer=void 0;this.sync=a||false;this.writable=true;this._fsync=c||false;this.append=l||false;this.mode=p;this.retryEAGAIN=f||(()=>true);this.mkdir=u||false;let d;let g;if(h===Wa){this._writingBuf=pr;this.write=Tm;this.flush=Mm;this.flushSync=Om;this._actualWrite=Lm;d=()=>q.writeSync(this.fd,this._writingBuf);g=()=>q.write(this.fd,this._writingBuf,this.release)}else if(h===void 0||h===Fa){this._writingBuf="";this.write=Rm;this.flush=vm;this.flushSync=Cm;this._actualWrite=Im;d=()=>{if(Buffer.isBuffer(this._writingBuf)){return q.writeSync(this.fd,this._writingBuf)}return q.writeSync(this.fd,this._writingBuf,"utf8")};g=()=>{if(Buffer.isBuffer(this._writingBuf)){return q.write(this.fd,this._writingBuf,this.release)}return q.write(this.fd,this._writingBuf,"utf8",this.release)}}else{throw new Error(`SonicBoom supports "${Fa}" and "${Wa}", but passed ${h}`)}if(typeof t==="number"){this.fd=t;process.nextTick(()=>this.emit("ready"))}else if(typeof t==="string"){Ua(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=(y,m)=>{if(y){if((y.code==="EAGAIN"||y.code==="EBUSY")&&this.retryEAGAIN(y,this._writingBuf.length,this._len-this._writingBuf.length)){if(this.sync){try{Yn(dr);this.release(void 0,0)}catch(S){this.release(S)}}else{setTimeout(g,dr)}}else{this._writing=false;this.emit("error",y)}return}this.emit("write",m);const w=Gn(this._writingBuf,this._len,m);this._len=w.len;this._writingBuf=w.writingBuf;if(this._writingBuf.length){if(!this.sync){g();return}try{do{const S=d();const A=Gn(this._writingBuf,this._len,S);this._len=A.len;this._writingBuf=A.writingBuf}while(this._writingBuf.length)}catch(S){this.release(S);return}}if(this._fsync){q.fsyncSync(this.fd)}const _=this._len;if(this._reopening){this._writing=false;this._reopening=false;this.reopen()}else if(_>this.minLength){this._actualWrite()}else if(this._ending){if(_>0){this._actualWrite()}else{this._writing=false;hr(this)}}else{this._writing=false;if(this.sync){if(!this._asyncDrainScheduled){this._asyncDrainScheduled=true;process.nextTick(Am,this)}}else{this.emit("drain")}}};this.on("newListener",function(y){if(y==="drain"){this._asyncDrainScheduled=false}});if(this._periodicFlush!==0){this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush);this._periodicFlushTimer.unref()}}function Gn(e,t,r){if(typeof e==="string"){e=Buffer.from(e)}t=Math.max(t-r,0);e=e.subarray(r);return{writingBuf:e,len:t}}function Am(e){const t=e.listenerCount("drain")>0;if(!t)return;e._asyncDrainScheduled=false;e.emit("drain")}bm(re,mm);function Ha(e,t){if(e.length===0){return pr}if(e.length===1){return e[0]}return Buffer.concat(e,t)}function Rm(e){if(this.destroyed){throw new Error("SonicBoom destroyed")}e=""+e;const t=Buffer.byteLength(e);const r=this._len+t;const n=this._bufs;if(this.maxLength&&r>this.maxLength){this.emit("drop",e);return this._len<this._hwm}if(n.length===0||Buffer.byteLength(n[n.length-1])+t>this.maxWrite){n.push(e)}else{n[n.length-1]+=e}this._len=r;if(!this._writing&&this._len>=this.minLength){this._actualWrite()}return this._len<this._hwm}function Tm(e){if(this.destroyed){throw new Error("SonicBoom destroyed")}const t=this._len+e.length;const r=this._bufs;const n=this._lens;if(this.maxLength&&t>this.maxLength){this.emit("drop",e);return this._len<this._hwm}if(r.length===0||n[n.length-1]+e.length>this.maxWrite){r.push([e]);n.push(e.length)}else{r[r.length-1].push(e);n[n.length-1]+=e.length}this._len=t;if(!this._writing&&this._len>=this.minLength){this._actualWrite()}return this._len<this._hwm}function Ka(e){this._flushPending=true;const t=()=>{if(!this._fsync){try{q.fsync(this.fd,n=>{this._flushPending=false;e(n)})}catch(n){e(n)}}else{this._flushPending=false;e()}this.off("error",r)};const r=n=>{this._flushPending=false;e(n);this.off("drain",t)};this.once("drain",t);this.once("error",r)}function vm(e){if(e!=null&&typeof e!=="function"){throw new Error("flush cb must be a function")}if(this.destroyed){const t=new Error("SonicBoom destroyed");if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}if(e){Ka.call(this,e)}if(this._writing){return}if(this._bufs.length===0){this._bufs.push("")}this._actualWrite()}function Mm(e){if(e!=null&&typeof e!=="function"){throw new Error("flush cb must be a function")}if(this.destroyed){const t=new Error("SonicBoom destroyed");if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}if(e){Ka.call(this,e)}if(this._writing){return}if(this._bufs.length===0){this._bufs.push([]);this._lens.push(0)}this._actualWrite()}re.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=true;if(this._writing){return}const t=this.fd;this.once("ready",()=>{if(t!==this.fd){q.close(t,r=>{if(r){return this.emit("error",r)}})}});Ua(this.file,this)};re.prototype.end=function(){if(this.destroyed){throw new Error("SonicBoom destroyed")}if(this._opening){this.once("ready",()=>{this.end()});return}if(this._ending){return}this._ending=true;if(this._writing){return}if(this._len>0&&this.fd>=0){this._actualWrite()}else{hr(this)}};function Cm(){if(this.destroyed){throw new Error("SonicBoom destroyed")}if(this.fd<0){throw new Error("sonic boom is not ready yet")}if(!this._writing&&this._writingBuf.length>0){this._bufs.unshift(this._writingBuf);this._writingBuf=""}let e="";while(this._bufs.length||e.length){if(e.length<=0){e=this._bufs[0]}try{const t=Buffer.isBuffer(e)?q.writeSync(this.fd,e):q.writeSync(this.fd,e,"utf8");const r=Gn(e,this._len,t);e=r.writingBuf;this._len=r.len;if(e.length<=0){this._bufs.shift()}}catch(t){const r=t.code==="EAGAIN"||t.code==="EBUSY";if(r&&!this.retryEAGAIN(t,e.length,this._len-e.length)){throw t}Yn(dr)}}try{q.fsyncSync(this.fd)}catch{}}function Om(){if(this.destroyed){throw new Error("SonicBoom destroyed")}if(this.fd<0){throw new Error("sonic boom is not ready yet")}if(!this._writing&&this._writingBuf.length>0){this._bufs.unshift([this._writingBuf]);this._writingBuf=pr}let e=pr;while(this._bufs.length||e.length){if(e.length<=0){e=Ha(this._bufs[0],this._lens[0])}try{const t=q.writeSync(this.fd,e);e=e.subarray(t);this._len=Math.max(this._len-t,0);if(e.length<=0){this._bufs.shift();this._lens.shift()}}catch(t){const r=t.code==="EAGAIN"||t.code==="EBUSY";if(r&&!this.retryEAGAIN(t,e.length,this._len-e.length)){throw t}Yn(dr)}}}re.prototype.destroy=function(){if(this.destroyed){return}hr(this)};function Im(){const e=this.release;this._writing=true;this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||"";if(this.sync){try{const t=Buffer.isBuffer(this._writingBuf)?q.writeSync(this.fd,this._writingBuf):q.writeSync(this.fd,this._writingBuf,"utf8");e(null,t)}catch(t){e(t)}}else{q.write(this.fd,this._writingBuf,e)}}function Lm(){const e=this.release;this._writing=true;this._writingBuf=this._writingBuf.length?this._writingBuf:Ha(this._bufs.shift(),this._lens.shift());if(this.sync){try{const t=q.writeSync(this.fd,this._writingBuf);e(null,t)}catch(t){e(t)}}else{if(xm){this._writingBuf=Buffer.from(this._writingBuf)}q.write(this.fd,this._writingBuf,e)}}function hr(e){if(e.fd===-1){e.once("ready",hr.bind(null,e));return}if(e._periodicFlushTimer!==void 0){clearInterval(e._periodicFlushTimer)}e.destroyed=true;e._bufs=[];e._lens=[];wm(typeof e.fd==="number",`sonic.fd must be a number, got ${typeof e.fd}`);try{q.fsync(e.fd,t)}catch{}function t(){if(e.fd!==1&&e.fd!==2){q.close(e.fd,r)}else{r()}}function r(n){if(n){e.emit("error",n);return}if(e._ending&&!e._writing){e.emit("finish")}e.emit("close")}}re.SonicBoom=re;re.default=re;Va.exports=re});var gr=E((aI,Ja)=>{"use strict";var ne={exit:[],beforeExit:[]};var za={exit:Nm,beforeExit:Dm};var et;function Pm(){if(et===void 0){et=new FinalizationRegistry(jm)}}function km(e){if(ne[e].length>0){return}process.on(e,za[e])}function Ga(e){if(ne[e].length>0){return}process.removeListener(e,za[e]);if(ne.exit.length===0&&ne.beforeExit.length===0){et=void 0}}function Nm(){Ya("exit")}function Dm(){Ya("beforeExit")}function Ya(e){for(const t of ne[e]){const r=t.deref();const n=t.fn;if(r!==void 0){n(r,e)}}ne[e]=[]}function jm(e){for(const t of["exit","beforeExit"]){const r=ne[t].indexOf(e);ne[t].splice(r,r+1);Ga(t)}}function Qa(e,t,r){if(t===void 0){throw new Error("the object can't be undefined")}km(e);const n=new WeakRef(t);n.fn=r;Pm();et.register(t,n);ne[e].push(n)}function Bm(e,t){Qa("exit",e,t)}function qm(e,t){Qa("beforeExit",e,t)}function $m(e){if(et===void 0){return}et.unregister(e);for(const t of["exit","beforeExit"]){ne[t]=ne[t].filter(r=>{const n=r.deref();return n&&n!==e});Ga(t)}}Ja.exports={register:Bm,registerBeforeExit:qm,unregister:$m}});var Xa=E((lI,Wm)=>{Wm.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 el=E((uI,Za)=>{"use strict";var yr=1e4;function Fm(e,t,r,n,i){const o=n===Infinity?Infinity:Date.now()+n;const s=()=>{const a=Atomics.load(e,t);if(a===r){i(null,"ok");return}if(o!==Infinity&&Date.now()>o){i(null,"timed-out");return}const l=o===Infinity?yr:Math.min(yr,Math.max(1,o-Date.now()));const u=Atomics.waitAsync(e,t,a,l);if(u.async){u.value.then(s)}else{setImmediate(s)}};s()}function Um(e,t,r,n,i){const o=n===Infinity?Infinity:Date.now()+n;const s=()=>{const a=Atomics.load(e,t);if(a!==r){i(null,"ok");return}if(o!==Infinity&&Date.now()>o){i(null,"timed-out");return}const l=o===Infinity?yr:Math.min(yr,Math.max(1,o-Date.now()));const u=Atomics.waitAsync(e,t,r,l);if(u.async){u.value.then(f=>{if(f==="ok"){i(null,"ok");return}s()})}else{setImmediate(s)}};s()}Za.exports={wait:Fm,waitDiff:Um}});var rl=E((cI,tl)=>{"use strict";var Hm=2;var Km=4;var Vm=8;tl.exports={WRITE_INDEX:Km,READ_INDEX:Vm,SEQ_INDEX:Hm}});var hl=E((fI,pl)=>{"use strict";var{version:zm}=Xa();var{EventEmitter:Gm}=I("events");var{Worker:Ym}=I("worker_threads");var{join:Qm}=I("path");var{pathToFileURL:Jm}=I("url");var{wait:Xm}=el();var{WRITE_INDEX:he,READ_INDEX:Le,SEQ_INDEX:Jn}=rl();var Zm=I("buffer");var eb=I("assert");var b=Symbol("kImpl");var tb=Zm.constants.MAX_STRING_LENGTH;function nl(){}function ti(e,t){Atomics.add(e[b].state,Jn,1);t();Atomics.add(e[b].state,Jn,1);Atomics.notify(e[b].state,Jn)}function il(e){ti(e,()=>{Atomics.store(e[b].state,Le,0);Atomics.store(e[b].state,he,0)})}var Tt=class{constructor(t){this._value=t}deref(){return this._value}};var mr=class{register(){}unregister(){}};var rb=process.env.NODE_V8_COVERAGE?mr:global.FinalizationRegistry||mr;var nb=process.env.NODE_V8_COVERAGE?Tt:global.WeakRef||Tt;var ol=new rb(e=>{if(e.exited){return}e.terminate()});function ib(e,t){const{filename:r,workerData:n}=t;const i="__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{};const o=i["thread-stream-worker"]||Qm(__dirname,"lib","worker.js");const s=new Ym(o,{...t.workerOpts,name:t.workerOpts?.name||"thread-stream",trackUnmanagedFds:false,workerData:{filename:r.indexOf("file://")===0?r:Jm(r).href,dataBuf:e[b].dataBuf,stateBuf:e[b].stateBuf,workerData:{$context:{threadStreamVersion:zm},...n}}});s.stream=new Tt(e);s.on("message",ob);s.on("exit",ll);ol.register(e,s);return s}function sl(e){eb(!e[b].sync);if(e[b].needDrain){e[b].needDrain=false;e.emit("drain")}}function al(e){while(true){const t=Atomics.load(e[b].state,he);const r=e[b].data.length-t;if(r>0){if(e[b].bufLen===0){e[b].flushing=false;if(e[b].ending){ri(e)}else if(e[b].needDrain){process.nextTick(sl,e)}return}fl(e,r,nl);continue}if(r===0){if(t===0&&e[b].bufLen===0){return}br(e,()=>{if(e.destroyed){return}il(e);al(e)});return}X(e,new Error("overwritten"));return}}function ob(e){const t=this.stream.deref();if(t===void 0){this.exited=true;this.terminate();return}if(e?.code==null){return}switch(e.code){case"READY":this.stream=new nb(t);br(t,()=>{t[b].ready=true;t.emit("ready")});break;case"ERROR":X(t,e.err);break;case"EVENT":if(Array.isArray(e.args)){t.emit(e.name,...e.args)}else{t.emit(e.name,e.args)}break;case"FLUSHED":{if(e.context!=="thread-stream"){X(t,new Error("this should not happen: "+e.code));break}const r=t[b].flushCallbacks.get(e.id);if(r){t[b].flushCallbacks.delete(e.id);process.nextTick(r)}break}case"WARNING":process.emitWarning(e.err);break;default:X(t,new Error("this should not happen: "+e.code))}}function ll(e){const t=this.stream.deref();if(t===void 0){return}ol.unregister(t);t.worker.exited=true;t.worker.off("exit",ll);X(t,e!==0?new Error("the worker thread exited"):null)}var Zn=class extends Gm{constructor(t={}){super();if(t.bufferSize<4){throw new Error("bufferSize must at least fit a 4-byte utf-8 char")}this[b]={};this[b].stateBuf=new SharedArrayBuffer(128);this[b].state=new Int32Array(this[b].stateBuf);this[b].dataBuf=new SharedArrayBuffer(t.bufferSize||4*1024*1024);this[b].data=Buffer.from(this[b].dataBuf);this[b].sync=t.sync||false;this[b].ending=false;this[b].ended=false;this[b].needDrain=false;this[b].destroyed=false;this[b].flushing=false;this[b].ready=false;this[b].finished=false;this[b].errored=null;this[b].closed=false;this[b].buf=[];this[b].bufHead=0;this[b].bufLen=0;this[b].flushCallbacks=new Map;this[b].nextFlushId=0;this.worker=ib(this,t);this.on("message",(r,n)=>{this.worker.postMessage(r,n)})}write(t){const r=Buffer.isBuffer(t)?t:Buffer.from(t);if(this[b].destroyed){ei(this,new Error("the worker has exited"));return false}if(this[b].ending){ei(this,new Error("the worker is ending"));return false}if(this[b].flushing&&this[b].bufLen+r.length>=tb){try{Xn(this);this[b].flushing=true}catch(n){X(this,n);return false}}this[b].buf.push(r);this[b].bufLen+=r.length;if(this[b].sync){try{Xn(this);return true}catch(n){X(this,n);return false}}if(!this[b].flushing){this[b].flushing=true;setImmediate(al,this)}this[b].needDrain=this[b].data.length-this[b].bufLen-Atomics.load(this[b].state,he)<=0;return!this[b].needDrain}end(){if(this[b].destroyed){return}this[b].ending=true;ri(this)}flush(t){t=typeof t==="function"?t:nl;ul(this,r=>{if(r){process.nextTick(t,r);return}cl(this,t)})}flushSync(){if(this[b].destroyed){return}Xn(this);dl(this)}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[b].ready}get destroyed(){return this[b].destroyed}get closed(){return this[b].closed}get writable(){return!this[b].destroyed&&!this[b].ending}get writableEnded(){return this[b].ending}get writableFinished(){return this[b].finished}get writableNeedDrain(){return this[b].needDrain}get writableObjectMode(){return false}get writableErrored(){return this[b].errored}};function ul(e,t){if(e[b].destroyed){process.nextTick(t,new Error("the worker has exited"));return}if(!e[b].sync&&(e[b].flushing||e[b].bufLen>0)){setImmediate(ul,e,t);return}br(e,t)}function br(e,t){const r=Atomics.load(e[b].state,he);Xm(e[b].state,Le,r,Infinity,(n,i)=>{if(n){X(e,n);t(n);return}if(i!=="ok"){br(e,t);return}t()})}function cl(e,t){if(e[b].destroyed){process.nextTick(t,new Error("the worker has exited"));return}if(!e[b].ready){const n=()=>{o();cl(e,t)};const i=()=>{o();process.nextTick(t,new Error("the worker has exited"))};const o=()=>{e.off("ready",n);e.off("close",i)};e.once("ready",n);e.once("close",i);return}const r=++e[b].nextFlushId;e[b].flushCallbacks.set(r,t);try{e.worker.postMessage({code:"FLUSH",context:"thread-stream",id:r})}catch(n){e[b].flushCallbacks.delete(r);X(e,n);process.nextTick(t,n)}}function sb(e,t){const r=e[b].flushCallbacks;if(r.size===0){return}const n=t||new Error("the worker has exited");for(const i of r.values()){process.nextTick(i,n)}r.clear()}function ei(e,t){setImmediate(()=>{e.emit("error",t)})}function X(e,t){if(e[b].destroyed){return}e[b].destroyed=true;sb(e,t);if(t){e[b].errored=t;ei(e,t)}if(!e.worker.exited){e.worker.terminate().catch(()=>{}).then(()=>{e[b].closed=true;e.emit("close")})}else{setImmediate(()=>{e[b].closed=true;e.emit("close")})}}function fl(e,t,r){const n=Atomics.load(e[b].state,he);let i=n;let o=t;while(o>0&&e[b].bufLen!==0){const s=e[b].bufHead;const a=e[b].buf[s];if(a.length<=o){a.copy(e[b].data,i);i+=a.length;o-=a.length;e[b].bufLen-=a.length;e[b].bufHead=s+1;if(e[b].bufHead===e[b].buf.length){e[b].buf.length=0;e[b].bufHead=0}else if(e[b].bufHead>=1024&&e[b].bufHead*2>=e[b].buf.length){e[b].buf.splice(0,e[b].bufHead);e[b].bufHead=0}continue}a.copy(e[b].data,i,0,o);e[b].buf[s]=a.subarray(o);e[b].bufLen-=o;i+=o;o=0}ti(e,()=>{Atomics.store(e[b].state,he,i)});r();return true}function ri(e){if(e[b].ended||!e[b].ending||e[b].flushing){return}e[b].ended=true;try{e.flushSync();let t=Atomics.load(e[b].state,Le);ti(e,()=>{Atomics.store(e[b].state,he,-1)});let r=0;while(t!==-1){Atomics.wait(e[b].state,Le,t,1e3);t=Atomics.load(e[b].state,Le);if(t===-2){X(e,new Error("end() failed"));return}if(++r===10){X(e,new Error("end() took too long (10s)"));return}}process.nextTick(()=>{e[b].finished=true;e.emit("finish")})}catch(t){X(e,t)}}function Xn(e){const t=()=>{if(e[b].ending){ri(e)}else if(e[b].needDrain){process.nextTick(sl,e)}};e[b].flushing=false;while(e[b].bufLen!==0){const r=Atomics.load(e[b].state,he);const n=e[b].data.length-r;if(n===0){dl(e);il(e);continue}else if(n<0){throw new Error("overwritten")}fl(e,n,t)}}function dl(e){if(e[b].flushing){throw new Error("unable to flush while flushing")}const t=Atomics.load(e[b].state,he);let r=0;while(true){const n=Atomics.load(e[b].state,Le);if(n===-2){throw Error("_flushSync failed")}if(n!==t){Atomics.wait(e[b].state,Le,n,1e3)}else{break}if(++r===10){throw new Error("_flushSync took too long (10s)")}}}pl.exports=Zn});var oi=E((dI,ml)=>{"use strict";var{createRequire:ab}=I("module");var{existsSync:lb}=I("node:fs");var ub=Fn();var{join:ni,isAbsolute:yl,sep:cb}=I("node:path");var{fileURLToPath:fb}=I("node:url");var db=zn();var ii=gr();var pb=hl();function hb(e){ii.register(e,wb);ii.registerBeforeExit(e,Sb);e.on("close",function(){ii.unregister(e)})}function gb(){const e=process.execArgv;for(let t=0;t<e.length;t++){const r=e[t];if(r==="--import"||r==="--require"||r==="-r"){return true}if(r.startsWith("--import=")||r.startsWith("--require=")||r.startsWith("-r=")){return true}}return false}function yb(e){const t=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!t){return e}const r=[];let n=false;for(let i=0;i<t.length;i++){const o=t[i];if(o==="--require"||o==="-r"||o==="--import"){const s=t[i+1];if(s&&gl(s)){n=true;i++;continue}r.push(o);if(s){r.push(s);i++}continue}if(o.startsWith("--require=")||o.startsWith("-r=")||o.startsWith("--import=")){const s=o.slice(o.indexOf("=")+1);if(gl(s)){n=true;continue}}r.push(o)}return n?r.join(" "):e}function gl(e){const t=mb(e);if(!t){return false}let r=t;if(r.startsWith("file://")){try{r=fb(r)}catch{return false}}return yl(r)&&!lb(r)}function mb(e){const t=e[0];const r=e[e.length-1];if(t==='"'&&r==='"'||t==="'"&&r==="'"){return e.slice(1,-1)}return e}function bb(e,t,r,n,i){if(!r.execArgv&&gb()&&I.main===void 0){r={...r,execArgv:[]}}if(!r.env&&process.env.NODE_OPTIONS){const l=yb(process.env.NODE_OPTIONS);if(l!==process.env.NODE_OPTIONS){r={...r,env:{...process.env,NODE_OPTIONS:l}}}}r={...r,name:i};const o=new pb({filename:e,workerData:t,workerOpts:r,sync:n});o.on("ready",s);o.on("close",function(){process.removeListener("exit",a)});process.on("exit",a);function s(){process.removeListener("exit",a);o.unref();if(r.autoEnd!==false){hb(o)}}function a(){if(o.closed){return}o.flushSync();db(100);o.end()}return o}function wb(e){e.ref();e.flushSync();e.end();e.once("close",function(){e.unref()})}function Sb(e){e.flushSync()}function _b(e){const{pipeline:t,targets:r,levels:n,dedupe:i,worker:o={},caller:s=ub(),sync:a=false}=e;const l={...e.options};const u=typeof s==="string"?[s]:s;const f=typeof globalThis==="object"&&Object.prototype.hasOwnProperty.call(globalThis,"__bundlerPathsOverrides")&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides==="object"?globalThis.__bundlerPathsOverrides:Object.create(null);let c=e.target;if(c&&r){throw new Error("only one of target or targets can be specified")}if(r){c=f["pino-worker"]||ni(__dirname,"worker.js");l.targets=r.filter(d=>d.target).map(d=>{return{...d,target:p(d.target)}});l.pipelines=r.filter(d=>d.pipeline).map(d=>{return d.pipeline.map(g=>{return{...g,level:d.level,target:p(g.target)}})})}else if(t){c=f["pino-worker"]||ni(__dirname,"worker.js");l.pipelines=[t.map(d=>{return{...d,target:p(d.target)}})]}if(n){l.levels=n}if(i){l.dedupe=i}l.pinoWillSendConfig=true;const h=r||t?"pino.transport":c;return bb(p(c),l,o,a,h);function p(d){d=f[d]||d;if(yl(d)||d.indexOf("file://")===0){return d}if(d==="pino/file"){return ni(__dirname,"..","file.js")}let g;for(const y of u){try{const m=y==="node:repl"?process.cwd()+cb:y;g=ab(m).resolve(d);break}catch(m){continue}}if(!g){throw new Error(`unable to determine transport target for "${d}"`)}return g}}ml.exports=_b});var _r=E((hI,Ol)=>{"use strict";var Eb=I("node:diagnostics_channel");var bl=qa();var{mapHttpRequest:xb,mapHttpResponse:Ab}=Wn();var ai=Qn();var wl=gr();var{lsCacheSym:Rb,chindingsSym:Al,writeSym:Sl,serializersSym:Rl,formatOptsSym:_l,endSym:Tb,stringifiersSym:Tl,stringifySym:vl,stringifySafeSym:li,wildcardFirstSym:Ml,nestedKeySym:vb,formattersSym:Cl,messageKeySym:Mb,errorKeySym:Cb,nestedKeyStrSym:Ob,msgPrefixSym:wr}=Ze();var{isMainThread:Ib}=I("worker_threads");var Lb=oi();var[Pb]=process.versions.node.split(".").map(e=>Number(e));var El=Eb.tracingChannel("pino_asJson");var si=Pb>=25?e=>JSON.stringify(e):Nb;function tt(){}function kb(e,t){if(!t)return r;return function n(...i){t.call(this,i,r,e)};function r(n,...i){if(typeof n==="object"){let o=n;if(n!==null){if(n.method&&n.headers&&n.socket){n=xb(n)}else if(typeof n.setHeader==="function"){n=Ab(n)}}let s;if(o===null&&i.length===0){s=[null]}else{o=i.shift();s=i}if(typeof this[wr]==="string"&&o!==void 0&&o!==null){o=this[wr]+o}this[Sl](n,bl(o,s,this[_l]),e)}else{let o=n===void 0?i.shift():n;if(typeof this[wr]==="string"&&o!==void 0&&o!==null){o=this[wr]+o}this[Sl](null,bl(o,i,this[_l]),e)}}}function Nb(e){let t="";let r=0;let n=false;let i=255;const o=e.length;if(o>100){return JSON.stringify(e)}for(var s=0;s<o&&i>=32;s++){i=e.charCodeAt(s);if(i===34||i===92){t+=e.slice(r,s)+"\\";r=s;n=true}}if(!n){t=e}else{t+=e.slice(r)}return i<32?JSON.stringify(e):'"'+t+'"'}function Db(e,t,r,n){if(El.hasSubscribers===false){return xl.call(this,e,t,r,n)}const i={instance:this,arguments};return El.traceSync(xl,i,this,e,t,r,n)}function xl(e,t,r,n){const i=this[vl];const o=this[li];const s=this[Tl];const a=this[Tb];const l=this[Al];const u=this[Rl];const f=this[Cl];const c=this[Mb];const h=this[Cb];let p=this[Rb][r]+n;p=p+l;let d;if(f.log){e=f.log(e)}const g=s[Ml];let y="";for(const w in e){d=e[w];if(Object.prototype.hasOwnProperty.call(e,w)&&d!==void 0){if(u[w]){d=u[w](d)}else if(w===h&&u.err){d=u.err(d)}const _=s[w]||g;switch(typeof d){case"undefined":case"function":continue;case"number":if(Number.isFinite(d)===false){d=null}case"boolean":if(_)d=_(d);break;case"string":d=(_||si)(d);break;default:d=(_||i)(d,o)}if(d===void 0)continue;const S=si(w);y+=","+S+":"+d}}let m="";if(t!==void 0){d=u[c]?u[c](t):t;const w=s[c]||g;switch(typeof d){case"function":break;case"number":if(Number.isFinite(d)===false){d=null}case"boolean":if(w)d=w(d);m=',"'+c+'":'+d;break;case"string":d=(w||si)(d);m=',"'+c+'":'+d;break;default:d=(w||i)(d,o);m=',"'+c+'":'+d}}if(this[vb]&&y){return p+this[Ob]+y.slice(1)+"}"+m+a}else{return p+y+m+a}}function jb(e,t){let r;let n=e[Al];const i=e[vl];const o=e[li];const s=e[Tl];const a=s[Ml];const l=e[Rl];const u=e[Cl].bindings;t=u(t);for(const f in t){r=t[f];const c=(f.length<5||f!=="level"&&f!=="serializers"&&f!=="formatters"&&f!=="customLevels")&&t.hasOwnProperty(f)&&r!==void 0;if(c===true){r=l[f]?l[f](r):r;r=(s[f]||a||i)(r,o);if(r===void 0)continue;n+=',"'+f+'":'+r}}return n}function Bb(e){return e.write!==e.constructor.prototype.write}function Sr(e){const t=new ai(e);t.on("error",r);if(!e.sync&&Ib){wl.register(t,qb);t.on("close",function(){wl.unregister(t)})}return t;function r(n){if(n.code==="EPIPE"){t.write=tt;t.end=tt;t.flushSync=tt;t.destroy=tt;return}t.removeListener("error",r);t.emit("error",n)}}function qb(e,t){if(e.destroyed){return}if(t==="beforeExit"){e.flush();e.on("drain",function(){e.end()})}else{e.flushSync()}}function $b(e){return function t(r,n,i={},o){if(typeof i==="string"){o=Sr({dest:i});i={}}else if(typeof o==="string"){if(i&&i.transport){throw Error("only one of option.transport or stream can be specified")}o=Sr({dest:o})}else if(i instanceof ai||i.writable||i._writableState){o=i;i={}}else if(i.transport){if(i.transport instanceof ai||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;if(i.customLevels){l=i.useOnlyCustomLevels?i.customLevels:Object.assign({},i.levels,i.customLevels)}o=Lb({caller:n,...i.transport,levels:l})}i=Object.assign({},e,i);i.serializers=Object.assign({},e.serializers,i.serializers);i.formatters=Object.assign({},e.formatters,i.formatters);if(i.prettyPrint){throw new Error("prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)")}const{enabled:s,onChild:a}=i;if(s===false)i.level="silent";if(!a)i.onChild=tt;if(!o){if(!Bb(process.stdout)){o=Sr({fd:process.stdout.fd||1})}else{o=process.stdout}}return{opts:i,stream:o}}}function Wb(e,t){try{return JSON.stringify(e)}catch(r){try{const n=t||this[li];return n(e)}catch(n){return'"[unable to serialize, circular reference is too complex to analyze]"'}}}function Fb(e,t,r){return{level:e,bindings:t,log:r}}function Ub(e){const t=Number(e);if(typeof e==="string"&&Number.isFinite(t)){return t}if(e===void 0){return 1}return e}Ol.exports={noop:tt,buildSafeSonicBoom:Sr,asChindings:jb,asJson:Db,genLog:kb,createArgsNormalizer:$b,stringify:Wb,buildFormatters:Fb,normalizeDestFileDescriptor:Ub}});var Er=E((gI,Il)=>{var Hb={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var Kb={ASC:"ASC",DESC:"DESC"};Il.exports={DEFAULT_LEVELS:Hb,SORTING_ORDER:Kb}});var fi=E((yI,Nl)=>{"use strict";var{lsCacheSym:Vb,levelValSym:ui,useOnlyCustomLevelsSym:zb,streamSym:Gb,formattersSym:Yb,hooksSym:Qb,levelCompSym:Ll}=Ze();var{noop:Jb,genLog:Pe}=_r();var{DEFAULT_LEVELS:ae,SORTING_ORDER:Pl}=Er();var kl={fatal:e=>{const t=Pe(ae.fatal,e);return function(...r){const n=this[Gb];t.call(this,...r);if(typeof n.flushSync==="function"){try{n.flushSync()}catch(i){}}}},error:e=>Pe(ae.error,e),warn:e=>Pe(ae.warn,e),info:e=>Pe(ae.info,e),debug:e=>Pe(ae.debug,e),trace:e=>Pe(ae.trace,e)};var ci=Object.keys(ae).reduce((e,t)=>{e[ae[t]]=t;return e},{});var Xb=Object.keys(ci).reduce((e,t)=>{e[t]='{"level":'+Number(t);return e},{});function Zb(e){const t=e[Yb].level;const{labels:r}=e.levels;const n={};for(const i in r){const o=t(r[i],Number(i));n[i]=JSON.stringify(o).slice(0,-1)}e[Vb]=n;return e}function ew(e,t){if(t){return false}switch(e){case"fatal":case"error":case"warn":case"info":case"debug":case"trace":return true;default:return false}}function tw(e){const{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);const n=this[ui];const i=this[ui]=r[e];const o=this[zb];const s=this[Ll];const a=this[Qb].logMethod;for(const l in r){if(s(r[l],i)===false){this[l]=Jb;continue}this[l]=ew(l,o)?kl[l](a):Pe(r[l],a)}this.emit("level-change",e,i,t[n],n,this)}function rw(e){const{levels:t,levelVal:r}=this;return t&&t.labels?t.labels[r]:""}function nw(e){const{values:t}=this.levels;const r=t[e];return r!==void 0&&this[Ll](r,this[ui])}function iw(e,t,r){if(e===Pl.DESC){return t<=r}return t>=r}function ow(e){if(typeof e==="string"){return iw.bind(null,e)}return e}function sw(e=null,t=false){const r=e?Object.keys(e).reduce((o,s)=>{o[e[s]]=s;return o},{}):null;const n=Object.assign(Object.create(Object.prototype,{Infinity:{value:"silent"}}),t?null:ci,r);const i=Object.assign(Object.create(Object.prototype,{silent:{value:Infinity}}),t?null:ae,e);return{labels:n,values:i}}function aw(e,t,r){if(typeof e==="number"){const i=[].concat(Object.keys(t||{}).map(o=>t[o]),r?[]:Object.keys(ci).map(o=>+o),Infinity);if(!i.includes(e)){throw Error(`default level:${e} must be included in custom levels`)}return}const n=Object.assign(Object.create(Object.prototype,{silent:{value:Infinity}}),r?null:ae,t);if(!(e in n)){throw Error(`default level:${e} must be included in custom levels`)}}function lw(e,t){const{labels:r,values:n}=e;for(const 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 uw(e){if(typeof e==="function"){return}if(typeof e==="string"&&Object.values(Pl).includes(e)){return}throw new Error('Levels comparison should be one of "ASC", "DESC" or "function" type')}Nl.exports={initialLsCache:Xb,genLsCache:Zb,levelMethods:kl,getLevel:rw,setLevel:tw,isLevelEnabled:nw,mappings:sw,assertNoLevelCollisions:lw,assertDefaultLevelFound:aw,genLevelComparison:ow,assertLevelComparison:uw}});var di=E((mI,Dl)=>{"use strict";Dl.exports={version:"10.3.1"}});var Hl=E((wI,Ul)=>{"use strict";var{EventEmitter:cw}=I("node:events");var{lsCacheSym:fw,levelValSym:dw,setLevelSym:hi,getLevelSym:jl,chindingsSym:Ar,mixinSym:pw,asJsonSym:ql,writeSym:hw,mixinMergeStrategySym:gw,timeSym:yw,timeSliceIndexSym:mw,streamSym:$l,serializersSym:ke,formattersSym:vt,errorKeySym:bw,messageKeySym:ww,useOnlyCustomLevelsSym:Sw,needsMetadataGsym:_w,redactFmtSym:Ew,stringifySym:xw,formatOptsSym:Aw,stringifiersSym:Rw,msgPrefixSym:gi,hooksSym:Tw}=Ze();var{getLevel:vw,setLevel:Mw,isLevelEnabled:Cw,mappings:Ow,initialLsCache:Iw,genLsCache:Lw,assertNoLevelCollisions:Pw}=fi();var{asChindings:yi,asJson:kw,buildFormatters:pi,stringify:Bl,noop:Wl}=_r();var{version:Nw}=di();var Dw=Kn();var jw=class bI{};var Fl={constructor:jw,child:Bw,bindings:qw,setBindings:$w,flush:Uw,isLevelEnabled:Cw,version:Nw,get level(){return this[jl]()},set level(e){this[hi](e)},get levelVal(){return this[dw]},set levelVal(e){throw Error("levelVal is read-only")},get msgPrefix(){return this[gi]},get[Symbol.toStringTag](){return"Pino"},[fw]:Iw,[hw]:Fw,[ql]:kw,[jl]:vw,[hi]:Mw};Object.setPrototypeOf(Fl,cw.prototype);Ul.exports=function(){return Object.create(Fl)};var xr=e=>e;function Bw(e,t){if(!e){throw Error("missing bindings for child Pino")}const r=this[ke];const n=this[vt];const i=Object.create(this);if(t==null){if(i[vt].bindings!==xr){i[vt]=pi(n.level,xr,n.log)}i[Ar]=yi(i,e);if(this.onChild!==Wl){this.onChild(i)}return i}if(t.hasOwnProperty("serializers")===true){i[ke]=Object.create(null);for(const u in r){i[ke][u]=r[u]}const a=Object.getOwnPropertySymbols(r);for(var o=0;o<a.length;o++){const u=a[o];i[ke][u]=r[u]}for(const u in t.serializers){i[ke][u]=t.serializers[u]}const l=Object.getOwnPropertySymbols(t.serializers);for(var s=0;s<l.length;s++){const u=l[s];i[ke][u]=t.serializers[u]}}else i[ke]=r;if(t.hasOwnProperty("formatters")){const{level:a,bindings:l,log:u}=t.formatters;i[vt]=pi(a||n.level,l||xr,u||n.log)}else{i[vt]=pi(n.level,xr,n.log)}if(t.hasOwnProperty("customLevels")===true){Pw(this.levels,t.customLevels);i.levels=Ow(t.customLevels,i[Sw]);Lw(i)}if(typeof t.redact==="object"&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;const a=Dw(i.redact,Bl);const l={stringify:a[Ew]};i[xw]=Bl;i[Rw]=a;i[Aw]=l}if(typeof t.msgPrefix==="string"){i[gi]=(this[gi]||"")+t.msgPrefix}i[Ar]=yi(i,e);if(t.level!==void 0&&t.level!==this.level||t.hasOwnProperty("customLevels")){const a=t.level||this.level;i[hi](a)}this.onChild(i);return i}function qw(){const e=this[Ar];const t=`{${e.substr(1)}}`;const r=JSON.parse(t);delete r.pid;delete r.hostname;return r}function $w(e){const t=yi(this,e);this[Ar]=t}function Ww(e,t){return Object.assign(t,e)}function Fw(e,t,r){const n=this[yw]();const i=this[pw];const o=this[bw];const s=this[ww];const a=this[gw]||Ww;let l;const u=this[Tw].streamWrite;if(e===void 0||e===null){l={}}else if(e instanceof Error){l={[o]:e};if(t===void 0){t=e.message}}else{l=e;if(t===void 0&&e[s]===void 0&&e[o]){t=e[o].message}}if(i){l=a(l,i(l,r,this))}const f=this[ql](l,t,r,n);const c=this[$l];if(c[_w]===true){c.lastLevel=r;c.lastObj=l;c.lastMsg=t;c.lastTime=n.slice(this[mw]);c.lastLogger=this}c.write(u?u(f):f)}function Uw(e){if(e!=null&&typeof e!=="function"){throw Error("callback must be a function")}const t=this[$l];if(typeof t.flush==="function"){t.flush(e||Wl)}else if(e)e()}});var Gl=E((Si,zl)=>{"use strict";var{hasOwnProperty:Mt}=Object.prototype;var De=wi();De.configure=wi;De.stringify=De;De.default=De;Si.stringify=De;Si.configure=wi;zl.exports=De;var Hw=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function _e(e){if(e.length<5e3&&!Hw.test(e)){return`"${e}"`}return JSON.stringify(e)}function mi(e,t){if(e.length>200||t){return e.sort(t)}for(let r=1;r<e.length;r++){const n=e[r];let i=r;while(i!==0&&e[i-1]>n){e[i]=e[i-1];i--}e[i]=n}return e}var Kw=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function bi(e){return Kw.call(e)!==void 0&&e.length!==0}function Kl(e,t,r){if(e.length<r){r=e.length}const n=t===","?"":" ";let i=`"0":${n}${e[0]}`;for(let o=1;o<r;o++){i+=`${t}"${o}":${n}${e[o]}`}return i}function Vw(e){if(Mt.call(e,"circularValue")){const 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 zw(e){let t;if(Mt.call(e,"deterministic")){t=e.deterministic;if(typeof t!=="boolean"&&typeof t!=="function"){throw new TypeError('The "deterministic" argument must be of type boolean or comparator function')}}return t===void 0?true:t}function Gw(e,t){let r;if(Mt.call(e,t)){r=e[t];if(typeof r!=="boolean"){throw new TypeError(`The "${t}" argument must be of type boolean`)}}return r===void 0?true:r}function Vl(e,t){let r;if(Mt.call(e,t)){r=e[t];if(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?Infinity:r}function Ne(e){if(e===1){return"1 item"}return`${e} items`}function Yw(e){const t=new Set;for(const r of e){if(typeof r==="string"||typeof r==="number"){t.add(String(r))}}return t}function Qw(e){if(Mt.call(e,"strict")){const 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}`;if(typeof r!=="function")n+=` (${r.toString()})`;throw new Error(n)}}}}function wi(e){e={...e};const t=Qw(e);if(t){if(e.bigint===void 0){e.bigint=false}if(!("circularValue"in e)){e.circularValue=Error}}const r=Vw(e);const n=Gw(e,"bigint");const i=zw(e);const o=typeof i==="function"?i:void 0;const s=Vl(e,"maximumDepth");const a=Vl(e,"maximumBreadth");function l(p,d,g,y,m,w){let _=d[p];if(typeof _==="object"&&_!==null&&typeof _.toJSON==="function"){_=_.toJSON(p)}_=y.call(d,p,_);switch(typeof _){case"string":return _e(_);case"object":{if(_===null){return"null"}if(g.indexOf(_)!==-1){return r}let S="";let A=",";const v=w;if(Array.isArray(_)){if(_.length===0){return"[]"}if(s<g.length+1){return'"[Array]"'}g.push(_);if(m!==""){w+=m;S+=`
3
3
  ${w}`;A=`,
4
4
  ${w}`}const D=Math.min(_.length,a);let x=0;for(;x<D-1;x++){const J=l(String(x),_,g,y,m,w);S+=J!==void 0?J:"null";S+=A}const z=l(String(x),_,g,y,m,w);S+=z!==void 0?z:"null";if(_.length-1>a){const J=_.length-a-1;S+=`${A}"... ${Ne(J)} not stringified"`}if(m!==""){S+=`
5
5
  ${v}`}g.pop();return`[${S}]`}let R=Object.keys(_);const M=R.length;if(M===0){return"{}"}if(s<g.length+1){return'"[Object]"'}let T="";let P="";if(m!==""){w+=m;A=`,
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
2
- var r=true?`ncode/${"0.1.0"}`:"ncode/dev";function a(n){return`${n} ${r}`}function l(n={}){const t=n.internalBuild===true;const i=n.insideBuild===true;if(t&&i){throw new Error("A product build cannot be both internal and inside")}const e=o(n.buildEnv);const d=i?"inside":t?"internal":"standard";return{buildEnv:e,variant:d,isDev:e==="dev",isTest:e==="test",isStaging:e==="staging",isProd:e==="prod",isInternalBuild:t,isInsideBuild:i}}function o(n){if(n==="development")return"dev";if(n==="production")return"prod";if(n==="dev"||n==="test"||n==="staging"||n==="prod"){return n}return void 0}export{a,l as b};
2
+ var r=true?`ncode/${"0.1.1"}`:"ncode/dev";function a(n){return`${n} ${r}`}function l(n={}){const t=n.internalBuild===true;const i=n.insideBuild===true;if(t&&i){throw new Error("A product build cannot be both internal and inside")}const e=o(n.buildEnv);const d=i?"inside":t?"internal":"standard";return{buildEnv:e,variant:d,isDev:e==="dev",isTest:e==="test",isStaging:e==="staging",isProd:e==="prod",isInternalBuild:t,isInsideBuild:i}}function o(n){if(n==="development")return"dev";if(n==="production")return"prod";if(n==="dev"||n==="test"||n==="staging"||n==="prod"){return n}return void 0}export{a,l as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
2
- import{a as x,c as M,d as p,j as ie,k as oe,l as se,m as ce,n as de,o as le,p as pe}from"./chunk-PGYNNAKS.js";import{a as ee,b as $,c as re,e as te,f as T,h as ne,i as ae}from"./chunk-V6SXVN2Z.js";import{a as A,b as N,c as F,d as K,e as z,f as S,j as I,l as H,n as b,o as X,q as y,r as Y,s as Z,t as G,u as W,x as Q,y as q}from"./chunk-7WOIEENL.js";import{n as V}from"./chunk-5R2PGOIA.js";import{a as Oe}from"./chunk-6MFNDZP7.js";import{e as Le}from"./chunk-FK3SSGJE.js";var Pe=Le(Oe(),1);import{createHash as De}from"node:crypto";import{existsSync as k,mkdirSync as ge,readFileSync as v,renameSync as me,rmSync as he,writeFileSync as Me}from"node:fs";import{homedir as Be}from"node:os";import d from"node:path";var je="https://algeng-ali-shanghai-agent-02.oss-cn-shanghai.aliyuncs.com/minimax-dialogue/data/env/.npm-global/mcode";var Je=8e3;var R=class{currentVersion;installRoot;releaseBaseUrl;publicKey;environment;dependencies;constructor(e){this.currentVersion=N(e.currentVersion);this.installRoot=e.installRoot??O(e.environment);this.releaseBaseUrl=(e.releaseBaseUrl??je).replace(/\/+$/u,"");this.publicKey=e.publicKey;this.environment=e.environment??process.env;this.dependencies={fetchBytes:Ke,installArtifact:ze,validateInstalledVersion:He,...e.dependencies}}async check(e={}){M(e.signal);p(e,"checking",true);const t=e.channel?A(e.channel):_e(this.installRoot);const n=e.version?N(e.version):void 0;const a=n?`${this.releaseBaseUrl}/releases/${encodeURIComponent(n)}/manifest.json`:`${this.releaseBaseUrl}/channels/${t}.json`;const o=this.publicKey??Fe(this.installRoot,this.environment);const i=ue(e.timeoutMs);const s=new AbortController;const c=fe(e.signal,s);let g=false;const l=setTimeout(()=>{g=true;s.abort(new Error(`MCode update check timed out after ${i}ms.`))},i);l.unref?.();try{const[u,h]=await Promise.all([this.dependencies.fetchBytes(a,{signal:s.signal,proxyEnvironment:this.environment}),this.dependencies.fetchBytes(`${a}.sig`,{signal:s.signal,proxyEnvironment:this.environment})]);const f=F(u,h.toString("utf8"),o);if(!n&&f.channel!==t){throw new Error(`Signed MCode release channel mismatch: expected ${t}, got ${f.channel}.`)}if(n&&f.version!==n){throw new Error(`Signed MCode release version mismatch: expected ${n}, got ${f.version}.`)}z(f,K());const m=S(this.currentVersion,f.version);return{status:m<0?"available":m>0?"ahead":"current",channel:t,currentVersion:this.currentVersion,latestVersion:f.version,manifest:f}}catch(u){if(e.signal?.aborted)throw new x;if(g){throw new Error(`MCode update check timed out after ${i}ms.`,{cause:u})}throw u}finally{clearTimeout(l);c()}}async apply(e={}){const t=await this.check(e);if(t.status==="current"){return{...t,applied:false,installRoot:this.installRoot}}if(t.status==="ahead"&&!e.version){throw new Error(`Installed MCode ${this.currentVersion} is newer than ${t.channel} ${t.latestVersion}; pass --to to downgrade explicitly.`)}const n=ue(e.timeoutMs);M(e.signal);p(e,"downloading",true);const a=new AbortController;const o=fe(e.signal,a);let i=false;const s=setTimeout(()=>{i=true;a.abort(new Error(`MCode artifact download timed out after ${n}ms.`))},n);s.unref?.();let c;try{c=await this.dependencies.fetchBytes(t.manifest.installArtifact.url,{signal:a.signal,proxyEnvironment:this.environment})}catch(m){if(e.signal?.aborted)throw new x;if(i){throw new Error(`MCode artifact download timed out after ${n}ms.`,{cause:m})}throw m}finally{clearTimeout(s);o()}M(e.signal);Xe(c,t.manifest);const g=d.join(this.installRoot,"versions");const l=d.join(g,t.latestVersion);const u=d.join(g,`.staging-${t.latestVersion}-${process.pid}-${Date.now()}`);const h=d.join(u,`minimax-mcode-${t.latestVersion}.tgz`);ge(u,{recursive:true});let f=false;try{p(e,"staging",true);M(e.signal);Me(h,c,{mode:384});M(e.signal);p(e,"installing",false);await this.dependencies.installArtifact({artifact:h,prefix:u,registry:t.manifest.registry,proxyEnvironment:this.environment});M(e.signal);V(()=>he(h,{force:true}));p(e,"validating",false);await this.dependencies.validateInstalledVersion(u,t.latestVersion);M(e.signal);p(e,"activating",false);if(k(l)){await this.dependencies.validateInstalledVersion(l,t.latestVersion);L(u)}else{V(()=>me(u,l));f=true}Ye(this.installRoot,t.latestVersion);p(e,"completed",false);return{...t,applied:true,installRoot:this.installRoot}}catch(m){L(u);if(f&&Ze(this.installRoot)!==t.latestVersion){L(l)}if(m instanceof x||e.signal?.aborted){throw new x}throw new Error(`MCode ${t.latestVersion} was not activated; the previous version is unchanged: ${xe(m)}`,{cause:m})}}};function O(r=process.env){if(r.MCODE_INSTALL_ROOT)return d.resolve(r.MCODE_INSTALL_ROOT);if(process.platform==="win32"){const t=r.LOCALAPPDATA;if(!t)throw new Error("LOCALAPPDATA is required to resolve the MCode install root.");return d.join(t,"MinimaxCode")}const e=r.XDG_DATA_HOME||d.join(Be(),".local","share");return d.join(e,"minimax-code")}function _e(r){const e=d.join(r,"update.json");if(!k(e))return"stable";let t;try{t=JSON.parse(v(e,"utf8"))}catch(n){throw new Error(`MCode update channel config is invalid: ${xe(n)}`)}if(typeof t!=="object"||t===null||!("channel"in t)||typeof t.channel!=="string"){throw new Error("MCode update channel config is missing channel.")}return A(t.channel)}function Fe(r,e){const t=e.MCODE_RELEASE_PUBLIC_KEY_FILE;if(t)return v(d.resolve(t),"utf8");const n=d.join(r,"install.json");if(!k(n)){throw new Error("MCode update trust root is missing. Install with the official Shell/PowerShell installer first.")}const a=JSON.parse(v(n,"utf8"));if(typeof a.publicKey!=="string"||!a.publicKey.includes("BEGIN PUBLIC KEY")){throw new Error("MCode installer metadata does not contain a valid release public key.")}return a.publicKey}function ue(r){if(r===void 0)return Je;if(!Number.isSafeInteger(r)||r<100||r>6e4){throw new Error("MCode update timeout must be an integer between 100 and 60000 milliseconds.")}return r}async function Ke(r,e={}){const[{default:t},{createTuiNetworkDispatcher:n}]=await Promise.all([import("./undici-L2CPAXQB.js"),import("./network-proxy-YUNTVZKM.js")]);const a=n(e.proxyEnvironment);try{const o=await t.fetch(r,{signal:e.signal,dispatcher:a,redirect:"error"});if(!o.ok){throw new Error(`MCode release server returned HTTP ${o.status} for ${r}`)}return Buffer.from(await o.arrayBuffer())}finally{await a.close()}}async function ze(r){const e=process.platform==="win32"?"npm.cmd":"npm";await ye(e,["install","--global","--prefix",r.prefix,r.artifact,"--registry",r.registry,"--no-audit","--no-fund","--package-lock=false"],r.proxyEnvironment,true)}async function He(r,e){let t=d.join(r,"bin","mcode");let n=["--version"];if(process.platform==="win32"){const o=ee(r,b().packageName);const i=JSON.parse(v(d.join(o,"package.json"),"utf8"));const s=ae(i.bin,"mcode");if(!s||!k(d.join(r,"mcode.cmd"))){throw new Error(`Installed MCode launcher is missing or invalid at ${r}.`)}t=process.execPath;n=[d.join(o,s),"--version"]}const a=await ye(t,n,process.env,true);if(a.trim()!==e){throw new Error(`Installed MCode version mismatch: expected ${e}, got ${a.trim()}`)}}function ye(r,e,t,n=false){return new Promise((a,o)=>{let i=false;const s=(0,Pe.default)(r,e,{env:t,shell:false,stdio:n?["ignore","pipe","pipe"]:"inherit",windowsHide:true});const c=[];const g=[];s.stdout?.on("data",l=>c.push(l));s.stderr?.on("data",l=>g.push(l));s.once("error",l=>{if(i)return;i=true;o(l)});s.once("close",(l,u)=>{if(i)return;i=true;if(l===0)return a(Buffer.concat(c).toString("utf8"));const h=Buffer.concat(g).toString("utf8").trim();o(new Error(`${r} failed (${u?`signal ${u}`:`exit ${String(l)}`})${h?`: ${h}`:""}`))})})}function fe(r,e){if(!r)return()=>void 0;const t=()=>e.abort(r.reason);if(r.aborted)t();else r.addEventListener("abort",t,{once:true});return()=>r.removeEventListener("abort",t)}function Xe(r,e){if(r.length!==e.installArtifact.size){throw new Error(`MCode artifact checksum/size verification failed: expected ${e.installArtifact.size} bytes, got ${r.length}.`)}const t=De("sha256").update(r).digest("hex");if(t!==e.installArtifact.sha256){throw new Error("MCode artifact checksum verification failed.")}}function Ye(r,e){ge(r,{recursive:true});const t=d.join(r,"current");const n=`${t}.tmp-${process.pid}-${Date.now()}`;Me(n,`${e}
2
+ import{a as x,c as M,d as p,j as ie,k as oe,l as se,m as ce,n as de,o as le,p as pe}from"./chunk-PGYNNAKS.js";import{a as ee,b as $,c as re,e as te,f as T,h as ne,i as ae}from"./chunk-V6SXVN2Z.js";import{a as A,b as N,c as F,d as K,e as z,f as S,j as I,l as H,n as b,o as X,q as y,r as Y,s as Z,t as G,u as W,x as Q,y as q}from"./chunk-7WOIEENL.js";import{n as V}from"./chunk-3MLT4F77.js";import{a as Oe}from"./chunk-6MFNDZP7.js";import{e as Le}from"./chunk-FK3SSGJE.js";var Pe=Le(Oe(),1);import{createHash as De}from"node:crypto";import{existsSync as k,mkdirSync as ge,readFileSync as v,renameSync as me,rmSync as he,writeFileSync as Me}from"node:fs";import{homedir as Be}from"node:os";import d from"node:path";var je="https://algeng-ali-shanghai-agent-02.oss-cn-shanghai.aliyuncs.com/minimax-dialogue/data/env/.npm-global/mcode";var Je=8e3;var R=class{currentVersion;installRoot;releaseBaseUrl;publicKey;environment;dependencies;constructor(e){this.currentVersion=N(e.currentVersion);this.installRoot=e.installRoot??O(e.environment);this.releaseBaseUrl=(e.releaseBaseUrl??je).replace(/\/+$/u,"");this.publicKey=e.publicKey;this.environment=e.environment??process.env;this.dependencies={fetchBytes:Ke,installArtifact:ze,validateInstalledVersion:He,...e.dependencies}}async check(e={}){M(e.signal);p(e,"checking",true);const t=e.channel?A(e.channel):_e(this.installRoot);const n=e.version?N(e.version):void 0;const a=n?`${this.releaseBaseUrl}/releases/${encodeURIComponent(n)}/manifest.json`:`${this.releaseBaseUrl}/channels/${t}.json`;const o=this.publicKey??Fe(this.installRoot,this.environment);const i=ue(e.timeoutMs);const s=new AbortController;const c=fe(e.signal,s);let g=false;const l=setTimeout(()=>{g=true;s.abort(new Error(`MCode update check timed out after ${i}ms.`))},i);l.unref?.();try{const[u,h]=await Promise.all([this.dependencies.fetchBytes(a,{signal:s.signal,proxyEnvironment:this.environment}),this.dependencies.fetchBytes(`${a}.sig`,{signal:s.signal,proxyEnvironment:this.environment})]);const f=F(u,h.toString("utf8"),o);if(!n&&f.channel!==t){throw new Error(`Signed MCode release channel mismatch: expected ${t}, got ${f.channel}.`)}if(n&&f.version!==n){throw new Error(`Signed MCode release version mismatch: expected ${n}, got ${f.version}.`)}z(f,K());const m=S(this.currentVersion,f.version);return{status:m<0?"available":m>0?"ahead":"current",channel:t,currentVersion:this.currentVersion,latestVersion:f.version,manifest:f}}catch(u){if(e.signal?.aborted)throw new x;if(g){throw new Error(`MCode update check timed out after ${i}ms.`,{cause:u})}throw u}finally{clearTimeout(l);c()}}async apply(e={}){const t=await this.check(e);if(t.status==="current"){return{...t,applied:false,installRoot:this.installRoot}}if(t.status==="ahead"&&!e.version){throw new Error(`Installed MCode ${this.currentVersion} is newer than ${t.channel} ${t.latestVersion}; pass --to to downgrade explicitly.`)}const n=ue(e.timeoutMs);M(e.signal);p(e,"downloading",true);const a=new AbortController;const o=fe(e.signal,a);let i=false;const s=setTimeout(()=>{i=true;a.abort(new Error(`MCode artifact download timed out after ${n}ms.`))},n);s.unref?.();let c;try{c=await this.dependencies.fetchBytes(t.manifest.installArtifact.url,{signal:a.signal,proxyEnvironment:this.environment})}catch(m){if(e.signal?.aborted)throw new x;if(i){throw new Error(`MCode artifact download timed out after ${n}ms.`,{cause:m})}throw m}finally{clearTimeout(s);o()}M(e.signal);Xe(c,t.manifest);const g=d.join(this.installRoot,"versions");const l=d.join(g,t.latestVersion);const u=d.join(g,`.staging-${t.latestVersion}-${process.pid}-${Date.now()}`);const h=d.join(u,`minimax-mcode-${t.latestVersion}.tgz`);ge(u,{recursive:true});let f=false;try{p(e,"staging",true);M(e.signal);Me(h,c,{mode:384});M(e.signal);p(e,"installing",false);await this.dependencies.installArtifact({artifact:h,prefix:u,registry:t.manifest.registry,proxyEnvironment:this.environment});M(e.signal);V(()=>he(h,{force:true}));p(e,"validating",false);await this.dependencies.validateInstalledVersion(u,t.latestVersion);M(e.signal);p(e,"activating",false);if(k(l)){await this.dependencies.validateInstalledVersion(l,t.latestVersion);L(u)}else{V(()=>me(u,l));f=true}Ye(this.installRoot,t.latestVersion);p(e,"completed",false);return{...t,applied:true,installRoot:this.installRoot}}catch(m){L(u);if(f&&Ze(this.installRoot)!==t.latestVersion){L(l)}if(m instanceof x||e.signal?.aborted){throw new x}throw new Error(`MCode ${t.latestVersion} was not activated; the previous version is unchanged: ${xe(m)}`,{cause:m})}}};function O(r=process.env){if(r.MCODE_INSTALL_ROOT)return d.resolve(r.MCODE_INSTALL_ROOT);if(process.platform==="win32"){const t=r.LOCALAPPDATA;if(!t)throw new Error("LOCALAPPDATA is required to resolve the MCode install root.");return d.join(t,"MinimaxCode")}const e=r.XDG_DATA_HOME||d.join(Be(),".local","share");return d.join(e,"minimax-code")}function _e(r){const e=d.join(r,"update.json");if(!k(e))return"stable";let t;try{t=JSON.parse(v(e,"utf8"))}catch(n){throw new Error(`MCode update channel config is invalid: ${xe(n)}`)}if(typeof t!=="object"||t===null||!("channel"in t)||typeof t.channel!=="string"){throw new Error("MCode update channel config is missing channel.")}return A(t.channel)}function Fe(r,e){const t=e.MCODE_RELEASE_PUBLIC_KEY_FILE;if(t)return v(d.resolve(t),"utf8");const n=d.join(r,"install.json");if(!k(n)){throw new Error("MCode update trust root is missing. Install with the official Shell/PowerShell installer first.")}const a=JSON.parse(v(n,"utf8"));if(typeof a.publicKey!=="string"||!a.publicKey.includes("BEGIN PUBLIC KEY")){throw new Error("MCode installer metadata does not contain a valid release public key.")}return a.publicKey}function ue(r){if(r===void 0)return Je;if(!Number.isSafeInteger(r)||r<100||r>6e4){throw new Error("MCode update timeout must be an integer between 100 and 60000 milliseconds.")}return r}async function Ke(r,e={}){const[{default:t},{createTuiNetworkDispatcher:n}]=await Promise.all([import("./undici-L2CPAXQB.js"),import("./network-proxy-YUNTVZKM.js")]);const a=n(e.proxyEnvironment);try{const o=await t.fetch(r,{signal:e.signal,dispatcher:a,redirect:"error"});if(!o.ok){throw new Error(`MCode release server returned HTTP ${o.status} for ${r}`)}return Buffer.from(await o.arrayBuffer())}finally{await a.close()}}async function ze(r){const e=process.platform==="win32"?"npm.cmd":"npm";await ye(e,["install","--global","--prefix",r.prefix,r.artifact,"--registry",r.registry,"--no-audit","--no-fund","--package-lock=false"],r.proxyEnvironment,true)}async function He(r,e){let t=d.join(r,"bin","mcode");let n=["--version"];if(process.platform==="win32"){const o=ee(r,b().packageName);const i=JSON.parse(v(d.join(o,"package.json"),"utf8"));const s=ae(i.bin,"mcode");if(!s||!k(d.join(r,"mcode.cmd"))){throw new Error(`Installed MCode launcher is missing or invalid at ${r}.`)}t=process.execPath;n=[d.join(o,s),"--version"]}const a=await ye(t,n,process.env,true);if(a.trim()!==e){throw new Error(`Installed MCode version mismatch: expected ${e}, got ${a.trim()}`)}}function ye(r,e,t,n=false){return new Promise((a,o)=>{let i=false;const s=(0,Pe.default)(r,e,{env:t,shell:false,stdio:n?["ignore","pipe","pipe"]:"inherit",windowsHide:true});const c=[];const g=[];s.stdout?.on("data",l=>c.push(l));s.stderr?.on("data",l=>g.push(l));s.once("error",l=>{if(i)return;i=true;o(l)});s.once("close",(l,u)=>{if(i)return;i=true;if(l===0)return a(Buffer.concat(c).toString("utf8"));const h=Buffer.concat(g).toString("utf8").trim();o(new Error(`${r} failed (${u?`signal ${u}`:`exit ${String(l)}`})${h?`: ${h}`:""}`))})})}function fe(r,e){if(!r)return()=>void 0;const t=()=>e.abort(r.reason);if(r.aborted)t();else r.addEventListener("abort",t,{once:true});return()=>r.removeEventListener("abort",t)}function Xe(r,e){if(r.length!==e.installArtifact.size){throw new Error(`MCode artifact checksum/size verification failed: expected ${e.installArtifact.size} bytes, got ${r.length}.`)}const t=De("sha256").update(r).digest("hex");if(t!==e.installArtifact.sha256){throw new Error("MCode artifact checksum verification failed.")}}function Ye(r,e){ge(r,{recursive:true});const t=d.join(r,"current");const n=`${t}.tmp-${process.pid}-${Date.now()}`;Me(n,`${e}
3
3
  `,{mode:384});V(()=>me(n,t))}function L(r){he(r,{recursive:true,force:true,maxRetries:4,retryDelay:50})}function Ze(r){const e=d.join(r,"current");if(!k(e))return void 0;return v(e,"utf8").trim()||void 0}function xe(r){return r instanceof Error?r.message:String(r)}import{randomUUID as C}from"node:crypto";import{chmodSync as Ge,existsSync as D,mkdirSync as U,readdirSync as We,readFileSync as J,renameSync as Ve,rmSync as B,writeFileSync as Se}from"node:fs";import P from"node:path";var _="releases";var be="current";var Qe=".mcode-update.lock";var qe=2;function $e(r,e,t=process.platform){const n=w(t);return n.join(r,_,`.staging-${e}-${process.pid}-${C()}`)}function Re(r){U(r,{recursive:true,mode:448})}function Ce(r){const e=P.join(r,Qe);U(e,{recursive:true,mode:448});const t=`${String(process.pid)}-${C()}.claim`;const n=P.join(e,t);Se(n,"choosing\n",{flag:"wx",mode:384});try{const o=Math.max(0,...ke(e).map(s=>s.ticket??0))+1;E(n,`${String(o)}
4
4
  `,384);const i=ke(e).some(s=>s.name!==t&&(s.ticket===void 0||s.ticket<o||s.ticket===o&&(s.pid<process.pid||s.pid===process.pid&&s.name.localeCompare(t)<0)));if(i)throw new Error("Another MCode update is already running.")}catch(o){B(n,{force:true});throw o}let a=false;return()=>{if(a)return;a=true;B(n,{force:true})}}function Ue(r,e=process.platform){const t=w(e);const n=t.join(r.activePrefix,_);const a=Ae(r.stagingPrefix,r,e);er(r.stagingPrefix,a,r.runtimeExecutable,e);ve(r.stagingPrefix,r,e);U(n,{recursive:true,mode:448});let o=r.expectedVersion;let i=t.join(n,o);if(D(i)){o=`${r.expectedVersion}-repair-${C()}`;i=t.join(n,o)}Ve(r.stagingPrefix,i);ve(i,r,e);nr(r,e);if(!tr(r.activePrefix,e)){rr(r.activePrefix,e)}E(t.join(r.activePrefix,be),`${o}
5
5
  `,384);return i}function Ae(r,e,t){const n=$(r,e.packageName,t);if(n.version!==e.expectedVersion){throw new Error(`MCode release contains ${n.version}; expected ${e.expectedVersion}.`)}return n}function ve(r,e,t){const n=Ae(r,e,t);const a=Ne(r,n,e.runtimeExecutable,t);for(const[o,i]of a){if(J(o,"utf8")!==i){throw new Error(`MCode release launcher is invalid: ${o}`)}}}function er(r,e,t,n){for(const[a,o]of Ne(r,e,t,n)){E(a,o,448)}}function Ne(r,e,t,n){const a=w(n);const o=new Map;if(!D(t)){throw new Error("MCode versioned launcher runtime is missing.")}for(const i of j(e)){if(!i.binEntry){throw new Error(`MCode versioned ${i.name} package entry is missing.`)}const s=a.join(e.packageRoot,...i.binEntry.split("/"));const c=a.relative(r,s);if(!c||c.startsWith("..")||a.isAbsolute(c)||!D(s)){throw new Error(`MCode versioned ${i.name} launcher path is invalid.`)}if(n==="win32"){o.set(a.join(r,`${i.releaseLauncher}.cmd`),`@ECHO off\r