@unocss/language-server 66.6.8 → 66.7.0

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