@maincode-ai/matilda-code 0.21.13 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunks/agent-IUINB66G.js +3 -0
- package/chunks/agent-headless-YA2RKYEZ.js +3 -0
- package/chunks/{askUserQuestion-BNSWGD26.js → askUserQuestion-RZYBOPLR.js} +3 -3
- package/chunks/ca-JKEHLTNL.js +23 -0
- package/chunks/chunk-225CZWD7.js +89 -0
- package/chunks/{chunk-MEV5XQI2.js → chunk-2XSB5XHX.js} +1 -1
- package/chunks/chunk-453BANK3.js +8 -0
- package/chunks/{chunk-6M5G5FBH.js → chunk-4UGPARBR.js} +1 -1
- package/chunks/{chunk-RNKDFE2S.js → chunk-5B2QERWR.js} +1 -1
- package/chunks/chunk-5ETLURI6.js +3 -0
- package/chunks/chunk-6NXVLJ3X.js +56 -0
- package/chunks/{chunk-QZI2ZGZY.js → chunk-7B65UIHB.js} +1 -1
- package/chunks/{chunk-27Q5KW3A.js → chunk-7E2YCGHS.js} +13 -13
- package/chunks/{chunk-DHDD5YJC.js → chunk-ARAB5QTM.js} +69 -69
- package/chunks/chunk-DUB7JMQV.js +13 -0
- package/chunks/chunk-G3F3ZCH2.js +9 -0
- package/chunks/chunk-GT6MSEK4.js +3 -0
- package/chunks/chunk-HEJO7OBH.js +3 -0
- package/chunks/{chunk-6T2GIM76.js → chunk-IHWAOFCQ.js} +1 -1
- package/chunks/chunk-ILHNCXBC.js +8 -0
- package/chunks/chunk-J3ZCE3TA.js +8 -0
- package/chunks/{chunk-AOOZREGV.js → chunk-LBQNFSZ2.js} +1 -1
- package/chunks/{chunk-5OHGYMKP.js → chunk-LM6OIN4B.js} +1 -1
- package/chunks/{chunk-EZDV7A76.js → chunk-LMZBADPW.js} +1 -1
- package/chunks/chunk-MGRXOZAG.js +8 -0
- package/chunks/chunk-NBLBE7PE.js +2609 -0
- package/chunks/chunk-POGNX7U3.js +31 -0
- package/chunks/chunk-PQZ6HKKW.js +80 -0
- package/chunks/chunk-QXSBPCBA.js +8 -0
- package/chunks/chunk-RHSUTILA.js +9 -0
- package/chunks/{chunk-P5TG5CON.js → chunk-RPXRN7E6.js} +1 -1
- package/chunks/chunk-TUKNB5CQ.js +33 -0
- package/chunks/chunk-UM6CLO7D.js +7 -0
- package/chunks/chunk-V2VUANFI.js +120 -0
- package/chunks/chunk-V4VILMIK.js +14 -0
- package/chunks/chunk-ZSGBDQXU.js +11 -0
- package/chunks/{computer-use-J4GAM4M6.js → computer-use-PBCWDTJR.js} +1 -1
- package/chunks/{cron-create-IDWSZENI.js → cron-create-PHQ43NYA.js} +1 -1
- package/chunks/cron-delete-7RCQIU2U.js +3 -0
- package/chunks/cron-list-KKNLLMNN.js +5 -0
- package/chunks/de-GMGNR5CZ.js +23 -0
- package/chunks/{devtools-XRQ4YJ5S.js → devtools-7YNCRYZV.js} +1 -1
- package/chunks/{chunk-OOEH6ZSV.js → dist-UWUWLWTO.js} +2 -2
- package/chunks/{edit-X2S2ZXRN.js → edit-ELHNQB5E.js} +1 -1
- package/chunks/en-3NQMLVKW.js +23 -0
- package/chunks/{enter-worktree-TUCGNCLO.js → enter-worktree-UZIBOBV3.js} +1 -1
- package/chunks/enterPlanMode-UHY3DZXE.js +18 -0
- package/chunks/{exit-worktree-7FLITFZI.js → exit-worktree-HLG4PDMX.js} +1 -1
- package/chunks/{exitPlanMode-O5UUJ3GM.js → exitPlanMode-V4HYNH3J.js} +2 -2
- package/chunks/fr-WS3EBB36.js +23 -0
- package/chunks/{getMachineId-bsd-ZYBNK2JG.js → getMachineId-bsd-ETKQTB6C.js} +1 -1
- package/chunks/{getMachineId-darwin-CM2MQGUI.js → getMachineId-darwin-AKNRWOWB.js} +1 -1
- package/chunks/{getMachineId-linux-SYE2KMCW.js → getMachineId-linux-2QSD7FTP.js} +1 -1
- package/chunks/{getMachineId-unsupported-6IHVG2XO.js → getMachineId-unsupported-UXSV7I24.js} +1 -1
- package/chunks/{getMachineId-win-S3J3JSUM.js → getMachineId-win-4MTFXGP3.js} +1 -1
- package/chunks/glob-C5CTWXLP.js +22 -0
- package/chunks/{goal-tools-YQOA6OKU.js → goal-tools-BGIWEJ3K.js} +3 -3
- package/chunks/{grep-VAB2VSXM.js → grep-BEFTGKHW.js} +1 -1
- package/chunks/ja-GBCDQ43R.js +23 -0
- package/chunks/keychain-token-storage-FEJZYJBB.js +3 -0
- package/chunks/ls-XH55NAD3.js +15 -0
- package/chunks/{lsp-NGLDRHZU.js → lsp-BKDCR37G.js} +1 -1
- package/chunks/mcp-client-GAQG7MCT.js +3 -0
- package/chunks/monitor-NSVUUKCM.js +32 -0
- package/chunks/{multipart-parser-JI75T2O5.js → multipart-parser-FKHYAVGR.js} +1 -1
- package/chunks/notebook-edit-AXKYC64C.js +17 -0
- package/chunks/openaiContentGenerator-66YY6CIM.js +47 -0
- package/chunks/pt-VID6J2CM.js +23 -0
- package/chunks/read-file-YFJMLS7V.js +3 -0
- package/chunks/ripGrep-BEHEB23R.js +3 -0
- package/chunks/ru-EB6V6EAN.js +23 -0
- package/chunks/scheduler-GKQOREMS.js +8 -0
- package/chunks/send-message-GJSEMAZB.js +8 -0
- package/chunks/shell-J5Q2UEXH.js +3 -0
- package/chunks/{skill-ETQM5NI3.js → skill-3RWNSUNE.js} +1 -1
- package/chunks/src-LZEU4AYF.js +5 -0
- package/chunks/symbol-search-4VM6J5Y4.js +19 -0
- package/chunks/{syntheticOutput-WZDPECYS.js → syntheticOutput-O7LEF3AM.js} +1 -1
- package/chunks/task-create-N4IRJBTF.js +3 -0
- package/chunks/{task-detach-TBAVUOTC.js → task-detach-RGNQUX3H.js} +1 -1
- package/chunks/task-list-Z7JUB4QK.js +9 -0
- package/chunks/{task-stop-HDSARSJ6.js → task-stop-L2OWK2PJ.js} +1 -1
- package/chunks/{task-update-MW2VT2XV.js → task-update-H5AXVXDS.js} +1 -1
- package/chunks/{team-create-VMYNLZCC.js → team-create-FWTIQ2FT.js} +2 -2
- package/chunks/team-delete-D45ALROH.js +8 -0
- package/chunks/todoWrite-LCQOQBI7.js +3 -0
- package/chunks/{tool-search-WX6FOE35.js → tool-search-X6UUCSPU.js} +1 -1
- package/chunks/{web-fetch-CKYBHGLF.js → web-fetch-244KUWSX.js} +17 -17
- package/chunks/web-search-YRZ3BZ3X.js +26 -0
- package/chunks/{workflow-WBSRQG3N.js → workflow-EP4AFR24.js} +2 -2
- package/chunks/write-file-EXWGRN4Q.js +15 -0
- package/cli.js +641 -678
- package/examples/starter/README.md +0 -3
- package/locales/ca.js +3 -87
- package/locales/de.js +3 -91
- package/locales/en.js +3 -91
- package/locales/fr.js +3 -88
- package/locales/ja.js +3 -92
- package/locales/pt.js +3 -92
- package/locales/ru.js +3 -91
- package/package.json +2 -2
- package/sandbox-macos-permissive-proxied.sb +1 -1
- package/sandbox-macos-restrictive-closed.sb +14 -1
- package/sandbox-macos-restrictive-open.sb +14 -1
- package/sandbox-macos-restrictive-proxied.sb +15 -2
- package/bundled/mainy/SKILL.md +0 -157
- package/bundled/mainy/docs/_meta.ts +0 -32
- package/bundled/mainy/docs/common-workflow.md +0 -571
- package/bundled/mainy/docs/configuration/_meta.ts +0 -7
- package/bundled/mainy/docs/configuration/auth.md +0 -82
- package/bundled/mainy/docs/configuration/matilda-ignore.md +0 -55
- package/bundled/mainy/docs/configuration/model-providers.md +0 -516
- package/bundled/mainy/docs/configuration/settings.md +0 -818
- package/bundled/mainy/docs/configuration/themes.md +0 -199
- package/bundled/mainy/docs/configuration/trusted-folders.md +0 -67
- package/bundled/mainy/docs/extension/_meta.ts +0 -9
- package/bundled/mainy/docs/extension/extension-releasing.md +0 -204
- package/bundled/mainy/docs/extension/getting-started-extensions.md +0 -299
- package/bundled/mainy/docs/extension/introduction.md +0 -338
- package/bundled/mainy/docs/features/_meta.ts +0 -27
- package/bundled/mainy/docs/features/approval-mode.md +0 -388
- package/bundled/mainy/docs/features/arena.md +0 -219
- package/bundled/mainy/docs/features/auto-mode.md +0 -308
- package/bundled/mainy/docs/features/channels/_meta.ts +0 -5
- package/bundled/mainy/docs/features/channels/overview.md +0 -328
- package/bundled/mainy/docs/features/channels/plugins.md +0 -87
- package/bundled/mainy/docs/features/channels/telegram.md +0 -120
- package/bundled/mainy/docs/features/code-review.md +0 -291
- package/bundled/mainy/docs/features/commands.md +0 -528
- package/bundled/mainy/docs/features/dual-output.md +0 -627
- package/bundled/mainy/docs/features/followup-suggestions.md +0 -109
- package/bundled/mainy/docs/features/headless.md +0 -448
- package/bundled/mainy/docs/features/hooks.md +0 -1308
- package/bundled/mainy/docs/features/language.md +0 -144
- package/bundled/mainy/docs/features/lsp.md +0 -496
- package/bundled/mainy/docs/features/markdown-rendering.md +0 -183
- package/bundled/mainy/docs/features/mcp.md +0 -423
- package/bundled/mainy/docs/features/memory.md +0 -185
- package/bundled/mainy/docs/features/sandbox.md +0 -249
- package/bundled/mainy/docs/features/scheduled-tasks.md +0 -139
- package/bundled/mainy/docs/features/skills.md +0 -347
- package/bundled/mainy/docs/features/status-line.md +0 -397
- package/bundled/mainy/docs/features/structured-output.md +0 -309
- package/bundled/mainy/docs/features/sub-agents.md +0 -737
- package/bundled/mainy/docs/features/tips.md +0 -54
- package/bundled/mainy/docs/features/token-caching.md +0 -29
- package/bundled/mainy/docs/features/tool-use-summaries.md +0 -178
- package/bundled/mainy/docs/features/worktree.md +0 -343
- package/bundled/mainy/docs/ide-integration/_meta.ts +0 -4
- package/bundled/mainy/docs/ide-integration/ide-companion-spec.md +0 -182
- package/bundled/mainy/docs/ide-integration/ide-integration.md +0 -144
- package/bundled/mainy/docs/integration-github-action.md +0 -241
- package/bundled/mainy/docs/integration-jetbrains.md +0 -81
- package/bundled/mainy/docs/integration-vscode.md +0 -39
- package/bundled/mainy/docs/integration-zed.md +0 -72
- package/bundled/mainy/docs/matilda-serve-deploy-local.md +0 -221
- package/bundled/mainy/docs/matilda-serve.md +0 -661
- package/bundled/mainy/docs/overview.md +0 -64
- package/bundled/mainy/docs/quickstart.md +0 -234
- package/bundled/mainy/docs/reference/_meta.ts +0 -3
- package/bundled/mainy/docs/reference/keyboard-shortcuts.md +0 -91
- package/bundled/mainy/docs/support/Uninstall.md +0 -65
- package/bundled/mainy/docs/support/_meta.ts +0 -6
- package/bundled/mainy/docs/support/tos-privacy.md +0 -94
- package/bundled/mainy/docs/support/troubleshooting.md +0 -127
- package/chunks/agent-SRAIVZEE.js +0 -3
- package/chunks/agent-headless-XRDOZESG.js +0 -3
- package/chunks/anthropicContentGenerator-LLDIKDMQ.js +0 -39
- package/chunks/ca-NPYL24ME.js +0 -25
- package/chunks/chunk-27HUYW23.js +0 -22
- package/chunks/chunk-2HTPVSGT.js +0 -3
- package/chunks/chunk-3B2HABK7.js +0 -30
- package/chunks/chunk-3MTZTNAU.js +0 -101
- package/chunks/chunk-3YLXGE6T.js +0 -8
- package/chunks/chunk-47XR7IMP.js +0 -8
- package/chunks/chunk-4F4DA5UI.js +0 -8
- package/chunks/chunk-4Q2SNBUH.js +0 -18
- package/chunks/chunk-6EQMZNIY.js +0 -8
- package/chunks/chunk-6I6VGTKD.js +0 -8
- package/chunks/chunk-DC7LAFZZ.js +0 -8
- package/chunks/chunk-DE3HKC2W.js +0 -9
- package/chunks/chunk-FWDMPRKU.js +0 -3
- package/chunks/chunk-G7R2XEEF.js +0 -7
- package/chunks/chunk-GOJCMVJJ.js +0 -8
- package/chunks/chunk-GTVCJCHR.js +0 -8
- package/chunks/chunk-IJEGHQ7Z.js +0 -32
- package/chunks/chunk-JCE3JAVC.js +0 -25
- package/chunks/chunk-KHHJYBR5.js +0 -9
- package/chunks/chunk-LUNDTQ3G.js +0 -8
- package/chunks/chunk-LWARA7JY.js +0 -37
- package/chunks/chunk-M53RP3YP.js +0 -31
- package/chunks/chunk-MTMU7JYZ.js +0 -11
- package/chunks/chunk-O44XK65C.js +0 -8
- package/chunks/chunk-OA56BXPD.js +0 -3
- package/chunks/chunk-PEKAUGYV.js +0 -2621
- package/chunks/chunk-PGUG43HG.js +0 -24
- package/chunks/chunk-PGXQZVLX.js +0 -8
- package/chunks/chunk-QKYGQLWC.js +0 -8
- package/chunks/chunk-QN6Y6NPA.js +0 -3
- package/chunks/chunk-RI54U73U.js +0 -56
- package/chunks/chunk-RPFSFS7Z.js +0 -39
- package/chunks/chunk-SDTWBD62.js +0 -8
- package/chunks/chunk-SOEIVSM5.js +0 -113
- package/chunks/chunk-SVSY6AWS.js +0 -59
- package/chunks/chunk-T2T2UEPY.js +0 -4
- package/chunks/chunk-TISQNFB5.js +0 -3
- package/chunks/chunk-TWJLOEAI.js +0 -31
- package/chunks/chunk-VI74YQQO.js +0 -8
- package/chunks/chunk-VYZOOSMP.js +0 -30
- package/chunks/chunk-W4QSMIWO.js +0 -9
- package/chunks/chunk-WC2VTVCE.js +0 -27
- package/chunks/chunk-YV3PUOBU.js +0 -65
- package/chunks/chunk-ZX34M2GF.js +0 -14
- package/chunks/contextCommand-5F5M7NA4.js +0 -3
- package/chunks/cron-delete-NQCDZDUI.js +0 -3
- package/chunks/cron-list-Z4XMC3TO.js +0 -5
- package/chunks/de-34YZHGC6.js +0 -25
- package/chunks/dist-7UYRLSLE.js +0 -3
- package/chunks/dist-PH6JW7XD.js +0 -42
- package/chunks/en-QLGMD6OS.js +0 -25
- package/chunks/enterPlanMode-SQEZAAIR.js +0 -18
- package/chunks/fileFromPath-7UCWPD4W.js +0 -3
- package/chunks/fr-EDNBQACJ.js +0 -25
- package/chunks/geminiContentGenerator-FIZFLPU3.js +0 -8
- package/chunks/glob-GSFTYAS2.js +0 -22
- package/chunks/ja-LV4RLM3M.js +0 -25
- package/chunks/keychain-token-storage-KQK6MNOJ.js +0 -3
- package/chunks/ls-IZJ3CKZY.js +0 -15
- package/chunks/matildaAgentContentGenerator-QQHPCFJ5.js +0 -8
- package/chunks/matildaContentGenerator-W7Z33ONU.js +0 -8
- package/chunks/matildaOAuth2-7COTQQR2.js +0 -3
- package/chunks/mcp-client-DXUNIEIB.js +0 -3
- package/chunks/monitor-4PFIGAGG.js +0 -32
- package/chunks/notebook-edit-MWJYAATJ.js +0 -17
- package/chunks/openaiContentGenerator-NDVJL6QL.js +0 -3
- package/chunks/pt-5SQ4DGL7.js +0 -25
- package/chunks/read-file-WPZKPXWA.js +0 -3
- package/chunks/ripGrep-7LZDZFTX.js +0 -3
- package/chunks/ru-7K24S53N.js +0 -25
- package/chunks/scheduler-DK2MVKXX.js +0 -8
- package/chunks/send-message-TCPX5UDU.js +0 -8
- package/chunks/serve-GSZPJI2O.js +0 -1026
- package/chunks/shell-PRS47PDP.js +0 -3
- package/chunks/src-UB7DZRYK.js +0 -3
- package/chunks/src-WZTRMETQ.js +0 -5
- package/chunks/symbol-search-HARHZ5AH.js +0 -19
- package/chunks/task-create-XRNIDT4T.js +0 -3
- package/chunks/task-list-Z6BDZZID.js +0 -9
- package/chunks/team-delete-F7QDC2TE.js +0 -8
- package/chunks/todoWrite-SCF5M24M.js +0 -3
- package/chunks/web-search-67DFNS5V.js +0 -26
- package/chunks/write-file-S5FAX4JJ.js +0 -15
package/chunks/chunk-VI74YQQO.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import{b as d}from"./chunk-GZPNIYVZ.js";d();import{setMaxListeners as b}from"node:events";var f=50;function c(r=f){let t=new AbortController;return b(r,t.signal),t}function m(r){if(r)return r instanceof AbortController?r.signal:r}function v(r,t){let e=c(t),n=m(r);if(!n)return e;if(n.aborted)return e.abort(n.reason),e;let a=new WeakRef(n),i=()=>{e.abort(a.deref()?.reason)};return n.addEventListener("abort",i,{once:!0}),e.signal.addEventListener("abort",()=>{a.deref()?.removeEventListener("abort",i)},{once:!0}),e}function g(r,t){let e=c(t?.maxListeners),n=r.find(o=>o?.aborted);if(n)return e.abort(n.reason),{signal:e.signal,cleanup:()=>{}};let a=[];for(let o of r){if(!o)continue;if(o.aborted){e.abort(o.reason);break}let u=()=>e.abort(o.reason);o.addEventListener("abort",u,{once:!0}),a.push(()=>o.removeEventListener("abort",u))}let i=t?.timeoutMs;if(i!==void 0&&i>0&&!e.signal.aborted){let o=setTimeout(()=>{e.abort(new DOMException("Operation timed out","TimeoutError"))},i);a.push(()=>clearTimeout(o))}let s=!1,l=()=>{if(!s){s=!0;for(let o of a)o()}};return e.signal.aborted?l():e.signal.addEventListener("abort",l,{once:!0}),{signal:e.signal,cleanup:l}}async function E(r,t){t?.throwIfAborted();let e=r();if(!t)return e;let n=()=>{},a=new Promise((i,s)=>{n=()=>s(t.reason),t.addEventListener("abort",n,{once:!0})});try{return await Promise.race([e,a])}finally{t.removeEventListener("abort",n),e.catch(()=>{})}}export{c as a,v as b,g as c,E as d};
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright 2025 Matilda
|
|
7
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
-
*/
|
package/chunks/chunk-VYZOOSMP.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import{a as Ya}from"./chunk-O44XK65C.js";import{b as I}from"./chunk-GZPNIYVZ.js";import{a as mr,c as Ct,d as $n,f as Nn}from"./chunk-OWGSC52X.js";var Un=$n((Tt,Qn)=>{I();(function(d,s){typeof Tt=="object"&&typeof Qn<"u"?s(Tt):typeof define=="function"&&define.amd?define(["exports"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.WebStreamsPolyfill={}))})(Tt,function(d){"use strict";function s(){}function l(e){return typeof e=="object"&&e!==null||typeof e=="function"}let b=s;function f(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch{}}let R=Promise,C=Promise.prototype.then,fe=Promise.reject.bind(R);function P(e){return new R(e)}function S(e){return P(t=>t(e))}function c(e){return fe(e)}function W(e,t,r){return C.call(e,t,r)}function v(e,t,r){W(W(e,t,r),void 0,b)}function L(e,t){v(e,t)}function Q(e,t){v(e,void 0,t)}function U(e,t,r){return W(e,t,r)}function Ce(e){W(e,void 0,b)}let de=e=>{if(typeof queueMicrotask=="function")de=queueMicrotask;else{let t=S(void 0);de=r=>W(t,r)}return de(e)};function ce(e,t,r){if(typeof e!="function")throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function K(e,t,r){try{return S(ce(e,t,r))}catch(n){return c(n)}}let Rr=16384;class k{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(t){let r=this._back,n=r;r._elements.length===Rr-1&&(n={_elements:[],_next:void 0}),r._elements.push(t),n!==r&&(this._back=n,r._next=n),++this._size}shift(){let t=this._front,r=t,n=this._cursor,o=n+1,a=t._elements,i=a[n];return o===Rr&&(r=t._next,o=0),--this._size,this._cursor=o,t!==r&&(this._front=r),a[n]=void 0,i}forEach(t){let r=this._cursor,n=this._front,o=n._elements;for(;(r!==o.length||n._next!==void 0)&&!(r===o.length&&(n=n._next,o=n._elements,r=0,o.length===0));)t(o[r]),++r}peek(){let t=this._front,r=this._cursor;return t._elements[r]}}let wr=Symbol("[[AbortSteps]]"),Cr=Symbol("[[ErrorSteps]]"),qt=Symbol("[[CancelSteps]]"),At=Symbol("[[PullSteps]]"),Wt=Symbol("[[ReleaseSteps]]");function Tr(e,t){e._ownerReadableStream=t,t._reader=e,t._state==="readable"?kt(e):t._state==="closed"?eo(e):Pr(e,t._storedError)}function Bt(e,t){let r=e._ownerReadableStream;return D(r,t)}function Y(e){let t=e._ownerReadableStream;t._state==="readable"?Ot(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):to(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),t._readableStreamController[Wt](),t._reader=void 0,e._ownerReadableStream=void 0}function He(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function kt(e){e._closedPromise=P((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function Pr(e,t){kt(e),Ot(e,t)}function eo(e){kt(e),vr(e)}function Ot(e,t){e._closedPromise_reject!==void 0&&(Ce(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function to(e,t){Pr(e,t)}function vr(e){e._closedPromise_resolve!==void 0&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}let Er=Number.isFinite||function(e){return typeof e=="number"&&isFinite(e)},ro=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function no(e){return typeof e=="object"||typeof e=="function"}function $(e,t){if(e!==void 0&&!no(e))throw new TypeError(`${t} is not an object.`)}function O(e,t){if(typeof e!="function")throw new TypeError(`${t} is not a function.`)}function oo(e){return typeof e=="object"&&e!==null||typeof e=="function"}function qr(e,t){if(!oo(e))throw new TypeError(`${t} is not an object.`)}function V(e,t,r){if(e===void 0)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function Ft(e,t,r){if(e===void 0)throw new TypeError(`${t} is required in '${r}'.`)}function zt(e){return Number(e)}function Ar(e){return e===0?0:e}function ao(e){return Ar(ro(e))}function It(e,t){let n=Number.MAX_SAFE_INTEGER,o=Number(e);if(o=Ar(o),!Er(o))throw new TypeError(`${t} is not a finite number`);if(o=ao(o),o<0||o>n)throw new TypeError(`${t} is outside the accepted range of 0 to ${n}, inclusive`);return!Er(o)||o===0?0:o}function jt(e,t){if(!ie(e))throw new TypeError(`${t} is not a ReadableStream.`)}function Te(e){return new ee(e)}function Wr(e,t){e._reader._readRequests.push(t)}function Dt(e,t,r){let o=e._reader._readRequests.shift();r?o._closeSteps():o._chunkSteps(t)}function Ge(e){return e._reader._readRequests.length}function Br(e){let t=e._reader;return!(t===void 0||!te(t))}class ee{constructor(t){if(V(t,1,"ReadableStreamDefaultReader"),jt(t,"First parameter"),se(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Tr(this,t),this._readRequests=new k}get closed(){return te(this)?this._closedPromise:c(xe("closed"))}cancel(t=void 0){return te(this)?this._ownerReadableStream===void 0?c(He("cancel")):Bt(this,t):c(xe("cancel"))}read(){if(!te(this))return c(xe("read"));if(this._ownerReadableStream===void 0)return c(He("read from"));let t,r,n=P((a,i)=>{t=a,r=i});return Ie(this,{_chunkSteps:a=>t({value:a,done:!1}),_closeSteps:()=>t({value:void 0,done:!0}),_errorSteps:a=>r(a)}),n}releaseLock(){if(!te(this))throw xe("releaseLock");this._ownerReadableStream!==void 0&&io(this)}}Object.defineProperties(ee.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),f(ee.prototype.cancel,"cancel"),f(ee.prototype.read,"read"),f(ee.prototype.releaseLock,"releaseLock"),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(ee.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});function te(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_readRequests")?!1:e instanceof ee}function Ie(e,t){let r=e._ownerReadableStream;r._disturbed=!0,r._state==="closed"?t._closeSteps():r._state==="errored"?t._errorSteps(r._storedError):r._readableStreamController[At](t)}function io(e){Y(e);let t=new TypeError("Reader was released");kr(e,t)}function kr(e,t){let r=e._readRequests;e._readRequests=new k,r.forEach(n=>{n._errorSteps(t)})}function xe(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}let so=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);class Or{constructor(t,r){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=t,this._preventCancel=r}next(){let t=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?U(this._ongoingPromise,t,t):t(),this._ongoingPromise}return(t){let r=()=>this._returnSteps(t);return this._ongoingPromise?U(this._ongoingPromise,r,r):r()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});let t=this._reader,r,n,o=P((i,u)=>{r=i,n=u});return Ie(t,{_chunkSteps:i=>{this._ongoingPromise=void 0,de(()=>r({value:i,done:!1}))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,Y(t),r({value:void 0,done:!0})},_errorSteps:i=>{this._ongoingPromise=void 0,this._isFinished=!0,Y(t),n(i)}}),o}_returnSteps(t){if(this._isFinished)return Promise.resolve({value:t,done:!0});this._isFinished=!0;let r=this._reader;if(!this._preventCancel){let n=Bt(r,t);return Y(r),U(n,()=>({value:t,done:!0}))}return Y(r),S({value:t,done:!0})}}let Fr={next(){return zr(this)?this._asyncIteratorImpl.next():c(Ir("next"))},return(e){return zr(this)?this._asyncIteratorImpl.return(e):c(Ir("return"))}};Object.setPrototypeOf(Fr,so);function lo(e,t){let r=Te(e),n=new Or(r,t),o=Object.create(Fr);return o._asyncIteratorImpl=n,o}function zr(e){if(!l(e)||!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof Or}catch{return!1}}function Ir(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}let jr=Number.isNaN||function(e){return e!==e};var Mt,Lt,$t;function je(e){return e.slice()}function Dr(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}let H=e=>(typeof e.transfer=="function"?H=t=>t.transfer():typeof structuredClone=="function"?H=t=>structuredClone(t,{transfer:[t]}):H=t=>t,H(e)),re=e=>(typeof e.detached=="boolean"?re=t=>t.detached:re=t=>t.byteLength===0,re(e));function Mr(e,t,r){if(e.slice)return e.slice(t,r);let n=r-t,o=new ArrayBuffer(n);return Dr(o,0,e,t,n),o}function Ze(e,t){let r=e[t];if(r!=null){if(typeof r!="function")throw new TypeError(`${String(t)} is not a function`);return r}}function uo(e){let t={[Symbol.iterator]:()=>e.iterator},r=async function*(){return yield*t}(),n=r.next;return{iterator:r,nextMethod:n,done:!1}}let Nt=($t=(Mt=Symbol.asyncIterator)!==null&&Mt!==void 0?Mt:(Lt=Symbol.for)===null||Lt===void 0?void 0:Lt.call(Symbol,"Symbol.asyncIterator"))!==null&&$t!==void 0?$t:"@@asyncIterator";function Lr(e,t="sync",r){if(r===void 0)if(t==="async"){if(r=Ze(e,Nt),r===void 0){let a=Ze(e,Symbol.iterator),i=Lr(e,"sync",a);return uo(i)}}else r=Ze(e,Symbol.iterator);if(r===void 0)throw new TypeError("The object is not iterable");let n=ce(r,e,[]);if(!l(n))throw new TypeError("The iterator method must return an object");let o=n.next;return{iterator:n,nextMethod:o,done:!1}}function fo(e){let t=ce(e.nextMethod,e.iterator,[]);if(!l(t))throw new TypeError("The iterator.next() method must return an object");return t}function co(e){return!!e.done}function ho(e){return e.value}function bo(e){return!(typeof e!="number"||jr(e)||e<0)}function $r(e){let t=Mr(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function Qt(e){let t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Ut(e,t,r){if(!bo(r)||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function mo(e){return e._queue.peek().value}function ne(e){e._queue=new k,e._queueTotalSize=0}function Nr(e){return e===DataView}function po(e){return Nr(e.constructor)}function yo(e){return Nr(e)?1:e.BYTES_PER_ELEMENT}class he{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!Yt(this))throw Zt("view");return this._view}respond(t){if(!Yt(this))throw Zt("respond");if(V(t,1,"respond"),t=It(t,"First parameter"),this._associatedReadableByteStreamController===void 0)throw new TypeError("This BYOB request has been invalidated");if(re(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");et(this._associatedReadableByteStreamController,t)}respondWithNewView(t){if(!Yt(this))throw Zt("respondWithNewView");if(V(t,1,"respondWithNewView"),!ArrayBuffer.isView(t))throw new TypeError("You can only respond with array buffer views");if(this._associatedReadableByteStreamController===void 0)throw new TypeError("This BYOB request has been invalidated");if(re(t.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");tt(this._associatedReadableByteStreamController,t)}}Object.defineProperties(he.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),f(he.prototype.respond,"respond"),f(he.prototype.respondWithNewView,"respondWithNewView"),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(he.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class G{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!be(this))throw Me("byobRequest");return xt(this)}get desiredSize(){if(!be(this))throw Me("desiredSize");return Jr(this)}close(){if(!be(this))throw Me("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");let t=this._controlledReadableByteStream._state;if(t!=="readable")throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be closed`);De(this)}enqueue(t){if(!be(this))throw Me("enqueue");if(V(t,1,"enqueue"),!ArrayBuffer.isView(t))throw new TypeError("chunk must be an array buffer view");if(t.byteLength===0)throw new TypeError("chunk must have non-zero byteLength");if(t.buffer.byteLength===0)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");let r=this._controlledReadableByteStream._state;if(r!=="readable")throw new TypeError(`The stream (in ${r} state) is not in the readable state and cannot be enqueued to`);Ke(this,t)}error(t=void 0){if(!be(this))throw Me("error");F(this,t)}[qt](t){Qr(this),ne(this);let r=this._cancelAlgorithm(t);return Je(this),r}[At](t){let r=this._controlledReadableByteStream;if(this._queueTotalSize>0){Xr(this,t);return}let n=this._autoAllocateChunkSize;if(n!==void 0){let o;try{o=new ArrayBuffer(n)}catch(i){t._errorSteps(i);return}let a={buffer:o,bufferByteLength:n,byteOffset:0,byteLength:n,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(a)}Wr(r,t),me(this)}[Wt](){if(this._pendingPullIntos.length>0){let t=this._pendingPullIntos.peek();t.readerType="none",this._pendingPullIntos=new k,this._pendingPullIntos.push(t)}}}Object.defineProperties(G.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),f(G.prototype.close,"close"),f(G.prototype.enqueue,"enqueue"),f(G.prototype.error,"error"),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(G.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});function be(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")?!1:e instanceof G}function Yt(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")?!1:e instanceof he}function me(e){if(!wo(e))return;if(e._pulling){e._pullAgain=!0;return}e._pulling=!0;let r=e._pullAlgorithm();v(r,()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,me(e)),null),n=>(F(e,n),null))}function Qr(e){Ht(e),e._pendingPullIntos=new k}function Vt(e,t){let r=!1;e._state==="closed"&&(r=!0);let n=Ur(t);t.readerType==="default"?Dt(e,n,r):qo(e,n,r)}function Ur(e){let t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function Xe(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function Yr(e,t,r,n){let o;try{o=Mr(t,r,r+n)}catch(a){throw F(e,a),a}Xe(e,o,0,n)}function Vr(e,t){t.bytesFilled>0&&Yr(e,t.buffer,t.byteOffset,t.bytesFilled),Pe(e)}function Hr(e,t){let r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),n=t.bytesFilled+r,o=r,a=!1,i=n%t.elementSize,u=n-i;u>=t.minimumFill&&(o=u-t.bytesFilled,a=!0);let p=e._queue;for(;o>0;){let h=p.peek(),y=Math.min(o,h.byteLength),_=t.byteOffset+t.bytesFilled;Dr(t.buffer,_,h.buffer,h.byteOffset,y),h.byteLength===y?p.shift():(h.byteOffset+=y,h.byteLength-=y),e._queueTotalSize-=y,Gr(e,y,t),o-=y}return a}function Gr(e,t,r){r.bytesFilled+=t}function xr(e){e._queueTotalSize===0&&e._closeRequested?(Je(e),Ye(e._controlledReadableByteStream)):me(e)}function Ht(e){e._byobRequest!==null&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Gt(e){for(;e._pendingPullIntos.length>0;){if(e._queueTotalSize===0)return;let t=e._pendingPullIntos.peek();Hr(e,t)&&(Pe(e),Vt(e._controlledReadableByteStream,t))}}function _o(e){let t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(e._queueTotalSize===0)return;let r=t._readRequests.shift();Xr(e,r)}}function So(e,t,r,n){let o=e._controlledReadableByteStream,a=t.constructor,i=yo(a),{byteOffset:u,byteLength:p}=t,h=r*i,y;try{y=H(t.buffer)}catch(w){n._errorSteps(w);return}let _={buffer:y,bufferByteLength:y.byteLength,byteOffset:u,byteLength:p,bytesFilled:0,minimumFill:h,elementSize:i,viewConstructor:a,readerType:"byob"};if(e._pendingPullIntos.length>0){e._pendingPullIntos.push(_),tn(o,n);return}if(o._state==="closed"){let w=new a(_.buffer,_.byteOffset,0);n._closeSteps(w);return}if(e._queueTotalSize>0){if(Hr(e,_)){let w=Ur(_);xr(e),n._chunkSteps(w);return}if(e._closeRequested){let w=new TypeError("Insufficient bytes to fill elements in the given buffer");F(e,w),n._errorSteps(w);return}}e._pendingPullIntos.push(_),tn(o,n),me(e)}function go(e,t){t.readerType==="none"&&Pe(e);let r=e._controlledReadableByteStream;if(Xt(r))for(;rn(r)>0;){let n=Pe(e);Vt(r,n)}}function Ro(e,t,r){if(Gr(e,t,r),r.readerType==="none"){Vr(e,r),Gt(e);return}if(r.bytesFilled<r.minimumFill)return;Pe(e);let n=r.bytesFilled%r.elementSize;if(n>0){let o=r.byteOffset+r.bytesFilled;Yr(e,r.buffer,o-n,n)}r.bytesFilled-=n,Vt(e._controlledReadableByteStream,r),Gt(e)}function Zr(e,t){let r=e._pendingPullIntos.peek();Ht(e),e._controlledReadableByteStream._state==="closed"?go(e,r):Ro(e,t,r),me(e)}function Pe(e){return e._pendingPullIntos.shift()}function wo(e){let t=e._controlledReadableByteStream;return t._state!=="readable"||e._closeRequested||!e._started?!1:!!(Br(t)&&Ge(t)>0||Xt(t)&&rn(t)>0||Jr(e)>0)}function Je(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function De(e){let t=e._controlledReadableByteStream;if(!(e._closeRequested||t._state!=="readable")){if(e._queueTotalSize>0){e._closeRequested=!0;return}if(e._pendingPullIntos.length>0){let r=e._pendingPullIntos.peek();if(r.bytesFilled%r.elementSize!==0){let n=new TypeError("Insufficient bytes to fill elements in the given buffer");throw F(e,n),n}}Je(e),Ye(t)}}function Ke(e,t){let r=e._controlledReadableByteStream;if(e._closeRequested||r._state!=="readable")return;let{buffer:n,byteOffset:o,byteLength:a}=t;if(re(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");let i=H(n);if(e._pendingPullIntos.length>0){let u=e._pendingPullIntos.peek();if(re(u.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Ht(e),u.buffer=H(u.buffer),u.readerType==="none"&&Vr(e,u)}if(Br(r))if(_o(e),Ge(r)===0)Xe(e,i,o,a);else{e._pendingPullIntos.length>0&&Pe(e);let u=new Uint8Array(i,o,a);Dt(r,u,!1)}else Xt(r)?(Xe(e,i,o,a),Gt(e)):Xe(e,i,o,a);me(e)}function F(e,t){let r=e._controlledReadableByteStream;r._state==="readable"&&(Qr(e),ne(e),Je(e),En(r,t))}function Xr(e,t){let r=e._queue.shift();e._queueTotalSize-=r.byteLength,xr(e);let n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function xt(e){if(e._byobRequest===null&&e._pendingPullIntos.length>0){let t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),n=Object.create(he.prototype);To(n,e,r),e._byobRequest=n}return e._byobRequest}function Jr(e){let t=e._controlledReadableByteStream._state;return t==="errored"?null:t==="closed"?0:e._strategyHWM-e._queueTotalSize}function et(e,t){let r=e._pendingPullIntos.peek();if(e._controlledReadableByteStream._state==="closed"){if(t!==0)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(t===0)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=H(r.buffer),Zr(e,t)}function tt(e,t){let r=e._pendingPullIntos.peek();if(e._controlledReadableByteStream._state==="closed"){if(t.byteLength!==0)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(t.byteLength===0)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");let o=t.byteLength;r.buffer=H(t.buffer),Zr(e,o)}function Kr(e,t,r,n,o,a,i){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,ne(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=a,t._pullAlgorithm=n,t._cancelAlgorithm=o,t._autoAllocateChunkSize=i,t._pendingPullIntos=new k,e._readableStreamController=t;let u=r();v(S(u),()=>(t._started=!0,me(t),null),p=>(F(t,p),null))}function Co(e,t,r){let n=Object.create(G.prototype),o,a,i;t.start!==void 0?o=()=>t.start(n):o=()=>{},t.pull!==void 0?a=()=>t.pull(n):a=()=>S(void 0),t.cancel!==void 0?i=p=>t.cancel(p):i=()=>S(void 0);let u=t.autoAllocateChunkSize;if(u===0)throw new TypeError("autoAllocateChunkSize must be greater than 0");Kr(e,n,o,a,i,r,u)}function To(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}function Zt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Me(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function Po(e,t){$(e,t);let r=e?.mode;return{mode:r===void 0?void 0:vo(r,`${t} has member 'mode' that`)}}function vo(e,t){if(e=`${e}`,e!=="byob")throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function Eo(e,t){var r;$(e,t);let n=(r=e?.min)!==null&&r!==void 0?r:1;return{min:It(n,`${t} has member 'min' that`)}}function en(e){return new oe(e)}function tn(e,t){e._reader._readIntoRequests.push(t)}function qo(e,t,r){let o=e._reader._readIntoRequests.shift();r?o._closeSteps(t):o._chunkSteps(t)}function rn(e){return e._reader._readIntoRequests.length}function Xt(e){let t=e._reader;return!(t===void 0||!pe(t))}class oe{constructor(t){if(V(t,1,"ReadableStreamBYOBReader"),jt(t,"First parameter"),se(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!be(t._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");Tr(this,t),this._readIntoRequests=new k}get closed(){return pe(this)?this._closedPromise:c(rt("closed"))}cancel(t=void 0){return pe(this)?this._ownerReadableStream===void 0?c(He("cancel")):Bt(this,t):c(rt("cancel"))}read(t,r={}){if(!pe(this))return c(rt("read"));if(!ArrayBuffer.isView(t))return c(new TypeError("view must be an array buffer view"));if(t.byteLength===0)return c(new TypeError("view must have non-zero byteLength"));if(t.buffer.byteLength===0)return c(new TypeError("view's buffer must have non-zero byteLength"));if(re(t.buffer))return c(new TypeError("view's buffer has been detached"));let n;try{n=Eo(r,"options")}catch(h){return c(h)}let o=n.min;if(o===0)return c(new TypeError("options.min must be greater than 0"));if(po(t)){if(o>t.byteLength)return c(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(o>t.length)return c(new RangeError("options.min must be less than or equal to view's length"));if(this._ownerReadableStream===void 0)return c(He("read from"));let a,i,u=P((h,y)=>{a=h,i=y});return nn(this,t,o,{_chunkSteps:h=>a({value:h,done:!1}),_closeSteps:h=>a({value:h,done:!0}),_errorSteps:h=>i(h)}),u}releaseLock(){if(!pe(this))throw rt("releaseLock");this._ownerReadableStream!==void 0&&Ao(this)}}Object.defineProperties(oe.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),f(oe.prototype.cancel,"cancel"),f(oe.prototype.read,"read"),f(oe.prototype.releaseLock,"releaseLock"),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(oe.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});function pe(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")?!1:e instanceof oe}function nn(e,t,r,n){let o=e._ownerReadableStream;o._disturbed=!0,o._state==="errored"?n._errorSteps(o._storedError):So(o._readableStreamController,t,r,n)}function Ao(e){Y(e);let t=new TypeError("Reader was released");on(e,t)}function on(e,t){let r=e._readIntoRequests;e._readIntoRequests=new k,r.forEach(n=>{n._errorSteps(t)})}function rt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function Le(e,t){let{highWaterMark:r}=e;if(r===void 0)return t;if(jr(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function nt(e){let{size:t}=e;return t||(()=>1)}function ot(e,t){$(e,t);let r=e?.highWaterMark,n=e?.size;return{highWaterMark:r===void 0?void 0:zt(r),size:n===void 0?void 0:Wo(n,`${t} has member 'size' that`)}}function Wo(e,t){return O(e,t),r=>zt(e(r))}function Bo(e,t){$(e,t);let r=e?.abort,n=e?.close,o=e?.start,a=e?.type,i=e?.write;return{abort:r===void 0?void 0:ko(r,e,`${t} has member 'abort' that`),close:n===void 0?void 0:Oo(n,e,`${t} has member 'close' that`),start:o===void 0?void 0:Fo(o,e,`${t} has member 'start' that`),write:i===void 0?void 0:zo(i,e,`${t} has member 'write' that`),type:a}}function ko(e,t,r){return O(e,r),n=>K(e,t,[n])}function Oo(e,t,r){return O(e,r),()=>K(e,t,[])}function Fo(e,t,r){return O(e,r),n=>ce(e,t,[n])}function zo(e,t,r){return O(e,r),(n,o)=>K(e,t,[n,o])}function an(e,t){if(!ve(e))throw new TypeError(`${t} is not a WritableStream.`)}function Io(e){if(typeof e!="object"||e===null)return!1;try{return typeof e.aborted=="boolean"}catch{return!1}}let jo=typeof AbortController=="function";function Do(){if(jo)return new AbortController}class ae{constructor(t={},r={}){t===void 0?t=null:qr(t,"First parameter");let n=ot(r,"Second parameter"),o=Bo(t,"First parameter");if(ln(this),o.type!==void 0)throw new RangeError("Invalid type is specified");let i=nt(n),u=Le(n,1);Jo(this,o,u,i)}get locked(){if(!ve(this))throw ut("locked");return Ee(this)}abort(t=void 0){return ve(this)?Ee(this)?c(new TypeError("Cannot abort a stream that already has a writer")):at(this,t):c(ut("abort"))}close(){return ve(this)?Ee(this)?c(new TypeError("Cannot close a stream that already has a writer")):N(this)?c(new TypeError("Cannot close an already-closing stream")):un(this):c(ut("close"))}getWriter(){if(!ve(this))throw ut("getWriter");return sn(this)}}Object.defineProperties(ae.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),f(ae.prototype.abort,"abort"),f(ae.prototype.close,"close"),f(ae.prototype.getWriter,"getWriter"),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(ae.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});function sn(e){return new x(e)}function Mo(e,t,r,n,o=1,a=()=>1){let i=Object.create(ae.prototype);ln(i);let u=Object.create(qe.prototype);return mn(i,u,e,t,r,n,o,a),i}function ln(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new k,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function ve(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")?!1:e instanceof ae}function Ee(e){return e._writer!==void 0}function at(e,t){var r;if(e._state==="closed"||e._state==="errored")return S(void 0);e._writableStreamController._abortReason=t,(r=e._writableStreamController._abortController)===null||r===void 0||r.abort(t);let n=e._state;if(n==="closed"||n==="errored")return S(void 0);if(e._pendingAbortRequest!==void 0)return e._pendingAbortRequest._promise;let o=!1;n==="erroring"&&(o=!0,t=void 0);let a=P((i,u)=>{e._pendingAbortRequest={_promise:void 0,_resolve:i,_reject:u,_reason:t,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=a,o||Kt(e,t),a}function un(e){let t=e._state;if(t==="closed"||t==="errored")return c(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));let r=P((o,a)=>{let i={_resolve:o,_reject:a};e._closeRequest=i}),n=e._writer;return n!==void 0&&e._backpressure&&t==="writable"&&sr(n),Ko(e._writableStreamController),r}function Lo(e){return P((r,n)=>{let o={_resolve:r,_reject:n};e._writeRequests.push(o)})}function Jt(e,t){if(e._state==="writable"){Kt(e,t);return}er(e)}function Kt(e,t){let r=e._writableStreamController;e._state="erroring",e._storedError=t;let n=e._writer;n!==void 0&&dn(n,t),!Yo(e)&&r._started&&er(e)}function er(e){e._state="errored",e._writableStreamController[Cr]();let t=e._storedError;if(e._writeRequests.forEach(o=>{o._reject(t)}),e._writeRequests=new k,e._pendingAbortRequest===void 0){it(e);return}let r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring){r._reject(t),it(e);return}let n=e._writableStreamController[wr](r._reason);v(n,()=>(r._resolve(),it(e),null),o=>(r._reject(o),it(e),null))}function $o(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}function No(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,Jt(e,t)}function Qo(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,e._state==="erroring"&&(e._storedError=void 0,e._pendingAbortRequest!==void 0&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";let r=e._writer;r!==void 0&&Sn(r)}function Uo(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,e._pendingAbortRequest!==void 0&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),Jt(e,t)}function N(e){return!(e._closeRequest===void 0&&e._inFlightCloseRequest===void 0)}function Yo(e){return!(e._inFlightWriteRequest===void 0&&e._inFlightCloseRequest===void 0)}function Vo(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0}function Ho(e){e._inFlightWriteRequest=e._writeRequests.shift()}function it(e){e._closeRequest!==void 0&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);let t=e._writer;t!==void 0&&ar(t,e._storedError)}function tr(e,t){let r=e._writer;r!==void 0&&t!==e._backpressure&&(t?ia(r):sr(r)),e._backpressure=t}class x{constructor(t){if(V(t,1,"WritableStreamDefaultWriter"),an(t,"First parameter"),Ee(t))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=t,t._writer=this;let r=t._state;if(r==="writable")!N(t)&&t._backpressure?dt(this):gn(this),ft(this);else if(r==="erroring")ir(this,t._storedError),ft(this);else if(r==="closed")gn(this),oa(this);else{let n=t._storedError;ir(this,n),_n(this,n)}}get closed(){return ye(this)?this._closedPromise:c(_e("closed"))}get desiredSize(){if(!ye(this))throw _e("desiredSize");if(this._ownerWritableStream===void 0)throw Ne("desiredSize");return Xo(this)}get ready(){return ye(this)?this._readyPromise:c(_e("ready"))}abort(t=void 0){return ye(this)?this._ownerWritableStream===void 0?c(Ne("abort")):Go(this,t):c(_e("abort"))}close(){if(!ye(this))return c(_e("close"));let t=this._ownerWritableStream;return t===void 0?c(Ne("close")):N(t)?c(new TypeError("Cannot close an already-closing stream")):fn(this)}releaseLock(){if(!ye(this))throw _e("releaseLock");this._ownerWritableStream!==void 0&&cn(this)}write(t=void 0){return ye(this)?this._ownerWritableStream===void 0?c(Ne("write to")):hn(this,t):c(_e("write"))}}Object.defineProperties(x.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),f(x.prototype.abort,"abort"),f(x.prototype.close,"close"),f(x.prototype.releaseLock,"releaseLock"),f(x.prototype.write,"write"),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(x.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});function ye(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")?!1:e instanceof x}function Go(e,t){let r=e._ownerWritableStream;return at(r,t)}function fn(e){let t=e._ownerWritableStream;return un(t)}function xo(e){let t=e._ownerWritableStream,r=t._state;return N(t)||r==="closed"?S(void 0):r==="errored"?c(t._storedError):fn(e)}function Zo(e,t){e._closedPromiseState==="pending"?ar(e,t):aa(e,t)}function dn(e,t){e._readyPromiseState==="pending"?Rn(e,t):sa(e,t)}function Xo(e){let t=e._ownerWritableStream,r=t._state;return r==="errored"||r==="erroring"?null:r==="closed"?0:pn(t._writableStreamController)}function cn(e){let t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");dn(e,r),Zo(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function hn(e,t){let r=e._ownerWritableStream,n=r._writableStreamController,o=ea(n,t);if(r!==e._ownerWritableStream)return c(Ne("write to"));let a=r._state;if(a==="errored")return c(r._storedError);if(N(r)||a==="closed")return c(new TypeError("The stream is closing or closed and cannot be written to"));if(a==="erroring")return c(r._storedError);let i=Lo(r);return ta(n,t,o),i}let bn={};class qe{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!rr(this))throw or("abortReason");return this._abortReason}get signal(){if(!rr(this))throw or("signal");if(this._abortController===void 0)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(t=void 0){if(!rr(this))throw or("error");this._controlledWritableStream._state==="writable"&&yn(this,t)}[wr](t){let r=this._abortAlgorithm(t);return st(this),r}[Cr](){ne(this)}}Object.defineProperties(qe.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(qe.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});function rr(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")?!1:e instanceof qe}function mn(e,t,r,n,o,a,i,u){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,ne(t),t._abortReason=void 0,t._abortController=Do(),t._started=!1,t._strategySizeAlgorithm=u,t._strategyHWM=i,t._writeAlgorithm=n,t._closeAlgorithm=o,t._abortAlgorithm=a;let p=nr(t);tr(e,p);let h=r(),y=S(h);v(y,()=>(t._started=!0,lt(t),null),_=>(t._started=!0,Jt(e,_),null))}function Jo(e,t,r,n){let o=Object.create(qe.prototype),a,i,u,p;t.start!==void 0?a=()=>t.start(o):a=()=>{},t.write!==void 0?i=h=>t.write(h,o):i=()=>S(void 0),t.close!==void 0?u=()=>t.close():u=()=>S(void 0),t.abort!==void 0?p=h=>t.abort(h):p=()=>S(void 0),mn(e,o,a,i,u,p,r,n)}function st(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Ko(e){Ut(e,bn,0),lt(e)}function ea(e,t){try{return e._strategySizeAlgorithm(t)}catch(r){return $e(e,r),1}}function pn(e){return e._strategyHWM-e._queueTotalSize}function ta(e,t,r){try{Ut(e,t,r)}catch(o){$e(e,o);return}let n=e._controlledWritableStream;if(!N(n)&&n._state==="writable"){let o=nr(e);tr(n,o)}lt(e)}function lt(e){let t=e._controlledWritableStream;if(!e._started||t._inFlightWriteRequest!==void 0)return;if(t._state==="erroring"){er(t);return}if(e._queue.length===0)return;let n=mo(e);n===bn?ra(e):na(e,n)}function $e(e,t){e._controlledWritableStream._state==="writable"&&yn(e,t)}function ra(e){let t=e._controlledWritableStream;Vo(t),Qt(e);let r=e._closeAlgorithm();st(e),v(r,()=>(Qo(t),null),n=>(Uo(t,n),null))}function na(e,t){let r=e._controlledWritableStream;Ho(r);let n=e._writeAlgorithm(t);v(n,()=>{$o(r);let o=r._state;if(Qt(e),!N(r)&&o==="writable"){let a=nr(e);tr(r,a)}return lt(e),null},o=>(r._state==="writable"&&st(e),No(r,o),null))}function nr(e){return pn(e)<=0}function yn(e,t){let r=e._controlledWritableStream;st(e),Kt(r,t)}function ut(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function or(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function _e(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function Ne(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function ft(e){e._closedPromise=P((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function _n(e,t){ft(e),ar(e,t)}function oa(e){ft(e),Sn(e)}function ar(e,t){e._closedPromise_reject!==void 0&&(Ce(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function aa(e,t){_n(e,t)}function Sn(e){e._closedPromise_resolve!==void 0&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function dt(e){e._readyPromise=P((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function ir(e,t){dt(e),Rn(e,t)}function gn(e){dt(e),sr(e)}function Rn(e,t){e._readyPromise_reject!==void 0&&(Ce(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function ia(e){dt(e)}function sa(e,t){ir(e,t)}function sr(e){e._readyPromise_resolve!==void 0&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}function la(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis}let lr=la();function ua(e){if(!(typeof e=="function"||typeof e=="object")||e.name!=="DOMException")return!1;try{return new e,!0}catch{return!1}}function fa(){let e=lr?.DOMException;return ua(e)?e:void 0}function da(){let e=function(r,n){this.message=r||"",this.name=n||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return f(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}let ca=fa()||da();function wn(e,t,r,n,o,a){let i=Te(e),u=sn(t);e._disturbed=!0;let p=!1,h=S(void 0);return P((y,_)=>{let w;if(a!==void 0){if(w=()=>{let m=a.reason!==void 0?a.reason:new ca("Aborted","AbortError"),g=[];n||g.push(()=>t._state==="writable"?at(t,m):S(void 0)),o||g.push(()=>e._state==="readable"?D(e,m):S(void 0)),A(()=>Promise.all(g.map(T=>T())),!0,m)},a.aborted){w();return}a.addEventListener("abort",w)}function M(){return P((m,g)=>{function T(B){B?m():W(ke(),T,g)}T(!1)})}function ke(){return p?S(!0):W(u._readyPromise,()=>P((m,g)=>{Ie(i,{_chunkSteps:T=>{h=W(hn(u,T),void 0,s),m(!1)},_closeSteps:()=>m(!0),_errorSteps:g})}))}if(X(e,i._closedPromise,m=>(n?z(!0,m):A(()=>at(t,m),!0,m),null)),X(t,u._closedPromise,m=>(o?z(!0,m):A(()=>D(e,m),!0,m),null)),q(e,i._closedPromise,()=>(r?z():A(()=>xo(u)),null)),N(t)||t._state==="closed"){let m=new TypeError("the destination writable stream closed before all data could be piped to it");o?z(!0,m):A(()=>D(e,m),!0,m)}Ce(M());function ue(){let m=h;return W(h,()=>m!==h?ue():void 0)}function X(m,g,T){m._state==="errored"?T(m._storedError):Q(g,T)}function q(m,g,T){m._state==="closed"?T():L(g,T)}function A(m,g,T){if(p)return;p=!0,t._state==="writable"&&!N(t)?L(ue(),B):B();function B(){return v(m(),()=>J(g,T),Oe=>J(!0,Oe)),null}}function z(m,g){p||(p=!0,t._state==="writable"&&!N(t)?L(ue(),()=>J(m,g)):J(m,g))}function J(m,g){return cn(u),Y(i),a!==void 0&&a.removeEventListener("abort",w),m?_(g):y(void 0),null}})}class Z{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!ct(this))throw bt("desiredSize");return ur(this)}close(){if(!ct(this))throw bt("close");if(!We(this))throw new TypeError("The stream is not in a state that permits close");Se(this)}enqueue(t=void 0){if(!ct(this))throw bt("enqueue");if(!We(this))throw new TypeError("The stream is not in a state that permits enqueue");return Ae(this,t)}error(t=void 0){if(!ct(this))throw bt("error");j(this,t)}[qt](t){ne(this);let r=this._cancelAlgorithm(t);return ht(this),r}[At](t){let r=this._controlledReadableStream;if(this._queue.length>0){let n=Qt(this);this._closeRequested&&this._queue.length===0?(ht(this),Ye(r)):Qe(this),t._chunkSteps(n)}else Wr(r,t),Qe(this)}[Wt](){}}Object.defineProperties(Z.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),f(Z.prototype.close,"close"),f(Z.prototype.enqueue,"enqueue"),f(Z.prototype.error,"error"),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(Z.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});function ct(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")?!1:e instanceof Z}function Qe(e){if(!Cn(e))return;if(e._pulling){e._pullAgain=!0;return}e._pulling=!0;let r=e._pullAlgorithm();v(r,()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,Qe(e)),null),n=>(j(e,n),null))}function Cn(e){let t=e._controlledReadableStream;return!We(e)||!e._started?!1:!!(se(t)&&Ge(t)>0||ur(e)>0)}function ht(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Se(e){if(!We(e))return;let t=e._controlledReadableStream;e._closeRequested=!0,e._queue.length===0&&(ht(e),Ye(t))}function Ae(e,t){if(!We(e))return;let r=e._controlledReadableStream;if(se(r)&&Ge(r)>0)Dt(r,t,!1);else{let n;try{n=e._strategySizeAlgorithm(t)}catch(o){throw j(e,o),o}try{Ut(e,t,n)}catch(o){throw j(e,o),o}}Qe(e)}function j(e,t){let r=e._controlledReadableStream;r._state==="readable"&&(ne(e),ht(e),En(r,t))}function ur(e){let t=e._controlledReadableStream._state;return t==="errored"?null:t==="closed"?0:e._strategyHWM-e._queueTotalSize}function ha(e){return!Cn(e)}function We(e){let t=e._controlledReadableStream._state;return!e._closeRequested&&t==="readable"}function Tn(e,t,r,n,o,a,i){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,ne(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=i,t._strategyHWM=a,t._pullAlgorithm=n,t._cancelAlgorithm=o,e._readableStreamController=t;let u=r();v(S(u),()=>(t._started=!0,Qe(t),null),p=>(j(t,p),null))}function ba(e,t,r,n){let o=Object.create(Z.prototype),a,i,u;t.start!==void 0?a=()=>t.start(o):a=()=>{},t.pull!==void 0?i=()=>t.pull(o):i=()=>S(void 0),t.cancel!==void 0?u=p=>t.cancel(p):u=()=>S(void 0),Tn(e,o,a,i,u,r,n)}function bt(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function ma(e,t){return be(e._readableStreamController)?ya(e):pa(e)}function pa(e,t){let r=Te(e),n=!1,o=!1,a=!1,i=!1,u,p,h,y,_,w=P(q=>{_=q});function M(){return n?(o=!0,S(void 0)):(n=!0,Ie(r,{_chunkSteps:A=>{de(()=>{o=!1;let z=A,J=A;a||Ae(h._readableStreamController,z),i||Ae(y._readableStreamController,J),n=!1,o&&M()})},_closeSteps:()=>{n=!1,a||Se(h._readableStreamController),i||Se(y._readableStreamController),(!a||!i)&&_(void 0)},_errorSteps:()=>{n=!1}}),S(void 0))}function ke(q){if(a=!0,u=q,i){let A=je([u,p]),z=D(e,A);_(z)}return w}function ue(q){if(i=!0,p=q,a){let A=je([u,p]),z=D(e,A);_(z)}return w}function X(){}return h=Ue(X,M,ke),y=Ue(X,M,ue),Q(r._closedPromise,q=>(j(h._readableStreamController,q),j(y._readableStreamController,q),(!a||!i)&&_(void 0),null)),[h,y]}function ya(e){let t=Te(e),r=!1,n=!1,o=!1,a=!1,i=!1,u,p,h,y,_,w=P(m=>{_=m});function M(m){Q(m._closedPromise,g=>(m!==t||(F(h._readableStreamController,g),F(y._readableStreamController,g),(!a||!i)&&_(void 0)),null))}function ke(){pe(t)&&(Y(t),t=Te(e),M(t)),Ie(t,{_chunkSteps:g=>{de(()=>{n=!1,o=!1;let T=g,B=g;if(!a&&!i)try{B=$r(g)}catch(Oe){F(h._readableStreamController,Oe),F(y._readableStreamController,Oe),_(D(e,Oe));return}a||Ke(h._readableStreamController,T),i||Ke(y._readableStreamController,B),r=!1,n?X():o&&q()})},_closeSteps:()=>{r=!1,a||De(h._readableStreamController),i||De(y._readableStreamController),h._readableStreamController._pendingPullIntos.length>0&&et(h._readableStreamController,0),y._readableStreamController._pendingPullIntos.length>0&&et(y._readableStreamController,0),(!a||!i)&&_(void 0)},_errorSteps:()=>{r=!1}})}function ue(m,g){te(t)&&(Y(t),t=en(e),M(t));let T=g?y:h,B=g?h:y;nn(t,m,1,{_chunkSteps:Fe=>{de(()=>{n=!1,o=!1;let ze=g?i:a;if(g?a:i)ze||tt(T._readableStreamController,Fe);else{let Ln;try{Ln=$r(Fe)}catch(br){F(T._readableStreamController,br),F(B._readableStreamController,br),_(D(e,br));return}ze||tt(T._readableStreamController,Fe),Ke(B._readableStreamController,Ln)}r=!1,n?X():o&&q()})},_closeSteps:Fe=>{r=!1;let ze=g?i:a,wt=g?a:i;ze||De(T._readableStreamController),wt||De(B._readableStreamController),Fe!==void 0&&(ze||tt(T._readableStreamController,Fe),!wt&&B._readableStreamController._pendingPullIntos.length>0&&et(B._readableStreamController,0)),(!ze||!wt)&&_(void 0)},_errorSteps:()=>{r=!1}})}function X(){if(r)return n=!0,S(void 0);r=!0;let m=xt(h._readableStreamController);return m===null?ke():ue(m._view,!1),S(void 0)}function q(){if(r)return o=!0,S(void 0);r=!0;let m=xt(y._readableStreamController);return m===null?ke():ue(m._view,!0),S(void 0)}function A(m){if(a=!0,u=m,i){let g=je([u,p]),T=D(e,g);_(T)}return w}function z(m){if(i=!0,p=m,a){let g=je([u,p]),T=D(e,g);_(T)}return w}function J(){}return h=vn(J,X,A),y=vn(J,q,z),M(t),[h,y]}function _a(e){return l(e)&&typeof e.getReader<"u"}function Sa(e){return _a(e)?Ra(e.getReader()):ga(e)}function ga(e){let t,r=Lr(e,"async"),n=s;function o(){let i;try{i=fo(r)}catch(p){return c(p)}let u=S(i);return U(u,p=>{if(!l(p))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(co(p))Se(t._readableStreamController);else{let y=ho(p);Ae(t._readableStreamController,y)}})}function a(i){let u=r.iterator,p;try{p=Ze(u,"return")}catch(_){return c(_)}if(p===void 0)return S(void 0);let h;try{h=ce(p,u,[i])}catch(_){return c(_)}let y=S(h);return U(y,_=>{if(!l(_))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")})}return t=Ue(n,o,a,0),t}function Ra(e){let t,r=s;function n(){let a;try{a=e.read()}catch(i){return c(i)}return U(a,i=>{if(!l(i))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(i.done)Se(t._readableStreamController);else{let u=i.value;Ae(t._readableStreamController,u)}})}function o(a){try{return S(e.cancel(a))}catch(i){return c(i)}}return t=Ue(r,n,o,0),t}function wa(e,t){$(e,t);let r=e,n=r?.autoAllocateChunkSize,o=r?.cancel,a=r?.pull,i=r?.start,u=r?.type;return{autoAllocateChunkSize:n===void 0?void 0:It(n,`${t} has member 'autoAllocateChunkSize' that`),cancel:o===void 0?void 0:Ca(o,r,`${t} has member 'cancel' that`),pull:a===void 0?void 0:Ta(a,r,`${t} has member 'pull' that`),start:i===void 0?void 0:Pa(i,r,`${t} has member 'start' that`),type:u===void 0?void 0:va(u,`${t} has member 'type' that`)}}function Ca(e,t,r){return O(e,r),n=>K(e,t,[n])}function Ta(e,t,r){return O(e,r),n=>K(e,t,[n])}function Pa(e,t,r){return O(e,r),n=>ce(e,t,[n])}function va(e,t){if(e=`${e}`,e!=="bytes")throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function Ea(e,t){return $(e,t),{preventCancel:!!e?.preventCancel}}function Pn(e,t){$(e,t);let r=e?.preventAbort,n=e?.preventCancel,o=e?.preventClose,a=e?.signal;return a!==void 0&&qa(a,`${t} has member 'signal' that`),{preventAbort:!!r,preventCancel:!!n,preventClose:!!o,signal:a}}function qa(e,t){if(!Io(e))throw new TypeError(`${t} is not an AbortSignal.`)}function Aa(e,t){$(e,t);let r=e?.readable;Ft(r,"readable","ReadableWritablePair"),jt(r,`${t} has member 'readable' that`);let n=e?.writable;return Ft(n,"writable","ReadableWritablePair"),an(n,`${t} has member 'writable' that`),{readable:r,writable:n}}class E{constructor(t={},r={}){t===void 0?t=null:qr(t,"First parameter");let n=ot(r,"Second parameter"),o=wa(t,"First parameter");if(fr(this),o.type==="bytes"){if(n.size!==void 0)throw new RangeError("The strategy for a byte stream cannot have a size function");let a=Le(n,0);Co(this,o,a)}else{let a=nt(n),i=Le(n,1);ba(this,o,i,a)}}get locked(){if(!ie(this))throw ge("locked");return se(this)}cancel(t=void 0){return ie(this)?se(this)?c(new TypeError("Cannot cancel a stream that already has a reader")):D(this,t):c(ge("cancel"))}getReader(t=void 0){if(!ie(this))throw ge("getReader");return Po(t,"First parameter").mode===void 0?Te(this):en(this)}pipeThrough(t,r={}){if(!ie(this))throw ge("pipeThrough");V(t,1,"pipeThrough");let n=Aa(t,"First parameter"),o=Pn(r,"Second parameter");if(se(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Ee(n.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");let a=wn(this,n.writable,o.preventClose,o.preventAbort,o.preventCancel,o.signal);return Ce(a),n.readable}pipeTo(t,r={}){if(!ie(this))return c(ge("pipeTo"));if(t===void 0)return c("Parameter 1 is required in 'pipeTo'.");if(!ve(t))return c(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let n;try{n=Pn(r,"Second parameter")}catch(o){return c(o)}return se(this)?c(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Ee(t)?c(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):wn(this,t,n.preventClose,n.preventAbort,n.preventCancel,n.signal)}tee(){if(!ie(this))throw ge("tee");let t=ma(this);return je(t)}values(t=void 0){if(!ie(this))throw ge("values");let r=Ea(t,"First parameter");return lo(this,r.preventCancel)}[Nt](t){return this.values(t)}static from(t){return Sa(t)}}Object.defineProperties(E,{from:{enumerable:!0}}),Object.defineProperties(E.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),f(E.from,"from"),f(E.prototype.cancel,"cancel"),f(E.prototype.getReader,"getReader"),f(E.prototype.pipeThrough,"pipeThrough"),f(E.prototype.pipeTo,"pipeTo"),f(E.prototype.tee,"tee"),f(E.prototype.values,"values"),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(E.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(E.prototype,Nt,{value:E.prototype.values,writable:!0,configurable:!0});function Ue(e,t,r,n=1,o=()=>1){let a=Object.create(E.prototype);fr(a);let i=Object.create(Z.prototype);return Tn(a,i,e,t,r,n,o),a}function vn(e,t,r){let n=Object.create(E.prototype);fr(n);let o=Object.create(G.prototype);return Kr(n,o,e,t,r,0,void 0),n}function fr(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function ie(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")?!1:e instanceof E}function se(e){return e._reader!==void 0}function D(e,t){if(e._disturbed=!0,e._state==="closed")return S(void 0);if(e._state==="errored")return c(e._storedError);Ye(e);let r=e._reader;if(r!==void 0&&pe(r)){let o=r._readIntoRequests;r._readIntoRequests=new k,o.forEach(a=>{a._closeSteps(void 0)})}let n=e._readableStreamController[qt](t);return U(n,s)}function Ye(e){e._state="closed";let t=e._reader;if(t!==void 0&&(vr(t),te(t))){let r=t._readRequests;t._readRequests=new k,r.forEach(n=>{n._closeSteps()})}}function En(e,t){e._state="errored",e._storedError=t;let r=e._reader;r!==void 0&&(Ot(r,t),te(r)?kr(r,t):on(r,t))}function ge(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function qn(e,t){$(e,t);let r=e?.highWaterMark;return Ft(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:zt(r)}}let An=e=>e.byteLength;f(An,"size");class mt{constructor(t){V(t,1,"ByteLengthQueuingStrategy"),t=qn(t,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!Bn(this))throw Wn("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!Bn(this))throw Wn("size");return An}}Object.defineProperties(mt.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(mt.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});function Wn(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function Bn(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")?!1:e instanceof mt}let kn=()=>1;f(kn,"size");class pt{constructor(t){V(t,1,"CountQueuingStrategy"),t=qn(t,"First parameter"),this._countQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!Fn(this))throw On("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!Fn(this))throw On("size");return kn}}Object.defineProperties(pt.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(pt.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});function On(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function Fn(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")?!1:e instanceof pt}function Wa(e,t){$(e,t);let r=e?.cancel,n=e?.flush,o=e?.readableType,a=e?.start,i=e?.transform,u=e?.writableType;return{cancel:r===void 0?void 0:Fa(r,e,`${t} has member 'cancel' that`),flush:n===void 0?void 0:Ba(n,e,`${t} has member 'flush' that`),readableType:o,start:a===void 0?void 0:ka(a,e,`${t} has member 'start' that`),transform:i===void 0?void 0:Oa(i,e,`${t} has member 'transform' that`),writableType:u}}function Ba(e,t,r){return O(e,r),n=>K(e,t,[n])}function ka(e,t,r){return O(e,r),n=>ce(e,t,[n])}function Oa(e,t,r){return O(e,r),(n,o)=>K(e,t,[n,o])}function Fa(e,t,r){return O(e,r),n=>K(e,t,[n])}class yt{constructor(t={},r={},n={}){t===void 0&&(t=null);let o=ot(r,"Second parameter"),a=ot(n,"Third parameter"),i=Wa(t,"First parameter");if(i.readableType!==void 0)throw new RangeError("Invalid readableType specified");if(i.writableType!==void 0)throw new RangeError("Invalid writableType specified");let u=Le(a,0),p=nt(a),h=Le(o,1),y=nt(o),_,w=P(M=>{_=M});za(this,w,h,y,u,p),ja(this,i),i.start!==void 0?_(i.start(this._transformStreamController)):_(void 0)}get readable(){if(!zn(this))throw Mn("readable");return this._readable}get writable(){if(!zn(this))throw Mn("writable");return this._writable}}Object.defineProperties(yt.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(yt.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});function za(e,t,r,n,o,a){function i(){return t}function u(w){return La(e,w)}function p(w){return $a(e,w)}function h(){return Na(e)}e._writable=Mo(i,u,h,p,r,n);function y(){return Qa(e)}function _(w){return Ua(e,w)}e._readable=Ue(i,y,_,o,a),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,_t(e,!0),e._transformStreamController=void 0}function zn(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")?!1:e instanceof yt}function In(e,t){j(e._readable._readableStreamController,t),dr(e,t)}function dr(e,t){gt(e._transformStreamController),$e(e._writable._writableStreamController,t),cr(e)}function cr(e){e._backpressure&&_t(e,!1)}function _t(e,t){e._backpressureChangePromise!==void 0&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=P(r=>{e._backpressureChangePromise_resolve=r}),e._backpressure=t}class le{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!St(this))throw Rt("desiredSize");let t=this._controlledTransformStream._readable._readableStreamController;return ur(t)}enqueue(t=void 0){if(!St(this))throw Rt("enqueue");jn(this,t)}error(t=void 0){if(!St(this))throw Rt("error");Da(this,t)}terminate(){if(!St(this))throw Rt("terminate");Ma(this)}}Object.defineProperties(le.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),f(le.prototype.enqueue,"enqueue"),f(le.prototype.error,"error"),f(le.prototype.terminate,"terminate"),typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(le.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});function St(e){return!l(e)||!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")?!1:e instanceof le}function Ia(e,t,r,n,o){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n,t._cancelAlgorithm=o,t._finishPromise=void 0,t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0}function ja(e,t){let r=Object.create(le.prototype),n,o,a;t.transform!==void 0?n=i=>t.transform(i,r):n=i=>{try{return jn(r,i),S(void 0)}catch(u){return c(u)}},t.flush!==void 0?o=()=>t.flush(r):o=()=>S(void 0),t.cancel!==void 0?a=i=>t.cancel(i):a=()=>S(void 0),Ia(e,r,n,o,a)}function gt(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function jn(e,t){let r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!We(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{Ae(n,t)}catch(a){throw dr(r,a),r._readable._storedError}ha(n)!==r._backpressure&&_t(r,!0)}function Da(e,t){In(e._controlledTransformStream,t)}function Dn(e,t){let r=e._transformAlgorithm(t);return U(r,void 0,n=>{throw In(e._controlledTransformStream,n),n})}function Ma(e){let t=e._controlledTransformStream,r=t._readable._readableStreamController;Se(r);let n=new TypeError("TransformStream terminated");dr(t,n)}function La(e,t){let r=e._transformStreamController;if(e._backpressure){let n=e._backpressureChangePromise;return U(n,()=>{let o=e._writable;if(o._state==="erroring")throw o._storedError;return Dn(r,t)})}return Dn(r,t)}function $a(e,t){let r=e._transformStreamController;if(r._finishPromise!==void 0)return r._finishPromise;let n=e._readable;r._finishPromise=P((a,i)=>{r._finishPromise_resolve=a,r._finishPromise_reject=i});let o=r._cancelAlgorithm(t);return gt(r),v(o,()=>(n._state==="errored"?Be(r,n._storedError):(j(n._readableStreamController,t),hr(r)),null),a=>(j(n._readableStreamController,a),Be(r,a),null)),r._finishPromise}function Na(e){let t=e._transformStreamController;if(t._finishPromise!==void 0)return t._finishPromise;let r=e._readable;t._finishPromise=P((o,a)=>{t._finishPromise_resolve=o,t._finishPromise_reject=a});let n=t._flushAlgorithm();return gt(t),v(n,()=>(r._state==="errored"?Be(t,r._storedError):(Se(r._readableStreamController),hr(t)),null),o=>(j(r._readableStreamController,o),Be(t,o),null)),t._finishPromise}function Qa(e){return _t(e,!1),e._backpressureChangePromise}function Ua(e,t){let r=e._transformStreamController;if(r._finishPromise!==void 0)return r._finishPromise;let n=e._writable;r._finishPromise=P((a,i)=>{r._finishPromise_resolve=a,r._finishPromise_reject=i});let o=r._cancelAlgorithm(t);return gt(r),v(o,()=>(n._state==="errored"?Be(r,n._storedError):($e(n._writableStreamController,t),cr(e),hr(r)),null),a=>($e(n._writableStreamController,a),cr(e),Be(r,a),null)),r._finishPromise}function Rt(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function hr(e){e._finishPromise_resolve!==void 0&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function Be(e,t){e._finishPromise_reject!==void 0&&(Ce(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function Mn(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}d.ByteLengthQueuingStrategy=mt,d.CountQueuingStrategy=pt,d.ReadableByteStreamController=G,d.ReadableStream=E,d.ReadableStreamBYOBReader=oe,d.ReadableStreamBYOBRequest=he,d.ReadableStreamDefaultController=Z,d.ReadableStreamDefaultReader=ee,d.TransformStream=yt,d.TransformStreamDefaultController=le,d.WritableStream=ae,d.WritableStreamDefaultController=qe,d.WritableStreamDefaultWriter=x})});var Yn=$n(()=>{I();if(!globalThis.ReadableStream)try{let d=mr("node:process"),{emitWarning:s}=d;try{d.emitWarning=()=>{},Object.assign(globalThis,mr("node:stream/web")),d.emitWarning=s}catch(l){throw d.emitWarning=s,l}}catch{Object.assign(globalThis,Un())}try{let{Blob:d}=mr("buffer");d&&!d.prototype.stream&&(d.prototype.stream=function(l){let b=0,f=this;return new ReadableStream({type:"bytes",async pull(R){let fe=await f.slice(b,Math.min(f.size,b+65536)).arrayBuffer();b+=fe.byteLength,R.enqueue(new Uint8Array(fe)),b===f.size&&R.close()}})})}catch{}});async function*pr(d,s=!0){for(let l of d)if("stream"in l)yield*l.stream();else if(ArrayBuffer.isView(l))if(s){let b=l.byteOffset,f=l.byteOffset+l.byteLength;for(;b!==f;){let R=Math.min(f-b,Vn),C=l.buffer.slice(b,b+R);b+=C.byteLength,yield new Uint8Array(C)}}else yield l;else{let b=0,f=l;for(;b!==f.size;){let C=await f.slice(b,Math.min(f.size,b+Vn)).arrayBuffer();b+=C.byteLength,yield new Uint8Array(C)}}}var si,Vn,Hn,Va,Re,Pt=Ct(()=>{I();si=Nn(Yn(),1);Vn=65536;Hn=class yr{#e=[];#t="";#r=0;#n="transparent";constructor(s=[],l={}){if(typeof s!="object"||s===null)throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");if(typeof s[Symbol.iterator]!="function")throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");if(typeof l!="object"&&typeof l!="function")throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");l===null&&(l={});let b=new TextEncoder;for(let R of s){let C;ArrayBuffer.isView(R)?C=new Uint8Array(R.buffer.slice(R.byteOffset,R.byteOffset+R.byteLength)):R instanceof ArrayBuffer?C=new Uint8Array(R.slice(0)):R instanceof yr?C=R:C=b.encode(`${R}`),this.#r+=ArrayBuffer.isView(C)?C.byteLength:C.size,this.#e.push(C)}this.#n=`${l.endings===void 0?"transparent":l.endings}`;let f=l.type===void 0?"":String(l.type);this.#t=/^[\x20-\x7E]*$/.test(f)?f:""}get size(){return this.#r}get type(){return this.#t}async text(){let s=new TextDecoder,l="";for await(let b of pr(this.#e,!1))l+=s.decode(b,{stream:!0});return l+=s.decode(),l}async arrayBuffer(){let s=new Uint8Array(this.size),l=0;for await(let b of pr(this.#e,!1))s.set(b,l),l+=b.length;return s.buffer}stream(){let s=pr(this.#e,!0);return new globalThis.ReadableStream({type:"bytes",async pull(l){let b=await s.next();b.done?l.close():l.enqueue(b.value)},async cancel(){await s.return()}})}slice(s=0,l=this.size,b=""){let{size:f}=this,R=s<0?Math.max(f+s,0):Math.min(s,f),C=l<0?Math.max(f+l,0):Math.min(l,f),fe=Math.max(C-R,0),P=this.#e,S=[],c=0;for(let v of P){if(c>=fe)break;let L=ArrayBuffer.isView(v)?v.byteLength:v.size;if(R&&L<=R)R-=L,C-=L;else{let Q;ArrayBuffer.isView(v)?(Q=v.subarray(R,Math.min(L,C)),c+=Q.byteLength):(Q=v.slice(R,Math.min(L,C)),c+=Q.size),C-=L,S.push(Q),R=0}}let W=new yr([],{type:String(b).toLowerCase()});return W.#r=fe,W.#e=S,W}get[Symbol.toStringTag](){return"Blob"}static[Symbol.hasInstance](s){return s&&typeof s=="object"&&typeof s.constructor=="function"&&(typeof s.stream=="function"||typeof s.arrayBuffer=="function")&&/^(Blob|File)$/.test(s[Symbol.toStringTag])}};Object.defineProperties(Hn.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}});Va=Hn,Re=Va});var Ha,Ga,vt,_r=Ct(()=>{I();Pt();Ha=class extends Re{#e=0;#t="";constructor(s,l,b={}){if(arguments.length<2)throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);super(s,b),b===null&&(b={});let f=b.lastModified===void 0?Date.now():Number(b.lastModified);Number.isNaN(f)||(this.#e=f),this.#t=String(l)}get name(){return this.#t}get lastModified(){return this.#e}get[Symbol.toStringTag](){return"File"}static[Symbol.hasInstance](s){return!!s&&s instanceof Re&&/^(File)$/.test(s[Symbol.toStringTag])}},Ga=Ha,vt=Ga});function _i(d,s=Re){var l=`${Gn()}${Gn()}`.replace(/\./g,"").slice(-28).padStart(32,"-"),b=[],f=`--${l}\r
|
|
4
|
-
Content-Disposition: form-data; name="`;return d.forEach((R,C)=>typeof R=="string"?b.push(f+Sr(C)+`"\r
|
|
5
|
-
\r
|
|
6
|
-
${R.replace(/\r(?!\n)|(?<!\r)\n/g,`\r
|
|
7
|
-
`)}\r
|
|
8
|
-
`):b.push(f+Sr(C)+`"; filename="${Sr(R.name,1)}"\r
|
|
9
|
-
Content-Type: ${R.type||"application/octet-stream"}\r
|
|
10
|
-
\r
|
|
11
|
-
`,R,`\r
|
|
12
|
-
`)),b.push(`--${l}--`),new s(b,{type:"multipart/form-data; boundary="+l})}var Ve,xa,Za,Gn,Xa,xn,Sr,we,pi,Ja=Ct(()=>{I();Pt();_r();({toStringTag:Ve,iterator:xa,hasInstance:Za}=Symbol),Gn=Math.random,Xa="append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","),xn=(d,s,l)=>(d+="",/^(Blob|File)$/.test(s&&s[Ve])?[(l=l!==void 0?l+"":s[Ve]=="File"?s.name:"blob",d),s.name!==l||s[Ve]=="blob"?new vt([s],l,s):s]:[d,s+""]),Sr=(d,s)=>(s?d:d.replace(/\r?\n|\r/g,`\r
|
|
13
|
-
`)).replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22"),we=(d,s,l)=>{if(s.length<l)throw new TypeError(`Failed to execute '${d}' on 'FormData': ${l} arguments required, but only ${s.length} present.`)},pi=class{#e=[];constructor(...s){if(s.length)throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.")}get[Ve](){return"FormData"}[xa](){return this.entries()}static[Za](s){return s&&typeof s=="object"&&s[Ve]==="FormData"&&!Xa.some(l=>typeof s[l]!="function")}append(...s){we("append",arguments,2),this.#e.push(xn(...s))}delete(s){we("delete",arguments,1),s+="",this.#e=this.#e.filter(([l])=>l!==s)}get(s){we("get",arguments,1),s+="";for(var l=this.#e,b=l.length,f=0;f<b;f++)if(l[f][0]===s)return l[f][1];return null}getAll(s,l){return we("getAll",arguments,1),l=[],s+="",this.#e.forEach(b=>b[0]===s&&l.push(b[1])),l}has(s){return we("has",arguments,1),s+="",this.#e.some(l=>l[0]===s)}forEach(s,l){we("forEach",arguments,1);for(var[b,f]of this)s.call(l,f,b,this)}set(...s){we("set",arguments,2);var l=[],b=!0;s=xn(...s),this.#e.forEach(f=>{f[0]===s[0]?b&&(b=!l.push(s)):l.push(f)}),b&&l.push(s),this.#e=l}*entries(){yield*this.#e}*keys(){for(var[s]of this)yield s}*values(){for(var[,s]of this)yield s}}});import{statSync as Zn,createReadStream as Ka,promises as ei}from"node:fs";import{basename as ti}from"node:path";var Xn,gr,Pi,vi,Ei,qi,Jn,Kn,Et,ri=Ct(()=>{I();Xn=Nn(Ya(),1);_r();Pt();({stat:gr}=ei),Pi=(d,s)=>Jn(Zn(d),d,s),vi=(d,s)=>gr(d).then(l=>Jn(l,d,s)),Ei=(d,s)=>gr(d).then(l=>Kn(l,d,s)),qi=(d,s)=>Kn(Zn(d),d,s),Jn=(d,s,l="")=>new Re([new Et({path:s,size:d.size,lastModified:d.mtimeMs,start:0})],{type:l}),Kn=(d,s,l="")=>new vt([new Et({path:s,size:d.size,lastModified:d.mtimeMs,start:0})],ti(s),{type:l,lastModified:d.mtimeMs}),Et=class d{#e;#t;constructor(s){this.#e=s.path,this.#t=s.start,this.size=s.size,this.lastModified=s.lastModified}slice(s,l){return new d({path:this.#e,lastModified:this.lastModified,size:l-s,start:this.#t+s})}async*stream(){let{mtimeMs:s}=await gr(this.#e);if(s>this.lastModified)throw new Xn.default("The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.","NotReadableError");yield*Ka(this.#e,{start:this.#t,end:this.#t+this.size-1})}get[Symbol.toStringTag](){return"Blob"}}});export{Re as a,Pt as b,vt as c,pi as d,_i as e,Ja as f,Pi as g,vi as h,Ei as i,qi as j,ri as k};
|
|
14
|
-
/*! Bundled license information:
|
|
15
|
-
|
|
16
|
-
web-streams-polyfill/dist/ponyfill.es2018.js:
|
|
17
|
-
(**
|
|
18
|
-
* @license
|
|
19
|
-
* web-streams-polyfill v3.3.3
|
|
20
|
-
* Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
|
|
21
|
-
* This code is released under the MIT license.
|
|
22
|
-
* SPDX-License-Identifier: MIT
|
|
23
|
-
*)
|
|
24
|
-
|
|
25
|
-
fetch-blob/index.js:
|
|
26
|
-
(*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
27
|
-
|
|
28
|
-
formdata-polyfill/esm.min.js:
|
|
29
|
-
(*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
30
|
-
*/
|
package/chunks/chunk-W4QSMIWO.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import{e as g}from"./chunk-ZX34M2GF.js";import{b as h}from"./chunk-7ZODGQO6.js";import{b as M}from"./chunk-TISQNFB5.js";import{c as w}from"./chunk-LUNDTQ3G.js";import{b as c,ba as b}from"./chunk-27Q5KW3A.js";import{b as p}from"./chunk-GZPNIYVZ.js";import{f as E}from"./chunk-OWGSC52X.js";p();var m=null;function D(e){m=e}function _(){return m}function P(){m=null}function S(e,r,o){return m?(m.enqueueApproval({teammateName:e,teammateColor:r,details:o}),!0):!1}function $(e,r,o,t){return{...e,title:`[${r}] ${e.title}`,onConfirm:async(i,s)=>{await o(i,s)}}}p();var C=E(h(),1);import*as a from"node:fs/promises";import*as u from"node:path";var y=b("AGENTS_TEAM_MAILBOX"),N={retries:{retries:10,minTimeout:5,maxTimeout:100,factor:2,randomize:!0},stale:5e3,onCompromised:e=>{y.debug("mailbox lock compromised:",e?.message??e)}},d=new Map;function O(e){let r=d.get(e);return r||(r=new M,d.set(e,r)),r}function I(e){let r=g(e),o=0;for(let t of d.keys())u.dirname(t)===r&&(d.delete(t),o++);return o}async function T(e,r){return O(e).runExclusive(async()=>{let o=await C.default.lock(e,N);try{return await r()}finally{await o()}})}function x(e,r){return u.join(g(e),`${r}.json`)}async function X(e,r){let o=x(e,r);try{let t=await a.readFile(o,"utf-8");return JSON.parse(t)}catch(t){if(c(t)&&t.code==="ENOENT")return[];throw t}}var L=5*60*1e3;async function A(e,r,o){let t=x(e,r);await v(t),await T(t,async()=>{let i=await k(t),s=Date.now()-L,l=i.filter(f=>{if(!f.read)return!0;let n=Date.parse(f.timestamp);return Number.isNaN(n)||n>=s});l.push(o),await w(t,l)})}async function z(e,r,o){let t=x(e,r);return await v(t),T(t,async()=>{let i=await k(t),s=n=>!n.read&&(o===void 0||n.type===o),l=i.filter(s);if(l.length===0)return[];let f=i.map(n=>s(n)?{...n,read:!0}:n);return await w(t,f),l})}async function G(e,r){let o=x(e,r);try{await a.unlink(o)}catch(t){if(!c(t)||t.code!=="ENOENT")throw t}}async function K(e){let r=g(e);await a.rm(r,{recursive:!0,force:!0}),I(e)}async function Q(e,r,o){await A(e,r,{from:o.from,text:o.text,timestamp:new Date().toISOString(),read:!1,type:o.type,color:o.color,summary:o.summary})}async function v(e){await a.mkdir(u.dirname(e),{recursive:!0});try{await a.writeFile(e,`[]
|
|
4
|
-
`,{flag:"wx"})}catch(r){if(!c(r)||r.code!=="EEXIST")throw r}}async function k(e){try{let r=await a.readFile(e,"utf-8");return JSON.parse(r)}catch(r){if(c(r)&&r.code==="ENOENT")return[];let o=r instanceof Error?r.message:String(r);y.warn(`Quarantining corrupt inbox at ${e}: ${o}`);try{await a.rename(e,`${e}.corrupt-${Date.now()}`)}catch(t){let i=t instanceof Error?t.message:String(t);throw y.warn(`Failed to quarantine ${e}: ${i}`),r instanceof Error?r:new Error(`Failed to read inbox at ${e}: ${o}`)}return[]}}export{D as a,_ as b,P as c,S as d,$ as e,I as f,x as g,X as h,A as i,z as j,G as k,K as l,Q as m};
|
|
5
|
-
/**
|
|
6
|
-
* @license
|
|
7
|
-
* Copyright 2025 Matilda
|
|
8
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
*/
|
package/chunks/chunk-WC2VTVCE.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import{c as U}from"./chunk-KHHJYBR5.js";import{c as Q}from"./chunk-VI74YQQO.js";import{a as Y,b as N}from"./chunk-3YLXGE6T.js";import{b as X}from"./chunk-LUNDTQ3G.js";import{Q as S,ba as I}from"./chunk-27Q5KW3A.js";import{b as M}from"./chunk-GZPNIYVZ.js";M();import ie from"crypto";import q from"node:path";import{promises as b}from"node:fs";import{EventEmitter as Re}from"events";import{randomUUID as se}from"node:crypto";M();import{execFile as le,spawn as de}from"node:child_process";import{promisify as he}from"node:util";import{platform as ue}from"node:os";import{resolve as Z}from"node:path";import{URL as fe,fileURLToPath as me}from"node:url";var ee=he(le);function pe(i,{allowFile:e=!1,allowedFilePaths:r}={}){let t;try{t=new fe(i)}catch{throw new Error(`Invalid URL: ${i}`)}let o=e?["http:","https:","file:"]:["http:","https:"];if(!o.includes(t.protocol))throw new Error(`Unsafe protocol: ${t.protocol}. Only ${o.join(", ")} are allowed.`);if(t.protocol==="file:"&&e){if(!r?.length)throw new Error("allowedFilePaths is required when allowFile is true");let n=Z(me(t));if(!r.map(c=>Z(c)).includes(n))throw new Error("File URL is not in the allowed file set")}if(/[\r\n\x00-\x1f]/.test(i))throw new Error("URL contains invalid characters")}async function te(i,e={}){pe(i,e);let r=ue(),t,o,n=process.env.BROWSER?.trim(),s=r==="win32"?void 0:we(n,i);if(s)try{await re(s.command,s.args);return}catch(l){console.warn(`Failed to open BROWSER command ${s.command}: ${ge(l)}. Falling back to the platform browser opener.`)}if(!N({ignoreBrowserBlocklist:!0})){console.warn(`Browser launch is not available in this environment. Please open this URL manually: ${i}`);return}switch(r){case"darwin":t="open",o=[i];break;case"win32":t="powershell.exe",o=["-NoProfile","-NonInteractive","-WindowStyle","Hidden","-Command",`Start-Process '${i.replace(/'/g,"''")}'`];break;case"linux":case"freebsd":case"openbsd":t="xdg-open",o=[i];break;default:throw new Error(`Unsupported platform: ${r}`)}let c={env:{...process.env,SHELL:void 0},detached:!0,stdio:"ignore"};try{await ee(t,o,c)}catch{if((r==="linux"||r==="freebsd"||r==="openbsd")&&t==="xdg-open"){let a=[{command:"gnome-open",detached:!1},{command:"kde-open",detached:!1},{command:"firefox",detached:!0},{command:"chromium",detached:!0},{command:"google-chrome",detached:!0},{command:"microsoft-edge",detached:!0}];for(let{command:d,detached:p}of a)try{p?await re(d,[i]):await ee(d,[i],c);return}catch{continue}}console.warn(`Failed to open browser automatically. Please open this URL manually: ${i}`);return}}async function re(i,e){let r={env:{...process.env,SHELL:void 0},detached:!0,stdio:"ignore"};await new Promise((t,o)=>{let n=de(i,e,r),s=!1;n.once("error",c=>{s||(s=!0,o(c))}),n.once("spawn",()=>{s||(s=!0,n.unref(),t())})})}function ge(i){return i instanceof Error?i.message:String(i)}function we(i,e){if(!i)return;let r=ke(i);if(!r){console.warn("Invalid BROWSER environment variable, falling back to platform default.");return}if(Y(r.command))return;let t=!1,o=r.args.map(n=>n.includes("%s")?(t=!0,n.replace(/%s/g,()=>e)):n);return t||o.push(e),{command:r.command,args:o}}function ke(i){let e=[],r="",t;for(let s of i){if(t){s===t?t=void 0:r+=s;continue}if(s==='"'||s==="'"){t=s;continue}if(/\s/.test(s)){r&&(e.push(r),r="");continue}r+=s}if(t)return;r&&e.push(r);let[o,...n]=e;if(o)return{command:o,args:n}}function Ve(){return N()}M();import H from"node:path";import{promises as y,unlinkSync as Ee}from"node:fs";import{randomUUID as ne}from"node:crypto";var D=I("MATILDA_OAUTH"),_e="oauth_creds.json",Ce="oauth_creds.lock",ve=30*1e3,ye=35e3,Te=5e3,oe={maxAttempts:20,attemptInterval:100,maxInterval:2e3};var h=class extends Error{constructor(r,t,o){super(t);this.type=r;this.originalError=o;this.name="TokenManagerError"}};function De(i){if(!i||typeof i!="object")throw new Error("Invalid credentials format");let e=i,r=["access_token","refresh_token","token_type"];for(let t of r)if(!e[t]||typeof e[t]!="string")throw new Error(`Invalid credentials: missing ${t}`);if(!e.expiry_date||typeof e.expiry_date!="number")throw new Error("Invalid credentials: missing expiry_date");return e}var R=class i{static instance=null;memoryCache={credentials:null,fileModTime:0,lastCheck:0};refreshPromise=null;checkPromise=null;cleanupHandlersRegistered=!1;cleanupFunction=null;lockConfig=oe;constructor(){this.registerCleanupHandlers()}static getInstance(){return i.instance||(i.instance=new i),i.instance}registerCleanupHandlers(){this.cleanupHandlersRegistered||(this.cleanupFunction=()=>{try{let e=this.getLockFilePath();Ee(e)}catch{}},process.on("exit",this.cleanupFunction),this.cleanupHandlersRegistered=!0)}async getValidCredentials(e,r=!1){try{if(await this.checkAndReloadIfNeeded(e),!r&&this.memoryCache.credentials&&this.isTokenValid(this.memoryCache.credentials))return this.memoryCache.credentials;let t=this.refreshPromise;t||(t=this.performTokenRefresh(e,r),this.refreshPromise=t);try{return await t}finally{this.refreshPromise===t&&(this.refreshPromise=null)}}catch(t){throw t instanceof h?t:new h("REFRESH_FAILED",`Failed to get valid credentials: ${t instanceof Error?t.message:String(t)}`,t)}}async checkAndReloadIfNeeded(e){if(this.checkPromise){await this.checkPromise;return}if(this.refreshPromise)return;let r=Date.now();if(!(r-this.memoryCache.lastCheck<Te)){this.checkPromise=this.performFileCheck(e,r);try{await this.checkPromise}finally{this.checkPromise=null}}}withTimeout(e,r,t="Operation"){let o;return Promise.race([e.finally(()=>{o&&clearTimeout(o)}),new Promise((n,s)=>{o=setTimeout(()=>s(new Error(`${t} timed out after ${r}ms`)),r)})])}async performFileCheck(e,r){this.memoryCache.lastCheck=r;try{let t=this.getCredentialFilePath(),n=(await this.withTimeout(y.stat(t),3e3,"File operation")).mtimeMs;n>this.memoryCache.fileModTime&&(await this.reloadCredentialsFromFile(e),this.memoryCache.fileModTime=n)}catch(t){if(t instanceof Error&&"code"in t&&t.code!=="ENOENT")throw this.updateCacheState(null,0,r),new h("FILE_ACCESS_ERROR",`Failed to access credentials file: ${t.message}`,t);this.memoryCache.fileModTime=0}}async forceFileCheck(e){try{let r=this.getCredentialFilePath(),o=(await y.stat(r)).mtimeMs;o>this.memoryCache.fileModTime&&(await this.reloadCredentialsFromFile(e),this.memoryCache.fileModTime=o,this.memoryCache.lastCheck=Date.now())}catch(r){if(r instanceof Error&&"code"in r&&r.code!=="ENOENT")throw this.updateCacheState(null,0),new h("FILE_ACCESS_ERROR",`Failed to access credentials file during refresh: ${r.message}`,r);this.memoryCache.fileModTime=0}}async reloadCredentialsFromFile(e){try{let r=this.getCredentialFilePath(),t=await y.readFile(r,"utf-8"),o=JSON.parse(t),n=De(o),s=this.memoryCache.credentials;this.memoryCache.credentials=n;try{e&&e.setCredentials(n)}catch(c){throw this.memoryCache.credentials=s,c}}catch(r){r instanceof Error&&r.message.includes("Invalid credentials")&&D.warn(`Failed to validate credentials file: ${r.message}`),this.memoryCache.credentials=null}}async performTokenRefresh(e,r=!1){let t=Date.now(),o=this.getLockFilePath(),n=!1;try{let s=e.getCredentials();if(!s.refresh_token)throw new h("NO_REFRESH_TOKEN","No refresh token available for token refresh");await this.acquireLock(o),n=!0;let c=Date.now()-t;if(c>5e3&&D.warn(`Token refresh lock acquisition took ${c}ms`),await this.forceFileCheck(e),!r&&this.memoryCache.credentials&&this.isTokenValid(this.memoryCache.credentials))return this.memoryCache.credentials;let l=await e.refreshAccessToken(),a=Date.now()-t;if(a>1e4&&D.warn(`Token refresh operation took ${a}ms`),!l||L(l)){let w=l;throw new h("REFRESH_FAILED",`Token refresh failed: ${w?.error||"Unknown error"} - ${w?.error_description||"No details provided"}`)}let d=l;if(!d.access_token)throw new h("REFRESH_FAILED","Failed to refresh access token: no token returned");let p={access_token:d.access_token,token_type:d.token_type,refresh_token:d.refresh_token||s.refresh_token,resource_url:d.resource_url,expiry_date:Date.now()+d.expires_in*1e3};return this.memoryCache.credentials=p,e.setCredentials(p),await this.saveCredentialsToFile(p),p}catch(s){throw s instanceof F?(D.debug("SharedTokenManager: Clearing memory cache due to credentials clear requirement"),this.memoryCache.credentials=null,this.memoryCache.fileModTime=0,this.refreshPromise=null,new h("REFRESH_FAILED",s.message,s)):s instanceof h?s:s instanceof Error&&(s.message.includes("fetch")||s.message.includes("network")||s.message.includes("timeout"))?new h("NETWORK_ERROR",`Network error during token refresh: ${s.message}`,s):new h("REFRESH_FAILED",`Unexpected error during token refresh: ${s instanceof Error?s.message:String(s)}`,s)}finally{n&&await this.releaseLock(o)}}async saveCredentialsToFile(e){let r=this.getCredentialFilePath(),t=H.dirname(r);try{await this.withTimeout(y.mkdir(t,{recursive:!0,mode:448}),5e3,"File operation")}catch(n){throw new h("FILE_ACCESS_ERROR",`Failed to create credentials directory: ${n instanceof Error?n.message:String(n)}`,n)}let o=JSON.stringify(e,null,2);try{await X(r,o,{mode:384,forceMode:!0,noFollow:!0});let n=await this.withTimeout(y.stat(r),5e3,"File operation");this.memoryCache.fileModTime=n.mtimeMs}catch(n){throw new h("FILE_ACCESS_ERROR",`Failed to write credentials file: ${n instanceof Error?n.message:String(n)}`,n)}}isTokenValid(e){return!e.expiry_date||!e.access_token?!1:Date.now()<e.expiry_date-ve}getCredentialFilePath(){return H.join(S.getGlobalMatildaDir(),_e)}getLockFilePath(){return H.join(S.getGlobalMatildaDir(),Ce)}async acquireLock(e){let{maxAttempts:r,attemptInterval:t,maxInterval:o}=this.lockConfig,n=ne(),s=t;for(let c=0;c<r;c++)try{await y.writeFile(e,n,{flag:"wx"});return}catch(l){if(l.code==="EEXIST"){try{let a=await y.stat(e),d=Date.now()-a.mtimeMs;if(d>ye){let p=`${e}.stale.${ne()}`;try{await y.rename(e,p),await y.unlink(p),D.warn(`Removed stale lock file: ${e} (age: ${d}ms)`);continue}catch(w){D.warn(`Failed to remove stale lock file ${e}: ${w instanceof Error?w.message:String(w)}`)}}}catch(a){D.warn(`Failed to stat lock file ${e}: ${a instanceof Error?a.message:String(a)}`)}await new Promise(a=>setTimeout(a,s)),s=Math.min(s*1.5,o)}else throw new h("FILE_ACCESS_ERROR",`Failed to create lock file: ${l instanceof Error?l.message:String(l)}`,l)}throw new h("LOCK_TIMEOUT","Failed to acquire file lock for token refresh: timeout exceeded")}async releaseLock(e){try{await y.unlink(e)}catch(r){r.code!=="ENOENT"&&D.warn(`Failed to release lock file ${e}: ${r instanceof Error?r.message:String(r)}`)}}updateCacheState(e,r,t){this.memoryCache={credentials:e,fileModTime:r,lastCheck:t??Date.now()}}clearCache(){this.updateCacheState(null,0,0),this.refreshPromise=null,this.checkPromise=null}getCurrentCredentials(){return this.memoryCache.credentials}isRefreshInProgress(){return this.refreshPromise!==null}setLockConfig(e){this.lockConfig={...oe,...e}}cleanup(){this.cleanupFunction&&this.cleanupHandlersRegistered&&(this.cleanupFunction(),process.removeListener("exit",this.cleanupFunction),this.cleanupHandlersRegistered=!1,this.cleanupFunction=null)}getDebugInfo(){let e=!!this.memoryCache.credentials,r=e?!this.isTokenValid(this.memoryCache.credentials):!1;return{hasCredentials:e,credentialsExpired:r,isRefreshing:this.isRefreshInProgress(),cacheAge:Date.now()-this.memoryCache.lastCheck}}};var u=I("MATILDA_OAUTH"),G="https://chat.matilda.ai",Ae=`${G}/api/v1/oauth2/device/code`,K=`${G}/api/v1/oauth2/token`,z="f0304373b74a44d2b584a3fb70ca9e56",Me="openid profile email model.completion",be="urn:ietf:params:oauth:grant-type:device_code",Pe=3e4,Se="oauth_creds.json";function Fe(){return ie.randomBytes(32).toString("base64url")}function Oe(i){let e=ie.createHash("sha256");return e.update(i),e.digest("base64url")}function xe(){let i=Fe(),e=Oe(i);return{code_verifier:i,code_challenge:e}}function B(i){return Object.keys(i).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(i[e])}`).join("&")}function W(i,e){let r=e?"Token refresh timeout":"Token refresh failed";return new Error(`${r}: ${U(i,{url:K})}`,{cause:i})}var F=class extends Error{constructor(r,t){super(r);this.originalError=t;this.name="CredentialsClearRequiredError"}},j=class extends Error{status;oauthError;description;constructor(e){super(`Device token poll failed: ${e.oauthError??"Unknown error"} - ${e.description??"(no description)"}`),this.name="MatildaOAuthPollError",this.oauthError=e.oauthError,this.description=e.description,this.status=e.status}};function V(i){return"device_code"in i}function Ie(i){return"access_token"in i&&i.access_token!==null&&i.access_token!==void 0&&typeof i.access_token=="string"&&i.access_token.length>0}function Le(i){return"status"in i&&i.status==="pending"}function L(i){return"error"in i}var J=class{credentials={};sharedManager;constructor(){this.sharedManager=R.getInstance()}setCredentials(e){this.credentials=e}getCredentials(){return this.credentials}async getAccessToken(){try{return{token:(await this.sharedManager.getValidCredentials(this)).access_token}}catch(e){return u.warn("Failed to get access token from shared manager:",e),{token:void 0}}}async requestDeviceAuthorization(e,r){let t={client_id:z,scope:e.scope,code_challenge:e.code_challenge,code_challenge_method:e.code_challenge_method},o=await fetch(Ae,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","x-request-id":se()},body:B(t),...r?.signal?{signal:r.signal}:{}});if(!o.ok){let s=await o.text();throw new Error(`Device authorization failed: ${o.status} ${o.statusText}. Response: ${s}`)}let n=await o.json();if(V(n))u.debug("Device authorization result (sanitized):",{ok:!0,expires_in:n.expires_in});else{let s=n;u.debug("Device authorization result (sanitized):",{ok:!1,error:s?.error})}if(!V(n)){let s=n;throw new Error(`Device authorization failed: ${s?.error||"Unknown error"} - ${s?.error_description||"No details provided"}`)}return n}async pollDeviceToken(e,r){let t={grant_type:be,client_id:z,device_code:e.device_code,code_verifier:e.code_verifier},o=await fetch(K,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:B(t),...r?.signal?{signal:r.signal}:{}});if(!o.ok){let n=await o.text(),s=null;try{s=JSON.parse(n)}catch{let l=new Error(`Device token poll failed: ${o.status} ${o.statusText}. Response: ${n}`);throw l.status=o.status,l}if(o.status===400&&s.error==="authorization_pending")return{status:"pending"};if(o.status===429&&s.error==="slow_down")return{status:"pending",slowDown:!0};throw new j({oauthError:s.error,description:s.error_description,status:o.status})}return await o.json()}async refreshAccessToken(){if(!this.credentials.refresh_token)throw new Error("No refresh token available");let e={grant_type:"refresh_token",refresh_token:this.credentials.refresh_token,client_id:z},{signal:r,cleanup:t}=Q([],{timeoutMs:Pe});u.debug("Refreshing access token...");try{let o;try{o=await fetch(K,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:B(e),signal:r})}catch(a){throw W(a,r.aborted)}if(!o.ok){let a;try{a=await o.text()}catch(d){throw W(d,r.aborted)}throw o.status===400||o.status===401?(await ae(),new F("Refresh token expired or invalid. Please use '/auth' to re-authenticate.",{status:o.status,response:a})):new Error(`Token refresh failed: ${o.status} ${o.statusText}. Response: ${a}`)}let n;try{n=await o.text()}catch(a){throw W(a,r.aborted)}let s;try{s=JSON.parse(n)}catch{throw new Error(`Legacy OAuth refresh returned invalid JSON: ${n||"(empty response body)"}`)}if(L(s)){let a=s;throw new Error(`Token refresh failed: ${a?.error||"Unknown error"} - ${a?.error_description||"No details provided"}`)}let c=s,l={access_token:c.access_token,token_type:c.token_type,refresh_token:c.refresh_token||this.credentials.refresh_token,resource_url:c.resource_url,expiry_date:Date.now()+c.expires_in*1e3};return this.setCredentials(l),s}finally{t()}}},$e=(t=>(t.AuthUri="auth-uri",t.AuthProgress="auth-progress",t.AuthCancel="auth-cancel",t))($e||{}),P=new Re;async function wr(i,e){let r=new J,t=R.getInstance();try{let o=await t.getValidCredentials(r);return r.setCredentials(o),r}catch(o){if(o instanceof h)switch(o.type){case"NO_REFRESH_TOKEN":u.debug("No refresh token available, proceeding with device flow");break;case"REFRESH_FAILED":u.debug("Token refresh failed, proceeding with device flow");break;case"NETWORK_ERROR":u.warn("Network error during token refresh, trying device flow");break;default:u.warn("Token manager error:",o.message)}if(e?.requireCachedCredentials)throw new Error("Matilda OAuth credentials expired. Please use /auth to re-authenticate with matilda-oauth.");let n=await Ue(r,i);if(!n.success){n.reason==="timeout"&&P.emit("auth-progress","timeout","Authentication timed out. Please try again or select a different authentication method.");let s=n.message||(()=>{switch(n.reason){case"timeout":return"Legacy OAuth authentication timed out";case"cancelled":return"Legacy OAuth authentication was cancelled by user";case"rate_limit":return"Too many requests for legacy OAuth authentication, please try again later.";case"error":default:return"Legacy OAuth authentication failed"}})();throw new Error(s)}return r}}function Ne(i){let e="Legacy OAuth Device Authorization",r=i,n=Math.min(Math.max(e.length+4,70),80),s=n-4,c=(m,T)=>{if(m.startsWith("http://")||m.startsWith("https://")){let v=[];for(let x=0;x<m.length;x+=T)v.push(m.substring(x,x+T));return v}let A=m.split(" "),C=[],_="";for(let v of A)_.length+v.length+1<=T?_+=(_?" ":"")+v:(_&&C.push(_),_=v.length>T?v.substring(0,T):v);return _&&C.push(_),C},l=" "+e+" ",a=n-2-l.length,d=Math.floor(a/2),p=a-d,w="+"+"-".repeat(d)+l+"-".repeat(p)+"+",k="|"+" ".repeat(n-2)+"|",O="+"+"-".repeat(n-2)+"+",g=c("Please visit the following URL in your browser to authorize:",s),f=c(r,s),E="Waiting for authorization to complete...";process.stderr.write(`
|
|
4
|
-
`+w+`
|
|
5
|
-
`),process.stderr.write(k+`
|
|
6
|
-
`);for(let m of g)process.stderr.write("| "+m+" ".repeat(s-m.length)+` |
|
|
7
|
-
`);process.stderr.write(k+`
|
|
8
|
-
`);for(let m of f)process.stderr.write("| "+m+" ".repeat(s-m.length)+` |
|
|
9
|
-
`);process.stderr.write(k+`
|
|
10
|
-
`),process.stderr.write("| "+E+" ".repeat(s-E.length)+` |
|
|
11
|
-
`),process.stderr.write(k+`
|
|
12
|
-
`),process.stderr.write(O+`
|
|
13
|
-
|
|
14
|
-
`)}async function Ue(i,e){let r=!1,t=()=>{r=!0};P.once("auth-cancel",t);let o=()=>{if(!r)return null;let c="Authentication cancelled by user.";return u.debug(`
|
|
15
|
-
`+c),P.emit("auth-progress","error",c),{success:!1,reason:"cancelled",message:c}},n=(c,l)=>{P.emit("auth-progress",c,l)},s=async c=>{try{await te(c)}catch(l){let a=l instanceof Error?l.message:String(l);u.warn(`Failed to open browser automatically: ${a}`),u.info(`Please open this URL manually: ${c}`)}};try{let{code_verifier:c,code_challenge:l}=xe(),a=await i.requestDeviceAuthorization({scope:Me,code_challenge:l,code_challenge_method:"S256"});if(!V(a)){let k=a;throw new Error(`Device authorization failed: ${k?.error||"Unknown error"} - ${k?.error_description||"No details provided"}`)}P.emit("auth-uri",a),(e.isBrowserLaunchSuppressed()||!e.isInteractive())&&Ne(a.verification_uri_complete),e.isBrowserLaunchSuppressed()||await s(a.verification_uri_complete),n("polling","Waiting for authorization..."),u.debug(`Waiting for authorization...
|
|
16
|
-
`);let d=2e3,p=Math.ceil(a.expires_in/(d/1e3));for(let k=0;k<p;k++){let O=o();if(O)return O;try{u.debug("polling for token...");let g=await i.pollDeviceToken({device_code:a.device_code,code_verifier:c});if(Ie(g)){let f=g,E={access_token:f.access_token,refresh_token:f.refresh_token||void 0,token_type:f.token_type,resource_url:f.resource_url,expiry_date:f.expires_in?Date.now()+f.expires_in*1e3:void 0};return i.setCredentials(E),await He(E),n("success","Authentication successful! Access token obtained."),u.debug("Authentication successful! Access token obtained."),{success:!0}}if(Le(g)){g.slowDown?(d=Math.min(d*1.5,1e4),u.debug(`
|
|
17
|
-
Server requested to slow down, increasing poll interval to ${d}ms'`)):d=2e3,n("polling",`Polling... (attempt ${k+1}/${p})`),await new Promise(m=>{let A=0,C=setInterval(()=>{if(A+=100,r){clearInterval(C),m();return}if(A>=d){clearInterval(C),m();return}},100)});let E=o();if(E)return E;continue}if(L(g)){let f=g;throw new Error(`Token polling failed: ${f?.error||"Unknown error"} - ${f?.error_description||"No details provided"}`)}}catch(g){let f=g instanceof Error?g.message:String(g),E=g instanceof Error?g.status:null,m=(C,_,v="error")=>(n(v,_),{success:!1,reason:C,message:_}),T=o();if(T)return T;if(f.includes("Failed to cache credentials"))return m("error",f);if(f.includes("401")||E===401)return m("error","Device code expired or invalid, please restart the authorization process.");if(f.includes("429")||E===429)return m("rate_limit","Too many requests. The server is rate limiting our requests. Please select a different authentication method or try again later.","rate_limit");let A=`Error polling for token: ${f}`;n("error",A),await new Promise(C=>setTimeout(C,d))}}let w="Authorization timeout, please restart the process.";return n("timeout",w),{success:!1,reason:"timeout",message:w}}catch(c){let a=`Device authorization flow failed: ${U(c,{url:G})}`;return n("error",a),{success:!1,reason:"error",message:a}}finally{P.off("auth-cancel",t)}}var $=384;async function He(i,e){let r=ce();try{await b.mkdir(q.dirname(r),{recursive:!0});let t=JSON.stringify(i,null,2),o=`${r}.tmp.${process.pid}.${se()}`;try{await b.writeFile(o,t,{mode:$,...e?.signal?{signal:e.signal}:{}});try{await b.chmod(o,$)}catch(n){if(process.platform!=="win32")throw new Error(`cacheMatildaCredentials: refusing to publish credentials \u2014 chmod 0o${$.toString(8)} on temp file failed: ${n instanceof Error?n.message:String(n)}`);u.warn(`cacheMatildaCredentials: chmod 0o${$.toString(8)} on Windows temp file ${o} failed; relying on NTFS ACL: ${n instanceof Error?n.message:String(n)}`)}await b.rename(o,r)}catch(n){try{await b.unlink(o)}catch{}throw n}try{R.getInstance().clearCache()}catch(n){u.warn(`cacheMatildaCredentials: SharedTokenManager.clearCache failed; in-process callers may serve stale credentials until the next mtime poll: ${n instanceof Error?n.message:String(n)}`)}}catch(t){let o=t instanceof Error?t.message:String(t);throw(t instanceof Error&&"code"in t?t.code:void 0)==="EACCES"?new Error(`Failed to cache credentials: Permission denied (EACCES). Current user has no permission to access \`${r}\`. Please check permissions.`):new Error(`Failed to cache credentials: error when creating folder \`${q.dirname(r)}\` and writing to \`${r}\`. ${o}. Please check permissions.`)}}async function ae(){try{let i=ce();await b.unlink(i),u.debug("Cached legacy OAuth credentials cleared successfully.")}catch(i){if(i instanceof Error&&"code"in i&&i.code==="ENOENT")return;u.warn("Warning: Failed to clear cached legacy OAuth credentials:",i)}finally{try{R.getInstance().clearCache()}catch{}}}function ce(){return q.join(S.getGlobalMatildaDir(),Se)}var kr=ae;export{te as a,Ve as b,R as c,Fe as d,Oe as e,xe as f,F as g,j as h,V as i,Ie as j,Le as k,L as l,J as m,$e as n,P as o,wr as p,$ as q,He as r,ae as s,kr as t};
|
|
18
|
-
/**
|
|
19
|
-
* @license
|
|
20
|
-
* Copyright 2025 Google LLC
|
|
21
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* @license
|
|
25
|
-
* Copyright 2025 Matilda
|
|
26
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
27
|
-
*/
|