string-remove-widows 4.0.35 → 4.0.36
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-remove-widows
|
|
3
3
|
* @fileoverview Helps to prevent widow words in a text
|
|
4
|
-
* @version 4.0.
|
|
4
|
+
* @version 4.0.36
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
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.0.
|
|
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.0.36";var f=" ",E="\\00A0",S="\\u00A0",j="–",M="\\2013",J="\\u2013",U="—",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
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,u,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,u=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,l)=>{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[l].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(" ",e)||t.startsWith(" ",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]&&t[e+1].toLowerCase()==="u"&&t[e+2]==="0"&&t[e+3]==="0"&&t[e+4]&&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]===`
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-remove-widows
|
|
3
3
|
* @fileoverview Helps to prevent widow words in a text
|
|
4
|
-
* @version 4.0.
|
|
4
|
+
* @version 4.0.36
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-remove-widows/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var stringRemoveWidows=(()=>{var Pe=Object.create;var F=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames,de=Object.getOwnPropertySymbols,ke=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty,Ue=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={}))me.call(t,i)&&q(e,i,t[i]);if(de)for(var i of de(t))Ue.call(t,i)&&q(e,i,t[i]);return e};var qe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Qe=(e,t)=>{for(var i in t)F(e,i,{get:t[i],enumerable:!0})},he=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let g of Je(t))!me.call(e,g)&&g!==i&&F(e,g,{get:()=>t[g],enumerable:!(n=Be(t,g))||n.enumerable});return e};var pe=(e,t,i)=>(i=e!=null?Pe(ke(e)):{},he(t||!e||!e.__esModule?F(i,"default",{value:e,enumerable:!0}):i,e)),Ge=e=>he(F({},"__esModule",{value:!0}),e);var Q=(e,t,i)=>q(e,typeof t!="symbol"?t+"":t,i);var G=qe((ft,be)=>{"use strict";be.exports=Ke;function x(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function Ke(e){if(e=e||{},e.circles)return Ze(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 Ze(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 ut={};Qe(ut,{defaults:()=>_e,removeWidows:()=>lt,version:()=>at});function $e(e){return typeof e!="string"?e:e.length?[e]:[]}var ye=pe(G(),1);var dt=(0,ye.default)();var we="\u2013",Ee="\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 C(e){return Number.isSafeInteger(e)&&e>=0}function R(e){return e!=null}function Ae(e,t){return H(e)&&D(t)&&t in e}var Te={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},ze=e=>e+1;function Ye(e,t,i,n,g=!1,r=ze){var w;let c=typeof i=="function"?i():i;if(+t<0&&g&&c==="EOL")return c;let u=T(T({},Te),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 Xe(e,t,i,n,g){var a,d,p;if(H(g)&&Ae(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({},Te),g);if(typeof r.trimCharsBeforeMatching=="string"&&(r.trimCharsBeforeMatching=$e(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 $=Ye(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 ve(e,t,i,n){return Xe("matchRightIncl",e,t,i,n)}var Se=pe(G(),1);var wt=(0,Se.default)();var L="\xA0";function et({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 et({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function tt({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 tt({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 rt={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function V(e,t){if(!Array.isArray(e)||!e.length)return e;let i=T(T({},rt),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 Ne={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function nt(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({},Ne),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({},Ne);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 st={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},De=class{constructor(e){Q(this,"ranges");Q(this,"opts");let t=T(T({},st),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(R(e)&&!R(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&&C(+e[0])&&C(+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(!R(e)&&R(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(C(i)&&(i=String(i)),C(n)&&C(g)){if(R(i)&&!D(i)&&!C(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(R(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=g,this.last()[2],this.last()[2]!==null&&R(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 C(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=nt(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>R(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])&&C(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 Oe={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function We(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({},Oe),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({},Oe);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 ot=!0,K="Invariant failed";function Ce(e,t){if(!e){if(ot)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=We(r,{progressFn:a=>{i&&(n=10+Math.floor(a/10),n!==g&&(g=n,i(n)))}});Ce(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 Re="4.0.35";var P=" ",B="\\00A0",J="\\u00A0",Me="–",xe="\\2013",Ie="\\u2013",Le="—",je="\\2014",Ve="\\u2014",z=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],Fe=[{heads:"{{",tails:"}}"}],Y=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],He=["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 ee,te,re,ne,se,oe,ie,ae,le,ue;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 De({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({},_e),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(Fe):["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(ce=>e.startsWith(ce,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(Ee).concat(we).includes(e[s])||e.startsWith(Me,s)||e.startsWith(xe,s)||e.startsWith(Ie,s)||e.startsWith(Le,s)||e.startsWith(je,s)||e.startsWith(Ve,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(" ",s)||e.startsWith(" ",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]==="\\"&&e[s+1]&&e[s+1].toLowerCase()==="u"&&e[s+2]==="0"&&e[s+3]==="0"&&e[s+4]&&e[s+4].toUpperCase()==="A"&&e[s+5]==="0"&&(A=s,w=s+6,(se=e[s+6])!=null&&se.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)),!$&&((oe=e[s])!=null&&oe.trim())&&!((ie=e[s-1])!=null&&ie.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()&&((ae=e[s-1])!=null&&ae.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()&&((le=e[s-1])!=null&&le.trim())&&(v===void 0||(ue=e[v-1])!=null&&ue.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("<")&&He.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=>ve(e,s,b.tails,{trimBeforeMatching:!0,cb:(W,ce,ge)=>{var fe;return ge&&(s=ge-1,(fe=e[s+1])!=null&&fe.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 Ge(ut);})();
|
|
10
|
+
"use strict";var stringRemoveWidows=(()=>{var Pe=Object.create;var F=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames,de=Object.getOwnPropertySymbols,ke=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty,Ue=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={}))me.call(t,i)&&q(e,i,t[i]);if(de)for(var i of de(t))Ue.call(t,i)&&q(e,i,t[i]);return e};var qe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Qe=(e,t)=>{for(var i in t)F(e,i,{get:t[i],enumerable:!0})},he=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let g of Je(t))!me.call(e,g)&&g!==i&&F(e,g,{get:()=>t[g],enumerable:!(n=Be(t,g))||n.enumerable});return e};var pe=(e,t,i)=>(i=e!=null?Pe(ke(e)):{},he(t||!e||!e.__esModule?F(i,"default",{value:e,enumerable:!0}):i,e)),Ge=e=>he(F({},"__esModule",{value:!0}),e);var Q=(e,t,i)=>q(e,typeof t!="symbol"?t+"":t,i);var G=qe((ft,be)=>{"use strict";be.exports=Ke;function x(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function Ke(e){if(e=e||{},e.circles)return Ze(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 Ze(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 ut={};Qe(ut,{defaults:()=>_e,removeWidows:()=>lt,version:()=>at});function $e(e){return typeof e!="string"?e:e.length?[e]:[]}var ye=pe(G(),1);var dt=(0,ye.default)();var we="\u2013",Ee="\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 C(e){return Number.isSafeInteger(e)&&e>=0}function R(e){return e!=null}function Ae(e,t){return H(e)&&D(t)&&t in e}var Te={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},ze=e=>e+1;function Ye(e,t,i,n,g=!1,r=ze){var w;let c=typeof i=="function"?i():i;if(+t<0&&g&&c==="EOL")return c;let u=T(T({},Te),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 Xe(e,t,i,n,g){var a,d,p;if(H(g)&&Ae(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({},Te),g);if(typeof r.trimCharsBeforeMatching=="string"&&(r.trimCharsBeforeMatching=$e(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 $=Ye(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 ve(e,t,i,n){return Xe("matchRightIncl",e,t,i,n)}var Se=pe(G(),1);var wt=(0,Se.default)();var L="\xA0";function et({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 et({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function tt({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 tt({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 rt={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function V(e,t){if(!Array.isArray(e)||!e.length)return e;let i=T(T({},rt),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 Ne={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function nt(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({},Ne),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({},Ne);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 st={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},De=class{constructor(e){Q(this,"ranges");Q(this,"opts");let t=T(T({},st),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(R(e)&&!R(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&&C(+e[0])&&C(+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(!R(e)&&R(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(C(i)&&(i=String(i)),C(n)&&C(g)){if(R(i)&&!D(i)&&!C(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(R(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=g,this.last()[2],this.last()[2]!==null&&R(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 C(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=nt(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>R(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])&&C(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 Oe={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function We(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({},Oe),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({},Oe);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 ot=!0,K="Invariant failed";function Ce(e,t){if(!e){if(ot)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=We(r,{progressFn:a=>{i&&(n=10+Math.floor(a/10),n!==g&&(g=n,i(n)))}});Ce(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 Re="4.0.36";var P=" ",B="\\00A0",J="\\u00A0",Me="–",xe="\\2013",Ie="\\u2013",Le="—",je="\\2014",Ve="\\u2014",z=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],Fe=[{heads:"{{",tails:"}}"}],Y=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],He=["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 ee,te,re,ne,se,oe,ie,ae,le,ue;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 De({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({},_e),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(Fe):["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(ce=>e.startsWith(ce,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(Ee).concat(we).includes(e[s])||e.startsWith(Me,s)||e.startsWith(xe,s)||e.startsWith(Ie,s)||e.startsWith(Le,s)||e.startsWith(je,s)||e.startsWith(Ve,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(" ",s)||e.startsWith(" ",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]==="\\"&&e[s+1]&&e[s+1].toLowerCase()==="u"&&e[s+2]==="0"&&e[s+3]==="0"&&e[s+4]&&e[s+4].toUpperCase()==="A"&&e[s+5]==="0"&&(A=s,w=s+6,(se=e[s+6])!=null&&se.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)),!$&&((oe=e[s])!=null&&oe.trim())&&!((ie=e[s-1])!=null&&ie.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()&&((ae=e[s-1])!=null&&ae.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()&&((le=e[s-1])!=null&&le.trim())&&(v===void 0||(ue=e[v-1])!=null&&ue.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("<")&&He.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=>ve(e,s,b.tails,{trimBeforeMatching:!0,cb:(W,ce,ge)=>{var fe;return ge&&(s=ge-1,(fe=e[s+1])!=null&&fe.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 Ge(ut);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name arrayiffy-if-string
|
|
13
13
|
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
14
|
-
* @version 5.0.
|
|
14
|
+
* @version 5.0.20
|
|
15
15
|
* @author Roy Revelt, Codsen Ltd
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* @name codsen-utils
|
|
21
21
|
* @fileoverview Various utility functions
|
|
22
|
-
* @version 1.6.
|
|
22
|
+
* @version 1.6.18
|
|
23
23
|
* @author Roy Revelt, Codsen Ltd
|
|
24
24
|
* @license MIT
|
|
25
25
|
* {@link https://codsen.com/os/codsen-utils/}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
/**
|
|
28
28
|
* @name string-match-left-right
|
|
29
29
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
30
|
-
* @version 9.0.
|
|
30
|
+
* @version 9.0.33
|
|
31
31
|
* @author Roy Revelt, Codsen Ltd
|
|
32
32
|
* @license MIT
|
|
33
33
|
* {@link https://codsen.com/os/string-match-left-right/}
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
/**
|
|
36
36
|
* @name string-left-right
|
|
37
37
|
* @fileoverview Looks up the first non-whitespace character to the left/right of a given index
|
|
38
|
-
* @version 6.0.
|
|
38
|
+
* @version 6.0.31
|
|
39
39
|
* @author Roy Revelt, Codsen Ltd
|
|
40
40
|
* @license MIT
|
|
41
41
|
* {@link https://codsen.com/os/string-left-right/}
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
/**
|
|
44
44
|
* @name string-collapse-leading-whitespace
|
|
45
45
|
* @fileoverview Collapse the leading and trailing whitespace of a string
|
|
46
|
-
* @version 7.0.
|
|
46
|
+
* @version 7.0.19
|
|
47
47
|
* @author Roy Revelt, Codsen Ltd
|
|
48
48
|
* @license MIT
|
|
49
49
|
* {@link https://codsen.com/os/string-collapse-leading-whitespace/}
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
/**
|
|
52
52
|
* @name ranges-sort
|
|
53
53
|
* @fileoverview Sort string index ranges
|
|
54
|
-
* @version 6.0.
|
|
54
|
+
* @version 6.0.24
|
|
55
55
|
* @author Roy Revelt, Codsen Ltd
|
|
56
56
|
* @license MIT
|
|
57
57
|
* {@link https://codsen.com/os/ranges-sort/}
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
/**
|
|
60
60
|
* @name ranges-push
|
|
61
61
|
* @fileoverview Gather string index ranges
|
|
62
|
-
* @version 7.0.
|
|
62
|
+
* @version 7.0.29
|
|
63
63
|
* @author Roy Revelt, Codsen Ltd
|
|
64
64
|
* @license MIT
|
|
65
65
|
* {@link https://codsen.com/os/ranges-push/}
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
/**
|
|
68
68
|
* @name ranges-merge
|
|
69
69
|
* @fileoverview Merge and sort string index ranges
|
|
70
|
-
* @version 9.0.
|
|
70
|
+
* @version 9.0.29
|
|
71
71
|
* @author Roy Revelt, Codsen Ltd
|
|
72
72
|
* @license MIT
|
|
73
73
|
* {@link https://codsen.com/os/ranges-merge/}
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
/**
|
|
76
76
|
* @name ranges-apply
|
|
77
77
|
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
|
|
78
|
-
* @version 7.0.
|
|
78
|
+
* @version 7.0.30
|
|
79
79
|
* @author Roy Revelt, Codsen Ltd
|
|
80
80
|
* @license MIT
|
|
81
81
|
* {@link https://codsen.com/os/ranges-apply/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-remove-widows",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.36",
|
|
4
4
|
"description": "Helps to prevent widow words in a text",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"against",
|
|
@@ -75,14 +75,14 @@
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"codsen-utils": "^1.6.
|
|
79
|
-
"ranges-apply": "^7.0.
|
|
80
|
-
"ranges-push": "^7.0.
|
|
81
|
-
"string-left-right": "^6.0.
|
|
82
|
-
"string-match-left-right": "^9.0.
|
|
78
|
+
"codsen-utils": "^1.6.18",
|
|
79
|
+
"ranges-apply": "^7.0.30",
|
|
80
|
+
"ranges-push": "^7.0.29",
|
|
81
|
+
"string-left-right": "^6.0.31",
|
|
82
|
+
"string-match-left-right": "^9.0.33"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"string-strip-html": "^13.4.
|
|
85
|
+
"string-strip-html": "^13.4.23"
|
|
86
86
|
},
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"registry": "https://registry.npmjs.org/"
|