@unocss/language-server 66.6.8 → 66.7.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2184 @@
1
+ const require_server = require("./server.cjs");
2
+ let node_path = require("node:path");
3
+ node_path = require_server.__toESM(node_path, 1);
4
+ let node_process = require("node:process");
5
+ node_process = require_server.__toESM(node_process, 1);
6
+ let node_url = require("node:url");
7
+ let node_util = require("node:util");
8
+ let fs = require("fs");
9
+ let node_fs = require("node:fs");
10
+ node_fs = require_server.__toESM(node_fs, 1);
11
+ let node_fs_promises = require("node:fs/promises");
12
+ node_fs_promises = require_server.__toESM(node_fs_promises, 1);
13
+ let node_module = require("node:module");
14
+ let node_child_process = require("node:child_process");
15
+ let node_stream_promises = require("node:stream/promises");
16
+ let node_stream = require("node:stream");
17
+ let node_readline = require("node:readline");
18
+ node_readline = require_server.__toESM(node_readline, 1);
19
+ let node_assert = require("node:assert");
20
+ node_assert = require_server.__toESM(node_assert, 1);
21
+ let node_v8 = require("node:v8");
22
+ node_v8 = require_server.__toESM(node_v8, 1);
23
+ //#region ../../node_modules/.pnpm/@iconify+utils@3.1.3/node_modules/@iconify/utils/lib/loader/warn.js
24
+ const warned = /* @__PURE__ */ new Set();
25
+ function warnOnce(msg) {
26
+ if (!warned.has(msg)) {
27
+ warned.add(msg);
28
+ console.warn((0, node_util.styleText)("yellow", `[@iconify-loader] ${msg}`));
29
+ }
30
+ }
31
+ //#endregion
32
+ //#region ../../node_modules/.pnpm/package-manager-detector@1.6.0/node_modules/package-manager-detector/dist/constants.mjs
33
+ const AGENTS = [
34
+ "npm",
35
+ "yarn",
36
+ "yarn@berry",
37
+ "pnpm",
38
+ "pnpm@6",
39
+ "bun",
40
+ "deno"
41
+ ];
42
+ const LOCKS = {
43
+ "bun.lock": "bun",
44
+ "bun.lockb": "bun",
45
+ "deno.lock": "deno",
46
+ "pnpm-lock.yaml": "pnpm",
47
+ "pnpm-workspace.yaml": "pnpm",
48
+ "yarn.lock": "yarn",
49
+ "package-lock.json": "npm",
50
+ "npm-shrinkwrap.json": "npm"
51
+ };
52
+ const INSTALL_METADATA = {
53
+ "node_modules/.deno/": "deno",
54
+ "node_modules/.pnpm/": "pnpm",
55
+ "node_modules/.yarn-state.yml": "yarn",
56
+ "node_modules/.yarn_integrity": "yarn",
57
+ "node_modules/.package-lock.json": "npm",
58
+ ".pnp.cjs": "yarn",
59
+ ".pnp.js": "yarn",
60
+ "bun.lock": "bun",
61
+ "bun.lockb": "bun"
62
+ };
63
+ //#endregion
64
+ //#region ../../node_modules/.pnpm/package-manager-detector@1.6.0/node_modules/package-manager-detector/dist/detect.mjs
65
+ async function pathExists$1(path2, type) {
66
+ try {
67
+ const stat = await node_fs_promises.default.stat(path2);
68
+ return type === "file" ? stat.isFile() : stat.isDirectory();
69
+ } catch {
70
+ return false;
71
+ }
72
+ }
73
+ function* lookup(cwd = node_process.default.cwd()) {
74
+ let directory = node_path.default.resolve(cwd);
75
+ const { root } = node_path.default.parse(directory);
76
+ while (directory && directory !== root) {
77
+ yield directory;
78
+ directory = node_path.default.dirname(directory);
79
+ }
80
+ }
81
+ async function parsePackageJson(filepath, options) {
82
+ if (!filepath || !await pathExists$1(filepath, "file")) return null;
83
+ return await handlePackageManager(filepath, options);
84
+ }
85
+ async function detect(options = {}) {
86
+ const { cwd, strategies = [
87
+ "lockfile",
88
+ "packageManager-field",
89
+ "devEngines-field"
90
+ ] } = options;
91
+ let stopDir;
92
+ if (typeof options.stopDir === "string") {
93
+ const resolved = node_path.default.resolve(options.stopDir);
94
+ stopDir = (dir) => dir === resolved;
95
+ } else stopDir = options.stopDir;
96
+ for (const directory of lookup(cwd)) {
97
+ for (const strategy of strategies) switch (strategy) {
98
+ case "lockfile":
99
+ for (const lock of Object.keys(LOCKS)) if (await pathExists$1(node_path.default.join(directory, lock), "file")) {
100
+ const name = LOCKS[lock];
101
+ const result = await parsePackageJson(node_path.default.join(directory, "package.json"), options);
102
+ if (result) return result;
103
+ else return {
104
+ name,
105
+ agent: name
106
+ };
107
+ }
108
+ break;
109
+ case "packageManager-field":
110
+ case "devEngines-field": {
111
+ const result = await parsePackageJson(node_path.default.join(directory, "package.json"), options);
112
+ if (result) return result;
113
+ break;
114
+ }
115
+ case "install-metadata":
116
+ for (const metadata of Object.keys(INSTALL_METADATA)) {
117
+ const fileOrDir = metadata.endsWith("/") ? "dir" : "file";
118
+ if (await pathExists$1(node_path.default.join(directory, metadata), fileOrDir)) {
119
+ const name = INSTALL_METADATA[metadata];
120
+ return {
121
+ name,
122
+ agent: name === "yarn" ? isMetadataYarnClassic(metadata) ? "yarn" : "yarn@berry" : name
123
+ };
124
+ }
125
+ }
126
+ break;
127
+ }
128
+ if (stopDir?.(directory)) break;
129
+ }
130
+ return null;
131
+ }
132
+ function getNameAndVer(pkg) {
133
+ const handelVer = (version) => version?.match(/\d+(\.\d+){0,2}/)?.[0] ?? version;
134
+ if (typeof pkg.packageManager === "string") {
135
+ const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
136
+ return {
137
+ name,
138
+ ver: handelVer(ver)
139
+ };
140
+ }
141
+ if (typeof pkg.devEngines?.packageManager?.name === "string") return {
142
+ name: pkg.devEngines.packageManager.name,
143
+ ver: handelVer(pkg.devEngines.packageManager.version)
144
+ };
145
+ }
146
+ async function handlePackageManager(filepath, options) {
147
+ try {
148
+ const content = await node_fs_promises.default.readFile(filepath, "utf8");
149
+ const pkg = options.packageJsonParser ? await options.packageJsonParser(content, filepath) : JSON.parse(content);
150
+ let agent;
151
+ const nameAndVer = getNameAndVer(pkg);
152
+ if (nameAndVer) {
153
+ const name = nameAndVer.name;
154
+ const ver = nameAndVer.ver;
155
+ let version = ver;
156
+ if (name === "yarn" && ver && Number.parseInt(ver) > 1) {
157
+ agent = "yarn@berry";
158
+ version = "berry";
159
+ return {
160
+ name,
161
+ agent,
162
+ version
163
+ };
164
+ } else if (name === "pnpm" && ver && Number.parseInt(ver) < 7) {
165
+ agent = "pnpm@6";
166
+ return {
167
+ name,
168
+ agent,
169
+ version
170
+ };
171
+ } else if (AGENTS.includes(name)) {
172
+ agent = name;
173
+ return {
174
+ name,
175
+ agent,
176
+ version
177
+ };
178
+ } else return options.onUnknown?.(pkg.packageManager) ?? null;
179
+ }
180
+ } catch {}
181
+ return null;
182
+ }
183
+ function isMetadataYarnClassic(metadataPath) {
184
+ return metadataPath.endsWith(".yarn_integrity");
185
+ }
186
+ //#endregion
187
+ //#region ../../node_modules/.pnpm/tinyexec@1.1.2/node_modules/tinyexec/dist/main.mjs
188
+ var u = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports);
189
+ var d = /* @__PURE__ */ (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
190
+ const f = /^path$/i;
191
+ const p = {
192
+ key: "PATH",
193
+ value: ""
194
+ };
195
+ function m(e) {
196
+ for (const t in e) {
197
+ if (!Object.prototype.hasOwnProperty.call(e, t) || !f.test(t)) continue;
198
+ const n = e[t];
199
+ if (!n) return p;
200
+ return {
201
+ key: t,
202
+ value: n
203
+ };
204
+ }
205
+ return p;
206
+ }
207
+ function h(e, t) {
208
+ const n = t.value.split(node_path.delimiter);
209
+ const r = [];
210
+ let s = e;
211
+ let c;
212
+ do {
213
+ r.push((0, node_path.resolve)(s, "node_modules", ".bin"));
214
+ c = s;
215
+ s = (0, node_path.dirname)(s);
216
+ } while (s !== c);
217
+ r.push((0, node_path.dirname)(process.execPath));
218
+ const l = r.concat(n).join(node_path.delimiter);
219
+ return {
220
+ key: t.key,
221
+ value: l
222
+ };
223
+ }
224
+ function g(e, t) {
225
+ const n = {
226
+ ...process.env,
227
+ ...t
228
+ };
229
+ const r = h(e, m(n));
230
+ n[r.key] = r.value;
231
+ return n;
232
+ }
233
+ const _ = (e) => {
234
+ let t = e.length;
235
+ const n = new node_stream.PassThrough();
236
+ const r = () => {
237
+ if (--t === 0) n.end();
238
+ };
239
+ for (const t of e) (0, node_stream_promises.pipeline)(t, n, { end: false }).then(r).catch(r);
240
+ return n;
241
+ };
242
+ var v = /* @__PURE__ */ u(((e, t) => {
243
+ t.exports = a;
244
+ a.sync = o;
245
+ var n = d("fs");
246
+ function r(e, t) {
247
+ var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT;
248
+ if (!n) return true;
249
+ n = n.split(";");
250
+ if (n.indexOf("") !== -1) return true;
251
+ for (var r = 0; r < n.length; r++) {
252
+ var i = n[r].toLowerCase();
253
+ if (i && e.substr(-i.length).toLowerCase() === i) return true;
254
+ }
255
+ return false;
256
+ }
257
+ function i(e, t, n) {
258
+ if (!e.isSymbolicLink() && !e.isFile()) return false;
259
+ return r(t, n);
260
+ }
261
+ function a(e, t, r) {
262
+ n.stat(e, function(n, a) {
263
+ r(n, n ? false : i(a, e, t));
264
+ });
265
+ }
266
+ function o(e, t) {
267
+ return i(n.statSync(e), e, t);
268
+ }
269
+ }));
270
+ var y = /* @__PURE__ */ u(((e, t) => {
271
+ t.exports = r;
272
+ r.sync = i;
273
+ var n = d("fs");
274
+ function r(e, t, r) {
275
+ n.stat(e, function(e, n) {
276
+ r(e, e ? false : a(n, t));
277
+ });
278
+ }
279
+ function i(e, t) {
280
+ return a(n.statSync(e), t);
281
+ }
282
+ function a(e, t) {
283
+ return e.isFile() && o(e, t);
284
+ }
285
+ function o(e, t) {
286
+ var n = e.mode;
287
+ var r = e.uid;
288
+ var i = e.gid;
289
+ var a = t.uid !== void 0 ? t.uid : process.getuid && process.getuid();
290
+ var o = t.gid !== void 0 ? t.gid : process.getgid && process.getgid();
291
+ var s = parseInt("100", 8);
292
+ var c = parseInt("010", 8);
293
+ var l = parseInt("001", 8);
294
+ var u = s | c;
295
+ return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
296
+ }
297
+ }));
298
+ var b = /* @__PURE__ */ u(((e, t) => {
299
+ d("fs");
300
+ var n;
301
+ if (process.platform === "win32" || global.TESTING_WINDOWS) n = v();
302
+ else n = y();
303
+ t.exports = r;
304
+ r.sync = i;
305
+ function r(e, t, i) {
306
+ if (typeof t === "function") {
307
+ i = t;
308
+ t = {};
309
+ }
310
+ if (!i) {
311
+ if (typeof Promise !== "function") throw new TypeError("callback not provided");
312
+ return new Promise(function(n, i) {
313
+ r(e, t || {}, function(e, t) {
314
+ if (e) i(e);
315
+ else n(t);
316
+ });
317
+ });
318
+ }
319
+ n(e, t || {}, function(e, n) {
320
+ if (e) {
321
+ if (e.code === "EACCES" || t && t.ignoreErrors) {
322
+ e = null;
323
+ n = false;
324
+ }
325
+ }
326
+ i(e, n);
327
+ });
328
+ }
329
+ function i(e, t) {
330
+ try {
331
+ return n.sync(e, t || {});
332
+ } catch (e) {
333
+ if (t && t.ignoreErrors || e.code === "EACCES") return false;
334
+ else throw e;
335
+ }
336
+ }
337
+ }));
338
+ var x = /* @__PURE__ */ u(((e, t) => {
339
+ const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
340
+ const r = d("path");
341
+ const i = n ? ";" : ":";
342
+ const a = b();
343
+ const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" });
344
+ const s = (e, t) => {
345
+ const r = t.colon || i;
346
+ const a = e.match(/\//) || n && e.match(/\\/) ? [""] : [...n ? [process.cwd()] : [], ...(t.path || process.env.PATH || "").split(r)];
347
+ const o = n ? t.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
348
+ const s = n ? o.split(r) : [""];
349
+ if (n) {
350
+ if (e.indexOf(".") !== -1 && s[0] !== "") s.unshift("");
351
+ }
352
+ return {
353
+ pathEnv: a,
354
+ pathExt: s,
355
+ pathExtExe: o
356
+ };
357
+ };
358
+ const c = (e, t, n) => {
359
+ if (typeof t === "function") {
360
+ n = t;
361
+ t = {};
362
+ }
363
+ if (!t) t = {};
364
+ const { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t);
365
+ const u = [];
366
+ const d = (n) => new Promise((a, s) => {
367
+ if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
368
+ const c = i[n];
369
+ const l = /^".*"$/.test(c) ? c.slice(1, -1) : c;
370
+ const d = r.join(l, e);
371
+ a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
372
+ });
373
+ const f = (e, n, r) => new Promise((i, o) => {
374
+ if (r === c.length) return i(d(n + 1));
375
+ const s = c[r];
376
+ a(e + s, { pathExt: l }, (a, o) => {
377
+ if (!a && o) if (t.all) u.push(e + s);
378
+ else return i(e + s);
379
+ return i(f(e, n, r + 1));
380
+ });
381
+ });
382
+ return n ? d(0).then((e) => n(null, e), n) : d(0);
383
+ };
384
+ const l = (e, t) => {
385
+ t = t || {};
386
+ const { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t);
387
+ const l = [];
388
+ for (let o = 0; o < n.length; o++) {
389
+ const s = n[o];
390
+ const u = /^".*"$/.test(s) ? s.slice(1, -1) : s;
391
+ const d = r.join(u, e);
392
+ const f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
393
+ for (let e = 0; e < i.length; e++) {
394
+ const n = f + i[e];
395
+ try {
396
+ if (a.sync(n, { pathExt: c })) if (t.all) l.push(n);
397
+ else return n;
398
+ } catch (e) {}
399
+ }
400
+ }
401
+ if (t.all && l.length) return l;
402
+ if (t.nothrow) return null;
403
+ throw o(e);
404
+ };
405
+ t.exports = c;
406
+ c.sync = l;
407
+ }));
408
+ var S = /* @__PURE__ */ u(((e, t) => {
409
+ const n = (e = {}) => {
410
+ const t = e.env || process.env;
411
+ if ((e.platform || process.platform) !== "win32") return "PATH";
412
+ return Object.keys(t).reverse().find((e) => e.toUpperCase() === "PATH") || "Path";
413
+ };
414
+ t.exports = n;
415
+ t.exports.default = n;
416
+ }));
417
+ var C = /* @__PURE__ */ u(((e, t) => {
418
+ const n = d("path");
419
+ const r = x();
420
+ const i = S();
421
+ function a(e, t) {
422
+ const a = e.options.env || process.env;
423
+ const o = process.cwd();
424
+ const s = e.options.cwd != null;
425
+ const c = s && process.chdir !== void 0 && !process.chdir.disabled;
426
+ if (c) try {
427
+ process.chdir(e.options.cwd);
428
+ } catch (e) {}
429
+ let l;
430
+ try {
431
+ l = r.sync(e.command, {
432
+ path: a[i({ env: a })],
433
+ pathExt: t ? n.delimiter : void 0
434
+ });
435
+ } catch (e) {} finally {
436
+ if (c) process.chdir(o);
437
+ }
438
+ if (l) l = n.resolve(s ? e.options.cwd : "", l);
439
+ return l;
440
+ }
441
+ function o(e) {
442
+ return a(e) || a(e, true);
443
+ }
444
+ t.exports = o;
445
+ }));
446
+ var w = /* @__PURE__ */ u(((e, t) => {
447
+ const n = /([()\][%!^"`<>&|;, *?])/g;
448
+ function r(e) {
449
+ e = e.replace(n, "^$1");
450
+ return e;
451
+ }
452
+ function i(e, t) {
453
+ e = `${e}`;
454
+ e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
455
+ e = e.replace(/(?=(\\+?)?)\1$/, "$1$1");
456
+ e = `"${e}"`;
457
+ e = e.replace(n, "^$1");
458
+ if (t) e = e.replace(n, "^$1");
459
+ return e;
460
+ }
461
+ t.exports.command = r;
462
+ t.exports.argument = i;
463
+ }));
464
+ var T = /* @__PURE__ */ u(((e, t) => {
465
+ t.exports = /^#!(.*)/;
466
+ }));
467
+ var E = /* @__PURE__ */ u(((e, t) => {
468
+ const n = T();
469
+ t.exports = (e = "") => {
470
+ const t = e.match(n);
471
+ if (!t) return null;
472
+ const [r, i] = t[0].replace(/#! ?/, "").split(" ");
473
+ const a = r.split("/").pop();
474
+ if (a === "env") return i;
475
+ return i ? `${a} ${i}` : a;
476
+ };
477
+ }));
478
+ var D = /* @__PURE__ */ u(((e, t) => {
479
+ const n = d("fs");
480
+ const r = E();
481
+ function i(e) {
482
+ const t = 150;
483
+ const i = Buffer.alloc(t);
484
+ let a;
485
+ try {
486
+ a = n.openSync(e, "r");
487
+ n.readSync(a, i, 0, t, 0);
488
+ n.closeSync(a);
489
+ } catch (e) {}
490
+ return r(i.toString());
491
+ }
492
+ t.exports = i;
493
+ }));
494
+ var O = /* @__PURE__ */ u(((e, t) => {
495
+ const n = d("path");
496
+ const r = C();
497
+ const i = w();
498
+ const a = D();
499
+ const o = process.platform === "win32";
500
+ const s = /\.(?:com|exe)$/i;
501
+ const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
502
+ function l(e) {
503
+ e.file = r(e);
504
+ const t = e.file && a(e.file);
505
+ if (t) {
506
+ e.args.unshift(e.file);
507
+ e.command = t;
508
+ return r(e);
509
+ }
510
+ return e.file;
511
+ }
512
+ function u(e) {
513
+ if (!o) return e;
514
+ const t = l(e);
515
+ const r = !s.test(t);
516
+ if (e.options.forceShell || r) {
517
+ const r = c.test(t);
518
+ e.command = n.normalize(e.command);
519
+ e.command = i.command(e.command);
520
+ e.args = e.args.map((e) => i.argument(e, r));
521
+ e.args = [
522
+ "/d",
523
+ "/s",
524
+ "/c",
525
+ `"${[e.command].concat(e.args).join(" ")}"`
526
+ ];
527
+ e.command = process.env.comspec || "cmd.exe";
528
+ e.options.windowsVerbatimArguments = true;
529
+ }
530
+ return e;
531
+ }
532
+ function f(e, t, n) {
533
+ if (t && !Array.isArray(t)) {
534
+ n = t;
535
+ t = null;
536
+ }
537
+ t = t ? t.slice(0) : [];
538
+ n = Object.assign({}, n);
539
+ const r = {
540
+ command: e,
541
+ args: t,
542
+ options: n,
543
+ file: void 0,
544
+ original: {
545
+ command: e,
546
+ args: t
547
+ }
548
+ };
549
+ return n.shell ? r : u(r);
550
+ }
551
+ t.exports = f;
552
+ }));
553
+ var k = /* @__PURE__ */ u(((e, t) => {
554
+ const n = process.platform === "win32";
555
+ function r(e, t) {
556
+ return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), {
557
+ code: "ENOENT",
558
+ errno: "ENOENT",
559
+ syscall: `${t} ${e.command}`,
560
+ path: e.command,
561
+ spawnargs: e.args
562
+ });
563
+ }
564
+ function i(e, t) {
565
+ if (!n) return;
566
+ const r = e.emit;
567
+ e.emit = function(n, i) {
568
+ if (n === "exit") {
569
+ const n = a(i, t);
570
+ if (n) return r.call(e, "error", n);
571
+ }
572
+ return r.apply(e, arguments);
573
+ };
574
+ }
575
+ function a(e, t) {
576
+ if (n && e === 1 && !t.file) return r(t.original, "spawn");
577
+ return null;
578
+ }
579
+ function o(e, t) {
580
+ if (n && e === 1 && !t.file) return r(t.original, "spawnSync");
581
+ return null;
582
+ }
583
+ t.exports = {
584
+ hookChildProcess: i,
585
+ verifyENOENT: a,
586
+ verifyENOENTSync: o,
587
+ notFoundError: r
588
+ };
589
+ }));
590
+ var j = (/* @__PURE__ */ u(((e, t) => {
591
+ const n = d("child_process");
592
+ const r = O();
593
+ const i = k();
594
+ function a(e, t, a) {
595
+ const o = r(e, t, a);
596
+ const s = n.spawn(o.command, o.args, o.options);
597
+ i.hookChildProcess(s, o);
598
+ return s;
599
+ }
600
+ function o(e, t, a) {
601
+ const o = r(e, t, a);
602
+ const s = n.spawnSync(o.command, o.args, o.options);
603
+ s.error = s.error || i.verifyENOENTSync(s.status, o);
604
+ return s;
605
+ }
606
+ t.exports = a;
607
+ t.exports.spawn = a;
608
+ t.exports.sync = o;
609
+ t.exports._parse = r;
610
+ t.exports._enoent = i;
611
+ })))();
612
+ var M = class extends Error {
613
+ get exitCode() {
614
+ if (this.result.exitCode !== null) return this.result.exitCode;
615
+ }
616
+ constructor(e, t) {
617
+ super(`Process exited with non-zero status (${e.exitCode})`);
618
+ this.result = e;
619
+ this.output = t;
620
+ }
621
+ };
622
+ const P = {
623
+ timeout: void 0,
624
+ persist: false
625
+ };
626
+ const I = { windowsHide: true };
627
+ function L(e) {
628
+ const t = new AbortController();
629
+ for (const n of e) {
630
+ if (n.aborted) {
631
+ t.abort();
632
+ return n;
633
+ }
634
+ const e = () => {
635
+ t.abort(n.reason);
636
+ };
637
+ n.addEventListener("abort", e, { signal: t.signal });
638
+ }
639
+ return t.signal;
640
+ }
641
+ async function R(e) {
642
+ let t = "";
643
+ try {
644
+ for await (const n of e) t += n.toString();
645
+ } catch {}
646
+ return t;
647
+ }
648
+ var z = class {
649
+ _process;
650
+ _aborted = false;
651
+ _options;
652
+ _command;
653
+ _args;
654
+ _resolveClose;
655
+ _processClosed;
656
+ _thrownError;
657
+ get process() {
658
+ return this._process;
659
+ }
660
+ get pid() {
661
+ return this._process?.pid;
662
+ }
663
+ get exitCode() {
664
+ if (this._process && this._process.exitCode !== null) return this._process.exitCode;
665
+ }
666
+ constructor(e, t, n) {
667
+ this._options = {
668
+ ...P,
669
+ ...n
670
+ };
671
+ this._command = e;
672
+ this._args = t ?? [];
673
+ this._processClosed = new Promise((e) => {
674
+ this._resolveClose = e;
675
+ });
676
+ }
677
+ kill(e) {
678
+ return this._process?.kill(e) === true;
679
+ }
680
+ get aborted() {
681
+ return this._aborted;
682
+ }
683
+ get killed() {
684
+ return this._process?.killed === true;
685
+ }
686
+ pipe(e, t, n) {
687
+ return H(e, t, {
688
+ ...n,
689
+ stdin: this
690
+ });
691
+ }
692
+ async *[Symbol.asyncIterator]() {
693
+ const e = this._process;
694
+ if (!e) return;
695
+ const t = [];
696
+ if (this._streamErr) t.push(this._streamErr);
697
+ if (this._streamOut) t.push(this._streamOut);
698
+ const n = _(t);
699
+ const r = node_readline.default.createInterface({ input: n });
700
+ for await (const e of r) yield e.toString();
701
+ await this._processClosed;
702
+ e.removeAllListeners();
703
+ if (this._thrownError) throw this._thrownError;
704
+ if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new M(this);
705
+ }
706
+ async _waitForOutput() {
707
+ const e = this._process;
708
+ if (!e) throw new Error("No process was started");
709
+ const [t, n] = await Promise.all([this._streamOut ? R(this._streamOut) : "", this._streamErr ? R(this._streamErr) : ""]);
710
+ await this._processClosed;
711
+ const { stdin: r } = this._options;
712
+ if (r && typeof r !== "string") await r;
713
+ e.removeAllListeners();
714
+ if (this._thrownError) throw this._thrownError;
715
+ const i = {
716
+ stderr: n,
717
+ stdout: t,
718
+ exitCode: this.exitCode
719
+ };
720
+ if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new M(this, i);
721
+ return i;
722
+ }
723
+ then(e, t) {
724
+ return this._waitForOutput().then(e, t);
725
+ }
726
+ _streamOut;
727
+ _streamErr;
728
+ spawn() {
729
+ const e = (0, node_process.cwd)();
730
+ const n = this._options;
731
+ const i = {
732
+ ...I,
733
+ ...n.nodeOptions
734
+ };
735
+ const a = [];
736
+ this._resetState();
737
+ if (n.timeout !== void 0) a.push(AbortSignal.timeout(n.timeout));
738
+ if (n.signal !== void 0) a.push(n.signal);
739
+ if (n.persist === true) i.detached = true;
740
+ if (a.length > 0) i.signal = L(a);
741
+ i.env = g(e, i.env);
742
+ const o = (0, j._parse)(this._command, this._args, i);
743
+ const s = (0, node_child_process.spawn)(o.command, o.args, o.options);
744
+ if (s.stderr) this._streamErr = s.stderr;
745
+ if (s.stdout) this._streamOut = s.stdout;
746
+ this._process = s;
747
+ s.once("error", this._onError);
748
+ s.once("close", this._onClose);
749
+ if (s.stdin) {
750
+ const { stdin: e } = n;
751
+ if (typeof e === "string") s.stdin.end(e);
752
+ else e?.process?.stdout?.pipe(s.stdin);
753
+ }
754
+ }
755
+ _resetState() {
756
+ this._aborted = false;
757
+ this._processClosed = new Promise((e) => {
758
+ this._resolveClose = e;
759
+ });
760
+ this._thrownError = void 0;
761
+ }
762
+ _onError = (e) => {
763
+ if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
764
+ this._aborted = true;
765
+ return;
766
+ }
767
+ this._thrownError = e;
768
+ };
769
+ _onClose = () => {
770
+ if (this._resolveClose) this._resolveClose();
771
+ };
772
+ };
773
+ const V = (e, t, n) => {
774
+ const r = new z(e, t, n);
775
+ r.spawn();
776
+ return r;
777
+ };
778
+ const H = V;
779
+ //#endregion
780
+ //#region ../../node_modules/.pnpm/@antfu+install-pkg@1.1.0/node_modules/@antfu/install-pkg/dist/index.js
781
+ async function detectPackageManager(cwd = node_process.default.cwd()) {
782
+ return (await detect({
783
+ cwd,
784
+ onUnknown(packageManager) {
785
+ console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
786
+ }
787
+ }))?.agent || null;
788
+ }
789
+ async function installPackage(names, options = {}) {
790
+ const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
791
+ const [agent] = detectedAgent.split("@");
792
+ if (!Array.isArray(names)) names = [names];
793
+ const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
794
+ if (options.preferOffline) if (detectedAgent === "yarn@berry") args.unshift("--cached");
795
+ else args.unshift("--prefer-offline");
796
+ if (agent === "pnpm") {
797
+ args.unshift(
798
+ /**
799
+ * Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
800
+ * @see https://pnpm.io/cli/install#--prod--p
801
+ */
802
+ "--prod=false"
803
+ );
804
+ if ((0, node_fs.existsSync)((0, node_path.resolve)(options.cwd ?? node_process.default.cwd(), "pnpm-workspace.yaml"))) args.unshift("-w");
805
+ }
806
+ return V(agent, [
807
+ agent === "yarn" ? "add" : "install",
808
+ options.dev ? "-D" : "",
809
+ ...args,
810
+ ...names
811
+ ].filter(Boolean), {
812
+ nodeOptions: {
813
+ stdio: options.silent ? "ignore" : "inherit",
814
+ cwd: options.cwd
815
+ },
816
+ throwOnError: true
817
+ });
818
+ }
819
+ //#endregion
820
+ //#region ../../node_modules/.pnpm/@iconify+utils@3.1.3/node_modules/@iconify/utils/lib/loader/install-pkg.js
821
+ let pending;
822
+ const tasks = {};
823
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
824
+ async function tryInstallPkg(name, autoInstall) {
825
+ if (pending) await pending;
826
+ if (!tasks[name]) {
827
+ console.log((0, node_util.styleText)("cyan", `Installing ${name}...`));
828
+ if (typeof autoInstall === "function") tasks[name] = pending = autoInstall(name).then(() => sleep(300)).finally(() => {
829
+ pending = void 0;
830
+ });
831
+ else tasks[name] = pending = installPackage(name, {
832
+ dev: true,
833
+ preferOffline: true
834
+ }).then(() => sleep(300)).catch((e) => {
835
+ warnOnce(`Failed to install ${name}`);
836
+ console.error(e);
837
+ }).finally(() => {
838
+ pending = void 0;
839
+ });
840
+ }
841
+ return tasks[name];
842
+ }
843
+ //#endregion
844
+ //#region ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/errors.js
845
+ /**
846
+ * @typedef ErrnoExceptionFields
847
+ * @property {number | undefined} [errnode]
848
+ * @property {string | undefined} [code]
849
+ * @property {string | undefined} [path]
850
+ * @property {string | undefined} [syscall]
851
+ * @property {string | undefined} [url]
852
+ *
853
+ * @typedef {Error & ErrnoExceptionFields} ErrnoException
854
+ */
855
+ /**
856
+ * @typedef {(...parameters: Array<any>) => string} MessageFunction
857
+ */
858
+ const own$1 = {}.hasOwnProperty;
859
+ const classRegExp = /^([A-Z][a-z\d]*)+$/;
860
+ const kTypes = new Set([
861
+ "string",
862
+ "function",
863
+ "number",
864
+ "object",
865
+ "Function",
866
+ "Object",
867
+ "boolean",
868
+ "bigint",
869
+ "symbol"
870
+ ]);
871
+ const codes = {};
872
+ /**
873
+ * Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
874
+ * We cannot use Intl.ListFormat because it's not available in
875
+ * --without-intl builds.
876
+ *
877
+ * @param {Array<string>} array
878
+ * An array of strings.
879
+ * @param {string} [type]
880
+ * The list type to be inserted before the last element.
881
+ * @returns {string}
882
+ */
883
+ function formatList(array, type = "and") {
884
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
885
+ }
886
+ /** @type {Map<string, MessageFunction | string>} */
887
+ const messages = /* @__PURE__ */ new Map();
888
+ const nodeInternalPrefix = "__node_internal_";
889
+ /** @type {number} */
890
+ let userStackTraceLimit;
891
+ codes.ERR_INVALID_ARG_TYPE = createError(
892
+ "ERR_INVALID_ARG_TYPE",
893
+ /**
894
+ * @param {string} name
895
+ * @param {Array<string> | string} expected
896
+ * @param {unknown} actual
897
+ */
898
+ (name, expected, actual) => {
899
+ node_assert.default.ok(typeof name === "string", "'name' must be a string");
900
+ if (!Array.isArray(expected)) expected = [expected];
901
+ let message = "The ";
902
+ if (name.endsWith(" argument")) message += `${name} `;
903
+ else {
904
+ const type = name.includes(".") ? "property" : "argument";
905
+ message += `"${name}" ${type} `;
906
+ }
907
+ message += "must be ";
908
+ /** @type {Array<string>} */
909
+ const types = [];
910
+ /** @type {Array<string>} */
911
+ const instances = [];
912
+ /** @type {Array<string>} */
913
+ const other = [];
914
+ for (const value of expected) {
915
+ node_assert.default.ok(typeof value === "string", "All expected entries have to be of type string");
916
+ if (kTypes.has(value)) types.push(value.toLowerCase());
917
+ else if (classRegExp.exec(value) === null) {
918
+ node_assert.default.ok(value !== "object", "The value \"object\" should be written as \"Object\"");
919
+ other.push(value);
920
+ } else instances.push(value);
921
+ }
922
+ if (instances.length > 0) {
923
+ const pos = types.indexOf("object");
924
+ if (pos !== -1) {
925
+ types.slice(pos, 1);
926
+ instances.push("Object");
927
+ }
928
+ }
929
+ if (types.length > 0) {
930
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
931
+ if (instances.length > 0 || other.length > 0) message += " or ";
932
+ }
933
+ if (instances.length > 0) {
934
+ message += `an instance of ${formatList(instances, "or")}`;
935
+ if (other.length > 0) message += " or ";
936
+ }
937
+ if (other.length > 0) if (other.length > 1) message += `one of ${formatList(other, "or")}`;
938
+ else {
939
+ if (other[0].toLowerCase() !== other[0]) message += "an ";
940
+ message += `${other[0]}`;
941
+ }
942
+ message += `. Received ${determineSpecificType(actual)}`;
943
+ return message;
944
+ },
945
+ TypeError
946
+ );
947
+ codes.ERR_INVALID_MODULE_SPECIFIER = createError(
948
+ "ERR_INVALID_MODULE_SPECIFIER",
949
+ /**
950
+ * @param {string} request
951
+ * @param {string} reason
952
+ * @param {string} [base]
953
+ */
954
+ (request, reason, base = void 0) => {
955
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
956
+ },
957
+ TypeError
958
+ );
959
+ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
960
+ "ERR_INVALID_PACKAGE_CONFIG",
961
+ /**
962
+ * @param {string} path
963
+ * @param {string} [base]
964
+ * @param {string} [message]
965
+ */
966
+ (path, base, message) => {
967
+ return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
968
+ },
969
+ Error
970
+ );
971
+ codes.ERR_INVALID_PACKAGE_TARGET = createError(
972
+ "ERR_INVALID_PACKAGE_TARGET",
973
+ /**
974
+ * @param {string} packagePath
975
+ * @param {string} key
976
+ * @param {unknown} target
977
+ * @param {boolean} [isImport=false]
978
+ * @param {string} [base]
979
+ */
980
+ (packagePath, key, target, isImport = false, base = void 0) => {
981
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
982
+ if (key === ".") {
983
+ node_assert.default.ok(isImport === false);
984
+ return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
985
+ }
986
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
987
+ },
988
+ Error
989
+ );
990
+ codes.ERR_MODULE_NOT_FOUND = createError(
991
+ "ERR_MODULE_NOT_FOUND",
992
+ /**
993
+ * @param {string} path
994
+ * @param {string} base
995
+ * @param {boolean} [exactUrl]
996
+ */
997
+ (path, base, exactUrl = false) => {
998
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path}' imported from ${base}`;
999
+ },
1000
+ Error
1001
+ );
1002
+ codes.ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
1003
+ codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
1004
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED",
1005
+ /**
1006
+ * @param {string} specifier
1007
+ * @param {string} packagePath
1008
+ * @param {string} base
1009
+ */
1010
+ (specifier, packagePath, base) => {
1011
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
1012
+ },
1013
+ TypeError
1014
+ );
1015
+ codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
1016
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
1017
+ /**
1018
+ * @param {string} packagePath
1019
+ * @param {string} subpath
1020
+ * @param {string} [base]
1021
+ */
1022
+ (packagePath, subpath, base = void 0) => {
1023
+ if (subpath === ".") return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
1024
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
1025
+ },
1026
+ Error
1027
+ );
1028
+ codes.ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
1029
+ codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", "Failed to resolve module specifier \"%s\" from \"%s\": Invalid relative URL or base scheme is not hierarchical.", TypeError);
1030
+ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
1031
+ "ERR_UNKNOWN_FILE_EXTENSION",
1032
+ /**
1033
+ * @param {string} extension
1034
+ * @param {string} path
1035
+ */
1036
+ (extension, path) => {
1037
+ return `Unknown file extension "${extension}" for ${path}`;
1038
+ },
1039
+ TypeError
1040
+ );
1041
+ codes.ERR_INVALID_ARG_VALUE = createError(
1042
+ "ERR_INVALID_ARG_VALUE",
1043
+ /**
1044
+ * @param {string} name
1045
+ * @param {unknown} value
1046
+ * @param {string} [reason='is invalid']
1047
+ */
1048
+ (name, value, reason = "is invalid") => {
1049
+ let inspected = (0, node_util.inspect)(value);
1050
+ if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
1051
+ return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
1052
+ },
1053
+ TypeError
1054
+ );
1055
+ /**
1056
+ * Utility function for registering the error codes. Only used here. Exported
1057
+ * *only* to allow for testing.
1058
+ * @param {string} sym
1059
+ * @param {MessageFunction | string} value
1060
+ * @param {ErrorConstructor} constructor
1061
+ * @returns {new (...parameters: Array<any>) => Error}
1062
+ */
1063
+ function createError(sym, value, constructor) {
1064
+ messages.set(sym, value);
1065
+ return makeNodeErrorWithCode(constructor, sym);
1066
+ }
1067
+ /**
1068
+ * @param {ErrorConstructor} Base
1069
+ * @param {string} key
1070
+ * @returns {ErrorConstructor}
1071
+ */
1072
+ function makeNodeErrorWithCode(Base, key) {
1073
+ return NodeError;
1074
+ /**
1075
+ * @param {Array<unknown>} parameters
1076
+ */
1077
+ function NodeError(...parameters) {
1078
+ const limit = Error.stackTraceLimit;
1079
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
1080
+ const error = new Base();
1081
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
1082
+ const message = getMessage(key, parameters, error);
1083
+ Object.defineProperties(error, {
1084
+ message: {
1085
+ value: message,
1086
+ enumerable: false,
1087
+ writable: true,
1088
+ configurable: true
1089
+ },
1090
+ toString: {
1091
+ /** @this {Error} */
1092
+ value() {
1093
+ return `${this.name} [${key}]: ${this.message}`;
1094
+ },
1095
+ enumerable: false,
1096
+ writable: true,
1097
+ configurable: true
1098
+ }
1099
+ });
1100
+ captureLargerStackTrace(error);
1101
+ error.code = key;
1102
+ return error;
1103
+ }
1104
+ }
1105
+ /**
1106
+ * @returns {boolean}
1107
+ */
1108
+ function isErrorStackTraceLimitWritable() {
1109
+ try {
1110
+ if (node_v8.default.startupSnapshot.isBuildingSnapshot()) return false;
1111
+ } catch {}
1112
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
1113
+ if (desc === void 0) return Object.isExtensible(Error);
1114
+ return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
1115
+ }
1116
+ /**
1117
+ * This function removes unnecessary frames from Node.js core errors.
1118
+ * @template {(...parameters: unknown[]) => unknown} T
1119
+ * @param {T} wrappedFunction
1120
+ * @returns {T}
1121
+ */
1122
+ function hideStackFrames(wrappedFunction) {
1123
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
1124
+ Object.defineProperty(wrappedFunction, "name", { value: hidden });
1125
+ return wrappedFunction;
1126
+ }
1127
+ const captureLargerStackTrace = hideStackFrames(
1128
+ /**
1129
+ * @param {Error} error
1130
+ * @returns {Error}
1131
+ */
1132
+ function(error) {
1133
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
1134
+ if (stackTraceLimitIsWritable) {
1135
+ userStackTraceLimit = Error.stackTraceLimit;
1136
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
1137
+ }
1138
+ Error.captureStackTrace(error);
1139
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
1140
+ return error;
1141
+ }
1142
+ );
1143
+ /**
1144
+ * @param {string} key
1145
+ * @param {Array<unknown>} parameters
1146
+ * @param {Error} self
1147
+ * @returns {string}
1148
+ */
1149
+ function getMessage(key, parameters, self) {
1150
+ const message = messages.get(key);
1151
+ node_assert.default.ok(message !== void 0, "expected `message` to be found");
1152
+ if (typeof message === "function") {
1153
+ node_assert.default.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
1154
+ return Reflect.apply(message, self, parameters);
1155
+ }
1156
+ const regex = /%[dfijoOs]/g;
1157
+ let expectedLength = 0;
1158
+ while (regex.exec(message) !== null) expectedLength++;
1159
+ node_assert.default.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
1160
+ if (parameters.length === 0) return message;
1161
+ parameters.unshift(message);
1162
+ return Reflect.apply(node_util.format, null, parameters);
1163
+ }
1164
+ /**
1165
+ * Determine the specific type of a value for type-mismatch errors.
1166
+ * @param {unknown} value
1167
+ * @returns {string}
1168
+ */
1169
+ function determineSpecificType(value) {
1170
+ if (value === null || value === void 0) return String(value);
1171
+ if (typeof value === "function" && value.name) return `function ${value.name}`;
1172
+ if (typeof value === "object") {
1173
+ if (value.constructor && value.constructor.name) return `an instance of ${value.constructor.name}`;
1174
+ return `${(0, node_util.inspect)(value, { depth: -1 })}`;
1175
+ }
1176
+ let inspected = (0, node_util.inspect)(value, { colors: false });
1177
+ if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
1178
+ return `type ${typeof value} (${inspected})`;
1179
+ }
1180
+ //#endregion
1181
+ //#region ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/package-json-reader.js
1182
+ /**
1183
+ * @import {ErrnoException} from './errors.js'
1184
+ *
1185
+ * @typedef {'commonjs' | 'module' | 'none'} PackageType
1186
+ *
1187
+ * @typedef PackageConfig
1188
+ * @property {string} pjsonPath
1189
+ * @property {boolean} exists
1190
+ * @property {string | undefined} [main]
1191
+ * @property {string | undefined} [name]
1192
+ * @property {PackageType} type
1193
+ * @property {Record<string, unknown> | undefined} [exports]
1194
+ * @property {Record<string, unknown> | undefined} [imports]
1195
+ */
1196
+ const hasOwnProperty$1 = {}.hasOwnProperty;
1197
+ const { ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG$1 } = codes;
1198
+ /** @type {Map<string, PackageConfig>} */
1199
+ const cache = /* @__PURE__ */ new Map();
1200
+ /**
1201
+ * @param {string} jsonPath
1202
+ * @param {{specifier: URL | string, base?: URL}} options
1203
+ * @returns {PackageConfig}
1204
+ */
1205
+ function read(jsonPath, { base, specifier }) {
1206
+ const existing = cache.get(jsonPath);
1207
+ if (existing) return existing;
1208
+ /** @type {string | undefined} */
1209
+ let string;
1210
+ try {
1211
+ string = node_fs.default.readFileSync(node_path.default.toNamespacedPath(jsonPath), "utf8");
1212
+ } catch (error) {
1213
+ const exception = error;
1214
+ if (exception.code !== "ENOENT") throw exception;
1215
+ }
1216
+ /** @type {PackageConfig} */
1217
+ const result = {
1218
+ exists: false,
1219
+ pjsonPath: jsonPath,
1220
+ main: void 0,
1221
+ name: void 0,
1222
+ type: "none",
1223
+ exports: void 0,
1224
+ imports: void 0
1225
+ };
1226
+ if (string !== void 0) {
1227
+ /** @type {Record<string, unknown>} */
1228
+ let parsed;
1229
+ try {
1230
+ parsed = JSON.parse(string);
1231
+ } catch (error_) {
1232
+ const cause = error_;
1233
+ const error = new ERR_INVALID_PACKAGE_CONFIG$1(jsonPath, (base ? `"${specifier}" from ` : "") + (0, node_url.fileURLToPath)(base || specifier), cause.message);
1234
+ error.cause = cause;
1235
+ throw error;
1236
+ }
1237
+ result.exists = true;
1238
+ if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") result.name = parsed.name;
1239
+ if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") result.main = parsed.main;
1240
+ if (hasOwnProperty$1.call(parsed, "exports")) result.exports = parsed.exports;
1241
+ if (hasOwnProperty$1.call(parsed, "imports")) result.imports = parsed.imports;
1242
+ if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) result.type = parsed.type;
1243
+ }
1244
+ cache.set(jsonPath, result);
1245
+ return result;
1246
+ }
1247
+ /**
1248
+ * @param {URL | string} resolved
1249
+ * @returns {PackageConfig}
1250
+ */
1251
+ function getPackageScopeConfig(resolved) {
1252
+ let packageJSONUrl = new URL("package.json", resolved);
1253
+ while (true) {
1254
+ if (packageJSONUrl.pathname.endsWith("node_modules/package.json")) break;
1255
+ const packageConfig = read((0, node_url.fileURLToPath)(packageJSONUrl), { specifier: resolved });
1256
+ if (packageConfig.exists) return packageConfig;
1257
+ const lastPackageJSONUrl = packageJSONUrl;
1258
+ packageJSONUrl = new URL("../package.json", packageJSONUrl);
1259
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
1260
+ }
1261
+ return {
1262
+ pjsonPath: (0, node_url.fileURLToPath)(packageJSONUrl),
1263
+ exists: false,
1264
+ type: "none"
1265
+ };
1266
+ }
1267
+ /**
1268
+ * Returns the package type for a given URL.
1269
+ * @param {URL} url - The URL to get the package type for.
1270
+ * @returns {PackageType}
1271
+ */
1272
+ function getPackageType(url) {
1273
+ return getPackageScopeConfig(url).type;
1274
+ }
1275
+ //#endregion
1276
+ //#region ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/get-format.js
1277
+ const { ERR_UNKNOWN_FILE_EXTENSION } = codes;
1278
+ const hasOwnProperty = {}.hasOwnProperty;
1279
+ /** @type {Record<string, string>} */
1280
+ const extensionFormatMap = {
1281
+ __proto__: null,
1282
+ ".cjs": "commonjs",
1283
+ ".js": "module",
1284
+ ".json": "json",
1285
+ ".mjs": "module"
1286
+ };
1287
+ /**
1288
+ * @param {string | null} mime
1289
+ * @returns {string | null}
1290
+ */
1291
+ function mimeToFormat(mime) {
1292
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return "module";
1293
+ if (mime === "application/json") return "json";
1294
+ return null;
1295
+ }
1296
+ /**
1297
+ * @callback ProtocolHandler
1298
+ * @param {URL} parsed
1299
+ * @param {{parentURL: string, source?: Buffer}} context
1300
+ * @param {boolean} ignoreErrors
1301
+ * @returns {string | null | void}
1302
+ */
1303
+ /**
1304
+ * @type {Record<string, ProtocolHandler>}
1305
+ */
1306
+ const protocolHandlers = {
1307
+ __proto__: null,
1308
+ "data:": getDataProtocolModuleFormat,
1309
+ "file:": getFileProtocolModuleFormat,
1310
+ "http:": getHttpProtocolModuleFormat,
1311
+ "https:": getHttpProtocolModuleFormat,
1312
+ "node:"() {
1313
+ return "builtin";
1314
+ }
1315
+ };
1316
+ /**
1317
+ * @param {URL} parsed
1318
+ */
1319
+ function getDataProtocolModuleFormat(parsed) {
1320
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
1321
+ null,
1322
+ null,
1323
+ null
1324
+ ];
1325
+ return mimeToFormat(mime);
1326
+ }
1327
+ /**
1328
+ * Returns the file extension from a URL.
1329
+ *
1330
+ * Should give similar result to
1331
+ * `require('node:path').extname(require('node:url').fileURLToPath(url))`
1332
+ * when used with a `file:` URL.
1333
+ *
1334
+ * @param {URL} url
1335
+ * @returns {string}
1336
+ */
1337
+ function extname(url) {
1338
+ const pathname = url.pathname;
1339
+ let index = pathname.length;
1340
+ while (index--) {
1341
+ const code = pathname.codePointAt(index);
1342
+ if (code === 47) return "";
1343
+ if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
1344
+ }
1345
+ return "";
1346
+ }
1347
+ /**
1348
+ * @type {ProtocolHandler}
1349
+ */
1350
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
1351
+ const value = extname(url);
1352
+ if (value === ".js") {
1353
+ const packageType = getPackageType(url);
1354
+ if (packageType !== "none") return packageType;
1355
+ return "commonjs";
1356
+ }
1357
+ if (value === "") {
1358
+ const packageType = getPackageType(url);
1359
+ if (packageType === "none" || packageType === "commonjs") return "commonjs";
1360
+ return "module";
1361
+ }
1362
+ const format = extensionFormatMap[value];
1363
+ if (format) return format;
1364
+ if (ignoreErrors) return;
1365
+ throw new ERR_UNKNOWN_FILE_EXTENSION(value, (0, node_url.fileURLToPath)(url));
1366
+ }
1367
+ function getHttpProtocolModuleFormat() {}
1368
+ /**
1369
+ * @param {URL} url
1370
+ * @param {{parentURL: string}} context
1371
+ * @returns {string | null}
1372
+ */
1373
+ function defaultGetFormatWithoutErrors(url, context) {
1374
+ const protocol = url.protocol;
1375
+ if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
1376
+ return protocolHandlers[protocol](url, context, true) || null;
1377
+ }
1378
+ //#endregion
1379
+ //#region ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/utils.js
1380
+ const { ERR_INVALID_ARG_VALUE } = codes;
1381
+ const DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
1382
+ const DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
1383
+ /**
1384
+ * Returns the default conditions for ES module loading.
1385
+ */
1386
+ function getDefaultConditions() {
1387
+ return DEFAULT_CONDITIONS;
1388
+ }
1389
+ /**
1390
+ * Returns the default conditions for ES module loading, as a Set.
1391
+ */
1392
+ function getDefaultConditionsSet() {
1393
+ return DEFAULT_CONDITIONS_SET;
1394
+ }
1395
+ /**
1396
+ * @param {Array<string>} [conditions]
1397
+ * @returns {Set<string>}
1398
+ */
1399
+ function getConditionsSet(conditions) {
1400
+ if (conditions !== void 0 && conditions !== getDefaultConditions()) {
1401
+ if (!Array.isArray(conditions)) throw new ERR_INVALID_ARG_VALUE("conditions", conditions, "expected an array");
1402
+ return new Set(conditions);
1403
+ }
1404
+ return getDefaultConditionsSet();
1405
+ }
1406
+ //#endregion
1407
+ //#region ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/resolve.js
1408
+ /**
1409
+ * @import {Stats} from 'node:fs'
1410
+ * @import {ErrnoException} from './errors.js'
1411
+ * @import {PackageConfig} from './package-json-reader.js'
1412
+ */
1413
+ const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
1414
+ const { ERR_NETWORK_IMPORT_DISALLOWED, ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_PACKAGE_CONFIG, ERR_INVALID_PACKAGE_TARGET, ERR_MODULE_NOT_FOUND, ERR_PACKAGE_IMPORT_NOT_DEFINED, ERR_PACKAGE_PATH_NOT_EXPORTED, ERR_UNSUPPORTED_DIR_IMPORT, ERR_UNSUPPORTED_RESOLVE_REQUEST } = codes;
1415
+ const own = {}.hasOwnProperty;
1416
+ const invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
1417
+ const deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
1418
+ const invalidPackageNameRegEx = /^\.|%|\\/;
1419
+ const patternRegEx = /\*/g;
1420
+ const encodedSeparatorRegEx = /%2f|%5c/i;
1421
+ /** @type {Set<string>} */
1422
+ const emittedPackageWarnings = /* @__PURE__ */ new Set();
1423
+ const doubleSlashRegEx = /[/\\]{2}/;
1424
+ /**
1425
+ *
1426
+ * @param {string} target
1427
+ * @param {string} request
1428
+ * @param {string} match
1429
+ * @param {URL} packageJsonUrl
1430
+ * @param {boolean} internal
1431
+ * @param {URL} base
1432
+ * @param {boolean} isTarget
1433
+ */
1434
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
1435
+ if (node_process.default.noDeprecation) return;
1436
+ const pjsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
1437
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
1438
+ node_process.default.emitWarning(`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, node_url.fileURLToPath)(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
1439
+ }
1440
+ /**
1441
+ * @param {URL} url
1442
+ * @param {URL} packageJsonUrl
1443
+ * @param {URL} base
1444
+ * @param {string} [main]
1445
+ * @returns {void}
1446
+ */
1447
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
1448
+ if (node_process.default.noDeprecation) return;
1449
+ if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
1450
+ const urlPath = (0, node_url.fileURLToPath)(url.href);
1451
+ const packagePath = (0, node_url.fileURLToPath)(new URL(".", packageJsonUrl));
1452
+ const basePath = (0, node_url.fileURLToPath)(base);
1453
+ if (!main) node_process.default.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
1454
+ else if (node_path.default.resolve(packagePath, main) !== urlPath) node_process.default.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
1455
+ }
1456
+ /**
1457
+ * @param {string} path
1458
+ * @returns {Stats | undefined}
1459
+ */
1460
+ function tryStatSync(path) {
1461
+ try {
1462
+ return (0, node_fs.statSync)(path);
1463
+ } catch {}
1464
+ }
1465
+ /**
1466
+ * Legacy CommonJS main resolution:
1467
+ * 1. let M = pkg_url + (json main field)
1468
+ * 2. TRY(M, M.js, M.json, M.node)
1469
+ * 3. TRY(M/index.js, M/index.json, M/index.node)
1470
+ * 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node)
1471
+ * 5. NOT_FOUND
1472
+ *
1473
+ * @param {URL} url
1474
+ * @returns {boolean}
1475
+ */
1476
+ function fileExists(url) {
1477
+ const stats = (0, node_fs.statSync)(url, { throwIfNoEntry: false });
1478
+ const isFile = stats ? stats.isFile() : void 0;
1479
+ return isFile === null || isFile === void 0 ? false : isFile;
1480
+ }
1481
+ /**
1482
+ * @param {URL} packageJsonUrl
1483
+ * @param {PackageConfig} packageConfig
1484
+ * @param {URL} base
1485
+ * @returns {URL}
1486
+ */
1487
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
1488
+ /** @type {URL | undefined} */
1489
+ let guess;
1490
+ if (packageConfig.main !== void 0) {
1491
+ guess = new URL(packageConfig.main, packageJsonUrl);
1492
+ if (fileExists(guess)) return guess;
1493
+ const tries = [
1494
+ `./${packageConfig.main}.js`,
1495
+ `./${packageConfig.main}.json`,
1496
+ `./${packageConfig.main}.node`,
1497
+ `./${packageConfig.main}/index.js`,
1498
+ `./${packageConfig.main}/index.json`,
1499
+ `./${packageConfig.main}/index.node`
1500
+ ];
1501
+ let i = -1;
1502
+ while (++i < tries.length) {
1503
+ guess = new URL(tries[i], packageJsonUrl);
1504
+ if (fileExists(guess)) break;
1505
+ guess = void 0;
1506
+ }
1507
+ if (guess) {
1508
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
1509
+ return guess;
1510
+ }
1511
+ }
1512
+ const tries = [
1513
+ "./index.js",
1514
+ "./index.json",
1515
+ "./index.node"
1516
+ ];
1517
+ let i = -1;
1518
+ while (++i < tries.length) {
1519
+ guess = new URL(tries[i], packageJsonUrl);
1520
+ if (fileExists(guess)) break;
1521
+ guess = void 0;
1522
+ }
1523
+ if (guess) {
1524
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
1525
+ return guess;
1526
+ }
1527
+ throw new ERR_MODULE_NOT_FOUND((0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
1528
+ }
1529
+ /**
1530
+ * @param {URL} resolved
1531
+ * @param {URL} base
1532
+ * @param {boolean} [preserveSymlinks]
1533
+ * @returns {URL}
1534
+ */
1535
+ function finalizeResolution(resolved, base, preserveSymlinks) {
1536
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, "must not include encoded \"/\" or \"\\\" characters", (0, node_url.fileURLToPath)(base));
1537
+ /** @type {string} */
1538
+ let filePath;
1539
+ try {
1540
+ filePath = (0, node_url.fileURLToPath)(resolved);
1541
+ } catch (error) {
1542
+ const cause = error;
1543
+ Object.defineProperty(cause, "input", { value: String(resolved) });
1544
+ Object.defineProperty(cause, "module", { value: String(base) });
1545
+ throw cause;
1546
+ }
1547
+ const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
1548
+ if (stats && stats.isDirectory()) {
1549
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, (0, node_url.fileURLToPath)(base));
1550
+ error.url = String(resolved);
1551
+ throw error;
1552
+ }
1553
+ if (!stats || !stats.isFile()) {
1554
+ const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && (0, node_url.fileURLToPath)(base), true);
1555
+ error.url = String(resolved);
1556
+ throw error;
1557
+ }
1558
+ if (!preserveSymlinks) {
1559
+ const real = (0, node_fs.realpathSync)(filePath);
1560
+ const { search, hash } = resolved;
1561
+ resolved = (0, node_url.pathToFileURL)(real + (filePath.endsWith(node_path.default.sep) ? "/" : ""));
1562
+ resolved.search = search;
1563
+ resolved.hash = hash;
1564
+ }
1565
+ return resolved;
1566
+ }
1567
+ /**
1568
+ * @param {string} specifier
1569
+ * @param {URL | undefined} packageJsonUrl
1570
+ * @param {URL} base
1571
+ * @returns {Error}
1572
+ */
1573
+ function importNotDefined(specifier, packageJsonUrl, base) {
1574
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && (0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
1575
+ }
1576
+ /**
1577
+ * @param {string} subpath
1578
+ * @param {URL} packageJsonUrl
1579
+ * @param {URL} base
1580
+ * @returns {Error}
1581
+ */
1582
+ function exportsNotFound(subpath, packageJsonUrl, base) {
1583
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED((0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), subpath, base && (0, node_url.fileURLToPath)(base));
1584
+ }
1585
+ /**
1586
+ * @param {string} request
1587
+ * @param {string} match
1588
+ * @param {URL} packageJsonUrl
1589
+ * @param {boolean} internal
1590
+ * @param {URL} [base]
1591
+ * @returns {never}
1592
+ */
1593
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
1594
+ throw new ERR_INVALID_MODULE_SPECIFIER(request, `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${(0, node_url.fileURLToPath)(packageJsonUrl)}`, base && (0, node_url.fileURLToPath)(base));
1595
+ }
1596
+ /**
1597
+ * @param {string} subpath
1598
+ * @param {unknown} target
1599
+ * @param {URL} packageJsonUrl
1600
+ * @param {boolean} internal
1601
+ * @param {URL} [base]
1602
+ * @returns {Error}
1603
+ */
1604
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
1605
+ target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
1606
+ return new ERR_INVALID_PACKAGE_TARGET((0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), subpath, target, internal, base && (0, node_url.fileURLToPath)(base));
1607
+ }
1608
+ /**
1609
+ * @param {string} target
1610
+ * @param {string} subpath
1611
+ * @param {string} match
1612
+ * @param {URL} packageJsonUrl
1613
+ * @param {URL} base
1614
+ * @param {boolean} pattern
1615
+ * @param {boolean} internal
1616
+ * @param {boolean} isPathMap
1617
+ * @param {Set<string> | undefined} conditions
1618
+ * @returns {URL}
1619
+ */
1620
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
1621
+ if (subpath !== "" && !pattern && target[target.length - 1] !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
1622
+ if (!target.startsWith("./")) {
1623
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
1624
+ let isURL = false;
1625
+ try {
1626
+ new URL(target);
1627
+ isURL = true;
1628
+ } catch {}
1629
+ if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
1630
+ }
1631
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
1632
+ }
1633
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
1634
+ if (!isPathMap) {
1635
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
1636
+ emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, true);
1637
+ }
1638
+ } else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
1639
+ const resolved = new URL(target, packageJsonUrl);
1640
+ const resolvedPath = resolved.pathname;
1641
+ const packagePath = new URL(".", packageJsonUrl).pathname;
1642
+ if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
1643
+ if (subpath === "") return resolved;
1644
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
1645
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
1646
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
1647
+ if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, false);
1648
+ } else throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
1649
+ }
1650
+ if (pattern) return new URL(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
1651
+ return new URL(subpath, resolved);
1652
+ }
1653
+ /**
1654
+ * @param {string} key
1655
+ * @returns {boolean}
1656
+ */
1657
+ function isArrayIndex(key) {
1658
+ const keyNumber = Number(key);
1659
+ if (`${keyNumber}` !== key) return false;
1660
+ return keyNumber >= 0 && keyNumber < 4294967295;
1661
+ }
1662
+ /**
1663
+ * @param {URL} packageJsonUrl
1664
+ * @param {unknown} target
1665
+ * @param {string} subpath
1666
+ * @param {string} packageSubpath
1667
+ * @param {URL} base
1668
+ * @param {boolean} pattern
1669
+ * @param {boolean} internal
1670
+ * @param {boolean} isPathMap
1671
+ * @param {Set<string> | undefined} conditions
1672
+ * @returns {URL | null}
1673
+ */
1674
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
1675
+ if (typeof target === "string") return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
1676
+ if (Array.isArray(target)) {
1677
+ /** @type {Array<unknown>} */
1678
+ const targetList = target;
1679
+ if (targetList.length === 0) return null;
1680
+ /** @type {ErrnoException | null | undefined} */
1681
+ let lastException;
1682
+ let i = -1;
1683
+ while (++i < targetList.length) {
1684
+ const targetItem = targetList[i];
1685
+ /** @type {URL | null} */
1686
+ let resolveResult;
1687
+ try {
1688
+ resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
1689
+ } catch (error) {
1690
+ const exception = error;
1691
+ lastException = exception;
1692
+ if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
1693
+ throw error;
1694
+ }
1695
+ if (resolveResult === void 0) continue;
1696
+ if (resolveResult === null) {
1697
+ lastException = null;
1698
+ continue;
1699
+ }
1700
+ return resolveResult;
1701
+ }
1702
+ if (lastException === void 0 || lastException === null) return null;
1703
+ throw lastException;
1704
+ }
1705
+ if (typeof target === "object" && target !== null) {
1706
+ const keys = Object.getOwnPropertyNames(target);
1707
+ let i = -1;
1708
+ while (++i < keys.length) {
1709
+ const key = keys[i];
1710
+ if (isArrayIndex(key)) throw new ERR_INVALID_PACKAGE_CONFIG((0, node_url.fileURLToPath)(packageJsonUrl), base, "\"exports\" cannot contain numeric property keys.");
1711
+ }
1712
+ i = -1;
1713
+ while (++i < keys.length) {
1714
+ const key = keys[i];
1715
+ if (key === "default" || conditions && conditions.has(key)) {
1716
+ const conditionalTarget = target[key];
1717
+ const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
1718
+ if (resolveResult === void 0) continue;
1719
+ return resolveResult;
1720
+ }
1721
+ }
1722
+ return null;
1723
+ }
1724
+ if (target === null) return null;
1725
+ throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
1726
+ }
1727
+ /**
1728
+ * @param {unknown} exports
1729
+ * @param {URL} packageJsonUrl
1730
+ * @param {URL} base
1731
+ * @returns {boolean}
1732
+ */
1733
+ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
1734
+ if (typeof exports === "string" || Array.isArray(exports)) return true;
1735
+ if (typeof exports !== "object" || exports === null) return false;
1736
+ const keys = Object.getOwnPropertyNames(exports);
1737
+ let isConditionalSugar = false;
1738
+ let i = 0;
1739
+ let keyIndex = -1;
1740
+ while (++keyIndex < keys.length) {
1741
+ const key = keys[keyIndex];
1742
+ const currentIsConditionalSugar = key === "" || key[0] !== ".";
1743
+ if (i++ === 0) isConditionalSugar = currentIsConditionalSugar;
1744
+ else if (isConditionalSugar !== currentIsConditionalSugar) throw new ERR_INVALID_PACKAGE_CONFIG((0, node_url.fileURLToPath)(packageJsonUrl), base, "\"exports\" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.");
1745
+ }
1746
+ return isConditionalSugar;
1747
+ }
1748
+ /**
1749
+ * @param {string} match
1750
+ * @param {URL} pjsonUrl
1751
+ * @param {URL} base
1752
+ */
1753
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
1754
+ if (node_process.default.noDeprecation) return;
1755
+ const pjsonPath = (0, node_url.fileURLToPath)(pjsonUrl);
1756
+ if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
1757
+ emittedPackageWarnings.add(pjsonPath + "|" + match);
1758
+ node_process.default.emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, node_url.fileURLToPath)(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
1759
+ }
1760
+ /**
1761
+ * @param {URL} packageJsonUrl
1762
+ * @param {string} packageSubpath
1763
+ * @param {Record<string, unknown>} packageConfig
1764
+ * @param {URL} base
1765
+ * @param {Set<string> | undefined} conditions
1766
+ * @returns {URL}
1767
+ */
1768
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
1769
+ let exports = packageConfig.exports;
1770
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) exports = { ".": exports };
1771
+ if (own.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
1772
+ const target = exports[packageSubpath];
1773
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
1774
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
1775
+ return resolveResult;
1776
+ }
1777
+ let bestMatch = "";
1778
+ let bestMatchSubpath = "";
1779
+ const keys = Object.getOwnPropertyNames(exports);
1780
+ let i = -1;
1781
+ while (++i < keys.length) {
1782
+ const key = keys[i];
1783
+ const patternIndex = key.indexOf("*");
1784
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
1785
+ if (packageSubpath.endsWith("/")) emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
1786
+ const patternTrailer = key.slice(patternIndex + 1);
1787
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
1788
+ bestMatch = key;
1789
+ bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
1790
+ }
1791
+ }
1792
+ }
1793
+ if (bestMatch) {
1794
+ const target = exports[bestMatch];
1795
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
1796
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
1797
+ return resolveResult;
1798
+ }
1799
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
1800
+ }
1801
+ /**
1802
+ * @param {string} a
1803
+ * @param {string} b
1804
+ */
1805
+ function patternKeyCompare(a, b) {
1806
+ const aPatternIndex = a.indexOf("*");
1807
+ const bPatternIndex = b.indexOf("*");
1808
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
1809
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
1810
+ if (baseLengthA > baseLengthB) return -1;
1811
+ if (baseLengthB > baseLengthA) return 1;
1812
+ if (aPatternIndex === -1) return 1;
1813
+ if (bPatternIndex === -1) return -1;
1814
+ if (a.length > b.length) return -1;
1815
+ if (b.length > a.length) return 1;
1816
+ return 0;
1817
+ }
1818
+ /**
1819
+ * @param {string} name
1820
+ * @param {URL} base
1821
+ * @param {Set<string>} [conditions]
1822
+ * @returns {URL}
1823
+ */
1824
+ function packageImportsResolve(name, base, conditions) {
1825
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) throw new ERR_INVALID_MODULE_SPECIFIER(name, "is not a valid internal imports specifier name", (0, node_url.fileURLToPath)(base));
1826
+ /** @type {URL | undefined} */
1827
+ let packageJsonUrl;
1828
+ const packageConfig = getPackageScopeConfig(base);
1829
+ if (packageConfig.exists) {
1830
+ packageJsonUrl = (0, node_url.pathToFileURL)(packageConfig.pjsonPath);
1831
+ const imports = packageConfig.imports;
1832
+ if (imports) if (own.call(imports, name) && !name.includes("*")) {
1833
+ const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
1834
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
1835
+ } else {
1836
+ let bestMatch = "";
1837
+ let bestMatchSubpath = "";
1838
+ const keys = Object.getOwnPropertyNames(imports);
1839
+ let i = -1;
1840
+ while (++i < keys.length) {
1841
+ const key = keys[i];
1842
+ const patternIndex = key.indexOf("*");
1843
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
1844
+ const patternTrailer = key.slice(patternIndex + 1);
1845
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
1846
+ bestMatch = key;
1847
+ bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
1848
+ }
1849
+ }
1850
+ }
1851
+ if (bestMatch) {
1852
+ const target = imports[bestMatch];
1853
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
1854
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
1855
+ }
1856
+ }
1857
+ }
1858
+ throw importNotDefined(name, packageJsonUrl, base);
1859
+ }
1860
+ /**
1861
+ * @param {string} specifier
1862
+ * @param {URL} base
1863
+ */
1864
+ function parsePackageName(specifier, base) {
1865
+ let separatorIndex = specifier.indexOf("/");
1866
+ let validPackageName = true;
1867
+ let isScoped = false;
1868
+ if (specifier[0] === "@") {
1869
+ isScoped = true;
1870
+ if (separatorIndex === -1 || specifier.length === 0) validPackageName = false;
1871
+ else separatorIndex = specifier.indexOf("/", separatorIndex + 1);
1872
+ }
1873
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
1874
+ if (invalidPackageNameRegEx.exec(packageName) !== null) validPackageName = false;
1875
+ if (!validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", (0, node_url.fileURLToPath)(base));
1876
+ return {
1877
+ packageName,
1878
+ packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
1879
+ isScoped
1880
+ };
1881
+ }
1882
+ /**
1883
+ * @param {string} specifier
1884
+ * @param {URL} base
1885
+ * @param {Set<string> | undefined} conditions
1886
+ * @returns {URL}
1887
+ */
1888
+ function packageResolve(specifier, base, conditions) {
1889
+ if (node_module.builtinModules.includes(specifier)) return new URL("node:" + specifier);
1890
+ const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
1891
+ const packageConfig = getPackageScopeConfig(base);
1892
+ /* c8 ignore next 16 */
1893
+ if (packageConfig.exists) {
1894
+ const packageJsonUrl = (0, node_url.pathToFileURL)(packageConfig.pjsonPath);
1895
+ if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
1896
+ }
1897
+ let packageJsonUrl = new URL("./node_modules/" + packageName + "/package.json", base);
1898
+ let packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
1899
+ /** @type {string} */
1900
+ let lastPath;
1901
+ do {
1902
+ const stat = tryStatSync(packageJsonPath.slice(0, -13));
1903
+ if (!stat || !stat.isDirectory()) {
1904
+ lastPath = packageJsonPath;
1905
+ packageJsonUrl = new URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
1906
+ packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
1907
+ continue;
1908
+ }
1909
+ const packageConfig = read(packageJsonPath, {
1910
+ base,
1911
+ specifier
1912
+ });
1913
+ if (packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
1914
+ if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig, base);
1915
+ return new URL(packageSubpath, packageJsonUrl);
1916
+ } while (packageJsonPath.length !== lastPath.length);
1917
+ throw new ERR_MODULE_NOT_FOUND(packageName, (0, node_url.fileURLToPath)(base), false);
1918
+ }
1919
+ /**
1920
+ * @param {string} specifier
1921
+ * @returns {boolean}
1922
+ */
1923
+ function isRelativeSpecifier(specifier) {
1924
+ if (specifier[0] === ".") {
1925
+ if (specifier.length === 1 || specifier[1] === "/") return true;
1926
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) return true;
1927
+ }
1928
+ return false;
1929
+ }
1930
+ /**
1931
+ * @param {string} specifier
1932
+ * @returns {boolean}
1933
+ */
1934
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
1935
+ if (specifier === "") return false;
1936
+ if (specifier[0] === "/") return true;
1937
+ return isRelativeSpecifier(specifier);
1938
+ }
1939
+ /**
1940
+ * The “Resolver Algorithm Specification” as detailed in the Node docs (which is
1941
+ * sync and slightly lower-level than `resolve`).
1942
+ *
1943
+ * @param {string} specifier
1944
+ * `/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`, etc.
1945
+ * @param {URL} base
1946
+ * Full URL (to a file) that `specifier` is resolved relative from.
1947
+ * @param {Set<string>} [conditions]
1948
+ * Conditions.
1949
+ * @param {boolean} [preserveSymlinks]
1950
+ * Keep symlinks instead of resolving them.
1951
+ * @returns {URL}
1952
+ * A URL object to the found thing.
1953
+ */
1954
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1955
+ if (conditions === void 0) conditions = getConditionsSet();
1956
+ const protocol = base.protocol;
1957
+ const isRemote = protocol === "data:" || protocol === "http:" || protocol === "https:";
1958
+ /** @type {URL | undefined} */
1959
+ let resolved;
1960
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
1961
+ resolved = new URL(specifier, base);
1962
+ } catch (error_) {
1963
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1964
+ error.cause = error_;
1965
+ throw error;
1966
+ }
1967
+ else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
1968
+ else try {
1969
+ resolved = new URL(specifier);
1970
+ } catch (error_) {
1971
+ if (isRemote && !node_module.builtinModules.includes(specifier)) {
1972
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1973
+ error.cause = error_;
1974
+ throw error;
1975
+ }
1976
+ resolved = packageResolve(specifier, base, conditions);
1977
+ }
1978
+ node_assert.default.ok(resolved !== void 0, "expected to be defined");
1979
+ if (resolved.protocol !== "file:") return resolved;
1980
+ return finalizeResolution(resolved, base, preserveSymlinks);
1981
+ }
1982
+ /**
1983
+ * @param {string} specifier
1984
+ * @param {URL | undefined} parsed
1985
+ * @param {URL | undefined} parsedParentURL
1986
+ */
1987
+ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
1988
+ if (parsedParentURL) {
1989
+ const parentProtocol = parsedParentURL.protocol;
1990
+ if (parentProtocol === "http:" || parentProtocol === "https:") {
1991
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
1992
+ const parsedProtocol = parsed?.protocol;
1993
+ if (parsedProtocol && parsedProtocol !== "https:" && parsedProtocol !== "http:") throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, "remote imports cannot import from a local location.");
1994
+ return { url: parsed?.href || "" };
1995
+ }
1996
+ if (node_module.builtinModules.includes(specifier)) throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, "remote imports cannot import from a local location.");
1997
+ throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, "only relative and absolute specifiers are supported.");
1998
+ }
1999
+ }
2000
+ }
2001
+ /**
2002
+ * Checks if a value has the shape of a WHATWG URL object.
2003
+ *
2004
+ * Using a symbol or instanceof would not be able to recognize URL objects
2005
+ * coming from other implementations (e.g. in Electron), so instead we are
2006
+ * checking some well known properties for a lack of a better test.
2007
+ *
2008
+ * We use `href` and `protocol` as they are the only properties that are
2009
+ * easy to retrieve and calculate due to the lazy nature of the getters.
2010
+ *
2011
+ * @template {unknown} Value
2012
+ * @param {Value} self
2013
+ * @returns {Value is URL}
2014
+ */
2015
+ function isURL(self) {
2016
+ return Boolean(self && typeof self === "object" && "href" in self && typeof self.href === "string" && "protocol" in self && typeof self.protocol === "string" && self.href && self.protocol);
2017
+ }
2018
+ /**
2019
+ * Validate user-input in `context` supplied by a custom loader.
2020
+ *
2021
+ * @param {unknown} parentURL
2022
+ * @returns {asserts parentURL is URL | string | undefined}
2023
+ */
2024
+ function throwIfInvalidParentURL(parentURL) {
2025
+ if (parentURL === void 0) return;
2026
+ if (typeof parentURL !== "string" && !isURL(parentURL)) throw new codes.ERR_INVALID_ARG_TYPE("parentURL", ["string", "URL"], parentURL);
2027
+ }
2028
+ /**
2029
+ * @param {string} specifier
2030
+ * @param {{parentURL?: string, conditions?: Array<string>}} context
2031
+ * @returns {{url: string, format?: string | null}}
2032
+ */
2033
+ function defaultResolve(specifier, context = {}) {
2034
+ const { parentURL } = context;
2035
+ node_assert.default.ok(parentURL !== void 0, "expected `parentURL` to be defined");
2036
+ throwIfInvalidParentURL(parentURL);
2037
+ /** @type {URL | undefined} */
2038
+ let parsedParentURL;
2039
+ if (parentURL) try {
2040
+ parsedParentURL = new URL(parentURL);
2041
+ } catch {}
2042
+ /** @type {URL | undefined} */
2043
+ let parsed;
2044
+ /** @type {string | undefined} */
2045
+ let protocol;
2046
+ try {
2047
+ parsed = shouldBeTreatedAsRelativeOrAbsolutePath(specifier) ? new URL(specifier, parsedParentURL) : new URL(specifier);
2048
+ protocol = parsed.protocol;
2049
+ if (protocol === "data:") return {
2050
+ url: parsed.href,
2051
+ format: null
2052
+ };
2053
+ } catch {}
2054
+ const maybeReturn = checkIfDisallowedImport(specifier, parsed, parsedParentURL);
2055
+ if (maybeReturn) return maybeReturn;
2056
+ if (protocol === void 0 && parsed) protocol = parsed.protocol;
2057
+ if (protocol === "node:") return { url: specifier };
2058
+ if (parsed && parsed.protocol === "node:") return { url: specifier };
2059
+ const conditions = getConditionsSet(context.conditions);
2060
+ const url = moduleResolve(specifier, new URL(parentURL), conditions, false);
2061
+ return {
2062
+ url: url.href,
2063
+ format: defaultGetFormatWithoutErrors(url, { parentURL })
2064
+ };
2065
+ }
2066
+ //#endregion
2067
+ //#region ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/index.js
2068
+ /**
2069
+ * @typedef {import('./lib/errors.js').ErrnoException} ErrnoException
2070
+ */
2071
+ /**
2072
+ * Match `import.meta.resolve` except that `parent` is required (you can pass
2073
+ * `import.meta.url`).
2074
+ *
2075
+ * @param {string} specifier
2076
+ * The module specifier to resolve relative to parent
2077
+ * (`/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`,
2078
+ * etc).
2079
+ * @param {string} parent
2080
+ * The absolute parent module URL to resolve from.
2081
+ * You must pass `import.meta.url` or something else.
2082
+ * @returns {string}
2083
+ * Returns a string to a full `file:`, `data:`, or `node:` URL
2084
+ * to the found thing.
2085
+ */
2086
+ function resolve(specifier, parent) {
2087
+ if (!parent) throw new Error("Please pass `parent`: `import-meta-resolve` cannot ponyfill that");
2088
+ try {
2089
+ return defaultResolve(specifier, { parentURL: parent }).url;
2090
+ } catch (error) {
2091
+ const exception = error;
2092
+ if ((exception.code === "ERR_UNSUPPORTED_DIR_IMPORT" || exception.code === "ERR_MODULE_NOT_FOUND") && typeof exception.url === "string") return exception.url;
2093
+ throw error;
2094
+ }
2095
+ }
2096
+ //#endregion
2097
+ //#region ../../node_modules/.pnpm/@iconify+utils@3.1.3/node_modules/@iconify/utils/lib/loader/resolve.js
2098
+ /**
2099
+ * Resolve path to package
2100
+ */
2101
+ async function resolvePathAsync(packageName, cwd) {
2102
+ if (!await pathExists(cwd)) return;
2103
+ if (!node_path.default.isAbsolute(cwd)) return;
2104
+ const parent = (0, node_url.pathToFileURL)(node_path.default.join(cwd, "_parent.mjs")).href;
2105
+ try {
2106
+ const resolvedPath = (0, node_url.fileURLToPath)(resolve(packageName, parent));
2107
+ if (await pathExists(resolvedPath)) return resolvedPath;
2108
+ } catch {}
2109
+ }
2110
+ async function pathExists(path) {
2111
+ try {
2112
+ await node_fs_promises.default.access(path);
2113
+ return true;
2114
+ } catch {
2115
+ return false;
2116
+ }
2117
+ }
2118
+ //#endregion
2119
+ //#region ../../node_modules/.pnpm/@iconify+utils@3.1.3/node_modules/@iconify/utils/lib/loader/fs.js
2120
+ const _collections = Object.create(null);
2121
+ /** Check if full package exists, per cwd value */
2122
+ const isLegacyExists = Object.create(null);
2123
+ /**
2124
+ * Asynchronously loads a collection from the file system.
2125
+ *
2126
+ * @param name {string} the name of the collection, e.g. 'mdi'
2127
+ * @param autoInstall {AutoInstall} [autoInstall=false] - whether to automatically install
2128
+ * @param scope {string} [scope='@iconify-json'] - the scope of the collection, e.g. '@my-company-json'
2129
+ * @param cwd {string} [cwd=process.cwd()] - current working directory for caching
2130
+ * @return {Promise<IconifyJSON | undefined>} the loaded IconifyJSON or undefined
2131
+ */
2132
+ async function loadCollectionFromFS(name, autoInstall = false, scope = "@iconify-json", cwd = process.cwd()) {
2133
+ const cache = _collections[cwd] || (_collections[cwd] = Object.create(null));
2134
+ if (!await cache[name]) cache[name] = task();
2135
+ return cache[name];
2136
+ async function task() {
2137
+ const packageName = scope.length === 0 ? name : `${scope}/${name}`;
2138
+ let jsonPath = await resolvePathAsync(`${packageName}/icons.json`, cwd);
2139
+ if (scope === "@iconify-json") {
2140
+ if (isLegacyExists[cwd] === void 0) isLegacyExists[cwd] = !!await resolvePathAsync(`@iconify/json/collections.json`, cwd);
2141
+ const checkLegacy = isLegacyExists[cwd];
2142
+ if (!jsonPath && checkLegacy) jsonPath = await resolvePathAsync(`@iconify/json/json/${name}.json`, cwd);
2143
+ if (!jsonPath && !checkLegacy && autoInstall) {
2144
+ await tryInstallPkg(packageName, autoInstall);
2145
+ jsonPath = await resolvePathAsync(`${packageName}/icons.json`, cwd);
2146
+ }
2147
+ } else if (!jsonPath && autoInstall) {
2148
+ await tryInstallPkg(packageName, autoInstall);
2149
+ jsonPath = await resolvePathAsync(`${packageName}/icons.json`, cwd);
2150
+ }
2151
+ if (!jsonPath) {
2152
+ const packagePath = await resolvePathAsync(packageName, cwd);
2153
+ if (packagePath) {
2154
+ const { icons } = await import((0, node_url.pathToFileURL)(packagePath).href);
2155
+ if (icons) return icons;
2156
+ }
2157
+ }
2158
+ let stat;
2159
+ try {
2160
+ stat = jsonPath ? await fs.promises.lstat(jsonPath) : void 0;
2161
+ } catch (err) {
2162
+ return;
2163
+ }
2164
+ if (stat?.isFile()) return JSON.parse(await fs.promises.readFile(jsonPath, "utf8"));
2165
+ else return;
2166
+ }
2167
+ }
2168
+ //#endregion
2169
+ //#region ../../node_modules/.pnpm/@iconify+utils@3.1.3/node_modules/@iconify/utils/lib/loader/node-loader.js
2170
+ const loadNodeIcon = async (collection, icon, options) => {
2171
+ let result = await require_server.loadIcon(collection, icon, options);
2172
+ if (result) return result;
2173
+ const cwds = Array.isArray(options?.cwd) ? options.cwd : [options?.cwd];
2174
+ for (let i = 0; i < cwds.length; i++) {
2175
+ const iconSet = await loadCollectionFromFS(collection, i === cwds.length - 1 ? options?.autoInstall : false, void 0, cwds[i]);
2176
+ if (iconSet) {
2177
+ result = await require_server.searchForIcon(iconSet, collection, require_server.getPossibleIconNames(icon), options);
2178
+ if (result) return result;
2179
+ }
2180
+ }
2181
+ if (options?.warn) warnOnce(`failed to load ${options.warn} icon`);
2182
+ };
2183
+ //#endregion
2184
+ exports.loadNodeIcon = loadNodeIcon;