ipx 4.0.0-alpha.2 → 4.0.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.
- package/README.md +505 -77
- package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
- package/dist/_chunks/libs/@fastify/accept-negotiator.mjs +23 -24
- package/dist/_chunks/libs/crossws.d.mts +1 -0
- package/dist/_chunks/libs/css-select.mjs +1078 -938
- package/dist/_chunks/libs/css-tree.mjs +175 -297
- package/dist/_chunks/libs/csso.mjs +65 -110
- package/dist/_chunks/libs/etag.mjs +1 -1
- package/dist/_chunks/libs/h3.d.mts +3 -0
- package/dist/_chunks/libs/h3.mjs +138 -95
- package/dist/_chunks/libs/image-meta.d.mts +2 -6
- package/dist/_chunks/libs/image-meta.mjs +465 -306
- package/dist/_chunks/libs/sax.mjs +82 -80
- package/dist/_chunks/libs/svgo.mjs +970 -1013
- package/dist/_chunks/libs/ufo.mjs +17 -24
- package/dist/_chunks/node-fs.mjs +1100 -200
- package/dist/_chunks/rolldown-runtime.mjs +2 -11
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +4 -3
- package/dist/index.d.mts +242 -21
- package/dist/index.mjs +2 -2
- package/package.json +32 -28
- package/dist/THIRD-PARTY-LICENSES.md +0 -539
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { __commonJSMin as e, __require as t
|
|
2
|
-
import {
|
|
3
|
-
import { require_cjs$1 as
|
|
4
|
-
import { require_cjs as
|
|
5
|
-
import { require_sax as
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
function
|
|
1
|
+
import { __commonJSMin as e, __require as t } from "../rolldown-runtime.mjs";
|
|
2
|
+
import { require_commonjs as n, require_commonjs$1 as r } from "./css-select.mjs";
|
|
3
|
+
import { require_cjs$1 as i } from "./css-tree.mjs";
|
|
4
|
+
import { require_cjs as a } from "./csso.mjs";
|
|
5
|
+
import { require_sax as o } from "./sax.mjs";
|
|
6
|
+
var s = e(((e) => {
|
|
7
|
+
var s = t(`os`), c = t(`fs/promises`), l = t(`path`), u = n(), d = r(), f = i(), p = a(), m = o(), h = t(`url`);
|
|
8
|
+
function g(e) {
|
|
9
9
|
var t = Object.create(null);
|
|
10
|
-
return e && Object.keys(e).forEach(
|
|
10
|
+
return e && Object.keys(e).forEach(function(n) {
|
|
11
11
|
if (n !== "default") {
|
|
12
12
|
var r = Object.getOwnPropertyDescriptor(e, n);
|
|
13
13
|
Object.defineProperty(t, n, r.get ? r : {
|
|
@@ -17,17 +17,17 @@ var l = e(((e) => {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
})
|
|
20
|
+
}), t.default = e, Object.freeze(t);
|
|
21
21
|
}
|
|
22
|
-
var
|
|
23
|
-
let
|
|
22
|
+
var _ = g(d), v = g(f), y = g(p);
|
|
23
|
+
let b = Symbol(), x = (e, t, n) => {
|
|
24
24
|
let r = t[e.type];
|
|
25
|
-
if (!(r?.enter && r.enter(e, n) ===
|
|
26
|
-
if (e.type === `root`) for (let n of e.children)
|
|
27
|
-
if (e.type === `element` && n.children.includes(e)) for (let n of e.children)
|
|
25
|
+
if (!(r?.enter && r.enter(e, n) === b)) {
|
|
26
|
+
if (e.type === `root`) for (let n of e.children) x(n, t, e);
|
|
27
|
+
if (e.type === `element` && n.children.includes(e)) for (let n of e.children) x(n, t, e);
|
|
28
28
|
r?.exit && r.exit(e, n);
|
|
29
29
|
}
|
|
30
|
-
},
|
|
30
|
+
}, S = (e, t, n, r, i) => {
|
|
31
31
|
for (let a of n) {
|
|
32
32
|
let n = r?.[a.name];
|
|
33
33
|
if (n === !1) continue;
|
|
@@ -36,52 +36,40 @@ var l = e(((e) => {
|
|
|
36
36
|
...i,
|
|
37
37
|
...n
|
|
38
38
|
}, s = a.fn(e, o, t);
|
|
39
|
-
s != null &&
|
|
39
|
+
s != null && x(e, s);
|
|
40
40
|
}
|
|
41
|
-
},
|
|
41
|
+
}, ee = ({ name: e, plugins: t }) => ({
|
|
42
42
|
name: e,
|
|
43
43
|
isPreset: !0,
|
|
44
44
|
plugins: Object.freeze(t),
|
|
45
45
|
fn: (n, r, i) => {
|
|
46
46
|
let { floatPrecision: a, overrides: o } = r, s = {};
|
|
47
47
|
if (a != null && (s.floatPrecision = a), o) {
|
|
48
|
-
let n = t.map((
|
|
48
|
+
let n = t.map(({ name: e }) => e);
|
|
49
49
|
for (let t of Object.keys(o)) n.includes(t) || console.warn(`You are trying to configure ${t} which is not part of ${e}.\nTry to put it before or after, for example\n\nplugins: [\n {\n name: '${e}',\n },\n '${t}'\n]\n`);
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
S(n, i, t, o, s);
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
function
|
|
54
|
+
function C(e) {
|
|
55
55
|
let t = /* @__PURE__ */ new Map();
|
|
56
|
-
for (let n of e.children) t.set(n, e),
|
|
56
|
+
for (let n of e.children) t.set(n, e), x(n, { element: { enter: (e, n) => {
|
|
57
57
|
t.set(e, n);
|
|
58
58
|
} } }, e);
|
|
59
59
|
return t;
|
|
60
60
|
}
|
|
61
|
-
let
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return n;
|
|
65
|
-
}, oe = (e, t) => {
|
|
66
|
-
for (let n of t) if (D(n)) {
|
|
67
|
-
if (e(n)) return n;
|
|
68
|
-
let t = oe(e, O(n));
|
|
69
|
-
if (t) return t;
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
};
|
|
73
|
-
function se(e, t) {
|
|
74
|
-
let n = (n) => (t ||= E(e), t.get(n) || null);
|
|
61
|
+
let w = (e) => e.type === `element`, te = (e, t) => e.attributes[t], T = (e) => e.children || [], ne = (e) => e.name, re = (e) => e.children[0].type === `text` || e.children[0].type === `cdata` ? e.children[0].value : ``, ie = (e, t) => e.attributes[t] !== void 0;
|
|
62
|
+
function ae(e, t) {
|
|
63
|
+
let n = (n) => (t ||= C(e), t.get(n) || null);
|
|
75
64
|
return {
|
|
76
|
-
isTag:
|
|
77
|
-
existsOne: ee,
|
|
65
|
+
isTag: w,
|
|
78
66
|
getAttributeValue: te,
|
|
79
|
-
getChildren:
|
|
67
|
+
getChildren: T,
|
|
80
68
|
getName: ne,
|
|
81
69
|
getParent: n,
|
|
82
70
|
getSiblings: (e) => {
|
|
83
71
|
let t = n(e);
|
|
84
|
-
return t ?
|
|
72
|
+
return t ? T(t) : [];
|
|
85
73
|
},
|
|
86
74
|
getText: re,
|
|
87
75
|
hasAttrib: ie,
|
|
@@ -98,52 +86,50 @@ var l = e(((e) => {
|
|
|
98
86
|
a && (e[t] = r);
|
|
99
87
|
}
|
|
100
88
|
return e;
|
|
101
|
-
}
|
|
102
|
-
findAll: ae,
|
|
103
|
-
findOne: oe
|
|
89
|
+
}
|
|
104
90
|
};
|
|
105
91
|
}
|
|
106
|
-
function
|
|
92
|
+
function oe(e, t) {
|
|
107
93
|
return {
|
|
108
94
|
xmlMode: !0,
|
|
109
|
-
adapter:
|
|
95
|
+
adapter: ae(e, t)
|
|
110
96
|
};
|
|
111
97
|
}
|
|
112
|
-
let
|
|
113
|
-
t.children = t.children.filter((
|
|
98
|
+
let E = (e, t, n) => u.selectAll(t, e, oe(e, n)), se = (e, t, n) => u.selectOne(t, e, oe(e, n)), ce = (e, t, n) => t !== `` && u.is(e, t, oe(e, n)), D = (e, t) => {
|
|
99
|
+
t.children = t.children.filter((t) => t !== e);
|
|
114
100
|
};
|
|
115
|
-
var
|
|
101
|
+
var le = Object.freeze({
|
|
116
102
|
__proto__: null,
|
|
117
103
|
description: `removes doctype declaration`,
|
|
118
104
|
fn: () => ({ doctype: { enter: (e, t) => {
|
|
119
|
-
|
|
105
|
+
D(e, t);
|
|
120
106
|
} } }),
|
|
121
107
|
name: `removeDoctype`
|
|
122
|
-
}),
|
|
108
|
+
}), ue = Object.freeze({
|
|
123
109
|
__proto__: null,
|
|
124
110
|
description: `removes XML processing instructions`,
|
|
125
111
|
fn: () => ({ instruction: { enter: (e, t) => {
|
|
126
|
-
e.name === `xml` &&
|
|
112
|
+
e.name === `xml` && D(e, t);
|
|
127
113
|
} } }),
|
|
128
114
|
name: `removeXMLProcInst`
|
|
129
115
|
});
|
|
130
|
-
let
|
|
131
|
-
var
|
|
116
|
+
let de = [/^!/];
|
|
117
|
+
var fe = Object.freeze({
|
|
132
118
|
__proto__: null,
|
|
133
119
|
description: `removes comments`,
|
|
134
120
|
fn: (e, t) => {
|
|
135
|
-
let { preservePatterns: n =
|
|
121
|
+
let { preservePatterns: n = de } = t;
|
|
136
122
|
return { comment: { enter: (e, t) => {
|
|
137
123
|
if (n) {
|
|
138
124
|
if (!Array.isArray(n)) throw Error(`Expected array in removeComments preservePatterns parameter but received ${n}`);
|
|
139
|
-
if (n.some((
|
|
125
|
+
if (n.some((t) => new RegExp(t).test(e.value))) return;
|
|
140
126
|
}
|
|
141
|
-
|
|
127
|
+
D(e, t);
|
|
142
128
|
} } };
|
|
143
129
|
},
|
|
144
130
|
name: `removeComments`
|
|
145
131
|
});
|
|
146
|
-
let
|
|
132
|
+
let O = {
|
|
147
133
|
animation: /* @__PURE__ */ new Set([
|
|
148
134
|
`animate`,
|
|
149
135
|
`animateColor`,
|
|
@@ -253,15 +239,15 @@ var l = e(((e) => {
|
|
|
253
239
|
`feTile`,
|
|
254
240
|
`feTurbulence`
|
|
255
241
|
])
|
|
256
|
-
},
|
|
257
|
-
...
|
|
242
|
+
}, pe = /* @__PURE__ */ new Set([
|
|
243
|
+
...O.textContent,
|
|
258
244
|
`pre`,
|
|
259
245
|
`title`
|
|
260
|
-
]),
|
|
246
|
+
]), me = /* @__PURE__ */ new Set([
|
|
261
247
|
`glyph`,
|
|
262
248
|
`missing-glyph`,
|
|
263
249
|
`path`
|
|
264
|
-
]),
|
|
250
|
+
]), k = {
|
|
265
251
|
animationAddition: /* @__PURE__ */ new Set([`additive`, `accumulate`]),
|
|
266
252
|
animationAttributeTarget: /* @__PURE__ */ new Set([`attributeType`, `attributeName`]),
|
|
267
253
|
animationEvent: /* @__PURE__ */ new Set([
|
|
@@ -354,7 +340,7 @@ var l = e(((e) => {
|
|
|
354
340
|
`tableValues`,
|
|
355
341
|
`type`
|
|
356
342
|
])
|
|
357
|
-
},
|
|
343
|
+
}, he = {
|
|
358
344
|
core: { "xml:space": `default` },
|
|
359
345
|
presentation: {
|
|
360
346
|
clip: `auto`,
|
|
@@ -416,7 +402,7 @@ var l = e(((e) => {
|
|
|
416
402
|
exponent: `1`,
|
|
417
403
|
offset: `0`
|
|
418
404
|
}
|
|
419
|
-
},
|
|
405
|
+
}, ge = {
|
|
420
406
|
animationAttributeTarget: { unsafe: /* @__PURE__ */ new Set([`attributeType`]) },
|
|
421
407
|
conditionalProcessing: { unsafe: /* @__PURE__ */ new Set([`requiredFeatures`]) },
|
|
422
408
|
core: { unsafe: /* @__PURE__ */ new Set([
|
|
@@ -432,7 +418,7 @@ var l = e(((e) => {
|
|
|
432
418
|
`glyph-orientation-vertical`,
|
|
433
419
|
`kerning`
|
|
434
420
|
]) }
|
|
435
|
-
},
|
|
421
|
+
}, _e = {
|
|
436
422
|
a: {
|
|
437
423
|
attrsGroups: /* @__PURE__ */ new Set([
|
|
438
424
|
`conditionalProcessing`,
|
|
@@ -2258,7 +2244,7 @@ var l = e(((e) => {
|
|
|
2258
2244
|
`u2`
|
|
2259
2245
|
]) }
|
|
2260
2246
|
}
|
|
2261
|
-
},
|
|
2247
|
+
}, ve = /* @__PURE__ */ new Set([
|
|
2262
2248
|
`http://creativecommons.org/ns#`,
|
|
2263
2249
|
`http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd`,
|
|
2264
2250
|
`http://krita.org/namespaces/svg/krita`,
|
|
@@ -2283,7 +2269,7 @@ var l = e(((e) => {
|
|
|
2283
2269
|
`http://www.vector.evaxdesign.sk`,
|
|
2284
2270
|
`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,
|
|
2285
2271
|
`https://boxy-svg.com`
|
|
2286
|
-
]),
|
|
2272
|
+
]), A = /* @__PURE__ */ new Set([
|
|
2287
2273
|
`clip-path`,
|
|
2288
2274
|
`color-profile`,
|
|
2289
2275
|
`fill`,
|
|
@@ -2294,7 +2280,7 @@ var l = e(((e) => {
|
|
|
2294
2280
|
`mask`,
|
|
2295
2281
|
`stroke`,
|
|
2296
2282
|
`style`
|
|
2297
|
-
]),
|
|
2283
|
+
]), j = new Set(`clip-rule.color-interpolation-filters.color-interpolation.color-profile.color-rendering.color.cursor.direction.dominant-baseline.fill-opacity.fill-rule.fill.font-family.font-size-adjust.font-size.font-stretch.font-style.font-variant.font-weight.font.glyph-orientation-horizontal.glyph-orientation-vertical.image-rendering.letter-spacing.marker-end.marker-mid.marker-start.marker.paint-order.pointer-events.shape-rendering.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.stroke.text-anchor.text-rendering.transform.visibility.word-spacing.writing-mode`.split(`.`)), ye = /* @__PURE__ */ new Set([
|
|
2298
2284
|
`clip-path`,
|
|
2299
2285
|
`display`,
|
|
2300
2286
|
`filter`,
|
|
@@ -2303,7 +2289,7 @@ var l = e(((e) => {
|
|
|
2303
2289
|
`text-decoration`,
|
|
2304
2290
|
`transform`,
|
|
2305
2291
|
`unicode-bidi`
|
|
2306
|
-
]),
|
|
2292
|
+
]), be = {
|
|
2307
2293
|
aliceblue: `#f0f8ff`,
|
|
2308
2294
|
antiquewhite: `#faebd7`,
|
|
2309
2295
|
aqua: `#0ff`,
|
|
@@ -2452,7 +2438,7 @@ var l = e(((e) => {
|
|
|
2452
2438
|
whitesmoke: `#f5f5f5`,
|
|
2453
2439
|
yellow: `#ff0`,
|
|
2454
2440
|
yellowgreen: `#9acd32`
|
|
2455
|
-
},
|
|
2441
|
+
}, xe = {
|
|
2456
2442
|
"#f0ffff": `azure`,
|
|
2457
2443
|
"#f5f5dc": `beige`,
|
|
2458
2444
|
"#ffe4c4": `bisque`,
|
|
@@ -2485,14 +2471,14 @@ var l = e(((e) => {
|
|
|
2485
2471
|
"#ff6347": `tomato`,
|
|
2486
2472
|
"#ee82ee": `violet`,
|
|
2487
2473
|
"#f5deb3": `wheat`
|
|
2488
|
-
},
|
|
2474
|
+
}, Se = /* @__PURE__ */ new Set([
|
|
2489
2475
|
`color`,
|
|
2490
2476
|
`fill`,
|
|
2491
2477
|
`flood-color`,
|
|
2492
2478
|
`lighting-color`,
|
|
2493
2479
|
`stop-color`,
|
|
2494
2480
|
`stroke`
|
|
2495
|
-
]),
|
|
2481
|
+
]), Ce = {
|
|
2496
2482
|
displayState: /* @__PURE__ */ new Set([
|
|
2497
2483
|
`fullscreen`,
|
|
2498
2484
|
`modal`,
|
|
@@ -2561,100 +2547,94 @@ var l = e(((e) => {
|
|
|
2561
2547
|
`has`
|
|
2562
2548
|
])
|
|
2563
2549
|
};
|
|
2564
|
-
var
|
|
2550
|
+
var we = Object.freeze({
|
|
2565
2551
|
__proto__: null,
|
|
2566
|
-
attrsGroups:
|
|
2567
|
-
attrsGroupsDefaults:
|
|
2568
|
-
attrsGroupsDeprecated:
|
|
2569
|
-
colorsNames:
|
|
2570
|
-
colorsProps:
|
|
2571
|
-
colorsShortNames:
|
|
2572
|
-
editorNamespaces:
|
|
2573
|
-
elems:
|
|
2574
|
-
elemsGroups:
|
|
2575
|
-
inheritableAttrs:
|
|
2576
|
-
pathElems:
|
|
2577
|
-
presentationNonInheritableGroupAttrs:
|
|
2578
|
-
pseudoClasses:
|
|
2579
|
-
referencesProps:
|
|
2580
|
-
textElems:
|
|
2552
|
+
attrsGroups: k,
|
|
2553
|
+
attrsGroupsDefaults: he,
|
|
2554
|
+
attrsGroupsDeprecated: ge,
|
|
2555
|
+
colorsNames: be,
|
|
2556
|
+
colorsProps: Se,
|
|
2557
|
+
colorsShortNames: xe,
|
|
2558
|
+
editorNamespaces: ve,
|
|
2559
|
+
elems: _e,
|
|
2560
|
+
elemsGroups: O,
|
|
2561
|
+
inheritableAttrs: j,
|
|
2562
|
+
pathElems: me,
|
|
2563
|
+
presentationNonInheritableGroupAttrs: ye,
|
|
2564
|
+
pseudoClasses: Ce,
|
|
2565
|
+
referencesProps: A,
|
|
2566
|
+
textElems: pe
|
|
2581
2567
|
});
|
|
2582
|
-
let
|
|
2568
|
+
let Te = v.walk.skip, Ee = (e, t) => {
|
|
2583
2569
|
let n = [];
|
|
2584
|
-
e.block.children.forEach((
|
|
2570
|
+
e.block.children.forEach((e) => {
|
|
2585
2571
|
e.type === `Declaration` && n.push({
|
|
2586
2572
|
name: e.property,
|
|
2587
|
-
value:
|
|
2573
|
+
value: v.generate(e.value),
|
|
2588
2574
|
important: e.important === !0
|
|
2589
2575
|
});
|
|
2590
|
-
})
|
|
2576
|
+
});
|
|
2591
2577
|
let r = [];
|
|
2592
|
-
return
|
|
2578
|
+
return v.walk(e.prelude, (e) => {
|
|
2593
2579
|
if (e.type === `Selector`) {
|
|
2594
|
-
let i =
|
|
2595
|
-
|
|
2580
|
+
let i = v.clone(e), a = !1;
|
|
2581
|
+
v.walk(i, (e, t, n) => {
|
|
2596
2582
|
e.type === `PseudoClassSelector` && (a = !0, n.remove(t));
|
|
2597
|
-
})
|
|
2598
|
-
specificity:
|
|
2583
|
+
}), r.push({
|
|
2584
|
+
specificity: p.syntax.specificity(e),
|
|
2599
2585
|
dynamic: a || t,
|
|
2600
|
-
selector:
|
|
2586
|
+
selector: v.generate(i),
|
|
2601
2587
|
declarations: n
|
|
2602
2588
|
});
|
|
2603
2589
|
}
|
|
2604
|
-
})
|
|
2605
|
-
},
|
|
2606
|
-
let n = [], r =
|
|
2590
|
+
}), r;
|
|
2591
|
+
}, De = (e, t) => {
|
|
2592
|
+
let n = [], r = v.parse(e, {
|
|
2607
2593
|
parseValue: !1,
|
|
2608
2594
|
parseAtrulePrelude: !1
|
|
2609
2595
|
});
|
|
2610
|
-
return
|
|
2611
|
-
if (e.type === `Rule`) return n.push(...
|
|
2596
|
+
return v.walk(r, (e) => {
|
|
2597
|
+
if (e.type === `Rule`) return n.push(...Ee(e, t || !1)), Te;
|
|
2612
2598
|
if (e.type === `Atrule`) return [
|
|
2613
2599
|
`keyframes`,
|
|
2614
2600
|
`-webkit-keyframes`,
|
|
2615
2601
|
`-o-keyframes`,
|
|
2616
2602
|
`-moz-keyframes`
|
|
2617
|
-
].includes(e.name) ||
|
|
2618
|
-
if (e.type === `Rule`) return n.push(...
|
|
2619
|
-
})
|
|
2620
|
-
})
|
|
2621
|
-
},
|
|
2622
|
-
let t = [], n =
|
|
2603
|
+
].includes(e.name) || v.walk(e, (e) => {
|
|
2604
|
+
if (e.type === `Rule`) return n.push(...Ee(e, t || !0)), Te;
|
|
2605
|
+
}), Te;
|
|
2606
|
+
}), n;
|
|
2607
|
+
}, Oe = (e) => {
|
|
2608
|
+
let t = [], n = v.parse(e, {
|
|
2623
2609
|
context: `declarationList`,
|
|
2624
2610
|
parseValue: !1
|
|
2625
2611
|
});
|
|
2626
|
-
return
|
|
2612
|
+
return v.walk(n, (e) => {
|
|
2627
2613
|
e.type === `Declaration` && t.push({
|
|
2628
2614
|
name: e.property,
|
|
2629
|
-
value:
|
|
2615
|
+
value: v.generate(e.value),
|
|
2630
2616
|
important: e.important === !0
|
|
2631
2617
|
});
|
|
2632
|
-
})
|
|
2633
|
-
},
|
|
2618
|
+
}), t;
|
|
2619
|
+
}, ke = (e, t, n) => {
|
|
2634
2620
|
let r = {}, i = /* @__PURE__ */ new Map();
|
|
2635
|
-
for (let [e, n] of Object.entries(t.attributes))
|
|
2621
|
+
for (let [e, n] of Object.entries(t.attributes)) k.presentation.has(e) && (r[e] = {
|
|
2636
2622
|
type: `static`,
|
|
2637
2623
|
inherited: !1,
|
|
2638
2624
|
value: n
|
|
2639
2625
|
}, i.set(e, !1));
|
|
2640
|
-
for (let { selector: a, declarations: o, dynamic: s } of e.rules) if (
|
|
2626
|
+
for (let { selector: a, declarations: o, dynamic: s } of e.rules) if (ce(t, a, n)) for (let { name: e, value: t, important: n } of o) {
|
|
2641
2627
|
let a = r[e];
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
(a == null || n === !0 || i.get(e) === !1) && (r[e] = {
|
|
2651
|
-
type: `static`,
|
|
2652
|
-
inherited: !1,
|
|
2653
|
-
value: t
|
|
2654
|
-
}, i.set(e, n));
|
|
2655
|
-
}
|
|
2628
|
+
a && a.type === `dynamic` || (s ? r[e] = {
|
|
2629
|
+
type: `dynamic`,
|
|
2630
|
+
inherited: !1
|
|
2631
|
+
} : (a == null || n === !0 || i.get(e) === !1) && (r[e] = {
|
|
2632
|
+
type: `static`,
|
|
2633
|
+
inherited: !1,
|
|
2634
|
+
value: t
|
|
2635
|
+
}, i.set(e, n)));
|
|
2656
2636
|
}
|
|
2657
|
-
let a = t.attributes.style == null ? [] :
|
|
2637
|
+
let a = t.attributes.style == null ? [] : Oe(t.attributes.style);
|
|
2658
2638
|
for (let { name: e, value: t, important: n } of a) {
|
|
2659
2639
|
let a = r[e];
|
|
2660
2640
|
a && a.type === `dynamic` || (a == null || n === !0 || i.get(e) === !1) && (r[e] = {
|
|
@@ -2664,83 +2644,83 @@ var l = e(((e) => {
|
|
|
2664
2644
|
}, i.set(e, n));
|
|
2665
2645
|
}
|
|
2666
2646
|
return r;
|
|
2667
|
-
},
|
|
2647
|
+
}, Ae = (e, t) => {
|
|
2668
2648
|
for (let n = 0; n < 4; n += 1) {
|
|
2669
2649
|
if (e[n] < t[n]) return -1;
|
|
2670
2650
|
if (e[n] > t[n]) return 1;
|
|
2671
2651
|
}
|
|
2672
2652
|
return 0;
|
|
2673
|
-
},
|
|
2653
|
+
}, M = (e) => {
|
|
2674
2654
|
let t = [], n = /* @__PURE__ */ new Map();
|
|
2675
|
-
return
|
|
2655
|
+
return x(e, { element: { enter: (e, r) => {
|
|
2676
2656
|
if (n.set(e, r), e.name === `style` && (e.attributes.type == null || e.attributes.type === `` || e.attributes.type === `text/css`)) {
|
|
2677
2657
|
let n = e.attributes.media != null && e.attributes.media !== `all`;
|
|
2678
|
-
for (let r of e.children) r.type !== `text` && r.type !== `cdata` || t.push(...
|
|
2658
|
+
for (let r of e.children) r.type !== `text` && r.type !== `cdata` || t.push(...De(r.value, n));
|
|
2679
2659
|
}
|
|
2680
|
-
} } }), t.sort((
|
|
2660
|
+
} } }), t.sort((e, t) => Ae(e.specificity, t.specificity)), {
|
|
2681
2661
|
rules: t,
|
|
2682
2662
|
parents: n
|
|
2683
2663
|
};
|
|
2684
|
-
},
|
|
2685
|
-
let { parents: n } = e, r =
|
|
2664
|
+
}, N = (e, t) => {
|
|
2665
|
+
let { parents: n } = e, r = ke(e, t, n), i = n.get(t);
|
|
2686
2666
|
for (; i != null && i.type !== `root`;) {
|
|
2687
|
-
let t =
|
|
2688
|
-
for (let [e, n] of Object.entries(t)) r[e] == null &&
|
|
2667
|
+
let t = ke(e, i, n);
|
|
2668
|
+
for (let [e, n] of Object.entries(t)) r[e] == null && j.has(e) && !ye.has(e) && (r[e] = {
|
|
2689
2669
|
...n,
|
|
2690
2670
|
inherited: !0
|
|
2691
2671
|
});
|
|
2692
2672
|
i = n.get(i);
|
|
2693
2673
|
}
|
|
2694
2674
|
return r;
|
|
2695
|
-
},
|
|
2696
|
-
let i = typeof e == `string` ?
|
|
2697
|
-
for (let e of i) if (e.some((
|
|
2675
|
+
}, je = (e, t, n = null, r = !1) => {
|
|
2676
|
+
let i = typeof e == `string` ? _.parse(e) : _.parse(v.generate(e.data));
|
|
2677
|
+
for (let e of i) if (e.some((i, a) => r && (a === e.length - 1 || !_.isTraversal(e[a + 1])) || i.type !== `attribute` || i.name !== t ? !1 : n == null || i.value === n)) return !0;
|
|
2698
2678
|
return !1;
|
|
2699
2679
|
};
|
|
2700
|
-
function
|
|
2680
|
+
function Me(e) {
|
|
2701
2681
|
let t = /* @__PURE__ */ new Set();
|
|
2702
|
-
return e.rules.forEach((
|
|
2703
|
-
|
|
2704
|
-
e.forEach((
|
|
2682
|
+
return e.rules.forEach((e) => {
|
|
2683
|
+
_.parse(e.selector).forEach((e) => {
|
|
2684
|
+
e.forEach((e) => {
|
|
2705
2685
|
e.type === `attribute` && t.add(e.name);
|
|
2706
|
-
})
|
|
2707
|
-
})
|
|
2708
|
-
})
|
|
2686
|
+
});
|
|
2687
|
+
});
|
|
2688
|
+
}), t;
|
|
2709
2689
|
}
|
|
2710
|
-
function
|
|
2711
|
-
t && (t.safe && t.safe.forEach((
|
|
2690
|
+
function Ne(e, t, n, r) {
|
|
2691
|
+
t && (t.safe && t.safe.forEach((t) => {
|
|
2712
2692
|
r.has(t) || delete e.attributes[t];
|
|
2713
|
-
})
|
|
2693
|
+
}), n.removeUnsafe && t.unsafe && t.unsafe.forEach((t) => {
|
|
2714
2694
|
r.has(t) || delete e.attributes[t];
|
|
2715
|
-
}))
|
|
2695
|
+
}));
|
|
2716
2696
|
}
|
|
2717
|
-
function
|
|
2718
|
-
let n =
|
|
2697
|
+
function Pe(e, t) {
|
|
2698
|
+
let n = Me(M(e));
|
|
2719
2699
|
return { element: { enter: (e) => {
|
|
2720
|
-
let r =
|
|
2721
|
-
r && (r.attrsGroups.has(`core`) && e.attributes[`xml:lang`] && !n.has(`xml:lang`) && e.attributes.lang && delete e.attributes[`xml:lang`], r.attrsGroups.forEach((
|
|
2722
|
-
|
|
2723
|
-
})
|
|
2700
|
+
let r = _e[e.name];
|
|
2701
|
+
r && (r.attrsGroups.has(`core`) && e.attributes[`xml:lang`] && !n.has(`xml:lang`) && e.attributes.lang && delete e.attributes[`xml:lang`], r.attrsGroups.forEach((r) => {
|
|
2702
|
+
Ne(e, ge[r], t, n);
|
|
2703
|
+
}), Ne(e, r.deprecated, t, n));
|
|
2724
2704
|
} } };
|
|
2725
2705
|
}
|
|
2726
|
-
var
|
|
2706
|
+
var Fe = Object.freeze({
|
|
2727
2707
|
__proto__: null,
|
|
2728
2708
|
description: `removes deprecated attributes`,
|
|
2729
|
-
fn:
|
|
2709
|
+
fn: Pe,
|
|
2730
2710
|
name: `removeDeprecatedAttrs`
|
|
2731
|
-
}),
|
|
2711
|
+
}), Ie = Object.freeze({
|
|
2732
2712
|
__proto__: null,
|
|
2733
2713
|
description: `removes <metadata>`,
|
|
2734
2714
|
fn: () => ({ element: { enter: (e, t) => {
|
|
2735
|
-
e.name === `metadata` &&
|
|
2715
|
+
e.name === `metadata` && D(e, t);
|
|
2736
2716
|
} } }),
|
|
2737
2717
|
name: `removeMetadata`
|
|
2738
|
-
}),
|
|
2718
|
+
}), Le = Object.freeze({
|
|
2739
2719
|
__proto__: null,
|
|
2740
2720
|
description: `removes editors namespaces, elements and attributes`,
|
|
2741
2721
|
fn: (e, t) => {
|
|
2742
|
-
let n = [...
|
|
2743
|
-
Array.isArray(t.additionalNamespaces) && (n = [...
|
|
2722
|
+
let n = [...ve];
|
|
2723
|
+
Array.isArray(t.additionalNamespaces) && (n = [...ve, ...t.additionalNamespaces]);
|
|
2744
2724
|
let r = [];
|
|
2745
2725
|
return { element: { enter: (e, t) => {
|
|
2746
2726
|
if (e.name === `svg`) for (let [t, i] of Object.entries(e.attributes)) t.startsWith(`xmlns:`) && n.includes(i) && (r.push(t.slice(6)), delete e.attributes[t]);
|
|
@@ -2750,58 +2730,54 @@ var l = e(((e) => {
|
|
|
2750
2730
|
}
|
|
2751
2731
|
if (e.name.includes(`:`)) {
|
|
2752
2732
|
let [n] = e.name.split(`:`);
|
|
2753
|
-
r.includes(n) &&
|
|
2733
|
+
r.includes(n) && D(e, t);
|
|
2754
2734
|
}
|
|
2755
2735
|
} } };
|
|
2756
2736
|
},
|
|
2757
2737
|
name: `removeEditorsNSData`
|
|
2758
2738
|
});
|
|
2759
|
-
let
|
|
2760
|
-
var
|
|
2739
|
+
let Re = /(\S)\r?\n(\S)/g, ze = /\r?\n/g, Be = /\s{2,}/g;
|
|
2740
|
+
var Ve = Object.freeze({
|
|
2761
2741
|
__proto__: null,
|
|
2762
2742
|
description: `cleanups attributes from newlines, trailing and repeating spaces`,
|
|
2763
2743
|
fn: (e, t) => {
|
|
2764
2744
|
let { newlines: n = !0, trim: r = !0, spaces: i = !0 } = t;
|
|
2765
2745
|
return { element: { enter: (e) => {
|
|
2766
|
-
for (let t of Object.keys(e.attributes)) n && (e.attributes[t] = e.attributes[t].replace(
|
|
2746
|
+
for (let t of Object.keys(e.attributes)) n && (e.attributes[t] = e.attributes[t].replace(Re, (e, t, n) => t + ` ` + n), e.attributes[t] = e.attributes[t].replace(ze, ``)), r && (e.attributes[t] = e.attributes[t].trim()), i && (e.attributes[t] = e.attributes[t].replace(Be, ` `));
|
|
2767
2747
|
} } };
|
|
2768
2748
|
},
|
|
2769
2749
|
name: `cleanupAttrs`
|
|
2770
|
-
}),
|
|
2750
|
+
}), He = Object.freeze({
|
|
2771
2751
|
__proto__: null,
|
|
2772
2752
|
description: `merge multiple style elements into one`,
|
|
2773
2753
|
fn: () => {
|
|
2774
2754
|
let e = null, t = ``, n = `text`;
|
|
2775
2755
|
return { element: { enter: (r, i) => {
|
|
2776
|
-
if (r.name === `foreignObject`) return
|
|
2756
|
+
if (r.name === `foreignObject`) return b;
|
|
2777
2757
|
if (r.name !== `style` || r.attributes.type != null && r.attributes.type !== `` && r.attributes.type !== `text/css`) return;
|
|
2778
2758
|
let a = ``;
|
|
2779
2759
|
for (let e of r.children) e.type === `text` && (a += e.value), e.type === `cdata` && (n = `cdata`, a += e.value);
|
|
2780
|
-
|
|
2781
|
-
A(r, i);
|
|
2782
|
-
return;
|
|
2783
|
-
}
|
|
2784
|
-
r.attributes.media == null ? t += a : (t += `@media ${r.attributes.media}{${a}}`, delete r.attributes.media), e == null ? e = r : (A(r, i), e.children = [{
|
|
2760
|
+
a.trim().length === 0 ? D(r, i) : (r.attributes.media == null ? t += a : (t += `@media ${r.attributes.media}{${a}}`, delete r.attributes.media), e == null ? e = r : (D(r, i), e.children = [{
|
|
2785
2761
|
type: n,
|
|
2786
2762
|
value: t
|
|
2787
|
-
}]);
|
|
2763
|
+
}]));
|
|
2788
2764
|
} } };
|
|
2789
2765
|
},
|
|
2790
2766
|
name: `mergeStyles`
|
|
2791
2767
|
});
|
|
2792
|
-
let
|
|
2793
|
-
var
|
|
2768
|
+
let Ue = [...Ce.functional, ...Ce.treeStructural];
|
|
2769
|
+
var We = Object.freeze({
|
|
2794
2770
|
__proto__: null,
|
|
2795
2771
|
description: `inline styles (additional options)`,
|
|
2796
2772
|
fn: (e, t) => {
|
|
2797
2773
|
let { onlyMatchedOnce: n = !0, removeMatchedSelectors: r = !0, useMqs: i = [``, `screen`], usePseudos: a = [``] } = t, o = [], s = [];
|
|
2798
2774
|
return {
|
|
2799
2775
|
element: { enter: (e, t) => {
|
|
2800
|
-
if (e.name === `foreignObject`) return
|
|
2776
|
+
if (e.name === `foreignObject`) return b;
|
|
2801
2777
|
if (e.name !== `style` || e.children.length === 0 || e.attributes.type != null && e.attributes.type !== `` && e.attributes.type !== `text/css`) return;
|
|
2802
|
-
let n = e.children.filter((
|
|
2778
|
+
let n = e.children.filter((e) => e.type === `text` || e.type === `cdata`).map((e) => e.value).join(``), r;
|
|
2803
2779
|
try {
|
|
2804
|
-
r =
|
|
2780
|
+
r = v.parse(n, {
|
|
2805
2781
|
parseValue: !1,
|
|
2806
2782
|
parseCustomProperty: !1
|
|
2807
2783
|
});
|
|
@@ -2812,22 +2788,22 @@ var l = e(((e) => {
|
|
|
2812
2788
|
node: e,
|
|
2813
2789
|
parentNode: t,
|
|
2814
2790
|
cssAst: r
|
|
2815
|
-
}),
|
|
2791
|
+
}), v.walk(r, {
|
|
2816
2792
|
visit: `Rule`,
|
|
2817
2793
|
enter(e) {
|
|
2818
2794
|
let t = this.atrule, n = ``;
|
|
2819
|
-
t != null && (n = t.name, t.prelude != null && (n += ` ${
|
|
2795
|
+
t != null && (n = t.name, t.prelude != null && (n += ` ${v.generate(t.prelude)}`)), i.includes(n) && e.prelude.type === `SelectorList` && e.prelude.children.forEach((t, n) => {
|
|
2820
2796
|
if (t.type === `Selector`) {
|
|
2821
2797
|
let r = [];
|
|
2822
|
-
t.children.forEach((
|
|
2823
|
-
(e.type === `PseudoClassSelector` || e.type === `PseudoElementSelector`) && !
|
|
2798
|
+
t.children.forEach((e, t, n) => {
|
|
2799
|
+
(e.type === `PseudoClassSelector` || e.type === `PseudoElementSelector`) && !Ue.includes(e.name) && r.push({
|
|
2824
2800
|
item: t,
|
|
2825
2801
|
list: n
|
|
2826
2802
|
});
|
|
2827
|
-
})
|
|
2828
|
-
let i =
|
|
2803
|
+
});
|
|
2804
|
+
let i = v.generate({
|
|
2829
2805
|
type: `Selector`,
|
|
2830
|
-
children: new
|
|
2806
|
+
children: new v.List().fromArray(r.map((e) => e.item.data))
|
|
2831
2807
|
});
|
|
2832
2808
|
if (a.includes(i)) for (let e of r) e.list.remove(e.item);
|
|
2833
2809
|
s.push({
|
|
@@ -2836,43 +2812,46 @@ var l = e(((e) => {
|
|
|
2836
2812
|
item: n
|
|
2837
2813
|
});
|
|
2838
2814
|
}
|
|
2839
|
-
})
|
|
2815
|
+
});
|
|
2840
2816
|
}
|
|
2841
2817
|
});
|
|
2842
2818
|
} },
|
|
2843
2819
|
root: { exit: () => {
|
|
2844
2820
|
if (o.length === 0) return;
|
|
2845
|
-
let t = s.slice().sort((
|
|
2821
|
+
let t = s.slice().sort((e, t) => {
|
|
2822
|
+
let n = p.syntax.specificity(e.item.data), r = p.syntax.specificity(t.item.data);
|
|
2823
|
+
return Ae(n, r);
|
|
2824
|
+
}).reverse();
|
|
2846
2825
|
for (let i of t) {
|
|
2847
|
-
let t =
|
|
2826
|
+
let t = v.generate(i.item.data), a = [];
|
|
2848
2827
|
try {
|
|
2849
|
-
for (let n of
|
|
2828
|
+
for (let n of E(e, t)) n.type === `element` && a.push(n);
|
|
2850
2829
|
} catch {
|
|
2851
2830
|
continue;
|
|
2852
2831
|
}
|
|
2853
2832
|
if (a.length !== 0 && !(n && a.length > 1)) {
|
|
2854
2833
|
for (let e of a) {
|
|
2855
|
-
let t =
|
|
2834
|
+
let t = v.parse(e.attributes.style ?? ``, {
|
|
2856
2835
|
context: `declarationList`,
|
|
2857
2836
|
parseValue: !1
|
|
2858
2837
|
});
|
|
2859
2838
|
if (t.type !== `DeclarationList`) continue;
|
|
2860
2839
|
let n = /* @__PURE__ */ new Map(), r;
|
|
2861
|
-
|
|
2840
|
+
v.walk(t, {
|
|
2862
2841
|
visit: `Declaration`,
|
|
2863
2842
|
enter(e, t) {
|
|
2864
2843
|
r ??= t, n.set(e.property.toLowerCase(), t);
|
|
2865
2844
|
}
|
|
2866
|
-
}),
|
|
2845
|
+
}), v.walk(i.rule, {
|
|
2867
2846
|
visit: `Declaration`,
|
|
2868
2847
|
enter(i) {
|
|
2869
2848
|
let a = i.property;
|
|
2870
|
-
|
|
2849
|
+
k.presentation.has(a) && !s.some((e) => je(e.item, a)) && delete e.attributes[a];
|
|
2871
2850
|
let o = n.get(a), c = t.children.createItem(i);
|
|
2872
2851
|
o == null ? t.children.insert(c, r) : o.data.important !== !0 && i.important === !0 && (t.children.replace(o, c), n.set(a, c));
|
|
2873
2852
|
}
|
|
2874
2853
|
});
|
|
2875
|
-
let a =
|
|
2854
|
+
let a = v.generate(t);
|
|
2876
2855
|
a.length !== 0 && (e.attributes.style = a);
|
|
2877
2856
|
}
|
|
2878
2857
|
r && a.length !== 0 && i.rule.prelude.type === `SelectorList` && i.rule.prelude.children.remove(i.item), i.matchedElements = a;
|
|
@@ -2881,20 +2860,20 @@ var l = e(((e) => {
|
|
|
2881
2860
|
if (r) {
|
|
2882
2861
|
for (let e of t) if (e.matchedElements != null && !(n && e.matchedElements.length > 1)) for (let t of e.matchedElements) {
|
|
2883
2862
|
let n = new Set(t.attributes.class == null ? null : t.attributes.class.split(` `));
|
|
2884
|
-
for (let t of e.node.children) t.type !== `ClassSelector` || s.some((
|
|
2863
|
+
for (let t of e.node.children) t.type !== `ClassSelector` || s.some((e) => je(e.item, `class`, t.name, !0)) || n.delete(t.name);
|
|
2885
2864
|
n.size === 0 ? delete t.attributes.class : t.attributes.class = Array.from(n).join(` `);
|
|
2886
2865
|
let r = e.node.children.first;
|
|
2887
|
-
r?.type !== `IdSelector` || t.attributes.id !== r.name || s.some((
|
|
2866
|
+
r?.type !== `IdSelector` || t.attributes.id !== r.name || s.some((e) => je(e.item, `id`, r.name, !0)) || delete t.attributes.id;
|
|
2888
2867
|
}
|
|
2889
|
-
for (let e of o) if (
|
|
2868
|
+
for (let e of o) if (v.walk(e.cssAst, {
|
|
2890
2869
|
visit: `Rule`,
|
|
2891
2870
|
enter: function(e, t, n) {
|
|
2892
2871
|
e.type === `Rule` && e.prelude.type === `SelectorList` && e.prelude.children.isEmpty && n.remove(t);
|
|
2893
2872
|
}
|
|
2894
|
-
}), e.cssAst.children.isEmpty)
|
|
2873
|
+
}), e.cssAst.children.isEmpty) D(e.node, e.parentNode);
|
|
2895
2874
|
else {
|
|
2896
2875
|
let t = e.node.children[0];
|
|
2897
|
-
t.type !== `text` && t.type !== `cdata` || (t.value =
|
|
2876
|
+
t.type !== `text` && t.type !== `cdata` || (t.value = v.generate(e.cssAst));
|
|
2898
2877
|
}
|
|
2899
2878
|
}
|
|
2900
2879
|
} }
|
|
@@ -2902,45 +2881,57 @@ var l = e(((e) => {
|
|
|
2902
2881
|
},
|
|
2903
2882
|
name: `inlineStyles`
|
|
2904
2883
|
});
|
|
2905
|
-
let
|
|
2884
|
+
let Ge = /\burl\((["'])?#(.+?)\1\)/g, Ke = /^#(.+?)$/, qe = /(\w+)\.[a-zA-Z]/, Je = (e, t) => {
|
|
2906
2885
|
let n = `data:image/svg+xml`;
|
|
2907
2886
|
return t && t !== `base64` ? t === `enc` ? e = n + `,` + encodeURIComponent(e) : t === `unenc` && (e = n + `,` + e) : (n += `;base64,`, e = n + Buffer.from(e).toString(`base64`)), e;
|
|
2908
|
-
},
|
|
2887
|
+
}, P = (e, t, n) => {
|
|
2909
2888
|
let r = ``, i, a;
|
|
2910
|
-
return e.forEach((
|
|
2889
|
+
return e.forEach((e, n) => {
|
|
2911
2890
|
i = ` `, n == 0 && (i = ``), t.noSpaceAfterFlags;
|
|
2912
|
-
let o = t.leadingZero ?
|
|
2891
|
+
let o = t.leadingZero ? F(e) : e.toString();
|
|
2913
2892
|
t.negativeExtraSpace && i != `` && (e < 0 || o.charAt(0) === `.` && a % 1 != 0) && (i = ``), a = e, r += i + o;
|
|
2914
|
-
})
|
|
2915
|
-
},
|
|
2893
|
+
}), r;
|
|
2894
|
+
}, F = (e) => {
|
|
2916
2895
|
let t = e.toString();
|
|
2917
2896
|
return 0 < e && e < 1 && t.startsWith(`0`) ? t.slice(1) : -1 < e && e < 0 && t[1] === `0` ? t[0] + t.slice(2) : t;
|
|
2918
|
-
},
|
|
2919
|
-
...
|
|
2920
|
-
...
|
|
2921
|
-
...
|
|
2922
|
-
...
|
|
2923
|
-
...
|
|
2924
|
-
],
|
|
2897
|
+
}, Ye = [
|
|
2898
|
+
...k.animationEvent,
|
|
2899
|
+
...k.documentEvent,
|
|
2900
|
+
...k.documentElementEvent,
|
|
2901
|
+
...k.globalEvent,
|
|
2902
|
+
...k.graphicalEvent
|
|
2903
|
+
], Xe = /* @__PURE__ */ new Set([
|
|
2904
|
+
`application/xhtml+xml`,
|
|
2905
|
+
`image/svg+xml`,
|
|
2906
|
+
`text/html`
|
|
2907
|
+
]), Ze = (e) => {
|
|
2908
|
+
let t = e.replace(/[\t\n\r]/g, ``).trimStart().toLowerCase();
|
|
2909
|
+
if (t.startsWith(`javascript:`) || t.startsWith(`vbscript:`)) return !0;
|
|
2910
|
+
if (!t.startsWith(`data:`)) return !1;
|
|
2911
|
+
let n = t.slice(5).search(/[;,]/);
|
|
2912
|
+
if (n === -1) return !1;
|
|
2913
|
+
let r = t.slice(5, n + 5).trim();
|
|
2914
|
+
return Xe.has(r);
|
|
2915
|
+
}, Qe = (e) => e.name === `script` && e.children.length !== 0 || e.name === `a` && Object.entries(e.attributes).some(([e, t]) => (e === `href` || e.endsWith(`:href`)) && t != null && Ze(t)) ? !0 : Ye.some((t) => e.attributes[t] != null), $e = (e) => new RegExp(Ge).test(e), et = (e) => /var\s*\(\s*--/.test(e), tt = (e, t) => {
|
|
2925
2916
|
let n = [];
|
|
2926
|
-
if (
|
|
2927
|
-
let e = t.matchAll(
|
|
2917
|
+
if (A.has(e)) {
|
|
2918
|
+
let e = t.matchAll(Ge);
|
|
2928
2919
|
for (let t of e) n.push(t[2]);
|
|
2929
2920
|
}
|
|
2930
2921
|
if (e === `href` || e.endsWith(`:href`)) {
|
|
2931
|
-
let e =
|
|
2922
|
+
let e = Ke.exec(t);
|
|
2932
2923
|
e != null && n.push(e[1]);
|
|
2933
2924
|
}
|
|
2934
2925
|
if (e === `begin`) {
|
|
2935
|
-
let e =
|
|
2926
|
+
let e = qe.exec(t);
|
|
2936
2927
|
e != null && n.push(e[1]);
|
|
2937
2928
|
}
|
|
2938
|
-
return n.map((
|
|
2939
|
-
},
|
|
2929
|
+
return n.map((e) => decodeURI(e));
|
|
2930
|
+
}, I = (e, t) => {
|
|
2940
2931
|
let n = 10 ** t;
|
|
2941
2932
|
return Math.round(e * n) / n;
|
|
2942
2933
|
};
|
|
2943
|
-
var
|
|
2934
|
+
var nt = Object.freeze({
|
|
2944
2935
|
__proto__: null,
|
|
2945
2936
|
description: `minifies styles and removes unused styles`,
|
|
2946
2937
|
fn: (e, { usage: t, ...n }) => {
|
|
@@ -2956,35 +2947,35 @@ var l = e(((e) => {
|
|
|
2956
2947
|
let e = {};
|
|
2957
2948
|
(!f || d) && (c && (e.tags = Array.from(a)), l && (e.ids = Array.from(o)), u && (e.classes = Array.from(s)));
|
|
2958
2949
|
for (let [t, i] of r.entries()) if (t.children[0].type === `text` || t.children[0].type === `cdata`) {
|
|
2959
|
-
let r = t.children[0].value, a =
|
|
2950
|
+
let r = t.children[0].value, a = y.minify(r, {
|
|
2960
2951
|
...n,
|
|
2961
2952
|
usage: e
|
|
2962
2953
|
}).css;
|
|
2963
2954
|
if (a.length === 0) {
|
|
2964
|
-
|
|
2955
|
+
D(t, i);
|
|
2965
2956
|
continue;
|
|
2966
2957
|
}
|
|
2967
2958
|
r.indexOf(`>`) >= 0 || r.indexOf(`<`) >= 0 ? (t.children[0].type = `cdata`, t.children[0].value = a) : (t.children[0].type = `text`, t.children[0].value = a);
|
|
2968
2959
|
}
|
|
2969
2960
|
for (let e of i) {
|
|
2970
2961
|
let t = e.attributes.style;
|
|
2971
|
-
e.attributes.style =
|
|
2962
|
+
e.attributes.style = y.minifyBlock(t, { ...n }).css;
|
|
2972
2963
|
}
|
|
2973
2964
|
} }
|
|
2974
2965
|
};
|
|
2975
2966
|
},
|
|
2976
2967
|
name: `minifyStyles`
|
|
2977
2968
|
});
|
|
2978
|
-
let
|
|
2969
|
+
let rt = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``), it = rt.length - 1, at = (e, t) => {
|
|
2979
2970
|
for (let n of t) if (e.startsWith(n)) return !0;
|
|
2980
2971
|
return !1;
|
|
2981
|
-
},
|
|
2972
|
+
}, ot = (e) => {
|
|
2982
2973
|
if (e == null) return [0];
|
|
2983
2974
|
e[e.length - 1] += 1;
|
|
2984
|
-
for (let t = e.length - 1; t > 0; t--) e[t] >
|
|
2985
|
-
return e[0] >
|
|
2986
|
-
},
|
|
2987
|
-
var
|
|
2975
|
+
for (let t = e.length - 1; t > 0; t--) e[t] > it && (e[t] = 0, e[t - 1] !== void 0 && e[t - 1]++);
|
|
2976
|
+
return e[0] > it && (e[0] = 0, e.unshift(0)), e;
|
|
2977
|
+
}, st = (e) => e.map((e) => rt[e]).join(``);
|
|
2978
|
+
var ct = Object.freeze({
|
|
2988
2979
|
__proto__: null,
|
|
2989
2980
|
description: `removes unused IDs and minifies used`,
|
|
2990
2981
|
fn: (e, t) => {
|
|
@@ -3002,14 +2993,14 @@ var l = e(((e) => {
|
|
|
3002
2993
|
t = !1;
|
|
3003
2994
|
break;
|
|
3004
2995
|
}
|
|
3005
|
-
if (t) return
|
|
2996
|
+
if (t) return b;
|
|
3006
2997
|
}
|
|
3007
2998
|
}
|
|
3008
2999
|
for (let [t, n] of Object.entries(e.attributes)) if (t === `id`) {
|
|
3009
3000
|
let t = n;
|
|
3010
3001
|
l.has(t) ? delete e.attributes.id : l.set(t, e);
|
|
3011
3002
|
} else {
|
|
3012
|
-
let r =
|
|
3003
|
+
let r = tt(t, n);
|
|
3013
3004
|
for (let n of r) {
|
|
3014
3005
|
let r = u.get(n);
|
|
3015
3006
|
r ?? (r = [], u.set(n, r)), r.push({
|
|
@@ -3021,14 +3012,14 @@ var l = e(((e) => {
|
|
|
3021
3012
|
} },
|
|
3022
3013
|
root: { exit: () => {
|
|
3023
3014
|
if (d) return;
|
|
3024
|
-
let e = (e) => s.has(e) ||
|
|
3015
|
+
let e = (e) => s.has(e) || at(e, c), t = null;
|
|
3025
3016
|
for (let [n, i] of u) {
|
|
3026
3017
|
let a = l.get(n);
|
|
3027
3018
|
if (a != null) {
|
|
3028
3019
|
if (r && e(n) === !1) {
|
|
3029
3020
|
let r;
|
|
3030
3021
|
do
|
|
3031
|
-
t =
|
|
3022
|
+
t = ot(t), r = st(t);
|
|
3032
3023
|
while (e(r) || u.has(r) && l.get(r) == null);
|
|
3033
3024
|
a.attributes.id = r;
|
|
3034
3025
|
for (let { element: e, name: t } of i) {
|
|
@@ -3045,21 +3036,21 @@ var l = e(((e) => {
|
|
|
3045
3036
|
},
|
|
3046
3037
|
name: `cleanupIds`
|
|
3047
3038
|
});
|
|
3048
|
-
let
|
|
3049
|
-
if (e.name === `defs` ||
|
|
3039
|
+
let lt = () => ({ element: { enter: (e, t) => {
|
|
3040
|
+
if (e.name === `defs` || O.nonRendering.has(e.name) && e.attributes.id == null) {
|
|
3050
3041
|
let n = [];
|
|
3051
|
-
|
|
3042
|
+
ut(e, n), n.length === 0 && D(e, t), e.children = n;
|
|
3052
3043
|
}
|
|
3053
|
-
} } }),
|
|
3054
|
-
for (let n of e.children) n.type === `element` && (n.attributes.id != null || n.name === `style` ? t.push(n) :
|
|
3044
|
+
} } }), ut = (e, t) => {
|
|
3045
|
+
for (let n of e.children) n.type === `element` && (n.attributes.id != null || n.name === `style` ? t.push(n) : ut(n, t));
|
|
3055
3046
|
};
|
|
3056
|
-
var
|
|
3047
|
+
var dt = Object.freeze({
|
|
3057
3048
|
__proto__: null,
|
|
3058
3049
|
description: `removes elements in <defs> without id`,
|
|
3059
|
-
fn:
|
|
3050
|
+
fn: lt,
|
|
3060
3051
|
name: `removeUselessDefs`
|
|
3061
3052
|
});
|
|
3062
|
-
let
|
|
3053
|
+
let ft = /^([-+]?\d*\.?\d+([eE][-+]?\d+)?)(px|pt|pc|mm|cm|m|in|ft|em|ex|%)?$/, pt = {
|
|
3063
3054
|
cm: 96 / 2.54,
|
|
3064
3055
|
mm: 96 / 25.4,
|
|
3065
3056
|
in: 96,
|
|
@@ -3067,7 +3058,7 @@ var l = e(((e) => {
|
|
|
3067
3058
|
pc: 16,
|
|
3068
3059
|
px: 1
|
|
3069
3060
|
};
|
|
3070
|
-
var
|
|
3061
|
+
var mt = Object.freeze({
|
|
3071
3062
|
__proto__: null,
|
|
3072
3063
|
description: `rounds numeric values to the fixed precision, removes default "px" units`,
|
|
3073
3064
|
fn: (e, t) => {
|
|
@@ -3075,30 +3066,30 @@ var l = e(((e) => {
|
|
|
3075
3066
|
return { element: { enter: (e) => {
|
|
3076
3067
|
if (e.attributes.viewBox != null) {
|
|
3077
3068
|
let t = e.attributes.viewBox.trim().split(/(?:\s,?|,)\s*/g);
|
|
3078
|
-
e.attributes.viewBox = t.map((
|
|
3069
|
+
e.attributes.viewBox = t.map((e) => {
|
|
3079
3070
|
let t = Number(e);
|
|
3080
3071
|
return Number.isNaN(t) ? e : Number(t.toFixed(n));
|
|
3081
|
-
})
|
|
3072
|
+
}).join(` `);
|
|
3082
3073
|
}
|
|
3083
3074
|
for (let [t, o] of Object.entries(e.attributes)) {
|
|
3084
3075
|
if (t === `version`) continue;
|
|
3085
|
-
let s =
|
|
3076
|
+
let s = ft.exec(o);
|
|
3086
3077
|
if (s) {
|
|
3087
3078
|
let o = Number(Number(s[1]).toFixed(n)), c = s[3] || ``;
|
|
3088
|
-
if (a && c !== `` && c in
|
|
3089
|
-
let e = Number((
|
|
3079
|
+
if (a && c !== `` && c in pt) {
|
|
3080
|
+
let e = Number((pt[c] * Number(s[1])).toFixed(n));
|
|
3090
3081
|
e.toString().length < s[0].length && (o = e, c = `px`);
|
|
3091
3082
|
}
|
|
3092
3083
|
let l;
|
|
3093
|
-
l = r ?
|
|
3084
|
+
l = r ? F(o) : o.toString(), i && c === `px` && (c = ``), e.attributes[t] = l + c;
|
|
3094
3085
|
}
|
|
3095
3086
|
}
|
|
3096
3087
|
} } };
|
|
3097
3088
|
},
|
|
3098
3089
|
name: `cleanupNumericValues`
|
|
3099
3090
|
});
|
|
3100
|
-
let
|
|
3101
|
-
var
|
|
3091
|
+
let ht = `([+-]?(?:\\d*\\.\\d+|\\d+\\.?)%?)`, gt = `(?:\\s*,\\s*|\\s+)`, _t = RegExp(`^rgb\\(\\s*` + ht + gt + ht + gt + ht + `\\s*\\)$`), vt = /^#(([a-fA-F0-9])\2){3}$/, yt = ([e, t, n]) => `#` + ((256 + e << 8 | t) << 8 | n).toString(16).slice(1).toUpperCase();
|
|
3092
|
+
var bt = Object.freeze({
|
|
3102
3093
|
__proto__: null,
|
|
3103
3094
|
description: `converts colors: rgb() to #rrggbb and #rrggbb to #rgb`,
|
|
3104
3095
|
fn: (e, t) => {
|
|
@@ -3106,7 +3097,7 @@ var l = e(((e) => {
|
|
|
3106
3097
|
return { element: {
|
|
3107
3098
|
enter: (e) => {
|
|
3108
3099
|
e.name === `mask` && c++;
|
|
3109
|
-
for (let [t, l] of Object.entries(e.attributes)) if (
|
|
3100
|
+
for (let [t, l] of Object.entries(e.attributes)) if (Se.has(t)) {
|
|
3110
3101
|
let u = l;
|
|
3111
3102
|
if (n && c === 0) {
|
|
3112
3103
|
let e;
|
|
@@ -3114,22 +3105,25 @@ var l = e(((e) => {
|
|
|
3114
3105
|
}
|
|
3115
3106
|
if (r) {
|
|
3116
3107
|
let e = u.toLowerCase();
|
|
3117
|
-
|
|
3108
|
+
be[e] != null && (u = be[e]);
|
|
3118
3109
|
}
|
|
3119
3110
|
if (i) {
|
|
3120
|
-
let e = u.match(
|
|
3121
|
-
e != null
|
|
3122
|
-
let t
|
|
3123
|
-
|
|
3124
|
-
|
|
3111
|
+
let e = u.match(_t);
|
|
3112
|
+
if (e != null) {
|
|
3113
|
+
let t = e.slice(1, 4).map((e) => {
|
|
3114
|
+
let t;
|
|
3115
|
+
return t = e.indexOf(`%`) > -1 ? Math.round(parseFloat(e) * 2.55) : Number(e), Math.max(0, Math.min(t, 255));
|
|
3116
|
+
});
|
|
3117
|
+
u = yt(t);
|
|
3118
|
+
}
|
|
3125
3119
|
}
|
|
3126
|
-
if (a
|
|
3127
|
-
let e =
|
|
3120
|
+
if (!a || $e(u) || et(u) || u === `currentColor` || (a === `lower` ? u = u.toLowerCase() : a === `upper` && (u = u.toUpperCase())), o) {
|
|
3121
|
+
let e = vt.exec(u);
|
|
3128
3122
|
e != null && (u = `#` + e[0][1] + e[0][3] + e[0][5]);
|
|
3129
3123
|
}
|
|
3130
3124
|
if (s) {
|
|
3131
3125
|
let e = u.toLowerCase();
|
|
3132
|
-
|
|
3126
|
+
xe[e] != null && (u = xe[e]);
|
|
3133
3127
|
}
|
|
3134
3128
|
e.attributes[t] = u;
|
|
3135
3129
|
}
|
|
@@ -3141,12 +3135,12 @@ var l = e(((e) => {
|
|
|
3141
3135
|
},
|
|
3142
3136
|
name: `convertColors`
|
|
3143
3137
|
});
|
|
3144
|
-
let
|
|
3145
|
-
for (let [e, t] of Object.entries(
|
|
3138
|
+
let xt = /* @__PURE__ */ new Map(), St = /* @__PURE__ */ new Map(), Ct = /* @__PURE__ */ new Map();
|
|
3139
|
+
for (let [e, t] of Object.entries(_e)) {
|
|
3146
3140
|
let n = /* @__PURE__ */ new Set();
|
|
3147
3141
|
if (t.content) for (let e of t.content) n.add(e);
|
|
3148
3142
|
if (t.contentGroups) for (let e of t.contentGroups) {
|
|
3149
|
-
let t =
|
|
3143
|
+
let t = O[e];
|
|
3150
3144
|
if (t) for (let e of t) n.add(e);
|
|
3151
3145
|
}
|
|
3152
3146
|
let r = /* @__PURE__ */ new Set();
|
|
@@ -3154,72 +3148,72 @@ var l = e(((e) => {
|
|
|
3154
3148
|
let i = /* @__PURE__ */ new Map();
|
|
3155
3149
|
if (t.defaults) for (let [e, n] of Object.entries(t.defaults)) i.set(e, n);
|
|
3156
3150
|
for (let e of t.attrsGroups) {
|
|
3157
|
-
let t =
|
|
3151
|
+
let t = k[e];
|
|
3158
3152
|
if (t) for (let e of t) r.add(e);
|
|
3159
|
-
let n =
|
|
3153
|
+
let n = he[e];
|
|
3160
3154
|
if (n) for (let [e, t] of Object.entries(n)) i.set(e, t);
|
|
3161
3155
|
}
|
|
3162
|
-
|
|
3156
|
+
xt.set(e, n), St.set(e, r), Ct.set(e, i);
|
|
3163
3157
|
}
|
|
3164
|
-
var
|
|
3158
|
+
var wt = Object.freeze({
|
|
3165
3159
|
__proto__: null,
|
|
3166
3160
|
description: `removes unknown elements content and attributes, removes attrs with default values`,
|
|
3167
3161
|
fn: (e, t) => {
|
|
3168
|
-
let { unknownContent: n = !0, unknownAttrs: r = !0, defaultAttrs: i = !0, defaultMarkupDeclarations: a = !0, uselessOverrides: o = !0, keepDataAttrs: s = !0, keepAriaAttrs: c = !0, keepRoleAttr: l = !1 } = t, u =
|
|
3162
|
+
let { unknownContent: n = !0, unknownAttrs: r = !0, defaultAttrs: i = !0, defaultMarkupDeclarations: a = !0, uselessOverrides: o = !0, keepDataAttrs: s = !0, keepAriaAttrs: c = !0, keepRoleAttr: l = !1 } = t, u = M(e);
|
|
3169
3163
|
return {
|
|
3170
3164
|
instruction: { enter: (e) => {
|
|
3171
3165
|
a && (e.value = e.value.replace(/\s*standalone\s*=\s*(["'])no\1/, ``));
|
|
3172
3166
|
} },
|
|
3173
3167
|
element: { enter: (e, t) => {
|
|
3174
3168
|
if (e.name.includes(`:`)) return;
|
|
3175
|
-
if (e.name === `foreignObject`) return
|
|
3169
|
+
if (e.name === `foreignObject`) return b;
|
|
3176
3170
|
if (n && t.type === `element`) {
|
|
3177
|
-
let n =
|
|
3171
|
+
let n = xt.get(t.name);
|
|
3178
3172
|
if (n == null || n.size === 0) {
|
|
3179
|
-
if (
|
|
3180
|
-
|
|
3173
|
+
if (xt.get(e.name) == null) {
|
|
3174
|
+
D(e, t);
|
|
3181
3175
|
return;
|
|
3182
3176
|
}
|
|
3183
3177
|
} else if (n.has(e.name) === !1) {
|
|
3184
|
-
|
|
3178
|
+
D(e, t);
|
|
3185
3179
|
return;
|
|
3186
3180
|
}
|
|
3187
3181
|
}
|
|
3188
|
-
let a =
|
|
3182
|
+
let a = St.get(e.name), d = Ct.get(e.name), f = t.type === `element` ? N(u, t) : null;
|
|
3189
3183
|
for (let [t, n] of Object.entries(e.attributes)) if (!(s && t.startsWith(`data-`)) && !(c && t.startsWith(`aria-`)) && !(l && t === `role`) && t !== `xmlns`) {
|
|
3190
3184
|
if (t.includes(`:`)) {
|
|
3191
3185
|
let [e] = t.split(`:`);
|
|
3192
3186
|
if (e !== `xml` && e !== `xlink`) continue;
|
|
3193
3187
|
}
|
|
3194
|
-
if (r && a && a.has(t) === !1 && delete e.attributes[t], i && e.attributes.id == null && d && d.get(t) === n && (f?.[t] != null || u.rules.some((
|
|
3188
|
+
if (r && a && a.has(t) === !1 && delete e.attributes[t], i && e.attributes.id == null && d && d.get(t) === n && (f?.[t] != null || u.rules.some((e) => je(e.selector, t)) || delete e.attributes[t]), o && e.attributes.id == null) {
|
|
3195
3189
|
let r = f?.[t];
|
|
3196
|
-
|
|
3190
|
+
ye.has(t) === !1 && r != null && r.type === `static` && r.value === n && delete e.attributes[t];
|
|
3197
3191
|
}
|
|
3198
3192
|
}
|
|
3199
3193
|
} }
|
|
3200
3194
|
};
|
|
3201
3195
|
},
|
|
3202
3196
|
name: `removeUnknownsAndDefaults`
|
|
3203
|
-
}),
|
|
3197
|
+
}), Tt = Object.freeze({
|
|
3204
3198
|
__proto__: null,
|
|
3205
3199
|
description: `removes non-inheritable group's presentational attributes`,
|
|
3206
3200
|
fn: () => ({ element: { enter: (e) => {
|
|
3207
|
-
if (e.name === `g`) for (let t of Object.keys(e.attributes)) !
|
|
3201
|
+
if (e.name === `g`) for (let t of Object.keys(e.attributes)) !k.presentation.has(t) || j.has(t) || ye.has(t) || delete e.attributes[t];
|
|
3208
3202
|
} } }),
|
|
3209
3203
|
name: `removeNonInheritableGroupAttrs`
|
|
3210
|
-
}),
|
|
3204
|
+
}), Et = Object.freeze({
|
|
3211
3205
|
__proto__: null,
|
|
3212
3206
|
description: `removes useless stroke and fill attributes`,
|
|
3213
3207
|
fn: (e, t) => {
|
|
3214
3208
|
let { stroke: n = !0, fill: r = !0, removeNone: i = !1 } = t, a = !1;
|
|
3215
|
-
if (
|
|
3209
|
+
if (x(e, { element: { enter: (e) => {
|
|
3216
3210
|
(e.name === `style` || Qe(e)) && (a = !0);
|
|
3217
3211
|
} } }), a) return null;
|
|
3218
|
-
let o =
|
|
3212
|
+
let o = M(e);
|
|
3219
3213
|
return { element: { enter: (e, t) => {
|
|
3220
|
-
if (e.attributes.id != null) return
|
|
3221
|
-
if (!
|
|
3222
|
-
let a =
|
|
3214
|
+
if (e.attributes.id != null) return b;
|
|
3215
|
+
if (!O.shape.has(e.name)) return;
|
|
3216
|
+
let a = N(o, e), s = a.stroke, c = a[`stroke-opacity`], l = a[`stroke-width`], u = a[`marker-end`], d = a.fill, f = a[`fill-opacity`], p = t.type === `element` ? N(o, t) : null, m = p == null ? null : p.stroke;
|
|
3223
3217
|
if (n && (s == null || s.type === `static` && s.value == `none` || c != null && c.type === `static` && c.value === `0` || l != null && l.type === `static` && l.value === `0`) && (l != null && l.type === `static` && l.value === `0` || u == null)) {
|
|
3224
3218
|
for (let t of Object.keys(e.attributes)) t.startsWith(`stroke`) && delete e.attributes[t];
|
|
3225
3219
|
m != null && m.type === `static` && m.value !== `none` && (e.attributes.stroke = `none`);
|
|
@@ -3228,52 +3222,52 @@ var l = e(((e) => {
|
|
|
3228
3222
|
for (let t of Object.keys(e.attributes)) t.startsWith(`fill-`) && delete e.attributes[t];
|
|
3229
3223
|
(d == null || d.type === `static` && d.value !== `none`) && (e.attributes.fill = `none`);
|
|
3230
3224
|
}
|
|
3231
|
-
i && (s != null && e.attributes.stroke !== `none` || (d == null || d.type !== `static` || d.value !== `none`) && e.attributes.fill !== `none` ||
|
|
3225
|
+
i && (s != null && e.attributes.stroke !== `none` || (d == null || d.type !== `static` || d.value !== `none`) && e.attributes.fill !== `none` || D(e, t));
|
|
3232
3226
|
} } };
|
|
3233
3227
|
},
|
|
3234
3228
|
name: `removeUselessStrokeAndFill`
|
|
3235
3229
|
});
|
|
3236
|
-
let
|
|
3230
|
+
let Dt = /^new\s0\s0\s([-+]?\d*\.?\d+([eE][-+]?\d+)?)\s([-+]?\d*\.?\d+([eE][-+]?\d+)?)$/, Ot = (e) => {
|
|
3237
3231
|
let t = !1;
|
|
3238
|
-
return
|
|
3232
|
+
return x(e, { element: { enter: (e) => {
|
|
3239
3233
|
e.name === `filter` && (t = !0);
|
|
3240
3234
|
} } }), { element: { enter: (e) => {
|
|
3241
3235
|
let n = null, r = null;
|
|
3242
|
-
if (e.attributes.style != null && (n =
|
|
3236
|
+
if (e.attributes.style != null && (n = v.parse(e.attributes.style, { context: `declarationList` }), n.type === `DeclarationList`)) {
|
|
3243
3237
|
let e = [];
|
|
3244
|
-
|
|
3238
|
+
v.walk(n, (t, n) => {
|
|
3245
3239
|
t.type === `Declaration` && t.property === `enable-background` && (e.push(n), r = n);
|
|
3246
|
-
})
|
|
3240
|
+
});
|
|
3247
3241
|
for (let t = 0; t < e.length - 1; t++) n.children.remove(e[t]);
|
|
3248
3242
|
}
|
|
3249
3243
|
if (!t) {
|
|
3250
|
-
delete e.attributes[`enable-background`], n?.type === `DeclarationList` && (r && n.children.remove(r), n.children.isEmpty ? delete e.attributes.style : e.attributes.style =
|
|
3244
|
+
delete e.attributes[`enable-background`], n?.type === `DeclarationList` && (r && n.children.remove(r), n.children.isEmpty ? delete e.attributes.style : e.attributes.style = v.generate(n));
|
|
3251
3245
|
return;
|
|
3252
3246
|
}
|
|
3253
3247
|
let i = e.attributes.width != null && e.attributes.height != null;
|
|
3254
3248
|
if ((e.name === `svg` || e.name === `mask` || e.name === `pattern`) && i) {
|
|
3255
|
-
let t = e.attributes[`enable-background`], i =
|
|
3249
|
+
let t = e.attributes[`enable-background`], i = kt(t, e.name, e.attributes.width, e.attributes.height);
|
|
3256
3250
|
if (i ? e.attributes[`enable-background`] = i : delete e.attributes[`enable-background`], n?.type === `DeclarationList` && r) {
|
|
3257
|
-
let t =
|
|
3258
|
-
|
|
3251
|
+
let t = v.generate(r.data.value), i = kt(t, e.name, e.attributes.width, e.attributes.height);
|
|
3252
|
+
i ? r.data.value = {
|
|
3259
3253
|
type: `Raw`,
|
|
3260
|
-
value:
|
|
3254
|
+
value: i
|
|
3261
3255
|
} : n.children.remove(r);
|
|
3262
3256
|
}
|
|
3263
3257
|
}
|
|
3264
|
-
n?.type === `DeclarationList` && (n.children.isEmpty ? delete e.attributes.style : e.attributes.style =
|
|
3258
|
+
n?.type === `DeclarationList` && (n.children.isEmpty ? delete e.attributes.style : e.attributes.style = v.generate(n));
|
|
3265
3259
|
} } };
|
|
3266
|
-
},
|
|
3267
|
-
let i =
|
|
3260
|
+
}, kt = (e, t, n, r) => {
|
|
3261
|
+
let i = Dt.exec(e);
|
|
3268
3262
|
return i != null && n === i[1] && r === i[3] ? t === `svg` ? void 0 : `new` : e;
|
|
3269
3263
|
};
|
|
3270
|
-
var
|
|
3264
|
+
var At = Object.freeze({
|
|
3271
3265
|
__proto__: null,
|
|
3272
3266
|
description: `remove or cleanup enable-background attribute when possible`,
|
|
3273
|
-
fn:
|
|
3267
|
+
fn: Ot,
|
|
3274
3268
|
name: `cleanupEnableBackground`
|
|
3275
3269
|
});
|
|
3276
|
-
let
|
|
3270
|
+
let jt = {
|
|
3277
3271
|
M: 2,
|
|
3278
3272
|
m: 2,
|
|
3279
3273
|
Z: 0,
|
|
@@ -3294,11 +3288,11 @@ var l = e(((e) => {
|
|
|
3294
3288
|
t: 2,
|
|
3295
3289
|
A: 7,
|
|
3296
3290
|
a: 7
|
|
3297
|
-
},
|
|
3298
|
-
`,
|
|
3291
|
+
}, Mt = (e) => e in jt, Nt = (e) => e === ` ` || e === ` ` || e === `\r` || e === `
|
|
3292
|
+
`, Pt = (e) => {
|
|
3299
3293
|
let t = e.codePointAt(0);
|
|
3300
|
-
return t
|
|
3301
|
-
},
|
|
3294
|
+
return t != null && 48 <= t && t <= 57;
|
|
3295
|
+
}, Ft = (e, t) => {
|
|
3302
3296
|
let n = t, r = ``, i = `none`;
|
|
3303
3297
|
for (; n < e.length; n += 1) {
|
|
3304
3298
|
let t = e[n];
|
|
@@ -3312,7 +3306,7 @@ var l = e(((e) => {
|
|
|
3312
3306
|
continue;
|
|
3313
3307
|
}
|
|
3314
3308
|
}
|
|
3315
|
-
if (
|
|
3309
|
+
if (Pt(t)) {
|
|
3316
3310
|
if (i === `none` || i === `sign` || i === `whole`) {
|
|
3317
3311
|
i = `whole`, r += t;
|
|
3318
3312
|
continue;
|
|
@@ -3326,34 +3320,28 @@ var l = e(((e) => {
|
|
|
3326
3320
|
continue;
|
|
3327
3321
|
}
|
|
3328
3322
|
}
|
|
3329
|
-
if (t === `.` && (i === `none` || i === `sign` || i === `whole`))
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
}
|
|
3333
|
-
if ((t === `E` || t == `e`) && (i === `whole` || i === `decimal_point` || i === `decimal`)) {
|
|
3334
|
-
i = `e`, r += t;
|
|
3335
|
-
continue;
|
|
3336
|
-
}
|
|
3337
|
-
break;
|
|
3323
|
+
if (t === `.` && (i === `none` || i === `sign` || i === `whole`)) i = `decimal_point`, r += t;
|
|
3324
|
+
else if ((t === `E` || t == `e`) && (i === `whole` || i === `decimal_point` || i === `decimal`)) i = `e`, r += t;
|
|
3325
|
+
else break;
|
|
3338
3326
|
}
|
|
3339
3327
|
let a = Number.parseFloat(r);
|
|
3340
3328
|
return Number.isNaN(a) ? [t, null] : [n - 1, a];
|
|
3341
|
-
},
|
|
3329
|
+
}, It = (e) => {
|
|
3342
3330
|
let t = [], n = null, r = [], i = 0, a = !1, o = !1;
|
|
3343
3331
|
for (let s = 0; s < e.length; s += 1) {
|
|
3344
3332
|
let c = e.charAt(s);
|
|
3345
|
-
if (
|
|
3333
|
+
if (Nt(c)) continue;
|
|
3346
3334
|
if (a && c === `,`) {
|
|
3347
3335
|
if (o) break;
|
|
3348
3336
|
o = !0;
|
|
3349
3337
|
continue;
|
|
3350
3338
|
}
|
|
3351
|
-
if (
|
|
3339
|
+
if (Mt(c)) {
|
|
3352
3340
|
if (o) return t;
|
|
3353
3341
|
if (n == null) {
|
|
3354
3342
|
if (c !== `M` && c !== `m`) return t;
|
|
3355
3343
|
} else if (r.length !== 0) return t;
|
|
3356
|
-
n = c, r = [], i =
|
|
3344
|
+
n = c, r = [], i = jt[n], a = !1, i === 0 && t.push({
|
|
3357
3345
|
command: n,
|
|
3358
3346
|
args: r
|
|
3359
3347
|
});
|
|
@@ -3363,172 +3351,124 @@ var l = e(((e) => {
|
|
|
3363
3351
|
let l = s, u = null;
|
|
3364
3352
|
if (n === `A` || n === `a`) {
|
|
3365
3353
|
let t = r.length;
|
|
3366
|
-
t !== 0 && t !== 1
|
|
3367
|
-
} else [l, u] =
|
|
3354
|
+
t !== 0 && t !== 1 && t !== 2 && t !== 5 && t !== 6 || ([l, u] = Ft(e, s)), (t === 3 || t === 4) && (c === `0` && (u = 0), c === `1` && (u = 1));
|
|
3355
|
+
} else [l, u] = Ft(e, s);
|
|
3368
3356
|
if (u == null) return t;
|
|
3369
|
-
r.push(u), a = !0, o = !1, s = l, r.length === i && (t.push({
|
|
3357
|
+
r.push(u), a = !0, o = !1, s = l, r.length === i && ((n === `A` || n === `a`) && (r[0] = Math.abs(r[0]), r[1] = Math.abs(r[1])), t.push({
|
|
3370
3358
|
command: n,
|
|
3371
3359
|
args: r
|
|
3372
3360
|
}), n === `M` && (n = `L`), n === `m` && (n = `l`), r = []);
|
|
3373
3361
|
}
|
|
3374
3362
|
return t;
|
|
3375
|
-
},
|
|
3376
|
-
roundedStr:
|
|
3363
|
+
}, Lt = (e, t) => (t != null && (e = I(e, t)), {
|
|
3364
|
+
roundedStr: F(e),
|
|
3377
3365
|
rounded: e
|
|
3378
|
-
}),
|
|
3366
|
+
}), Rt = (e, t, n, r) => {
|
|
3379
3367
|
let i = ``, a;
|
|
3380
3368
|
for (let o = 0; o < t.length; o++) {
|
|
3381
|
-
let { roundedStr: s, rounded: c } =
|
|
3382
|
-
!r || e !== `A` && e !== `a` || o % 7 != 4 && o % 7 != 5 ? o === 0 || c < 0 ? i += s : Number.isInteger(a) ||
|
|
3369
|
+
let { roundedStr: s, rounded: c } = Lt(t[o], n);
|
|
3370
|
+
!r || e !== `A` && e !== `a` || o % 7 != 4 && o % 7 != 5 ? o === 0 || c < 0 ? i += s : Number.isInteger(a) || Pt(s[0]) ? i += ` ${s}` : i += s : i += s, a = c;
|
|
3383
3371
|
}
|
|
3384
3372
|
return i;
|
|
3385
|
-
},
|
|
3373
|
+
}, L = ({ pathData: e, precision: t, disableSpaceAfterFlags: n }) => {
|
|
3386
3374
|
if (e.length === 1) {
|
|
3387
3375
|
let { command: r, args: i } = e[0];
|
|
3388
|
-
return r +
|
|
3376
|
+
return r + Rt(r, i, t, n);
|
|
3389
3377
|
}
|
|
3390
3378
|
let r = ``, i = { ...e[0] };
|
|
3391
3379
|
e[1].command === `L` ? i.command = `M` : e[1].command === `l` && (i.command = `m`);
|
|
3392
3380
|
for (let a = 1; a < e.length; a++) {
|
|
3393
3381
|
let { command: o, args: s } = e[a];
|
|
3394
|
-
i.command === o && i.command !== `M` && i.command !== `m` || i.command === `M` && o === `L` || i.command === `m` && o === `l` ? (i.args = [...i.args, ...s], a === e.length - 1 && (r += i.command +
|
|
3382
|
+
i.command === o && i.command !== `M` && i.command !== `m` || i.command === `M` && o === `L` || i.command === `m` && o === `l` ? (i.args = [...i.args, ...s], a === e.length - 1 && (r += i.command + Rt(i.command, i.args, t, n))) : (r += i.command + Rt(i.command, i.args, t, n), a === e.length - 1 ? r += o + Rt(o, s, t, n) : i = {
|
|
3395
3383
|
command: o,
|
|
3396
3384
|
args: s
|
|
3397
3385
|
});
|
|
3398
3386
|
}
|
|
3399
3387
|
return r;
|
|
3400
|
-
},
|
|
3401
|
-
var
|
|
3388
|
+
}, zt = O.nonRendering;
|
|
3389
|
+
var Bt = Object.freeze({
|
|
3402
3390
|
__proto__: null,
|
|
3403
3391
|
description: `removes hidden elements (zero sized, with absent attributes)`,
|
|
3404
3392
|
fn: (e, t) => {
|
|
3405
|
-
let { isHidden: n = !0, displayNone: r = !0, opacity0: i = !0, circleR0: a = !0, ellipseRX0: o = !0, ellipseRY0: s = !0, rectWidth0: c = !0, rectHeight0: l = !0, patternWidth0: u = !0, patternHeight0: d = !0, imageWidth0: f = !0, imageHeight0: p = !0, pathEmptyD: m = !0, polylineEmptyPoints: h = !0, polygonEmptyPoints: g = !0 } = t, _ =
|
|
3406
|
-
function
|
|
3407
|
-
if (
|
|
3408
|
-
for (let t of e.children) if (t.type === `element` && !
|
|
3393
|
+
let { isHidden: n = !0, displayNone: r = !0, opacity0: i = !0, circleR0: a = !0, ellipseRX0: o = !0, ellipseRY0: s = !0, rectWidth0: c = !0, rectHeight0: l = !0, patternWidth0: u = !0, patternHeight0: d = !0, imageWidth0: f = !0, imageHeight0: p = !0, pathEmptyD: m = !0, polylineEmptyPoints: h = !0, polygonEmptyPoints: g = !0 } = t, _ = M(e), v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Map(), w = !1;
|
|
3394
|
+
function te(e) {
|
|
3395
|
+
if (ee.has(e.attributes.id)) return !1;
|
|
3396
|
+
for (let t of e.children) if (t.type === `element` && !te(t)) return !1;
|
|
3409
3397
|
return !0;
|
|
3410
3398
|
}
|
|
3411
|
-
function
|
|
3412
|
-
e.type === `element` && e.attributes.id != null && t.type === `element` && t.name === `defs` && y.add(e.attributes.id),
|
|
3399
|
+
function T(e, t) {
|
|
3400
|
+
e.type === `element` && e.attributes.id != null && t.type === `element` && t.name === `defs` && y.add(e.attributes.id), D(e, t);
|
|
3413
3401
|
}
|
|
3414
|
-
return
|
|
3415
|
-
if (
|
|
3416
|
-
let n =
|
|
3402
|
+
return x(e, { element: { enter: (e, t) => {
|
|
3403
|
+
if (zt.has(e.name)) return v.set(e, t), b;
|
|
3404
|
+
let n = N(_, e);
|
|
3417
3405
|
if (i && n.opacity && n.opacity.type === `static` && n.opacity.value === `0`) {
|
|
3418
|
-
if (e.name === `path`) return v.set(e, t),
|
|
3419
|
-
|
|
3406
|
+
if (e.name === `path`) return v.set(e, t), b;
|
|
3407
|
+
T(e, t);
|
|
3420
3408
|
}
|
|
3421
3409
|
} } }), {
|
|
3422
3410
|
element: { enter: (e, t) => {
|
|
3423
3411
|
if (e.name === `style` && e.children.length !== 0 || Qe(e)) {
|
|
3424
|
-
|
|
3412
|
+
w = !0;
|
|
3425
3413
|
return;
|
|
3426
3414
|
}
|
|
3427
|
-
if (e.name === `defs` &&
|
|
3415
|
+
if (e.name === `defs` && S.set(e, t), e.name === `use`) for (let n of Object.keys(e.attributes)) {
|
|
3428
3416
|
if (n !== `href` && !n.endsWith(`:href`)) continue;
|
|
3429
|
-
let r = e.attributes[n].slice(1), i =
|
|
3430
|
-
i || (i = [],
|
|
3417
|
+
let r = e.attributes[n].slice(1), i = C.get(r);
|
|
3418
|
+
i || (i = [], C.set(r, i)), i.push({
|
|
3431
3419
|
node: e,
|
|
3432
3420
|
parentNode: t
|
|
3433
3421
|
});
|
|
3434
3422
|
}
|
|
3435
|
-
if (a && e.name === `circle` && e.children.length === 0 && e.attributes.r === `0`) {
|
|
3436
|
-
|
|
3437
|
-
return;
|
|
3438
|
-
}
|
|
3439
|
-
if (o && e.name === `ellipse` && e.children.length === 0 && e.attributes.rx === `0`) {
|
|
3440
|
-
D(e, t);
|
|
3441
|
-
return;
|
|
3442
|
-
}
|
|
3443
|
-
if (s && e.name === `ellipse` && e.children.length === 0 && e.attributes.ry === `0`) {
|
|
3444
|
-
D(e, t);
|
|
3445
|
-
return;
|
|
3446
|
-
}
|
|
3447
|
-
if (c && e.name === `rect` && e.children.length === 0 && e.attributes.width === `0`) {
|
|
3448
|
-
D(e, t);
|
|
3449
|
-
return;
|
|
3450
|
-
}
|
|
3451
|
-
if (l && c && e.name === `rect` && e.children.length === 0 && e.attributes.height === `0`) {
|
|
3452
|
-
D(e, t);
|
|
3453
|
-
return;
|
|
3454
|
-
}
|
|
3455
|
-
if (u && e.name === `pattern` && e.attributes.width === `0`) {
|
|
3456
|
-
D(e, t);
|
|
3457
|
-
return;
|
|
3458
|
-
}
|
|
3459
|
-
if (d && e.name === `pattern` && e.attributes.height === `0`) {
|
|
3460
|
-
D(e, t);
|
|
3461
|
-
return;
|
|
3462
|
-
}
|
|
3463
|
-
if (f && e.name === `image` && e.attributes.width === `0`) {
|
|
3464
|
-
D(e, t);
|
|
3465
|
-
return;
|
|
3466
|
-
}
|
|
3467
|
-
if (p && e.name === `image` && e.attributes.height === `0`) {
|
|
3468
|
-
D(e, t);
|
|
3423
|
+
if (a && e.name === `circle` && e.children.length === 0 && e.attributes.r === `0` || o && e.name === `ellipse` && e.children.length === 0 && e.attributes.rx === `0` || s && e.name === `ellipse` && e.children.length === 0 && e.attributes.ry === `0` || c && e.name === `rect` && e.children.length === 0 && e.attributes.width === `0` || l && c && e.name === `rect` && e.children.length === 0 && e.attributes.height === `0` || u && e.name === `pattern` && e.attributes.width === `0` || d && e.name === `pattern` && e.attributes.height === `0` || f && e.name === `image` && e.attributes.width === `0` || p && e.name === `image` && e.attributes.height === `0` || h && e.name === `polyline` && e.attributes.points == null || g && e.name === `polygon` && e.attributes.points == null) {
|
|
3424
|
+
T(e, t);
|
|
3469
3425
|
return;
|
|
3470
3426
|
}
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
D(e, t);
|
|
3486
|
-
return;
|
|
3487
|
-
}
|
|
3488
|
-
if (m && e.name === `path`) {
|
|
3489
|
-
if (e.attributes.d == null) {
|
|
3490
|
-
D(e, t);
|
|
3491
|
-
return;
|
|
3492
|
-
}
|
|
3493
|
-
let n = Nt(e.attributes.d);
|
|
3494
|
-
if (n.length === 0) {
|
|
3495
|
-
D(e, t);
|
|
3496
|
-
return;
|
|
3427
|
+
let i = N(_, e);
|
|
3428
|
+
if (n && i.visibility && i.visibility.type === `static` && i.visibility.value === `hidden` && se(e, `[visibility=visible]`) == null) T(e, t);
|
|
3429
|
+
else if (r && i.display && i.display.type === `static` && i.display.value === `none` && e.name !== `marker`) T(e, t);
|
|
3430
|
+
else {
|
|
3431
|
+
if (m && e.name === `path`) {
|
|
3432
|
+
if (e.attributes.d == null) {
|
|
3433
|
+
T(e, t);
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
let n = It(e.attributes.d);
|
|
3437
|
+
if (n.length === 0 || n.length === 1 && i[`marker-start`] == null && i[`marker-end`] == null) {
|
|
3438
|
+
T(e, t);
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3497
3441
|
}
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3442
|
+
for (let [t, n] of Object.entries(e.attributes)) {
|
|
3443
|
+
let e = tt(t, n);
|
|
3444
|
+
for (let t of e) ee.add(t);
|
|
3501
3445
|
}
|
|
3502
3446
|
}
|
|
3503
|
-
for (let [t, n] of Object.entries(e.attributes)) {
|
|
3504
|
-
let e = et(t, n);
|
|
3505
|
-
for (let t of e) x.add(t);
|
|
3506
|
-
}
|
|
3507
3447
|
} },
|
|
3508
3448
|
root: { exit: () => {
|
|
3509
3449
|
for (let e of y) {
|
|
3510
|
-
let t =
|
|
3511
|
-
if (t) for (let { node: e, parentNode: n } of t)
|
|
3450
|
+
let t = C.get(e);
|
|
3451
|
+
if (t) for (let { node: e, parentNode: n } of t) D(e, n);
|
|
3512
3452
|
}
|
|
3513
|
-
if (!
|
|
3514
|
-
for (let [e, t] of
|
|
3453
|
+
if (!w) for (let [e, t] of v.entries()) te(e) && D(e, t);
|
|
3454
|
+
for (let [e, t] of S.entries()) e.children.length === 0 && D(e, t);
|
|
3515
3455
|
} }
|
|
3516
3456
|
};
|
|
3517
3457
|
},
|
|
3518
3458
|
name: `removeHiddenElems`
|
|
3519
|
-
}),
|
|
3459
|
+
}), Vt = Object.freeze({
|
|
3520
3460
|
__proto__: null,
|
|
3521
3461
|
description: `removes empty <text> elements`,
|
|
3522
3462
|
fn: (e, t) => {
|
|
3523
3463
|
let { text: n = !0, tspan: r = !0, tref: i = !0 } = t;
|
|
3524
3464
|
return { element: { enter: (e, t) => {
|
|
3525
|
-
n && e.name === `text` && e.children.length === 0 &&
|
|
3465
|
+
n && e.name === `text` && e.children.length === 0 && D(e, t), r && e.name === `tspan` && e.children.length === 0 && D(e, t), i && e.name === `tref` && e.attributes[`xlink:href`] == null && D(e, t);
|
|
3526
3466
|
} } };
|
|
3527
3467
|
},
|
|
3528
3468
|
name: `removeEmptyText`
|
|
3529
3469
|
});
|
|
3530
|
-
let
|
|
3531
|
-
var
|
|
3470
|
+
let Ht = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g;
|
|
3471
|
+
var Ut = Object.freeze({
|
|
3532
3472
|
__proto__: null,
|
|
3533
3473
|
description: `converts basic shapes to more compact path form`,
|
|
3534
3474
|
fn: (e, t) => {
|
|
@@ -3559,7 +3499,7 @@ var l = e(((e) => {
|
|
|
3559
3499
|
args: []
|
|
3560
3500
|
}
|
|
3561
3501
|
];
|
|
3562
|
-
e.name = `path`, e.attributes.d =
|
|
3502
|
+
e.name = `path`, e.attributes.d = L({
|
|
3563
3503
|
pathData: o,
|
|
3564
3504
|
precision: r
|
|
3565
3505
|
}), delete e.attributes.x, delete e.attributes.y, delete e.attributes.width, delete e.attributes.height;
|
|
@@ -3574,15 +3514,15 @@ var l = e(((e) => {
|
|
|
3574
3514
|
command: `L`,
|
|
3575
3515
|
args: [i, a]
|
|
3576
3516
|
}];
|
|
3577
|
-
e.name = `path`, e.attributes.d =
|
|
3517
|
+
e.name = `path`, e.attributes.d = L({
|
|
3578
3518
|
pathData: o,
|
|
3579
3519
|
precision: r
|
|
3580
3520
|
}), delete e.attributes.x1, delete e.attributes.y1, delete e.attributes.x2, delete e.attributes.y2;
|
|
3581
3521
|
}
|
|
3582
3522
|
if ((e.name === `polyline` || e.name === `polygon`) && e.attributes.points != null) {
|
|
3583
|
-
let n = (e.attributes.points.match(
|
|
3523
|
+
let n = (e.attributes.points.match(Ht) || []).map(Number);
|
|
3584
3524
|
if (n.length < 4) {
|
|
3585
|
-
|
|
3525
|
+
D(e, t);
|
|
3586
3526
|
return;
|
|
3587
3527
|
}
|
|
3588
3528
|
let i = [];
|
|
@@ -3593,7 +3533,7 @@ var l = e(((e) => {
|
|
|
3593
3533
|
e.name === `polygon` && i.push({
|
|
3594
3534
|
command: `z`,
|
|
3595
3535
|
args: []
|
|
3596
|
-
}), e.name = `path`, e.attributes.d =
|
|
3536
|
+
}), e.name = `path`, e.attributes.d = L({
|
|
3597
3537
|
pathData: i,
|
|
3598
3538
|
precision: r
|
|
3599
3539
|
}), delete e.attributes.points;
|
|
@@ -3635,7 +3575,7 @@ var l = e(((e) => {
|
|
|
3635
3575
|
args: []
|
|
3636
3576
|
}
|
|
3637
3577
|
];
|
|
3638
|
-
e.name = `path`, e.attributes.d =
|
|
3578
|
+
e.name = `path`, e.attributes.d = L({
|
|
3639
3579
|
pathData: a,
|
|
3640
3580
|
precision: r
|
|
3641
3581
|
}), delete e.attributes.cx, delete e.attributes.cy, delete e.attributes.r;
|
|
@@ -3677,7 +3617,7 @@ var l = e(((e) => {
|
|
|
3677
3617
|
args: []
|
|
3678
3618
|
}
|
|
3679
3619
|
];
|
|
3680
|
-
e.name = `path`, e.attributes.d =
|
|
3620
|
+
e.name = `path`, e.attributes.d = L({
|
|
3681
3621
|
pathData: o,
|
|
3682
3622
|
precision: r
|
|
3683
3623
|
}), delete e.attributes.cx, delete e.attributes.cy, delete e.attributes.rx, delete e.attributes.ry;
|
|
@@ -3685,7 +3625,7 @@ var l = e(((e) => {
|
|
|
3685
3625
|
} } };
|
|
3686
3626
|
},
|
|
3687
3627
|
name: `convertShapeToPath`
|
|
3688
|
-
}),
|
|
3628
|
+
}), Wt = Object.freeze({
|
|
3689
3629
|
__proto__: null,
|
|
3690
3630
|
description: `converts non-eccentric <ellipse>s to <circle>s`,
|
|
3691
3631
|
fn: () => ({ element: { enter: (e) => {
|
|
@@ -3699,20 +3639,22 @@ var l = e(((e) => {
|
|
|
3699
3639
|
}
|
|
3700
3640
|
} } }),
|
|
3701
3641
|
name: `convertEllipseToCircle`
|
|
3702
|
-
}),
|
|
3642
|
+
}), Gt = Object.freeze({
|
|
3703
3643
|
__proto__: null,
|
|
3704
3644
|
description: `Move common attributes of group children to the group`,
|
|
3705
3645
|
fn: (e) => {
|
|
3706
3646
|
let t = !1;
|
|
3707
|
-
return
|
|
3647
|
+
return x(e, { element: { enter: (e) => {
|
|
3708
3648
|
e.name === `style` && (t = !0);
|
|
3709
3649
|
} } }), { element: { exit: (e) => {
|
|
3710
3650
|
if (e.name !== `g` || e.children.length <= 1 || t) return;
|
|
3711
3651
|
let n = /* @__PURE__ */ new Map(), r = !0, i = !0;
|
|
3712
|
-
for (let t of e.children) if (t.type === `element`)
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3652
|
+
for (let t of e.children) if (t.type === `element`) {
|
|
3653
|
+
if (me.has(t.name) || (i = !1), r) {
|
|
3654
|
+
r = !1;
|
|
3655
|
+
for (let [e, r] of Object.entries(t.attributes)) j.has(e) && n.set(e, r);
|
|
3656
|
+
} else for (let [e, r] of n) t.attributes[e] !== r && n.delete(e);
|
|
3657
|
+
}
|
|
3716
3658
|
e.attributes.filter == null && e.attributes[`clip-path`] == null && e.attributes.mask == null || n.delete(`transform`), i && n.delete(`transform`);
|
|
3717
3659
|
for (let [t, r] of n) t === `transform` ? e.attributes.transform == null ? e.attributes.transform = r : e.attributes.transform = `${e.attributes.transform} ${r}` : e.attributes[t] = r;
|
|
3718
3660
|
for (let t of e.children) if (t.type === `element`) for (let [e] of n) delete t.attributes[e];
|
|
@@ -3720,16 +3662,16 @@ var l = e(((e) => {
|
|
|
3720
3662
|
},
|
|
3721
3663
|
name: `moveElemsAttrsToGroup`
|
|
3722
3664
|
});
|
|
3723
|
-
let
|
|
3724
|
-
...
|
|
3665
|
+
let Kt = [
|
|
3666
|
+
...me,
|
|
3725
3667
|
`g`,
|
|
3726
3668
|
`text`
|
|
3727
3669
|
];
|
|
3728
|
-
var
|
|
3670
|
+
var qt = Object.freeze({
|
|
3729
3671
|
__proto__: null,
|
|
3730
3672
|
description: `moves some group attributes to the content elements`,
|
|
3731
3673
|
fn: () => ({ element: { enter: (e) => {
|
|
3732
|
-
if (e.name === `g` && e.children.length !== 0 && e.attributes.transform != null && Object.entries(e.attributes).some((
|
|
3674
|
+
if (e.name === `g` && e.children.length !== 0 && e.attributes.transform != null && Object.entries(e.attributes).some(([e, t]) => A.has(e) && $e(t)) === !1 && e.children.every((e) => e.type === `element` && Kt.includes(e.name) && e.attributes.id == null)) {
|
|
3733
3675
|
for (let t of e.children) {
|
|
3734
3676
|
let n = e.attributes.transform;
|
|
3735
3677
|
t.type === `element` && (t.attributes.transform == null ? t.attributes.transform = n : t.attributes.transform = `${n} ${t.attributes.transform}`);
|
|
@@ -3739,36 +3681,36 @@ var l = e(((e) => {
|
|
|
3739
3681
|
} } }),
|
|
3740
3682
|
name: `moveGroupAttrsToElems`
|
|
3741
3683
|
});
|
|
3742
|
-
let
|
|
3684
|
+
let Jt = (e, t) => {
|
|
3743
3685
|
if (e.type === `element`) {
|
|
3744
|
-
if (
|
|
3745
|
-
for (let n of e.children) if (
|
|
3686
|
+
if (O.animation.has(e.name) && e.attributes.attributeName === t) return !0;
|
|
3687
|
+
for (let n of e.children) if (Jt(n, t)) return !0;
|
|
3746
3688
|
}
|
|
3747
3689
|
return !1;
|
|
3748
3690
|
};
|
|
3749
|
-
var
|
|
3691
|
+
var Yt = Object.freeze({
|
|
3750
3692
|
__proto__: null,
|
|
3751
3693
|
description: `collapses useless groups`,
|
|
3752
3694
|
fn: (e) => {
|
|
3753
|
-
let t =
|
|
3695
|
+
let t = M(e);
|
|
3754
3696
|
return { element: { exit: (e, n) => {
|
|
3755
|
-
if (
|
|
3697
|
+
if (n.type !== `root` && n.name !== `switch` && e.name === `g` && e.children.length !== 0) {
|
|
3756
3698
|
if (Object.keys(e.attributes).length !== 0 && e.children.length === 1) {
|
|
3757
|
-
let n = e.children[0], r = !!(e.attributes.filter ||
|
|
3699
|
+
let n = e.children[0], r = !!(e.attributes.filter || N(t, e).filter);
|
|
3758
3700
|
if (n.type === `element` && n.attributes.id == null && !r && (e.attributes.class == null || n.attributes.class == null) && (e.attributes[`clip-path`] == null && e.attributes.mask == null || n.name === `g` && e.attributes.transform == null && n.attributes.transform == null)) {
|
|
3759
3701
|
let t = { ...n.attributes };
|
|
3760
3702
|
for (let [r, i] of Object.entries(e.attributes)) {
|
|
3761
|
-
if (
|
|
3703
|
+
if (Jt(n, r)) return;
|
|
3762
3704
|
if (t[r] == null) t[r] = i;
|
|
3763
3705
|
else if (r === `transform`) t[r] = i + ` ` + t[r];
|
|
3764
3706
|
else if (t[r] === `inherit`) t[r] = i;
|
|
3765
|
-
else if (!
|
|
3707
|
+
else if (!j.has(r) && t[r] !== i) return;
|
|
3766
3708
|
}
|
|
3767
3709
|
e.attributes = {}, n.attributes = t;
|
|
3768
3710
|
}
|
|
3769
3711
|
}
|
|
3770
3712
|
if (Object.keys(e.attributes).length === 0) {
|
|
3771
|
-
for (let t of e.children) if (t.type === `element` &&
|
|
3713
|
+
for (let t of e.children) if (t.type === `element` && O.animation.has(t.name)) return;
|
|
3772
3714
|
let t = n.children.indexOf(e);
|
|
3773
3715
|
n.children.splice(t, 1, ...e.children);
|
|
3774
3716
|
}
|
|
@@ -3777,22 +3719,22 @@ var l = e(((e) => {
|
|
|
3777
3719
|
},
|
|
3778
3720
|
name: `collapseGroups`
|
|
3779
3721
|
});
|
|
3780
|
-
let
|
|
3722
|
+
let R, Xt = (e) => {
|
|
3781
3723
|
if (e.pathJS) return e.pathJS;
|
|
3782
|
-
let t = [], n =
|
|
3724
|
+
let t = [], n = It(e.attributes.d);
|
|
3783
3725
|
for (let { command: e, args: r } of n) t.push({
|
|
3784
3726
|
command: e,
|
|
3785
3727
|
args: r
|
|
3786
3728
|
});
|
|
3787
3729
|
return t.length && t[0].command == `m` && (t[0].command = `M`), e.pathJS = t, t;
|
|
3788
|
-
},
|
|
3730
|
+
}, Zt = (e) => {
|
|
3789
3731
|
let t = [], n = [0, 0], r = [0, 0];
|
|
3790
3732
|
for (let { command: i, args: a } of e) a = a.slice(), i === `m` && (a[0] += r[0], a[1] += r[1], i = `M`), i === `M` && (r[0] = a[0], r[1] = a[1], n[0] = r[0], n[1] = r[1]), i === `h` && (a[0] += r[0], i = `H`), i === `H` && (r[0] = a[0]), i === `v` && (a[0] += r[1], i = `V`), i === `V` && (r[1] = a[0]), i === `l` && (a[0] += r[0], a[1] += r[1], i = `L`), i === `L` && (r[0] = a[0], r[1] = a[1]), i === `c` && (a[0] += r[0], a[1] += r[1], a[2] += r[0], a[3] += r[1], a[4] += r[0], a[5] += r[1], i = `C`), i === `C` && (r[0] = a[4], r[1] = a[5]), i === `s` && (a[0] += r[0], a[1] += r[1], a[2] += r[0], a[3] += r[1], i = `S`), i === `S` && (r[0] = a[2], r[1] = a[3]), i === `q` && (a[0] += r[0], a[1] += r[1], a[2] += r[0], a[3] += r[1], i = `Q`), i === `Q` && (r[0] = a[2], r[1] = a[3]), i === `t` && (a[0] += r[0], a[1] += r[1], i = `T`), i === `T` && (r[0] = a[0], r[1] = a[1]), i === `a` && (a[5] += r[0], a[6] += r[1], i = `A`), i === `A` && (r[0] = a[5], r[1] = a[6]), (i === `z` || i === `Z`) && (r[0] = n[0], r[1] = n[1], i = `z`), t.push({
|
|
3791
3733
|
command: i,
|
|
3792
3734
|
args: a
|
|
3793
3735
|
});
|
|
3794
3736
|
return t;
|
|
3795
|
-
},
|
|
3737
|
+
}, Qt = function(e, t, n) {
|
|
3796
3738
|
e.pathJS = t;
|
|
3797
3739
|
let r = [];
|
|
3798
3740
|
for (let e of t) {
|
|
@@ -3805,67 +3747,67 @@ var l = e(((e) => {
|
|
|
3805
3747
|
args: e.args
|
|
3806
3748
|
});
|
|
3807
3749
|
}
|
|
3808
|
-
e.attributes.d =
|
|
3750
|
+
e.attributes.d = L({
|
|
3809
3751
|
pathData: r,
|
|
3810
3752
|
precision: n.floatPrecision,
|
|
3811
3753
|
disableSpaceAfterFlags: n.noSpaceAfterFlags
|
|
3812
3754
|
});
|
|
3813
3755
|
};
|
|
3814
|
-
function
|
|
3756
|
+
function z(e, t) {
|
|
3815
3757
|
return e[0] = t[t.length - 2], e[1] = t[t.length - 1], e;
|
|
3816
3758
|
}
|
|
3817
|
-
let
|
|
3818
|
-
let n =
|
|
3819
|
-
if (n.maxX <= r.minX || r.maxX <= n.minX || n.maxY <= r.minY || r.maxY <= n.minY || n.list.every((
|
|
3820
|
-
let i = n.list.map(
|
|
3821
|
-
return i.some(
|
|
3822
|
-
return e.list.length < 3 ? !1 : a.some(
|
|
3759
|
+
let $t = function(e, t) {
|
|
3760
|
+
let n = rn(Zt(e)), r = rn(Zt(t));
|
|
3761
|
+
if (n.maxX <= r.minX || r.maxX <= n.minX || n.maxY <= r.minY || r.maxY <= n.minY || n.list.every((e) => r.list.every((t) => e.list[e.maxX][0] <= t.list[t.minX][0] || t.list[t.maxX][0] <= e.list[e.minX][0] || e.list[e.maxY][1] <= t.list[t.minY][1] || t.list[t.maxY][1] <= e.list[e.minY][1]))) return !1;
|
|
3762
|
+
let i = n.list.map(an), a = r.list.map(an);
|
|
3763
|
+
return i.some(function(e) {
|
|
3764
|
+
return e.list.length < 3 ? !1 : a.some(function(t) {
|
|
3823
3765
|
if (t.list.length < 3) return !1;
|
|
3824
|
-
let n = [o(e, t, [1, 0])], r =
|
|
3766
|
+
let n = [o(e, t, [1, 0])], r = B(n[0]), i = 1e4;
|
|
3825
3767
|
for (;;) {
|
|
3826
3768
|
if (i-- == 0) return console.error(`Error: infinite loop while processing mergePaths plugin.`), !0;
|
|
3827
|
-
if (n.push(o(e, t, r)),
|
|
3828
|
-
if (
|
|
3769
|
+
if (n.push(o(e, t, r)), V(r, n[n.length - 1]) <= 0) return !1;
|
|
3770
|
+
if (en(n, r)) return !0;
|
|
3829
3771
|
}
|
|
3830
|
-
})
|
|
3831
|
-
})
|
|
3772
|
+
});
|
|
3773
|
+
});
|
|
3832
3774
|
function o(e, t, n) {
|
|
3833
|
-
return
|
|
3775
|
+
return tn(s(e, n), s(t, B(n)));
|
|
3834
3776
|
}
|
|
3835
3777
|
function s(e, t) {
|
|
3836
|
-
let n = t[1] >= 0 ? t[0] < 0 ? e.maxY : e.maxX : t[0] < 0 ? e.minX : e.minY, r = -
|
|
3837
|
-
for (; (i =
|
|
3778
|
+
let n = t[1] >= 0 ? t[0] < 0 ? e.maxY : e.maxX : t[0] < 0 ? e.minX : e.minY, r = -1 / 0, i;
|
|
3779
|
+
for (; (i = V(e.list[n], t)) > r;) r = i, n = (n + 1) % e.list.length;
|
|
3838
3780
|
return e.list[(n || e.list.length) - 1];
|
|
3839
3781
|
}
|
|
3840
3782
|
};
|
|
3841
|
-
function
|
|
3783
|
+
function en(e, t) {
|
|
3842
3784
|
if (e.length == 2) {
|
|
3843
|
-
let n = e[1], r = e[0], i =
|
|
3844
|
-
|
|
3785
|
+
let n = e[1], r = e[0], i = B(e[1]), a = tn(r, n);
|
|
3786
|
+
V(i, a) > 0 ? z(t, nn(a, n)) : (z(t, i), e.shift());
|
|
3845
3787
|
} else {
|
|
3846
|
-
let n = e[2], r = e[1], i = e[0], a =
|
|
3847
|
-
if (
|
|
3788
|
+
let n = e[2], r = e[1], i = e[0], a = tn(r, n), o = tn(i, n), s = B(n), c = nn(a, o), l = nn(o, a);
|
|
3789
|
+
if (V(c, s) > 0) V(a, s) > 0 ? (z(t, c), e.shift()) : (z(t, s), e.splice(0, 2));
|
|
3848
3790
|
else {
|
|
3849
|
-
if (!(
|
|
3850
|
-
|
|
3791
|
+
if (!(V(l, s) > 0)) return !0;
|
|
3792
|
+
V(o, s) > 0 ? (z(t, l), e.splice(1, 1)) : (z(t, s), e.splice(0, 2));
|
|
3851
3793
|
}
|
|
3852
3794
|
}
|
|
3853
3795
|
return !1;
|
|
3854
3796
|
}
|
|
3855
|
-
function
|
|
3797
|
+
function B(e) {
|
|
3856
3798
|
return [-e[0], -e[1]];
|
|
3857
3799
|
}
|
|
3858
|
-
function
|
|
3800
|
+
function tn(e, t) {
|
|
3859
3801
|
return [e[0] - t[0], e[1] - t[1]];
|
|
3860
3802
|
}
|
|
3861
|
-
function
|
|
3803
|
+
function V(e, t) {
|
|
3862
3804
|
return e[0] * t[0] + e[1] * t[1];
|
|
3863
3805
|
}
|
|
3864
|
-
function
|
|
3806
|
+
function nn(e, t) {
|
|
3865
3807
|
let n = [-e[1], e[0]];
|
|
3866
|
-
return
|
|
3808
|
+
return V(n, B(t)) < 0 ? B(n) : n;
|
|
3867
3809
|
}
|
|
3868
|
-
function
|
|
3810
|
+
function rn(e) {
|
|
3869
3811
|
let t = {
|
|
3870
3812
|
list: [],
|
|
3871
3813
|
minX: 0,
|
|
@@ -3900,40 +3842,38 @@ var l = e(((e) => {
|
|
|
3900
3842
|
c != null && n(o, [c[0], l[0]]);
|
|
3901
3843
|
break;
|
|
3902
3844
|
case `Q`:
|
|
3903
|
-
n(o, l.slice(0, 2)),
|
|
3845
|
+
n(o, l.slice(0, 2)), R = [l[2] - l[0], l[3] - l[1]];
|
|
3904
3846
|
break;
|
|
3905
3847
|
case `T`:
|
|
3906
|
-
c != null && s != null && (s.command == `Q` || s.command == `T`) && (u = [c[0] +
|
|
3848
|
+
c != null && s != null && (s.command == `Q` || s.command == `T`) && (u = [c[0] + R[0], c[1] + R[1]], n(o, u), R = [l[0] - u[0], l[1] - u[1]]);
|
|
3907
3849
|
break;
|
|
3908
3850
|
case `C`:
|
|
3909
|
-
c != null && n(o, [.5 * (c[0] + l[0]), .5 * (c[1] + l[1])]), n(o, [.5 * (l[0] + l[2]), .5 * (l[1] + l[3])]), n(o, [.5 * (l[2] + l[4]), .5 * (l[3] + l[5])]),
|
|
3851
|
+
c != null && n(o, [.5 * (c[0] + l[0]), .5 * (c[1] + l[1])]), n(o, [.5 * (l[0] + l[2]), .5 * (l[1] + l[3])]), n(o, [.5 * (l[2] + l[4]), .5 * (l[3] + l[5])]), R = [l[4] - l[2], l[5] - l[3]];
|
|
3910
3852
|
break;
|
|
3911
3853
|
case `S`:
|
|
3912
|
-
c != null && s != null && (s.command == `C` || s.command == `S`) && (n(o, [c[0] + .5 *
|
|
3913
|
-
break;
|
|
3914
|
-
case `A`:
|
|
3915
|
-
if (c != null) {
|
|
3916
|
-
let e = rn.apply(0, c.concat(l));
|
|
3917
|
-
for (var r; (r = e.splice(0, 6).map(d)).length;) c != null && n(o, [.5 * (c[0] + r[0]), .5 * (c[1] + r[1])]), n(o, [.5 * (r[0] + r[2]), .5 * (r[1] + r[3])]), n(o, [.5 * (r[2] + r[4]), .5 * (r[3] + r[5])]), e.length && n(o, c = r.slice(-2));
|
|
3918
|
-
}
|
|
3854
|
+
c != null && s != null && (s.command == `C` || s.command == `S`) && (n(o, [c[0] + .5 * R[0], c[1] + .5 * R[1]]), u = [c[0] + R[0], c[1] + R[1]]), u != null && n(o, [.5 * (u[0] + l[0]), .5 * (u[1] + l[1])]), n(o, [.5 * (l[0] + l[2]), .5 * (l[1] + l[3])]), R = [l[2] - l[0], l[3] - l[1]];
|
|
3919
3855
|
break;
|
|
3856
|
+
case `A`: if (c != null) {
|
|
3857
|
+
let e = sn.apply(0, c.concat(l));
|
|
3858
|
+
for (var r; (r = e.splice(0, 6).map(d)).length;) c != null && n(o, [.5 * (c[0] + r[0]), .5 * (c[1] + r[1])]), n(o, [.5 * (r[0] + r[2]), .5 * (r[1] + r[3])]), n(o, [.5 * (r[2] + r[4]), .5 * (r[3] + r[5])]), e.length && n(o, c = r.slice(-2));
|
|
3859
|
+
}
|
|
3920
3860
|
}
|
|
3921
3861
|
l.length >= 2 && n(o, l.slice(-2));
|
|
3922
3862
|
}
|
|
3923
3863
|
return t;
|
|
3924
3864
|
}
|
|
3925
|
-
function
|
|
3926
|
-
e.list.sort(
|
|
3865
|
+
function an(e) {
|
|
3866
|
+
e.list.sort(function(e, t) {
|
|
3927
3867
|
return e[0] == t[0] ? e[1] - t[1] : e[0] - t[0];
|
|
3928
|
-
})
|
|
3868
|
+
});
|
|
3929
3869
|
let t = [], n = 0, r = 0;
|
|
3930
3870
|
for (let i = 0; i < e.list.length; i++) {
|
|
3931
|
-
for (; t.length >= 2 &&
|
|
3871
|
+
for (; t.length >= 2 && on(t[t.length - 2], t[t.length - 1], e.list[i]) <= 0;) t.pop();
|
|
3932
3872
|
e.list[i][1] < e.list[n][1] && (n = i, r = t.length), t.push(e.list[i]);
|
|
3933
3873
|
}
|
|
3934
3874
|
let i = [], a = e.list.length - 1, o = 0;
|
|
3935
3875
|
for (let t = e.list.length; t--;) {
|
|
3936
|
-
for (; i.length >= 2 &&
|
|
3876
|
+
for (; i.length >= 2 && on(i[i.length - 2], i[i.length - 1], e.list[t]) <= 0;) i.pop();
|
|
3937
3877
|
e.list[t][1] > e.list[a][1] && (a = t, o = i.length), i.push(e.list[t]);
|
|
3938
3878
|
}
|
|
3939
3879
|
i.pop(), t.pop();
|
|
@@ -3946,10 +3886,10 @@ var l = e(((e) => {
|
|
|
3946
3886
|
maxY: (t.length + o) % s.length
|
|
3947
3887
|
};
|
|
3948
3888
|
}
|
|
3949
|
-
function
|
|
3889
|
+
function on(e, t, n) {
|
|
3950
3890
|
return (t[0] - e[0]) * (n[1] - e[1]) - (t[1] - e[1]) * (n[0] - e[0]);
|
|
3951
3891
|
}
|
|
3952
|
-
let
|
|
3892
|
+
let sn = (e, t, n, r, i, a, o, s, c, l) => {
|
|
3953
3893
|
let u = Math.PI * 120 / 180, d = Math.PI / 180 * (+i || 0), f = [], p = (e, t, n) => e * Math.cos(n) - t * Math.sin(n), m = (e, t, n) => e * Math.sin(n) + t * Math.cos(n);
|
|
3954
3894
|
if (l) _ = l[0], v = l[1], h = l[2], g = l[3];
|
|
3955
3895
|
else {
|
|
@@ -3963,7 +3903,7 @@ var l = e(((e) => {
|
|
|
3963
3903
|
let y = v - _;
|
|
3964
3904
|
if (Math.abs(y) > u) {
|
|
3965
3905
|
let e = v, t = s, a = c;
|
|
3966
|
-
v = _ + u * (o && v > _ ? 1 : -1), s = h + n * Math.cos(v), c = g + r * Math.sin(v), f =
|
|
3906
|
+
v = _ + u * (o && v > _ ? 1 : -1), s = h + n * Math.cos(v), c = g + r * Math.sin(v), f = sn(s, c, n, r, i, 0, o, t, a, [
|
|
3967
3907
|
v,
|
|
3968
3908
|
e,
|
|
3969
3909
|
h,
|
|
@@ -3971,58 +3911,60 @@ var l = e(((e) => {
|
|
|
3971
3911
|
]);
|
|
3972
3912
|
}
|
|
3973
3913
|
y = v - _;
|
|
3974
|
-
let b = Math.cos(_), x = Math.sin(_), S = Math.cos(v),
|
|
3975
|
-
-
|
|
3976
|
-
|
|
3977
|
-
s +
|
|
3978
|
-
c -
|
|
3914
|
+
let b = Math.cos(_), x = Math.sin(_), S = Math.cos(v), ee = Math.sin(v), C = Math.tan(y / 4), w = 4 / 3 * n * C, te = 4 / 3 * r * C, T = [
|
|
3915
|
+
-w * x,
|
|
3916
|
+
te * b,
|
|
3917
|
+
s + w * ee - e,
|
|
3918
|
+
c - te * S - t,
|
|
3979
3919
|
s - e,
|
|
3980
3920
|
c - t
|
|
3981
3921
|
];
|
|
3982
|
-
if (l) return
|
|
3922
|
+
if (l) return T.concat(f);
|
|
3983
3923
|
{
|
|
3984
|
-
f =
|
|
3924
|
+
f = T.concat(f);
|
|
3985
3925
|
let e = [];
|
|
3986
3926
|
for (let t = 0, n = f.length; t < n; t++) e[t] = t % 2 ? m(f[t - 1], f[t], d) : p(f[t], f[t + 1], d);
|
|
3987
3927
|
return e;
|
|
3988
3928
|
}
|
|
3989
|
-
},
|
|
3929
|
+
}, cn = /* @__PURE__ */ new Set([
|
|
3990
3930
|
`matrix`,
|
|
3991
3931
|
`rotate`,
|
|
3992
3932
|
`scale`,
|
|
3993
3933
|
`skewX`,
|
|
3994
3934
|
`skewY`,
|
|
3995
3935
|
`translate`
|
|
3996
|
-
]),
|
|
3936
|
+
]), ln = /\s*(matrix|translate|scale|rotate|skewX|skewY)\s*\(\s*(.+?)\s*\)[\s,]*/, un = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g, dn = (e) => {
|
|
3997
3937
|
let t = [], n = null;
|
|
3998
|
-
for (let r of e.split(
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
3938
|
+
for (let r of e.split(ln)) if (r) {
|
|
3939
|
+
if (cn.has(r)) n = {
|
|
3940
|
+
name: r,
|
|
3941
|
+
data: []
|
|
3942
|
+
}, t.push(n);
|
|
3943
|
+
else {
|
|
3944
|
+
let e;
|
|
3945
|
+
for (; e = un.exec(r);) e = Number(e), n?.data.push(e);
|
|
3946
|
+
}
|
|
4005
3947
|
}
|
|
4006
3948
|
return n == null || n.data.length == 0 ? [] : t;
|
|
4007
|
-
},
|
|
4008
|
-
let t = e.map((
|
|
3949
|
+
}, fn = (e) => {
|
|
3950
|
+
let t = e.map((e) => e.name === `matrix` ? e.data : xn(e));
|
|
4009
3951
|
return {
|
|
4010
3952
|
name: `matrix`,
|
|
4011
|
-
data: t.length > 0 ? t.reduce(
|
|
3953
|
+
data: t.length > 0 ? t.reduce(Cn) : []
|
|
4012
3954
|
};
|
|
4013
|
-
},
|
|
3955
|
+
}, H = {
|
|
4014
3956
|
rad: (e) => e * Math.PI / 180,
|
|
4015
3957
|
deg: (e) => e * 180 / Math.PI,
|
|
4016
|
-
cos: (e) => Math.cos(
|
|
4017
|
-
acos: (e, t) =>
|
|
4018
|
-
sin: (e) => Math.sin(
|
|
4019
|
-
asin: (e, t) =>
|
|
4020
|
-
tan: (e) => Math.tan(
|
|
4021
|
-
atan: (e, t) =>
|
|
4022
|
-
},
|
|
4023
|
-
let t = [], n =
|
|
3958
|
+
cos: (e) => Math.cos(H.rad(e)),
|
|
3959
|
+
acos: (e, t) => I(H.deg(Math.acos(e)), t),
|
|
3960
|
+
sin: (e) => Math.sin(H.rad(e)),
|
|
3961
|
+
asin: (e, t) => I(H.deg(Math.asin(e)), t),
|
|
3962
|
+
tan: (e) => Math.tan(H.rad(e)),
|
|
3963
|
+
atan: (e, t) => I(H.deg(Math.atan(e)), t)
|
|
3964
|
+
}, pn = (e) => {
|
|
3965
|
+
let t = [], n = mn(e), r = hn(e);
|
|
4024
3966
|
return n && t.push(n), r && t.push(r), t;
|
|
4025
|
-
},
|
|
3967
|
+
}, mn = (e) => {
|
|
4026
3968
|
let [t, n, r, i, a, o] = e.data, s = t * i - n * r;
|
|
4027
3969
|
if (s === 0) return;
|
|
4028
3970
|
let c = Math.hypot(t, n);
|
|
@@ -4036,7 +3978,7 @@ var l = e(((e) => {
|
|
|
4036
3978
|
l.push({
|
|
4037
3979
|
name: `rotate`,
|
|
4038
3980
|
data: [
|
|
4039
|
-
|
|
3981
|
+
H.deg(n < 0 ? -e : e),
|
|
4040
3982
|
0,
|
|
4041
3983
|
0
|
|
4042
3984
|
]
|
|
@@ -4050,9 +3992,9 @@ var l = e(((e) => {
|
|
|
4050
3992
|
let p = t * r + n * i;
|
|
4051
3993
|
return p && l.push({
|
|
4052
3994
|
name: `skewX`,
|
|
4053
|
-
data: [
|
|
3995
|
+
data: [H.deg(Math.atan(p / (t * t + n * n)))]
|
|
4054
3996
|
}), l;
|
|
4055
|
-
},
|
|
3997
|
+
}, hn = (e) => {
|
|
4056
3998
|
let [t, n, r, i, a, o] = e.data, s = t * i - n * r;
|
|
4057
3999
|
if (s === 0) return;
|
|
4058
4000
|
let c = Math.hypot(r, i);
|
|
@@ -4066,7 +4008,7 @@ var l = e(((e) => {
|
|
|
4066
4008
|
l.push({
|
|
4067
4009
|
name: `rotate`,
|
|
4068
4010
|
data: [
|
|
4069
|
-
|
|
4011
|
+
H.deg(u),
|
|
4070
4012
|
0,
|
|
4071
4013
|
0
|
|
4072
4014
|
]
|
|
@@ -4079,10 +4021,10 @@ var l = e(((e) => {
|
|
|
4079
4021
|
let p = t * r + n * i;
|
|
4080
4022
|
return p && l.push({
|
|
4081
4023
|
name: `skewY`,
|
|
4082
|
-
data: [
|
|
4024
|
+
data: [H.deg(Math.atan(p / (r * r + i * i)))]
|
|
4083
4025
|
}), l;
|
|
4084
|
-
},
|
|
4085
|
-
let r =
|
|
4026
|
+
}, gn = (e, t, n) => {
|
|
4027
|
+
let r = H.rad(n), i = 1 - Math.cos(r), a = Math.sin(r), o = (i * t + a * e) / (i * i + a * a);
|
|
4086
4028
|
return {
|
|
4087
4029
|
name: `rotate`,
|
|
4088
4030
|
data: [
|
|
@@ -4091,7 +4033,7 @@ var l = e(((e) => {
|
|
|
4091
4033
|
o
|
|
4092
4034
|
]
|
|
4093
4035
|
};
|
|
4094
|
-
},
|
|
4036
|
+
}, _n = (e) => {
|
|
4095
4037
|
switch (e.name) {
|
|
4096
4038
|
case `rotate`:
|
|
4097
4039
|
case `skewX`:
|
|
@@ -4100,11 +4042,11 @@ var l = e(((e) => {
|
|
|
4100
4042
|
case `translate`: return e.data[0] === 0 && e.data[1] === 0;
|
|
4101
4043
|
}
|
|
4102
4044
|
return !1;
|
|
4103
|
-
},
|
|
4045
|
+
}, vn = (e, t) => {
|
|
4104
4046
|
let n = [];
|
|
4105
4047
|
for (let r = 0; r < e.length; r++) {
|
|
4106
4048
|
let i = e[r];
|
|
4107
|
-
if (
|
|
4049
|
+
if (_n(i)) continue;
|
|
4108
4050
|
let a = i.data;
|
|
4109
4051
|
switch (i.name) {
|
|
4110
4052
|
case `rotate`:
|
|
@@ -4113,7 +4055,7 @@ var l = e(((e) => {
|
|
|
4113
4055
|
case -180:
|
|
4114
4056
|
{
|
|
4115
4057
|
let t = e[r + 1];
|
|
4116
|
-
t && t.name === `scale` ? (n.push(
|
|
4058
|
+
t && t.name === `scale` ? (n.push(yn(t.data.map((e) => -e))), r++) : n.push({
|
|
4117
4059
|
name: `scale`,
|
|
4118
4060
|
data: [-1]
|
|
4119
4061
|
});
|
|
@@ -4126,7 +4068,7 @@ var l = e(((e) => {
|
|
|
4126
4068
|
});
|
|
4127
4069
|
break;
|
|
4128
4070
|
case `scale`:
|
|
4129
|
-
n.push(
|
|
4071
|
+
n.push(yn(a));
|
|
4130
4072
|
break;
|
|
4131
4073
|
case `skewX`:
|
|
4132
4074
|
case `skewY`:
|
|
@@ -4140,7 +4082,7 @@ var l = e(((e) => {
|
|
|
4140
4082
|
let i = e[r + 1];
|
|
4141
4083
|
if (i && i.name === `rotate` && i.data[0] !== 180 && i.data[0] !== -180 && i.data[0] !== 0 && i.data[1] === 0 && i.data[2] === 0) {
|
|
4142
4084
|
let e = t[r].data;
|
|
4143
|
-
n.push(
|
|
4085
|
+
n.push(gn(e[0], e[1], t[r + 1].data[0])), r++;
|
|
4144
4086
|
continue;
|
|
4145
4087
|
}
|
|
4146
4088
|
}
|
|
@@ -4148,27 +4090,29 @@ var l = e(((e) => {
|
|
|
4148
4090
|
name: `translate`,
|
|
4149
4091
|
data: a.slice(0, a[1] ? 2 : 1)
|
|
4150
4092
|
});
|
|
4151
|
-
break;
|
|
4152
4093
|
}
|
|
4153
4094
|
}
|
|
4154
4095
|
return n.length ? n : [{
|
|
4155
4096
|
name: `scale`,
|
|
4156
4097
|
data: [1]
|
|
4157
4098
|
}];
|
|
4158
|
-
},
|
|
4099
|
+
}, yn = (e) => ({
|
|
4159
4100
|
name: `scale`,
|
|
4160
4101
|
data: e.slice(0, e[0] === e[1] ? 1 : 2)
|
|
4161
|
-
}),
|
|
4162
|
-
let n =
|
|
4102
|
+
}), bn = (e, t) => {
|
|
4103
|
+
let n = pn(e), r, i = Number.MAX_VALUE;
|
|
4163
4104
|
for (let e of n) {
|
|
4164
|
-
let n =
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4105
|
+
let n = e.map((e) => {
|
|
4106
|
+
let n = {
|
|
4107
|
+
name: e.name,
|
|
4108
|
+
data: [...e.data]
|
|
4109
|
+
};
|
|
4110
|
+
return wn(n, t);
|
|
4111
|
+
}), a = vn(n, e), o = An(a, t).length;
|
|
4112
|
+
o < i && (r = a, i = o);
|
|
4169
4113
|
}
|
|
4170
4114
|
return r ?? [e];
|
|
4171
|
-
},
|
|
4115
|
+
}, xn = (e) => {
|
|
4172
4116
|
if (e.name === `matrix`) return e.data;
|
|
4173
4117
|
switch (e.name) {
|
|
4174
4118
|
case `translate`: return [
|
|
@@ -4188,7 +4132,7 @@ var l = e(((e) => {
|
|
|
4188
4132
|
0
|
|
4189
4133
|
];
|
|
4190
4134
|
case `rotate`:
|
|
4191
|
-
var t =
|
|
4135
|
+
var t = H.cos(e.data[0]), n = H.sin(e.data[0]), r = e.data[1] || 0, i = e.data[2] || 0;
|
|
4192
4136
|
return [
|
|
4193
4137
|
t,
|
|
4194
4138
|
n,
|
|
@@ -4200,14 +4144,14 @@ var l = e(((e) => {
|
|
|
4200
4144
|
case `skewX`: return [
|
|
4201
4145
|
1,
|
|
4202
4146
|
0,
|
|
4203
|
-
|
|
4147
|
+
H.tan(e.data[0]),
|
|
4204
4148
|
1,
|
|
4205
4149
|
0,
|
|
4206
4150
|
0
|
|
4207
4151
|
];
|
|
4208
4152
|
case `skewY`: return [
|
|
4209
4153
|
1,
|
|
4210
|
-
|
|
4154
|
+
H.tan(e.data[0]),
|
|
4211
4155
|
0,
|
|
4212
4156
|
1,
|
|
4213
4157
|
0,
|
|
@@ -4215,156 +4159,155 @@ var l = e(((e) => {
|
|
|
4215
4159
|
];
|
|
4216
4160
|
default: throw Error(`Unknown transform ${e.name}`);
|
|
4217
4161
|
}
|
|
4218
|
-
},
|
|
4162
|
+
}, Sn = (e, t, n) => {
|
|
4219
4163
|
let r = t[5] - e[0], i = t[6] - e[1], a = t[0], o = t[1], s = t[2] * Math.PI / 180, c = Math.cos(s), l = Math.sin(s);
|
|
4220
4164
|
if (a > 0 && o > 0) {
|
|
4221
4165
|
let e = (r * c + i * l) ** 2 / (4 * a * a) + (i * c - r * l) ** 2 / (4 * o * o);
|
|
4222
4166
|
e > 1 && (e = Math.sqrt(e), a *= e, o *= e);
|
|
4223
4167
|
}
|
|
4224
|
-
let u =
|
|
4168
|
+
let u = [
|
|
4225
4169
|
a * c,
|
|
4226
4170
|
a * l,
|
|
4227
4171
|
-o * l,
|
|
4228
4172
|
o * c,
|
|
4229
4173
|
0,
|
|
4230
4174
|
0
|
|
4231
|
-
]
|
|
4232
|
-
if (
|
|
4233
|
-
let e = (
|
|
4175
|
+
], d = Cn(n, u), f = d[2] * d[2] + d[3] * d[3], p = d[0] * d[0] + d[1] * d[1] + f, m = Math.hypot(d[0] - d[3], d[1] + d[2]) * Math.hypot(d[0] + d[3], d[1] - d[2]);
|
|
4176
|
+
if (m) {
|
|
4177
|
+
let e = (p + m) / 2, n = (p - m) / 2, r = Math.abs(e - f) > 1e-6, i = (r ? e : n) - f, a = d[0] * d[2] + d[1] * d[3], o = d[0] * i + d[2] * a, s = d[1] * i + d[3] * a;
|
|
4234
4178
|
t[0] = Math.sqrt(e), t[1] = Math.sqrt(n), t[2] = ((r ? s < 0 : o > 0) ? -1 : 1) * Math.acos((r ? o : s) / Math.hypot(o, s)) * 180 / Math.PI;
|
|
4235
|
-
} else t[0] = t[1] = Math.sqrt(
|
|
4179
|
+
} else t[0] = t[1] = Math.sqrt(p / 2), t[2] = 0;
|
|
4236
4180
|
return n[0] < 0 != n[3] < 0 && (t[4] = 1 - t[4]), t;
|
|
4237
|
-
},
|
|
4181
|
+
}, Cn = (e, t) => [
|
|
4238
4182
|
e[0] * t[0] + e[2] * t[1],
|
|
4239
4183
|
e[1] * t[0] + e[3] * t[1],
|
|
4240
4184
|
e[0] * t[2] + e[2] * t[3],
|
|
4241
4185
|
e[1] * t[2] + e[3] * t[3],
|
|
4242
4186
|
e[0] * t[4] + e[2] * t[5] + e[4],
|
|
4243
4187
|
e[1] * t[4] + e[3] * t[5] + e[5]
|
|
4244
|
-
],
|
|
4188
|
+
], wn = (e, t) => {
|
|
4245
4189
|
switch (e.name) {
|
|
4246
4190
|
case `translate`:
|
|
4247
|
-
e.data =
|
|
4191
|
+
e.data = En(e.data, t);
|
|
4248
4192
|
break;
|
|
4249
4193
|
case `rotate`:
|
|
4250
|
-
e.data = [...
|
|
4194
|
+
e.data = [...Tn(e.data.slice(0, 1), t), ...En(e.data.slice(1), t)];
|
|
4251
4195
|
break;
|
|
4252
4196
|
case `skewX`:
|
|
4253
4197
|
case `skewY`:
|
|
4254
|
-
e.data =
|
|
4198
|
+
e.data = Tn(e.data, t);
|
|
4255
4199
|
break;
|
|
4256
4200
|
case `scale`:
|
|
4257
|
-
e.data =
|
|
4258
|
-
break;
|
|
4259
|
-
case `matrix`:
|
|
4260
|
-
e.data = [...wn(e.data.slice(0, 4), t), ...Cn(e.data.slice(4), t)];
|
|
4201
|
+
e.data = Dn(e.data, t);
|
|
4261
4202
|
break;
|
|
4203
|
+
case `matrix`: e.data = [...Dn(e.data.slice(0, 4), t), ...En(e.data.slice(4), t)];
|
|
4262
4204
|
}
|
|
4263
4205
|
return e;
|
|
4264
|
-
},
|
|
4265
|
-
for (let n = t.length, r = +(.1 ** e).toFixed(e); n--;) if (
|
|
4206
|
+
}, Tn = (e, t) => t.degPrecision != null && t.degPrecision >= 1 && t.floatPrecision < 20 ? kn(t.degPrecision, e) : On(e), En = (e, t) => t.floatPrecision >= 1 && t.floatPrecision < 20 ? kn(t.floatPrecision, e) : On(e), Dn = (e, t) => t.transformPrecision >= 1 && t.floatPrecision < 20 ? kn(t.transformPrecision, e) : On(e), On = (e) => e.map(Math.round), kn = (e, t) => {
|
|
4207
|
+
for (let n = t.length, r = +(.1 ** e).toFixed(e); n--;) if (I(t[n], e) !== t[n]) {
|
|
4266
4208
|
let i = +t[n].toFixed(e - 1);
|
|
4267
4209
|
t[n] = +Math.abs(i - t[n]).toFixed(e + 1) >= r ? +t[n].toFixed(e) : i;
|
|
4268
4210
|
}
|
|
4269
4211
|
return t;
|
|
4270
|
-
},
|
|
4271
|
-
let n =
|
|
4212
|
+
}, An = (e, t) => e.map((e) => (wn(e, t), `${e.name}(${P(e.data, t)})`)).join(``), jn = /[-+]?(\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g, Mn = (e, t) => {
|
|
4213
|
+
let n = M(e);
|
|
4272
4214
|
return { element: { enter: (e) => {
|
|
4273
|
-
if (e.attributes.d == null || e.attributes.id != null || e.attributes.transform == null || e.attributes.transform === `` || e.attributes.style != null || Object.entries(e.attributes).some((
|
|
4274
|
-
let r =
|
|
4215
|
+
if (e.attributes.d == null || e.attributes.id != null || e.attributes.transform == null || e.attributes.transform === `` || e.attributes.style != null || Object.entries(e.attributes).some(([e, t]) => A.has(e) && $e(t))) return;
|
|
4216
|
+
let r = N(n, e), i = r.transform;
|
|
4275
4217
|
if (i.type === `static` && i.value !== e.attributes.transform) return;
|
|
4276
|
-
let a =
|
|
4218
|
+
let a = fn(dn(e.attributes.transform)), o = r.stroke?.type === `static` ? r.stroke.value : null, s = r[`stroke-width`]?.type === `static` ? r[`stroke-width`].value : null, c = t.transformPrecision;
|
|
4277
4219
|
if (r.stroke?.type === `dynamic` || r[`stroke-width`]?.type === `dynamic`) return;
|
|
4278
4220
|
let l = Number(Math.hypot(a.data[0], a.data[1]).toFixed(c));
|
|
4279
4221
|
if (o && o != `none`) {
|
|
4280
4222
|
if (!t.applyTransformsStroked || (a.data[0] !== a.data[3] || a.data[1] !== -a.data[2]) && (a.data[0] !== -a.data[3] || a.data[1] !== a.data[2])) return;
|
|
4281
|
-
l !== 1 && e.attributes[`vector-effect`] !== `non-scaling-stroke` && (e.attributes[`stroke-width`] = (s ||
|
|
4223
|
+
l !== 1 && e.attributes[`vector-effect`] !== `non-scaling-stroke` && (e.attributes[`stroke-width`] = (s || he.presentation[`stroke-width`]).trim().replace(jn, (e) => F(Number(e) * l)), e.attributes[`stroke-dashoffset`] != null && (e.attributes[`stroke-dashoffset`] = e.attributes[`stroke-dashoffset`].trim().replace(jn, (e) => F(Number(e) * l))), e.attributes[`stroke-dasharray`] != null && (e.attributes[`stroke-dasharray`] = e.attributes[`stroke-dasharray`].trim().replace(jn, (e) => F(Number(e) * l))));
|
|
4282
4224
|
}
|
|
4283
|
-
|
|
4225
|
+
let u = Xt(e);
|
|
4226
|
+
Nn(u, a.data), delete e.attributes.transform;
|
|
4284
4227
|
} } };
|
|
4285
|
-
},
|
|
4228
|
+
}, U = (e, t, n) => [e[0] * t + e[2] * n + e[4], e[1] * t + e[3] * n + e[5]], W = (e, t, n) => [e[0] * t + e[2] * n, e[1] * t + e[3] * n], Nn = (e, t) => {
|
|
4286
4229
|
let n = [0, 0], r = [0, 0];
|
|
4287
4230
|
for (let i of e) {
|
|
4288
4231
|
let { command: e, args: a } = i;
|
|
4289
4232
|
if (e === `M`) {
|
|
4290
4233
|
r[0] = a[0], r[1] = a[1], n[0] = r[0], n[1] = r[1];
|
|
4291
|
-
let [e, i] =
|
|
4234
|
+
let [e, i] = U(t, a[0], a[1]);
|
|
4292
4235
|
a[0] = e, a[1] = i;
|
|
4293
4236
|
}
|
|
4294
4237
|
if (e === `m`) {
|
|
4295
4238
|
r[0] += a[0], r[1] += a[1], n[0] = r[0], n[1] = r[1];
|
|
4296
|
-
let [e, i] =
|
|
4239
|
+
let [e, i] = W(t, a[0], a[1]);
|
|
4297
4240
|
a[0] = e, a[1] = i;
|
|
4298
4241
|
}
|
|
4299
4242
|
if (e === `H` && (e = `L`, a = [a[0], r[1]]), e === `h` && (e = `l`, a = [a[0], 0]), e === `V` && (e = `L`, a = [r[0], a[0]]), e === `v` && (e = `l`, a = [0, a[0]]), e === `L`) {
|
|
4300
4243
|
r[0] = a[0], r[1] = a[1];
|
|
4301
|
-
let [e, n] =
|
|
4244
|
+
let [e, n] = U(t, a[0], a[1]);
|
|
4302
4245
|
a[0] = e, a[1] = n;
|
|
4303
4246
|
}
|
|
4304
4247
|
if (e === `l`) {
|
|
4305
4248
|
r[0] += a[0], r[1] += a[1];
|
|
4306
|
-
let [e, n] =
|
|
4249
|
+
let [e, n] = W(t, a[0], a[1]);
|
|
4307
4250
|
a[0] = e, a[1] = n;
|
|
4308
4251
|
}
|
|
4309
4252
|
if (e === `C`) {
|
|
4310
4253
|
r[0] = a[4], r[1] = a[5];
|
|
4311
|
-
let [e, n] =
|
|
4254
|
+
let [e, n] = U(t, a[0], a[1]), [i, o] = U(t, a[2], a[3]), [s, c] = U(t, a[4], a[5]);
|
|
4312
4255
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o, a[4] = s, a[5] = c;
|
|
4313
4256
|
}
|
|
4314
4257
|
if (e === `c`) {
|
|
4315
4258
|
r[0] += a[4], r[1] += a[5];
|
|
4316
|
-
let [e, n] =
|
|
4259
|
+
let [e, n] = W(t, a[0], a[1]), [i, o] = W(t, a[2], a[3]), [s, c] = W(t, a[4], a[5]);
|
|
4317
4260
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o, a[4] = s, a[5] = c;
|
|
4318
4261
|
}
|
|
4319
4262
|
if (e === `S`) {
|
|
4320
4263
|
r[0] = a[2], r[1] = a[3];
|
|
4321
|
-
let [e, n] =
|
|
4264
|
+
let [e, n] = U(t, a[0], a[1]), [i, o] = U(t, a[2], a[3]);
|
|
4322
4265
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o;
|
|
4323
4266
|
}
|
|
4324
4267
|
if (e === `s`) {
|
|
4325
4268
|
r[0] += a[2], r[1] += a[3];
|
|
4326
|
-
let [e, n] =
|
|
4269
|
+
let [e, n] = W(t, a[0], a[1]), [i, o] = W(t, a[2], a[3]);
|
|
4327
4270
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o;
|
|
4328
4271
|
}
|
|
4329
4272
|
if (e === `Q`) {
|
|
4330
4273
|
r[0] = a[2], r[1] = a[3];
|
|
4331
|
-
let [e, n] =
|
|
4274
|
+
let [e, n] = U(t, a[0], a[1]), [i, o] = U(t, a[2], a[3]);
|
|
4332
4275
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o;
|
|
4333
4276
|
}
|
|
4334
4277
|
if (e === `q`) {
|
|
4335
4278
|
r[0] += a[2], r[1] += a[3];
|
|
4336
|
-
let [e, n] =
|
|
4279
|
+
let [e, n] = W(t, a[0], a[1]), [i, o] = W(t, a[2], a[3]);
|
|
4337
4280
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o;
|
|
4338
4281
|
}
|
|
4339
4282
|
if (e === `T`) {
|
|
4340
4283
|
r[0] = a[0], r[1] = a[1];
|
|
4341
|
-
let [e, n] =
|
|
4284
|
+
let [e, n] = U(t, a[0], a[1]);
|
|
4342
4285
|
a[0] = e, a[1] = n;
|
|
4343
4286
|
}
|
|
4344
4287
|
if (e === `t`) {
|
|
4345
4288
|
r[0] += a[0], r[1] += a[1];
|
|
4346
|
-
let [e, n] =
|
|
4289
|
+
let [e, n] = W(t, a[0], a[1]);
|
|
4347
4290
|
a[0] = e, a[1] = n;
|
|
4348
4291
|
}
|
|
4349
4292
|
if (e === `A`) {
|
|
4350
|
-
if (
|
|
4293
|
+
if (Sn(r, a, t), r[0] = a[5], r[1] = a[6], Math.abs(a[2]) > 80) {
|
|
4351
4294
|
let e = a[0], t = a[2];
|
|
4352
4295
|
a[0] = a[1], a[1] = e, a[2] = t + (t > 0 ? -90 : 90);
|
|
4353
4296
|
}
|
|
4354
|
-
let [e, n] =
|
|
4297
|
+
let [e, n] = U(t, a[5], a[6]);
|
|
4355
4298
|
a[5] = e, a[6] = n;
|
|
4356
4299
|
}
|
|
4357
4300
|
if (e === `a`) {
|
|
4358
|
-
if (
|
|
4301
|
+
if (Sn([0, 0], a, t), r[0] += a[5], r[1] += a[6], Math.abs(a[2]) > 80) {
|
|
4359
4302
|
let e = a[0], t = a[2];
|
|
4360
4303
|
a[0] = a[1], a[1] = e, a[2] = t + (t > 0 ? -90 : 90);
|
|
4361
4304
|
}
|
|
4362
|
-
let [e, n] =
|
|
4305
|
+
let [e, n] = W(t, a[5], a[6]);
|
|
4363
4306
|
a[5] = e, a[6] = n;
|
|
4364
4307
|
}
|
|
4365
4308
|
(e === `z` || e === `Z`) && (r[0] = n[0], r[1] = n[1]), i.command = e, i.args = a;
|
|
4366
4309
|
}
|
|
4367
|
-
},
|
|
4310
|
+
}, G, K, q, Pn, Fn, In = (e, t) => {
|
|
4368
4311
|
let { applyTransforms: n = !0, applyTransformsStroked: r = !0, makeArcs: i = {
|
|
4369
4312
|
threshold: 2.5,
|
|
4370
4313
|
tolerance: .5
|
|
@@ -4388,30 +4331,30 @@ var l = e(((e) => {
|
|
|
4388
4331
|
noSpaceAfterFlags: v,
|
|
4389
4332
|
forceAbsolutePath: y
|
|
4390
4333
|
};
|
|
4391
|
-
n &&
|
|
4334
|
+
n && x(e, Mn(e, {
|
|
4392
4335
|
transformPrecision: d,
|
|
4393
4336
|
applyTransformsStroked: r
|
|
4394
4337
|
}));
|
|
4395
|
-
let
|
|
4338
|
+
let S = M(e);
|
|
4396
4339
|
return { element: { enter: (e) => {
|
|
4397
|
-
if (
|
|
4398
|
-
let t =
|
|
4399
|
-
|
|
4400
|
-
let n = t[`marker-mid`] != null, r = t.stroke && (t.stroke.type === `dynamic` || t.stroke.value !== `none`), a = t[`stroke-linecap`] && (t[`stroke-linecap`].type === `dynamic` || t[`stroke-linecap`].value !== `butt`), o =
|
|
4340
|
+
if (me.has(e.name) && e.attributes.d != null) {
|
|
4341
|
+
let t = N(S, e);
|
|
4342
|
+
K = u, q = K === !1 ? .01 : +(.1 ** K).toFixed(K), G = K && K > 0 && K < 20 ? Hn : Un, i && (Pn = i.threshold, Fn = i.tolerance);
|
|
4343
|
+
let n = t[`marker-mid`] != null, r = t.stroke && (t.stroke.type === `dynamic` || t.stroke.value !== `none`), a = t[`stroke-linecap`] && (t[`stroke-linecap`].type === `dynamic` || t[`stroke-linecap`].value !== `butt`), o = !r || t[`stroke-linecap`]?.type === `static` && t[`stroke-linecap`].value === `round` && t[`stroke-linejoin`]?.type === `static` && t[`stroke-linejoin`].value === `round`, s = (e, t) => r ? e ? !a : t : !0, c = Xt(e);
|
|
4401
4344
|
if (c.length) {
|
|
4402
|
-
let t = c.some((
|
|
4403
|
-
|
|
4404
|
-
isSafeToUseZ:
|
|
4405
|
-
|
|
4345
|
+
let t = c.some((e) => e.command !== `m` && e.command !== `M`);
|
|
4346
|
+
Ln(c), c = Rn(c, b, {
|
|
4347
|
+
isSafeToUseZ: o,
|
|
4348
|
+
isSafeToRemove: s,
|
|
4406
4349
|
hasMarkerMid: n
|
|
4407
|
-
}), h && (c =
|
|
4350
|
+
}), h && (c = zn(c, b)), (e.attributes[`marker-start`] != null || e.attributes[`marker-end`] != null) && t && c.every((e) => e.command === `m` || e.command === `M`) && c.push({
|
|
4408
4351
|
command: `z`,
|
|
4409
4352
|
args: []
|
|
4410
|
-
}),
|
|
4353
|
+
}), Qt(e, c, b);
|
|
4411
4354
|
}
|
|
4412
4355
|
}
|
|
4413
4356
|
} } };
|
|
4414
|
-
},
|
|
4357
|
+
}, Ln = (e) => {
|
|
4415
4358
|
let t = [0, 0], n = [0, 0], r = [0, 0];
|
|
4416
4359
|
for (let i = 0; i < e.length; i += 1) {
|
|
4417
4360
|
let a = e[i], { command: o, args: s } = a;
|
|
@@ -4419,9 +4362,9 @@ var l = e(((e) => {
|
|
|
4419
4362
|
}
|
|
4420
4363
|
return e;
|
|
4421
4364
|
};
|
|
4422
|
-
function
|
|
4423
|
-
let a =
|
|
4424
|
-
return e = e.filter(
|
|
4365
|
+
function Rn(e, t, { isSafeToUseZ: n, isSafeToRemove: r, hasMarkerMid: i }) {
|
|
4366
|
+
let a = $n.bind(null, t), o = [0, 0], s = [0, 0], c = {}, l;
|
|
4367
|
+
return e = e.filter(function(e, u, d) {
|
|
4425
4368
|
let f = l, p = e.command, m = e.args, h = d[u + 1];
|
|
4426
4369
|
if (p !== `Z` && p !== `z`) {
|
|
4427
4370
|
let l = m, _;
|
|
@@ -4430,8 +4373,8 @@ var l = e(((e) => {
|
|
|
4430
4373
|
let e = c.args, t = e.length;
|
|
4431
4374
|
l[0] = e[t - 2] - e[t - 4], l[1] = e[t - 1] - e[t - 3];
|
|
4432
4375
|
}
|
|
4433
|
-
if (t.makeArcs && (p == `c` || p == `s`) &&
|
|
4434
|
-
let t =
|
|
4376
|
+
if (t.makeArcs && (p == `c` || p == `s`) && Bn(l) && (_ = Yn(l))) {
|
|
4377
|
+
let t = G([_.radius])[0], n = Qn(l, _), r = +(l[5] * l[0] - l[4] * l[1] > 0), i = {
|
|
4435
4378
|
command: `a`,
|
|
4436
4379
|
args: [
|
|
4437
4380
|
t,
|
|
@@ -4448,9 +4391,9 @@ var l = e(((e) => {
|
|
|
4448
4391
|
center: f,
|
|
4449
4392
|
radius: _.radius
|
|
4450
4393
|
}, y = [e], b = 0, x = ``, S;
|
|
4451
|
-
if (c.command == `c` &&
|
|
4394
|
+
if (c.command == `c` && Bn(c.args) && Zn(c.args, _) || c.command == `a` && c.sdata && Zn(c.sdata, _)) {
|
|
4452
4395
|
y.unshift(c), i.base = c.base, i.args[5] = i.coords[0] - i.base[0], i.args[6] = i.coords[1] - i.base[1];
|
|
4453
|
-
let e = c.command == `a` ? c.sdata : c.args, t =
|
|
4396
|
+
let e = c.command == `a` ? c.sdata : c.args, t = Qn(e, {
|
|
4454
4397
|
center: [e[4] + _.center[0], e[5] + _.center[1]],
|
|
4455
4398
|
radius: _.radius
|
|
4456
4399
|
});
|
|
@@ -4458,10 +4401,10 @@ var l = e(((e) => {
|
|
|
4458
4401
|
}
|
|
4459
4402
|
for (var g = u; (h = d[++g]) && (h.command === `c` || h.command === `s`);) {
|
|
4460
4403
|
let e = h.args;
|
|
4461
|
-
if (h.command == `s` && (S =
|
|
4404
|
+
if (h.command == `s` && (S = J({
|
|
4462
4405
|
command: `s`,
|
|
4463
4406
|
args: h.args.slice()
|
|
4464
|
-
}, d[g - 1].args), e = S.args, S.args = e.slice(0, 2), x = a([S])), !
|
|
4407
|
+
}, d[g - 1].args), e = S.args, S.args = e.slice(0, 2), x = a([S])), !Bn(e) || !Xn(e, v) || (n += Qn(e, v), n - 2 * Math.PI > .001)) break;
|
|
4465
4408
|
if (n > Math.PI && (i.args[3] = 1), y.push(h), !(2 * Math.PI - n > .001)) {
|
|
4466
4409
|
i.args[5] = 2 * (v.center[0] - e[4]), i.args[6] = 2 * (v.center[1] - e[5]), i.coords = [i.base[0] + i.args[5], i.base[1] + i.args[6]], i = {
|
|
4467
4410
|
command: `a`,
|
|
@@ -4482,75 +4425,75 @@ var l = e(((e) => {
|
|
|
4482
4425
|
i.coords = h.coords, i.args[5] = i.coords[0] - i.base[0], i.args[6] = i.coords[1] - i.base[1], f[0] -= e[4], f[1] -= e[5];
|
|
4483
4426
|
}
|
|
4484
4427
|
if ((a(s) + x).length < a(y).length) {
|
|
4485
|
-
if (d[g] && d[g].command == `s` &&
|
|
4428
|
+
if (d[g] && d[g].command == `s` && J(d[g], d[g - 1].args), b) {
|
|
4486
4429
|
let t = s.shift();
|
|
4487
|
-
|
|
4430
|
+
G(t.args), o[0] += t.args[5] - c.args[c.args.length - 2], o[1] += t.args[6] - c.args[c.args.length - 1], c.command = `a`, c.args = t.args, e.base = c.coords = t.coords;
|
|
4488
4431
|
}
|
|
4489
4432
|
if (i = s.shift(), y.length == 1 ? e.sdata = l.slice() : y.length - 1 - b > 0 && d.splice(u + 1, y.length - 1 - b, ...s), !i) return !1;
|
|
4490
4433
|
p = `a`, m = i.args, e.coords = i.coords;
|
|
4491
4434
|
}
|
|
4492
4435
|
}
|
|
4493
|
-
if (
|
|
4436
|
+
if (K !== !1) {
|
|
4494
4437
|
if (p === `m` || p === `l` || p === `t` || p === `q` || p === `s` || p === `c`) for (let t = m.length; t--;) m[t] += e.base[t % 2] - o[t % 2];
|
|
4495
4438
|
else p == `h` ? m[0] += e.base[0] - o[0] : p == `v` ? m[0] += e.base[1] - o[1] : p == `a` && (m[5] += e.base[0] - o[0], m[6] += e.base[1] - o[1]);
|
|
4496
|
-
|
|
4439
|
+
G(m), p == `h` ? o[0] += m[0] : p == `v` ? o[1] += m[0] : (o[0] += m[m.length - 2], o[1] += m[m.length - 1]), G(o), (p === `M` || p === `m`) && (s[0] = o[0], s[1] = o[1]);
|
|
4497
4440
|
}
|
|
4498
|
-
let v = p === `a` ?
|
|
4499
|
-
if (t.smartArcRounding && v !== void 0 &&
|
|
4500
|
-
let t =
|
|
4441
|
+
let v = p === `a` ? Gn(m) : void 0;
|
|
4442
|
+
if (t.smartArcRounding && v !== void 0 && K) for (let e = K; e >= 0; e--) {
|
|
4443
|
+
let t = I(m[0], e), n = Gn([
|
|
4501
4444
|
t,
|
|
4502
4445
|
t,
|
|
4503
4446
|
...m.slice(2)
|
|
4504
4447
|
]);
|
|
4505
|
-
if (!(Math.abs(v - n) <
|
|
4448
|
+
if (!(Math.abs(v - n) < q)) break;
|
|
4506
4449
|
m[0] = t, m[1] = t;
|
|
4507
4450
|
}
|
|
4508
|
-
if (t.straightCurves && (p === `c` &&
|
|
4451
|
+
if (t.straightCurves && (p === `c` && Wn(m) || p === `s` && Wn(l) ? (h && h.command == `s` && J(h, m), p = `l`, m = m.slice(-2)) : p === `q` && Wn(m) || p === `t` && c.command !== `q` && c.command !== `t` ? (p == `q` && h && h.command == `t` && J(h, m), p == `t` && h && h.command == `t` && (h.command = `q`, h.args.unshift(2 * e.coords[0] - e.base[0] - e.coords[0], 2 * e.coords[1] - e.base[1] - e.coords[1])), p = `l`, m = m.slice(-2)) : p === `a` && (m[0] === 0 || m[1] === 0 || v !== void 0 && v < q) && (p = `l`, m = m.slice(-2))), t.convertToQ && p == `c`) {
|
|
4509
4452
|
let n = .75 * (e.base[0] + m[0]) - .25 * e.base[0], r = .75 * (e.base[0] + m[2]) - .25 * (e.base[0] + m[4]);
|
|
4510
|
-
if (Math.abs(n - r) <
|
|
4453
|
+
if (Math.abs(n - r) < q * 2) {
|
|
4511
4454
|
let i = .75 * (e.base[1] + m[1]) - .25 * e.base[1], a = .75 * (e.base[1] + m[3]) - .25 * (e.base[1] + m[5]);
|
|
4512
|
-
if (Math.abs(i - a) <
|
|
4455
|
+
if (Math.abs(i - a) < q * 2) {
|
|
4513
4456
|
let o = m.slice();
|
|
4514
|
-
o.splice(0, 4, n + r - e.base[0], i + a - e.base[1]),
|
|
4515
|
-
let s =
|
|
4516
|
-
|
|
4457
|
+
o.splice(0, 4, n + r - e.base[0], i + a - e.base[1]), G(o);
|
|
4458
|
+
let s = P(m, t).length;
|
|
4459
|
+
P(o, t).length < s && (p = `q`, m = o, h && h.command == `s` && J(h, m));
|
|
4517
4460
|
}
|
|
4518
4461
|
}
|
|
4519
4462
|
}
|
|
4520
4463
|
if (t.lineShorthands && p === `l` && (m[1] === 0 ? (p = `h`, m.pop()) : m[0] === 0 && (p = `v`, m.shift())), t.collapseRepeated && i === !1 && (p === `m` || p === `h` || p === `v`) && c.command && p == c.command.toLowerCase() && (p != `h` && p != `v` || c.args[0] >= 0 == m[0] >= 0)) return c.args[0] += m[0], p != `h` && p != `v` && (c.args[1] += m[1]), c.coords = e.coords, d[u] = c, !1;
|
|
4521
4464
|
if (t.curveSmoothShorthands && c.command) {
|
|
4522
|
-
if (p === `c`) (c.command === `c` && Math.abs(m[0] - -(c.args[2] - c.args[4])) <
|
|
4465
|
+
if (p === `c`) (c.command === `c` && Math.abs(m[0] - -(c.args[2] - c.args[4])) < q && Math.abs(m[1] - -(c.args[3] - c.args[5])) < q || c.command === `s` && Math.abs(m[0] - -(c.args[0] - c.args[2])) < q && Math.abs(m[1] - -(c.args[1] - c.args[3])) < q || c.command !== `c` && c.command !== `s` && Math.abs(m[0]) < q && Math.abs(m[1]) < q) && (p = `s`, m = m.slice(2));
|
|
4523
4466
|
else if (p === `q`) {
|
|
4524
|
-
if (c.command === `q` && Math.abs(m[0] - (c.args[2] - c.args[0])) <
|
|
4467
|
+
if (c.command === `q` && Math.abs(m[0] - (c.args[2] - c.args[0])) < q && Math.abs(m[1] - (c.args[3] - c.args[1])) < q) p = `t`, m = m.slice(2);
|
|
4525
4468
|
else if (c.command === `t`) {
|
|
4526
|
-
let t =
|
|
4527
|
-
Math.abs(t[0] - n[0]) <
|
|
4469
|
+
let t = qn(f, e.base), n = [m[0] + e.base[0], m[1] + e.base[1]];
|
|
4470
|
+
Math.abs(t[0] - n[0]) < q && Math.abs(t[1] - n[1]) < q && (p = `t`, m = m.slice(2));
|
|
4528
4471
|
}
|
|
4529
4472
|
}
|
|
4530
4473
|
}
|
|
4531
|
-
if (t.removeUseless &&
|
|
4474
|
+
if (t.removeUseless && r(c.command == `m` || c.command == `M`, !0) && ((p === `l` || p === `h` || p === `v` || p === `q` || p === `t` || p === `c` || p === `s`) && m.every(function(e) {
|
|
4532
4475
|
return e === 0;
|
|
4533
|
-
})
|
|
4534
|
-
t.convertToZ && (n || h?.command === `Z` || h?.command === `z`) && (p === `l` || p === `h` || p === `v`) && Math.abs(s[0] - e.coords[0]) <
|
|
4476
|
+
}) || p === `a` && m[5] === 0 && m[6] === 0)) return d[u] = c, !1;
|
|
4477
|
+
t.convertToZ && (n || h?.command === `Z` || h?.command === `z`) && (p === `l` || p === `h` || p === `v`) && Math.abs(s[0] - e.coords[0]) < q && Math.abs(s[1] - e.coords[1]) < q && (p = `z`, m = []), e.command = p, e.args = m;
|
|
4535
4478
|
} else if (o[0] = s[0], o[1] = s[1], c.command === `Z` || c.command === `z`) return !1;
|
|
4536
|
-
return (p === `Z` || p === `z`) && t.removeUseless && n && Math.abs(e.base[0] - e.coords[0]) <
|
|
4537
|
-
})
|
|
4479
|
+
return (p === `Z` || p === `z`) && t.removeUseless && r(c.command == `m` || c.command == `M`, n) && Math.abs(e.base[0] - e.coords[0]) < q / 10 && Math.abs(e.base[1] - e.coords[1]) < q / 10 ? !1 : (l = p === `q` ? [m[0] + e.base[0], m[1] + e.base[1]] : p === `t` ? f ? qn(f, e.base) : e.coords : void 0, c = e, !0);
|
|
4480
|
+
}), e;
|
|
4538
4481
|
}
|
|
4539
|
-
function
|
|
4482
|
+
function zn(e, t) {
|
|
4540
4483
|
let n = e[0];
|
|
4541
|
-
return e = e.filter(
|
|
4484
|
+
return e = e.filter(function(e, r) {
|
|
4542
4485
|
if (r == 0) return !0;
|
|
4543
4486
|
if (e.command === `Z` || e.command === `z`) return n = e, !0;
|
|
4544
4487
|
let i = e.command, a = e.args, o = a.slice(), s = a.slice();
|
|
4545
4488
|
if (i === `m` || i === `l` || i === `t` || i === `q` || i === `s` || i === `c`) for (let t = o.length; t--;) o[t] += e.base[t % 2];
|
|
4546
4489
|
else i == `h` ? o[0] += e.base[0] : i == `v` ? o[0] += e.base[1] : i == `a` && (o[5] += e.base[0], o[6] += e.base[1]);
|
|
4547
|
-
|
|
4548
|
-
let c =
|
|
4490
|
+
G(o), G(s);
|
|
4491
|
+
let c = P(o, t), l = P(s, t);
|
|
4549
4492
|
return (t.forceAbsolutePath || c.length < l.length && !(t.negativeExtraSpace && i == n.command && n.command.charCodeAt(0) > 96 && c.length == l.length - 1 && (a[0] < 0 || Math.floor(a[0]) === 0 && !Number.isInteger(a[0]) && n.args[n.args.length - 1] % 1))) && (e.command = i.toUpperCase(), e.args = o), n = e, !0;
|
|
4550
|
-
})
|
|
4493
|
+
}), e;
|
|
4551
4494
|
}
|
|
4552
|
-
function
|
|
4553
|
-
let t =
|
|
4495
|
+
function Bn(e) {
|
|
4496
|
+
let t = Vn([
|
|
4554
4497
|
0,
|
|
4555
4498
|
0,
|
|
4556
4499
|
e[2],
|
|
@@ -4562,63 +4505,61 @@ var l = e(((e) => {
|
|
|
4562
4505
|
]);
|
|
4563
4506
|
return t != null && e[2] < t[0] == t[0] < 0 && e[3] < t[1] == t[1] < 0 && e[4] < t[0] == t[0] < e[0] && e[5] < t[1] == t[1] < e[1];
|
|
4564
4507
|
}
|
|
4565
|
-
function
|
|
4508
|
+
function Vn(e) {
|
|
4566
4509
|
let t = e[1] - e[3], n = e[2] - e[0], r = e[0] * e[3] - e[2] * e[1], i = e[5] - e[7], a = e[6] - e[4], o = e[4] * e[7] - e[5] * e[6], s = t * a - i * n;
|
|
4567
4510
|
if (!s) return;
|
|
4568
4511
|
let c = [(n * o - a * r) / s, (t * o - i * r) / -s];
|
|
4569
4512
|
if (!isNaN(c[0]) && !isNaN(c[1]) && isFinite(c[0]) && isFinite(c[1])) return c;
|
|
4570
4513
|
}
|
|
4571
|
-
function
|
|
4572
|
-
let t =
|
|
4514
|
+
function Hn(e) {
|
|
4515
|
+
let t = K || 0;
|
|
4573
4516
|
for (let n = e.length; n-- > 0;) {
|
|
4574
|
-
let r =
|
|
4517
|
+
let r = I(e[n], t);
|
|
4575
4518
|
if (r !== e[n]) {
|
|
4576
|
-
let i =
|
|
4577
|
-
e[n] =
|
|
4519
|
+
let i = I(e[n], t - 1);
|
|
4520
|
+
e[n] = I(Math.abs(i - e[n]), t + 1) >= q ? r : i;
|
|
4578
4521
|
}
|
|
4579
4522
|
}
|
|
4580
4523
|
return e;
|
|
4581
4524
|
}
|
|
4582
|
-
function
|
|
4525
|
+
function Un(e) {
|
|
4583
4526
|
for (let t = e.length; t-- > 0;) e[t] = Math.round(e[t]);
|
|
4584
4527
|
return e;
|
|
4585
4528
|
}
|
|
4586
|
-
function
|
|
4529
|
+
function Wn(e) {
|
|
4587
4530
|
let t = e.length - 2, n = -e[t + 1], r = e[t], i = 1 / (n * n + r * r);
|
|
4588
4531
|
if (t <= 1 || !isFinite(i)) return !1;
|
|
4589
|
-
for (; (t -= 2) >= 0;) if (Math.sqrt((n * e[t] + r * e[t + 1]) ** 2 * i) >
|
|
4532
|
+
for (; (t -= 2) >= 0;) if (Math.sqrt((n * e[t] + r * e[t + 1]) ** 2 * i) > q) return !1;
|
|
4590
4533
|
return !0;
|
|
4591
4534
|
}
|
|
4592
|
-
function
|
|
4535
|
+
function Gn(e) {
|
|
4593
4536
|
if (e[3] === 1) return;
|
|
4594
4537
|
let [t, n] = e;
|
|
4595
|
-
if (Math.abs(t - n) >
|
|
4538
|
+
if (Math.abs(t - n) > q) return;
|
|
4596
4539
|
let r = Math.hypot(e[5], e[6]);
|
|
4597
4540
|
if (!(r > t * 2)) return t - Math.sqrt(t ** 2 - .25 * r ** 2);
|
|
4598
4541
|
}
|
|
4599
|
-
function
|
|
4542
|
+
function J(e, t) {
|
|
4600
4543
|
switch (e.command) {
|
|
4601
4544
|
case `s`:
|
|
4602
4545
|
e.command = `c`;
|
|
4603
4546
|
break;
|
|
4604
|
-
case `t`:
|
|
4605
|
-
e.command = `q`;
|
|
4606
|
-
break;
|
|
4547
|
+
case `t`: e.command = `q`;
|
|
4607
4548
|
}
|
|
4608
4549
|
return e.args.unshift(t[t.length - 2] - t[t.length - 4], t[t.length - 1] - t[t.length - 3]), e;
|
|
4609
4550
|
}
|
|
4610
|
-
function
|
|
4551
|
+
function Kn(e, t) {
|
|
4611
4552
|
return Math.hypot(e[0] - t[0], e[1] - t[1]);
|
|
4612
4553
|
}
|
|
4613
|
-
function
|
|
4554
|
+
function qn(e, t) {
|
|
4614
4555
|
return [2 * t[0] - e[0], 2 * t[1] - e[1]];
|
|
4615
4556
|
}
|
|
4616
|
-
function
|
|
4557
|
+
function Jn(e, t) {
|
|
4617
4558
|
let n = t * t, r = n * t, i = 1 - t, a = i * i;
|
|
4618
4559
|
return [3 * a * t * e[0] + 3 * i * n * e[2] + r * e[4], 3 * a * t * e[1] + 3 * i * n * e[3] + r * e[5]];
|
|
4619
4560
|
}
|
|
4620
|
-
function
|
|
4621
|
-
let t =
|
|
4561
|
+
function Yn(e) {
|
|
4562
|
+
let t = Jn(e, .5), n = [t[0] / 2, t[1] / 2], r = [(t[0] + e[4]) / 2, (t[1] + e[5]) / 2], i = Vn([
|
|
4622
4563
|
n[0],
|
|
4623
4564
|
n[1],
|
|
4624
4565
|
n[0] + n[1],
|
|
@@ -4627,49 +4568,49 @@ var l = e(((e) => {
|
|
|
4627
4568
|
r[1],
|
|
4628
4569
|
r[0] + (r[1] - t[1]),
|
|
4629
4570
|
r[1] - (r[0] - t[0])
|
|
4630
|
-
]), a = i &&
|
|
4631
|
-
if (i && a < 0x38d7ea4c68000 && [1 / 4, 3 / 4].every(
|
|
4632
|
-
return Math.abs(
|
|
4633
|
-
}))
|
|
4571
|
+
]), a = i && Kn([0, 0], i), o = Math.min(Pn * q, Fn * a / 100);
|
|
4572
|
+
if (i && a < 0x38d7ea4c68000 && [1 / 4, 3 / 4].every(function(t) {
|
|
4573
|
+
return Math.abs(Kn(Jn(e, t), i) - a) <= o;
|
|
4574
|
+
})) return {
|
|
4634
4575
|
center: i,
|
|
4635
4576
|
radius: a
|
|
4636
4577
|
};
|
|
4637
4578
|
}
|
|
4638
|
-
function
|
|
4639
|
-
let n = Math.min(
|
|
4579
|
+
function Xn(e, t) {
|
|
4580
|
+
let n = Math.min(Pn * q, Fn * t.radius / 100);
|
|
4640
4581
|
return [
|
|
4641
4582
|
0,
|
|
4642
4583
|
1 / 4,
|
|
4643
4584
|
.5,
|
|
4644
4585
|
3 / 4,
|
|
4645
4586
|
1
|
|
4646
|
-
].every(
|
|
4647
|
-
return Math.abs(
|
|
4648
|
-
})
|
|
4587
|
+
].every(function(r) {
|
|
4588
|
+
return Math.abs(Kn(Jn(e, r), t.center) - t.radius) <= n;
|
|
4589
|
+
});
|
|
4649
4590
|
}
|
|
4650
|
-
function
|
|
4651
|
-
return
|
|
4591
|
+
function Zn(e, t) {
|
|
4592
|
+
return Xn(e, {
|
|
4652
4593
|
center: [t.center[0] + e[4], t.center[1] + e[5]],
|
|
4653
4594
|
radius: t.radius
|
|
4654
4595
|
});
|
|
4655
4596
|
}
|
|
4656
|
-
function
|
|
4597
|
+
function Qn(e, t) {
|
|
4657
4598
|
let n = -t.center[0], r = -t.center[1], i = e[4] - t.center[0], a = e[5] - t.center[1];
|
|
4658
4599
|
return Math.acos((n * i + r * a) / Math.sqrt((n * n + r * r) * (i * i + a * a)));
|
|
4659
4600
|
}
|
|
4660
|
-
function
|
|
4661
|
-
return t.reduce(
|
|
4601
|
+
function $n(e, t) {
|
|
4602
|
+
return t.reduce(function(t, n) {
|
|
4662
4603
|
let r = ``;
|
|
4663
|
-
return n.args && (r =
|
|
4664
|
-
}
|
|
4604
|
+
return n.args && (r = P(G(n.args.slice()), e)), t + n.command + r;
|
|
4605
|
+
}, ``);
|
|
4665
4606
|
}
|
|
4666
|
-
var
|
|
4607
|
+
var er = Object.freeze({
|
|
4667
4608
|
__proto__: null,
|
|
4668
4609
|
description: `optimizes path data: writes in shorter form, applies transformations`,
|
|
4669
|
-
fn:
|
|
4610
|
+
fn: In,
|
|
4670
4611
|
name: `convertPathData`
|
|
4671
4612
|
});
|
|
4672
|
-
let
|
|
4613
|
+
let tr = (e, t) => {
|
|
4673
4614
|
let { convertToShorts: n = !0, degPrecision: r, floatPrecision: i = 3, transformPrecision: a = 5, matrixToTransform: o = !0, shortTranslate: s = !0, shortScale: c = !0, shortRotate: l = !0, removeUseless: u = !0, collapseIntoOne: d = !0, leadingZero: f = !0, negativeExtraSpace: p = !1 } = t, m = {
|
|
4674
4615
|
convertToShorts: n,
|
|
4675
4616
|
degPrecision: r,
|
|
@@ -4685,27 +4626,27 @@ var l = e(((e) => {
|
|
|
4685
4626
|
negativeExtraSpace: p
|
|
4686
4627
|
};
|
|
4687
4628
|
return { element: { enter: (e) => {
|
|
4688
|
-
e.attributes.transform != null &&
|
|
4629
|
+
e.attributes.transform != null && nr(e, `transform`, m), e.attributes.gradientTransform != null && nr(e, `gradientTransform`, m), e.attributes.patternTransform != null && nr(e, `patternTransform`, m);
|
|
4689
4630
|
} } };
|
|
4690
|
-
},
|
|
4691
|
-
let r =
|
|
4692
|
-
n =
|
|
4693
|
-
},
|
|
4631
|
+
}, nr = (e, t, n) => {
|
|
4632
|
+
let r = dn(e.attributes[t]);
|
|
4633
|
+
n = rr(r, n), n.collapseIntoOne && r.length > 1 && (r = [fn(r)]), n.convertToShorts ? r = ar(r, n) : r.forEach((e) => wn(e, n)), n.removeUseless && (r = or(r)), r.length ? e.attributes[t] = An(r, n) : delete e.attributes[t];
|
|
4634
|
+
}, rr = (e, { ...t }) => {
|
|
4694
4635
|
let n = [];
|
|
4695
4636
|
for (let t of e) t.name == `matrix` && n.push(...t.data.slice(0, 4));
|
|
4696
4637
|
let r = t.transformPrecision;
|
|
4697
|
-
return n.length && (t.transformPrecision = Math.min(t.transformPrecision, Math.max.apply(Math, n.map(
|
|
4698
|
-
},
|
|
4638
|
+
return n.length && (t.transformPrecision = Math.min(t.transformPrecision, Math.max.apply(Math, n.map(ir)) || t.transformPrecision), r = Math.max.apply(Math, n.map((e) => e.toString().replace(/\D+/g, ``).length))), t.degPrecision ??= Math.max(0, Math.min(t.floatPrecision, r - 2)), t;
|
|
4639
|
+
}, ir = (e) => {
|
|
4699
4640
|
let t = e.toString();
|
|
4700
4641
|
return t.slice(t.indexOf(`.`)).length - 1;
|
|
4701
|
-
},
|
|
4642
|
+
}, ar = (e, t) => {
|
|
4702
4643
|
for (let n = 0; n < e.length; n++) {
|
|
4703
4644
|
let r = e[n];
|
|
4704
4645
|
if (t.matrixToTransform && r.name === `matrix`) {
|
|
4705
|
-
let i =
|
|
4706
|
-
|
|
4646
|
+
let i = bn(r, t);
|
|
4647
|
+
An(i, t).length <= An([r], t).length && e.splice(n, 1, ...i), r = e[n];
|
|
4707
4648
|
}
|
|
4708
|
-
|
|
4649
|
+
wn(r, t), t.shortTranslate && r.name === `translate` && r.data.length === 2 && !r.data[1] && r.data.pop(), t.shortScale && r.name === `scale` && r.data.length === 2 && r.data[0] === r.data[1] && r.data.pop(), t.shortRotate && e[n - 2]?.name === `translate` && e[n - 1].name === `rotate` && e[n].name === `translate` && e[n - 2].data[0] === -e[n].data[0] && e[n - 2].data[1] === -e[n].data[1] && (e.splice(n - 2, 3, {
|
|
4709
4650
|
name: `rotate`,
|
|
4710
4651
|
data: [
|
|
4711
4652
|
e[n - 1].data[0],
|
|
@@ -4715,34 +4656,34 @@ var l = e(((e) => {
|
|
|
4715
4656
|
}), n -= 2);
|
|
4716
4657
|
}
|
|
4717
4658
|
return e;
|
|
4718
|
-
},
|
|
4659
|
+
}, or = (e) => e.filter((e) => !([
|
|
4719
4660
|
`translate`,
|
|
4720
4661
|
`rotate`,
|
|
4721
4662
|
`skewX`,
|
|
4722
4663
|
`skewY`
|
|
4723
|
-
].indexOf(e.name) > -1 && (e.data.length == 1 || e.name == `rotate`) && !e.data[0] || e.name == `translate` && !e.data[0] && !e.data[1] || e.name == `scale` && e.data[0] == 1 && (e.data.length < 2 || e.data[1] == 1) || e.name == `matrix` && e.data[0] == 1 && e.data[3] == 1 && !(e.data[1] || e.data[2] || e.data[4] || e.data[5])))
|
|
4724
|
-
var
|
|
4664
|
+
].indexOf(e.name) > -1 && (e.data.length == 1 || e.name == `rotate`) && !e.data[0] || e.name == `translate` && !e.data[0] && !e.data[1] || e.name == `scale` && e.data[0] == 1 && (e.data.length < 2 || e.data[1] == 1) || e.name == `matrix` && e.data[0] == 1 && e.data[3] == 1 && !(e.data[1] || e.data[2] || e.data[4] || e.data[5])));
|
|
4665
|
+
var sr = Object.freeze({
|
|
4725
4666
|
__proto__: null,
|
|
4726
4667
|
description: `collapses multiple transformations and optimizes it`,
|
|
4727
|
-
fn:
|
|
4668
|
+
fn: tr,
|
|
4728
4669
|
name: `convertTransform`
|
|
4729
|
-
}),
|
|
4670
|
+
}), cr = Object.freeze({
|
|
4730
4671
|
__proto__: null,
|
|
4731
4672
|
description: `removes empty attributes`,
|
|
4732
4673
|
fn: () => ({ element: { enter: (e) => {
|
|
4733
|
-
for (let [t, n] of Object.entries(e.attributes)) n !== `` ||
|
|
4674
|
+
for (let [t, n] of Object.entries(e.attributes)) n !== `` || k.conditionalProcessing.has(t) || delete e.attributes[t];
|
|
4734
4675
|
} } }),
|
|
4735
4676
|
name: `removeEmptyAttrs`
|
|
4736
|
-
}),
|
|
4677
|
+
}), lr = Object.freeze({
|
|
4737
4678
|
__proto__: null,
|
|
4738
4679
|
description: `removes empty container elements`,
|
|
4739
4680
|
fn: (e) => {
|
|
4740
|
-
let t =
|
|
4681
|
+
let t = M(e), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
|
|
4741
4682
|
return {
|
|
4742
4683
|
element: {
|
|
4743
4684
|
enter: (e, t) => {
|
|
4744
4685
|
if (e.name === `use`) for (let [n, i] of Object.entries(e.attributes)) {
|
|
4745
|
-
let a =
|
|
4686
|
+
let a = tt(n, i);
|
|
4746
4687
|
for (let n of a) {
|
|
4747
4688
|
let i = r.get(n);
|
|
4748
4689
|
i === void 0 && (i = [], r.set(n, i)), i.push({
|
|
@@ -4753,32 +4694,32 @@ var l = e(((e) => {
|
|
|
4753
4694
|
}
|
|
4754
4695
|
},
|
|
4755
4696
|
exit: (e, r) => {
|
|
4756
|
-
e.name
|
|
4697
|
+
e.name !== `svg` && O.container.has(e.name) && e.children.length === 0 && (e.name !== `pattern` || Object.keys(e.attributes).length === 0) && (e.name !== `mask` || e.attributes.id == null) && (r.type !== `element` || r.name !== `switch`) && (e.name !== `g` || e.attributes.filter == null && !N(t, e).filter) && (D(e, r), e.attributes.id && n.add(e.attributes.id));
|
|
4757
4698
|
}
|
|
4758
4699
|
},
|
|
4759
4700
|
root: { exit: () => {
|
|
4760
4701
|
for (let e of n) {
|
|
4761
4702
|
let t = r.get(e);
|
|
4762
|
-
if (t) for (let e of t)
|
|
4703
|
+
if (t) for (let e of t) D(e.node, e.parent);
|
|
4763
4704
|
}
|
|
4764
4705
|
} }
|
|
4765
4706
|
};
|
|
4766
4707
|
},
|
|
4767
4708
|
name: `removeEmptyContainers`
|
|
4768
4709
|
});
|
|
4769
|
-
function
|
|
4710
|
+
function ur(e, t) {
|
|
4770
4711
|
let n = e[t];
|
|
4771
|
-
return n?.type === `static`
|
|
4712
|
+
return n?.type === `static` && $e(n.value);
|
|
4772
4713
|
}
|
|
4773
|
-
var
|
|
4714
|
+
var dr = Object.freeze({
|
|
4774
4715
|
__proto__: null,
|
|
4775
4716
|
description: `merges multiple paths in one if possible`,
|
|
4776
4717
|
fn: (e, t) => {
|
|
4777
|
-
let { force: n = !1, floatPrecision: r = 3, noSpaceAfterFlags: i = !1 } = t, a =
|
|
4718
|
+
let { force: n = !1, floatPrecision: r = 3, noSpaceAfterFlags: i = !1 } = t, a = M(e);
|
|
4778
4719
|
return { element: { enter: (e) => {
|
|
4779
4720
|
if (e.children.length <= 1) return;
|
|
4780
|
-
let t =
|
|
4781
|
-
|
|
4721
|
+
let t = /* @__PURE__ */ new Set(), o = e.children[0], s = null, c = (e, t) => {
|
|
4722
|
+
Qt(e, t, {
|
|
4782
4723
|
floatPrecision: r,
|
|
4783
4724
|
noSpaceAfterFlags: i
|
|
4784
4725
|
}), s = null;
|
|
@@ -4793,36 +4734,28 @@ var l = e(((e) => {
|
|
|
4793
4734
|
s && c(o, s), o = i;
|
|
4794
4735
|
continue;
|
|
4795
4736
|
}
|
|
4796
|
-
let l =
|
|
4737
|
+
let l = N(a, i);
|
|
4797
4738
|
if (l[`marker-start`] || l[`marker-mid`] || l[`marker-end`] || l[`clip-path`] || l.mask || l[`mask-image`] || [
|
|
4798
4739
|
`fill`,
|
|
4799
4740
|
`filter`,
|
|
4800
4741
|
`stroke`
|
|
4801
|
-
].some((
|
|
4742
|
+
].some((e) => ur(l, e))) {
|
|
4802
4743
|
s && c(o, s), o = i;
|
|
4803
4744
|
continue;
|
|
4804
4745
|
}
|
|
4805
4746
|
let u = Object.keys(i.attributes);
|
|
4806
|
-
if (u.length !== Object.keys(o.attributes).length) {
|
|
4747
|
+
if (u.length !== Object.keys(o.attributes).length || u.some((e) => e !== `d` && o.type === `element` && o.attributes[e] !== i.attributes[e])) {
|
|
4807
4748
|
s && c(o, s), o = i;
|
|
4808
4749
|
continue;
|
|
4809
4750
|
}
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
continue;
|
|
4813
|
-
}
|
|
4814
|
-
let d = s != null, f = qt(i);
|
|
4815
|
-
if (s ??= qt(o), n || !Xt(s, f)) {
|
|
4816
|
-
s.push(...f), t.push(i);
|
|
4817
|
-
continue;
|
|
4818
|
-
}
|
|
4819
|
-
d && c(o, s), o = i, s = null;
|
|
4751
|
+
let d = s != null, f = Xt(i);
|
|
4752
|
+
s ??= Xt(o), n || !$t(s, f) ? (s.push(...f), t.add(i)) : (d && c(o, s), o = i, s = null);
|
|
4820
4753
|
}
|
|
4821
|
-
s && o.type === `element` && c(o, s), e.children = e.children.filter((
|
|
4754
|
+
s && o.type === `element` && c(o, s), e.children = e.children.filter((e) => !t.has(e));
|
|
4822
4755
|
} } };
|
|
4823
4756
|
},
|
|
4824
4757
|
name: `mergePaths`
|
|
4825
|
-
}),
|
|
4758
|
+
}), fr = Object.freeze({
|
|
4826
4759
|
__proto__: null,
|
|
4827
4760
|
description: `removes unused namespaces declaration`,
|
|
4828
4761
|
fn: () => {
|
|
@@ -4852,7 +4785,7 @@ var l = e(((e) => {
|
|
|
4852
4785
|
} };
|
|
4853
4786
|
},
|
|
4854
4787
|
name: `removeUnusedNS`
|
|
4855
|
-
}),
|
|
4788
|
+
}), pr = Object.freeze({
|
|
4856
4789
|
__proto__: null,
|
|
4857
4790
|
description: `Sort element attributes for better compression`,
|
|
4858
4791
|
fn: (e, t) => {
|
|
@@ -4901,7 +4834,7 @@ var l = e(((e) => {
|
|
|
4901
4834
|
} } };
|
|
4902
4835
|
},
|
|
4903
4836
|
name: `sortAttrs`
|
|
4904
|
-
}),
|
|
4837
|
+
}), mr = Object.freeze({
|
|
4905
4838
|
__proto__: null,
|
|
4906
4839
|
description: `Sorts children of <defs> to improve compression`,
|
|
4907
4840
|
fn: () => ({ element: { enter: (e) => {
|
|
@@ -4911,7 +4844,7 @@ var l = e(((e) => {
|
|
|
4911
4844
|
let e = t.get(n.name);
|
|
4912
4845
|
e == null ? t.set(n.name, 1) : t.set(n.name, e + 1);
|
|
4913
4846
|
}
|
|
4914
|
-
e.children.sort((
|
|
4847
|
+
e.children.sort((e, n) => {
|
|
4915
4848
|
if (e.type !== `element` || n.type !== `element`) return 0;
|
|
4916
4849
|
let r = t.get(e.name), i = t.get(n.name);
|
|
4917
4850
|
if (r != null && i != null) {
|
|
@@ -4920,63 +4853,63 @@ var l = e(((e) => {
|
|
|
4920
4853
|
}
|
|
4921
4854
|
let a = n.name.length - e.name.length;
|
|
4922
4855
|
return a === 0 ? e.name === n.name ? 0 : e.name > n.name ? -1 : 1 : a;
|
|
4923
|
-
})
|
|
4856
|
+
});
|
|
4924
4857
|
}
|
|
4925
4858
|
} } }),
|
|
4926
4859
|
name: `sortDefsChildren`
|
|
4927
4860
|
});
|
|
4928
|
-
let
|
|
4929
|
-
var
|
|
4861
|
+
let hr = /^(Created with|Created using)/;
|
|
4862
|
+
var gr = Object.freeze({
|
|
4930
4863
|
__proto__: null,
|
|
4931
4864
|
description: `removes <desc>`,
|
|
4932
4865
|
fn: (e, t) => {
|
|
4933
4866
|
let { removeAny: n = !1 } = t;
|
|
4934
4867
|
return { element: { enter: (e, t) => {
|
|
4935
|
-
e.name === `desc` && (n || e.children.length === 0 || e.children[0].type === `text` &&
|
|
4868
|
+
e.name === `desc` && (n || e.children.length === 0 || e.children[0].type === `text` && hr.test(e.children[0].value)) && D(e, t);
|
|
4936
4869
|
} } };
|
|
4937
4870
|
},
|
|
4938
4871
|
name: `removeDesc`
|
|
4939
4872
|
});
|
|
4940
|
-
let
|
|
4873
|
+
let _r = ee({
|
|
4941
4874
|
name: `preset-default`,
|
|
4942
4875
|
plugins: [
|
|
4943
|
-
|
|
4876
|
+
le,
|
|
4877
|
+
ue,
|
|
4944
4878
|
fe,
|
|
4945
|
-
|
|
4879
|
+
Fe,
|
|
4880
|
+
Ie,
|
|
4946
4881
|
Le,
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
Ue,
|
|
4882
|
+
Ve,
|
|
4883
|
+
He,
|
|
4950
4884
|
We,
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
Dt,
|
|
4961
|
-
Lt,
|
|
4962
|
-
Rt,
|
|
4885
|
+
nt,
|
|
4886
|
+
ct,
|
|
4887
|
+
dt,
|
|
4888
|
+
mt,
|
|
4889
|
+
bt,
|
|
4890
|
+
wt,
|
|
4891
|
+
Tt,
|
|
4892
|
+
Et,
|
|
4893
|
+
At,
|
|
4963
4894
|
Bt,
|
|
4964
4895
|
Vt,
|
|
4965
|
-
|
|
4896
|
+
Ut,
|
|
4966
4897
|
Wt,
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4898
|
+
Gt,
|
|
4899
|
+
qt,
|
|
4900
|
+
Yt,
|
|
4901
|
+
er,
|
|
4902
|
+
sr,
|
|
4972
4903
|
cr,
|
|
4973
4904
|
lr,
|
|
4974
|
-
ur,
|
|
4975
4905
|
dr,
|
|
4976
|
-
|
|
4906
|
+
fr,
|
|
4907
|
+
pr,
|
|
4908
|
+
mr,
|
|
4909
|
+
gr
|
|
4977
4910
|
]
|
|
4978
4911
|
});
|
|
4979
|
-
var
|
|
4912
|
+
var vr = Object.freeze({
|
|
4980
4913
|
__proto__: null,
|
|
4981
4914
|
description: `adds attributes to an outer <svg> element`,
|
|
4982
4915
|
fn: (e, t) => {
|
|
@@ -5026,7 +4959,7 @@ plugins: [
|
|
|
5026
4959
|
} } };
|
|
5027
4960
|
},
|
|
5028
4961
|
name: `addAttributesToSVGElement`
|
|
5029
|
-
}),
|
|
4962
|
+
}), yr = Object.freeze({
|
|
5030
4963
|
__proto__: null,
|
|
5031
4964
|
description: `adds classnames to an outer <svg> element`,
|
|
5032
4965
|
fn: (e, t, n) => {
|
|
@@ -5066,7 +4999,7 @@ plugins: [
|
|
|
5066
4999
|
},
|
|
5067
5000
|
name: `addClassesToSVGElement`
|
|
5068
5001
|
});
|
|
5069
|
-
let
|
|
5002
|
+
let br = /^([-+]?\d*\.?\d+([eE][-+]?\d+)?)(px|pt|pc|mm|cm|m|in|ft|em|ex|%)?$/, xr = /\s+,?\s*|,\s*/, Sr = {
|
|
5070
5003
|
cm: 96 / 2.54,
|
|
5071
5004
|
mm: 96 / 25.4,
|
|
5072
5005
|
in: 96,
|
|
@@ -5074,22 +5007,22 @@ plugins: [
|
|
|
5074
5007
|
pc: 16,
|
|
5075
5008
|
px: 1
|
|
5076
5009
|
};
|
|
5077
|
-
var
|
|
5010
|
+
var Cr = Object.freeze({
|
|
5078
5011
|
__proto__: null,
|
|
5079
5012
|
description: `rounds list of values to the fixed precision`,
|
|
5080
5013
|
fn: (e, t) => {
|
|
5081
5014
|
let { floatPrecision: n = 3, leadingZero: r = !0, defaultPx: i = !0, convertToPx: a = !0 } = t, o = (e) => {
|
|
5082
5015
|
let t = [];
|
|
5083
|
-
for (let o of e.split(
|
|
5084
|
-
let e = o.match(
|
|
5016
|
+
for (let o of e.split(xr)) {
|
|
5017
|
+
let e = o.match(br), s = o.match(/new/);
|
|
5085
5018
|
if (e) {
|
|
5086
5019
|
let o = Number(Number(e[1]).toFixed(n)), s = e[3] || ``;
|
|
5087
|
-
if (a && s && s in
|
|
5088
|
-
let t = Number((
|
|
5020
|
+
if (a && s && s in Sr) {
|
|
5021
|
+
let t = Number((Sr[s] * Number(e[1])).toFixed(n));
|
|
5089
5022
|
t.toString().length < e[0].length && (o = t, s = `px`);
|
|
5090
5023
|
}
|
|
5091
5024
|
let c;
|
|
5092
|
-
c = r ?
|
|
5025
|
+
c = r ? F(o) : o.toString(), i && s === `px` && (s = ``), t.push(c + s);
|
|
5093
5026
|
} else s ? t.push(`new`) : o && t.push(o);
|
|
5094
5027
|
}
|
|
5095
5028
|
return t.join(` `);
|
|
@@ -5099,11 +5032,11 @@ plugins: [
|
|
|
5099
5032
|
} } };
|
|
5100
5033
|
},
|
|
5101
5034
|
name: `cleanupListOfValues`
|
|
5102
|
-
}),
|
|
5035
|
+
}), wr = Object.freeze({
|
|
5103
5036
|
__proto__: null,
|
|
5104
5037
|
description: `converts one-stop (single color) gradients to a plain color`,
|
|
5105
5038
|
fn: (e) => {
|
|
5106
|
-
let t =
|
|
5039
|
+
let t = M(e), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0;
|
|
5107
5040
|
return { element: {
|
|
5108
5041
|
enter: (o, s) => {
|
|
5109
5042
|
if (o.attributes[`xlink:href`] != null && a++, o.name === `defs`) {
|
|
@@ -5111,67 +5044,67 @@ plugins: [
|
|
|
5111
5044
|
return;
|
|
5112
5045
|
}
|
|
5113
5046
|
if (o.name !== `linearGradient` && o.name !== `radialGradient`) return;
|
|
5114
|
-
let c = o.children.filter((
|
|
5047
|
+
let c = o.children.filter((e) => e.type === `element` && e.name === `stop`), l = o.attributes[`xlink:href`] || o.attributes.href, u = c.length === 0 && l != null && l.startsWith(`#`) ? se(e, l) : o;
|
|
5115
5048
|
if (u == null || u.type !== `element`) {
|
|
5116
5049
|
i.set(o, s);
|
|
5117
5050
|
return;
|
|
5118
5051
|
}
|
|
5119
|
-
let d = u.children.filter((
|
|
5052
|
+
let d = u.children.filter((e) => e.type === `element` && e.name === `stop`);
|
|
5120
5053
|
if (d.length !== 1 || d[0].type !== `element`) return;
|
|
5121
5054
|
s.type === `element` && s.name === `defs` && n.add(s), i.set(o, s);
|
|
5122
|
-
let f, p =
|
|
5055
|
+
let f, p = N(t, d[0])[`stop-color`];
|
|
5123
5056
|
p != null && p.type === `static` && (f = p.value);
|
|
5124
|
-
let m = `url(#${o.attributes.id})`, h =
|
|
5125
|
-
for (let e of
|
|
5126
|
-
let
|
|
5127
|
-
for (let e of
|
|
5057
|
+
let m = `url(#${o.attributes.id})`, h = [...Se].map((e) => `[${e}="${m}"]`).join(`,`), g = E(e, h);
|
|
5058
|
+
for (let e of g) if (e.type === `element`) for (let t of Se) e.attributes[t] === m && (f == null ? delete e.attributes[t] : e.attributes[t] = f);
|
|
5059
|
+
let _ = E(e, `[style*=${m}]`);
|
|
5060
|
+
for (let e of _) e.type === `element` && (e.attributes.style = e.attributes.style.replace(m, f || he.presentation[`stop-color`]));
|
|
5128
5061
|
},
|
|
5129
5062
|
exit: (e) => {
|
|
5130
5063
|
if (e.name === `svg`) {
|
|
5131
|
-
for (let [e, t] of i.entries()) e.attributes[`xlink:href`] != null && a--,
|
|
5064
|
+
for (let [e, t] of i.entries()) e.attributes[`xlink:href`] != null && a--, D(e, t);
|
|
5132
5065
|
a === 0 && delete e.attributes[`xmlns:xlink`];
|
|
5133
|
-
for (let [e, t] of r.entries()) n.has(e) && e.children.length === 0 &&
|
|
5066
|
+
for (let [e, t] of r.entries()) n.has(e) && e.children.length === 0 && D(e, t);
|
|
5134
5067
|
}
|
|
5135
5068
|
}
|
|
5136
5069
|
} };
|
|
5137
5070
|
},
|
|
5138
5071
|
name: `convertOneStopGradients`
|
|
5139
5072
|
});
|
|
5140
|
-
let
|
|
5141
|
-
var
|
|
5073
|
+
let Y = (...e) => `(?:` + e.join(`|`) + `)`, Tr = k.presentation, X = `\\\\(?:[0-9a-f]{1,6}\\s?|\\r\\n|.)`, Er = `\\s*(` + Y(`[^:;\\\\]`, X) + `*?)\\s*`, Dr = `'(?:[^'\\n\\r\\\\]|` + X + `)*?(?:'|$)`, Or = `"(?:[^"\\n\\r\\\\]|` + X + `)*?(?:"|$)`, kr = RegExp(`^` + Y(Dr, Or) + `$`), Ar = `\\s*(` + Y(`[^!'"();\\\\]+?`, X, Dr, Or, `\\(` + Y(`[^'"()\\\\]+`, X, Dr, Or) + `*?\\)`, `[^;]*?`) + `*?)`, jr = RegExp(Er + `:` + Ar + `(\\s*!important(?![-(\\w]))?\\s*(?:;\\s*|$)`, `ig`), Mr = new RegExp(Y(X, Dr, Or, `/\\*[^]*?\\*/`), `ig`);
|
|
5074
|
+
var Nr = Object.freeze({
|
|
5142
5075
|
__proto__: null,
|
|
5143
5076
|
description: `converts style to attributes`,
|
|
5144
5077
|
fn: (e, t) => {
|
|
5145
5078
|
let { keepImportant: n = !1 } = t;
|
|
5146
5079
|
return { element: { enter: (e) => {
|
|
5147
5080
|
if (e.attributes.style != null) {
|
|
5148
|
-
let r = [], i = {}, a = e.attributes.style.replace(
|
|
5149
|
-
|
|
5150
|
-
for (var t; t =
|
|
5151
|
-
r.length && (r = r.filter(
|
|
5081
|
+
let r = [], i = {}, a = e.attributes.style.replace(Mr, (e) => e[0] == `/` ? `` : e[0] == `\\` && /[-g-z]/i.test(e[1]) ? e[1] : e);
|
|
5082
|
+
jr.lastIndex = 0;
|
|
5083
|
+
for (var t; t = jr.exec(a);) n && t[3] || r.push([t[1], t[2]]);
|
|
5084
|
+
r.length && (r = r.filter(function(e) {
|
|
5152
5085
|
if (e[0]) {
|
|
5153
5086
|
let t = e[0].toLowerCase(), n = e[1];
|
|
5154
|
-
if (
|
|
5087
|
+
if (kr.test(n) && (n = n.slice(1, -1)), Tr.has(t)) return i[t] = n, !1;
|
|
5155
5088
|
}
|
|
5156
5089
|
return !0;
|
|
5157
|
-
})
|
|
5090
|
+
}), Object.assign(e.attributes, i), r.length ? e.attributes.style = r.map((e) => e.join(`:`)).join(`;`) : delete e.attributes.style);
|
|
5158
5091
|
}
|
|
5159
5092
|
} } };
|
|
5160
5093
|
},
|
|
5161
5094
|
name: `convertStyleToAttrs`
|
|
5162
5095
|
});
|
|
5163
|
-
let
|
|
5096
|
+
let Pr = (e) => {
|
|
5164
5097
|
let t = /[/\\]?([^/\\]+)$/.exec(e);
|
|
5165
5098
|
return t ? t[1] : ``;
|
|
5166
|
-
},
|
|
5099
|
+
}, Fr = (e) => e.replace(/[. ]/g, `_`), Ir = (e) => e.startsWith(`"`) && e.endsWith(`"`) || e.startsWith(`'`) && e.endsWith(`'`) ? e.slice(1, -1) : e, Z = (e, t) => {
|
|
5167
5100
|
let n = e(t);
|
|
5168
5101
|
return t.startsWith(n) ? t : n + t;
|
|
5169
|
-
}, Lr = (e, t) => t.startsWith(`#`) ? `#` +
|
|
5102
|
+
}, Lr = (e, t) => t.startsWith(`#`) ? `#` + Z(e, t.slice(1)) : null, Rr = (e, t, n, r, i, a) => {
|
|
5170
5103
|
if (typeof r == `function`) {
|
|
5171
5104
|
let o = a.get(e);
|
|
5172
|
-
return o ?? (o = r(t, n) + i, a.set(e, o), o
|
|
5105
|
+
return o ?? (o = r(t, n) + i, a.set(e, o)), o;
|
|
5173
5106
|
}
|
|
5174
|
-
return typeof r == `string` ? r + i : r === !1 ? `` : n.path != null && n.path.length > 0 ? Pr(
|
|
5107
|
+
return typeof r == `string` ? r + i : r === !1 ? `` : n.path != null && n.path.length > 0 ? Fr(Pr(n.path)) + i : `prefix` + i;
|
|
5175
5108
|
};
|
|
5176
5109
|
var zr = Object.freeze({
|
|
5177
5110
|
__proto__: null,
|
|
@@ -5186,42 +5119,39 @@ plugins: [
|
|
|
5186
5119
|
if (n.type !== `text` && n.type !== `cdata`) continue;
|
|
5187
5120
|
let e = n.value, r;
|
|
5188
5121
|
try {
|
|
5189
|
-
r =
|
|
5122
|
+
r = v.parse(e, {
|
|
5190
5123
|
parseValue: !0,
|
|
5191
5124
|
parseCustomProperty: !1
|
|
5192
5125
|
});
|
|
5193
5126
|
} catch {
|
|
5194
5127
|
return;
|
|
5195
5128
|
}
|
|
5196
|
-
|
|
5197
|
-
if (a && e.type === `IdSelector` || o && e.type === `ClassSelector`)
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
}
|
|
5201
|
-
if (e.type === `Url` && e.value.length > 0) {
|
|
5202
|
-
let n = Lr(t, Fr(e.value));
|
|
5129
|
+
v.walk(r, (e) => {
|
|
5130
|
+
if (a && e.type === `IdSelector` || o && e.type === `ClassSelector`) e.name = Z(t, e.name);
|
|
5131
|
+
else if (e.type === `Url` && e.value.length > 0) {
|
|
5132
|
+
let n = Lr(t, Ir(e.value));
|
|
5203
5133
|
n != null && (e.value = n);
|
|
5204
5134
|
}
|
|
5205
|
-
})
|
|
5135
|
+
}), n.value = v.generate(r);
|
|
5206
5136
|
}
|
|
5207
5137
|
}
|
|
5208
|
-
a && e.attributes.id != null && e.attributes.id.length !== 0 && (e.attributes.id =
|
|
5138
|
+
a && e.attributes.id != null && e.attributes.id.length !== 0 && (e.attributes.id = Z(t, e.attributes.id)), o && e.attributes.class != null && e.attributes.class.length !== 0 && (e.attributes.class = e.attributes.class.split(/\s+/).map((e) => Z(t, e)).join(` `));
|
|
5209
5139
|
for (let n of [`href`, `xlink:href`]) if (e.attributes[n] != null && e.attributes[n].length !== 0) {
|
|
5210
5140
|
let r = Lr(t, e.attributes[n]);
|
|
5211
5141
|
r != null && (e.attributes[n] = r);
|
|
5212
5142
|
}
|
|
5213
|
-
for (let n of
|
|
5143
|
+
for (let n of A) e.attributes[n] != null && e.attributes[n].length !== 0 && (e.attributes[n] = e.attributes[n].replace(/\burl\((["'])?(#.+?)\1\)/gi, (e, n, r) => {
|
|
5214
5144
|
let i = Lr(t, r);
|
|
5215
5145
|
return i == null ? e : `url(${i})`;
|
|
5216
|
-
}))
|
|
5146
|
+
}));
|
|
5217
5147
|
for (let n of [`begin`, `end`]) if (e.attributes[n] != null && e.attributes[n].length !== 0) {
|
|
5218
|
-
let r = e.attributes[n].split(/\s*;\s+/).map((
|
|
5148
|
+
let r = e.attributes[n].split(/\s*;\s+/).map((e) => {
|
|
5219
5149
|
if (e.endsWith(`.end`) || e.endsWith(`.start`)) {
|
|
5220
5150
|
let [n, r] = e.split(`.`);
|
|
5221
|
-
return `${
|
|
5151
|
+
return `${Z(t, n)}.${r}`;
|
|
5222
5152
|
}
|
|
5223
5153
|
return e;
|
|
5224
|
-
})
|
|
5154
|
+
});
|
|
5225
5155
|
e.attributes[n] = r.join(`; `);
|
|
5226
5156
|
}
|
|
5227
5157
|
} } };
|
|
@@ -5231,11 +5161,16 @@ plugins: [
|
|
|
5231
5161
|
__proto__: null,
|
|
5232
5162
|
description: `removes attributes of elements that match a css selector`,
|
|
5233
5163
|
fn: (e, t) => {
|
|
5164
|
+
if (!Array.isArray(t.selectors) && (!t.selector || !t.attributes)) return console.warn(`Warning: The plugin "removeAttributesBySelector" is missing parameters.
|
|
5165
|
+
It should have a list of "selectors", or one "selector" and one "attributes".
|
|
5166
|
+
Without either, the plugin is a noop.`), null;
|
|
5234
5167
|
let n = Array.isArray(t.selectors) ? t.selectors : [t];
|
|
5235
5168
|
for (let { selector: t, attributes: r } of n) {
|
|
5236
|
-
let n =
|
|
5237
|
-
for (let e of n) if (e.type === `element`)
|
|
5238
|
-
|
|
5169
|
+
let n = E(e, t);
|
|
5170
|
+
for (let e of n) if (e.type === `element`) {
|
|
5171
|
+
if (Array.isArray(r)) for (let t of r) delete e.attributes[t];
|
|
5172
|
+
else delete e.attributes[r];
|
|
5173
|
+
}
|
|
5239
5174
|
}
|
|
5240
5175
|
return {};
|
|
5241
5176
|
},
|
|
@@ -5265,11 +5200,11 @@ plugins: [
|
|
|
5265
5200
|
t,
|
|
5266
5201
|
`.*`
|
|
5267
5202
|
].join(n);
|
|
5268
|
-
let i = t.split(n).map((
|
|
5203
|
+
let i = t.split(n).map((e) => (e === `*` && (e = `.*`), new RegExp([
|
|
5269
5204
|
`^`,
|
|
5270
5205
|
e,
|
|
5271
5206
|
`$`
|
|
5272
|
-
].join(``), `i`)))
|
|
5207
|
+
].join(``), `i`)));
|
|
5273
5208
|
if (i[0].test(e.name)) for (let [t, n] of Object.entries(e.attributes)) {
|
|
5274
5209
|
let a = n.toLowerCase() === `currentcolor`;
|
|
5275
5210
|
!(r && t == `fill` && a) && !(r && t == `stroke` && a) && i[1].test(t) && i[2].test(n) && delete e.attributes[t];
|
|
@@ -5297,10 +5232,10 @@ plugins: [
|
|
|
5297
5232
|
fn: (e, t) => {
|
|
5298
5233
|
let n = t.id == null ? [] : Array.isArray(t.id) ? t.id : [t.id], r = t.class == null ? [] : Array.isArray(t.class) ? t.class : [t.class];
|
|
5299
5234
|
return { element: { enter: (e, t) => {
|
|
5300
|
-
if (e.attributes.id != null && n.length !== 0 && n.includes(e.attributes.id) &&
|
|
5235
|
+
if (e.attributes.id != null && n.length !== 0 && n.includes(e.attributes.id) && D(e, t), e.attributes.class && r.length !== 0) {
|
|
5301
5236
|
let n = e.attributes.class.split(` `);
|
|
5302
5237
|
for (let i of r) if (n.includes(i)) {
|
|
5303
|
-
|
|
5238
|
+
D(e, t);
|
|
5304
5239
|
break;
|
|
5305
5240
|
}
|
|
5306
5241
|
}
|
|
@@ -5328,9 +5263,9 @@ plugins: [
|
|
|
5328
5263
|
height: s
|
|
5329
5264
|
};
|
|
5330
5265
|
}
|
|
5331
|
-
if (t.attributes.transform != null) return
|
|
5266
|
+
if (t.attributes.transform != null) return b;
|
|
5332
5267
|
if (t.name === `path` && t.attributes.d != null && e != null) {
|
|
5333
|
-
let r =
|
|
5268
|
+
let r = It(t.attributes.d), i = !1;
|
|
5334
5269
|
for (let t of r) if (t.command === `M`) {
|
|
5335
5270
|
let [n, r] = t.args;
|
|
5336
5271
|
n >= e.left && n <= e.right && r >= e.top && r <= e.bottom && (i = !0);
|
|
@@ -5341,7 +5276,7 @@ plugins: [
|
|
|
5341
5276
|
args: []
|
|
5342
5277
|
});
|
|
5343
5278
|
let { left: a, top: o, width: s, height: c } = e;
|
|
5344
|
-
|
|
5279
|
+
$t([
|
|
5345
5280
|
{
|
|
5346
5281
|
command: `M`,
|
|
5347
5282
|
args: [a, o]
|
|
@@ -5362,7 +5297,7 @@ plugins: [
|
|
|
5362
5297
|
command: `z`,
|
|
5363
5298
|
args: []
|
|
5364
5299
|
}
|
|
5365
|
-
], r) === !1 &&
|
|
5300
|
+
], r) === !1 && D(t, n);
|
|
5366
5301
|
}
|
|
5367
5302
|
} } };
|
|
5368
5303
|
},
|
|
@@ -5371,64 +5306,96 @@ plugins: [
|
|
|
5371
5306
|
__proto__: null,
|
|
5372
5307
|
description: `removes raster images`,
|
|
5373
5308
|
fn: () => ({ element: { enter: (e, t) => {
|
|
5374
|
-
e.name === `image` && e.attributes[`xlink:href`] != null && /(\.|image\/)(jpe?g|png|gif)/.test(e.attributes[`xlink:href`]) &&
|
|
5309
|
+
e.name === `image` && e.attributes[`xlink:href`] != null && /(\.|image\/)(jpe?g|png|gif)/.test(e.attributes[`xlink:href`]) && D(e, t);
|
|
5375
5310
|
} } }),
|
|
5376
5311
|
name: `removeRasterImages`
|
|
5377
5312
|
});
|
|
5378
5313
|
let Kr = [
|
|
5379
|
-
...
|
|
5380
|
-
...
|
|
5381
|
-
...
|
|
5382
|
-
...
|
|
5383
|
-
...
|
|
5384
|
-
]
|
|
5385
|
-
|
|
5314
|
+
...k.animationEvent,
|
|
5315
|
+
...k.documentEvent,
|
|
5316
|
+
...k.documentElementEvent,
|
|
5317
|
+
...k.globalEvent,
|
|
5318
|
+
...k.graphicalEvent
|
|
5319
|
+
], qr = `http://www.w3.org/2000/svg`, Jr = [qr], Yr = [qr], Xr = [qr, `http://www.w3.org/1999/xhtml`], Zr = /* @__PURE__ */ new Set([
|
|
5320
|
+
`action`,
|
|
5321
|
+
`data`,
|
|
5322
|
+
`formaction`,
|
|
5323
|
+
`href`,
|
|
5324
|
+
`src`
|
|
5325
|
+
]);
|
|
5326
|
+
function Qr(e, t, n, r) {
|
|
5327
|
+
if (e === t) return !0;
|
|
5328
|
+
if (e.includes(`:`)) {
|
|
5329
|
+
let [i, a] = e.split(`:`, 2);
|
|
5330
|
+
if (t === a) {
|
|
5331
|
+
let e = n.get(i), t = e[e.length - 1];
|
|
5332
|
+
return r.includes(t);
|
|
5333
|
+
}
|
|
5334
|
+
}
|
|
5335
|
+
return !1;
|
|
5336
|
+
}
|
|
5337
|
+
var $r = Object.freeze({
|
|
5386
5338
|
__proto__: null,
|
|
5387
5339
|
description: `removes scripts`,
|
|
5388
|
-
fn: () =>
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
for (let
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5340
|
+
fn: () => {
|
|
5341
|
+
let e = /* @__PURE__ */ new Map(), t = 0;
|
|
5342
|
+
return { element: {
|
|
5343
|
+
enter: (n, r) => {
|
|
5344
|
+
for (let [t, r] of Object.entries(n.attributes)) {
|
|
5345
|
+
if (!t.startsWith(`xmlns:`)) continue;
|
|
5346
|
+
let n = t.slice(6);
|
|
5347
|
+
e.has(n) ? e.get(n).push(r) : e.set(n, [r]);
|
|
5348
|
+
}
|
|
5349
|
+
if (Qr(n.name, `foreignObject`, e, Jr) && (t += 1), Qr(n.name, `script`, e, Xr)) D(n, r);
|
|
5350
|
+
else for (let [e, r] of Object.entries(n.attributes)) {
|
|
5351
|
+
let i = e.slice(e.lastIndexOf(`:`) + 1).toLowerCase(), a = Kr.includes(e) || t > 0 && i.startsWith(`on`), o = t > 0 && i === `srcdoc`, s = t > 0 && Zr.has(i) && Ze(r);
|
|
5352
|
+
(a || o || s) && delete n.attributes[e];
|
|
5353
|
+
}
|
|
5354
|
+
},
|
|
5355
|
+
exit: (n, r) => {
|
|
5356
|
+
let i = Qr(n.name, `foreignObject`, e, Jr), a = Qr(n.name, `a`, e, Yr);
|
|
5357
|
+
for (let t of Object.keys(n.attributes)) {
|
|
5358
|
+
if (!t.startsWith(`xmlns:`)) continue;
|
|
5359
|
+
let n = t.slice(6);
|
|
5360
|
+
e.get(n).pop();
|
|
5402
5361
|
}
|
|
5362
|
+
if (a) {
|
|
5363
|
+
for (let e of Object.keys(n.attributes)) if (e === `href` || e.endsWith(`:href`)) {
|
|
5364
|
+
if (n.attributes[e] == null || !Ze(n.attributes[e])) continue;
|
|
5365
|
+
let t = r.children.indexOf(n), i = n.children.filter((e) => e.type !== `text`);
|
|
5366
|
+
r.children.splice(t, 1, ...i);
|
|
5367
|
+
}
|
|
5368
|
+
}
|
|
5369
|
+
i && --t;
|
|
5403
5370
|
}
|
|
5404
|
-
}
|
|
5405
|
-
}
|
|
5371
|
+
} };
|
|
5372
|
+
},
|
|
5406
5373
|
name: `removeScripts`
|
|
5407
|
-
}),
|
|
5374
|
+
}), ei = Object.freeze({
|
|
5408
5375
|
__proto__: null,
|
|
5409
5376
|
description: `removes <style> element`,
|
|
5410
5377
|
fn: () => ({ element: { enter: (e, t) => {
|
|
5411
|
-
e.name === `style` &&
|
|
5378
|
+
e.name === `style` && D(e, t);
|
|
5412
5379
|
} } }),
|
|
5413
5380
|
name: `removeStyleElement`
|
|
5414
|
-
}),
|
|
5381
|
+
}), ti = Object.freeze({
|
|
5415
5382
|
__proto__: null,
|
|
5416
5383
|
description: `removes <title>`,
|
|
5417
5384
|
fn: () => ({ element: { enter: (e, t) => {
|
|
5418
|
-
e.name === `title` &&
|
|
5385
|
+
e.name === `title` && D(e, t);
|
|
5419
5386
|
} } }),
|
|
5420
5387
|
name: `removeTitle`
|
|
5421
5388
|
});
|
|
5422
|
-
let
|
|
5389
|
+
let ni = /* @__PURE__ */ new Set([
|
|
5423
5390
|
`pattern`,
|
|
5424
5391
|
`svg`,
|
|
5425
5392
|
`symbol`
|
|
5426
5393
|
]);
|
|
5427
|
-
var
|
|
5394
|
+
var ri = Object.freeze({
|
|
5428
5395
|
__proto__: null,
|
|
5429
5396
|
description: `removes viewBox attribute when possible`,
|
|
5430
5397
|
fn: () => ({ element: { enter: (e, t) => {
|
|
5431
|
-
if (
|
|
5398
|
+
if (ni.has(e.name) && e.attributes.viewBox != null && e.attributes.width != null && e.attributes.height != null) {
|
|
5432
5399
|
if (e.name === `svg` && t.type !== `root`) return;
|
|
5433
5400
|
let n = e.attributes.viewBox.split(/[ ,]+/g);
|
|
5434
5401
|
n[0] === `0` && n[1] === `0` && e.attributes.width.replace(/px$/, ``) === n[2] && e.attributes.height.replace(/px$/, ``) === n[3] && delete e.attributes.viewBox;
|
|
@@ -5436,17 +5403,17 @@ plugins: [
|
|
|
5436
5403
|
} } }),
|
|
5437
5404
|
name: `removeViewBox`
|
|
5438
5405
|
});
|
|
5439
|
-
let
|
|
5406
|
+
let ii = `http://www.w3.org/1999/xlink`, ai = {
|
|
5440
5407
|
new: `_blank`,
|
|
5441
5408
|
replace: `_self`
|
|
5442
|
-
},
|
|
5409
|
+
}, oi = /* @__PURE__ */ new Set([
|
|
5443
5410
|
`cursor`,
|
|
5444
5411
|
`filter`,
|
|
5445
5412
|
`font-face-uri`,
|
|
5446
5413
|
`glyphRef`,
|
|
5447
5414
|
`tref`
|
|
5448
|
-
]),
|
|
5449
|
-
var
|
|
5415
|
+
]), si = (e, t, n) => t.map((e) => `${e}:${n}`).filter((t) => e.attributes[t] != null);
|
|
5416
|
+
var ci = Object.freeze({
|
|
5450
5417
|
__proto__: null,
|
|
5451
5418
|
description: `remove xlink namespace and replaces attributes with the SVG 2 equivalent where applicable`,
|
|
5452
5419
|
fn: (e, t) => {
|
|
@@ -5455,26 +5422,22 @@ plugins: [
|
|
|
5455
5422
|
enter: (e) => {
|
|
5456
5423
|
for (let [t, n] of Object.entries(e.attributes)) if (t.startsWith(`xmlns:`)) {
|
|
5457
5424
|
let e = t.split(`:`, 2)[1];
|
|
5458
|
-
if (n ===
|
|
5425
|
+
if (n === ii) {
|
|
5459
5426
|
r.push(e);
|
|
5460
5427
|
continue;
|
|
5461
5428
|
}
|
|
5462
5429
|
r.includes(e) && i.push(e);
|
|
5463
5430
|
}
|
|
5464
|
-
if (i.some((
|
|
5465
|
-
let t =
|
|
5431
|
+
if (i.some((e) => r.includes(e))) return;
|
|
5432
|
+
let t = si(e, r, `show`), o = e.attributes.target != null;
|
|
5466
5433
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
5467
|
-
let r = t[n], i =
|
|
5468
|
-
|
|
5469
|
-
delete e.attributes[r];
|
|
5470
|
-
continue;
|
|
5471
|
-
}
|
|
5472
|
-
i !== ye[e.name]?.defaults?.target && (e.attributes.target = i), delete e.attributes[r], o = !0;
|
|
5434
|
+
let r = t[n], i = e.attributes[r], a = ai[i];
|
|
5435
|
+
o || a == null ? delete e.attributes[r] : (a !== _e[e.name]?.defaults?.target && (e.attributes.target = a), delete e.attributes[r], o = !0);
|
|
5473
5436
|
}
|
|
5474
|
-
let s =
|
|
5437
|
+
let s = si(e, r, `title`);
|
|
5475
5438
|
for (let t = s.length - 1; t >= 0; t--) {
|
|
5476
5439
|
let n = s[t], r = e.attributes[n];
|
|
5477
|
-
if (e.children.filter((
|
|
5440
|
+
if (e.children.filter((e) => e.type === `element` && e.name === `title`).length > 0) {
|
|
5478
5441
|
delete e.attributes[n];
|
|
5479
5442
|
continue;
|
|
5480
5443
|
}
|
|
@@ -5492,29 +5455,19 @@ plugins: [
|
|
|
5492
5455
|
value: e
|
|
5493
5456
|
}), e.children.unshift(i), delete e.attributes[n];
|
|
5494
5457
|
}
|
|
5495
|
-
let c =
|
|
5496
|
-
if (c.length > 0 &&
|
|
5497
|
-
|
|
5498
|
-
return;
|
|
5499
|
-
}
|
|
5500
|
-
for (let t = c.length - 1; t >= 0; t--) {
|
|
5458
|
+
let c = si(e, r, `href`);
|
|
5459
|
+
if (c.length > 0 && oi.has(e.name) && !n) c.map((e) => e.split(`:`, 1)[0]).forEach((e) => a.push(e));
|
|
5460
|
+
else for (let t = c.length - 1; t >= 0; t--) {
|
|
5501
5461
|
let n = c[t], r = e.attributes[n];
|
|
5502
|
-
|
|
5503
|
-
delete e.attributes[n];
|
|
5504
|
-
continue;
|
|
5505
|
-
}
|
|
5506
|
-
e.attributes.href = r, delete e.attributes[n];
|
|
5462
|
+
e.attributes.href ?? (e.attributes.href = r), delete e.attributes[n];
|
|
5507
5463
|
}
|
|
5508
5464
|
},
|
|
5509
5465
|
exit: (e) => {
|
|
5510
5466
|
for (let [t, o] of Object.entries(e.attributes)) {
|
|
5511
5467
|
let [s, c] = t.split(`:`, 2);
|
|
5512
|
-
if (r.includes(s) && !i.includes(s) && !a.includes(s) && !n)
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
}
|
|
5516
|
-
if (t.startsWith(`xmlns:`) && !a.includes(c)) {
|
|
5517
|
-
if (o === Qr) {
|
|
5468
|
+
if (r.includes(s) && !i.includes(s) && !a.includes(s) && !n) delete e.attributes[t];
|
|
5469
|
+
else if (t.startsWith(`xmlns:`) && !a.includes(c)) {
|
|
5470
|
+
if (o === ii) {
|
|
5518
5471
|
let n = r.indexOf(c);
|
|
5519
5472
|
r.splice(n, 1), delete e.attributes[t];
|
|
5520
5473
|
continue;
|
|
@@ -5529,18 +5482,18 @@ plugins: [
|
|
|
5529
5482
|
} };
|
|
5530
5483
|
},
|
|
5531
5484
|
name: `removeXlink`
|
|
5532
|
-
}),
|
|
5485
|
+
}), li = Object.freeze({
|
|
5533
5486
|
__proto__: null,
|
|
5534
5487
|
description: `removes xmlns attribute (for inline svg)`,
|
|
5535
5488
|
fn: () => ({ element: { enter: (e) => {
|
|
5536
5489
|
e.name === `svg` && delete e.attributes.xmlns;
|
|
5537
5490
|
} } }),
|
|
5538
5491
|
name: `removeXMLNS`
|
|
5539
|
-
}),
|
|
5492
|
+
}), ui = Object.freeze({
|
|
5540
5493
|
__proto__: null,
|
|
5541
5494
|
description: `Finds <path> elements with the same d, fill, and stroke, and converts them to <use> elements referencing a single <path> def.`,
|
|
5542
5495
|
fn: (e) => {
|
|
5543
|
-
let t =
|
|
5496
|
+
let t = M(e), n = /* @__PURE__ */ new Map(), r, i = /* @__PURE__ */ new Set();
|
|
5544
5497
|
return { element: {
|
|
5545
5498
|
enter: (e, t) => {
|
|
5546
5499
|
if (e.name === `path` && e.attributes.d != null) {
|
|
@@ -5575,17 +5528,17 @@ plugins: [
|
|
|
5575
5528
|
`d`
|
|
5576
5529
|
]) r[0].attributes[e] != null && (n.attributes[e] = r[0].attributes[e]);
|
|
5577
5530
|
let s = r[0].attributes.id;
|
|
5578
|
-
s == null || i.has(s) || t.rules.some((
|
|
5531
|
+
s == null || i.has(s) || t.rules.some((e) => e.selector === `#${s}`) ? n.attributes.id = `reuse-` + o++ : (n.attributes.id = s, delete r[0].attributes.id), a.children.push(n);
|
|
5579
5532
|
for (let t of r) {
|
|
5580
5533
|
if (delete t.attributes.d, delete t.attributes.stroke, delete t.attributes.fill, a.children.includes(t) && t.children.length === 0) {
|
|
5581
5534
|
if (Object.keys(t.attributes).length === 0) {
|
|
5582
|
-
|
|
5535
|
+
D(t, a);
|
|
5583
5536
|
continue;
|
|
5584
5537
|
}
|
|
5585
5538
|
if (Object.keys(t.attributes).length === 1 && t.attributes.id != null) {
|
|
5586
|
-
|
|
5539
|
+
D(t, a);
|
|
5587
5540
|
let r = `[xlink\\:href=#${t.attributes.id}], [href=#${t.attributes.id}]`;
|
|
5588
|
-
for (let t of
|
|
5541
|
+
for (let t of E(e, r)) if (t.type === `element`) for (let e of [`href`, `xlink:href`]) t.attributes[e] != null && (t.attributes[e] = `#` + n.attributes.id);
|
|
5589
5542
|
continue;
|
|
5590
5543
|
}
|
|
5591
5544
|
}
|
|
@@ -5599,68 +5552,68 @@ plugins: [
|
|
|
5599
5552
|
},
|
|
5600
5553
|
name: `reusePaths`
|
|
5601
5554
|
});
|
|
5602
|
-
let
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
Vt,
|
|
5614
|
-
xr,
|
|
5615
|
-
Zn,
|
|
5616
|
-
Bt,
|
|
5617
|
-
Mr,
|
|
5618
|
-
ir,
|
|
5619
|
-
Ke,
|
|
5620
|
-
cr,
|
|
5621
|
-
We,
|
|
5622
|
-
tt,
|
|
5623
|
-
Ht,
|
|
5555
|
+
let di = Object.freeze([
|
|
5556
|
+
_r,
|
|
5557
|
+
vr,
|
|
5558
|
+
yr,
|
|
5559
|
+
Ve,
|
|
5560
|
+
At,
|
|
5561
|
+
ct,
|
|
5562
|
+
Cr,
|
|
5563
|
+
mt,
|
|
5564
|
+
Yt,
|
|
5565
|
+
bt,
|
|
5624
5566
|
Wt,
|
|
5567
|
+
wr,
|
|
5568
|
+
er,
|
|
5569
|
+
Ut,
|
|
5570
|
+
Nr,
|
|
5571
|
+
sr,
|
|
5572
|
+
We,
|
|
5573
|
+
dr,
|
|
5574
|
+
He,
|
|
5575
|
+
nt,
|
|
5576
|
+
Gt,
|
|
5577
|
+
qt,
|
|
5625
5578
|
zr,
|
|
5626
5579
|
Br,
|
|
5627
5580
|
Vr,
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5581
|
+
fe,
|
|
5582
|
+
Fe,
|
|
5583
|
+
gr,
|
|
5631
5584
|
Hr,
|
|
5632
|
-
|
|
5633
|
-
|
|
5585
|
+
le,
|
|
5586
|
+
Le,
|
|
5634
5587
|
Ur,
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5588
|
+
cr,
|
|
5589
|
+
lr,
|
|
5590
|
+
Vt,
|
|
5591
|
+
Bt,
|
|
5592
|
+
Ie,
|
|
5593
|
+
Tt,
|
|
5641
5594
|
Wr,
|
|
5642
5595
|
Gr,
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
Zr,
|
|
5651
|
-
ni,
|
|
5596
|
+
$r,
|
|
5597
|
+
ei,
|
|
5598
|
+
ti,
|
|
5599
|
+
wt,
|
|
5600
|
+
fr,
|
|
5601
|
+
dt,
|
|
5602
|
+
Et,
|
|
5652
5603
|
ri,
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5604
|
+
ci,
|
|
5605
|
+
li,
|
|
5606
|
+
ue,
|
|
5607
|
+
ui,
|
|
5608
|
+
pr,
|
|
5609
|
+
mr
|
|
5657
5610
|
]);
|
|
5658
|
-
var
|
|
5611
|
+
var fi = class e extends Error {
|
|
5659
5612
|
constructor(t, n, r, i, a) {
|
|
5660
5613
|
super(t), this.name = `SvgoParserError`, this.message = `${a || `<input>`}:${n}:${r}: ${t}`, this.reason = t, this.line = n, this.column = r, this.source = i, Error.captureStackTrace && Error.captureStackTrace(this, e);
|
|
5661
5614
|
}
|
|
5662
5615
|
toString() {
|
|
5663
|
-
let e = this.source.split(/\r?\n/), t = Math.max(this.line - 3, 0), n = Math.min(this.line + 2, e.length), r = String(n).length, i = Math.max(this.column - 54, 0), a = Math.max(this.column + 20, 80), o = e.slice(t, n).map((
|
|
5616
|
+
let e = this.source.split(/\r?\n/), t = Math.max(this.line - 3, 0), n = Math.min(this.line + 2, e.length), r = String(n).length, i = Math.max(this.column - 54, 0), a = Math.max(this.column + 20, 80), o = e.slice(t, n).map((e, n) => {
|
|
5664
5617
|
let o = e.slice(i, a), s = ``, c = ``;
|
|
5665
5618
|
i !== 0 && (s = i > e.length - 1 ? ` ` : `…`), a < e.length - 1 && (c = `…`);
|
|
5666
5619
|
let l = t + 1 + n, u = ` ${l.toString().padStart(r)} | `;
|
|
@@ -5669,12 +5622,12 @@ plugins: [
|
|
|
5669
5622
|
return `>${u}${s}${o}${c}\n ${t}^`;
|
|
5670
5623
|
}
|
|
5671
5624
|
return ` ${u}${s}${o}${c}`;
|
|
5672
|
-
})
|
|
5625
|
+
}).join(`
|
|
5673
5626
|
`);
|
|
5674
5627
|
return `${this.name}: ${this.message}\n\n${o}\n`;
|
|
5675
5628
|
}
|
|
5676
5629
|
};
|
|
5677
|
-
let
|
|
5630
|
+
let pi = /<!ENTITY\s+(\S+)\s+(?:'([^']+)'|"([^"]+)")\s*>/g, mi = {
|
|
5678
5631
|
strict: !0,
|
|
5679
5632
|
trim: !1,
|
|
5680
5633
|
normalize: !1,
|
|
@@ -5682,8 +5635,8 @@ plugins: [
|
|
|
5682
5635
|
xmlns: !0,
|
|
5683
5636
|
position: !0,
|
|
5684
5637
|
unparsedEntities: !0
|
|
5685
|
-
},
|
|
5686
|
-
let n =
|
|
5638
|
+
}, hi = (e, t) => {
|
|
5639
|
+
let n = m.parser(mi.strict, mi), r = {
|
|
5687
5640
|
type: `root`,
|
|
5688
5641
|
children: []
|
|
5689
5642
|
}, i = r, a = [r], o = (e) => {
|
|
@@ -5697,21 +5650,23 @@ plugins: [
|
|
|
5697
5650
|
});
|
|
5698
5651
|
let r = t.indexOf(`[`);
|
|
5699
5652
|
if (r >= 0) {
|
|
5700
|
-
|
|
5701
|
-
let t =
|
|
5702
|
-
for (; t != null;) n.ENTITIES[t[1]] = t[2] || t[3], t =
|
|
5653
|
+
pi.lastIndex = r;
|
|
5654
|
+
let t = pi.exec(e);
|
|
5655
|
+
for (; t != null;) n.ENTITIES[t[1]] = t[2] || t[3], t = pi.exec(e);
|
|
5703
5656
|
}
|
|
5704
5657
|
}, n.onprocessinginstruction = (e) => {
|
|
5705
|
-
|
|
5658
|
+
let t = {
|
|
5706
5659
|
type: `instruction`,
|
|
5707
5660
|
name: e.name,
|
|
5708
5661
|
value: e.body
|
|
5709
|
-
}
|
|
5662
|
+
};
|
|
5663
|
+
o(t);
|
|
5710
5664
|
}, n.oncomment = (e) => {
|
|
5711
|
-
|
|
5665
|
+
let t = {
|
|
5712
5666
|
type: `comment`,
|
|
5713
5667
|
value: e.trim()
|
|
5714
|
-
}
|
|
5668
|
+
};
|
|
5669
|
+
o(t);
|
|
5715
5670
|
}, n.oncdata = (e) => {
|
|
5716
5671
|
o({
|
|
5717
5672
|
type: `cdata`,
|
|
@@ -5727,22 +5682,24 @@ plugins: [
|
|
|
5727
5682
|
for (let [n, r] of Object.entries(e.attributes)) t.attributes[n] = r.value;
|
|
5728
5683
|
o(t), i = t, a.push(t);
|
|
5729
5684
|
}, n.ontext = (e) => {
|
|
5730
|
-
if (i.type === `element`)
|
|
5731
|
-
|
|
5732
|
-
value: e
|
|
5733
|
-
});
|
|
5734
|
-
else {
|
|
5735
|
-
let t = e.trim();
|
|
5736
|
-
t !== `` && o({
|
|
5685
|
+
if (i.type === `element`) {
|
|
5686
|
+
if (pe.has(i.name)) o({
|
|
5737
5687
|
type: `text`,
|
|
5738
|
-
value:
|
|
5688
|
+
value: e
|
|
5739
5689
|
});
|
|
5690
|
+
else {
|
|
5691
|
+
let t = e.trim();
|
|
5692
|
+
t !== `` && o({
|
|
5693
|
+
type: `text`,
|
|
5694
|
+
value: t
|
|
5695
|
+
});
|
|
5696
|
+
}
|
|
5740
5697
|
}
|
|
5741
5698
|
}, n.onclosetag = () => {
|
|
5742
5699
|
a.pop(), i = a[a.length - 1];
|
|
5743
5700
|
}, n.onerror = (r) => {
|
|
5744
5701
|
let i = r.message.split(`
|
|
5745
|
-
`)[0], a = new
|
|
5702
|
+
`)[0], a = new fi(i, n.line + 1, n.column, e, t);
|
|
5746
5703
|
if (r.message.indexOf(`Unexpected end`) === -1) throw a;
|
|
5747
5704
|
}, n.write(e).close(), r;
|
|
5748
5705
|
}, Q = {
|
|
@@ -5767,18 +5724,18 @@ plugins: [
|
|
|
5767
5724
|
indent: 4,
|
|
5768
5725
|
regEntities: /[&'"<>]/g,
|
|
5769
5726
|
regValEntities: /[&"<>]/g,
|
|
5770
|
-
encodeEntity: (e) =>
|
|
5727
|
+
encodeEntity: (e) => gi[e],
|
|
5771
5728
|
pretty: !1,
|
|
5772
5729
|
useShortTags: !0,
|
|
5773
5730
|
eol: `lf`,
|
|
5774
5731
|
finalNewline: !1
|
|
5775
|
-
},
|
|
5732
|
+
}, gi = {
|
|
5776
5733
|
"&": `&`,
|
|
5777
5734
|
"'": `'`,
|
|
5778
5735
|
"\"": `"`,
|
|
5779
5736
|
">": `>`,
|
|
5780
5737
|
"<": `<`
|
|
5781
|
-
},
|
|
5738
|
+
}, _i = (e, t = {}) => {
|
|
5782
5739
|
let n = {
|
|
5783
5740
|
...Q,
|
|
5784
5741
|
...t
|
|
@@ -5792,55 +5749,55 @@ plugins: [
|
|
|
5792
5749
|
` : `
|
|
5793
5750
|
`;
|
|
5794
5751
|
n.pretty && (n.doctypeEnd += o, n.procInstEnd += o, n.commentEnd += o, n.cdataEnd += o, n.tagShortEnd += o, n.tagOpenEnd += o, n.tagCloseEnd += o, n.textEnd += o);
|
|
5795
|
-
let s =
|
|
5752
|
+
let s = vi(e, n, a);
|
|
5796
5753
|
return n.finalNewline && s.length > 0 && !s.endsWith(`
|
|
5797
5754
|
`) && (s += o), s;
|
|
5798
|
-
},
|
|
5755
|
+
}, vi = (e, t, n) => {
|
|
5799
5756
|
let r = ``;
|
|
5800
5757
|
n.indentLevel++;
|
|
5801
5758
|
for (let i of e.children) switch (i.type) {
|
|
5802
5759
|
case `element`:
|
|
5803
|
-
r +=
|
|
5760
|
+
r += Ci(i, t, n);
|
|
5804
5761
|
break;
|
|
5805
5762
|
case `text`:
|
|
5806
|
-
r +=
|
|
5763
|
+
r += Ti(i, t, n);
|
|
5807
5764
|
break;
|
|
5808
5765
|
case `doctype`:
|
|
5809
|
-
r +=
|
|
5766
|
+
r += yi(i, t);
|
|
5810
5767
|
break;
|
|
5811
5768
|
case `instruction`:
|
|
5812
|
-
r +=
|
|
5769
|
+
r += bi(i, t);
|
|
5813
5770
|
break;
|
|
5814
5771
|
case `comment`:
|
|
5815
|
-
r +=
|
|
5772
|
+
r += xi(i, t);
|
|
5816
5773
|
break;
|
|
5817
|
-
case `cdata`: r +=
|
|
5774
|
+
case `cdata`: r += Si(i, t, n);
|
|
5818
5775
|
}
|
|
5819
5776
|
return n.indentLevel--, r;
|
|
5820
5777
|
}, $ = (e, t) => {
|
|
5821
5778
|
let n = ``;
|
|
5822
5779
|
return e.pretty && t.textContext == null && (n = t.indent.repeat(t.indentLevel - 1)), n;
|
|
5823
|
-
},
|
|
5824
|
-
if (e.children.length === 0) return t.useShortTags ? $(t, n) + t.tagShortStart + e.name +
|
|
5780
|
+
}, yi = (e, t) => t.doctypeStart + e.data.doctype + t.doctypeEnd, bi = (e, t) => t.procInstStart + e.name + ` ` + e.value + t.procInstEnd, xi = (e, t) => t.commentStart + e.value + t.commentEnd, Si = (e, t, n) => $(t, n) + t.cdataStart + e.value + t.cdataEnd, Ci = (e, t, n) => {
|
|
5781
|
+
if (e.children.length === 0) return t.useShortTags ? $(t, n) + t.tagShortStart + e.name + wi(e, t) + t.tagShortEnd : $(t, n) + t.tagShortStart + e.name + wi(e, t) + t.tagOpenEnd + t.tagCloseStart + e.name + t.tagCloseEnd;
|
|
5825
5782
|
let r = t.tagOpenStart, i = t.tagOpenEnd, a = t.tagCloseStart, o = t.tagCloseEnd, s = $(t, n), c = $(t, n);
|
|
5826
|
-
n.textContext ? (r = Q.tagOpenStart, i = Q.tagOpenEnd, a = Q.tagCloseStart, o = Q.tagCloseEnd, s = ``) :
|
|
5827
|
-
let l =
|
|
5828
|
-
return n.textContext === e && (n.textContext = null), s + r + e.name +
|
|
5829
|
-
},
|
|
5783
|
+
n.textContext ? (r = Q.tagOpenStart, i = Q.tagOpenEnd, a = Q.tagCloseStart, o = Q.tagCloseEnd, s = ``) : pe.has(e.name) && (i = Q.tagOpenEnd, a = Q.tagCloseStart, c = ``, n.textContext = e);
|
|
5784
|
+
let l = vi(e, t, n);
|
|
5785
|
+
return n.textContext === e && (n.textContext = null), s + r + e.name + wi(e, t) + i + l + c + a + e.name + o;
|
|
5786
|
+
}, wi = (e, t) => {
|
|
5830
5787
|
let n = ``;
|
|
5831
5788
|
for (let [r, i] of Object.entries(e.attributes)) if (n += ` ` + r, i !== void 0) {
|
|
5832
5789
|
let e = i.toString().replace(t.regValEntities, t.encodeEntity);
|
|
5833
5790
|
n += t.attrStart + e + t.attrEnd;
|
|
5834
5791
|
}
|
|
5835
5792
|
return n;
|
|
5836
|
-
},
|
|
5837
|
-
for (let e of
|
|
5838
|
-
function
|
|
5839
|
-
return e === `removeScriptElement` ? (console.warn(`Warning: removeScriptElement has been renamed to removeScripts, please update your SVGO config`),
|
|
5793
|
+
}, Ti = (e, t, n) => $(t, n) + t.textStart + e.value.replace(t.regEntities, t.encodeEntity) + (n.textContext ? `` : t.textEnd), Ei = /* @__PURE__ */ new Map();
|
|
5794
|
+
for (let e of di) Ei.set(e.name, e);
|
|
5795
|
+
function Di(e) {
|
|
5796
|
+
return e === `removeScriptElement` ? (console.warn(`Warning: removeScriptElement has been renamed to removeScripts, please update your SVGO config`), Ei.get(`removeScripts`)) : Ei.get(e);
|
|
5840
5797
|
}
|
|
5841
|
-
let
|
|
5798
|
+
let Oi = (e) => {
|
|
5842
5799
|
if (typeof e == `string`) {
|
|
5843
|
-
let t =
|
|
5800
|
+
let t = Di(e);
|
|
5844
5801
|
if (t == null) throw Error(`Unknown builtin plugin "${e}" specified.`);
|
|
5845
5802
|
return {
|
|
5846
5803
|
name: e,
|
|
@@ -5852,7 +5809,7 @@ plugins: [
|
|
|
5852
5809
|
if (e.name == null) throw Error(`Plugin name must be specified`);
|
|
5853
5810
|
let t = e.fn;
|
|
5854
5811
|
if (t == null) {
|
|
5855
|
-
let n =
|
|
5812
|
+
let n = Di(e.name);
|
|
5856
5813
|
if (n == null) throw Error(`Unknown builtin plugin "${e.name}" specified.`);
|
|
5857
5814
|
t = n.fn;
|
|
5858
5815
|
}
|
|
@@ -5863,56 +5820,56 @@ plugins: [
|
|
|
5863
5820
|
};
|
|
5864
5821
|
}
|
|
5865
5822
|
return null;
|
|
5866
|
-
},
|
|
5823
|
+
}, ki = (e, t) => {
|
|
5867
5824
|
if (t ??= {}, typeof t != `object`) throw Error(`Config should be an object`);
|
|
5868
|
-
let n = t.multipass ? 10 : 1, r =
|
|
5825
|
+
let n = t.multipass ? 10 : 1, r = 1 / 0, i = ``, a = {};
|
|
5869
5826
|
t.path != null && (a.path = t.path);
|
|
5870
5827
|
for (let o = 0; o < n; o += 1) {
|
|
5871
5828
|
a.multipassCount = o;
|
|
5872
|
-
let n =
|
|
5829
|
+
let n = hi(e, t.path), s = t.plugins || [`preset-default`];
|
|
5873
5830
|
if (!Array.isArray(s)) throw Error("malformed config, `plugins` property must be an array.\nSee more info here: https://github.com/svg/svgo#configuration");
|
|
5874
|
-
let c = s.filter((
|
|
5831
|
+
let c = s.filter((e) => e != null).map(Oi);
|
|
5875
5832
|
c.length < s.length && console.warn(`Warning: plugins list includes null or undefined elements, these will be ignored.`);
|
|
5876
5833
|
let l = {};
|
|
5877
|
-
if (t.floatPrecision != null && (l.floatPrecision = t.floatPrecision),
|
|
5834
|
+
if (t.floatPrecision != null && (l.floatPrecision = t.floatPrecision), S(n, a, c, null, l), i = _i(n, t.js2svg), !(i.length < r)) break;
|
|
5878
5835
|
e = i, r = i.length;
|
|
5879
5836
|
}
|
|
5880
|
-
return t.datauri && (i =
|
|
5881
|
-
},
|
|
5882
|
-
let t =
|
|
5837
|
+
return t.datauri && (i = Je(i, t.datauri)), { data: i };
|
|
5838
|
+
}, Ai = async (e) => {
|
|
5839
|
+
let t = l.resolve(e), n = (await import(h.pathToFileURL(t).toString())).default;
|
|
5883
5840
|
if (typeof n != `object` || !n || Array.isArray(n)) throw Error(`Invalid config file "${e}"`);
|
|
5884
5841
|
return n;
|
|
5885
|
-
},
|
|
5842
|
+
}, ji = async (e) => {
|
|
5886
5843
|
try {
|
|
5887
|
-
return (await
|
|
5844
|
+
return (await c.stat(e)).isFile();
|
|
5888
5845
|
} catch {
|
|
5889
5846
|
return !1;
|
|
5890
5847
|
}
|
|
5891
5848
|
};
|
|
5892
|
-
e.VERSION = `4.0
|
|
5893
|
-
if (e != null) return
|
|
5849
|
+
e.VERSION = `4.1.0`, e._collections = we, e.builtinPlugins = di, e.loadConfig = async (e, t = process.cwd()) => {
|
|
5850
|
+
if (e != null) return l.isAbsolute(e) ? Ai(e) : Ai(l.join(t, e));
|
|
5894
5851
|
let n = t;
|
|
5895
5852
|
for (;;) {
|
|
5896
|
-
let e =
|
|
5897
|
-
if (await
|
|
5898
|
-
let t =
|
|
5899
|
-
if (await
|
|
5900
|
-
let r =
|
|
5901
|
-
if (await
|
|
5902
|
-
let i =
|
|
5853
|
+
let e = l.join(n, `svgo.config.js`);
|
|
5854
|
+
if (await ji(e)) return Ai(e);
|
|
5855
|
+
let t = l.join(n, `svgo.config.mjs`);
|
|
5856
|
+
if (await ji(t)) return Ai(t);
|
|
5857
|
+
let r = l.join(n, `svgo.config.cjs`);
|
|
5858
|
+
if (await ji(r)) return Ai(r);
|
|
5859
|
+
let i = l.dirname(n);
|
|
5903
5860
|
if (n === i) return null;
|
|
5904
5861
|
n = i;
|
|
5905
5862
|
}
|
|
5906
|
-
}, e.mapNodesToParents =
|
|
5863
|
+
}, e.mapNodesToParents = C, e.optimize = (e, t) => {
|
|
5907
5864
|
if (t ??= {}, typeof t != `object`) throw Error(`Config should be an object`);
|
|
5908
|
-
return
|
|
5865
|
+
return ki(e, {
|
|
5909
5866
|
...t,
|
|
5910
5867
|
js2svg: {
|
|
5911
|
-
eol:
|
|
5868
|
+
eol: s.EOL === `\r
|
|
5912
5869
|
` ? `crlf` : `lf`,
|
|
5913
5870
|
...t.js2svg
|
|
5914
5871
|
}
|
|
5915
5872
|
});
|
|
5916
|
-
}, e.querySelector =
|
|
5873
|
+
}, e.querySelector = se, e.querySelectorAll = E;
|
|
5917
5874
|
}));
|
|
5918
|
-
export {
|
|
5875
|
+
export { s as require_svgo_node };
|