UNPKG

compromise

Version:
1 lines 351 kB
var e={methods:{one:{},two:{},three:{},four:{}},model:{one:{},two:{},three:{}},compute:{},hooks:[]};const t={compute:function(e){const{world:t}=this,n=t.compute;return"string"==typeof e&&n.hasOwnProperty(e)?n[e](this):(e=>"[object Array]"===Object.prototype.toString.call(e))(e)?e.forEach((r=>{t.compute.hasOwnProperty(r)?n[r](this):console.warn("no compute:",e)})):"function"==typeof e?e(this):console.warn("no compute:",e),this}};var n={forEach:function(e){return this.fullPointer.forEach(((t,n)=>{let r=this.update([t]);e(r,n)})),this},map:function(e,t){let n=this.fullPointer.map(((t,n)=>{let r=this.update([t]),a=e(r,n);return void 0===a?this.none():a}));if(0===n.length)return t||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((e=>{r=r.concat(e.fullPointer)})),this.toView(r)},filter:function(e){let t=this.fullPointer;return t=t.filter(((t,n)=>{let r=this.update([t]);return e(r,n)})),this.update(t)},find:function(e){let t=this.fullPointer.find(((t,n)=>{let r=this.update([t]);return e(r,n)}));return this.update([t])},some:function(e){return this.fullPointer.some(((t,n)=>{let r=this.update([t]);return e(r,n)}))},random:function(e=1){let t=this.fullPointer,n=Math.floor(Math.random()*t.length);return n+e>this.length&&(n=this.length-e,n=n<0?0:n),t=t.slice(n,n+e),this.update(t)}};const r={termList:function(){return this.methods.one.termList(this.docs)},terms:function(e){let t=this.match(".");return"number"==typeof e?t.eq(e):t},groups:function(e){if(e||0===e)return this.update(this._groups[e]||[]);let t={};return Object.keys(this._groups).forEach((e=>{t[e]=this.update(this._groups[e])})),t},eq:function(e){let t=this.pointer;return t||(t=this.docs.map(((e,t)=>[t]))),t[e]?this.update([t[e]]):this.none()},first:function(){return this.eq(0)},last:function(){let e=this.fullPointer.length-1;return this.eq(e)},firstTerms:function(){return this.match("^.")},lastTerms:function(){return this.match(".$")},slice:function(e,t){let n=this.pointer||this.docs.map(((e,t)=>[t]));return n=n.slice(e,t),this.update(n)},all:function(){return this.update().toView()},fullSentences:function(){let e=this.fullPointer.map((e=>[e[0]]));return this.update(e).toView()},none:function(){return this.update([])},isDoc:function(e){if(!e||!e.isView)return!1;let t=this.fullPointer,n=e.fullPointer;return!t.length!==n.length&&t.every(((e,t)=>!!n[t]&&(e[0]===n[t][0]&&e[1]===n[t][1]&&e[2]===n[t][2])))},wordCount:function(){return this.docs.reduce(((e,t)=>(e+=t.filter((e=>""!==e.text)).length,e)),0)},isFull:function(){let e=this.pointer;if(!e)return!0;if(0===e.length||0!==e[0][0])return!1;let t=0,n=0;return this.document.forEach((e=>t+=e.length)),this.docs.forEach((e=>n+=e.length)),t===n},getNth:function(e){return"number"==typeof e?this.eq(e):"string"==typeof e?this.if(e):this}};r.group=r.groups,r.fullSentence=r.fullSentences,r.sentence=r.fullSentences,r.lastTerm=r.lastTerms,r.firstTerm=r.firstTerms;const a=Object.assign({},r,t,n);a.get=a.eq;class View{constructor(t,n,r={}){[["document",t],["world",e],["_groups",r],["_cache",null],["viewType","View"]].forEach((e=>{Object.defineProperty(this,e[0],{value:e[1],writable:!0})})),this.ptrs=n}get docs(){let t=this.document;return this.ptrs&&(t=e.methods.one.getDoc(this.ptrs,this.document)),t}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:e,ptrs:t,document:n}=this,r=t||e.map(((e,t)=>[t]));return r.map((e=>{let[t,r,a,o,i]=e;return r=r||0,a=a||(n[t]||[]).length,n[t]&&n[t][r]&&(o=o||n[t][r].id,n[t][a-1]&&(i=i||n[t][a-1].id)),[t,r,a,o,i]}))}update(e){let t=new View(this.document,e);if(this._cache&&e&&e.length>0){let n=[];e.forEach(((e,t)=>{let[r,a,o]=e;(1===e.length||0===a&&this.document[r].length===o)&&(n[t]=this._cache[r])})),n.length>0&&(t._cache=n)}return t.world=this.world,t}toView(e){return new View(this.document,e||this.pointer)}fromText(e){const{methods:t}=this;let n=t.one.tokenize.fromString(e,this.world),r=new View(n);return r.world=this.world,r.compute(["normal","freeze","lexicon"]),this.world.compute.preTagger&&r.compute("preTagger"),r.compute("unfreeze"),r}clone(){let e=this.document.slice(0);e=e.map((e=>e.map((e=>((e=Object.assign({},e)).tags=new Set(e.tags),e)))));let t=this.update(this.pointer);return t.document=e,t._cache=this._cache,t}}Object.assign(View.prototype,a);const o=function(e){return e&&"object"==typeof e&&!Array.isArray(e)};function i(e,t){if(o(t))for(const n in t)o(t[n])?(e[n]||Object.assign(e,{[n]:{}}),i(e[n],t[n])):Object.assign(e,{[n]:t[n]});return e}const s=function(e,t,n,r){const{methods:a,model:o,compute:s,hooks:l}=t;e.methods&&function(e,t){for(const n in t)e[n]=e[n]||{},Object.assign(e[n],t[n])}(a,e.methods),e.model&&i(o,e.model),e.irregulars&&function(e,t){let n=e.two.models||{};Object.keys(t).forEach((e=>{t[e].pastTense&&(n.toPast&&(n.toPast.ex[e]=t[e].pastTense),n.fromPast&&(n.fromPast.ex[t[e].pastTense]=e)),t[e].presentTense&&(n.toPresent&&(n.toPresent.ex[e]=t[e].presentTense),n.fromPresent&&(n.fromPresent.ex[t[e].presentTense]=e)),t[e].gerund&&(n.toGerund&&(n.toGerund.ex[e]=t[e].gerund),n.fromGerund&&(n.fromGerund.ex[t[e].gerund]=e)),t[e].comparative&&(n.toComparative&&(n.toComparative.ex[e]=t[e].comparative),n.fromComparative&&(n.fromComparative.ex[t[e].comparative]=e)),t[e].superlative&&(n.toSuperlative&&(n.toSuperlative.ex[e]=t[e].superlative),n.fromSuperlative&&(n.fromSuperlative.ex[t[e].superlative]=e))}))}(o,e.irregulars),e.compute&&Object.assign(s,e.compute),l&&(t.hooks=l.concat(e.hooks||[])),e.api&&e.api(n),e.lib&&Object.keys(e.lib).forEach((t=>r[t]=e.lib[t])),e.tags&&r.addTags(e.tags),e.words&&r.addWords(e.words),e.frozen&&r.addWords(e.frozen,!0),e.mutate&&e.mutate(t,r)},l=function(e){return"[object Array]"===Object.prototype.toString.call(e)},u=function(e,t,n){const{methods:r}=n;let a=new t([]);if(a.world=n,"number"==typeof e&&(e=String(e)),!e)return a;if("string"==typeof e){return new t(r.one.tokenize.fromString(e,n))}if(o=e,"[object Object]"===Object.prototype.toString.call(o)&&e.isView)return new t(e.document,e.ptrs);var o;if(l(e)){if(l(e[0])){let n=e.map((e=>e.map((e=>({text:e,normal:e,pre:"",post:" ",tags:new Set})))));return new t(n)}let n=e.map((e=>e.terms.map((e=>(l(e.tags)&&(e.tags=new Set(e.tags)),e)))));return new t(n)}return a};let c=Object.assign({},e);const h=function(e,t){t&&h.addWords(t);let n=u(e,View,c);return e&&n.compute(c.hooks),n};Object.defineProperty(h,"_world",{value:c,writable:!0}),h.tokenize=function(e,t){const{compute:n}=this._world;t&&h.addWords(t);let r=u(e,View,c);return n.contractions&&r.compute(["alias","normal","machine","contractions"]),r},h.plugin=function(e){return s(e,this._world,View,this),this},h.extend=h.plugin,h.world=function(){return this._world},h.model=function(){return this._world.model},h.methods=function(){return this._world.methods},h.hooks=function(){return this._world.hooks},h.verbose=function(e){const t="undefined"!=typeof process&&process.env?process.env:self.env||{};return t.DEBUG_TAGS="tagger"===e||!0===e||"",t.DEBUG_MATCH="match"===e||!0===e||"",t.DEBUG_CHUNKS="chunker"===e||!0===e||"",this},h.version="14.14.4";var d={one:{cacheDoc:function(e){let t=e.map((e=>{let t=new Set;return e.forEach((e=>{""!==e.normal&&t.add(e.normal),e.switch&&t.add(`%${e.switch}%`),e.implicit&&t.add(e.implicit),e.machine&&t.add(e.machine),e.root&&t.add(e.root),e.alias&&e.alias.forEach((e=>t.add(e)));let n=Array.from(e.tags);for(let e=0;e<n.length;e+=1)t.add("#"+n[e])})),t}));return t}}};const m={cache:function(){return this._cache=this.methods.one.cacheDoc(this.document),this},uncache:function(){return this._cache=null,this}};var p={api:function(e){Object.assign(e.prototype,m)},compute:{cache:function(e){e._cache=e.methods.one.cacheDoc(e.document)}},methods:d};const f=e=>/^\p{Lu}[\p{Ll}'’]/u.test(e)||/^\p{Lu}$/u.test(e),b=(e,t,n)=>{if(n.forEach((e=>e.dirty=!0)),e){let r=[t,0].concat(n);Array.prototype.splice.apply(e,r)}return e},v=function(e){let t=e[e.length-1];!t||/ $/.test(t.post)||/[-–—]/.test(t.post)||(t.post+=" ")},y=(e,t,n)=>{const r=/[-.?!,;:)–—'"]/g;let a=e[t-1];if(!a)return;let o=a.post;if(r.test(o)){let e=o.match(r).join(""),t=n[n.length-1];t.post=e+t.post,a.post=a.post.replace(r,"")}},w=function(e,t,n,r){let[a,o,i]=t;0===o||i===r[a].length?v(n):(v(n),v([e[t[1]]])),function(e,t,n){let r=e[t];if(0!==t||!f(r.text))return;n[0].text=n[0].text.replace(/^\p{Ll}/u,(e=>e.toUpperCase()));let a=e[t];a.tags.has("ProperNoun")||a.tags.has("Acronym")||f(a.text)&&a.text.length>1&&(a.text=(o=a.text,o.replace(/^\p{Lu}/u,(e=>e.toLowerCase()))));var o}(e,o,n),b(e,o,n)};let k=0;const P=e=>(e=e.length<3?"0"+e:e).length<3?"0"+e:e,A=function(e){let[t,n]=e.index||[0,0];k+=1,k=k>46655?0:k,t=t>46655?0:t,n=n>1294?0:n;let r=P(k.toString(36));r+=P(t.toString(36));let a=n.toString(36);return a=a.length<2?"0"+a:a,r+=a,r+=parseInt(36*Math.random(),10).toString(36),e.normal+"|"+r.toUpperCase()},C=function(e){if(e.has("@hasContraction")&&"function"==typeof e.contractions){e.grow("@hasContraction").contractions().expand()}},N=e=>"[object Array]"===Object.prototype.toString.call(e),j=function(e,t,n){const{document:r,world:a}=t;t.uncache();let o=t.fullPointer,i=t.fullPointer;t.forEach(((s,l)=>{let u=s.fullPointer[0],[c]=u,h=r[c],d=function(e,t){const{methods:n}=t;return"string"==typeof e?n.one.tokenize.fromString(e,t)[0]:"object"==typeof e&&e.isView?e.clone().docs[0]||[]:N(e)?N(e[0])?e[0]:e:[]}(e,a);0!==d.length&&(d=function(e){return e.map((e=>(e.id=A(e),e)))}(d),n?(C(t.update([u]).firstTerm()),w(h,u,d,r)):(C(t.update([u]).lastTerm()),function(e,t,n,r){let[a,,o]=t,i=(r[a]||[]).length;o<i?(y(e,o,n),v(n)):i===o&&(v(e),y(e,o,n),r[a+1]&&(n[n.length-1].post+=" ")),b(e,t[2],n),t[4]=n[n.length-1].id}(h,u,d,r)),r[c]&&r[c][u[1]]&&(u[3]=r[c][u[1]].id),i[l]=u,u[2]+=d.length,o[l]=u)}));let s=t.toView(o);return t.ptrs=i,s.compute(["id","index","freeze","lexicon"]),s.world.compute.preTagger&&s.compute("preTagger"),s.compute("unfreeze"),s},x={insertAfter:function(e){return j(e,this,!1)},insertBefore:function(e){return j(e,this,!0)}};x.append=x.insertAfter,x.prepend=x.insertBefore,x.insert=x.insertAfter;const I=/\$[0-9a-z]+/g,T={},D=e=>e.replace(/^\p{Ll}/u,(e=>e.toUpperCase())),H=e=>e.replace(/^\p{Lu}/u,(e=>e.toLowerCase()));T.replaceWith=function(e,t={}){let n=this.fullPointer,r=this;if(this.uncache(),"function"==typeof e)return function(e,t,n){return e.forEach((e=>{let r=t(e);e.replaceWith(r,n)})),e}(r,e,t);let a=r.docs[0];if(!a)return r;let o=t.possessives&&a[a.length-1].tags.has("Possessive"),i=t.case&&(s=a[0].text,/^\p{Lu}[\p{Ll}'’]/u.test(s)||/^\p{Lu}$/u.test(s));var s;e=function(e,t){if("string"!=typeof e)return e;let n=t.groups();return e=e.replace(I,(e=>{let t=e.replace(/\$/,"");return n.hasOwnProperty(t)?n[t].text():e})),e}(e,r);let l=this.update(n);n=n.map((e=>e.slice(0,3)));let u=(l.docs[0]||[]).map((e=>Array.from(e.tags))),c=l.docs[0][0].pre,h=l.docs[0][l.docs[0].length-1].post;if("string"==typeof e&&(e=this.fromText(e).compute("id")),r.insertAfter(e),l.has("@hasContraction")&&r.contractions){r.grow("@hasContraction+").contractions().expand()}if(r.delete(l),o){let e=r.docs[0],t=e[e.length-1];t.tags.has("Possessive")||(t.text+="'s",t.normal+="'s",t.tags.add("Possessive"))}if(c&&r.docs[0]&&(r.docs[0][0].pre=c),h&&r.docs[0]){let e=r.docs[0][r.docs[0].length-1];e.post.trim()||(e.post=h)}let d=r.toView(n).compute(["index","freeze","lexicon"]);if(d.world.compute.preTagger&&d.compute("preTagger"),d.compute("unfreeze"),t.tags&&d.terms().forEach(((e,t)=>{e.tagSafe(u[t])})),!d.docs[0]||!d.docs[0][0])return d;if(t.case){let e=i?D:H;d.docs[0][0].text=e(d.docs[0][0].text)}return d},T.replace=function(e,t,n){if(e&&!t)return this.replaceWith(e,n);let r=this.match(e);return r.found?(this.soften(),r.replaceWith(t,n)):this};const E={remove:function(e){const{indexN:t}=this.methods.one.pointer;this.uncache();let n=this.all(),r=this;e&&(n=this,r=this.match(e));let a=!n.ptrs;if(r.has("@hasContraction")&&r.contractions){r.grow("@hasContraction").contractions().expand()}let o=n.fullPointer,i=r.fullPointer.reverse(),s=function(e,t){t.forEach((t=>{let[n,r,a]=t,o=a-r;e[n]&&(a===e[n].length&&a>1&&function(e,t){let n=e.length-1,r=e[n],a=e[n-t];a&&r&&(a.post+=r.post,a.post=a.post.replace(/ +([.?!,;:])/,"$1"),a.post=a.post.replace(/[,;:]+([.?!])/,"$1"))}(e[n],o),e[n].splice(r,o))}));for(let t=e.length-1;t>=0;t-=1)if(0===e[t].length&&(e.splice(t,1),t===e.length&&e[t-1])){let n=e[t-1],r=n[n.length-1];r&&(r.post=r.post.trimEnd())}return e}(this.document,i);return o=function(e,t){return e=e.map((e=>{let[n]=e;return t[n]?(t[n].forEach((t=>{let n=t[2]-t[1];e[1]<=t[1]&&e[2]>=t[2]&&(e[2]-=n)})),e):e})),e.forEach(((t,n)=>{if(0===t[1]&&0==t[2])for(let t=n+1;t<e.length;t+=1)e[t][0]-=1,e[t][0]<0&&(e[t][0]=0)})),e=(e=e.filter((e=>e[2]-e[1]>0))).map((e=>(e[3]=null,e[4]=null,e)))}(o,t(i)),n.ptrs=o,n.document=s,n.compute("index"),a&&(n.ptrs=void 0),e?n.toView(o):(this.ptrs=[],n.none())}};E.delete=E.remove;const G={pre:function(e,t){return void 0===e&&this.found?this.docs[0][0].pre:(this.docs.forEach((n=>{let r=n[0];!0===t?r.pre+=e:r.pre=e})),this)},post:function(e,t){if(void 0===e){let e=this.docs[this.docs.length-1];return e[e.length-1].post}return this.docs.forEach((n=>{let r=n[n.length-1];!0===t?r.post+=e:r.post=e})),this},trim:function(){if(!this.found)return this;let e=this.docs,t=e[0][0];t.pre=t.pre.trimStart();let n=e[e.length-1],r=n[n.length-1];return r.post=r.post.trimEnd(),this},hyphenate:function(){return this.docs.forEach((e=>{e.forEach(((t,n)=>{0!==n&&(t.pre=""),e[n+1]&&(t.post="-")}))})),this},dehyphenate:function(){const e=/[-–—]/;return this.docs.forEach((t=>{t.forEach((t=>{e.test(t.post)&&(t.post=" ")}))})),this},toQuotations:function(e,t){return e=e||'"',t=t||'"',this.docs.forEach((n=>{n[0].pre=e+n[0].pre;let r=n[n.length-1];r.post=t+r.post})),this},toParentheses:function(e,t){return e=e||"(",t=t||")",this.docs.forEach((n=>{n[0].pre=e+n[0].pre;let r=n[n.length-1];r.post=t+r.post})),this}};G.deHyphenate=G.dehyphenate,G.toQuotation=G.toQuotations;var O={alpha:(e,t)=>e.normal<t.normal?-1:e.normal>t.normal?1:0,length:(e,t)=>{let n=e.normal.trim().length,r=t.normal.trim().length;return n<r?1:n>r?-1:0},wordCount:(e,t)=>e.words<t.words?1:e.words>t.words?-1:0,sequential:(e,t)=>e[0]<t[0]?1:e[0]>t[0]?-1:e[1]>t[1]?1:-1,byFreq:function(e){let t={};return e.forEach((e=>{t[e.normal]=t[e.normal]||0,t[e.normal]+=1})),e.sort(((e,n)=>{let r=t[e.normal],a=t[n.normal];return r<a?1:r>a?-1:0})),e}};const F=new Set(["index","sequence","seq","sequential","chron","chronological"]),V=new Set(["freq","frequency","topk","repeats"]),z=new Set(["alpha","alphabetical"]);var B={unique:function(){let e=new Set,t=this.filter((t=>{let n=t.text("machine");return!e.has(n)&&(e.add(n),!0)}));return t},reverse:function(){let e=this.pointer||this.docs.map(((e,t)=>[t]));return e=[].concat(e),e=e.reverse(),this._cache&&(this._cache=this._cache.reverse()),this.update(e)},sort:function(e){let{docs:t,pointer:n}=this;if(this.uncache(),"function"==typeof e)return function(e,t){let n=e.fullPointer;return n=n.sort(((n,r)=>(n=e.update([n]),r=e.update([r]),t(n,r)))),e.ptrs=n,e}(this,e);e=e||"alpha";let r=n||t.map(((e,t)=>[t])),a=t.map(((e,t)=>({index:t,words:e.length,normal:e.map((e=>e.machine||e.normal||"")).join(" "),pointer:r[t]})));return F.has(e)&&(e="sequential"),z.has(e)&&(e="alpha"),V.has(e)?(a=O.byFreq(a),this.update(a.map((e=>e.pointer)))):"function"==typeof O[e]?(a=a.sort(O[e]),this.update(a.map((e=>e.pointer)))):this}};const S=function(e,t){if(e.length>0){let t=e[e.length-1],n=t[t.length-1];!1===/ /.test(n.post)&&(n.post+=" ")}return e=e.concat(t)};var $={concat:function(e){if("string"==typeof e){let t=this.fromText(e);if(this.found&&this.ptrs){let e=this.fullPointer,n=e[e.length-1][0];this.document.splice(n,0,...t.document)}else this.document=this.document.concat(t.document);return this.all().compute("index")}if("object"==typeof e&&e.isView)return function(e,t){if(e.document===t.document){let n=e.fullPointer.concat(t.fullPointer);return e.toView(n).compute("index")}return t.fullPointer.forEach((t=>{t[0]+=e.document.length})),e.document=S(e.document,t.docs),e.all()}(this,e);if(t=e,"[object Array]"===Object.prototype.toString.call(t)){let t=S(this.document,e);return this.document=t,this.all()}var t;return this}};var M={harden:function(){return this.ptrs=this.fullPointer,this},soften:function(){let e=this.ptrs;return!e||e.length<1||(e=e.map((e=>e.slice(0,3))),this.ptrs=e),this}};const L=Object.assign({},{toLowerCase:function(){return this.termList().forEach((e=>{e.text=e.text.toLowerCase()})),this},toUpperCase:function(){return this.termList().forEach((e=>{e.text=e.text.toUpperCase()})),this},toTitleCase:function(){return this.termList().forEach((e=>{e.text=e.text.replace(/^ *[a-z\u00C0-\u00FF]/,(e=>e.toUpperCase()))})),this},toCamelCase:function(){return this.docs.forEach((e=>{e.forEach(((t,n)=>{0!==n&&(t.text=t.text.replace(/^ *[a-z\u00C0-\u00FF]/,(e=>e.toUpperCase()))),n!==e.length-1&&(t.post="")}))})),this}},x,T,E,G,B,$,M),K={id:function(e){let t=e.docs;for(let e=0;e<t.length;e+=1)for(let n=0;n<t[e].length;n+=1){let r=t[e][n];r.id=r.id||A(r)}}};var J={api:function(e){Object.assign(e.prototype,L)},compute:K};const W=!0;var q={one:{contractions:[{word:"@",out:["at"]},{word:"arent",out:["are","not"]},{word:"alot",out:["a","lot"]},{word:"brb",out:["be","right","back"]},{word:"cannot",out:["can","not"]},{word:"dun",out:["do","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:"dunno",out:["do","not","know"]},{word:"gonna",out:["going","to"]},{word:"gotta",out:["have","got","to"]},{word:"gimme",out:["give","me"]},{word:"outta",out:["out","of"]},{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:"shoulda",out:["should","have"]},{word:"coulda",out:["coulda","have"]},{word:"woulda",out:["woulda","have"]},{word:"musta",out:["must","have"]},{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"]},{word:"shouldnt",out:["should","not"]},{word:"couldnt",out:["could","not"]},{word:"wouldnt",out:["would","not"]},{word:"hasnt",out:["has","not"]},{word:"wasnt",out:["was","not"]},{word:"isnt",out:["is","not"]},{word:"cant",out:["can","not"]},{word:"dont",out:["do","not"]},{word:"wont",out:["will","not"]},{word:"howd",out:["how","did"]},{word:"whatd",out:["what","did"]},{word:"whend",out:["when","did"]},{word:"whered",out:["where","did"]}],numberSuffixes:{st:W,nd:W,rd:W,th:W,am:W,pm:W,max:W,"°":W,s:W,e:W,er:W,"ère":W,"ème":W}}};const U=function(e,t,n){let[r,a]=t;n&&0!==n.length&&(n=n.map(((e,t)=>(e.implicit=e.text,e.machine=e.text,e.pre="",e.post="",e.text="",e.normal="",e.index=[r,a+t],e))),n[0]&&(n[0].pre=e[r][a].pre,n[n.length-1].post=e[r][a].post,n[0].text=e[r][a].text,n[0].normal=e[r][a].normal),e[r].splice(a,1,...n))},R=/'/,Q=new Set(["what","how","when","where","why"]),Z=new Set(["be","go","start","think","need"]),_=new Set(["been","gone"]),X=/'/,Y=/(e|é|aison|sion|tion)$/,ee=/(age|isme|acle|ege|oire)$/;var te=(e,t)=>["je",e[t].normal.split(X)[1]],ne=(e,t)=>{let n=e[t].normal.split(X)[1];return n&&n.endsWith("e")?["la",n]:["le",n]},re=(e,t)=>{let n=e[t].normal.split(X)[1];return n&&Y.test(n)&&!ee.test(n)?["du",n]:n&&n.endsWith("s")?["des",n]:["de",n]};const ae=/^([0-9.]{1,4}[a-z]{0,2}) ?[-–—] ?([0-9]{1,4}[a-z]{0,2})$/i,oe=/^([0-9]{1,2}(:[0-9][0-9])?(am|pm)?) ?[-–—] ?([0-9]{1,2}(:[0-9][0-9])?(am|pm)?)$/i,ie=/^[0-9]{3}-[0-9]{4}$/,se=function(e,t){let n=e[t],r=n.text.match(ae);return null!==r?!0===n.tags.has("PhoneNumber")||ie.test(n.text)?null:[r[1],"to",r[2]]:(r=n.text.match(oe),null!==r?[r[1],"to",r[4]]:null)},le=/^([+-]?[0-9][.,0-9]*)([a-z°²³µ/]+)$/,ue=function(e,t,n){const r=n.model.one.numberSuffixes||{};let a=e[t].text.match(le);if(null!==a){let e=a[2].toLowerCase().trim();return r.hasOwnProperty(e)?null:[a[1],e]}return null},ce=/'/,he=/^[0-9][^-–—]*[-–—].*?[0-9]/,de=function(e,t,n,r){let a=t.update();a.document=[e];let o=n+r;n>0&&(n-=1),e[o]&&(o+=1),a.ptrs=[[0,n,o]]},ge={t:(e,t)=>function(e,t){return"ain't"===e[t].normal||"aint"===e[t].normal?null:[e[t].normal.replace(/n't/,""),"not"]}(e,t),d:(e,t)=>function(e,t){let n=e[t].normal.split(R)[0];if(Q.has(n))return[n,"did"];if(e[t+1]){if(_.has(e[t+1].normal))return[n,"had"];if(Z.has(e[t+1].normal))return[n,"would"]}return null}(e,t)},me={j:(e,t)=>te(e,t),l:(e,t)=>ne(e,t),d:(e,t)=>re(e,t)},pe=function(e,t,n,r){for(let a=0;a<e.length;a+=1){let o=e[a];if(o.word===t.normal)return o.out;if(null!==r&&r===o.after)return[n].concat(o.out);if(null!==n&&n===o.before&&r&&r.length>2)return o.out.concat(r)}return null},fe=function(e,t){let n=t.fromText(e.join(" "));return n.compute(["id","alias"]),n.docs[0]},be=function(e,t){for(let n=t+1;n<5&&e[n];n+=1)if("been"===e[n].normal)return["there","has"];return["there","is"]};var ve={contractions:e=>{let{world:t,document:n}=e;const{model:r,methods:a}=t;let o=r.one.contractions||[];n.forEach(((r,i)=>{for(let s=r.length-1;s>=0;s-=1){let l=null,u=null;if(!0===ce.test(r[s].normal)){let e=r[s].normal.split(ce);l=e[0],u=e[1]}let c=pe(o,r[s],l,u);!c&&ge.hasOwnProperty(u)&&(c=ge[u](r,s,t)),!c&&me.hasOwnProperty(l)&&(c=me[l](r,s)),"there"===l&&"s"===u&&(c=be(r,s)),c?(c=fe(c,e),U(n,[i,s],c),de(n[i],e,s,c.length)):he.test(r[s].normal)?(c=se(r,s),c&&(c=fe(c,e),U(n,[i,s],c),a.one.setTag(c,"NumberRange",t),c[2]&&c[2].tags.has("Time")&&a.one.setTag([c[0]],"Time",t,null,"time-range"),de(n[i],e,s,c.length))):(c=ue(r,s,t),c&&(c=fe(c,e),U(n,[i,s],c),a.one.setTag([c[1]],"Unit",t,null,"contraction-unit")))}}))}};const ye={model:q,compute:ve,hooks:["contractions"]},we=function(e){const t=e.world,{model:n,methods:r}=e.world,a=r.one.setTag,{frozenLex:o}=n.one,i=n.one._multiCache||{};e.docs.forEach((e=>{for(let n=0;n<e.length;n+=1){let r=e[n],s=r.machine||r.normal;if(void 0!==i[s]&&e[n+1]){for(let r=n+i[s]-1;r>n;r-=1){let i=e.slice(n,r+1),s=i.map((e=>e.machine||e.normal)).join(" ");!0!==o.hasOwnProperty(s)||(a(i,o[s],t,!1,"1-frozen-multi-lexicon"),i.forEach((e=>e.frozen=!0)))}}void 0!==o[s]&&o.hasOwnProperty(s)&&(a([r],o[s],t,!1,"1-freeze-lexicon"),r.frozen=!0)}}))};const ke=e=>""+e+"",Pe=e=>""+e+"",Ae=function(e){e.docs.forEach((e=>{console.log(ke("\n ┌─────────")),e.forEach((e=>{let t=` ${Pe("│")} `,n=e.implicit||e.text||"-";!0===e.frozen?t+=`${ke(n)} ❄️`:t+=Pe(n),console.log(t)}))}))};var Ce={compute:{frozen:we,freeze:we,unfreeze:function(e){return e.docs.forEach((e=>{e.forEach((e=>{delete e.frozen}))})),e}},mutate:e=>{const t=e.methods.one;t.termMethods.isFrozen=e=>!0===e.frozen,t.debug.freeze=Ae,t.debug.frozen=Ae},api:function(e){e.prototype.freeze=function(){return this.docs.forEach((e=>{e.forEach((e=>{e.frozen=!0}))})),this},e.prototype.unfreeze=function(){this.compute("unfreeze")},e.prototype.isFrozen=function(){return this.match("@isFrozen+")}},hooks:["freeze"]};const Ne=function(e,t,n){const{model:r,methods:a}=n,o=a.one.setTag,i=r.one._multiCache||{},{lexicon:s}=r.one||{};let l=e[t],u=l.machine||l.normal;if(void 0!==i[u]&&e[t+1]){for(let r=t+i[u]-1;r>t;r-=1){let a=e.slice(t,r+1);if(a.length<=1)return!1;let i=a.map((e=>e.machine||e.normal)).join(" ");if(!0===s.hasOwnProperty(i)){let e=s[i];return o(a,e,n,!1,"1-multi-lexicon"),!e||2!==e.length||"PhrasalVerb"!==e[0]&&"PhrasalVerb"!==e[1]||o([a[1]],"Particle",n,!1,"1-phrasal-particle"),!0}}return!1}return null},je=/^(under|over|mis|re|un|dis|semi|pre|post)-?/,xe=new Set(["Verb","Infinitive","PastTense","Gerund","PresentTense","Adjective","Participle"]),Ie=function(e,t,n){const{model:r,methods:a}=n,o=a.one.setTag,{lexicon:i}=r.one;let s=e[t],l=s.machine||s.normal;if(void 0!==i[l]&&i.hasOwnProperty(l))return o([s],i[l],n,!1,"1-lexicon"),!0;if(s.alias){let e=s.alias.find((e=>i.hasOwnProperty(e)));if(e)return o([s],i[e],n,!1,"1-lexicon-alias"),!0}if(!0===je.test(l)){let e=l.replace(je,"");if(i.hasOwnProperty(e)&&e.length>3&&xe.has(i[e]))return o([s],i[e],n,!1,"1-lexicon-prefix"),!0}return null};var Te={lexicon:function(e){const t=e.world;e.docs.forEach((e=>{for(let n=0;n<e.length;n+=1)if(0===e[n].tags.size){let r=null;r=r||Ne(e,n,t),r=r||Ie(e,n,t)}}))}};var De={one:{expandLexicon:function(e){let t={},n={};return Object.keys(e).forEach((r=>{let a=e[r],o=(r=(r=r.toLowerCase().trim()).replace(/'s\b/,"")).split(/ /);o.length>1&&(void 0===n[o[0]]||o.length>n[o[0]])&&(n[o[0]]=o.length),t[r]=t[r]||a})),delete t[""],delete t.null,delete t[" "],{lex:t,_multi:n}}}};var He={addWords:function(e,t=!1){const n=this.world(),{methods:r,model:a}=n;if(!e)return;if(Object.keys(e).forEach((t=>{"string"==typeof e[t]&&e[t].startsWith("#")&&(e[t]=e[t].replace(/^#/,""))})),!0===t){let{lex:t,_multi:o}=r.one.expandLexicon(e,n);return Object.assign(a.one._multiCache,o),void Object.assign(a.one.frozenLex,t)}if(r.two.expandLexicon){let{lex:t,_multi:o}=r.two.expandLexicon(e,n);Object.assign(a.one.lexicon,t),Object.assign(a.one._multiCache,o)}let{lex:o,_multi:i}=r.one.expandLexicon(e,n);Object.assign(a.one.lexicon,o),Object.assign(a.one._multiCache,i)}};var Ee={model:{one:{lexicon:{},_multiCache:{},frozenLex:{}}},methods:De,compute:Te,lib:He,hooks:["lexicon"]};const Ge=function(e,t){let n=[{}],r=[null],a=[0],o=[],i=0;e.forEach((function(e){let a=0,o=function(e,t){const{methods:n,model:r}=t;let a=n.one.tokenize.splitTerms(e,r).map((e=>n.one.tokenize.splitWhitespace(e,r)));return a.map((e=>e.text.toLowerCase()))}(e,t);for(let e=0;e<o.length;e++){let t=o[e];n[a]&&n[a].hasOwnProperty(t)?a=n[a][t]:(i++,n[a][t]=i,n[i]={},a=i,r[i]=null)}r[a]=[o.length]}));for(let e in n[0])i=n[0][e],a[i]=0,o.push(i);for(;o.length;){let e=o.shift(),t=Object.keys(n[e]);for(let s=0;s<t.length;s+=1){let l=t[s],u=n[e][l];for(o.push(u),i=a[e];i>0&&!n[i].hasOwnProperty(l);)i=a[i];if(n.hasOwnProperty(i)){let e=n[i][l];a[u]=e,r[e]&&(r[u]=r[u]||[],r[u]=r[u].concat(r[e]))}else a[u]=0}}return{goNext:n,endAs:r,failTo:a}},Oe=function(e,t,n){let r=0,a=[];for(let o=0;o<e.length;o++){let i=e[o][n.form]||e[o].normal;for(;r>0&&(void 0===t.goNext[r]||!t.goNext[r].hasOwnProperty(i));)r=t.failTo[r]||0;if(t.goNext[r].hasOwnProperty(i)&&(r=t.goNext[r][i],t.endAs[r])){let n=t.endAs[r];for(let t=0;t<n.length;t++){let r=n[t],i=e[o-r+1],[s,l]=i.index;a.push([s,l,l+r,i.id])}}}return a},Fe=function(e,t){for(let n=0;n<e.length;n+=1)if(!0===t.has(e[n]))return!1;return!0};const Ve=(e,t)=>{for(let n=e.length-1;n>=0;n-=1)if(e[n]!==t)return e=e.slice(0,n+1);return e},ze={buildTrie:function(e){return function(e){return e.goNext=e.goNext.map((e=>{if(0!==Object.keys(e).length)return e})),e.goNext=Ve(e.goNext,void 0),e.failTo=Ve(e.failTo,0),e.endAs=Ve(e.endAs,null),e}(Ge(e,this.world()))}};ze.compile=ze.buildTrie;var Be={api:function(e){e.prototype.lookup=function(e,t={}){if(!e)return this.none();var n;"string"==typeof e&&(e=[e]);let r=function(e,t,n){let r=[];n.form=n.form||"normal";let a=e.docs;if(!t.goNext||!t.goNext[0])return console.error("Compromise invalid lookup trie"),e.none();let o=Object.keys(t.goNext[0]);for(let i=0;i<a.length;i++){if(e._cache&&e._cache[i]&&!0===Fe(o,e._cache[i]))continue;let s=a[i],l=Oe(s,t,n);l.length>0&&(r=r.concat(l))}return e.update(r)}(this,(n=e,"[object Object]"===Object.prototype.toString.call(n)?e:Ge(e,this.world)),t);return r=r.settle(),r}},lib:ze};const Se=function(e,t){return t?(e.forEach((e=>{let n=e[0];t[n]&&(e[0]=t[n][0],e[1]+=t[n][1],e[2]+=t[n][1])})),e):e},$e=function(e,t){let{ptrs:n,byGroup:r}=e;return n=Se(n,t),Object.keys(r).forEach((e=>{r[e]=Se(r[e],t)})),{ptrs:n,byGroup:r}},Me=function(e,t,n){const r=n.methods.one;return"number"==typeof e&&(e=String(e)),"string"==typeof e&&(e=r.killUnicode(e,n),e=r.parseMatch(e,t,n)),e},Le=e=>"[object Object]"===Object.prototype.toString.call(e),Ke=e=>e&&Le(e)&&!0===e.isView,Je=e=>e&&Le(e)&&!0===e.isNet;var We={matchOne:function(e,t,n){const r=this.methods.one;if(Ke(e))return this.intersection(e).eq(0);if(Je(e))return this.sweep(e,{tagger:!1,matchOne:!0}).view;let a={regs:e=Me(e,n,this.world),group:t,justOne:!0},o=r.match(this.docs,a,this._cache),{ptrs:i,byGroup:s}=$e(o,this.fullPointer),l=this.toView(i);return l._groups=s,l},match:function(e,t,n){const r=this.methods.one;if(Ke(e))return this.intersection(e);if(Je(e))return this.sweep(e,{tagger:!1}).view.settle();let a={regs:e=Me(e,n,this.world),group:t},o=r.match(this.docs,a,this._cache),{ptrs:i,byGroup:s}=$e(o,this.fullPointer),l=this.toView(i);return l._groups=s,l},has:function(e,t,n){const r=this.methods.one;if(Ke(e)){return this.intersection(e).fullPointer.length>0}if(Je(e))return this.sweep(e,{tagger:!1}).view.found;let a={regs:e=Me(e,n,this.world),group:t,justOne:!0};return r.match(this.docs,a,this._cache).ptrs.length>0},if:function(e,t,n){const r=this.methods.one;if(Ke(e))return this.filter((t=>t.intersection(e).found));if(Je(e)){let t=this.sweep(e,{tagger:!1}).view.settle();return this.if(t)}let a={regs:e=Me(e,n,this.world),group:t,justOne:!0},o=this.fullPointer,i=this._cache||[];o=o.filter(((e,t)=>{let n=this.update([e]);return r.match(n.docs,a,i[t]).ptrs.length>0}));let s=this.update(o);return this._cache&&(s._cache=o.map((e=>i[e[0]]))),s},ifNo:function(e,t,n){const{methods:r}=this,a=r.one;if(Ke(e))return this.filter((t=>!t.intersection(e).found));if(Je(e)){let t=this.sweep(e,{tagger:!1}).view.settle();return this.ifNo(t)}e=Me(e,n,this.world);let o=this._cache||[],i=this.filter(((n,r)=>{let i={regs:e,group:t,justOne:!0};return 0===a.match(n.docs,i,o[r]).ptrs.length}));return this._cache&&(i._cache=i.ptrs.map((e=>o[e[0]]))),i}};var qe={before:function(e,t,n){const{indexN:r}=this.methods.one.pointer;let a=[],o=r(this.fullPointer);Object.keys(o).forEach((e=>{let t=o[e].sort(((e,t)=>e[1]>t[1]?1:-1))[0];t[1]>0&&a.push([t[0],0,t[1]])}));let i=this.toView(a);return e?i.match(e,t,n):i},after:function(e,t,n){const{indexN:r}=this.methods.one.pointer;let a=[],o=r(this.fullPointer),i=this.document;Object.keys(o).forEach((e=>{let t=o[e].sort(((e,t)=>e[1]>t[1]?-1:1))[0],[n,,r]=t;r<i[n].length&&a.push([n,r,i[n].length])}));let s=this.toView(a);return e?s.match(e,t,n):s},growLeft:function(e,t,n){"string"==typeof e&&(e=this.world.methods.one.parseMatch(e,n,this.world)),e[e.length-1].end=!0;let r=this.fullPointer;return this.forEach(((n,a)=>{let o=n.before(e,t);if(o.found){let e=o.terms();r[a][1]-=e.length,r[a][3]=e.docs[0][0].id}})),this.update(r)},growRight:function(e,t,n){"string"==typeof e&&(e=this.world.methods.one.parseMatch(e,n,this.world)),e[0].start=!0;let r=this.fullPointer;return this.forEach(((n,a)=>{let o=n.after(e,t);if(o.found){let e=o.terms();r[a][2]+=e.length,r[a][4]=null}})),this.update(r)},grow:function(e,t,n){return this.growRight(e,t,n).growLeft(e,t,n)}};const Ue=function(e,t){return[e[0],e[1],t[2]]},Re=(e,t,n)=>{return"string"==typeof e||(r=e,"[object Array]"===Object.prototype.toString.call(r))?t.match(e,n):e||t.none();var r},Qe=function(e,t){let[n,r,a]=e;return t.document[n]&&t.document[n][r]&&(e[3]=e[3]||t.document[n][r].id,t.document[n][a-1]&&(e[4]=e[4]||t.document[n][a-1].id)),e},Ze={splitOn:function(e,t){const{splitAll:n}=this.methods.one.pointer;let r=Re(e,this,t).fullPointer,a=n(this.fullPointer,r),o=[];return a.forEach((e=>{o.push(e.passthrough),o.push(e.before),o.push(e.match),o.push(e.after)})),o=o.filter((e=>e)),o=o.map((e=>Qe(e,this))),this.update(o)},splitBefore:function(e,t){const{splitAll:n}=this.methods.one.pointer;let r=Re(e,this,t).fullPointer,a=n(this.fullPointer,r);for(let e=0;e<a.length;e+=1)!a[e].after&&a[e+1]&&a[e+1].before&&a[e].match&&a[e].match[0]===a[e+1].before[0]&&(a[e].after=a[e+1].before,delete a[e+1].before);let o=[];return a.forEach((e=>{o.push(e.passthrough),o.push(e.before),e.match&&e.after?o.push(Ue(e.match,e.after)):o.push(e.match)})),o=o.filter((e=>e)),o=o.map((e=>Qe(e,this))),this.update(o)},splitAfter:function(e,t){const{splitAll:n}=this.methods.one.pointer;let r=Re(e,this,t).fullPointer,a=n(this.fullPointer,r),o=[];return a.forEach((e=>{o.push(e.passthrough),e.before&&e.match?o.push(Ue(e.before,e.match)):(o.push(e.before),o.push(e.match)),o.push(e.after)})),o=o.filter((e=>e)),o=o.map((e=>Qe(e,this))),this.update(o)}};Ze.split=Ze.splitAfter;const _e=function(e,t){return!(!e||!t)&&(e[0]===t[0]&&e[2]===t[1])},Xe=function(e,t,n){const r=e.world,a=r.methods.one.parseMatch;n=n||"^.";let o=a(t=t||".$",{},r),i=a(n,{},r);o[o.length-1].end=!0,i[0].start=!0;let s=e.fullPointer,l=[s[0]];for(let t=1;t<s.length;t+=1){let n=l[l.length-1],r=s[t],a=e.update([n]),u=e.update([r]);_e(n,r)&&a.has(o)&&u.has(i)?l[l.length-1]=[n[0],n[1],r[2],n[3],r[4]]:l.push(r)}return e.update(l)},Ye={joinIf:function(e,t){return Xe(this,e,t)},join:function(){return Xe(this)}},et=Object.assign({},We,qe,Ze,Ye);et.lookBehind=et.before,et.lookBefore=et.before,et.lookAhead=et.after,et.lookAfter=et.after,et.notIf=et.ifNo;const tt=/(?:^|\s)([![^]*(?:<[^<]*>)?\/.*?[^\\/]\/[?\]+*$~]*)(?:\s|$)/,nt=/([!~[^]*(?:<[^<]*>)?\([^)]+[^\\)]\)[?\]+*$~]*)(?:\s|$)/,rt=/ /g,at=e=>/^[![^]*(<[^<]*>)?\//.test(e)&&/\/[?\]+*$~]*$/.test(e),ot=function(e){return e=(e=e.map((e=>e.trim()))).filter((e=>e))},it=/\{([0-9]+)?(, *[0-9]*)?\}/,st=/&&/,lt=new RegExp(/^<\s*(\S+)\s*>/),ut=e=>e.charAt(0).toUpperCase()+e.substring(1),ct=e=>e.charAt(e.length-1),ht=e=>e.charAt(0),dt=e=>e.substring(1),gt=e=>e.substring(0,e.length-1),mt=function(e){return e=dt(e),e=gt(e)},pt=function(e,t){let n={};for(let r=0;r<2;r+=1){if("$"===ct(e)&&(n.end=!0,e=gt(e)),"^"===ht(e)&&(n.start=!0,e=dt(e)),"?"===ct(e)&&(n.optional=!0,e=gt(e)),("["===ht(e)||"]"===ct(e))&&(n.group=null,"["===ht(e)&&(n.groupStart=!0),"]"===ct(e)&&(n.groupEnd=!0),e=(e=e.replace(/^\[/,"")).replace(/\]$/,""),"<"===ht(e))){const t=lt.exec(e);t.length>=2&&(n.group=t[1],e=e.replace(t[0],""))}if("+"===ct(e)&&(n.greedy=!0,e=gt(e)),"*"!==e&&"*"===ct(e)&&"\\*"!==e&&(n.greedy=!0,e=gt(e)),"!"===ht(e)&&(n.negative=!0,e=dt(e)),"~"===ht(e)&&"~"===ct(e)&&e.length>2&&(e=mt(e),n.fuzzy=!0,n.min=t.fuzzy||.85,!1===/\(/.test(e)))return n.word=e,n;if("/"===ht(e)&&"/"===ct(e))return e=mt(e),t.caseSensitive&&(n.use="text"),n.regex=new RegExp(e),n;if(!0===it.test(e)&&(e=e.replace(it,((e,t,r)=>(void 0===r?(n.min=Number(t),n.max=Number(t)):(r=r.replace(/, */,""),void 0===t?(n.min=0,n.max=Number(r)):(n.min=Number(t),n.max=Number(r||999))),n.greedy=!0,n.min||(n.optional=!0),"")))),"("===ht(e)&&")"===ct(e)){st.test(e)?(n.choices=e.split(st),n.operator="and"):(n.choices=e.split("|"),n.operator="or"),n.choices[0]=dt(n.choices[0]);let r=n.choices.length-1;n.choices[r]=gt(n.choices[r]),n.choices=n.choices.map((e=>e.trim())),n.choices=n.choices.filter((e=>e)),n.choices=n.choices.map((e=>e.split(/ /g).map((e=>pt(e,t))))),e=""}if("{"===ht(e)&&"}"===ct(e)){if(e=mt(e),n.root=e,/\//.test(e)){let e=n.root.split(/\//);n.root=e[0],n.pos=e[1],"adj"===n.pos&&(n.pos="Adjective"),n.pos=n.pos.charAt(0).toUpperCase()+n.pos.substr(1).toLowerCase(),void 0!==e[2]&&(n.sense=e[2])}return n}if("<"===ht(e)&&">"===ct(e))return e=mt(e),n.chunk=ut(e),n.greedy=!0,n;if("%"===ht(e)&&"%"===ct(e))return e=mt(e),n.switch=e,n}return"#"===ht(e)?(n.tag=dt(e),n.tag=ut(n.tag),n):"@"===ht(e)?(n.method=dt(e),n):"."===e?(n.anything=!0,n):"*"===e?(n.anything=!0,n.greedy=!0,n.optional=!0,n):(e&&(e=(e=e.replace("\\*","*")).replace("\\.","."),t.caseSensitive?n.use="text":e=e.toLowerCase(),n.word=e),n)},ft=/[a-z0-9][-–—][a-z]/i,bt=function(e,t){let{all:n}=t.methods.two.transform.verb||{},r=e.root;return n?n(r,t.model):[]},vt=function(e,t){let{all:n}=t.methods.two.transform.noun||{};return n?n(e.root,t.model):[e.root]},yt=function(e,t){let{all:n}=t.methods.two.transform.adjective||{};return n?n(e.root,t.model):[e.root]},wt=function(e){return e=function(e){let t=0,n=null;for(let r=0;r<e.length;r++){const a=e[r];!0===a.groupStart&&(n=a.group,null===n&&(n=String(t),t+=1)),null!==n&&(a.group=n),!0===a.groupEnd&&(n=null)}return e}(e),e=function(e){return e.map((e=>(e.fuzzy&&e.choices&&e.choices.forEach((t=>{1===t.length&&t[0].word&&(t[0].fuzzy=!0,t[0].min=e.min)})),e)))}(e=e.map((e=>{if(void 0!==e.choices){if("or"!==e.operator)return e;if(!0===e.fuzzy)return e;!0===e.choices.every((e=>{if(1!==e.length)return!1;let t=e[0];return!0!==t.fuzzy&&!t.start&&!t.end&&void 0!==t.word&&!0!==t.negative&&!0!==t.optional&&!0!==t.method}))&&(e.fastOr=new Set,e.choices.forEach((t=>{e.fastOr.add(t[0].word)})),delete e.choices)}return e}))),e},kt=function(e,t){for(let n of t)if(e.has(n))return!0;return!1},Pt=function(e,t){for(let n=0;n<e.length;n+=1){let r=e[n];if(!0!==r.optional&&!0!==r.negative&&!0!==r.fuzzy){if(void 0!==r.word&&!1===t.has(r.word))return!0;if(void 0!==r.tag&&!1===t.has("#"+r.tag))return!0;if(r.fastOr&&!1===kt(r.fastOr,t))return!1}}return!1},At=function(e,t,n=3){if(e===t)return 1;if(e.length<n||t.length<n)return 0;const r=function(e,t){let n=e.length,r=t.length;if(0===n)return r;if(0===r)return n;let a=(r>n?r:n)+1;if(Math.abs(n-r)>(a||100))return a||100;let o,i,s,l,u,c,h=[];for(let e=0;e<a;e++)h[e]=[e],h[e].length=a;for(let e=0;e<a;e++)h[0][e]=e;for(let a=1;a<=n;++a)for(i=e[a-1],o=1;o<=r;++o){if(a===o&&h[a][o]>4)return n;s=t[o-1],l=i===s?0:1,u=h[a-1][o]+1,(c=h[a][o-1]+1)<u&&(u=c),(c=h[a-1][o-1]+l)<u&&(u=c);let r=a>1&&o>1&&i===t[o-2]&&e[a-2]===s&&(c=h[a-2][o-2]+l)<u;h[a][o]=r?c:u}return h[n][r]}(e,t);let a=Math.max(e.length,t.length);return 1-(0===a?0:r/a)},Ct=/([\u0022\uFF02\u0027\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F])/,Nt=/([\u0022\uFF02\u0027\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4])/,jt=/^[-–—]$/,xt=/ [-–—]{1,3} /,It=(e,t)=>-1!==e.post.indexOf(t),Tt={hasQuote:e=>Ct.test(e.pre)||Nt.test(e.post),hasComma:e=>It(e,","),hasPeriod:e=>!0===It(e,".")&&!1===It(e,"..."),hasExclamation:e=>It(e,"!"),hasQuestionMark:e=>It(e,"?")||It(e,"¿"),hasEllipses:e=>It(e,"..")||It(e,"…"),hasSemicolon:e=>It(e,";"),hasColon:e=>It(e,":"),hasSlash:e=>/\//.test(e.text),hasHyphen:e=>jt.test(e.post)||jt.test(e.pre),hasDash:e=>xt.test(e.post)||xt.test(e.pre),hasContraction:e=>Boolean(e.implicit),isAcronym:e=>e.tags.has("Acronym"),isKnown:e=>e.tags.size>0,isTitleCase:e=>/^\p{Lu}[a-z'\u00C0-\u00FF]/u.test(e.text),isUpperCase:e=>/^\p{Lu}+$/u.test(e.text)};Tt.hasQuotation=Tt.hasQuote;let Dt=function(){};Dt=function(e,t,n,r){let a=function(e,t,n,r){if(!0===t.anything)return!0;if(!0===t.start&&0!==n)return!1;if(!0===t.end&&n!==r-1)return!1;if(void 0!==t.id&&t.id===e.id)return!0;if(void 0!==t.word){if(t.use)return t.word===e[t.use];if(null!==e.machine&&e.machine===t.word)return!0;if(void 0!==e.alias&&e.alias.hasOwnProperty(t.word))return!0;if(!0===t.fuzzy){if(t.word===e.root)return!0;if(At(t.word,e.normal)>=t.min)return!0}return!(!e.alias||!e.alias.some((e=>e===t.word)))||t.word===e.text||t.word===e.normal}if(void 0!==t.tag)return!0===e.tags.has(t.tag);if(void 0!==t.method)return"function"==typeof Tt[t.method]&&!0===Tt[t.method](e);if(void 0!==t.pre)return e.pre&&e.pre.includes(t.pre);if(void 0!==t.post)return e.post&&e.post.includes(t.post);if(void 0!==t.regex){let n=e.normal;return t.use&&(n=e[t.use]),t.regex.test(n)}if(void 0!==t.chunk)return e.chunk===t.chunk;if(void 0!==t.switch)return e.switch===t.switch;if(void 0!==t.machine)return e.normal===t.machine||e.machine===t.machine||e.root===t.machine;if(void 0!==t.sense)return e.sense===t.sense;if(void 0!==t.fastOr){if(t.pos&&!e.tags.has(t.pos))return null;let n=e.root||e.implicit||e.machine||e.normal;return t.fastOr.has(n)||t.fastOr.has(e.text)}return void 0!==t.choices&&("and"===t.operator?t.choices.every((t=>Dt(e,t,n,r))):t.choices.some((t=>Dt(e,t,n,r))))}(e,t,n,r);return!0===t.negative?!a:a};const Ht=function(e,t){if(!0===e.end&&!0===e.greedy&&t.start_i+t.t<t.phrase_length-1){let n=Object.assign({},e,{end:!1});if(!0===Dt(t.terms[t.t],n,t.start_i+t.t,t.phrase_length))return!0}return!1},Et=function(e,t){return e.groups[e.inGroup]||(e.groups[e.inGroup]={start:t,length:0}),e.groups[e.inGroup]},Gt=function(e){let{regs:t}=e,n=t[e.r],r=function(e,t){let n=e.t;if(!t)return e.terms.length;for(;n<e.terms.length;n+=1)if(!0===Dt(e.terms[n],t,e.start_i+n,e.phrase_length))return n;return null}(e,t[e.r+1]);if(null===r||0===r)return null;if(void 0!==n.min&&r-e.t<n.min)return null;if(void 0!==n.max&&r-e.t>n.max)return e.t=e.t+n.max,!0;if(!0===e.hasGroup){Et(e,e.t).length=r-e.t}return e.t=r,!0},Ot=function(e,t=0){let n=e.regs[e.r],r=!1;for(let o=0;o<n.choices.length;o+=1){let i=n.choices[o];if(a=i,"[object Array]"!==Object.prototype.toString.call(a))return!1;if(r=i.every(((n,r)=>{let a=0,o=e.t+r+t+a;if(void 0===e.terms[o])return!1;let i=Dt(e.terms[o],n,o+e.start_i,e.phrase_length);if(!0===i&&!0===n.greedy)for(let t=1;t<e.terms.length;t+=1){let r=e.terms[o+t];if(r){if(!0!==Dt(r,n,e.start_i+t,e.phrase_length))break;a+=1}}return t+=a,i})),r){t+=i.length;break}}var a;return r&&!0===n.greedy?Ot(e,t):t},Ft=function(e){const{regs:t}=e;let n=t[e.r],r=Ot(e);if(r){if(!0===n.negative)return null;if(!0===e.hasGroup){Et(e,e.t).length+=r}if(!0===n.end){let t=e.phrase_length;if(e.t+e.start_i+r!==t)return null}return e.t+=r,!0}return!!n.optional||null},Vt=function(e){const{regs:t}=e;let n=t[e.r],r=function(e){let t=0;return!0===e.regs[e.r].choices.every((n=>{let r=n.every(((t,n)=>{let r=e.t+n;return void 0!==e.terms[r]&&Dt(e.terms[r],t,r,e.phrase_length)}));return!0===r&&n.length>t&&(t=n.length),r}))&&t}(e);if(r){if(!0===n.negative)return null;if(!0===e.hasGroup){Et(e,e.t).length+=r}if(!0===n.end){let t=e.phrase_length-1;if(e.t+e.start_i!==t)return null}return e.t+=r,!0}return!!n.optional||null},zt=function(e){const{regs:t}=e;let n=t[e.r],r=Object.assign({},n);if(r.negative=!1,Dt(e.terms[e.t],r,e.start_i+e.t,e.phrase_length))return!1;if(n.optional){let n=t[e.r+1];if(n){if(Dt(e.terms[e.t],n,e.start_i+e.t,e.phrase_length))e.r+=1;else if(n.optional&&t[e.r+2]){Dt(e.terms[e.t],t[e.r+2],e.start_i+e.t,e.phrase_length)&&(e.r+=2)}}}return n.greedy?function(e,t,n){let r=0;for(let a=e.t;a<e.terms.length;a+=1){let o=Dt(e.terms[a],t,e.start_i+e.t,e.phrase_length);if(o)break;if(n&&(o=Dt(e.terms[a],n,e.start_i+e.t,e.phrase_length),o))break;if(r+=1,void 0!==t.max&&r===t.max)break}return!(0===r||t.min&&t.min>r||(e.t+=r,0))}(e,r,t[e.r+1]):(e.t+=1,!0)},Bt=function(e){const{regs:t,phrase_length:n}=e;let r=t[e.r];return e.t=function(e,t){let n=Object.assign({},e.regs[e.r],{start:!1,end:!1}),r=e.t;for(;e.t<e.terms.length;e.t+=1){if(t&&Dt(e.terms[e.t],t,e.start_i+e.t,e.phrase_length))return e.t;let a=e.t-r+1;if(void 0!==n.max&&a===n.max)return e.t;if(!1===Dt(e.terms[e.t],n,e.start_i+e.t,e.phrase_length))return void 0!==n.min&&a<n.min?null:e.t}return e.t}(e,t[e.r+1]),null===e.t||r.min&&r.min>e.t?null:!0!==r.end||e.start_i+e.t===n||null},St=function(e){const{regs:t}=e;let n=t[e.r],r=e.terms[e.t],a=e.t;if(n.optional&&t[e.r+1]&&n.negative)return!0;if(n.optional&&t[e.r+1]&&function(e){const{regs:t}=e;let n=t[e.r],r=e.terms[e.t],a=Dt(r,t[e.r+1],e.start_i+e.t,e.phrase_length);if(n.negative||a){let n=e.terms[e.t+1];n&&Dt(n,t[e.r+1],e.start_i+e.t,e.phrase_length)||(e.r+=1)}}(e),r.implicit&&e.terms[e.t+1]&&function(e){let t=e.terms[e.t],n=e.regs[e.r];if(t.implicit&&e.terms[e.t+1]){if(!e.terms[e.t+1].implicit)return;n.word===t.normal&&(e.t+=1),"hasContraction"===n.method&&(e.t+=1)}}(e),e.t+=1,!0===n.end&&e.t!==e.terms.length&&!0!==n.greedy)return null;if(!0===n.greedy){if(!Bt(e))return null}return!0===e.hasGroup&&function(e,t){let n=e.regs[e.r];const r=Et(e,t);e.t>1&&n.greedy?r.length+=e.t-t:r.length++}(e,a),!0},$t=function(e,t,n,r){if(0===e.length||0===t.length)return null;let a={t:0,terms:e,r:0,regs:t,groups:{},start_i:n,phrase_length:r,inGroup:null};for(;a.r<t.length;a.r+=1){let e=t[a.r];if(a.hasGroup=Boolean(e.group),!0===a.hasGroup?a.inGroup=e.group:a.inGroup=null,!a.terms[a.t]){if(!1===t.slice(a.r).some((e=>!e.optional)))break;return null}if(!0!==e.anything||!0!==e.greedy)if(void 0===e.choices||"or"!==e.operator)if(void 0===e.choices||"and"!==e.operator)if(!0!==e.anything)if(!0!==Ht(e,a))if(e.negative){if(!zt(a))return null}else if(!0!==Dt(a.terms[a.t],e,a.start_i+a.t,a.phrase_length)){if(!0!==e.optional)return null}else{if(!St(a))return null}else{if(!St(a))return null}else{if(e.negative&&e.anything)return null;if(!St(a))return null}else{if(!Vt(a))return null}else{if(!Ft(a))return null}else{if(!Gt(a))return null}}let o=[null,n,a.t+n];if(o[1]===o[2])return null;let i={};return Object.keys(a.groups).forEach((e=>{let t=a.groups[e],r=n+t.start;i[e]=[null,r,r+t.length]})),{pointer:o,groups:i}},Mt=function(e,t){return e.pointer[0]=t,Object.keys(e.groups).forEach((n=>{e.groups[n][0]=t})),e},Lt=function(e,t,n){let r=$t(e,t,0,e.length);return r?(r=Mt(r,n),r):null},Kt={one:{termMethods:Tt,parseMatch:function(e,t,n){if(null==e||""===e)return[];t=t||{},"number"==typeof e&&(e=String(e));let r=function(e){let t=e.split(tt),n=[];t.forEach((e=>{at(e)?n.push(e):n=n.concat(e.split(nt))})),n=ot(n);let r=[];return n.forEach((e=>{(e=>/^[![^]*(<[^<]*>)?\(/.test(e)&&/\)[?\]+*$~]*$/.test(e))(e)||at(e)?r.push(e):r=r.concat(e.split(rt))})),r=ot(r),r}(e);return r=r.map((e=>pt(e,t))),r=function(e,t){let n=t.model.one.prefixes;for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r.word&&ft.test(r.word)){let a=r.word.split(/[-–—]/g);if(n.hasOwnProperty(a[0]))continue;a=a.filter((e=>e)).reverse(),e.splice(t,1),a.forEach((n=>{let a=Object.assign({},r);a.word=n,e.splice(t,0,a)}))}}return e}(r,n),r=function(e,t){return e.map((e=>{if(e.root)if(t.methods.two&&t.methods.two.transform){let n=[];e.pos?"Verb"===e.pos?n=n.concat(bt(e,t)):"Noun"===e.pos?n=n.concat(vt(e,t)):"Adjective"===e.pos&&(n=n.concat(yt(e,t))):(n=n.concat(bt(e,t)),n=n.concat(vt(e,t)),n=n.concat(yt(e,t))),n=n.filter((e=>e)),n.length>0&&(e.operator="or",e.fastOr=new Set(n))}else e.machine=e.root,delete e.id,delete e.root;return e}))}(r,n),r=wt(r),r},match:function(e,t,n){n=n||[];let{regs:r,group:a,justOne:o}=t,i=[];if(!r||0===r.length)return{ptrs:[],byGroup:{}};const s=r.filter((e=>!0!==e.optional&&!0!==e.negative)).length;e:for(let t=0;t<e.length;t+=1){let a=e[t];if(!n[t]||!Pt(r,n[t]))if(!0!==r[0].start)for(let e=0;e<a.length;e+=1){let n=a.slice(e);if(n.length<s)break;let l=$t(n,r,e,a.length);if(l){if(l=Mt(l,t),i.push(l),!0===o)break e;let n=l.pointer[2];Math.abs(n-1)>e&&(e=Math.abs(n-1))}}else{let e=Lt(a,r,t);e&&i.push(e)}}return!0===r[r.length-1].end&&(i=i.filter((t=>{let n=t.pointer[0];return e[n].length===t.pointer[2]}))),t.notIf&&(i=function(e,t,n){return e=e.filter((e=>{let[r,a,o]=e.pointer,i=n[r].slice(a,o);for(let e=0;e<i.length;e+=1){let n=i.slice(e);if(null!==$t(n,t,e,i.length))return!1}return!0})),e}(i,t.notIf,e)),i=function(e,t){let n=[],r={};return 0===e.length||("number"==typeof t&&(t=String(t)),t?e.forEach((e=>{e.groups[t]&&n.push(e.groups[t])})):e.forEach((e=>{n.push(e.pointer),Object.keys(e.groups).forEach((t=>{r[t]=r[t]||[],r[t].push(e.groups[t])}))}))),{ptrs:n,byGroup:r}}(i,a),i.ptrs.forEach((t=>{let[n,r,a]=t;t[3]=e[n][r].id,t[4]=e[n][a-1].id})),i}}};var Jt={api:function(e){Object.assign(e.prototype,et)},methods:Kt,lib:{parseMatch:function(e,t){const n=this.world();let r=n.methods.one.killUnicode;return r&&(e=r(e,n)),n.methods.one.parseMatch(e,t,n)}}};const Wt=/^\../,qt=/^#./,Ut=function(e,t){let n={},r={};return Object.keys(t).forEach((a=>{let o=t[a],i=function(e){let t="",n="</span>";return e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),Wt.test(e)?t=`<span class="${e.replace(/^\./,"")}"`:qt.test(e)?t=`<span id="${e.replace(/^#/,"")}"`:(t=`<${e}`,n=`</${e}>`),t+=">",{start:t,end:n}}(a);"string"==typeof o&&(o=e.match(o)),o.docs.forEach((e=>{if(e.every((e=>e.implicit)))return;let t=e[0].id;n[t]=n[t]||[],n[t].push(i.start);let a=e[e.length-1].id;r[a]=r[a]||[],r[a].push(i.end)}))})),{starts:n,ends:r}};var Rt={html:function(e){let{starts:t,ends:n}=Ut(this,e),r="";return this.docs.forEach((e=>{for(let a=0;a<e.length;a+=1){let o=e[a];t.hasOwnProperty(o.id)&&(r+=t[o.id].join("")),r+=o.pre||"",r+=o.text||"",n.hasOwnProperty(o.id)&&(r+=n[o.id].join("")),r+=o.post||""}})),r}};const Qt=/[,:;)\]*.?~!\u0022\uFF02\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4—-]+$/,Zt=/^[(['"*~\uFF02\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F]+/,_t=/[,:;)('"\u201D\]]/,Xt=/^[-–—]$/,Yt=/ /,en=function(e,t,n=!0){let r="";return e.forEach((e=>{let n=e.pre||"",a=e.post||"";"some"===t.punctuation&&(n=n.replace(Zt,""),Xt.test(a)&&(a=" "),a=a.replace(_t,""),a=a.replace(/\?!+/,"?"),a=a.replace(/!+/,"!"),a=a.replace(/\?+/,"?"),a=a.replace(/\.{2,}/,""),e.tags.has("Abbreviation")&&(a=a.replace(/\./,""))),"some"===t.whitespace&&(n=n.replace(/\s/,""),a=a.replace(/\s+/," ")),t.keepPunct||(n=n.replace(Zt,""),a="-"===a?" ":a.replace(Qt,""));let o=e[t.form||"text"]||e.normal||"";"implicit"===t.form&&(o=e.implicit||e.text),"root"===t.form&&e.implicit&&(o=e.root||e.implicit||e.normal),"machine"!==t.form&&"implicit"!==t.form&&"root"!==t.form||!e.implicit||a&&Yt.test(a)||(a+=" "),r+=n+o+a})),!1===n&&(r=r.trim()),!0===t.lowerCase&&(r=r.toLowerCase()),r},tn={text:{form:"text"},normal:{whitespace:"some",punctuation:"some",case:"some",unicode:"some",form:"normal"},machine:{keepSpace:!1,whitespace:"some",punctuation:"some",case:"none",unico