peachsim 0.1.2438 → 0.1.2439

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 (175) hide show
  1. package/README.md +30 -98
  2. package/cli/app-catalog.ts +4 -73
  3. package/cli/catalog/content.ts +1 -1
  4. package/cli/cloud-box-artifact.ts +26 -39
  5. package/cli/cloud-client.ts +69 -117
  6. package/cli/cloud-session.ts +2 -9
  7. package/cli/commands/box.ts +6 -6
  8. package/cli/commands/control.ts +4 -11
  9. package/cli/commands/flow.ts +5 -9
  10. package/cli/commands/kotlin.ts +2 -1
  11. package/cli/commands/platform.ts +21 -39
  12. package/cli/commands/record-three.ts +1 -1
  13. package/cli/commands/shell-url.ts +29 -23
  14. package/cli/dev-build-freshness.ts +4 -3
  15. package/cli/native-input.ts +2 -2
  16. package/cli/outbound-endpoints.ts +20 -45
  17. package/cli/remote-project-bundle.ts +8 -14
  18. package/cli/remote-simulators.ts +1 -1
  19. package/cli/send-to-box.ts +2 -1
  20. package/detox/jest-preset.cjs +1 -1
  21. package/detox/jest-transform.cjs +40 -2
  22. package/dist-lib/agent-daemon-client.cjs +34 -24
  23. package/dist-lib/agent-events.cjs +1 -1
  24. package/dist-lib/attached-projects.cjs +19 -17
  25. package/dist-lib/auth/shared-session.cjs +18 -16
  26. package/dist-lib/backend-origin.cjs +1 -1
  27. package/dist-lib/beta.cjs +1 -1
  28. package/dist-lib/beta.mjs +2 -1
  29. package/dist-lib/bridge-constants.cjs +1 -1
  30. package/dist-lib/bridge-contract-input.cjs +1 -1
  31. package/dist-lib/bridge-contract-input.mjs +20 -583
  32. package/dist-lib/bridge-contract.cjs +1 -1
  33. package/dist-lib/bridge-contract.mjs +17 -99
  34. package/dist-lib/bundle-channel.cjs +8718 -5552
  35. package/dist-lib/capture-contract.cjs +1 -1
  36. package/dist-lib/capture-contract.mjs +13 -363
  37. package/dist-lib/cloud-contract.cjs +1 -1
  38. package/dist-lib/cloud-contract.mjs +34 -155
  39. package/dist-lib/cloud-test-args.cjs +1 -1
  40. package/dist-lib/cloud-test-args.mjs +2 -1
  41. package/dist-lib/cloud.cjs +1 -1
  42. package/dist-lib/cloud.mjs +26 -155
  43. package/dist-lib/config.cjs +1 -4
  44. package/dist-lib/config.mjs +11 -30
  45. package/dist-lib/detox/index.cjs +2554 -230
  46. package/dist-lib/detox/jest-preset.cjs +1 -1
  47. package/dist-lib/detox/jest-transform.cjs +40 -2
  48. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  49. package/dist-lib/esm-chunks/acorn-FGE4PYDJ.mjs +50 -0
  50. package/dist-lib/esm-chunks/chunk-2EUHEBIJ.mjs +664 -0
  51. package/dist-lib/esm-chunks/chunk-2NPABFPN.mjs +5719 -0
  52. package/dist-lib/esm-chunks/chunk-4ZFNH7TU.mjs +10 -0
  53. package/dist-lib/esm-chunks/chunk-5T4XBUJP.mjs +1353 -0
  54. package/dist-lib/esm-chunks/chunk-6VY6HTJC.mjs +18951 -0
  55. package/dist-lib/esm-chunks/chunk-7HANEMO4.mjs +188 -0
  56. package/dist-lib/esm-chunks/chunk-C3WBGYP6.mjs +186 -0
  57. package/dist-lib/esm-chunks/chunk-CVGDRROP.mjs +57 -0
  58. package/dist-lib/esm-chunks/chunk-DADGQELM.mjs +375 -0
  59. package/dist-lib/esm-chunks/chunk-DEGYKHN7.mjs +12 -0
  60. package/dist-lib/esm-chunks/chunk-HIDNO3RP.mjs +10992 -0
  61. package/dist-lib/esm-chunks/chunk-HSADZOVN.mjs +30 -0
  62. package/dist-lib/esm-chunks/chunk-IWJUYJQO.mjs +42 -0
  63. package/dist-lib/esm-chunks/chunk-JCKI3VZ6.mjs +10 -0
  64. package/dist-lib/esm-chunks/chunk-KSQ5KM5Y.mjs +17 -0
  65. package/dist-lib/esm-chunks/chunk-KVTIDLBK.mjs +598 -0
  66. package/dist-lib/esm-chunks/chunk-MIQSRBVU.mjs +10 -0
  67. package/dist-lib/esm-chunks/chunk-YB27R6JG.mjs +115 -0
  68. package/dist-lib/esm-chunks/metro-layout-parser-MVUAXRUJ.mjs +58 -0
  69. package/dist-lib/expo-swift-bundle.cjs +7856 -4707
  70. package/dist-lib/expo-swift-metadata.cjs +1 -1
  71. package/dist-lib/expo-swift-metadata.mjs +16 -165
  72. package/dist-lib/home-paths.cjs +1 -1
  73. package/dist-lib/host/bridge-host.cjs +15658 -11404
  74. package/dist-lib/host/fetch-proxy-handler.cjs +3927 -342
  75. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  76. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -1
  77. package/dist-lib/host/replacement-module-handler.cjs +4 -4
  78. package/dist-lib/host/websocket-proxy.cjs +1 -1
  79. package/dist-lib/index.cjs +9145 -32150
  80. package/dist-lib/jump-to-source-babel.cjs +1 -1
  81. package/dist-lib/jump-to-source-native.cjs +2 -2
  82. package/dist-lib/kotlin-host.cjs +260 -253
  83. package/dist-lib/menu.cjs +1 -1
  84. package/dist-lib/menu.mjs +5 -13
  85. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  86. package/dist-lib/metro-fingerprint-registry.mjs +5 -6
  87. package/dist-lib/metro-production-bundle.cjs +22 -3
  88. package/dist-lib/metro-production-bundle.mjs +26 -92
  89. package/dist-lib/native-app-identity-project.cjs +663 -451
  90. package/dist-lib/native-app-identity-project.mjs +509 -2318
  91. package/dist-lib/native-app-identity.cjs +1 -1
  92. package/dist-lib/native-app-identity.mjs +27 -1340
  93. package/dist-lib/native-firebase-metadata.cjs +1 -1
  94. package/dist-lib/native-firebase-metadata.mjs +5 -18
  95. package/dist-lib/pdfium-raster.cjs +1 -1
  96. package/dist-lib/pdfium-raster.mjs +2 -1
  97. package/dist-lib/plist.cjs +2 -2
  98. package/dist-lib/plist.mjs +5 -7
  99. package/dist-lib/profiles.cjs +2 -1
  100. package/dist-lib/public-brand.cjs +1 -1
  101. package/dist-lib/public-origins-lib-esm.json +246 -187
  102. package/dist-lib/public-origins-lib-static.json +1 -1
  103. package/dist-lib/public-origins-lib.json +1059 -1238
  104. package/dist-lib/react-native-host-modules.cjs +1 -1
  105. package/dist-lib/react-native-host-modules.mjs +2 -1
  106. package/dist-lib/reap-browser.cjs +18 -7
  107. package/dist-lib/scripts/dev-server-scanner.cjs +6 -230
  108. package/dist-lib/sdk.cjs +1 -1
  109. package/dist-lib/sdk.mjs +22 -78
  110. package/dist-lib/skills.cjs +21657 -17374
  111. package/dist-lib/swift-compile.cjs +1343 -1318
  112. package/dist-lib/swift-compile.mjs +68 -19013
  113. package/dist-lib/swift-package.cjs +1 -1
  114. package/dist-lib/swift-package.mjs +35 -630
  115. package/dist-lib/swift-submit.cjs +1 -1
  116. package/dist-lib/swift-submit.mjs +9 -24
  117. package/dist-lib/swift-toolchain.cjs +1 -1
  118. package/dist-lib/swift.cjs +1 -1
  119. package/dist-lib/vendor/@peculiar/x509.cjs +18061 -0
  120. package/dist-lib/vendor/acorn.cjs +5699 -0
  121. package/dist-lib/vendor/bplist-parser.cjs +1589 -0
  122. package/dist-lib/vendor/ignore.cjs +455 -0
  123. package/dist-lib/vendor/magic-string.cjs +1693 -0
  124. package/dist-lib/vendor/plist.cjs +10978 -0
  125. package/dist-lib/vendor/smol-toml.cjs +768 -0
  126. package/dist-lib/vendor/stream-json.cjs +1997 -0
  127. package/dist-lib/vendor/sucrase/dist/index.js.cjs +23593 -0
  128. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +15750 -0
  129. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +11316 -0
  130. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +482 -0
  131. package/dist-lib/vendor/sucrase.cjs +23593 -0
  132. package/dist-lib/vendor/terser.cjs +36874 -0
  133. package/dist-lib/vendor/valibot.cjs +6253 -0
  134. package/dist-lib/vendor/zod.cjs +23262 -0
  135. package/dist-lib/worklet-executable.cjs +3 -3
  136. package/dist-lib/worklet-executable.mjs +11 -16
  137. package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
  138. package/kotlin/fork/NOTICE +3 -0
  139. package/kotlin/sdk.tar.gz +0 -0
  140. package/kotlin/toolchain.json +6 -6
  141. package/package.json +17 -121
  142. package/runtime-companion.json +1 -1
  143. package/scripts/dev-server-scanner.ts +13 -223
  144. package/src/android-autolinking.ts +2 -2
  145. package/src/bundle-channel.mjs +3 -15
  146. package/src/cloud-contract.ts +3 -4
  147. package/src/config.ts +0 -5
  148. package/src/host/bridge-host.ts +19 -1
  149. package/src/host/server-scan-handler.ts +1 -9
  150. package/src/index.ts +0 -2
  151. package/src/kotlin-host.ts +1 -2
  152. package/src/kotlinDiscoveryContract.ts +1 -0
  153. package/src/metro-production-bundle.ts +28 -6
  154. package/src/native-seam-manifest.ts +0 -13
  155. package/src/one-native-app-catalog.ts +8 -27
  156. package/src/one-native-app-config.ts +95 -0
  157. package/src/one-native-source.ts +250 -0
  158. package/src/one-widget-metadata.ts +45 -126
  159. package/src/oneWidgetContract.ts +80 -117
  160. package/src/serverDiscoveryContract.ts +0 -1
  161. package/src/simulator-route.ts +8 -0
  162. package/src/vite-plugin.ts +2 -2
  163. package/src/xcode-project.ts +1 -1
  164. package/dist-lib/metro.cjs +0 -27984
  165. package/dist-lib/vite-swift.cjs +0 -43376
  166. package/dist-lib/vite.cjs +0 -21456
  167. package/src/androidAutolinkingContract.ts +0 -48
  168. package/src/androidRootModuleContract.ts +0 -39
  169. package/src/dev-server-open.ts +0 -92
  170. package/src/metro-plugin.ts +0 -578
  171. package/src/one-widget-discovery.ts +0 -23
  172. package/src/swift-vite-lifetime.ts +0 -42
  173. package/src/vite-plugin-one.ts +0 -746
  174. package/src/vite-plugin-swift.ts +0 -225
  175. package/src/vite.d.ts +0 -10
