string-remove-widows 4.1.3 → 4.2.1

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,11 +3,25 @@
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
- ## 4.1.0 (2025-10-15)
6
+ ## 4.2.0 (2026-08-19)
7
+
8
+ ### Bug Fixes
9
+
10
+ - make validation diagnostics safe ([7b01074](https://github.com/codsen/codsen/commit/7b0107476f12734aeb8e82852ba980b187280110))
11
+ - require a plain options object ([99991b2](https://github.com/codsen/codsen/commit/99991b2833d83c55a787aabd3365c25c63f6fb40))
12
+ - resolve review findings REV-004 through REV-007 ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
13
+ - retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
7
14
 
8
15
  ### Features
9
16
 
10
- - if value to be added is a number, keep it as is, don't stringify ([ce3e1a5](https://github.com/codsen/codsen/commit/ce3e1a525998ca3c0abf0142affef95b14cd1990))
17
+ - add codsen-glob and migrate glob consumers ([5595a2b](https://github.com/codsen/codsen/commit/5595a2b267eaa6cb60072d037aef00b7a28edd42))
18
+ - migrate to biome, format all sources, sort the imports, refresh the setup ([693c542](https://github.com/codsen/codsen/commit/693c542058043cf5de77e8d8310f5c8f157c41ca))
19
+ - refresh the tooling and generate with the latest dependencies ([781f802](https://github.com/codsen/codsen/commit/781f802911066a82a4533b0e5a3fcbd742d0dd83))
20
+
21
+ ### Reverts
22
+
23
+ - Revert "Merge pull request #128 from codsen/release/npm-32198404552-1" ([5baeeaa](https://github.com/codsen/codsen/commit/5baeeaaa677b86f1eaa6396cadf3aea32b06416e)), closes [#128](https://github.com/codsen/codsen/issues/128)
24
+ - Revert "Merge pull request #127 from codsen/release/npm-32194020886-1" ([5f1e94d](https://github.com/codsen/codsen/commit/5f1e94deef910ce735266b16aeee08a76de7a862)), closes [#127](https://github.com/codsen/codsen/issues/127)
11
25
 
12
26
  ## 4.0.0 (2022-12-01)
13
27
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright © 2010-2025 Roy Revelt and other contributors
3
+ Copyright © 2010-2026 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
@@ -32,7 +32,7 @@ npm i string-remove-widows
32
32
  ## Quick Take
33
33
 
34
34
  ```js
35
- import { strict as assert } from "assert";
35
+ import { strict as assert } from "node:assert";
36
36
 
37
37
  import { removeWidows } from "string-remove-widows";
38
38
 
@@ -44,6 +44,7 @@ assert.deepEqual(ranges, [[32, 33, " "]]);
44
44
  assert.equal(res, "Some text with many words on one line.");
45
45
  ```
46
46
 
47
+
47
48
  ## Documentation
48
49
 
49
50
  Please [visit codsen.com](https://codsen.com/os/string-remove-widows/) for a full description of the API. If you’re looking for the **Changelog**, it’s [here](https://github.com/codsen/codsen/blob/main/packages/string-remove-widows/CHANGELOG.md).
@@ -56,6 +57,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
56
57
 
57
58
  MIT License
58
59
 
59
- Copyright © 2010-2025 Roy Revelt and other contributors
60
+ Copyright © 2010-2026 Roy Revelt and other contributors
60
61
 
61
62
  <p align="center"><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"></p>
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * @name string-remove-widows
3
3
  * @fileoverview Helps to prevent widow words in a text
4
- * @version 4.1.3
4
+ * @version 4.2.1
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-remove-widows/}
8
8
  */
9
9
 
10
- import{matchRightIncl as Q}from"string-match-left-right";import{left as T,right as D}from"string-left-right";import{Ranges as X}from"ranges-push";import{rApply as q}from"ranges-apply";import{rawNbsp as w,rawNDash as ee,rawMDash as te}from"codsen-utils";var R="4.1.3";var f="&nbsp;",E="\\00A0",S="\\u00A0",j="&ndash;",M="\\2013",J="\\u2013",U="&mdash;",k="\\2014",I="\\u2014",C=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],B=[{heads:"{{",tails:"}}"}],P=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],_=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"];var ce=R,oe={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function me(t,h){let G=Date.now();if(typeof t!="string")throw t===void 0?new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "${typeof t}", equal to:
11
- ${JSON.stringify(t,null,4)}`);if(h&&typeof h!="object")throw new Error(`string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof h}, equal to ${JSON.stringify(h,null,4)}`);let b=Array.isArray,L=t.length,a=new X({mergeType:2}),K=["."],Z=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,Y=/^[0-9][A-Z]{2}/,V=.06,$,A=0,g=0,W=0,y,N,l,c,r,d,s,p,o={...oe,...h},m={removeWidows:!1,convertEntities:!1};if(!o.ignore||!b(o.ignore)&&typeof o.ignore!="string")o.ignore=[];else if(typeof o.ignore=="string"&&(o.ignore=[o.ignore]),o.ignore.includes("all"))o.ignore=o.ignore.concat(C.concat(P));else if(o.ignore.some(e=>typeof e=="string")){let e=[];o.ignore=o.ignore.filter(i=>typeof i=="string"&&i.length?(["nunjucks","jinja","liquid"].includes(i.trim().toLowerCase())?e=e.concat(C):["hugo"].includes(i.trim().toLowerCase())?e=e.concat(B):["hexo"].includes(i.trim().toLowerCase())&&(e=e.concat(P)),!1):typeof i=="object"),e.length&&(o.ignore=o.ignore.concat(e))}let x;o.reportProgressFunc&&(x=Math.floor(o.reportProgressFuncTo-(o.reportProgressFuncTo-o.reportProgressFuncFrom)*V-o.reportProgressFuncFrom));function v(e,i){let n=w;o.removeWidowPreventionMeasures?n=" ":o.convertEntities&&(n=f,typeof o.targetLanguage=="string"&&(o.targetLanguage.trim().toLowerCase()==="css"?n=E:o.targetLanguage.trim().toLowerCase()==="js"&&(n=S))),t.slice(e,i)!==n&&a.push(e,i,n)}function O(){g=0,W=0,y=void 0,N=void 0,l=void 0,c=void 0,r=void 0,d=void 0}O();for(let e=0;e<=L;e++){if(!s&&b(o.ignore)&&o.ignore.length&&o.ignore.some((n,u)=>{if(b(n.heads)&&n.heads.some(H=>t.startsWith(H,e))||typeof n.heads=="string"&&t.startsWith(n.heads,e))return g+=1,s=o.ignore[u].tails,!0}),!s&&p&&p===e&&(g+=1,p=void 0),typeof o.reportProgressFunc=="function"&&($=o.reportProgressFuncFrom+Math.floor(e/L*(x||1)),$!==A&&(A=$,o.reportProgressFunc($))),!s&&e&&t[e]?.trim()&&(!t[e-1]||t[e-1]&&!t[e-1].trim())&&(c=e),!s&&t[e]?.trim()&&(W+=1),!s&&o.hyphens&&(`-${te}${ee}`.includes(t[e])||t.startsWith(j,e)||t.startsWith(M,e)||t.startsWith(J,e)||t.startsWith(U,e)||t.startsWith(k,e)||t.startsWith(I,e))&&t[e+1]&&(!t[e+1].trim()||t[e]==="&")&&t[e-1]&&!t[e-1].trim()&&t[T(t,e)]&&(v(T(t,e)+1,e),m.removeWidows=!0),!s&&(t.startsWith("&nbsp;",e)||t.startsWith("&#160;",e))&&(r=e,d=e+6,t[e+6]?.trim()&&(p=e+6),o.convertEntities?(o.targetLanguage==="css"||o.targetLanguage==="js")&&(a.push(e,e+6,o.targetLanguage==="css"?E:S),m.convertEntities=!0):(a.push(e,e+6,w),m.convertEntities=!0)),!s&&t[e+4]&&t[e]==="\\"&&t[e+1]==="0"&&t[e+2]==="0"&&t[e+3].toUpperCase()==="A"&&t[e+4]==="0"&&(r=e,d=e+5,t[e+5]?.trim()&&(p=e+5),o.convertEntities?(o.targetLanguage==="html"||o.targetLanguage==="js")&&(a.push(e,e+5,o.targetLanguage==="html"?f:S),m.convertEntities=!0):(a.push(e,e+5,w),m.convertEntities=!0)),!s&&t[e]==="\\"&&t[e+1]?.toLowerCase()==="u"&&t[e+2]==="0"&&t[e+3]==="0"&&t[e+4]?.toUpperCase()==="A"&&t[e+5]==="0"&&(r=e,d=e+6,t[e+6]?.trim()&&(p=e+6),o.convertEntities?(o.targetLanguage==="html"||o.targetLanguage==="css")&&a.push(e,e+6,o.targetLanguage==="html"?f:E):a.push(e,e+6,w)),!s&&t[e]===w&&(r=e,d=e+1,o.convertEntities&&a.push(e,e+1,o.targetLanguage==="css"?E:o.targetLanguage==="js"?S:f)),!s&&t[e]?.trim()&&!t[e-1]?.trim()&&(g+=1),!s&&(!t[e]||`\r
10
+ import{formatDiagnosticValue as q,isPlainObject as X,rawMDash as ee,rawNbsp as w,rawNDash as te}from"codsen-utils";import{rApply as G}from"ranges-apply";import{Ranges as oe}from"ranges-push";import{left as N,right as D}from"string-left-right";import{matchRightIncl as ne}from"string-match-left-right";var F="4.2.1";var f="&nbsp;",E="\\00A0",S="\\u00A0",R="&ndash;",M="\\2013",k="\\u2013",U="&mdash;",J="\\2014",I="\\u2014",C=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],B=[{heads:"{{",tails:"}}"}],P=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],_=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"];var ge=F,se={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function be(t,h){let K=Date.now();if(typeof t!="string")throw t===void 0?new Error("string-remove-widows/removeWidows(): [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows/removeWidows(): [THROW_ID_02] the first input argument must be string! It was given as "${typeof t}", equal to:
11
+ ${q(t,4)}`);if(h&&!X(h))throw new Error(`string-remove-widows/removeWidows(): [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof h}, equal to ${q(h,4)}`);let b=Array.isArray,L=t.length,a=new oe({mergeType:2}),Z=["."],Y=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,z=/^[0-9][A-Z]{2}/,v=.06,$,W=0,g=0,A=0,y,T,l,c,r,d,s,p,o={...se,...h},m={removeWidows:!1,convertEntities:!1};if(!o.ignore||!b(o.ignore)&&typeof o.ignore!="string")o.ignore=[];else if(typeof o.ignore=="string"&&(o.ignore=[o.ignore]),o.ignore.includes("all"))o.ignore=o.ignore.concat(C.concat(P));else if(o.ignore.some(e=>typeof e=="string")){let e=[];o.ignore=o.ignore.filter(i=>typeof i=="string"&&i.length?(["nunjucks","jinja","liquid"].includes(i.trim().toLowerCase())?e=e.concat(C):["hugo"].includes(i.trim().toLowerCase())?e=e.concat(B):["hexo"].includes(i.trim().toLowerCase())&&(e=e.concat(P)),!1):typeof i=="object"),e.length&&(o.ignore=o.ignore.concat(e))}let x;o.reportProgressFunc&&(x=Math.floor(o.reportProgressFuncTo-(o.reportProgressFuncTo-o.reportProgressFuncFrom)*v-o.reportProgressFuncFrom));function V(e,i){let n=w;o.removeWidowPreventionMeasures?n=" ":o.convertEntities&&(n=f,typeof o.targetLanguage=="string"&&(o.targetLanguage.trim().toLowerCase()==="css"?n=E:o.targetLanguage.trim().toLowerCase()==="js"&&(n=S))),t.slice(e,i)!==n&&a.push(e,i,n)}function O(){g=0,A=0,y=void 0,T=void 0,l=void 0,c=void 0,r=void 0,d=void 0}O();for(let e=0;e<=L;e++){if(!s&&b(o.ignore)&&o.ignore.length&&o.ignore.some((n,u)=>b(n.heads)&&n.heads.some(j=>t.startsWith(j,e))||typeof n.heads=="string"&&t.startsWith(n.heads,e)?(g+=1,s=o.ignore[u].tails,!0):!1),!s&&p&&p===e&&(g+=1,p=void 0),typeof o.reportProgressFunc=="function"&&($=o.reportProgressFuncFrom+Math.floor(e/L*(x||1)),$!==W&&(W=$,o.reportProgressFunc($))),!s&&e&&t[e]?.trim()&&(!t[e-1]||t[e-1]&&!t[e-1].trim())&&(c=e),!s&&t[e]?.trim()&&(A+=1),!s&&o.hyphens&&(`-${ee}${te}`.includes(t[e])||t.startsWith(R,e)||t.startsWith(M,e)||t.startsWith(k,e)||t.startsWith(U,e)||t.startsWith(J,e)||t.startsWith(I,e))&&t[e+1]&&(!t[e+1].trim()||t[e]==="&")&&t[e-1]&&!t[e-1].trim()&&t[N(t,e)]&&(V(N(t,e)+1,e),m.removeWidows=!0),!s&&(t.startsWith("&nbsp;",e)||t.startsWith("&#160;",e))&&(r=e,d=e+6,t[e+6]?.trim()&&(p=e+6),o.convertEntities?(o.targetLanguage==="css"||o.targetLanguage==="js")&&(a.push(e,e+6,o.targetLanguage==="css"?E:S),m.convertEntities=!0):(a.push(e,e+6,w),m.convertEntities=!0)),!s&&t[e+4]&&t[e]==="\\"&&t[e+1]==="0"&&t[e+2]==="0"&&t[e+3].toUpperCase()==="A"&&t[e+4]==="0"&&(r=e,d=e+5,t[e+5]?.trim()&&(p=e+5),o.convertEntities?(o.targetLanguage==="html"||o.targetLanguage==="js")&&(a.push(e,e+5,o.targetLanguage==="html"?f:S),m.convertEntities=!0):(a.push(e,e+5,w),m.convertEntities=!0)),!s&&t[e]==="\\"&&t[e+1]?.toLowerCase()==="u"&&t[e+2]==="0"&&t[e+3]==="0"&&t[e+4]?.toUpperCase()==="A"&&t[e+5]==="0"&&(r=e,d=e+6,t[e+6]?.trim()&&(p=e+6),o.convertEntities?(o.targetLanguage==="html"||o.targetLanguage==="css")&&a.push(e,e+6,o.targetLanguage==="html"?f:E):a.push(e,e+6,w)),!s&&t[e]===w&&(r=e,d=e+1,o.convertEntities&&a.push(e,e+1,o.targetLanguage==="css"?E:o.targetLanguage==="js"?S:f)),!s&&t[e]?.trim()&&!t[e-1]?.trim()&&(g+=1),!s&&(!t[e]||`\r
12
12
  `.includes(t[e])||(t[e]===`
13
13
  `||t[e]==="\r"||t[e]==="\r"&&t[e+1]===`
14
- `)&&T(t,e)&&K.includes(t[T(t,e)]))){if((!o.minWordCount||g>=o.minWordCount)&&(!o.minCharCount||W>=o.minCharCount)){let n,u;l!==void 0&&c!==void 0&&r!==void 0&&d!==void 0?l>r?(n=l,u=c):(n=r,u=d):l!==void 0&&c!==void 0?(n=l,u=c):r!==void 0&&d!==void 0&&(n=r,u=d),!(n&&u)&&y&&N&&(n=y,u=N),n&&u&&(v(n,u),m.removeWidows=!0)}O()}o.UKPostcodes&&t[e]&&!t[e].trim()&&t[e-1]?.trim()&&Z.test(t.slice(0,e))&&t[D(t,e)]&&Y.test(t.slice(D(t,e)))&&(v(e,D(t,e)),m.removeWidows=!0),!s&&t[e]&&!t[e].trim()&&t[e-1]?.trim()&&(l===void 0||t[l-1]?.trim())&&!"/>".includes(t[D(t,e)])&&!t.slice(0,e).trim().endsWith("br")&&!t.slice(0,e).trim().endsWith("hr")&&!(t.slice(0,e).endsWith("<")&&_.some(n=>t.startsWith(n,D(t,e))))&&(y=l,N=c,l=e,c=void 0,(r!==void 0||d!==void 0)&&(r=void 0,d=void 0));let i;s&&(typeof s=="string"&&(!s.length||t.startsWith(s,e))?s=void 0:b(s)&&(!s.length||s.some(n=>{if(t.startsWith(n,e))return i=n,!0}))&&(s=void 0,e+=i.length,b(o.ignore)&&o.ignore.length&&t[e+1]&&o.ignore.some(n=>Q(t,e,n.tails,{trimBeforeMatching:!0,cb:(u,H,F)=>(F&&(e=F-1,t[e+1]?.trim()&&(g+=1)),!0)})))),t[e]&&`\r
15
- `.includes(t[e])&&(g=0,W=0),b(o.tagRanges)&&o.tagRanges.length&&o.tagRanges.some(n=>{if(e>=n[0]&&e<=n[1]&&n[1]-1>e)return e=n[1]-1,!0})}return q(t,a.current()).split("").forEach((e,i)=>{}),{res:q(t,a.current(),o.reportProgressFunc?e=>{$=Math.floor((o.reportProgressFuncTo-o.reportProgressFuncFrom)*(1-V)+e/100*(o.reportProgressFuncTo-o.reportProgressFuncFrom)*V),$!==A&&(A=$,o.reportProgressFunc($))}:void 0),ranges:a.current(),log:{timeTakenInMilliseconds:Date.now()-G},whatWasDone:m}}export{oe as defaults,me as removeWidows,ce as version};
14
+ `)&&N(t,e)&&Z.includes(t[N(t,e)]))){if((!o.minWordCount||g>=o.minWordCount)&&(!o.minCharCount||A>=o.minCharCount)){let n,u;l!==void 0&&c!==void 0&&r!==void 0&&d!==void 0?l>r?(n=l,u=c):(n=r,u=d):l!==void 0&&c!==void 0?(n=l,u=c):r!==void 0&&d!==void 0&&(n=r,u=d),!(n&&u)&&y&&T&&(n=y,u=T),n&&u&&(V(n,u),m.removeWidows=!0)}O()}o.UKPostcodes&&t[e]&&!t[e].trim()&&t[e-1]?.trim()&&Y.test(t.slice(0,e))&&t[D(t,e)]&&z.test(t.slice(D(t,e)))&&(V(e,D(t,e)),m.removeWidows=!0),!s&&t[e]&&!t[e].trim()&&t[e-1]?.trim()&&(l===void 0||t[l-1]?.trim())&&!"/>".includes(t[D(t,e)])&&!t.slice(0,e).trim().endsWith("br")&&!t.slice(0,e).trim().endsWith("hr")&&!(t.slice(0,e).endsWith("<")&&_.some(n=>t.startsWith(n,D(t,e))))&&(y=l,T=c,l=e,c=void 0,(r!==void 0||d!==void 0)&&(r=void 0,d=void 0));let i;s&&(typeof s=="string"&&(!s.length||t.startsWith(s,e))?s=void 0:b(s)&&(!s.length||s.some(n=>t.startsWith(n,e)?(i=n,!0):!1))&&(s=void 0,e+=i.length,b(o.ignore)&&o.ignore.length&&t[e+1]&&o.ignore.some(n=>ne(t,e,n.tails,{trimBeforeMatching:!0,cb:(u,j,H)=>(H&&(e=H-1,t[e+1]?.trim()&&(g+=1)),!0)})))),t[e]&&`\r
15
+ `.includes(t[e])&&(g=0,A=0),b(o.tagRanges)&&o.tagRanges.length&&o.tagRanges.some(n=>e>=n[0]&&e<=n[1]&&n[1]-1>e?(e=n[1]-1,!0):!1)}return G(t,a.current()).split("").forEach((e,i)=>{}),{res:G(t,a.current(),o.reportProgressFunc?e=>{$=Math.floor((o.reportProgressFuncTo-o.reportProgressFuncFrom)*(1-v)+e/100*(o.reportProgressFuncTo-o.reportProgressFuncFrom)*v),$!==W&&(W=$,o.reportProgressFunc($))}:void 0),ranges:a.current(),log:{timeTakenInMilliseconds:Date.now()-K},whatWasDone:m}}export{se as defaults,be as removeWidows,ge as version};
@@ -1,82 +1,82 @@
1
1
  /**
2
2
  * @name string-remove-widows
3
3
  * @fileoverview Helps to prevent widow words in a text
4
- * @version 4.1.3
4
+ * @version 4.2.1
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-remove-widows/}
8
8
  */
9
9
 
10
- "use strict";var stringRemoveWidows=(()=>{var ke=Object.create;var F=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames,he=Object.getOwnPropertySymbols,Qe=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var q=(e,t,i)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,T=(e,t)=>{for(var i in t||(t={}))pe.call(t,i)&&q(e,i,t[i]);if(he)for(var i of he(t))Ge.call(t,i)&&q(e,i,t[i]);return e};var Ke=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ze=(e,t)=>{for(var i in t)F(e,i,{get:t[i],enumerable:!0})},$e=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let g of qe(t))!pe.call(e,g)&&g!==i&&F(e,g,{get:()=>t[g],enumerable:!(n=Ue(t,g))||n.enumerable});return e};var be=(e,t,i)=>(i=e!=null?ke(Qe(e)):{},$e(t||!e||!e.__esModule?F(i,"default",{value:e,enumerable:!0}):i,e)),ze=e=>$e(F({},"__esModule",{value:!0}),e);var Q=(e,t,i)=>q(e,typeof t!="symbol"?t+"":t,i);var G=Ke((ht,we)=>{"use strict";we.exports=Ye;function x(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function Ye(e){if(e=e||{},e.circles)return Xe(e);let t=new Map;if(t.set(Date,c=>new Date(c)),t.set(Map,(c,u)=>new Map(n(Array.from(c),u))),t.set(Set,(c,u)=>new Set(n(Array.from(c),u))),e.constructorHandlers)for(let c of e.constructorHandlers)t.set(c[0],c[1]);let i=null;return e.proto?r:g;function n(c,u){let l=Object.keys(c),o=new Array(l.length);for(let a=0;a<l.length;a++){let d=l[a],p=c[d];typeof p!="object"||p===null?o[d]=p:p.constructor!==Object&&(i=t.get(p.constructor))?o[d]=i(p,u):ArrayBuffer.isView(p)?o[d]=x(p):o[d]=u(p)}return o}function g(c){if(typeof c!="object"||c===null)return c;if(Array.isArray(c))return n(c,g);if(c.constructor!==Object&&(i=t.get(c.constructor)))return i(c,g);let u={};for(let l in c){if(Object.hasOwnProperty.call(c,l)===!1)continue;let o=c[l];typeof o!="object"||o===null?u[l]=o:o.constructor!==Object&&(i=t.get(o.constructor))?u[l]=i(o,g):ArrayBuffer.isView(o)?u[l]=x(o):u[l]=g(o)}return u}function r(c){if(typeof c!="object"||c===null)return c;if(Array.isArray(c))return n(c,r);if(c.constructor!==Object&&(i=t.get(c.constructor)))return i(c,r);let u={};for(let l in c){let o=c[l];typeof o!="object"||o===null?u[l]=o:o.constructor!==Object&&(i=t.get(o.constructor))?u[l]=i(o,r):ArrayBuffer.isView(o)?u[l]=x(o):u[l]=r(o)}return u}}function Xe(e){let t=[],i=[],n=new Map;if(n.set(Date,l=>new Date(l)),n.set(Map,(l,o)=>new Map(r(Array.from(l),o))),n.set(Set,(l,o)=>new Set(r(Array.from(l),o))),e.constructorHandlers)for(let l of e.constructorHandlers)n.set(l[0],l[1]);let g=null;return e.proto?u:c;function r(l,o){let a=Object.keys(l),d=new Array(a.length);for(let p=0;p<a.length;p++){let h=a[p],m=l[h];if(typeof m!="object"||m===null)d[h]=m;else if(m.constructor!==Object&&(g=n.get(m.constructor)))d[h]=g(m,o);else if(ArrayBuffer.isView(m))d[h]=x(m);else{let y=t.indexOf(m);y!==-1?d[h]=i[y]:d[h]=o(m)}}return d}function c(l){if(typeof l!="object"||l===null)return l;if(Array.isArray(l))return r(l,c);if(l.constructor!==Object&&(g=n.get(l.constructor)))return g(l,c);let o={};t.push(l),i.push(o);for(let a in l){if(Object.hasOwnProperty.call(l,a)===!1)continue;let d=l[a];if(typeof d!="object"||d===null)o[a]=d;else if(d.constructor!==Object&&(g=n.get(d.constructor)))o[a]=g(d,c);else if(ArrayBuffer.isView(d))o[a]=x(d);else{let p=t.indexOf(d);p!==-1?o[a]=i[p]:o[a]=c(d)}}return t.pop(),i.pop(),o}function u(l){if(typeof l!="object"||l===null)return l;if(Array.isArray(l))return r(l,u);if(l.constructor!==Object&&(g=n.get(l.constructor)))return g(l,u);let o={};t.push(l),i.push(o);for(let a in l){let d=l[a];if(typeof d!="object"||d===null)o[a]=d;else if(d.constructor!==Object&&(g=n.get(d.constructor)))o[a]=g(d,u);else if(ArrayBuffer.isView(d))o[a]=x(d);else{let p=t.indexOf(d);p!==-1?o[a]=i[p]:o[a]=u(d)}}return t.pop(),i.pop(),o}}});var ft={};Ze(ft,{defaults:()=>Je,removeWidows:()=>gt,version:()=>ct});function ye(e){return typeof e!="string"?e:e.length?[e]:[]}var Ee=be(G(),1);var pt=(0,Ee.default)();var Ae="\u2013",Te="\u2014",I="\xA0";function H(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function D(e){return typeof e=="string"}function ve(e){return Number.isFinite(e)}function R(e){return Number.isSafeInteger(e)&&e>=0}function C(e){return e!=null}function Se(e,t){return H(e)&&D(t)&&t in e}var Ne={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},et=e=>e+1;function tt(e,t,i,n,g=!1,r=et){var w;let c=typeof i=="function"?i():i;if(+t<0&&g&&c==="EOL")return c;let u=T(T({},Ne),n);if(t>=e.length&&!g)return!1;let l=g?1:i.length,o=0,a=!1,d=!1,p=!1,h=u.maxMismatches,m=t,y=!1,v=!1,E=!1;function A(){return o===1&&h<u.maxMismatches-1}for(;e[m];){let $=r(m);if(u.trimBeforeMatching&&e[m].trim()===""){if(!e[$]&&g&&i==="EOL")return!0;m=r(m);continue}if(u&&!u.i&&((w=u==null?void 0:u.trimCharsBeforeMatching)!=null&&w.includes(e[m]))||u!=null&&u.i&&u.trimCharsBeforeMatching&&u.trimCharsBeforeMatching.map(f=>f.toLowerCase()).includes(e[m].toLowerCase())){if(g&&i==="EOL"&&!e[$])return!0;m=r(m);continue}let O=$>m?i[i.length-l]:i[l-1];if(!u.i&&e[m]===O||u.i&&e[m].toLowerCase()===O.toLowerCase()){if(y||(y=!0),p||(p=!0),l===i.length){if(v=!0,h!==u.maxMismatches)return!1}else l===1&&(E=!0);if(l-=1,o++,A())return!1;if(!l)return o!==i.length||h===u.maxMismatches||!a?m:!1}else if(!a&&!o&&(a=!0),u.maxMismatches&&h&&m){h-=1;for(let f=0;f<=h;f++){let S=$>m?i[i.length-l+1+f]:i[l-2-f],M=e[r(m)];if(S&&(!u.i&&e[m]===S||u.i&&e[m].toLowerCase()===S.toLowerCase())&&(!u.firstMustMatch||l!==i.length)){if(o++,A())return!1;l-=2,y=!0;break}else if(M&&S&&(!u.i&&M===S||u.i&&M.toLowerCase()===S.toLowerCase())&&(!u.firstMustMatch||l!==i.length)){if(!o&&!u.hungry)return!1;l-=1,y=!0;break}else if(S===void 0&&h>=0&&y&&(!u.firstMustMatch||v)&&(!u.lastMustMatch||E))return m}y||(d=m)}else return m===0&&l===1&&!u.lastMustMatch&&p?0:!1;if(d!==!1&&d!==m&&(d=!1),l<1)return m;m=r(m)}if(l>0)return g&&c==="EOL"?!0:u&&u.maxMismatches>=l&&p?d||0:!1}function rt(e,t,i,n,g){var a,d,p;if(H(g)&&Se(g,"trimBeforeMatching")&&g&&typeof g.trimBeforeMatching!="boolean")throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!").concat(Array.isArray(g.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""));let r=T(T({},Ne),g);if(typeof r.trimCharsBeforeMatching=="string"&&(r.trimCharsBeforeMatching=ye(r.trimCharsBeforeMatching)),r.trimCharsBeforeMatching=r.trimCharsBeforeMatching.map(h=>D(h)?h:String(h)),!D(t)||!t.length)return!1;if(!Number.isInteger(i)||i<0)throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ").concat(typeof i,", equal to:\n").concat(JSON.stringify(i,null,4)));let c,u;if(D(n))c=[n];else if(Array.isArray(n))c=n;else if(!n)c=n;else if(typeof n=="function")c=[],c.push(n);else throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ").concat(typeof n,", equal to:\n").concat(JSON.stringify(n,null,4)));if(g&&!H(g))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type \"").concat(typeof g,'", and equal to:\n').concat(JSON.stringify(g,null,4)));let l=0,o="";if((a=r==null?void 0:r.trimCharsBeforeMatching)!=null&&a.some((h,m)=>h.length>1?(l=m,o=h,!0):!1))throw new Error("string-match-left-right/".concat(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 ").concat(l," is longer than 1 character, ").concat(o.length," (equals to ").concat(o,"). Please split it into separate characters and put into array as separate elements."));if(!c||!Array.isArray(c)||Array.isArray(c)&&!c.length||Array.isArray(c)&&c.length===1&&D(c[0])&&!c[0].trim()){if(typeof r.cb=="function"){let m,y=i;if((e==="matchLeftIncl"||e==="matchRight")&&(y+=1),e[5]==="L")for(let w=y;w--;){let $=t[w];if((!r.trimBeforeMatching||r.trimBeforeMatching&&($!=null&&$.trim()))&&(!((d=r.trimCharsBeforeMatching)!=null&&d.length)||$!==void 0&&!r.trimCharsBeforeMatching.includes($))){m=w;break}}else if(e.startsWith("matchRight"))for(let w=y;w<t.length;w++){let $=t[w];if((!r.trimBeforeMatching||r.trimBeforeMatching&&$.trim())&&(!((p=r.trimCharsBeforeMatching)!=null&&p.length)||!r.trimCharsBeforeMatching.includes($))){m=w;break}}if(m===void 0)return!1;let v=t[m],E=m+1,A="";return E&&E>0&&(A=t.slice(0,E)),e[5]==="L"||m&&m>0&&(A=t.slice(m)),r.cb(v,A,m)}let h="";throw g||(h=" More so, the whole options object, the fourth input argument, is missing!"),new Error("string-match-left-right/".concat(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!').concat(h))}for(let h=0,m=c.length;h<m;h++){u=typeof c[h]=="function";let y=c[h],v,E,A="",w=i;e==="matchRight"?w+=1:e==="matchLeft"&&(w-=1);let $=tt(t,w,y,r,u,O=>e[5]==="L"?O-1:O+1);if($&&u&&typeof y=="function"&&y()==="EOL")return y()&&(!r.cb||r.cb(v,A,E))?y():!1;if(Number.isInteger($)&&(E=e.startsWith("matchLeft")?$-1:$+1,e[5]==="L"?A=t.slice(0,$):A=t.slice(E)),E<0&&(E=void 0),t[E]&&(v=t[E]),Number.isInteger($)&&(!r.cb||r.cb(v,A,E)))return y}return!1}function De(e,t,i,n){return rt("matchRightIncl",e,t,i,n)}var Oe=be(G(),1);var Tt=(0,Oe.default)();var L="\xA0";function nt({str:e,idx:t=0,stopAtNewlines:i=!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()||i&&"\n\r".includes(e[t+1])||n&&e[t+1]===L))return t+1;if(e[t+2]&&(e[t+2].trim()||i&&"\n\r".includes(e[t+2])||n&&e[t+2]===L))return t+2;for(let g=t+1,r=e.length;g<r;g++)if(e[g].trim()||i&&"\n\r".includes(e[g])||n&&e[g]===L)return g;return null}function j(e,t=0){return nt({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function st({str:e,idx:t,stopAtNewlines:i,stopAtRawNbsp:n}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),t<1))return null;if(e[~-t]&&(e[~-t].trim()||i&&"\n\r".includes(e[~-t])||n&&e[~-t]===L))return~-t;if(e[t-2]&&(e[t-2].trim()||i&&"\n\r".includes(e[t-2])||n&&e[t-2]===L))return t-2;for(let g=t;g--;)if(e[g]&&(e[g].trim()||i&&"\n\r".includes(e[g])||n&&e[g]===L))return g;return null}function _(e,t=0){return st({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function k(e,t=1){let i="\xA0";function n(r){return Array.from(r).reverse().join("")}function g(r,c,u){let l=u?"\n":"\r",o=u?"\r":"\n";if(!r)return r;let a=0,d=0,p="";for(let h=0,m=r.length;h<m;h++)(r[h]===l||r[h]===o&&r[h-1]!==l)&&d++,"\r\n".includes(r[h])||r[h]===i?(a=0,r[h]===i?p+=r[h]:r[h]===l?d<=c&&(p+=r[h],r[h+1]===o&&(p+=r[h+1],h++)):r[h]===o&&(r==null?void 0:r[h-1])!==l&&d<=c&&(p+=r[h])):(a++,!r[h+1]&&!d&&(p+=" "));return p}if(typeof e=="string"&&e.length){let r=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(r=+t);let c="",u="";if(!e.trim())c=e;else if(!e[0].trim()){for(let l=0,o=e.length;l<o;l++)if(e[l].trim()){c=e.slice(0,l);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===i)){for(let l=e.length;l--;)if(e[l].trim()){u=e.slice(l+1);break}}return"".concat(g(c,r,!1)).concat(e.trim()).concat(n(g(n(u),r,!0)))}return e}var ot={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function V(e,t){if(!Array.isArray(e)||!e.length)return e;let i=T(T({},ot),t),n,g;if(i.strictlyTwoElementsInRangeArrays&&!e.every((u,l)=>!Array.isArray(u)||u.length!==2?(n=l,g=u.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, ".concat(n,"th range (").concat(JSON.stringify(e[n],null,4),") has not two but ").concat(g," elements!"));if(!e.every((u,l)=>!Array.isArray(u)||!Number.isInteger(u[0])||u[0]<0||!Number.isInteger(u[1])||u[1]<0?(n=l,!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, ".concat(n,"th range (").concat(JSON.stringify(e[n],null,4),") does not consist of only natural numbers!"));let r=e.length**2,c=0;return Array.from(e).sort((u,l)=>(i.progressFn&&(c+=1,i.progressFn(Math.floor(c*100/r))),u[0]===l[0]?u[1]<l[1]?-1:u[1]>l[1]?1:0:u[0]<l[0]?-1:1))}var We={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function it(e,t){var o;function i(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}if(!Array.isArray(e)||!e.length)return null;let n;if(t)if(i(t)){if(n=T(T({},We),t),n.progressFn&&i(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] resolvedOpts.progressFn must be a function! It was given of a type: "'.concat(typeof n.progressFn,'", equal to ').concat(JSON.stringify(n.progressFn,null,4)));if(![1,2,"1","2"].includes(n.mergeType))throw new Error('ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof n.mergeType,'", equal to ').concat(JSON.stringify(n.mergeType,null,4)));if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error('ranges-merge: [THROW_ID_04] resolvedOpts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "'.concat(typeof n.joinRangesThatTouchEdges,'", equal to ').concat(JSON.stringify(n.joinRangesThatTouchEdges,null,4)))}else throw new Error("ranges-merge: [THROW_ID_03] the second input argument must be a plain object. It was given as:\n".concat(JSON.stringify(t,null,4)," (type ").concat(typeof t,")"));else n=T({},We);let g=e.filter(a=>Array.isArray(a)).map(a=>[...a]).filter(a=>a[2]!==void 0||a[0]!==a[1]),r,c,u;n.progressFn?r=V(g,{progressFn:a=>{u=Math.floor(a/5),u!==c&&(c=u,n.progressFn!=null&&n.progressFn(u))}}):r=V(g);let l=r.length-1;for(let a=l;a>0;a--)n.progressFn&&(u=Math.floor((1-a/l)*78)+21,u!==c&&u>c&&(c=u,n.progressFn(u))),(r[a][0]<=r[a-1][0]||!n.joinRangesThatTouchEdges&&r[a][0]<r[a-1][1]||n.joinRangesThatTouchEdges&&r[a][0]<=r[a-1][1])&&(r[a-1][0]=Math.min(r[a][0],r[a-1][0]),r[a-1][1]=Math.max(r[a][1],r[a-1][1]),r[a][2]!==void 0&&(r[a-1][0]>=r[a][0]||r[a-1][1]<=r[a][1])&&r[a-1][2]!==null&&(r[a][2]===null&&r[a-1][2]!==null?r[a-1][2]=null:r[a-1][2]!=null?+((o=n||{})==null?void 0:o.mergeType)==2&&r[a-1][0]===r[a][0]?r[a-1][2]=r[a][2]:r[a-1][2]+=r[a][2]:r[a-1][2]=r[a][2]),r.splice(a,1),a=r.length);return r.length?r:null}var at={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},Ce=class{constructor(e){Q(this,"ranges");Q(this,"opts");let t=T(T({},at),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(D(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(D(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: "'.concat(typeof t.mergeType,'", equal to ').concat(JSON.stringify(t.mergeType,null,4)));this.opts=t,this.ranges=[]}add(e,t,i){var r;if(e==null&&t==null)return;if(C(e)&&!C(t)){if(Array.isArray(e)){if(e.length){if(e.some(c=>Array.isArray(c))){e.forEach(c=>{Array.isArray(c)&&this.add(...c)});return}e.length&&R(+e[0])&&R(+e[1])&&this.add(...e)}return}throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set ('.concat(JSON.stringify(e,null,0),') but second-one, "to" is not (').concat(JSON.stringify(t,null,0),")"))}else if(!C(e)&&C(t))throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set ('.concat(JSON.stringify(t,null,0),') but first-one, "from" is not (').concat(JSON.stringify(e,null,0),")"));let n=+e,g=+t;if(R(n)&&R(g)){if(C(i)&&!D(i)&&!ve(i))throw new TypeError("ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ".concat(typeof i,", equal to:\n").concat(JSON.stringify(i,null,4)));if(C(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=g,this.last()[2],this.last()[2]!==null&&C(i)){let c=this.last()[2]&&this.last()[2].length&&(!((r=this.opts)!=null&&r.mergeType)||this.opts.mergeType===1)?"".concat(this.last()[2]).concat(i):i;this.opts.limitToBeAddedWhitespace&&(c=k(c,this.opts.limitLinebreaksCount)),D(c)&&!c.length||(this.last()[2]=c)}}else{this.ranges||(this.ranges=[]);let c=i!==void 0&&!(D(i)&&!i.length)?[n,g,i&&this.opts.limitToBeAddedWhitespace?k(i,this.opts.limitLinebreaksCount):i]:[n,g];this.ranges.push(c)}}else throw R(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 "'.concat(typeof g,'" equal to: ').concat(JSON.stringify(g,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 "'.concat(typeof n,'" equal to: ').concat(JSON.stringify(n,null,4)))}push(e,t,i){this.add(e,t,i)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=it(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>C(e[2])?[e[0],e[1],k(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])&&R(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, ".concat(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}};var Re={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Me(e,t){function i(o){return!!o&&typeof o=="object"&&!Array.isArray(o)}if(!Array.isArray(e)||!e.length)return null;let n;if(t)if(i(t)){if(n=T(T({},Re),t),n.progressFn&&i(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: "'.concat(typeof n.progressFn,'", equal to ').concat(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: "'.concat(typeof n.mergeType,'", equal to ').concat(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: "'.concat(typeof n.joinRangesThatTouchEdges,'", equal to ').concat(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:\n".concat(JSON.stringify(t,null,4)," (type ").concat(typeof t,")"));else n=T({},Re);let g=e.filter(o=>Array.isArray(o)).map(o=>[...o]).filter(o=>o[2]!==void 0||o[0]!==o[1]),r,c,u;n.progressFn?r=V(g,{progressFn:o=>{u=Math.floor(o/5),u!==c&&(c=u,n.progressFn(u))}}):r=V(g);let l=r.length-1;for(let o=l;o>0;o--)n.progressFn&&(u=Math.floor((1-o/l)*78)+21,u!==c&&u>c&&(c=u,n.progressFn(u))),(r[o][0]<=r[o-1][0]||!n.joinRangesThatTouchEdges&&r[o][0]<r[o-1][1]||n.joinRangesThatTouchEdges&&r[o][0]<=r[o-1][1])&&(r[o-1][0]=Math.min(r[o][0],r[o-1][0]),r[o-1][1]=Math.max(r[o][1],r[o-1][1]),r[o][2]!==void 0&&(r[o-1][0]>=r[o][0]||r[o-1][1]<=r[o][1])&&r[o-1][2]!==null&&(r[o][2]===null&&r[o-1][2]!==null?r[o-1][2]=null:r[o-1][2]!=null?+n.mergeType==2&&r[o-1][0]===r[o][0]?r[o-1][2]=r[o][2]:r[o-1][2]+=r[o][2]:r[o-1][2]=r[o][2]),r.splice(o,1),o=r.length);return r.length?r:null}var lt=!0,K="Invariant failed";function xe(e,t){if(!e){if(lt)throw new Error(K);var i=typeof t=="function"?t():t,n=i?"".concat(K,": ").concat(i):K;throw new Error(n)}}function Z(e,t,i){let n=0,g=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: ".concat(typeof e,", equal to: ").concat(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: ".concat(typeof t,", equal to: ").concat(JSON.stringify(t,null,4)));if(i&&typeof i!="function")throw new TypeError("ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ".concat(typeof i,", equal to: ").concat(JSON.stringify(i,null,4)));if(!(t!=null&&t.filter(a=>a).length))return e;let r;Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?r=[Array.from(t)]:r=Array.from(t);let c=r.length,u=0;r.filter(a=>a).forEach((a,d)=>{if(i&&(n=Math.floor(u/c*10),n!==g&&(g=n,i(n))),!Array.isArray(a))throw new TypeError("ranges-apply: [THROW_ID_05] ranges array, second input arg., has ".concat(d,"th element not an array: ").concat(JSON.stringify(a,null,4),", which is ").concat(typeof a));if(!Number.isInteger(a[0])){if(!Number.isInteger(+a[0])||+a[0]<0)throw new TypeError("ranges-apply: [THROW_ID_06] ranges array, second input arg. has ".concat(d,"th element, array ").concat(JSON.stringify(a,null,0),". Its first element is not an integer, string index, but ").concat(typeof a[0],", equal to: ").concat(JSON.stringify(a[0],null,4),"."));r[d][0]=+r[d][0]}if(!Number.isInteger(a[1])){if(!Number.isInteger(+a[1])||+a[1]<0)throw new TypeError("ranges-apply: [THROW_ID_07] ranges array, second input arg. has ".concat(d,"th element, array ").concat(JSON.stringify(a,null,0),". Its second element is not an integer, string index, but ").concat(typeof a[1],", equal to: ").concat(JSON.stringify(a[1],null,4),"."));r[d][1]=+r[d][1]}u+=1});let l=Me(r,{progressFn:a=>{i&&(n=10+Math.floor(a/10),n!==g&&(g=n,i(n)))}});xe(l);let o=l.length;if(o>0){let a=e.slice(l[o-1][1]);e=l.reduce((d,p,h,m)=>{i&&(n=20+Math.floor(h/o*80),n!==g&&(g=n,i(n)));let y=h===0?0:m[h-1][1],v=m[h][0];return"".concat(d).concat(e.slice(y,v)).concat(m[h][2]||"")},""),e+=a}return e}var Ie="4.1.3";var P="&nbsp;",B="\\00A0",J="\\u00A0",Le="&ndash;",je="\\2013",Ve="\\u2013",Fe="&mdash;",He="\\2014",_e="\\u2014",z=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],Pe=[{heads:"{{",tails:"}}"}],Y=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],Be=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"];var ct=Ie,Je={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function gt(e,t){var ee,te,re,ne,se,oe,ie,ae,le,ue,ce,ge;let i=Date.now();if(typeof e!="string")throw e===void 0?new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error('string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "'.concat(typeof e,'", equal to:\n').concat(JSON.stringify(e,null,4)));if(t&&typeof t!="object")throw new Error("string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ".concat(typeof t,", equal to ").concat(JSON.stringify(t,null,4)));let n=Array.isArray,g=e.length,r=new Ce({mergeType:2}),c=["."],u=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,l=/^[0-9][A-Z]{2}/,o=.06,a,d=0,p=0,h=0,m,y,v,E,A,w,$,O,f=T(T({},Je),t),S={removeWidows:!1,convertEntities:!1};if(!f.ignore||!n(f.ignore)&&typeof f.ignore!="string")f.ignore=[];else if(typeof f.ignore=="string"&&(f.ignore=[f.ignore]),f.ignore.includes("all"))f.ignore=f.ignore.concat(z.concat(Y));else if(f.ignore.some(s=>typeof s=="string")){let s=[];f.ignore=f.ignore.filter(N=>typeof N=="string"&&N.length?(["nunjucks","jinja","liquid"].includes(N.trim().toLowerCase())?s=s.concat(z):["hugo"].includes(N.trim().toLowerCase())?s=s.concat(Pe):["hexo"].includes(N.trim().toLowerCase())&&(s=s.concat(Y)),!1):typeof N=="object"),s.length&&(f.ignore=f.ignore.concat(s))}let M;f.reportProgressFunc&&(M=Math.floor(f.reportProgressFuncTo-(f.reportProgressFuncTo-f.reportProgressFuncFrom)*o-f.reportProgressFuncFrom));function U(s,N){let b=I;f.removeWidowPreventionMeasures?b=" ":f.convertEntities&&(b=P,typeof f.targetLanguage=="string"&&(f.targetLanguage.trim().toLowerCase()==="css"?b=B:f.targetLanguage.trim().toLowerCase()==="js"&&(b=J))),e.slice(s,N)!==b&&r.push(s,N,b)}function X(){p=0,h=0,m=void 0,y=void 0,v=void 0,E=void 0,A=void 0,w=void 0}X();for(let s=0;s<=g;s++){if(!$&&n(f.ignore)&&f.ignore.length&&f.ignore.some((b,W)=>{if(n(b.heads)&&b.heads.some(fe=>e.startsWith(fe,s))||typeof b.heads=="string"&&e.startsWith(b.heads,s))return p+=1,$=f.ignore[W].tails,!0}),!$&&O&&O===s&&(p+=1,O=void 0),typeof f.reportProgressFunc=="function"&&(a=f.reportProgressFuncFrom+Math.floor(s/g*(M||1)),a!==d&&(d=a,f.reportProgressFunc(a))),!$&&s&&((ee=e[s])!=null&&ee.trim())&&(!e[s-1]||e[s-1]&&!e[s-1].trim())&&(E=s),!$&&((te=e[s])!=null&&te.trim())&&(h+=1),!$&&f.hyphens&&("-".concat(Te).concat(Ae).includes(e[s])||e.startsWith(Le,s)||e.startsWith(je,s)||e.startsWith(Ve,s)||e.startsWith(Fe,s)||e.startsWith(He,s)||e.startsWith(_e,s))&&e[s+1]&&(!e[s+1].trim()||e[s]==="&")&&e[s-1]&&!e[s-1].trim()&&e[_(e,s)]&&(U(_(e,s)+1,s),S.removeWidows=!0),!$&&(e.startsWith("&nbsp;",s)||e.startsWith("&#160;",s))&&(A=s,w=s+6,(re=e[s+6])!=null&&re.trim()&&(O=s+6),f.convertEntities?(f.targetLanguage==="css"||f.targetLanguage==="js")&&(r.push(s,s+6,f.targetLanguage==="css"?B:J),S.convertEntities=!0):(r.push(s,s+6,I),S.convertEntities=!0)),!$&&e[s+4]&&e[s]==="\\"&&e[s+1]==="0"&&e[s+2]==="0"&&e[s+3].toUpperCase()==="A"&&e[s+4]==="0"&&(A=s,w=s+5,(ne=e[s+5])!=null&&ne.trim()&&(O=s+5),f.convertEntities?(f.targetLanguage==="html"||f.targetLanguage==="js")&&(r.push(s,s+5,f.targetLanguage==="html"?P:J),S.convertEntities=!0):(r.push(s,s+5,I),S.convertEntities=!0)),!$&&e[s]==="\\"&&((se=e[s+1])==null?void 0:se.toLowerCase())==="u"&&e[s+2]==="0"&&e[s+3]==="0"&&((oe=e[s+4])==null?void 0:oe.toUpperCase())==="A"&&e[s+5]==="0"&&(A=s,w=s+6,(ie=e[s+6])!=null&&ie.trim()&&(O=s+6),f.convertEntities?(f.targetLanguage==="html"||f.targetLanguage==="css")&&r.push(s,s+6,f.targetLanguage==="html"?P:B):r.push(s,s+6,I)),!$&&e[s]===I&&(A=s,w=s+1,f.convertEntities&&r.push(s,s+1,f.targetLanguage==="css"?B:f.targetLanguage==="js"?J:P)),!$&&((ae=e[s])!=null&&ae.trim())&&!((le=e[s-1])!=null&&le.trim())&&(p+=1),!$&&(!e[s]||"\r\n".includes(e[s])||(e[s]==="\n"||e[s]==="\r"||e[s]==="\r"&&e[s+1]==="\n")&&_(e,s)&&c.includes(e[_(e,s)]))){if((!f.minWordCount||p>=f.minWordCount)&&(!f.minCharCount||h>=f.minCharCount)){let b,W;v!==void 0&&E!==void 0&&A!==void 0&&w!==void 0?v>A?(b=v,W=E):(b=A,W=w):v!==void 0&&E!==void 0?(b=v,W=E):A!==void 0&&w!==void 0&&(b=A,W=w),!(b&&W)&&m&&y&&(b=m,W=y),b&&W&&(U(b,W),S.removeWidows=!0)}X()}f.UKPostcodes&&e[s]&&!e[s].trim()&&((ue=e[s-1])!=null&&ue.trim())&&u.test(e.slice(0,s))&&e[j(e,s)]&&l.test(e.slice(j(e,s)))&&(U(s,j(e,s)),S.removeWidows=!0),!$&&e[s]&&!e[s].trim()&&((ce=e[s-1])!=null&&ce.trim())&&(v===void 0||(ge=e[v-1])!=null&&ge.trim())&&!"/>".includes(e[j(e,s)])&&!e.slice(0,s).trim().endsWith("br")&&!e.slice(0,s).trim().endsWith("hr")&&!(e.slice(0,s).endsWith("<")&&Be.some(b=>e.startsWith(b,j(e,s))))&&(m=v,y=E,v=s,E=void 0,(A!==void 0||w!==void 0)&&(A=void 0,w=void 0));let N;$&&(typeof $=="string"&&(!$.length||e.startsWith($,s))?$=void 0:n($)&&(!$.length||$.some(b=>{if(e.startsWith(b,s))return N=b,!0}))&&($=void 0,s+=N.length,n(f.ignore)&&f.ignore.length&&e[s+1]&&f.ignore.some(b=>De(e,s,b.tails,{trimBeforeMatching:!0,cb:(W,fe,de)=>{var me;return de&&(s=de-1,(me=e[s+1])!=null&&me.trim()&&(p+=1)),!0}})))),e[s]&&"\r\n".includes(e[s])&&(p=0,h=0),n(f.tagRanges)&&f.tagRanges.length&&f.tagRanges.some(b=>{if(s>=b[0]&&s<=b[1]&&b[1]-1>s)return s=b[1]-1,!0})}return Z(e,r.current()).split("").forEach((s,N)=>{}),{res:Z(e,r.current(),f.reportProgressFunc?s=>{a=Math.floor((f.reportProgressFuncTo-f.reportProgressFuncFrom)*(1-o)+s/100*(f.reportProgressFuncTo-f.reportProgressFuncFrom)*o),a!==d&&(d=a,f.reportProgressFunc(a))}:void 0),ranges:r.current(),log:{timeTakenInMilliseconds:Date.now()-i},whatWasDone:S}}return ze(ft);})();
10
+ "use strict";var stringRemoveWidows=(()=>{var U=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable;var K=(e,t,n)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t)=>{for(var n in t||(t={}))$e.call(t,n)&&K(e,n,t[n]);if(me)for(var n of me(t))He.call(t,n)&&K(e,n,t[n]);return e};var Pe=(e,t)=>{for(var n in t)U(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ke(t))!$e.call(e,u)&&u!==n&&U(e,u,{get:()=>t[u],enumerable:!(s=Fe(t,u))||s.enumerable});return e};var Ue=e=>Be(U({},"__esModule",{value:!0}),e);var F=(e,t,n)=>K(e,typeof t!="symbol"?t+"":t,n);var ut={};Pe(ut,{defaults:()=>_e,removeWidows:()=>lt,version:()=>at});function qe(){let e=[],t=0,n=!1;return{append(s){return n?!1:t+s.length>1999?(e.push("\u2026"),t+=1,n=!0,!1):(e.push(s),t+=s.length,!0)},result(){return e.join("")},stopped(){return n}}}function Je(e){return"\\u".concat(e.toString(16).padStart(4,"0"))}function q(e,t){if(e.append('"')){for(let n=0;n<t.length&&!e.stopped();n+=1){let s=t.charCodeAt(n);s===34?e.append('\\"'):s===92?e.append("\\\\"):s===8?e.append("\\b"):s===9?e.append("\\t"):s===10?e.append("\\n"):s===12?e.append("\\f"):s===13?e.append("\\r"):s<32||s===8232||s===8233||s>=55296&&s<=57343?e.append(Je(s)):e.append(t[n])}e.append('"')}}function Ge(e){return e.get&&e.set?"[Getter/Setter]":e.get?"[Getter]":e.set?"[Setter]":"[Accessor]"}function ye(e,t){e.append("Symbol(");let n=String(t);n.length>8&&q(e,n.slice(7,-1)),e.append(")")}function be(e,t){typeof t=="symbol"?ye(e,t):q(e,String(t))}function $(e,t=0){let n=qe(),s=t===4?4:0,u=new WeakSet,r=0;function g(a){s&&n.append(" ".repeat(a*s))}function l(a,p){a&&n.append(","),s&&(n.append("\n"),g(p+1))}function c(a,p,w){s&&p&&(n.append("\n"),g(w)),n.append(a)}function i(a,p){Object.prototype.hasOwnProperty.call(a,"value")?h(a.value,p):n.append(Ge(a))}function m(a,p){let w;try{w=Reflect.getOwnPropertyDescriptor(a,"length")}catch(b){n.append("[Uninspectable]");return}let y=w==null?void 0:w.value;if(!Number.isSafeInteger(y)||y<0){n.append("[Uninspectable]");return}n.append("[");let A=!1;for(let b=0;b<y&&!n.stopped();b+=1){if(l(A,p),A=!0,r>=50){n.append("[MaxEntries]");break}r+=1;let d;try{d=Reflect.getOwnPropertyDescriptor(a,String(b))}catch(S){n.append("[Uninspectable]");continue}d!=null&&d.enumerable?i(d,p+1):n.append("[Empty]")}c("]",A,p)}function v(a,p){let w;try{w=Reflect.ownKeys(a)}catch(A){n.append("[Uninspectable]");return}n.append("{");let y=!1;for(let A of w){if(n.stopped())break;if(r>=50){l(y,p),y=!0,q(n,"\u2026"),n.append(s?": ":":"),n.append("[MaxEntries]");break}r+=1;let b;try{b=Reflect.getOwnPropertyDescriptor(a,A)}catch(d){l(y,p),y=!0,be(n,A),n.append(s?": ":":"),n.append("[Uninspectable]");continue}b!=null&&b.enumerable&&(l(y,p),y=!0,be(n,A),n.append(s?": ":":"),i(b,p+1))}c("}",y,p)}function T(a,p){if(u.has(a)){n.append("[Circular]");return}if(p>=5){n.append("[MaxDepth]");return}let w;try{w=Array.isArray(a)}catch(y){n.append("[Uninspectable]");return}u.add(a);try{w?m(a,p):v(a,p)}finally{u.delete(a)}}function h(a,p){a===null?n.append("null"):typeof a=="string"?q(n,a):typeof a=="number"?n.append(Object.is(a,-0)?"-0":String(a)):typeof a=="boolean"?n.append(a?"true":"false"):typeof a>"u"?n.append("undefined"):typeof a=="bigint"?n.append("".concat(a,"n")):typeof a=="symbol"?ye(n,a):typeof a=="function"?n.append("[Function]"):T(a,p)}try{return h(e,0),n.result()}catch(a){return"[Uninspectable]"}}var we="\u2013",Ae="\u2014",L="\xA0";var gt=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]),ze=Object.prototype.hasOwnProperty;function N(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function R(e){return typeof e=="string"}function Ee(e){return Number.isFinite(e)}function M(e){return Number.isSafeInteger(e)&&e>=0}function I(e){return e!=null}function ve(e,t){return N(e)&&R(t)&&ze.call(e,t)}var Ke={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function V(e,t){if(!Array.isArray(e)||!e.length)return e;let n=W(W({},Ke),t),s,u;if(n.strictlyTwoElementsInRangeArrays&&!e.every((l,c)=>!Array.isArray(l)||l.length!==2?(s=c,u=l.length,!1):!0))throw new TypeError("ranges-sort/rSort(): [THROW_ID_01] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ".concat(s,"th range (").concat($(e[s],4),") has not two but ").concat(u," elements!"));if(!e.every((l,c)=>!Array.isArray(l)||!Number.isInteger(l[0])||l[0]<0||!Number.isInteger(l[1])||l[1]<0?(s=c,!1):!0))throw new TypeError("ranges-sort/rSort(): [THROW_ID_02] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ".concat(s,"th range (").concat($(e[s],4),") does not consist of only natural numbers!"));let r=e.length**2,g=0;return Array.from(e).sort((l,c)=>(n.progressFn&&(g+=1,n.progressFn(Math.floor(g*100/r))),l[0]===c[0]?l[1]<c[1]?-1:l[1]>c[1]?1:0:l[0]<c[0]?-1:1))}var Qe={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Q(e,t){function n(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;if(t&&!n(t))throw new TypeError("ranges-merge/rMerge(): [THROW_ID_01] the second input argument must be a plain object. It was given as:\n".concat($(t,4)," (type ").concat(typeof t,")"));let s=W(W({},Qe),t);if(s.progressFn&&n(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new TypeError('ranges-merge/rMerge(): [THROW_ID_02] opts.progressFn must be a function! It was given of a type: "'.concat(typeof s.progressFn,'", equal to ').concat($(s.progressFn,4)));if(![1,2,"1","2"].includes(s.mergeType))throw new TypeError('ranges-merge/rMerge(): [THROW_ID_03] opts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof s.mergeType,'", equal to ').concat($(s.mergeType,4)));if(typeof s.joinRangesThatTouchEdges!="boolean")throw new TypeError('ranges-merge/rMerge(): [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "'.concat(typeof s.joinRangesThatTouchEdges,'", equal to ').concat($(s.joinRangesThatTouchEdges,4)));let u=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),r,g,l;s.progressFn?r=V(u,{progressFn:i=>{l=Math.floor(i/5),l!==g&&(g=l,s.progressFn(l))}}):r=V(u);let c=r.length-1;for(let i=c;i>0;i--)s.progressFn&&(l=Math.floor((1-i/c)*78)+21,l!==g&&l>g&&(g=l,s.progressFn(l))),(r[i][0]<=r[i-1][0]||!s.joinRangesThatTouchEdges&&r[i][0]<r[i-1][1]||s.joinRangesThatTouchEdges&&r[i][0]<=r[i-1][1])&&(r[i-1][0]=Math.min(r[i][0],r[i-1][0]),r[i-1][1]=Math.max(r[i][1],r[i-1][1]),r[i][2]!==void 0&&(r[i-1][0]>=r[i][0]||r[i-1][1]<=r[i][1])&&r[i-1][2]!==null&&(r[i][2]===null&&r[i-1][2]!==null?r[i-1][2]=null:r[i-1][2]!=null?+s.mergeType==2&&r[i-1][0]===r[i][0]?r[i-1][2]=r[i][2]:r[i-1][2]+=r[i][2]:r[i-1][2]=r[i][2]),r.splice(i,1),i=r.length);return r.length?r:null}function J(e){if(typeof e=="number")return Number.isInteger(e)&&e>=0;if(typeof e!="string"||!e.trim())return!1;let t=Number(e);return Number.isInteger(t)&&t>=0}function Z(e,t,n){let s=0,u=0;if(e===void 0&&t===void 0&&n===void 0)throw new Error("ranges-apply/rApply(): [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError("ranges-apply/rApply(): [THROW_ID_02] first input argument must be a string! Currently it's: ".concat(typeof e,", equal to: ").concat($(e,4)));if(t!=null&&!Array.isArray(t))throw new TypeError("ranges-apply/rApply(): [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ".concat(typeof t,", equal to: ").concat($(t,4)));if(n&&typeof n!="function")throw new TypeError("ranges-apply/rApply(): [THROW_ID_04] the third input argument must be a function (or falsy)! Currently it's: ".concat(typeof n,", equal to: ").concat($(n,4)));if(!(t!=null&&t.some(Boolean)))return e;let r;Array.isArray(t)&&!Array.isArray(t[0])&&J(t[0])&&J(t[1])?r=[Array.from(t)]:r=Array.from(t);let g=r.length,l=0;r.forEach((m,v)=>{if(m){if(n&&(s=Math.floor(l/g*10),s!==u&&(u=s,n(s))),!Array.isArray(m))throw new TypeError("ranges-apply/rApply(): [THROW_ID_05] ranges array, second input arg., has ".concat(v,"th element not an array: ").concat($(m,4),", which is ").concat(typeof m));if(!J(m[0]))throw new TypeError("ranges-apply/rApply(): [THROW_ID_06] ranges array, second input arg. has ".concat(v,"th element, array ").concat($(m),". Its first element is not a non-negative integer or string index, but ").concat(typeof m[0],", equal to: ").concat($(m[0],4),"."));if(typeof m[0]=="string"&&(r[v]=[...m],r[v][0]=Number(m[0])),!J(m[1]))throw new TypeError("ranges-apply/rApply(): [THROW_ID_07] ranges array, second input arg. has ".concat(v,"th element, array ").concat($(m),". Its second element is not a non-negative integer or string index, but ").concat(typeof m[1],", equal to: ").concat($(m[1],4),"."));typeof m[1]=="string"&&(r[v]===m&&(r[v]=[...m]),r[v][1]=Number(m[1])),l+=1}});let c=n?Q(r,{progressFn:m=>{s=10+Math.floor(m/10),s!==u&&(u=s,n(s))}}):Q(r),i=(c==null?void 0:c.length)||0;if(c&&i>0){let m=e.slice(c[i-1][1]);e=c.reduce((v,T,h,a)=>{n&&(s=20+Math.floor(h/i*80),s!==u&&(u=s,n(s)));let p=h===0?0:a[h-1][1],w=a[h][0];return"".concat(v).concat(e.slice(p,w)).concat(a[h][2]||"")},""),e+=m}return e}function G(e,t=1){let n="\xA0";function s(r){return Array.from(r).reverse().join("")}function u(r,g,l){let c=l?"\n":"\r",i=l?"\r":"\n";if(!r)return r;let m=0,v=0,T="";for(let h=0,a=r.length;h<a;h++)(r[h]===c||r[h]===i&&r[h-1]!==c)&&v++,"\r\n".includes(r[h])||r[h]===n?(m=0,r[h]===n?T+=r[h]:r[h]===c?v<=g&&(T+=r[h],r[h+1]===i&&(T+=r[h+1],h++)):r[h]===i&&(r==null?void 0:r[h-1])!==c&&v<=g&&(T+=r[h])):(m++,!r[h+1]&&!v&&(T+=" "));return T}if(typeof e=="string"&&e.length){let r=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(r=+t);let g="",l="";if(!e.trim())g=e;else if(!e[0].trim()){for(let c=0,i=e.length;c<i;c++)if(e[c].trim()){g=e.slice(0,c);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===n)){for(let c=e.length;c--;)if(e[c].trim()){l=e.slice(c+1);break}}return"".concat(u(g,r,!1)).concat(e.trim()).concat(s(u(s(l),r,!0)))}return e}var Ze={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Ye(e,t){function n(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;if(t&&!n(t))throw new TypeError("ranges-push/rMerge(): [THROW_ID_10] the second input argument must be a plain object. It was given as:\n".concat($(t,4)," (type ").concat(typeof t,")"));let s=W(W({},Ze),t);if(s.progressFn&&n(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new TypeError('ranges-push/rMerge(): [THROW_ID_11] resolvedOpts.progressFn must be a function! It was given of a type: "'.concat(typeof s.progressFn,'", equal to ').concat($(s.progressFn,4)));if(![1,2,"1","2"].includes(s.mergeType))throw new TypeError('ranges-push/rMerge(): [THROW_ID_12] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof s.mergeType,'", equal to ').concat($(s.mergeType,4)));if(typeof s.joinRangesThatTouchEdges!="boolean")throw new TypeError('ranges-push/rMerge(): [THROW_ID_13] resolvedOpts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "'.concat(typeof s.joinRangesThatTouchEdges,'", equal to ').concat($(s.joinRangesThatTouchEdges,4)));let u=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),r,g,l;s.progressFn?r=V(u,{progressFn:i=>{l=Math.floor(i/5),l!==g&&(g=l,s.progressFn!=null&&s.progressFn(l))}}):r=V(u);let c=r.length-1;for(let i=c;i>0;i--)s.progressFn&&(l=Math.floor((1-i/c)*78)+21,l!==g&&l>g&&(g=l,s.progressFn(l))),(r[i][0]<=r[i-1][0]||!s.joinRangesThatTouchEdges&&r[i][0]<r[i-1][1]||s.joinRangesThatTouchEdges&&r[i][0]<=r[i-1][1])&&(r[i-1][0]=Math.min(r[i][0],r[i-1][0]),r[i-1][1]=Math.max(r[i][1],r[i-1][1]),r[i][2]!==void 0&&(r[i-1][0]>=r[i][0]||r[i-1][1]<=r[i][1])&&r[i-1][2]!==null&&(r[i][2]===null&&r[i-1][2]!==null?r[i-1][2]=null:r[i-1][2]!=null?+s.mergeType==2&&r[i-1][0]===r[i][0]?r[i-1][2]=r[i][2]:r[i-1][2]+=r[i][2]:r[i-1][2]=r[i][2]),r.splice(i,1),i=r.length);return r.length?r:null}var Xe={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1};function Te(e){return e[2]===void 0&&e[0]===e[1]}function et(e){let t=-1;for(let n=0,s=e.length;n<s;n++){let u=e[n];if(Array.isArray(u)){if(u[0]<t)return!1;t=u[0]}}return!0}var We=class{constructor(e){F(this,"ranges");F(this,"opts");F(this,"sorted");if(e!=null&&!N(e))throw new TypeError("ranges-push/Ranges/constructor(): [THROW_ID_01] The options argument must be a plain object. It was given as ".concat($(e,4)," (type ").concat(typeof e,")."));let t=W(W({},Xe),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(R(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(R(t.mergeType)&&t.mergeType.trim()==="2")t.mergeType=2;else throw new Error('ranges-push/Ranges/constructor(): [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof t.mergeType,'", equal to ').concat($(t.mergeType,4)));this.opts=t,this.ranges=[],this.sorted=!0}add(e,t,n){var r;if(e==null&&t==null)return;if(I(e)&&!I(t)){if(Array.isArray(e)){if(e.length){if(e.some(g=>Array.isArray(g))){e.forEach(g=>{Array.isArray(g)&&this.add(...g)});return}e.length&&M(+e[0])&&M(+e[1])&&this.add(...e)}return}throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_03] the first input argument, "from" is set ('.concat($(e),') but second-one, "to" is not (').concat($(t),")"))}else if(!I(e)&&I(t))throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_04] the second input argument, "to" is set ('.concat($(t),') but first-one, "from" is not (').concat($(e),")"));let s=+e,u=+t;if(M(s)&&M(u)){if(I(n)&&!R(n)&&!Ee(n))throw new TypeError("ranges-push/Ranges/add(): [THROW_ID_05] The third argument, the value to add, was given not as string but ".concat(typeof n,", equal to:\n").concat($(n,4)));if(I(this.ranges)&&Array.isArray(this.last())&&s===this.last()[1]){if(this.last()[1]=u,this.last()[2],this.last()[2]!==null&&I(n)){let g=this.last()[2]&&this.last()[2].length&&(!((r=this.opts)!=null&&r.mergeType)||this.opts.mergeType===1)?"".concat(this.last()[2]).concat(n):n;this.opts.limitToBeAddedWhitespace&&(g=G(g,this.opts.limitLinebreaksCount)),R(g)&&!g.length||(this.last()[2]=g)}}else{this.ranges||(this.ranges=[]);let g=this.last();g&&s<g[0]&&(this.sorted=!1);let l=n!==void 0&&!(R(n)&&!n.length)?[s,u,n&&this.opts.limitToBeAddedWhitespace?G(n,this.opts.limitLinebreaksCount):n]:[s,u];this.ranges.push(l)}}else throw M(s)?new TypeError('ranges-push/Ranges/add(): [THROW_ID_07] "to" value, the second input argument, must be a natural number or zero! Currently it\'s of a type "'.concat(typeof t,'" equal to: ').concat($(t,4))):new TypeError('ranges-push/Ranges/add(): [THROW_ID_06] "from" value, the first input argument, must be a natural number or zero! Currently it\'s of a type "'.concat(typeof e,'" equal to: ').concat($(e,4)))}push(e,t,n){this.add(e,t,n)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=Ye(this.ranges,{mergeType:this.opts.mergeType}),this.sorted=!0,this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>I(e[2])?[e[0],e[1],G(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}firstCovers(e){if(!M(e))throw new TypeError("ranges-push/Ranges/firstCovers(): [THROW_ID_08] the input argument must be a natural number or zero! It was given as ".concat($(e,4)," (type ").concat(typeof e,")"));if(!Array.isArray(this.ranges)||!this.ranges.length)return!1;let t=null;if(this.sorted){for(let s=0,u=this.ranges.length;s<u;s++){let r=this.ranges[s];if(!(!Array.isArray(r)||Te(r))){if(t===null){if(r[0]!==0)return!1;t=r[1]}else{if(r[0]>t)break;r[1]>t&&(t=r[1])}if(t>=e)return!0}}return t!==null&&t>=e}let n=!0;for(;n;){n=!1;for(let s=0,u=this.ranges.length;s<u;s++){let r=this.ranges[s];if(!(!Array.isArray(r)||Te(r))){if(r[0]<0)return!1;(t===null?r[0]===0:r[0]<=t&&r[1]>t)&&(t=r[1],n=!0)}}}return t!==null&&t>=e}wipe(){this.ranges=[],this.sorted=!0}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&M(e[0][0]))this.ranges=Array.from(e),this.sorted=et(this.ranges);else throw new Error("ranges-push/Ranges/replace(): [THROW_ID_09] Single range was given but we expected array of arrays! The first element, ".concat($(e[0],4)," should be an array and its first element should be an integer, a string index."));else this.ranges=[],this.sorted=!0}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};var j="\xA0";function tt({str:e,idx:t=0,stopAtNewlines:n=!1,stopAtRawNbsp:s=!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()||n&&"\n\r".includes(e[t+1])||s&&e[t+1]===j))return t+1;if(e[t+2]&&(e[t+2].trim()||n&&"\n\r".includes(e[t+2])||s&&e[t+2]===j))return t+2;for(let u=t+1,r=e.length;u<r;u++)if(e[u].trim()||n&&"\n\r".includes(e[u])||s&&e[u]===j)return u;return null}function _(e,t=0){return tt({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function rt({str:e,idx:t,stopAtNewlines:n,stopAtRawNbsp:s}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),t<1))return null;if(e[~-t]&&(e[~-t].trim()||n&&"\n\r".includes(e[~-t])||s&&e[~-t]===j))return~-t;if(e[t-2]&&(e[t-2].trim()||n&&"\n\r".includes(e[t-2])||s&&e[t-2]===j))return t-2;for(let u=t;u--;)if(e[u]&&(e[u].trim()||n&&"\n\r".includes(e[u])||s&&e[u]===j))return u;return null}function k(e,t=0){return rt({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function De(e){return typeof e!="string"?e:e.length?[e]:[]}var Se={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},nt=e=>e+1;function st(e,t,n,s,u=!1,r=nt){var b;let g=typeof n=="function"?n():n;if(+t<0&&u&&g==="EOL")return g;let l=W(W({},Se),s);if(t>=e.length&&!u)return!1;let c=u?1:n.length,i=0,m=!1,v=!1,T=!1,h=l.maxMismatches,a=t,p=!1,w=!1,y=!1;function A(){return i===1&&h<l.maxMismatches-1}for(;e[a];){let d=r(a);if(l.trimBeforeMatching&&e[a].trim()===""){if(!e[d]&&u&&n==="EOL")return!0;a=r(a);continue}if(l&&!l.i&&((b=l==null?void 0:l.trimCharsBeforeMatching)!=null&&b.includes(e[a]))||l!=null&&l.i&&l.trimCharsBeforeMatching&&l.trimCharsBeforeMatching.map(f=>f.toLowerCase()).includes(e[a].toLowerCase())){if(u&&n==="EOL"&&!e[d])return!0;a=r(a);continue}let S=d>a?n[n.length-c]:n[c-1];if(!l.i&&e[a]===S||l.i&&S!==void 0&&e[a].toLowerCase()===S.toLowerCase()){if(p||(p=!0),T||(T=!0),c===n.length){if(w=!0,h!==l.maxMismatches)return!1}else c===1&&(y=!0);if(c-=1,i++,A())return!1;if(!c)return i!==n.length||h===l.maxMismatches||!m?a:!1}else if(!m&&!i&&(m=!0),l.maxMismatches&&h&&a){h-=1;for(let f=0;f<=h;f++){let D=d>a?n[n.length-c+1+f]:n[c-2-f],x=e[r(a)];if(D&&(!l.i&&e[a]===D||l.i&&e[a].toLowerCase()===D.toLowerCase())&&(!l.firstMustMatch||c!==n.length)){if(i++,A())return!1;c-=2,p=!0;break}else if(x&&D&&(!l.i&&x===D||l.i&&x.toLowerCase()===D.toLowerCase())&&(!l.firstMustMatch||c!==n.length)){if(!i&&!l.hungry)return!1;c-=1,p=!0;break}else if(D===void 0&&h>=0&&p&&(!l.firstMustMatch||w)&&(!l.lastMustMatch||y))return a}p||(v=a)}else return a===0&&c===1&&!l.lastMustMatch&&T?0:!1;if(v!==!1&&v!==a&&(v=!1),c<1)return a;a=r(a)}if(c>0)return u&&g==="EOL"?!0:l&&l.maxMismatches>=c&&T?v||0:!1}function ot(e,t,n,s,u){var m,v,T;if(N(u)&&ve(u,"trimBeforeMatching")&&u&&typeof u.trimBeforeMatching!="boolean")throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_01] opts.trimBeforeMatching should be boolean!").concat(Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""));let r=W(W({},Se),u);if(typeof r.trimCharsBeforeMatching=="string"&&(r.trimCharsBeforeMatching=De(r.trimCharsBeforeMatching)),r.trimCharsBeforeMatching=r.trimCharsBeforeMatching.map(h=>R(h)?h:String(h)),!R(t)||!t.length)return!1;if(!Number.isInteger(n)||n<0)throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_02] the second argument should be a natural number. Currently it's of a type: ").concat(typeof n,", equal to:\n").concat($(n,4)));let g,l;if(R(s))g=[s];else if(Array.isArray(s))g=s;else if(!s)g=s;else if(typeof s=="function")g=[],g.push(s);else throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_03] the third argument, whatToMatch, is neither string nor array of strings! It's ").concat(typeof s,", equal to:\n").concat($(s,4)));if(u&&!N(u))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_04] the fourth argument, options object, should be a plain object. Currently it's of a type \"").concat(typeof u,'", and equal to:\n').concat($(u,4)));let c=0,i="";if((m=r==null?void 0:r.trimCharsBeforeMatching)!=null&&m.some((h,a)=>h.length>1?(c=a,i=h,!0):!1))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_05] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ").concat(c," is longer than 1 character, ").concat(i.length," (equals to ").concat(i,"). Please split it into separate characters and put into array as separate elements."));if(!g||!Array.isArray(g)||Array.isArray(g)&&!g.length||Array.isArray(g)&&g.length===1&&R(g[0])&&!g[0].trim()){if(typeof r.cb=="function"){let a,p=n;if((e==="matchLeftIncl"||e==="matchRight")&&(p+=1),e[5]==="L")for(let b=p;b--;){let d=t[b];if((!r.trimBeforeMatching||r.trimBeforeMatching&&(d!=null&&d.trim()))&&(!((v=r.trimCharsBeforeMatching)!=null&&v.length)||d!==void 0&&!r.trimCharsBeforeMatching.includes(d))){a=b;break}}else if(e.startsWith("matchRight"))for(let b=p;b<t.length;b++){let d=t[b];if((!r.trimBeforeMatching||r.trimBeforeMatching&&d.trim())&&(!((T=r.trimCharsBeforeMatching)!=null&&T.length)||!r.trimCharsBeforeMatching.includes(d))){a=b;break}}if(a===void 0)return!1;let w=t[a],y=a+1,A="";return y&&y>0&&(A=t.slice(0,y)),e[5]==="L"||a&&a>0&&(A=t.slice(a)),r.cb(w,A,a)}let h="";throw u||(h=" More so, the whole options object, the fourth input argument, is missing!"),new Error("string-match-left-right/".concat(e,'(): [THROW_ID_06] 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!').concat(h))}for(let h=0,a=g.length;h<a;h++){l=typeof g[h]=="function";let p=g[h],w,y,A="",b=n;e==="matchRight"?b+=1:e==="matchLeft"&&(b-=1);let d=st(t,b,p,r,l,S=>e[5]==="L"?S-1:S+1);if(d&&l&&typeof p=="function"&&p()==="EOL")return p()&&(!r.cb||r.cb(w,A,y))?p():!1;if(Number.isInteger(d)&&(y=e.startsWith("matchLeft")?d-1:d+1,e[5]==="L"?A=t.slice(0,d):A=t.slice(y)),y<0&&(y=void 0),t[y]&&(w=t[y]),Number.isInteger(d)&&(!r.cb||r.cb(w,A,y)))return p}return!1}function Ce(e,t,n,s){return ot("matchRightIncl",e,t,n,s)}var Re="4.2.1";var H="&nbsp;",P="\\00A0",B="\\u00A0",Oe="&ndash;",Ne="\\2013",Me="\\u2013",Ie="&mdash;",xe="\\2014",Le="\\u2014",Y=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],Ve=[{heads:"{{",tails:"}}"}],X=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],je=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"];var at=Re,_e={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function lt(e,t){var te,re,ne,se,oe,ie,ae,le,ue,fe,ge,ce;let n=Date.now();if(typeof e!="string")throw e===void 0?new Error("string-remove-widows/removeWidows(): [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error('string-remove-widows/removeWidows(): [THROW_ID_02] the first input argument must be string! It was given as "'.concat(typeof e,'", equal to:\n').concat($(e,4)));if(t&&!N(t))throw new Error("string-remove-widows/removeWidows(): [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ".concat(typeof t,", equal to ").concat($(t,4)));let s=Array.isArray,u=e.length,r=new We({mergeType:2}),g=["."],l=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,c=/^[0-9][A-Z]{2}/,i=.06,m,v=0,T=0,h=0,a,p,w,y,A,b,d,S,f=W(W({},_e),t),D={removeWidows:!1,convertEntities:!1};if(!f.ignore||!s(f.ignore)&&typeof f.ignore!="string")f.ignore=[];else if(typeof f.ignore=="string"&&(f.ignore=[f.ignore]),f.ignore.includes("all"))f.ignore=f.ignore.concat(Y.concat(X));else if(f.ignore.some(o=>typeof o=="string")){let o=[];f.ignore=f.ignore.filter(C=>typeof C=="string"&&C.length?(["nunjucks","jinja","liquid"].includes(C.trim().toLowerCase())?o=o.concat(Y):["hugo"].includes(C.trim().toLowerCase())?o=o.concat(Ve):["hexo"].includes(C.trim().toLowerCase())&&(o=o.concat(X)),!1):typeof C=="object"),o.length&&(f.ignore=f.ignore.concat(o))}let x;f.reportProgressFunc&&(x=Math.floor(f.reportProgressFuncTo-(f.reportProgressFuncTo-f.reportProgressFuncFrom)*i-f.reportProgressFuncFrom));function z(o,C){let E=L;f.removeWidowPreventionMeasures?E=" ":f.convertEntities&&(E=H,typeof f.targetLanguage=="string"&&(f.targetLanguage.trim().toLowerCase()==="css"?E=P:f.targetLanguage.trim().toLowerCase()==="js"&&(E=B))),e.slice(o,C)!==E&&r.push(o,C,E)}function ee(){T=0,h=0,a=void 0,p=void 0,w=void 0,y=void 0,A=void 0,b=void 0}ee();for(let o=0;o<=u;o++){if(!d&&s(f.ignore)&&f.ignore.length&&f.ignore.some((E,O)=>s(E.heads)&&E.heads.some(he=>e.startsWith(he,o))||typeof E.heads=="string"&&e.startsWith(E.heads,o)?(T+=1,d=f.ignore[O].tails,!0):!1),!d&&S&&S===o&&(T+=1,S=void 0),typeof f.reportProgressFunc=="function"&&(m=f.reportProgressFuncFrom+Math.floor(o/u*(x||1)),m!==v&&(v=m,f.reportProgressFunc(m))),!d&&o&&((te=e[o])!=null&&te.trim())&&(!e[o-1]||e[o-1]&&!e[o-1].trim())&&(y=o),!d&&((re=e[o])!=null&&re.trim())&&(h+=1),!d&&f.hyphens&&("-".concat(Ae).concat(we).includes(e[o])||e.startsWith(Oe,o)||e.startsWith(Ne,o)||e.startsWith(Me,o)||e.startsWith(Ie,o)||e.startsWith(xe,o)||e.startsWith(Le,o))&&e[o+1]&&(!e[o+1].trim()||e[o]==="&")&&e[o-1]&&!e[o-1].trim()&&e[k(e,o)]&&(z(k(e,o)+1,o),D.removeWidows=!0),!d&&(e.startsWith("&nbsp;",o)||e.startsWith("&#160;",o))&&(A=o,b=o+6,(ne=e[o+6])!=null&&ne.trim()&&(S=o+6),f.convertEntities?(f.targetLanguage==="css"||f.targetLanguage==="js")&&(r.push(o,o+6,f.targetLanguage==="css"?P:B),D.convertEntities=!0):(r.push(o,o+6,L),D.convertEntities=!0)),!d&&e[o+4]&&e[o]==="\\"&&e[o+1]==="0"&&e[o+2]==="0"&&e[o+3].toUpperCase()==="A"&&e[o+4]==="0"&&(A=o,b=o+5,(se=e[o+5])!=null&&se.trim()&&(S=o+5),f.convertEntities?(f.targetLanguage==="html"||f.targetLanguage==="js")&&(r.push(o,o+5,f.targetLanguage==="html"?H:B),D.convertEntities=!0):(r.push(o,o+5,L),D.convertEntities=!0)),!d&&e[o]==="\\"&&((oe=e[o+1])==null?void 0:oe.toLowerCase())==="u"&&e[o+2]==="0"&&e[o+3]==="0"&&((ie=e[o+4])==null?void 0:ie.toUpperCase())==="A"&&e[o+5]==="0"&&(A=o,b=o+6,(ae=e[o+6])!=null&&ae.trim()&&(S=o+6),f.convertEntities?(f.targetLanguage==="html"||f.targetLanguage==="css")&&r.push(o,o+6,f.targetLanguage==="html"?H:P):r.push(o,o+6,L)),!d&&e[o]===L&&(A=o,b=o+1,f.convertEntities&&r.push(o,o+1,f.targetLanguage==="css"?P:f.targetLanguage==="js"?B:H)),!d&&((le=e[o])!=null&&le.trim())&&!((ue=e[o-1])!=null&&ue.trim())&&(T+=1),!d&&(!e[o]||"\r\n".includes(e[o])||(e[o]==="\n"||e[o]==="\r"||e[o]==="\r"&&e[o+1]==="\n")&&k(e,o)&&g.includes(e[k(e,o)]))){if((!f.minWordCount||T>=f.minWordCount)&&(!f.minCharCount||h>=f.minCharCount)){let E,O;w!==void 0&&y!==void 0&&A!==void 0&&b!==void 0?w>A?(E=w,O=y):(E=A,O=b):w!==void 0&&y!==void 0?(E=w,O=y):A!==void 0&&b!==void 0&&(E=A,O=b),!(E&&O)&&a&&p&&(E=a,O=p),E&&O&&(z(E,O),D.removeWidows=!0)}ee()}f.UKPostcodes&&e[o]&&!e[o].trim()&&((fe=e[o-1])!=null&&fe.trim())&&l.test(e.slice(0,o))&&e[_(e,o)]&&c.test(e.slice(_(e,o)))&&(z(o,_(e,o)),D.removeWidows=!0),!d&&e[o]&&!e[o].trim()&&((ge=e[o-1])!=null&&ge.trim())&&(w===void 0||(ce=e[w-1])!=null&&ce.trim())&&!"/>".includes(e[_(e,o)])&&!e.slice(0,o).trim().endsWith("br")&&!e.slice(0,o).trim().endsWith("hr")&&!(e.slice(0,o).endsWith("<")&&je.some(E=>e.startsWith(E,_(e,o))))&&(a=w,p=y,w=o,y=void 0,(A!==void 0||b!==void 0)&&(A=void 0,b=void 0));let C;d&&(typeof d=="string"&&(!d.length||e.startsWith(d,o))?d=void 0:s(d)&&(!d.length||d.some(E=>e.startsWith(E,o)?(C=E,!0):!1))&&(d=void 0,o+=C.length,s(f.ignore)&&f.ignore.length&&e[o+1]&&f.ignore.some(E=>Ce(e,o,E.tails,{trimBeforeMatching:!0,cb:(O,he,de)=>{var pe;return de&&(o=de-1,(pe=e[o+1])!=null&&pe.trim()&&(T+=1)),!0}})))),e[o]&&"\r\n".includes(e[o])&&(T=0,h=0),s(f.tagRanges)&&f.tagRanges.length&&f.tagRanges.some(E=>o>=E[0]&&o<=E[1]&&E[1]-1>o?(o=E[1]-1,!0):!1)}return Z(e,r.current()).split("").forEach((o,C)=>{}),{res:Z(e,r.current(),f.reportProgressFunc?o=>{m=Math.floor((f.reportProgressFuncTo-f.reportProgressFuncFrom)*(1-i)+o/100*(f.reportProgressFuncTo-f.reportProgressFuncFrom)*i),m!==v&&(v=m,f.reportProgressFunc(m))}:void 0),ranges:r.current(),log:{timeTakenInMilliseconds:Date.now()-n},whatWasDone:D}}return Ue(ut);})();
11
11
  /**
12
- * @name arrayiffy-if-string
13
- * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
14
- * @version 5.1.3
12
+ * @name codsen-utils
13
+ * @fileoverview Various utility functions
14
+ * @version 1.8.0
15
15
  * @author Roy Revelt
16
16
  * @license MIT
17
- * {@link https://codsen.com/os/arrayiffy-if-string/}
17
+ * {@link https://codsen.com/os/codsen-utils/}
18
18
  */
19
19
  /**
20
- * @name codsen-utils
21
- * @fileoverview Various utility functions
22
- * @version 1.7.3
20
+ * @name ranges-sort
21
+ * @fileoverview Sort string index ranges
22
+ * @version 6.2.0
23
23
  * @author Roy Revelt
24
24
  * @license MIT
25
- * {@link https://codsen.com/os/codsen-utils/}
25
+ * {@link https://codsen.com/os/ranges-sort/}
26
26
  */
27
27
  /**
28
- * @name string-match-left-right
29
- * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
30
- * @version 9.1.3
28
+ * @name ranges-merge
29
+ * @fileoverview Merge and sort string index ranges
30
+ * @version 9.2.1
31
31
  * @author Roy Revelt
32
32
  * @license MIT
33
- * {@link https://codsen.com/os/string-match-left-right/}
33
+ * {@link https://codsen.com/os/ranges-merge/}
34
34
  */
35
35
  /**
36
- * @name string-left-right
37
- * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
38
- * @version 6.1.3
36
+ * @name ranges-apply
37
+ * @fileoverview Take an array of string index ranges, delete/replace the string according to them
38
+ * @version 7.2.1
39
39
  * @author Roy Revelt
40
40
  * @license MIT
41
- * {@link https://codsen.com/os/string-left-right/}
41
+ * {@link https://codsen.com/os/ranges-apply/}
42
42
  */
43
43
  /**
44
44
  * @name string-collapse-leading-whitespace
45
45
  * @fileoverview Collapse the leading and trailing whitespace of a string
46
- * @version 7.1.3
46
+ * @version 7.2.0
47
47
  * @author Roy Revelt
48
48
  * @license MIT
49
49
  * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
50
50
  */
51
51
  /**
52
- * @name ranges-sort
53
- * @fileoverview Sort string index ranges
54
- * @version 6.1.3
52
+ * @name ranges-push
53
+ * @fileoverview Gather string index ranges
54
+ * @version 7.2.0
55
55
  * @author Roy Revelt
56
56
  * @license MIT
57
- * {@link https://codsen.com/os/ranges-sort/}
57
+ * {@link https://codsen.com/os/ranges-push/}
58
58
  */
59
59
  /**
60
- * @name ranges-push
61
- * @fileoverview Gather string index ranges
62
- * @version 7.1.3
60
+ * @name string-left-right
61
+ * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
62
+ * @version 6.2.0
63
63
  * @author Roy Revelt
64
64
  * @license MIT
65
- * {@link https://codsen.com/os/ranges-push/}
65
+ * {@link https://codsen.com/os/string-left-right/}
66
66
  */
67
67
  /**
68
- * @name ranges-merge
69
- * @fileoverview Merge and sort string index ranges
70
- * @version 9.1.3
68
+ * @name arrayiffy-if-string
69
+ * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
70
+ * @version 5.2.1
71
71
  * @author Roy Revelt
72
72
  * @license MIT
73
- * {@link https://codsen.com/os/ranges-merge/}
73
+ * {@link https://codsen.com/os/arrayiffy-if-string/}
74
74
  */
75
75
  /**
76
- * @name ranges-apply
77
- * @fileoverview Take an array of string index ranges, delete/replace the string according to them
78
- * @version 7.1.3
76
+ * @name string-match-left-right
77
+ * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
78
+ * @version 9.2.1
79
79
  * @author Roy Revelt
80
80
  * @license MIT
81
- * {@link https://codsen.com/os/ranges-apply/}
81
+ * {@link https://codsen.com/os/string-match-left-right/}
82
82
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-remove-widows",
3
- "version": "4.1.3",
3
+ "version": "4.2.1",
4
4
  "description": "Helps to prevent widow words in a text",
5
5
  "keywords": [
6
6
  "against",
@@ -39,50 +39,49 @@
39
39
  },
40
40
  "types": "types/index.d.ts",
41
41
  "scripts": {
42
- "build": "node '../../ops/scripts/esbuild.js' && npm run dts",
43
- "cjs-off": "exit 0",
44
- "cjs-on": "exit 0",
45
- "dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
42
+ "build": "node ../../ops/scripts/esbuild.js && npm run dts",
43
+ "coverage": "c8 uvu test",
44
+ "dev": "node ../../ops/scripts/esbuild.js --dev && npm run dts",
46
45
  "devtest": "c8 npm run unit && npm run examples && npm run lint",
47
- "dts": "rollup -c && npm run prettier -- 'types/index.d.ts' --write --log-level 'silent'",
46
+ "dts": "rollup -c && biome format --write --config-path=../../biome.json --vcs-enabled=false --use-editorconfig=false types/index.d.ts",
48
47
  "examples": "node '../../ops/scripts/run-examples.js'",
49
- "lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
50
- "letspublish": "npm publish --provenance || :",
51
- "lint": "eslint . --fix --concurrency=auto --cache",
48
+ "lect": "node '../../ops/lect/lect.js'",
49
+ "lect:check": "node '../../ops/lect/lect.js' --check",
50
+ "lint": "biome lint --error-on-warnings . && npm run typecheck",
51
+ "lint:fix": "biome lint --write --error-on-warnings . && npm run typecheck",
52
52
  "perf": "node perf/check.js",
53
53
  "prep": "echo 'ready'",
54
- "prettier": "prettier",
55
- "prettier:format": "npm run prettier -- --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern --log-level 'silent'",
56
- "pretest": "npm run lect && npm run build",
54
+ "prettier": "biome format",
55
+ "prettier:format": "biome format --write .",
56
+ "pretest": "npm run lect:check && npm run build",
57
57
  "test": "npm run devtest",
58
+ "typecheck": "tsc --noEmit --pretty false --project tsconfig.json",
58
59
  "unit": "uvu test"
59
60
  },
60
- "engines": {
61
- "node": ">=14.18.0"
62
- },
63
61
  "c8": {
62
+ "all": true,
64
63
  "check-coverage": true,
65
- "exclude": [
66
- "**/test/**/*.*"
67
- ],
64
+ "exclude": ["**/test/**/*.*"],
65
+ "include": ["dist/*.esm.js"],
68
66
  "lines": 100
69
67
  },
70
68
  "lect": {
71
69
  "licence": {
72
- "extras": [
73
- ""
74
- ]
70
+ "extras": [""]
75
71
  }
76
72
  },
77
73
  "dependencies": {
78
- "codsen-utils": "^1.7.3",
79
- "ranges-apply": "^7.1.3",
80
- "ranges-push": "^7.1.3",
81
- "string-left-right": "^6.1.3",
82
- "string-match-left-right": "^9.1.3"
74
+ "codsen-utils": "^1.8.0",
75
+ "ranges-apply": "^7.2.1",
76
+ "ranges-push": "^7.2.0",
77
+ "string-left-right": "^6.2.0",
78
+ "string-match-left-right": "^9.2.1"
83
79
  },
84
80
  "devDependencies": {
85
- "string-strip-html": "^13.5.3"
81
+ "string-strip-html": "^13.6.1"
82
+ },
83
+ "engines": {
84
+ "node": ">=18.20.8"
86
85
  },
87
86
  "publishConfig": {
88
87
  "registry": "https://registry.npmjs.org/"
package/types/index.d.ts CHANGED
@@ -29,6 +29,7 @@ declare const defaults: Opts;
29
29
  interface Res {
30
30
  res: string;
31
31
  ranges: Ranges;
32
+ /** Best-effort elapsed time for user-facing completion feedback. */
32
33
  log: {
33
34
  timeTakenInMilliseconds: number;
34
35
  };