@scalemule/nextjs 0.0.34 → 0.0.35

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.
@@ -3,7 +3,1917 @@
3
3
  var headers = require('next/headers');
4
4
  var server = require('next/server');
5
5
  var crypto$1 = require('crypto');
6
- var server$1 = require('@scalemule/sdk/flags/server');
6
+
7
+ var __create = Object.create;
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __getProtoOf = Object.getPrototypeOf;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __commonJS = (cb, mod) => function __require() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
30
+ mod
31
+ ));
32
+
33
+ // node_modules/semver/internal/constants.js
34
+ var require_constants = __commonJS({
35
+ "node_modules/semver/internal/constants.js"(exports$1, module) {
36
+ var SEMVER_SPEC_VERSION = "2.0.0";
37
+ var MAX_LENGTH = 256;
38
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
39
+ 9007199254740991;
40
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
41
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
42
+ var RELEASE_TYPES = [
43
+ "major",
44
+ "premajor",
45
+ "minor",
46
+ "preminor",
47
+ "patch",
48
+ "prepatch",
49
+ "prerelease"
50
+ ];
51
+ module.exports = {
52
+ MAX_LENGTH,
53
+ MAX_SAFE_COMPONENT_LENGTH,
54
+ MAX_SAFE_BUILD_LENGTH,
55
+ MAX_SAFE_INTEGER,
56
+ RELEASE_TYPES,
57
+ SEMVER_SPEC_VERSION,
58
+ FLAG_INCLUDE_PRERELEASE: 1,
59
+ FLAG_LOOSE: 2
60
+ };
61
+ }
62
+ });
63
+
64
+ // node_modules/semver/internal/debug.js
65
+ var require_debug = __commonJS({
66
+ "node_modules/semver/internal/debug.js"(exports$1, module) {
67
+ var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
68
+ };
69
+ module.exports = debug;
70
+ }
71
+ });
72
+
73
+ // node_modules/semver/internal/re.js
74
+ var require_re = __commonJS({
75
+ "node_modules/semver/internal/re.js"(exports$1, module) {
76
+ var {
77
+ MAX_SAFE_COMPONENT_LENGTH,
78
+ MAX_SAFE_BUILD_LENGTH,
79
+ MAX_LENGTH
80
+ } = require_constants();
81
+ var debug = require_debug();
82
+ exports$1 = module.exports = {};
83
+ var re = exports$1.re = [];
84
+ var safeRe = exports$1.safeRe = [];
85
+ var src = exports$1.src = [];
86
+ var safeSrc = exports$1.safeSrc = [];
87
+ var t = exports$1.t = {};
88
+ var R = 0;
89
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
90
+ var safeRegexReplacements = [
91
+ ["\\s", 1],
92
+ ["\\d", MAX_LENGTH],
93
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
94
+ ];
95
+ var makeSafeRegex = (value) => {
96
+ for (const [token, max] of safeRegexReplacements) {
97
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
98
+ }
99
+ return value;
100
+ };
101
+ var createToken = (name, value, isGlobal) => {
102
+ const safe = makeSafeRegex(value);
103
+ const index = R++;
104
+ debug(name, index, value);
105
+ t[name] = index;
106
+ src[index] = value;
107
+ safeSrc[index] = safe;
108
+ re[index] = new RegExp(value, isGlobal ? "g" : void 0);
109
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
110
+ };
111
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
112
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
113
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
114
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
115
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
116
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
117
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
118
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
119
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
120
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
121
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
122
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
123
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
124
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
125
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
126
+ createToken("GTLT", "((?:<|>)?=?)");
127
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
128
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
129
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
130
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
131
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
132
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
133
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
134
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
135
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
136
+ createToken("COERCERTL", src[t.COERCE], true);
137
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
138
+ createToken("LONETILDE", "(?:~>?)");
139
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
140
+ exports$1.tildeTrimReplace = "$1~";
141
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
142
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
143
+ createToken("LONECARET", "(?:\\^)");
144
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
145
+ exports$1.caretTrimReplace = "$1^";
146
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
147
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
148
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
149
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
150
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
151
+ exports$1.comparatorTrimReplace = "$1$2$3";
152
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
153
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
154
+ createToken("STAR", "(<|>)?=?\\s*\\*");
155
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
156
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
157
+ }
158
+ });
159
+
160
+ // node_modules/semver/internal/parse-options.js
161
+ var require_parse_options = __commonJS({
162
+ "node_modules/semver/internal/parse-options.js"(exports$1, module) {
163
+ var looseOption = Object.freeze({ loose: true });
164
+ var emptyOpts = Object.freeze({});
165
+ var parseOptions = (options) => {
166
+ if (!options) {
167
+ return emptyOpts;
168
+ }
169
+ if (typeof options !== "object") {
170
+ return looseOption;
171
+ }
172
+ return options;
173
+ };
174
+ module.exports = parseOptions;
175
+ }
176
+ });
177
+
178
+ // node_modules/semver/internal/identifiers.js
179
+ var require_identifiers = __commonJS({
180
+ "node_modules/semver/internal/identifiers.js"(exports$1, module) {
181
+ var numeric = /^[0-9]+$/;
182
+ var compareIdentifiers = (a, b) => {
183
+ if (typeof a === "number" && typeof b === "number") {
184
+ return a === b ? 0 : a < b ? -1 : 1;
185
+ }
186
+ const anum = numeric.test(a);
187
+ const bnum = numeric.test(b);
188
+ if (anum && bnum) {
189
+ a = +a;
190
+ b = +b;
191
+ }
192
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
193
+ };
194
+ var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
195
+ module.exports = {
196
+ compareIdentifiers,
197
+ rcompareIdentifiers
198
+ };
199
+ }
200
+ });
201
+
202
+ // node_modules/semver/classes/semver.js
203
+ var require_semver = __commonJS({
204
+ "node_modules/semver/classes/semver.js"(exports$1, module) {
205
+ var debug = require_debug();
206
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
207
+ var { safeRe: re, t } = require_re();
208
+ var parseOptions = require_parse_options();
209
+ var { compareIdentifiers } = require_identifiers();
210
+ var SemVer = class _SemVer {
211
+ constructor(version, options) {
212
+ options = parseOptions(options);
213
+ if (version instanceof _SemVer) {
214
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
215
+ return version;
216
+ } else {
217
+ version = version.version;
218
+ }
219
+ } else if (typeof version !== "string") {
220
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
221
+ }
222
+ if (version.length > MAX_LENGTH) {
223
+ throw new TypeError(
224
+ `version is longer than ${MAX_LENGTH} characters`
225
+ );
226
+ }
227
+ debug("SemVer", version, options);
228
+ this.options = options;
229
+ this.loose = !!options.loose;
230
+ this.includePrerelease = !!options.includePrerelease;
231
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
232
+ if (!m) {
233
+ throw new TypeError(`Invalid Version: ${version}`);
234
+ }
235
+ this.raw = version;
236
+ this.major = +m[1];
237
+ this.minor = +m[2];
238
+ this.patch = +m[3];
239
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
240
+ throw new TypeError("Invalid major version");
241
+ }
242
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
243
+ throw new TypeError("Invalid minor version");
244
+ }
245
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
246
+ throw new TypeError("Invalid patch version");
247
+ }
248
+ if (!m[4]) {
249
+ this.prerelease = [];
250
+ } else {
251
+ this.prerelease = m[4].split(".").map((id) => {
252
+ if (/^[0-9]+$/.test(id)) {
253
+ const num = +id;
254
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
255
+ return num;
256
+ }
257
+ }
258
+ return id;
259
+ });
260
+ }
261
+ this.build = m[5] ? m[5].split(".") : [];
262
+ this.format();
263
+ }
264
+ format() {
265
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
266
+ if (this.prerelease.length) {
267
+ this.version += `-${this.prerelease.join(".")}`;
268
+ }
269
+ return this.version;
270
+ }
271
+ toString() {
272
+ return this.version;
273
+ }
274
+ compare(other) {
275
+ debug("SemVer.compare", this.version, this.options, other);
276
+ if (!(other instanceof _SemVer)) {
277
+ if (typeof other === "string" && other === this.version) {
278
+ return 0;
279
+ }
280
+ other = new _SemVer(other, this.options);
281
+ }
282
+ if (other.version === this.version) {
283
+ return 0;
284
+ }
285
+ return this.compareMain(other) || this.comparePre(other);
286
+ }
287
+ compareMain(other) {
288
+ if (!(other instanceof _SemVer)) {
289
+ other = new _SemVer(other, this.options);
290
+ }
291
+ if (this.major < other.major) {
292
+ return -1;
293
+ }
294
+ if (this.major > other.major) {
295
+ return 1;
296
+ }
297
+ if (this.minor < other.minor) {
298
+ return -1;
299
+ }
300
+ if (this.minor > other.minor) {
301
+ return 1;
302
+ }
303
+ if (this.patch < other.patch) {
304
+ return -1;
305
+ }
306
+ if (this.patch > other.patch) {
307
+ return 1;
308
+ }
309
+ return 0;
310
+ }
311
+ comparePre(other) {
312
+ if (!(other instanceof _SemVer)) {
313
+ other = new _SemVer(other, this.options);
314
+ }
315
+ if (this.prerelease.length && !other.prerelease.length) {
316
+ return -1;
317
+ } else if (!this.prerelease.length && other.prerelease.length) {
318
+ return 1;
319
+ } else if (!this.prerelease.length && !other.prerelease.length) {
320
+ return 0;
321
+ }
322
+ let i = 0;
323
+ do {
324
+ const a = this.prerelease[i];
325
+ const b = other.prerelease[i];
326
+ debug("prerelease compare", i, a, b);
327
+ if (a === void 0 && b === void 0) {
328
+ return 0;
329
+ } else if (b === void 0) {
330
+ return 1;
331
+ } else if (a === void 0) {
332
+ return -1;
333
+ } else if (a === b) {
334
+ continue;
335
+ } else {
336
+ return compareIdentifiers(a, b);
337
+ }
338
+ } while (++i);
339
+ }
340
+ compareBuild(other) {
341
+ if (!(other instanceof _SemVer)) {
342
+ other = new _SemVer(other, this.options);
343
+ }
344
+ let i = 0;
345
+ do {
346
+ const a = this.build[i];
347
+ const b = other.build[i];
348
+ debug("build compare", i, a, b);
349
+ if (a === void 0 && b === void 0) {
350
+ return 0;
351
+ } else if (b === void 0) {
352
+ return 1;
353
+ } else if (a === void 0) {
354
+ return -1;
355
+ } else if (a === b) {
356
+ continue;
357
+ } else {
358
+ return compareIdentifiers(a, b);
359
+ }
360
+ } while (++i);
361
+ }
362
+ // preminor will bump the version up to the next minor release, and immediately
363
+ // down to pre-release. premajor and prepatch work the same way.
364
+ inc(release, identifier, identifierBase) {
365
+ if (release.startsWith("pre")) {
366
+ if (!identifier && identifierBase === false) {
367
+ throw new Error("invalid increment argument: identifier is empty");
368
+ }
369
+ if (identifier) {
370
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
371
+ if (!match || match[1] !== identifier) {
372
+ throw new Error(`invalid identifier: ${identifier}`);
373
+ }
374
+ }
375
+ }
376
+ switch (release) {
377
+ case "premajor":
378
+ this.prerelease.length = 0;
379
+ this.patch = 0;
380
+ this.minor = 0;
381
+ this.major++;
382
+ this.inc("pre", identifier, identifierBase);
383
+ break;
384
+ case "preminor":
385
+ this.prerelease.length = 0;
386
+ this.patch = 0;
387
+ this.minor++;
388
+ this.inc("pre", identifier, identifierBase);
389
+ break;
390
+ case "prepatch":
391
+ this.prerelease.length = 0;
392
+ this.inc("patch", identifier, identifierBase);
393
+ this.inc("pre", identifier, identifierBase);
394
+ break;
395
+ // If the input is a non-prerelease version, this acts the same as
396
+ // prepatch.
397
+ case "prerelease":
398
+ if (this.prerelease.length === 0) {
399
+ this.inc("patch", identifier, identifierBase);
400
+ }
401
+ this.inc("pre", identifier, identifierBase);
402
+ break;
403
+ case "release":
404
+ if (this.prerelease.length === 0) {
405
+ throw new Error(`version ${this.raw} is not a prerelease`);
406
+ }
407
+ this.prerelease.length = 0;
408
+ break;
409
+ case "major":
410
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
411
+ this.major++;
412
+ }
413
+ this.minor = 0;
414
+ this.patch = 0;
415
+ this.prerelease = [];
416
+ break;
417
+ case "minor":
418
+ if (this.patch !== 0 || this.prerelease.length === 0) {
419
+ this.minor++;
420
+ }
421
+ this.patch = 0;
422
+ this.prerelease = [];
423
+ break;
424
+ case "patch":
425
+ if (this.prerelease.length === 0) {
426
+ this.patch++;
427
+ }
428
+ this.prerelease = [];
429
+ break;
430
+ // This probably shouldn't be used publicly.
431
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
432
+ case "pre": {
433
+ const base = Number(identifierBase) ? 1 : 0;
434
+ if (this.prerelease.length === 0) {
435
+ this.prerelease = [base];
436
+ } else {
437
+ let i = this.prerelease.length;
438
+ while (--i >= 0) {
439
+ if (typeof this.prerelease[i] === "number") {
440
+ this.prerelease[i]++;
441
+ i = -2;
442
+ }
443
+ }
444
+ if (i === -1) {
445
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
446
+ throw new Error("invalid increment argument: identifier already exists");
447
+ }
448
+ this.prerelease.push(base);
449
+ }
450
+ }
451
+ if (identifier) {
452
+ let prerelease = [identifier, base];
453
+ if (identifierBase === false) {
454
+ prerelease = [identifier];
455
+ }
456
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
457
+ if (isNaN(this.prerelease[1])) {
458
+ this.prerelease = prerelease;
459
+ }
460
+ } else {
461
+ this.prerelease = prerelease;
462
+ }
463
+ }
464
+ break;
465
+ }
466
+ default:
467
+ throw new Error(`invalid increment argument: ${release}`);
468
+ }
469
+ this.raw = this.format();
470
+ if (this.build.length) {
471
+ this.raw += `+${this.build.join(".")}`;
472
+ }
473
+ return this;
474
+ }
475
+ };
476
+ module.exports = SemVer;
477
+ }
478
+ });
479
+
480
+ // node_modules/semver/functions/parse.js
481
+ var require_parse = __commonJS({
482
+ "node_modules/semver/functions/parse.js"(exports$1, module) {
483
+ var SemVer = require_semver();
484
+ var parse = (version, options, throwErrors = false) => {
485
+ if (version instanceof SemVer) {
486
+ return version;
487
+ }
488
+ try {
489
+ return new SemVer(version, options);
490
+ } catch (er) {
491
+ if (!throwErrors) {
492
+ return null;
493
+ }
494
+ throw er;
495
+ }
496
+ };
497
+ module.exports = parse;
498
+ }
499
+ });
500
+
501
+ // node_modules/semver/functions/valid.js
502
+ var require_valid = __commonJS({
503
+ "node_modules/semver/functions/valid.js"(exports$1, module) {
504
+ var parse = require_parse();
505
+ var valid = (version, options) => {
506
+ const v = parse(version, options);
507
+ return v ? v.version : null;
508
+ };
509
+ module.exports = valid;
510
+ }
511
+ });
512
+
513
+ // node_modules/semver/functions/clean.js
514
+ var require_clean = __commonJS({
515
+ "node_modules/semver/functions/clean.js"(exports$1, module) {
516
+ var parse = require_parse();
517
+ var clean = (version, options) => {
518
+ const s = parse(version.trim().replace(/^[=v]+/, ""), options);
519
+ return s ? s.version : null;
520
+ };
521
+ module.exports = clean;
522
+ }
523
+ });
524
+
525
+ // node_modules/semver/functions/inc.js
526
+ var require_inc = __commonJS({
527
+ "node_modules/semver/functions/inc.js"(exports$1, module) {
528
+ var SemVer = require_semver();
529
+ var inc = (version, release, options, identifier, identifierBase) => {
530
+ if (typeof options === "string") {
531
+ identifierBase = identifier;
532
+ identifier = options;
533
+ options = void 0;
534
+ }
535
+ try {
536
+ return new SemVer(
537
+ version instanceof SemVer ? version.version : version,
538
+ options
539
+ ).inc(release, identifier, identifierBase).version;
540
+ } catch (er) {
541
+ return null;
542
+ }
543
+ };
544
+ module.exports = inc;
545
+ }
546
+ });
547
+
548
+ // node_modules/semver/functions/diff.js
549
+ var require_diff = __commonJS({
550
+ "node_modules/semver/functions/diff.js"(exports$1, module) {
551
+ var parse = require_parse();
552
+ var diff = (version1, version2) => {
553
+ const v1 = parse(version1, null, true);
554
+ const v2 = parse(version2, null, true);
555
+ const comparison = v1.compare(v2);
556
+ if (comparison === 0) {
557
+ return null;
558
+ }
559
+ const v1Higher = comparison > 0;
560
+ const highVersion = v1Higher ? v1 : v2;
561
+ const lowVersion = v1Higher ? v2 : v1;
562
+ const highHasPre = !!highVersion.prerelease.length;
563
+ const lowHasPre = !!lowVersion.prerelease.length;
564
+ if (lowHasPre && !highHasPre) {
565
+ if (!lowVersion.patch && !lowVersion.minor) {
566
+ return "major";
567
+ }
568
+ if (lowVersion.compareMain(highVersion) === 0) {
569
+ if (lowVersion.minor && !lowVersion.patch) {
570
+ return "minor";
571
+ }
572
+ return "patch";
573
+ }
574
+ }
575
+ const prefix = highHasPre ? "pre" : "";
576
+ if (v1.major !== v2.major) {
577
+ return prefix + "major";
578
+ }
579
+ if (v1.minor !== v2.minor) {
580
+ return prefix + "minor";
581
+ }
582
+ if (v1.patch !== v2.patch) {
583
+ return prefix + "patch";
584
+ }
585
+ return "prerelease";
586
+ };
587
+ module.exports = diff;
588
+ }
589
+ });
590
+
591
+ // node_modules/semver/functions/major.js
592
+ var require_major = __commonJS({
593
+ "node_modules/semver/functions/major.js"(exports$1, module) {
594
+ var SemVer = require_semver();
595
+ var major = (a, loose) => new SemVer(a, loose).major;
596
+ module.exports = major;
597
+ }
598
+ });
599
+
600
+ // node_modules/semver/functions/minor.js
601
+ var require_minor = __commonJS({
602
+ "node_modules/semver/functions/minor.js"(exports$1, module) {
603
+ var SemVer = require_semver();
604
+ var minor = (a, loose) => new SemVer(a, loose).minor;
605
+ module.exports = minor;
606
+ }
607
+ });
608
+
609
+ // node_modules/semver/functions/patch.js
610
+ var require_patch = __commonJS({
611
+ "node_modules/semver/functions/patch.js"(exports$1, module) {
612
+ var SemVer = require_semver();
613
+ var patch = (a, loose) => new SemVer(a, loose).patch;
614
+ module.exports = patch;
615
+ }
616
+ });
617
+
618
+ // node_modules/semver/functions/prerelease.js
619
+ var require_prerelease = __commonJS({
620
+ "node_modules/semver/functions/prerelease.js"(exports$1, module) {
621
+ var parse = require_parse();
622
+ var prerelease = (version, options) => {
623
+ const parsed = parse(version, options);
624
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
625
+ };
626
+ module.exports = prerelease;
627
+ }
628
+ });
629
+
630
+ // node_modules/semver/functions/compare.js
631
+ var require_compare = __commonJS({
632
+ "node_modules/semver/functions/compare.js"(exports$1, module) {
633
+ var SemVer = require_semver();
634
+ var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
635
+ module.exports = compare;
636
+ }
637
+ });
638
+
639
+ // node_modules/semver/functions/rcompare.js
640
+ var require_rcompare = __commonJS({
641
+ "node_modules/semver/functions/rcompare.js"(exports$1, module) {
642
+ var compare = require_compare();
643
+ var rcompare = (a, b, loose) => compare(b, a, loose);
644
+ module.exports = rcompare;
645
+ }
646
+ });
647
+
648
+ // node_modules/semver/functions/compare-loose.js
649
+ var require_compare_loose = __commonJS({
650
+ "node_modules/semver/functions/compare-loose.js"(exports$1, module) {
651
+ var compare = require_compare();
652
+ var compareLoose = (a, b) => compare(a, b, true);
653
+ module.exports = compareLoose;
654
+ }
655
+ });
656
+
657
+ // node_modules/semver/functions/compare-build.js
658
+ var require_compare_build = __commonJS({
659
+ "node_modules/semver/functions/compare-build.js"(exports$1, module) {
660
+ var SemVer = require_semver();
661
+ var compareBuild = (a, b, loose) => {
662
+ const versionA = new SemVer(a, loose);
663
+ const versionB = new SemVer(b, loose);
664
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
665
+ };
666
+ module.exports = compareBuild;
667
+ }
668
+ });
669
+
670
+ // node_modules/semver/functions/sort.js
671
+ var require_sort = __commonJS({
672
+ "node_modules/semver/functions/sort.js"(exports$1, module) {
673
+ var compareBuild = require_compare_build();
674
+ var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
675
+ module.exports = sort;
676
+ }
677
+ });
678
+
679
+ // node_modules/semver/functions/rsort.js
680
+ var require_rsort = __commonJS({
681
+ "node_modules/semver/functions/rsort.js"(exports$1, module) {
682
+ var compareBuild = require_compare_build();
683
+ var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
684
+ module.exports = rsort;
685
+ }
686
+ });
687
+
688
+ // node_modules/semver/functions/gt.js
689
+ var require_gt = __commonJS({
690
+ "node_modules/semver/functions/gt.js"(exports$1, module) {
691
+ var compare = require_compare();
692
+ var gt = (a, b, loose) => compare(a, b, loose) > 0;
693
+ module.exports = gt;
694
+ }
695
+ });
696
+
697
+ // node_modules/semver/functions/lt.js
698
+ var require_lt = __commonJS({
699
+ "node_modules/semver/functions/lt.js"(exports$1, module) {
700
+ var compare = require_compare();
701
+ var lt = (a, b, loose) => compare(a, b, loose) < 0;
702
+ module.exports = lt;
703
+ }
704
+ });
705
+
706
+ // node_modules/semver/functions/eq.js
707
+ var require_eq = __commonJS({
708
+ "node_modules/semver/functions/eq.js"(exports$1, module) {
709
+ var compare = require_compare();
710
+ var eq = (a, b, loose) => compare(a, b, loose) === 0;
711
+ module.exports = eq;
712
+ }
713
+ });
714
+
715
+ // node_modules/semver/functions/neq.js
716
+ var require_neq = __commonJS({
717
+ "node_modules/semver/functions/neq.js"(exports$1, module) {
718
+ var compare = require_compare();
719
+ var neq = (a, b, loose) => compare(a, b, loose) !== 0;
720
+ module.exports = neq;
721
+ }
722
+ });
723
+
724
+ // node_modules/semver/functions/gte.js
725
+ var require_gte = __commonJS({
726
+ "node_modules/semver/functions/gte.js"(exports$1, module) {
727
+ var compare = require_compare();
728
+ var gte = (a, b, loose) => compare(a, b, loose) >= 0;
729
+ module.exports = gte;
730
+ }
731
+ });
732
+
733
+ // node_modules/semver/functions/lte.js
734
+ var require_lte = __commonJS({
735
+ "node_modules/semver/functions/lte.js"(exports$1, module) {
736
+ var compare = require_compare();
737
+ var lte = (a, b, loose) => compare(a, b, loose) <= 0;
738
+ module.exports = lte;
739
+ }
740
+ });
741
+
742
+ // node_modules/semver/functions/cmp.js
743
+ var require_cmp = __commonJS({
744
+ "node_modules/semver/functions/cmp.js"(exports$1, module) {
745
+ var eq = require_eq();
746
+ var neq = require_neq();
747
+ var gt = require_gt();
748
+ var gte = require_gte();
749
+ var lt = require_lt();
750
+ var lte = require_lte();
751
+ var cmp = (a, op, b, loose) => {
752
+ switch (op) {
753
+ case "===":
754
+ if (typeof a === "object") {
755
+ a = a.version;
756
+ }
757
+ if (typeof b === "object") {
758
+ b = b.version;
759
+ }
760
+ return a === b;
761
+ case "!==":
762
+ if (typeof a === "object") {
763
+ a = a.version;
764
+ }
765
+ if (typeof b === "object") {
766
+ b = b.version;
767
+ }
768
+ return a !== b;
769
+ case "":
770
+ case "=":
771
+ case "==":
772
+ return eq(a, b, loose);
773
+ case "!=":
774
+ return neq(a, b, loose);
775
+ case ">":
776
+ return gt(a, b, loose);
777
+ case ">=":
778
+ return gte(a, b, loose);
779
+ case "<":
780
+ return lt(a, b, loose);
781
+ case "<=":
782
+ return lte(a, b, loose);
783
+ default:
784
+ throw new TypeError(`Invalid operator: ${op}`);
785
+ }
786
+ };
787
+ module.exports = cmp;
788
+ }
789
+ });
790
+
791
+ // node_modules/semver/functions/coerce.js
792
+ var require_coerce = __commonJS({
793
+ "node_modules/semver/functions/coerce.js"(exports$1, module) {
794
+ var SemVer = require_semver();
795
+ var parse = require_parse();
796
+ var { safeRe: re, t } = require_re();
797
+ var coerce = (version, options) => {
798
+ if (version instanceof SemVer) {
799
+ return version;
800
+ }
801
+ if (typeof version === "number") {
802
+ version = String(version);
803
+ }
804
+ if (typeof version !== "string") {
805
+ return null;
806
+ }
807
+ options = options || {};
808
+ let match = null;
809
+ if (!options.rtl) {
810
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
811
+ } else {
812
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
813
+ let next;
814
+ while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
815
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
816
+ match = next;
817
+ }
818
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
819
+ }
820
+ coerceRtlRegex.lastIndex = -1;
821
+ }
822
+ if (match === null) {
823
+ return null;
824
+ }
825
+ const major = match[2];
826
+ const minor = match[3] || "0";
827
+ const patch = match[4] || "0";
828
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
829
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
830
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
831
+ };
832
+ module.exports = coerce;
833
+ }
834
+ });
835
+
836
+ // node_modules/semver/internal/lrucache.js
837
+ var require_lrucache = __commonJS({
838
+ "node_modules/semver/internal/lrucache.js"(exports$1, module) {
839
+ var LRUCache = class {
840
+ constructor() {
841
+ this.max = 1e3;
842
+ this.map = /* @__PURE__ */ new Map();
843
+ }
844
+ get(key) {
845
+ const value = this.map.get(key);
846
+ if (value === void 0) {
847
+ return void 0;
848
+ } else {
849
+ this.map.delete(key);
850
+ this.map.set(key, value);
851
+ return value;
852
+ }
853
+ }
854
+ delete(key) {
855
+ return this.map.delete(key);
856
+ }
857
+ set(key, value) {
858
+ const deleted = this.delete(key);
859
+ if (!deleted && value !== void 0) {
860
+ if (this.map.size >= this.max) {
861
+ const firstKey = this.map.keys().next().value;
862
+ this.delete(firstKey);
863
+ }
864
+ this.map.set(key, value);
865
+ }
866
+ return this;
867
+ }
868
+ };
869
+ module.exports = LRUCache;
870
+ }
871
+ });
872
+
873
+ // node_modules/semver/classes/range.js
874
+ var require_range = __commonJS({
875
+ "node_modules/semver/classes/range.js"(exports$1, module) {
876
+ var SPACE_CHARACTERS = /\s+/g;
877
+ var Range = class _Range {
878
+ constructor(range, options) {
879
+ options = parseOptions(options);
880
+ if (range instanceof _Range) {
881
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
882
+ return range;
883
+ } else {
884
+ return new _Range(range.raw, options);
885
+ }
886
+ }
887
+ if (range instanceof Comparator) {
888
+ this.raw = range.value;
889
+ this.set = [[range]];
890
+ this.formatted = void 0;
891
+ return this;
892
+ }
893
+ this.options = options;
894
+ this.loose = !!options.loose;
895
+ this.includePrerelease = !!options.includePrerelease;
896
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
897
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
898
+ if (!this.set.length) {
899
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
900
+ }
901
+ if (this.set.length > 1) {
902
+ const first = this.set[0];
903
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
904
+ if (this.set.length === 0) {
905
+ this.set = [first];
906
+ } else if (this.set.length > 1) {
907
+ for (const c of this.set) {
908
+ if (c.length === 1 && isAny(c[0])) {
909
+ this.set = [c];
910
+ break;
911
+ }
912
+ }
913
+ }
914
+ }
915
+ this.formatted = void 0;
916
+ }
917
+ get range() {
918
+ if (this.formatted === void 0) {
919
+ this.formatted = "";
920
+ for (let i = 0; i < this.set.length; i++) {
921
+ if (i > 0) {
922
+ this.formatted += "||";
923
+ }
924
+ const comps = this.set[i];
925
+ for (let k = 0; k < comps.length; k++) {
926
+ if (k > 0) {
927
+ this.formatted += " ";
928
+ }
929
+ this.formatted += comps[k].toString().trim();
930
+ }
931
+ }
932
+ }
933
+ return this.formatted;
934
+ }
935
+ format() {
936
+ return this.range;
937
+ }
938
+ toString() {
939
+ return this.range;
940
+ }
941
+ parseRange(range) {
942
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
943
+ const memoKey = memoOpts + ":" + range;
944
+ const cached = cache.get(memoKey);
945
+ if (cached) {
946
+ return cached;
947
+ }
948
+ const loose = this.options.loose;
949
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
950
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
951
+ debug("hyphen replace", range);
952
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
953
+ debug("comparator trim", range);
954
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
955
+ debug("tilde trim", range);
956
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
957
+ debug("caret trim", range);
958
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
959
+ if (loose) {
960
+ rangeList = rangeList.filter((comp) => {
961
+ debug("loose invalid filter", comp, this.options);
962
+ return !!comp.match(re[t.COMPARATORLOOSE]);
963
+ });
964
+ }
965
+ debug("range list", rangeList);
966
+ const rangeMap = /* @__PURE__ */ new Map();
967
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
968
+ for (const comp of comparators) {
969
+ if (isNullSet(comp)) {
970
+ return [comp];
971
+ }
972
+ rangeMap.set(comp.value, comp);
973
+ }
974
+ if (rangeMap.size > 1 && rangeMap.has("")) {
975
+ rangeMap.delete("");
976
+ }
977
+ const result2 = [...rangeMap.values()];
978
+ cache.set(memoKey, result2);
979
+ return result2;
980
+ }
981
+ intersects(range, options) {
982
+ if (!(range instanceof _Range)) {
983
+ throw new TypeError("a Range is required");
984
+ }
985
+ return this.set.some((thisComparators) => {
986
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
987
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
988
+ return rangeComparators.every((rangeComparator) => {
989
+ return thisComparator.intersects(rangeComparator, options);
990
+ });
991
+ });
992
+ });
993
+ });
994
+ }
995
+ // if ANY of the sets match ALL of its comparators, then pass
996
+ test(version) {
997
+ if (!version) {
998
+ return false;
999
+ }
1000
+ if (typeof version === "string") {
1001
+ try {
1002
+ version = new SemVer(version, this.options);
1003
+ } catch (er) {
1004
+ return false;
1005
+ }
1006
+ }
1007
+ for (let i = 0; i < this.set.length; i++) {
1008
+ if (testSet(this.set[i], version, this.options)) {
1009
+ return true;
1010
+ }
1011
+ }
1012
+ return false;
1013
+ }
1014
+ };
1015
+ module.exports = Range;
1016
+ var LRU = require_lrucache();
1017
+ var cache = new LRU();
1018
+ var parseOptions = require_parse_options();
1019
+ var Comparator = require_comparator();
1020
+ var debug = require_debug();
1021
+ var SemVer = require_semver();
1022
+ var {
1023
+ safeRe: re,
1024
+ t,
1025
+ comparatorTrimReplace,
1026
+ tildeTrimReplace,
1027
+ caretTrimReplace
1028
+ } = require_re();
1029
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
1030
+ var isNullSet = (c) => c.value === "<0.0.0-0";
1031
+ var isAny = (c) => c.value === "";
1032
+ var isSatisfiable = (comparators, options) => {
1033
+ let result2 = true;
1034
+ const remainingComparators = comparators.slice();
1035
+ let testComparator = remainingComparators.pop();
1036
+ while (result2 && remainingComparators.length) {
1037
+ result2 = remainingComparators.every((otherComparator) => {
1038
+ return testComparator.intersects(otherComparator, options);
1039
+ });
1040
+ testComparator = remainingComparators.pop();
1041
+ }
1042
+ return result2;
1043
+ };
1044
+ var parseComparator = (comp, options) => {
1045
+ comp = comp.replace(re[t.BUILD], "");
1046
+ debug("comp", comp, options);
1047
+ comp = replaceCarets(comp, options);
1048
+ debug("caret", comp);
1049
+ comp = replaceTildes(comp, options);
1050
+ debug("tildes", comp);
1051
+ comp = replaceXRanges(comp, options);
1052
+ debug("xrange", comp);
1053
+ comp = replaceStars(comp, options);
1054
+ debug("stars", comp);
1055
+ return comp;
1056
+ };
1057
+ var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
1058
+ var replaceTildes = (comp, options) => {
1059
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
1060
+ };
1061
+ var replaceTilde = (comp, options) => {
1062
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1063
+ return comp.replace(r, (_, M, m, p, pr) => {
1064
+ debug("tilde", comp, _, M, m, p, pr);
1065
+ let ret;
1066
+ if (isX(M)) {
1067
+ ret = "";
1068
+ } else if (isX(m)) {
1069
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
1070
+ } else if (isX(p)) {
1071
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
1072
+ } else if (pr) {
1073
+ debug("replaceTilde pr", pr);
1074
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1075
+ } else {
1076
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1077
+ }
1078
+ debug("tilde return", ret);
1079
+ return ret;
1080
+ });
1081
+ };
1082
+ var replaceCarets = (comp, options) => {
1083
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
1084
+ };
1085
+ var replaceCaret = (comp, options) => {
1086
+ debug("caret", comp, options);
1087
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1088
+ const z = options.includePrerelease ? "-0" : "";
1089
+ return comp.replace(r, (_, M, m, p, pr) => {
1090
+ debug("caret", comp, _, M, m, p, pr);
1091
+ let ret;
1092
+ if (isX(M)) {
1093
+ ret = "";
1094
+ } else if (isX(m)) {
1095
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1096
+ } else if (isX(p)) {
1097
+ if (M === "0") {
1098
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1099
+ } else {
1100
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1101
+ }
1102
+ } else if (pr) {
1103
+ debug("replaceCaret pr", pr);
1104
+ if (M === "0") {
1105
+ if (m === "0") {
1106
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
1107
+ } else {
1108
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1109
+ }
1110
+ } else {
1111
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
1112
+ }
1113
+ } else {
1114
+ debug("no pr");
1115
+ if (M === "0") {
1116
+ if (m === "0") {
1117
+ ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
1118
+ } else {
1119
+ ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
1120
+ }
1121
+ } else {
1122
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
1123
+ }
1124
+ }
1125
+ debug("caret return", ret);
1126
+ return ret;
1127
+ });
1128
+ };
1129
+ var replaceXRanges = (comp, options) => {
1130
+ debug("replaceXRanges", comp, options);
1131
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
1132
+ };
1133
+ var replaceXRange = (comp, options) => {
1134
+ comp = comp.trim();
1135
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1136
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1137
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
1138
+ const xM = isX(M);
1139
+ const xm = xM || isX(m);
1140
+ const xp = xm || isX(p);
1141
+ const anyX = xp;
1142
+ if (gtlt === "=" && anyX) {
1143
+ gtlt = "";
1144
+ }
1145
+ pr = options.includePrerelease ? "-0" : "";
1146
+ if (xM) {
1147
+ if (gtlt === ">" || gtlt === "<") {
1148
+ ret = "<0.0.0-0";
1149
+ } else {
1150
+ ret = "*";
1151
+ }
1152
+ } else if (gtlt && anyX) {
1153
+ if (xm) {
1154
+ m = 0;
1155
+ }
1156
+ p = 0;
1157
+ if (gtlt === ">") {
1158
+ gtlt = ">=";
1159
+ if (xm) {
1160
+ M = +M + 1;
1161
+ m = 0;
1162
+ p = 0;
1163
+ } else {
1164
+ m = +m + 1;
1165
+ p = 0;
1166
+ }
1167
+ } else if (gtlt === "<=") {
1168
+ gtlt = "<";
1169
+ if (xm) {
1170
+ M = +M + 1;
1171
+ } else {
1172
+ m = +m + 1;
1173
+ }
1174
+ }
1175
+ if (gtlt === "<") {
1176
+ pr = "-0";
1177
+ }
1178
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1179
+ } else if (xm) {
1180
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1181
+ } else if (xp) {
1182
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
1183
+ }
1184
+ debug("xRange return", ret);
1185
+ return ret;
1186
+ });
1187
+ };
1188
+ var replaceStars = (comp, options) => {
1189
+ debug("replaceStars", comp, options);
1190
+ return comp.trim().replace(re[t.STAR], "");
1191
+ };
1192
+ var replaceGTE0 = (comp, options) => {
1193
+ debug("replaceGTE0", comp, options);
1194
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
1195
+ };
1196
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
1197
+ if (isX(fM)) {
1198
+ from = "";
1199
+ } else if (isX(fm)) {
1200
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
1201
+ } else if (isX(fp)) {
1202
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
1203
+ } else if (fpr) {
1204
+ from = `>=${from}`;
1205
+ } else {
1206
+ from = `>=${from}${incPr ? "-0" : ""}`;
1207
+ }
1208
+ if (isX(tM)) {
1209
+ to = "";
1210
+ } else if (isX(tm)) {
1211
+ to = `<${+tM + 1}.0.0-0`;
1212
+ } else if (isX(tp)) {
1213
+ to = `<${tM}.${+tm + 1}.0-0`;
1214
+ } else if (tpr) {
1215
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1216
+ } else if (incPr) {
1217
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1218
+ } else {
1219
+ to = `<=${to}`;
1220
+ }
1221
+ return `${from} ${to}`.trim();
1222
+ };
1223
+ var testSet = (set, version, options) => {
1224
+ for (let i = 0; i < set.length; i++) {
1225
+ if (!set[i].test(version)) {
1226
+ return false;
1227
+ }
1228
+ }
1229
+ if (version.prerelease.length && !options.includePrerelease) {
1230
+ for (let i = 0; i < set.length; i++) {
1231
+ debug(set[i].semver);
1232
+ if (set[i].semver === Comparator.ANY) {
1233
+ continue;
1234
+ }
1235
+ if (set[i].semver.prerelease.length > 0) {
1236
+ const allowed = set[i].semver;
1237
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
1238
+ return true;
1239
+ }
1240
+ }
1241
+ }
1242
+ return false;
1243
+ }
1244
+ return true;
1245
+ };
1246
+ }
1247
+ });
1248
+
1249
+ // node_modules/semver/classes/comparator.js
1250
+ var require_comparator = __commonJS({
1251
+ "node_modules/semver/classes/comparator.js"(exports$1, module) {
1252
+ var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
1253
+ var Comparator = class _Comparator {
1254
+ static get ANY() {
1255
+ return ANY;
1256
+ }
1257
+ constructor(comp, options) {
1258
+ options = parseOptions(options);
1259
+ if (comp instanceof _Comparator) {
1260
+ if (comp.loose === !!options.loose) {
1261
+ return comp;
1262
+ } else {
1263
+ comp = comp.value;
1264
+ }
1265
+ }
1266
+ comp = comp.trim().split(/\s+/).join(" ");
1267
+ debug("comparator", comp, options);
1268
+ this.options = options;
1269
+ this.loose = !!options.loose;
1270
+ this.parse(comp);
1271
+ if (this.semver === ANY) {
1272
+ this.value = "";
1273
+ } else {
1274
+ this.value = this.operator + this.semver.version;
1275
+ }
1276
+ debug("comp", this);
1277
+ }
1278
+ parse(comp) {
1279
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1280
+ const m = comp.match(r);
1281
+ if (!m) {
1282
+ throw new TypeError(`Invalid comparator: ${comp}`);
1283
+ }
1284
+ this.operator = m[1] !== void 0 ? m[1] : "";
1285
+ if (this.operator === "=") {
1286
+ this.operator = "";
1287
+ }
1288
+ if (!m[2]) {
1289
+ this.semver = ANY;
1290
+ } else {
1291
+ this.semver = new SemVer(m[2], this.options.loose);
1292
+ }
1293
+ }
1294
+ toString() {
1295
+ return this.value;
1296
+ }
1297
+ test(version) {
1298
+ debug("Comparator.test", version, this.options.loose);
1299
+ if (this.semver === ANY || version === ANY) {
1300
+ return true;
1301
+ }
1302
+ if (typeof version === "string") {
1303
+ try {
1304
+ version = new SemVer(version, this.options);
1305
+ } catch (er) {
1306
+ return false;
1307
+ }
1308
+ }
1309
+ return cmp(version, this.operator, this.semver, this.options);
1310
+ }
1311
+ intersects(comp, options) {
1312
+ if (!(comp instanceof _Comparator)) {
1313
+ throw new TypeError("a Comparator is required");
1314
+ }
1315
+ if (this.operator === "") {
1316
+ if (this.value === "") {
1317
+ return true;
1318
+ }
1319
+ return new Range(comp.value, options).test(this.value);
1320
+ } else if (comp.operator === "") {
1321
+ if (comp.value === "") {
1322
+ return true;
1323
+ }
1324
+ return new Range(this.value, options).test(comp.semver);
1325
+ }
1326
+ options = parseOptions(options);
1327
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
1328
+ return false;
1329
+ }
1330
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
1331
+ return false;
1332
+ }
1333
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
1334
+ return true;
1335
+ }
1336
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
1337
+ return true;
1338
+ }
1339
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
1340
+ return true;
1341
+ }
1342
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
1343
+ return true;
1344
+ }
1345
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
1346
+ return true;
1347
+ }
1348
+ return false;
1349
+ }
1350
+ };
1351
+ module.exports = Comparator;
1352
+ var parseOptions = require_parse_options();
1353
+ var { safeRe: re, t } = require_re();
1354
+ var cmp = require_cmp();
1355
+ var debug = require_debug();
1356
+ var SemVer = require_semver();
1357
+ var Range = require_range();
1358
+ }
1359
+ });
1360
+
1361
+ // node_modules/semver/functions/satisfies.js
1362
+ var require_satisfies = __commonJS({
1363
+ "node_modules/semver/functions/satisfies.js"(exports$1, module) {
1364
+ var Range = require_range();
1365
+ var satisfies = (version, range, options) => {
1366
+ try {
1367
+ range = new Range(range, options);
1368
+ } catch (er) {
1369
+ return false;
1370
+ }
1371
+ return range.test(version);
1372
+ };
1373
+ module.exports = satisfies;
1374
+ }
1375
+ });
1376
+
1377
+ // node_modules/semver/ranges/to-comparators.js
1378
+ var require_to_comparators = __commonJS({
1379
+ "node_modules/semver/ranges/to-comparators.js"(exports$1, module) {
1380
+ var Range = require_range();
1381
+ var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
1382
+ module.exports = toComparators;
1383
+ }
1384
+ });
1385
+
1386
+ // node_modules/semver/ranges/max-satisfying.js
1387
+ var require_max_satisfying = __commonJS({
1388
+ "node_modules/semver/ranges/max-satisfying.js"(exports$1, module) {
1389
+ var SemVer = require_semver();
1390
+ var Range = require_range();
1391
+ var maxSatisfying = (versions, range, options) => {
1392
+ let max = null;
1393
+ let maxSV = null;
1394
+ let rangeObj = null;
1395
+ try {
1396
+ rangeObj = new Range(range, options);
1397
+ } catch (er) {
1398
+ return null;
1399
+ }
1400
+ versions.forEach((v) => {
1401
+ if (rangeObj.test(v)) {
1402
+ if (!max || maxSV.compare(v) === -1) {
1403
+ max = v;
1404
+ maxSV = new SemVer(max, options);
1405
+ }
1406
+ }
1407
+ });
1408
+ return max;
1409
+ };
1410
+ module.exports = maxSatisfying;
1411
+ }
1412
+ });
1413
+
1414
+ // node_modules/semver/ranges/min-satisfying.js
1415
+ var require_min_satisfying = __commonJS({
1416
+ "node_modules/semver/ranges/min-satisfying.js"(exports$1, module) {
1417
+ var SemVer = require_semver();
1418
+ var Range = require_range();
1419
+ var minSatisfying = (versions, range, options) => {
1420
+ let min = null;
1421
+ let minSV = null;
1422
+ let rangeObj = null;
1423
+ try {
1424
+ rangeObj = new Range(range, options);
1425
+ } catch (er) {
1426
+ return null;
1427
+ }
1428
+ versions.forEach((v) => {
1429
+ if (rangeObj.test(v)) {
1430
+ if (!min || minSV.compare(v) === 1) {
1431
+ min = v;
1432
+ minSV = new SemVer(min, options);
1433
+ }
1434
+ }
1435
+ });
1436
+ return min;
1437
+ };
1438
+ module.exports = minSatisfying;
1439
+ }
1440
+ });
1441
+
1442
+ // node_modules/semver/ranges/min-version.js
1443
+ var require_min_version = __commonJS({
1444
+ "node_modules/semver/ranges/min-version.js"(exports$1, module) {
1445
+ var SemVer = require_semver();
1446
+ var Range = require_range();
1447
+ var gt = require_gt();
1448
+ var minVersion = (range, loose) => {
1449
+ range = new Range(range, loose);
1450
+ let minver = new SemVer("0.0.0");
1451
+ if (range.test(minver)) {
1452
+ return minver;
1453
+ }
1454
+ minver = new SemVer("0.0.0-0");
1455
+ if (range.test(minver)) {
1456
+ return minver;
1457
+ }
1458
+ minver = null;
1459
+ for (let i = 0; i < range.set.length; ++i) {
1460
+ const comparators = range.set[i];
1461
+ let setMin = null;
1462
+ comparators.forEach((comparator) => {
1463
+ const compver = new SemVer(comparator.semver.version);
1464
+ switch (comparator.operator) {
1465
+ case ">":
1466
+ if (compver.prerelease.length === 0) {
1467
+ compver.patch++;
1468
+ } else {
1469
+ compver.prerelease.push(0);
1470
+ }
1471
+ compver.raw = compver.format();
1472
+ /* fallthrough */
1473
+ case "":
1474
+ case ">=":
1475
+ if (!setMin || gt(compver, setMin)) {
1476
+ setMin = compver;
1477
+ }
1478
+ break;
1479
+ case "<":
1480
+ case "<=":
1481
+ break;
1482
+ /* istanbul ignore next */
1483
+ default:
1484
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
1485
+ }
1486
+ });
1487
+ if (setMin && (!minver || gt(minver, setMin))) {
1488
+ minver = setMin;
1489
+ }
1490
+ }
1491
+ if (minver && range.test(minver)) {
1492
+ return minver;
1493
+ }
1494
+ return null;
1495
+ };
1496
+ module.exports = minVersion;
1497
+ }
1498
+ });
1499
+
1500
+ // node_modules/semver/ranges/valid.js
1501
+ var require_valid2 = __commonJS({
1502
+ "node_modules/semver/ranges/valid.js"(exports$1, module) {
1503
+ var Range = require_range();
1504
+ var validRange = (range, options) => {
1505
+ try {
1506
+ return new Range(range, options).range || "*";
1507
+ } catch (er) {
1508
+ return null;
1509
+ }
1510
+ };
1511
+ module.exports = validRange;
1512
+ }
1513
+ });
1514
+
1515
+ // node_modules/semver/ranges/outside.js
1516
+ var require_outside = __commonJS({
1517
+ "node_modules/semver/ranges/outside.js"(exports$1, module) {
1518
+ var SemVer = require_semver();
1519
+ var Comparator = require_comparator();
1520
+ var { ANY } = Comparator;
1521
+ var Range = require_range();
1522
+ var satisfies = require_satisfies();
1523
+ var gt = require_gt();
1524
+ var lt = require_lt();
1525
+ var lte = require_lte();
1526
+ var gte = require_gte();
1527
+ var outside = (version, range, hilo, options) => {
1528
+ version = new SemVer(version, options);
1529
+ range = new Range(range, options);
1530
+ let gtfn, ltefn, ltfn, comp, ecomp;
1531
+ switch (hilo) {
1532
+ case ">":
1533
+ gtfn = gt;
1534
+ ltefn = lte;
1535
+ ltfn = lt;
1536
+ comp = ">";
1537
+ ecomp = ">=";
1538
+ break;
1539
+ case "<":
1540
+ gtfn = lt;
1541
+ ltefn = gte;
1542
+ ltfn = gt;
1543
+ comp = "<";
1544
+ ecomp = "<=";
1545
+ break;
1546
+ default:
1547
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
1548
+ }
1549
+ if (satisfies(version, range, options)) {
1550
+ return false;
1551
+ }
1552
+ for (let i = 0; i < range.set.length; ++i) {
1553
+ const comparators = range.set[i];
1554
+ let high = null;
1555
+ let low = null;
1556
+ comparators.forEach((comparator) => {
1557
+ if (comparator.semver === ANY) {
1558
+ comparator = new Comparator(">=0.0.0");
1559
+ }
1560
+ high = high || comparator;
1561
+ low = low || comparator;
1562
+ if (gtfn(comparator.semver, high.semver, options)) {
1563
+ high = comparator;
1564
+ } else if (ltfn(comparator.semver, low.semver, options)) {
1565
+ low = comparator;
1566
+ }
1567
+ });
1568
+ if (high.operator === comp || high.operator === ecomp) {
1569
+ return false;
1570
+ }
1571
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
1572
+ return false;
1573
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1574
+ return false;
1575
+ }
1576
+ }
1577
+ return true;
1578
+ };
1579
+ module.exports = outside;
1580
+ }
1581
+ });
1582
+
1583
+ // node_modules/semver/ranges/gtr.js
1584
+ var require_gtr = __commonJS({
1585
+ "node_modules/semver/ranges/gtr.js"(exports$1, module) {
1586
+ var outside = require_outside();
1587
+ var gtr = (version, range, options) => outside(version, range, ">", options);
1588
+ module.exports = gtr;
1589
+ }
1590
+ });
1591
+
1592
+ // node_modules/semver/ranges/ltr.js
1593
+ var require_ltr = __commonJS({
1594
+ "node_modules/semver/ranges/ltr.js"(exports$1, module) {
1595
+ var outside = require_outside();
1596
+ var ltr = (version, range, options) => outside(version, range, "<", options);
1597
+ module.exports = ltr;
1598
+ }
1599
+ });
1600
+
1601
+ // node_modules/semver/ranges/intersects.js
1602
+ var require_intersects = __commonJS({
1603
+ "node_modules/semver/ranges/intersects.js"(exports$1, module) {
1604
+ var Range = require_range();
1605
+ var intersects = (r1, r2, options) => {
1606
+ r1 = new Range(r1, options);
1607
+ r2 = new Range(r2, options);
1608
+ return r1.intersects(r2, options);
1609
+ };
1610
+ module.exports = intersects;
1611
+ }
1612
+ });
1613
+
1614
+ // node_modules/semver/ranges/simplify.js
1615
+ var require_simplify = __commonJS({
1616
+ "node_modules/semver/ranges/simplify.js"(exports$1, module) {
1617
+ var satisfies = require_satisfies();
1618
+ var compare = require_compare();
1619
+ module.exports = (versions, range, options) => {
1620
+ const set = [];
1621
+ let first = null;
1622
+ let prev = null;
1623
+ const v = versions.sort((a, b) => compare(a, b, options));
1624
+ for (const version of v) {
1625
+ const included = satisfies(version, range, options);
1626
+ if (included) {
1627
+ prev = version;
1628
+ if (!first) {
1629
+ first = version;
1630
+ }
1631
+ } else {
1632
+ if (prev) {
1633
+ set.push([first, prev]);
1634
+ }
1635
+ prev = null;
1636
+ first = null;
1637
+ }
1638
+ }
1639
+ if (first) {
1640
+ set.push([first, null]);
1641
+ }
1642
+ const ranges = [];
1643
+ for (const [min, max] of set) {
1644
+ if (min === max) {
1645
+ ranges.push(min);
1646
+ } else if (!max && min === v[0]) {
1647
+ ranges.push("*");
1648
+ } else if (!max) {
1649
+ ranges.push(`>=${min}`);
1650
+ } else if (min === v[0]) {
1651
+ ranges.push(`<=${max}`);
1652
+ } else {
1653
+ ranges.push(`${min} - ${max}`);
1654
+ }
1655
+ }
1656
+ const simplified = ranges.join(" || ");
1657
+ const original = typeof range.raw === "string" ? range.raw : String(range);
1658
+ return simplified.length < original.length ? simplified : range;
1659
+ };
1660
+ }
1661
+ });
1662
+
1663
+ // node_modules/semver/ranges/subset.js
1664
+ var require_subset = __commonJS({
1665
+ "node_modules/semver/ranges/subset.js"(exports$1, module) {
1666
+ var Range = require_range();
1667
+ var Comparator = require_comparator();
1668
+ var { ANY } = Comparator;
1669
+ var satisfies = require_satisfies();
1670
+ var compare = require_compare();
1671
+ var subset = (sub, dom, options = {}) => {
1672
+ if (sub === dom) {
1673
+ return true;
1674
+ }
1675
+ sub = new Range(sub, options);
1676
+ dom = new Range(dom, options);
1677
+ let sawNonNull = false;
1678
+ OUTER: for (const simpleSub of sub.set) {
1679
+ for (const simpleDom of dom.set) {
1680
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
1681
+ sawNonNull = sawNonNull || isSub !== null;
1682
+ if (isSub) {
1683
+ continue OUTER;
1684
+ }
1685
+ }
1686
+ if (sawNonNull) {
1687
+ return false;
1688
+ }
1689
+ }
1690
+ return true;
1691
+ };
1692
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
1693
+ var minimumVersion = [new Comparator(">=0.0.0")];
1694
+ var simpleSubset = (sub, dom, options) => {
1695
+ if (sub === dom) {
1696
+ return true;
1697
+ }
1698
+ if (sub.length === 1 && sub[0].semver === ANY) {
1699
+ if (dom.length === 1 && dom[0].semver === ANY) {
1700
+ return true;
1701
+ } else if (options.includePrerelease) {
1702
+ sub = minimumVersionWithPreRelease;
1703
+ } else {
1704
+ sub = minimumVersion;
1705
+ }
1706
+ }
1707
+ if (dom.length === 1 && dom[0].semver === ANY) {
1708
+ if (options.includePrerelease) {
1709
+ return true;
1710
+ } else {
1711
+ dom = minimumVersion;
1712
+ }
1713
+ }
1714
+ const eqSet = /* @__PURE__ */ new Set();
1715
+ let gt, lt;
1716
+ for (const c of sub) {
1717
+ if (c.operator === ">" || c.operator === ">=") {
1718
+ gt = higherGT(gt, c, options);
1719
+ } else if (c.operator === "<" || c.operator === "<=") {
1720
+ lt = lowerLT(lt, c, options);
1721
+ } else {
1722
+ eqSet.add(c.semver);
1723
+ }
1724
+ }
1725
+ if (eqSet.size > 1) {
1726
+ return null;
1727
+ }
1728
+ let gtltComp;
1729
+ if (gt && lt) {
1730
+ gtltComp = compare(gt.semver, lt.semver, options);
1731
+ if (gtltComp > 0) {
1732
+ return null;
1733
+ } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
1734
+ return null;
1735
+ }
1736
+ }
1737
+ for (const eq of eqSet) {
1738
+ if (gt && !satisfies(eq, String(gt), options)) {
1739
+ return null;
1740
+ }
1741
+ if (lt && !satisfies(eq, String(lt), options)) {
1742
+ return null;
1743
+ }
1744
+ for (const c of dom) {
1745
+ if (!satisfies(eq, String(c), options)) {
1746
+ return false;
1747
+ }
1748
+ }
1749
+ return true;
1750
+ }
1751
+ let higher, lower;
1752
+ let hasDomLT, hasDomGT;
1753
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
1754
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
1755
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
1756
+ needDomLTPre = false;
1757
+ }
1758
+ for (const c of dom) {
1759
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
1760
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
1761
+ if (gt) {
1762
+ if (needDomGTPre) {
1763
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
1764
+ needDomGTPre = false;
1765
+ }
1766
+ }
1767
+ if (c.operator === ">" || c.operator === ">=") {
1768
+ higher = higherGT(gt, c, options);
1769
+ if (higher === c && higher !== gt) {
1770
+ return false;
1771
+ }
1772
+ } else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) {
1773
+ return false;
1774
+ }
1775
+ }
1776
+ if (lt) {
1777
+ if (needDomLTPre) {
1778
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
1779
+ needDomLTPre = false;
1780
+ }
1781
+ }
1782
+ if (c.operator === "<" || c.operator === "<=") {
1783
+ lower = lowerLT(lt, c, options);
1784
+ if (lower === c && lower !== lt) {
1785
+ return false;
1786
+ }
1787
+ } else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) {
1788
+ return false;
1789
+ }
1790
+ }
1791
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
1792
+ return false;
1793
+ }
1794
+ }
1795
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
1796
+ return false;
1797
+ }
1798
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
1799
+ return false;
1800
+ }
1801
+ if (needDomGTPre || needDomLTPre) {
1802
+ return false;
1803
+ }
1804
+ return true;
1805
+ };
1806
+ var higherGT = (a, b, options) => {
1807
+ if (!a) {
1808
+ return b;
1809
+ }
1810
+ const comp = compare(a.semver, b.semver, options);
1811
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
1812
+ };
1813
+ var lowerLT = (a, b, options) => {
1814
+ if (!a) {
1815
+ return b;
1816
+ }
1817
+ const comp = compare(a.semver, b.semver, options);
1818
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
1819
+ };
1820
+ module.exports = subset;
1821
+ }
1822
+ });
1823
+
1824
+ // node_modules/semver/index.js
1825
+ var require_semver2 = __commonJS({
1826
+ "node_modules/semver/index.js"(exports$1, module) {
1827
+ var internalRe = require_re();
1828
+ var constants = require_constants();
1829
+ var SemVer = require_semver();
1830
+ var identifiers = require_identifiers();
1831
+ var parse = require_parse();
1832
+ var valid = require_valid();
1833
+ var clean = require_clean();
1834
+ var inc = require_inc();
1835
+ var diff = require_diff();
1836
+ var major = require_major();
1837
+ var minor = require_minor();
1838
+ var patch = require_patch();
1839
+ var prerelease = require_prerelease();
1840
+ var compare = require_compare();
1841
+ var rcompare = require_rcompare();
1842
+ var compareLoose = require_compare_loose();
1843
+ var compareBuild = require_compare_build();
1844
+ var sort = require_sort();
1845
+ var rsort = require_rsort();
1846
+ var gt = require_gt();
1847
+ var lt = require_lt();
1848
+ var eq = require_eq();
1849
+ var neq = require_neq();
1850
+ var gte = require_gte();
1851
+ var lte = require_lte();
1852
+ var cmp = require_cmp();
1853
+ var coerce = require_coerce();
1854
+ var Comparator = require_comparator();
1855
+ var Range = require_range();
1856
+ var satisfies = require_satisfies();
1857
+ var toComparators = require_to_comparators();
1858
+ var maxSatisfying = require_max_satisfying();
1859
+ var minSatisfying = require_min_satisfying();
1860
+ var minVersion = require_min_version();
1861
+ var validRange = require_valid2();
1862
+ var outside = require_outside();
1863
+ var gtr = require_gtr();
1864
+ var ltr = require_ltr();
1865
+ var intersects = require_intersects();
1866
+ var simplifyRange = require_simplify();
1867
+ var subset = require_subset();
1868
+ module.exports = {
1869
+ parse,
1870
+ valid,
1871
+ clean,
1872
+ inc,
1873
+ diff,
1874
+ major,
1875
+ minor,
1876
+ patch,
1877
+ prerelease,
1878
+ compare,
1879
+ rcompare,
1880
+ compareLoose,
1881
+ compareBuild,
1882
+ sort,
1883
+ rsort,
1884
+ gt,
1885
+ lt,
1886
+ eq,
1887
+ neq,
1888
+ gte,
1889
+ lte,
1890
+ cmp,
1891
+ coerce,
1892
+ Comparator,
1893
+ Range,
1894
+ satisfies,
1895
+ toComparators,
1896
+ maxSatisfying,
1897
+ minSatisfying,
1898
+ minVersion,
1899
+ validRange,
1900
+ outside,
1901
+ gtr,
1902
+ ltr,
1903
+ intersects,
1904
+ simplifyRange,
1905
+ subset,
1906
+ SemVer,
1907
+ re: internalRe.re,
1908
+ src: internalRe.src,
1909
+ tokens: internalRe.t,
1910
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
1911
+ RELEASE_TYPES: constants.RELEASE_TYPES,
1912
+ compareIdentifiers: identifiers.compareIdentifiers,
1913
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
1914
+ };
1915
+ }
1916
+ });
7
1917
 
