html-crush 4.1.10 → 5.0.2

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 CHANGED
@@ -3,6 +3,33 @@
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.1 (2021-09-13)
7
+
8
+ ### Bug Fixes
9
+
10
+ - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
11
+
12
+ ## 5.0.0 (2021-09-09)
13
+
14
+ ### Bug Fixes
15
+
16
+ - tweaks to the line length calculation ([4ec1fe2](https://github.com/codsen/codsen/commit/4ec1fe224f8e2c32e94c085afb8cf517cc806a8c))
17
+
18
+ ### Features
19
+
20
+ - avoid two closing curlies in a sequence ([b7293b0](https://github.com/codsen/codsen/commit/b7293b0bd5e132946936d41cfa36d27e61a11522)), closes [#16](https://github.com/codsen/codsen/issues/16)
21
+ - migrate to ES Modules ([8c9d95d](https://github.com/codsen/codsen/commit/8c9d95d5dea0b769c2f070397141918a4893d575))
22
+
23
+ ### BREAKING CHANGES
24
+
25
+ - programs now are in ES Modules and won't work with Common JS require()
26
+
27
+ ## 4.2.0 (2021-05-24)
28
+
29
+ ### Features
30
+
31
+ - config file based major bump blacklisting ([e15f9bb](https://github.com/codsen/codsen/commit/e15f9bba1c4fd5f847ac28b3f38fa6ee633f5dca))
32
+
6
33
  ## 4.1.9 (2021-04-11)
7
34
 
8
35
  ### Reverts
package/README.md CHANGED
@@ -26,10 +26,14 @@
26
26
 
27
27
  ## Install
28
28
 
29
+ This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
30
+
29
31
  ```bash
30
32
  npm i html-crush
31
33
  ```
32
34
 
35
+ If you need a legacy version which works with `require`, use version 4.2.0
36
+
33
37
  ## Quick Take
34
38
 
35
39
  ```js
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name html-crush
3
3
  * @fileoverview Minifies HTML/CSS: valid or broken, pure or mixed with other languages
4
- * @version 4.1.10
4
+ * @version 5.0.2
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/html-crush/}
@@ -13,7 +13,7 @@ import { matchRightIncl, matchRight, matchLeft } from 'string-match-left-right';
13
13
  import { expander } from 'string-range-expander';
14
14
  import { right, left } from 'string-left-right';
15
15
 
16
- var version$1 = "4.1.10";
16
+ var version$1 = "5.0.2";
17
17
 
18
18
  const version = version$1;
19
19
  const finalIndexesToDelete = new Ranges({
@@ -128,6 +128,16 @@ function crush(str, originalOpts) {
128
128
  }
129
129
  }
130
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
+ }
131
141
  if (doNothing && typeof doNothing === "number" && i >= doNothing) {
132
142
  doNothing = undefined;
133
143
  }
@@ -162,19 +172,19 @@ function crush(str, originalOpts) {
162
172
  }
163
173
  if (tagNameStartsAt !== null && tagName === null && !/\w/.test(str[i])
164
174
  ) {
165
- tagName = str.slice(tagNameStartsAt, i);
166
- const idxOnTheRight = right(str, ~-i);
167
- if (typeof idxOnTheRight === "number" && str[idxOnTheRight] === ">" && !str[i].trim() && right(str, i)) {
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)) {
168
181
  finalIndexesToDelete.push(i, right(str, i));
169
- } else if (idxOnTheRight && str[idxOnTheRight] === "/" && str[right(str, idxOnTheRight)] === ">") {
170
- if (!str[i].trim() && right(str, i)) {
171
- finalIndexesToDelete.push(i, right(str, i));
172
- }
173
- if (str[idxOnTheRight + 1] !== ">" && right(str, idxOnTheRight + 1)) {
174
- finalIndexesToDelete.push(idxOnTheRight + 1, right(str, idxOnTheRight + 1));
175
- }
182
+ }
183
+ if (str[idxOnTheRight + 1] !== ">" && right(str, idxOnTheRight + 1)) {
184
+ finalIndexesToDelete.push(idxOnTheRight + 1, right(str, idxOnTheRight + 1));
176
185
  }
177
186
  }
187
+ }
178
188
  if (!doNothing && !withinStyleTag && !withinInlineStyle && str[~-i] === "<" && tagNameStartsAt === null) {
179
189
  if (/\w/.test(str[i])) {
180
190
  tagNameStartsAt = i;
@@ -248,8 +258,7 @@ function crush(str, originalOpts) {
248
258
  htmlCommentStartedAt = i;
249
259
  }
250
260
  } else if (
251
- opts.removeHTMLComments && (
252
- !withinHTMLConditional || opts.removeHTMLComments === 2)) {
261
+ opts.removeHTMLComments && (!withinHTMLConditional || opts.removeHTMLComments === 2)) {
253
262
  htmlCommentStartedAt = i;
254
263
  }
255
264
  if (!applicableOpts.removeHTMLComments) {
@@ -327,6 +336,9 @@ function crush(str, originalOpts) {
327
336
  countCharactersPerLine -= right(str, i) - i + 1;
328
337
  }
329
338
  }
339
+ if (withinStyleTag && str[i] === "}" && whitespaceStartedAt && str[whitespaceStartedAt - 1] === "}") {
340
+ whatToAdd = " ";
341
+ }
330
342
  if (whatToAdd && whatToAdd.length) {
331
343
  countCharactersPerLine += 1;
332
344
  }
@@ -392,8 +404,6 @@ function crush(str, originalOpts) {
392
404
  finalIndexesToDelete.push(stageFrom, stageTo, whatToAdd);
393
405
  lastLinebreak = null;
394
406
  }
395
- } else {
396
- countCharactersPerLine -= lastLinebreak || 0;
397
407
  }
398
408
  }
399
409
  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, {
@@ -521,6 +531,9 @@ function crush(str, originalOpts) {
521
531
  if (str[i] === "<" && leftTagName !== null) {
522
532
  leftTagName = null;
523
533
  }
534
+ if (withinStyleTag && str[i] === "{" && str[i + 1] === "{" && str.indexOf("}}") !== -1) {
535
+ doNothing = str.indexOf("}}") + 2;
536
+ }
524
537
  }
525
538
  if (finalIndexesToDelete.current()) {
526
539
  const ranges = finalIndexesToDelete.current();
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name html-crush
3
3
  * @fileoverview Minifies HTML/CSS: valid or broken, pure or mixed with other languages
4
- * @version 4.1.10
4
+ * @version 5.0.2
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/html-crush/}
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * @name ranges-sort
13
13
  * @fileoverview Sort string index ranges
14
- * @version 4.0.16
14
+ * @version 5.0.2
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/ranges-sort/}
@@ -19,7 +19,7 @@
19
19
  /**
20
20
  * @name ranges-merge
21
21
  * @fileoverview Merge and sort string index ranges
22
- * @version 7.0.16
22
+ * @version 8.0.2
23
23
  * @author Roy Revelt, Codsen Ltd
24
24
  * @license MIT
25
25
  * {@link https://codsen.com/os/ranges-merge/}
@@ -27,7 +27,7 @@
27
27
  /**
28
28
  * @name ranges-apply
29
29
  * @fileoverview Take an array of string index ranges, delete/replace the string according to them
30
- * @version 5.0.16
30
+ * @version 6.0.2
31
31
  * @author Roy Revelt, Codsen Ltd
32
32
  * @license MIT
33
33
  * {@link https://codsen.com/os/ranges-apply/}
@@ -35,7 +35,7 @@
35
35
  /**
36
36
  * @name string-collapse-leading-whitespace
37
37
  * @fileoverview Collapse the leading and trailing whitespace of a string
38
- * @version 5.0.16
38
+ * @version 6.0.2
39
39
  * @author Roy Revelt, Codsen Ltd
40
40
  * @license MIT
41
41
  * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
@@ -44,43 +44,43 @@ function s(e,t=1){function r(e){return Array.from(e).reverse().join("")}function
44
44
  /**
45
45
  * @name ranges-push
46
46
  * @fileoverview Gather string index ranges
47
- * @version 5.0.16
47
+ * @version 6.0.2
48
48
  * @author Roy Revelt, Codsen Ltd
49
49
  * @license MIT
50
50
  * {@link https://codsen.com/os/ranges-push/}
51
- */function o(e){return null!=e}function a(e){return Number.isInteger(e)&&e>=0}function l(e){return"string"==typeof e}const u={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1};
51
+ */const o={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function a(e,t){if(!Array.isArray(e)||!e.length)return e;const r={...o,...t};let n,i;if(r.strictlyTwoElementsInRangeArrays&&!e.filter((e=>e)).every(((e,t)=>2===e.length||(n=t,i=e.length,!1))))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 ${i} elements!`);if(!e.filter((e=>e)).every(((e,t)=>!(!Number.isInteger(e[0])||e[0]<0||!Number.isInteger(e[1])||e[1]<0)||(n=t,!1))))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!`);const s=e.filter((e=>e)).length**2;let a=0;return Array.from(e).filter((e=>e)).sort(((e,t)=>(r.progressFn&&(a+=1,r.progressFn(Math.floor(100*a/s))),e[0]===t[0]?e[1]<t[1]?-1:e[1]>t[1]?1:0:e[0]<t[0]?-1:1)))}const l={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function u(e){return null!=e}function h(e){return Number.isInteger(e)&&e>=0}function f(e){return"string"==typeof e}const c={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1};
52
52
  /**
53
53
  * @name string-match-left-right
54
54
  * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
55
- * @version 7.0.10
55
+ * @version 8.0.2
56
56
  * @author Roy Revelt, Codsen Ltd
57
57
  * @license MIT
58
58
  * {@link https://codsen.com/os/string-match-left-right/}
59
59
  */
60
- function h(e){return e&&"object"==typeof e&&!Array.isArray(e)}function f(e){return"string"==typeof e}const c={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},g=e=>e+1;function p(e,t,r,n,i=!1,s=g){const o="function"==typeof r?r():r;if(+t<0&&i&&"EOL"===o)return o;const a={...c,...n};if(t>=e.length&&!i)return!1;let l=i?1:r.length,u=0,h=!1,f=!1,p=!1,d=a.maxMismatches,m=t,y=!1,T=!1,b=!1;function w(){return 1===u&&d<a.maxMismatches-1}for(;e[m];){const t=s(m);if(a.trimBeforeMatching&&""===e[m].trim()){if(!e[t]&&i&&"EOL"===r)return!0;m=s(m);continue}if(a&&!a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.includes(e[m])||a&&a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.map((e=>e.toLowerCase())).includes(e[m].toLowerCase())){if(i&&"EOL"===r&&!e[t])return!0;m=s(m);continue}const n=t>m?r[r.length-l]:r[l-1];if(!a.i&&e[m]===n||a.i&&e[m].toLowerCase()===n.toLowerCase()){if(y||(y=!0),p||(p=!0),l===r.length){if(T=!0,d!==a.maxMismatches)return!1}else 1===l&&(b=!0);if(l-=1,u++,w())return!1;if(!l)return(u!==r.length||d===a.maxMismatches||!h)&&m}else{if(h||u||(h=!0),!(a.maxMismatches&&d&&m))return!(0!==m||1!==l||a.lastMustMatch||!p)&&0;d-=1;for(let n=0;n<=d;n++){const i=t>m?r[r.length-l+1+n]:r[l-2-n],o=e[s(m)];if(i&&(!a.i&&e[m]===i||a.i&&e[m].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&&d>=0&&y&&(!a.firstMustMatch||T)&&(!a.lastMustMatch||b))return m}y||(f=m)}if(!1!==f&&f!==m&&(f=!1),l<1)return m;m=s(m)}return l>0?!(!i||"EOL"!==o)||!!(a&&a.maxMismatches>=l&&p)&&(f||0):void 0}function d(e,t,r,n,i){if(h(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={...c,...i};
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
61
  /**
62
62
  * @name arrayiffy-if-string
63
63
  * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
64
- * @version 3.13.16
64
+ * @version 4.0.2
65
65
  * @author Roy Revelt, Codsen Ltd
66
66
  * @license MIT
67
67
  * {@link https://codsen.com/os/arrayiffy-if-string/}
68
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=>f(e)?e:String(e))),!f(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(f(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&&!h(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,g="";if(s&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.some(((e,t)=>e.length>1&&(u=t,g=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, ${g.length} (equals to ${g}). 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&&f(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=p(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 m(e,t,r,n){return d("matchLeft",e,t,r,n)}function y(e,t,r,n){return d("matchRightIncl",e,t,r,n)}function T(e,t,r,n){return d("matchRight",e,t,r,n)}
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
70
  /**
71
71
  * @name string-range-expander
72
72
  * @fileoverview Expands string index ranges within whitespace boundaries until letters are met
73
- * @version 2.0.16
73
+ * @version 3.0.2
74
74
  * @author Roy Revelt, Codsen Ltd
75
75
  * @license MIT
76
76
  * {@link https://codsen.com/os/string-range-expander/}
77
- */const b={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function w(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={...b,...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]}Function.prototype.toString.call(Object);var _="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e){var t={exports:{}};e(t,t.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]",d="[object String]",m="[object Symbol]",y="[object WeakMap]",T="[object ArrayBuffer]",b="[object DataView]",w="[object Float32Array]",v="[object Float64Array]",O="[object Int8Array]",I="[object Int16Array]",L="[object Int32Array]",S="[object Uint8Array]",A="[object Uint8ClampedArray]",C="[object Uint16Array]",$="[object Uint32Array]",M=/\w*$/,R=/^\[object .+?Constructor\]$/,x=/^(?:0|[1-9]\d*)$/,j={};j[i]=j["[object Array]"]=j[T]=j[b]=j[s]=j[o]=j[w]=j[v]=j[O]=j[I]=j[L]=j[u]=j[h]=j[f]=j[g]=j[p]=j[d]=j[m]=j[S]=j[A]=j[C]=j[$]=!0,j["[object Error]"]=j[a]=j[y]=!1;var W="object"==typeof self&&self&&self.Object===Object&&self,E="object"==typeof _&&_&&_.Object===Object&&_||W||Function("return this")(),N=t&&!t.nodeType&&t,k=N&&e&&!e.nodeType&&e,B=k&&k.exports===N;function F(e,t){return e.set(t[0],t[1]),e}function H(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=B?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=ke(E,"DataView"),ge=ke(E,"Map"),pe=ke(E,"Promise"),de=ke(E,"Set"),me=ke(E,"WeakMap"),ye=ke(Object,"create"),Te=Je(ce),be=Je(ge),we=Je(pe),_e=Je(de),ve=Je(me),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 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 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 Ce(e){this.__data__=new Se(e)}function $e(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||He(o,n))||r.push(o);return r}function Me(e,t,r){var n=e[t];X.call(e,t)&&Pe(n,r)&&(void 0!==r||t in e)||(e[t]=r)}function Re(e,t){for(var r=e.length;r--;)if(Pe(e[r][0],t))return r;return-1}function xe(e,t,r,n,c,y,_){var R;if(n&&(R=y?n(e,c,y,_):n(e)),void 0!==R)return R;if(!Ge(e))return e;var x=qe(e);if(x){if(R=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,R)}else{var W=Fe(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(R=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,Be(e),t)}(e,function(e,t){return e&&Ee(t,Ye(t),e)}(R,e))}else{if(!j[W])return y?e:{};R=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 v:case O:case I:case L:case S:case A:case C:case $: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),F,new e.constructor)}(e,n,r);case h:case d:return new i(e);case g:return function(e){var t=new e.constructor(e.source,M.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),H,new e.constructor)}(e,n,r);case m:return a=e,Ie?Object(Ie.call(a)):{}}var a}(e,W,xe,t)}}_||(_=new Ce);var N=_.get(e);if(N)return N;if(_.set(e,R),!x)var k=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,Be)}(e):Ye(e);return function(e,t){for(var r=-1,n=e?e.length:0;++r<n&&!1!==t(e[r],r,e););}(k||e,(function(i,s){k&&(i=e[s=i]),Me(R,s,xe(i,t,r,n,s,e,_))})),R}function je(e){return!(!Ge(e)||(t=e,K&&K in t))&&(Ve(e)||J(e)?te:R).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;Me(r,o,void 0===a?e[o]:a)}return r}function Ne(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 ke(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return je(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},Se.prototype.clear=function(){this.__data__=[]},Se.prototype.delete=function(e){var t=this.__data__,r=Re(t,e);return!(r<0)&&(r==t.length-1?t.pop():le.call(t,r,1),!0)},Se.prototype.get=function(e){var t=this.__data__,r=Re(t,e);return r<0?void 0:t[r][1]},Se.prototype.has=function(e){return Re(this.__data__,e)>-1},Se.prototype.set=function(e,t){var r=this.__data__,n=Re(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ae.prototype.clear=function(){this.__data__={hash:new Le,map:new(ge||Se),string:new Le}},Ae.prototype.delete=function(e){return Ne(this,e).delete(e)},Ae.prototype.get=function(e){return Ne(this,e).get(e)},Ae.prototype.has=function(e){return Ne(this,e).has(e)},Ae.prototype.set=function(e,t){return Ne(this,e).set(e,t),this},Ce.prototype.clear=function(){this.__data__=new Se},Ce.prototype.delete=function(e){return this.__data__.delete(e)},Ce.prototype.get=function(e){return this.__data__.get(e)},Ce.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Se){var n=r.__data__;if(!ge||n.length<199)return n.push([e,t]),this;r=this.__data__=new Ae(n)}return r.set(e,t),this};var Be=ue?q(ue,Object):function(){return[]},Fe=function(e){return ee.call(e)};function He(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||x.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&&Fe(new ce(new ArrayBuffer(1)))!=b||ge&&Fe(new ge)!=u||pe&&Fe(pe.resolve())!=c||de&&Fe(new de)!=p||me&&Fe(new me)!=y)&&(Fe=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)?$e(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 xe(e,!0,!0)}}));
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
78
  /**
79
79
  * @name string-left-right
80
80
  * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
81
- * @version 4.0.16
81
+ * @version 5.0.2
82
82
  * @author Roy Revelt, Codsen Ltd
83
83
  * @license MIT
84
84
  * {@link https://codsen.com/os/string-left-right/}
85
85
  */
86
- const v=" ";function O(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]===v))return t+1;if(e[t+2]&&(e[t+2].trim()||r&&"\n\r".includes(e[t+2])||n&&e[t+2]===v))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]===v)return i;return null}({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function I(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]===v))return~-t;if(e[t-2]&&(e[t-2].trim()||r&&"\n\r".includes(e[t-2])||n&&e[t-2]===v))return t-2;for(let i=t;i--;)if(e[i]&&(e[i].trim()||r&&"\n\r".includes(e[i])||n&&e[i]===v))return i;return null}({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}const L=new class{constructor(e){const t={...u,...e};if(t.mergeType&&1!==t.mergeType&&2!==t.mergeType)if(l(t.mergeType)&&"1"===t.mergeType.trim())t.mergeType=1;else{if(!l(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=[]}add(e,t,r){if(null==e&&null==t)return;if(o(e)&&!o(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&&a(+e[0])&&a(+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(!o(e)&&o(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(a(r)&&(r=String(r)),!a(n)||!a(i))throw a(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(o(r)&&!l(r)&&!a(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(o(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=i,this.last(),null!==this.last()[2]&&o(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)),l(e)&&!e.length||(this.last()[2]=e)}}else{this.ranges||(this.ranges=[]);const e=void 0===r||l(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=i(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map((e=>o(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])||!a(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}),S={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"]},A={removeHTMLComments:!1,removeCSSComments:!1};function C(e){return"string"==typeof e}function $(e){return"string"==typeof e&&e.toUpperCase()!==e.toLowerCase()}e.crush=function(e,t){const r=Date.now();if(!C(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(!C(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={...S,...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,d=null,b=null,_=null,v=null,M=null,R=null,x=null,j=null,W=null;const E=">};",N="<",k="!",B=">",F="<",H="{},:;<>~+",D=H,J=H;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&&"number"==typeof o&&t>=o&&(o=void 0),null===_||!e.startsWith("</script",t)||$(e[t+8])){if(!o&&!c&&e.startsWith("<script",t)&&!$(e[t+7])){_=t,o=!0;let e="";(n.removeLineBreaks||n.removeIndentations)&&null!==l&&(l>0&&(e=Y),L.push(l,t,e)),l=null,a=null}if(null!==j&&null===x&&!/\w/.test(e[t])){x=e.slice(j,t);const r=O(e,~-t);"number"==typeof r&&">"===e[r]&&!e[t].trim()&&O(e,t)?L.push(t,O(e,t)):r&&"/"===e[r]&&">"===e[O(e,r)]&&(!e[t].trim()&&O(e,t)&&L.push(t,O(e,t)),">"!==e[r+1]&&O(e,r+1)&&L.push(r+1,O(e,r+1)))}if(o||c||p||"<"!==e[~-t]||null!==j||(/\w/.test(e[t])?j=t:"/"===e[O(e,~-t)]&&/\w/.test(e[O(e,O(e,~-t))]||"")&&(j=O(e,O(e,~-t)))),o||!c&&!p||null===d||"*"!==e[t]||"/"!==e[t+1]||([v,M]=w({str:e,from:d,to:t+2,ifLeftSideIncludesThisThenCropTightly:D,ifRightSideIncludesThisThenCropTightly:J}),d=null,null!=v?L.push(v,M):(h+=1,t+=1),o=t+2),o||!c&&!p||null!==d||"/"!==e[t]||"*"!==e[t+1]||(A.removeCSSComments||(A.removeCSSComments=!0),n.removeCSSComments&&(d=t)),g&&e.startsWith("![endif",t+1)&&(g=!1),!o&&!c&&!p&&null!==b){let r;e.startsWith("--\x3e",t)?r=3:">"===e[t]&&"]"===e[t-1]&&(r=1),r&&([v,M]=w({str:e,from:b,to:t+r}),b=null,null!=v?n.lineLengthLimit&&f-(M-v)>=n.lineLengthLimit?(L.push(v,M,Y),f=-r):(L.push(v,M),f-=M-v):(h+=r-1,t+=r-1),o=t+r)}if(o||c||p||!e.startsWith("\x3c!--",t)||null!==b||(e.startsWith("[if",t+4)?(g||(g=!0),2===n.removeHTMLComments&&(b=t)):!n.removeHTMLComments||g&&2!==n.removeHTMLComments||(b=t),A.removeHTMLComments||(A.removeHTMLComments=!0)),!o&&c&&null===d&&e.startsWith("</style",t)&&!$(e[t+7])?c=!1:o||c||null!==d||!e.startsWith("<style",t)||$(e[t+6])||(c=!0,(n.removeLineBreaks||n.removeIndentations)&&n.breakToTheLeftOf.includes("<style")&&e.startsWith(' type="text/css">',t+6)&&e[t+24]&&L.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===d)){if(null!==l){if(n.removeLineBreaks&&(h+=1),P)P=!1,(n.removeIndentations||n.removeLineBreaks)&&L.push(0,t);else if(n.removeIndentations&&!n.removeLineBreaks&&(!u&&null!==a&&t>a?L.push(a+1,t):l+1<t&&(e.endsWith("]>",l)||e.endsWith("--\x3e",l)||e.startsWith("<![",t)||e.startsWith("\x3c!--<![",t)?L.push(l,t):" "===e[l]?L.push(l+1,t):" "===e[~-t]?L.push(l,~-t):L.push(l,t," "))),n.removeLineBreaks||p){if(s.includes(e[t])&&y(e,t,n.breakToTheLeftOf)){"\r\n".includes(e[~-t])&&l===~-t||"\n"===e[~-t]&&"\r"===e[t-2]&&l===t-2||L.push(l,t,Y),v=null,M=null,R=null,l=null,h=1;continue}let r=" ";"<"===e[t]&&T(e,t,n.mindTheInlineTags,{cb:e=>!e||!/\w/.test(e)})||(e[~-l]&&B.includes(e[~-l])&&F.includes(e[t])||(c||p)&&null===d&&(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[I(e,t)])||"<"===e[O(e,t)])||"/"===e[t]&&">"===e[O(e,t)])&&(r="","/"===e[t]&&">"===e[t+1]&&O(e,t)&&O(e,t)>t+1&&(L.push(t+1,O(e,t)),h-=O(e,t)-t+1)),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])&&!N.includes(e[t+1]))&&(r=Y,h=1),(h>n.lineLengthLimit||" "!==r||t!==l+1)&&(L.push(l,t,r),a=null),v=null,M=null,R=null):(null===v||l<v)&&(v=l,M=t,R=r):t===l+1&&" "===r||L.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&&y(e,t,n.breakToTheLeftOf)&&e.slice(0,t).trim()&&(!e.startsWith("<![endif]",t)||!m(e,t,"\x3c!--"))){L.push(t,t,Y),v=null,M=null,R=null,h=1;continue}if(n.lineLengthLimit&&h<=n.lineLengthLimit){if(!e[t+1]||N.includes(e[t])&&!k.includes(e[t])||E.includes(e[t])||!e[t].trim()){if(null!==v&&null!==M&&(v!==M||R&&R.length)){let r=R;e[t].trim()&&e[t+1]&&e[t+1].trim()&&h+(R?R.length:0)>n.lineLengthLimit&&(r=Y),h+(r?r.length:0)>n.lineLengthLimit||" "!==r||M!==v+1||" "!==e[v]?"}"===e[~-v]&&"{"===e[M]||(L.push(v,M,r),a=null):h-=a||0}!(e[t].trim()&&(N.includes(e[t])||e[~-t]&&E.includes(e[~-t]))&&C(W))||x&&n.mindTheInlineTags.includes(x)||"<"===e[t]&&T(e,t,n.mindTheInlineTags,{cb:e=>!e||!/\w/.test(e)})||"<"===e[t]&&T(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)})?null!==d||null===v||!(p||!n.mindTheInlineTags||!Array.isArray(n.mindTheInlineTags)||Array.isArray(n.mindTheInlineTags.length)&&!n.mindTheInlineTags.length||!C(x)||Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&C(x)&&!n.mindTheInlineTags.includes(x))||"<"===e[t]&&T(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)})||(v=null,M=null,R=null):(v=t,M=t,R=null)}}else if(n.lineLengthLimit)if(!N.includes(e[t])||"<"===e[t]&&T(e,t,n.mindTheInlineTags,{trimCharsBeforeMatching:"/",cb:e=>!e||!/\w/.test(e)}))e[t+1]&&E.includes(e[t])&&C(x)&&Array.isArray(n.mindTheInlineTags)&&n.mindTheInlineTags.length&&!n.mindTheInlineTags.includes(x)?null!==v&&null!==M&&(v!==M||R&&R.length)||(L.push(t+1,t+1,Y),h=0):e[t].trim()&&(e[t+1]||null!==v&&null!==M&&(v!==M||R&&R.length)&&L.push(v,M,Y));else if(null!==v&&null!==M&&(v!==M||R&&R.length)){const e=R&&R.length?R.length:0;h-(M-v-e)-1>n.lineLengthLimit||(L.push(v,M,R),h-(M-v-e)-1===n.lineLengthLimit&&(L.push(t,t,Y),h=0),v=null,M=null,R=null)}else L.push(t,t,Y),h=0}if(!o&&!P&&n.removeLineBreaks&&n.lineLengthLimit&&h>=n.lineLengthLimit&&null!==v&&null!==M&&!E.includes(e[t])&&!N.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=R),r===Y&&!e[~-v].trim()&&I(e,v)&&(v=I(e,v)+1),L.push(v,M,r),h=t-M,e[t].length&&(h+=1),v=null,M=null,R=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]&&L.push(l,t)),e[t+1]||(c&&null!==d?L.push(...w({str:e,from:d,to:t,ifLeftSideIncludesThisThenCropTightly:D,ifRightSideIncludesThisThenCropTightly:J})):l&&"\n"!==e[t]&&"\r"!==e[t]?L.push(l,t+1):l&&("\r"===e[t]&&"\n"===e[t+1]||"\n"===e[t]&&"\r"!==e[t-1])&&L.push(l,t)),!o&&p&&p<t&&e[p]===e[t]&&(p=null),!o&&!c&&e.startsWith("<pre",t)&&!$(e[t+4])){const r=e.indexOf("</pre",t+5);r>0&&(o=r)}if(!o&&!c&&e.startsWith("<code",t)&&!$(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===j||">"!==e[t]||("<"===e[O(e,t)]&&(W=x),j=null,x=null),"<"===e[t]&&null!==W&&(W=null)}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&&L.push(r+1,t);break}_=null,o=!1,t+=8}if(L.current()){const t=L.current();L.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:A,result:o}}}return{log:{timeTakenInMilliseconds:Date.now()-r,originalLength:q,cleanedLength:q,bytesSaved:0,percentageReducedOfOriginal:0},applicableOpts:A,ranges:null,result:e}},e.defaults=S,e.version="4.1.10",Object.defineProperty(e,"__esModule",{value:!0})}));
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.2",Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-crush",
3
- "version": "4.1.10",
3
+ "version": "5.0.2",
4
4
  "description": "Minifies HTML/CSS: valid or broken, pure or mixed with other languages",
5
5
  "keywords": [
6
6
  "breaks",
@@ -36,9 +36,11 @@
36
36
  "email": "roy@codsen.com",
37
37
  "url": "https://codsen.com"
38
38
  },
39
- "main": "dist/html-crush.cjs.js",
40
- "module": "dist/html-crush.esm.js",
41
- "browser": "dist/html-crush.umd.js",
39
+ "type": "module",
40
+ "exports": {
41
+ "script": "./dist/html-crush.umd.js",
42
+ "default": "./dist/html-crush.esm.js"
43
+ },
42
44
  "types": "types/index.d.ts",
43
45
  "scripts": {
44
46
  "build": "rollup -c",
@@ -58,18 +60,20 @@
58
60
  "pretest": "npm run build",
59
61
  "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
60
62
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
61
- "unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
63
+ "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
62
64
  "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
63
65
  "clean_types": "../../scripts/cleanTypes.js"
64
66
  },
65
67
  "tap": {
68
+ "check-coverage": false,
66
69
  "coverage-report": [
67
70
  "json-summary",
68
71
  "text"
69
72
  ],
70
- "nyc-arg": [
71
- "--exclude=**/*.cjs.js",
72
- "--exclude=**/*.umd.js"
73
+ "node-arg": [
74
+ "--no-warnings",
75
+ "--experimental-loader",
76
+ "@istanbuljs/esm-loader-hook"
73
77
  ],
74
78
  "timeout": 0
75
79
  },
@@ -89,54 +93,57 @@
89
93
  }
90
94
  },
91
95
  "dependencies": {
92
- "@babel/runtime": "^7.13.10",
93
- "ranges-apply": "^5.0.16",
94
- "ranges-push": "^5.0.16",
95
- "string-left-right": "^4.0.16",
96
- "string-match-left-right": "^7.0.10",
97
- "string-range-expander": "^2.0.16",
98
- "test-mixer": "^2.0.16"
96
+ "@babel/runtime": "^7.15.4",
97
+ "ranges-apply": "^6.0.2",
98
+ "ranges-push": "^6.0.2",
99
+ "string-left-right": "^5.0.2",
100
+ "string-match-left-right": "^8.0.2",
101
+ "string-range-expander": "^3.0.2",
102
+ "test-mixer": "^3.0.2"
99
103
  },
100
104
  "devDependencies": {
101
- "@babel/cli": "^7.13.14",
102
- "@babel/core": "^7.13.14",
103
- "@babel/node": "^7.13.13",
104
- "@babel/plugin-external-helpers": "^7.12.13",
105
- "@babel/plugin-proposal-class-properties": "^7.13.0",
106
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8",
107
- "@babel/plugin-proposal-object-rest-spread": "^7.13.8",
108
- "@babel/plugin-proposal-optional-chaining": "^7.13.12",
109
- "@babel/plugin-transform-runtime": "^7.13.10",
105
+ "@babel/cli": "^7.15.4",
106
+ "@babel/core": "^7.15.5",
107
+ "@babel/node": "^7.15.4",
108
+ "@babel/plugin-external-helpers": "^7.14.5",
109
+ "@babel/plugin-proposal-class-properties": "^7.14.5",
110
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
111
+ "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
112
+ "@babel/plugin-proposal-optional-chaining": "^7.14.5",
113
+ "@babel/plugin-transform-runtime": "^7.15.0",
110
114
  "@babel/polyfill": "^7.12.1",
111
- "@babel/preset-env": "^7.13.12",
112
- "@babel/preset-typescript": "^7.13.0",
113
- "@babel/register": "^7.13.14",
115
+ "@babel/preset-env": "^7.15.6",
116
+ "@babel/preset-typescript": "^7.15.0",
117
+ "@babel/register": "^7.15.3",
118
+ "@istanbuljs/esm-loader-hook": "^0.1.2",
114
119
  "@rollup/plugin-babel": "^5.3.0",
115
- "@rollup/plugin-commonjs": "^18.0.0",
120
+ "@rollup/plugin-commonjs": "^20.0.0",
116
121
  "@rollup/plugin-json": "^4.1.0",
117
- "@rollup/plugin-node-resolve": "^11.2.1",
118
- "@rollup/plugin-replace": "^2.4.2",
119
- "@rollup/plugin-strip": "^2.0.0",
120
- "@rollup/plugin-typescript": "^8.2.1",
121
- "@types/node": "^14.14.37",
122
- "@types/tap": "^14.10.3",
123
- "@typescript-eslint/eslint-plugin": "^4.20.0",
124
- "@typescript-eslint/parser": "^4.20.0",
125
- "core-js": "^3.10.0",
122
+ "@rollup/plugin-node-resolve": "^13.0.4",
123
+ "@rollup/plugin-strip": "^2.1.0",
124
+ "@rollup/plugin-typescript": "^8.2.5",
125
+ "@types/node": "^16.9.1",
126
+ "@types/tap": "^15.0.5",
127
+ "@typescript-eslint/eslint-plugin": "^4.31.0",
128
+ "@typescript-eslint/parser": "^4.31.0",
129
+ "core-js": "^3.17.3",
126
130
  "cross-env": "^7.0.3",
127
- "eslint": "^7.23.0",
128
- "lect": "^0.16.16",
129
- "node-fetch": "^2.6.1",
130
- "p-map": "^4.0.0",
131
- "rollup": "^2.44.0",
131
+ "eslint": "^7.32.0",
132
+ "lect": "^0.18.2",
133
+ "node-fetch": "^3.0.0",
134
+ "p-map": "^5.1.0",
135
+ "rollup": "^2.56.3",
132
136
  "rollup-plugin-ascii": "^0.0.3",
133
137
  "rollup-plugin-banner": "^0.2.1",
134
138
  "rollup-plugin-cleanup": "^3.2.1",
135
- "rollup-plugin-dts": "^3.0.1",
139
+ "rollup-plugin-dts": "^4.0.0",
136
140
  "rollup-plugin-node-builtins": "^2.1.2",
137
141
  "rollup-plugin-terser": "^7.0.2",
138
- "tap": "^14.11.0",
139
- "tslib": "^2.1.0",
140
- "typescript": "^4.2.3"
142
+ "tap": "^15.0.9",
143
+ "tslib": "^2.3.1",
144
+ "typescript": "^4.4.3"
145
+ },
146
+ "engines": {
147
+ "node": ">=12"
141
148
  }
142
149
  }