@mgdis/core-ui-helpers 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/.turbo/turbo-build.log +16 -16
  2. package/CHANGELOG.md +18 -0
  3. package/dist/playwright/index.cjs +11 -5
  4. package/dist/playwright/index.cjs.map +1 -1
  5. package/dist/playwright/index.d.ts +7 -3
  6. package/dist/playwright/index.js +11 -5
  7. package/dist/playwright/index.js.map +1 -1
  8. package/dist/playwright/index.umd.js +11 -5
  9. package/dist/playwright/index.umd.js.map +1 -1
  10. package/dist/stencil/index.cjs +153 -1682
  11. package/dist/stencil/index.cjs.map +1 -1
  12. package/dist/stencil/index.d.ts +113 -2
  13. package/dist/stencil/index.js +152 -1683
  14. package/dist/stencil/index.js.map +1 -1
  15. package/dist/stencil/index.umd.js +352 -1881
  16. package/dist/stencil/index.umd.js.map +1 -1
  17. package/dist/storybook/index.cjs +168 -1705
  18. package/dist/storybook/index.cjs.map +1 -1
  19. package/dist/storybook/index.js +168 -1705
  20. package/dist/storybook/index.js.map +1 -1
  21. package/dist/storybook/index.umd.js +168 -1705
  22. package/dist/storybook/index.umd.js.map +1 -1
  23. package/json-doc.test.json +13 -2
  24. package/package.json +12 -12
  25. package/src/playwright/utils/__snapshots__/utils.spec.ts.snap +3 -3
  26. package/src/playwright/utils/utils.ts +10 -5
  27. package/src/stencil/ide/__snapshots__/cem.spec.ts.snap +248 -0
  28. package/src/stencil/ide/__snapshots__/ide.spec.ts.snap +11 -124
  29. package/src/stencil/ide/cem.spec.ts +35 -0
  30. package/src/stencil/ide/cem.ts +96 -0
  31. package/src/stencil/ide/ide.ts +33 -26
  32. package/src/stencil/ide/index.ts +1 -0
  33. package/src/stencil/index.ts +1 -0
  34. package/src/stencil/normalize-boolean-attributes/index.ts +1 -0
  35. package/src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.spec.ts +63 -0
  36. package/src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.ts +40 -0
  37. package/src/storybook/stencil/__snapshots__/stencil.spec.ts.snap +1 -1
@@ -3,264 +3,24 @@
3
3
  // src/app-data/index.ts
4
4
  var BUILD = {
5
5
  updatable: true,
6
- slotRelocation: true,
7
- // TODO(STENCIL-914): remove this option when `experimentalSlotFixes` is the default behavior
8
- experimentalSlotFixes: false
9
- };
6
+ slotRelocation: true};
10
7
 
11
8
  /*
12
- Stencil Client Platform v4.40.1 | MIT Licensed | https://stenciljs.com
9
+ Stencil Client Platform v4.43.5 | MIT Licensed | https://stenciljs.com
13
10
  */
14
- var __create = Object.create;
15
- var __defProp = Object.defineProperty;
16
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
17
- var __getOwnPropNames = Object.getOwnPropertyNames;
18
- var __getProtoOf = Object.getPrototypeOf;
19
- var __hasOwnProp = Object.prototype.hasOwnProperty;
20
- var __typeError = (msg) => {
21
- throw TypeError(msg);
22
- };
23
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
24
- var __commonJS = (cb, mod) => function __require() {
25
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
26
- };
27
- var __export = (target, all) => {
28
- for (var name in all)
29
- __defProp(target, name, { get: all[name], enumerable: true });
30
- };
31
- var __copyProps = (to, from, except, desc) => {
32
- if (from && typeof from === "object" || typeof from === "function") {
33
- for (let key of __getOwnPropNames(from))
34
- if (!__hasOwnProp.call(to, key) && key !== except)
35
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
36
- }
37
- return to;
38
- };
39
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
40
- // If the importer is in node compatibility mode or this is not an ESM
41
- // file that has been converted to a CommonJS file using a Babel-
42
- // compatible transform (i.e. "__esModule" has not been set), then set
43
- // "default" to the CommonJS "module.exports" for node compatibility.
44
- __defProp(target, "default", { value: mod, enumerable: true }) ,
45
- mod
46
- ));
47
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
48
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
49
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
50
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
51
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
52
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
53
-
54
- // node_modules/balanced-match/index.js
55
- var require_balanced_match = __commonJS({
56
- "node_modules/balanced-match/index.js"(exports$1, module) {
57
- module.exports = balanced;
58
- function balanced(a, b, str) {
59
- if (a instanceof RegExp) a = maybeMatch(a, str);
60
- if (b instanceof RegExp) b = maybeMatch(b, str);
61
- var r = range(a, b, str);
62
- return r && {
63
- start: r[0],
64
- end: r[1],
65
- pre: str.slice(0, r[0]),
66
- body: str.slice(r[0] + a.length, r[1]),
67
- post: str.slice(r[1] + b.length)
68
- };
69
- }
70
- function maybeMatch(reg, str) {
71
- var m = str.match(reg);
72
- return m ? m[0] : null;
73
- }
74
- balanced.range = range;
75
- function range(a, b, str) {
76
- var begs, beg, left, right, result;
77
- var ai = str.indexOf(a);
78
- var bi = str.indexOf(b, ai + 1);
79
- var i2 = ai;
80
- if (ai >= 0 && bi > 0) {
81
- if (a === b) {
82
- return [ai, bi];
83
- }
84
- begs = [];
85
- left = str.length;
86
- while (i2 >= 0 && !result) {
87
- if (i2 == ai) {
88
- begs.push(i2);
89
- ai = str.indexOf(a, i2 + 1);
90
- } else if (begs.length == 1) {
91
- result = [begs.pop(), bi];
92
- } else {
93
- beg = begs.pop();
94
- if (beg < left) {
95
- left = beg;
96
- right = bi;
97
- }
98
- bi = str.indexOf(b, i2 + 1);
99
- }
100
- i2 = ai < bi && ai >= 0 ? ai : bi;
101
- }
102
- if (begs.length) {
103
- result = [left, right];
104
- }
105
- }
106
- return result;
107
- }
108
- }
109
- });
110
-
111
- // node_modules/brace-expansion/index.js
112
- var require_brace_expansion = __commonJS({
113
- "node_modules/brace-expansion/index.js"(exports$1, module) {
114
- var balanced = require_balanced_match();
115
- module.exports = expandTop;
116
- var escSlash = "\0SLASH" + Math.random() + "\0";
117
- var escOpen = "\0OPEN" + Math.random() + "\0";
118
- var escClose = "\0CLOSE" + Math.random() + "\0";
119
- var escComma = "\0COMMA" + Math.random() + "\0";
120
- var escPeriod = "\0PERIOD" + Math.random() + "\0";
121
- function numeric(str) {
122
- return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
123
- }
124
- function escapeBraces(str) {
125
- return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
126
- }
127
- function unescapeBraces(str) {
128
- return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
129
- }
130
- function parseCommaParts(str) {
131
- if (!str)
132
- return [""];
133
- var parts = [];
134
- var m = balanced("{", "}", str);
135
- if (!m)
136
- return str.split(",");
137
- var pre = m.pre;
138
- var body = m.body;
139
- var post = m.post;
140
- var p = pre.split(",");
141
- p[p.length - 1] += "{" + body + "}";
142
- var postParts = parseCommaParts(post);
143
- if (post.length) {
144
- p[p.length - 1] += postParts.shift();
145
- p.push.apply(p, postParts);
146
- }
147
- parts.push.apply(parts, p);
148
- return parts;
149
- }
150
- function expandTop(str) {
151
- if (!str)
152
- return [];
153
- if (str.substr(0, 2) === "{}") {
154
- str = "\\{\\}" + str.substr(2);
155
- }
156
- return expand2(escapeBraces(str), true).map(unescapeBraces);
157
- }
158
- function embrace(str) {
159
- return "{" + str + "}";
160
- }
161
- function isPadded(el) {
162
- return /^-?0\d/.test(el);
163
- }
164
- function lte(i2, y) {
165
- return i2 <= y;
166
- }
167
- function gte(i2, y) {
168
- return i2 >= y;
169
- }
170
- function expand2(str, isTop) {
171
- var expansions = [];
172
- var m = balanced("{", "}", str);
173
- if (!m) return [str];
174
- var pre = m.pre;
175
- var post = m.post.length ? expand2(m.post, false) : [""];
176
- if (/\$$/.test(m.pre)) {
177
- for (var k = 0; k < post.length; k++) {
178
- var expansion = pre + "{" + m.body + "}" + post[k];
179
- expansions.push(expansion);
180
- }
181
- } else {
182
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
183
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
184
- var isSequence = isNumericSequence || isAlphaSequence;
185
- var isOptions = m.body.indexOf(",") >= 0;
186
- if (!isSequence && !isOptions) {
187
- if (m.post.match(/,(?!,).*\}/)) {
188
- str = m.pre + "{" + m.body + escClose + m.post;
189
- return expand2(str);
190
- }
191
- return [str];
192
- }
193
- var n;
194
- if (isSequence) {
195
- n = m.body.split(/\.\./);
196
- } else {
197
- n = parseCommaParts(m.body);
198
- if (n.length === 1) {
199
- n = expand2(n[0], false).map(embrace);
200
- if (n.length === 1) {
201
- return post.map(function(p) {
202
- return m.pre + n[0] + p;
203
- });
204
- }
205
- }
206
- }
207
- var N;
208
- if (isSequence) {
209
- var x = numeric(n[0]);
210
- var y = numeric(n[1]);
211
- var width = Math.max(n[0].length, n[1].length);
212
- var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
213
- var test = lte;
214
- var reverse = y < x;
215
- if (reverse) {
216
- incr *= -1;
217
- test = gte;
218
- }
219
- var pad = n.some(isPadded);
220
- N = [];
221
- for (var i2 = x; test(i2, y); i2 += incr) {
222
- var c;
223
- if (isAlphaSequence) {
224
- c = String.fromCharCode(i2);
225
- if (c === "\\")
226
- c = "";
227
- } else {
228
- c = String(i2);
229
- if (pad) {
230
- var need = width - c.length;
231
- if (need > 0) {
232
- var z = new Array(need + 1).join("0");
233
- if (i2 < 0)
234
- c = "-" + z + c.slice(1);
235
- else
236
- c = z + c;
237
- }
238
- }
239
- }
240
- N.push(c);
241
- }
242
- } else {
243
- N = [];
244
- for (var j = 0; j < n.length; j++) {
245
- N.push.apply(N, expand2(n[j], false));
246
- }
247
- }
248
- for (var j = 0; j < N.length; j++) {
249
- for (var k = 0; k < post.length; k++) {
250
- var expansion = pre + N[j] + post[k];
251
- if (!isTop || isSequence || expansion)
252
- expansions.push(expansion);
253
- }
254
- }
255
- }
256
- return expansions;
257
- }
258
- }
259
- });
11
+
260
12
 