8
1918
  // src/types/index.ts
9
1919
  var ScaleMuleApiError = class extends Error {
@@ -1144,7 +3054,7 @@ function createAuthRoutes(config = {}) {
1144
3054
  if (!email) {
1145
3055
  return errorResponse("VALIDATION_ERROR", "Email required", 400);
1146
3056
  }
1147
- const result = await sm.auth.forgotPassword(email, { clientContext });
3057
+ const result2 = await sm.auth.forgotPassword(email, { clientContext });
1148
3058
  return successResponse({ message: "If an account exists, a reset email has been sent" });
1149
3059
  }
1150
3060
  // ==================== Reset Password ====================
@@ -1848,9 +3758,9 @@ var CODE_TO_STATUS = {
1848
3758
  function errorCodeToStatus(code) {
1849
3759
  return CODE_TO_STATUS[code.toLowerCase()] || 400;
1850
3760
  }
1851
- function unwrap(result) {
1852
- if (result !== null && result !== void 0 && typeof result === "object" && ("success" in result || "error" in result) && "data" in result) {
1853
- const envelope = result;
3761
+ function unwrap(result2) {
3762
+ if (result2 !== null && result2 !== void 0 && typeof result2 === "object" && ("success" in result2 || "error" in result2) && "data" in result2) {
3763
+ const envelope = result2;
1854
3764
  if (envelope.error || envelope.success === false) {
1855
3765
  const err = envelope.error;
1856
3766
  const code = err?.code || "UNKNOWN_ERROR";
@@ -1864,7 +3774,7 @@ function unwrap(result) {
1864
3774
  }
1865
3775
  return envelope.data;
1866
3776
  }
1867
- return result;
3777
+ return result2;
1868
3778
  }
1869
3779
 
1870
3780
  // src/server/handler.ts
@@ -1891,10 +3801,10 @@ function apiHandler(handler, options) {
1891
3801
  searchParams: request.nextUrl.searchParams,
1892
3802
  session
1893
3803
  };
1894
- const result = await handler(request, context);
1895
- if (result instanceof Response) return result;
1896
- if (result !== void 0) {
1897
- return Response.json({ success: true, data: result }, { status: 200 });
3804
+ const result2 = await handler(request, context);
3805
+ if (result2 instanceof Response) return result2;
3806
+ if (result2 !== void 0) {
3807
+ return Response.json({ success: true, data: result2 }, { status: 200 });
1898
3808
  }
1899
3809
  return new Response(null, { status: 204 });
1900
3810
  } catch (error) {
@@ -1941,14 +3851,14 @@ function parseWebhookEvent(payload) {
1941
3851
  }
1942
3852
  async function registerVideoWebhook(url, options) {
1943
3853
  const sm = createServerClient(options?.clientConfig);
1944
- const result = await sm.webhooks.create({
3854
+ const result2 = await sm.webhooks.create({
1945
3855
  webhook_name: options?.name || "Video Status Webhook",
1946
3856
  url,
1947
3857
  events: options?.events || ["video.ready", "video.failed"]
1948
3858
  });
1949
3859
  return {
1950
- id: result.id,
1951
- secret: result.secret
3860
+ id: result2.id,
3861
+ secret: result2.secret
1952
3862
  };
1953
3863
  }
1954
3864
  function createWebhookRoutes(config = {}) {
@@ -2035,6 +3945,518 @@ function createWebhookHandler(config = {}) {
2035
3945
  }
2036
3946
  };
2037
3947
  }
3948
+
3949
+ // node_modules/@scalemule/sdk/dist/flags/server.mjs
3950
+ var import_semver = __toESM(require_semver2());
3951
+ function hashToBucket(flagKey, identifier, salt) {
3952
+ const hash = crypto$1.createHash("sha256").update(`${salt}.${flagKey}.${identifier}`).digest();
3953
+ return hash.readUInt32BE(0) % 1e4;
3954
+ }
3955
+ function allConditionsMatch(conditions, context) {
3956
+ return conditions.every((c) => conditionMatches(c, context));
3957
+ }
3958
+ function conditionMatches(condition, context) {
3959
+ const attributeValue = getAttribute(context, condition.attribute);
3960
+ const op = condition.operator;
3961
+ if (op === "exists") return attributeValue !== void 0 && attributeValue !== null;
3962
+ if (op === "not_exists") return attributeValue === void 0 || attributeValue === null;
3963
+ if (attributeValue === void 0 || attributeValue === null) return false;
3964
+ switch (op) {
3965
+ case "eq":
3966
+ return compareValues(attributeValue, condition.value) === 0;
3967
+ case "neq":
3968
+ return compareValues(attributeValue, condition.value) !== 0;
3969
+ case "in":
3970
+ return candidateValues(condition).some((v) => compareValues(attributeValue, v) === 0);
3971
+ case "not_in":
3972
+ return !candidateValues(condition).some((v) => compareValues(attributeValue, v) === 0);
3973
+ case "contains":
3974
+ return containsValue(attributeValue, condition.value);
3975
+ case "starts_with":
3976
+ return typeof attributeValue === "string" && typeof condition.value === "string" ? attributeValue.startsWith(condition.value) : false;
3977
+ case "ends_with":
3978
+ return typeof attributeValue === "string" && typeof condition.value === "string" ? attributeValue.endsWith(condition.value) : false;
3979
+ case "gt":
3980
+ return compareValues(attributeValue, condition.value) === 1;
3981
+ case "gte": {
3982
+ const cmp = compareValues(attributeValue, condition.value);
3983
+ return cmp === 1 || cmp === 0;
3984
+ }
3985
+ case "lt":
3986
+ return compareValues(attributeValue, condition.value) === -1;
3987
+ case "lte": {
3988
+ const cmp = compareValues(attributeValue, condition.value);
3989
+ return cmp === -1 || cmp === 0;
3990
+ }
3991
+ case "regex": {
3992
+ if (typeof attributeValue !== "string" || typeof condition.value !== "string") return false;
3993
+ try {
3994
+ return new RegExp(condition.value).test(attributeValue);
3995
+ } catch {
3996
+ return false;
3997
+ }
3998
+ }
3999
+ case "semver_eq":
4000
+ return semverCmp(attributeValue, condition.value) === 0;
4001
+ case "semver_neq":
4002
+ return semverCmp(attributeValue, condition.value) !== 0;
4003
+ case "semver_gt":
4004
+ return semverCmp(attributeValue, condition.value) === 1;
4005
+ case "semver_gte": {
4006
+ const cmp = semverCmp(attributeValue, condition.value);
4007
+ return cmp === 1 || cmp === 0;
4008
+ }
4009
+ case "semver_lt":
4010
+ return semverCmp(attributeValue, condition.value) === -1;
4011
+ case "semver_lte": {
4012
+ const cmp = semverCmp(attributeValue, condition.value);
4013
+ return cmp === -1 || cmp === 0;
4014
+ }
4015
+ default:
4016
+ return false;
4017
+ }
4018
+ }
4019
+ function getAttribute(context, key) {
4020
+ switch (key) {
4021
+ case "user_id":
4022
+ return context.user_id;
4023
+ case "email":
4024
+ return context.email;
4025
+ case "session_id":
4026
+ return context.session_id;
4027
+ case "ip_address":
4028
+ return context.ip_address;
4029
+ case "user_agent":
4030
+ return context.user_agent;
4031
+ case "timestamp":
4032
+ return context.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
4033
+ default:
4034
+ return context[key];
4035
+ }
4036
+ }
4037
+ function candidateValues(condition) {
4038
+ if (condition.values && condition.values.length > 0) return condition.values;
4039
+ if (condition.value === void 0 || condition.value === null) return [];
4040
+ if (Array.isArray(condition.value)) return condition.value;
4041
+ return [condition.value];
4042
+ }
4043
+ function compareValues(actual, expected) {
4044
+ if (expected === void 0 || expected === null) return null;
4045
+ const numA = toNumber(actual);
4046
+ const numB = toNumber(expected);
4047
+ if (numA !== null && numB !== null) {
4048
+ if (numA < numB) return -1;
4049
+ if (numA > numB) return 1;
4050
+ return 0;
4051
+ }
4052
+ if (typeof actual === "boolean" && typeof expected === "boolean") {
4053
+ if (actual === expected) return 0;
4054
+ return actual ? 1 : -1;
4055
+ }
4056
+ const strA = toString(actual);
4057
+ const strB = toString(expected);
4058
+ if (strA !== null && strB !== null) {
4059
+ if (strA < strB) return -1;
4060
+ if (strA > strB) return 1;
4061
+ return 0;
4062
+ }
4063
+ return null;
4064
+ }
4065
+ function containsValue(actual, expected) {
4066
+ if (expected === void 0 || expected === null) return false;
4067
+ if (Array.isArray(actual)) {
4068
+ return actual.some((item) => compareValues(item, expected) === 0);
4069
+ }
4070
+ if (typeof actual === "string" && typeof expected === "string") {
4071
+ return actual.includes(expected);
4072
+ }
4073
+ return false;
4074
+ }
4075
+ function toNumber(value) {
4076
+ if (typeof value === "number") return value;
4077
+ if (typeof value === "string") {
4078
+ const n = Number(value);
4079
+ return isNaN(n) ? null : n;
4080
+ }
4081
+ return null;
4082
+ }
4083
+ function toString(value) {
4084
+ if (typeof value === "string") return value;
4085
+ return null;
4086
+ }
4087
+ function semverCmp(actual, expected) {
4088
+ if (typeof actual !== "string" || typeof expected !== "string") return null;
4089
+ try {
4090
+ const a = (0, import_semver.parse)(actual);
4091
+ const b = (0, import_semver.parse)(expected);
4092
+ if (!a || !b) return null;
4093
+ return (0, import_semver.compare)(a, b);
4094
+ } catch {
4095
+ return null;
4096
+ }
4097
+ }
4098
+ function evaluateFlag(flag, config, context, segmentIndex) {
4099
+ const effectiveDefault = flag.environment_default_value ?? flag.default_value;
4100
+ if (flag.status !== "active") {
4101
+ return result(flag, config.environment, effectiveDefault, "disabled");
4102
+ }
4103
+ if (!flag.environment_enabled) {
4104
+ return result(flag, config.environment, effectiveDefault, "disabled");
4105
+ }
4106
+ const bucketIdentifier = getBucketIdentifier(context);
4107
+ for (const rule of flag.rules) {
4108
+ if (!rule.enabled) continue;
4109
+ if (rule.segment_ids.length > 0) {
4110
+ const segmentMatched = rule.segment_ids.some((segId) => {
4111
+ const segment = segmentIndex ? segmentIndex.get(segId) : config.segments.find((s) => s.id === segId);
4112
+ if (!segment) return false;
4113
+ return userMatchesSegment(segment, context);
4114
+ });
4115
+ if (!segmentMatched) continue;
4116
+ }
4117
+ if (!allConditionsMatch(rule.conditions, context)) continue;
4118
+ if (rule.rollout_percentage !== null && rule.rollout_percentage !== void 0) {
4119
+ const bucket = hashToBucket(flag.flag_key, bucketIdentifier, config.rollout_salt);
4120
+ if (bucket >= rule.rollout_percentage) continue;
4121
+ return {
4122
+ flag_id: flag.flag_id,
4123
+ flag_key: flag.flag_key,
4124
+ environment: config.environment,
4125
+ value: rule.serve_value,
4126
+ reason: "rule_match",
4127
+ matched_rule_id: rule.id,
4128
+ variant_key: null,
4129
+ bucket
4130
+ };
4131
+ }
4132
+ return {
4133
+ flag_id: flag.flag_id,
4134
+ flag_key: flag.flag_key,
4135
+ environment: config.environment,
4136
+ value: rule.serve_value,
4137
+ reason: "rule_match",
4138
+ matched_rule_id: rule.id,
4139
+ variant_key: null,
4140
+ bucket: null
4141
+ };
4142
+ }
4143
+ if (flag.variants.length > 0) {
4144
+ const totalWeight = flag.variants.reduce((sum, v) => sum + v.weight, 0);
4145
+ if (totalWeight > 0) {
4146
+ const bucket = hashToBucket(flag.flag_key, bucketIdentifier, config.rollout_salt);
4147
+ const scaled = Math.floor(bucket * totalWeight / 1e4);
4148
+ let cursor = 0;
4149
+ for (const variant of flag.variants) {
4150
+ cursor += variant.weight;
4151
+ if (scaled < cursor) {
4152
+ return {
4153
+ flag_id: flag.flag_id,
4154
+ flag_key: flag.flag_key,
4155
+ environment: config.environment,
4156
+ value: variant.value,
4157
+ reason: "variant",
4158
+ matched_rule_id: null,
4159
+ variant_key: variant.variant_key,
4160
+ bucket
4161
+ };
4162
+ }
4163
+ }
4164
+ }
4165
+ }
4166
+ return result(flag, config.environment, effectiveDefault, "default");
4167
+ }
4168
+ function getBucketIdentifier(context) {
4169
+ return context.user_id ?? context.session_id ?? context.email ?? context.ip_address ?? "anonymous";
4170
+ }
4171
+ function userMatchesSegment(segment, context) {
4172
+ const identifiers = [context.user_id, context.email, context.session_id].filter(
4173
+ (v) => v !== void 0 && v !== null
4174
+ );
4175
+ if (identifiers.some((id) => segment.excluded_users.includes(id))) {
4176
+ return false;
4177
+ }
4178
+ if (identifiers.some((id) => segment.included_users.includes(id))) {
4179
+ return true;
4180
+ }
4181
+ return allConditionsMatch(segment.conditions, context);
4182
+ }
4183
+ function result(flag, environment, value, reason) {
4184
+ return {
4185
+ flag_id: flag.flag_id,
4186
+ flag_key: flag.flag_key,
4187
+ environment,
4188
+ value,
4189
+ reason,
4190
+ matched_rule_id: null,
4191
+ variant_key: null,
4192
+ bucket: null
4193
+ };
4194
+ }
4195
+ var FlagClient = class {
4196
+ constructor(options) {
4197
+ this.config = null;
4198
+ this.flagIndex = /* @__PURE__ */ new Map();
4199
+ this.segmentIndex = /* @__PURE__ */ new Map();
4200
+ this.lastETag = "";
4201
+ this.streamState = "idle";
4202
+ this.pollTimer = null;
4203
+ this.reconnectTimer = null;
4204
+ this.telemetryTimer = null;
4205
+ this.abortController = null;
4206
+ this.initPromise = null;
4207
+ this.telemetryCounters = /* @__PURE__ */ new Map();
4208
+ this.isShuttingDown = false;
4209
+ this.streamConnectInFlight = false;
4210
+ this.apiKey = options.apiKey;
4211
+ this.environment = options.environment;
4212
+ this.gatewayUrl = options.gatewayUrl;
4213
+ }
4214
+ async init() {
4215
+ this.isShuttingDown = false;
4216
+ if (this.config) return;
4217
+ if (this.initPromise) return this.initPromise;
4218
+ this.initPromise = this.doInit();
4219
+ try {
4220
+ await this.initPromise;
4221
+ } finally {
4222
+ this.initPromise = null;
4223
+ }
4224
+ }
4225
+ async doInit() {
4226
+ const resp = await fetch(`${this.gatewayUrl}/v1/flags/config?environment=${encodeURIComponent(this.environment)}`, {
4227
+ headers: { "x-api-key": this.apiKey }
4228
+ });
4229
+ if (resp.status === 403) throw new Error("Secret API key required for /config");
4230
+ if (!resp.ok) throw new Error(`Config fetch failed: ${resp.status}`);
4231
+ const json = await resp.json();
4232
+ this.config = json.data;
4233
+ this.buildIndexes();
4234
+ this.lastETag = resp.headers.get("etag") || "";
4235
+ this.connectStream();
4236
+ this.startTelemetryFlush();
4237
+ }
4238
+ buildIndexes() {
4239
+ this.flagIndex.clear();
4240
+ this.segmentIndex.clear();
4241
+ if (!this.config) return;
4242
+ for (const flag of this.config.flags) {
4243
+ this.flagIndex.set(flag.flag_key, flag);
4244
+ }
4245
+ for (const segment of this.config.segments) {
4246
+ this.segmentIndex.set(segment.id, segment);
4247
+ }
4248
+ }
4249
+ evaluate(flagKey, context) {
4250
+ if (!this.config) throw new Error("FlagClient not initialized \u2014 call init() first");
4251
+ const flagConfig = this.flagIndex.get(flagKey);
4252
+ if (!flagConfig) {
4253
+ return {
4254
+ flag_id: "",
4255
+ flag_key: flagKey,
4256
+ environment: this.environment,
4257
+ value: null,
4258
+ reason: "not_found",
4259
+ matched_rule_id: null,
4260
+ variant_key: null,
4261
+ bucket: null
4262
+ };
4263
+ }
4264
+ const result2 = evaluateFlag(flagConfig, this.config, context, this.segmentIndex);
4265
+ this.recordTelemetry(result2);
4266
+ return result2;
4267
+ }
4268
+ evaluateBatch(flagKeys, context) {
4269
+ if (!this.config) throw new Error("FlagClient not initialized \u2014 call init() first");
4270
+ const results = {};
4271
+ for (const key of flagKeys) {
4272
+ const flagConfig = this.flagIndex.get(key);
4273
+ if (flagConfig) {
4274
+ const result2 = evaluateFlag(flagConfig, this.config, context, this.segmentIndex);
4275
+ this.recordTelemetry(result2);
4276
+ results[key] = result2;
4277
+ }
4278
+ }
4279
+ return results;
4280
+ }
4281
+ async shutdown() {
4282
+ this.isShuttingDown = true;
4283
+ this.streamState = "idle";
4284
+ this.abortController?.abort();
4285
+ this.abortController = null;
4286
+ if (this.pollTimer) {
4287
+ clearInterval(this.pollTimer);
4288
+ this.pollTimer = null;
4289
+ }
4290
+ if (this.reconnectTimer) {
4291
+ clearInterval(this.reconnectTimer);
4292
+ this.reconnectTimer = null;
4293
+ }
4294
+ if (this.telemetryTimer) {
4295
+ clearInterval(this.telemetryTimer);
4296
+ this.telemetryTimer = null;
4297
+ }
4298
+ await this.flushTelemetry();
4299
+ }
4300
+ // ======== SSE Streaming ========
4301
+ async connectStream() {
4302
+ if (this.isShuttingDown || this.streamState === "streaming" || this.streamConnectInFlight) return;
4303
+ this.streamConnectInFlight = true;
4304
+ this.abortController?.abort();
4305
+ const abortController = new AbortController();
4306
+ this.abortController = abortController;
4307
+ const shouldResumePolling = this.streamState !== "polling";
4308
+ let startPolling = shouldResumePolling;
4309
+ try {
4310
+ const resp = await fetch(
4311
+ `${this.gatewayUrl}/v1/flags/stream?environment=${encodeURIComponent(this.environment)}`,
4312
+ {
4313
+ headers: {
4314
+ "x-api-key": this.apiKey,
4315
+ "Last-Event-ID": String(this.config?.version ?? 0)
4316
+ },
4317
+ signal: abortController.signal
4318
+ }
4319
+ );
4320
+ if (resp.ok && resp.body) {
4321
+ this.streamState = "streaming";
4322
+ this.stopPolling();
4323
+ startPolling = false;
4324
+ const reader = resp.body.getReader();
4325
+ const decoder = new TextDecoder();
4326
+ let buffer = "";
4327
+ while (true) {
4328
+ const { done, value } = await reader.read();
4329
+ if (done) break;
4330
+ buffer += decoder.decode(value, { stream: true });
4331
+ let idx;
4332
+ while ((idx = buffer.indexOf("\n\n")) !== -1) {
4333
+ const frame = buffer.slice(0, idx);
4334
+ buffer = buffer.slice(idx + 2);
4335
+ this.handleSseFrame(frame);
4336
+ }
4337
+ }
4338
+ if (this.streamState === "streaming") {
4339
+ this.streamState = "idle";
4340
+ startPolling = true;
4341
+ }
4342
+ }
4343
+ } catch {
4344
+ startPolling = !abortController.signal.aborted && shouldResumePolling;
4345
+ } finally {
4346
+ this.streamConnectInFlight = false;
4347
+ }
4348
+ if (!this.isShuttingDown && startPolling) {
4349
+ this.startPolling();
4350
+ }
4351
+ }
4352
+ handleSseFrame(frame) {
4353
+ let eventType = "";
4354
+ let data = "";
4355
+ for (const line of frame.split("\n")) {
4356
+ if (line.startsWith("event:")) eventType = line.slice(6).trim();
4357
+ else if (line.startsWith("data:")) data += line.slice(5).trim();
4358
+ }
4359
+ if (eventType === "config" && data) {
4360
+ try {
4361
+ const parsed = JSON.parse(data);
4362
+ const newConfig = parsed.data;
4363
+ if (newConfig && newConfig.version !== void 0) {
4364
+ this.config = newConfig;
4365
+ this.buildIndexes();
4366
+ }
4367
+ } catch {
4368
+ }
4369
+ }
4370
+ }
4371
+ // ======== Polling Fallback ========
4372
+ startPolling() {
4373
+ if (this.streamState === "polling") return;
4374
+ this.streamState = "polling";
4375
+ this.pollTimer = setInterval(() => void this.pollConfig(), 6e4);
4376
+ this.reconnectTimer = setInterval(() => void this.connectStream(), 3e5);
4377
+ }
4378
+ stopPolling() {
4379
+ if (this.pollTimer) {
4380
+ clearInterval(this.pollTimer);
4381
+ this.pollTimer = null;
4382
+ }
4383
+ if (this.reconnectTimer) {
4384
+ clearInterval(this.reconnectTimer);
4385
+ this.reconnectTimer = null;
4386
+ }
4387
+ }
4388
+ async pollConfig() {
4389
+ try {
4390
+ const headers2 = { "x-api-key": this.apiKey };
4391
+ if (this.lastETag) headers2["if-none-match"] = this.lastETag;
4392
+ const resp = await fetch(
4393
+ `${this.gatewayUrl}/v1/flags/config?environment=${encodeURIComponent(this.environment)}`,
4394
+ { headers: headers2 }
4395
+ );
4396
+ if (resp.status === 304) return;
4397
+ if (!resp.ok) return;
4398
+ const json = await resp.json();
4399
+ this.config = json.data;
4400
+ this.buildIndexes();
4401
+ this.lastETag = resp.headers.get("etag") || "";
4402
+ } catch {
4403
+ }
4404
+ }
4405
+ // ======== Telemetry ========
4406
+ recordTelemetry(evaluation) {
4407
+ const key = `${evaluation.flag_key}:${evaluation.reason}:${String(evaluation.value)}`;
4408
+ const existing = this.telemetryCounters.get(key);
4409
+ if (existing) {
4410
+ existing.count++;
4411
+ if (evaluation.value === true) existing.true_count++;
4412
+ else if (evaluation.value === false) existing.false_count++;
4413
+ } else {
4414
+ this.telemetryCounters.set(key, {
4415
+ flag_key: evaluation.flag_key,
4416
+ flag_id: evaluation.flag_id,
4417
+ reason: evaluation.reason,
4418
+ count: 1,
4419
+ true_count: evaluation.value === true ? 1 : 0,
4420
+ false_count: evaluation.value === false ? 1 : 0
4421
+ });
4422
+ }
4423
+ }
4424
+ startTelemetryFlush() {
4425
+ this.telemetryTimer = setInterval(() => void this.flushTelemetry(), 6e4);
4426
+ }
4427
+ async flushTelemetry() {
4428
+ if (this.telemetryCounters.size === 0) return;
4429
+ const evaluations = Array.from(this.telemetryCounters.values());
4430
+ this.telemetryCounters.clear();
4431
+ try {
4432
+ await fetch(`${this.gatewayUrl}/v1/flags/telemetry`, {
4433
+ method: "POST",
4434
+ headers: {
4435
+ "Content-Type": "application/json",
4436
+ "x-api-key": this.apiKey
4437
+ },
4438
+ body: JSON.stringify({
4439
+ environment: this.environment,
4440
+ evaluations
4441
+ })
4442
+ });
4443
+ } catch {
4444
+ for (const counter of evaluations) {
4445
+ const key = `${counter.flag_key}:${counter.reason}:${counter.count}`;
4446
+ const existing = this.telemetryCounters.get(key);
4447
+ if (existing) {
4448
+ existing.count += counter.count;
4449
+ existing.true_count += counter.true_count;
4450
+ existing.false_count += counter.false_count;
4451
+ } else {
4452
+ this.telemetryCounters.set(key, counter);
4453
+ }
4454
+ }
4455
+ }
4456
+ }
4457
+ };
4458
+
4459
+ // src/server/bootstrap-flags.ts
2038
4460
  var _clients = /* @__PURE__ */ new Map();
2039
4461
  var _initPromises = /* @__PURE__ */ new Map();
2040
4462
  var _serverClient = null;
@@ -2062,7 +4484,7 @@ async function getFlagClient(environment) {
2062
4484
  const pending = _initPromises.get(key);
2063
4485
  if (pending) return pending;
2064
4486
  const promise = (async () => {
2065
- const client = new server$1.FlagClient({ apiKey, environment, gatewayUrl });
4487
+ const client = new FlagClient({ apiKey, environment, gatewayUrl });
2066
4488
  await Promise.race([
2067
4489
  client.init(),
2068
4490
  new Promise(
@@ -2111,8 +4533,8 @@ async function getBootstrapFlags(flagKeys, environment = "prod", extraContext =
2111
4533
  const clientIp = extractClientIp(hdrs);
2112
4534
  const context = { ...extraContext };
2113
4535
  if (clientIp) context.ip_address = clientIp;
2114
- const result = await getServerClient().flags.evaluateBatch(flagKeys, context, environment);
2115
- return result || {};
4536
+ const result2 = await getServerClient().flags.evaluateBatch(flagKeys, context, environment);
4537
+ return result2 || {};
2116
4538
  } catch {
2117
4539
  return {};
2118
4540
  }
@@ -2262,15 +4684,15 @@ async function getAppSecret(key) {
2262
4684
  }
2263
4685
  try {
2264
4686
  const client = createServerClient();
2265
- const result = await client.secrets.get(key);
2266
- if (!noCache && result) {
4687
+ const result2 = await client.secrets.get(key);
4688
+ if (!noCache && result2) {
2267
4689
  secretsCache[key] = {
2268
- value: result.value,
2269
- version: result.version,
4690
+ value: result2.value,
4691
+ version: result2.version,
2270
4692
  cachedAt: Date.now()
2271
4693
  };
2272
4694
  }
2273
- return result?.value;
4695
+ return result2?.value;
2274
4696
  } catch (error) {
2275
4697
  if (error instanceof ScaleMuleApiError && error.code === "SECRET_NOT_FOUND") {
2276
4698
  return void 0;
@@ -2321,17 +4743,17 @@ async function getBundle(key, resolve = true) {
2321
4743
  }
2322
4744
  try {
2323
4745
  const client = createServerClient();
2324
- const result = await client.bundles.get(key, resolve);
2325
- if (!noCache && result) {
4746
+ const result2 = await client.bundles.get(key, resolve);
4747
+ if (!noCache && result2) {
2326
4748
  bundlesCache[key] = {
2327
- type: result.type,
2328
- data: result.data,
2329
- version: result.version,
2330
- inheritsFrom: result.inherits_from,
4749
+ type: result2.type,
4750
+ data: result2.data,
4751
+ version: result2.version,
4752
+ inheritsFrom: result2.inherits_from,
2331
4753
  cachedAt: Date.now()
2332
4754
  };
2333
4755
  }
2334
- return result?.data;
4756
+ return result2?.data;
2335
4757
  } catch (error) {
2336
4758
  if (error instanceof ScaleMuleApiError && error.code === "BUNDLE_NOT_FOUND") {
2337
4759
  return void 0;