@runfusion/fusion 0.43.1 → 0.44.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.
Files changed (168) hide show
  1. package/dist/automation-store-EKXXEE2S.js +10 -0
  2. package/dist/automation-store-PLNG3X72.js +10 -0
  3. package/dist/automation-store-RDDYZFUJ.js +10 -0
  4. package/dist/bin.js +8097 -1796
  5. package/dist/chunk-2JI3F6MG.js +948 -0
  6. package/dist/chunk-4L6CLWJC.js +8345 -0
  7. package/dist/chunk-4VNS5WPM.js +42 -0
  8. package/dist/chunk-5RGECGQL.js +1139 -0
  9. package/dist/chunk-6JDLN7IL.js +409 -0
  10. package/dist/chunk-AICJATVW.js +948 -0
  11. package/dist/chunk-AWKNRUOR.js +1148 -0
  12. package/dist/chunk-BHM3UYWS.js +4651 -0
  13. package/dist/chunk-BMUXDSBF.js +4647 -0
  14. package/dist/chunk-GETECT6V.js +353 -0
  15. package/dist/chunk-GUV4QQT3.js +1143 -0
  16. package/dist/chunk-JKQO7YYZ.js +8369 -0
  17. package/dist/chunk-LYZVU6UV.js +409 -0
  18. package/dist/chunk-MAN4WYHO.js +353 -0
  19. package/dist/chunk-MCUG2Z7M.js +4651 -0
  20. package/dist/chunk-PSDYB45U.js +948 -0
  21. package/dist/chunk-RR2HM46R.js +8345 -0
  22. package/dist/chunk-RXMQ5OMY.js +9226 -0
  23. package/dist/chunk-S2EVJUY3.js +353 -0
  24. package/dist/chunk-UXR5XZFZ.js +409 -0
  25. package/dist/client/.vite/manifest.json +272 -261
  26. package/dist/client/assets/{AgentDetailView-BGN03dyz.css → AgentDetailView-CanIeYHg.css} +1 -1
  27. package/dist/client/assets/{AgentDetailView-DKMz3r04.js → AgentDetailView-DxV8pFHX.js} +3 -3
  28. package/dist/client/assets/{AgentPermissionPolicyEditor-BiY1a4KR.js → AgentPermissionPolicyEditor--YS4iMUY.js} +2 -2
  29. package/dist/client/assets/AgentsView-BVILQjdS.css +1 -0
  30. package/dist/client/assets/{AgentsView-Co-k4vjh.js → AgentsView-CTzbcvhK.js} +3 -3
  31. package/dist/client/assets/ChatView-COygcnyk.js +6 -0
  32. package/dist/client/assets/CommandCenter-CTaopaC0.css +1 -0
  33. package/dist/client/assets/CommandCenter-DoKX2HWm.js +56 -0
  34. package/dist/client/assets/DevServerView-Cyevyvqx.js +1 -0
  35. package/dist/client/assets/{DirectoryPicker-DTKtd8L2.css → DirectoryPicker-0rspvcMz.css} +1 -1
  36. package/dist/client/assets/{DirectoryPicker-CkcGjyv0.js → DirectoryPicker-DBdyXEhR.js} +1 -1
  37. package/dist/client/assets/DocumentsView-BzSMyrns.js +1 -0
  38. package/dist/client/assets/{EvalsView-CUfyj5GW.js → EvalsView-ikz00o9g.js} +1 -1
  39. package/dist/client/assets/ExperimentalAgentOnboardingModal-CZ_jbgep.css +1 -0
  40. package/dist/client/assets/{ExperimentalAgentOnboardingModal-Dau9RTU_.js → ExperimentalAgentOnboardingModal-D-rzCCET.js} +10 -10
  41. package/dist/client/assets/GoalsView-Bfu1Oy2-.js +2 -0
  42. package/dist/client/assets/GoalsView-rg9VSIza.css +1 -0
  43. package/dist/client/assets/{InsightsView-BQPxHxKI.js → InsightsView-Cgmf5nES.js} +1 -1
  44. package/dist/client/assets/InsightsView-LMv1M1dU.css +1 -0
  45. package/dist/client/assets/MemoryView-DkEuDKQs.js +2 -0
  46. package/dist/client/assets/{NodesView-CSMvGwDU.js → NodesView-B_KYfS4o.js} +3 -3
  47. package/dist/client/assets/{PiExtensionsManager-BtqXF3fl.js → PiExtensionsManager-Dz69kkKs.js} +2 -2
  48. package/dist/client/assets/PluginManager-DSiHizRD.css +1 -0
  49. package/dist/client/assets/{PluginManager-CSSDb3VO.js → PluginManager-LHCVcduP.js} +1 -1
  50. package/dist/client/assets/PullRequestView-3AdbS2a1.css +1 -0
  51. package/dist/client/assets/{PullRequestView-Bjyfffdu.js → PullRequestView-DBJutLLl.js} +2 -2
  52. package/dist/client/assets/{ResearchView-CRU_NPho.js → ResearchView-gpn1XcVy.js} +1 -1
  53. package/dist/client/assets/{SecretsView-Bs8ySyC5.js → SecretsView-B7YqIowt.js} +1 -1
  54. package/dist/client/assets/SessionTerminal-9l4bdKcn.js +2 -0
  55. package/dist/client/assets/SessionTerminal-BNgtmXb3.css +1 -0
  56. package/dist/client/assets/SettingsModal-BGEK9_9A.js +31 -0
  57. package/dist/client/assets/{SettingsModal-DpAxDq6M.css → SettingsModal-CKv0TJfM.css} +1 -1
  58. package/dist/client/assets/SettingsModal-CXogw-Er.css +1 -0
  59. package/dist/client/assets/{SettingsModal-Nw5cTKAK.js → SettingsModal-DIIoHGUH.js} +1 -1
  60. package/dist/client/assets/{SetupWizardModal-CE79myEy.js → SetupWizardModal-BcVeMxeX.js} +1 -1
  61. package/dist/client/assets/{SkillsView-Dc8YskAX.js → SkillsView-BxSJ4PHL.js} +1 -1
  62. package/dist/client/assets/{StashRecoveryView-CqKOFiXT.js → StashRecoveryView-BhFQ2FsP.js} +1 -1
  63. package/dist/client/assets/{TodoView-BqIRwcZw.js → TodoView-BZpewjy0.js} +2 -2
  64. package/dist/client/assets/WorkflowNodeEditor-Yn1FRF2v.css +1 -0
  65. package/dist/client/assets/WorkflowNodeEditor-tWsgCdVt.js +8 -0
  66. package/dist/client/assets/{addon-fit-B4jkcKk4.js → addon-fit-SnYDEvGm.js} +1 -1
  67. package/dist/client/assets/{addon-unicode11-Cdne2Sj4.js → addon-unicode11-s5GoZCpi.js} +1 -1
  68. package/dist/client/assets/{addon-web-links-CRNLzj7m.js → addon-web-links-jjt2f_oV.js} +1 -1
  69. package/dist/client/assets/{addon-webgl-CeCSULF1.js → addon-webgl-Icn-RnEx.js} +1 -1
  70. package/dist/client/assets/{app-sEkTyT-w.js → app-BmGA0Hiz.js} +3 -3
  71. package/dist/client/assets/{app-BffGU_HQ.js → app-CEVYlVuJ.js} +3 -3
  72. package/dist/client/assets/{app-C8AHhs5N.js → app-CbBFax2C.js} +3 -3
  73. package/dist/client/assets/{app-B2ZxMfJT.js → app-DORKrGAz.js} +3 -3
  74. package/dist/client/assets/{app-Ri9Te2Dv.js → app-DQibuQ9z.js} +3 -3
  75. package/dist/client/assets/app-k76GrQP0.js +13 -0
  76. package/dist/client/assets/{createLucideIcon-BYvOGRiO.js → createLucideIcon-DmVITl5d.js} +1 -1
  77. package/dist/client/assets/{dashboard-view-C3SsjXo1.js → dashboard-view-B4LXCv5H.js} +4 -4
  78. package/dist/client/assets/{dashboard-view-DlKsVySD.js → dashboard-view-BFoyhTYF.js} +1 -1
  79. package/dist/client/assets/{dashboard-view-BhbN8LPh.js → dashboard-view-Cxzm_eqc.js} +1 -1
  80. package/dist/client/assets/dashboard-view-_8yfNwju.css +1 -0
  81. package/dist/client/assets/{folder-open-Bw1mxVfa.js → folder-open-33WGVnbp.js} +1 -1
  82. package/dist/client/assets/index-Bglw05rM.js +791 -0
  83. package/dist/client/assets/index-FYgnflWD.css +1 -0
  84. package/dist/client/assets/shield-alert-CqeGWBUK.js +6 -0
  85. package/dist/client/assets/{upload-BCmd-1I0.js → upload-C11J2diI.js} +1 -1
  86. package/dist/client/assets/{users-DO_t3V1p.js → users-a-ELbyyZ.js} +1 -1
  87. package/dist/client/assets/{vendor-i18n-CV0mwX_-.js → vendor-i18n-DYlSUfot.js} +1 -1
  88. package/dist/client/assets/vendor-react-BTgM5bbZ.js +49 -0
  89. package/dist/client/assets/{vendor-reactflow-CRZcPCXF.js → vendor-reactflow-ZasuEfF9.js} +3 -3
  90. package/dist/client/assets/{vendor-xterm-tcedd2Jt.js → vendor-xterm-ea7-K05z.js} +1 -1
  91. package/dist/client/assets/{x-CqNX_9E2.js → x-PItWc-wQ.js} +1 -1
  92. package/dist/client/assets/{zoom-out-CSTHbJgD.js → zoom-out-CzlHv0Kj.js} +1 -1
  93. package/dist/client/icons/icon-192.png +0 -0
  94. package/dist/client/icons/icon-512.png +0 -0
  95. package/dist/client/index.html +6 -6
  96. package/dist/client/sw.js +1 -1
  97. package/dist/client/theme-data.css +288 -285
  98. package/dist/client/version.json +1 -1
  99. package/dist/droid-cli/package.json +1 -1
  100. package/dist/droid-cli/src/__tests__/execsync-guard.test.ts +17 -0
  101. package/dist/droid-cli/src/__tests__/process-manager.test.ts +1 -45
  102. package/dist/extension.js +4780 -793
  103. package/dist/extract-zip-WL55Z3AU.js +2497 -0
  104. package/dist/index.min-CHQ3ABYJ.js +2926 -0
  105. package/dist/memory-dreams-7USISKVE.js +32 -0
  106. package/dist/memory-dreams-PBPISUDD.js +32 -0
  107. package/dist/memory-dreams-XNO2B2QF.js +32 -0
  108. package/dist/migration-EH2YOCYQ.js +15 -0
  109. package/dist/migration-PLGTTKL5.js +15 -0
  110. package/dist/migration-WZEZK22R.js +15 -0
  111. package/dist/pi-claude-cli/index.ts +47 -8
  112. package/dist/pi-claude-cli/package.json +4 -1
  113. package/dist/pi-claude-cli/src/__tests__/acp-dispatch.test.ts +80 -0
  114. package/dist/pi-claude-cli/src/__tests__/acp-driver.test.ts +423 -0
  115. package/dist/pi-claude-cli/src/__tests__/execsync-guard.test.ts +14 -0
  116. package/dist/pi-claude-cli/src/__tests__/process-manager.test.ts +1 -45
  117. package/dist/pi-claude-cli/src/__tests__/provider.test.ts +0 -1
  118. package/dist/pi-claude-cli/src/acp-driver.ts +585 -0
  119. package/dist/pi-claude-cli/src/event-bridge.ts +7 -0
  120. package/dist/pi-claude-cli/src/mcp-config.ts +29 -0
  121. package/dist/pi-claude-cli/src/process-manager.ts +6 -38
  122. package/dist/plugin-sdk/index.d.ts +5179 -5144
  123. package/dist/plugins/fusion-plugin-acp-runtime/bundled.js +263 -19
  124. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  125. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  126. package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +37 -7
  127. package/dist/plugins/fusion-plugin-compound-engineering/manifest.json +4 -4
  128. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  129. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  130. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  131. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +1 -1
  132. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  133. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  134. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  135. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  136. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  137. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  138. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  139. package/dist/plugins/fusion-plugin-whatsapp-chat/src/__tests__/index.test.ts +5 -1
  140. package/dist/routine-store-GIJ6MXWY.js +10 -0
  141. package/dist/routine-store-HTVC2PUQ.js +10 -0
  142. package/dist/routine-store-KGHZBPDF.js +10 -0
  143. package/package.json +1 -1
  144. package/skill/fusion/references/engine-tools.md +6 -4
  145. package/dist/client/assets/AgentsView-DfznJDek.css +0 -1
  146. package/dist/client/assets/ChatView-BkAG99bj.js +0 -6
  147. package/dist/client/assets/DevServerView-C6DC0URX.js +0 -1
  148. package/dist/client/assets/DocumentsView-OCK1Vsw_.js +0 -1
  149. package/dist/client/assets/ExperimentalAgentOnboardingModal-BNpveCEk.css +0 -1
  150. package/dist/client/assets/GoalsView-CNLTn0rX.js +0 -2
  151. package/dist/client/assets/GoalsView-DI66UsjT.css +0 -1
  152. package/dist/client/assets/InsightsView-C9-mqVvf.css +0 -1
  153. package/dist/client/assets/MemoryView-D3xQIFjj.js +0 -2
  154. package/dist/client/assets/PluginManager-UHVLvWWl.css +0 -1
  155. package/dist/client/assets/PullRequestView-WQIS0zUC.css +0 -1
  156. package/dist/client/assets/ReliabilityView-QKMUDebT.js +0 -1
  157. package/dist/client/assets/ReliabilityView-eoKBhBc4.css +0 -1
  158. package/dist/client/assets/SessionTerminal-BiigPP2l.css +0 -1
  159. package/dist/client/assets/SessionTerminal-Dk1NgmN2.js +0 -2
  160. package/dist/client/assets/SettingsModal-JCaNvdAb.js +0 -31
  161. package/dist/client/assets/SettingsModal-nF_GaeeK.css +0 -1
  162. package/dist/client/assets/WorkflowNodeEditor-2jDuk2FR.js +0 -8
  163. package/dist/client/assets/WorkflowNodeEditor-BokhW3de.css +0 -1
  164. package/dist/client/assets/app-CUu1sm3x.js +0 -13
  165. package/dist/client/assets/dashboard-view-Du53JbmQ.css +0 -1
  166. package/dist/client/assets/index-CpTBp1RG.js +0 -793
  167. package/dist/client/assets/index-DqhCiU35.css +0 -1
  168. package/dist/client/assets/vendor-react-D37HfzIf.js +0 -49
