/
compromise-one.mjs
1 lines (1 loc) · 81.7 KB
/
compromise-one.mjs
1
var t={methods:{one:{},two:{},three:{},four:{}},model:{one:{},two:{},three:{}},compute:{},hooks:[]};const e={compute:function(t){const{world:e}=this,n=e.compute;return"string"==typeof t&&n.hasOwnProperty(t)?n[t](this):(t=>"[object Array]"===Object.prototype.toString.call(t))(t)?t.forEach((r=>{e.compute.hasOwnProperty(r)?n[r](this):console.warn("no compute:",t)})):"function"==typeof t?t(this):console.warn("no compute:",t),this}};var n=e;var r={forEach:function(t){return this.fullPointer.forEach(((e,n)=>{let r=this.update([e]);t(r,n)})),this},map:function(t,e){let n=this.fullPointer.map(((e,n)=>{let r=this.update([e]),o=t(r,n);return void 0===o?this.none():o}));if(0===n.length)return e||this.update([]);if(void 0!==n[0]){if("string"==typeof n[0])return n;if("object"==typeof n[0]&&(null===n[0]||!n[0].isView))return n}let r=[];return n.forEach((t=>{r=r.concat(t.fullPointer)})),this.toView(r)},filter:function(t){let e=this.fullPointer;return e=e.filter(((e,n)=>{let r=this.update([e]);return t(r,n)})),this.update(e)},find:function(t){let e=this.fullPointer.find(((e,n)=>{let r=this.update([e]);return t(r,n)}));return this.update([e])},some:function(t){return this.fullPointer.some(((e,n)=>{let r=this.update([e]);return t(r,n)}))},random:function(t=1){let e=this.fullPointer,n=Math.floor(Math.random()*e.length);return n+t>this.length&&(n=this.length-t,n=n<0?0:n),e=e.slice(n,n+t),this.update(e)}};const o={termList:function(){return this.methods.one.termList(this.docs)},terms:function(t){let e=this.match(".");return"number"==typeof t?e.eq(t):e},groups:function(t){if(t||0===t)return this.update(this._groups[t]||[]);let e={};return Object.keys(this._groups).forEach((t=>{e[t]=this.update(this._groups[t])})),e},eq:function(t){let e=this.pointer;return e||(e=this.docs.map(((t,e)=>[e]))),e[t]?this.update([e[t]]):this.none()},first:function(){return this.eq(0)},last:function(){let t=this.fullPointer.length-1;return this.eq(t)},firstTerms:function(){return this.match("^.")},lastTerms:function(){return this.match(".$")},slice:function(t,e){let n=this.pointer||this.docs.map(((t,e)=>[e]));return n=n.slice(t,e),this.update(n)},all:function(){return this.update().toView()},fullSentences:function(){let t=this.fullPointer.map((t=>[t[0]]));return this.update(t).toView()},none:function(){return this.update([])},isDoc:function(t){if(!t||!t.isView)return!1;let e=this.fullPointer,n=t.fullPointer;return!e.length!==n.length&&e.every(((t,e)=>!!n[e]&&(t[0]===n[e][0]&&t[1]===n[e][1]&&t[2]===n[e][2])))},wordCount:function(){return this.docs.reduce(((t,e)=>(t+=e.filter((t=>""!==t.text)).length,t)),0)},isFull:function(){let t=this.pointer;if(!t)return!0;let e=this.document;for(let n=0;n<t.length;n+=1){let[r,o,i]=t[n];if(r!==n||0!==o)return!1;if(e[r].length>i)return!1}return!0},getNth:function(t){return"number"==typeof t?this.eq(t):"string"==typeof t?this.if(t):this}};o.group=o.groups,o.fullSentence=o.fullSentences,o.sentence=o.fullSentences,o.lastTerm=o.lastTerms,o.firstTerm=o.firstTerms;var i=o;const s=Object.assign({},i,n,r);s.get=s.eq;var l=s;class View{constructor(e,n,r={}){[["document",e],["world",t],["_groups",r],["_cache",null],["viewType","View"]].forEach((t=>{Object.defineProperty(this,t[0],{value:t[1],writable:!0})})),this.ptrs=n}get docs(){let e=this.document;return this.ptrs&&(e=t.methods.one.getDoc(this.ptrs,this.document)),e}get pointer(){return this.ptrs}get methods(){return this.world.methods}get model(){return this.world.model}get hooks(){return this.world.hooks}get isView(){return!0}get found(){return this.docs.length>0}get length(){return this.docs.length}get fullPointer(){let{docs:t,ptrs:e,document:n}=this,r=e||t.map(((t,e)=>[e]));return r.map((t=>{let[e,r,o,i,s]=t;return r=r||0,o=o||(n[e]||[]).length,n[e]&&n[e][r]&&(i=i||n[e][r].id,n[e][o-1]&&(s=s||n[e][o-1].id)),[e,r,o,i,s]}))}update(t){let e=new View(this.document,t);if(this._cache&&t&&t.length>0){let n=[];t.forEach(((t,e)=>{let[r,o,i]=t;(1===t.length||0===o&&this.document[r].length===i)&&(n[e]=this._cache[r])})),n.length>0&&(e._cache=n)}return e.world=this.world,e}toView(t){return new View(this.document,t||this.pointer)}fromText(t){const{methods:e}=this;let n=e.one.tokenize.fromString(t,this.world),r=new View(n);return r.world=this.world,r.compute(["normal","lexicon"]),this.world.compute.preTagger&&r.compute("preTagger"),r}clone(){let t=this.document.slice(0);t=t.map((t=>t.map((t=>((t=Object.assign({},t)).tags=new Set(t.tags),t)))));let e=this.update(this.pointer);return e.document=t,e._cache=this._cache,e}}Object.assign(View.prototype,l);var a=View;const c=function(t){return t&&"object"==typeof t&&!Array.isArray(t)};function u(t,e){if(c(e))for(const n in e)c(e[n])?(t[n]||Object.assign(t,{[n]:{}}),u(t[n],e[n])):Object.assign(t,{[n]:e[n]});return t}var h=function(t,e,n,r){const{methods:o,model:i,compute:s,hooks:l}=e;t.methods&&function(t,e){for(const n in e)t[n]=t[n]||{},Object.assign(t[n],e[n])}(o,t.methods),t.model&&u(i,t.model),t.irregulars&&function(t,e){let n=t.two.models||{};Object.keys(e).forEach((t=>{e[t].pastTense&&(n.toPast&&(n.toPast.exceptions[t]=e[t].pastTense),n.fromPast&&(n.fromPast.exceptions[e[t].pastTense]=t)),e[t].presentTense&&(n.toPresent&&(n.toPresent.exceptions[t]=e[t].presentTense),n.fromPresent&&(n.fromPresent.exceptions[e[t].presentTense]=t)),e[t].gerund&&(n.toGerund&&(n.toGerund.exceptions[t]=e[t].gerund),n.fromGerund&&(n.fromGerund.exceptions[e[t].gerund]=t)),e[t].comparative&&(n.toComparative&&(n.toComparative.exceptions[t]=e[t].comparative),n.fromComparative&&(n.fromComparative.exceptions[e[t].comparative]=t)),e[t].superlative&&(n.toSuperlative&&(n.toSuperlative.exceptions[t]=e[t].superlative),n.fromSuperlative&&(n.fromSuperlative.exceptions[e[t].superlative]=t))}))}(i,t.irregulars),t.compute&&Object.assign(s,t.compute),l&&(e.hooks=l.concat(t.hooks||[])),t.api&&t.api(n),t.lib&&Object.keys(t.lib).forEach((e=>r[e]=t.lib[e])),t.tags&&r.addTags(t.tags),t.words&&r.addWords(t.words),t.mutate&&t.mutate(e)};const f=function(t){return"[object Array]"===Object.prototype.toString.call(t)};var p=function(t,e,n){const{methods:r}=n;let o=new e([]);if(o.world=n,"number"==typeof t&&(t=String(t)),!t)return o;if("string"==typeof t){return new e(r.one.tokenize.fromString(t,n))}if(i=t,"[object Object]"===Object.prototype.toString.call(i)&&t.isView)return new e(t.document,t.ptrs);var i;if(f(t)){if(f(t[0])){let n=t.map((t=>t.map((t=>({text:t,normal:t,pre:"",post:" ",tags:new Set})))));return new e(n)}let n=function(t){return t.map((t=>t.terms.map((t=>(f(t.tags)&&(t.tags=new Set(t.tags)),t)))))}(t);return new e(n)}return o};let d=Object.assign({},t);const m=function(t,e){e&&m.addWords(e);let n=p(t,a,d);return t&&n.compute(d.hooks),n};Object.defineProperty(m,"_world",{value:d,writable:!0}),m.tokenize=function(t,e){const{compute:n}=this._world;e&&m.addWords(e);let r=p(t,a,d);return n.contractions&&r.compute(["alias","normal","machine","contractions"]),r},m.plugin=function(t){return h(t,this._world,a,this),this},m.extend=m.plugin,m.world=function(){return this._world},m.model=function(){return this._world.model},m.methods=function(){return this._world.methods},m.hooks=function(){return this._world.hooks},m.verbose=function(t){const e="undefined"!=typeof process&&process.env?process.env:self.env||{};return e.DEBUG_TAGS="tagger"===t||!0===t||"",e.DEBUG_MATCH="match"===t||!0===t||"",e.DEBUG_CHUNKS="chunker"===t||!0===t||"",this},m.version="14.8.0";var w=m;var v=function(t){let e=t.map((t=>{let e=new Set;return t.forEach((t=>{""!==t.normal&&e.add(t.normal),t.switch&&e.add(`%${t.switch}%`),t.implicit&&e.add(t.implicit),t.machine&&e.add(t.machine),t.root&&e.add(t.root),t.alias&&t.alias.forEach((t=>e.add(t)));let n=Array.from(t.tags);for(let t=0;t<n.length;t+=1)e.add("#"+n[t])})),e}));return e};const y={cache:function(){return this._cache=this.methods.one.cacheDoc(this.document),this},uncache:function(){return this._cache=null,this}};var b=function(t){Object.assign(t.prototype,y)},x={api:b,compute:{cache:function(t){t._cache=t.methods.one.cacheDoc(t.document)}},methods:{one:{cacheDoc:v}}};const j=t=>/^\p{Lu}[\p{Ll}'’]/u.test(t)||/^\p{Lu}$/u.test(t),O=(t,e,n)=>{if(n.forEach((t=>t.dirty=!0)),t){let r=[e,0].concat(n);Array.prototype.splice.apply(t,r)}return t},E=function(t){let e=t[t.length-1];!e||/ $/.test(e.post)||/[-–—]/.test(e.post)||(e.post+=" ")},k=(t,e,n)=>{const r=/[-.?!,;:)–—'"]/g;let o=t[e-1];if(!o)return;let i=o.post;if(r.test(i)){let t=i.match(r).join(""),e=n[n.length-1];e.post=t+e.post,o.post=o.post.replace(r,"")}},P=function(t,e,n,r){let[o,i,s]=e;0===i||s===r[o].length?E(n):(E(n),E([t[e[1]]])),function(t,e,n){let r=t[e];if(0!==e||!j(r.text))return;n[0].text=n[0].text.replace(/^\p{Ll}/u,(t=>t.toUpperCase()));let o=t[e];o.tags.has("ProperNoun")||o.tags.has("Acronym")||j(o.text)&&o.text.length>1&&(o.text=(i=o.text,i.replace(/^\p{Lu}/u,(t=>t.toLowerCase()))));var i}(t,i,n),O(t,i,n)};let _=0;const S=t=>(t=t.length<3?"0"+t:t).length<3?"0"+t:t;var A=function(t){let[e,n]=t.index||[0,0];_+=1,_=_>46655?0:_,e=e>46655?0:e,n=n>1294?0:n;let r=S(_.toString(36));r+=S(e.toString(36));let o=n.toString(36);return o=o.length<2?"0"+o:o,r+=o,r+=parseInt(36*Math.random(),10).toString(36),t.normal+"|"+r.toUpperCase()};const T=function(t){if(t.has("@hasContraction")&&"function"==typeof t.contractions){t.grow("@hasContraction").contractions().expand()}},$=t=>"[object Array]"===Object.prototype.toString.call(t),C=function(t,e,n){const{document:r,world:o}=e;e.uncache();let i=e.fullPointer,s=e.fullPointer;e.forEach(((l,a)=>{let c=l.fullPointer[0],[u]=c,h=r[u],f=function(t,e){const{methods:n}=e;return"string"==typeof t?n.one.tokenize.fromString(t,e)[0]:"object"==typeof t&&t.isView?t.clone().docs[0]||[]:$(t)?$(t[0])?t[0]:t:[]}(t,o);0!==f.length&&(f=function(t){return t.map((t=>(t.id=A(t),t)))}(f),n?(T(e.update([c]).firstTerm()),P(h,c,f,r)):(T(e.update([c]).lastTerm()),function(t,e,n,r){let[o,,i]=e,s=(r[o]||[]).length;i<s?(k(t,i,n),E(n)):s===i&&(E(t),k(t,i,n),r[o+1]&&(n[n.length-1].post+=" ")),O(t,e[2],n),e[4]=n[n.length-1].id}(h,c,f,r)),r[u]&&r[u][c[1]]&&(c[3]=r[u][c[1]].id),s[a]=c,c[2]+=f.length,i[a]=c)}));let l=e.toView(i);return e.ptrs=s,l.compute(["id","index","lexicon"]),l.world.compute.preTagger&&l.compute("preTagger"),l},z={insertAfter:function(t){return C(t,this,!1)},insertBefore:function(t){return C(t,this,!0)}};z.append=z.insertAfter,z.prepend=z.insertBefore,z.insert=z.insertAfter;var N=z;const L=/\$[0-9a-z]+/g,q={};q.replaceWith=function(t,e={}){let n=this.fullPointer,r=this;if(this.uncache(),"function"==typeof t)return function(t,e){return t.forEach((t=>{let n=e(t);t.replaceWith(n)})),t}(r,t);t=function(t,e){if("string"!=typeof t)return t;let n=e.groups();return t=t.replace(L,(t=>{let e=t.replace(/\$/,"");return n.hasOwnProperty(e)?n[e].text():t})),t}(t,r);let o=this.update(n);n=n.map((t=>t.slice(0,3)));let i=(o.docs[0]||[]).map((t=>Array.from(t.tags)));if("string"==typeof t&&(t=this.fromText(t).compute("id")),r.insertAfter(t),o.has("@hasContraction")&&r.contractions){r.grow("@hasContraction+").contractions().expand()}r.delete(o);let s=r.toView(n).compute(["index","lexicon"]);return s.world.compute.preTagger&&s.compute("preTagger"),e.tags&&s.terms().forEach(((t,e)=>{t.tagSafe(i[e])})),e.case&&s.docs[0]&&s.docs[0][0]&&0===s.docs[0][0].index[1]&&(s.docs[0][0].text=s.docs[0][0].text.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substring(1).toLowerCase()))),s},q.replace=function(t,e,n){if(t&&!e)return this.replaceWith(t,n);let r=this.match(t);return r.found?(this.soften(),r.replaceWith(e,n)):this};var V=q;var F=function(t,e){e.forEach((e=>{let[n,r,o]=e,i=o-r;t[n]&&(o===t[n].length&&o>1&&function(t,e){let n=t.length-1,r=t[n],o=t[n-e];o&&r&&(o.post+=r.post,o.post=o.post.replace(/ +([.?!,;:])/,"$1"),o.post=o.post.replace(/[,;:]+([.?!])/,"$1"))}(t[n],i),t[n].splice(r,i))}));for(let e=t.length-1;e>=0;e-=1)if(0===t[e].length&&(t.splice(e,1),e===t.length&&t[e-1])){let n=t[e-1],r=n[n.length-1];r&&(r.post=r.post.trimEnd())}return t};const G={remove:function(t){const{indexN:e}=this.methods.one.pointer;this.uncache();let n=this.all(),r=this;t&&(n=this,r=this.match(t));let o=!n.ptrs;if(r.has("@hasContraction")&&r.contractions){r.grow("@hasContraction").contractions().expand()}let i=n.fullPointer,s=r.fullPointer.reverse(),l=F(this.document,s);return i=function(t,e){return t=t.map((t=>{let[n]=t;return e[n]?(e[n].forEach((e=>{let n=e[2]-e[1];t[1]<=e[1]&&t[2]>=e[2]&&(t[2]-=n)})),t):t})),t.forEach(((e,n)=>{if(0===e[1]&&0==e[2])for(let e=n+1;e<t.length;e+=1)t[e][0]-=1,t[e][0]<0&&(t[e][0]=0)})),t=(t=t.filter((t=>t[2]-t[1]>0))).map((t=>(t[3]=null,t[4]=null,t)))}(i,e(s)),n.ptrs=i,n.document=l,n.compute("index"),o&&(n.ptrs=void 0),t?n.toView(i):(this.ptrs=[],n.none())}};G.delete=G.remove;var D=G;const B={pre:function(t,e){return void 0===t&&this.found?this.docs[0][0].pre:(this.docs.forEach((n=>{let r=n[0];!0===e?r.pre+=t:r.pre=t})),this)},post:function(t,e){if(void 0===t){let t=this.docs[this.docs.length-1];return t[t.length-1].post}return this.docs.forEach((n=>{let r=n[n.length-1];!0===e?r.post+=t:r.post=t})),this},trim:function(){if(!this.found)return this;let t=this.docs,e=t[0][0];e.pre=e.pre.trimStart();let n=t[t.length-1],r=n[n.length-1];return r.post=r.post.trimEnd(),this},hyphenate:function(){return this.docs.forEach((t=>{t.forEach(((e,n)=>{0!==n&&(e.pre=""),t[n+1]&&(e.post="-")}))})),this},dehyphenate:function(){const t=/[-–—]/;return this.docs.forEach((e=>{e.forEach((e=>{t.test(e.post)&&(e.post=" ")}))})),this},toQuotations:function(t,e){return t=t||'"',e=e||'"',this.docs.forEach((n=>{n[0].pre=t+n[0].pre;let r=n[n.length-1];r.post=e+r.post})),this},toParentheses:function(t,e){return t=t||"(",e=e||")",this.docs.forEach((n=>{n[0].pre=t+n[0].pre;let r=n[n.length-1];r.post=e+r.post})),this}};B.deHyphenate=B.dehyphenate,B.toQuotation=B.toQuotations;var U=B;var M={alpha:(t,e)=>t.normal<e.normal?-1:t.normal>e.normal?1:0,length:(t,e)=>{let n=t.normal.trim().length,r=e.normal.trim().length;return n<r?1:n>r?-1:0},wordCount:(t,e)=>t.words<e.words?1:t.words>e.words?-1:0,sequential:(t,e)=>t[0]<e[0]?1:t[0]>e[0]?-1:t[1]>e[1]?1:-1,byFreq:function(t){let e={};return t.forEach((t=>{e[t.normal]=e[t.normal]||0,e[t.normal]+=1})),t.sort(((t,n)=>{let r=e[t.normal],o=e[n.normal];return r<o?1:r>o?-1:0})),t}};const W=new Set(["index","sequence","seq","sequential","chron","chronological"]),I=new Set(["freq","frequency","topk","repeats"]),R=new Set(["alpha","alphabetical"]);var Q={unique:function(){let t=new Set;return this.filter((e=>{let n=e.text("machine");return!t.has(n)&&(t.add(n),!0)}))},reverse:function(){let t=this.pointer||this.docs.map(((t,e)=>[e]));return t=[].concat(t),t=t.reverse(),this._cache&&(this._cache=this._cache.reverse()),this.update(t)},sort:function(t){let{docs:e,pointer:n}=this;if(this.uncache(),"function"==typeof t)return function(t,e){let n=t.fullPointer;return n=n.sort(((n,r)=>(n=t.update([n]),r=t.update([r]),e(n,r)))),t.ptrs=n,t}(this,t);t=t||"alpha";let r=n||e.map(((t,e)=>[e])),o=e.map(((t,e)=>({index:e,words:t.length,normal:t.map((t=>t.machine||t.normal||"")).join(" "),pointer:r[e]})));return W.has(t)&&(t="sequential"),R.has(t)&&(t="alpha"),I.has(t)?(o=M.byFreq(o),this.update(o.map((t=>t.pointer)))):"function"==typeof M[t]?(o=o.sort(M[t]),this.update(o.map((t=>t.pointer)))):this}};const H=function(t,e){if(t.length>0){let e=t[t.length-1],n=e[e.length-1];!1===/ /.test(n.post)&&(n.post+=" ")}return t=t.concat(e)};var Z={concat:function(t){if("string"==typeof t){let e=this.fromText(t);if(this.found&&this.ptrs){let t=this.fullPointer,n=t[t.length-1][0];this.document.splice(n,0,...e.document)}else this.document=this.document.concat(e.document);return this.all().compute("index")}if("object"==typeof t&&t.isView)return function(t,e){if(t.document===e.document){let n=t.fullPointer.concat(e.fullPointer);return t.toView(n).compute("index")}return e.fullPointer.forEach((e=>{e[0]+=t.document.length})),t.document=H(t.document,e.docs),t.all()}(this,t);if(e=t,"[object Array]"===Object.prototype.toString.call(e)){let e=H(this.document,t);return this.document=e,this.all()}var e;return this}};var K={harden:function(){return this.ptrs=this.fullPointer,this},soften:function(){let t=this.ptrs;return!t||t.length<1||(t=t.map((t=>t.slice(0,3))),this.ptrs=t),this}};const J=Object.assign({},{toLowerCase:function(){return this.termList().forEach((t=>{t.text=t.text.toLowerCase()})),this},toUpperCase:function(){return this.termList().forEach((t=>{t.text=t.text.toUpperCase()})),this},toTitleCase:function(){return this.termList().forEach((t=>{t.text=t.text.replace(/^ *[a-z\u00C0-\u00FF]/,(t=>t.toUpperCase()))})),this},toCamelCase:function(){return this.docs.forEach((t=>{t.forEach(((e,n)=>{0!==n&&(e.text=e.text.replace(/^ *[a-z\u00C0-\u00FF]/,(t=>t.toUpperCase()))),n!==t.length-1&&(e.post="")}))})),this}},N,V,D,U,Q,Z,K);var X=function(t){Object.assign(t.prototype,J)};const Y={id:function(t){let e=t.docs;for(let t=0;t<e.length;t+=1)for(let n=0;n<e[t].length;n+=1){let r=e[t][n];r.id=r.id||A(r)}}};var tt={api:X,compute:Y},et={one:{contractions:[{word:"@",out:["at"]},{word:"alot",out:["a","lot"]},{word:"brb",out:["be","right","back"]},{word:"cannot",out:["can","not"]},{word:"cant",out:["can","not"]},{word:"dont",out:["do","not"]},{word:"dun",out:["do","not"]},{word:"wont",out:["will","not"]},{word:"can't",out:["can","not"]},{word:"shan't",out:["should","not"]},{word:"won't",out:["will","not"]},{word:"that's",out:["that","is"]},{word:"what's",out:["what","is"]},{word:"let's",out:["let","us"]},{word:"there's",out:["there","is"]},{word:"dunno",out:["do","not","know"]},{word:"gonna",out:["going","to"]},{word:"gotta",out:["have","got","to"]},{word:"gimme",out:["give","me"]},{word:"tryna",out:["trying","to"]},{word:"gtg",out:["got","to","go"]},{word:"im",out:["i","am"]},{word:"imma",out:["I","will"]},{word:"imo",out:["in","my","opinion"]},{word:"irl",out:["in","real","life"]},{word:"ive",out:["i","have"]},{word:"rn",out:["right","now"]},{word:"tbh",out:["to","be","honest"]},{word:"wanna",out:["want","to"]},{word:"c'mere",out:["come","here"]},{word:"c'mon",out:["come","on"]},{word:"howd",out:["how","did"]},{word:"whatd",out:["what","did"]},{word:"whend",out:["when","did"]},{word:"whered",out:["where","did"]},{word:"tis",out:["it","is"]},{word:"twas",out:["it","was"]},{word:"y'know",out:["you","know"]},{word:"ne'er",out:["never"]},{word:"o'er",out:["over"]},{after:"ll",out:["will"]},{after:"ve",out:["have"]},{after:"re",out:["are"]},{after:"m",out:["am"]},{before:"c",out:["ce"]},{before:"m",out:["me"]},{before:"n",out:["ne"]},{before:"qu",out:["que"]},{before:"s",out:["se"]},{before:"t",out:["tu"]}]}};var nt=function(t,e,n){let[r,o]=e;n&&0!==n.length&&(n=n.map(((t,e)=>(t.implicit=t.text,t.machine=t.text,t.pre="",t.post="",t.text="",t.normal="",t.index=[r,o+e],t))),n[0]&&(n[0].pre=t[r][o].pre,n[n.length-1].post=t[r][o].post,n[0].text=t[r][o].text,n[0].normal=t[r][o].normal),t[r].splice(o,1,...n))};const rt=/'/,ot=new Set(["what","how","when","where","why"]),it=new Set(["be","go","start","think","need"]),st=new Set(["been","gone"]);var lt=function(t,e){let n=t[e].normal.split(rt)[0];if(ot.has(n))return[n,"did"];if(t[e+1]){if(st.has(t[e+1].normal))return[n,"had"];if(it.has(t[e+1].normal))return[n,"would"]}return null};var at=function(t,e){if("ain't"===t[e].normal||"aint"===t[e].normal)return null;return[t[e].normal.replace(/n't/,""),"not"]};const ct=/'/;var ut=(t,e)=>["je",t[e].normal.split(ct)[1]],ht=(t,e)=>{let n=t[e].normal.split(ct)[1];return n&&n.endsWith("e")?["la",n]:["le",n]},ft=(t,e)=>{let n=t[e].normal.split(ct)[1];return n&&n.endsWith("e")?["du",n]:n&&n.endsWith("s")?["des",n]:["de",n]};const pt=/^([0-9.]{1,4}[a-z]{0,2}) ?[-–—] ?([0-9]{1,4}[a-z]{0,2})$/i,dt=/^([0-9]{1,2}(:[0-9][0-9])?(am|pm)?) ?[-–—] ?([0-9]{1,2}(:[0-9][0-9])?(am|pm)?)$/i,mt=/^[0-9]{3}-[0-9]{4}$/;var gt=function(t,e){let n=t[e],r=n.text.match(pt);return null!==r?!0===n.tags.has("PhoneNumber")||mt.test(n.text)?null:[r[1],"to",r[2]]:(r=n.text.match(dt),null!==r?[r[1],"to",r[4]]:null)};const wt=/^([+-]?[0-9][.,0-9]*)([a-z°²³µ/]+)$/,vt=new Set(["st","nd","rd","th","am","pm","max","°","s","e"]);var yt=function(t,e){let n=t[e].text.match(wt);if(null!==n){let t=n[2].toLowerCase().trim();return vt.has(t)?null:[n[1],t]}return null};const bt=/'/,xt=/^[0-9][^-–—]*[-–—].*?[0-9]/,jt=function(t,e,n,r){let o=e.update();o.document=[t];let i=n+r;n>0&&(n-=1),t[i]&&(i+=1),o.ptrs=[[0,n,i]]},Ot={t:(t,e)=>at(t,e),d:(t,e)=>lt(t,e)},Et={j:(t,e)=>ut(t,e),l:(t,e)=>ht(t,e),d:(t,e)=>ft(t,e)},kt=function(t,e,n,r){for(let o=0;o<t.length;o+=1){let i=t[o];if(i.word===e.normal)return i.out;if(null!==r&&r===i.after)return[n].concat(i.out);if(null!==n&&n===i.before)return i.out.concat(r)}return null},Pt=function(t,e){let n=e.fromText(t.join(" "));return n.compute(["id","alias"]),n.docs[0]};var _t=t=>{let{world:e,document:n}=t;const{model:r,methods:o}=e;let i=r.one.contractions||[];new Set(r.one.units||[]),n.forEach(((r,s)=>{for(let l=r.length-1;l>=0;l-=1){let a=null,c=null;!0===bt.test(r[l].normal)&&([a,c]=r[l].normal.split(bt));let u=kt(i,r[l],a,c);!u&&Ot.hasOwnProperty(c)&&(u=Ot[c](r,l,e)),!u&&Et.hasOwnProperty(a)&&(u=Et[a](r,l)),u?(u=Pt(u,t),nt(n,[s,l],u),jt(n[s],t,l,u.length)):xt.test(r[l].normal)?(u=gt(r,l),u&&(u=Pt(u,t),nt(n,[s,l],u),o.one.setTag(u,"NumberRange",e),u[2]&&u[2].tags.has("Time")&&o.one.setTag([u[0]],"Time",e,null,"time-range"),jt(n[s],t,l,u.length))):(u=yt(r,l),u&&(u=Pt(u,t),nt(n,[s,l],u),o.one.setTag([u[1]],"Unit",e,null,"contraction-unit")))}}))};var St={model:et,compute:{contractions:_t},hooks:["contractions"]};var At=function(t,e,n){const{model:r,methods:o}=n,i=o.one.setTag,s=r.one._multiCache||{},l=r.one.lexicon||{};let a=t[e],c=a.machine||a.normal;return void 0!==t[e+1]&&!0===s[c]?function(t,e,n,r,o){let i=e+4>t.length?t.length-e:4,s=t[e].machine||t[e].normal;for(let l=1;l<i;l+=1){let i=t[e+l];if(s+=" "+(i.machine||i.normal),!0===n.hasOwnProperty(s)){let i=n[s];return r(t.slice(e,e+l+1),i,o,!1,"1-multi-lexicon"),!0}}return!1}(t,e,l,i,n):null};const Tt=/^(under|over|mis|re|un|dis|semi|pre|post)-?/,$t=new Set(["Verb","Infinitive","PastTense","Gerund","PresentTense","Adjective","Participle"]);var Ct=function(t,e,n){const{model:r,methods:o}=n,i=o.one.setTag,s=r.one.lexicon;let l=t[e],a=l.machine||l.normal;if(void 0!==s[a]&&s.hasOwnProperty(a)){return i([l],s[a],n,!1,"1-lexicon"),!0}if(l.alias){let t=l.alias.find((t=>s.hasOwnProperty(t)));if(t){return i([l],s[t],n,!1,"1-lexicon-alias"),!0}}if(!0===Tt.test(a)){let t=a.replace(Tt,"");if(s.hasOwnProperty(t)&&t.length>3&&$t.has(s[t]))return i([l],s[t],n,!1,"1-lexicon-prefix"),!0}return null};var zt={lexicon:function(t){const e=t.world;t.docs.forEach((t=>{for(let n=0;n<t.length;n+=1)if(0===t[n].tags.size){let r=null;r=r||At(t,n,e),r=r||Ct(t,n,e)}}))}};var Nt=function(t){let e={},n={};return Object.keys(t).forEach((r=>{let o=t[r],i=(r=(r=r.toLowerCase().trim()).replace(/'s\b/,"")).split(/ /);i.length>1&&(n[i[0]]=!0),e[r]=e[r]||o})),delete e[""],delete e.null,delete e[" "],{lex:e,_multi:n}};var Lt={addWords:function(t){const e=this.world(),{methods:n,model:r}=e;if(t)if(Object.keys(t).forEach((e=>{"string"==typeof t[e]&&t[e].startsWith("#")&&(t[e]=t[e].replace(/^#/,""))})),n.two.expandLexicon){let{lex:o,_multi:i}=n.two.expandLexicon(t,e);Object.assign(r.one.lexicon,o),Object.assign(r.one._multiCache,i)}else if(n.one.expandLexicon){let{lex:o,_multi:i}=n.one.expandLexicon(t,e);Object.assign(r.one.lexicon,o),Object.assign(r.one._multiCache,i)}else Object.assign(r.one.lexicon,t)}};var qt={model:{one:{lexicon:{},_multiCache:{}}},methods:{one:{expandLexicon:Nt}},compute:zt,lib:Lt,hooks:["lexicon"]};var Vt=function(t,e){let n=[{}],r=[null],o=[0],i=[],s=0;t.forEach((function(t){let o=0,i=function(t,e){const{methods:n,model:r}=e;let o=n.one.tokenize.splitTerms(t,r).map((t=>n.one.tokenize.splitWhitespace(t,r)));return o.map((t=>t.text.toLowerCase()))}(t,e);for(let t=0;t<i.length;t++){let e=i[t];n[o]&&n[o].hasOwnProperty(e)?o=n[o][e]:(s++,n[o][e]=s,n[s]={},o=s,r[s]=null)}r[o]=[i.length]}));for(let t in n[0])s=n[0][t],o[s]=0,i.push(s);for(;i.length;){let t=i.shift(),e=Object.keys(n[t]);for(let l=0;l<e.length;l+=1){let a=e[l],c=n[t][a];for(i.push(c),s=o[t];s>0&&!n[s].hasOwnProperty(a);)s=o[s];if(n.hasOwnProperty(s)){let t=n[s][a];o[c]=t,r[t]&&(r[c]=r[c]||[],r[c]=r[c].concat(r[t]))}else o[c]=0}}return{goNext:n,endAs:r,failTo:o}};const Ft=function(t,e,n){let r=0,o=[];for(let i=0;i<t.length;i++){let s=t[i][n.form]||t[i].normal;for(;r>0&&(void 0===e.goNext[r]||!e.goNext[r].hasOwnProperty(s));)r=e.failTo[r]||0;if(e.goNext[r].hasOwnProperty(s)&&(r=e.goNext[r][s],e.endAs[r])){let n=e.endAs[r];for(let e=0;e<n.length;e++){let r=n[e],s=t[i-r+1],[l,a]=s.index;o.push([l,a,a+r,s.id])}}}return o},Gt=function(t,e){for(let n=0;n<t.length;n+=1)if(!0===e.has(t[n]))return!1;return!0};var Dt=function(t,e,n){let r=[];n.form=n.form||"normal";let o=t.docs;if(!e.goNext||!e.goNext[0])return console.error("Compromise invalid lookup trie"),t.none();let i=Object.keys(e.goNext[0]);for(let s=0;s<o.length;s++){if(t._cache&&t._cache[s]&&!0===Gt(i,t._cache[s]))continue;let l=o[s],a=Ft(l,e,n);a.length>0&&(r=r.concat(a))}return t.update(r)};const Bt=(t,e)=>{for(let n=t.length-1;n>=0;n-=1)if(t[n]!==e)return t=t.slice(0,n+1),t;return t};var Ut=function(t){return t.goNext=t.goNext.map((t=>{if(0!==Object.keys(t).length)return t})),t.goNext=Bt(t.goNext,void 0),t.failTo=Bt(t.failTo,0),t.endAs=Bt(t.endAs,null),t};const Mt={buildTrie:function(t){const e=Vt(t,this.world());return Ut(e)}};Mt.compile=Mt.buildTrie;var Wt={api:function(t){t.prototype.lookup=function(t,e={}){if(!t)return this.none();"string"==typeof t&&(t=[t]);let n=(r=t,"[object Object]"===Object.prototype.toString.call(r)?t:Vt(t,this.world));var r;let o=Dt(this,n,e);return o=o.settle(),o}},lib:Mt};const It=function(t,e){return e?(t.forEach((t=>{let n=t[0];e[n]&&(t[0]=e[n][0],t[1]+=e[n][1],t[2]+=e[n][1])})),t):t},Rt=function(t,e){let{ptrs:n,byGroup:r}=t;return n=It(n,e),Object.keys(r).forEach((t=>{r[t]=It(r[t],e)})),{ptrs:n,byGroup:r}},Qt=t=>"[object Object]"===Object.prototype.toString.call(t),Ht=t=>t&&Qt(t)&&!0===t.isView,Zt=t=>t&&Qt(t)&&!0===t.isNet,Kt=function(t,e,n){const r=n.methods.one;return"number"==typeof t&&(t=String(t)),"string"==typeof t&&(t=r.killUnicode(t,n),t=r.parseMatch(t,e,n)),t};var Jt={matchOne:function(t,e,n){const r=this.methods.one;if(Ht(t))return this.intersection(t).eq(0);if(Zt(t))return this.sweep(t,{tagger:!1,matchOne:!0}).view;let o={regs:t=Kt(t,n,this.world),group:e,justOne:!0},i=r.match(this.docs,o,this._cache),{ptrs:s,byGroup:l}=Rt(i,this.fullPointer),a=this.toView(s);return a._groups=l,a},match:function(t,e,n){const r=this.methods.one;if(Ht(t))return this.intersection(t);if(Zt(t))return this.sweep(t,{tagger:!1}).view.settle();let o={regs:t=Kt(t,n,this.world),group:e},i=r.match(this.docs,o,this._cache),{ptrs:s,byGroup:l}=Rt(i,this.fullPointer),a=this.toView(s);return a._groups=l,a},has:function(t,e,n){const r=this.methods.one;if(Ht(t)){return t.fullPointer.length>0}if(Zt(t))return this.sweep(t,{tagger:!1}).view.found;let o={regs:t=Kt(t,n,this.world),group:e,justOne:!0};return r.match(this.docs,o,this._cache).ptrs.length>0},if:function(t,e,n){const r=this.methods.one;if(Ht(t))return this.filter((e=>e.intersection(t).found));if(Zt(t)){let e=this.sweep(t,{tagger:!1}).view.settle();return this.if(e)}let o={regs:t=Kt(t,n,this.world),group:e,justOne:!0},i=this.fullPointer,s=this._cache||[];i=i.filter(((t,e)=>{let n=this.update([t]);return r.match(n.docs,o,s[e]).ptrs.length>0}));let l=this.update(i);return this._cache&&(l._cache=i.map((t=>s[t[0]]))),l},ifNo:function(t,e,n){const{methods:r}=this,o=r.one;if(Ht(t))return this.filter((e=>!e.intersection(t).found));if(Zt(t)){let e=this.sweep(t,{tagger:!1}).view.settle();return this.ifNo(e)}t=Kt(t,n,this.world);let i=this._cache||[],s=this.filter(((n,r)=>{let s={regs:t,group:e,justOne:!0};return 0===o.match(n.docs,s,i[r]).ptrs.length}));return this._cache&&(s._cache=s.ptrs.map((t=>i[t[0]]))),s}};var Xt={before:function(t,e,n){const{indexN:r}=this.methods.one.pointer;let o=[],i=r(this.fullPointer);Object.keys(i).forEach((t=>{let e=i[t].sort(((t,e)=>t[1]>e[1]?1:-1))[0];e[1]>0&&o.push([e[0],0,e[1]])}));let s=this.toView(o);return t?s.match(t,e,n):s},after:function(t,e,n){const{indexN:r}=this.methods.one.pointer;let o=[],i=r(this.fullPointer),s=this.document;Object.keys(i).forEach((t=>{let e=i[t].sort(((t,e)=>t[1]>e[1]?-1:1))[0],[n,,r]=e;r<s[n].length&&o.push([n,r,s[n].length])}));let l=this.toView(o);return t?l.match(t,e,n):l},growLeft:function(t,e,n){"string"==typeof t&&(t=this.world.methods.one.parseMatch(t,n,this.world)),t[t.length-1].end=!0;let r=this.fullPointer;return this.forEach(((n,o)=>{let i=n.before(t,e);if(i.found){let t=i.terms();r[o][1]-=t.length,r[o][3]=t.docs[0][0].id}})),this.update(r)},growRight:function(t,e,n){"string"==typeof t&&(t=this.world.methods.one.parseMatch(t,n,this.world)),t[0].start=!0;let r=this.fullPointer;return this.forEach(((n,o)=>{let i=n.after(t,e);if(i.found){let t=i.terms();r[o][2]+=t.length,r[o][4]=null}})),this.update(r)},grow:function(t,e,n){return this.growRight(t,e,n).growLeft(t,e,n)}};const Yt=function(t,e){return[t[0],t[1],e[2]]},te=(t,e,n)=>{return"string"==typeof t||(r=t,"[object Array]"===Object.prototype.toString.call(r))?e.match(t,n):t||e.none();var r},ee=function(t,e){let[n,r,o]=t;return e.document[n]&&e.document[n][r]&&(t[3]=t[3]||e.document[n][r].id,e.document[n][o-1]&&(t[4]=t[4]||e.document[n][o-1].id)),t},ne={splitOn:function(t,e){const{splitAll:n}=this.methods.one.pointer;let r=te(t,this,e).fullPointer,o=n(this.fullPointer,r),i=[];return o.forEach((t=>{i.push(t.passthrough),i.push(t.before),i.push(t.match),i.push(t.after)})),i=i.filter((t=>t)),i=i.map((t=>ee(t,this))),this.update(i)},splitBefore:function(t,e){const{splitAll:n}=this.methods.one.pointer;let r=te(t,this,e).fullPointer,o=n(this.fullPointer,r),i=[];return o.forEach((t=>{i.push(t.passthrough),i.push(t.before),t.match&&t.after?i.push(Yt(t.match,t.after)):(i.push(t.match),i.push(t.after))})),i=i.filter((t=>t)),i=i.map((t=>ee(t,this))),this.update(i)},splitAfter:function(t,e){const{splitAll:n}=this.methods.one.pointer;let r=te(t,this,e).fullPointer,o=n(this.fullPointer,r),i=[];return o.forEach((t=>{i.push(t.passthrough),t.before&&t.match?i.push(Yt(t.before,t.match)):(i.push(t.before),i.push(t.match)),i.push(t.after)})),i=i.filter((t=>t)),i=i.map((t=>ee(t,this))),this.update(i)}};ne.split=ne.splitAfter;var re=ne;const oe=Object.assign({},Jt,Xt,re);oe.lookBehind=oe.before,oe.lookBefore=oe.before,oe.lookAhead=oe.after,oe.lookAfter=oe.after,oe.notIf=oe.ifNo;var ie=function(t){Object.assign(t.prototype,oe)};const se=/(?:^|\s)([![^]*(?:<[^<]*>)?\/.*?[^\\/]\/[?\]+*$~]*)(?:\s|$)/,le=/([!~[^]*(?:<[^<]*>)?\([^)]+[^\\)]\)[?\]+*$~]*)(?:\s|$)/,ae=/ /g,ce=t=>/^[![^]*(<[^<]*>)?\//.test(t)&&/\/[?\]+*$~]*$/.test(t),ue=function(t){return t=(t=t.map((t=>t.trim()))).filter((t=>t))};var he=function(t){let e=t.split(se),n=[];e.forEach((t=>{ce(t)?n.push(t):n=n.concat(t.split(le))})),n=ue(n);let r=[];return n.forEach((t=>{(t=>/^[![^]*(<[^<]*>)?\(/.test(t)&&/\)[?\]+*$~]*$/.test(t))(t)||ce(t)?r.push(t):r=r.concat(t.split(ae))})),r=ue(r),r};const fe=/\{([0-9]+)?(, *[0-9]*)?\}/,pe=/&&/,de=new RegExp(/^<\s*(\S+)\s*>/),me=t=>t.charAt(0).toUpperCase()+t.substring(1),ge=t=>t.charAt(t.length-1),we=t=>t.charAt(0),ve=t=>t.substring(1),ye=t=>t.substring(0,t.length-1),be=function(t){return t=ve(t),t=ye(t)},xe=function(t,e){let n={};for(let r=0;r<2;r+=1){if("$"===ge(t)&&(n.end=!0,t=ye(t)),"^"===we(t)&&(n.start=!0,t=ve(t)),("["===we(t)||"]"===ge(t))&&(n.group=null,"["===we(t)&&(n.groupStart=!0),"]"===ge(t)&&(n.groupEnd=!0),t=(t=t.replace(/^\[/,"")).replace(/\]$/,""),"<"===we(t))){const e=de.exec(t);e.length>=2&&(n.group=e[1],t=t.replace(e[0],""))}if("+"===ge(t)&&(n.greedy=!0,t=ye(t)),"*"!==t&&"*"===ge(t)&&"\\*"!==t&&(n.greedy=!0,t=ye(t)),"?"===ge(t)&&(n.optional=!0,t=ye(t)),"!"===we(t)&&(n.negative=!0,t=ve(t)),"~"===we(t)&&"~"===ge(t)&&t.length>2&&(t=be(t),n.fuzzy=!0,n.min=e.fuzzy||.85,!1===/\(/.test(t)))return n.word=t,n;if("("===we(t)&&")"===ge(t)){pe.test(t)?(n.choices=t.split(pe),n.operator="and"):(n.choices=t.split("|"),n.operator="or"),n.choices[0]=ve(n.choices[0]);let r=n.choices.length-1;n.choices[r]=ye(n.choices[r]),n.choices=n.choices.map((t=>t.trim())),n.choices=n.choices.filter((t=>t)),n.choices=n.choices.map((t=>t.split(/ /g).map((t=>xe(t,e))))),t=""}if("/"===we(t)&&"/"===ge(t))return t=be(t),e.caseSensitive&&(n.use="text"),n.regex=new RegExp(t),n;if("{"===we(t)&&"}"===ge(t)){if(t=be(t),n.root=t,/\//.test(t)){let t=n.root.split(/\//);n.root=t[0],n.pos=t[1],"adj"===n.pos&&(n.pos="Adjective"),n.pos=n.pos.charAt(0).toUpperCase()+n.pos.substr(1).toLowerCase(),void 0!==t[2]&&(n.sense=t[2])}return n}if("<"===we(t)&&">"===ge(t))return t=be(t),n.chunk=me(t),n.greedy=!0,n;if("%"===we(t)&&"%"===ge(t))return t=be(t),n.switch=t,n}return!0===fe.test(t)&&(t=t.replace(fe,((t,e,r)=>(void 0===r?(n.min=Number(e),n.max=Number(e)):(r=r.replace(/, */,""),void 0===e?(n.min=0,n.max=Number(r)):(n.min=Number(e),n.max=Number(r||999))),n.greedy=!0,n.min||(n.optional=!0),"")))),"#"===we(t)?(n.tag=ve(t),n.tag=me(n.tag),n):"@"===we(t)?(n.method=ve(t),n):"."===t?(n.anything=!0,n):"*"===t?(n.anything=!0,n.greedy=!0,n.optional=!0,n):(t&&(t=(t=t.replace("\\*","*")).replace("\\.","."),e.caseSensitive?n.use="text":t=t.toLowerCase(),n.word=t),n)};var je=xe;const Oe=/[a-z0-9][-–—][a-z]/i;var Ee=function(t,e){let n=e.model.one.prefixes;for(let e=t.length-1;e>=0;e-=1){let r=t[e];if(r.word&&Oe.test(r.word)){let o=r.word.split(/[-–—]/g);if(n.hasOwnProperty(o[0]))continue;o=o.filter((t=>t)).reverse(),t.splice(e,1),o.forEach((n=>{let o=Object.assign({},r);o.word=n,t.splice(e,0,o)}))}}return t};const ke=function(t,e){let{all:n}=e.methods.two.transform.verb||{},r=t.root;return n?n(r,e.model):[]},Pe=function(t,e){let{all:n}=e.methods.two.transform.noun||{};return n?n(t.root,e.model):[t.root]},_e=function(t,e){let{all:n}=e.methods.two.transform.adjective||{};return n?n(t.root,e.model):[t.root]};var Se=function(t,e){return t=t.map((t=>{if(t.root)if(e.methods.two&&e.methods.two.transform){let n=[];t.pos?"Verb"===t.pos?n=n.concat(ke(t,e)):"Noun"===t.pos?n=n.concat(Pe(t,e)):"Adjective"===t.pos&&(n=n.concat(_e(t,e))):(n=n.concat(ke(t,e)),n=n.concat(Pe(t,e)),n=n.concat(_e(t,e))),n=n.filter((t=>t)),n.length>0&&(t.operator="or",t.fastOr=new Set(n))}else t.machine=t.root,delete t.id,delete t.root;return t}))};var Ae=function(t){return t=function(t){let e=0,n=null;for(let r=0;r<t.length;r++){const o=t[r];!0===o.groupStart&&(n=o.group,null===n&&(n=String(e),e+=1)),null!==n&&(o.group=n),!0===o.groupEnd&&(n=null)}return t}(t),t=function(t){return t.map((t=>(t.fuzzy&&t.choices&&t.choices.forEach((e=>{1===e.length&&e[0].word&&(e[0].fuzzy=!0,e[0].min=t.min)})),t)))}(t=t.map((t=>{if(void 0!==t.choices){if("or"!==t.operator)return t;if(!0===t.fuzzy)return t;!0===t.choices.every((t=>{if(1!==t.length)return!1;let e=t[0];return!0!==e.fuzzy&&!e.start&&!e.end&&void 0!==e.word&&!0!==e.negative&&!0!==e.optional&&!0!==e.method}))&&(t.fastOr=new Set,t.choices.forEach((e=>{t.fastOr.add(e[0].word)})),delete t.choices)}return t}))),t};var Te=function(t,e,n){if(null==t||""===t)return[];e=e||{},"number"==typeof t&&(t=String(t));let r=he(t);return r=r.map((t=>je(t,e))),r=Ee(r,n),r=Se(r,n),r=Ae(r),r};const $e=function(t,e){for(let n of e)if(t.has(n))return!0;return!1};var Ce=function(t,e){for(let n=0;n<t.length;n+=1){let r=t[n];if(!0!==r.optional&&!0!==r.negative&&!0!==r.fuzzy){if(void 0!==r.word&&!1===e.has(r.word))return!0;if(void 0!==r.tag&&!1===e.has("#"+r.tag))return!0;if(r.fastOr&&!1===$e(r.fastOr,e))return!1}}return!1};var ze=function(t,e,n=3){if(t===e)return 1;if(t.length<n||e.length<n)return 0;const r=function(t,e){let n=t.length,r=e.length;if(0===n)return r;if(0===r)return n;let o=(r>n?r:n)+1;if(Math.abs(n-r)>(o||100))return o||100;let i,s,l,a,c,u,h=[];for(let t=0;t<o;t++)h[t]=[t],h[t].length=o;for(let t=0;t<o;t++)h[0][t]=t;for(let o=1;o<=n;++o)for(s=t[o-1],i=1;i<=r;++i){if(o===i&&h[o][i]>4)return n;l=e[i-1],a=s===l?0:1,c=h[o-1][i]+1,(u=h[o][i-1]+1)<c&&(c=u),(u=h[o-1][i-1]+a)<c&&(c=u);let r=o>1&&i>1&&s===e[i-2]&&t[o-2]===l&&(u=h[o-2][i-2]+a)<c;h[o][i]=r?u:c}return h[n][r]}(t,e);let o=Math.max(t.length,e.length);return 1-(0===o?0:r/o)};const Ne=/([\u0022\uFF02\u0027\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F])/,Le=/([\u0022\uFF02\u0027\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4])/,qe=/^[-–—]$/,Ve=/ [-–—]{1,3} /,Fe=(t,e)=>-1!==t.post.indexOf(e),Ge=(t,e)=>-1!==t.pre.indexOf(e),De={hasQuote:t=>Ne.test(t.pre)||Le.test(t.post),hasComma:t=>Fe(t,","),hasPeriod:t=>!0===Fe(t,".")&&!1===Fe(t,"..."),hasExclamation:t=>Fe(t,"!"),hasQuestionMark:t=>Fe(t,"?")||Fe(t,"¿"),hasEllipses:t=>Fe(t,"..")||Fe(t,"…")||Ge(t,"..")||Ge(t,"…"),hasSemicolon:t=>Fe(t,";"),hasColon:t=>Fe(t,":"),hasSlash:t=>/\//.test(t.text),hasHyphen:t=>qe.test(t.post)||qe.test(t.pre),hasDash:t=>Ve.test(t.post)||Ve.test(t.pre),hasContraction:t=>Boolean(t.implicit),isAcronym:t=>t.tags.has("Acronym"),isKnown:t=>t.tags.size>0,isTitleCase:t=>/^\p{Lu}[a-z'\u00C0-\u00FF]/u.test(t.text),isUpperCase:t=>/^\p{Lu}+$/u.test(t.text)};De.hasQuotation=De.hasQuote;var Be=De;let Ue=function(){};Ue=function(t,e,n,r){let o=function(t,e,n,r){if(!0===e.anything)return!0;if(!0===e.start&&0!==n)return!1;if(!0===e.end&&n!==r-1)return!1;if(void 0!==e.id&&e.id===t.id)return!0;if(void 0!==e.word){if(e.use)return e.word===t[e.use];if(null!==t.machine&&t.machine===e.word)return!0;if(void 0!==t.alias&&t.alias.hasOwnProperty(e.word))return!0;if(!0===e.fuzzy){if(e.word===t.root)return!0;if(ze(e.word,t.normal)>=e.min)return!0}return!(!t.alias||!t.alias.some((t=>t===e.word)))||e.word===t.text||e.word===t.normal}if(void 0!==e.tag)return!0===t.tags.has(e.tag);if(void 0!==e.method)return"function"==typeof Be[e.method]&&!0===Be[e.method](t);if(void 0!==e.pre)return t.pre&&t.pre.includes(e.pre);if(void 0!==e.post)return t.post&&t.post.includes(e.post);if(void 0!==e.regex){let n=t.normal;return e.use&&(n=t[e.use]),e.regex.test(n)}return void 0!==e.chunk?t.chunk===e.chunk:void 0!==e.switch?t.switch===e.switch:void 0!==e.machine?t.normal===e.machine||t.machine===e.machine||t.root===e.machine:void 0!==e.sense?t.sense===e.sense:void 0!==e.fastOr?e.pos&&!t.tags.has(e.pos)?null:e.fastOr.has(t.implicit)||e.fastOr.has(t.normal)||e.fastOr.has(t.text)||e.fastOr.has(t.machine):void 0!==e.choices&&("and"===e.operator?e.choices.every((e=>Ue(t,e,n,r))):e.choices.some((e=>Ue(t,e,n,r))))}(t,e,n,r);return!0===e.negative?!o:o};var Me=Ue;const We=function(t,e){if(!0===t.end&&!0===t.greedy&&e.start_i+e.t<e.phrase_length-1){let n=Object.assign({},t,{end:!1});if(!0===Me(e.terms[e.t],n,e.start_i+e.t,e.phrase_length))return!0}return!1},Ie=function(t,e){return t.groups[t.inGroup]||(t.groups[t.inGroup]={start:e,length:0}),t.groups[t.inGroup]};var Re=function(t){let{regs:e}=t,n=e[t.r],r=function(t,e){let n=t.t;if(!e)return t.terms.length;for(;n<t.terms.length;n+=1)if(!0===Me(t.terms[n],e,t.start_i+n,t.phrase_length))return n;return null}(t,e[t.r+1]);if(null===r||0===r)return null;if(void 0!==n.min&&r-t.t<n.min)return null;if(void 0!==n.max&&r-t.t>n.max)return t.t=t.t+n.max,!0;if(!0===t.hasGroup){Ie(t,t.t).length=r-t.t}return t.t=r,!0};const Qe=function(t,e=0){let n=t.regs[t.r],r=!1;for(let i=0;i<n.choices.length;i+=1){let s=n.choices[i];if(o=s,"[object Array]"!==Object.prototype.toString.call(o))return!1;if(r=s.every(((n,r)=>{let o=0,i=t.t+r+e+o;if(void 0===t.terms[i])return!1;let s=Me(t.terms[i],n,i+t.start_i,t.phrase_length);if(!0===s&&!0===n.greedy)for(let e=1;e<t.terms.length;e+=1){let r=t.terms[i+e];if(r){if(!0!==Me(r,n,t.start_i+e,t.phrase_length))break;o+=1}}return e+=o,s})),r){e+=s.length;break}}var o;return r&&!0===n.greedy?Qe(t,e):e};var He=function(t){const{regs:e}=t;let n=e[t.r],r=Qe(t);if(r){if(!0===n.negative)return null;if(!0===t.hasGroup){Ie(t,t.t).length+=r}if(!0===n.end){let e=t.phrase_length;if(t.t+t.start_i+r!==e)return null}return t.t+=r,!0}return!!n.optional||null};var Ze=function(t){const{regs:e}=t;let n=e[t.r],r=function(t){let e=0;return!0===t.regs[t.r].choices.every((n=>{let r=n.every(((e,n)=>{let r=t.t+n;return void 0!==t.terms[r]&&Me(t.terms[r],e,r,t.phrase_length)}));return!0===r&&n.length>e&&(e=n.length),r}))&&e}(t);if(r){if(!0===n.negative)return null;if(!0===t.hasGroup){Ie(t,t.t).length+=r}if(!0===n.end){let e=t.phrase_length-1;if(t.t+t.start_i!==e)return null}return t.t+=r,!0}return!!n.optional||null};var Ke=function(t,e,n){let r=0;for(let o=t.t;o<t.terms.length;o+=1){let i=Me(t.terms[o],e,t.start_i+t.t,t.phrase_length);if(i)break;if(n&&(i=Me(t.terms[o],n,t.start_i+t.t,t.phrase_length),i))break;if(r+=1,void 0!==e.max&&r===e.max)break}return 0!==r&&(!(e.min&&e.min>r)&&(t.t+=r,!0))};var Je=function(t){const{regs:e}=t;let n=e[t.r],r=Object.assign({},n);if(r.negative=!1,Me(t.terms[t.t],r,t.start_i+t.t,t.phrase_length))return!1;if(n.optional){let n=e[t.r+1];if(n){if(Me(t.terms[t.t],n,t.start_i+t.t,t.phrase_length))t.r+=1;else if(n.optional&&e[t.r+2]){Me(t.terms[t.t],e[t.r+2],t.start_i+t.t,t.phrase_length)&&(t.r+=2)}}}return n.greedy?Ke(t,r,e[t.r+1]):(t.t+=1,!0)};var Xe=function(t){const{regs:e}=t;let n=e[t.r],r=t.terms[t.t],o=Me(r,e[t.r+1],t.start_i+t.t,t.phrase_length);if(n.negative||o){let n=t.terms[t.t+1];n&&Me(n,e[t.r+1],t.start_i+t.t,t.phrase_length)||(t.r+=1)}};var Ye=function(t){const{regs:e,phrase_length:n}=t;let r=e[t.r];return t.t=function(t,e){let n=Object.assign({},t.regs[t.r],{start:!1,end:!1}),r=t.t;for(;t.t<t.terms.length;t.t+=1){if(e&&Me(t.terms[t.t],e,t.start_i+t.t,t.phrase_length))return t.t;let o=t.t-r+1;if(void 0!==n.max&&o===n.max)return t.t;if(!1===Me(t.terms[t.t],n,t.start_i+t.t,t.phrase_length))return void 0!==n.min&&o<n.min?null:t.t}return t.t}(t,e[t.r+1]),null===t.t||r.min&&r.min>t.t?null:!0!==r.end||t.start_i+t.t===n||null};var tn=function(t){let e=t.terms[t.t],n=t.regs[t.r];if(e.implicit&&t.terms[t.t+1]){if(!t.terms[t.t+1].implicit)return;n.word===e.normal&&(t.t+=1),"hasContraction"===n.method&&(t.t+=1)}};var en=function(t){const{regs:e}=t;let n=e[t.r],r=t.terms[t.t],o=t.t;if(n.optional&&e[t.r+1]&&n.negative)return!0;if(n.optional&&e[t.r+1]&&Xe(t),r.implicit&&t.terms[t.t+1]&&tn(t),t.t+=1,!0===n.end&&t.t!==t.terms.length&&!0!==n.greedy)return null;if(!0===n.greedy){if(!Ye(t))return null}return!0===t.hasGroup&&function(t,e){let n=t.regs[t.r];const r=Ie(t,e);t.t>1&&n.greedy?r.length+=t.t-e:r.length++}(t,o),!0};var nn=function(t,e,n,r){if(0===t.length||0===e.length)return null;let o={t:0,terms:t,r:0,regs:e,groups:{},start_i:n,phrase_length:r,inGroup:null};for(;o.r<e.length;o.r+=1){let t=e[o.r];if(o.hasGroup=Boolean(t.group),!0===o.hasGroup?o.inGroup=t.group:o.inGroup=null,!o.terms[o.t]){if(!1===e.slice(o.r).some((t=>!t.optional)))break;return null}if(!0!==t.anything||!0!==t.greedy)if(void 0===t.choices||"or"!==t.operator)if(void 0===t.choices||"and"!==t.operator)if(!0!==t.anything)if(!0!==We(t,o))if(t.negative){if(!Je(o))return null}else if(!0!==Me(o.terms[o.t],t,o.start_i+o.t,o.phrase_length)){if(!0!==t.optional)return null}else{if(!en(o))return null}else{if(!en(o))return null}else{if(t.negative&&t.anything)return null;if(!en(o))return null}else{if(!Ze(o))return null}else{if(!He(o))return null}else{if(!Re(o))return null}}let i=[null,n,o.t+n];if(i[1]===i[2])return null;let s={};return Object.keys(o.groups).forEach((t=>{let e=o.groups[t],r=n+e.start;s[t]=[null,r,r+e.length]})),{pointer:i,groups:s}};var rn=function(t,e){let n=[],r={};return 0===t.length||("number"==typeof e&&(e=String(e)),e?t.forEach((t=>{t.groups[e]&&n.push(t.groups[e])})):t.forEach((t=>{n.push(t.pointer),Object.keys(t.groups).forEach((e=>{r[e]=r[e]||[],r[e].push(t.groups[e])}))}))),{ptrs:n,byGroup:r}};var on=function(t,e,n){return t=t.filter((t=>{let[r,o,i]=t.pointer,s=n[r].slice(o,i);for(let t=0;t<s.length;t+=1){let n=s.slice(t);if(null!==nn(n,e,t,s.length))return!1}return!0})),t};const sn=function(t,e){return t.pointer[0]=e,Object.keys(t.groups).forEach((n=>{t.groups[n][0]=e})),t},ln=function(t,e,n){let r=nn(t,e,0,t.length);return r?(r=sn(r,n),r):null};var an=function(t,e,n){n=n||[];let{regs:r,group:o,justOne:i}=e,s=[];if(!r||0===r.length)return{ptrs:[],byGroup:{}};const l=r.filter((t=>!0!==t.optional&&!0!==t.negative)).length;t:for(let e=0;e<t.length;e+=1){let o=t[e];if(!n[e]||!Ce(r,n[e]))if(!0!==r[0].start)for(let t=0;t<o.length;t+=1){let n=o.slice(t);if(n.length<l)break;let a=nn(n,r,t,o.length);if(a){if(a=sn(a,e),s.push(a),!0===i)break t;let n=a.pointer[2];Math.abs(n-1)>t&&(t=Math.abs(n-1))}}else{let t=ln(o,r,e);t&&s.push(t)}}return!0===r[r.length-1].end&&(s=s.filter((e=>{let n=e.pointer[0];return t[n].length===e.pointer[2]}))),e.notIf&&(s=on(s,e.notIf,t)),s=rn(s,o),s.ptrs.forEach((e=>{let[n,r,o]=e;e[3]=t[n][r].id,e[4]=t[n][o-1].id})),s};var cn={api:ie,methods:{one:{termMethods:Be,parseMatch:Te,match:an}},lib:{parseMatch:function(t,e){const n=this.world();let r=n.methods.one.killUnicode;return r&&(t=r(t,n)),n.methods.one.parseMatch(t,e,n)}}};const un=/^\../,hn=/^#./,fn=function(t,e){let n={},r={};return Object.keys(e).forEach((o=>{let i=e[o],s=function(t){let e="",n="</span>";return t=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),un.test(t)?e=`<span class="${t.replace(/^\./,"")}"`:hn.test(t)?e=`<span id="${t.replace(/^#/,"")}"`:(e=`<${t}`,n=`</${t}>`),e+=">",{start:e,end:n}}(o);"string"==typeof i&&(i=t.match(i)),i.docs.forEach((t=>{if(t.every((t=>t.implicit)))return;let e=t[0].id;n[e]=n[e]||[],n[e].push(s.start);let o=t[t.length-1].id;r[o]=r[o]||[],r[o].push(s.end)}))})),{starts:n,ends:r}};var pn={html:function(t){let{starts:e,ends:n}=fn(this,t),r="";return this.docs.forEach((t=>{for(let o=0;o<t.length;o+=1){let i=t[o];e.hasOwnProperty(i.id)&&(r+=e[i.id].join("")),r+=i.pre||""+i.text||"",n.hasOwnProperty(i.id)&&(r+=n[i.id].join("")),r+=i.post||""}})),r}};const dn=/[,:;)\]*.?~!\u0022\uFF02\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4—-]+$/,mn=/^[(['"*~\uFF02\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F]+/,gn=/[,:;)('"\u201D\]]/,wn=/^[-–—]$/,vn=/ /,yn=function(t,e,n=!0){let r="";return t.forEach((t=>{let n=t.pre||"",o=t.post||"";"some"===e.punctuation&&(n=n.replace(mn,""),wn.test(o)&&(o=" "),o=o.replace(gn,""),o=o.replace(/\?!+/,"?"),o=o.replace(/!+/,"!"),o=o.replace(/\?+/,"?"),o=o.replace(/\.{2,}/,""),t.tags.has("Abbreviation")&&(o=o.replace(/\./,""))),"some"===e.whitespace&&(n=n.replace(/\s/,""),o=o.replace(/\s+/," ")),e.keepPunct||(n=n.replace(mn,""),o="-"===o?" ":o.replace(dn,""));let i=t[e.form||"text"]||t.normal||"";"implicit"===e.form&&(i=t.implicit||t.text),"root"===e.form&&t.implicit&&(i=t.root||t.implicit||t.normal),"machine"!==e.form&&"implicit"!==e.form&&"root"!==e.form||!t.implicit||o&&vn.test(o)||(o+=" "),r+=n+i+o})),!1===n&&(r=r.trim()),!0===e.lowerCase&&(r=r.toLowerCase()),r},bn={text:{form:"text"},normal:{whitespace:"some",punctuation:"some",case:"some",unicode:"some",form:"normal"},machine:{keepSpace:!1,whitespace:"some",punctuation:"some",case:"none",unicode:"some",form:"machine"},root:{keepSpace:!1,whitespace:"some",punctuation:"some",case:"some",unicode:"some",form:"root"},implicit:{form:"implicit"}};bn.clean=bn.normal,bn.reduced=bn.root;var xn=bn;let jn=[],On=0;for(;On<64;)jn[On]=0|4294967296*Math.sin(++On%Math.PI);function En(t){let e,n,r,o=[e=1732584193,n=4023233417,~e,~n],i=[],s=decodeURI(encodeURI(t))+"",l=s.length;for(t=--l/4+2|15,i[--t]=8*l;~l;)i[l>>2]|=s.charCodeAt(l)<<8*l--;for(On=s=0;On<t;On+=16){for(l=o;s<64;l=[r=l[3],e+((r=l[0]+[e&n|~e&r,r&e|~r&n,e^n^r,n^(e|~r)][l=s>>4]+jn[s]+~~i[On|15&[s,5*s+1,3*s+5,7*s][l]])<<(l=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*l+s++%4])|r>>>-l),e,n])e=0|l[1],n=l[2];for(s=4;s;)o[--s]+=l[s]}for(t="";s<32;)t+=(o[s>>3]>>4*(1^s++)&15).toString(16);return t}const kn={text:!0,terms:!0};let Pn={case:"none",unicode:"some",form:"machine",punctuation:"some"};const _n=function(t,e){return Object.assign({},t,e)},Sn={text:t=>yn(t,{keepPunct:!0},!1),normal:t=>yn(t,_n(xn.normal,{keepPunct:!0}),!1),implicit:t=>yn(t,_n(xn.implicit,{keepPunct:!0}),!1),machine:t=>yn(t,Pn,!1),root:t=>yn(t,_n(Pn,{form:"root"}),!1),hash:t=>En(yn(t,{keepPunct:!0},!1)),offset:t=>{let e=Sn.text(t).length;return{index:t[0].offset.index,start:t[0].offset.start,length:e}},terms:t=>t.map((t=>{let e=Object.assign({},t);return e.tags=Array.from(t.tags),e})),confidence:(t,e,n)=>e.eq(n).confidence(),syllables:(t,e,n)=>e.eq(n).syllables(),sentence:(t,e,n)=>e.eq(n).fullSentence().text(),dirty:t=>t.some((t=>!0===t.dirty))};Sn.sentences=Sn.sentence,Sn.clean=Sn.normal,Sn.reduced=Sn.root;const An={json:function(t){let e=(n=this,"string"==typeof(r=(r=t)||{})&&(r={}),(r=Object.assign({},kn,r)).offset&&n.compute("offset"),n.docs.map(((t,e)=>{let o={};return Object.keys(r).forEach((i=>{r[i]&&Sn[i]&&(o[i]=Sn[i](t,n,e))})),o})));var n,r;return"number"==typeof t?e[t]:e}};An.data=An.json;var Tn=An;var $n=function(t){console.log("%c -=-=- ","background-color:#6699cc;"),t.forEach((t=>{console.groupCollapsed(t.text());let e=t.docs[0].map((t=>{let e=t.text||"-";return t.implicit&&(e="["+t.implicit+"]"),{text:e,tags:"["+Array.from(t.tags).join(", ")+"]"}}));console.table(e,["text","tags"]),console.groupEnd()}))};var Cn={green:t=>"[32m"+t+"[0m",red:t=>"[31m"+t+"[0m",blue:t=>"[34m"+t+"[0m",magenta:t=>"[35m"+t+"[0m",cyan:t=>"[36m"+t+"[0m",yellow:t=>"[33m"+t+"[0m",black:t=>"[30m"+t+"[0m",dim:t=>"[2m"+t+"[0m",i:t=>"[3m"+t+"[0m"};var zn=function(t){let{docs:e,model:n}=t;0===e.length&&console.log(Cn.blue("\n ──────")),e.forEach((e=>{console.log(Cn.blue("\n ┌─────────")),e.forEach((e=>{let r=[...e.tags||[]],o=e.text||"-";e.sense&&(o=`{${e.normal}/${e.sense}}`),e.implicit&&(o="["+e.implicit+"]"),o=Cn.yellow(o);let i="'"+o+"'";if(e.reference){let n=t.update([e.reference]).text("normal");i+=` - ${Cn.dim(Cn.i("["+n+"]"))}`}i=i.padEnd(18);let s=Cn.blue(" │ ")+Cn.i(i)+" - "+function(t,e){return e.one.tagSet&&(t=t.map((t=>{if(!e.one.tagSet.hasOwnProperty(t))return t;const n=e.one.tagSet[t].color||"blue";return Cn[n](t)}))),t.join(", ")}(r,n);console.log(s)}))}))};var Nn=function(t){let{docs:e}=t;console.log(""),e.forEach((t=>{let e=[];t.forEach((t=>{"Noun"===t.chunk?e.push(Cn.blue(t.implicit||t.normal)):"Verb"===t.chunk?e.push(Cn.green(t.implicit||t.normal)):"Adjective"===t.chunk?e.push(Cn.yellow(t.implicit||t.normal)):"Pivot"===t.chunk?e.push(Cn.red(t.implicit||t.normal)):e.push(t.implicit||t.normal)})),console.log(e.join(" "),"\n")}))};var Ln=function(t){if(!t.found)return;let e={};t.fullPointer.forEach((t=>{e[t[0]]=e[t[0]]||[],e[t[0]].push(t)})),Object.keys(e).forEach((n=>{let r=t.update([[Number(n)]]).text();t.update(e[n]).json({offset:!0}).forEach(((t,e)=>{r=function(t,e,n){let r=((t,e,n)=>{let r=9*n,o=e.start+r,i=o+e.length;return[t.substring(0,o),t.substring(o,i),t.substring(i,t.length)]})(t,e,n);return`${r[0]}${Cn.blue(r[1])}${r[2]}`}(r,t.offset,e)})),console.log(r)}))};var qn=function(t={}){let e=this;if("string"==typeof t){let e={};e[t]=!0,t=e}return"undefined"!=typeof window&&window.document?($n(e),e):(!1!==t.tags&&(zn(e),console.log("\n")),!0===t.chunks&&(Nn(e),console.log("\n")),!0===t.highlight&&(Ln(e),console.log("\n")),e)};const Vn=function(t){let e=t.pre||"",n=t.post||"";return e+t.text+n};var Fn=function(t,e){let n=function(t,e){let n={};return Object.keys(e).forEach((r=>{t.match(r).fullPointer.forEach((t=>{n[t[3]]={fn:e[r],end:t[2]}}))})),n}(t,e),r="";return t.docs.forEach(((e,o)=>{for(let i=0;i<e.length;i+=1){let s=e[i];if(n.hasOwnProperty(s.id)){let{fn:l,end:a}=n[s.id],c=t.update([[o,i,a]]);r+=e[i].pre||"",r+=l(c),i=a-1,r+=e[i].post||""}else r+=Vn(s)}})),r};const Gn={debug:qn,out:function(t){if(e=t,"[object Object]"===Object.prototype.toString.call(e))return Fn(this,t);var e;if("text"===t)return this.text();if("normal"===t)return this.text("normal");if("root"===t)return this.text("root");if("machine"===t||"reduced"===t)return this.text("machine");if("hash"===t||"md5"===t)return En(this.text());if("json"===t)return this.json();if("offset"===t||"offsets"===t)return this.compute("offset"),this.json({offset:!0});if("array"===t){let t=this.docs.map((t=>t.reduce(((t,e)=>t+e.pre+e.text+e.post),"").trim()));return t.filter((t=>t))}if("freq"===t||"frequency"===t||"topk"===t)return function(t){let e={};t.forEach((t=>{e[t]=e[t]||0,e[t]+=1}));let n=Object.keys(e).map((t=>({normal:t,count:e[t]})));return n.sort(((t,e)=>t.count>e.count?-1:0))}(this.json({normal:!0}).map((t=>t.normal)));if("terms"===t){let t=[];return this.docs.forEach((e=>{let n=e.terms.map((t=>t.text));n=n.filter((t=>t)),t=t.concat(n)})),t}return"tags"===t?this.docs.map((t=>t.reduce(((t,e)=>(t[e.implicit||e.normal]=Array.from(e.tags),t)),{}))):"debug"===t?this.debug():this.text()},wrap:function(t){return Fn(this,t)}};var Dn=Gn;var Bn={text:function(t){let e={};var n;if(t&&"string"==typeof t&&xn.hasOwnProperty(t)?e=Object.assign({},xn[t]):t&&(n=t,"[object Object]"===Object.prototype.toString.call(n))&&(e=Object.assign({},t)),void 0===e.keepSpace&&this.pointer&&(e.keepSpace=!1),void 0===e.keepPunct&&this.pointer){let t=this.pointer[0];t&&t[1]?e.keepPunct=!1:e.keepPunct=!0}return void 0===e.keepPunct&&(e.keepPunct=!0),void 0===e.keepSpace&&(e.keepSpace=!0),function(t,e){let n="";if(!t||!t[0]||!t[0][0])return n;for(let r=0;r<t.length;r+=1)n+=yn(t[r],e,!0);if(e.keepSpace||(n=n.trim()),!1===e.keepPunct){t[0][0].tags.has("Emoticon")||(n=n.replace(mn,""));let e=t[t.length-1];e[e.length-1].tags.has("Emoticon")||(n=n.replace(dn,""))}return!0===e.cleanWhitespace&&(n=n.trim()),n}(this.docs,e)}};const Un=Object.assign({},Dn,Bn,Tn,pn);var Mn=function(t){Object.assign(t.prototype,Un)},Wn={api:Mn,methods:{one:{hash:En}}};const In=function(t,e){if(t[0]!==e[0])return!1;let[,n,r]=t,[,o,i]=e;return n<=o&&r>o||o<=n&&i>n},Rn=function(t){let e={};return t.forEach((t=>{e[t[0]]=e[t[0]]||[],e[t[0]].push(t)})),e};var Qn=function(t,e){let n=Rn(e),r=[];return t.forEach((t=>{let[e]=t,o=n[e]||[];if(o=o.filter((e=>function(t,e){return t[1]<=e[1]&&e[2]<=t[2]}(t,e))),0===o.length)return void r.push({passthrough:t});o=o.sort(((t,e)=>t[1]-e[1]));let i=t;o.forEach(((t,e)=>{let n=function(t,e){let[n,r]=t,o=e[1],i=e[2],s={};if(r<o){let e=o<t[2]?o:t[2];s.before=[n,r,e]}return s.match=e,t[2]>i&&(s.after=[n,i,t[2]]),s}(i,t);o[e+1]?(r.push({before:n.before,match:n.match}),n.after&&(i=n.after)):r.push(n)}))})),r};var Hn=function(t,e){let n=[];return t.forEach(((r,o)=>{if(!r)return;let[i,s,l,a,c]=r,u=e[i]||[];if(void 0===s&&(s=0),void 0===l&&(l=u.length),!a||u[s]&&u[s].id===a)u=u.slice(s,l);else{let n=function(t,e,n){for(let r=0;r<20;r+=1){if(e[n-r]){let o=e[n-r].findIndex((e=>e.id===t));if(-1!==o)return[n-r,o]}if(e[n+r]){let o=e[n+r].findIndex((e=>e.id===t));if(-1!==o)return[n+r,o]}}return null}(a,e,i);if(null!==n){let r=l-s;u=e[n[0]].slice(n[1],n[1]+r);let i=u[0]?u[0].id:null;t[o]=[n[0],n[1],n[1]+r,i]}}0!==u.length&&s!==l&&(c&&u[u.length-1].id!==c&&(u=function(t,e){let[n,r,,,o]=t,i=e[n],s=i.findIndex((t=>t.id===o));return-1===s?(t[2]=e[n].length,t[4]=i.length?i[i.length-1].id:null):t[2]=s,e[n].slice(r,t[2]+1)}(r,e)),n.push(u))})),n=n.filter((t=>t.length>0)),n};var Zn={one:{termList:function(t){let e=[];for(let n=0;n<t.length;n+=1)for(let r=0;r<t[n].length;r+=1)e.push(t[n][r]);return e},getDoc:Hn,pointer:{indexN:Rn,splitAll:Qn}}};var Kn=function(t,e){let n=t.concat(e),r=Rn(n),o=[];return n.forEach((t=>{let[e]=t;if(1===r[e].length)return void o.push(t);let n=r[e].filter((e=>In(t,e)));n.push(t);let i=function(t){let e=t[0][1],n=t[0][2];return t.forEach((t=>{t[1]<e&&(e=t[1]),t[2]>n&&(n=t[2])})),[t[0][0],e,n]}(n);o.push(i)})),o=function(t){let e={};for(let n=0;n<t.length;n+=1)e[t[n].join(",")]=t[n];return Object.values(e)}(o),o};var Jn=function(t,e){let n=[];return Qn(t,e).forEach((t=>{t.passthrough&&n.push(t.passthrough),t.before&&n.push(t.before),t.after&&n.push(t.after)})),n};var Xn=function(t,e){let n=Rn(e),r=[];return t.forEach((t=>{let e=n[t[0]]||[];e=e.filter((e=>In(t,e))),0!==e.length&&e.forEach((e=>{let n=function(t,e){let n=t[1]<e[1]?e[1]:t[1],r=t[2]>e[2]?e[2]:t[2];return n<r?[t[0],n,r]:null}(t,e);n&&r.push(n)}))})),r};const Yn=(t,e)=>{return"string"==typeof t||(n=t,"[object Array]"===Object.prototype.toString.call(n))?e.match(t):t||e.none();var n},tr=function(t,e){return t.map((t=>{let[n,r]=t;return e[n]&&e[n][r]&&(t[3]=e[n][r].id),t}))},er={union:function(t){t=Yn(t,this);let e=Kn(this.fullPointer,t.fullPointer);return e=tr(e,this.document),this.toView(e)}};er.and=er.union,er.intersection=function(t){t=Yn(t,this);let e=Xn(this.fullPointer,t.fullPointer);return e=tr(e,this.document),this.toView(e)},er.not=function(t){t=Yn(t,this);let e=Jn(this.fullPointer,t.fullPointer);return e=tr(e,this.document),this.toView(e)},er.difference=er.not,er.complement=function(){let t=this.all(),e=Jn(t.fullPointer,this.fullPointer);return e=tr(e,this.document),this.toView(e)},er.settle=function(){let t=this.fullPointer;return t.forEach((e=>{t=Kn(t,[e])})),t=tr(t,this.document),this.update(t)};var nr=function(t){Object.assign(t.prototype,er)},rr={methods:Zn,api:nr};var or=function(t){t.prototype.sweep=function(t,e={}){const{world:n,docs:r}=this,{methods:o}=n;let i=o.one.bulkMatch(r,t,this.methods,e);!1!==e.tagger&&o.one.bulkTagger(i,r,this.world),i=i.map((t=>{let e=t.pointer,n=r[e[0]][e[1]],o=e[2]-e[1];return n.index&&(t.pointer=[n.index[0],n.index[1],e[1]+o]),t}));let s=i.map((t=>t.pointer));return i=i.map((t=>(t.view=this.update([t.pointer]),delete t.regs,delete t.needs,delete t.pointer,delete t._expanded,t))),{view:this.update(s),found:i}}};const ir=function(t){return!0===t.optional||!0===t.negative?null:t.tag?"#"+t.tag:t.word?t.word:t.switch?`%${t.switch}%`:null};var sr=function(t,e){const n=e.methods.one.parseMatch;return t.forEach((t=>{t.regs=n(t.match,{},e),"string"==typeof t.ifNo&&(t.ifNo=[t.ifNo]),t.notIf&&(t.notIf=n(t.notIf,{},e)),t.needs=function(t){let e=[];return t.forEach((t=>{e.push(ir(t)),"and"===t.operator&&t.choices&&t.choices.forEach((t=>{t.forEach((t=>{e.push(ir(t))}))}))})),e.filter((t=>t))}(t.regs);let{wants:r,count:o}=function(t){let e=[],n=0;return t.forEach((t=>{"or"!==t.operator||t.optional||t.negative||(t.fastOr&&Array.from(t.fastOr).forEach((t=>{e.push(t)})),t.choices&&t.choices.forEach((t=>{t.forEach((t=>{let n=ir(t);n&&e.push(n)}))})),n+=1)})),{wants:e,count:n}}(t.regs);t.wants=r,t.minWant=o,t.minWords=t.regs.filter((t=>!t.optional)).length})),t};var lr=function(t,e){t=sr(t,e);let n={};t.forEach((t=>{t.needs.forEach((e=>{n[e]=n[e]||[],n[e].push(t)})),t.wants.forEach((e=>{n[e]=n[e]||[],n[e].push(t)}))})),Object.keys(n).forEach((t=>{let e={};n[t]=n[t].filter((t=>!e[t.match]&&(e[t.match]=!0,!0)))}));let r=t.filter((t=>0===t.needs.length&&0===t.wants.length));return{hooks:n,always:r}};var ar=function(t,e){return t.map(((n,r)=>{let o=[];Object.keys(e).forEach((n=>{t[r].has(n)&&(o=o.concat(e[n]))}));let i={};return o=o.filter((t=>!i[t.match]&&(i[t.match]=!0,!0))),o}))};var cr=function(t,e){return t.map(((t,n)=>{let r=e[n];return t=(t=(t=t.filter((t=>t.needs.every((t=>r.has(t)))))).filter((t=>void 0===t.ifNo||!0!==t.ifNo.some((t=>r.has(t)))))).filter((t=>{if(0===t.wants.length)return!0;return t.wants.filter((t=>r.has(t))).length>=t.minWant}))}))};var ur=function(t,e,n,r,o){let i=[];for(let n=0;n<t.length;n+=1)for(let s=0;s<t[n].length;s+=1){let l=t[n][s],a=r.one.match([e[n]],l);if(a.ptrs.length>0&&(a.ptrs.forEach((t=>{t[0]=n;let e=Object.assign({},l,{pointer:t});void 0!==l.unTag&&(e.unTag=l.unTag),i.push(e)})),!0===o.matchOne))return[i[0]]}return i};var hr=function(t,e,n,r={}){let o=n.one.cacheDoc(t),i=ar(o,e.hooks);return i=cr(i,o),e.always.length>0&&(i=i.map((t=>t.concat(e.always)))),i=function(t,e){return t.map(((t,n)=>{let r=e[n].length;return t=t.filter((t=>r>=t.minWords)),t}))}(i,t),ur(i,t,o,n,r)};var fr=function(t,e,n){let r=n.one.tagSet;if(!r.hasOwnProperty(e))return!0;let o=r[e].not||[];for(let e=0;e<t.length;e+=1){let n=t[e];for(let t=0;t<o.length;t+=1)if(!0===n.tags.has(o[t]))return!1}return!0};var pr=function(t,e,n){const{model:r,methods:o}=n,{getDoc:i,setTag:s,unTag:l}=o.one,a=o.two.looksPlural;if(0===t.length)return t;return("undefined"!=typeof process&&process.env?process.env:self.env||{}).DEBUG_TAGS&&console.log(`\n\n [32m→ ${t.length} post-tagger:[0m`),t.map((t=>{if(!t.tag&&!t.chunk&&!t.unTag)return;let o=t.reason||t.match,c=i([t.pointer],e)[0];if(!0===t.safe){if(!1===fr(c,t.tag,r))return;if("-"===c[c.length-1].post)return}if(void 0!==t.tag&&(s(c,t.tag,n,t.safe,`[post] '${o}'`),"Noun"===t.tag)){let e=c[c.length-1];a(e.text)?s([e],"Plural",n,t.safe,"quick-plural"):s([e],"Singular",n,t.safe,"quick-singular")}void 0!==t.unTag&&l(c,t.unTag,n,t.safe,o),t.chunk&&c.forEach((e=>e.chunk=t.chunk))}))},dr={lib:{buildNet:function(t){let e=this.methods().one.buildNet(t,this.world());return e.isNet=!0,e}},api:or,methods:{one:{buildNet:lr,bulkMatch:hr,bulkTagger:pr}}};const mr=/ /,gr=function(t,e){"Noun"===e&&(t.chunk=e),"Verb"===e&&(t.chunk=e)},wr=function(t,e,n,r){if(!0===t.tags.has(e))return null;if("."===e)return null;let o=n[e];if(o){if(o.not&&o.not.length>0)for(let e=0;e<o.not.length;e+=1){if(!0===r&&t.tags.has(o.not[e]))return null;t.tags.delete(o.not[e])}if(o.parents&&o.parents.length>0)for(let e=0;e<o.parents.length;e+=1)t.tags.add(o.parents[e]),gr(t,o.parents[e])}return t.tags.add(e),t.dirty=!0,gr(t,e),!0},vr=function(t,e,n={},r,o){const i=n.model.one.tagSet||{};if(!e)return;const s="undefined"!=typeof process&&process.env?process.env:self.env||{};var l;if(s&&s.DEBUG_TAGS&&((t,e,n="")=>{let r=t.map((t=>t.text||"["+t.implicit+"]")).join(" ");var o;"string"!=typeof e&&e.length>2&&(e=e.slice(0,2).join(", #")+" +"),e="string"!=typeof e?e.join(", #"):e,console.log(` ${(o=r,"[33m[3m"+o+"[0m").padEnd(24)} [32m→[0m #${e.padEnd(22)} ${(t=>"[3m"+t+"[0m")(n)}`)})(t,e,o),!0!=(l=e,"[object Array]"===Object.prototype.toString.call(l)))if("string"==typeof e)if(e=e.trim(),mr.test(e))!function(t,e,n,r){let o=e.split(mr);t.forEach(((t,e)=>{let i=o[e];i&&(i=i.replace(/^#/,""),wr(t,i,n,r))}))}(t,e,i,r);else{e=e.replace(/^#/,"");for(let n=0;n<t.length;n+=1)wr(t[n],e,i,r)}else console.warn(`compromise: Invalid tag '${e}'`);else e.forEach((e=>vr(t,e,n,r)))};var yr=vr;var br=function(t,e,n){e=e.trim().replace(/^#/,"");for(let r=0;r<t.length;r+=1){let o=t[r];if("*"===e){o.tags.clear();continue}let i=n[e];if(i&&i.children.length>0)for(let t=0;t<i.children.length;t+=1)o.tags.delete(i.children[t]);o.tags.delete(e)}};const xr=function(t){return t.children=t.children||[],t._cache=t._cache||{},t.props=t.props||{},t._cache.parents=t._cache.parents||[],t._cache.children=t._cache.children||[],t},jr=/^ *(#|\/\/)/,Or=function(t){let e=t.trim().split(/->/),n=[];e.forEach((t=>{n=n.concat(function(t){if(!(t=t.trim()))return null;if(/^\[/.test(t)&&/\]$/.test(t)){let e=(t=(t=t.replace(/^\[/,"")).replace(/\]$/,"")).split(/,/);return e=e.map((t=>t.trim())).filter((t=>t)),e=e.map((t=>xr({id:t}))),e}return[xr({id:t})]}(t))})),n=n.filter((t=>t));let r=n[0];for(let t=1;t<n.length;t+=1)r.children.push(n[t]),r=n[t];return n[0]},Er=(t,e)=>{let n=[],r=[t];for(;r.length>0;){let t=r.pop();n.push(t),t.children&&t.children.forEach((n=>{e&&e(t,n),r.push(n)}))}return n},kr=t=>"[object Array]"===Object.prototype.toString.call(t),Pr=t=>(t=t||"").trim(),_r=function(t=[]){return"string"==typeof t?function(t){let e=t.split(/\r?\n/),n=[];e.forEach((t=>{if(!t.trim()||jr.test(t))return;let e=(t=>{const e=/^( {2}|\t)/;let n=0;for(;e.test(t);)t=t.replace(e,""),n+=1;return n})(t);n.push({indent:e,node:Or(t)})}));let r=function(t){let e={children:[]};return t.forEach(((n,r)=>{0===n.indent?e.children=e.children.concat(n.node):t[r-1]&&function(t,e){let n=t[e].indent;for(;e>=0;e-=1)if(t[e].indent<n)return t[e];return t[0]}(t,r).node.children.push(n.node)})),e}(n);return r=xr(r),r}(t):kr(t)?function(t){let e={};t.forEach((t=>{e[t.id]=t}));let n=xr({});return t.forEach((t=>{if((t=xr(t)).parent)if(e.hasOwnProperty(t.parent)){let n=e[t.parent];delete t.parent,n.children.push(t)}else console.warn(`[Grad] - missing node '${t.parent}'`);else n.children.push(t)})),n}(t):(Er(e=t).forEach(xr),e);var e},Sr=function(t,e){let n="-> ";e&&(n=(t=>"[2m"+t+"[0m")("→ "));let r="";return Er(t).forEach(((t,o)=>{let i=t.id||"";if(e&&(i=(t=>"[31m"+t+"[0m")(i)),0===o&&!t.id)return;let s=t._cache.parents.length;r+=" ".repeat(s)+n+i+"\n"})),r},Ar=function(t){let e=Er(t);e.forEach((t=>{delete(t=Object.assign({},t)).children}));let n=e[0];return n&&!n.id&&0===Object.keys(n.props).length&&e.shift(),e},Tr={text:Sr,txt:Sr,array:Ar,flat:Ar},$r=function(t,e){return"nested"===e||"json"===e?t:"debug"===e?(console.log(Sr(t,!0)),null):Tr.hasOwnProperty(e)?Tr[e](t):t},Cr=t=>{Er(t,((t,e)=>{t.id&&(t._cache.parents=t._cache.parents||[],e._cache.parents=t._cache.parents.concat([t.id]))}))},zr=/\//;class g{constructor(t={}){Object.defineProperty(this,"json",{enumerable:!1,value:t,writable:!0})}get children(){return this.json.children}get id(){return this.json.id}get found(){return this.json.id||this.json.children.length>0}props(t={}){let e=this.json.props||{};return"string"==typeof t&&(e[t]=!0),this.json.props=Object.assign(e,t),this}get(t){if(t=Pr(t),!zr.test(t)){let e=this.json.children.find((e=>e.id===t));return new g(e)}let e=((t,e)=>{let n=(t=>"string"!=typeof t?t:(t=t.replace(/^\//,"")).split(/\//))(e=e||"");for(let e=0;e<n.length;e+=1){let r=t.children.find((t=>t.id===n[e]));if(!r)return null;t=r}return t})(this.json,t)||xr({});return new g(e)}add(t,e={}){if(kr(t))return t.forEach((t=>this.add(Pr(t),e))),this;t=Pr(t);let n=xr({id:t,props:e});return this.json.children.push(n),new g(n)}remove(t){return t=Pr(t),this.json.children=this.json.children.filter((e=>e.id!==t)),this}nodes(){return Er(this.json).map((t=>(delete(t=Object.assign({},t)).children,t)))}cache(){return(t=>{let e=Er(t,((t,e)=>{t.id&&(t._cache.parents=t._cache.parents||[],t._cache.children=t._cache.children||[],e._cache.parents=t._cache.parents.concat([t.id]))})),n={};e.forEach((t=>{t.id&&(n[t.id]=t)})),e.forEach((t=>{t._cache.parents.forEach((e=>{n.hasOwnProperty(e)&&n[e]._cache.children.push(t.id)}))})),t._cache.children=Object.keys(n)})(this.json),this}list(){return Er(this.json)}fillDown(){var t;return t=this.json,Er(t,((t,e)=>{e.props=((t,e)=>(Object.keys(e).forEach((n=>{if(e[n]instanceof Set){let r=t[n]||new Set;t[n]=new Set([...r,...e[n]])}else if((t=>t&&"object"==typeof t&&!Array.isArray(t))(e[n])){let r=t[n]||{};t[n]=Object.assign({},e[n],r)}else kr(e[n])?t[n]=e[n].concat(t[n]||[]):void 0===t[n]&&(t[n]=e[n])})),t))(e.props,t.props)})),this}depth(){Cr(this.json);let t=Er(this.json),e=t.length>1?1:0;return t.forEach((t=>{if(0===t._cache.parents.length)return;let n=t._cache.parents.length+1;n>e&&(e=n)})),e}out(t){return Cr(this.json),$r(this.json,t)}debug(){return Cr(this.json),$r(this.json,"debug"),this}}const Nr=function(t){let e=_r(t);return new g(e)};Nr.prototype.plugin=function(t){t(this)};var Lr={Noun:"blue",Verb:"green",Negative:"green",Date:"red",Value:"red",Adjective:"magenta",Preposition:"cyan",Conjunction:"cyan",Determiner:"cyan",Hyphenated:"cyan",Adverb:"cyan"};const qr=function(t){if(Lr.hasOwnProperty(t.id))return Lr[t.id];if(Lr.hasOwnProperty(t.is))return Lr[t.is];let e=t._cache.parents.find((t=>Lr[t]));return Lr[e]};var Vr=function(t){const e={};return t.forEach((t=>{let{not:n,also:r,is:o,novel:i}=t.props,s=t._cache.parents;r&&(s=s.concat(r)),e[t.id]={is:o,not:n,novel:i,also:r,parents:s,children:t._cache.children,color:qr(t)}})),Object.keys(e).forEach((t=>{let n=new Set(e[t].not);e[t].not.forEach((t=>{e[t]&&e[t].children.forEach((t=>n.add(t)))})),e[t].not=Array.from(n)})),e};const Fr=function(t){return t?"string"==typeof t?[t]:t:[]};var Gr=function(t,e){return t=function(t,e){return Object.keys(t).forEach((n=>{t[n].isA&&(t[n].is=t[n].isA),t[n].notA&&(t[n].not=t[n].notA),t[n].is&&"string"==typeof t[n].is&&(e.hasOwnProperty(t[n].is)||t.hasOwnProperty(t[n].is)||(t[t[n].is]={})),t[n].not&&"string"==typeof t[n].not&&!t.hasOwnProperty(t[n].not)&&(e.hasOwnProperty(t[n].not)||t.hasOwnProperty(t[n].not)||(t[t[n].not]={}))})),t}(t,e),Object.keys(t).forEach((e=>{t[e].children=Fr(t[e].children),t[e].not=Fr(t[e].not)})),Object.keys(t).forEach((e=>{(t[e].not||[]).forEach((n=>{t[n]&&t[n].not&&t[n].not.push(e)}))})),t};var Dr=function(t,e){Object.keys(e).length>0&&(t=function(t){return Object.keys(t).forEach((e=>{t[e]=Object.assign({},t[e]),t[e].novel=!0})),t}(t)),t=Gr(t,e);const n=function(t){const e=Object.keys(t).map((e=>{let n=t[e];const r={not:new Set(n.not),also:n.also,is:n.is,novel:n.novel};return{id:e,parent:n.is,props:r,children:[]}}));return Nr(e).cache().fillDown().out("array")}(Object.assign({},e,t));return Vr(n)},Br={one:{setTag:yr,unTag:br,addTags:Dr}};const Ur=function(t){return"[object Array]"===Object.prototype.toString.call(t)},Mr={tag:function(t,e="",n){if(!this.found||!t)return this;let r=this.termList();if(0===r.length)return this;const{methods:o,verbose:i,world:s}=this;return!0===i&&console.log(" + ",t,e||""),Ur(t)?t.forEach((t=>o.one.setTag(r,t,s,n,e))):o.one.setTag(r,t,s,n,e),this.uncache(),this},tagSafe:function(t,e=""){return this.tag(t,e,!0)},unTag:function(t,e){if(!this.found||!t)return this;let n=this.termList();if(0===n.length)return this;const{methods:r,verbose:o,model:i}=this;!0===o&&console.log(" - ",t,e||"");let s=i.one.tagSet;return Ur(t)?t.forEach((t=>r.one.unTag(n,t,s))):r.one.unTag(n,t,s),this.uncache(),this},canBe:function(t){t=t.replace(/^#/,"");let e=this.model.one.tagSet;if(!e.hasOwnProperty(t))return this;let n=e[t].not||[],r=[];this.document.forEach(((t,e)=>{t.forEach(((t,o)=>{n.find((e=>t.tags.has(e)))&&r.push([e,o,o+1])}))}));let o=this.update(r);return this.difference(o)}};var Wr=Mr;var Ir=function(t){Object.assign(t.prototype,Wr)};var Rr={addTags:function(t){const{model:e,methods:n}=this.world(),r=e.one.tagSet;let o=(0,n.one.addTags)(t,r);return e.one.tagSet=o,this}};const Qr=new Set(["Auxiliary","Possessive"]);var Hr=function(t){const{document:e,world:n}=t,r=n.model.one.tagSet;e.forEach((t=>{t.forEach((t=>{let e=Array.from(t.tags);t.tagRank=function(t,e){return t=t.sort(((t,n)=>{if(Qr.has(t)||!e.hasOwnProperty(n))return 1;if(Qr.has(n)||!e.hasOwnProperty(t))return-1;let r=e[t].children||[],o=r.length;return r=e[n].children||[],o-r.length})),t}(e,r)}))}))},Zr={model:{one:{tagSet:{}}},compute:{tagRank:Hr},methods:Br,api:Ir,lib:Rr};const Kr=/([.!?\u203D\u2E18\u203C\u2047-\u2049]+\s)/g,Jr=/^[.!?\u203D\u2E18\u203C\u2047-\u2049]+\s$/,Xr=/((?:\r?\n|\r)+)/;var Yr=function(t){let e=[],n=t.split(Xr);for(let t=0;t<n.length;t++){let r=n[t].split(Kr);for(let t=0;t<r.length;t++)r[t+1]&&!0===Jr.test(r[t+1])&&(r[t]+=r[t+1],r[t+1]=""),""!==r[t]&&e.push(r[t])}return e};const to=/[a-z0-9\u00C0-\u00FF\u00a9\u00ae\u2000-\u3300\ud000-\udfff]/i,eo=/\S/;var no=function(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(void 0!==r&&""!==r){if(!1===eo.test(r)||!1===to.test(r)){if(e[e.length-1]){e[e.length-1]+=r;continue}if(t[n+1]){t[n+1]=r+t[n+1];continue}}e.push(r)}}return e};var ro=function(t,e){const n=e.methods.one.tokenize.isSentence,r=e.model.one.abbreviations||new Set;let o=[];for(let e=0;e<t.length;e++){let i=t[e];t[e+1]&&!1===n(i,r)?t[e+1]=i+(t[e+1]||""):i&&i.length>0&&(o.push(i),t[e]="")}return o};const oo={'"':'"',""":""","“":"”","‟":"”","„":"”","⹂":"”","‚":"’","«":"»","‹":"›","‵":"′","‶":"″","‷":"‴","〝":"〞","〟":"〞"},io=RegExp("("+Object.keys(oo).join("|")+")","g"),so=RegExp("("+Object.values(oo).join("|")+")","g"),lo=function(t){if(!t)return!1;let e=t.match(so);return null!==e&&1===e.length};var ao=function(t){let e=[];for(let n=0;n<t.length;n+=1){let r=t[n].match(io);if(null!==r&&1===r.length){if(lo(t[n+1])&&t[n+1].length<280){t[n]+=t[n+1],e.push(t[n]),t[n+1]="",n+=1;continue}if(lo(t[n+2])){let r=t[n+1]+t[n+2];if(r.length<280){t[n]+=r,e.push(t[n]),t[n+1]="",t[n+2]="",n+=2;continue}}}e.push(t[n])}return e};const co=/\(/g,uo=/\)/g;var ho=function(t){let e=[];for(let n=0;n<t.length;n+=1){let r=t[n].match(co);if(null!==r&&1===r.length&&t[n+1]&&t[n+1].length<250){if(null!==t[n+1].match(uo)&&1===r.length&&!co.test(t[n+1])){t[n]+=t[n+1],e.push(t[n]),t[n+1]="",n+=1;continue}}e.push(t[n])}return e};const fo=/\S/,po=/^\s+/;var mo=function(t,e){if(t=t||"",!(t=String(t))||"string"!=typeof t||!1===fo.test(t))return[];t=t.replace(" "," ");let n=Yr(t),r=no(n);if(r=ro(r,e),r=ao(r),r=ho(r),0===r.length)return[t];for(let t=1;t<r.length;t+=1){let e=r[t].match(po);null!==e&&(r[t-1]+=e[0],r[t]=r[t].replace(po,""))}return r};const go=function(t,e){let n=t.split(/[-–—]/);if(n.length<=1)return!1;const{prefixes:r,suffixes:o}=e.one;if(1===n[0].length&&/[a-z]/i.test(n[0]))return!1;if(r.hasOwnProperty(n[0]))return!1;if(n[1]=n[1].trim().replace(/[.?!]$/,""),o.hasOwnProperty(n[1]))return!1;if(!0===/^([a-z\u00C0-\u00FF`"'/]+)[-–—]([a-z0-9\u00C0-\u00FF].*)/i.test(t))return!0;return!0===/^([0-9]{1,4})[-–—]([a-z\u00C0-\u00FF`"'/-]+$)/i.test(t)},wo=function(t){let e=[];const n=t.split(/[-–—]/);let r="-",o=t.match(/[-–—]/);o&&o[0]&&(r=o);for(let t=0;t<n.length;t++)t===n.length-1?e.push(n[t]):e.push(n[t]+r);return e};var vo=function(t){const e=/^[0-9]{1,4}(:[0-9][0-9])?([a-z]{1,2})? ?[-–—] ?$/,n=/^[0-9]{1,4}([a-z]{1,2})? ?$/;for(let r=0;r<t.length-1;r+=1)t[r+1]&&e.test(t[r])&&n.test(t[r+1])&&(t[r]=t[r]+t[r+1],t[r+1]=null);return t};const yo=/\p{L} ?\/ ?\p{L}+$/u;var bo=function(t){for(let e=1;e<t.length-1;e++)yo.test(t[e])&&(t[e-1]+=t[e]+t[e+1],t[e]=null,t[e+1]=null);return t};const xo=/\S/,jo=/^[!?.]+$/,Oo=/(\S+)/;let Eo=[".","?","!",":",";","-","–","—","--","...","(",")","[","]",'"',"'","`","«","»","*"];Eo=Eo.reduce(((t,e)=>(t[e]=!0,t)),{});var ko=function(t,e){let n=[],r=[];if("number"==typeof(t=t||"")&&(t=String(t)),function(t){return"[object Array]"===Object.prototype.toString.call(t)}(t))return t;const o=t.split(Oo);for(let t=0;t<o.length;t++)!0!==go(o[t],e)?r.push(o[t]):r=r.concat(wo(o[t]));let i="";for(let t=0;t<r.length;t++){let e=r[t];!0===xo.test(e)&&!1===Eo.hasOwnProperty(e)&&!1===jo.test(e)?(n.length>0?(n[n.length-1]+=i,n.push(e)):n.push(i+e),i=""):i+=e}return i&&(0===n.length&&(n[0]=""),n[n.length-1]+=i),n=bo(n),n=vo(n),n=n.filter((t=>t)),n};const Po=/\p{Letter}/u,_o=/[\p{Number}\p{Currency_Symbol}]/u,So=/^[a-z]\.([a-z]\.)+/i,Ao=/[sn]['’]$/;var To=function(t,e){let{prePunctuation:n,postPunctuation:r,emoticons:o}=e.one,i=t,s="",l="",a=Array.from(t);if(o.hasOwnProperty(t.trim()))return{str:t.trim(),pre:s,post:" "};let c=a.length;for(let t=0;t<c;t+=1){let t=a[0];if(!0!==n[t]){if(("+"===t||"-"===t)&&_o.test(a[1]))break;if("'"===t&&3===t.length&&_o.test(a[1]))break;if(Po.test(t)||_o.test(t))break;s+=a.shift()}}c=a.length;for(let t=0;t<c;t+=1){let t=a[a.length-1];if(!0!==r[t]){if(Po.test(t)||_o.test(t))break;"."===t&&!0===So.test(i)||"'"===t&&!0===Ao.test(i)||(l=a.pop()+l)}}return""===(t=a.join(""))&&(i=i.replace(/ *$/,(t=>(l=t||"",""))),t=i,s=""),{str:t,pre:s,post:l}};var $o=(t,e)=>{let{str:n,pre:r,post:o}=To(t,e);return{text:n,pre:r,post:o,tags:new Set}};var Co=function(t,e){const n=e.model.one.unicode||{};let r=(t=t||"").split("");return r.forEach(((t,e)=>{n[t]&&(r[e]=n[t])})),r.join("")};var zo=function(t){let e=t=(t=(t=t||"").toLowerCase()).trim();return t=(t=(t=t.replace(/[,;.!?]+$/,"")).replace(/\u2026/g,"...")).replace(/\u2013/g,"-"),!1===/^[:;]/.test(t)&&(t=(t=(t=t.replace(/\.{3,}$/g,"")).replace(/[",.!:;?)]+$/g,"")).replace(/^['"(]+/g,"")),""===(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"")).trim())&&(t=e),t=t.replace(/([0-9]),([0-9])/g,"$1$2")};const No=/([A-Z]\.)+[A-Z]?,?$/,Lo=/^[A-Z]\.,?$/,qo=/[A-Z]{2,}('s|,)?$/,Vo=/([a-z]\.)+[a-z]\.?$/;var Fo=function(t){return function(t){return!0===No.test(t)||!0===Vo.test(t)||!0===Lo.test(t)||!0===qo.test(t)}(t)&&(t=t.replace(/\./g,"")),t};var Go=function(t,e){const n=e.methods.one.killUnicode;let r=t.text||"";r=zo(r),r=n(r,e),r=Fo(r),t.normal=r};var Do=function(t,e){const{methods:n,model:r}=e,{splitSentences:o,splitTerms:i,splitWhitespace:s}=n.one.tokenize;return t=o(t=t||"",e).map((t=>{let n=i(t,r);return n=n.map((t=>s(t,r))),n.forEach((t=>{Go(t,e)})),n})),t};const Bo=/[ .][A-Z]\.? *$/i,Uo=/(?:\u2026|\.{2,}) *$/,Mo=/\p{L}/u,Wo=/^[A-Z]\. $/;var Io={one:{killUnicode:Co,tokenize:{splitSentences:mo,isSentence:function(t,e){if(!1===Mo.test(t))return!1;if(!0===Bo.test(t))return!1;if(3===t.length&&Wo.test(t))return!1;if(!0===Uo.test(t))return!1;let n=t.replace(/[.!?\u203D\u2E18\u203C\u2047-\u2049] *$/,"").split(" "),r=n[n.length-1].toLowerCase();return!0!==e.hasOwnProperty(r)},splitTerms:ko,splitWhitespace:$o,fromString:Do}}};var Ro={"&":"and","@":"at","%":"percent",plz:"please",bein:"being"};let Qo={},Ho={};[[["approx","apt","bc","cyn","eg","esp","est","etc","ex","exp","prob","pron","gal","min","pseud","fig","jd","lat","lng","vol","fm","def","misc","plz","ea","ps","sec","pt","pref","pl","pp","qt","fr","sq","nee","ss","tel","temp","vet","ver","fem","masc","eng","adj","vb","rb","inf","situ","vivo","vitro","wr"]],[["dl","ml","gal","qt","pt","tbl","tsp","tbsp","km","dm","cm","mm","mi","td","hr","hrs","kg","hg","dg","cg","mg","µg","lb","oz","sq ft","hz","mps","mph","kmph","kb","mb","tb","lx","lm","fl oz","yb"],"Unit"],[["ad","al","arc","ba","bl","ca","cca","col","corp","ft","fy","ie","lit","ma","md","pd","tce"],"Noun"],[["adj","adm","adv","asst","atty","bldg","brig","capt","cmdr","comdr","cpl","det","dr","esq","gen","gov","hon","jr","llb","lt","maj","messrs","mlle","mme","mr","mrs","ms","mstr","phd","prof","pvt","rep","reps","res","rev","sen","sens","sfc","sgt","sir","sr","supt","surg"],"Honorific"],[["jan","feb","mar","apr","jun","jul","aug","sep","sept","oct","nov","dec"],"Month"],[["dept","univ","assn","bros","inc","ltd","co"],"Organization"],[["rd","st","dist","mt","ave","blvd","cl","cres","hwy","ariz","cal","calif","colo","conn","fla","fl","ga","ida","ia","kan","kans","minn","neb","nebr","okla","penna","penn","pa","dak","tenn","tex","ut","vt","va","wis","wisc","wy","wyo","usafa","alta","ont","que","sask"],"Place"]].forEach((t=>{t[0].forEach((e=>{Qo[e]=!0,Ho[e]="Abbreviation",void 0!==t[1]&&(Ho[e]=[Ho[e],t[1]])}))}));var Zo=["anti","bi","co","contra","de","extra","infra","inter","intra","macro","micro","mis","mono","multi","peri","pre","pro","proto","pseudo","re","sub","supra","trans","tri","un","out","ex"].reduce(((t,e)=>(t[e]=!0,t)),{});let Ko={"!":"¡","?":"¿Ɂ",'"':'“”"❝❞',"'":"‘‛❛❜’","-":"—–",a:"ªÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻȀȁȂȃȦȧȺΆΑΔΛάαλАаѦѧӐӑӒӓƛæ",b:"ßþƀƁƂƃƄƅɃΒβϐϦБВЪЬвъьѢѣҌҍ",c:"¢©ÇçĆćĈĉĊċČčƆƇƈȻȼͻͼϲϹϽϾСсєҀҁҪҫ",d:"ÐĎďĐđƉƊȡƋƌ",e:"ÈÉÊËèéêëĒēĔĕĖėĘęĚěƐȄȅȆȇȨȩɆɇΈΕΞΣέεξϵЀЁЕеѐёҼҽҾҿӖӗ",f:"ƑƒϜϝӺӻҒғſ",g:"ĜĝĞğĠġĢģƓǤǥǦǧǴǵ",h:"ĤĥĦħƕǶȞȟΉΗЂЊЋНнђћҢңҤҥҺһӉӊ",I:"ÌÍÎÏ",i:"ìíîïĨĩĪīĬĭĮįİıƖƗȈȉȊȋΊΐΪίιϊІЇії",j:"ĴĵǰȷɈɉϳЈј",k:"ĶķĸƘƙǨǩΚκЌЖКжкќҚқҜҝҞҟҠҡ",l:"ĹĺĻļĽľĿŀŁłƚƪǀǏǐȴȽΙӀӏ",m:"ΜϺϻМмӍӎ",n:"ÑñŃńŅņŇňʼnŊŋƝƞǸǹȠȵΝΠήηϞЍИЙЛПийлпѝҊҋӅӆӢӣӤӥπ",o:"ÒÓÔÕÖØðòóôõöøŌōŎŏŐőƟƠơǑǒǪǫǬǭǾǿȌȍȎȏȪȫȬȭȮȯȰȱΌΘΟθοσόϕϘϙϬϴОФоѲѳӦӧӨөӪӫ",p:"ƤΡρϷϸϼРрҎҏÞ",q:"Ɋɋ",r:"ŔŕŖŗŘřƦȐȑȒȓɌɍЃГЯгяѓҐґ",s:"ŚśŜŝŞşŠšƧƨȘșȿЅѕ",t:"ŢţŤťŦŧƫƬƭƮȚțȶȾΓΤτϮТт",u:"ÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưƱƲǓǔǕǖǗǘǙǚǛǜȔȕȖȗɄΰυϋύ",v:"νѴѵѶѷ",w:"ŴŵƜωώϖϢϣШЩшщѡѿ",x:"×ΧχϗϰХхҲҳӼӽӾӿ",y:"ÝýÿŶŷŸƳƴȲȳɎɏΎΥΫγψϒϓϔЎУучўѰѱҮүҰұӮӯӰӱӲӳ",z:"ŹźŻżŽžƵƶȤȥɀΖ"},Jo={};Object.keys(Ko).forEach((function(t){Ko[t].split("").forEach((function(e){Jo[e]=t}))}));const Xo=/\//,Yo=/[a-z]\.[a-z]/i,ti=/[0-9]/;var ei=function(t,e){let n=t.normal||t.text||t.machine;const r=e.model.one.aliases;if(r.hasOwnProperty(n)&&(t.alias=t.alias||[],t.alias.push(r[n])),Xo.test(n)&&!Yo.test(n)&&!ti.test(n)){let e=n.split(Xo);e.length<=2&&e.forEach((e=>{""!==(e=e.trim())&&(t.alias=t.alias||[],t.alias.push(e))}))}return t};const ni=/^\p{Letter}+-\p{Letter}+$/u;var ri=function(t){let e=t.implicit||t.normal||t.text;e=e.replace(/['’]s$/,""),e=e.replace(/s['’]$/,"s"),e=e.replace(/([aeiou][ktrp])in'$/,"$1ing"),ni.test(e)&&(e=e.replace(/-/g,"")),e=e.replace(/^[#@]/,""),e!==t.normal&&(t.machine=e)};var oi=function(t){let e=t.docs,n={};for(let t=0;t<e.length;t+=1)for(let r=0;r<e[t].length;r+=1){let o=e[t][r],i=o.machine||o.normal;n[i]=n[i]||0,n[i]+=1}for(let t=0;t<e.length;t+=1)for(let r=0;r<e[t].length;r+=1){let o=e[t][r],i=o.machine||o.normal;o.freq=n[i]}};var ii=function(t){let e=0,n=0,r=t.document;for(let t=0;t<r.length;t+=1)for(let o=0;o<r[t].length;o+=1){let i=r[t][o];i.offset={index:n,start:e+i.pre.length,length:i.text.length},e+=i.pre.length+i.text.length+i.post.length,n+=1}};var si=function(t){let e=t.document;for(let t=0;t<e.length;t+=1)for(let n=0;n<e[t].length;n+=1)e[t][n].index=[t,n]};var li=function(t){let e=0,n=t.docs;for(let t=0;t<n.length;t+=1)for(let r=0;r<n[t].length;r+=1)""!==n[t][r].normal&&(e+=1,n[t][r].wordCount=e)};const ai=function(t,e){let n=t.docs;for(let r=0;r<n.length;r+=1)for(let o=0;o<n[r].length;o+=1)e(n[r][o],t.world)};var ci={compute:{alias:t=>ai(t,ei),machine:t=>ai(t,ri),normal:t=>ai(t,Go),freq:oi,offset:ii,index:si,wordCount:li},methods:Io,model:{one:{aliases:Ro,abbreviations:Qo,prefixes:Zo,suffixes:{like:!0,ish:!0,less:!0,able:!0,elect:!0,type:!0,designate:!0},prePunctuation:{"#":!0,"@":!0,_:!0,"°":!0,"":!0,"":!0,"":!0,"\ufeff":!0},postPunctuation:{"%":!0,_:!0,"°":!0,"":!0,"":!0,"":!0,"\ufeff":!0},lexicon:Ho,unicode:Jo,emoticons:{"<3":!0,"</3":!0,"<\\3":!0,":^P":!0,":^p":!0,":^O":!0,":^3":!0}}},hooks:["alias","machine","index","id"]};var ui={typeahead:function(t){const e=t.model.one.typeahead,n=t.docs;if(0===n.length||0===Object.keys(e).length)return;let r=n[n.length-1]||[],o=r[r.length-1];if(!o.post&&e.hasOwnProperty(o.normal)){let n=e[o.normal];o.implicit=n,o.machine=n,o.typeahead=!0,t.compute.preTagger&&t.last().unTag("*").compute(["lexicon","preTagger"])}}};const hi=function(){const t=this.docs;if(0===t.length)return this;let e=t[t.length-1]||[],n=e[e.length-1];return!0===n.typeahead&&n.machine&&(n.text=n.machine,n.normal=n.machine),this};var fi=function(t){t.prototype.autoFill=hi};var pi=function(t,e,n){let r={},o=[],i=n.prefixes||{};return t.forEach((t=>{let s=(t=t.toLowerCase().trim()).length;e.max&&s>e.max&&(s=e.max);for(let l=e.min;l<s;l+=1){let s=t.substring(0,l);e.safe&&n.model.one.lexicon.hasOwnProperty(s)||(!0!==i.hasOwnProperty(s)&&!0!==r.hasOwnProperty(s)?r[s]=t:o.push(s))}})),r=Object.assign({},i,r),o.forEach((t=>{delete r[t]})),r};const di={safe:!0,min:3};var mi={typeahead:function(t=[],e={}){let n=this.model();var r;e=Object.assign({},di,e),r=t,"[object Object]"===Object.prototype.toString.call(r)&&(Object.assign(n.one.lexicon,t),t=Object.keys(t));let o=pi(t,e,this.world());return Object.keys(o).forEach((t=>{n.one.typeahead.hasOwnProperty(t)?delete n.one.typeahead[t]:n.one.typeahead[t]=o[t]})),this}};var gi={model:{one:{typeahead:{}}},api:fi,lib:mi,compute:ui,hooks:["typeahead"]};w.extend(tt),w.extend(Wn),w.extend(cn),w.extend(rr),w.extend(Zr),w.plugin(St),w.extend(ci),w.plugin(x),w.extend(Wt),w.extend(gi),w.extend(qt),w.extend(dr);export{w as default};