@@ -0,0 +1,1693 @@
1
+ /*! peach v0.1.2439 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
+ let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
+ "use strict";
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __commonJS = (cb, mod) => function __require() {
6
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
+ };
8
+
9
+ // ../../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js
10
+ var require_sourcemap_codec_umd = __commonJS({
11
+ "../../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js"(exports2, module2) {
12
+ (function(global, factory) {
13
+ if (typeof exports2 === "object" && typeof module2 !== "undefined") {
14
+ factory(module2);
15
+ module2.exports = def(module2);
16
+ } else if (typeof define === "function" && define.amd) {
17
+ define(["module"], function(mod) {
18
+ factory.apply(this, arguments);
19
+ mod.exports = def(mod);
20
+ });
21
+ } else {
22
+ const mod = { exports: {} };
23
+ factory(mod);
24
+ global = typeof globalThis !== "undefined" ? globalThis : global || self;
25
+ global.sourcemapCodec = def(mod);
26
+ }
27
+ function def(m) {
28
+ return "default" in m.exports ? m.exports.default : m.exports;
29
+ }
30
+ })(exports2, (function(module3) {
31
+ "use strict";
32
+ var __defProp = Object.defineProperty;
33
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
34
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
35
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
36
+ var __export = (target, all) => {
37
+ for (var name in all)
38
+ __defProp(target, name, { get: all[name], enumerable: true });
39
+ };
40
+ var __copyProps = (to, from, except, desc) => {
41
+ if (from && typeof from === "object" || typeof from === "function") {
42
+ for (let key of __getOwnPropNames2(from))
43
+ if (!__hasOwnProp.call(to, key) && key !== except)
44
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
45
+ }
46
+ return to;
47
+ };
48
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
49
+ var sourcemap_codec_exports = {};
50
+ __export(sourcemap_codec_exports, {
51
+ decode: () => decode,
52
+ decodeGeneratedRanges: () => decodeGeneratedRanges,
53
+ decodeOriginalScopes: () => decodeOriginalScopes,
54
+ encode: () => encode,
55
+ encodeGeneratedRanges: () => encodeGeneratedRanges,
56
+ encodeOriginalScopes: () => encodeOriginalScopes
57
+ });
58
+ module3.exports = __toCommonJS(sourcemap_codec_exports);
59
+ var comma = ",".charCodeAt(0);
60
+ var semicolon = ";".charCodeAt(0);
61
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
62
+ var intToChar = new Uint8Array(64);
63
+ var charToInt = new Uint8Array(128);
64
+ for (let i = 0; i < chars.length; i++) {
65
+ const c = chars.charCodeAt(i);
66
+ intToChar[i] = c;
67
+ charToInt[c] = i;
68
+ }
69
+ function decodeInteger(reader, relative) {
70
+ let value = 0;
71
+ let shift = 0;
72
+ let integer = 0;
73
+ do {
74
+ const c = reader.next();
75
+ integer = charToInt[c];
76
+ value |= (integer & 31) << shift;
77
+ shift += 5;
78
+ } while (integer & 32);
79
+ const shouldNegate = value & 1;
80
+ value >>>= 1;
81
+ if (shouldNegate) {
82
+ value = -2147483648 | -value;
83
+ }
84
+ return relative + value;
85
+ }
86
+ function encodeInteger(builder, num, relative) {
87
+ let delta = num - relative;
88
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
89
+ do {
90
+ let clamped = delta & 31;
91
+ delta >>>= 5;
92
+ if (delta > 0) clamped |= 32;
93
+ builder.write(intToChar[clamped]);
94
+ } while (delta > 0);
95
+ return num;
96
+ }
97
+ function hasMoreVlq(reader, max) {
98
+ if (reader.pos >= max) return false;
99
+ return reader.peek() !== comma;
100
+ }
101
+ var bufLength = 1024 * 16;
102
+ var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
103
+ decode(buf) {
104
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
105
+ return out.toString();
106
+ }
107
+ } : {
108
+ decode(buf) {
109
+ let out = "";
110
+ for (let i = 0; i < buf.length; i++) {
111
+ out += String.fromCharCode(buf[i]);
112
+ }
113
+ return out;
114
+ }
115
+ };
116
+ var StringWriter = class {
117
+ constructor() {
118
+ this.pos = 0;
119
+ this.out = "";
120
+ this.buffer = new Uint8Array(bufLength);
121
+ }
122
+ write(v) {
123
+ const { buffer } = this;
124
+ buffer[this.pos++] = v;
125
+ if (this.pos === bufLength) {
126
+ this.out += td.decode(buffer);
127
+ this.pos = 0;
128
+ }
129
+ }
130
+ flush() {
131
+ const { buffer, out, pos } = this;
132
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
133
+ }
134
+ };
135
+ var StringReader = class {
136
+ constructor(buffer) {
137
+ this.pos = 0;
138
+ this.buffer = buffer;
139
+ }
140
+ next() {
141
+ return this.buffer.charCodeAt(this.pos++);
142
+ }
143
+ peek() {
144
+ return this.buffer.charCodeAt(this.pos);
145
+ }
146
+ indexOf(char) {
147
+ const { buffer, pos } = this;
148
+ const idx = buffer.indexOf(char, pos);
149
+ return idx === -1 ? buffer.length : idx;
150
+ }
151
+ };
152
+ var EMPTY = [];
153
+ function decodeOriginalScopes(input) {
154
+ const { length } = input;
155
+ const reader = new StringReader(input);
156
+ const scopes = [];
157
+ const stack = [];
158
+ let line = 0;
159
+ for (; reader.pos < length; reader.pos++) {
160
+ line = decodeInteger(reader, line);
161
+ const column = decodeInteger(reader, 0);
162
+ if (!hasMoreVlq(reader, length)) {
163
+ const last = stack.pop();
164
+ last[2] = line;
165
+ last[3] = column;
166
+ continue;
167
+ }
168
+ const kind = decodeInteger(reader, 0);
169
+ const fields = decodeInteger(reader, 0);
170
+ const hasName = fields & 1;
171
+ const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
172
+ let vars = EMPTY;
173
+ if (hasMoreVlq(reader, length)) {
174
+ vars = [];
175
+ do {
176
+ const varsIndex = decodeInteger(reader, 0);
177
+ vars.push(varsIndex);
178
+ } while (hasMoreVlq(reader, length));
179
+ }
180
+ scope.vars = vars;
181
+ scopes.push(scope);
182
+ stack.push(scope);
183
+ }
184
+ return scopes;
185
+ }
186
+ function encodeOriginalScopes(scopes) {
187
+ const writer = new StringWriter();
188
+ for (let i = 0; i < scopes.length; ) {
189
+ i = _encodeOriginalScopes(scopes, i, writer, [0]);
190
+ }
191
+ return writer.flush();
192
+ }
193
+ function _encodeOriginalScopes(scopes, index, writer, state) {
194
+ const scope = scopes[index];
195
+ const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
196
+ if (index > 0) writer.write(comma);
197
+ state[0] = encodeInteger(writer, startLine, state[0]);
198
+ encodeInteger(writer, startColumn, 0);
199
+ encodeInteger(writer, kind, 0);
200
+ const fields = scope.length === 6 ? 1 : 0;
201
+ encodeInteger(writer, fields, 0);
202
+ if (scope.length === 6) encodeInteger(writer, scope[5], 0);
203
+ for (const v of vars) {
204
+ encodeInteger(writer, v, 0);
205
+ }
206
+ for (index++; index < scopes.length; ) {
207
+ const next = scopes[index];
208
+ const { 0: l, 1: c } = next;
209
+ if (l > endLine || l === endLine && c >= endColumn) {
210
+ break;
211
+ }
212
+ index = _encodeOriginalScopes(scopes, index, writer, state);
213
+ }
214
+ writer.write(comma);
215
+ state[0] = encodeInteger(writer, endLine, state[0]);
216
+ encodeInteger(writer, endColumn, 0);
217
+ return index;
218
+ }
219
+ function decodeGeneratedRanges(input) {
220
+ const { length } = input;
221
+ const reader = new StringReader(input);
222
+ const ranges = [];
223
+ const stack = [];
224
+ let genLine = 0;
225
+ let definitionSourcesIndex = 0;
226
+ let definitionScopeIndex = 0;
227
+ let callsiteSourcesIndex = 0;
228
+ let callsiteLine = 0;
229
+ let callsiteColumn = 0;
230
+ let bindingLine = 0;
231
+ let bindingColumn = 0;
232
+ do {
233
+ const semi = reader.indexOf(";");
234
+ let genColumn = 0;
235
+ for (; reader.pos < semi; reader.pos++) {
236
+ genColumn = decodeInteger(reader, genColumn);
237
+ if (!hasMoreVlq(reader, semi)) {
238
+ const last = stack.pop();
239
+ last[2] = genLine;
240
+ last[3] = genColumn;
241
+ continue;
242
+ }
243
+ const fields = decodeInteger(reader, 0);
244
+ const hasDefinition = fields & 1;
245
+ const hasCallsite = fields & 2;
246
+ const hasScope = fields & 4;
247
+ let callsite = null;
248
+ let bindings = EMPTY;
249
+ let range;
250
+ if (hasDefinition) {
251
+ const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
252
+ definitionScopeIndex = decodeInteger(
253
+ reader,
254
+ definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0
255
+ );
256
+ definitionSourcesIndex = defSourcesIndex;
257
+ range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
258
+ } else {
259
+ range = [genLine, genColumn, 0, 0];
260
+ }
261
+ range.isScope = !!hasScope;
262
+ if (hasCallsite) {
263
+ const prevCsi = callsiteSourcesIndex;
264
+ const prevLine = callsiteLine;
265
+ callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
266
+ const sameSource = prevCsi === callsiteSourcesIndex;
267
+ callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
268
+ callsiteColumn = decodeInteger(
269
+ reader,
270
+ sameSource && prevLine === callsiteLine ? callsiteColumn : 0
271
+ );
272
+ callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
273
+ }
274
+ range.callsite = callsite;
275
+ if (hasMoreVlq(reader, semi)) {
276
+ bindings = [];
277
+ do {
278
+ bindingLine = genLine;
279
+ bindingColumn = genColumn;
280
+ const expressionsCount = decodeInteger(reader, 0);
281
+ let expressionRanges;
282
+ if (expressionsCount < -1) {
283
+ expressionRanges = [[decodeInteger(reader, 0)]];
284
+ for (let i = -1; i > expressionsCount; i--) {
285
+ const prevBl = bindingLine;
286
+ bindingLine = decodeInteger(reader, bindingLine);
287
+ bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
288
+ const expression = decodeInteger(reader, 0);
289
+ expressionRanges.push([expression, bindingLine, bindingColumn]);
290
+ }
291
+ } else {
292
+ expressionRanges = [[expressionsCount]];
293
+ }
294
+ bindings.push(expressionRanges);
295
+ } while (hasMoreVlq(reader, semi));
296
+ }
297
+ range.bindings = bindings;
298
+ ranges.push(range);
299
+ stack.push(range);
300
+ }
301
+ genLine++;
302
+ reader.pos = semi + 1;
303
+ } while (reader.pos < length);
304
+ return ranges;
305
+ }
306
+ function encodeGeneratedRanges(ranges) {
307
+ if (ranges.length === 0) return "";
308
+ const writer = new StringWriter();
309
+ for (let i = 0; i < ranges.length; ) {
310
+ i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
311
+ }
312
+ return writer.flush();
313
+ }
314
+ function _encodeGeneratedRanges(ranges, index, writer, state) {
315
+ const range = ranges[index];
316
+ const {
317
+ 0: startLine,
318
+ 1: startColumn,
319
+ 2: endLine,
320
+ 3: endColumn,
321
+ isScope,
322
+ callsite,
323
+ bindings
324
+ } = range;
325
+ if (state[0] < startLine) {
326
+ catchupLine(writer, state[0], startLine);
327
+ state[0] = startLine;
328
+ state[1] = 0;
329
+ } else if (index > 0) {
330
+ writer.write(comma);
331
+ }
332
+ state[1] = encodeInteger(writer, range[1], state[1]);
333
+ const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
334
+ encodeInteger(writer, fields, 0);
335
+ if (range.length === 6) {
336
+ const { 4: sourcesIndex, 5: scopesIndex } = range;
337
+ if (sourcesIndex !== state[2]) {
338
+ state[3] = 0;
339
+ }
340
+ state[2] = encodeInteger(writer, sourcesIndex, state[2]);
341
+ state[3] = encodeInteger(writer, scopesIndex, state[3]);
342
+ }
343
+ if (callsite) {
344
+ const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
345
+ if (sourcesIndex !== state[4]) {
346
+ state[5] = 0;
347
+ state[6] = 0;
348
+ } else if (callLine !== state[5]) {
349
+ state[6] = 0;
350
+ }
351
+ state[4] = encodeInteger(writer, sourcesIndex, state[4]);
352
+ state[5] = encodeInteger(writer, callLine, state[5]);
353
+ state[6] = encodeInteger(writer, callColumn, state[6]);
354
+ }
355
+ if (bindings) {
356
+ for (const binding of bindings) {
357
+ if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
358
+ const expression = binding[0][0];
359
+ encodeInteger(writer, expression, 0);
360
+ let bindingStartLine = startLine;
361
+ let bindingStartColumn = startColumn;
362
+ for (let i = 1; i < binding.length; i++) {
363
+ const expRange = binding[i];
364
+ bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
365
+ bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
366
+ encodeInteger(writer, expRange[0], 0);
367
+ }
368
+ }
369
+ }
370
+ for (index++; index < ranges.length; ) {
371
+ const next = ranges[index];
372
+ const { 0: l, 1: c } = next;
373
+ if (l > endLine || l === endLine && c >= endColumn) {
374
+ break;
375
+ }
376
+ index = _encodeGeneratedRanges(ranges, index, writer, state);
377
+ }
378
+ if (state[0] < endLine) {
379
+ catchupLine(writer, state[0], endLine);
380
+ state[0] = endLine;
381
+ state[1] = 0;
382
+ } else {
383
+ writer.write(comma);
384
+ }
385
+ state[1] = encodeInteger(writer, endColumn, state[1]);
386
+ return index;
387
+ }
388
+ function catchupLine(writer, lastLine, line) {
389
+ do {
390
+ writer.write(semicolon);
391
+ } while (++lastLine < line);
392
+ }
393
+ function decode(mappings) {
394
+ const { length } = mappings;
395
+ const reader = new StringReader(mappings);
396
+ const decoded = [];
397
+ let genColumn = 0;
398
+ let sourcesIndex = 0;
399
+ let sourceLine = 0;
400
+ let sourceColumn = 0;
401
+ let namesIndex = 0;
402
+ do {
403
+ const semi = reader.indexOf(";");
404
+ const line = [];
405
+ let sorted = true;
406
+ let lastCol = 0;
407
+ genColumn = 0;
408
+ while (reader.pos < semi) {
409
+ let seg;
410
+ genColumn = decodeInteger(reader, genColumn);
411
+ if (genColumn < lastCol) sorted = false;
412
+ lastCol = genColumn;
413
+ if (hasMoreVlq(reader, semi)) {
414
+ sourcesIndex = decodeInteger(reader, sourcesIndex);
415
+ sourceLine = decodeInteger(reader, sourceLine);
416
+ sourceColumn = decodeInteger(reader, sourceColumn);
417
+ if (hasMoreVlq(reader, semi)) {
418
+ namesIndex = decodeInteger(reader, namesIndex);
419
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
420
+ } else {
421
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
422
+ }
423
+ } else {
424
+ seg = [genColumn];
425
+ }
426
+ line.push(seg);
427
+ reader.pos++;
428
+ }
429
+ if (!sorted) sort(line);
430
+ decoded.push(line);
431
+ reader.pos = semi + 1;
432
+ } while (reader.pos <= length);
433
+ return decoded;
434
+ }
435
+ function sort(line) {
436
+ line.sort(sortComparator);
437
+ }
438
+ function sortComparator(a, b) {
439
+ return a[0] - b[0];
440
+ }
441
+ function encode(decoded) {
442
+ const writer = new StringWriter();
443
+ let sourcesIndex = 0;
444
+ let sourceLine = 0;
445
+ let sourceColumn = 0;
446
+ let namesIndex = 0;
447
+ for (let i = 0; i < decoded.length; i++) {
448
+ const line = decoded[i];
449
+ if (i > 0) writer.write(semicolon);
450
+ if (line.length === 0) continue;
451
+ let genColumn = 0;
452
+ for (let j = 0; j < line.length; j++) {
453
+ const segment = line[j];
454
+ if (j > 0) writer.write(comma);
455
+ genColumn = encodeInteger(writer, segment[0], genColumn);
456
+ if (segment.length === 1) continue;
457
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
458
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
459
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
460
+ if (segment.length === 4) continue;
461
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
462
+ }
463
+ }
464
+ return writer.flush();
465
+ }
466
+ }));
467
+ }
468
+ });
469
+
470
+ // ../../node_modules/magic-string/dist/magic-string.cjs.js
471
+ var sourcemapCodec = require_sourcemap_codec_umd();
472
+ var BitSet = class _BitSet {
473
+ constructor(arg) {
474
+ this.bits = arg instanceof _BitSet ? arg.bits.slice() : [];
475
+ }
476
+ add(n2) {
477
+ this.bits[n2 >> 5] |= 1 << (n2 & 31);
478
+ }
479
+ has(n2) {
480
+ return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
481
+ }
482
+ };
483
+ var Chunk = class _Chunk {
484
+ constructor(start, end, content) {
485
+ this.start = start;
486
+ this.end = end;
487
+ this.original = content;
488
+ this.intro = "";
489
+ this.outro = "";
490
+ this.content = content;
491
+ this.storeName = false;
492
+ this.edited = false;
493
+ {
494
+ this.previous = null;
495
+ this.next = null;
496
+ }
497
+ }
498
+ appendLeft(content) {
499
+ this.outro += content;
500
+ }
501
+ appendRight(content) {
502
+ this.intro = this.intro + content;
503
+ }
504
+ clone() {
505
+ const chunk = new _Chunk(this.start, this.end, this.original);
506
+ chunk.intro = this.intro;
507
+ chunk.outro = this.outro;
508
+ chunk.content = this.content;
509
+ chunk.storeName = this.storeName;
510
+ chunk.edited = this.edited;
511
+ return chunk;
512
+ }
513
+ contains(index) {
514
+ return this.start < index && index < this.end;
515
+ }
516
+ eachNext(fn) {
517
+ let chunk = this;
518
+ while (chunk) {
519
+ fn(chunk);
520
+ chunk = chunk.next;
521
+ }
522
+ }
523
+ eachPrevious(fn) {
524
+ let chunk = this;
525
+ while (chunk) {
526
+ fn(chunk);
527
+ chunk = chunk.previous;
528
+ }
529
+ }
530
+ edit(content, storeName, contentOnly) {
531
+ this.content = content;
532
+ if (!contentOnly) {
533
+ this.intro = "";
534
+ this.outro = "";
535
+ }
536
+ this.storeName = storeName;
537
+ this.edited = true;
538
+ return this;
539
+ }
540
+ prependLeft(content) {
541
+ this.outro = content + this.outro;
542
+ }
543
+ prependRight(content) {
544
+ this.intro = content + this.intro;
545
+ }
546
+ reset() {
547
+ this.intro = "";
548
+ this.outro = "";
549
+ if (this.edited) {
550
+ this.content = this.original;
551
+ this.storeName = false;
552
+ this.edited = false;
553
+ }
554
+ }
555
+ split(index) {
556
+ const sliceIndex = index - this.start;
557
+ const originalBefore = this.original.slice(0, sliceIndex);
558
+ const originalAfter = this.original.slice(sliceIndex);
559
+ this.original = originalBefore;
560
+ const newChunk = new _Chunk(index, this.end, originalAfter);
561
+ newChunk.outro = this.outro;
562
+ this.outro = "";
563
+ this.end = index;
564
+ if (this.edited) {
565
+ newChunk.edit("", false);
566
+ this.content = "";
567
+ } else {
568
+ this.content = originalBefore;
569
+ }
570
+ newChunk.next = this.next;
571
+ if (newChunk.next) newChunk.next.previous = newChunk;
572
+ newChunk.previous = this;
573
+ this.next = newChunk;
574
+ return newChunk;
575
+ }
576
+ toString() {
577
+ return this.intro + this.content + this.outro;
578
+ }
579
+ trimEnd(rx) {
580
+ this.outro = this.outro.replace(rx, "");
581
+ if (this.outro.length) return true;
582
+ const trimmed = this.content.replace(rx, "");
583
+ if (trimmed.length) {
584
+ if (trimmed !== this.content) {
585
+ this.split(this.start + trimmed.length).edit("", void 0, true);
586
+ if (this.edited) {
587
+ this.edit(trimmed, this.storeName, true);
588
+ }
589
+ }
590
+ return true;
591
+ } else {
592
+ this.edit("", void 0, true);
593
+ this.intro = this.intro.replace(rx, "");
594
+ if (this.intro.length) return true;
595
+ }
596
+ }
597
+ trimStart(rx) {
598
+ this.intro = this.intro.replace(rx, "");
599
+ if (this.intro.length) return true;
600
+ const trimmed = this.content.replace(rx, "");
601
+ if (trimmed.length) {
602
+ if (trimmed !== this.content) {
603
+ const newChunk = this.split(this.end - trimmed.length);
604
+ if (this.edited) {
605
+ newChunk.edit(trimmed, this.storeName, true);
606
+ }
607
+ this.edit("", void 0, true);
608
+ }
609
+ return true;
610
+ } else {
611
+ this.edit("", void 0, true);
612
+ this.outro = this.outro.replace(rx, "");
613
+ if (this.outro.length) return true;
614
+ }
615
+ }
616
+ };
617
+ function getBtoa() {
618
+ if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
619
+ return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
620
+ } else if (typeof Buffer === "function") {
621
+ return (str) => Buffer.from(str, "utf-8").toString("base64");
622
+ } else {
623
+ return () => {
624
+ throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
625
+ };
626
+ }
627
+ }
628
+ var btoa = /* @__PURE__ */ getBtoa();
629
+ var SourceMap = class {
630
+ constructor(properties) {
631
+ this.version = 3;
632
+ this.file = properties.file;
633
+ this.sources = properties.sources;
634
+ this.sourcesContent = properties.sourcesContent;
635
+ this.names = properties.names;
636
+ this.mappings = sourcemapCodec.encode(properties.mappings);
637
+ if (typeof properties.x_google_ignoreList !== "undefined") {
638
+ this.x_google_ignoreList = properties.x_google_ignoreList;
639
+ }
640
+ if (typeof properties.debugId !== "undefined") {
641
+ this.debugId = properties.debugId;
642
+ }
643
+ }
644
+ toString() {
645
+ return JSON.stringify(this);
646
+ }
647
+ toUrl() {
648
+ return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
649
+ }
650
+ };
651
+ function guessIndent(code) {
652
+ const lines = code.split("\n");
653
+ const tabbed = lines.filter((line) => /^\t+/.test(line));
654
+ const spaced = lines.filter((line) => /^ {2,}/.test(line));
655
+ if (tabbed.length === 0 && spaced.length === 0) {
656
+ return null;
657
+ }
658
+ if (tabbed.length >= spaced.length) {
659
+ return " ";
660
+ }
661
+ const min = spaced.reduce((previous, current) => {
662
+ const numSpaces = /^ +/.exec(current)[0].length;
663
+ return Math.min(numSpaces, previous);
664
+ }, Infinity);
665
+ return new Array(min + 1).join(" ");
666
+ }
667
+ function getRelativePath(from, to) {
668
+ const fromParts = from.split(/[/\\]/);
669
+ const toParts = to.split(/[/\\]/);
670
+ fromParts.pop();
671
+ while (fromParts[0] === toParts[0]) {
672
+ fromParts.shift();
673
+ toParts.shift();
674
+ }
675
+ if (fromParts.length) {
676
+ let i = fromParts.length;
677
+ while (i--) fromParts[i] = "..";
678
+ }
679
+ return fromParts.concat(toParts).join("/");
680
+ }
681
+ var toString = Object.prototype.toString;
682
+ function isObject(thing) {
683
+ return toString.call(thing) === "[object Object]";
684
+ }
685
+ function getLocator(source) {
686
+ const originalLines = source.split("\n");
687
+ const lineOffsets = [];
688
+ for (let i = 0, pos = 0; i < originalLines.length; i++) {
689
+ lineOffsets.push(pos);
690
+ pos += originalLines[i].length + 1;
691
+ }
692
+ return function locate(index) {
693
+ let i = 0;
694
+ let j = lineOffsets.length;
695
+ while (i < j) {
696
+ const m = i + j >> 1;
697
+ if (index < lineOffsets[m]) {
698
+ j = m;
699
+ } else {
700
+ i = m + 1;
701
+ }
702
+ }
703
+ const line = i - 1;
704
+ const column = index - lineOffsets[line];
705
+ return { line, column };
706
+ };
707
+ }
708
+ var wordRegex = /\w/;
709
+ var Mappings = class {
710
+ constructor(hires) {
711
+ this.hires = hires;
712
+ this.generatedCodeLine = 0;
713
+ this.generatedCodeColumn = 0;
714
+ this.raw = [];
715
+ this.rawSegments = this.raw[this.generatedCodeLine] = [];
716
+ this.pending = null;
717
+ }
718
+ addEdit(sourceIndex, content, loc, nameIndex) {
719
+ if (content.length) {
720
+ const contentLengthMinusOne = content.length - 1;
721
+ let contentLineEnd = content.indexOf("\n", 0);
722
+ let previousContentLineEnd = -1;
723
+ while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
724
+ const segment2 = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
725
+ if (nameIndex >= 0) {
726
+ segment2.push(nameIndex);
727
+ }
728
+ this.rawSegments.push(segment2);
729
+ this.generatedCodeLine += 1;
730
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
731
+ this.generatedCodeColumn = 0;
732
+ previousContentLineEnd = contentLineEnd;
733
+ contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
734
+ }
735
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
736
+ if (nameIndex >= 0) {
737
+ segment.push(nameIndex);
738
+ }
739
+ this.rawSegments.push(segment);
740
+ this.advance(content.slice(previousContentLineEnd + 1));
741
+ } else if (this.pending) {
742
+ this.rawSegments.push(this.pending);
743
+ this.advance(content);
744
+ }
745
+ this.pending = null;
746
+ }
747
+ addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
748
+ let originalCharIndex = chunk.start;
749
+ let first = true;
750
+ let charInHiresBoundary = false;
751
+ while (originalCharIndex < chunk.end) {
752
+ if (original[originalCharIndex] === "\n") {
753
+ loc.line += 1;
754
+ loc.column = 0;
755
+ this.generatedCodeLine += 1;
756
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
757
+ this.generatedCodeColumn = 0;
758
+ first = true;
759
+ charInHiresBoundary = false;
760
+ } else {
761
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
762
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
763
+ if (this.hires === "boundary") {
764
+ if (wordRegex.test(original[originalCharIndex])) {
765
+ if (!charInHiresBoundary) {
766
+ this.rawSegments.push(segment);
767
+ charInHiresBoundary = true;
768
+ }
769
+ } else {
770
+ this.rawSegments.push(segment);
771
+ charInHiresBoundary = false;
772
+ }
773
+ } else {
774
+ this.rawSegments.push(segment);
775
+ }
776
+ }
777
+ loc.column += 1;
778
+ this.generatedCodeColumn += 1;
779
+ first = false;
780
+ }
781
+ originalCharIndex += 1;
782
+ }
783
+ this.pending = null;
784
+ }
785
+ advance(str) {
786
+ if (!str) return;
787
+ const lines = str.split("\n");
788
+ if (lines.length > 1) {
789
+ for (let i = 0; i < lines.length - 1; i++) {
790
+ this.generatedCodeLine++;
791
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
792
+ }
793
+ this.generatedCodeColumn = 0;
794
+ }
795
+ this.generatedCodeColumn += lines[lines.length - 1].length;
796
+ }
797
+ };
798
+ var n = "\n";
799
+ var warned = {
800
+ insertLeft: false,
801
+ insertRight: false,
802
+ storeName: false
803
+ };
804
+ var MagicString = class _MagicString {
805
+ constructor(string, options = {}) {
806
+ const chunk = new Chunk(0, string.length, string);
807
+ Object.defineProperties(this, {
808
+ original: { writable: true, value: string },
809
+ outro: { writable: true, value: "" },
810
+ intro: { writable: true, value: "" },
811
+ firstChunk: { writable: true, value: chunk },
812
+ lastChunk: { writable: true, value: chunk },
813
+ lastSearchedChunk: { writable: true, value: chunk },
814
+ byStart: { writable: true, value: {} },
815
+ byEnd: { writable: true, value: {} },
816
+ filename: { writable: true, value: options.filename },
817
+ indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
818
+ sourcemapLocations: { writable: true, value: new BitSet() },
819
+ storedNames: { writable: true, value: {} },
820
+ indentStr: { writable: true, value: void 0 },
821
+ ignoreList: { writable: true, value: options.ignoreList },
822
+ offset: { writable: true, value: options.offset || 0 }
823
+ });
824
+ this.byStart[0] = chunk;
825
+ this.byEnd[string.length] = chunk;
826
+ }
827
+ addSourcemapLocation(char) {
828
+ this.sourcemapLocations.add(char);
829
+ }
830
+ append(content) {
831
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
832
+ this.outro += content;
833
+ return this;
834
+ }
835
+ appendLeft(index, content) {
836
+ index = index + this.offset;
837
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
838
+ this._split(index);
839
+ const chunk = this.byEnd[index];
840
+ if (chunk) {
841
+ chunk.appendLeft(content);
842
+ } else {
843
+ this.intro += content;
844
+ }
845
+ return this;
846
+ }
847
+ appendRight(index, content) {
848
+ index = index + this.offset;
849
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
850
+ this._split(index);
851
+ const chunk = this.byStart[index];
852
+ if (chunk) {
853
+ chunk.appendRight(content);
854
+ } else {
855
+ this.outro += content;
856
+ }
857
+ return this;
858
+ }
859
+ clone() {
860
+ const cloned = new _MagicString(this.original, { filename: this.filename, offset: this.offset });
861
+ let originalChunk = this.firstChunk;
862
+ let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
863
+ while (originalChunk) {
864
+ cloned.byStart[clonedChunk.start] = clonedChunk;
865
+ cloned.byEnd[clonedChunk.end] = clonedChunk;
866
+ const nextOriginalChunk = originalChunk.next;
867
+ const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
868
+ if (nextClonedChunk) {
869
+ clonedChunk.next = nextClonedChunk;
870
+ nextClonedChunk.previous = clonedChunk;
871
+ clonedChunk = nextClonedChunk;
872
+ }
873
+ originalChunk = nextOriginalChunk;
874
+ }
875
+ cloned.lastChunk = clonedChunk;
876
+ if (this.indentExclusionRanges) {
877
+ cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
878
+ }
879
+ cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
880
+ cloned.intro = this.intro;
881
+ cloned.outro = this.outro;
882
+ return cloned;
883
+ }
884
+ generateDecodedMap(options) {
885
+ options = options || {};
886
+ const sourceIndex = 0;
887
+ const names = Object.keys(this.storedNames);
888
+ const mappings = new Mappings(options.hires);
889
+ const locate = getLocator(this.original);
890
+ if (this.intro) {
891
+ mappings.advance(this.intro);
892
+ }
893
+ this.firstChunk.eachNext((chunk) => {
894
+ const loc = locate(chunk.start);
895
+ if (chunk.intro.length) mappings.advance(chunk.intro);
896
+ if (chunk.edited) {
897
+ mappings.addEdit(
898
+ sourceIndex,
899
+ chunk.content,
900
+ loc,
901
+ chunk.storeName ? names.indexOf(chunk.original) : -1
902
+ );
903
+ } else {
904
+ mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
905
+ }
906
+ if (chunk.outro.length) mappings.advance(chunk.outro);
907
+ });
908
+ if (this.outro) {
909
+ mappings.advance(this.outro);
910
+ }
911
+ return {
912
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
913
+ sources: [
914
+ options.source ? getRelativePath(options.file || "", options.source) : options.file || ""
915
+ ],
916
+ sourcesContent: options.includeContent ? [this.original] : void 0,
917
+ names,
918
+ mappings: mappings.raw,
919
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
920
+ };
921
+ }
922
+ generateMap(options) {
923
+ return new SourceMap(this.generateDecodedMap(options));
924
+ }
925
+ _ensureindentStr() {
926
+ if (this.indentStr === void 0) {
927
+ this.indentStr = guessIndent(this.original);
928
+ }
929
+ }
930
+ _getRawIndentString() {
931
+ this._ensureindentStr();
932
+ return this.indentStr;
933
+ }
934
+ getIndentString() {
935
+ this._ensureindentStr();
936
+ return this.indentStr === null ? " " : this.indentStr;
937
+ }
938
+ indent(indentStr, options) {
939
+ const pattern = /^[^\r\n]/gm;
940
+ if (isObject(indentStr)) {
941
+ options = indentStr;
942
+ indentStr = void 0;
943
+ }
944
+ if (indentStr === void 0) {
945
+ this._ensureindentStr();
946
+ indentStr = this.indentStr || " ";
947
+ }
948
+ if (indentStr === "") return this;
949
+ options = options || {};
950
+ const isExcluded = {};
951
+ if (options.exclude) {
952
+ const exclusions = typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude;
953
+ exclusions.forEach((exclusion) => {
954
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
955
+ isExcluded[i] = true;
956
+ }
957
+ });
958
+ }
959
+ let shouldIndentNextCharacter = options.indentStart !== false;
960
+ const replacer = (match) => {
961
+ if (shouldIndentNextCharacter) return `${indentStr}${match}`;
962
+ shouldIndentNextCharacter = true;
963
+ return match;
964
+ };
965
+ this.intro = this.intro.replace(pattern, replacer);
966
+ let charIndex = 0;
967
+ let chunk = this.firstChunk;
968
+ while (chunk) {
969
+ const end = chunk.end;
970
+ if (chunk.edited) {
971
+ if (!isExcluded[charIndex]) {
972
+ chunk.content = chunk.content.replace(pattern, replacer);
973
+ if (chunk.content.length) {
974
+ shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
975
+ }
976
+ }
977
+ } else {
978
+ charIndex = chunk.start;
979
+ while (charIndex < end) {
980
+ if (!isExcluded[charIndex]) {
981
+ const char = this.original[charIndex];
982
+ if (char === "\n") {
983
+ shouldIndentNextCharacter = true;
984
+ } else if (char !== "\r" && shouldIndentNextCharacter) {
985
+ shouldIndentNextCharacter = false;
986
+ if (charIndex === chunk.start) {
987
+ chunk.prependRight(indentStr);
988
+ } else {
989
+ this._splitChunk(chunk, charIndex);
990
+ chunk = chunk.next;
991
+ chunk.prependRight(indentStr);
992
+ }
993
+ }
994
+ }
995
+ charIndex += 1;
996
+ }
997
+ }
998
+ charIndex = chunk.end;
999
+ chunk = chunk.next;
1000
+ }
1001
+ this.outro = this.outro.replace(pattern, replacer);
1002
+ return this;
1003
+ }
1004
+ insert() {
1005
+ throw new Error(
1006
+ "magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
1007
+ );
1008
+ }
1009
+ insertLeft(index, content) {
1010
+ if (!warned.insertLeft) {
1011
+ console.warn(
1012
+ "magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
1013
+ );
1014
+ warned.insertLeft = true;
1015
+ }
1016
+ return this.appendLeft(index, content);
1017
+ }
1018
+ insertRight(index, content) {
1019
+ if (!warned.insertRight) {
1020
+ console.warn(
1021
+ "magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
1022
+ );
1023
+ warned.insertRight = true;
1024
+ }
1025
+ return this.prependRight(index, content);
1026
+ }
1027
+ move(start, end, index) {
1028
+ start = start + this.offset;
1029
+ end = end + this.offset;
1030
+ index = index + this.offset;
1031
+ if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
1032
+ this._split(start);
1033
+ this._split(end);
1034
+ this._split(index);
1035
+ const first = this.byStart[start];
1036
+ const last = this.byEnd[end];
1037
+ const oldLeft = first.previous;
1038
+ const oldRight = last.next;
1039
+ const newRight = this.byStart[index];
1040
+ if (!newRight && last === this.lastChunk) return this;
1041
+ const newLeft = newRight ? newRight.previous : this.lastChunk;
1042
+ if (oldLeft) oldLeft.next = oldRight;
1043
+ if (oldRight) oldRight.previous = oldLeft;
1044
+ if (newLeft) newLeft.next = first;
1045
+ if (newRight) newRight.previous = last;
1046
+ if (!first.previous) this.firstChunk = last.next;
1047
+ if (!last.next) {
1048
+ this.lastChunk = first.previous;
1049
+ this.lastChunk.next = null;
1050
+ }
1051
+ first.previous = newLeft;
1052
+ last.next = newRight || null;
1053
+ if (!newLeft) this.firstChunk = first;
1054
+ if (!newRight) this.lastChunk = last;
1055
+ return this;
1056
+ }
1057
+ overwrite(start, end, content, options) {
1058
+ options = options || {};
1059
+ return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
1060
+ }
1061
+ update(start, end, content, options) {
1062
+ start = start + this.offset;
1063
+ end = end + this.offset;
1064
+ if (typeof content !== "string") throw new TypeError("replacement content must be a string");
1065
+ if (this.original.length !== 0) {
1066
+ while (start < 0) start += this.original.length;
1067
+ while (end < 0) end += this.original.length;
1068
+ }
1069
+ if (end > this.original.length) throw new Error("end is out of bounds");
1070
+ if (start === end)
1071
+ throw new Error(
1072
+ "Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
1073
+ );
1074
+ this._split(start);
1075
+ this._split(end);
1076
+ if (options === true) {
1077
+ if (!warned.storeName) {
1078
+ console.warn(
1079
+ "The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
1080
+ );
1081
+ warned.storeName = true;
1082
+ }
1083
+ options = { storeName: true };
1084
+ }
1085
+ const storeName = options !== void 0 ? options.storeName : false;
1086
+ const overwrite = options !== void 0 ? options.overwrite : false;
1087
+ if (storeName) {
1088
+ const original = this.original.slice(start, end);
1089
+ Object.defineProperty(this.storedNames, original, {
1090
+ writable: true,
1091
+ value: true,
1092
+ enumerable: true
1093
+ });
1094
+ }
1095
+ const first = this.byStart[start];
1096
+ const last = this.byEnd[end];
1097
+ if (first) {
1098
+ let chunk = first;
1099
+ while (chunk !== last) {
1100
+ if (chunk.next !== this.byStart[chunk.end]) {
1101
+ throw new Error("Cannot overwrite across a split point");
1102
+ }
1103
+ chunk = chunk.next;
1104
+ chunk.edit("", false);
1105
+ }
1106
+ first.edit(content, storeName, !overwrite);
1107
+ } else {
1108
+ const newChunk = new Chunk(start, end, "").edit(content, storeName);
1109
+ last.next = newChunk;
1110
+ newChunk.previous = last;
1111
+ }
1112
+ return this;
1113
+ }
1114
+ prepend(content) {
1115
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
1116
+ this.intro = content + this.intro;
1117
+ return this;
1118
+ }
1119
+ prependLeft(index, content) {
1120
+ index = index + this.offset;
1121
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
1122
+ this._split(index);
1123
+ const chunk = this.byEnd[index];
1124
+ if (chunk) {
1125
+ chunk.prependLeft(content);
1126
+ } else {
1127
+ this.intro = content + this.intro;
1128
+ }
1129
+ return this;
1130
+ }
1131
+ prependRight(index, content) {
1132
+ index = index + this.offset;
1133
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
1134
+ this._split(index);
1135
+ const chunk = this.byStart[index];
1136
+ if (chunk) {
1137
+ chunk.prependRight(content);
1138
+ } else {
1139
+ this.outro = content + this.outro;
1140
+ }
1141
+ return this;
1142
+ }
1143
+ remove(start, end) {
1144
+ start = start + this.offset;
1145
+ end = end + this.offset;
1146
+ if (this.original.length !== 0) {
1147
+ while (start < 0) start += this.original.length;
1148
+ while (end < 0) end += this.original.length;
1149
+ }
1150
+ if (start === end) return this;
1151
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
1152
+ if (start > end) throw new Error("end must be greater than start");
1153
+ this._split(start);
1154
+ this._split(end);
1155
+ let chunk = this.byStart[start];
1156
+ while (chunk) {
1157
+ chunk.intro = "";
1158
+ chunk.outro = "";
1159
+ chunk.edit("");
1160
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
1161
+ }
1162
+ return this;
1163
+ }
1164
+ reset(start, end) {
1165
+ start = start + this.offset;
1166
+ end = end + this.offset;
1167
+ if (this.original.length !== 0) {
1168
+ while (start < 0) start += this.original.length;
1169
+ while (end < 0) end += this.original.length;
1170
+ }
1171
+ if (start === end) return this;
1172
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
1173
+ if (start > end) throw new Error("end must be greater than start");
1174
+ this._split(start);
1175
+ this._split(end);
1176
+ let chunk = this.byStart[start];
1177
+ while (chunk) {
1178
+ chunk.reset();
1179
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
1180
+ }
1181
+ return this;
1182
+ }
1183
+ lastChar() {
1184
+ if (this.outro.length) return this.outro[this.outro.length - 1];
1185
+ let chunk = this.lastChunk;
1186
+ do {
1187
+ if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
1188
+ if (chunk.content.length) return chunk.content[chunk.content.length - 1];
1189
+ if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
1190
+ } while (chunk = chunk.previous);
1191
+ if (this.intro.length) return this.intro[this.intro.length - 1];
1192
+ return "";
1193
+ }
1194
+ lastLine() {
1195
+ let lineIndex = this.outro.lastIndexOf(n);
1196
+ if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
1197
+ let lineStr = this.outro;
1198
+ let chunk = this.lastChunk;
1199
+ do {
1200
+ if (chunk.outro.length > 0) {
1201
+ lineIndex = chunk.outro.lastIndexOf(n);
1202
+ if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
1203
+ lineStr = chunk.outro + lineStr;
1204
+ }
1205
+ if (chunk.content.length > 0) {
1206
+ lineIndex = chunk.content.lastIndexOf(n);
1207
+ if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
1208
+ lineStr = chunk.content + lineStr;
1209
+ }
1210
+ if (chunk.intro.length > 0) {
1211
+ lineIndex = chunk.intro.lastIndexOf(n);
1212
+ if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
1213
+ lineStr = chunk.intro + lineStr;
1214
+ }
1215
+ } while (chunk = chunk.previous);
1216
+ lineIndex = this.intro.lastIndexOf(n);
1217
+ if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
1218
+ return this.intro + lineStr;
1219
+ }
1220
+ slice(start = 0, end = this.original.length - this.offset) {
1221
+ start = start + this.offset;
1222
+ end = end + this.offset;
1223
+ if (this.original.length !== 0) {
1224
+ while (start < 0) start += this.original.length;
1225
+ while (end < 0) end += this.original.length;
1226
+ }
1227
+ let result = "";
1228
+ let chunk = this.firstChunk;
1229
+ while (chunk && (chunk.start > start || chunk.end <= start)) {
1230
+ if (chunk.start < end && chunk.end >= end) {
1231
+ return result;
1232
+ }
1233
+ chunk = chunk.next;
1234
+ }
1235
+ if (chunk && chunk.edited && chunk.start !== start)
1236
+ throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
1237
+ const startChunk = chunk;
1238
+ while (chunk) {
1239
+ if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
1240
+ result += chunk.intro;
1241
+ }
1242
+ const containsEnd = chunk.start < end && chunk.end >= end;
1243
+ if (containsEnd && chunk.edited && chunk.end !== end)
1244
+ throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
1245
+ const sliceStart = startChunk === chunk ? start - chunk.start : 0;
1246
+ const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
1247
+ result += chunk.content.slice(sliceStart, sliceEnd);
1248
+ if (chunk.outro && (!containsEnd || chunk.end === end)) {
1249
+ result += chunk.outro;
1250
+ }
1251
+ if (containsEnd) {
1252
+ break;
1253
+ }
1254
+ chunk = chunk.next;
1255
+ }
1256
+ return result;
1257
+ }
1258
+ // TODO deprecate this? not really very useful
1259
+ snip(start, end) {
1260
+ const clone = this.clone();
1261
+ clone.remove(0, start);
1262
+ clone.remove(end, clone.original.length);
1263
+ return clone;
1264
+ }
1265
+ _split(index) {
1266
+ if (this.byStart[index] || this.byEnd[index]) return;
1267
+ let chunk = this.lastSearchedChunk;
1268
+ let previousChunk = chunk;
1269
+ const searchForward = index > chunk.end;
1270
+ while (chunk) {
1271
+ if (chunk.contains(index)) return this._splitChunk(chunk, index);
1272
+ chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
1273
+ if (chunk === previousChunk) return;
1274
+ previousChunk = chunk;
1275
+ }
1276
+ }
1277
+ _splitChunk(chunk, index) {
1278
+ if (chunk.edited && chunk.content.length) {
1279
+ const loc = getLocator(this.original)(index);
1280
+ throw new Error(
1281
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`
1282
+ );
1283
+ }
1284
+ const newChunk = chunk.split(index);
1285
+ this.byEnd[index] = chunk;
1286
+ this.byStart[index] = newChunk;
1287
+ this.byEnd[newChunk.end] = newChunk;
1288
+ if (chunk === this.lastChunk) this.lastChunk = newChunk;
1289
+ this.lastSearchedChunk = chunk;
1290
+ return true;
1291
+ }
1292
+ toString() {
1293
+ let str = this.intro;
1294
+ let chunk = this.firstChunk;
1295
+ while (chunk) {
1296
+ str += chunk.toString();
1297
+ chunk = chunk.next;
1298
+ }
1299
+ return str + this.outro;
1300
+ }
1301
+ isEmpty() {
1302
+ let chunk = this.firstChunk;
1303
+ do {
1304
+ if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
1305
+ return false;
1306
+ } while (chunk = chunk.next);
1307
+ return true;
1308
+ }
1309
+ length() {
1310
+ let chunk = this.firstChunk;
1311
+ let length = 0;
1312
+ do {
1313
+ length += chunk.intro.length + chunk.content.length + chunk.outro.length;
1314
+ } while (chunk = chunk.next);
1315
+ return length;
1316
+ }
1317
+ trimLines() {
1318
+ return this.trim("[\\r\\n]");
1319
+ }
1320
+ trim(charType) {
1321
+ return this.trimStart(charType).trimEnd(charType);
1322
+ }
1323
+ trimEndAborted(charType) {
1324
+ const rx = new RegExp((charType || "\\s") + "+$");
1325
+ this.outro = this.outro.replace(rx, "");
1326
+ if (this.outro.length) return true;
1327
+ let chunk = this.lastChunk;
1328
+ do {
1329
+ const end = chunk.end;
1330
+ const aborted = chunk.trimEnd(rx);
1331
+ if (chunk.end !== end) {
1332
+ if (this.lastChunk === chunk) {
1333
+ this.lastChunk = chunk.next;
1334
+ }
1335
+ this.byEnd[chunk.end] = chunk;
1336
+ this.byStart[chunk.next.start] = chunk.next;
1337
+ this.byEnd[chunk.next.end] = chunk.next;
1338
+ }
1339
+ if (aborted) return true;
1340
+ chunk = chunk.previous;
1341
+ } while (chunk);
1342
+ return false;
1343
+ }
1344
+ trimEnd(charType) {
1345
+ this.trimEndAborted(charType);
1346
+ return this;
1347
+ }
1348
+ trimStartAborted(charType) {
1349
+ const rx = new RegExp("^" + (charType || "\\s") + "+");
1350
+ this.intro = this.intro.replace(rx, "");
1351
+ if (this.intro.length) return true;
1352
+ let chunk = this.firstChunk;
1353
+ do {
1354
+ const end = chunk.end;
1355
+ const aborted = chunk.trimStart(rx);
1356
+ if (chunk.end !== end) {
1357
+ if (chunk === this.lastChunk) this.lastChunk = chunk.next;
1358
+ this.byEnd[chunk.end] = chunk;
1359
+ this.byStart[chunk.next.start] = chunk.next;
1360
+ this.byEnd[chunk.next.end] = chunk.next;
1361
+ }
1362
+ if (aborted) return true;
1363
+ chunk = chunk.next;
1364
+ } while (chunk);
1365
+ return false;
1366
+ }
1367
+ trimStart(charType) {
1368
+ this.trimStartAborted(charType);
1369
+ return this;
1370
+ }
1371
+ hasChanged() {
1372
+ return this.original !== this.toString();
1373
+ }
1374
+ _replaceRegexp(searchValue, replacement) {
1375
+ function getReplacement(match, str) {
1376
+ if (typeof replacement === "string") {
1377
+ return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
1378
+ if (i === "$") return "$";
1379
+ if (i === "&") return match[0];
1380
+ const num = +i;
1381
+ if (num < match.length) return match[+i];
1382
+ return `$${i}`;
1383
+ });
1384
+ } else {
1385
+ return replacement(...match, match.index, str, match.groups);
1386
+ }
1387
+ }
1388
+ function matchAll(re, str) {
1389
+ let match;
1390
+ const matches = [];
1391
+ while (match = re.exec(str)) {
1392
+ matches.push(match);
1393
+ }
1394
+ return matches;
1395
+ }
1396
+ if (searchValue.global) {
1397
+ const matches = matchAll(searchValue, this.original);
1398
+ matches.forEach((match) => {
1399
+ if (match.index != null) {
1400
+ const replacement2 = getReplacement(match, this.original);
1401
+ if (replacement2 !== match[0]) {
1402
+ this.overwrite(match.index, match.index + match[0].length, replacement2);
1403
+ }
1404
+ }
1405
+ });
1406
+ } else {
1407
+ const match = this.original.match(searchValue);
1408
+ if (match && match.index != null) {
1409
+ const replacement2 = getReplacement(match, this.original);
1410
+ if (replacement2 !== match[0]) {
1411
+ this.overwrite(match.index, match.index + match[0].length, replacement2);
1412
+ }
1413
+ }
1414
+ }
1415
+ return this;
1416
+ }
1417
+ _replaceString(string, replacement) {
1418
+ const { original } = this;
1419
+ const index = original.indexOf(string);
1420
+ if (index !== -1) {
1421
+ if (typeof replacement === "function") {
1422
+ replacement = replacement(string, index, original);
1423
+ }
1424
+ if (string !== replacement) {
1425
+ this.overwrite(index, index + string.length, replacement);
1426
+ }
1427
+ }
1428
+ return this;
1429
+ }
1430
+ replace(searchValue, replacement) {
1431
+ if (typeof searchValue === "string") {
1432
+ return this._replaceString(searchValue, replacement);
1433
+ }
1434
+ return this._replaceRegexp(searchValue, replacement);
1435
+ }
1436
+ _replaceAllString(string, replacement) {
1437
+ const { original } = this;
1438
+ const stringLength = string.length;
1439
+ for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
1440
+ const previous = original.slice(index, index + stringLength);
1441
+ let _replacement = replacement;
1442
+ if (typeof replacement === "function") {
1443
+ _replacement = replacement(previous, index, original);
1444
+ }
1445
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
1446
+ }
1447
+ return this;
1448
+ }
1449
+ replaceAll(searchValue, replacement) {
1450
+ if (typeof searchValue === "string") {
1451
+ return this._replaceAllString(searchValue, replacement);
1452
+ }
1453
+ if (!searchValue.global) {
1454
+ throw new TypeError(
1455
+ "MagicString.prototype.replaceAll called with a non-global RegExp argument"
1456
+ );
1457
+ }
1458
+ return this._replaceRegexp(searchValue, replacement);
1459
+ }
1460
+ };
1461
+ var hasOwnProp = Object.prototype.hasOwnProperty;
1462
+ var Bundle = class _Bundle {
1463
+ constructor(options = {}) {
1464
+ this.intro = options.intro || "";
1465
+ this.separator = options.separator !== void 0 ? options.separator : "\n";
1466
+ this.sources = [];
1467
+ this.uniqueSources = [];
1468
+ this.uniqueSourceIndexByFilename = {};
1469
+ }
1470
+ addSource(source) {
1471
+ if (source instanceof MagicString) {
1472
+ return this.addSource({
1473
+ content: source,
1474
+ filename: source.filename,
1475
+ separator: this.separator
1476
+ });
1477
+ }
1478
+ if (!isObject(source) || !source.content) {
1479
+ throw new Error(
1480
+ "bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`"
1481
+ );
1482
+ }
1483
+ ["filename", "ignoreList", "indentExclusionRanges", "separator"].forEach((option) => {
1484
+ if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
1485
+ });
1486
+ if (source.separator === void 0) {
1487
+ source.separator = this.separator;
1488
+ }
1489
+ if (source.filename) {
1490
+ if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
1491
+ this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
1492
+ this.uniqueSources.push({ filename: source.filename, content: source.content.original });
1493
+ } else {
1494
+ const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
1495
+ if (source.content.original !== uniqueSource.content) {
1496
+ throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
1497
+ }
1498
+ }
1499
+ }
1500
+ this.sources.push(source);
1501
+ return this;
1502
+ }
1503
+ append(str, options) {
1504
+ this.addSource({
1505
+ content: new MagicString(str),
1506
+ separator: options && options.separator || ""
1507
+ });
1508
+ return this;
1509
+ }
1510
+ clone() {
1511
+ const bundle = new _Bundle({
1512
+ intro: this.intro,
1513
+ separator: this.separator
1514
+ });
1515
+ this.sources.forEach((source) => {
1516
+ bundle.addSource({
1517
+ filename: source.filename,
1518
+ content: source.content.clone(),
1519
+ separator: source.separator
1520
+ });
1521
+ });
1522
+ return bundle;
1523
+ }
1524
+ generateDecodedMap(options = {}) {
1525
+ const names = [];
1526
+ let x_google_ignoreList = void 0;
1527
+ this.sources.forEach((source) => {
1528
+ Object.keys(source.content.storedNames).forEach((name) => {
1529
+ if (!~names.indexOf(name)) names.push(name);
1530
+ });
1531
+ });
1532
+ const mappings = new Mappings(options.hires);
1533
+ if (this.intro) {
1534
+ mappings.advance(this.intro);
1535
+ }
1536
+ this.sources.forEach((source, i) => {
1537
+ if (i > 0) {
1538
+ mappings.advance(this.separator);
1539
+ }
1540
+ const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
1541
+ const magicString = source.content;
1542
+ const locate = getLocator(magicString.original);
1543
+ if (magicString.intro) {
1544
+ mappings.advance(magicString.intro);
1545
+ }
1546
+ magicString.firstChunk.eachNext((chunk) => {
1547
+ const loc = locate(chunk.start);
1548
+ if (chunk.intro.length) mappings.advance(chunk.intro);
1549
+ if (source.filename) {
1550
+ if (chunk.edited) {
1551
+ mappings.addEdit(
1552
+ sourceIndex,
1553
+ chunk.content,
1554
+ loc,
1555
+ chunk.storeName ? names.indexOf(chunk.original) : -1
1556
+ );
1557
+ } else {
1558
+ mappings.addUneditedChunk(
1559
+ sourceIndex,
1560
+ chunk,
1561
+ magicString.original,
1562
+ loc,
1563
+ magicString.sourcemapLocations
1564
+ );
1565
+ }
1566
+ } else {
1567
+ mappings.advance(chunk.content);
1568
+ }
1569
+ if (chunk.outro.length) mappings.advance(chunk.outro);
1570
+ });
1571
+ if (magicString.outro) {
1572
+ mappings.advance(magicString.outro);
1573
+ }
1574
+ if (source.ignoreList && sourceIndex !== -1) {
1575
+ if (x_google_ignoreList === void 0) {
1576
+ x_google_ignoreList = [];
1577
+ }
1578
+ x_google_ignoreList.push(sourceIndex);
1579
+ }
1580
+ });
1581
+ return {
1582
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
1583
+ sources: this.uniqueSources.map((source) => {
1584
+ return options.file ? getRelativePath(options.file, source.filename) : source.filename;
1585
+ }),
1586
+ sourcesContent: this.uniqueSources.map((source) => {
1587
+ return options.includeContent ? source.content : null;
1588
+ }),
1589
+ names,
1590
+ mappings: mappings.raw,
1591
+ x_google_ignoreList
1592
+ };
1593
+ }
1594
+ generateMap(options) {
1595
+ return new SourceMap(this.generateDecodedMap(options));
1596
+ }
1597
+ getIndentString() {
1598
+ const indentStringCounts = {};
1599
+ this.sources.forEach((source) => {
1600
+ const indentStr = source.content._getRawIndentString();
1601
+ if (indentStr === null) return;
1602
+ if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
1603
+ indentStringCounts[indentStr] += 1;
1604
+ });
1605
+ return Object.keys(indentStringCounts).sort((a, b) => {
1606
+ return indentStringCounts[a] - indentStringCounts[b];
1607
+ })[0] || " ";
1608
+ }
1609
+ indent(indentStr) {
1610
+ if (!arguments.length) {
1611
+ indentStr = this.getIndentString();
1612
+ }
1613
+ if (indentStr === "") return this;
1614
+ let trailingNewline = !this.intro || this.intro.slice(-1) === "\n";
1615
+ this.sources.forEach((source, i) => {
1616
+ const separator = source.separator !== void 0 ? source.separator : this.separator;
1617
+ const indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
1618
+ source.content.indent(indentStr, {
1619
+ exclude: source.indentExclusionRanges,
1620
+ indentStart
1621
+ //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
1622
+ });
1623
+ trailingNewline = source.content.lastChar() === "\n";
1624
+ });
1625
+ if (this.intro) {
1626
+ this.intro = indentStr + this.intro.replace(/^[^\n]/gm, (match, index) => {
1627
+ return index > 0 ? indentStr + match : match;
1628
+ });
1629
+ }
1630
+ return this;
1631
+ }
1632
+ prepend(str) {
1633
+ this.intro = str + this.intro;
1634
+ return this;
1635
+ }
1636
+ toString() {
1637
+ const body = this.sources.map((source, i) => {
1638
+ const separator = source.separator !== void 0 ? source.separator : this.separator;
1639
+ const str = (i > 0 ? separator : "") + source.content.toString();
1640
+ return str;
1641
+ }).join("");
1642
+ return this.intro + body;
1643
+ }
1644
+ isEmpty() {
1645
+ if (this.intro.length && this.intro.trim()) return false;
1646
+ if (this.sources.some((source) => !source.content.isEmpty())) return false;
1647
+ return true;
1648
+ }
1649
+ length() {
1650
+ return this.sources.reduce(
1651
+ (length, source) => length + source.content.length(),
1652
+ this.intro.length
1653
+ );
1654
+ }
1655
+ trimLines() {
1656
+ return this.trim("[\\r\\n]");
1657
+ }
1658
+ trim(charType) {
1659
+ return this.trimStart(charType).trimEnd(charType);
1660
+ }
1661
+ trimStart(charType) {
1662
+ const rx = new RegExp("^" + (charType || "\\s") + "+");
1663
+ this.intro = this.intro.replace(rx, "");
1664
+ if (!this.intro) {
1665
+ let source;
1666
+ let i = 0;
1667
+ do {
1668
+ source = this.sources[i++];
1669
+ if (!source) {
1670
+ break;
1671
+ }
1672
+ } while (!source.content.trimStartAborted(charType));
1673
+ }
1674
+ return this;
1675
+ }
1676
+ trimEnd(charType) {
1677
+ const rx = new RegExp((charType || "\\s") + "+$");
1678
+ let source;
1679
+ let i = this.sources.length - 1;
1680
+ do {
1681
+ source = this.sources[i--];
1682
+ if (!source) {
1683
+ this.intro = this.intro.replace(rx, "");
1684
+ break;
1685
+ }
1686
+ } while (!source.content.trimEndAborted(charType));
1687
+ return this;
1688
+ }
1689
+ };
1690
+ MagicString.Bundle = Bundle;
1691
+ MagicString.SourceMap = SourceMap;
1692
+ MagicString.default = MagicString;
1693
+ module.exports = MagicString;