@@ -0,0 +1,2926 @@
1
+ import "./chunk-4VNS5WPM.js";
2
+
3
+ // ../../node_modules/.pnpm/tar@7.5.13/node_modules/tar/dist/esm/index.min.js
4
+ import Kr from "events";
5
+ import I from "fs";
6
+ import { EventEmitter as Ti } from "events";
7
+ import Ns from "stream";
8
+ import { StringDecoder as Mr } from "string_decoder";
9
+ import nr from "path";
10
+ import Vt from "fs";
11
+ import { dirname as xn, parse as Ln } from "path";
12
+ import { EventEmitter as _n } from "events";
13
+ import Mi from "assert";
14
+ import { Buffer as gt } from "buffer";
15
+ import * as ks from "zlib";
16
+ import qr from "zlib";
17
+ import { posix as Zt } from "path";
18
+ import { basename as wn } from "path";
19
+ import fi from "fs";
20
+ import $ from "fs";
21
+ import $s from "path";
22
+ import { win32 as In } from "path";
23
+ import sr from "path";
24
+ import Cr from "fs";
25
+ import so from "assert";
26
+ import { randomBytes as Ir } from "crypto";
27
+ import u from "fs";
28
+ import R from "path";
29
+ import cr from "fs";
30
+ import mi from "fs";
31
+ import Ee from "path";
32
+ import k from "fs";
33
+ import jn from "fs/promises";
34
+ import pi from "path";
35
+ import { join as br } from "path";
36
+ import v from "fs";
37
+ import Fr from "path";
38
+ var kr = Object.defineProperty;
39
+ var vr = (s3, t) => {
40
+ for (var e in t) kr(s3, e, { get: t[e], enumerable: true });
41
+ };
42
+ var Os = typeof process == "object" && process ? process : { stdout: null, stderr: null };
43
+ var Br = (s3) => !!s3 && typeof s3 == "object" && (s3 instanceof D || s3 instanceof Ns || Pr(s3) || zr(s3));
44
+ var Pr = (s3) => !!s3 && typeof s3 == "object" && s3 instanceof Ti && typeof s3.pipe == "function" && s3.pipe !== Ns.Writable.prototype.pipe;
45
+ var zr = (s3) => !!s3 && typeof s3 == "object" && s3 instanceof Ti && typeof s3.write == "function" && typeof s3.end == "function";
46
+ var q = /* @__PURE__ */ Symbol("EOF");
47
+ var j = /* @__PURE__ */ Symbol("maybeEmitEnd");
48
+ var rt = /* @__PURE__ */ Symbol("emittedEnd");
49
+ var Le = /* @__PURE__ */ Symbol("emittingEnd");
50
+ var jt = /* @__PURE__ */ Symbol("emittedError");
51
+ var Ne = /* @__PURE__ */ Symbol("closed");
52
+ var Ts = /* @__PURE__ */ Symbol("read");
53
+ var Ae = /* @__PURE__ */ Symbol("flush");
54
+ var xs = /* @__PURE__ */ Symbol("flushChunk");
55
+ var z = /* @__PURE__ */ Symbol("encoding");
56
+ var Mt = /* @__PURE__ */ Symbol("decoder");
57
+ var b = /* @__PURE__ */ Symbol("flowing");
58
+ var Qt = /* @__PURE__ */ Symbol("paused");
59
+ var Bt = /* @__PURE__ */ Symbol("resume");
60
+ var _ = /* @__PURE__ */ Symbol("buffer");
61
+ var A = /* @__PURE__ */ Symbol("pipes");
62
+ var g = /* @__PURE__ */ Symbol("bufferLength");
63
+ var yi = /* @__PURE__ */ Symbol("bufferPush");
64
+ var De = /* @__PURE__ */ Symbol("bufferShift");
65
+ var L = /* @__PURE__ */ Symbol("objectMode");
66
+ var w = /* @__PURE__ */ Symbol("destroyed");
67
+ var Ri = /* @__PURE__ */ Symbol("error");
68
+ var bi = /* @__PURE__ */ Symbol("emitData");
69
+ var Ls = /* @__PURE__ */ Symbol("emitEnd");
70
+ var _i = /* @__PURE__ */ Symbol("emitEnd2");
71
+ var Z = /* @__PURE__ */ Symbol("async");
72
+ var gi = /* @__PURE__ */ Symbol("abort");
73
+ var Ie = /* @__PURE__ */ Symbol("aborted");
74
+ var Jt = /* @__PURE__ */ Symbol("signal");
75
+ var yt = /* @__PURE__ */ Symbol("dataListeners");
76
+ var C = /* @__PURE__ */ Symbol("discarded");
77
+ var te = (s3) => Promise.resolve().then(s3);
78
+ var Ur = (s3) => s3();
79
+ var Hr = (s3) => s3 === "end" || s3 === "finish" || s3 === "prefinish";
80
+ var Wr = (s3) => s3 instanceof ArrayBuffer || !!s3 && typeof s3 == "object" && s3.constructor && s3.constructor.name === "ArrayBuffer" && s3.byteLength >= 0;
81
+ var Gr = (s3) => !Buffer.isBuffer(s3) && ArrayBuffer.isView(s3);
82
+ var Ce = class {
83
+ src;
84
+ dest;
85
+ opts;
86
+ ondrain;
87
+ constructor(t, e, i) {
88
+ this.src = t, this.dest = e, this.opts = i, this.ondrain = () => t[Bt](), this.dest.on("drain", this.ondrain);
89
+ }
90
+ unpipe() {
91
+ this.dest.removeListener("drain", this.ondrain);
92
+ }
93
+ proxyErrors(t) {
94
+ }
95
+ end() {
96
+ this.unpipe(), this.opts.end && this.dest.end();
97
+ }
98
+ };
99
+ var Oi = class extends Ce {
100
+ unpipe() {
101
+ this.src.removeListener("error", this.proxyErrors), super.unpipe();
102
+ }
103
+ constructor(t, e, i) {
104
+ super(t, e, i), this.proxyErrors = (r) => this.dest.emit("error", r), t.on("error", this.proxyErrors);
105
+ }
106
+ };
107
+ var Zr = (s3) => !!s3.objectMode;
108
+ var Yr = (s3) => !s3.objectMode && !!s3.encoding && s3.encoding !== "buffer";
109
+ var D = class extends Ti {
110
+ [b] = false;
111
+ [Qt] = false;
112
+ [A] = [];
113
+ [_] = [];
114
+ [L];
115
+ [z];
116
+ [Z];
117
+ [Mt];
118
+ [q] = false;
119
+ [rt] = false;
120
+ [Le] = false;
121
+ [Ne] = false;
122
+ [jt] = null;
123
+ [g] = 0;
124
+ [w] = false;
125
+ [Jt];
126
+ [Ie] = false;
127
+ [yt] = 0;
128
+ [C] = false;
129
+ writable = true;
130
+ readable = true;
131
+ constructor(...t) {
132
+ let e = t[0] || {};
133
+ if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
134
+ Zr(e) ? (this[L] = true, this[z] = null) : Yr(e) ? (this[z] = e.encoding, this[L] = false) : (this[L] = false, this[z] = null), this[Z] = !!e.async, this[Mt] = this[z] ? new Mr(this[z]) : null, e && e.debugExposeBuffer === true && Object.defineProperty(this, "buffer", { get: () => this[_] }), e && e.debugExposePipes === true && Object.defineProperty(this, "pipes", { get: () => this[A] });
135
+ let { signal: i } = e;
136
+ i && (this[Jt] = i, i.aborted ? this[gi]() : i.addEventListener("abort", () => this[gi]()));
137
+ }
138
+ get bufferLength() {
139
+ return this[g];
140
+ }
141
+ get encoding() {
142
+ return this[z];
143
+ }
144
+ set encoding(t) {
145
+ throw new Error("Encoding must be set at instantiation time");
146
+ }
147
+ setEncoding(t) {
148
+ throw new Error("Encoding must be set at instantiation time");
149
+ }
150
+ get objectMode() {
151
+ return this[L];
152
+ }
153
+ set objectMode(t) {
154
+ throw new Error("objectMode must be set at instantiation time");
155
+ }
156
+ get async() {
157
+ return this[Z];
158
+ }
159
+ set async(t) {
160
+ this[Z] = this[Z] || !!t;
161
+ }
162
+ [gi]() {
163
+ this[Ie] = true, this.emit("abort", this[Jt]?.reason), this.destroy(this[Jt]?.reason);
164
+ }
165
+ get aborted() {
166
+ return this[Ie];
167
+ }
168
+ set aborted(t) {
169
+ }
170
+ write(t, e, i) {
171
+ if (this[Ie]) return false;
172
+ if (this[q]) throw new Error("write after end");
173
+ if (this[w]) return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), true;
174
+ typeof e == "function" && (i = e, e = "utf8"), e || (e = "utf8");
175
+ let r = this[Z] ? te : Ur;
176
+ if (!this[L] && !Buffer.isBuffer(t)) {
177
+ if (Gr(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
178
+ else if (Wr(t)) t = Buffer.from(t);
179
+ else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
180
+ }
181
+ return this[L] ? (this[b] && this[g] !== 0 && this[Ae](true), this[b] ? this.emit("data", t) : this[yi](t), this[g] !== 0 && this.emit("readable"), i && r(i), this[b]) : t.length ? (typeof t == "string" && !(e === this[z] && !this[Mt]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[z] && (t = this[Mt].write(t)), this[b] && this[g] !== 0 && this[Ae](true), this[b] ? this.emit("data", t) : this[yi](t), this[g] !== 0 && this.emit("readable"), i && r(i), this[b]) : (this[g] !== 0 && this.emit("readable"), i && r(i), this[b]);
182
+ }
183
+ read(t) {
184
+ if (this[w]) return null;
185
+ if (this[C] = false, this[g] === 0 || t === 0 || t && t > this[g]) return this[j](), null;
186
+ this[L] && (t = null), this[_].length > 1 && !this[L] && (this[_] = [this[z] ? this[_].join("") : Buffer.concat(this[_], this[g])]);
187
+ let e = this[Ts](t || null, this[_][0]);
188
+ return this[j](), e;
189
+ }
190
+ [Ts](t, e) {
191
+ if (this[L]) this[De]();
192
+ else {
193
+ let i = e;
194
+ t === i.length || t === null ? this[De]() : typeof i == "string" ? (this[_][0] = i.slice(t), e = i.slice(0, t), this[g] -= t) : (this[_][0] = i.subarray(t), e = i.subarray(0, t), this[g] -= t);
195
+ }
196
+ return this.emit("data", e), !this[_].length && !this[q] && this.emit("drain"), e;
197
+ }
198
+ end(t, e, i) {
199
+ return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = "utf8"), t !== void 0 && this.write(t, e), i && this.once("end", i), this[q] = true, this.writable = false, (this[b] || !this[Qt]) && this[j](), this;
200
+ }
201
+ [Bt]() {
202
+ this[w] || (!this[yt] && !this[A].length && (this[C] = true), this[Qt] = false, this[b] = true, this.emit("resume"), this[_].length ? this[Ae]() : this[q] ? this[j]() : this.emit("drain"));
203
+ }
204
+ resume() {
205
+ return this[Bt]();
206
+ }
207
+ pause() {
208
+ this[b] = false, this[Qt] = true, this[C] = false;
209
+ }
210
+ get destroyed() {
211
+ return this[w];
212
+ }
213
+ get flowing() {
214
+ return this[b];
215
+ }
216
+ get paused() {
217
+ return this[Qt];
218
+ }
219
+ [yi](t) {
220
+ this[L] ? this[g] += 1 : this[g] += t.length, this[_].push(t);
221
+ }
222
+ [De]() {
223
+ return this[L] ? this[g] -= 1 : this[g] -= this[_][0].length, this[_].shift();
224
+ }
225
+ [Ae](t = false) {
226
+ do
227
+ ;
228
+ while (this[xs](this[De]()) && this[_].length);
229
+ !t && !this[_].length && !this[q] && this.emit("drain");
230
+ }
231
+ [xs](t) {
232
+ return this.emit("data", t), this[b];
233
+ }
234
+ pipe(t, e) {
235
+ if (this[w]) return t;
236
+ this[C] = false;
237
+ let i = this[rt];
238
+ return e = e || {}, t === Os.stdout || t === Os.stderr ? e.end = false : e.end = e.end !== false, e.proxyErrors = !!e.proxyErrors, i ? e.end && t.end() : (this[A].push(e.proxyErrors ? new Oi(this, t, e) : new Ce(this, t, e)), this[Z] ? te(() => this[Bt]()) : this[Bt]()), t;
239
+ }
240
+ unpipe(t) {
241
+ let e = this[A].find((i) => i.dest === t);
242
+ e && (this[A].length === 1 ? (this[b] && this[yt] === 0 && (this[b] = false), this[A] = []) : this[A].splice(this[A].indexOf(e), 1), e.unpipe());
243
+ }
244
+ addListener(t, e) {
245
+ return this.on(t, e);
246
+ }
247
+ on(t, e) {
248
+ let i = super.on(t, e);
249
+ if (t === "data") this[C] = false, this[yt]++, !this[A].length && !this[b] && this[Bt]();
250
+ else if (t === "readable" && this[g] !== 0) super.emit("readable");
251
+ else if (Hr(t) && this[rt]) super.emit(t), this.removeAllListeners(t);
252
+ else if (t === "error" && this[jt]) {
253
+ let r = e;
254
+ this[Z] ? te(() => r.call(this, this[jt])) : r.call(this, this[jt]);
255
+ }
256
+ return i;
257
+ }
258
+ removeListener(t, e) {
259
+ return this.off(t, e);
260
+ }
261
+ off(t, e) {
262
+ let i = super.off(t, e);
263
+ return t === "data" && (this[yt] = this.listeners("data").length, this[yt] === 0 && !this[C] && !this[A].length && (this[b] = false)), i;
264
+ }
265
+ removeAllListeners(t) {
266
+ let e = super.removeAllListeners(t);
267
+ return (t === "data" || t === void 0) && (this[yt] = 0, !this[C] && !this[A].length && (this[b] = false)), e;
268
+ }
269
+ get emittedEnd() {
270
+ return this[rt];
271
+ }
272
+ [j]() {
273
+ !this[Le] && !this[rt] && !this[w] && this[_].length === 0 && this[q] && (this[Le] = true, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Ne] && this.emit("close"), this[Le] = false);
274
+ }
275
+ emit(t, ...e) {
276
+ let i = e[0];
277
+ if (t !== "error" && t !== "close" && t !== w && this[w]) return false;
278
+ if (t === "data") return !this[L] && !i ? false : this[Z] ? (te(() => this[bi](i)), true) : this[bi](i);
279
+ if (t === "end") return this[Ls]();
280
+ if (t === "close") {
281
+ if (this[Ne] = true, !this[rt] && !this[w]) return false;
282
+ let n = super.emit("close");
283
+ return this.removeAllListeners("close"), n;
284
+ } else if (t === "error") {
285
+ this[jt] = i, super.emit(Ri, i);
286
+ let n = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : false;
287
+ return this[j](), n;
288
+ } else if (t === "resume") {
289
+ let n = super.emit("resume");
290
+ return this[j](), n;
291
+ } else if (t === "finish" || t === "prefinish") {
292
+ let n = super.emit(t);
293
+ return this.removeAllListeners(t), n;
294
+ }
295
+ let r = super.emit(t, ...e);
296
+ return this[j](), r;
297
+ }
298
+ [bi](t) {
299
+ for (let i of this[A]) i.dest.write(t) === false && this.pause();
300
+ let e = this[C] ? false : super.emit("data", t);
301
+ return this[j](), e;
302
+ }
303
+ [Ls]() {
304
+ return this[rt] ? false : (this[rt] = true, this.readable = false, this[Z] ? (te(() => this[_i]()), true) : this[_i]());
305
+ }
306
+ [_i]() {
307
+ if (this[Mt]) {
308
+ let e = this[Mt].end();
309
+ if (e) {
310
+ for (let i of this[A]) i.dest.write(e);
311
+ this[C] || super.emit("data", e);
312
+ }
313
+ }
314
+ for (let e of this[A]) e.end();
315
+ let t = super.emit("end");
316
+ return this.removeAllListeners("end"), t;
317
+ }
318
+ async collect() {
319
+ let t = Object.assign([], { dataLength: 0 });
320
+ this[L] || (t.dataLength = 0);
321
+ let e = this.promise();
322
+ return this.on("data", (i) => {
323
+ t.push(i), this[L] || (t.dataLength += i.length);
324
+ }), await e, t;
325
+ }
326
+ async concat() {
327
+ if (this[L]) throw new Error("cannot concat in objectMode");
328
+ let t = await this.collect();
329
+ return this[z] ? t.join("") : Buffer.concat(t, t.dataLength);
330
+ }
331
+ async promise() {
332
+ return new Promise((t, e) => {
333
+ this.on(w, () => e(new Error("stream destroyed"))), this.on("error", (i) => e(i)), this.on("end", () => t());
334
+ });
335
+ }
336
+ [Symbol.asyncIterator]() {
337
+ this[C] = false;
338
+ let t = false, e = async () => (this.pause(), t = true, { value: void 0, done: true });
339
+ return { next: () => {
340
+ if (t) return e();
341
+ let r = this.read();
342
+ if (r !== null) return Promise.resolve({ done: false, value: r });
343
+ if (this[q]) return e();
344
+ let n, o, h = (d) => {
345
+ this.off("data", a), this.off("end", l), this.off(w, c), e(), o(d);
346
+ }, a = (d) => {
347
+ this.off("error", h), this.off("end", l), this.off(w, c), this.pause(), n({ value: d, done: !!this[q] });
348
+ }, l = () => {
349
+ this.off("error", h), this.off("data", a), this.off(w, c), e(), n({ done: true, value: void 0 });
350
+ }, c = () => h(new Error("stream destroyed"));
351
+ return new Promise((d, S) => {
352
+ o = S, n = d, this.once(w, c), this.once("error", h), this.once("end", l), this.once("data", a);
353
+ });
354
+ }, throw: e, return: e, [Symbol.asyncIterator]() {
355
+ return this;
356
+ }, [Symbol.asyncDispose]: async () => {
357
+ } };
358
+ }
359
+ [Symbol.iterator]() {
360
+ this[C] = false;
361
+ let t = false, e = () => (this.pause(), this.off(Ri, e), this.off(w, e), this.off("end", e), t = true, { done: true, value: void 0 }), i = () => {
362
+ if (t) return e();
363
+ let r = this.read();
364
+ return r === null ? e() : { done: false, value: r };
365
+ };
366
+ return this.once("end", e), this.once(Ri, e), this.once(w, e), { next: i, throw: e, return: e, [Symbol.iterator]() {
367
+ return this;
368
+ }, [Symbol.dispose]: () => {
369
+ } };
370
+ }
371
+ destroy(t) {
372
+ if (this[w]) return t ? this.emit("error", t) : this.emit(w), this;
373
+ this[w] = true, this[C] = true, this[_].length = 0, this[g] = 0;
374
+ let e = this;
375
+ return typeof e.close == "function" && !this[Ne] && e.close(), t ? this.emit("error", t) : this.emit(w), this;
376
+ }
377
+ static get isStream() {
378
+ return Br;
379
+ }
380
+ };
381
+ var Vr = I.writev;
382
+ var ot = /* @__PURE__ */ Symbol("_autoClose");
383
+ var H = /* @__PURE__ */ Symbol("_close");
384
+ var ee = /* @__PURE__ */ Symbol("_ended");
385
+ var m = /* @__PURE__ */ Symbol("_fd");
386
+ var xi = /* @__PURE__ */ Symbol("_finished");
387
+ var J = /* @__PURE__ */ Symbol("_flags");
388
+ var Li = /* @__PURE__ */ Symbol("_flush");
389
+ var Ii = /* @__PURE__ */ Symbol("_handleChunk");
390
+ var Ci = /* @__PURE__ */ Symbol("_makeBuf");
391
+ var se = /* @__PURE__ */ Symbol("_mode");
392
+ var Fe = /* @__PURE__ */ Symbol("_needDrain");
393
+ var Ut = /* @__PURE__ */ Symbol("_onerror");
394
+ var Ht = /* @__PURE__ */ Symbol("_onopen");
395
+ var Ni = /* @__PURE__ */ Symbol("_onread");
396
+ var Pt = /* @__PURE__ */ Symbol("_onwrite");
397
+ var ht = /* @__PURE__ */ Symbol("_open");
398
+ var U = /* @__PURE__ */ Symbol("_path");
399
+ var nt = /* @__PURE__ */ Symbol("_pos");
400
+ var Y = /* @__PURE__ */ Symbol("_queue");
401
+ var zt = /* @__PURE__ */ Symbol("_read");
402
+ var Ai = /* @__PURE__ */ Symbol("_readSize");
403
+ var Q = /* @__PURE__ */ Symbol("_reading");
404
+ var ie = /* @__PURE__ */ Symbol("_remain");
405
+ var Di = /* @__PURE__ */ Symbol("_size");
406
+ var ke = /* @__PURE__ */ Symbol("_write");
407
+ var Rt = /* @__PURE__ */ Symbol("_writing");
408
+ var ve = /* @__PURE__ */ Symbol("_defaultFlag");
409
+ var bt = /* @__PURE__ */ Symbol("_errored");
410
+ var _t = class extends D {
411
+ [bt] = false;
412
+ [m];
413
+ [U];
414
+ [Ai];
415
+ [Q] = false;
416
+ [Di];
417
+ [ie];
418
+ [ot];
419
+ constructor(t, e) {
420
+ if (e = e || {}, super(e), this.readable = true, this.writable = false, typeof t != "string") throw new TypeError("path must be a string");
421
+ this[bt] = false, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[U] = t, this[Ai] = e.readSize || 16 * 1024 * 1024, this[Q] = false, this[Di] = typeof e.size == "number" ? e.size : 1 / 0, this[ie] = this[Di], this[ot] = typeof e.autoClose == "boolean" ? e.autoClose : true, typeof this[m] == "number" ? this[zt]() : this[ht]();
422
+ }
423
+ get fd() {
424
+ return this[m];
425
+ }
426
+ get path() {
427
+ return this[U];
428
+ }
429
+ write() {
430
+ throw new TypeError("this is a readable stream");
431
+ }
432
+ end() {
433
+ throw new TypeError("this is a readable stream");
434
+ }
435
+ [ht]() {
436
+ I.open(this[U], "r", (t, e) => this[Ht](t, e));
437
+ }
438
+ [Ht](t, e) {
439
+ t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[zt]());
440
+ }
441
+ [Ci]() {
442
+ return Buffer.allocUnsafe(Math.min(this[Ai], this[ie]));
443
+ }
444
+ [zt]() {
445
+ if (!this[Q]) {
446
+ this[Q] = true;
447
+ let t = this[Ci]();
448
+ if (t.length === 0) return process.nextTick(() => this[Ni](null, 0, t));
449
+ I.read(this[m], t, 0, t.length, null, (e, i, r) => this[Ni](e, i, r));
450
+ }
451
+ }
452
+ [Ni](t, e, i) {
453
+ this[Q] = false, t ? this[Ut](t) : this[Ii](e, i) && this[zt]();
454
+ }
455
+ [H]() {
456
+ if (this[ot] && typeof this[m] == "number") {
457
+ let t = this[m];
458
+ this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
459
+ }
460
+ }
461
+ [Ut](t) {
462
+ this[Q] = true, this[H](), this.emit("error", t);
463
+ }
464
+ [Ii](t, e) {
465
+ let i = false;
466
+ return this[ie] -= t, t > 0 && (i = super.write(t < e.length ? e.subarray(0, t) : e)), (t === 0 || this[ie] <= 0) && (i = false, this[H](), super.end()), i;
467
+ }
468
+ emit(t, ...e) {
469
+ switch (t) {
470
+ case "prefinish":
471
+ case "finish":
472
+ return false;
473
+ case "drain":
474
+ return typeof this[m] == "number" && this[zt](), false;
475
+ case "error":
476
+ return this[bt] ? false : (this[bt] = true, super.emit(t, ...e));
477
+ default:
478
+ return super.emit(t, ...e);
479
+ }
480
+ }
481
+ };
482
+ var Me = class extends _t {
483
+ [ht]() {
484
+ let t = true;
485
+ try {
486
+ this[Ht](null, I.openSync(this[U], "r")), t = false;
487
+ } finally {
488
+ t && this[H]();
489
+ }
490
+ }
491
+ [zt]() {
492
+ let t = true;
493
+ try {
494
+ if (!this[Q]) {
495
+ this[Q] = true;
496
+ do {
497
+ let e = this[Ci](), i = e.length === 0 ? 0 : I.readSync(this[m], e, 0, e.length, null);
498
+ if (!this[Ii](i, e)) break;
499
+ } while (true);
500
+ this[Q] = false;
501
+ }
502
+ t = false;
503
+ } finally {
504
+ t && this[H]();
505
+ }
506
+ }
507
+ [H]() {
508
+ if (this[ot] && typeof this[m] == "number") {
509
+ let t = this[m];
510
+ this[m] = void 0, I.closeSync(t), this.emit("close");
511
+ }
512
+ }
513
+ };
514
+ var tt = class extends Kr {
515
+ readable = false;
516
+ writable = true;
517
+ [bt] = false;
518
+ [Rt] = false;
519
+ [ee] = false;
520
+ [Y] = [];
521
+ [Fe] = false;
522
+ [U];
523
+ [se];
524
+ [ot];
525
+ [m];
526
+ [ve];
527
+ [J];
528
+ [xi] = false;
529
+ [nt];
530
+ constructor(t, e) {
531
+ e = e || {}, super(e), this[U] = t, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[se] = e.mode === void 0 ? 438 : e.mode, this[nt] = typeof e.start == "number" ? e.start : void 0, this[ot] = typeof e.autoClose == "boolean" ? e.autoClose : true;
532
+ let i = this[nt] !== void 0 ? "r+" : "w";
533
+ this[ve] = e.flags === void 0, this[J] = e.flags === void 0 ? i : e.flags, this[m] === void 0 && this[ht]();
534
+ }
535
+ emit(t, ...e) {
536
+ if (t === "error") {
537
+ if (this[bt]) return false;
538
+ this[bt] = true;
539
+ }
540
+ return super.emit(t, ...e);
541
+ }
542
+ get fd() {
543
+ return this[m];
544
+ }
545
+ get path() {
546
+ return this[U];
547
+ }
548
+ [Ut](t) {
549
+ this[H](), this[Rt] = true, this.emit("error", t);
550
+ }
551
+ [ht]() {
552
+ I.open(this[U], this[J], this[se], (t, e) => this[Ht](t, e));
553
+ }
554
+ [Ht](t, e) {
555
+ this[ve] && this[J] === "r+" && t && t.code === "ENOENT" ? (this[J] = "w", this[ht]()) : t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[Rt] || this[Li]());
556
+ }
557
+ end(t, e) {
558
+ return t && this.write(t, e), this[ee] = true, !this[Rt] && !this[Y].length && typeof this[m] == "number" && this[Pt](null, 0), this;
559
+ }
560
+ write(t, e) {
561
+ return typeof t == "string" && (t = Buffer.from(t, e)), this[ee] ? (this.emit("error", new Error("write() after end()")), false) : this[m] === void 0 || this[Rt] || this[Y].length ? (this[Y].push(t), this[Fe] = true, false) : (this[Rt] = true, this[ke](t), true);
562
+ }
563
+ [ke](t) {
564
+ I.write(this[m], t, 0, t.length, this[nt], (e, i) => this[Pt](e, i));
565
+ }
566
+ [Pt](t, e) {
567
+ t ? this[Ut](t) : (this[nt] !== void 0 && typeof e == "number" && (this[nt] += e), this[Y].length ? this[Li]() : (this[Rt] = false, this[ee] && !this[xi] ? (this[xi] = true, this[H](), this.emit("finish")) : this[Fe] && (this[Fe] = false, this.emit("drain"))));
568
+ }
569
+ [Li]() {
570
+ if (this[Y].length === 0) this[ee] && this[Pt](null, 0);
571
+ else if (this[Y].length === 1) this[ke](this[Y].pop());
572
+ else {
573
+ let t = this[Y];
574
+ this[Y] = [], Vr(this[m], t, this[nt], (e, i) => this[Pt](e, i));
575
+ }
576
+ }
577
+ [H]() {
578
+ if (this[ot] && typeof this[m] == "number") {
579
+ let t = this[m];
580
+ this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
581
+ }
582
+ }
583
+ };
584
+ var Wt = class extends tt {
585
+ [ht]() {
586
+ let t;
587
+ if (this[ve] && this[J] === "r+") try {
588
+ t = I.openSync(this[U], this[J], this[se]);
589
+ } catch (e) {
590
+ if (e?.code === "ENOENT") return this[J] = "w", this[ht]();
591
+ throw e;
592
+ }
593
+ else t = I.openSync(this[U], this[J], this[se]);
594
+ this[Ht](null, t);
595
+ }
596
+ [H]() {
597
+ if (this[ot] && typeof this[m] == "number") {
598
+ let t = this[m];
599
+ this[m] = void 0, I.closeSync(t), this.emit("close");
600
+ }
601
+ }
602
+ [ke](t) {
603
+ let e = true;
604
+ try {
605
+ this[Pt](null, I.writeSync(this[m], t, 0, t.length, this[nt])), e = false;
606
+ } finally {
607
+ if (e) try {
608
+ this[H]();
609
+ } catch {
610
+ }
611
+ }
612
+ }
613
+ };
614
+ var $r = /* @__PURE__ */ new Map([["C", "cwd"], ["f", "file"], ["z", "gzip"], ["P", "preservePaths"], ["U", "unlink"], ["strip-components", "strip"], ["stripComponents", "strip"], ["keep-newer", "newer"], ["keepNewer", "newer"], ["keep-newer-files", "newer"], ["keepNewerFiles", "newer"], ["k", "keep"], ["keep-existing", "keep"], ["keepExisting", "keep"], ["m", "noMtime"], ["no-mtime", "noMtime"], ["p", "preserveOwner"], ["L", "follow"], ["h", "follow"], ["onentry", "onReadEntry"]]);
615
+ var As = (s3) => !!s3.sync && !!s3.file;
616
+ var Ds = (s3) => !s3.sync && !!s3.file;
617
+ var Is = (s3) => !!s3.sync && !s3.file;
618
+ var Cs = (s3) => !s3.sync && !s3.file;
619
+ var Fs = (s3) => !!s3.file;
620
+ var Xr = (s3) => {
621
+ let t = $r.get(s3);
622
+ return t || s3;
623
+ };
624
+ var re = (s3 = {}) => {
625
+ if (!s3) return {};
626
+ let t = {};
627
+ for (let [e, i] of Object.entries(s3)) {
628
+ let r = Xr(e);
629
+ t[r] = i;
630
+ }
631
+ return t.chmod === void 0 && t.noChmod === false && (t.chmod = true), delete t.noChmod, t;
632
+ };
633
+ var K = (s3, t, e, i, r) => Object.assign((n = [], o, h) => {
634
+ Array.isArray(n) && (o = n, n = {}), typeof o == "function" && (h = o, o = void 0), o = o ? Array.from(o) : [];
635
+ let a = re(n);
636
+ if (r?.(a, o), As(a)) {
637
+ if (typeof h == "function") throw new TypeError("callback not supported for sync tar functions");
638
+ return s3(a, o);
639
+ } else if (Ds(a)) {
640
+ let l = t(a, o);
641
+ return h ? l.then(() => h(), h) : l;
642
+ } else if (Is(a)) {
643
+ if (typeof h == "function") throw new TypeError("callback not supported for sync tar functions");
644
+ return e(a, o);
645
+ } else if (Cs(a)) {
646
+ if (typeof h == "function") throw new TypeError("callback only supported with file option");
647
+ return i(a, o);
648
+ }
649
+ throw new Error("impossible options??");
650
+ }, { syncFile: s3, asyncFile: t, syncNoFile: e, asyncNoFile: i, validate: r });
651
+ var jr = qr.constants || { ZLIB_VERNUM: 4736 };
652
+ var M = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BLOCK: 5, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1, Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_MEM_ERROR: -4, Z_BUF_ERROR: -5, Z_VERSION_ERROR: -6, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4, Z_DEFAULT_STRATEGY: 0, DEFLATE: 1, INFLATE: 2, GZIP: 3, GUNZIP: 4, DEFLATERAW: 5, INFLATERAW: 6, UNZIP: 7, BROTLI_DECODE: 8, BROTLI_ENCODE: 9, Z_MIN_WINDOWBITS: 8, Z_MAX_WINDOWBITS: 15, Z_DEFAULT_WINDOWBITS: 15, Z_MIN_CHUNK: 64, Z_MAX_CHUNK: 1 / 0, Z_DEFAULT_CHUNK: 16384, Z_MIN_MEMLEVEL: 1, Z_MAX_MEMLEVEL: 9, Z_DEFAULT_MEMLEVEL: 8, Z_MIN_LEVEL: -1, Z_MAX_LEVEL: 9, Z_DEFAULT_LEVEL: -1, BROTLI_OPERATION_PROCESS: 0, BROTLI_OPERATION_FLUSH: 1, BROTLI_OPERATION_FINISH: 2, BROTLI_OPERATION_EMIT_METADATA: 3, BROTLI_MODE_GENERIC: 0, BROTLI_MODE_TEXT: 1, BROTLI_MODE_FONT: 2, BROTLI_DEFAULT_MODE: 0, BROTLI_MIN_QUALITY: 0, BROTLI_MAX_QUALITY: 11, BROTLI_DEFAULT_QUALITY: 11, BROTLI_MIN_WINDOW_BITS: 10, BROTLI_MAX_WINDOW_BITS: 24, BROTLI_LARGE_MAX_WINDOW_BITS: 30, BROTLI_DEFAULT_WINDOW: 22, BROTLI_MIN_INPUT_BLOCK_BITS: 16, BROTLI_MAX_INPUT_BLOCK_BITS: 24, BROTLI_PARAM_MODE: 0, BROTLI_PARAM_QUALITY: 1, BROTLI_PARAM_LGWIN: 2, BROTLI_PARAM_LGBLOCK: 3, BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4, BROTLI_PARAM_SIZE_HINT: 5, BROTLI_PARAM_LARGE_WINDOW: 6, BROTLI_PARAM_NPOSTFIX: 7, BROTLI_PARAM_NDIRECT: 8, BROTLI_DECODER_RESULT_ERROR: 0, BROTLI_DECODER_RESULT_SUCCESS: 1, BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2, BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3, BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0, BROTLI_DECODER_PARAM_LARGE_WINDOW: 1, BROTLI_DECODER_NO_ERROR: 0, BROTLI_DECODER_SUCCESS: 1, BROTLI_DECODER_NEEDS_MORE_INPUT: 2, BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1, BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5, BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6, BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7, BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10, BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11, BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12, BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13, BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14, BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15, BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16, BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19, BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21, BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27, BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30, BROTLI_DECODER_ERROR_UNREACHABLE: -31 }, jr));
653
+ var Qr = gt.concat;
654
+ var vs = Object.getOwnPropertyDescriptor(gt, "concat");
655
+ var Jr = (s3) => s3;
656
+ var ki = vs?.writable === true || vs?.set !== void 0 ? (s3) => {
657
+ gt.concat = s3 ? Jr : Qr;
658
+ } : (s3) => {
659
+ };
660
+ var Ot = /* @__PURE__ */ Symbol("_superWrite");
661
+ var Gt = class extends Error {
662
+ code;
663
+ errno;
664
+ constructor(t, e) {
665
+ super("zlib: " + t.message, { cause: t }), this.code = t.code, this.errno = t.errno, this.code || (this.code = "ZLIB_ERROR"), this.message = "zlib: " + t.message, Error.captureStackTrace(this, e ?? this.constructor);
666
+ }
667
+ get name() {
668
+ return "ZlibError";
669
+ }
670
+ };
671
+ var vi = /* @__PURE__ */ Symbol("flushFlag");
672
+ var ne = class extends D {
673
+ #t = false;
674
+ #i = false;
675
+ #s;
676
+ #n;
677
+ #r;
678
+ #e;
679
+ #o;
680
+ get sawError() {
681
+ return this.#t;
682
+ }
683
+ get handle() {
684
+ return this.#e;
685
+ }
686
+ get flushFlag() {
687
+ return this.#s;
688
+ }
689
+ constructor(t, e) {
690
+ if (!t || typeof t != "object") throw new TypeError("invalid options for ZlibBase constructor");
691
+ if (super(t), this.#s = t.flush ?? 0, this.#n = t.finishFlush ?? 0, this.#r = t.fullFlushFlag ?? 0, typeof ks[e] != "function") throw new TypeError("Compression method not supported: " + e);
692
+ try {
693
+ this.#e = new ks[e](t);
694
+ } catch (i) {
695
+ throw new Gt(i, this.constructor);
696
+ }
697
+ this.#o = (i) => {
698
+ this.#t || (this.#t = true, this.close(), this.emit("error", i));
699
+ }, this.#e?.on("error", (i) => this.#o(new Gt(i))), this.once("end", () => this.close);
700
+ }
701
+ close() {
702
+ this.#e && (this.#e.close(), this.#e = void 0, this.emit("close"));
703
+ }
704
+ reset() {
705
+ if (!this.#t) return Mi(this.#e, "zlib binding closed"), this.#e.reset?.();
706
+ }
707
+ flush(t) {
708
+ this.ended || (typeof t != "number" && (t = this.#r), this.write(Object.assign(gt.alloc(0), { [vi]: t })));
709
+ }
710
+ end(t, e, i) {
711
+ return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), t && (e ? this.write(t, e) : this.write(t)), this.flush(this.#n), this.#i = true, super.end(i);
712
+ }
713
+ get ended() {
714
+ return this.#i;
715
+ }
716
+ [Ot](t) {
717
+ return super.write(t);
718
+ }
719
+ write(t, e, i) {
720
+ if (typeof e == "function" && (i = e, e = "utf8"), typeof t == "string" && (t = gt.from(t, e)), this.#t) return;
721
+ Mi(this.#e, "zlib binding closed");
722
+ let r = this.#e._handle, n = r.close;
723
+ r.close = () => {
724
+ };
725
+ let o = this.#e.close;
726
+ this.#e.close = () => {
727
+ }, ki(true);
728
+ let h;
729
+ try {
730
+ let l = typeof t[vi] == "number" ? t[vi] : this.#s;
731
+ h = this.#e._processChunk(t, l), ki(false);
732
+ } catch (l) {
733
+ ki(false), this.#o(new Gt(l, this.write));
734
+ } finally {
735
+ this.#e && (this.#e._handle = r, r.close = n, this.#e.close = o, this.#e.removeAllListeners("error"));
736
+ }
737
+ this.#e && this.#e.on("error", (l) => this.#o(new Gt(l, this.write)));
738
+ let a;
739
+ if (h) if (Array.isArray(h) && h.length > 0) {
740
+ let l = h[0];
741
+ a = this[Ot](gt.from(l));
742
+ for (let c = 1; c < h.length; c++) a = this[Ot](h[c]);
743
+ } else a = this[Ot](gt.from(h));
744
+ return i && i(), a;
745
+ }
746
+ };
747
+ var Be = class extends ne {
748
+ #t;
749
+ #i;
750
+ constructor(t, e) {
751
+ t = t || {}, t.flush = t.flush || M.Z_NO_FLUSH, t.finishFlush = t.finishFlush || M.Z_FINISH, t.fullFlushFlag = M.Z_FULL_FLUSH, super(t, e), this.#t = t.level, this.#i = t.strategy;
752
+ }
753
+ params(t, e) {
754
+ if (!this.sawError) {
755
+ if (!this.handle) throw new Error("cannot switch params when binding is closed");
756
+ if (!this.handle.params) throw new Error("not supported in this implementation");
757
+ if (this.#t !== t || this.#i !== e) {
758
+ this.flush(M.Z_SYNC_FLUSH), Mi(this.handle, "zlib binding closed");
759
+ let i = this.handle.flush;
760
+ this.handle.flush = (r, n) => {
761
+ typeof r == "function" && (n = r, r = this.flushFlag), this.flush(r), n?.();
762
+ };
763
+ try {
764
+ this.handle.params(t, e);
765
+ } finally {
766
+ this.handle.flush = i;
767
+ }
768
+ this.handle && (this.#t = t, this.#i = e);
769
+ }
770
+ }
771
+ }
772
+ };
773
+ var Pe = class extends Be {
774
+ #t;
775
+ constructor(t) {
776
+ super(t, "Gzip"), this.#t = t && !!t.portable;
777
+ }
778
+ [Ot](t) {
779
+ return this.#t ? (this.#t = false, t[9] = 255, super[Ot](t)) : super[Ot](t);
780
+ }
781
+ };
782
+ var ze = class extends Be {
783
+ constructor(t) {
784
+ super(t, "Unzip");
785
+ }
786
+ };
787
+ var Ue = class extends ne {
788
+ constructor(t, e) {
789
+ t = t || {}, t.flush = t.flush || M.BROTLI_OPERATION_PROCESS, t.finishFlush = t.finishFlush || M.BROTLI_OPERATION_FINISH, t.fullFlushFlag = M.BROTLI_OPERATION_FLUSH, super(t, e);
790
+ }
791
+ };
792
+ var He = class extends Ue {
793
+ constructor(t) {
794
+ super(t, "BrotliCompress");
795
+ }
796
+ };
797
+ var We = class extends Ue {
798
+ constructor(t) {
799
+ super(t, "BrotliDecompress");
800
+ }
801
+ };
802
+ var Ge = class extends ne {
803
+ constructor(t, e) {
804
+ t = t || {}, t.flush = t.flush || M.ZSTD_e_continue, t.finishFlush = t.finishFlush || M.ZSTD_e_end, t.fullFlushFlag = M.ZSTD_e_flush, super(t, e);
805
+ }
806
+ };
807
+ var Ze = class extends Ge {
808
+ constructor(t) {
809
+ super(t, "ZstdCompress");
810
+ }
811
+ };
812
+ var Ye = class extends Ge {
813
+ constructor(t) {
814
+ super(t, "ZstdDecompress");
815
+ }
816
+ };
817
+ var Ms = (s3, t) => {
818
+ if (Number.isSafeInteger(s3)) s3 < 0 ? sn(s3, t) : en(s3, t);
819
+ else throw Error("cannot encode number outside of javascript safe integer range");
820
+ return t;
821
+ };
822
+ var en = (s3, t) => {
823
+ t[0] = 128;
824
+ for (var e = t.length; e > 1; e--) t[e - 1] = s3 & 255, s3 = Math.floor(s3 / 256);
825
+ };
826
+ var sn = (s3, t) => {
827
+ t[0] = 255;
828
+ var e = false;
829
+ s3 = s3 * -1;
830
+ for (var i = t.length; i > 1; i--) {
831
+ var r = s3 & 255;
832
+ s3 = Math.floor(s3 / 256), e ? t[i - 1] = Ps(r) : r === 0 ? t[i - 1] = 0 : (e = true, t[i - 1] = zs(r));
833
+ }
834
+ };
835
+ var Bs = (s3) => {
836
+ let t = s3[0], e = t === 128 ? nn(s3.subarray(1, s3.length)) : t === 255 ? rn(s3) : null;
837
+ if (e === null) throw Error("invalid base256 encoding");
838
+ if (!Number.isSafeInteger(e)) throw Error("parsed number outside of javascript safe integer range");
839
+ return e;
840
+ };
841
+ var rn = (s3) => {
842
+ for (var t = s3.length, e = 0, i = false, r = t - 1; r > -1; r--) {
843
+ var n = Number(s3[r]), o;
844
+ i ? o = Ps(n) : n === 0 ? o = n : (i = true, o = zs(n)), o !== 0 && (e -= o * Math.pow(256, t - r - 1));
845
+ }
846
+ return e;
847
+ };
848
+ var nn = (s3) => {
849
+ for (var t = s3.length, e = 0, i = t - 1; i > -1; i--) {
850
+ var r = Number(s3[i]);
851
+ r !== 0 && (e += r * Math.pow(256, t - i - 1));
852
+ }
853
+ return e;
854
+ };
855
+ var Ps = (s3) => (255 ^ s3) & 255;
856
+ var zs = (s3) => (255 ^ s3) + 1 & 255;
857
+ var Bi = {};
858
+ vr(Bi, { code: () => Ke, isCode: () => oe, isName: () => hn, name: () => he });
859
+ var oe = (s3) => he.has(s3);
860
+ var hn = (s3) => Ke.has(s3);
861
+ var he = /* @__PURE__ */ new Map([["0", "File"], ["", "OldFile"], ["1", "Link"], ["2", "SymbolicLink"], ["3", "CharacterDevice"], ["4", "BlockDevice"], ["5", "Directory"], ["6", "FIFO"], ["7", "ContiguousFile"], ["g", "GlobalExtendedHeader"], ["x", "ExtendedHeader"], ["A", "SolarisACL"], ["D", "GNUDumpDir"], ["I", "Inode"], ["K", "NextFileHasLongLinkpath"], ["L", "NextFileHasLongPath"], ["M", "ContinuationFile"], ["N", "OldGnuLongPath"], ["S", "SparseFile"], ["V", "TapeVolumeHeader"], ["X", "OldExtendedHeader"]]);
862
+ var Ke = new Map(Array.from(he).map((s3) => [s3[1], s3[0]]));
863
+ var F = class {
864
+ cksumValid = false;
865
+ needPax = false;
866
+ nullBlock = false;
867
+ block;
868
+ path;
869
+ mode;
870
+ uid;
871
+ gid;
872
+ size;
873
+ cksum;
874
+ #t = "Unsupported";
875
+ linkpath;
876
+ uname;
877
+ gname;
878
+ devmaj = 0;
879
+ devmin = 0;
880
+ atime;
881
+ ctime;
882
+ mtime;
883
+ charset;
884
+ comment;
885
+ constructor(t, e = 0, i, r) {
886
+ Buffer.isBuffer(t) ? this.decode(t, e || 0, i, r) : t && this.#i(t);
887
+ }
888
+ decode(t, e, i, r) {
889
+ if (e || (e = 0), !t || !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
890
+ this.path = i?.path ?? Tt(t, e, 100), this.mode = i?.mode ?? r?.mode ?? at(t, e + 100, 8), this.uid = i?.uid ?? r?.uid ?? at(t, e + 108, 8), this.gid = i?.gid ?? r?.gid ?? at(t, e + 116, 8), this.size = i?.size ?? r?.size ?? at(t, e + 124, 12), this.mtime = i?.mtime ?? r?.mtime ?? Pi(t, e + 136, 12), this.cksum = at(t, e + 148, 12), r && this.#i(r, true), i && this.#i(i);
891
+ let n = Tt(t, e + 156, 1);
892
+ if (oe(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = Tt(t, e + 157, 100), t.subarray(e + 257, e + 265).toString() === "ustar\x0000") if (this.uname = i?.uname ?? r?.uname ?? Tt(t, e + 265, 32), this.gname = i?.gname ?? r?.gname ?? Tt(t, e + 297, 32), this.devmaj = i?.devmaj ?? r?.devmaj ?? at(t, e + 329, 8) ?? 0, this.devmin = i?.devmin ?? r?.devmin ?? at(t, e + 337, 8) ?? 0, t[e + 475] !== 0) {
893
+ let h = Tt(t, e + 345, 155);
894
+ this.path = h + "/" + this.path;
895
+ } else {
896
+ let h = Tt(t, e + 345, 130);
897
+ h && (this.path = h + "/" + this.path), this.atime = i?.atime ?? r?.atime ?? Pi(t, e + 476, 12), this.ctime = i?.ctime ?? r?.ctime ?? Pi(t, e + 488, 12);
898
+ }
899
+ let o = 256;
900
+ for (let h = e; h < e + 148; h++) o += t[h];
901
+ for (let h = e + 156; h < e + 512; h++) o += t[h];
902
+ this.cksumValid = o === this.cksum, this.cksum === void 0 && o === 256 && (this.nullBlock = true);
903
+ }
904
+ #i(t, e = false) {
905
+ Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e || i === "linkpath" && e || i === "global"))));
906
+ }
907
+ encode(t, e = 0) {
908
+ if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
909
+ let i = this.ctime || this.atime ? 130 : 155, r = an(this.path || "", i), n = r[0], o = r[1];
910
+ this.needPax = !!r[2], this.needPax = xt(t, e, 100, n) || this.needPax, this.needPax = lt(t, e + 100, 8, this.mode) || this.needPax, this.needPax = lt(t, e + 108, 8, this.uid) || this.needPax, this.needPax = lt(t, e + 116, 8, this.gid) || this.needPax, this.needPax = lt(t, e + 124, 12, this.size) || this.needPax, this.needPax = zi(t, e + 136, 12, this.mtime) || this.needPax, t[e + 156] = Number(this.#t.codePointAt(0)), this.needPax = xt(t, e + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e + 257, 8), this.needPax = xt(t, e + 265, 32, this.uname) || this.needPax, this.needPax = xt(t, e + 297, 32, this.gname) || this.needPax, this.needPax = lt(t, e + 329, 8, this.devmaj) || this.needPax, this.needPax = lt(t, e + 337, 8, this.devmin) || this.needPax, this.needPax = xt(t, e + 345, i, o) || this.needPax, t[e + 475] !== 0 ? this.needPax = xt(t, e + 345, 155, o) || this.needPax : (this.needPax = xt(t, e + 345, 130, o) || this.needPax, this.needPax = zi(t, e + 476, 12, this.atime) || this.needPax, this.needPax = zi(t, e + 488, 12, this.ctime) || this.needPax);
911
+ let h = 256;
912
+ for (let a = e; a < e + 148; a++) h += t[a];
913
+ for (let a = e + 156; a < e + 512; a++) h += t[a];
914
+ return this.cksum = h, lt(t, e + 148, 8, this.cksum), this.cksumValid = true, this.needPax;
915
+ }
916
+ get type() {
917
+ return this.#t === "Unsupported" ? this.#t : he.get(this.#t);
918
+ }
919
+ get typeKey() {
920
+ return this.#t;
921
+ }
922
+ set type(t) {
923
+ let e = String(Ke.get(t));
924
+ if (oe(e) || e === "Unsupported") this.#t = e;
925
+ else if (oe(t)) this.#t = t;
926
+ else throw new TypeError("invalid entry type: " + t);
927
+ }
928
+ };
929
+ var an = (s3, t) => {
930
+ let i = s3, r = "", n, o = Zt.parse(s3).root || ".";
931
+ if (Buffer.byteLength(i) < 100) n = [i, r, false];
932
+ else {
933
+ r = Zt.dirname(i), i = Zt.basename(i);
934
+ do
935
+ Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i = Zt.join(Zt.basename(r), i), r = Zt.dirname(r));
936
+ while (r !== o && n === void 0);
937
+ n || (n = [s3.slice(0, 99), "", true]);
938
+ }
939
+ return n;
940
+ };
941
+ var Tt = (s3, t, e) => s3.subarray(t, t + e).toString("utf8").replace(/\0.*/, "");
942
+ var Pi = (s3, t, e) => ln(at(s3, t, e));
943
+ var ln = (s3) => s3 === void 0 ? void 0 : new Date(s3 * 1e3);
944
+ var at = (s3, t, e) => Number(s3[t]) & 128 ? Bs(s3.subarray(t, t + e)) : fn(s3, t, e);
945
+ var cn = (s3) => isNaN(s3) ? void 0 : s3;
946
+ var fn = (s3, t, e) => cn(parseInt(s3.subarray(t, t + e).toString("utf8").replace(/\0.*$/, "").trim(), 8));
947
+ var dn = { 12: 8589934591, 8: 2097151 };
948
+ var lt = (s3, t, e, i) => i === void 0 ? false : i > dn[e] || i < 0 ? (Ms(i, s3.subarray(t, t + e)), true) : (un(s3, t, e, i), false);
949
+ var un = (s3, t, e, i) => s3.write(mn(i, e), t, e, "ascii");
950
+ var mn = (s3, t) => pn(Math.floor(s3).toString(8), t);
951
+ var pn = (s3, t) => (s3.length === t - 1 ? s3 : new Array(t - s3.length - 1).join("0") + s3 + " ") + "\0";
952
+ var zi = (s3, t, e, i) => i === void 0 ? false : lt(s3, t, e, i.getTime() / 1e3);
953
+ var En = new Array(156).join("\0");
954
+ var xt = (s3, t, e, i) => i === void 0 ? false : (s3.write(i + En, t, e, "utf8"), i.length !== Buffer.byteLength(i) || i.length > e);
955
+ var ct = class s {
956
+ atime;
957
+ mtime;
958
+ ctime;
959
+ charset;
960
+ comment;
961
+ gid;
962
+ uid;
963
+ gname;
964
+ uname;
965
+ linkpath;
966
+ dev;
967
+ ino;
968
+ nlink;
969
+ path;
970
+ size;
971
+ mode;
972
+ global;
973
+ constructor(t, e = false) {
974
+ this.atime = t.atime, this.charset = t.charset, this.comment = t.comment, this.ctime = t.ctime, this.dev = t.dev, this.gid = t.gid, this.global = e, this.gname = t.gname, this.ino = t.ino, this.linkpath = t.linkpath, this.mtime = t.mtime, this.nlink = t.nlink, this.path = t.path, this.size = t.size, this.uid = t.uid, this.uname = t.uname;
975
+ }
976
+ encode() {
977
+ let t = this.encodeBody();
978
+ if (t === "") return Buffer.allocUnsafe(0);
979
+ let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
980
+ for (let n = 0; n < 512; n++) r[n] = 0;
981
+ new F({ path: ("PaxHeader/" + wn(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r), r.write(t, 512, e, "utf8");
982
+ for (let n = e + 512; n < r.length; n++) r[n] = 0;
983
+ return r;
984
+ }
985
+ encodeBody() {
986
+ return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
987
+ }
988
+ encodeField(t) {
989
+ if (this[t] === void 0) return "";
990
+ let e = this[t], i = e instanceof Date ? e.getTime() / 1e3 : e, r = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
991
+ `, n = Buffer.byteLength(r), o = Math.floor(Math.log(n) / Math.log(10)) + 1;
992
+ return n + o >= Math.pow(10, o) && (o += 1), o + n + r;
993
+ }
994
+ static parse(t, e, i = false) {
995
+ return new s(Sn(yn(t), e), i);
996
+ }
997
+ };
998
+ var Sn = (s3, t) => t ? Object.assign({}, t, s3) : s3;
999
+ var yn = (s3) => s3.replace(/\n$/, "").split(`
1000
+ `).reduce(Rn, /* @__PURE__ */ Object.create(null));
1001
+ var Rn = (s3, t) => {
1002
+ let e = parseInt(t, 10);
1003
+ if (e !== Buffer.byteLength(t) + 1) return s3;
1004
+ t = t.slice((e + " ").length);
1005
+ let i = t.split("="), r = i.shift();
1006
+ if (!r) return s3;
1007
+ let n = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o = i.join("=");
1008
+ return s3[n] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n) ? new Date(Number(o) * 1e3) : /^[0-9]+$/.test(o) ? +o : o, s3;
1009
+ };
1010
+ var bn = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
1011
+ var f = bn !== "win32" ? (s3) => s3 : (s3) => s3 && s3.replaceAll(/\\/g, "/");
1012
+ var Yt = class extends D {
1013
+ extended;
1014
+ globalExtended;
1015
+ header;
1016
+ startBlockSize;
1017
+ blockRemain;
1018
+ remain;
1019
+ type;
1020
+ meta = false;
1021
+ ignore = false;
1022
+ path;
1023
+ mode;
1024
+ uid;
1025
+ gid;
1026
+ uname;
1027
+ gname;
1028
+ size = 0;
1029
+ mtime;
1030
+ atime;
1031
+ ctime;
1032
+ linkpath;
1033
+ dev;
1034
+ ino;
1035
+ nlink;
1036
+ invalid = false;
1037
+ absolute;
1038
+ unsupported = false;
1039
+ constructor(t, e, i) {
1040
+ switch (super({}), this.pause(), this.extended = e, this.globalExtended = i, this.header = t, this.remain = t.size ?? 0, this.startBlockSize = 512 * Math.ceil(this.remain / 512), this.blockRemain = this.startBlockSize, this.type = t.type, this.type) {
1041
+ case "File":
1042
+ case "OldFile":
1043
+ case "Link":
1044
+ case "SymbolicLink":
1045
+ case "CharacterDevice":
1046
+ case "BlockDevice":
1047
+ case "Directory":
1048
+ case "FIFO":
1049
+ case "ContiguousFile":
1050
+ case "GNUDumpDir":
1051
+ break;
1052
+ case "NextFileHasLongLinkpath":
1053
+ case "NextFileHasLongPath":
1054
+ case "OldGnuLongPath":
1055
+ case "GlobalExtendedHeader":
1056
+ case "ExtendedHeader":
1057
+ case "OldExtendedHeader":
1058
+ this.meta = true;
1059
+ break;
1060
+ default:
1061
+ this.ignore = true;
1062
+ }
1063
+ if (!t.path) throw new Error("no path provided for tar.ReadEntry");
1064
+ this.path = f(t.path), this.mode = t.mode, this.mode && (this.mode = this.mode & 4095), this.uid = t.uid, this.gid = t.gid, this.uname = t.uname, this.gname = t.gname, this.size = this.remain, this.mtime = t.mtime, this.atime = t.atime, this.ctime = t.ctime, this.linkpath = t.linkpath ? f(t.linkpath) : void 0, this.uname = t.uname, this.gname = t.gname, e && this.#t(e), i && this.#t(i, true);
1065
+ }
1066
+ write(t) {
1067
+ let e = t.length;
1068
+ if (e > this.blockRemain) throw new Error("writing more to entry than is appropriate");
1069
+ let i = this.remain, r = this.blockRemain;
1070
+ return this.remain = Math.max(0, i - e), this.blockRemain = Math.max(0, r - e), this.ignore ? true : i >= e ? super.write(t) : super.write(t.subarray(0, i));
1071
+ }
1072
+ #t(t, e = false) {
1073
+ t.path && (t.path = f(t.path)), t.linkpath && (t.linkpath = f(t.linkpath)), Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e))));
1074
+ }
1075
+ };
1076
+ var Lt = (s3, t, e, i = {}) => {
1077
+ s3.file && (i.file = s3.file), s3.cwd && (i.cwd = s3.cwd), i.code = e instanceof Error && e.code || t, i.tarCode = t, !s3.strict && i.recoverable !== false ? (e instanceof Error && (i = Object.assign(e, i), e = e.message), s3.emit("warn", t, e, i)) : e instanceof Error ? s3.emit("error", Object.assign(e, i)) : s3.emit("error", Object.assign(new Error(`${t}: ${e}`), i));
1078
+ };
1079
+ var gn = 1024 * 1024;
1080
+ var Zi = Buffer.from([31, 139]);
1081
+ var Yi = Buffer.from([40, 181, 47, 253]);
1082
+ var On = Math.max(Zi.length, Yi.length);
1083
+ var B = /* @__PURE__ */ Symbol("state");
1084
+ var Nt = /* @__PURE__ */ Symbol("writeEntry");
1085
+ var et = /* @__PURE__ */ Symbol("readEntry");
1086
+ var Ui = /* @__PURE__ */ Symbol("nextEntry");
1087
+ var Us = /* @__PURE__ */ Symbol("processEntry");
1088
+ var V = /* @__PURE__ */ Symbol("extendedHeader");
1089
+ var ae = /* @__PURE__ */ Symbol("globalExtendedHeader");
1090
+ var ft = /* @__PURE__ */ Symbol("meta");
1091
+ var Hs = /* @__PURE__ */ Symbol("emitMeta");
1092
+ var p = /* @__PURE__ */ Symbol("buffer");
1093
+ var it = /* @__PURE__ */ Symbol("queue");
1094
+ var dt = /* @__PURE__ */ Symbol("ended");
1095
+ var Hi = /* @__PURE__ */ Symbol("emittedEnd");
1096
+ var At = /* @__PURE__ */ Symbol("emit");
1097
+ var y = /* @__PURE__ */ Symbol("unzip");
1098
+ var Ve = /* @__PURE__ */ Symbol("consumeChunk");
1099
+ var $e = /* @__PURE__ */ Symbol("consumeChunkSub");
1100
+ var Wi = /* @__PURE__ */ Symbol("consumeBody");
1101
+ var Ws = /* @__PURE__ */ Symbol("consumeMeta");
1102
+ var Gs = /* @__PURE__ */ Symbol("consumeHeader");
1103
+ var le = /* @__PURE__ */ Symbol("consuming");
1104
+ var Gi = /* @__PURE__ */ Symbol("bufferConcat");
1105
+ var Xe = /* @__PURE__ */ Symbol("maybeEnd");
1106
+ var Kt = /* @__PURE__ */ Symbol("writing");
1107
+ var ut = /* @__PURE__ */ Symbol("aborted");
1108
+ var qe = /* @__PURE__ */ Symbol("onDone");
1109
+ var Dt = /* @__PURE__ */ Symbol("sawValidEntry");
1110
+ var je = /* @__PURE__ */ Symbol("sawNullBlock");
1111
+ var Qe = /* @__PURE__ */ Symbol("sawEOF");
1112
+ var Zs = /* @__PURE__ */ Symbol("closeStream");
1113
+ var Tn = () => true;
1114
+ var st = class extends _n {
1115
+ file;
1116
+ strict;
1117
+ maxMetaEntrySize;
1118
+ filter;
1119
+ brotli;
1120
+ zstd;
1121
+ writable = true;
1122
+ readable = false;
1123
+ [it] = [];
1124
+ [p];
1125
+ [et];
1126
+ [Nt];
1127
+ [B] = "begin";
1128
+ [ft] = "";
1129
+ [V];
1130
+ [ae];
1131
+ [dt] = false;
1132
+ [y];
1133
+ [ut] = false;
1134
+ [Dt];
1135
+ [je] = false;
1136
+ [Qe] = false;
1137
+ [Kt] = false;
1138
+ [le] = false;
1139
+ [Hi] = false;
1140
+ constructor(t = {}) {
1141
+ super(), this.file = t.file || "", this.on(qe, () => {
1142
+ (this[B] === "begin" || this[Dt] === false) && this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
1143
+ }), t.ondone ? this.on(qe, t.ondone) : this.on(qe, () => {
1144
+ this.emit("prefinish"), this.emit("finish"), this.emit("end");
1145
+ }), this.strict = !!t.strict, this.maxMetaEntrySize = t.maxMetaEntrySize || gn, this.filter = typeof t.filter == "function" ? t.filter : Tn;
1146
+ let e = t.file && (t.file.endsWith(".tar.br") || t.file.endsWith(".tbr"));
1147
+ this.brotli = !(t.gzip || t.zstd) && t.brotli !== void 0 ? t.brotli : e ? void 0 : false;
1148
+ let i = t.file && (t.file.endsWith(".tar.zst") || t.file.endsWith(".tzst"));
1149
+ this.zstd = !(t.gzip || t.brotli) && t.zstd !== void 0 ? t.zstd : i ? true : void 0, this.on("end", () => this[Zs]()), typeof t.onwarn == "function" && this.on("warn", t.onwarn), typeof t.onReadEntry == "function" && this.on("entry", t.onReadEntry);
1150
+ }
1151
+ warn(t, e, i = {}) {
1152
+ Lt(this, t, e, i);
1153
+ }
1154
+ [Gs](t, e) {
1155
+ this[Dt] === void 0 && (this[Dt] = false);
1156
+ let i;
1157
+ try {
1158
+ i = new F(t, e, this[V], this[ae]);
1159
+ } catch (r) {
1160
+ return this.warn("TAR_ENTRY_INVALID", r);
1161
+ }
1162
+ if (i.nullBlock) this[je] ? (this[Qe] = true, this[B] === "begin" && (this[B] = "header"), this[At]("eof")) : (this[je] = true, this[At]("nullBlock"));
1163
+ else if (this[je] = false, !i.cksumValid) this.warn("TAR_ENTRY_INVALID", "checksum failure", { header: i });
1164
+ else if (!i.path) this.warn("TAR_ENTRY_INVALID", "path is required", { header: i });
1165
+ else {
1166
+ let r = i.type;
1167
+ if (/^(Symbolic)?Link$/.test(r) && !i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath required", { header: i });
1168
+ else if (!/^(Symbolic)?Link$/.test(r) && !/^(Global)?ExtendedHeader$/.test(r) && i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
1169
+ else {
1170
+ let n = this[Nt] = new Yt(i, this[V], this[ae]);
1171
+ if (!this[Dt]) if (n.remain) {
1172
+ let o = () => {
1173
+ n.invalid || (this[Dt] = true);
1174
+ };
1175
+ n.on("end", o);
1176
+ } else this[Dt] = true;
1177
+ n.meta ? n.size > this.maxMetaEntrySize ? (n.ignore = true, this[At]("ignoredEntry", n), this[B] = "ignore", n.resume()) : n.size > 0 && (this[ft] = "", n.on("data", (o) => this[ft] += o), this[B] = "meta") : (this[V] = void 0, n.ignore = n.ignore || !this.filter(n.path, n), n.ignore ? (this[At]("ignoredEntry", n), this[B] = n.remain ? "ignore" : "header", n.resume()) : (n.remain ? this[B] = "body" : (this[B] = "header", n.end()), this[et] ? this[it].push(n) : (this[it].push(n), this[Ui]())));
1178
+ }
1179
+ }
1180
+ }
1181
+ [Zs]() {
1182
+ queueMicrotask(() => this.emit("close"));
1183
+ }
1184
+ [Us](t) {
1185
+ let e = true;
1186
+ if (!t) this[et] = void 0, e = false;
1187
+ else if (Array.isArray(t)) {
1188
+ let [i, ...r] = t;
1189
+ this.emit(i, ...r);
1190
+ } else this[et] = t, this.emit("entry", t), t.emittedEnd || (t.on("end", () => this[Ui]()), e = false);
1191
+ return e;
1192
+ }
1193
+ [Ui]() {
1194
+ do
1195
+ ;
1196
+ while (this[Us](this[it].shift()));
1197
+ if (this[it].length === 0) {
1198
+ let t = this[et];
1199
+ !t || t.flowing || t.size === t.remain ? this[Kt] || this.emit("drain") : t.once("drain", () => this.emit("drain"));
1200
+ }
1201
+ }
1202
+ [Wi](t, e) {
1203
+ let i = this[Nt];
1204
+ if (!i) throw new Error("attempt to consume body without entry??");
1205
+ let r = i.blockRemain ?? 0, n = r >= t.length && e === 0 ? t : t.subarray(e, e + r);
1206
+ return i.write(n), i.blockRemain || (this[B] = "header", this[Nt] = void 0, i.end()), n.length;
1207
+ }
1208
+ [Ws](t, e) {
1209
+ let i = this[Nt], r = this[Wi](t, e);
1210
+ return !this[Nt] && i && this[Hs](i), r;
1211
+ }
1212
+ [At](t, e, i) {
1213
+ this[it].length === 0 && !this[et] ? this.emit(t, e, i) : this[it].push([t, e, i]);
1214
+ }
1215
+ [Hs](t) {
1216
+ switch (this[At]("meta", this[ft]), t.type) {
1217
+ case "ExtendedHeader":
1218
+ case "OldExtendedHeader":
1219
+ this[V] = ct.parse(this[ft], this[V], false);
1220
+ break;
1221
+ case "GlobalExtendedHeader":
1222
+ this[ae] = ct.parse(this[ft], this[ae], true);
1223
+ break;
1224
+ case "NextFileHasLongPath":
1225
+ case "OldGnuLongPath": {
1226
+ let e = this[V] ?? /* @__PURE__ */ Object.create(null);
1227
+ this[V] = e, e.path = this[ft].replace(/\0.*/, "");
1228
+ break;
1229
+ }
1230
+ case "NextFileHasLongLinkpath": {
1231
+ let e = this[V] || /* @__PURE__ */ Object.create(null);
1232
+ this[V] = e, e.linkpath = this[ft].replace(/\0.*/, "");
1233
+ break;
1234
+ }
1235
+ default:
1236
+ throw new Error("unknown meta: " + t.type);
1237
+ }
1238
+ }
1239
+ abort(t) {
1240
+ this[ut] = true, this.emit("abort", t), this.warn("TAR_ABORT", t, { recoverable: false });
1241
+ }
1242
+ write(t, e, i) {
1243
+ if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this[ut]) return i?.(), false;
1244
+ if ((this[y] === void 0 || this.brotli === void 0 && this[y] === false) && t) {
1245
+ if (this[p] && (t = Buffer.concat([this[p], t]), this[p] = void 0), t.length < On) return this[p] = t, i?.(), true;
1246
+ for (let a = 0; this[y] === void 0 && a < Zi.length; a++) t[a] !== Zi[a] && (this[y] = false);
1247
+ let o = false;
1248
+ if (this[y] === false && this.zstd !== false) {
1249
+ o = true;
1250
+ for (let a = 0; a < Yi.length; a++) if (t[a] !== Yi[a]) {
1251
+ o = false;
1252
+ break;
1253
+ }
1254
+ }
1255
+ let h = this.brotli === void 0 && !o;
1256
+ if (this[y] === false && h) if (t.length < 512) if (this[dt]) this.brotli = true;
1257
+ else return this[p] = t, i?.(), true;
1258
+ else try {
1259
+ new F(t.subarray(0, 512)), this.brotli = false;
1260
+ } catch {
1261
+ this.brotli = true;
1262
+ }
1263
+ if (this[y] === void 0 || this[y] === false && (this.brotli || o)) {
1264
+ let a = this[dt];
1265
+ this[dt] = false, this[y] = this[y] === void 0 ? new ze({}) : o ? new Ye({}) : new We({}), this[y].on("data", (c) => this[Ve](c)), this[y].on("error", (c) => this.abort(c)), this[y].on("end", () => {
1266
+ this[dt] = true, this[Ve]();
1267
+ }), this[Kt] = true;
1268
+ let l = !!this[y][a ? "end" : "write"](t);
1269
+ return this[Kt] = false, i?.(), l;
1270
+ }
1271
+ }
1272
+ this[Kt] = true, this[y] ? this[y].write(t) : this[Ve](t), this[Kt] = false;
1273
+ let n = this[it].length > 0 ? false : this[et] ? this[et].flowing : true;
1274
+ return !n && this[it].length === 0 && this[et]?.once("drain", () => this.emit("drain")), i?.(), n;
1275
+ }
1276
+ [Gi](t) {
1277
+ t && !this[ut] && (this[p] = this[p] ? Buffer.concat([this[p], t]) : t);
1278
+ }
1279
+ [Xe]() {
1280
+ if (this[dt] && !this[Hi] && !this[ut] && !this[le]) {
1281
+ this[Hi] = true;
1282
+ let t = this[Nt];
1283
+ if (t && t.blockRemain) {
1284
+ let e = this[p] ? this[p].length : 0;
1285
+ this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`, { entry: t }), this[p] && t.write(this[p]), t.end();
1286
+ }
1287
+ this[At](qe);
1288
+ }
1289
+ }
1290
+ [Ve](t) {
1291
+ if (this[le] && t) this[Gi](t);
1292
+ else if (!t && !this[p]) this[Xe]();
1293
+ else if (t) {
1294
+ if (this[le] = true, this[p]) {
1295
+ this[Gi](t);
1296
+ let e = this[p];
1297
+ this[p] = void 0, this[$e](e);
1298
+ } else this[$e](t);
1299
+ for (; this[p] && this[p]?.length >= 512 && !this[ut] && !this[Qe]; ) {
1300
+ let e = this[p];
1301
+ this[p] = void 0, this[$e](e);
1302
+ }
1303
+ this[le] = false;
1304
+ }
1305
+ (!this[p] || this[dt]) && this[Xe]();
1306
+ }
1307
+ [$e](t) {
1308
+ let e = 0, i = t.length;
1309
+ for (; e + 512 <= i && !this[ut] && !this[Qe]; ) switch (this[B]) {
1310
+ case "begin":
1311
+ case "header":
1312
+ this[Gs](t, e), e += 512;
1313
+ break;
1314
+ case "ignore":
1315
+ case "body":
1316
+ e += this[Wi](t, e);
1317
+ break;
1318
+ case "meta":
1319
+ e += this[Ws](t, e);
1320
+ break;
1321
+ default:
1322
+ throw new Error("invalid state: " + this[B]);
1323
+ }
1324
+ e < i && (this[p] = this[p] ? Buffer.concat([t.subarray(e), this[p]]) : t.subarray(e));
1325
+ }
1326
+ end(t, e, i) {
1327
+ return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e)), i && this.once("finish", i), this[ut] || (this[y] ? (t && this[y].write(t), this[y].end()) : (this[dt] = true, (this.brotli === void 0 || this.zstd === void 0) && (t = t || Buffer.alloc(0)), t && this.write(t), this[Xe]())), this;
1328
+ }
1329
+ };
1330
+ var mt = (s3) => {
1331
+ let t = s3.length - 1, e = -1;
1332
+ for (; t > -1 && s3.charAt(t) === "/"; ) e = t, t--;
1333
+ return e === -1 ? s3 : s3.slice(0, e);
1334
+ };
1335
+ var Nn = (s3) => {
1336
+ let t = s3.onReadEntry;
1337
+ s3.onReadEntry = t ? (e) => {
1338
+ t(e), e.resume();
1339
+ } : (e) => e.resume();
1340
+ };
1341
+ var Ki = (s3, t) => {
1342
+ let e = new Map(t.map((n) => [mt(n), true])), i = s3.filter, r = (n, o = "") => {
1343
+ let h = o || Ln(n).root || ".", a;
1344
+ if (n === h) a = false;
1345
+ else {
1346
+ let l = e.get(n);
1347
+ a = l !== void 0 ? l : r(xn(n), h);
1348
+ }
1349
+ return e.set(n, a), a;
1350
+ };
1351
+ s3.filter = i ? (n, o) => i(n, o) && r(mt(n)) : (n) => r(mt(n));
1352
+ };
1353
+ var An = (s3) => {
1354
+ let t = new st(s3), e = s3.file, i;
1355
+ try {
1356
+ i = Vt.openSync(e, "r");
1357
+ let r = Vt.fstatSync(i), n = s3.maxReadSize || 16 * 1024 * 1024;
1358
+ if (r.size < n) {
1359
+ let o = Buffer.allocUnsafe(r.size), h = Vt.readSync(i, o, 0, r.size, 0);
1360
+ t.end(h === o.byteLength ? o : o.subarray(0, h));
1361
+ } else {
1362
+ let o = 0, h = Buffer.allocUnsafe(n);
1363
+ for (; o < r.size; ) {
1364
+ let a = Vt.readSync(i, h, 0, n, o);
1365
+ if (a === 0) break;
1366
+ o += a, t.write(h.subarray(0, a));
1367
+ }
1368
+ t.end();
1369
+ }
1370
+ } finally {
1371
+ if (typeof i == "number") try {
1372
+ Vt.closeSync(i);
1373
+ } catch {
1374
+ }
1375
+ }
1376
+ };
1377
+ var Dn = (s3, t) => {
1378
+ let e = new st(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
1379
+ return new Promise((o, h) => {
1380
+ e.on("error", h), e.on("end", o), Vt.stat(r, (a, l) => {
1381
+ if (a) h(a);
1382
+ else {
1383
+ let c = new _t(r, { readSize: i, size: l.size });
1384
+ c.on("error", h), c.pipe(e);
1385
+ }
1386
+ });
1387
+ });
1388
+ };
1389
+ var It = K(An, Dn, (s3) => new st(s3), (s3) => new st(s3), (s3, t) => {
1390
+ t?.length && Ki(s3, t), s3.noResume || Nn(s3);
1391
+ });
1392
+ var Vi = (s3, t, e) => (s3 &= 4095, e && (s3 = (s3 | 384) & -19), t && (s3 & 256 && (s3 |= 64), s3 & 32 && (s3 |= 8), s3 & 4 && (s3 |= 1)), s3);
1393
+ var { isAbsolute: Cn, parse: Ys } = In;
1394
+ var ce = (s3) => {
1395
+ let t = "", e = Ys(s3);
1396
+ for (; Cn(s3) || e.root; ) {
1397
+ let i = s3.charAt(0) === "/" && s3.slice(0, 4) !== "//?/" ? "/" : e.root;
1398
+ s3 = s3.slice(i.length), t += i, e = Ys(s3);
1399
+ }
1400
+ return [t, s3];
1401
+ };
1402
+ var Je = ["|", "<", ">", "?", ":"];
1403
+ var $i = Je.map((s3) => String.fromCodePoint(61440 + Number(s3.codePointAt(0))));
1404
+ var Fn = new Map(Je.map((s3, t) => [s3, $i[t]]));
1405
+ var kn = new Map($i.map((s3, t) => [s3, Je[t]]));
1406
+ var Xi = (s3) => Je.reduce((t, e) => t.split(e).join(Fn.get(e)), s3);
1407
+ var Ks = (s3) => $i.reduce((t, e) => t.split(e).join(kn.get(e)), s3);
1408
+ var Js = (s3, t) => t ? (s3 = f(s3).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s3) : f(s3);
1409
+ var vn = 16 * 1024 * 1024;
1410
+ var Xs = /* @__PURE__ */ Symbol("process");
1411
+ var qs = /* @__PURE__ */ Symbol("file");
1412
+ var js = /* @__PURE__ */ Symbol("directory");
1413
+ var ji = /* @__PURE__ */ Symbol("symlink");
1414
+ var Qs = /* @__PURE__ */ Symbol("hardlink");
1415
+ var fe = /* @__PURE__ */ Symbol("header");
1416
+ var ti = /* @__PURE__ */ Symbol("read");
1417
+ var Qi = /* @__PURE__ */ Symbol("lstat");
1418
+ var ei = /* @__PURE__ */ Symbol("onlstat");
1419
+ var Ji = /* @__PURE__ */ Symbol("onread");
1420
+ var ts = /* @__PURE__ */ Symbol("onreadlink");
1421
+ var es = /* @__PURE__ */ Symbol("openfile");
1422
+ var is = /* @__PURE__ */ Symbol("onopenfile");
1423
+ var pt = /* @__PURE__ */ Symbol("close");
1424
+ var ii = /* @__PURE__ */ Symbol("mode");
1425
+ var ss = /* @__PURE__ */ Symbol("awaitDrain");
1426
+ var qi = /* @__PURE__ */ Symbol("ondrain");
1427
+ var X = /* @__PURE__ */ Symbol("prefix");
1428
+ var de = class extends D {
1429
+ path;
1430
+ portable;
1431
+ myuid = process.getuid && process.getuid() || 0;
1432
+ myuser = process.env.USER || "";
1433
+ maxReadSize;
1434
+ linkCache;
1435
+ statCache;
1436
+ preservePaths;
1437
+ cwd;
1438
+ strict;
1439
+ mtime;
1440
+ noPax;
1441
+ noMtime;
1442
+ prefix;
1443
+ fd;
1444
+ blockLen = 0;
1445
+ blockRemain = 0;
1446
+ buf;
1447
+ pos = 0;
1448
+ remain = 0;
1449
+ length = 0;
1450
+ offset = 0;
1451
+ win32;
1452
+ absolute;
1453
+ header;
1454
+ type;
1455
+ linkpath;
1456
+ stat;
1457
+ onWriteEntry;
1458
+ #t = false;
1459
+ constructor(t, e = {}) {
1460
+ let i = re(e);
1461
+ super(), this.path = f(t), this.portable = !!i.portable, this.maxReadSize = i.maxReadSize || vn, this.linkCache = i.linkCache || /* @__PURE__ */ new Map(), this.statCache = i.statCache || /* @__PURE__ */ new Map(), this.preservePaths = !!i.preservePaths, this.cwd = f(i.cwd || process.cwd()), this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.mtime = i.mtime, this.prefix = i.prefix ? f(i.prefix) : void 0, this.onWriteEntry = i.onWriteEntry, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
1462
+ let r = false;
1463
+ if (!this.preservePaths) {
1464
+ let [o, h] = ce(this.path);
1465
+ o && typeof h == "string" && (this.path = h, r = o);
1466
+ }
1467
+ this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Ks(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || $s.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, { entry: this, path: r + this.path });
1468
+ let n = this.statCache.get(this.absolute);
1469
+ n ? this[ei](n) : this[Qi]();
1470
+ }
1471
+ warn(t, e, i = {}) {
1472
+ return Lt(this, t, e, i);
1473
+ }
1474
+ emit(t, ...e) {
1475
+ return t === "error" && (this.#t = true), super.emit(t, ...e);
1476
+ }
1477
+ [Qi]() {
1478
+ $.lstat(this.absolute, (t, e) => {
1479
+ if (t) return this.emit("error", t);
1480
+ this[ei](e);
1481
+ });
1482
+ }
1483
+ [ei](t) {
1484
+ this.statCache.set(this.absolute, t), this.stat = t, t.isFile() || (t.size = 0), this.type = Mn(t), this.emit("stat", t), this[Xs]();
1485
+ }
1486
+ [Xs]() {
1487
+ switch (this.type) {
1488
+ case "File":
1489
+ return this[qs]();
1490
+ case "Directory":
1491
+ return this[js]();
1492
+ case "SymbolicLink":
1493
+ return this[ji]();
1494
+ default:
1495
+ return this.end();
1496
+ }
1497
+ }
1498
+ [ii](t) {
1499
+ return Vi(t, this.type === "Directory", this.portable);
1500
+ }
1501
+ [X](t) {
1502
+ return Js(t, this.prefix);
1503
+ }
1504
+ [fe]() {
1505
+ if (!this.stat) throw new Error("cannot write header before stat");
1506
+ this.type === "Directory" && this.portable && (this.noMtime = true), this.onWriteEntry?.(this), this.header = new F({ path: this[X](this.path), linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath, mode: this[ii](this.stat.mode), uid: this.portable ? void 0 : this.stat.uid, gid: this.portable ? void 0 : this.stat.gid, size: this.stat.size, mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime, type: this.type === "Unsupported" ? void 0 : this.type, uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "", atime: this.portable ? void 0 : this.stat.atime, ctime: this.portable ? void 0 : this.stat.ctime }), this.header.encode() && !this.noPax && super.write(new ct({ atime: this.portable ? void 0 : this.header.atime, ctime: this.portable ? void 0 : this.header.ctime, gid: this.portable ? void 0 : this.header.gid, mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime, path: this[X](this.path), linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath, size: this.header.size, uid: this.portable ? void 0 : this.header.uid, uname: this.portable ? void 0 : this.header.uname, dev: this.portable ? void 0 : this.stat.dev, ino: this.portable ? void 0 : this.stat.ino, nlink: this.portable ? void 0 : this.stat.nlink }).encode());
1507
+ let t = this.header?.block;
1508
+ if (!t) throw new Error("failed to encode header");
1509
+ super.write(t);
1510
+ }
1511
+ [js]() {
1512
+ if (!this.stat) throw new Error("cannot create directory entry without stat");
1513
+ this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[fe](), this.end();
1514
+ }
1515
+ [ji]() {
1516
+ $.readlink(this.absolute, (t, e) => {
1517
+ if (t) return this.emit("error", t);
1518
+ this[ts](e);
1519
+ });
1520
+ }
1521
+ [ts](t) {
1522
+ this.linkpath = f(t), this[fe](), this.end();
1523
+ }
1524
+ [Qs](t) {
1525
+ if (!this.stat) throw new Error("cannot create link entry without stat");
1526
+ this.type = "Link", this.linkpath = f($s.relative(this.cwd, t)), this.stat.size = 0, this[fe](), this.end();
1527
+ }
1528
+ [qs]() {
1529
+ if (!this.stat) throw new Error("cannot create file entry without stat");
1530
+ if (this.stat.nlink > 1) {
1531
+ let t = `${this.stat.dev}:${this.stat.ino}`, e = this.linkCache.get(t);
1532
+ if (e?.indexOf(this.cwd) === 0) return this[Qs](e);
1533
+ this.linkCache.set(t, this.absolute);
1534
+ }
1535
+ if (this[fe](), this.stat.size === 0) return this.end();
1536
+ this[es]();
1537
+ }
1538
+ [es]() {
1539
+ $.open(this.absolute, "r", (t, e) => {
1540
+ if (t) return this.emit("error", t);
1541
+ this[is](e);
1542
+ });
1543
+ }
1544
+ [is](t) {
1545
+ if (this.fd = t, this.#t) return this[pt]();
1546
+ if (!this.stat) throw new Error("should stat before calling onopenfile");
1547
+ this.blockLen = 512 * Math.ceil(this.stat.size / 512), this.blockRemain = this.blockLen;
1548
+ let e = Math.min(this.blockLen, this.maxReadSize);
1549
+ this.buf = Buffer.allocUnsafe(e), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ti]();
1550
+ }
1551
+ [ti]() {
1552
+ let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
1553
+ if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
1554
+ $.read(t, e, i, r, n, (o, h) => {
1555
+ if (o) return this[pt](() => this.emit("error", o));
1556
+ this[Ji](h);
1557
+ });
1558
+ }
1559
+ [pt](t = () => {
1560
+ }) {
1561
+ this.fd !== void 0 && $.close(this.fd, t);
1562
+ }
1563
+ [Ji](t) {
1564
+ if (t <= 0 && this.remain > 0) {
1565
+ let r = Object.assign(new Error("encountered unexpected EOF"), { path: this.absolute, syscall: "read", code: "EOF" });
1566
+ return this[pt](() => this.emit("error", r));
1567
+ }
1568
+ if (t > this.remain) {
1569
+ let r = Object.assign(new Error("did not encounter expected EOF"), { path: this.absolute, syscall: "read", code: "EOF" });
1570
+ return this[pt](() => this.emit("error", r));
1571
+ }
1572
+ if (!this.buf) throw new Error("should have created buffer prior to reading");
1573
+ if (t === this.remain) for (let r = t; r < this.length && t < this.blockRemain; r++) this.buf[r + this.offset] = 0, t++, this.remain++;
1574
+ let e = this.offset === 0 && t === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + t);
1575
+ this.write(e) ? this[qi]() : this[ss](() => this[qi]());
1576
+ }
1577
+ [ss](t) {
1578
+ this.once("drain", t);
1579
+ }
1580
+ write(t, e, i) {
1581
+ if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this.blockRemain < t.length) {
1582
+ let r = Object.assign(new Error("writing more data than expected"), { path: this.absolute });
1583
+ return this.emit("error", r);
1584
+ }
1585
+ return this.remain -= t.length, this.blockRemain -= t.length, this.pos += t.length, this.offset += t.length, super.write(t, null, i);
1586
+ }
1587
+ [qi]() {
1588
+ if (!this.remain) return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), this[pt]((t) => t ? this.emit("error", t) : this.end());
1589
+ if (!this.buf) throw new Error("buffer lost somehow in ONDRAIN");
1590
+ this.offset >= this.length && (this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length)), this.offset = 0), this.length = this.buf.length - this.offset, this[ti]();
1591
+ }
1592
+ };
1593
+ var si = class extends de {
1594
+ sync = true;
1595
+ [Qi]() {
1596
+ this[ei]($.lstatSync(this.absolute));
1597
+ }
1598
+ [ji]() {
1599
+ this[ts]($.readlinkSync(this.absolute));
1600
+ }
1601
+ [es]() {
1602
+ this[is]($.openSync(this.absolute, "r"));
1603
+ }
1604
+ [ti]() {
1605
+ let t = true;
1606
+ try {
1607
+ let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
1608
+ if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
1609
+ let h = $.readSync(e, i, r, n, o);
1610
+ this[Ji](h), t = false;
1611
+ } finally {
1612
+ if (t) try {
1613
+ this[pt](() => {
1614
+ });
1615
+ } catch {
1616
+ }
1617
+ }
1618
+ }
1619
+ [ss](t) {
1620
+ t();
1621
+ }
1622
+ [pt](t = () => {
1623
+ }) {
1624
+ this.fd !== void 0 && $.closeSync(this.fd), t();
1625
+ }
1626
+ };
1627
+ var ri = class extends D {
1628
+ blockLen = 0;
1629
+ blockRemain = 0;
1630
+ buf = 0;
1631
+ pos = 0;
1632
+ remain = 0;
1633
+ length = 0;
1634
+ preservePaths;
1635
+ portable;
1636
+ strict;
1637
+ noPax;
1638
+ noMtime;
1639
+ readEntry;
1640
+ type;
1641
+ prefix;
1642
+ path;
1643
+ mode;
1644
+ uid;
1645
+ gid;
1646
+ uname;
1647
+ gname;
1648
+ header;
1649
+ mtime;
1650
+ atime;
1651
+ ctime;
1652
+ linkpath;
1653
+ size;
1654
+ onWriteEntry;
1655
+ warn(t, e, i = {}) {
1656
+ return Lt(this, t, e, i);
1657
+ }
1658
+ constructor(t, e = {}) {
1659
+ let i = re(e);
1660
+ super(), this.preservePaths = !!i.preservePaths, this.portable = !!i.portable, this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.onWriteEntry = i.onWriteEntry, this.readEntry = t;
1661
+ let { type: r } = t;
1662
+ if (r === "Unsupported") throw new Error("writing entry that should be ignored");
1663
+ this.type = r, this.type === "Directory" && this.portable && (this.noMtime = true), this.prefix = i.prefix, this.path = f(t.path), this.mode = t.mode !== void 0 ? this[ii](t.mode) : void 0, this.uid = this.portable ? void 0 : t.uid, this.gid = this.portable ? void 0 : t.gid, this.uname = this.portable ? void 0 : t.uname, this.gname = this.portable ? void 0 : t.gname, this.size = t.size, this.mtime = this.noMtime ? void 0 : i.mtime || t.mtime, this.atime = this.portable ? void 0 : t.atime, this.ctime = this.portable ? void 0 : t.ctime, this.linkpath = t.linkpath !== void 0 ? f(t.linkpath) : void 0, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
1664
+ let n = false;
1665
+ if (!this.preservePaths) {
1666
+ let [h, a] = ce(this.path);
1667
+ h && typeof a == "string" && (this.path = a, n = h);
1668
+ }
1669
+ this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new F({ path: this[X](this.path), linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath, mode: this.mode, uid: this.portable ? void 0 : this.uid, gid: this.portable ? void 0 : this.gid, size: this.size, mtime: this.noMtime ? void 0 : this.mtime, type: this.type, uname: this.portable ? void 0 : this.uname, atime: this.portable ? void 0 : this.atime, ctime: this.portable ? void 0 : this.ctime }), n && this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute path`, { entry: this, path: n + this.path }), this.header.encode() && !this.noPax && super.write(new ct({ atime: this.portable ? void 0 : this.atime, ctime: this.portable ? void 0 : this.ctime, gid: this.portable ? void 0 : this.gid, mtime: this.noMtime ? void 0 : this.mtime, path: this[X](this.path), linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath, size: this.size, uid: this.portable ? void 0 : this.uid, uname: this.portable ? void 0 : this.uname, dev: this.portable ? void 0 : this.readEntry.dev, ino: this.portable ? void 0 : this.readEntry.ino, nlink: this.portable ? void 0 : this.readEntry.nlink }).encode());
1670
+ let o = this.header?.block;
1671
+ if (!o) throw new Error("failed to encode header");
1672
+ super.write(o), t.pipe(this);
1673
+ }
1674
+ [X](t) {
1675
+ return Js(t, this.prefix);
1676
+ }
1677
+ [ii](t) {
1678
+ return Vi(t, this.type === "Directory", this.portable);
1679
+ }
1680
+ write(t, e, i) {
1681
+ typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8"));
1682
+ let r = t.length;
1683
+ if (r > this.blockRemain) throw new Error("writing more to entry than is appropriate");
1684
+ return this.blockRemain -= r, super.write(t, i);
1685
+ }
1686
+ end(t, e, i) {
1687
+ return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e ?? "utf8")), i && this.once("finish", i), t ? super.end(t, i) : super.end(i), this;
1688
+ }
1689
+ };
1690
+ var Mn = (s3) => s3.isFile() ? "File" : s3.isDirectory() ? "Directory" : s3.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
1691
+ var ni = class s2 {
1692
+ tail;
1693
+ head;
1694
+ length = 0;
1695
+ static create(t = []) {
1696
+ return new s2(t);
1697
+ }
1698
+ constructor(t = []) {
1699
+ for (let e of t) this.push(e);
1700
+ }
1701
+ *[Symbol.iterator]() {
1702
+ for (let t = this.head; t; t = t.next) yield t.value;
1703
+ }
1704
+ removeNode(t) {
1705
+ if (t.list !== this) throw new Error("removing node which does not belong to this list");
1706
+ let e = t.next, i = t.prev;
1707
+ return e && (e.prev = i), i && (i.next = e), t === this.head && (this.head = e), t === this.tail && (this.tail = i), this.length--, t.next = void 0, t.prev = void 0, t.list = void 0, e;
1708
+ }
1709
+ unshiftNode(t) {
1710
+ if (t === this.head) return;
1711
+ t.list && t.list.removeNode(t);
1712
+ let e = this.head;
1713
+ t.list = this, t.next = e, e && (e.prev = t), this.head = t, this.tail || (this.tail = t), this.length++;
1714
+ }
1715
+ pushNode(t) {
1716
+ if (t === this.tail) return;
1717
+ t.list && t.list.removeNode(t);
1718
+ let e = this.tail;
1719
+ t.list = this, t.prev = e, e && (e.next = t), this.tail = t, this.head || (this.head = t), this.length++;
1720
+ }
1721
+ push(...t) {
1722
+ for (let e = 0, i = t.length; e < i; e++) Pn(this, t[e]);
1723
+ return this.length;
1724
+ }
1725
+ unshift(...t) {
1726
+ for (var e = 0, i = t.length; e < i; e++) zn(this, t[e]);
1727
+ return this.length;
1728
+ }
1729
+ pop() {
1730
+ if (!this.tail) return;
1731
+ let t = this.tail.value, e = this.tail;
1732
+ return this.tail = this.tail.prev, this.tail ? this.tail.next = void 0 : this.head = void 0, e.list = void 0, this.length--, t;
1733
+ }
1734
+ shift() {
1735
+ if (!this.head) return;
1736
+ let t = this.head.value, e = this.head;
1737
+ return this.head = this.head.next, this.head ? this.head.prev = void 0 : this.tail = void 0, e.list = void 0, this.length--, t;
1738
+ }
1739
+ forEach(t, e) {
1740
+ e = e || this;
1741
+ for (let i = this.head, r = 0; i; r++) t.call(e, i.value, r, this), i = i.next;
1742
+ }
1743
+ forEachReverse(t, e) {
1744
+ e = e || this;
1745
+ for (let i = this.tail, r = this.length - 1; i; r--) t.call(e, i.value, r, this), i = i.prev;
1746
+ }
1747
+ get(t) {
1748
+ let e = 0, i = this.head;
1749
+ for (; i && e < t; e++) i = i.next;
1750
+ if (e === t && i) return i.value;
1751
+ }
1752
+ getReverse(t) {
1753
+ let e = 0, i = this.tail;
1754
+ for (; i && e < t; e++) i = i.prev;
1755
+ if (e === t && i) return i.value;
1756
+ }
1757
+ map(t, e) {
1758
+ e = e || this;
1759
+ let i = new s2();
1760
+ for (let r = this.head; r; ) i.push(t.call(e, r.value, this)), r = r.next;
1761
+ return i;
1762
+ }
1763
+ mapReverse(t, e) {
1764
+ e = e || this;
1765
+ var i = new s2();
1766
+ for (let r = this.tail; r; ) i.push(t.call(e, r.value, this)), r = r.prev;
1767
+ return i;
1768
+ }
1769
+ reduce(t, e) {
1770
+ let i, r = this.head;
1771
+ if (arguments.length > 1) i = e;
1772
+ else if (this.head) r = this.head.next, i = this.head.value;
1773
+ else throw new TypeError("Reduce of empty list with no initial value");
1774
+ for (var n = 0; r; n++) i = t(i, r.value, n), r = r.next;
1775
+ return i;
1776
+ }
1777
+ reduceReverse(t, e) {
1778
+ let i, r = this.tail;
1779
+ if (arguments.length > 1) i = e;
1780
+ else if (this.tail) r = this.tail.prev, i = this.tail.value;
1781
+ else throw new TypeError("Reduce of empty list with no initial value");
1782
+ for (let n = this.length - 1; r; n--) i = t(i, r.value, n), r = r.prev;
1783
+ return i;
1784
+ }
1785
+ toArray() {
1786
+ let t = new Array(this.length);
1787
+ for (let e = 0, i = this.head; i; e++) t[e] = i.value, i = i.next;
1788
+ return t;
1789
+ }
1790
+ toArrayReverse() {
1791
+ let t = new Array(this.length);
1792
+ for (let e = 0, i = this.tail; i; e++) t[e] = i.value, i = i.prev;
1793
+ return t;
1794
+ }
1795
+ slice(t = 0, e = this.length) {
1796
+ e < 0 && (e += this.length), t < 0 && (t += this.length);
1797
+ let i = new s2();
1798
+ if (e < t || e < 0) return i;
1799
+ t < 0 && (t = 0), e > this.length && (e = this.length);
1800
+ let r = this.head, n = 0;
1801
+ for (n = 0; r && n < t; n++) r = r.next;
1802
+ for (; r && n < e; n++, r = r.next) i.push(r.value);
1803
+ return i;
1804
+ }
1805
+ sliceReverse(t = 0, e = this.length) {
1806
+ e < 0 && (e += this.length), t < 0 && (t += this.length);
1807
+ let i = new s2();
1808
+ if (e < t || e < 0) return i;
1809
+ t < 0 && (t = 0), e > this.length && (e = this.length);
1810
+ let r = this.length, n = this.tail;
1811
+ for (; n && r > e; r--) n = n.prev;
1812
+ for (; n && r > t; r--, n = n.prev) i.push(n.value);
1813
+ return i;
1814
+ }
1815
+ splice(t, e = 0, ...i) {
1816
+ t > this.length && (t = this.length - 1), t < 0 && (t = this.length + t);
1817
+ let r = this.head;
1818
+ for (let o = 0; r && o < t; o++) r = r.next;
1819
+ let n = [];
1820
+ for (let o = 0; r && o < e; o++) n.push(r.value), r = this.removeNode(r);
1821
+ r ? r !== this.tail && (r = r.prev) : r = this.tail;
1822
+ for (let o of i) r = Bn(this, r, o);
1823
+ return n;
1824
+ }
1825
+ reverse() {
1826
+ let t = this.head, e = this.tail;
1827
+ for (let i = t; i; i = i.prev) {
1828
+ let r = i.prev;
1829
+ i.prev = i.next, i.next = r;
1830
+ }
1831
+ return this.head = e, this.tail = t, this;
1832
+ }
1833
+ };
1834
+ function Bn(s3, t, e) {
1835
+ let i = t, r = t ? t.next : s3.head, n = new ue(e, i, r, s3);
1836
+ return n.next === void 0 && (s3.tail = n), n.prev === void 0 && (s3.head = n), s3.length++, n;
1837
+ }
1838
+ function Pn(s3, t) {
1839
+ s3.tail = new ue(t, s3.tail, void 0, s3), s3.head || (s3.head = s3.tail), s3.length++;
1840
+ }
1841
+ function zn(s3, t) {
1842
+ s3.head = new ue(t, void 0, s3.head, s3), s3.tail || (s3.tail = s3.head), s3.length++;
1843
+ }
1844
+ var ue = class {
1845
+ list;
1846
+ next;
1847
+ prev;
1848
+ value;
1849
+ constructor(t, e, i, r) {
1850
+ this.list = r, this.value = t, e ? (e.next = this, this.prev = e) : this.prev = void 0, i ? (i.prev = this, this.next = i) : this.next = void 0;
1851
+ }
1852
+ };
1853
+ var di = class {
1854
+ path;
1855
+ absolute;
1856
+ entry;
1857
+ stat;
1858
+ readdir;
1859
+ pending = false;
1860
+ ignore = false;
1861
+ piped = false;
1862
+ constructor(t, e) {
1863
+ this.path = t || "./", this.absolute = e;
1864
+ }
1865
+ };
1866
+ var tr = Buffer.alloc(1024);
1867
+ var oi = /* @__PURE__ */ Symbol("onStat");
1868
+ var me = /* @__PURE__ */ Symbol("ended");
1869
+ var W = /* @__PURE__ */ Symbol("queue");
1870
+ var Ct = /* @__PURE__ */ Symbol("current");
1871
+ var Ft = /* @__PURE__ */ Symbol("process");
1872
+ var pe = /* @__PURE__ */ Symbol("processing");
1873
+ var rs = /* @__PURE__ */ Symbol("processJob");
1874
+ var G = /* @__PURE__ */ Symbol("jobs");
1875
+ var ns = /* @__PURE__ */ Symbol("jobDone");
1876
+ var hi = /* @__PURE__ */ Symbol("addFSEntry");
1877
+ var er = /* @__PURE__ */ Symbol("addTarEntry");
1878
+ var as = /* @__PURE__ */ Symbol("stat");
1879
+ var ls = /* @__PURE__ */ Symbol("readdir");
1880
+ var ai = /* @__PURE__ */ Symbol("onreaddir");
1881
+ var li = /* @__PURE__ */ Symbol("pipe");
1882
+ var ir = /* @__PURE__ */ Symbol("entry");
1883
+ var os = /* @__PURE__ */ Symbol("entryOpt");
1884
+ var ci = /* @__PURE__ */ Symbol("writeEntryClass");
1885
+ var rr = /* @__PURE__ */ Symbol("write");
1886
+ var hs = /* @__PURE__ */ Symbol("ondrain");
1887
+ var Et = class extends D {
1888
+ sync = false;
1889
+ opt;
1890
+ cwd;
1891
+ maxReadSize;
1892
+ preservePaths;
1893
+ strict;
1894
+ noPax;
1895
+ prefix;
1896
+ linkCache;
1897
+ statCache;
1898
+ file;
1899
+ portable;
1900
+ zip;
1901
+ readdirCache;
1902
+ noDirRecurse;
1903
+ follow;
1904
+ noMtime;
1905
+ mtime;
1906
+ filter;
1907
+ jobs;
1908
+ [ci];
1909
+ onWriteEntry;
1910
+ [W];
1911
+ [G] = 0;
1912
+ [pe] = false;
1913
+ [me] = false;
1914
+ constructor(t = {}) {
1915
+ if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f(t.prefix || ""), this.linkCache = t.linkCache || /* @__PURE__ */ new Map(), this.statCache = t.statCache || /* @__PURE__ */ new Map(), this.readdirCache = t.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = t.onWriteEntry, this[ci] = de, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
1916
+ if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
1917
+ if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = true), this.zip = new Pe(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new He(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ze(t.zstd)), !this.zip) throw new Error("impossible");
1918
+ let e = this.zip;
1919
+ e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[hs]()), this.on("resume", () => e.resume());
1920
+ } else this.on("drain", this[hs]);
1921
+ this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => true, this[W] = new ni(), this[G] = 0, this.jobs = Number(t.jobs) || 4, this[pe] = false, this[me] = false;
1922
+ }
1923
+ [rr](t) {
1924
+ return super.write(t);
1925
+ }
1926
+ add(t) {
1927
+ return this.write(t), this;
1928
+ }
1929
+ end(t, e, i) {
1930
+ return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = void 0), t && this.add(t), this[me] = true, this[Ft](), i && i(), this;
1931
+ }
1932
+ write(t) {
1933
+ if (this[me]) throw new Error("write after end");
1934
+ return t instanceof Yt ? this[er](t) : this[hi](t), this.flowing;
1935
+ }
1936
+ [er](t) {
1937
+ let e = f(sr.resolve(this.cwd, t.path));
1938
+ if (!this.filter(t.path, t)) t.resume();
1939
+ else {
1940
+ let i = new di(t.path, e);
1941
+ i.entry = new ri(t, this[os](i)), i.entry.on("end", () => this[ns](i)), this[G] += 1, this[W].push(i);
1942
+ }
1943
+ this[Ft]();
1944
+ }
1945
+ [hi](t) {
1946
+ let e = f(sr.resolve(this.cwd, t));
1947
+ this[W].push(new di(t, e)), this[Ft]();
1948
+ }
1949
+ [as](t) {
1950
+ t.pending = true, this[G] += 1;
1951
+ let e = this.follow ? "stat" : "lstat";
1952
+ fi[e](t.absolute, (i, r) => {
1953
+ t.pending = false, this[G] -= 1, i ? this.emit("error", i) : this[oi](t, r);
1954
+ });
1955
+ }
1956
+ [oi](t, e) {
1957
+ this.statCache.set(t.absolute, e), t.stat = e, this.filter(t.path, e) ? e.isFile() && e.nlink > 1 && t === this[Ct] && !this.linkCache.get(`${e.dev}:${e.ino}`) && !this.sync && this[rs](t) : t.ignore = true, this[Ft]();
1958
+ }
1959
+ [ls](t) {
1960
+ t.pending = true, this[G] += 1, fi.readdir(t.absolute, (e, i) => {
1961
+ if (t.pending = false, this[G] -= 1, e) return this.emit("error", e);
1962
+ this[ai](t, i);
1963
+ });
1964
+ }
1965
+ [ai](t, e) {
1966
+ this.readdirCache.set(t.absolute, e), t.readdir = e, this[Ft]();
1967
+ }
1968
+ [Ft]() {
1969
+ if (!this[pe]) {
1970
+ this[pe] = true;
1971
+ for (let t = this[W].head; t && this[G] < this.jobs; t = t.next) if (this[rs](t.value), t.value.ignore) {
1972
+ let e = t.next;
1973
+ this[W].removeNode(t), t.next = e;
1974
+ }
1975
+ this[pe] = false, this[me] && this[W].length === 0 && this[G] === 0 && (this.zip ? this.zip.end(tr) : (super.write(tr), super.end()));
1976
+ }
1977
+ }
1978
+ get [Ct]() {
1979
+ return this[W] && this[W].head && this[W].head.value;
1980
+ }
1981
+ [ns](t) {
1982
+ this[W].shift(), this[G] -= 1, this[Ft]();
1983
+ }
1984
+ [rs](t) {
1985
+ if (!t.pending) {
1986
+ if (t.entry) {
1987
+ t === this[Ct] && !t.piped && this[li](t);
1988
+ return;
1989
+ }
1990
+ if (!t.stat) {
1991
+ let e = this.statCache.get(t.absolute);
1992
+ e ? this[oi](t, e) : this[as](t);
1993
+ }
1994
+ if (t.stat && !t.ignore) {
1995
+ if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
1996
+ let e = this.readdirCache.get(t.absolute);
1997
+ if (e ? this[ai](t, e) : this[ls](t), !t.readdir) return;
1998
+ }
1999
+ if (t.entry = this[ir](t), !t.entry) {
2000
+ t.ignore = true;
2001
+ return;
2002
+ }
2003
+ t === this[Ct] && !t.piped && this[li](t);
2004
+ }
2005
+ }
2006
+ }
2007
+ [os](t) {
2008
+ return { onwarn: (e, i, r) => this.warn(e, i, r), noPax: this.noPax, cwd: this.cwd, absolute: t.absolute, preservePaths: this.preservePaths, maxReadSize: this.maxReadSize, strict: this.strict, portable: this.portable, linkCache: this.linkCache, statCache: this.statCache, noMtime: this.noMtime, mtime: this.mtime, prefix: this.prefix, onWriteEntry: this.onWriteEntry };
2009
+ }
2010
+ [ir](t) {
2011
+ this[G] += 1;
2012
+ try {
2013
+ return new this[ci](t.path, this[os](t)).on("end", () => this[ns](t)).on("error", (i) => this.emit("error", i));
2014
+ } catch (e) {
2015
+ this.emit("error", e);
2016
+ }
2017
+ }
2018
+ [hs]() {
2019
+ this[Ct] && this[Ct].entry && this[Ct].entry.resume();
2020
+ }
2021
+ [li](t) {
2022
+ t.piped = true, t.readdir && t.readdir.forEach((r) => {
2023
+ let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
2024
+ this[hi](o + r);
2025
+ });
2026
+ let e = t.entry, i = this.zip;
2027
+ if (!e) throw new Error("cannot pipe without source");
2028
+ i ? e.on("data", (r) => {
2029
+ i.write(r) || e.pause();
2030
+ }) : e.on("data", (r) => {
2031
+ super.write(r) || e.pause();
2032
+ });
2033
+ }
2034
+ pause() {
2035
+ return this.zip && this.zip.pause(), super.pause();
2036
+ }
2037
+ warn(t, e, i = {}) {
2038
+ Lt(this, t, e, i);
2039
+ }
2040
+ };
2041
+ var kt = class extends Et {
2042
+ sync = true;
2043
+ constructor(t) {
2044
+ super(t), this[ci] = si;
2045
+ }
2046
+ pause() {
2047
+ }
2048
+ resume() {
2049
+ }
2050
+ [as](t) {
2051
+ let e = this.follow ? "statSync" : "lstatSync";
2052
+ this[oi](t, fi[e](t.absolute));
2053
+ }
2054
+ [ls](t) {
2055
+ this[ai](t, fi.readdirSync(t.absolute));
2056
+ }
2057
+ [li](t) {
2058
+ let e = t.entry, i = this.zip;
2059
+ if (t.readdir && t.readdir.forEach((r) => {
2060
+ let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
2061
+ this[hi](o + r);
2062
+ }), !e) throw new Error("Cannot pipe without source");
2063
+ i ? e.on("data", (r) => {
2064
+ i.write(r);
2065
+ }) : e.on("data", (r) => {
2066
+ super[rr](r);
2067
+ });
2068
+ }
2069
+ };
2070
+ var Un = (s3, t) => {
2071
+ let e = new kt(s3), i = new Wt(s3.file, { mode: s3.mode || 438 });
2072
+ e.pipe(i), or(e, t);
2073
+ };
2074
+ var Hn = (s3, t) => {
2075
+ let e = new Et(s3), i = new tt(s3.file, { mode: s3.mode || 438 });
2076
+ e.pipe(i);
2077
+ let r = new Promise((n, o) => {
2078
+ i.on("error", o), i.on("close", n), e.on("error", o);
2079
+ });
2080
+ return hr(e, t).catch((n) => e.emit("error", n)), r;
2081
+ };
2082
+ var or = (s3, t) => {
2083
+ t.forEach((e) => {
2084
+ e.charAt(0) === "@" ? It({ file: nr.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
2085
+ }), s3.end();
2086
+ };
2087
+ var hr = async (s3, t) => {
2088
+ for (let e of t) e.charAt(0) === "@" ? await It({ file: nr.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
2089
+ s3.add(i);
2090
+ } }) : s3.add(e);
2091
+ s3.end();
2092
+ };
2093
+ var Wn = (s3, t) => {
2094
+ let e = new kt(s3);
2095
+ return or(e, t), e;
2096
+ };
2097
+ var Gn = (s3, t) => {
2098
+ let e = new Et(s3);
2099
+ return hr(e, t).catch((i) => e.emit("error", i)), e;
2100
+ };
2101
+ var Zn = K(Un, Hn, Wn, Gn, (s3, t) => {
2102
+ if (!t?.length) throw new TypeError("no paths specified to add to archive");
2103
+ });
2104
+ var Yn = process.env.__FAKE_PLATFORM__ || process.platform;
2105
+ var fr = Yn === "win32";
2106
+ var { O_CREAT: dr, O_NOFOLLOW: ar, O_TRUNC: ur, O_WRONLY: mr } = cr.constants;
2107
+ var pr = Number(process.env.__FAKE_FS_O_FILENAME__) || cr.constants.UV_FS_O_FILEMAP || 0;
2108
+ var Kn = fr && !!pr;
2109
+ var Vn = 512 * 1024;
2110
+ var $n = pr | ur | dr | mr;
2111
+ var lr = !fr && typeof ar == "number" ? ar | ur | dr | mr : null;
2112
+ var cs = lr !== null ? () => lr : Kn ? (s3) => s3 < Vn ? $n : "w" : () => "w";
2113
+ var fs = (s3, t, e) => {
2114
+ try {
2115
+ return mi.lchownSync(s3, t, e);
2116
+ } catch (i) {
2117
+ if (i?.code !== "ENOENT") throw i;
2118
+ }
2119
+ };
2120
+ var ui = (s3, t, e, i) => {
2121
+ mi.lchown(s3, t, e, (r) => {
2122
+ i(r && r?.code !== "ENOENT" ? r : null);
2123
+ });
2124
+ };
2125
+ var Xn = (s3, t, e, i, r) => {
2126
+ if (t.isDirectory()) ds(Ee.resolve(s3, t.name), e, i, (n) => {
2127
+ if (n) return r(n);
2128
+ let o = Ee.resolve(s3, t.name);
2129
+ ui(o, e, i, r);
2130
+ });
2131
+ else {
2132
+ let n = Ee.resolve(s3, t.name);
2133
+ ui(n, e, i, r);
2134
+ }
2135
+ };
2136
+ var ds = (s3, t, e, i) => {
2137
+ mi.readdir(s3, { withFileTypes: true }, (r, n) => {
2138
+ if (r) {
2139
+ if (r.code === "ENOENT") return i();
2140
+ if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
2141
+ }
2142
+ if (r || !n.length) return ui(s3, t, e, i);
2143
+ let o = n.length, h = null, a = (l) => {
2144
+ if (!h) {
2145
+ if (l) return i(h = l);
2146
+ if (--o === 0) return ui(s3, t, e, i);
2147
+ }
2148
+ };
2149
+ for (let l of n) Xn(s3, l, t, e, a);
2150
+ });
2151
+ };
2152
+ var qn = (s3, t, e, i) => {
2153
+ t.isDirectory() && us(Ee.resolve(s3, t.name), e, i), fs(Ee.resolve(s3, t.name), e, i);
2154
+ };
2155
+ var us = (s3, t, e) => {
2156
+ let i;
2157
+ try {
2158
+ i = mi.readdirSync(s3, { withFileTypes: true });
2159
+ } catch (r) {
2160
+ let n = r;
2161
+ if (n?.code === "ENOENT") return;
2162
+ if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return fs(s3, t, e);
2163
+ throw n;
2164
+ }
2165
+ for (let r of i) qn(s3, r, t, e);
2166
+ return fs(s3, t, e);
2167
+ };
2168
+ var we = class extends Error {
2169
+ path;
2170
+ code;
2171
+ syscall = "chdir";
2172
+ constructor(t, e) {
2173
+ super(`${e}: Cannot cd into '${t}'`), this.path = t, this.code = e;
2174
+ }
2175
+ get name() {
2176
+ return "CwdError";
2177
+ }
2178
+ };
2179
+ var wt = class extends Error {
2180
+ path;
2181
+ symlink;
2182
+ syscall = "symlink";
2183
+ code = "TAR_SYMLINK_ERROR";
2184
+ constructor(t, e) {
2185
+ super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"), this.symlink = t, this.path = e;
2186
+ }
2187
+ get name() {
2188
+ return "SymlinkError";
2189
+ }
2190
+ };
2191
+ var Qn = (s3, t) => {
2192
+ k.stat(s3, (e, i) => {
2193
+ (e || !i.isDirectory()) && (e = new we(s3, e?.code || "ENOTDIR")), t(e);
2194
+ });
2195
+ };
2196
+ var Er = (s3, t, e) => {
2197
+ s3 = f(s3);
2198
+ let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, h = t.gid, a = typeof o == "number" && typeof h == "number" && (o !== t.processUid || h !== t.processGid), l = t.preserve, c = t.unlink, d = f(t.cwd), S = (E, x) => {
2199
+ E ? e(E) : x && a ? ds(x, o, h, (xe) => S(xe)) : n ? k.chmod(s3, r, e) : e();
2200
+ };
2201
+ if (s3 === d) return Qn(s3, S);
2202
+ if (l) return jn.mkdir(s3, { mode: r, recursive: true }).then((E) => S(null, E ?? void 0), S);
2203
+ let N = f(pi.relative(d, s3)).split("/");
2204
+ ms(d, N, r, c, d, void 0, S);
2205
+ };
2206
+ var ms = (s3, t, e, i, r, n, o) => {
2207
+ if (t.length === 0) return o(null, n);
2208
+ let h = t.shift(), a = f(pi.resolve(s3 + "/" + h));
2209
+ k.mkdir(a, e, wr(a, t, e, i, r, n, o));
2210
+ };
2211
+ var wr = (s3, t, e, i, r, n, o) => (h) => {
2212
+ h ? k.lstat(s3, (a, l) => {
2213
+ if (a) a.path = a.path && f(a.path), o(a);
2214
+ else if (l.isDirectory()) ms(s3, t, e, i, r, n, o);
2215
+ else if (i) k.unlink(s3, (c) => {
2216
+ if (c) return o(c);
2217
+ k.mkdir(s3, e, wr(s3, t, e, i, r, n, o));
2218
+ });
2219
+ else {
2220
+ if (l.isSymbolicLink()) return o(new wt(s3, s3 + "/" + t.join("/")));
2221
+ o(h);
2222
+ }
2223
+ }) : (n = n || s3, ms(s3, t, e, i, r, n, o));
2224
+ };
2225
+ var Jn = (s3) => {
2226
+ let t = false, e;
2227
+ try {
2228
+ t = k.statSync(s3).isDirectory();
2229
+ } catch (i) {
2230
+ e = i?.code;
2231
+ } finally {
2232
+ if (!t) throw new we(s3, e ?? "ENOTDIR");
2233
+ }
2234
+ };
2235
+ var Sr = (s3, t) => {
2236
+ s3 = f(s3);
2237
+ let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, h = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), a = t.preserve, l = t.unlink, c = f(t.cwd), d = (E) => {
2238
+ E && h && us(E, n, o), r && k.chmodSync(s3, i);
2239
+ };
2240
+ if (s3 === c) return Jn(c), d();
2241
+ if (a) return d(k.mkdirSync(s3, { mode: i, recursive: true }) ?? void 0);
2242
+ let T = f(pi.relative(c, s3)).split("/"), N;
2243
+ for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
2244
+ x = f(pi.resolve(x));
2245
+ try {
2246
+ k.mkdirSync(x, i), N = N || x;
2247
+ } catch {
2248
+ let xe = k.lstatSync(x);
2249
+ if (xe.isDirectory()) continue;
2250
+ if (l) {
2251
+ k.unlinkSync(x), k.mkdirSync(x, i), N = N || x;
2252
+ continue;
2253
+ } else if (xe.isSymbolicLink()) return new wt(x, x + "/" + T.join("/"));
2254
+ }
2255
+ }
2256
+ return d(N);
2257
+ };
2258
+ var ps = /* @__PURE__ */ Object.create(null);
2259
+ var yr = 1e4;
2260
+ var $t = /* @__PURE__ */ new Set();
2261
+ var Rr = (s3) => {
2262
+ $t.has(s3) ? $t.delete(s3) : ps[s3] = s3.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"), $t.add(s3);
2263
+ let t = ps[s3], e = $t.size - yr;
2264
+ if (e > yr / 10) {
2265
+ for (let i of $t) if ($t.delete(i), delete ps[i], --e <= 0) break;
2266
+ }
2267
+ return t;
2268
+ };
2269
+ var to = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
2270
+ var eo = to === "win32";
2271
+ var io = (s3) => s3.split("/").slice(0, -1).reduce((e, i) => {
2272
+ let r = e.at(-1);
2273
+ return r !== void 0 && (i = br(r, i)), e.push(i || "/"), e;
2274
+ }, []);
2275
+ var Ei = class {
2276
+ #t = /* @__PURE__ */ new Map();
2277
+ #i = /* @__PURE__ */ new Map();
2278
+ #s = /* @__PURE__ */ new Set();
2279
+ reserve(t, e) {
2280
+ t = eo ? ["win32 parallelization disabled"] : t.map((r) => mt(br(Rr(r))));
2281
+ let i = new Set(t.map((r) => io(r)).reduce((r, n) => r.concat(n)));
2282
+ this.#i.set(e, { dirs: i, paths: t });
2283
+ for (let r of t) {
2284
+ let n = this.#t.get(r);
2285
+ n ? n.push(e) : this.#t.set(r, [e]);
2286
+ }
2287
+ for (let r of i) {
2288
+ let n = this.#t.get(r);
2289
+ if (!n) this.#t.set(r, [/* @__PURE__ */ new Set([e])]);
2290
+ else {
2291
+ let o = n.at(-1);
2292
+ o instanceof Set ? o.add(e) : n.push(/* @__PURE__ */ new Set([e]));
2293
+ }
2294
+ }
2295
+ return this.#r(e);
2296
+ }
2297
+ #n(t) {
2298
+ let e = this.#i.get(t);
2299
+ if (!e) throw new Error("function does not have any path reservations");
2300
+ return { paths: e.paths.map((i) => this.#t.get(i)), dirs: [...e.dirs].map((i) => this.#t.get(i)) };
2301
+ }
2302
+ check(t) {
2303
+ let { paths: e, dirs: i } = this.#n(t);
2304
+ return e.every((r) => r && r[0] === t) && i.every((r) => r && r[0] instanceof Set && r[0].has(t));
2305
+ }
2306
+ #r(t) {
2307
+ return this.#s.has(t) || !this.check(t) ? false : (this.#s.add(t), t(() => this.#e(t)), true);
2308
+ }
2309
+ #e(t) {
2310
+ if (!this.#s.has(t)) return false;
2311
+ let e = this.#i.get(t);
2312
+ if (!e) throw new Error("invalid reservation");
2313
+ let { paths: i, dirs: r } = e, n = /* @__PURE__ */ new Set();
2314
+ for (let o of i) {
2315
+ let h = this.#t.get(o);
2316
+ if (!h || h?.[0] !== t) continue;
2317
+ let a = h[1];
2318
+ if (!a) {
2319
+ this.#t.delete(o);
2320
+ continue;
2321
+ }
2322
+ if (h.shift(), typeof a == "function") n.add(a);
2323
+ else for (let l of a) n.add(l);
2324
+ }
2325
+ for (let o of r) {
2326
+ let h = this.#t.get(o), a = h?.[0];
2327
+ if (!(!h || !(a instanceof Set))) if (a.size === 1 && h.length === 1) {
2328
+ this.#t.delete(o);
2329
+ continue;
2330
+ } else if (a.size === 1) {
2331
+ h.shift();
2332
+ let l = h[0];
2333
+ typeof l == "function" && n.add(l);
2334
+ } else a.delete(t);
2335
+ }
2336
+ return this.#s.delete(t), n.forEach((o) => this.#r(o)), true;
2337
+ }
2338
+ };
2339
+ var _r = () => process.umask();
2340
+ var gr = /* @__PURE__ */ Symbol("onEntry");
2341
+ var ys = /* @__PURE__ */ Symbol("checkFs");
2342
+ var Or = /* @__PURE__ */ Symbol("checkFs2");
2343
+ var Rs = /* @__PURE__ */ Symbol("isReusable");
2344
+ var P = /* @__PURE__ */ Symbol("makeFs");
2345
+ var bs = /* @__PURE__ */ Symbol("file");
2346
+ var _s = /* @__PURE__ */ Symbol("directory");
2347
+ var Si = /* @__PURE__ */ Symbol("link");
2348
+ var Tr = /* @__PURE__ */ Symbol("symlink");
2349
+ var xr = /* @__PURE__ */ Symbol("hardlink");
2350
+ var ye = /* @__PURE__ */ Symbol("ensureNoSymlink");
2351
+ var Lr = /* @__PURE__ */ Symbol("unsupported");
2352
+ var Nr = /* @__PURE__ */ Symbol("checkPath");
2353
+ var Es = /* @__PURE__ */ Symbol("stripAbsolutePath");
2354
+ var St = /* @__PURE__ */ Symbol("mkdir");
2355
+ var O = /* @__PURE__ */ Symbol("onError");
2356
+ var wi = /* @__PURE__ */ Symbol("pending");
2357
+ var Ar = /* @__PURE__ */ Symbol("pend");
2358
+ var Xt = /* @__PURE__ */ Symbol("unpend");
2359
+ var ws = /* @__PURE__ */ Symbol("ended");
2360
+ var Ss = /* @__PURE__ */ Symbol("maybeClose");
2361
+ var gs = /* @__PURE__ */ Symbol("skip");
2362
+ var Re = /* @__PURE__ */ Symbol("doChown");
2363
+ var be = /* @__PURE__ */ Symbol("uid");
2364
+ var _e = /* @__PURE__ */ Symbol("gid");
2365
+ var ge = /* @__PURE__ */ Symbol("checkedCwd");
2366
+ var ro = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
2367
+ var Oe = ro === "win32";
2368
+ var no = 1024;
2369
+ var oo = (s3, t) => {
2370
+ if (!Oe) return u.unlink(s3, t);
2371
+ let e = s3 + ".DELETE." + Ir(16).toString("hex");
2372
+ u.rename(s3, e, (i) => {
2373
+ if (i) return t(i);
2374
+ u.unlink(e, t);
2375
+ });
2376
+ };
2377
+ var ho = (s3) => {
2378
+ if (!Oe) return u.unlinkSync(s3);
2379
+ let t = s3 + ".DELETE." + Ir(16).toString("hex");
2380
+ u.renameSync(s3, t), u.unlinkSync(t);
2381
+ };
2382
+ var Dr = (s3, t, e) => s3 !== void 0 && s3 === s3 >>> 0 ? s3 : t !== void 0 && t === t >>> 0 ? t : e;
2383
+ var qt = class extends st {
2384
+ [ws] = false;
2385
+ [ge] = false;
2386
+ [wi] = 0;
2387
+ reservations = new Ei();
2388
+ transform;
2389
+ writable = true;
2390
+ readable = false;
2391
+ uid;
2392
+ gid;
2393
+ setOwner;
2394
+ preserveOwner;
2395
+ processGid;
2396
+ processUid;
2397
+ maxDepth;
2398
+ forceChown;
2399
+ win32;
2400
+ newer;
2401
+ keep;
2402
+ noMtime;
2403
+ preservePaths;
2404
+ unlink;
2405
+ cwd;
2406
+ strip;
2407
+ processUmask;
2408
+ umask;
2409
+ dmode;
2410
+ fmode;
2411
+ chmod;
2412
+ constructor(t = {}) {
2413
+ if (t.ondone = () => {
2414
+ this[ws] = true, this[Ss]();
2415
+ }, super(t), this.transform = t.transform, this.chmod = !!t.chmod, typeof t.uid == "number" || typeof t.gid == "number") {
2416
+ if (typeof t.uid != "number" || typeof t.gid != "number") throw new TypeError("cannot set owner without number uid and gid");
2417
+ if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
2418
+ this.uid = t.uid, this.gid = t.gid, this.setOwner = true;
2419
+ } else this.uid = void 0, this.gid = void 0, this.setOwner = false;
2420
+ this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? !!(process.getuid && process.getuid() === 0) : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : no, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Oe, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(R.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : _r() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[gr](e));
2421
+ }
2422
+ warn(t, e, i = {}) {
2423
+ return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = false), super.warn(t, e, i);
2424
+ }
2425
+ [Ss]() {
2426
+ this[ws] && this[wi] === 0 && (this.emit("prefinish"), this.emit("finish"), this.emit("end"));
2427
+ }
2428
+ [Es](t, e) {
2429
+ let i = t[e], { type: r } = t;
2430
+ if (!i || this.preservePaths) return true;
2431
+ let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
2432
+ if (h.includes("..") || Oe && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
2433
+ if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, { entry: t, [e]: i }), false;
2434
+ let a = R.posix.dirname(t.path), l = R.posix.normalize(R.posix.join(a, h.join("/")));
2435
+ if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, { entry: t, [e]: i }), false;
2436
+ }
2437
+ return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, { entry: t, [e]: i })), true;
2438
+ }
2439
+ [Nr](t) {
2440
+ let e = f(t.path), i = e.split("/");
2441
+ if (this.strip) {
2442
+ if (i.length < this.strip) return false;
2443
+ if (t.type === "Link") {
2444
+ let r = f(String(t.linkpath)).split("/");
2445
+ if (r.length >= this.strip) t.linkpath = r.slice(this.strip).join("/");
2446
+ else return false;
2447
+ }
2448
+ i.splice(0, this.strip), t.path = i.join("/");
2449
+ }
2450
+ if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", { entry: t, path: e, depth: i.length, maxDepth: this.maxDepth }), false;
2451
+ if (!this[Es](t, "path") || !this[Es](t, "linkpath")) return false;
2452
+ if (t.absolute = R.isAbsolute(t.path) ? f(R.resolve(t.path)) : f(R.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t, path: f(t.path), resolvedPath: t.absolute, cwd: this.cwd }), false;
2453
+ if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return false;
2454
+ if (this.win32) {
2455
+ let { root: r } = R.win32.parse(String(t.absolute));
2456
+ t.absolute = r + Xi(String(t.absolute).slice(r.length));
2457
+ let { root: n } = R.win32.parse(t.path);
2458
+ t.path = n + Xi(t.path.slice(n.length));
2459
+ }
2460
+ return true;
2461
+ }
2462
+ [gr](t) {
2463
+ if (!this[Nr](t)) return t.resume();
2464
+ switch (so.equal(typeof t.absolute, "string"), t.type) {
2465
+ case "Directory":
2466
+ case "GNUDumpDir":
2467
+ t.mode && (t.mode = t.mode | 448);
2468
+ case "File":
2469
+ case "OldFile":
2470
+ case "ContiguousFile":
2471
+ case "Link":
2472
+ case "SymbolicLink":
2473
+ return this[ys](t);
2474
+ default:
2475
+ return this[Lr](t);
2476
+ }
2477
+ }
2478
+ [O](t, e) {
2479
+ t.name === "CwdError" ? this.emit("error", t) : (this.warn("TAR_ENTRY_ERROR", t, { entry: e }), this[Xt](), e.resume());
2480
+ }
2481
+ [St](t, e, i) {
2482
+ Er(f(t), { uid: this.uid, gid: this.gid, processUid: this.processUid, processGid: this.processGid, umask: this.processUmask, preserve: this.preservePaths, unlink: this.unlink, cwd: this.cwd, mode: e }, i);
2483
+ }
2484
+ [Re](t) {
2485
+ return this.forceChown || this.preserveOwner && (typeof t.uid == "number" && t.uid !== this.processUid || typeof t.gid == "number" && t.gid !== this.processGid) || typeof this.uid == "number" && this.uid !== this.processUid || typeof this.gid == "number" && this.gid !== this.processGid;
2486
+ }
2487
+ [be](t) {
2488
+ return Dr(this.uid, t.uid, this.processUid);
2489
+ }
2490
+ [_e](t) {
2491
+ return Dr(this.gid, t.gid, this.processGid);
2492
+ }
2493
+ [bs](t, e) {
2494
+ let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new tt(String(t.absolute), { flags: cs(t.size), mode: i, autoClose: false });
2495
+ r.on("error", (a) => {
2496
+ r.fd && u.close(r.fd, () => {
2497
+ }), r.write = () => true, this[O](a, t), e();
2498
+ });
2499
+ let n = 1, o = (a) => {
2500
+ if (a) {
2501
+ r.fd && u.close(r.fd, () => {
2502
+ }), this[O](a, t), e();
2503
+ return;
2504
+ }
2505
+ --n === 0 && r.fd !== void 0 && u.close(r.fd, (l) => {
2506
+ l ? this[O](l, t) : this[Xt](), e();
2507
+ });
2508
+ };
2509
+ r.on("finish", () => {
2510
+ let a = String(t.absolute), l = r.fd;
2511
+ if (typeof l == "number" && t.mtime && !this.noMtime) {
2512
+ n++;
2513
+ let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
2514
+ u.futimes(l, c, d, (S) => S ? u.utimes(a, c, d, (T) => o(T && S)) : o());
2515
+ }
2516
+ if (typeof l == "number" && this[Re](t)) {
2517
+ n++;
2518
+ let c = this[be](t), d = this[_e](t);
2519
+ typeof c == "number" && typeof d == "number" && u.fchown(l, c, d, (S) => S ? u.chown(a, c, d, (T) => o(T && S)) : o());
2520
+ }
2521
+ o();
2522
+ });
2523
+ let h = this.transform && this.transform(t) || t;
2524
+ h !== t && (h.on("error", (a) => {
2525
+ this[O](a, t), e();
2526
+ }), t.pipe(h)), h.pipe(r);
2527
+ }
2528
+ [_s](t, e) {
2529
+ let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode;
2530
+ this[St](String(t.absolute), i, (r) => {
2531
+ if (r) {
2532
+ this[O](r, t), e();
2533
+ return;
2534
+ }
2535
+ let n = 1, o = () => {
2536
+ --n === 0 && (e(), this[Xt](), t.resume());
2537
+ };
2538
+ t.mtime && !this.noMtime && (n++, u.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[Re](t) && (n++, u.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o)), o();
2539
+ });
2540
+ }
2541
+ [Lr](t) {
2542
+ t.unsupported = true, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
2543
+ }
2544
+ [Tr](t, e) {
2545
+ let i = f(R.relative(this.cwd, R.resolve(R.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
2546
+ this[ye](t, this.cwd, i, () => this[Si](t, String(t.linkpath), "symlink", e), (r) => {
2547
+ this[O](r, t), e();
2548
+ });
2549
+ }
2550
+ [xr](t, e) {
2551
+ let i = f(R.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
2552
+ this[ye](t, this.cwd, r, () => this[Si](t, i, "link", e), (n) => {
2553
+ this[O](n, t), e();
2554
+ });
2555
+ }
2556
+ [ye](t, e, i, r, n) {
2557
+ let o = i.shift();
2558
+ if (this.preservePaths || o === void 0) return r();
2559
+ let h = R.resolve(e, o);
2560
+ u.lstat(h, (a, l) => {
2561
+ if (a) return r();
2562
+ if (l?.isSymbolicLink()) return n(new wt(h, R.resolve(h, i.join("/"))));
2563
+ this[ye](t, h, i, r, n);
2564
+ });
2565
+ }
2566
+ [Ar]() {
2567
+ this[wi]++;
2568
+ }
2569
+ [Xt]() {
2570
+ this[wi]--, this[Ss]();
2571
+ }
2572
+ [gs](t) {
2573
+ this[Xt](), t.resume();
2574
+ }
2575
+ [Rs](t, e) {
2576
+ return t.type === "File" && !this.unlink && e.isFile() && e.nlink <= 1 && !Oe;
2577
+ }
2578
+ [ys](t) {
2579
+ this[Ar]();
2580
+ let e = [t.path];
2581
+ t.linkpath && e.push(t.linkpath), this.reservations.reserve(e, (i) => this[Or](t, i));
2582
+ }
2583
+ [Or](t, e) {
2584
+ let i = (h) => {
2585
+ e(h);
2586
+ }, r = () => {
2587
+ this[St](this.cwd, this.dmode, (h) => {
2588
+ if (h) {
2589
+ this[O](h, t), i();
2590
+ return;
2591
+ }
2592
+ this[ge] = true, n();
2593
+ });
2594
+ }, n = () => {
2595
+ if (t.absolute !== this.cwd) {
2596
+ let h = f(R.dirname(String(t.absolute)));
2597
+ if (h !== this.cwd) return this[St](h, this.dmode, (a) => {
2598
+ if (a) {
2599
+ this[O](a, t), i();
2600
+ return;
2601
+ }
2602
+ o();
2603
+ });
2604
+ }
2605
+ o();
2606
+ }, o = () => {
2607
+ u.lstat(String(t.absolute), (h, a) => {
2608
+ if (a && (this.keep || this.newer && a.mtime > (t.mtime ?? a.mtime))) {
2609
+ this[gs](t), i();
2610
+ return;
2611
+ }
2612
+ if (h || this[Rs](t, a)) return this[P](null, t, i);
2613
+ if (a.isDirectory()) {
2614
+ if (t.type === "Directory") {
2615
+ let l = this.chmod && t.mode && (a.mode & 4095) !== t.mode, c = (d) => this[P](d ?? null, t, i);
2616
+ return l ? u.chmod(String(t.absolute), Number(t.mode), c) : c();
2617
+ }
2618
+ if (t.absolute !== this.cwd) return u.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
2619
+ }
2620
+ if (t.absolute === this.cwd) return this[P](null, t, i);
2621
+ oo(String(t.absolute), (l) => this[P](l ?? null, t, i));
2622
+ });
2623
+ };
2624
+ this[ge] ? n() : r();
2625
+ }
2626
+ [P](t, e, i) {
2627
+ if (t) {
2628
+ this[O](t, e), i();
2629
+ return;
2630
+ }
2631
+ switch (e.type) {
2632
+ case "File":
2633
+ case "OldFile":
2634
+ case "ContiguousFile":
2635
+ return this[bs](e, i);
2636
+ case "Link":
2637
+ return this[xr](e, i);
2638
+ case "SymbolicLink":
2639
+ return this[Tr](e, i);
2640
+ case "Directory":
2641
+ case "GNUDumpDir":
2642
+ return this[_s](e, i);
2643
+ }
2644
+ }
2645
+ [Si](t, e, i, r) {
2646
+ u[i](e, String(t.absolute), (n) => {
2647
+ n ? this[O](n, t) : (this[Xt](), t.resume()), r();
2648
+ });
2649
+ }
2650
+ };
2651
+ var Se = (s3) => {
2652
+ try {
2653
+ return [null, s3()];
2654
+ } catch (t) {
2655
+ return [t, null];
2656
+ }
2657
+ };
2658
+ var Te = class extends qt {
2659
+ sync = true;
2660
+ [P](t, e) {
2661
+ return super[P](t, e, () => {
2662
+ });
2663
+ }
2664
+ [ys](t) {
2665
+ if (!this[ge]) {
2666
+ let n = this[St](this.cwd, this.dmode);
2667
+ if (n) return this[O](n, t);
2668
+ this[ge] = true;
2669
+ }
2670
+ if (t.absolute !== this.cwd) {
2671
+ let n = f(R.dirname(String(t.absolute)));
2672
+ if (n !== this.cwd) {
2673
+ let o = this[St](n, this.dmode);
2674
+ if (o) return this[O](o, t);
2675
+ }
2676
+ }
2677
+ let [e, i] = Se(() => u.lstatSync(String(t.absolute)));
2678
+ if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[gs](t);
2679
+ if (e || this[Rs](t, i)) return this[P](null, t);
2680
+ if (i.isDirectory()) {
2681
+ if (t.type === "Directory") {
2682
+ let o = this.chmod && t.mode && (i.mode & 4095) !== t.mode, [h] = o ? Se(() => {
2683
+ u.chmodSync(String(t.absolute), Number(t.mode));
2684
+ }) : [];
2685
+ return this[P](h, t);
2686
+ }
2687
+ let [n] = Se(() => u.rmdirSync(String(t.absolute)));
2688
+ this[P](n, t);
2689
+ }
2690
+ let [r] = t.absolute === this.cwd ? [] : Se(() => ho(String(t.absolute)));
2691
+ this[P](r, t);
2692
+ }
2693
+ [bs](t, e) {
2694
+ let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (h) => {
2695
+ let a;
2696
+ try {
2697
+ u.closeSync(n);
2698
+ } catch (l) {
2699
+ a = l;
2700
+ }
2701
+ (h || a) && this[O](h || a, t), e();
2702
+ }, n;
2703
+ try {
2704
+ n = u.openSync(String(t.absolute), cs(t.size), i);
2705
+ } catch (h) {
2706
+ return r(h);
2707
+ }
2708
+ let o = this.transform && this.transform(t) || t;
2709
+ o !== t && (o.on("error", (h) => this[O](h, t)), t.pipe(o)), o.on("data", (h) => {
2710
+ try {
2711
+ u.writeSync(n, h, 0, h.length);
2712
+ } catch (a) {
2713
+ r(a);
2714
+ }
2715
+ }), o.on("end", () => {
2716
+ let h = null;
2717
+ if (t.mtime && !this.noMtime) {
2718
+ let a = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
2719
+ try {
2720
+ u.futimesSync(n, a, l);
2721
+ } catch (c) {
2722
+ try {
2723
+ u.utimesSync(String(t.absolute), a, l);
2724
+ } catch {
2725
+ h = c;
2726
+ }
2727
+ }
2728
+ }
2729
+ if (this[Re](t)) {
2730
+ let a = this[be](t), l = this[_e](t);
2731
+ try {
2732
+ u.fchownSync(n, Number(a), Number(l));
2733
+ } catch (c) {
2734
+ try {
2735
+ u.chownSync(String(t.absolute), Number(a), Number(l));
2736
+ } catch {
2737
+ h = h || c;
2738
+ }
2739
+ }
2740
+ }
2741
+ r(h);
2742
+ });
2743
+ }
2744
+ [_s](t, e) {
2745
+ let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode, r = this[St](String(t.absolute), i);
2746
+ if (r) {
2747
+ this[O](r, t), e();
2748
+ return;
2749
+ }
2750
+ if (t.mtime && !this.noMtime) try {
2751
+ u.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
2752
+ } catch {
2753
+ }
2754
+ if (this[Re](t)) try {
2755
+ u.chownSync(String(t.absolute), Number(this[be](t)), Number(this[_e](t)));
2756
+ } catch {
2757
+ }
2758
+ e(), t.resume();
2759
+ }
2760
+ [St](t, e) {
2761
+ try {
2762
+ return Sr(f(t), { uid: this.uid, gid: this.gid, processUid: this.processUid, processGid: this.processGid, umask: this.processUmask, preserve: this.preservePaths, unlink: this.unlink, cwd: this.cwd, mode: e });
2763
+ } catch (i) {
2764
+ return i;
2765
+ }
2766
+ }
2767
+ [ye](t, e, i, r, n) {
2768
+ if (this.preservePaths || i.length === 0) return r();
2769
+ let o = e;
2770
+ for (let h of i) {
2771
+ o = R.resolve(o, h);
2772
+ let [a, l] = Se(() => u.lstatSync(o));
2773
+ if (a) return r();
2774
+ if (l.isSymbolicLink()) return n(new wt(o, R.resolve(e, i.join("/"))));
2775
+ }
2776
+ r();
2777
+ }
2778
+ [Si](t, e, i, r) {
2779
+ let n = `${i}Sync`;
2780
+ try {
2781
+ u[n](e, String(t.absolute)), r(), t.resume();
2782
+ } catch (o) {
2783
+ return this[O](o, t);
2784
+ }
2785
+ }
2786
+ };
2787
+ var ao = (s3) => {
2788
+ let t = new Te(s3), e = s3.file, i = Cr.statSync(e), r = s3.maxReadSize || 16 * 1024 * 1024;
2789
+ new Me(e, { readSize: r, size: i.size }).pipe(t);
2790
+ };
2791
+ var lo = (s3, t) => {
2792
+ let e = new qt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
2793
+ return new Promise((o, h) => {
2794
+ e.on("error", h), e.on("close", o), Cr.stat(r, (a, l) => {
2795
+ if (a) h(a);
2796
+ else {
2797
+ let c = new _t(r, { readSize: i, size: l.size });
2798
+ c.on("error", h), c.pipe(e);
2799
+ }
2800
+ });
2801
+ });
2802
+ };
2803
+ var co = K(ao, lo, (s3) => new Te(s3), (s3) => new qt(s3), (s3, t) => {
2804
+ t?.length && Ki(s3, t);
2805
+ });
2806
+ var fo = (s3, t) => {
2807
+ let e = new kt(s3), i = true, r, n;
2808
+ try {
2809
+ try {
2810
+ r = v.openSync(s3.file, "r+");
2811
+ } catch (a) {
2812
+ if (a?.code === "ENOENT") r = v.openSync(s3.file, "w+");
2813
+ else throw a;
2814
+ }
2815
+ let o = v.fstatSync(r), h = Buffer.alloc(512);
2816
+ t: for (n = 0; n < o.size; n += 512) {
2817
+ for (let c = 0, d = 0; c < 512; c += d) {
2818
+ if (d = v.readSync(r, h, c, h.length - c, n + c), n === 0 && h[0] === 31 && h[1] === 139) throw new Error("cannot append to compressed archives");
2819
+ if (!d) break t;
2820
+ }
2821
+ let a = new F(h);
2822
+ if (!a.cksumValid) break;
2823
+ let l = 512 * Math.ceil((a.size || 0) / 512);
2824
+ if (n + l + 512 > o.size) break;
2825
+ n += l, s3.mtimeCache && a.mtime && s3.mtimeCache.set(String(a.path), a.mtime);
2826
+ }
2827
+ i = false, uo(s3, e, n, r, t);
2828
+ } finally {
2829
+ if (i) try {
2830
+ v.closeSync(r);
2831
+ } catch {
2832
+ }
2833
+ }
2834
+ };
2835
+ var uo = (s3, t, e, i, r) => {
2836
+ let n = new Wt(s3.file, { fd: i, start: e });
2837
+ t.pipe(n), po(t, r);
2838
+ };
2839
+ var mo = (s3, t) => {
2840
+ t = Array.from(t);
2841
+ let e = new Et(s3), i = (n, o, h) => {
2842
+ let a = (T, N) => {
2843
+ T ? v.close(n, (E) => h(T)) : h(null, N);
2844
+ }, l = 0;
2845
+ if (o === 0) return a(null, 0);
2846
+ let c = 0, d = Buffer.alloc(512), S = (T, N) => {
2847
+ if (T || N === void 0) return a(T);
2848
+ if (c += N, c < 512 && N) return v.read(n, d, c, d.length - c, l + c, S);
2849
+ if (l === 0 && d[0] === 31 && d[1] === 139) return a(new Error("cannot append to compressed archives"));
2850
+ if (c < 512) return a(null, l);
2851
+ let E = new F(d);
2852
+ if (!E.cksumValid) return a(null, l);
2853
+ let x = 512 * Math.ceil((E.size ?? 0) / 512);
2854
+ if (l + x + 512 > o || (l += x + 512, l >= o)) return a(null, l);
2855
+ s3.mtimeCache && E.mtime && s3.mtimeCache.set(String(E.path), E.mtime), c = 0, v.read(n, d, 0, 512, l, S);
2856
+ };
2857
+ v.read(n, d, 0, 512, l, S);
2858
+ };
2859
+ return new Promise((n, o) => {
2860
+ e.on("error", o);
2861
+ let h = "r+", a = (l, c) => {
2862
+ if (l && l.code === "ENOENT" && h === "r+") return h = "w+", v.open(s3.file, h, a);
2863
+ if (l || !c) return o(l);
2864
+ v.fstat(c, (d, S) => {
2865
+ if (d) return v.close(c, () => o(d));
2866
+ i(c, S.size, (T, N) => {
2867
+ if (T) return o(T);
2868
+ let E = new tt(s3.file, { fd: c, start: N });
2869
+ e.pipe(E), E.on("error", o), E.on("close", n), Eo(e, t);
2870
+ });
2871
+ });
2872
+ };
2873
+ v.open(s3.file, h, a);
2874
+ });
2875
+ };
2876
+ var po = (s3, t) => {
2877
+ t.forEach((e) => {
2878
+ e.charAt(0) === "@" ? It({ file: Fr.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
2879
+ }), s3.end();
2880
+ };
2881
+ var Eo = async (s3, t) => {
2882
+ for (let e of t) e.charAt(0) === "@" ? await It({ file: Fr.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
2883
+ s3.end();
2884
+ };
2885
+ var vt = K(fo, mo, () => {
2886
+ throw new TypeError("file is required");
2887
+ }, () => {
2888
+ throw new TypeError("file is required");
2889
+ }, (s3, t) => {
2890
+ if (!Fs(s3)) throw new TypeError("file is required");
2891
+ if (s3.gzip || s3.brotli || s3.zstd || s3.file.endsWith(".br") || s3.file.endsWith(".tbr")) throw new TypeError("cannot append to compressed archives");
2892
+ if (!t?.length) throw new TypeError("no paths specified to add/replace");
2893
+ });
2894
+ var wo = K(vt.syncFile, vt.asyncFile, vt.syncNoFile, vt.asyncNoFile, (s3, t = []) => {
2895
+ vt.validate?.(s3, t), So(s3);
2896
+ });
2897
+ var So = (s3) => {
2898
+ let t = s3.filter;
2899
+ s3.mtimeCache || (s3.mtimeCache = /* @__PURE__ */ new Map()), s3.filter = t ? (e, i) => t(e, i) && !((s3.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e, i) => !((s3.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0));
2900
+ };
2901
+ export {
2902
+ F as Header,
2903
+ Et as Pack,
2904
+ di as PackJob,
2905
+ kt as PackSync,
2906
+ st as Parser,
2907
+ ct as Pax,
2908
+ Yt as ReadEntry,
2909
+ qt as Unpack,
2910
+ Te as UnpackSync,
2911
+ de as WriteEntry,
2912
+ si as WriteEntrySync,
2913
+ ri as WriteEntryTar,
2914
+ Zn as c,
2915
+ Zn as create,
2916
+ co as extract,
2917
+ Ki as filesFilter,
2918
+ It as list,
2919
+ vt as r,
2920
+ vt as replace,
2921
+ It as t,
2922
+ Bi as types,
2923
+ wo as u,
2924
+ wo as update,
2925
+ co as x
2926
+ };