plan options
This commit is contained in:
1 parent
8463f50f6b
commit
ecb66a76b5
14 files changed
+277
-303
No files matched your search
@@ -0,0 +1 @@
|
||||
function I(e){return Array.isArray?Array.isArray(e):ft(e)==="[object Array]"}var Et=1/0;function mt(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-Et?"-0":t}function Dt(e){return e==null?"":mt(e)}function F(e){return typeof e=="string"}function lt(e){return typeof e=="number"}function Ft(e){return e===!0||e===!1||Bt(e)&&ft(e)=="[object Boolean]"}function dt(e){return typeof e=="object"}function Bt(e){return dt(e)&&e!==null}function C(e){return e!=null}function V(e){return!e.trim().length}function ft(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var Mt="Incorrect 'index' type",It=e=>`Invalid value for key ${e}`,yt=e=>`Pattern length exceeds max of ${e}.`,_t=e=>`Missing ${e} property in key`,St=e=>`Property 'weight' in key '${e}' must be a positive integer`,ut=Object.prototype.hasOwnProperty,H=class{constructor(t){this._keys=[],this._keyMap={};let s=0;t.forEach(n=>{let i=gt(n);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(n=>{n.weight/=s})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function gt(e){let t=null,s=null,n=null,i=1,r=null;if(F(e)||I(e))n=e,t=ct(e),s=U(e);else{if(!ut.call(e,"name"))throw new Error(_t("name"));let c=e.name;if(n=c,ut.call(e,"weight")&&(i=e.weight,i<=0))throw new Error(St(c));t=ct(c),s=U(c),r=e.getFn}return{path:t,id:s,weight:i,src:n,getFn:r}}function ct(e){return I(e)?e:e.split(".")}function U(e){return I(e)?e.join("."):e}function wt(e,t){let s=[],n=!1,i=(r,c,o)=>{if(C(r))if(!c[o])s.push(r);else{let h=c[o],u=r[h];if(!C(u))return;if(o===c.length-1&&(F(u)||lt(u)||Ft(u)))s.push(Dt(u));else if(I(u)){n=!0;for(let a=0,d=u.length;a<d;a+=1)i(u[a],c,o+1)}else c.length&&i(u,c,o+1)}};return i(e,F(t)?t.split("."):t,0),n?s:s[0]}var xt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Lt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},bt={location:0,threshold:.6,distance:100},Rt={useExtendedSearch:!1,getFn:wt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},l={...Lt,...xt,...bt,...Rt},Ot=/[^ ]+/g;function kt(e=1,t=3){let s=new Map,n=Math.pow(10,t);return{get(i){let r=i.match(Ot).length;if(s.has(r))return s.get(r);let c=1/Math.pow(r,.5*e),o=parseFloat(Math.round(c*n)/n);return s.set(r,o),o},clear(){s.clear()}}}var O=class{constructor({getFn:t=l.getFn,fieldNormWeight:s=l.fieldNormWeight}={}){this.norm=kt(s,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,F(this.docs[0])?this.docs.forEach((t,s)=>{this._addString(t,s)}):this.docs.forEach((t,s)=>{this._addObject(t,s)}),this.norm.clear())}add(t){let s=this.size();F(t)?this._addString(t,s):this._addObject(t,s)}removeAt(t){this.records.splice(t,1);for(let s=t,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(t,s){return t[this._keysMap[s]]}size(){return this.records.length}_addString(t,s){if(!C(t)||V(t))return;let n={v:t,i:s,n:this.norm.get(t)};this.records.push(n)}_addObject(t,s){let n={i:s,$:{}};this.keys.forEach((i,r)=>{let c=i.getFn?i.getFn(t):this.getFn(t,i.path);if(C(c)){if(I(c)){let o=[],h=[{nestedArrIndex:-1,value:c}];for(;h.length;){let{nestedArrIndex:u,value:a}=h.pop();if(C(a))if(F(a)&&!V(a)){let d={v:a,i:u,n:this.norm.get(a)};o.push(d)}else I(a)&&a.forEach((d,f)=>{h.push({nestedArrIndex:f,value:d})})}n.$[r]=o}else if(F(c)&&!V(c)){let o={v:c,n:this.norm.get(c)};n.$[r]=o}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}};function At(e,t,{getFn:s=l.getFn,fieldNormWeight:n=l.fieldNormWeight}={}){let i=new O({getFn:s,fieldNormWeight:n});return i.setKeys(e.map(gt)),i.setSources(t),i.create(),i}function Nt(e,{getFn:t=l.getFn,fieldNormWeight:s=l.fieldNormWeight}={}){let{keys:n,records:i}=e,r=new O({getFn:t,fieldNormWeight:s});return r.setKeys(n),r.setIndexRecords(i),r}function N(e,{errors:t=0,currentLocation:s=0,expectedLocation:n=0,distance:i=l.distance,ignoreLocation:r=l.ignoreLocation}={}){let c=t/e.length;if(r)return c;let o=Math.abs(n-s);return i?c+o/i:o?1:c}function $t(e=[],t=l.minMatchCharLength){let s=[],n=-1,i=-1,r=0;for(let c=e.length;r<c;r+=1){let o=e[r];o&&n===-1?n=r:!o&&n!==-1&&(i=r-1,i-n+1>=t&&s.push([n,i]),n=-1)}return e[r-1]&&r-n>=t&&s.push([n,r-1]),s}var L=32;function Tt(e,t,s,{location:n=l.location,distance:i=l.distance,threshold:r=l.threshold,findAllMatches:c=l.findAllMatches,minMatchCharLength:o=l.minMatchCharLength,includeMatches:h=l.includeMatches,ignoreLocation:u=l.ignoreLocation}={}){if(t.length>L)throw new Error(yt(L));let a=t.length,d=e.length,f=Math.max(0,Math.min(n,d)),g=r,A=f,p=o>1||h,m=p?Array(d):[],_;for(;(_=e.indexOf(t,A))>-1;){let E=N(t,{currentLocation:_,expectedLocation:f,distance:i,ignoLine truncated
|
||||
Reference in new issue
Block a user