html-crush 5.0.4 → 5.0.10
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/CHANGELOG.md +7 -9
- package/LICENSE +1 -1
- package/README.md +4 -1
- package/dist/html-crush.esm.js +16 -573
- package/dist/html-crush.umd.js +68 -41
- package/examples/_quickTake.js +2 -0
- package/package.json +27 -92
- package/types/index.d.ts +0 -1
- package/examples/api.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,25 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## 5.0.
|
|
6
|
+
## 5.0.10 (2021-12-24)
|
|
7
7
|
|
|
8
8
|
### Bug Fixes
|
|
9
9
|
|
|
10
|
-
-
|
|
10
|
+
- add missing extension ([147bd6e](https://github.com/codsen/codsen/commit/147bd6ec2a2d44c09749f0fba0ca3e3d9c52da94))
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
|
|
12
|
+
## 5.0.9 (2021-12-24)
|
|
15
13
|
|
|
16
|
-
###
|
|
14
|
+
### Bug Fixes
|
|
17
15
|
|
|
18
|
-
-
|
|
16
|
+
- add missing extension ([147bd6e](https://github.com/codsen/codsen/commit/147bd6ec2a2d44c09749f0fba0ca3e3d9c52da94))
|
|
19
17
|
|
|
20
|
-
## 5.0.
|
|
18
|
+
## 5.0.8 (2021-12-24)
|
|
21
19
|
|
|
22
20
|
### Bug Fixes
|
|
23
21
|
|
|
24
|
-
-
|
|
22
|
+
- add missing extension ([147bd6e](https://github.com/codsen/codsen/commit/147bd6ec2a2d44c09749f0fba0ca3e3d9c52da94))
|
|
25
23
|
|
|
26
24
|
## 5.0.0 (2021-09-09)
|
|
27
25
|
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010
|
|
3
|
+
Copyright (c) 2010-2021 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ If you need a legacy version which works with `require`, use version 4.2.0
|
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
40
|
import { strict as assert } from "assert";
|
|
41
|
+
|
|
41
42
|
import { crush, defaults, version } from "html-crush";
|
|
42
43
|
|
|
43
44
|
assert.equal(
|
|
@@ -58,7 +59,7 @@ assert.equal(
|
|
|
58
59
|
|
|
59
60
|
## Documentation
|
|
60
61
|
|
|
61
|
-
Please [visit codsen.com](https://codsen.com/os/html-crush/) for a full description of the API
|
|
62
|
+
Please [visit codsen.com](https://codsen.com/os/html-crush/) for a full description of the API.
|
|
62
63
|
|
|
63
64
|
## Contributing
|
|
64
65
|
|
|
@@ -70,4 +71,6 @@ MIT License
|
|
|
70
71
|
|
|
71
72
|
Copyright (c) 2010-2021 Roy Revelt and other contributors
|
|
72
73
|
|
|
74
|
+
|
|
73
75
|
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
|
76
|
+
|
package/dist/html-crush.esm.js
CHANGED
|
@@ -1,581 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name html-crush
|
|
3
3
|
* @fileoverview Minifies HTML/CSS: valid or broken, pure or mixed with other languages
|
|
4
|
-
* @version 5.0.
|
|
4
|
+
* @version 5.0.10
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/html-crush/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
removeLineBreaks: false,
|
|
26
|
-
removeHTMLComments: false,
|
|
27
|
-
removeCSSComments: true,
|
|
28
|
-
reportProgressFunc: null,
|
|
29
|
-
reportProgressFuncFrom: 0,
|
|
30
|
-
reportProgressFuncTo: 100,
|
|
31
|
-
breakToTheLeftOf: ["</td", "<html", "</html", "<head", "</head", "<meta", "<link", "<table", "<script", "</script", "<!DOCTYPE", "<style", "</style", "<title", "<body", "@media", "</body", "<!--[if", "<!--<![endif", "<![endif]"],
|
|
32
|
-
mindTheInlineTags: ["a", "abbr", "acronym", "audio", "b", "bdi", "bdo", "big", "br", "button", "canvas", "cite", "code", "data", "datalist", "del", "dfn", "em", "embed", "i", "iframe", "img", "input", "ins", "kbd", "label", "map", "mark", "meter", "noscript", "object", "output", "picture", "progress", "q", "ruby", "s", "samp", "script", "select", "slot", "small", "span", "strong", "sub", "sup", "svg", "template", "textarea", "time", "u", "tt", "var", "video", "wbr"]
|
|
33
|
-
};
|
|
34
|
-
const applicableOpts = {
|
|
35
|
-
removeHTMLComments: false,
|
|
36
|
-
removeCSSComments: false
|
|
37
|
-
};
|
|
38
|
-
function isStr(something) {
|
|
39
|
-
return typeof something === "string";
|
|
40
|
-
}
|
|
41
|
-
function isLetter(something) {
|
|
42
|
-
return typeof something === "string" && something.toUpperCase() !== something.toLowerCase();
|
|
43
|
-
}
|
|
44
|
-
function crush(str, originalOpts) {
|
|
45
|
-
const start = Date.now();
|
|
46
|
-
if (!isStr(str)) {
|
|
47
|
-
if (str === undefined) {
|
|
48
|
-
throw new Error("html-crush: [THROW_ID_01] the first input argument is completely missing! It should be given as string.");
|
|
49
|
-
} else {
|
|
50
|
-
throw new Error(`html-crush: [THROW_ID_02] the first input argument must be string! It was given as "${typeof str}", equal to:\n${JSON.stringify(str, null, 4)}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (originalOpts && typeof originalOpts !== "object") {
|
|
54
|
-
throw new Error(`html-crush: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof originalOpts}, equal to ${JSON.stringify(originalOpts, null, 4)}`);
|
|
55
|
-
}
|
|
56
|
-
if (originalOpts && Array.isArray(originalOpts.breakToTheLeftOf) && originalOpts.breakToTheLeftOf.length) {
|
|
57
|
-
for (let z = 0, len = originalOpts.breakToTheLeftOf.length; z < len; z++) {
|
|
58
|
-
if (!isStr(originalOpts.breakToTheLeftOf[z])) {
|
|
59
|
-
throw new TypeError(`html-crush: [THROW_ID_05] the opts.breakToTheLeftOf array contains non-string elements! For example, element at index ${z} is of a type "${typeof originalOpts.breakToTheLeftOf[z]}" and is equal to:\n${JSON.stringify(originalOpts.breakToTheLeftOf[z], null, 4)}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const opts = { ...defaults,
|
|
64
|
-
...originalOpts
|
|
65
|
-
};
|
|
66
|
-
if (typeof opts.removeHTMLComments === "boolean") {
|
|
67
|
-
opts.removeHTMLComments = opts.removeHTMLComments ? 1 : 0;
|
|
68
|
-
}
|
|
69
|
-
let breakToTheLeftOfFirstLetters = "";
|
|
70
|
-
if (Array.isArray(opts.breakToTheLeftOf) && opts.breakToTheLeftOf.length) {
|
|
71
|
-
breakToTheLeftOfFirstLetters = [...new Set(opts.breakToTheLeftOf.map(val => val[0]))].join("");
|
|
72
|
-
}
|
|
73
|
-
let lastLinebreak = null;
|
|
74
|
-
let whitespaceStartedAt = null;
|
|
75
|
-
let nonWhitespaceCharMet = false;
|
|
76
|
-
let countCharactersPerLine = 0;
|
|
77
|
-
let cpl = 0;
|
|
78
|
-
let withinStyleTag = false;
|
|
79
|
-
let withinHTMLConditional = false;
|
|
80
|
-
let withinInlineStyle = null;
|
|
81
|
-
let styleCommentStartedAt = null;
|
|
82
|
-
let htmlCommentStartedAt = null;
|
|
83
|
-
let scriptStartedAt = null;
|
|
84
|
-
let doNothing;
|
|
85
|
-
let stageFrom = null;
|
|
86
|
-
let stageTo = null;
|
|
87
|
-
let stageAdd = null;
|
|
88
|
-
let tagName = null;
|
|
89
|
-
let tagNameStartsAt = null;
|
|
90
|
-
let leftTagName = null;
|
|
91
|
-
const CHARS_BREAK_ON_THE_RIGHT_OF_THEM = `>};`;
|
|
92
|
-
const CHARS_BREAK_ON_THE_LEFT_OF_THEM = `<`;
|
|
93
|
-
const CHARS_DONT_BREAK_ON_THE_LEFT_OF_THEM = `!`;
|
|
94
|
-
const DELETE_TIGHTLY_IF_ON_LEFT_IS = `>`;
|
|
95
|
-
const DELETE_TIGHTLY_IF_ON_RIGHT_IS = `<`;
|
|
96
|
-
const set = `{},:;<>~+`;
|
|
97
|
-
const DELETE_IN_STYLE_TIGHTLY_IF_ON_LEFT_IS = set;
|
|
98
|
-
const DELETE_IN_STYLE_TIGHTLY_IF_ON_RIGHT_IS = set;
|
|
99
|
-
let beginningOfAFile = true;
|
|
100
|
-
const len = str.length;
|
|
101
|
-
const midLen = Math.floor(len / 2);
|
|
102
|
-
const leavePercForLastStage = 0.01;
|
|
103
|
-
let ceil;
|
|
104
|
-
if (opts.reportProgressFunc) {
|
|
105
|
-
ceil = Math.floor(opts.reportProgressFuncTo - (opts.reportProgressFuncTo - opts.reportProgressFuncFrom) * leavePercForLastStage - opts.reportProgressFuncFrom);
|
|
106
|
-
}
|
|
107
|
-
let currentPercentageDone;
|
|
108
|
-
let lastPercentage = 0;
|
|
109
|
-
let lineEnding = `\n`;
|
|
110
|
-
if (str.includes(`\r\n`)) {
|
|
111
|
-
lineEnding = `\r\n`;
|
|
112
|
-
} else if (str.includes(`\r`)) {
|
|
113
|
-
lineEnding = `\r`;
|
|
114
|
-
}
|
|
115
|
-
if (len) {
|
|
116
|
-
for (let i = 0; i < len; i++) {
|
|
117
|
-
if (opts.reportProgressFunc) {
|
|
118
|
-
if (len > 1000 && len < 2000) {
|
|
119
|
-
if (i === midLen) {
|
|
120
|
-
opts.reportProgressFunc(Math.floor((opts.reportProgressFuncTo - opts.reportProgressFuncFrom) / 2));
|
|
121
|
-
}
|
|
122
|
-
} else if (len >= 2000) {
|
|
123
|
-
currentPercentageDone = opts.reportProgressFuncFrom + Math.floor(i / len * (ceil || 1));
|
|
124
|
-
if (currentPercentageDone !== lastPercentage) {
|
|
125
|
-
lastPercentage = currentPercentageDone;
|
|
126
|
-
opts.reportProgressFunc(currentPercentageDone);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
cpl++;
|
|
131
|
-
if (!doNothing && withinStyleTag && str[i] === "}" && str[i - 1] === "}") {
|
|
132
|
-
if (countCharactersPerLine + 1 >= opts.lineLengthLimit) {
|
|
133
|
-
finalIndexesToDelete.push(i, i, lineEnding);
|
|
134
|
-
countCharactersPerLine = 0;
|
|
135
|
-
} else {
|
|
136
|
-
stageFrom = i;
|
|
137
|
-
stageTo = i;
|
|
138
|
-
stageAdd = " ";
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (doNothing && typeof doNothing === "number" && i >= doNothing) {
|
|
142
|
-
doNothing = undefined;
|
|
143
|
-
}
|
|
144
|
-
if (scriptStartedAt !== null && str.startsWith("</script", i) && !isLetter(str[i + 8])) {
|
|
145
|
-
if ((opts.removeIndentations || opts.removeLineBreaks) && i > 0 && str[~-i] && !str[~-i].trim()) {
|
|
146
|
-
for (let y = i; y--;) {
|
|
147
|
-
if (str[y] === "\n" || str[y] === "\r" || str[y].trim()) {
|
|
148
|
-
if (y + 1 < i) {
|
|
149
|
-
finalIndexesToDelete.push(y + 1, i);
|
|
150
|
-
}
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
scriptStartedAt = null;
|
|
156
|
-
doNothing = false;
|
|
157
|
-
i += 8;
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
if (!doNothing && !withinStyleTag && str.startsWith("<script", i) && !isLetter(str[i + 7])) {
|
|
161
|
-
scriptStartedAt = i;
|
|
162
|
-
doNothing = true;
|
|
163
|
-
let whatToInsert = "";
|
|
164
|
-
if ((opts.removeLineBreaks || opts.removeIndentations) && whitespaceStartedAt !== null) {
|
|
165
|
-
if (whitespaceStartedAt > 0) {
|
|
166
|
-
whatToInsert = lineEnding;
|
|
167
|
-
}
|
|
168
|
-
finalIndexesToDelete.push(whitespaceStartedAt, i, whatToInsert);
|
|
169
|
-
}
|
|
170
|
-
whitespaceStartedAt = null;
|
|
171
|
-
lastLinebreak = null;
|
|
172
|
-
}
|
|
173
|
-
if (tagNameStartsAt !== null && tagName === null && !/\w/.test(str[i])
|
|
174
|
-
) {
|
|
175
|
-
tagName = str.slice(tagNameStartsAt, i);
|
|
176
|
-
const idxOnTheRight = right(str, ~-i);
|
|
177
|
-
if (typeof idxOnTheRight === "number" && str[idxOnTheRight] === ">" && !str[i].trim() && right(str, i)) {
|
|
178
|
-
finalIndexesToDelete.push(i, right(str, i));
|
|
179
|
-
} else if (idxOnTheRight && str[idxOnTheRight] === "/" && str[right(str, idxOnTheRight)] === ">") {
|
|
180
|
-
if (!str[i].trim() && right(str, i)) {
|
|
181
|
-
finalIndexesToDelete.push(i, right(str, i));
|
|
182
|
-
}
|
|
183
|
-
if (str[idxOnTheRight + 1] !== ">" && right(str, idxOnTheRight + 1)) {
|
|
184
|
-
finalIndexesToDelete.push(idxOnTheRight + 1, right(str, idxOnTheRight + 1));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (!doNothing && !withinStyleTag && !withinInlineStyle && str[~-i] === "<" && tagNameStartsAt === null) {
|
|
189
|
-
if (/\w/.test(str[i])) {
|
|
190
|
-
tagNameStartsAt = i;
|
|
191
|
-
} else if (str[right(str, ~-i)] === "/" && /\w/.test(str[right(str, right(str, ~-i))] || "")) {
|
|
192
|
-
tagNameStartsAt = right(str, right(str, ~-i));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (!doNothing && (withinStyleTag || withinInlineStyle) && styleCommentStartedAt !== null && str[i] === "*" && str[i + 1] === "/") {
|
|
196
|
-
[stageFrom, stageTo] = expander({
|
|
197
|
-
str,
|
|
198
|
-
from: styleCommentStartedAt,
|
|
199
|
-
to: i + 2,
|
|
200
|
-
ifLeftSideIncludesThisThenCropTightly: DELETE_IN_STYLE_TIGHTLY_IF_ON_LEFT_IS ,
|
|
201
|
-
ifRightSideIncludesThisThenCropTightly: DELETE_IN_STYLE_TIGHTLY_IF_ON_RIGHT_IS
|
|
202
|
-
});
|
|
203
|
-
styleCommentStartedAt = null;
|
|
204
|
-
if (stageFrom != null) {
|
|
205
|
-
finalIndexesToDelete.push(stageFrom, stageTo);
|
|
206
|
-
} else {
|
|
207
|
-
countCharactersPerLine += 1;
|
|
208
|
-
i += 1;
|
|
209
|
-
}
|
|
210
|
-
doNothing = i + 2;
|
|
211
|
-
}
|
|
212
|
-
if (!doNothing && (withinStyleTag || withinInlineStyle) && styleCommentStartedAt === null && str[i] === "/" && str[i + 1] === "*") {
|
|
213
|
-
if (!applicableOpts.removeCSSComments) {
|
|
214
|
-
applicableOpts.removeCSSComments = true;
|
|
215
|
-
}
|
|
216
|
-
if (opts.removeCSSComments) {
|
|
217
|
-
styleCommentStartedAt = i;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
if (withinHTMLConditional && str.startsWith("![endif", i + 1)) {
|
|
221
|
-
withinHTMLConditional = false;
|
|
222
|
-
}
|
|
223
|
-
if (!doNothing && !withinStyleTag && !withinInlineStyle && htmlCommentStartedAt !== null) {
|
|
224
|
-
let distanceFromHereToCommentEnding;
|
|
225
|
-
if (str.startsWith("-->", i)) {
|
|
226
|
-
distanceFromHereToCommentEnding = 3;
|
|
227
|
-
} else if (str[i] === ">" && str[i - 1] === "]") {
|
|
228
|
-
distanceFromHereToCommentEnding = 1;
|
|
229
|
-
}
|
|
230
|
-
if (distanceFromHereToCommentEnding) {
|
|
231
|
-
[stageFrom, stageTo] = expander({
|
|
232
|
-
str,
|
|
233
|
-
from: htmlCommentStartedAt,
|
|
234
|
-
to: i + distanceFromHereToCommentEnding
|
|
235
|
-
});
|
|
236
|
-
htmlCommentStartedAt = null;
|
|
237
|
-
if (stageFrom != null) {
|
|
238
|
-
if (opts.lineLengthLimit && cpl - (stageTo - stageFrom) >= opts.lineLengthLimit) {
|
|
239
|
-
finalIndexesToDelete.push(stageFrom, stageTo, lineEnding);
|
|
240
|
-
cpl = -distanceFromHereToCommentEnding;
|
|
241
|
-
} else {
|
|
242
|
-
finalIndexesToDelete.push(stageFrom, stageTo);
|
|
243
|
-
cpl -= stageTo - stageFrom;
|
|
244
|
-
}
|
|
245
|
-
} else {
|
|
246
|
-
countCharactersPerLine += distanceFromHereToCommentEnding - 1;
|
|
247
|
-
i += distanceFromHereToCommentEnding - 1;
|
|
248
|
-
}
|
|
249
|
-
doNothing = i + distanceFromHereToCommentEnding;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (!doNothing && !withinStyleTag && !withinInlineStyle && str.startsWith("<!--", i) && htmlCommentStartedAt === null) {
|
|
253
|
-
if (str.startsWith("[if", i + 4)) {
|
|
254
|
-
if (!withinHTMLConditional) {
|
|
255
|
-
withinHTMLConditional = true;
|
|
256
|
-
}
|
|
257
|
-
if (opts.removeHTMLComments === 2) {
|
|
258
|
-
htmlCommentStartedAt = i;
|
|
259
|
-
}
|
|
260
|
-
} else if (
|
|
261
|
-
opts.removeHTMLComments && (
|
|
262
|
-
!withinHTMLConditional || opts.removeHTMLComments === 2)) {
|
|
263
|
-
htmlCommentStartedAt = i;
|
|
264
|
-
}
|
|
265
|
-
if (!applicableOpts.removeHTMLComments) {
|
|
266
|
-
applicableOpts.removeHTMLComments = true;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
if (!doNothing && withinStyleTag && styleCommentStartedAt === null && str.startsWith("</style", i) && !isLetter(str[i + 7])) {
|
|
270
|
-
withinStyleTag = false;
|
|
271
|
-
} else if (!doNothing && !withinStyleTag && styleCommentStartedAt === null && str.startsWith("<style", i) && !isLetter(str[i + 6])) {
|
|
272
|
-
withinStyleTag = true;
|
|
273
|
-
if ((opts.removeLineBreaks || opts.removeIndentations) && opts.breakToTheLeftOf.includes("<style") && str.startsWith(` type="text/css">`, i + 6) && str[i + 24]) {
|
|
274
|
-
finalIndexesToDelete.push(i + 23, i + 23, lineEnding);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
if (!doNothing && !withinInlineStyle && `"'`.includes(str[i]) && str.endsWith("style=", i)) {
|
|
278
|
-
withinInlineStyle = i;
|
|
279
|
-
}
|
|
280
|
-
if (!doNothing && !str[i].trim()) {
|
|
281
|
-
if (whitespaceStartedAt === null) {
|
|
282
|
-
whitespaceStartedAt = i;
|
|
283
|
-
}
|
|
284
|
-
} else if (!doNothing && !((withinStyleTag || withinInlineStyle) && styleCommentStartedAt !== null)) {
|
|
285
|
-
if (whitespaceStartedAt !== null) {
|
|
286
|
-
if (opts.removeLineBreaks) {
|
|
287
|
-
countCharactersPerLine += 1;
|
|
288
|
-
}
|
|
289
|
-
if (beginningOfAFile) {
|
|
290
|
-
beginningOfAFile = false;
|
|
291
|
-
if (opts.removeIndentations || opts.removeLineBreaks) {
|
|
292
|
-
finalIndexesToDelete.push(0, i);
|
|
293
|
-
}
|
|
294
|
-
} else {
|
|
295
|
-
if (opts.removeIndentations && !opts.removeLineBreaks) {
|
|
296
|
-
if (!nonWhitespaceCharMet && lastLinebreak !== null && i > lastLinebreak) {
|
|
297
|
-
finalIndexesToDelete.push(lastLinebreak + 1, i);
|
|
298
|
-
} else if (whitespaceStartedAt + 1 < i) {
|
|
299
|
-
if (
|
|
300
|
-
str.endsWith("]>", whitespaceStartedAt) ||
|
|
301
|
-
str.endsWith("-->", whitespaceStartedAt) ||
|
|
302
|
-
str.startsWith("<![", i) ||
|
|
303
|
-
str.startsWith("<!--<![", i)) {
|
|
304
|
-
finalIndexesToDelete.push(whitespaceStartedAt, i);
|
|
305
|
-
} else if (str[whitespaceStartedAt] === " ") {
|
|
306
|
-
finalIndexesToDelete.push(whitespaceStartedAt + 1, i);
|
|
307
|
-
} else if (str[~-i] === " ") {
|
|
308
|
-
finalIndexesToDelete.push(whitespaceStartedAt, ~-i);
|
|
309
|
-
} else {
|
|
310
|
-
finalIndexesToDelete.push(whitespaceStartedAt, i, " ");
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
if (opts.removeLineBreaks || withinInlineStyle) {
|
|
315
|
-
if (breakToTheLeftOfFirstLetters.includes(str[i]) && matchRightIncl(str, i, opts.breakToTheLeftOf)) {
|
|
316
|
-
if (
|
|
317
|
-
!(`\r\n`.includes(str[~-i]) && whitespaceStartedAt === ~-i) &&
|
|
318
|
-
!(str[~-i] === "\n" && str[i - 2] === "\r" && whitespaceStartedAt === i - 2)) {
|
|
319
|
-
finalIndexesToDelete.push(whitespaceStartedAt, i, lineEnding);
|
|
320
|
-
}
|
|
321
|
-
stageFrom = null;
|
|
322
|
-
stageTo = null;
|
|
323
|
-
stageAdd = null;
|
|
324
|
-
whitespaceStartedAt = null;
|
|
325
|
-
countCharactersPerLine = 1;
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
let whatToAdd = " ";
|
|
329
|
-
if (
|
|
330
|
-
str[i] === "<" && matchRight(str, i, opts.mindTheInlineTags, {
|
|
331
|
-
cb: nextChar => !nextChar || !/\w/.test(nextChar)
|
|
332
|
-
})
|
|
333
|
-
) ; else if (str[~-whitespaceStartedAt] && DELETE_TIGHTLY_IF_ON_LEFT_IS.includes(str[~-whitespaceStartedAt]) && DELETE_TIGHTLY_IF_ON_RIGHT_IS.includes(str[i]) || (withinStyleTag || withinInlineStyle) && styleCommentStartedAt === null && (DELETE_IN_STYLE_TIGHTLY_IF_ON_LEFT_IS.includes(str[~-whitespaceStartedAt]) || DELETE_IN_STYLE_TIGHTLY_IF_ON_RIGHT_IS.includes(str[i])) || str.startsWith("!important", i) && !withinHTMLConditional || withinInlineStyle && (str[~-whitespaceStartedAt] === "'" || str[~-whitespaceStartedAt] === '"') || str[~-whitespaceStartedAt] === "}" && str.startsWith("</style", i) || str[i] === ">" && (`'"`.includes(str[left(str, i)]) || str[right(str, i)] === "<") || str[i] === "/" && str[right(str, i)] === ">") {
|
|
334
|
-
whatToAdd = "";
|
|
335
|
-
if (str[i] === "/" && str[i + 1] === ">" && right(str, i) && right(str, i) > i + 1) {
|
|
336
|
-
finalIndexesToDelete.push(i + 1, right(str, i));
|
|
337
|
-
countCharactersPerLine -= right(str, i) - i + 1;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
if (withinStyleTag && str[i] === "}" && whitespaceStartedAt && str[whitespaceStartedAt - 1] === "}") {
|
|
341
|
-
whatToAdd = " ";
|
|
342
|
-
}
|
|
343
|
-
if (whatToAdd && whatToAdd.length) {
|
|
344
|
-
countCharactersPerLine += 1;
|
|
345
|
-
}
|
|
346
|
-
if (!opts.lineLengthLimit) {
|
|
347
|
-
if (!(i === whitespaceStartedAt + 1 &&
|
|
348
|
-
whatToAdd === " ")) {
|
|
349
|
-
finalIndexesToDelete.push(whitespaceStartedAt, i, whatToAdd);
|
|
350
|
-
}
|
|
351
|
-
} else {
|
|
352
|
-
if (countCharactersPerLine >= opts.lineLengthLimit || !str[i + 1] || str[i] === ">" || str[i] === "/" && str[i + 1] === ">") {
|
|
353
|
-
if (countCharactersPerLine > opts.lineLengthLimit || countCharactersPerLine === opts.lineLengthLimit && str[i + 1] && str[i + 1].trim() && !CHARS_BREAK_ON_THE_RIGHT_OF_THEM.includes(str[i]) && !CHARS_BREAK_ON_THE_LEFT_OF_THEM.includes(str[i + 1])) {
|
|
354
|
-
whatToAdd = lineEnding;
|
|
355
|
-
countCharactersPerLine = 1;
|
|
356
|
-
}
|
|
357
|
-
if (countCharactersPerLine > opts.lineLengthLimit || !(whatToAdd === " " && i === whitespaceStartedAt + 1)) {
|
|
358
|
-
finalIndexesToDelete.push(whitespaceStartedAt, i, whatToAdd);
|
|
359
|
-
lastLinebreak = null;
|
|
360
|
-
}
|
|
361
|
-
stageFrom = null;
|
|
362
|
-
stageTo = null;
|
|
363
|
-
stageAdd = null;
|
|
364
|
-
} else if (stageFrom === null || whitespaceStartedAt < stageFrom) {
|
|
365
|
-
stageFrom = whitespaceStartedAt;
|
|
366
|
-
stageTo = i;
|
|
367
|
-
stageAdd = whatToAdd;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
whitespaceStartedAt = null;
|
|
373
|
-
if (!nonWhitespaceCharMet) {
|
|
374
|
-
nonWhitespaceCharMet = true;
|
|
375
|
-
}
|
|
376
|
-
} else {
|
|
377
|
-
if (beginningOfAFile) {
|
|
378
|
-
beginningOfAFile = false;
|
|
379
|
-
}
|
|
380
|
-
if (opts.removeLineBreaks) {
|
|
381
|
-
countCharactersPerLine += 1;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
if (!nonWhitespaceCharMet) {
|
|
385
|
-
nonWhitespaceCharMet = true;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
if (!doNothing && !beginningOfAFile && i !== 0 && opts.removeLineBreaks && (opts.lineLengthLimit || breakToTheLeftOfFirstLetters) && !str.startsWith("</a", i)) {
|
|
389
|
-
if (breakToTheLeftOfFirstLetters && matchRightIncl(str, i, opts.breakToTheLeftOf) && str.slice(0, i).trim() && (!str.startsWith("<![endif]", i) || !matchLeft(str, i, "<!--"))) {
|
|
390
|
-
finalIndexesToDelete.push(i, i, lineEnding);
|
|
391
|
-
stageFrom = null;
|
|
392
|
-
stageTo = null;
|
|
393
|
-
stageAdd = null;
|
|
394
|
-
countCharactersPerLine = 1;
|
|
395
|
-
continue;
|
|
396
|
-
} else if (opts.lineLengthLimit && countCharactersPerLine <= opts.lineLengthLimit) {
|
|
397
|
-
if (!str[i + 1] || CHARS_BREAK_ON_THE_LEFT_OF_THEM.includes(str[i]) && !CHARS_DONT_BREAK_ON_THE_LEFT_OF_THEM.includes(str[i]) || CHARS_BREAK_ON_THE_RIGHT_OF_THEM.includes(str[i]) || !str[i].trim()) {
|
|
398
|
-
if (stageFrom !== null && stageTo !== null && (stageFrom !== stageTo || stageAdd && stageAdd.length)) {
|
|
399
|
-
let whatToAdd = stageAdd;
|
|
400
|
-
if (str[i].trim() && str[i + 1] && str[i + 1].trim() && countCharactersPerLine + (stageAdd ? stageAdd.length : 0) > opts.lineLengthLimit) {
|
|
401
|
-
whatToAdd = lineEnding;
|
|
402
|
-
}
|
|
403
|
-
if (countCharactersPerLine + (whatToAdd ? whatToAdd.length : 0) > opts.lineLengthLimit || !(whatToAdd === " " && stageTo === stageFrom + 1 && str[stageFrom] === " ")) {
|
|
404
|
-
if (!(str[~-stageFrom] === "}" && str[stageTo] === "{")) {
|
|
405
|
-
finalIndexesToDelete.push(stageFrom, stageTo, whatToAdd);
|
|
406
|
-
lastLinebreak = null;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
if (str[i].trim() && (CHARS_BREAK_ON_THE_LEFT_OF_THEM.includes(str[i]) || str[~-i] && CHARS_BREAK_ON_THE_RIGHT_OF_THEM.includes(str[~-i])) && isStr(leftTagName) && (!tagName || !opts.mindTheInlineTags.includes(tagName)) && !(str[i] === "<" && matchRight(str, i, opts.mindTheInlineTags, {
|
|
411
|
-
cb: nextChar => !nextChar || !/\w/.test(nextChar)
|
|
412
|
-
})) && !(str[i] === "<" && matchRight(str, i, opts.mindTheInlineTags, {
|
|
413
|
-
trimCharsBeforeMatching: "/",
|
|
414
|
-
cb: nextChar => !nextChar || !/\w/.test(nextChar)
|
|
415
|
-
}))) {
|
|
416
|
-
stageFrom = i;
|
|
417
|
-
stageTo = i;
|
|
418
|
-
stageAdd = null;
|
|
419
|
-
} else if (styleCommentStartedAt === null && stageFrom !== null && (withinInlineStyle || !opts.mindTheInlineTags || !Array.isArray(opts.mindTheInlineTags) || Array.isArray(opts.mindTheInlineTags.length) && !opts.mindTheInlineTags.length || !isStr(tagName) || Array.isArray(opts.mindTheInlineTags) && opts.mindTheInlineTags.length && isStr(tagName) && !opts.mindTheInlineTags.includes(tagName)) && !(str[i] === "<" && matchRight(str, i, opts.mindTheInlineTags, {
|
|
420
|
-
trimCharsBeforeMatching: "/",
|
|
421
|
-
cb: nextChar => !nextChar || !/\w/.test(nextChar)
|
|
422
|
-
}))) {
|
|
423
|
-
stageFrom = null;
|
|
424
|
-
stageTo = null;
|
|
425
|
-
stageAdd = null;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
} else if (opts.lineLengthLimit) {
|
|
429
|
-
if (CHARS_BREAK_ON_THE_LEFT_OF_THEM.includes(str[i]) && !(str[i] === "<" && matchRight(str, i, opts.mindTheInlineTags, {
|
|
430
|
-
trimCharsBeforeMatching: "/",
|
|
431
|
-
cb: nextChar => !nextChar || !/\w/.test(nextChar)
|
|
432
|
-
}))) {
|
|
433
|
-
if (stageFrom !== null && stageTo !== null && (stageFrom !== stageTo || stageAdd && stageAdd.length)) {
|
|
434
|
-
const whatToAddLength = stageAdd && stageAdd.length ? stageAdd.length : 0;
|
|
435
|
-
if (countCharactersPerLine - (stageTo - stageFrom - whatToAddLength) - 1 > opts.lineLengthLimit) ; else {
|
|
436
|
-
finalIndexesToDelete.push(stageFrom, stageTo, stageAdd);
|
|
437
|
-
if (countCharactersPerLine - (stageTo - stageFrom - whatToAddLength) - 1 === opts.lineLengthLimit) {
|
|
438
|
-
finalIndexesToDelete.push(i, i, lineEnding);
|
|
439
|
-
countCharactersPerLine = 0;
|
|
440
|
-
}
|
|
441
|
-
stageFrom = null;
|
|
442
|
-
stageTo = null;
|
|
443
|
-
stageAdd = null;
|
|
444
|
-
}
|
|
445
|
-
} else {
|
|
446
|
-
finalIndexesToDelete.push(i, i, lineEnding);
|
|
447
|
-
countCharactersPerLine = 0;
|
|
448
|
-
}
|
|
449
|
-
} else if (str[i + 1] && CHARS_BREAK_ON_THE_RIGHT_OF_THEM.includes(str[i]) && isStr(tagName) && Array.isArray(opts.mindTheInlineTags) && opts.mindTheInlineTags.length && !opts.mindTheInlineTags.includes(tagName)) {
|
|
450
|
-
if (stageFrom !== null && stageTo !== null && (stageFrom !== stageTo || stageAdd && stageAdd.length)) ; else {
|
|
451
|
-
finalIndexesToDelete.push(i + 1, i + 1, lineEnding);
|
|
452
|
-
countCharactersPerLine = 0;
|
|
453
|
-
}
|
|
454
|
-
} else if (!str[i].trim()) ; else if (!str[i + 1]) {
|
|
455
|
-
if (stageFrom !== null && stageTo !== null && (stageFrom !== stageTo || stageAdd && stageAdd.length)) {
|
|
456
|
-
finalIndexesToDelete.push(stageFrom, stageTo, lineEnding);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
if (!doNothing && !beginningOfAFile && opts.removeLineBreaks && opts.lineLengthLimit && countCharactersPerLine >= opts.lineLengthLimit && stageFrom !== null && stageTo !== null && !CHARS_BREAK_ON_THE_RIGHT_OF_THEM.includes(str[i]) && !CHARS_BREAK_ON_THE_LEFT_OF_THEM.includes(str[i]) && !"/".includes(str[i])) {
|
|
462
|
-
if (!(countCharactersPerLine === opts.lineLengthLimit && str[i + 1] && !str[i + 1].trim())) {
|
|
463
|
-
let whatToAdd = lineEnding;
|
|
464
|
-
if (str[i + 1] && !str[i + 1].trim() && countCharactersPerLine === opts.lineLengthLimit) {
|
|
465
|
-
whatToAdd = stageAdd;
|
|
466
|
-
}
|
|
467
|
-
if (whatToAdd === lineEnding && !str[~-stageFrom].trim() && left(str, stageFrom)) {
|
|
468
|
-
stageFrom = left(str, stageFrom) + 1;
|
|
469
|
-
}
|
|
470
|
-
finalIndexesToDelete.push(stageFrom, stageTo, whatToAdd);
|
|
471
|
-
countCharactersPerLine = i - stageTo;
|
|
472
|
-
if (str[i].length) {
|
|
473
|
-
countCharactersPerLine += 1;
|
|
474
|
-
}
|
|
475
|
-
stageFrom = null;
|
|
476
|
-
stageTo = null;
|
|
477
|
-
stageAdd = null;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
if (!doNothing && str[i] === "\n" || str[i] === "\r" && (!str[i + 1] || str[i + 1] && str[i + 1] !== "\n")) {
|
|
481
|
-
lastLinebreak = i;
|
|
482
|
-
if (nonWhitespaceCharMet) {
|
|
483
|
-
nonWhitespaceCharMet = false;
|
|
484
|
-
}
|
|
485
|
-
if (!opts.removeLineBreaks && whitespaceStartedAt !== null && whitespaceStartedAt < i && str[i + 1] && str[i + 1] !== "\r" && str[i + 1] !== "\n") {
|
|
486
|
-
finalIndexesToDelete.push(whitespaceStartedAt, i);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
if (!str[i + 1]) {
|
|
490
|
-
if (withinStyleTag && styleCommentStartedAt !== null) {
|
|
491
|
-
finalIndexesToDelete.push(...expander({
|
|
492
|
-
str,
|
|
493
|
-
from: styleCommentStartedAt,
|
|
494
|
-
to: i,
|
|
495
|
-
ifLeftSideIncludesThisThenCropTightly: DELETE_IN_STYLE_TIGHTLY_IF_ON_LEFT_IS ,
|
|
496
|
-
ifRightSideIncludesThisThenCropTightly: DELETE_IN_STYLE_TIGHTLY_IF_ON_RIGHT_IS
|
|
497
|
-
}));
|
|
498
|
-
} else if (whitespaceStartedAt && str[i] !== "\n" && str[i] !== "\r") {
|
|
499
|
-
finalIndexesToDelete.push(whitespaceStartedAt, i + 1);
|
|
500
|
-
} else if (whitespaceStartedAt && (str[i] === "\r" && str[i + 1] === "\n" || str[i] === "\n" && str[i - 1] !== "\r")) {
|
|
501
|
-
finalIndexesToDelete.push(whitespaceStartedAt, i);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
if (!doNothing && withinInlineStyle && withinInlineStyle < i && str[withinInlineStyle] === str[i]) {
|
|
505
|
-
withinInlineStyle = null;
|
|
506
|
-
}
|
|
507
|
-
if (!doNothing && !withinStyleTag && str.startsWith("<pre", i) && !isLetter(str[i + 4])) {
|
|
508
|
-
const locationOfClosingPre = str.indexOf("</pre", i + 5);
|
|
509
|
-
if (locationOfClosingPre > 0) {
|
|
510
|
-
doNothing = locationOfClosingPre;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
if (!doNothing && !withinStyleTag && str.startsWith("<code", i) && !isLetter(str[i + 5])) {
|
|
514
|
-
const locationOfClosingCode = str.indexOf("</code", i + 5);
|
|
515
|
-
if (locationOfClosingCode > 0) {
|
|
516
|
-
doNothing = locationOfClosingCode;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
if (!doNothing && str.startsWith("<![CDATA[", i)) {
|
|
520
|
-
const locationOfClosingCData = str.indexOf("]]>", i + 9);
|
|
521
|
-
if (locationOfClosingCData > 0) {
|
|
522
|
-
doNothing = locationOfClosingCData;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
if (!doNothing && !withinStyleTag && !withinInlineStyle && tagNameStartsAt !== null && str[i] === ">") {
|
|
526
|
-
if (str[right(str, i)] === "<") {
|
|
527
|
-
leftTagName = tagName;
|
|
528
|
-
}
|
|
529
|
-
tagNameStartsAt = null;
|
|
530
|
-
tagName = null;
|
|
531
|
-
}
|
|
532
|
-
if (str[i] === "<" && leftTagName !== null) {
|
|
533
|
-
leftTagName = null;
|
|
534
|
-
}
|
|
535
|
-
if (withinStyleTag && str[i] === "{" && str[i + 1] === "{" && str.indexOf("}}") !== -1) {
|
|
536
|
-
doNothing = str.indexOf("}}") + 2;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
if (finalIndexesToDelete.current()) {
|
|
540
|
-
const ranges = finalIndexesToDelete.current();
|
|
541
|
-
finalIndexesToDelete.wipe();
|
|
542
|
-
const startingPercentageDone = opts.reportProgressFuncTo - (opts.reportProgressFuncTo - opts.reportProgressFuncFrom) * leavePercForLastStage;
|
|
543
|
-
const res = rApply(str, ranges, applyPercDone => {
|
|
544
|
-
if (opts.reportProgressFunc && len >= 2000) {
|
|
545
|
-
currentPercentageDone = Math.floor(startingPercentageDone + (opts.reportProgressFuncTo - startingPercentageDone) * (applyPercDone / 100));
|
|
546
|
-
if (currentPercentageDone !== lastPercentage) {
|
|
547
|
-
lastPercentage = currentPercentageDone;
|
|
548
|
-
opts.reportProgressFunc(currentPercentageDone);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
const resLen = res.length;
|
|
553
|
-
return {
|
|
554
|
-
log: {
|
|
555
|
-
timeTakenInMilliseconds: Date.now() - start,
|
|
556
|
-
originalLength: len,
|
|
557
|
-
cleanedLength: resLen,
|
|
558
|
-
bytesSaved: Math.max(len - resLen, 0),
|
|
559
|
-
percentageReducedOfOriginal: len ? Math.round(Math.max(len - resLen, 0) * 100 / len) : 0
|
|
560
|
-
},
|
|
561
|
-
ranges,
|
|
562
|
-
applicableOpts,
|
|
563
|
-
result: res
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
return {
|
|
568
|
-
log: {
|
|
569
|
-
timeTakenInMilliseconds: Date.now() - start,
|
|
570
|
-
originalLength: len,
|
|
571
|
-
cleanedLength: len,
|
|
572
|
-
bytesSaved: 0,
|
|
573
|
-
percentageReducedOfOriginal: 0
|
|
574
|
-
},
|
|
575
|
-
applicableOpts,
|
|
576
|
-
ranges: null,
|
|
577
|
-
result: str
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
export { crush, defaults, version };
|
|
10
|
+
import{rApply as ne}from"ranges-apply";import{Ranges as le}from"ranges-push";import{matchLeft as oe,matchRight as F,matchRightIncl as X}from"string-match-left-right";import{expander as _}from"string-range-expander";import{left as G,right as a}from"string-left-right";var Y="5.0.10";var ge=Y,$=new le({limitToBeAddedWhitespace:!0}),te={lineLengthLimit:500,removeIndentations:!0,removeLineBreaks:!1,removeHTMLComments:!1,removeCSSComments:!0,reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,breakToTheLeftOf:["</td","<html","</html","<head","</head","<meta","<link","<table","<script","<\/script","<!DOCTYPE","<style","</style","<title","<body","@media","</body","<!--[if","<!--<![endif","<![endif]"],mindTheInlineTags:["a","abbr","acronym","audio","b","bdi","bdo","big","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","label","map","mark","meter","noscript","object","output","picture","progress","q","ruby","s","samp","script","select","slot","small","span","strong","sub","sup","svg","template","textarea","time","u","tt","var","video","wbr"]};function y(n){return typeof n=="string"}function A(n){return typeof n=="string"&&n.toUpperCase()!==n.toLowerCase()}function ce(n,E){let W=Date.now();if(!y(n))throw n===void 0?new Error("html-crush: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`html-crush: [THROW_ID_02] the first input argument must be string! It was given as "${typeof n}", equal to:
|
|
11
|
+
${JSON.stringify(n,null,4)}`);if(E&&typeof E!="object")throw new Error(`html-crush: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof E}, equal to ${JSON.stringify(E,null,4)}`);if(E&&Array.isArray(E.breakToTheLeftOf)&&E.breakToTheLeftOf.length){for(let e=0,w=E.breakToTheLeftOf.length;e<w;e++)if(!y(E.breakToTheLeftOf[e]))throw new TypeError(`html-crush: [THROW_ID_05] the opts.breakToTheLeftOf array contains non-string elements! For example, element at index ${e} is of a type "${typeof E.breakToTheLeftOf[e]}" and is equal to:
|
|
12
|
+
${JSON.stringify(E.breakToTheLeftOf[e],null,4)}`)}let l={...te,...E};typeof l.removeHTMLComments=="boolean"&&(l.removeHTMLComments=l.removeHTMLComments?1:0);let H="";Array.isArray(l.breakToTheLeftOf)&&l.breakToTheLeftOf.length&&(H=[...new Set(l.breakToTheLeftOf.map(e=>e[0]))].join(""));let D={removeHTMLComments:!1,removeCSSComments:!1},S=null,i=null,p=!1,m=0,M=0,g=!1,V=!1,c=null,f=null,C=null,U=null,s,t=null,u=null,r=null,T=null,L=null,v=null,P=">};",I="<",K="!",q=">",z="<",B="{},:;<>~+",k=B,J=B,O=!0,h=n.length,Q=Math.floor(h/2),x=.01,j;l.reportProgressFunc&&(j=Math.floor(l.reportProgressFuncTo-(l.reportProgressFuncTo-l.reportProgressFuncFrom)*x-l.reportProgressFuncFrom));let d,R=0,b=`
|
|
13
|
+
`;if(n.includes(`\r
|
|
14
|
+
`)?b=`\r
|
|
15
|
+
`:n.includes("\r")&&(b="\r"),h){for(let e=0;e<h;e++){if(l.reportProgressFunc&&(h>1e3&&h<2e3?e===Q&&l.reportProgressFunc(Math.floor((l.reportProgressFuncTo-l.reportProgressFuncFrom)/2)):h>=2e3&&(d=l.reportProgressFuncFrom+Math.floor(e/h*(j||1)),d!==R&&(R=d,l.reportProgressFunc(d)))),M++,!s&&g&&n[e]==="}"&&n[e-1]==="}"&&(m+1>=l.lineLengthLimit?($.push(e,e,b),m=0):(t=e,u=e,r=" ")),s&&typeof s=="number"&&e>=s&&(s=void 0),U!==null&&n.startsWith("<\/script",e)&&!A(n[e+8])){if((l.removeIndentations||l.removeLineBreaks)&&e>0&&n[~-e]&&!n[~-e].trim()){for(let o=e;o--;)if(n[o]===`
|
|
16
|
+
`||n[o]==="\r"||n[o].trim()){o+1<e&&$.push(o+1,e);break}}U=null,s=!1,e+=8;continue}if(!s&&!g&&n.startsWith("<script",e)&&!A(n[e+7])){U=e,s=!0;let o="";(l.removeLineBreaks||l.removeIndentations)&&i!==null&&(i>0&&(o=b),$.push(i,e,o)),i=null,S=null}if(L!==null&&T===null&&!/\w/.test(n[e])){T=n.slice(L,e);let o=a(n,~-e);typeof o=="number"&&n[o]===">"&&!n[e].trim()&&a(n,e)?$.push(e,a(n,e)):o&&n[o]==="/"&&n[a(n,o)]===">"&&(!n[e].trim()&&a(n,e)&&$.push(e,a(n,e)),n[o+1]!==">"&&a(n,o+1)&&$.push(o+1,a(n,o+1)))}if(!s&&!g&&!c&&n[~-e]==="<"&&L===null&&(/\w/.test(n[e])?L=e:n[a(n,~-e)]==="/"&&/\w/.test(n[a(n,a(n,~-e))]||"")&&(L=a(n,a(n,~-e)))),!s&&(g||c)&&f!==null&&n[e]==="*"&&n[e+1]==="/"&&([t,u]=_({str:n,from:f,to:e+2,ifLeftSideIncludesThisThenCropTightly:k||"",ifRightSideIncludesThisThenCropTightly:J||""}),f=null,t!=null?$.push(t,u):(m+=1,e+=1),s=e+2),!s&&(g||c)&&f===null&&n[e]==="/"&&n[e+1]==="*"&&(D.removeCSSComments||(D.removeCSSComments=!0),l.removeCSSComments&&(f=e)),V&&n.startsWith("![endif",e+1)&&(V=!1),!s&&!g&&!c&&C!==null){let o;n.startsWith("-->",e)?o=3:n[e]===">"&&n[e-1]==="]"&&(o=1),o&&([t,u]=_({str:n,from:C,to:e+o}),C=null,t!=null?l.lineLengthLimit&&M-(u-t)>=l.lineLengthLimit?($.push(t,u,b),M=-o):($.push(t,u),M-=u-t):(m+=o-1,e+=o-1),s=e+o)}if(!s&&!g&&!c&&(n.startsWith("<!--",e)||l.removeHTMLComments===2&&n.startsWith("<![endif",e))&&C===null&&(n.startsWith("[if",e+4)?(V||(V=!0),l.removeHTMLComments===2&&(C=e)):l.removeHTMLComments&&(!V||l.removeHTMLComments===2)&&(C=e),D.removeHTMLComments||(D.removeHTMLComments=!0)),!s&&g&&f===null&&n.startsWith("</style",e)&&!A(n[e+7])?g=!1:!s&&!g&&f===null&&n.startsWith("<style",e)&&!A(n[e+6])&&(g=!0,(l.removeLineBreaks||l.removeIndentations)&&l.breakToTheLeftOf.includes("<style")&&n.startsWith(' type="text/css">',e+6)&&n[e+24]&&$.push(e+23,e+23,b)),!s&&!c&&`"'`.includes(n[e])&&n.endsWith("style=",e)&&(c=e),!s&&!n[e].trim())i===null&&(i=e);else if(!s&&!((g||c)&&f!==null)){if(i!==null){if(l.removeLineBreaks&&(m+=1),O)O=!1,(l.removeIndentations||l.removeLineBreaks)&&$.push(0,e);else if(l.removeIndentations&&!l.removeLineBreaks&&(!p&&S!==null&&e>S?$.push(S+1,e):i+1<e&&(n.endsWith("]>",i)||n.endsWith("-->",i)||n.startsWith("<![",e)||n.startsWith("<!--<![",e)?$.push(i,e):n[i]===" "?$.push(i+1,e):n[~-e]===" "?$.push(i,~-e):$.push(i,e," "))),l.removeLineBreaks||c){if(H.includes(n[e])&&X(n,e,l.breakToTheLeftOf)){!(`\r
|
|
17
|
+
`.includes(n[~-e])&&i===~-e)&&!(n[~-e]===`
|
|
18
|
+
`&&n[e-2]==="\r"&&i===e-2)&&$.push(i,e,b),t=null,u=null,r=null,i=null,m=1;continue}let o=" ";n[e]==="<"&&F(n,e,l.mindTheInlineTags,{cb:N=>!N||!/\w/.test(N)})||(n[~-i]&&q.includes(n[~-i])&&z.includes(n[e])||(g||c)&&f===null&&(k.includes(n[~-i])||J.includes(n[e]))||n.startsWith("!important",e)&&!V||c&&(n[~-i]==="'"||n[~-i]==='"')||n[~-i]==="}"&&n.startsWith("</style",e)||n[e]===">"&&(`'"`.includes(n[G(n,e)])||n[a(n,e)]==="<")||n[e]==="/"&&n[a(n,e)]===">")&&(o="",n[e]==="/"&&n[e+1]===">"&&a(n,e)&&a(n,e)>e+1&&($.push(e+1,a(n,e)),m-=a(n,e)-e+1)),g&&n[e]==="}"&&i&&n[i-1]==="}"&&(o=" "),o?.length&&(m+=1),l.lineLengthLimit?m>=l.lineLengthLimit||!n[e+1]||n[e]===">"||n[e]==="/"&&n[e+1]===">"?((m>l.lineLengthLimit||m===l.lineLengthLimit&&n[e+1]&&n[e+1].trim()&&!P.includes(n[e])&&!I.includes(n[e+1]))&&(o=b,m=1),(m>l.lineLengthLimit||!(o===" "&&e===i+1))&&($.push(i,e,o),S=null),t=null,u=null,r=null):(t===null||i<t)&&(t=i,u=e,r=o):e===i+1&&o===" "||$.push(i,e,o)}i=null,p||(p=!0)}else O&&(O=!1),l.removeLineBreaks&&(m+=1);p||(p=!0)}if(!s&&!O&&e!==0&&l.removeLineBreaks&&(l.lineLengthLimit||H)&&!n.startsWith("</a",e)){if(H&&X(n,e,l.breakToTheLeftOf)&&n.slice(0,e).trim()&&(!n.startsWith("<![endif]",e)||!oe(n,e,"<!--"))){$.push(e,e,b),t=null,u=null,r=null,m=1;continue}else if(l.lineLengthLimit&&m<=l.lineLengthLimit){if(!n[e+1]||I.includes(n[e])&&!K.includes(n[e])||P.includes(n[e])||!n[e].trim()){if(t!==null&&u!==null&&(t!==u||r?.length)){let o=r;n[e].trim()&&n[e+1]&&n[e+1].trim()&&m+(r?r.length:0)>l.lineLengthLimit&&(o=b),(m+(o?o.length:0)>l.lineLengthLimit||!(o===" "&&u===t+1&&n[t]===" "))&&(n[~-t]==="}"&&n[u]==="{"||($.push(t,u,o),S=null))}n[e].trim()&&(I.includes(n[e])||n[~-e]&&P.includes(n[~-e]))&&y(v)&&(!T||!l.mindTheInlineTags.includes(T))&&!(n[e]==="<"&&F(n,e,l.mindTheInlineTags,{cb:o=>!o||!/\w/.test(o)}))&&!(n[e]==="<"&&F(n,e,l.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:o=>!o||!/\w/.test(o)}))?(t=e,u=e,r=null):f===null&&t!==null&&(c||!l.mindTheInlineTags||!Array.isArray(l.mindTheInlineTags)||Array.isArray(l.mindTheInlineTags.length)&&!l.mindTheInlineTags.length||!y(T)||Array.isArray(l.mindTheInlineTags)&&l.mindTheInlineTags.length&&y(T)&&!l.mindTheInlineTags.includes(T))&&!(n[e]==="<"&&F(n,e,l.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:o=>!o||!/\w/.test(o)}))&&(t=null,u=null,r=null)}}else if(l.lineLengthLimit)if(I.includes(n[e])&&!(n[e]==="<"&&F(n,e,l.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:o=>!o||!/\w/.test(o)})))if(t!==null&&u!==null&&(t!==u||r?.length)){let o=r?.length?r.length:0;m-(u-t-o)-1>l.lineLengthLimit||($.push(t,u,r),m-(u-t-o)-1===l.lineLengthLimit&&($.push(e,e,b),m=0),t=null,u=null,r=null)}else $.push(e,e,b),m=0;else n[e+1]&&P.includes(n[e])&&y(T)&&Array.isArray(l.mindTheInlineTags)&&l.mindTheInlineTags.length&&!l.mindTheInlineTags.includes(T)?t!==null&&u!==null&&(t!==u||r?.length)||($.push(e+1,e+1,b),m=0):n[e].trim()&&(n[e+1]||t!==null&&u!==null&&(t!==u||r?.length)&&$.push(t,u,b))}if(!s&&!O&&l.removeLineBreaks&&l.lineLengthLimit&&m>=l.lineLengthLimit&&t!==null&&u!==null&&!P.includes(n[e])&&!I.includes(n[e])&&!"/".includes(n[e])&&!(m===l.lineLengthLimit&&n[e+1]&&!n[e+1].trim())){let o=b;n[e+1]&&!n[e+1].trim()&&m===l.lineLengthLimit&&(o=r),o===b&&!n[~-t].trim()&&G(n,t)&&(t=G(n,t)+1),$.push(t,u,o),m=e-u,n[e].length&&(m+=1),t=null,u=null,r=null}if((!s&&n[e]===`
|
|
19
|
+
`||n[e]==="\r"&&(!n[e+1]||n[e+1]&&n[e+1]!==`
|
|
20
|
+
`))&&(S=e,p&&(p=!1),!l.removeLineBreaks&&i!==null&&i<e&&n[e+1]&&n[e+1]!=="\r"&&n[e+1]!==`
|
|
21
|
+
`&&$.push(i,e)),n[e+1]||(g&&f!==null?$.push(..._({str:n,from:f,to:e,ifLeftSideIncludesThisThenCropTightly:k||"",ifRightSideIncludesThisThenCropTightly:J||""})):i&&n[e]!==`
|
|
22
|
+
`&&n[e]!=="\r"?$.push(i,e+1):i&&(n[e]==="\r"&&n[e+1]===`
|
|
23
|
+
`||n[e]===`
|
|
24
|
+
`&&n[e-1]!=="\r")&&$.push(i,e)),!s&&c&&c<e&&n[c]===n[e]&&(c=null),!s&&!g&&n.startsWith("<pre",e)&&!A(n[e+4])){let o=n.indexOf("</pre",e+5);o>0&&(s=o)}if(!s&&!g&&n.startsWith("<code",e)&&!A(n[e+5])){let o=n.indexOf("</code",e+5);o>0&&(s=o)}if(!s&&n.startsWith("<![CDATA[",e)){let o=n.indexOf("]]>",e+9);o>0&&(s=o)}!s&&!g&&!c&&L!==null&&n[e]===">"&&(n[a(n,e)]==="<"&&(v=T),L=null,T=null),n[e]==="<"&&v!==null&&(v=null),g&&n[e]==="{"&&n[e+1]==="{"&&n.indexOf("}}")!==-1&&(s=n.indexOf("}}")+2);let w=!0}if($.current()){let e=$.current();$.wipe();let w=l.reportProgressFuncTo-(l.reportProgressFuncTo-l.reportProgressFuncFrom)*x,o=ne(n,e,Z=>{l.reportProgressFunc&&h>=2e3&&(d=Math.floor(w+(l.reportProgressFuncTo-w)*(Z/100)),d!==R&&(R=d,l.reportProgressFunc(d)))}),N=o.length;return{log:{timeTakenInMilliseconds:Date.now()-W,originalLength:h,cleanedLength:N,bytesSaved:Math.max(h-N,0),percentageReducedOfOriginal:h?Math.round(Math.max(h-N,0)*100/h):0},ranges:e,applicableOpts:D,result:o}}}return{log:{timeTakenInMilliseconds:Date.now()-W,originalLength:h,cleanedLength:h,bytesSaved:0,percentageReducedOfOriginal:0},applicableOpts:D,ranges:null,result:n}}export{ce as crush,te as defaults,ge as version};
|
package/dist/html-crush.umd.js
CHANGED
|
@@ -1,86 +1,113 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name html-crush
|
|
3
3
|
* @fileoverview Minifies HTML/CSS: valid or broken, pure or mixed with other languages
|
|
4
|
-
* @version 5.0.
|
|
4
|
+
* @version 5.0.10
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/html-crush/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).htmlCrush={})}(this,(function(e){"use strict";
|
|
10
|
+
var htmlCrush=(()=>{var ln=Object.create;var ee=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var an=Object.getOwnPropertyNames,ke=Object.getOwnPropertySymbols,un=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty,gn=Object.prototype.propertyIsEnumerable;var ye=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,S=(e,t)=>{for(var r in t||(t={}))Be.call(t,r)&&ye(e,r,t[r]);if(ke)for(var r of ke(t))gn.call(t,r)&&ye(e,r,t[r]);return e};var Ue=e=>ee(e,"__esModule",{value:!0});var Ge=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),cn=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},qe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of an(t))!Be.call(e,a)&&(r||a!=="default")&&ee(e,a,{get:()=>t[a],enumerable:!(n=sn(t,a))||n.enumerable});return e},Ke=(e,t)=>qe(Ue(ee(e!=null?ln(un(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),fn=(e=>(t,r)=>e&&e.get(t)||(r=qe(Ue({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var Ee=(e,t,r)=>(ye(e,typeof t!="symbol"?t+"":t,r),r);var ut=Ge((Ci,at)=>{var En="[object Object]";function Sn(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function wn(e,t){return function(r){return e(t(r))}}var On=Function.prototype,lt=Object.prototype,st=On.toString,Ln=lt.hasOwnProperty,Dn=st.call(Object),An=lt.toString,Cn=wn(Object.getPrototypeOf,Object);function In(e){return!!e&&typeof e=="object"}function _n(e){if(!In(e)||An.call(e)!=En||Sn(e))return!1;var t=Cn(e);if(t===null)return!0;var r=Ln.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&st.call(r)==Dn}at.exports=_n});var zt=Ge((ie,q)=>{var Nn=200,gt="__lodash_hash_undefined__",ct=9007199254740991,De="[object Arguments]",vn="[object Array]",ft="[object Boolean]",mt="[object Date]",Vn="[object Error]",Ae="[object Function]",ht="[object GeneratorFunction]",ue="[object Map]",$t="[object Number]",Ce="[object Object]",pt="[object Promise]",bt="[object RegExp]",ge="[object Set]",dt="[object String]",Tt="[object Symbol]",Ie="[object WeakMap]",yt="[object ArrayBuffer]",ce="[object DataView]",Et="[object Float32Array]",St="[object Float64Array]",wt="[object Int8Array]",Ot="[object Int16Array]",Lt="[object Int32Array]",Dt="[object Uint8Array]",At="[object Uint8ClampedArray]",Ct="[object Uint16Array]",It="[object Uint32Array]",Rn=/[\\^$.*+?()[\]{}|]/g,Mn=/\w*$/,Pn=/^\[object .+?Constructor\]$/,Hn=/^(?:0|[1-9]\d*)$/,w={};w[De]=w[vn]=w[yt]=w[ce]=w[ft]=w[mt]=w[Et]=w[St]=w[wt]=w[Ot]=w[Lt]=w[ue]=w[$t]=w[Ce]=w[bt]=w[ge]=w[dt]=w[Tt]=w[Dt]=w[At]=w[Ct]=w[It]=!0;w[Vn]=w[Ae]=w[Ie]=!1;var Fn=typeof global=="object"&&global&&global.Object===Object&&global,xn=typeof self=="object"&&self&&self.Object===Object&&self,N=Fn||xn||Function("return this")(),_t=typeof ie=="object"&&ie&&!ie.nodeType&&ie,Nt=_t&&typeof q=="object"&&q&&!q.nodeType&&q,Wn=Nt&&Nt.exports===_t;function Jn(e,t){return e.set(t[0],t[1]),e}function jn(e,t){return e.add(t),e}function kn(e,t){for(var r=-1,n=e?e.length:0;++r<n&&t(e[r],r,e)!==!1;);return e}function Bn(e,t){for(var r=-1,n=t.length,a=e.length;++r<n;)e[a+r]=t[r];return e}function vt(e,t,r,n){var a=-1,o=e?e.length:0;for(n&&o&&(r=e[++a]);++a<o;)r=t(r,e[a],a,e);return r}function Un(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function Gn(e,t){return e==null?void 0:e[t]}function Vt(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function Rt(e){var t=-1,r=Array(e.size);return e.forEach(function(n,a){r[++t]=[a,n]}),r}function _e(e,t){return function(r){return e(t(r))}}function Mt(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var qn=Array.prototype,Kn=Function.prototype,fe=Object.prototype,Ne=N["__core-js_shared__"],Pt=function(){var e=/[^.]+$/.exec(Ne&&Ne.keys&&Ne.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ht=Kn.toString,H=fe.hasOwnProperty,me=fe.toString,Yn=RegExp("^"+Ht.call(H).replace(Rn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ft=Wn?N.Buffer:void 0,xt=N.Symbol,Wt=N.Uint8Array,Xn=_e(Object.getPrototypeOf,Object),zn=Object.create,Zn=fe.propertyIsEnumerable,Qn=qn.splice,Jt=Object.getOwnPropertySymbols,er=Ft?Ft.isBuffer:void 0,tr=_e(Object.keys,Object),ve=G(N,"DataView"),ne=G(N,"Map"),Ve=G(N,"Promise"),Re=G(N,"Set"),Me=G(N,"WeakMap"),re=G(Object,"create"),nr=W(ve),rr=W(ne),ir=W(Ve),or=W(Re),lr=W(Me),jt=xt?xt.prototype:void 0,kt=jt?jt.valueOf:void 0;function F(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function sr(){this.__data__=re?re(null):{}}function ar(e){return this.has(e)&&delete this.__data__[e]}function ur(e){var t=this.__data__;if(re){var r=t[e];return r===gt?void 0:r}return H.call(t,e)?t[e]:void 0}function gr(e){var t=this.__data__;return re?t[e]!==void 0:H.call(t,e)}function cr(e,t){var r=this.__data__;return r[e]=re&&t===void 0?gt:t,this}F.prototype.clear=sr;F.prototype.delete=ar;F.prototype.get=ur;F.prototype.has=gr;F.prototype.set=cr;function v(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function fr(){this.__data__=[]}function mr(e){var t=this.__data__,r=he(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Qn.call(t,r,1),!0}function hr(e){var t=this.__data__,r=he(t,e);return r<0?void 0:t[r][1]}function $r(e){return he(this.__data__,e)>-1}function pr(e,t){var r=this.__data__,n=he(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}v.prototype.clear=fr;v.prototype.delete=mr;v.prototype.get=hr;v.prototype.has=$r;v.prototype.set=pr;function B(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function br(){this.__data__={hash:new F,map:new(ne||v),string:new F}}function dr(e){return $e(this,e).delete(e)}function Tr(e){return $e(this,e).get(e)}function yr(e){return $e(this,e).has(e)}function Er(e,t){return $e(this,e).set(e,t),this}B.prototype.clear=br;B.prototype.delete=dr;B.prototype.get=Tr;B.prototype.has=yr;B.prototype.set=Er;function U(e){this.__data__=new v(e)}function Sr(){this.__data__=new v}function wr(e){return this.__data__.delete(e)}function Or(e){return this.__data__.get(e)}function Lr(e){return this.__data__.has(e)}function Dr(e,t){var r=this.__data__;if(r instanceof v){var n=r.__data__;if(!ne||n.length<Nn-1)return n.push([e,t]),this;r=this.__data__=new B(n)}return r.set(e,t),this}U.prototype.clear=Sr;U.prototype.delete=wr;U.prototype.get=Or;U.prototype.has=Lr;U.prototype.set=Dr;function Ar(e,t){var r=Fe(e)||zr(e)?Un(e.length,String):[],n=r.length,a=!!n;for(var o in e)(t||H.call(e,o))&&!(a&&(o=="length"||qr(o,n)))&&r.push(o);return r}function Bt(e,t,r){var n=e[t];(!(H.call(e,t)&&Kt(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function he(e,t){for(var r=e.length;r--;)if(Kt(e[r][0],t))return r;return-1}function Cr(e,t){return e&&Ut(t,xe(t),e)}function Pe(e,t,r,n,a,o,u){var s;if(n&&(s=o?n(e,a,o,u):n(e)),s!==void 0)return s;if(!pe(e))return e;var c=Fe(e);if(c){if(s=Br(e),!t)return Jr(e,s)}else{var l=x(e),$=l==Ae||l==ht;if(Qr(e))return Rr(e,t);if(l==Ce||l==De||$&&!o){if(Vt(e))return o?e:{};if(s=Ur($?{}:e),!t)return jr(e,Cr(s,e))}else{if(!w[l])return o?e:{};s=Gr(e,l,Pe,t)}}u||(u=new U);var h=u.get(e);if(h)return h;if(u.set(e,s),!c)var T=r?kr(e):xe(e);return kn(T||e,function(m,f){T&&(f=m,m=e[f]),Bt(s,f,Pe(m,t,r,n,f,e,u))}),s}function Ir(e){return pe(e)?zn(e):{}}function _r(e,t,r){var n=t(e);return Fe(e)?n:Bn(n,r(e))}function Nr(e){return me.call(e)}function vr(e){if(!pe(e)||Yr(e))return!1;var t=Xt(e)||Vt(e)?Yn:Pn;return t.test(W(e))}function Vr(e){if(!qt(e))return tr(e);var t=[];for(var r in Object(e))H.call(e,r)&&r!="constructor"&&t.push(r);return t}function Rr(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}function He(e){var t=new e.constructor(e.byteLength);return new Wt(t).set(new Wt(e)),t}function Mr(e,t){var r=t?He(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}function Pr(e,t,r){var n=t?r(Rt(e),!0):Rt(e);return vt(n,Jn,new e.constructor)}function Hr(e){var t=new e.constructor(e.source,Mn.exec(e));return t.lastIndex=e.lastIndex,t}function Fr(e,t,r){var n=t?r(Mt(e),!0):Mt(e);return vt(n,jn,new e.constructor)}function xr(e){return kt?Object(kt.call(e)):{}}function Wr(e,t){var r=t?He(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Jr(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}function Ut(e,t,r,n){r||(r={});for(var a=-1,o=t.length;++a<o;){var u=t[a],s=n?n(r[u],e[u],u,r,e):void 0;Bt(r,u,s===void 0?e[u]:s)}return r}function jr(e,t){return Ut(e,Gt(e),t)}function kr(e){return _r(e,xe,Gt)}function $e(e,t){var r=e.__data__;return Kr(t)?r[typeof t=="string"?"string":"hash"]:r.map}function G(e,t){var r=Gn(e,t);return vr(r)?r:void 0}var Gt=Jt?_e(Jt,Object):ni,x=Nr;(ve&&x(new ve(new ArrayBuffer(1)))!=ce||ne&&x(new ne)!=ue||Ve&&x(Ve.resolve())!=pt||Re&&x(new Re)!=ge||Me&&x(new Me)!=Ie)&&(x=function(e){var t=me.call(e),r=t==Ce?e.constructor:void 0,n=r?W(r):void 0;if(n)switch(n){case nr:return ce;case rr:return ue;case ir:return pt;case or:return ge;case lr:return Ie}return t});function Br(e){var t=e.length,r=e.constructor(t);return t&&typeof e[0]=="string"&&H.call(e,"index")&&(r.index=e.index,r.input=e.input),r}function Ur(e){return typeof e.constructor=="function"&&!qt(e)?Ir(Xn(e)):{}}function Gr(e,t,r,n){var a=e.constructor;switch(t){case yt:return He(e);case ft:case mt:return new a(+e);case ce:return Mr(e,n);case Et:case St:case wt:case Ot:case Lt:case Dt:case At:case Ct:case It:return Wr(e,n);case ue:return Pr(e,n,r);case $t:case dt:return new a(e);case bt:return Hr(e);case ge:return Fr(e,n,r);case Tt:return xr(e)}}function qr(e,t){return t=t==null?ct:t,!!t&&(typeof e=="number"||Hn.test(e))&&e>-1&&e%1==0&&e<t}function Kr(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Yr(e){return!!Pt&&Pt in e}function qt(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||fe;return e===r}function W(e){if(e!=null){try{return Ht.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function Xr(e){return Pe(e,!0,!0)}function Kt(e,t){return e===t||e!==e&&t!==t}function zr(e){return Zr(e)&&H.call(e,"callee")&&(!Zn.call(e,"callee")||me.call(e)==De)}var Fe=Array.isArray;function Yt(e){return e!=null&&ei(e.length)&&!Xt(e)}function Zr(e){return ti(e)&&Yt(e)}var Qr=er||ri;function Xt(e){var t=pe(e)?me.call(e):"";return t==Ae||t==ht}function ei(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=ct}function pe(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function ti(e){return!!e&&typeof e=="object"}function xe(e){return Yt(e)?Ar(e):Vr(e)}function ni(){return[]}function ri(){return!1}q.exports=Xr});var ci={};cn(ci,{crush:()=>gi,defaults:()=>Qt,version:()=>ui});var mn={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Se(e,t){if(!Array.isArray(e)||!e.length)return e;let r=S(S({},mn),t),n,a;if(r.strictlyTwoElementsInRangeArrays&&!e.every((s,c)=>!Array.isArray(s)||s.length!==2?(n=c,a=s.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${a} elements!`);if(!e.every((s,c)=>!Array.isArray(s)||!Number.isInteger(s[0])||s[0]<0||!Number.isInteger(s[1])||s[1]<0?(n=c,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);let o=e.length**2,u=0;return Array.from(e).sort((s,c)=>(r.progressFn&&(u+=1,r.progressFn(Math.floor(u*100/o))),s[0]===c[0]?s[1]<c[1]?-1:s[1]>c[1]?1:0:s[0]<c[0]?-1:1))}var Ye={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Xe(e,t){function r(l){return l&&typeof l=="object"&&!Array.isArray(l)}if(!Array.isArray(e)||!e.length)return null;let n;if(t)if(r(t)){if(n=S(S({},Ye),t),n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&typeof n.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(![1,2,"1","2"].includes(n.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
11
|
+
${JSON.stringify(t,null,4)} (type ${typeof t})`);else n=S({},Ye);let a=e.filter(l=>Array.isArray(l)).map(l=>[...l]).filter(l=>l[2]!==void 0||l[0]!==l[1]),o,u,s;n.progressFn?o=Se(a,{progressFn:l=>{s=Math.floor(l/5),s!==u&&(u=s,n.progressFn(s))}}):o=Se(a);let c=o.length-1;for(let l=c;l>0;l--)n.progressFn&&(s=Math.floor((1-l/c)*78)+21,s!==u&&s>u&&(u=s,n.progressFn(s))),(o[l][0]<=o[l-1][0]||!n.joinRangesThatTouchEdges&&o[l][0]<o[l-1][1]||n.joinRangesThatTouchEdges&&o[l][0]<=o[l-1][1])&&(o[l-1][0]=Math.min(o[l][0],o[l-1][0]),o[l-1][1]=Math.max(o[l][1],o[l-1][1]),o[l][2]!==void 0&&(o[l-1][0]>=o[l][0]||o[l-1][1]<=o[l][1])&&o[l-1][2]!==null&&(o[l][2]===null&&o[l-1][2]!==null?o[l-1][2]=null:o[l-1][2]!=null?+n.mergeType==2&&o[l-1][0]===o[l][0]?o[l-1][2]=o[l][2]:o[l-1][2]+=o[l][2]:o[l-1][2]=o[l][2]),o.splice(l,1),l=o.length);return o.length?o:null}var hn=!0,we="Invariant failed";function ze(e,t){if(!e){if(hn)throw new Error(we);var r=typeof t=="function"?t():t,n=r?we+": "+r:we;throw new Error(n)}}function Ze(e,t,r){let n=0,a=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&typeof r!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter($=>$).length)return e;let o;Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?o=[Array.from(t)]:o=Array.from(t);let u=o.length,s=0;o.filter($=>$).forEach(($,h)=>{if(r&&(n=Math.floor(s/u*10),n!==a&&(a=n,r(n))),!Array.isArray($))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${h}th element not an array: ${JSON.stringify($,null,4)}, which is ${typeof $}`);if(!Number.isInteger($[0])){if(!Number.isInteger(+$[0])||+$[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${h}th element, array ${JSON.stringify($,null,0)}. Its first element is not an integer, string index, but ${typeof $[0]}, equal to: ${JSON.stringify($[0],null,4)}.`);o[h][0]=+o[h][0]}if(!Number.isInteger($[1])){if(!Number.isInteger(+$[1])||+$[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${h}th element, array ${JSON.stringify($,null,0)}. Its second element is not an integer, string index, but ${typeof $[1]}, equal to: ${JSON.stringify($[1],null,4)}.`);o[h][1]=+o[h][1]}s+=1});let c=Xe(o,{progressFn:$=>{r&&(n=10+Math.floor($/10),n!==a&&(a=n,r(n)))}});ze(c);let l=c.length;if(l>0){let $=e.slice(c[l-1][1]);e=c.reduce((h,T,m,f)=>{r&&(n=20+Math.floor(m/l*80),n!==a&&(a=n,r(n)));let O=m===0?0:f[m-1][1],L=f[m][0];return`${h}${e.slice(O,L)}${f[m][2]||""}`},""),e+=$}return e}function le(e,t=1){let r="\xA0";function n(o){return Array.from(o).reverse().join("")}function a(o,u,s){let c=s?`
|
|
12
|
+
`:"\r",l=s?"\r":`
|
|
13
|
+
`;if(!o)return o;let $=0,h=0,T="";for(let m=0,f=o.length;m<f;m++)(o[m]===c||o[m]===l&&o[m-1]!==c)&&h++,`\r
|
|
14
|
+
`.includes(o[m])||o[m]===r?($=0,o[m]===r?T+=o[m]:o[m]===c?h<=u&&(T+=o[m],o[m+1]===l&&(T+=o[m+1],m++)):o[m]===l&&(!o[m-1]||o[m-1]!==c)&&h<=u&&(T+=o[m])):($++,!o[m+1]&&!h&&(T+=" "));return T}if(typeof e=="string"&&e.length){let o=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(o=+t);let u="",s="";if(!e.trim())u=e;else if(!e[0].trim()){for(let c=0,l=e.length;c<l;c++)if(e[c].trim()){u=e.slice(0,c);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===r)){for(let c=e.length;c--;)if(e[c].trim()){s=e.slice(c+1);break}}return`${a(u,o,!1)}${e.trim()}${n(a(n(s),o,!0))}`}return e}var $n={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Qe(e,t){if(!Array.isArray(e)||!e.length)return e;let r=S(S({},$n),t),n,a;if(r.strictlyTwoElementsInRangeArrays&&!e.every((s,c)=>!Array.isArray(s)||s.length!==2?(n=c,a=s.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${a} elements!`);if(!e.every((s,c)=>!Array.isArray(s)||!Number.isInteger(s[0])||s[0]<0||!Number.isInteger(s[1])||s[1]<0?(n=c,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);let o=e.length**2,u=0;return Array.from(e).sort((s,c)=>(r.progressFn&&(u+=1,r.progressFn(Math.floor(u*100/o))),s[0]===c[0]?s[1]<c[1]?-1:s[1]>c[1]?1:0:s[0]<c[0]?-1:1))}var et={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function pn(e,t){function r(l){return l&&typeof l=="object"&&!Array.isArray(l)}if(!Array.isArray(e)||!e.length)return null;let n;if(t)if(r(t)){if(n=S(S({},et),t),n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&typeof n.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(![1,2,"1","2"].includes(n.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
15
|
+
${JSON.stringify(t,null,4)} (type ${typeof t})`);else n=S({},et);let a=e.filter(l=>Array.isArray(l)).map(l=>[...l]).filter(l=>l[2]!==void 0||l[0]!==l[1]),o,u,s;n.progressFn?o=Qe(a,{progressFn:l=>{s=Math.floor(l/5),s!==u&&(u=s,n.progressFn(s))}}):o=Qe(a);let c=o.length-1;for(let l=c;l>0;l--)n.progressFn&&(s=Math.floor((1-l/c)*78)+21,s!==u&&s>u&&(u=s,n.progressFn(s))),(o[l][0]<=o[l-1][0]||!n.joinRangesThatTouchEdges&&o[l][0]<o[l-1][1]||n.joinRangesThatTouchEdges&&o[l][0]<=o[l-1][1])&&(o[l-1][0]=Math.min(o[l][0],o[l-1][0]),o[l-1][1]=Math.max(o[l][1],o[l-1][1]),o[l][2]!==void 0&&(o[l-1][0]>=o[l][0]||o[l-1][1]<=o[l][1])&&o[l-1][2]!==null&&(o[l][2]===null&&o[l-1][2]!==null?o[l-1][2]=null:o[l-1][2]!=null?+n.mergeType==2&&o[l-1][0]===o[l][0]?o[l-1][2]=o[l][2]:o[l-1][2]+=o[l][2]:o[l-1][2]=o[l][2]),o.splice(l,1),l=o.length);return o.length?o:null}function M(e){return e!=null}function P(e){return Number.isInteger(e)&&e>=0}function te(e){return typeof e=="string"}var bn={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},tt=class{constructor(e){Ee(this,"ranges");Ee(this,"opts");let t=S(S({},bn),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(te(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(te(t.mergeType)&&t.mergeType.trim()==="2")t.mergeType=2;else throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);this.opts=t,this.ranges=[]}add(e,t,r){if(e==null&&t==null)return;if(M(e)&&!M(t)){if(Array.isArray(e)){if(e.length){if(e.some(o=>Array.isArray(o))){e.forEach(o=>{Array.isArray(o)&&this.add(...o)});return}e.length&&P(+e[0])&&P(+e[1])&&this.add(...e)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(e,null,0)}) but second-one, "to" is not (${JSON.stringify(t,null,0)})`)}else if(!M(e)&&M(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);let n=+e,a=+t;if(P(r)&&(r=String(r)),P(n)&&P(a)){if(M(r)&&!te(r)&&!P(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:
|
|
16
|
+
${JSON.stringify(r,null,4)}`);if(M(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=a,this.last()[2],this.last()[2]!==null&&M(r)){let o=this.last()[2]&&this.last()[2].length>0&&(!this.opts||!this.opts.mergeType||this.opts.mergeType===1)?`${this.last()[2]}${r}`:r;this.opts.limitToBeAddedWhitespace&&(o=le(o,this.opts.limitLinebreaksCount)),te(o)&&!o.length||(this.last()[2]=o)}}else{this.ranges||(this.ranges=[]);let o=r!==void 0&&!(te(r)&&!r.length)?[n,a,r&&this.opts.limitToBeAddedWhitespace?le(r,this.opts.limitLinebreaksCount):r]:[n,a];this.ranges.push(o)}}else throw P(n)&&n>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof a}" equal to: ${JSON.stringify(a,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof n}" equal to: ${JSON.stringify(n,null,4)}`)}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=pn(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>M(e[2])?[e[0],e[1],le(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&P(e[0][0]))this.ranges=Array.from(e);else throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};function nt(e){return typeof e=="string"?e.length?[e]:[]:e}function rt(e){return e&&typeof e=="object"&&!Array.isArray(e)}function se(e){return typeof e=="string"}var it={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},dn=e=>e+1;function Tn(e,t,r,n,a=!1,o=dn){let u=typeof r=="function"?r():r;if(+t<0&&a&&u==="EOL")return u;let s=S(S({},it),n);if(t>=e.length&&!a)return!1;let c=a?1:r.length,l=0,$=!1,h=!1,T=!1,m=s.maxMismatches,f=t,O=!1,L=!1,p=!1;function b(){return l===1&&m<s.maxMismatches-1}for(;e[f];){let d=o(f);if(s.trimBeforeMatching&&e[f].trim()===""){if(!e[d]&&a&&r==="EOL")return!0;f=o(f);continue}if(s&&!s.i&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.includes(e[f])||(s==null?void 0:s.i)&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.map(A=>A.toLowerCase()).includes(e[f].toLowerCase())){if(a&&r==="EOL"&&!e[d])return!0;f=o(f);continue}let E=d>f?r[r.length-c]:r[c-1];if(!s.i&&e[f]===E||s.i&&e[f].toLowerCase()===E.toLowerCase()){if(O||(O=!0),T||(T=!0),c===r.length){if(L=!0,m!==s.maxMismatches)return!1}else c===1&&(p=!0);if(c-=1,l++,b())return!1;if(!c)return l!==r.length||m===s.maxMismatches||!$?f:!1}else if(!$&&!l&&($=!0),s.maxMismatches&&m&&f){m-=1;for(let A=0;A<=m;A++){let I=d>f?r[r.length-c+1+A]:r[c-2-A],V=e[o(f)];if(I&&(!s.i&&e[f]===I||s.i&&e[f].toLowerCase()===I.toLowerCase())&&(!s.firstMustMatch||c!==r.length)){if(l++,b())return!1;c-=2,O=!0;break}else if(V&&I&&(!s.i&&V===I||s.i&&V.toLowerCase()===I.toLowerCase())&&(!s.firstMustMatch||c!==r.length)){if(!l&&!s.hungry)return!1;c-=1,O=!0;break}else if(I===void 0&&m>=0&&O&&(!s.firstMustMatch||L)&&(!s.lastMustMatch||p))return f}O||(h=f)}else return f===0&&c===1&&!s.lastMustMatch&&T?0:!1;if(h!==!1&&h!==f&&(h=!1),c<1)return f;f=o(f)}if(c>0)return a&&u==="EOL"?!0:s&&s.maxMismatches>=c&&T?h||0:!1}function Oe(e,t,r,n,a){if(rt(a)&&Object.prototype.hasOwnProperty.call(a,"trimBeforeMatching")&&typeof a.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(a.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let o=S(S({},it),a);if(typeof o.trimCharsBeforeMatching=="string"&&(o.trimCharsBeforeMatching=nt(o.trimCharsBeforeMatching)),o.trimCharsBeforeMatching=o.trimCharsBeforeMatching.map($=>se($)?$:String($)),!se(t)||!t.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof r}, equal to:
|
|
17
|
+
${JSON.stringify(r,null,4)}`);let u,s;if(se(n))u=[n];else if(Array.isArray(n))u=n;else if(!n)u=n;else if(typeof n=="function")u=[],u.push(n);else throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof n}, equal to:
|
|
18
|
+
${JSON.stringify(n,null,4)}`);if(a&&!rt(a))throw new Error(`string-match-left-right/${e}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof a}", and equal to:
|
|
19
|
+
${JSON.stringify(a,null,4)}`);let c=0,l="";if((o==null?void 0:o.trimCharsBeforeMatching)&&o.trimCharsBeforeMatching.some(($,h)=>$.length>1?(c=h,l=$,!0):!1))throw new Error(`string-match-left-right/${e}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${c} is longer than 1 character, ${l.length} (equals to ${l}). Please split it into separate characters and put into array as separate elements.`);if(!u||!Array.isArray(u)||Array.isArray(u)&&!u.length||Array.isArray(u)&&u.length===1&&se(u[0])&&!u[0].trim()){if(typeof o.cb=="function"){let h,T=r;if((e==="matchLeftIncl"||e==="matchRight")&&(T+=1),e[5]==="L")for(let L=T;L--;){let p=t[L];if((!o.trimBeforeMatching||o.trimBeforeMatching&&p!==void 0&&p.trim())&&(!o.trimCharsBeforeMatching||!o.trimCharsBeforeMatching.length||p!==void 0&&!o.trimCharsBeforeMatching.includes(p))){h=L;break}}else if(e.startsWith("matchRight"))for(let L=T;L<t.length;L++){let p=t[L];if((!o.trimBeforeMatching||o.trimBeforeMatching&&p.trim())&&(!o.trimCharsBeforeMatching||!o.trimCharsBeforeMatching.length||!o.trimCharsBeforeMatching.includes(p))){h=L;break}}if(h===void 0)return!1;let m=t[h],f=h+1,O="";return f&&f>0&&(O=t.slice(0,f)),e[5]==="L"||h&&h>0&&(O=t.slice(h)),o.cb(m,O,h)}let $="";throw a||($=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${$}`)}for(let $=0,h=u.length;$<h;$++){s=typeof u[$]=="function";let T=u[$],m,f,O="",L=r;e==="matchRight"?L+=1:e==="matchLeft"&&(L-=1);let p=Tn(t,L,T,o,s,b=>e[5]==="L"?b-1:b+1);if(p&&s&&typeof T=="function"&&T()==="EOL")return T()&&(o.cb?o.cb(m,O,f):!0)?T():!1;if(Number.isInteger(p)&&(f=e.startsWith("matchLeft")?p-1:p+1,e[5]==="L"?O=t.slice(0,p):O=t.slice(f)),f<0&&(f=void 0),t[f]&&(m=t[f]),Number.isInteger(p)&&(o.cb?o.cb(m,O,f):!0))return T}return!1}function ot(e,t,r,n){return Oe("matchLeft",e,t,r,n)}function Le(e,t,r,n){return Oe("matchRightIncl",e,t,r,n)}function k(e,t,r,n){return Oe("matchRight",e,t,r,n)}var yn={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function ae(e){var c;let t=/^[0-9a-zA-Z]+$/;function r(l){return!l||typeof l!="string"?!1:!l.trim()}function n(l){return typeof l=="string"}if(!e||typeof e!="object"||Array.isArray(e)){let l;throw e===void 0?l="but it is missing completely.":e===null?l="but it was given as null.":l=`but it was given as ${typeof e}, equal to:
|
|
20
|
+
${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${l}`)}else if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&!Object.keys(e).length)throw new Error("string-range-expander: [THROW_ID_02] Input must be a plain object but it was given as a plain object without any keys.");if(typeof e.from!="number")throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value opts.from, is not a number! Currently it's given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if(typeof e.to!="number")throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value opts.to, is not a number! Currently it's given as ${typeof e.to}, equal to ${JSON.stringify(e.to,null,0)}`);if((e==null?void 0:e.str)&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string opts.str ("${e.str}") must contain the character at index "from" ("${e.from}")`);if((e==null?void 0:e.str)&&!e.str[e.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, opts.str ("${e.str}") must contain the character at index before "to" ("${e.to-1}")`);if(e.from>e.to)throw new Error(`string-range-expander: [THROW_ID_07] The given "from" index, "${e.from}" is greater than "to" index, "${e.to}". That's wrong!`);if(n(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!n(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide!==!1)throw new Error(`string-range-expander: [THROW_ID_08] The opts.extendToOneSide value is not recogniseable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);let a=S(S({},yn),e);if(Array.isArray(a.ifLeftSideIncludesThisThenCropTightly)){let l,$;if(a.ifLeftSideIncludesThisThenCropTightly.every((h,T)=>n(h)?!0:(l=T,$=h,!1)))a.ifLeftSideIncludesThisThenCropTightly=a.ifLeftSideIncludesThisThenCropTightly.join("");else throw new Error(`string-range-expander: [THROW_ID_09] The opts.ifLeftSideIncludesThisThenCropTightly was set to an array:
|
|
21
|
+
${JSON.stringify(a.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${l} is of a type ${typeof $} (equal to ${JSON.stringify($,null,0)}).`)}let o=a.str,u=a.from,s=a.to;if(a.extendToOneSide!=="right"&&(r(o[u-1])&&(r(o[u-2])||a.ifLeftSideIncludesThisCropItToo.includes(o[u-2]))||o[u-1]&&a.ifLeftSideIncludesThisCropItToo.includes(o[u-1])||a.wipeAllWhitespaceOnLeft&&r(o[u-1]))){for(let l=u;l--;)if(!a.ifLeftSideIncludesThisCropItToo.includes(o[l])){if(o[l].trim()){a.wipeAllWhitespaceOnLeft||a.ifLeftSideIncludesThisCropItToo.includes(o[l+1])?u=l+1:u=l+2;break}else if(l===0){a.wipeAllWhitespaceOnLeft?u=0:u=1;break}}}if(a.extendToOneSide!=="left"&&(r(o[s])&&(a.wipeAllWhitespaceOnRight||r(o[s+1]))||a.ifRightSideIncludesThisCropItToo.includes(o[s]))){for(let l=s,$=o.length;l<$;l++)if(!a.ifRightSideIncludesThisCropItToo.includes(o[l])&&((c=o[l])==null?void 0:c.trim())){a.wipeAllWhitespaceOnRight||a.ifRightSideIncludesThisCropItToo.includes(o[l-1])?s=l:s=l-1;break}}return(a.extendToOneSide!=="right"&&n(a.ifLeftSideIncludesThisThenCropTightly)&&a.ifLeftSideIncludesThisThenCropTightly&&(o[u-2]&&a.ifLeftSideIncludesThisThenCropTightly.includes(o[u-2])||o[u-1]&&a.ifLeftSideIncludesThisThenCropTightly.includes(o[u-1]))||a.extendToOneSide!=="left"&&n(a.ifRightSideIncludesThisThenCropTightly)&&a.ifRightSideIncludesThisThenCropTightly&&(o[s+1]&&a.ifRightSideIncludesThisThenCropTightly.includes(o[s+1])||o[s]&&a.ifRightSideIncludesThisThenCropTightly.includes(o[s])))&&(a.extendToOneSide!=="right"&&r(o[u-1])&&!a.wipeAllWhitespaceOnLeft&&(u-=1),a.extendToOneSide!=="left"&&r(o[s])&&!a.wipeAllWhitespaceOnRight&&(s+=1)),a.addSingleSpaceToPreventAccidentalConcatenation&&o[u-1]&&o[u-1].trim()&&o[s]&&o[s].trim()&&(!a.ifLeftSideIncludesThisThenCropTightly&&!a.ifRightSideIncludesThisThenCropTightly||!((!a.ifLeftSideIncludesThisThenCropTightly||a.ifLeftSideIncludesThisThenCropTightly.includes(o[u-1]))&&(!a.ifRightSideIncludesThisThenCropTightly||o[s]&&a.ifRightSideIncludesThisThenCropTightly.includes(o[s]))))&&(t.test(o[u-1])||t.test(o[s]))?[u,s," "]:[u,s]}var ii=Ke(ut(),1),oi=Ke(zt(),1);var K="\xA0";function li({str:e,idx:t=0,stopAtNewlines:r=!1,stopAtRawNbsp:n=!1}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),!e[t+1]))return null;if(e[t+1]&&(e[t+1].trim()||r&&`
|
|
22
|
+
\r`.includes(e[t+1])||n&&e[t+1]===K))return t+1;if(e[t+2]&&(e[t+2].trim()||r&&`
|
|
23
|
+
\r`.includes(e[t+2])||n&&e[t+2]===K))return t+2;for(let a=t+1,o=e.length;a<o;a++)if(e[a].trim()||r&&`
|
|
24
|
+
\r`.includes(e[a])||n&&e[a]===K)return a;return null}function D(e,t=0){return li({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function si({str:e,idx:t,stopAtNewlines:r,stopAtRawNbsp:n}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),t<1))return null;if(e[~-t]&&(e[~-t].trim()||r&&`
|
|
25
|
+
\r`.includes(e[~-t])||n&&e[~-t]===K))return~-t;if(e[t-2]&&(e[t-2].trim()||r&&`
|
|
26
|
+
\r`.includes(e[t-2])||n&&e[t-2]===K))return t-2;for(let a=t;a--;)if(e[a]&&(e[a].trim()||r&&`
|
|
27
|
+
\r`.includes(e[a])||n&&e[a]===K))return a;return null}function be(e,t=0){return si({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}var Zt="5.0.10";var ui=Zt,y=new tt({limitToBeAddedWhitespace:!0}),Qt={lineLengthLimit:500,removeIndentations:!0,removeLineBreaks:!1,removeHTMLComments:!1,removeCSSComments:!0,reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,breakToTheLeftOf:["</td","<html","</html","<head","</head","<meta","<link","<table","<script","<\/script","<!DOCTYPE","<style","</style","<title","<body","@media","</body","<!--[if","<!--<![endif","<![endif]"],mindTheInlineTags:["a","abbr","acronym","audio","b","bdi","bdo","big","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","label","map","mark","meter","noscript","object","output","picture","progress","q","ruby","s","samp","script","select","slot","small","span","strong","sub","sup","svg","template","textarea","time","u","tt","var","video","wbr"]};function Y(e){return typeof e=="string"}function X(e){return typeof e=="string"&&e.toUpperCase()!==e.toLowerCase()}function gi(e,t){var fi;let r=Date.now();if(!Y(e))throw e===void 0?new Error("html-crush: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`html-crush: [THROW_ID_02] the first input argument must be string! It was given as "${typeof e}", equal to:
|
|
28
|
+
${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`html-crush: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof t}, equal to ${JSON.stringify(t,null,4)}`);if(t&&Array.isArray(t.breakToTheLeftOf)&&t.breakToTheLeftOf.length){for(let i=0,Q=t.breakToTheLeftOf.length;i<Q;i++)if(!Y(t.breakToTheLeftOf[i]))throw new TypeError(`html-crush: [THROW_ID_05] the opts.breakToTheLeftOf array contains non-string elements! For example, element at index ${i} is of a type "${typeof t.breakToTheLeftOf[i]}" and is equal to:
|
|
29
|
+
${JSON.stringify(t.breakToTheLeftOf[i],null,4)}`)}let n=S(S({},Qt),t);typeof n.removeHTMLComments=="boolean"&&(n.removeHTMLComments=n.removeHTMLComments?1:0);let a="";Array.isArray(n.breakToTheLeftOf)&&n.breakToTheLeftOf.length&&(a=[...new Set(n.breakToTheLeftOf.map(i=>i[0]))].join(""));let o={removeHTMLComments:!1,removeCSSComments:!1},u=null,s=null,c=!1,l=0,$=0,h=!1,T=!1,m=null,f=null,O=null,L=null,p,b=null,d=null,E=null,A=null,I=null,V=null,z=">};",Z="<",en="!",tn=">",nn="<",We="{},:;<>~+",de=We,Te=We,J=!0,_=e.length,rn=Math.floor(_/2),Je=.01,je;n.reportProgressFunc&&(je=Math.floor(n.reportProgressFuncTo-(n.reportProgressFuncTo-n.reportProgressFuncFrom)*Je-n.reportProgressFuncFrom));let R,oe=0,C=`
|
|
30
|
+
`;if(e.includes(`\r
|
|
31
|
+
`)?C=`\r
|
|
32
|
+
`:e.includes("\r")&&(C="\r"),_){for(let i=0;i<_;i++){if(n.reportProgressFunc&&(_>1e3&&_<2e3?i===rn&&n.reportProgressFunc(Math.floor((n.reportProgressFuncTo-n.reportProgressFuncFrom)/2)):_>=2e3&&(R=n.reportProgressFuncFrom+Math.floor(i/_*(je||1)),R!==oe&&(oe=R,n.reportProgressFunc(R)))),$++,!p&&h&&e[i]==="}"&&e[i-1]==="}"&&(l+1>=n.lineLengthLimit?(y.push(i,i,C),l=0):(b=i,d=i,E=" ")),p&&typeof p=="number"&&i>=p&&(p=void 0),L!==null&&e.startsWith("<\/script",i)&&!X(e[i+8])){if((n.removeIndentations||n.removeLineBreaks)&&i>0&&e[~-i]&&!e[~-i].trim()){for(let g=i;g--;)if(e[g]===`
|
|
33
|
+
`||e[g]==="\r"||e[g].trim()){g+1<i&&y.push(g+1,i);break}}L=null,p=!1,i+=8;continue}if(!p&&!h&&e.startsWith("<script",i)&&!X(e[i+7])){L=i,p=!0;let g="";(n.removeLineBreaks||n.removeIndentations)&&s!==null&&(s>0&&(g=C),y.push(s,i,g)),s=null,u=null}if(I!==null&&A===null&&!/\w/.test(e[i])){A=e.slice(I,i);let g=D(e,~-i);typeof g=="number"&&e[g]===">"&&!e[i].trim()&&D(e,i)?y.push(i,D(e,i)):g&&e[g]==="/"&&e[D(e,g)]===">"&&(!e[i].trim()&&D(e,i)&&y.push(i,D(e,i)),e[g+1]!==">"&&D(e,g+1)&&y.push(g+1,D(e,g+1)))}if(!p&&!h&&!m&&e[~-i]==="<"&&I===null&&(/\w/.test(e[i])?I=i:e[D(e,~-i)]==="/"&&/\w/.test(e[D(e,D(e,~-i))]||"")&&(I=D(e,D(e,~-i)))),!p&&(h||m)&&f!==null&&e[i]==="*"&&e[i+1]==="/"&&([b,d]=ae({str:e,from:f,to:i+2,ifLeftSideIncludesThisThenCropTightly:de||"",ifRightSideIncludesThisThenCropTightly:Te||""}),f=null,b!=null?y.push(b,d):(l+=1,i+=1),p=i+2),!p&&(h||m)&&f===null&&e[i]==="/"&&e[i+1]==="*"&&(o.removeCSSComments||(o.removeCSSComments=!0),n.removeCSSComments&&(f=i)),T&&e.startsWith("![endif",i+1)&&(T=!1),!p&&!h&&!m&&O!==null){let g;e.startsWith("-->",i)?g=3:e[i]===">"&&e[i-1]==="]"&&(g=1),g&&([b,d]=ae({str:e,from:O,to:i+g}),O=null,b!=null?n.lineLengthLimit&&$-(d-b)>=n.lineLengthLimit?(y.push(b,d,C),$=-g):(y.push(b,d),$-=d-b):(l+=g-1,i+=g-1),p=i+g)}if(!p&&!h&&!m&&(e.startsWith("<!--",i)||n.removeHTMLComments===2&&e.startsWith("<![endif",i))&&O===null&&(e.startsWith("[if",i+4)?(T||(T=!0),n.removeHTMLComments===2&&(O=i)):n.removeHTMLComments&&(!T||n.removeHTMLComments===2)&&(O=i),o.removeHTMLComments||(o.removeHTMLComments=!0)),!p&&h&&f===null&&e.startsWith("</style",i)&&!X(e[i+7])?h=!1:!p&&!h&&f===null&&e.startsWith("<style",i)&&!X(e[i+6])&&(h=!0,(n.removeLineBreaks||n.removeIndentations)&&n.breakToTheLeftOf.includes("<style")&&e.startsWith(' type="text/css">',i+6)&&e[i+24]&&y.push(i+23,i+23,C)),!p&&!m&&`"'`.includes(e[i])&&e.endsWith("style=",i)&&(m=i),!p&&!e[i].trim())s===null&&(s=i);else if(!p&&!((h||m)&&f!==null)){if(s!==null){if(n.removeLineBreaks&&(l+=1),J)J=!1,(n.removeIndentations||n.removeLineBreaks)&&y.push(0,i);else if(n.removeIndentations&&!n.removeLineBreaks&&(!c&&u!==null&&i>u?y.push(u+1,i):s+1<i&&(e.endsWith("]>",s)||e.endsWith("-->",s)||e.startsWith("<![",i)||e.startsWith("<!--<![",i)?y.push(s,i):e[s]===" "?y.push(s+1,i):e[~-i]===" "?y.push(s,~-i):y.push(s,i," "))),n.removeLineBreaks||m){if(a.includes(e[i])&&Le(e,i,n.breakToTheLeftOf)){!(`\r
|
|
34
|
+
`.includes(e[~-i])&&s===~-i)&&!(e[~-i]===`
|
|
35
|
+
`&&e[i-2]==="\r"&&s===i-2)&&y.push(s,i,C),b=null,d=null,E=null,s=null,l=1;continue}let g=" ";e[i]==="<"&&k(e,i,n.mindTheInlineTags,{cb:j=>!j||!/\w/.test(j)})||(e[~-s]&&tn.includes(e[~-s])&&nn.includes(e[i])||(h||m)&&f===null&&(de.includes(e[~-s])||Te.includes(e[i]))||e.startsWith("!important",i)&&!T||m&&(e[~-s]==="'"||e[~-s]==='"')||e[~-s]==="}"&&e.startsWith("</style",i)||e[i]===">"&&(`'"`.includes(e[be(e,i)])||e[D(e,i)]==="<")||e[i]==="/"&&e[D(e,i)]===">")&&(g="",e[i]==="/"&&e[i+1]===">"&&D(e,i)&&D(e,i)>i+1&&(y.push(i+1,D(e,i)),l-=D(e,i)-i+1)),h&&e[i]==="}"&&s&&e[s-1]==="}"&&(g=" "),(g==null?void 0:g.length)&&(l+=1),n.lineLengthLimit?l>=n.lineLengthLimit||!e[i+1]||e[i]===">"||e[i]==="/"&&e[i+1]===">"?((l>n.lineLengthLimit||l===n.lineLengthLimit&&e[i+1]&&e[i+1].trim()&&!z.includes(e[i])&&!Z.includes(e[i+1]))&&(g=C,l=1),(l>n.lineLengthLimit||!(g===" "&&i===s+1))&&(y.push(s,i,g),u=null),b=null,d=null,E=null):(b===null||s<b)&&(b=s,d=i,E=g):i===s+1&&g===" "||y.push(s,i,g)}s=null,c||(c=!0)}else J&&(J=!1),n.removeLineBreaks&&(l+=1);c||(c=!0)}if(!p&&!J&&i!==0&&n.removeLineBreaks&&(n.lineLengthLimit||a)&&!e.startsWith("</a",i)){if(a&&Le(e,i,n.breakToTheLeftOf)&&e.slice(0,i).trim()&&(!e.startsWith("<![endif]",i)||!ot(e,i,"<!--"))){y.push(i,i,C),b=null,d=null,E=null,l=1;continue}else if(n.lineLengthLimit&&l<=n.lineLengthLimit){if(!e[i+1]||Z.includes(e[i])&&!en.includes(e[i])||z.includes(e[i])||!e[i].trim()){if(b!==null&&d!==null&&(b!==d||(E==null?void 0:E.length))){let g=E;e[i].trim()&&e[i+1]&&e[i+1].trim()&&l+(E?E.length:0)>n.lineLengthLimit&&(g=C),(l+(g?g.length:0)>n.lineLengthLimit||!(g===" "&&d===b+1&&e[b]===" "))&&(e[~-b]==="}"&&e[d]==="{"||(y.push(b,d,g),u=null))}e[i].trim()&&(Z.includes(e[i])||e[~-i]&&z.includes(e[~-i]))&&Y(V)&&(!A||!n.mindTheInlineTags.includes(A))&&!(e[i]==="<"&&k(e,i,n.mindTheInlineTags,{cb:g=>!g||!/\w/.test(g)}))&&!(e[i]==="<"&&k(e,i,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:g=>!g||!/\w/.test(g)}))?(b=i,d=i,E=null):f===null&&b!==null&&(m||!n.mindTheInlineTags||!Array.isArray(n.mindTheInlineTags)||Array.isArray(n.mindTheInlineTags.length)&&!n.mindTheInlineTags.length||!Y(A)||Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&Y(A)&&!n.mindTheInlineTags.includes(A))&&!(e[i]==="<"&&k(e,i,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:g=>!g||!/\w/.test(g)}))&&(b=null,d=null,E=null)}}else if(n.lineLengthLimit)if(Z.includes(e[i])&&!(e[i]==="<"&&k(e,i,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:g=>!g||!/\w/.test(g)})))if(b!==null&&d!==null&&(b!==d||(E==null?void 0:E.length))){let g=(E==null?void 0:E.length)?E.length:0;l-(d-b-g)-1>n.lineLengthLimit||(y.push(b,d,E),l-(d-b-g)-1===n.lineLengthLimit&&(y.push(i,i,C),l=0),b=null,d=null,E=null)}else y.push(i,i,C),l=0;else e[i+1]&&z.includes(e[i])&&Y(A)&&Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&!n.mindTheInlineTags.includes(A)?b!==null&&d!==null&&(b!==d||(E==null?void 0:E.length))||(y.push(i+1,i+1,C),l=0):e[i].trim()&&(e[i+1]||b!==null&&d!==null&&(b!==d||(E==null?void 0:E.length))&&y.push(b,d,C))}if(!p&&!J&&n.removeLineBreaks&&n.lineLengthLimit&&l>=n.lineLengthLimit&&b!==null&&d!==null&&!z.includes(e[i])&&!Z.includes(e[i])&&!"/".includes(e[i])&&!(l===n.lineLengthLimit&&e[i+1]&&!e[i+1].trim())){let g=C;e[i+1]&&!e[i+1].trim()&&l===n.lineLengthLimit&&(g=E),g===C&&!e[~-b].trim()&&be(e,b)&&(b=be(e,b)+1),y.push(b,d,g),l=i-d,e[i].length&&(l+=1),b=null,d=null,E=null}if((!p&&e[i]===`
|
|
36
|
+
`||e[i]==="\r"&&(!e[i+1]||e[i+1]&&e[i+1]!==`
|
|
37
|
+
`))&&(u=i,c&&(c=!1),!n.removeLineBreaks&&s!==null&&s<i&&e[i+1]&&e[i+1]!=="\r"&&e[i+1]!==`
|
|
38
|
+
`&&y.push(s,i)),e[i+1]||(h&&f!==null?y.push(...ae({str:e,from:f,to:i,ifLeftSideIncludesThisThenCropTightly:de||"",ifRightSideIncludesThisThenCropTightly:Te||""})):s&&e[i]!==`
|
|
39
|
+
`&&e[i]!=="\r"?y.push(s,i+1):s&&(e[i]==="\r"&&e[i+1]===`
|
|
40
|
+
`||e[i]===`
|
|
41
|
+
`&&e[i-1]!=="\r")&&y.push(s,i)),!p&&m&&m<i&&e[m]===e[i]&&(m=null),!p&&!h&&e.startsWith("<pre",i)&&!X(e[i+4])){let g=e.indexOf("</pre",i+5);g>0&&(p=g)}if(!p&&!h&&e.startsWith("<code",i)&&!X(e[i+5])){let g=e.indexOf("</code",i+5);g>0&&(p=g)}if(!p&&e.startsWith("<![CDATA[",i)){let g=e.indexOf("]]>",i+9);g>0&&(p=g)}!p&&!h&&!m&&I!==null&&e[i]===">"&&(e[D(e,i)]==="<"&&(V=A),I=null,A=null),e[i]==="<"&&V!==null&&(V=null),h&&e[i]==="{"&&e[i+1]==="{"&&e.indexOf("}}")!==-1&&(p=e.indexOf("}}")+2);let Q=!0}if(y.current()){let i=y.current();y.wipe();let Q=n.reportProgressFuncTo-(n.reportProgressFuncTo-n.reportProgressFuncFrom)*Je,g=Ze(e,i,on=>{n.reportProgressFunc&&_>=2e3&&(R=Math.floor(Q+(n.reportProgressFuncTo-Q)*(on/100)),R!==oe&&(oe=R,n.reportProgressFunc(R)))}),j=g.length;return{log:{timeTakenInMilliseconds:Date.now()-r,originalLength:_,cleanedLength:j,bytesSaved:Math.max(_-j,0),percentageReducedOfOriginal:_?Math.round(Math.max(_-j,0)*100/_):0},ranges:i,applicableOpts:o,result:g}}}return{log:{timeTakenInMilliseconds:Date.now()-r,originalLength:_,cleanedLength:_,bytesSaved:0,percentageReducedOfOriginal:0},applicableOpts:o,ranges:null,result:e}}return fn(ci);})();
|
|
11
42
|
/**
|
|
12
|
-
* @name
|
|
13
|
-
* @fileoverview
|
|
14
|
-
* @version
|
|
43
|
+
* @name arrayiffy-if-string
|
|
44
|
+
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
45
|
+
* @version 4.0.10
|
|
15
46
|
* @author Roy Revelt, Codsen Ltd
|
|
16
47
|
* @license MIT
|
|
17
|
-
* {@link https://codsen.com/os/
|
|
18
|
-
*/
|
|
48
|
+
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* @name ranges-apply
|
|
52
|
+
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
|
|
53
|
+
* @version 6.0.10
|
|
54
|
+
* @author Roy Revelt, Codsen Ltd
|
|
55
|
+
* @license MIT
|
|
56
|
+
* {@link https://codsen.com/os/ranges-apply/}
|
|
57
|
+
*/
|
|
19
58
|
/**
|
|
20
59
|
* @name ranges-merge
|
|
21
60
|
* @fileoverview Merge and sort string index ranges
|
|
22
|
-
* @version 8.0.
|
|
61
|
+
* @version 8.0.10
|
|
23
62
|
* @author Roy Revelt, Codsen Ltd
|
|
24
63
|
* @license MIT
|
|
25
64
|
* {@link https://codsen.com/os/ranges-merge/}
|
|
26
|
-
*/
|
|
65
|
+
*/
|
|
27
66
|
/**
|
|
28
|
-
* @name ranges-
|
|
29
|
-
* @fileoverview
|
|
30
|
-
* @version 6.0.
|
|
67
|
+
* @name ranges-push
|
|
68
|
+
* @fileoverview Gather string index ranges
|
|
69
|
+
* @version 6.0.10
|
|
31
70
|
* @author Roy Revelt, Codsen Ltd
|
|
32
71
|
* @license MIT
|
|
33
|
-
* {@link https://codsen.com/os/ranges-
|
|
72
|
+
* {@link https://codsen.com/os/ranges-push/}
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* @name ranges-sort
|
|
76
|
+
* @fileoverview Sort string index ranges
|
|
77
|
+
* @version 5.0.10
|
|
78
|
+
* @author Roy Revelt, Codsen Ltd
|
|
79
|
+
* @license MIT
|
|
80
|
+
* {@link https://codsen.com/os/ranges-sort/}
|
|
34
81
|
*/
|
|
35
82
|
/**
|
|
36
83
|
* @name string-collapse-leading-whitespace
|
|
37
84
|
* @fileoverview Collapse the leading and trailing whitespace of a string
|
|
38
|
-
* @version 6.0.
|
|
85
|
+
* @version 6.0.10
|
|
39
86
|
* @author Roy Revelt, Codsen Ltd
|
|
40
87
|
* @license MIT
|
|
41
88
|
* {@link https://codsen.com/os/string-collapse-leading-whitespace/}
|
|
42
89
|
*/
|
|
43
|
-
function s(e,t=1){function r(e){return Array.from(e).reverse().join("")}function n(e,t,r){const n=r?"\n":"\r",i=r?"\r":"\n";if(!e)return e;let s=0,o="";for(let r=0,a=e.length;r<a;r++)(e[r]===n||e[r]===i&&e[r-1]!==n)&&s++,"\r\n".includes(e[r])||" "===e[r]?" "===e[r]?o+=e[r]:e[r]===n?s<=t&&(o+=e[r],e[r+1]===i&&(o+=e[r+1],r++)):e[r]===i&&(!e[r-1]||e[r-1]!==n)&&s<=t&&(o+=e[r]):e[r+1]||s||(o+=" ");return o}if("string"==typeof e&&e.length){let i=1;"number"==typeof+t&&Number.isInteger(+t)&&+t>=0&&(i=+t);let s="",o="";if(e.trim()){if(!e[0].trim())for(let t=0,r=e.length;t<r;t++)if(e[t].trim()){s=e.slice(0,t);break}}else s=e;if(e.trim()&&(""===e.slice(-1).trim()||" "===e.slice(-1)))for(let t=e.length;t--;)if(e[t].trim()){o=e.slice(t+1);break}return`${n(s,i,!1)}${e.trim()}${r(n(r(o),i,!0))}`}return e}
|
|
44
90
|
/**
|
|
45
|
-
* @name
|
|
46
|
-
* @fileoverview
|
|
47
|
-
* @version
|
|
91
|
+
* @name string-left-right
|
|
92
|
+
* @fileoverview Looks up the first non-whitespace character to the left/right of a given index
|
|
93
|
+
* @version 5.0.10
|
|
48
94
|
* @author Roy Revelt, Codsen Ltd
|
|
49
95
|
* @license MIT
|
|
50
|
-
* {@link https://codsen.com/os/
|
|
51
|
-
*/
|
|
96
|
+
* {@link https://codsen.com/os/string-left-right/}
|
|
97
|
+
*/
|
|
52
98
|
/**
|
|
53
99
|
* @name string-match-left-right
|
|
54
100
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
55
|
-
* @version 8.0.
|
|
101
|
+
* @version 8.0.10
|
|
56
102
|
* @author Roy Revelt, Codsen Ltd
|
|
57
103
|
* @license MIT
|
|
58
104
|
* {@link https://codsen.com/os/string-match-left-right/}
|
|
59
105
|
*/
|
|
60
|
-
function g(e){return e&&"object"==typeof e&&!Array.isArray(e)}function p(e){return"string"==typeof e}const m={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},d=e=>e+1;function y(e,t,r,n,i=!1,s=d){const o="function"==typeof r?r():r;if(+t<0&&i&&"EOL"===o)return o;const a={...m,...n};if(t>=e.length&&!i)return!1;let l=i?1:r.length,u=0,h=!1,f=!1,c=!1,g=a.maxMismatches,p=t,y=!1,T=!1,b=!1;function w(){return 1===u&&g<a.maxMismatches-1}for(;e[p];){const t=s(p);if(a.trimBeforeMatching&&""===e[p].trim()){if(!e[t]&&i&&"EOL"===r)return!0;p=s(p);continue}if(a&&!a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.includes(e[p])||a&&a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.map((e=>e.toLowerCase())).includes(e[p].toLowerCase())){if(i&&"EOL"===r&&!e[t])return!0;p=s(p);continue}const n=t>p?r[r.length-l]:r[l-1];if(!a.i&&e[p]===n||a.i&&e[p].toLowerCase()===n.toLowerCase()){if(y||(y=!0),c||(c=!0),l===r.length){if(T=!0,g!==a.maxMismatches)return!1}else 1===l&&(b=!0);if(l-=1,u++,w())return!1;if(!l)return(u!==r.length||g===a.maxMismatches||!h)&&p}else{if(h||u||(h=!0),!(a.maxMismatches&&g&&p))return!(0!==p||1!==l||a.lastMustMatch||!c)&&0;g-=1;for(let n=0;n<=g;n++){const i=t>p?r[r.length-l+1+n]:r[l-2-n],o=e[s(p)];if(i&&(!a.i&&e[p]===i||a.i&&e[p].toLowerCase()===i.toLowerCase())&&(!a.firstMustMatch||l!==r.length)){if(u++,w())return!1;l-=2,y=!0;break}if(o&&i&&(!a.i&&o===i||a.i&&o.toLowerCase()===i.toLowerCase())&&(!a.firstMustMatch||l!==r.length)){if(!u&&!a.hungry)return!1;l-=1,y=!0;break}if(void 0===i&&g>=0&&y&&(!a.firstMustMatch||T)&&(!a.lastMustMatch||b))return p}y||(f=p)}if(!1!==f&&f!==p&&(f=!1),l<1)return p;p=s(p)}return l>0?!(!i||"EOL"!==o)||!!(a&&a.maxMismatches>=l&&c)&&(f||0):void 0}function T(e,t,r,n,i){if(g(i)&&Object.prototype.hasOwnProperty.call(i,"trimBeforeMatching")&&"boolean"!=typeof i.trimBeforeMatching)throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(i.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);const s={...m,...i};
|
|
61
|
-
/**
|
|
62
|
-
* @name arrayiffy-if-string
|
|
63
|
-
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
64
|
-
* @version 4.0.4
|
|
65
|
-
* @author Roy Revelt, Codsen Ltd
|
|
66
|
-
* @license MIT
|
|
67
|
-
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
|
68
|
-
*/
|
|
69
|
-
var o;if("string"==typeof s.trimCharsBeforeMatching&&(s.trimCharsBeforeMatching="string"==typeof(o=s.trimCharsBeforeMatching)?o.length?[o]:[]:o),s.trimCharsBeforeMatching=s.trimCharsBeforeMatching.map((e=>p(e)?e:String(e))),!p(t))return!1;if(!t.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof r}, equal to:\n${JSON.stringify(r,null,4)}`);let a,l;if(p(n))a=[n];else if(Array.isArray(n))a=n;else if(n){if("function"!=typeof n)throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof n}, equal to:\n${JSON.stringify(n,null,4)}`);a=[],a.push(n)}else a=n;if(i&&!g(i))throw new Error(`string-match-left-right/${e}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof i}", and equal to:\n${JSON.stringify(i,null,4)}`);let u=0,h="";if(s&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.some(((e,t)=>e.length>1&&(u=t,h=e,!0))))throw new Error(`string-match-left-right/${e}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${u} is longer than 1 character, ${h.length} (equals to ${h}). Please split it into separate characters and put into array as separate elements.`);if(!a||!Array.isArray(a)||Array.isArray(a)&&!a.length||Array.isArray(a)&&1===a.length&&p(a[0])&&!a[0].trim()){if("function"==typeof s.cb){let n,i=r;if("matchLeftIncl"!==e&&"matchRight"!==e||(i+=1),"L"===e[5])for(let e=i;e--;){const r=t[e];if((!s.trimBeforeMatching||s.trimBeforeMatching&&void 0!==r&&r.trim())&&(!s.trimCharsBeforeMatching||!s.trimCharsBeforeMatching.length||void 0!==r&&!s.trimCharsBeforeMatching.includes(r))){n=e;break}}else if(e.startsWith("matchRight"))for(let e=i;e<t.length;e++){const r=t[e];if((!s.trimBeforeMatching||s.trimBeforeMatching&&r.trim())&&(!s.trimCharsBeforeMatching||!s.trimCharsBeforeMatching.length||!s.trimCharsBeforeMatching.includes(r))){n=e;break}}if(void 0===n)return!1;const o=t[n],a=n+1;let l="";return a&&a>0&&(l=t.slice(0,a)),"L"===e[5]?s.cb(o,l,n):(n&&n>0&&(l=t.slice(n)),s.cb(o,l,n))}let n="";throw i||(n=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${n}`)}for(let n=0,i=a.length;n<i;n++){l="function"==typeof a[n];const i=a[n];let o,u,h="",f=r;"matchRight"===e?f+=1:"matchLeft"===e&&(f-=1);const c=y(t,f,i,s,l,(t=>"L"===e[5]?t-1:t+1));if(c&&l&&"function"==typeof i&&"EOL"===i())return!(!i()||s.cb&&!s.cb(o,h,u))&&i();if(Number.isInteger(c)&&(u=e.startsWith("matchLeft")?c-1:c+1,h="L"===e[5]?t.slice(0,c):t.slice(u)),u<0&&(u=void 0),t[u]&&(o=t[u]),Number.isInteger(c)&&(!s.cb||s.cb(o,h,u)))return i}return!1}function b(e,t,r,n){return T("matchLeft",e,t,r,n)}function w(e,t,r,n){return T("matchRightIncl",e,t,r,n)}function _(e,t,r,n){return T("matchRight",e,t,r,n)}
|
|
70
106
|
/**
|
|
71
107
|
* @name string-range-expander
|
|
72
108
|
* @fileoverview Expands string index ranges within whitespace boundaries until letters are met
|
|
73
|
-
* @version 3.0.
|
|
109
|
+
* @version 3.0.10
|
|
74
110
|
* @author Roy Revelt, Codsen Ltd
|
|
75
111
|
* @license MIT
|
|
76
112
|
* {@link https://codsen.com/os/string-range-expander/}
|
|
77
|
-
*/const v={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function O(e){const t=/^[0-9a-zA-Z]+$/;function r(e){return!(!e||"string"!=typeof e)&&!e.trim()}function n(e){return"string"==typeof e}if(!e||"object"!=typeof e||Array.isArray(e)){let t;throw t=void 0===e?"but it is missing completely.":null===e?"but it was given as null.":`but it was given as ${typeof e}, equal to:\n${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${t}`)}if("object"==typeof e&&null!==e&&!Array.isArray(e)&&!Object.keys(e).length)throw new Error("string-range-expander: [THROW_ID_02] Input must be a plain object but it was given as a plain object without any keys.");if("number"!=typeof e.from)throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value opts.from, is not a number! Currently it's given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if("number"!=typeof e.to)throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value opts.to, is not a number! Currently it's given as ${typeof e.to}, equal to ${JSON.stringify(e.to,null,0)}`);if(e&&e.str&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string opts.str ("${e.str}") must contain the character at index "from" ("${e.from}")`);if(e&&e.str&&!e.str[e.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, opts.str ("${e.str}") must contain the character at index before "to" ("${e.to-1}")`);if(e.from>e.to)throw new Error(`string-range-expander: [THROW_ID_07] The given "from" index, "${e.from}" is greater than "to" index, "${e.to}". That's wrong!`);if(n(e.extendToOneSide)&&"left"!==e.extendToOneSide&&"right"!==e.extendToOneSide||!n(e.extendToOneSide)&&void 0!==e.extendToOneSide&&!1!==e.extendToOneSide)throw new Error(`string-range-expander: [THROW_ID_08] The opts.extendToOneSide value is not recogniseable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);const i={...v,...e};if(Array.isArray(i.ifLeftSideIncludesThisThenCropTightly)){let e,t;if(!i.ifLeftSideIncludesThisThenCropTightly.every(((r,i)=>!!n(r)||(e=i,t=r,!1))))throw new Error(`string-range-expander: [THROW_ID_09] The opts.ifLeftSideIncludesThisThenCropTightly was set to an array:\n${JSON.stringify(i.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${e} is of a type ${typeof t} (equal to ${JSON.stringify(t,null,0)}).`);i.ifLeftSideIncludesThisThenCropTightly=i.ifLeftSideIncludesThisThenCropTightly.join("")}const s=i.str;let o=i.from,a=i.to;if("right"!==i.extendToOneSide&&(r(s[o-1])&&(r(s[o-2])||i.ifLeftSideIncludesThisCropItToo.includes(s[o-2]))||s[o-1]&&i.ifLeftSideIncludesThisCropItToo.includes(s[o-1])||i.wipeAllWhitespaceOnLeft&&r(s[o-1])))for(let e=o;e--;)if(!i.ifLeftSideIncludesThisCropItToo.includes(s[e])){if(s[e].trim()){o=i.wipeAllWhitespaceOnLeft||i.ifLeftSideIncludesThisCropItToo.includes(s[e+1])?e+1:e+2;break}if(0===e){o=i.wipeAllWhitespaceOnLeft?0:1;break}}if("left"!==i.extendToOneSide&&(r(s[a])&&(i.wipeAllWhitespaceOnRight||r(s[a+1]))||i.ifRightSideIncludesThisCropItToo.includes(s[a])))for(let e=a,t=s.length;e<t;e++)if(!i.ifRightSideIncludesThisCropItToo.includes(s[e])&&(s[e]&&s[e].trim()||void 0===s[e])){a=i.wipeAllWhitespaceOnRight||i.ifRightSideIncludesThisCropItToo.includes(s[e-1])?e:e-1;break}return("right"!==i.extendToOneSide&&n(i.ifLeftSideIncludesThisThenCropTightly)&&i.ifLeftSideIncludesThisThenCropTightly&&(s[o-2]&&i.ifLeftSideIncludesThisThenCropTightly.includes(s[o-2])||s[o-1]&&i.ifLeftSideIncludesThisThenCropTightly.includes(s[o-1]))||"left"!==i.extendToOneSide&&n(i.ifRightSideIncludesThisThenCropTightly)&&i.ifRightSideIncludesThisThenCropTightly&&(s[a+1]&&i.ifRightSideIncludesThisThenCropTightly.includes(s[a+1])||s[a]&&i.ifRightSideIncludesThisThenCropTightly.includes(s[a])))&&("right"!==i.extendToOneSide&&r(s[o-1])&&!i.wipeAllWhitespaceOnLeft&&(o-=1),"left"!==i.extendToOneSide&&r(s[a])&&!i.wipeAllWhitespaceOnRight&&(a+=1)),i.addSingleSpaceToPreventAccidentalConcatenation&&s[o-1]&&s[o-1].trim()&&s[a]&&s[a].trim()&&(!i.ifLeftSideIncludesThisThenCropTightly&&!i.ifRightSideIncludesThisThenCropTightly||i.ifLeftSideIncludesThisThenCropTightly&&!i.ifLeftSideIncludesThisThenCropTightly.includes(s[o-1])||!(!i.ifRightSideIncludesThisThenCropTightly||s[a]&&i.ifRightSideIncludesThisThenCropTightly.includes(s[a])))&&(t.test(s[o-1])||t.test(s[a]))?[o,a," "]:[o,a]}var I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};Function.prototype.toString.call(Object);var L={exports:{}};!function(e,t){var r="__lodash_hash_undefined__",n=9007199254740991,i="[object Arguments]",s="[object Boolean]",o="[object Date]",a="[object Function]",l="[object GeneratorFunction]",u="[object Map]",h="[object Number]",f="[object Object]",c="[object Promise]",g="[object RegExp]",p="[object Set]",m="[object String]",d="[object Symbol]",y="[object WeakMap]",T="[object ArrayBuffer]",b="[object DataView]",w="[object Float32Array]",_="[object Float64Array]",v="[object Int8Array]",O="[object Int16Array]",L="[object Int32Array]",A="[object Uint8Array]",S="[object Uint8ClampedArray]",$="[object Uint16Array]",C="[object Uint32Array]",R=/\w*$/,M=/^\[object .+?Constructor\]$/,j=/^(?:0|[1-9]\d*)$/,x={};x[i]=x["[object Array]"]=x[T]=x[b]=x[s]=x[o]=x[w]=x[_]=x[v]=x[O]=x[L]=x[u]=x[h]=x[f]=x[g]=x[p]=x[m]=x[d]=x[A]=x[S]=x[$]=x[C]=!0,x["[object Error]"]=x[a]=x[y]=!1;var W="object"==typeof self&&self&&self.Object===Object&&self,E="object"==typeof I&&I&&I.Object===Object&&I||W||Function("return this")(),F=t&&!t.nodeType&&t,N=F&&e&&!e.nodeType&&e,H=N&&N.exports===F;function k(e,t){return e.set(t[0],t[1]),e}function B(e,t){return e.add(t),e}function D(e,t,r,n){var i=-1,s=e?e.length:0;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}function J(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function P(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function q(e,t){return function(r){return e(t(r))}}function U(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var z,V=Array.prototype,G=Function.prototype,Y=Object.prototype,Z=E["__core-js_shared__"],K=(z=/[^.]+$/.exec(Z&&Z.keys&&Z.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"",Q=G.toString,X=Y.hasOwnProperty,ee=Y.toString,te=RegExp("^"+Q.call(X).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=H?E.Buffer:void 0,ne=E.Symbol,ie=E.Uint8Array,se=q(Object.getPrototypeOf,Object),oe=Object.create,ae=Y.propertyIsEnumerable,le=V.splice,ue=Object.getOwnPropertySymbols,he=re?re.isBuffer:void 0,fe=q(Object.keys,Object),ce=Ne(E,"DataView"),ge=Ne(E,"Map"),pe=Ne(E,"Promise"),me=Ne(E,"Set"),de=Ne(E,"WeakMap"),ye=Ne(Object,"create"),Te=Je(ce),be=Je(ge),we=Je(pe),_e=Je(me),ve=Je(de),Oe=ne?ne.prototype:void 0,Ie=Oe?Oe.valueOf:void 0;function Le(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ae(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Se(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function $e(e){this.__data__=new Ae(e)}function Ce(e,t){var r=qe(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Ue(e)}(e)&&X.call(e,"callee")&&(!ae.call(e,"callee")||ee.call(e)==i)}(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],n=r.length,s=!!n;for(var o in e)!t&&!X.call(e,o)||s&&("length"==o||Be(o,n))||r.push(o);return r}function Re(e,t,r){var n=e[t];X.call(e,t)&&Pe(n,r)&&(void 0!==r||t in e)||(e[t]=r)}function Me(e,t){for(var r=e.length;r--;)if(Pe(e[r][0],t))return r;return-1}function je(e,t,r,n,c,y,I){var M;if(n&&(M=y?n(e,c,y,I):n(e)),void 0!==M)return M;if(!Ge(e))return e;var j=qe(e);if(j){if(M=function(e){var t=e.length,r=e.constructor(t);t&&"string"==typeof e[0]&&X.call(e,"index")&&(r.index=e.index,r.input=e.input);return r}(e),!t)return function(e,t){var r=-1,n=e.length;t||(t=Array(n));for(;++r<n;)t[r]=e[r];return t}(e,M)}else{var W=ke(e),E=W==a||W==l;if(ze(e))return function(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}(e,t);if(W==f||W==i||E&&!y){if(J(e))return y?e:{};if(M=function(e){return"function"!=typeof e.constructor||De(e)?{}:(t=se(e),Ge(t)?oe(t):{});var t}(E?{}:e),!t)return function(e,t){return Ee(e,He(e),t)}(e,function(e,t){return e&&Ee(t,Ye(t),e)}(M,e))}else{if(!x[W])return y?e:{};M=function(e,t,r,n){var i=e.constructor;switch(t){case T:return We(e);case s:case o:return new i(+e);case b:return function(e,t){var r=t?We(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,n);case w:case _:case v:case O:case L:case A:case S:case $:case C:return function(e,t){var r=t?We(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,n);case u:return function(e,t,r){return D(t?r(P(e),!0):P(e),k,new e.constructor)}(e,n,r);case h:case m:return new i(e);case g:return function(e){var t=new e.constructor(e.source,R.exec(e));return t.lastIndex=e.lastIndex,t}(e);case p:return function(e,t,r){return D(t?r(U(e),!0):U(e),B,new e.constructor)}(e,n,r);case d:return a=e,Ie?Object(Ie.call(a)):{}}var a}(e,W,je,t)}}I||(I=new $e);var F=I.get(e);if(F)return F;if(I.set(e,M),!j)var N=r?function(e){return function(e,t,r){var n=t(e);return qe(e)?n:function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}(n,r(e))}(e,Ye,He)}(e):Ye(e);return function(e,t){for(var r=-1,n=e?e.length:0;++r<n&&!1!==t(e[r],r,e););}(N||e,(function(i,s){N&&(i=e[s=i]),Re(M,s,je(i,t,r,n,s,e,I))})),M}function xe(e){return!(!Ge(e)||(t=e,K&&K in t))&&(Ve(e)||J(e)?te:M).test(Je(e));var t}function We(e){var t=new e.constructor(e.byteLength);return new ie(t).set(new ie(e)),t}function Ee(e,t,r,n){r||(r={});for(var i=-1,s=t.length;++i<s;){var o=t[i],a=n?n(r[o],e[o],o,r,e):void 0;Re(r,o,void 0===a?e[o]:a)}return r}function Fe(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function Ne(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return xe(r)?r:void 0}Le.prototype.clear=function(){this.__data__=ye?ye(null):{}},Le.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Le.prototype.get=function(e){var t=this.__data__;if(ye){var n=t[e];return n===r?void 0:n}return X.call(t,e)?t[e]:void 0},Le.prototype.has=function(e){var t=this.__data__;return ye?void 0!==t[e]:X.call(t,e)},Le.prototype.set=function(e,t){return this.__data__[e]=ye&&void 0===t?r:t,this},Ae.prototype.clear=function(){this.__data__=[]},Ae.prototype.delete=function(e){var t=this.__data__,r=Me(t,e);return!(r<0)&&(r==t.length-1?t.pop():le.call(t,r,1),!0)},Ae.prototype.get=function(e){var t=this.__data__,r=Me(t,e);return r<0?void 0:t[r][1]},Ae.prototype.has=function(e){return Me(this.__data__,e)>-1},Ae.prototype.set=function(e,t){var r=this.__data__,n=Me(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Se.prototype.clear=function(){this.__data__={hash:new Le,map:new(ge||Ae),string:new Le}},Se.prototype.delete=function(e){return Fe(this,e).delete(e)},Se.prototype.get=function(e){return Fe(this,e).get(e)},Se.prototype.has=function(e){return Fe(this,e).has(e)},Se.prototype.set=function(e,t){return Fe(this,e).set(e,t),this},$e.prototype.clear=function(){this.__data__=new Ae},$e.prototype.delete=function(e){return this.__data__.delete(e)},$e.prototype.get=function(e){return this.__data__.get(e)},$e.prototype.has=function(e){return this.__data__.has(e)},$e.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ae){var n=r.__data__;if(!ge||n.length<199)return n.push([e,t]),this;r=this.__data__=new Se(n)}return r.set(e,t),this};var He=ue?q(ue,Object):function(){return[]},ke=function(e){return ee.call(e)};function Be(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||j.test(e))&&e>-1&&e%1==0&&e<t}function De(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Y)}function Je(e){if(null!=e){try{return Q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Pe(e,t){return e===t||e!=e&&t!=t}(ce&&ke(new ce(new ArrayBuffer(1)))!=b||ge&&ke(new ge)!=u||pe&&ke(pe.resolve())!=c||me&&ke(new me)!=p||de&&ke(new de)!=y)&&(ke=function(e){var t=ee.call(e),r=t==f?e.constructor:void 0,n=r?Je(r):void 0;if(n)switch(n){case Te:return b;case be:return u;case we:return c;case _e:return p;case ve:return y}return t});var qe=Array.isArray;function Ue(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}(e.length)&&!Ve(e)}var ze=he||function(){return!1};function Ve(e){var t=Ge(e)?ee.call(e):"";return t==a||t==l}function Ge(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ye(e){return Ue(e)?Ce(e):function(e){if(!De(e))return fe(e);var t=[];for(var r in Object(e))X.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}e.exports=function(e){return je(e,!0,!0)}}(L,L.exports);
|
|
78
|
-
/**
|
|
79
|
-
* @name string-left-right
|
|
80
|
-
* @fileoverview Looks up the first non-whitespace character to the left/right of a given index
|
|
81
|
-
* @version 5.0.4
|
|
82
|
-
* @author Roy Revelt, Codsen Ltd
|
|
83
|
-
* @license MIT
|
|
84
|
-
* {@link https://codsen.com/os/string-left-right/}
|
|
85
113
|
*/
|
|
86
|
-
const A=" ";function S(e,t=0){return function({str:e,idx:t=0,stopAtNewlines:r=!1,stopAtRawNbsp:n=!1}){if("string"!=typeof e||!e.length)return null;if(t&&"number"==typeof t||(t=0),!e[t+1])return null;if(e[t+1]&&(e[t+1].trim()||r&&"\n\r".includes(e[t+1])||n&&e[t+1]===A))return t+1;if(e[t+2]&&(e[t+2].trim()||r&&"\n\r".includes(e[t+2])||n&&e[t+2]===A))return t+2;for(let i=t+1,s=e.length;i<s;i++)if(e[i].trim()||r&&"\n\r".includes(e[i])||n&&e[i]===A)return i;return null}({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function $(e,t=0){return function({str:e,idx:t,stopAtNewlines:r,stopAtRawNbsp:n}){if("string"!=typeof e||!e.length)return null;if(t&&"number"==typeof t||(t=0),t<1)return null;if(e[~-t]&&(e[~-t].trim()||r&&"\n\r".includes(e[~-t])||n&&e[~-t]===A))return~-t;if(e[t-2]&&(e[t-2].trim()||r&&"\n\r".includes(e[t-2])||n&&e[t-2]===A))return t-2;for(let i=t;i--;)if(e[i]&&(e[i].trim()||r&&"\n\r".includes(e[i])||n&&e[i]===A))return i;return null}({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}const C=new class{constructor(e){const t={...c,...e};if(t.mergeType&&1!==t.mergeType&&2!==t.mergeType)if(f(t.mergeType)&&"1"===t.mergeType.trim())t.mergeType=1;else{if(!f(t.mergeType)||"2"!==t.mergeType.trim())throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);t.mergeType=2}this.opts=t,this.ranges=[]}ranges;opts;add(e,t,r){if(null==e&&null==t)return;if(u(e)&&!u(t)){if(Array.isArray(e)){if(e.length){if(e.some((e=>Array.isArray(e))))return void e.forEach((e=>{Array.isArray(e)&&this.add(...e)}));e.length&&h(+e[0])&&h(+e[1])&&this.add(...e)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(e,null,0)}) but second-one, "to" is not (${JSON.stringify(t,null,0)})`)}if(!u(e)&&u(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);const n=+e,i=+t;if(h(r)&&(r=String(r)),!h(n)||!h(i))throw h(n)&&n>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof i}" equal to: ${JSON.stringify(i,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof n}" equal to: ${JSON.stringify(n,null,4)}`);if(u(r)&&!f(r)&&!h(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:\n${JSON.stringify(r,null,4)}`);if(u(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=i,this.last(),null!==this.last()[2]&&u(r)){let e=!(this.last()[2]&&this.last()[2].length>0)||this.opts&&this.opts.mergeType&&1!==this.opts.mergeType?r:this.last()[2]+r;this.opts.limitToBeAddedWhitespace&&(e=s(e,this.opts.limitLinebreaksCount)),f(e)&&!e.length||(this.last()[2]=e)}}else{this.ranges||(this.ranges=[]);const e=void 0===r||f(r)&&!r.length?[n,i]:[n,i,r&&this.opts.limitToBeAddedWhitespace?s(r,this.opts.limitLinebreaksCount):r];this.ranges.push(e)}}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=function(e,t){function r(e){return e&&"object"==typeof e&&!Array.isArray(e)}if(!Array.isArray(e)||!e.length)return null;let n;if(t){if(!r(t))throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:\n${JSON.stringify(t,null,4)} (type ${typeof t})`);if(n={...l,...t},n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&"function"!=typeof n.progressFn)throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(n.mergeType&&1!=+n.mergeType&&2!=+n.mergeType)throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if("boolean"!=typeof n.joinRangesThatTouchEdges)throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else n={...l};const i=e.filter((e=>e)).map((e=>[...e])).filter((e=>void 0!==e[2]||e[0]!==e[1]));let s,o,u;if(s=n.progressFn?a(i,{progressFn:e=>{u=Math.floor(e/5),u!==o&&(o=u,n.progressFn(u))}}):a(i),!s)return null;const h=s.length-1;for(let e=h;e>0;e--)n.progressFn&&(u=Math.floor(78*(1-e/h))+21,u!==o&&u>o&&(o=u,n.progressFn(u))),(s[e][0]<=s[e-1][0]||!n.joinRangesThatTouchEdges&&s[e][0]<s[e-1][1]||n.joinRangesThatTouchEdges&&s[e][0]<=s[e-1][1])&&(s[e-1][0]=Math.min(s[e][0],s[e-1][0]),s[e-1][1]=Math.max(s[e][1],s[e-1][1]),void 0!==s[e][2]&&(s[e-1][0]>=s[e][0]||s[e-1][1]<=s[e][1])&&null!==s[e-1][2]&&(null===s[e][2]&&null!==s[e-1][2]?s[e-1][2]=null:null!=s[e-1][2]?2==+n.mergeType&&s[e-1][0]===s[e][0]?s[e-1][2]=s[e][2]:s[e-1][2]+=s[e][2]:s[e-1][2]=s[e][2]),s.splice(e,1),e=s.length);return s.length?s:null}(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map((e=>u(e[2])?[e[0],e[1],s(e[2],this.opts.limitLinebreaksCount)]:e)):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length){if(!Array.isArray(e[0])||!h(e[0][0]))throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);this.ranges=Array.from(e)}else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}}({limitToBeAddedWhitespace:!0}),R={lineLengthLimit:500,removeIndentations:!0,removeLineBreaks:!1,removeHTMLComments:!1,removeCSSComments:!0,reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,breakToTheLeftOf:["</td","<html","</html","<head","</head","<meta","<link","<table","<script","</script","<!DOCTYPE","<style","</style","<title","<body","@media","</body","\x3c!--[if","\x3c!--<![endif","<![endif]"],mindTheInlineTags:["a","abbr","acronym","audio","b","bdi","bdo","big","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","label","map","mark","meter","noscript","object","output","picture","progress","q","ruby","s","samp","script","select","slot","small","span","strong","sub","sup","svg","template","textarea","time","u","tt","var","video","wbr"]},M={removeHTMLComments:!1,removeCSSComments:!1};function j(e){return"string"==typeof e}function x(e){return"string"==typeof e&&e.toUpperCase()!==e.toLowerCase()}e.crush=function(e,t){const r=Date.now();if(!j(e))throw void 0===e?new Error("html-crush: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`html-crush: [THROW_ID_02] the first input argument must be string! It was given as "${typeof e}", equal to:\n${JSON.stringify(e,null,4)}`);if(t&&"object"!=typeof t)throw new Error(`html-crush: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof t}, equal to ${JSON.stringify(t,null,4)}`);if(t&&Array.isArray(t.breakToTheLeftOf)&&t.breakToTheLeftOf.length)for(let e=0,r=t.breakToTheLeftOf.length;e<r;e++)if(!j(t.breakToTheLeftOf[e]))throw new TypeError(`html-crush: [THROW_ID_05] the opts.breakToTheLeftOf array contains non-string elements! For example, element at index ${e} is of a type "${typeof t.breakToTheLeftOf[e]}" and is equal to:\n${JSON.stringify(t.breakToTheLeftOf[e],null,4)}`);const n={...R,...t};"boolean"==typeof n.removeHTMLComments&&(n.removeHTMLComments=n.removeHTMLComments?1:0);let s="";Array.isArray(n.breakToTheLeftOf)&&n.breakToTheLeftOf.length&&(s=[...new Set(n.breakToTheLeftOf.map((e=>e[0])))].join(""));let o,a=null,l=null,u=!1,h=0,f=0,c=!1,g=!1,p=null,m=null,d=null,y=null,T=null,v=null,I=null,L=null,A=null,W=null;const E=">};",F="<",N="!",H=">",k="<",B="{},:;<>~+",D=B,J=B;let P=!0;const q=e.length,U=Math.floor(q/2);let z,V;n.reportProgressFunc&&(z=Math.floor(n.reportProgressFuncTo-.01*(n.reportProgressFuncTo-n.reportProgressFuncFrom)-n.reportProgressFuncFrom));let G=0,Y="\n";if(e.includes("\r\n")?Y="\r\n":e.includes("\r")&&(Y="\r"),q){for(let t=0;t<q;t++)if(n.reportProgressFunc&&(q>1e3&&q<2e3?t===U&&n.reportProgressFunc(Math.floor((n.reportProgressFuncTo-n.reportProgressFuncFrom)/2)):q>=2e3&&(V=n.reportProgressFuncFrom+Math.floor(t/q*(z||1)),V!==G&&(G=V,n.reportProgressFunc(V)))),f++,!o&&c&&"}"===e[t]&&"}"===e[t-1]&&(h+1>=n.lineLengthLimit?(C.push(t,t,Y),h=0):(T=t,v=t,I=" ")),o&&"number"==typeof o&&t>=o&&(o=void 0),null===y||!e.startsWith("</script",t)||x(e[t+8])){if(!o&&!c&&e.startsWith("<script",t)&&!x(e[t+7])){y=t,o=!0;let e="";(n.removeLineBreaks||n.removeIndentations)&&null!==l&&(l>0&&(e=Y),C.push(l,t,e)),l=null,a=null}if(null!==A&&null===L&&!/\w/.test(e[t])){L=e.slice(A,t);const r=S(e,~-t);"number"==typeof r&&">"===e[r]&&!e[t].trim()&&S(e,t)?C.push(t,S(e,t)):r&&"/"===e[r]&&">"===e[S(e,r)]&&(!e[t].trim()&&S(e,t)&&C.push(t,S(e,t)),">"!==e[r+1]&&S(e,r+1)&&C.push(r+1,S(e,r+1)))}if(o||c||p||"<"!==e[~-t]||null!==A||(/\w/.test(e[t])?A=t:"/"===e[S(e,~-t)]&&/\w/.test(e[S(e,S(e,~-t))]||"")&&(A=S(e,S(e,~-t)))),o||!c&&!p||null===m||"*"!==e[t]||"/"!==e[t+1]||([T,v]=O({str:e,from:m,to:t+2,ifLeftSideIncludesThisThenCropTightly:D,ifRightSideIncludesThisThenCropTightly:J}),m=null,null!=T?C.push(T,v):(h+=1,t+=1),o=t+2),o||!c&&!p||null!==m||"/"!==e[t]||"*"!==e[t+1]||(M.removeCSSComments||(M.removeCSSComments=!0),n.removeCSSComments&&(m=t)),g&&e.startsWith("![endif",t+1)&&(g=!1),!o&&!c&&!p&&null!==d){let r;e.startsWith("--\x3e",t)?r=3:">"===e[t]&&"]"===e[t-1]&&(r=1),r&&([T,v]=O({str:e,from:d,to:t+r}),d=null,null!=T?n.lineLengthLimit&&f-(v-T)>=n.lineLengthLimit?(C.push(T,v,Y),f=-r):(C.push(T,v),f-=v-T):(h+=r-1,t+=r-1),o=t+r)}if(o||c||p||!e.startsWith("\x3c!--",t)||null!==d||(e.startsWith("[if",t+4)?(g||(g=!0),2===n.removeHTMLComments&&(d=t)):!n.removeHTMLComments||g&&2!==n.removeHTMLComments||(d=t),M.removeHTMLComments||(M.removeHTMLComments=!0)),!o&&c&&null===m&&e.startsWith("</style",t)&&!x(e[t+7])?c=!1:o||c||null!==m||!e.startsWith("<style",t)||x(e[t+6])||(c=!0,(n.removeLineBreaks||n.removeIndentations)&&n.breakToTheLeftOf.includes("<style")&&e.startsWith(' type="text/css">',t+6)&&e[t+24]&&C.push(t+23,t+23,Y)),!o&&!p&&"\"'".includes(e[t])&&e.endsWith("style=",t)&&(p=t),o||e[t].trim()){if(!o&&(!c&&!p||null===m)){if(null!==l){if(n.removeLineBreaks&&(h+=1),P)P=!1,(n.removeIndentations||n.removeLineBreaks)&&C.push(0,t);else if(n.removeIndentations&&!n.removeLineBreaks&&(!u&&null!==a&&t>a?C.push(a+1,t):l+1<t&&(e.endsWith("]>",l)||e.endsWith("--\x3e",l)||e.startsWith("<![",t)||e.startsWith("\x3c!--<![",t)?C.push(l,t):" "===e[l]?C.push(l+1,t):" "===e[~-t]?C.push(l,~-t):C.push(l,t," "))),n.removeLineBreaks||p){if(s.includes(e[t])&&w(e,t,n.breakToTheLeftOf)){"\r\n".includes(e[~-t])&&l===~-t||"\n"===e[~-t]&&"\r"===e[t-2]&&l===t-2||C.push(l,t,Y),T=null,v=null,I=null,l=null,h=1;continue}let r=" ";"<"===e[t]&&_(e,t,n.mindTheInlineTags,{cb:e=>!e||!/\w/.test(e)})||(e[~-l]&&H.includes(e[~-l])&&k.includes(e[t])||(c||p)&&null===m&&(D.includes(e[~-l])||J.includes(e[t]))||e.startsWith("!important",t)&&!g||p&&("'"===e[~-l]||'"'===e[~-l])||"}"===e[~-l]&&e.startsWith("</style",t)||">"===e[t]&&("'\"".includes(e[$(e,t)])||"<"===e[S(e,t)])||"/"===e[t]&&">"===e[S(e,t)])&&(r="","/"===e[t]&&">"===e[t+1]&&S(e,t)&&S(e,t)>t+1&&(C.push(t+1,S(e,t)),h-=S(e,t)-t+1)),c&&"}"===e[t]&&l&&"}"===e[l-1]&&(r=" "),r&&r.length&&(h+=1),n.lineLengthLimit?h>=n.lineLengthLimit||!e[t+1]||">"===e[t]||"/"===e[t]&&">"===e[t+1]?((h>n.lineLengthLimit||h===n.lineLengthLimit&&e[t+1]&&e[t+1].trim()&&!E.includes(e[t])&&!F.includes(e[t+1]))&&(r=Y,h=1),(h>n.lineLengthLimit||" "!==r||t!==l+1)&&(C.push(l,t,r),a=null),T=null,v=null,I=null):(null===T||l<T)&&(T=l,v=t,I=r):t===l+1&&" "===r||C.push(l,t,r)}l=null,u||(u=!0)}else P&&(P=!1),n.removeLineBreaks&&(h+=1);u||(u=!0)}}else null===l&&(l=t);if(!o&&!P&&0!==t&&n.removeLineBreaks&&(n.lineLengthLimit||s)&&!e.startsWith("</a",t)){if(s&&w(e,t,n.breakToTheLeftOf)&&e.slice(0,t).trim()&&(!e.startsWith("<![endif]",t)||!b(e,t,"\x3c!--"))){C.push(t,t,Y),T=null,v=null,I=null,h=1;continue}if(n.lineLengthLimit&&h<=n.lineLengthLimit){if(!e[t+1]||F.includes(e[t])&&!N.includes(e[t])||E.includes(e[t])||!e[t].trim()){if(null!==T&&null!==v&&(T!==v||I&&I.length)){let r=I;e[t].trim()&&e[t+1]&&e[t+1].trim()&&h+(I?I.length:0)>n.lineLengthLimit&&(r=Y),(h+(r?r.length:0)>n.lineLengthLimit||" "!==r||v!==T+1||" "!==e[T])&&("}"===e[~-T]&&"{"===e[v]||(C.push(T,v,r),a=null))}!(e[t].trim()&&(F.includes(e[t])||e[~-t]&&E.includes(e[~-t]))&&j(W))||L&&n.mindTheInlineTags.includes(L)||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{cb:e=>!e||!/\w/.test(e)})||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)})?null!==m||null===T||!(p||!n.mindTheInlineTags||!Array.isArray(n.mindTheInlineTags)||Array.isArray(n.mindTheInlineTags.length)&&!n.mindTheInlineTags.length||!j(L)||Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&j(L)&&!n.mindTheInlineTags.includes(L))||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)})||(T=null,v=null,I=null):(T=t,v=t,I=null)}}else if(n.lineLengthLimit)if(!F.includes(e[t])||"<"===e[t]&&_(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)}))e[t+1]&&E.includes(e[t])&&j(L)&&Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&!n.mindTheInlineTags.includes(L)?null!==T&&null!==v&&(T!==v||I&&I.length)||(C.push(t+1,t+1,Y),h=0):e[t].trim()&&(e[t+1]||null!==T&&null!==v&&(T!==v||I&&I.length)&&C.push(T,v,Y));else if(null!==T&&null!==v&&(T!==v||I&&I.length)){const e=I&&I.length?I.length:0;h-(v-T-e)-1>n.lineLengthLimit||(C.push(T,v,I),h-(v-T-e)-1===n.lineLengthLimit&&(C.push(t,t,Y),h=0),T=null,v=null,I=null)}else C.push(t,t,Y),h=0}if(!o&&!P&&n.removeLineBreaks&&n.lineLengthLimit&&h>=n.lineLengthLimit&&null!==T&&null!==v&&!E.includes(e[t])&&!F.includes(e[t])&&!"/".includes(e[t])&&(h!==n.lineLengthLimit||!e[t+1]||e[t+1].trim())){let r=Y;e[t+1]&&!e[t+1].trim()&&h===n.lineLengthLimit&&(r=I),r===Y&&!e[~-T].trim()&&$(e,T)&&(T=$(e,T)+1),C.push(T,v,r),h=t-v,e[t].length&&(h+=1),T=null,v=null,I=null}if((!o&&"\n"===e[t]||"\r"===e[t]&&(!e[t+1]||e[t+1]&&"\n"!==e[t+1]))&&(a=t,u&&(u=!1),!n.removeLineBreaks&&null!==l&&l<t&&e[t+1]&&"\r"!==e[t+1]&&"\n"!==e[t+1]&&C.push(l,t)),e[t+1]||(c&&null!==m?C.push(...O({str:e,from:m,to:t,ifLeftSideIncludesThisThenCropTightly:D,ifRightSideIncludesThisThenCropTightly:J})):l&&"\n"!==e[t]&&"\r"!==e[t]?C.push(l,t+1):l&&("\r"===e[t]&&"\n"===e[t+1]||"\n"===e[t]&&"\r"!==e[t-1])&&C.push(l,t)),!o&&p&&p<t&&e[p]===e[t]&&(p=null),!o&&!c&&e.startsWith("<pre",t)&&!x(e[t+4])){const r=e.indexOf("</pre",t+5);r>0&&(o=r)}if(!o&&!c&&e.startsWith("<code",t)&&!x(e[t+5])){const r=e.indexOf("</code",t+5);r>0&&(o=r)}if(!o&&e.startsWith("<![CDATA[",t)){const r=e.indexOf("]]>",t+9);r>0&&(o=r)}o||c||p||null===A||">"!==e[t]||("<"===e[S(e,t)]&&(W=L),A=null,L=null),"<"===e[t]&&null!==W&&(W=null),c&&"{"===e[t]&&"{"===e[t+1]&&-1!==e.indexOf("}}")&&(o=e.indexOf("}}")+2)}else{if((n.removeIndentations||n.removeLineBreaks)&&t>0&&e[~-t]&&!e[~-t].trim())for(let r=t;r--;)if("\n"===e[r]||"\r"===e[r]||e[r].trim()){r+1<t&&C.push(r+1,t);break}y=null,o=!1,t+=8}if(C.current()){const t=C.current();C.wipe();const s=n.reportProgressFuncTo-.01*(n.reportProgressFuncTo-n.reportProgressFuncFrom),o=function(e,t,r){let n,s=0,o=0;if(0===arguments.length)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if("string"!=typeof e)throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&"function"!=typeof r)throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter((e=>e)).length)return e;n=Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?[Array.from(t)]:Array.from(t);const a=n.length;let l=0;n.filter((e=>e)).forEach(((e,t)=>{if(r&&(s=Math.floor(l/a*10),s!==o&&(o=s,r(s))),!Array.isArray(e))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${t}th element not an array: ${JSON.stringify(e,null,4)}, which is ${typeof e}`);if(!Number.isInteger(e[0])){if(!Number.isInteger(+e[0])||+e[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${t}th element, array ${JSON.stringify(e,null,0)}. Its first element is not an integer, string index, but ${typeof e[0]}, equal to: ${JSON.stringify(e[0],null,4)}.`);n[t][0]=+n[t][0]}if(!Number.isInteger(e[1])){if(!Number.isInteger(+e[1])||+e[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${t}th element, array ${JSON.stringify(e,null,0)}. Its second element is not an integer, string index, but ${typeof e[1]}, equal to: ${JSON.stringify(e[1],null,4)}.`);n[t][1]=+n[t][1]}l+=1}));const u=i(n,{progressFn:e=>{r&&(s=10+Math.floor(e/10),s!==o&&(o=s,r(s)))}}),h=Array.isArray(u)?u.length:0;if(h>0){const t=e.slice(u[h-1][1]);e=u.reduce(((t,n,i,a)=>(r&&(s=20+Math.floor(i/h*80),s!==o&&(o=s,r(s))),t+e.slice(0===i?0:a[i-1][1],a[i][0])+(a[i][2]||""))),""),e+=t}return e}(e,t,(e=>{n.reportProgressFunc&&q>=2e3&&(V=Math.floor(s+e/100*(n.reportProgressFuncTo-s)),V!==G&&(G=V,n.reportProgressFunc(V)))})),a=o.length;return{log:{timeTakenInMilliseconds:Date.now()-r,originalLength:q,cleanedLength:a,bytesSaved:Math.max(q-a,0),percentageReducedOfOriginal:q?Math.round(100*Math.max(q-a,0)/q):0},ranges:t,applicableOpts:M,result:o}}}return{log:{timeTakenInMilliseconds:Date.now()-r,originalLength:q,cleanedLength:q,bytesSaved:0,percentageReducedOfOriginal:0},applicableOpts:M,ranges:null,result:e}},e.defaults=R,e.version="5.0.4",Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/examples/_quickTake.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-crush",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.10",
|
|
4
4
|
"description": "Minifies HTML/CSS: valid or broken, pure or mixed with other languages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"breaks",
|
|
@@ -43,107 +43,42 @@
|
|
|
43
43
|
},
|
|
44
44
|
"types": "types/index.d.ts",
|
|
45
45
|
"scripts": {
|
|
46
|
-
"build": "
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
|
|
59
|
-
"republish": "npm publish || :",
|
|
60
|
-
"tap": "tap",
|
|
61
|
-
"pretest": "npm run build",
|
|
62
|
-
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
63
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
64
|
-
"tsc": "tsc",
|
|
65
|
-
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
46
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
47
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
48
|
+
"dts": "rollup -c",
|
|
49
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
50
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
51
|
+
"letspublish": "yarn publish || :",
|
|
52
|
+
"lint": "eslint . --fix",
|
|
53
|
+
"perf": "node perf/check.js",
|
|
54
|
+
"prepare": "echo 'ready'",
|
|
55
|
+
"pretest": "yarn run lect && yarn run build",
|
|
56
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
57
|
+
"unit": "uvu test"
|
|
66
58
|
},
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"--no-warnings",
|
|
75
|
-
"--experimental-loader",
|
|
76
|
-
"@istanbuljs/esm-loader-hook"
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
61
|
+
},
|
|
62
|
+
"c8": {
|
|
63
|
+
"check-coverage": true,
|
|
64
|
+
"exclude": [
|
|
65
|
+
"**/test/**/*.*"
|
|
77
66
|
],
|
|
78
|
-
"
|
|
67
|
+
"lines": 100
|
|
79
68
|
},
|
|
80
69
|
"lect": {
|
|
81
70
|
"licence": {
|
|
82
71
|
"extras": [
|
|
83
72
|
""
|
|
84
73
|
]
|
|
85
|
-
},
|
|
86
|
-
"req": "{ crush, defaults, version }",
|
|
87
|
-
"various": {
|
|
88
|
-
"devDependencies": [
|
|
89
|
-
"@babel/polyfill",
|
|
90
|
-
"node-fetch",
|
|
91
|
-
"p-map"
|
|
92
|
-
]
|
|
93
74
|
}
|
|
94
75
|
},
|
|
95
76
|
"dependencies": {
|
|
96
|
-
"
|
|
97
|
-
"ranges-
|
|
98
|
-
"
|
|
99
|
-
"string-left-right": "^
|
|
100
|
-
"string-
|
|
101
|
-
"
|
|
102
|
-
"test-mixer": "^3.0.4"
|
|
103
|
-
},
|
|
104
|
-
"devDependencies": {
|
|
105
|
-
"@babel/cli": "^7.16.0",
|
|
106
|
-
"@babel/core": "^7.16.0",
|
|
107
|
-
"@babel/node": "^7.16.0",
|
|
108
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
109
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
110
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
111
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
112
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
113
|
-
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
114
|
-
"@babel/polyfill": "^7.12.1",
|
|
115
|
-
"@babel/preset-env": "^7.16.0",
|
|
116
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
117
|
-
"@babel/register": "^7.16.0",
|
|
118
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
119
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
120
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
121
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
122
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
123
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
124
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
125
|
-
"@types/node": "^16.11.6",
|
|
126
|
-
"@types/tap": "^15.0.5",
|
|
127
|
-
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
128
|
-
"@typescript-eslint/parser": "^5.3.0",
|
|
129
|
-
"core-js": "^3.19.1",
|
|
130
|
-
"cross-env": "^7.0.3",
|
|
131
|
-
"eslint": "^8.1.0",
|
|
132
|
-
"lect": "^0.18.4",
|
|
133
|
-
"node-fetch": "^3.0.0",
|
|
134
|
-
"p-map": "^5.3.0",
|
|
135
|
-
"rollup": "^2.59.0",
|
|
136
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
137
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
138
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
139
|
-
"rollup-plugin-dts": "^4.0.0",
|
|
140
|
-
"rollup-plugin-node-builtins": "^2.1.2",
|
|
141
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
142
|
-
"tap": "^15.0.10",
|
|
143
|
-
"tslib": "^2.3.1",
|
|
144
|
-
"typescript": "^4.4.4"
|
|
145
|
-
},
|
|
146
|
-
"engines": {
|
|
147
|
-
"node": ">=12"
|
|
77
|
+
"ranges-apply": "^6.0.10",
|
|
78
|
+
"ranges-push": "^6.0.10",
|
|
79
|
+
"string-left-right": "^5.0.10",
|
|
80
|
+
"string-match-left-right": "^8.0.10",
|
|
81
|
+
"string-range-expander": "^3.0.10",
|
|
82
|
+
"test-mixer": "^3.0.10"
|
|
148
83
|
}
|
|
149
84
|
}
|
package/types/index.d.ts
CHANGED
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport { crush, defaults, version } from \"html-crush\";\n\nassert.equal(\n crush(\n `<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n <tr>\n <td>\n hi\n </td>\n </tr>\n</table>`,\n { removeLineBreaks: true }\n ).result,\n `<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td> hi\n</td></tr></table>`\n);"}}
|