2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
|
|
import{j as m}from"./jsx-runtime.CyXy1Ci3.js";import{r as v}from"./index.CaZlGE7t.js";import{m as et}from"./marked.esm.BhM9K_2c.js";function _(e){return Array.isArray?Array.isArray(e):rt(e)==="[object Array]"}function dt(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ft(e){return e==null?"":dt(e)}function w(e){return typeof e=="string"}function st(e){return typeof e=="number"}function gt(e){return e===!0||e===!1||pt(e)&&rt(e)=="[object Boolean]"}function nt(e){return typeof e=="object"}function pt(e){return nt(e)&&e!==null}function x(e){return e!=null}function K(e){return!e.trim().length}function rt(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const mt="Incorrect 'index' type",xt=e=>`Invalid value for key ${e}`,Mt=e=>`Pattern length exceeds max of ${e}.`,yt=e=>`Missing ${e} property in key`,St=e=>`Property 'weight' in key '${e}' must be a positive integer`,J=Object.prototype.hasOwnProperty;class wt{constructor(t){this._keys=[],this._keyMap={};let s=0;t.forEach(n=>{let r=it(n);s+=r.weight,this._keys.push(r),this._keyMap[r.id]=r,s+=r.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 it(e){let t=null,s=null,n=null,r=1,i=null;if(w(e)||_(e))n=e,t=X(e),s=B(e);else{if(!J.call(e,"name"))throw new Error(yt("name"));const c=e.name;if(n=c,J.call(e,"weight")&&(r=e.weight,r<=0))throw new Error(St(c));t=X(c),s=B(c),i=e.getFn}return{path:t,id:s,weight:r,src:n,getFn:i}}function X(e){return _(e)?e:e.split(".")}function B(e){return _(e)?e.join("."):e}function Et(e,t){let s=[],n=!1;const r=(i,c,a)=>{if(x(i))if(!c[a])s.push(i);else{let o=c[a];const h=i[o];if(!x(h))return;if(a===c.length-1&&(w(h)||st(h)||gt(h)))s.push(ft(h));else if(_(h)){n=!0;for(let l=0,d=h.length;l<d;l+=1)r(h[l],c,a+1)}else c.length&&r(h,c,a+1)}};return r(e,w(t)?t.split("."):t,0),n?s:s[0]}const _t={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},It={isCaseSensitive:!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},Lt={location:0,threshold:.6,distance:100},Rt={useExtendedSearch:!1,getFn:Et,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var u={...It,..._t,...Lt,...Rt};const At=/[^ ]+/g;function bt(e=1,t=3){const s=new Map,n=Math.pow(10,t);return{get(r){const i=r.match(At).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*e),a=parseFloat(Math.round(c*n)/n);return s.set(i,a),a},clear(){s.clear()}}}class G{constructor({getFn:t=u.getFn,fieldNormWeight:s=u.fieldNormWeight}={}){this.norm=bt(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,w(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){const s=this.size();w(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(!x(t)||K(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((r,i)=>{let c=r.getFn?r.getFn(t):this.getFn(t,r.path);if(x(c)){if(_(c)){let a=[];const o=[{nestedArrIndex:-1,value:c}];for(;o.length;){const{nestedArrIndex:h,value:l}=o.pop();if(x(l))if(w(l)&&!K(l)){let d={v:l,i:h,n:this.norm.get(l)};a.push(d)}else _(l)&&l.forEach((d,f)=>{o.push({nestedArrIndex:f,value:d})})}n.$[i]=a}else if(w(c)&&!K(c)){let a={v:c,n:this.norm.get(c)};n.$[i]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function ct(e,t,{getFn:s=u.getFn,fieldNormWeight:n=u.fieldNormWeight}={}){const r=new G({getFn:s,fieldNormWeight:n});return r.setKeys(e.map(it)),r.setSources(t),r.crea
|