261
13
  // src/utils/constants.ts
262
14
  var SVG_NS = "http://www.w3.org/2000/svg";
263
15
  var HTML_NS = "http://www.w3.org/1999/xhtml";
16
+
17
+ // src/client/client-host-ref.ts
18
+ var getHostRef = (ref) => {
19
+ if (ref.__stencil__getHostRef) {
20
+ return ref.__stencil__getHostRef();
21
+ }
22
+ return void 0;
23
+ };
264
24
  var isMemberInElement = (elm, memberName) => memberName in elm;
265
25
  var XLINK_NS = "http://www.w3.org/1999/xlink";
266
26
  var win = typeof window !== "undefined" ? window : {};
@@ -273,1420 +33,6 @@ var plt = {
273
33
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
274
34
  ce: (eventName, opts) => new CustomEvent(eventName, opts)
275
35
  };
276
-
277
- // src/utils/helpers.ts
278
- var isDef = (v) => v != null && v !== void 0;
279
- var isComplexType = (o) => {
280
- o = typeof o;
281
- return o === "object" || o === "function";
282
- };
283
-
284
- // node_modules/minimatch/dist/esm/index.js
285
- var import_brace_expansion = __toESM(require_brace_expansion());
286
-
287
- // node_modules/minimatch/dist/esm/assert-valid-pattern.js
288
- var MAX_PATTERN_LENGTH = 1024 * 64;
289
- var assertValidPattern = (pattern) => {
290
- if (typeof pattern !== "string") {
291
- throw new TypeError("invalid pattern");
292
- }
293
- if (pattern.length > MAX_PATTERN_LENGTH) {
294
- throw new TypeError("pattern is too long");
295
- }
296
- };
297
-
298
- // node_modules/minimatch/dist/esm/brace-expressions.js
299
- var posixClasses = {
300
- "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
301
- "[:alpha:]": ["\\p{L}\\p{Nl}", true],
302
- "[:ascii:]": ["\\x00-\\x7f", false],
303
- "[:blank:]": ["\\p{Zs}\\t", true],
304
- "[:cntrl:]": ["\\p{Cc}", true],
305
- "[:digit:]": ["\\p{Nd}", true],
306
- "[:graph:]": ["\\p{Z}\\p{C}", true, true],
307
- "[:lower:]": ["\\p{Ll}", true],
308
- "[:print:]": ["\\p{C}", true],
309
- "[:punct:]": ["\\p{P}", true],
310
- "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
311
- "[:upper:]": ["\\p{Lu}", true],
312
- "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
313
- "[:xdigit:]": ["A-Fa-f0-9", false]
314
- };
315
- var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
316
- var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
317
- var rangesToString = (ranges) => ranges.join("");
318
- var parseClass = (glob, position) => {
319
- const pos = position;
320
- if (glob.charAt(pos) !== "[") {
321
- throw new Error("not in a brace expression");
322
- }
323
- const ranges = [];
324
- const negs = [];
325
- let i2 = pos + 1;
326
- let sawStart = false;
327
- let uflag = false;
328
- let escaping = false;
329
- let negate = false;
330
- let endPos = pos;
331
- let rangeStart = "";
332
- WHILE: while (i2 < glob.length) {
333
- const c = glob.charAt(i2);
334
- if ((c === "!" || c === "^") && i2 === pos + 1) {
335
- negate = true;
336
- i2++;
337
- continue;
338
- }
339
- if (c === "]" && sawStart && !escaping) {
340
- endPos = i2 + 1;
341
- break;
342
- }
343
- sawStart = true;
344
- if (c === "\\") {
345
- if (!escaping) {
346
- escaping = true;
347
- i2++;
348
- continue;
349
- }
350
- }
351
- if (c === "[" && !escaping) {
352
- for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
353
- if (glob.startsWith(cls, i2)) {
354
- if (rangeStart) {
355
- return ["$.", false, glob.length - pos, true];
356
- }
357
- i2 += cls.length;
358
- if (neg)
359
- negs.push(unip);
360
- else
361
- ranges.push(unip);
362
- uflag = uflag || u;
363
- continue WHILE;
364
- }
365
- }
366
- }
367
- escaping = false;
368
- if (rangeStart) {
369
- if (c > rangeStart) {
370
- ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
371
- } else if (c === rangeStart) {
372
- ranges.push(braceEscape(c));
373
- }
374
- rangeStart = "";
375
- i2++;
376
- continue;
377
- }
378
- if (glob.startsWith("-]", i2 + 1)) {
379
- ranges.push(braceEscape(c + "-"));
380
- i2 += 2;
381
- continue;
382
- }
383
- if (glob.startsWith("-", i2 + 1)) {
384
- rangeStart = c;
385
- i2 += 2;
386
- continue;
387
- }
388
- ranges.push(braceEscape(c));
389
- i2++;
390
- }
391
- if (endPos < i2) {
392
- return ["", false, 0, false];
393
- }
394
- if (!ranges.length && !negs.length) {
395
- return ["$.", false, glob.length - pos, true];
396
- }
397
- if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
398
- const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
399
- return [regexpEscape(r), false, endPos - pos, false];
400
- }
401
- const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
402
- const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
403
- const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
404
- return [comb, uflag, endPos - pos, true];
405
- };
406
-
407
- // node_modules/minimatch/dist/esm/unescape.js
408
- var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
409
- return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
410
- };
411
-
412
- // node_modules/minimatch/dist/esm/ast.js
413
- var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
414
- var isExtglobType = (c) => types.has(c);
415
- var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
416
- var startNoDot = "(?!\\.)";
417
- var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
418
- var justDots = /* @__PURE__ */ new Set(["..", "."]);
419
- var reSpecials = new Set("().*{}+?[]^$\\!");
420
- var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
421
- var qmark = "[^/]";
422
- var star = qmark + "*?";
423
- var starNoEmpty = qmark + "+?";
424
- var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn;
425
- var _AST = class _AST {
426
- constructor(type, parent, options = {}) {
427
- __privateAdd(this, _AST_instances);
428
- __publicField(this, "type");
429
- __privateAdd(this, _root);
430
- __privateAdd(this, _hasMagic);
431
- __privateAdd(this, _uflag, false);
432
- __privateAdd(this, _parts, []);
433
- __privateAdd(this, _parent);
434
- __privateAdd(this, _parentIndex);
435
- __privateAdd(this, _negs);
436
- __privateAdd(this, _filledNegs, false);
437
- __privateAdd(this, _options);
438
- __privateAdd(this, _toString);
439
- // set to true if it's an extglob with no children
440
- // (which really means one child of '')
441
- __privateAdd(this, _emptyExt, false);
442
- this.type = type;
443
- if (type)
444
- __privateSet(this, _hasMagic, true);
445
- __privateSet(this, _parent, parent);
446
- __privateSet(this, _root, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _root) : this);
447
- __privateSet(this, _options, __privateGet(this, _root) === this ? options : __privateGet(__privateGet(this, _root), _options));
448
- __privateSet(this, _negs, __privateGet(this, _root) === this ? [] : __privateGet(__privateGet(this, _root), _negs));
449
- if (type === "!" && !__privateGet(__privateGet(this, _root), _filledNegs))
450
- __privateGet(this, _negs).push(this);
451
- __privateSet(this, _parentIndex, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0);
452
- }
453
- get hasMagic() {
454
- if (__privateGet(this, _hasMagic) !== void 0)
455
- return __privateGet(this, _hasMagic);
456
- for (const p of __privateGet(this, _parts)) {
457
- if (typeof p === "string")
458
- continue;
459
- if (p.type || p.hasMagic)
460
- return __privateSet(this, _hasMagic, true);
461
- }
462
- return __privateGet(this, _hasMagic);
463
- }
464
- // reconstructs the pattern
465
- toString() {
466
- if (__privateGet(this, _toString) !== void 0)
467
- return __privateGet(this, _toString);
468
- if (!this.type) {
469
- return __privateSet(this, _toString, __privateGet(this, _parts).map((p) => String(p)).join(""));
470
- } else {
471
- return __privateSet(this, _toString, this.type + "(" + __privateGet(this, _parts).map((p) => String(p)).join("|") + ")");
472
- }
473
- }
474
- push(...parts) {
475
- for (const p of parts) {
476
- if (p === "")
477
- continue;
478
- if (typeof p !== "string" && !(p instanceof _AST && __privateGet(p, _parent) === this)) {
479
- throw new Error("invalid part: " + p);
480
- }
481
- __privateGet(this, _parts).push(p);
482
- }
483
- }
484
- toJSON() {
485
- var _a;
486
- const ret = this.type === null ? __privateGet(this, _parts).slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...__privateGet(this, _parts).map((p) => p.toJSON())];
487
- if (this.isStart() && !this.type)
488
- ret.unshift([]);
489
- if (this.isEnd() && (this === __privateGet(this, _root) || __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")) {
490
- ret.push({});
491
- }
492
- return ret;
493
- }
494
- isStart() {
495
- var _a;
496
- if (__privateGet(this, _root) === this)
497
- return true;
498
- if (!((_a = __privateGet(this, _parent)) == null ? void 0 : _a.isStart()))
499
- return false;
500
- if (__privateGet(this, _parentIndex) === 0)
501
- return true;
502
- const p = __privateGet(this, _parent);
503
- for (let i2 = 0; i2 < __privateGet(this, _parentIndex); i2++) {
504
- const pp = __privateGet(p, _parts)[i2];
505
- if (!(pp instanceof _AST && pp.type === "!")) {
506
- return false;
507
- }
508
- }
509
- return true;
510
- }
511
- isEnd() {
512
- var _a, _b, _c;
513
- if (__privateGet(this, _root) === this)
514
- return true;
515
- if (((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")
516
- return true;
517
- if (!((_b = __privateGet(this, _parent)) == null ? void 0 : _b.isEnd()))
518
- return false;
519
- if (!this.type)
520
- return (_c = __privateGet(this, _parent)) == null ? void 0 : _c.isEnd();
521
- const pl = __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0;
522
- return __privateGet(this, _parentIndex) === pl - 1;
523
- }
524
- copyIn(part) {
525
- if (typeof part === "string")
526
- this.push(part);
527
- else
528
- this.push(part.clone(this));
529
- }
530
- clone(parent) {
531
- const c = new _AST(this.type, parent);
532
- for (const p of __privateGet(this, _parts)) {
533
- c.copyIn(p);
534
- }
535
- return c;
536
- }
537
- static fromGlob(pattern, options = {}) {
538
- var _a;
539
- const ast = new _AST(null, void 0, options);
540
- __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, pattern, ast, 0, options);
541
- return ast;
542
- }
543
- // returns the regular expression if there's magic, or the unescaped
544
- // string if not.
545
- toMMPattern() {
546
- if (this !== __privateGet(this, _root))
547
- return __privateGet(this, _root).toMMPattern();
548
- const glob = this.toString();
549
- const [re, body, hasMagic, uflag] = this.toRegExpSource();
550
- const anyMagic = hasMagic || __privateGet(this, _hasMagic) || __privateGet(this, _options).nocase && !__privateGet(this, _options).nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
551
- if (!anyMagic) {
552
- return body;
553
- }
554
- const flags = (__privateGet(this, _options).nocase ? "i" : "") + (uflag ? "u" : "");
555
- return Object.assign(new RegExp(`^${re}$`, flags), {
556
- _src: re,
557
- _glob: glob
558
- });
559
- }
560
- get options() {
561
- return __privateGet(this, _options);
562
- }
563
- // returns the string match, the regexp source, whether there's magic
564
- // in the regexp (so a regular expression is required) and whether or
565
- // not the uflag is needed for the regular expression (for posix classes)
566
- // TODO: instead of injecting the start/end at this point, just return
567
- // the BODY of the regexp, along with the start/end portions suitable
568
- // for binding the start/end in either a joined full-path makeRe context
569
- // (where we bind to (^|/), or a standalone matchPart context (where
570
- // we bind to ^, and not /). Otherwise slashes get duped!
571
- //
572
- // In part-matching mode, the start is:
573
- // - if not isStart: nothing
574
- // - if traversal possible, but not allowed: ^(?!\.\.?$)
575
- // - if dots allowed or not possible: ^
576
- // - if dots possible and not allowed: ^(?!\.)
577
- // end is:
578
- // - if not isEnd(): nothing
579
- // - else: $
580
- //
581
- // In full-path matching mode, we put the slash at the START of the
582
- // pattern, so start is:
583
- // - if first pattern: same as part-matching mode
584
- // - if not isStart(): nothing
585
- // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
586
- // - if dots allowed or not possible: /
587
- // - if dots possible and not allowed: /(?!\.)
588
- // end is:
589
- // - if last pattern, same as part-matching mode
590
- // - else nothing
591
- //
592
- // Always put the (?:$|/) on negated tails, though, because that has to be
593
- // there to bind the end of the negated pattern portion, and it's easier to
594
- // just stick it in now rather than try to inject it later in the middle of
595
- // the pattern.
596
- //
597
- // We can just always return the same end, and leave it up to the caller
598
- // to know whether it's going to be used joined or in parts.
599
- // And, if the start is adjusted slightly, can do the same there:
600
- // - if not isStart: nothing
601
- // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
602
- // - if dots allowed or not possible: (?:/|^)
603
- // - if dots possible and not allowed: (?:/|^)(?!\.)
604
- //
605
- // But it's better to have a simpler binding without a conditional, for
606
- // performance, so probably better to return both start options.
607
- //
608
- // Then the caller just ignores the end if it's not the first pattern,
609
- // and the start always gets applied.
610
- //
611
- // But that's always going to be $ if it's the ending pattern, or nothing,
612
- // so the caller can just attach $ at the end of the pattern when building.
613
- //
614
- // So the todo is:
615
- // - better detect what kind of start is needed
616
- // - return both flavors of starting pattern
617
- // - attach $ at the end of the pattern when creating the actual RegExp
618
- //
619
- // Ah, but wait, no, that all only applies to the root when the first pattern
620
- // is not an extglob. If the first pattern IS an extglob, then we need all
621
- // that dot prevention biz to live in the extglob portions, because eg
622
- // +(*|.x*) can match .xy but not .yx.
623
- //
624
- // So, return the two flavors if it's #root and the first child is not an
625
- // AST, otherwise leave it to the child AST to handle it, and there,
626
- // use the (?:^|/) style of start binding.
627
- //
628
- // Even simplified further:
629
- // - Since the start for a join is eg /(?!\.) and the start for a part
630
- // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
631
- // or start or whatever) and prepend ^ or / at the Regexp construction.
632
- toRegExpSource(allowDot) {
633
- var _a;
634
- const dot = allowDot != null ? allowDot : !!__privateGet(this, _options).dot;
635
- if (__privateGet(this, _root) === this)
636
- __privateMethod(this, _AST_instances, fillNegs_fn).call(this);
637
- if (!this.type) {
638
- const noEmpty = this.isStart() && this.isEnd();
639
- const src = __privateGet(this, _parts).map((p) => {
640
- var _a2;
641
- const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a2 = _AST, _AST_static, parseGlob_fn).call(_a2, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot);
642
- __privateSet(this, _hasMagic, __privateGet(this, _hasMagic) || hasMagic);
643
- __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
644
- return re;
645
- }).join("");
646
- let start2 = "";
647
- if (this.isStart()) {
648
- if (typeof __privateGet(this, _parts)[0] === "string") {
649
- const dotTravAllowed = __privateGet(this, _parts).length === 1 && justDots.has(__privateGet(this, _parts)[0]);
650
- if (!dotTravAllowed) {
651
- const aps = addPatternStart;
652
- const needNoTrav = (
653
- // dots are allowed, and the pattern starts with [ or .
654
- dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
655
- src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
656
- src.startsWith("\\.\\.") && aps.has(src.charAt(4))
657
- );
658
- const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
659
- start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
660
- }
661
- }
662
- }
663
- let end = "";
664
- if (this.isEnd() && __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!") {
665
- end = "(?:$|\\/)";
666
- }
667
- const final2 = start2 + src + end;
668
- return [
669
- final2,
670
- unescape(src),
671
- __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
672
- __privateGet(this, _uflag)
673
- ];
674
- }
675
- const repeated = this.type === "*" || this.type === "+";
676
- const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
677
- let body = __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, dot);
678
- if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
679
- const s = this.toString();
680
- __privateSet(this, _parts, [s]);
681
- this.type = null;
682
- __privateSet(this, _hasMagic, void 0);
683
- return [s, unescape(this.toString()), false, false];
684
- }
685
- let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, true);
686
- if (bodyDotAllowed === body) {
687
- bodyDotAllowed = "";
688
- }
689
- if (bodyDotAllowed) {
690
- body = `(?:${body})(?:${bodyDotAllowed})*?`;
691
- }
692
- let final = "";
693
- if (this.type === "!" && __privateGet(this, _emptyExt)) {
694
- final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
695
- } else {
696
- const close = this.type === "!" ? (
697
- // !() must match something,but !(x) can match ''
698
- "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
699
- ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
700
- final = start + body + close;
701
- }
702
- return [
703
- final,
704
- unescape(body),
705
- __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
706
- __privateGet(this, _uflag)
707
- ];
708
- }
709
- };
710
- _root = new WeakMap();
711
- _hasMagic = new WeakMap();
712
- _uflag = new WeakMap();
713
- _parts = new WeakMap();
714
- _parent = new WeakMap();
715
- _parentIndex = new WeakMap();
716
- _negs = new WeakMap();
717
- _filledNegs = new WeakMap();
718
- _options = new WeakMap();
719
- _toString = new WeakMap();
720
- _emptyExt = new WeakMap();
721
- _AST_instances = new WeakSet();
722
- fillNegs_fn = function() {
723
- if (this !== __privateGet(this, _root))
724
- throw new Error("should only call on root");
725
- if (__privateGet(this, _filledNegs))
726
- return this;
727
- this.toString();
728
- __privateSet(this, _filledNegs, true);
729
- let n;
730
- while (n = __privateGet(this, _negs).pop()) {
731
- if (n.type !== "!")
732
- continue;
733
- let p = n;
734
- let pp = __privateGet(p, _parent);
735
- while (pp) {
736
- for (let i2 = __privateGet(p, _parentIndex) + 1; !pp.type && i2 < __privateGet(pp, _parts).length; i2++) {
737
- for (const part of __privateGet(n, _parts)) {
738
- if (typeof part === "string") {
739
- throw new Error("string part in extglob AST??");
740
- }
741
- part.copyIn(__privateGet(pp, _parts)[i2]);
742
- }
743
- }
744
- p = pp;
745
- pp = __privateGet(p, _parent);
746
- }
747
- }
748
- return this;
749
- };
750
- _AST_static = new WeakSet();
751
- parseAST_fn = function(str, ast, pos, opt) {
752
- var _a, _b;
753
- let escaping = false;
754
- let inBrace = false;
755
- let braceStart = -1;
756
- let braceNeg = false;
757
- if (ast.type === null) {
758
- let i3 = pos;
759
- let acc2 = "";
760
- while (i3 < str.length) {
761
- const c = str.charAt(i3++);
762
- if (escaping || c === "\\") {
763
- escaping = !escaping;
764
- acc2 += c;
765
- continue;
766
- }
767
- if (inBrace) {
768
- if (i3 === braceStart + 1) {
769
- if (c === "^" || c === "!") {
770
- braceNeg = true;
771
- }
772
- } else if (c === "]" && !(i3 === braceStart + 2 && braceNeg)) {
773
- inBrace = false;
774
- }
775
- acc2 += c;
776
- continue;
777
- } else if (c === "[") {
778
- inBrace = true;
779
- braceStart = i3;
780
- braceNeg = false;
781
- acc2 += c;
782
- continue;
783
- }
784
- if (!opt.noext && isExtglobType(c) && str.charAt(i3) === "(") {
785
- ast.push(acc2);
786
- acc2 = "";
787
- const ext2 = new _AST(c, ast);
788
- i3 = __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, str, ext2, i3, opt);
789
- ast.push(ext2);
790
- continue;
791
- }
792
- acc2 += c;
793
- }
794
- ast.push(acc2);
795
- return i3;
796
- }
797
- let i2 = pos + 1;
798
- let part = new _AST(null, ast);
799
- const parts = [];
800
- let acc = "";
801
- while (i2 < str.length) {
802
- const c = str.charAt(i2++);
803
- if (escaping || c === "\\") {
804
- escaping = !escaping;
805
- acc += c;
806
- continue;
807
- }
808
- if (inBrace) {
809
- if (i2 === braceStart + 1) {
810
- if (c === "^" || c === "!") {
811
- braceNeg = true;
812
- }
813
- } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
814
- inBrace = false;
815
- }
816
- acc += c;
817
- continue;
818
- } else if (c === "[") {
819
- inBrace = true;
820
- braceStart = i2;
821
- braceNeg = false;
822
- acc += c;
823
- continue;
824
- }
825
- if (isExtglobType(c) && str.charAt(i2) === "(") {
826
- part.push(acc);
827
- acc = "";
828
- const ext2 = new _AST(c, part);
829
- part.push(ext2);
830
- i2 = __privateMethod(_b = _AST, _AST_static, parseAST_fn).call(_b, str, ext2, i2, opt);
831
- continue;
832
- }
833
- if (c === "|") {
834
- part.push(acc);
835
- acc = "";
836
- parts.push(part);
837
- part = new _AST(null, ast);
838
- continue;
839
- }
840
- if (c === ")") {
841
- if (acc === "" && __privateGet(ast, _parts).length === 0) {
842
- __privateSet(ast, _emptyExt, true);
843
- }
844
- part.push(acc);
845
- acc = "";
846
- ast.push(...parts, part);
847
- return i2;
848
- }
849
- acc += c;
850
- }
851
- ast.type = null;
852
- __privateSet(ast, _hasMagic, void 0);
853
- __privateSet(ast, _parts, [str.substring(pos - 1)]);
854
- return i2;
855
- };
856
- partsToRegExp_fn = function(dot) {
857
- return __privateGet(this, _parts).map((p) => {
858
- if (typeof p === "string") {
859
- throw new Error("string type in extglob ast??");
860
- }
861
- const [re, _, _hasMagic2, uflag] = p.toRegExpSource(dot);
862
- __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
863
- return re;
864
- }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
865
- };
866
- parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
867
- let escaping = false;
868
- let re = "";
869
- let uflag = false;
870
- for (let i2 = 0; i2 < glob.length; i2++) {
871
- const c = glob.charAt(i2);
872
- if (escaping) {
873
- escaping = false;
874
- re += (reSpecials.has(c) ? "\\" : "") + c;
875
- continue;
876
- }
877
- if (c === "\\") {
878
- if (i2 === glob.length - 1) {
879
- re += "\\\\";
880
- } else {
881
- escaping = true;
882
- }
883
- continue;
884
- }
885
- if (c === "[") {
886
- const [src, needUflag, consumed, magic] = parseClass(glob, i2);
887
- if (consumed) {
888
- re += src;
889
- uflag = uflag || needUflag;
890
- i2 += consumed - 1;
891
- hasMagic = hasMagic || magic;
892
- continue;
893
- }
894
- }
895
- if (c === "*") {
896
- if (noEmpty && glob === "*")
897
- re += starNoEmpty;
898
- else
899
- re += star;
900
- hasMagic = true;
901
- continue;
902
- }
903
- if (c === "?") {
904
- re += qmark;
905
- hasMagic = true;
906
- continue;
907
- }
908
- re += regExpEscape(c);
909
- }
910
- return [re, unescape(glob), !!hasMagic, uflag];
911
- };
912
- __privateAdd(_AST, _AST_static);
913
- var AST = _AST;
914
-
915
- // node_modules/minimatch/dist/esm/escape.js
916
- var escape = (s, { windowsPathsNoEscape = false } = {}) => {
917
- return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
918
- };
919
-
920
- // node_modules/minimatch/dist/esm/index.js
921
- var minimatch = (p, pattern, options = {}) => {
922
- assertValidPattern(pattern);
923
- if (!options.nocomment && pattern.charAt(0) === "#") {
924
- return false;
925
- }
926
- return new Minimatch(pattern, options).match(p);
927
- };
928
- var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
929
- var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
930
- var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
931
- var starDotExtTestNocase = (ext2) => {
932
- ext2 = ext2.toLowerCase();
933
- return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
934
- };
935
- var starDotExtTestNocaseDot = (ext2) => {
936
- ext2 = ext2.toLowerCase();
937
- return (f) => f.toLowerCase().endsWith(ext2);
938
- };
939
- var starDotStarRE = /^\*+\.\*+$/;
940
- var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
941
- var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
942
- var dotStarRE = /^\.\*+$/;
943
- var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
944
- var starRE = /^\*+$/;
945
- var starTest = (f) => f.length !== 0 && !f.startsWith(".");
946
- var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
947
- var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
948
- var qmarksTestNocase = ([$0, ext2 = ""]) => {
949
- const noext = qmarksTestNoExt([$0]);
950
- if (!ext2)
951
- return noext;
952
- ext2 = ext2.toLowerCase();
953
- return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
954
- };
955
- var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
956
- const noext = qmarksTestNoExtDot([$0]);
957
- if (!ext2)
958
- return noext;
959
- ext2 = ext2.toLowerCase();
960
- return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
961
- };
962
- var qmarksTestDot = ([$0, ext2 = ""]) => {
963
- const noext = qmarksTestNoExtDot([$0]);
964
- return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
965
- };
966
- var qmarksTest = ([$0, ext2 = ""]) => {
967
- const noext = qmarksTestNoExt([$0]);
968
- return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
969
- };
970
- var qmarksTestNoExt = ([$0]) => {
971
- const len = $0.length;
972
- return (f) => f.length === len && !f.startsWith(".");
973
- };
974
- var qmarksTestNoExtDot = ([$0]) => {
975
- const len = $0.length;
976
- return (f) => f.length === len && f !== "." && f !== "..";
977
- };
978
- var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
979
- var path = {
980
- win32: { sep: "\\" },
981
- posix: { sep: "/" }
982
- };
983
- var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
984
- minimatch.sep = sep;
985
- var GLOBSTAR = Symbol("globstar **");
986
- minimatch.GLOBSTAR = GLOBSTAR;
987
- var qmark2 = "[^/]";
988
- var star2 = qmark2 + "*?";
989
- var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
990
- var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
991
- var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
992
- minimatch.filter = filter;
993
- var ext = (a, b = {}) => Object.assign({}, a, b);
994
- var defaults = (def) => {
995
- if (!def || typeof def !== "object" || !Object.keys(def).length) {
996
- return minimatch;
997
- }
998
- const orig = minimatch;
999
- const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
1000
- return Object.assign(m, {
1001
- Minimatch: class Minimatch extends orig.Minimatch {
1002
- constructor(pattern, options = {}) {
1003
- super(pattern, ext(def, options));
1004
- }
1005
- static defaults(options) {
1006
- return orig.defaults(ext(def, options)).Minimatch;
1007
- }
1008
- },
1009
- AST: class AST extends orig.AST {
1010
- /* c8 ignore start */
1011
- constructor(type, parent, options = {}) {
1012
- super(type, parent, ext(def, options));
1013
- }
1014
- /* c8 ignore stop */
1015
- static fromGlob(pattern, options = {}) {
1016
- return orig.AST.fromGlob(pattern, ext(def, options));
1017
- }
1018
- },
1019
- unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
1020
- escape: (s, options = {}) => orig.escape(s, ext(def, options)),
1021
- filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
1022
- defaults: (options) => orig.defaults(ext(def, options)),
1023
- makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
1024
- braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
1025
- match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
1026
- sep: orig.sep,
1027
- GLOBSTAR
1028
- });
1029
- };
1030
- minimatch.defaults = defaults;
1031
- var braceExpand = (pattern, options = {}) => {
1032
- assertValidPattern(pattern);
1033
- if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
1034
- return [pattern];
1035
- }
1036
- return (0, import_brace_expansion.default)(pattern);
1037
- };
1038
- minimatch.braceExpand = braceExpand;
1039
- var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
1040
- minimatch.makeRe = makeRe;
1041
- var match = (list, pattern, options = {}) => {
1042
- const mm = new Minimatch(pattern, options);
1043
- list = list.filter((f) => mm.match(f));
1044
- if (mm.options.nonull && !list.length) {
1045
- list.push(pattern);
1046
- }
1047
- return list;
1048
- };
1049
- minimatch.match = match;
1050
- var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
1051
- var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1052
- var Minimatch = class {
1053
- options;
1054
- set;
1055
- pattern;
1056
- windowsPathsNoEscape;
1057
- nonegate;
1058
- negate;
1059
- comment;
1060
- empty;
1061
- preserveMultipleSlashes;
1062
- partial;
1063
- globSet;
1064
- globParts;
1065
- nocase;
1066
- isWindows;
1067
- platform;
1068
- windowsNoMagicRoot;
1069
- regexp;
1070
- constructor(pattern, options = {}) {
1071
- assertValidPattern(pattern);
1072
- options = options || {};
1073
- this.options = options;
1074
- this.pattern = pattern;
1075
- this.platform = options.platform || defaultPlatform;
1076
- this.isWindows = this.platform === "win32";
1077
- this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
1078
- if (this.windowsPathsNoEscape) {
1079
- this.pattern = this.pattern.replace(/\\/g, "/");
1080
- }
1081
- this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
1082
- this.regexp = null;
1083
- this.negate = false;
1084
- this.nonegate = !!options.nonegate;
1085
- this.comment = false;
1086
- this.empty = false;
1087
- this.partial = !!options.partial;
1088
- this.nocase = !!this.options.nocase;
1089
- this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
1090
- this.globSet = [];
1091
- this.globParts = [];
1092
- this.set = [];
1093
- this.make();
1094
- }
1095
- hasMagic() {
1096
- if (this.options.magicalBraces && this.set.length > 1) {
1097
- return true;
1098
- }
1099
- for (const pattern of this.set) {
1100
- for (const part of pattern) {
1101
- if (typeof part !== "string")
1102
- return true;
1103
- }
1104
- }
1105
- return false;
1106
- }
1107
- debug(..._) {
1108
- }
1109
- make() {
1110
- const pattern = this.pattern;
1111
- const options = this.options;
1112
- if (!options.nocomment && pattern.charAt(0) === "#") {
1113
- this.comment = true;
1114
- return;
1115
- }
1116
- if (!pattern) {
1117
- this.empty = true;
1118
- return;
1119
- }
1120
- this.parseNegate();
1121
- this.globSet = [...new Set(this.braceExpand())];
1122
- if (options.debug) {
1123
- this.debug = (...args) => console.error(...args);
1124
- }
1125
- this.debug(this.pattern, this.globSet);
1126
- const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
1127
- this.globParts = this.preprocess(rawGlobParts);
1128
- this.debug(this.pattern, this.globParts);
1129
- let set = this.globParts.map((s, _, __) => {
1130
- if (this.isWindows && this.windowsNoMagicRoot) {
1131
- const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
1132
- const isDrive = /^[a-z]:/i.test(s[0]);
1133
- if (isUNC) {
1134
- return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
1135
- } else if (isDrive) {
1136
- return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
1137
- }
1138
- }
1139
- return s.map((ss) => this.parse(ss));
1140
- });
1141
- this.debug(this.pattern, set);
1142
- this.set = set.filter((s) => s.indexOf(false) === -1);
1143
- if (this.isWindows) {
1144
- for (let i2 = 0; i2 < this.set.length; i2++) {
1145
- const p = this.set[i2];
1146
- if (p[0] === "" && p[1] === "" && this.globParts[i2][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
1147
- p[2] = "?";
1148
- }
1149
- }
1150
- }
1151
- this.debug(this.pattern, this.set);
1152
- }
1153
- // various transforms to equivalent pattern sets that are
1154
- // faster to process in a filesystem walk. The goal is to
1155
- // eliminate what we can, and push all ** patterns as far
1156
- // to the right as possible, even if it increases the number
1157
- // of patterns that we have to process.
1158
- preprocess(globParts) {
1159
- if (this.options.noglobstar) {
1160
- for (let i2 = 0; i2 < globParts.length; i2++) {
1161
- for (let j = 0; j < globParts[i2].length; j++) {
1162
- if (globParts[i2][j] === "**") {
1163
- globParts[i2][j] = "*";
1164
- }
1165
- }
1166
- }
1167
- }
1168
- const { optimizationLevel = 1 } = this.options;
1169
- if (optimizationLevel >= 2) {
1170
- globParts = this.firstPhasePreProcess(globParts);
1171
- globParts = this.secondPhasePreProcess(globParts);
1172
- } else if (optimizationLevel >= 1) {
1173
- globParts = this.levelOneOptimize(globParts);
1174
- } else {
1175
- globParts = this.adjascentGlobstarOptimize(globParts);
1176
- }
1177
- return globParts;
1178
- }
1179
- // just get rid of adjascent ** portions
1180
- adjascentGlobstarOptimize(globParts) {
1181
- return globParts.map((parts) => {
1182
- let gs = -1;
1183
- while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1184
- let i2 = gs;
1185
- while (parts[i2 + 1] === "**") {
1186
- i2++;
1187
- }
1188
- if (i2 !== gs) {
1189
- parts.splice(gs, i2 - gs);
1190
- }
1191
- }
1192
- return parts;
1193
- });
1194
- }
1195
- // get rid of adjascent ** and resolve .. portions
1196
- levelOneOptimize(globParts) {
1197
- return globParts.map((parts) => {
1198
- parts = parts.reduce((set, part) => {
1199
- const prev = set[set.length - 1];
1200
- if (part === "**" && prev === "**") {
1201
- return set;
1202
- }
1203
- if (part === "..") {
1204
- if (prev && prev !== ".." && prev !== "." && prev !== "**") {
1205
- set.pop();
1206
- return set;
1207
- }
1208
- }
1209
- set.push(part);
1210
- return set;
1211
- }, []);
1212
- return parts.length === 0 ? [""] : parts;
1213
- });
1214
- }
1215
- levelTwoFileOptimize(parts) {
1216
- if (!Array.isArray(parts)) {
1217
- parts = this.slashSplit(parts);
1218
- }
1219
- let didSomething = false;
1220
- do {
1221
- didSomething = false;
1222
- if (!this.preserveMultipleSlashes) {
1223
- for (let i2 = 1; i2 < parts.length - 1; i2++) {
1224
- const p = parts[i2];
1225
- if (i2 === 1 && p === "" && parts[0] === "")
1226
- continue;
1227
- if (p === "." || p === "") {
1228
- didSomething = true;
1229
- parts.splice(i2, 1);
1230
- i2--;
1231
- }
1232
- }
1233
- if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1234
- didSomething = true;
1235
- parts.pop();
1236
- }
1237
- }
1238
- let dd = 0;
1239
- while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1240
- const p = parts[dd - 1];
1241
- if (p && p !== "." && p !== ".." && p !== "**") {
1242
- didSomething = true;
1243
- parts.splice(dd - 1, 2);
1244
- dd -= 2;
1245
- }
1246
- }
1247
- } while (didSomething);
1248
- return parts.length === 0 ? [""] : parts;
1249
- }
1250
- // First phase: single-pattern processing
1251
- // <pre> is 1 or more portions
1252
- // <rest> is 1 or more portions
1253
- // <p> is any portion other than ., .., '', or **
1254
- // <e> is . or ''
1255
- //
1256
- // **/.. is *brutal* for filesystem walking performance, because
1257
- // it effectively resets the recursive walk each time it occurs,
1258
- // and ** cannot be reduced out by a .. pattern part like a regexp
1259
- // or most strings (other than .., ., and '') can be.
1260
- //
1261
- // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
1262
- // <pre>/<e>/<rest> -> <pre>/<rest>
1263
- // <pre>/<p>/../<rest> -> <pre>/<rest>
1264
- // **/**/<rest> -> **/<rest>
1265
- //
1266
- // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
1267
- // this WOULD be allowed if ** did follow symlinks, or * didn't
1268
- firstPhasePreProcess(globParts) {
1269
- let didSomething = false;
1270
- do {
1271
- didSomething = false;
1272
- for (let parts of globParts) {
1273
- let gs = -1;
1274
- while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1275
- let gss = gs;
1276
- while (parts[gss + 1] === "**") {
1277
- gss++;
1278
- }
1279
- if (gss > gs) {
1280
- parts.splice(gs + 1, gss - gs);
1281
- }
1282
- let next = parts[gs + 1];
1283
- const p = parts[gs + 2];
1284
- const p2 = parts[gs + 3];
1285
- if (next !== "..")
1286
- continue;
1287
- if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
1288
- continue;
1289
- }
1290
- didSomething = true;
1291
- parts.splice(gs, 1);
1292
- const other = parts.slice(0);
1293
- other[gs] = "**";
1294
- globParts.push(other);
1295
- gs--;
1296
- }
1297
- if (!this.preserveMultipleSlashes) {
1298
- for (let i2 = 1; i2 < parts.length - 1; i2++) {
1299
- const p = parts[i2];
1300
- if (i2 === 1 && p === "" && parts[0] === "")
1301
- continue;
1302
- if (p === "." || p === "") {
1303
- didSomething = true;
1304
- parts.splice(i2, 1);
1305
- i2--;
1306
- }
1307
- }
1308
- if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1309
- didSomething = true;
1310
- parts.pop();
1311
- }
1312
- }
1313
- let dd = 0;
1314
- while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1315
- const p = parts[dd - 1];
1316
- if (p && p !== "." && p !== ".." && p !== "**") {
1317
- didSomething = true;
1318
- const needDot = dd === 1 && parts[dd + 1] === "**";
1319
- const splin = needDot ? ["."] : [];
1320
- parts.splice(dd - 1, 2, ...splin);
1321
- if (parts.length === 0)
1322
- parts.push("");
1323
- dd -= 2;
1324
- }
1325
- }
1326
- }
1327
- } while (didSomething);
1328
- return globParts;
1329
- }
1330
- // second phase: multi-pattern dedupes
1331
- // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
1332
- // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
1333
- // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
1334
- //
1335
- // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
1336
- // ^-- not valid because ** doens't follow symlinks
1337
- secondPhasePreProcess(globParts) {
1338
- for (let i2 = 0; i2 < globParts.length - 1; i2++) {
1339
- for (let j = i2 + 1; j < globParts.length; j++) {
1340
- const matched = this.partsMatch(globParts[i2], globParts[j], !this.preserveMultipleSlashes);
1341
- if (!matched)
1342
- continue;
1343
- globParts[i2] = matched;
1344
- globParts[j] = [];
1345
- }
1346
- }
1347
- return globParts.filter((gs) => gs.length);
1348
- }
1349
- partsMatch(a, b, emptyGSMatch = false) {
1350
- let ai = 0;
1351
- let bi = 0;
1352
- let result = [];
1353
- let which = "";
1354
- while (ai < a.length && bi < b.length) {
1355
- if (a[ai] === b[bi]) {
1356
- result.push(which === "b" ? b[bi] : a[ai]);
1357
- ai++;
1358
- bi++;
1359
- } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
1360
- result.push(a[ai]);
1361
- ai++;
1362
- } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
1363
- result.push(b[bi]);
1364
- bi++;
1365
- } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
1366
- if (which === "b")
1367
- return false;
1368
- which = "a";
1369
- result.push(a[ai]);
1370
- ai++;
1371
- bi++;
1372
- } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
1373
- if (which === "a")
1374
- return false;
1375
- which = "b";
1376
- result.push(b[bi]);
1377
- ai++;
1378
- bi++;
1379
- } else {
1380
- return false;
1381
- }
1382
- }
1383
- return a.length === b.length && result;
1384
- }
1385
- parseNegate() {
1386
- if (this.nonegate)
1387
- return;
1388
- const pattern = this.pattern;
1389
- let negate = false;
1390
- let negateOffset = 0;
1391
- for (let i2 = 0; i2 < pattern.length && pattern.charAt(i2) === "!"; i2++) {
1392
- negate = !negate;
1393
- negateOffset++;
1394
- }
1395
- if (negateOffset)
1396
- this.pattern = pattern.slice(negateOffset);
1397
- this.negate = negate;
1398
- }
1399
- // set partial to true to test if, for example,
1400
- // "/a/b" matches the start of "/*/b/*/d"
1401
- // Partial means, if you run out of file before you run
1402
- // out of pattern, then that's fine, as long as all
1403
- // the parts match.
1404
- matchOne(file, pattern, partial = false) {
1405
- const options = this.options;
1406
- if (this.isWindows) {
1407
- const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
1408
- const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
1409
- const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
1410
- const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
1411
- const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
1412
- const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
1413
- if (typeof fdi === "number" && typeof pdi === "number") {
1414
- const [fd, pd] = [file[fdi], pattern[pdi]];
1415
- if (fd.toLowerCase() === pd.toLowerCase()) {
1416
- pattern[pdi] = fd;
1417
- if (pdi > fdi) {
1418
- pattern = pattern.slice(pdi);
1419
- } else if (fdi > pdi) {
1420
- file = file.slice(fdi);
1421
- }
1422
- }
1423
- }
1424
- }
1425
- const { optimizationLevel = 1 } = this.options;
1426
- if (optimizationLevel >= 2) {
1427
- file = this.levelTwoFileOptimize(file);
1428
- }
1429
- this.debug("matchOne", this, { file, pattern });
1430
- this.debug("matchOne", file.length, pattern.length);
1431
- for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
1432
- this.debug("matchOne loop");
1433
- var p = pattern[pi];
1434
- var f = file[fi];
1435
- this.debug(pattern, p, f);
1436
- if (p === false) {
1437
- return false;
1438
- }
1439
- if (p === GLOBSTAR) {
1440
- this.debug("GLOBSTAR", [pattern, p, f]);
1441
- var fr = fi;
1442
- var pr = pi + 1;
1443
- if (pr === pl) {
1444
- this.debug("** at the end");
1445
- for (; fi < fl; fi++) {
1446
- if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
1447
- return false;
1448
- }
1449
- return true;
1450
- }
1451
- while (fr < fl) {
1452
- var swallowee = file[fr];
1453
- this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
1454
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
1455
- this.debug("globstar found match!", fr, fl, swallowee);
1456
- return true;
1457
- } else {
1458
- if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
1459
- this.debug("dot detected!", file, fr, pattern, pr);
1460
- break;
1461
- }
1462
- this.debug("globstar swallow a segment, and continue");
1463
- fr++;
1464
- }
1465
- }
1466
- if (partial) {
1467
- this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
1468
- if (fr === fl) {
1469
- return true;
1470
- }
1471
- }
1472
- return false;
1473
- }
1474
- let hit;
1475
- if (typeof p === "string") {
1476
- hit = f === p;
1477
- this.debug("string match", p, f, hit);
1478
- } else {
1479
- hit = p.test(f);
1480
- this.debug("pattern match", p, f, hit);
1481
- }
1482
- if (!hit)
1483
- return false;
1484
- }
1485
- if (fi === fl && pi === pl) {
1486
- return true;
1487
- } else if (fi === fl) {
1488
- return partial;
1489
- } else if (pi === pl) {
1490
- return fi === fl - 1 && file[fi] === "";
1491
- } else {
1492
- throw new Error("wtf?");
1493
- }
1494
- }
1495
- braceExpand() {
1496
- return braceExpand(this.pattern, this.options);
1497
- }
1498
- parse(pattern) {
1499
- assertValidPattern(pattern);
1500
- const options = this.options;
1501
- if (pattern === "**")
1502
- return GLOBSTAR;
1503
- if (pattern === "")
1504
- return "";
1505
- let m;
1506
- let fastTest = null;
1507
- if (m = pattern.match(starRE)) {
1508
- fastTest = options.dot ? starTestDot : starTest;
1509
- } else if (m = pattern.match(starDotExtRE)) {
1510
- fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
1511
- } else if (m = pattern.match(qmarksRE)) {
1512
- fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
1513
- } else if (m = pattern.match(starDotStarRE)) {
1514
- fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
1515
- } else if (m = pattern.match(dotStarRE)) {
1516
- fastTest = dotStarTest;
1517
- }
1518
- const re = AST.fromGlob(pattern, this.options).toMMPattern();
1519
- if (fastTest && typeof re === "object") {
1520
- Reflect.defineProperty(re, "test", { value: fastTest });
1521
- }
1522
- return re;
1523
- }
1524
- makeRe() {
1525
- if (this.regexp || this.regexp === false)
1526
- return this.regexp;
1527
- const set = this.set;
1528
- if (!set.length) {
1529
- this.regexp = false;
1530
- return this.regexp;
1531
- }
1532
- const options = this.options;
1533
- const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
1534
- const flags = new Set(options.nocase ? ["i"] : []);
1535
- let re = set.map((pattern) => {
1536
- const pp = pattern.map((p) => {
1537
- if (p instanceof RegExp) {
1538
- for (const f of p.flags.split(""))
1539
- flags.add(f);
1540
- }
1541
- return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
1542
- });
1543
- pp.forEach((p, i2) => {
1544
- const next = pp[i2 + 1];
1545
- const prev = pp[i2 - 1];
1546
- if (p !== GLOBSTAR || prev === GLOBSTAR) {
1547
- return;
1548
- }
1549
- if (prev === void 0) {
1550
- if (next !== void 0 && next !== GLOBSTAR) {
1551
- pp[i2 + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
1552
- } else {
1553
- pp[i2] = twoStar;
1554
- }
1555
- } else if (next === void 0) {
1556
- pp[i2 - 1] = prev + "(?:\\/|" + twoStar + ")?";
1557
- } else if (next !== GLOBSTAR) {
1558
- pp[i2 - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
1559
- pp[i2 + 1] = GLOBSTAR;
1560
- }
1561
- });
1562
- return pp.filter((p) => p !== GLOBSTAR).join("/");
1563
- }).join("|");
1564
- const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
1565
- re = "^" + open + re + close + "$";
1566
- if (this.negate)
1567
- re = "^(?!" + re + ").+$";
1568
- try {
1569
- this.regexp = new RegExp(re, [...flags].join(""));
1570
- } catch (ex) {
1571
- this.regexp = false;
1572
- }
1573
- return this.regexp;
1574
- }
1575
- slashSplit(p) {
1576
- if (this.preserveMultipleSlashes) {
1577
- return p.split("/");
1578
- } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
1579
- return ["", ...p.split(/\/+/)];
1580
- } else {
1581
- return p.split(/\/+/);
1582
- }
1583
- }
1584
- match(f, partial = this.partial) {
1585
- this.debug("match", f, this.pattern);
1586
- if (this.comment) {
1587
- return false;
1588
- }
1589
- if (this.empty) {
1590
- return f === "";
1591
- }
1592
- if (f === "/" && partial) {
1593
- return true;
1594
- }
1595
- const options = this.options;
1596
- if (this.isWindows) {
1597
- f = f.split("\\").join("/");
1598
- }
1599
- const ff = this.slashSplit(f);
1600
- this.debug(this.pattern, "split", ff);
1601
- const set = this.set;
1602
- this.debug(this.pattern, "set", set);
1603
- let filename = ff[ff.length - 1];
1604
- if (!filename) {
1605
- for (let i2 = ff.length - 2; !filename && i2 >= 0; i2--) {
1606
- filename = ff[i2];
1607
- }
1608
- }
1609
- for (let i2 = 0; i2 < set.length; i2++) {
1610
- const pattern = set[i2];
1611
- let file = ff;
1612
- if (options.matchBase && pattern.length === 1) {
1613
- file = [filename];
1614
- }
1615
- const hit = this.matchOne(file, pattern, partial);
1616
- if (hit) {
1617
- if (options.flipNegate) {
1618
- return true;
1619
- }
1620
- return !this.negate;
1621
- }
1622
- }
1623
- if (options.flipNegate) {
1624
- return false;
1625
- }
1626
- return this.negate;
1627
- }
1628
- static defaults(def) {
1629
- return minimatch.defaults(def).Minimatch;
1630
- }
1631
- };
1632
- minimatch.AST = AST;
1633
- minimatch.Minimatch = Minimatch;
1634
- minimatch.escape = escape;
1635
- minimatch.unescape = unescape;
1636
-
1637
- // src/utils/regular-expression.ts
1638
- var escapeRegExpSpecialCharacters = (text) => {
1639
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1640
- };
1641
-
1642
- // src/utils/result.ts
1643
- var result_exports = {};
1644
- __export(result_exports, {
1645
- err: () => err,
1646
- map: () => map,
1647
- ok: () => ok,
1648
- unwrap: () => unwrap,
1649
- unwrapErr: () => unwrapErr
1650
- });
1651
- var ok = (value) => ({
1652
- isOk: true,
1653
- isErr: false,
1654
- value
1655
- });
1656
- var err = (value) => ({
1657
- isOk: false,
1658
- isErr: true,
1659
- value
1660
- });
1661
- function map(result, fn) {
1662
- if (result.isOk) {
1663
- const val = fn(result.value);
1664
- if (val instanceof Promise) {
1665
- return val.then((newVal) => ok(newVal));
1666
- } else {
1667
- return ok(val);
1668
- }
1669
- }
1670
- if (result.isErr) {
1671
- const value = result.value;
1672
- return err(value);
1673
- }
1674
- throw "should never get here";
1675
- }
1676
- var unwrap = (result) => {
1677
- if (result.isOk) {
1678
- return result.value;
1679
- } else {
1680
- throw result.value;
1681
- }
1682
- };
1683
- var unwrapErr = (result) => {
1684
- if (result.isErr) {
1685
- return result.value;
1686
- } else {
1687
- throw result.value;
1688
- }
1689
- };
1690
36
  var updateFallbackSlotVisibility = (elm) => {
1691
37
  const childNodes = internalCall(elm, "childNodes");
1692
38
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
@@ -1724,8 +70,9 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
1724
70
  let childNode;
1725
71
  for (; i2 < childNodes.length; i2++) {
1726
72
  childNode = childNodes[i2];
1727
- if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0)) {
73
+ if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
1728
74
  slottedNodes.push(childNode);
75
+ if (typeof slotName !== "undefined") return slottedNodes;
1729
76
  }
1730
77
  slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
1731
78
  }
@@ -1783,6 +130,18 @@ function patchSlotNode(node) {
1783
130
  node.assignedElements = assignedFactory(true);
1784
131
  node.assignedNodes = assignedFactory(false);
1785
132
  }
133
+ function dispatchSlotChangeEvent(elm) {
134
+ elm.dispatchEvent(new CustomEvent("slotchange", { bubbles: false, cancelable: false, composed: false }));
135
+ }
136
+ function findSlotFromSlottedNode(slottedNode, parentHost) {
137
+ var _a;
138
+ parentHost = parentHost || ((_a = slottedNode["s-ol"]) == null ? void 0 : _a.parentElement);
139
+ if (!parentHost) return { slotNode: null, slotName: "" };
140
+ const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
141
+ const childNodes = internalCall(parentHost, "childNodes");
142
+ const slotNode = getHostSlotNodes(childNodes, parentHost.tagName, slotName)[0];
143
+ return { slotNode, slotName };
144
+ }
1786
145
  function internalCall(node, method) {
1787
146
  if ("__" + method in node) {
1788
147
  const toReturn = node["__" + method];
@@ -1793,6 +152,15 @@ function internalCall(node, method) {
1793
152
  return node[method].bind(node);
1794
153
  }
1795
154
  }
155
+
156
+ // src/utils/helpers.ts
157
+ var isDef = (v) => v != null && v !== void 0;
158
+ var isComplexType = (o) => {
159
+ o = typeof o;
160
+ return o === "object" || o === "function";
161
+ };
162
+
163
+ // src/runtime/vdom/h.ts
1796
164
  var h = (nodeName, vnodeData, ...children) => {
1797
165
  let child = null;
1798
166
  let key = null;
@@ -1836,7 +204,8 @@ var newVNode = (tag, text) => {
1836
204
  const vnode = {
1837
205
  $flags$: 0,
1838
206
  $tag$: tag,
1839
- $text$: text,
207
+ // Normalize undefined to null to prevent rendering "undefined" as text
208
+ $text$: text != null ? text : null,
1840
209
  $elm$: null,
1841
210
  $children$: null
1842
211
  };
@@ -1853,18 +222,6 @@ var newVNode = (tag, text) => {
1853
222
  };
1854
223
  var Host = {};
1855
224
  var isHost = (node) => node && node.$tag$ === Host;
1856
- var createSupportsRuleRe = (selector) => {
1857
- const safeSelector2 = escapeRegExpSpecialCharacters(selector);
1858
- return new RegExp(
1859
- // First capture group: match any context before the selector that's not inside @supports selector()
1860
- // Using negative lookahead to avoid matching inside @supports selector(...) condition
1861
- `(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector2}))(${safeSelector2}\\b)`,
1862
- "g"
1863
- );
1864
- };
1865
- createSupportsRuleRe("::slotted");
1866
- createSupportsRuleRe(":host");
1867
- createSupportsRuleRe(":host-context");
1868
225
  var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
1869
226
  if (oldValue === newValue) {
1870
227
  return;
@@ -1902,7 +259,7 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
1902
259
  }
1903
260
  } else if (memberName === "key") ; else if (memberName === "ref") {
1904
261
  if (newValue) {
1905
- newValue(elm);
262
+ queueRefAttachment(newValue, elm);
1906
263
  }
1907
264
  } else if ((!elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
1908
265
  if (memberName[2] === "-") {
@@ -1922,6 +279,36 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
1922
279
  plt.ael(elm, memberName, newValue, capture);
1923
280
  }
1924
281
  }
282
+ } else if (memberName[0] === "a" && memberName.startsWith("attr:")) {
283
+ const propName = memberName.slice(5);
284
+ let attrName;
285
+ {
286
+ const hostRef = getHostRef(elm);
287
+ if (hostRef && hostRef.$cmpMeta$ && hostRef.$cmpMeta$.$members$) {
288
+ const memberMeta = hostRef.$cmpMeta$.$members$[propName];
289
+ if (memberMeta && memberMeta[1]) {
290
+ attrName = memberMeta[1];
291
+ }
292
+ }
293
+ }
294
+ if (!attrName) {
295
+ attrName = propName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
296
+ }
297
+ if (newValue == null || newValue === false) {
298
+ if (newValue !== false || elm.getAttribute(attrName) === "") {
299
+ elm.removeAttribute(attrName);
300
+ }
301
+ } else {
302
+ elm.setAttribute(attrName, newValue === true ? "" : newValue);
303
+ }
304
+ return;
305
+ } else if (memberName[0] === "p" && memberName.startsWith("prop:")) {
306
+ const propName = memberName.slice(5);
307
+ try {
308
+ elm[propName] = newValue;
309
+ } catch (e) {
310
+ }
311
+ return;
1925
312
  } else {
1926
313
  const isComplex = isComplexType(newValue);
1927
314
  if ((isProp || isComplex && newValue !== null) && !isSvg) {
@@ -1930,7 +317,7 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
1930
317
  const n = newValue == null ? "" : newValue;
1931
318
  if (memberName === "list") {
1932
319
  isProp = false;
1933
- } else if (oldValue == null || elm[memberName] != n) {
320
+ } else if (oldValue == null || elm[memberName] !== n) {
1934
321
  if (typeof elm.__lookupSetter__(memberName) === "function") {
1935
322
  elm[memberName] = n;
1936
323
  } else {
@@ -2027,6 +414,8 @@ var useNativeShadowDom = false;
2027
414
  var checkSlotFallbackVisibility = false;
2028
415
  var checkSlotRelocate = false;
2029
416
  var isSvgMode = false;
417
+ var refCallbacksToRemove = [];
418
+ var refCallbacksToAttach = [];
2030
419
  var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2031
420
  var _a;
2032
421
  const newVNode2 = newParentVNode.$children$[childIndex];
@@ -2049,7 +438,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2049
438
  );
2050
439
  }
2051
440
  }
2052
- if (newVNode2.$text$ !== null) {
441
+ if (newVNode2.$text$ != null) {
2053
442
  elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
2054
443
  } else if (newVNode2.$flags$ & 1 /* isSlotReference */) {
2055
444
  elm = newVNode2.$elm$ = win.document.createTextNode("");
@@ -2061,9 +450,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2061
450
  isSvgMode = newVNode2.$tag$ === "svg";
2062
451
  }
2063
452
  if (!win.document) {
2064
- throw new Error(
2065
- "You are trying to render a Stencil component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component."
2066
- );
453
+ throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");
2067
454
  }
2068
455
  elm = newVNode2.$elm$ = win.document.createElementNS(
2069
456
  isSvgMode ? SVG_NS : HTML_NS,
@@ -2105,9 +492,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2105
492
  patchSlotNode(elm);
2106
493
  oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
2107
494
  if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
2108
- {
2109
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
2110
- }
495
+ relocateToHostRoot(oldParentVNode.$elm$);
2111
496
  }
2112
497
  {
2113
498
  addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
@@ -2116,10 +501,37 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2116
501
  }
2117
502
  return elm;
2118
503
  };
504
+ var relocateToHostRoot = (parentElm) => {
505
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
506
+ const host = parentElm.closest(hostTagName.toLowerCase());
507
+ if (host != null) {
508
+ const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
509
+ (ref) => ref["s-cr"]
510
+ );
511
+ const childNodeArray = Array.from(
512
+ parentElm.__childNodes || parentElm.childNodes
513
+ );
514
+ for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
515
+ if (childNode["s-sh"] != null) {
516
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
517
+ childNode["s-sh"] = void 0;
518
+ checkSlotRelocate = true;
519
+ }
520
+ }
521
+ }
522
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
523
+ };
2119
524
  var putBackInOriginalLocation = (parentElm, recursive) => {
2120
525
  plt.$flags$ |= 1 /* isTmpDisconnected */;
2121
526
  const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
2122
- if (parentElm["s-sr"] && BUILD.experimentalSlotFixes) ;
527
+ if (parentElm["s-sr"]) {
528
+ let node = parentElm;
529
+ while (node = node.nextSibling) {
530
+ if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
531
+ oldSlotChildNodes.push(node);
532
+ }
533
+ }
534
+ }
2123
535
  for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
2124
536
  const childNode = oldSlotChildNodes[i2];
2125
537
  if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
@@ -2292,11 +704,17 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
2292
704
  const tag = newVNode2.$tag$;
2293
705
  const text = newVNode2.$text$;
2294
706
  let defaultHolder;
2295
- if (text === null) {
707
+ if (text == null) {
2296
708
  {
2297
709
  isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
2298
710
  }
2299
711
  {
712
+ if (tag === "slot" && !useNativeShadowDom) {
713
+ if (oldVNode.$name$ !== newVNode2.$name$) {
714
+ newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
715
+ relocateToHostRoot(newVNode2.$elm$.parentElement);
716
+ }
717
+ }
2300
718
  updateElement(oldVNode, newVNode2, isSvgMode);
2301
719
  }
2302
720
  if (oldChildren !== null && newChildren !== null) {
@@ -2333,7 +751,7 @@ var markSlotContentForRelocation = (elm) => {
2333
751
  const slotName = childNode["s-sn"];
2334
752
  for (j = hostContentNodes.length - 1; j >= 0; j--) {
2335
753
  node = hostContentNodes[j];
2336
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (true)) {
754
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
2337
755
  if (isNodeLocatedInSlot(node, slotName)) {
2338
756
  let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2339
757
  checkSlotFallbackVisibility = true;
@@ -2373,15 +791,39 @@ var markSlotContentForRelocation = (elm) => {
2373
791
  };
2374
792
  var nullifyVNodeRefs = (vNode) => {
2375
793
  {
2376
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
794
+ if (vNode.$attrs$ && vNode.$attrs$.ref) {
795
+ refCallbacksToRemove.push(() => vNode.$attrs$.ref(null));
796
+ }
2377
797
  vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
2378
798
  }
2379
799
  };
2380
- var insertBefore = (parent, newNode, reference) => {
2381
- if (typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
2382
- addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
800
+ var queueRefAttachment = (refCallback, elm) => {
801
+ {
802
+ refCallbacksToAttach.push(() => refCallback(elm));
2383
803
  }
804
+ };
805
+ var flushQueuedRefCallbacks = () => {
2384
806
  {
807
+ refCallbacksToRemove.forEach((cb) => cb());
808
+ refCallbacksToRemove.length = 0;
809
+ refCallbacksToAttach.forEach((cb) => cb());
810
+ refCallbacksToAttach.length = 0;
811
+ }
812
+ };
813
+ var insertBefore = (parent, newNode, reference, isInitialLoad) => {
814
+ {
815
+ if (typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
816
+ addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
817
+ } else if (typeof newNode["s-sn"] === "string") {
818
+ parent.insertBefore(newNode, reference);
819
+ const { slotNode } = findSlotFromSlottedNode(newNode);
820
+ if (slotNode && !isInitialLoad) dispatchSlotChangeEvent(slotNode);
821
+ return newNode;
822
+ }
823
+ }
824
+ if (parent.__insertBefore) {
825
+ return parent.__insertBefore(newNode, reference);
826
+ } else {
2385
827
  return parent == null ? void 0 : parent.insertBefore(newNode, reference);
2386
828
  }
2387
829
  };
@@ -2453,7 +895,12 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2453
895
  if (!nodeToRelocate["s-ol"] && win.document) {
2454
896
  const orgLocationNode = win.document.createTextNode("");
2455
897
  orgLocationNode["s-nr"] = nodeToRelocate;
2456
- insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
898
+ insertBefore(
899
+ nodeToRelocate.parentNode,
900
+ nodeToRelocate["s-ol"] = orgLocationNode,
901
+ nodeToRelocate,
902
+ isInitialLoad
903
+ );
2457
904
  }
2458
905
  }
2459
906
  for (const relocateData of relocateNodes) {
@@ -2465,7 +912,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2465
912
  if (slotRefNode) {
2466
913
  const parentNodeRef = slotRefNode.parentNode;
2467
914
  let insertBeforeNode = slotRefNode.nextSibling;
2468
- {
915
+ if (insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */) {
2469
916
  let orgLocationNode = (_b = nodeToRelocate["s-ol"]) == null ? void 0 : _b.previousSibling;
2470
917
  while (orgLocationNode) {
2471
918
  let refNode = (_c = orgLocationNode["s-nr"]) != null ? _c : null;
@@ -2486,10 +933,18 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2486
933
  const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
2487
934
  if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
2488
935
  if (nodeToRelocate !== insertBeforeNode) {
2489
- if (!nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
2490
- nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
936
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode, isInitialLoad);
937
+ if (nodeToRelocate.nodeType === 8 /* CommentNode */ && nodeToRelocate.nodeValue.startsWith("s-nt-")) {
938
+ const textNode = win.document.createTextNode(nodeToRelocate.nodeValue.replace(/^s-nt-/, ""));
939
+ textNode["s-hn"] = nodeToRelocate["s-hn"];
940
+ textNode["s-sn"] = nodeToRelocate["s-sn"];
941
+ textNode["s-sh"] = nodeToRelocate["s-sh"];
942
+ textNode["s-sr"] = nodeToRelocate["s-sr"];
943
+ textNode["s-ol"] = nodeToRelocate["s-ol"];
944
+ textNode["s-ol"]["s-nr"] = textNode;
945
+ insertBefore(nodeToRelocate.parentNode, textNode, nodeToRelocate, isInitialLoad);
946
+ nodeToRelocate.parentNode.removeChild(nodeToRelocate);
2491
947
  }
2492
- insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
2493
948
  if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
2494
949
  nodeToRelocate.hidden = (_d = nodeToRelocate["s-ih"]) != null ? _d : false;
2495
950
  }
@@ -2507,18 +962,26 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2507
962
  plt.$flags$ &= -2 /* isTmpDisconnected */;
2508
963
  relocateNodes.length = 0;
2509
964
  }
2510
- if (BUILD.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
965
+ if (!useNativeShadowDom && !(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && hostElm["s-cr"]) {
2511
966
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2512
967
  for (const childNode of children) {
2513
- if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"] && childNode.nodeType === 1 /* ElementNode */) {
968
+ if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2514
969
  if (isInitialLoad && childNode["s-ih"] == null) {
2515
970
  childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
2516
971
  }
2517
- childNode.hidden = true;
972
+ if (childNode.nodeType === 1 /* ElementNode */) {
973
+ childNode.hidden = true;
974
+ } else if (childNode.nodeType === 3 /* TextNode */ && !!childNode.nodeValue.trim()) {
975
+ const textCommentNode = win.document.createComment("s-nt-" + childNode.nodeValue);
976
+ textCommentNode["s-sn"] = childNode["s-sn"];
977
+ insertBefore(childNode.parentNode, textCommentNode, childNode, isInitialLoad);
978
+ childNode.parentNode.removeChild(childNode);
979
+ }
2518
980
  }
2519
981
  }
2520
982
  }
2521
983
  contentRef = void 0;
984
+ flushQueuedRefCallbacks();
2522
985
  };
2523
986
 
2524
987
  /**
@@ -3304,7 +1767,7 @@ const enqueue = (html) => {
3304
1767
  *
3305
1768
  * @returns {string}
3306
1769
  */
3307
- const process$1 = () => {
1770
+ const process = () => {
3308
1771
  const { config, constants } = getState();
3309
1772
  const step = " ".repeat(config.tab_size);
3310
1773
  const tag_wrap = config.tag_wrap;
@@ -3521,7 +1984,7 @@ const prettify = (html, config) => {
3521
1984
 
3522
1985
  html = minify(html);
3523
1986
  enqueue(html);
3524
- html = process$1();
1987
+ html = process();
3525
1988
 
3526
1989
  /* Revert html text within attribute values. */
3527
1990
  html = unsetIgnoreAttribute(html);