2 lines
No EOL
25 KiB
JavaScript
2 lines
No EOL
25 KiB
JavaScript
e=this,t=function(){"use strict";function z(e){return(z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function S(e,t){for(var n,s=0;s<t.length;s++)n=t[s],n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function n(e,t,n){return t&&S(e.prototype,t),n&&S(e,n),e}function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(e,t){var n,s=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),s.push.apply(s,n)),s}function L(e){for(var t,n=1;n<arguments.length;n++)t=null!=arguments[n]?arguments[n]:{},n%2?T(Object(t),!0).forEach(function(n){O(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):T(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))});return e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&P(e,t)}function j(e){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function P(e,t){return(P=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ee(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var n,o,s=j(e);return t?(o=j(this).constructor,n=Reflect.construct(s,arguments,o)):n=s.apply(this,arguments),ee(this,n)}}function l(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function p(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function i(e){return Array.isArray?Array.isArray(e):"[object Array]"===D(e)}function a(e){return"string"==typeof e}function B(e){return"number"==typeof e}function te(e){return!0===e||!1===e||function(e){return R(e)&&null!==e}(e)&&"[object Boolean]"==D(e)}function R(e){return"object"===z(e)}function s(e){return e!=null}function y(e){return!e.trim().length}function D(e){return e==null?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var ae=function(e){return"Invalid value for key ".concat(e)},fe=function(e){return"Pattern length exceeds max of ".concat(e,".")},A=Object.prototype.hasOwnProperty,Q=function(){function e(n){var s,o=this;t(this,e),this._keys=[],this._keyMap={},s=0,n.forEach(function(e){var t=E(e);s+=t.weight,o._keys.push(t),o._keyMap[t.id]=t,s+=t.weight}),this._keys.forEach(function(e){e.weight/=s})}return n(e,[{key:"get",value:function(e){return this._keyMap[e]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function E(e){var t,n=null,s=null,o=null,r=1;if(a(e)||i(e))o=e,n=k(e),s=_(e);else{if(!A.call(e,"name"))throw new Error(function(e){return"Missing ".concat(e," property in key")}("name"));if(t=e.name,o=t,A.call(e,"weight")&&(r=e.weight)<=0)throw new Error(function(e){return"Property 'weight' in key '".concat(e,"' must be a positive integer")}(t));n=k(t),s=_(t)}return{path:n,id:s,weight:r,src:o}}function k(e){return i(e)?e:e.split(".")}function _(e){return i(e)?e.join("."):e}e=L({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(e,t){return e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1}},{},{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},{},{location:0,threshold:.6,distance:100},{},{useExtendedSearch:!1,getFn:function(e,t){var n=[],o=!1;return function e(t,r,c){if(s(t))if(r[c]){if(l=t[r[c]],!s(l))return;if(c===r.length-1&&(a(l)||B(l)||te(l)))n.push(function(e){return e==null?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(l));else if(i(l)){o=!0;for(var l,d=0,u=l.length;d<u;d+=1)e(l[d],r,c+1)}else r.length&&e(l,r,c+1)}else n.push(t)}(e,a(t)?t.split("."):t,0),o?n:n[0]},ignoreLocation:!1,ignoreFieldNorm:!1}),M=/[^ ]+/g;function le(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3,e=new Map,t=Math.pow(10,n);return{get:function(n){if(s=n.match(M).length,e.has(s))return e.get(s);var s,i=1/Math.sqrt(s),o=parseFloat(Math.round(i*t)/t);return e.set(s,o),o},clear:function(){e.clear()}}}u=function(){function o(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=s.getFn,i=void 0===n?e.getFn:n;t(this,o),this.norm=le(3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return n(o,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=e,this._keysMap={},e.forEach(function(e,n){t._keysMap[e.id]=n})}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,a(this.docs[0])?this.docs.forEach(function(t,n){e._addString(t,n)}):this.docs.forEach(function(t,n){e._addObject(t,n)}),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();a(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t<n;t+=1)this.records[t].i-=1}},{key:"getValueForItemAtKeyId",value:function(e,t){return e[this._keysMap[t]]}},{key:"size",value:function(){return this.records.length}},{key:"_addString",value:function(e,t){if(s(e)&&!y(e)){var n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}}},{key:"_addObject",value:function(e,t){var n=this,o={i:t,$:{}};this.keys.forEach(function(t,r){var l,c=n.getFn(e,t.path);s(c)&&(i(c)?!function(){for(l=[],t=[{nestedArrIndex:-1,value:c}];t.length;){var t,l,u,d=t.pop(),h=d.nestedArrIndex,e=d.value;s(e)&&(a(e)&&!y(e)?(u={v:e,i:h,n:n.norm.get(e)},l.push(u)):i(e)&&e.forEach(function(e,n){t.push({nestedArrIndex:n,value:e})}))}o.$[r]=l}():y(c)||(l={v:c,n:n.norm.get(c)},o.$[r]=l))}),this.records.push(o)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),o}();function x(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i.getFn,a=void 0===o?e.getFn:o,s=new u({getFn:a});return s.setKeys(t.map(E)),s.setSources(n),s.create(),s}function h(t){var s,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},d=n.errors,f=void 0===d?0:d,l=n.currentLocation,u=void 0===l?0:l,a=n.expectedLocation,h=void 0===a?0:a,r=n.distance,c=void 0===r?e.distance:r,i=n.ignoreLocation,m=void 0===i?e.ignoreLocation:i,o=f/t.length;return m?o:(s=Math.abs(h-u),c?o+s/c:s?1:o)}function Y(){for(var i,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.minMatchCharLength,o=[],t=-1,r=-1,n=0,c=s.length;n<c;n+=1)i=s[n],i&&-1===t?t=n:i||-1===t||((r=n-1)-t+1>=a&&o.push([t,r]),t=-1);return s[n-1]&&n-t>=a&&o.push([t,n-1]),o}function W(e){for(var s,n={},t=0,o=e.length;t<o;t+=1)s=e.charAt(t),n[s]=(n[s]||0)|1<<o-t-1;return n}b=function(){function s(n){var i,a,c,j=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=o.location,x=void 0===u?e.location:u,p=o.threshold,w=void 0===p?e.threshold:p,l=o.distance,k=void 0===l?e.distance:l,h=o.includeMatches,C=void 0===h?e.includeMatches:h,f=o.findAllMatches,O=void 0===f?e.findAllMatches:f,g=o.minMatchCharLength,y=void 0===g?e.minMatchCharLength:g,d=o.isCaseSensitive,b=void 0===d?e.isCaseSensitive:d,v=o.ignoreLocation,_=void 0===v?e.ignoreLocation:v;if(t(this,s),this.options={location:x,threshold:w,distance:k,includeMatches:C,findAllMatches:O,minMatchCharLength:y,isCaseSensitive:b,ignoreLocation:_},this.pattern=b?n:n.toLowerCase(),this.chunks=[],this.pattern.length)if(a=function(e,t){j.chunks.push({pattern:e,alphabet:W(e),startIndex:t})},i=this.pattern.length,i>32){for(var r=0,m=i%32,E=i-m;r<E;)a(this.pattern.substr(r,32),r),r+=32;m&&(c=i-32,a(this.pattern.substr(c),c))}else a(this.pattern,0)}return n(s,[{key:"searchIn",value:function(t){var c=this.options,b=c.isCaseSensitive,a=c.includeMatches;if(b||(t=t.toLowerCase()),this.pattern===t)return r={isMatch:!0,score:0},a&&(r.indices=[[0,t.length-1]]),r;var i,r,n=this.options,v=n.location,u=n.distance,g=n.threshold,p=n.findAllMatches,m=n.minMatchCharLength,f=n.ignoreLocation,o=[],d=0,s=!1;return this.chunks.forEach(function(n){var b=n.pattern,j=n.alphabet,y=n.startIndex,i=function(t,n,s){var o,a,f,p,b,x,A,S,z,R,H,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},B=r.location,$=void 0===B?e.location:B,M=r.distance,j=void 0===M?e.distance:M,D=r.threshold,U=void 0===D?e.threshold:D,I=r.findAllMatches,W=void 0===I?e.findAllMatches:I,T=r.minMatchCharLength,F=void 0===T?e.minMatchCharLength:T,L=r.includeMatches,V=void 0===L?e.includeMatches:L,N=r.ignoreLocation,y=void 0===N?e.ignoreLocation:N;if(n.length>32)throw new Error(fe(32));for(var _,l=n.length,g=t.length,i=Math.max(0,Math.min($,g)),m=U,u=i,v=F>1||V,k=v?Array(g):[];(_=t.indexOf(n,u))>-1;)if(z=h(n,{currentLocation:_,expectedLocation:i,distance:j,ignoreLocation:y}),m=Math.min(z,m),u=_+l,v)for(x=0;x<l;)k[_+x]=1,x+=1;u=-1;for(var O=[],E=1,w=l+g,K=1<<l-1,c=0;c<l;c+=1){for(f=0,a=w;f<a;)R=h(n,{errors:c,currentLocation:i+a,expectedLocation:i,distance:j,ignoreLocation:y}),R<=m?f=a:w=a,a=Math.floor((w-f)/2+f);var w=a,P=Math.max(1,i-a+1),C=W?g:Math.min(i+a,g)+l,d=Array(C+2);d[C+1]=(1<<c)-1;for(o=C;o>=P;o-=1)if(p=o-1,S=s[t.charAt(p)],v&&(k[p]=+!!S),d[o]=(d[o+1]<<1|1)&S,c&&(d[o]|=(O[o+1]|O[o])<<1|1|O[o+1]),d[o]&K&&(E=h(n,{errors:c,currentLocation:p,expectedLocation:i,distance:j,ignoreLocation:y}))<=m){if(m=E,(u=p)<=i)break;P=Math.max(1,2*i-u)}if(H=h(n,{errors:c+1,currentLocation:i,expectedLocation:i,distance:j,ignoreLocation:y}),H>m)break;O=d}return b={isMatch:u>=0,score:Math.max(.001,E)},v&&(A=Y(k,F),A.length?V&&(b.indices=A):b.isMatch=!1),b}(t,b,j,{location:v+y,distance:u,threshold:g,findAllMatches:p,minMatchCharLength:m,includeMatches:a,ignoreLocation:f}),r=i.isMatch,_=i.score,c=i.indices;r&&(s=!0),d+=_,r&&c&&(o=[].concat(l(o),l(c)))}),i={isMatch:s,score:s?d/this.chunks.length:1},s&&a&&(i.indices=o),i}}]),s}(),o=function(){function e(n){t(this,e),this.pattern=n}return n(e,[{key:"search",value:function(){}}],[{key:"isMultiMatch",value:function(e){return H(e,this.multiRegex)}},{key:"isSingleMatch",value:function(e){return H(e,this.singleRegex)}}]),e}();function H(e,t){var n=e.match(t);return n?n[1]:null}var e,o,d,u,b,M,G=function(e){r(s,e);var o=c(s);function s(e){return t(this,s),o.call(this,e)}return n(s,[{key:"search",value:function(e){var t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"exact"}},{key:"multiRegex",get:function(){return/^="(.*)"$/}},{key:"singleRegex",get:function(){return/^=(.*)$/}}]),s}(o),U=function(e){r(s,e);var o=c(s);function s(e){return t(this,s),o.call(this,e)}return n(s,[{key:"search",value:function(e){var t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"$/}},{key:"singleRegex",get:function(){return/^!(.*)$/}}]),s}(o),q=function(e){r(s,e);var o=c(s);function s(e){return t(this,s),o.call(this,e)}return n(s,[{key:"search",value:function(e){var t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"prefix-exact"}},{key:"multiRegex",get:function(){return/^\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^\^(.*)$/}}]),s}(o),ne=function(e){r(s,e);var o=c(s);function s(e){return t(this,s),o.call(this,e)}return n(s,[{key:"search",value:function(e){var t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-prefix-exact"}},{key:"multiRegex",get:function(){return/^!\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^!\^(.*)$/}}]),s}(o),K=function(e){r(s,e);var o=c(s);function s(e){return t(this,s),o.call(this,e)}return n(s,[{key:"search",value:function(e){var t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}],[{key:"type",get:function(){return"suffix-exact"}},{key:"multiRegex",get:function(){return/^"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^(.*)\$$/}}]),s}(o),se=function(e){r(s,e);var o=c(s);function s(e){return t(this,s),o.call(this,e)}return n(s,[{key:"search",value:function(e){var t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-suffix-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^!(.*)\$$/}}]),s}(o),$=function(s){r(o,s);var i=c(o);function o(n){var f,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},h=s.location,g=void 0===h?e.location:h,l=s.threshold,p=void 0===l?e.threshold:l,u=s.distance,y=void 0===u?e.distance:u,a=s.includeMatches,w=void 0===a?e.includeMatches:a,d=s.findAllMatches,v=void 0===d?e.findAllMatches:d,m=s.minMatchCharLength,j=void 0===m?e.minMatchCharLength:m,r=s.isCaseSensitive,_=void 0===r?e.isCaseSensitive:r,c=s.ignoreLocation,O=void 0===c?e.ignoreLocation:c;return t(this,o),(f=i.call(this,n))._bitapSearch=new b(n,{location:g,threshold:p,distance:y,includeMatches:w,findAllMatches:v,minMatchCharLength:j,isCaseSensitive:_,ignoreLocation:O}),f}return n(o,[{key:"search",value:function(e){return this._bitapSearch.searchIn(e)}}],[{key:"type",get:function(){return"fuzzy"}},{key:"multiRegex",get:function(){return/^"(.*)"$/}},{key:"singleRegex",get:function(){return/^(.*)$/}}]),o}(o),V=function(e){r(s,e);var o=c(s);function s(e){return t(this,s),o.call(this,e)}return n(s,[{key:"search",value:function(e){for(var t,o,n=0,s=[],i=this.pattern.length;(t=e.indexOf(this.pattern,n))>-1;)n=t+i,s.push([t,n-1]);return o=!!s.length,{isMatch:o,score:o?0:1,indices:s}}}],[{key:"type",get:function(){return"include"}},{key:"multiRegex",get:function(){return/^'"(.*)"$/}},{key:"singleRegex",get:function(){return/^'(.*)$/}}]),s}(o),g=[G,V,q,ne,se,K,U,$],I=g.length,X=/ +(?=([^"]*"[^"]*")*[^"]*$)/;function oe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.split("|").map(function(e){for(var a,r,c,l,d=e.trim().split(X).filter(function(e){return e&&!!e.trim()}),s=[],o=0,h=d.length;o<h;o+=1){for(var u=d[o],i=!1,n=-1;!i&&++n<I;)a=g[n],r=a.isMultiMatch(u),r&&(s.push(new a(r,t)),i=!0);if(!i)for(n=-1;++n<I;)if(c=g[n],l=c.isSingleMatch(u),l){s.push(new c(l,t));break}}return s})}var Z=new Set([$.type,V.type]),J=function(){function s(n){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=o.isCaseSensitive,r=void 0===a?e.isCaseSensitive:a,c=o.includeMatches,j=void 0===c?e.includeMatches:c,d=o.minMatchCharLength,v=void 0===d?e.minMatchCharLength:d,h=o.ignoreLocation,f=void 0===h?e.ignoreLocation:h,m=o.findAllMatches,p=void 0===m?e.findAllMatches:m,i=o.location,g=void 0===i?e.location:i,u=o.threshold,b=void 0===u?e.threshold:u,l=o.distance,y=void 0===l?e.distance:l;t(this,s),this.query=null,this.options={isCaseSensitive:r,includeMatches:j,minMatchCharLength:v,findAllMatches:p,ignoreLocation:f,location:g,threshold:b,distance:y},this.pattern=r?n:n.toLowerCase(),this.query=oe(this.pattern,this.options)}return n(s,[{key:"searchIn",value:function(e){if(o=this.query,!o)return{isMatch:!1,score:1};u=this.options,d=u.includeMatches,e=u.isCaseSensitive?e:e.toLowerCase();for(var s,o,i,c,d,u,f,g,n=0,t=[],a=0,r=0,j=o.length;r<j;r+=1){i=o[r],t.length=0,n=0;for(s=0,f=i.length;s<f;s+=1){var m=i[s],h=m.search(e),v=h.isMatch,p=h.indices,b=h.score;if(!v){a=0,n=0,t.length=0;break}n+=1,a+=b,d&&(g=m.constructor.type,Z.has(g)?t=[].concat(l(t),l(p)):t.push(p))}if(n)return c={isMatch:!0,score:a/n},d&&(c.indices=t),c}return{isMatch:!1,score:1}}}],[{key:"condition",value:function(e,t){return t.useExtendedSearch}}]),s}(),m=[];function v(e,t){for(var s,n=0,o=m.length;n<o;n+=1)if(s=m[n],s.condition(e,t))return new s(e,t);return new b(e,t)}var f="$and",N="$or",C="$path",ie="$val",w=function(e){return!!e[f]||!!e[N]},re=function(e){return!!e[C]},ce=function(e){return!i(e)&&R(e)&&!w(e)},F=function(e){return O({},f,Object.keys(e).map(function(t){return O({},t,e[t])}))};function de(t,n){var s=n.ignoreFieldNorm,o=void 0===s?e.ignoreFieldNorm:s;t.forEach(function(e){var t=1;e.matches.forEach(function(e){var n=e.key,a=e.norm,s=e.score,i=n?n.weight:null;t*=Math.pow(0===s&&i?Number.EPSILON:s,(i||1)*(o?1:a))}),e.score=t})}function ue(e,t){var n=e.matches;t.matches=[],s(n)&&n.forEach(function(e){if(s(e.indices)&&e.indices.length){var n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.src),e.idx>-1&&(n.refIndex=e.idx),t.matches.push(n)}})}function he(e,t){t.score=e.score}function me(t,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=o.includeMatches,r=void 0===i?e.includeMatches:i,a=o.includeScore,c=void 0===a?e.includeScore:a,s=[];return r&&s.push(ue),c&&s.push(he),t.map(function(e){var t=e.idx,o={item:n[t],refIndex:t};return s.length&&s.forEach(function(t){t(e,o)}),o})}return d=function(){function o(n){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;t(this,o),this.options=L({},e,{},s),this.options.useExtendedSearch,this._keyStore=new Q(this.options.keys),this.setCollection(n,i)}return n(o,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof u))throw new Error("Incorrect 'index' type");this._myIndex=t||x(this.options.keys,this._docs,{getFn:this.options.getFn})}},{key:"add",value:function(e){s(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var t,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},n=[],e=0,s=this._docs.length;e<s;e+=1)t=this._docs[e],o(t,e)&&(this.removeAt(e),e-=1,s-=1,n.push(t));return n}},{key:"removeAt",value:function(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}},{key:"getIndex",value:function(){return this._myIndex}},{key:"search",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.limit,s=void 0===o?-1:o,t=this.options,r=t.includeMatches,c=t.includeScore,l=t.shouldSort,d=t.sortFn,u=t.ignoreFieldNorm,n=a(e)?a(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return de(n,{ignoreFieldNorm:u}),l&&n.sort(d),B(s)&&s>-1&&(n=n.slice(0,s)),me(n,this._docs,{includeMatches:r,includeScore:c})}},{key:"_searchStringList",value:function(e){var n=v(e,this.options),o=this._myIndex.records,t=[];return o.forEach(function(e){var o=e.v,a=e.i,r=e.n;if(s(o)){var i=n.searchIn(o),c=i.isMatch,l=i.score,d=i.indices;c&&t.push({item:o,idx:a,matches:[{score:l,value:o,norm:r,indices:d}]})}}),t}},{key:"_searchLogical",value:function(e){var n=this,r=function(e,t){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=s.auto,o=void 0===n||n,r=function e(n){var r,c,d,u,s=Object.keys(n),l=re(n);if(!l&&s.length>1&&!w(n))return e(F(n));if(ce(n)){if(r=l?n[C]:s[0],c=l?n[ie]:n[r],!a(c))throw new Error(ae(r));return d={keyId:_(r),pattern:c},o&&(d.searcher=v(c,t)),d}return u={children:[],operator:s[0]},s.forEach(function(t){var s=n[t];i(s)&&s.forEach(function(t){u.children.push(e(t))})}),u};return w(e)||(e=F(e)),r(e)}(e,this.options),c=this._myIndex.records,t={},o=[];return c.forEach(function(e){var c,a=e.$,i=e.i;s(a)&&(c=function e(t,s,o){if(!t.children){var c,h,m=t.keyId,p=t.searcher,i=n._findMatches({key:n._keyStore.get(m),value:n._myIndex.getValueForItemAtKeyId(s,m),searcher:p});return i&&i.length?[{idx:o,item:s,matches:i}]:[]}switch(t.operator){case f:for(var a=[],r=0,g=t.children.length;r<g;r+=1){if(c=e(t.children[r],s,o),!c.length)return[];a.push.apply(a,l(c))}return a;case N:for(var d=[],u=0,v=t.children.length;u<v;u+=1)if(h=e(t.children[u],s,o),h.length){d.push.apply(d,l(h));break}return d}}(r,a,i),c.length&&(t[i]||(t[i]={idx:i,item:a,matches:[]},o.push(t[i])),c.forEach(function(e){var n,s=e.matches;(n=t[i].matches).push.apply(n,l(s))})))}),o}},{key:"_searchObjectList",value:function(e){var o=this,i=v(e,this.options),t=this._myIndex,a=t.keys,r=t.records,n=[];return r.forEach(function(e){var t,r=e.$,c=e.i;s(r)&&(t=[],a.forEach(function(e,n){t.push.apply(t,l(o._findMatches({key:e,value:r[n],searcher:i})))}),t.length&&n.push({idx:c,item:r,matches:t}))}),n}},{key:"_findMatches",value:function(e){var a=e.key,t=e.value,r=e.searcher;if(!s(t))return[];if(n=[],i(t))t.forEach(function(e){var t=e.v,i=e.i,c=e.n;if(s(t)){var o=r.searchIn(t),l=o.isMatch,d=o.score,u=o.indices;l&&n.push({score:d,key:a,value:t,idx:i,norm:c,indices:u})}});else{var n,c=t.v,l=t.n,o=r.searchIn(c),d=o.isMatch,u=o.score,h=o.indices;d&&n.push({score:u,key:a,value:c,norm:l,indices:h})}return n}}]),o}(),d.version="6.4.6",d.createIndex=x,d.parseIndex=function(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=o.getFn,i=void 0===s?e.getFn:s,a=t.keys,r=t.records,n=new u({getFn:i});return n.setKeys(a),n.setIndexRecords(r),n},d.config=e,function(){m.push.apply(m,arguments)}(J),d},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Fuse=t();var e,t,fuse,searchVisible=!1,firstRun=!0,list=document.querySelector(".search-list"),first=list.firstChild,last=list.lastChild,maininput=document.querySelector(".search-ui input"),searchResultsHeading=document.querySelector(".search-results"),noResults=document.querySelector(".no-results"),resultsAvailable=!1;document.querySelector(".open-search").addEventListener("click",openSearch),document.querySelector(".close-search").addEventListener("click",closeSearch);function closeSearch(){document.querySelector(".search-ui").classList.add("hidden"),document.activeElement.blur(),searchVisible=!1,searchResultsHeading.classList.add("hidden")}function openSearch(){firstRun&&(loadSearch(),firstRun=!1),mobileMenu.classList.toggle("hidden"),searchVisible||(document.querySelector(".search-ui").classList.remove("hidden"),document.querySelector(".search-ui input").focus(),searchVisible=!0)}document.addEventListener("keydown",function(e){e.metaKey&&e.which===191&&openSearch(),e.keyCode==27&&searchVisible&&(document.querySelector(".search-ui").classList.add("hidden"),document.activeElement.blur(),searchVisible=!1,searchResultsHeading.classList.add("hidden")),e.keyCode==40&&searchVisible&&resultsAvailable&&(console.log("down"),e.preventDefault(),document.activeElement==maininput?first.focus():document.activeElement==last?last.focus():document.activeElement.parentElement.nextSibling.firstElementChild.focus()),e.keyCode==38&&searchVisible&&resultsAvailable&&(e.preventDefault(),document.activeElement==maininput?maininput.focus():document.activeElement==first?maininput.focus():document.activeElement.parentElement.previousSibling.firstElementChild.focus())}),document.querySelector(".search-ui input").onkeyup=function(){executeSearch(this.value)};function fetchJSONFile(e,t){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(n.readyState===4&&n.status===200){var e=JSON.parse(n.responseText);t&&t(e)}},n.open("GET",e),n.send()}function loadSearch(){const e=document.querySelector('head > meta[name="lang"]')?.getAttribute?.("content");fetchJSONFile(`${e?"/"+e:""}/index.json`,function(e){var t={shouldSort:!0,location:0,distance:100,threshold:.4,minMatchCharLength:2,keys:["title","permalink","contents"]};fuse=new Fuse(e,t)})}function executeSearch(e){let t=fuse.search(e),n="";if(t.length===0)resultsAvailable=!1,n="",e!==""?noResults.classList.remove("hidden"):noResults.classList.add("hidden");else{noResults.classList.add("hidden"),e!==""&&searchResultsHeading.classList.remove("hidden");for(let e in t.slice(0,5)){const s='<div class="text-2xl mb-2 font-bold">'+t[e].item.title+"</div>",o=t[e].item.date?'<div><em class="px-4">'+new Date(t[e].item.date).toUTCString().substring(0,16)+"</em></div>":"",i='<div class="prose px-4">'+t[e].item.contents+"</div>";n=n+'<li><a class="block mb-2 px-4 py-2 rounded pb-2 border-b border-gray-200 dark:border-gray-600 focus:bg-gray-100 dark:focus:bg-gray-700 focus:outline-none" href="'+t[e].item.permalink+'" tabindex="0">'+s+"</a>"+o+i+"</li>"}resultsAvailable=!0}list.innerHTML=n,t.length>0&&(first=list.firstChild.firstElementChild,last=list.lastChild.firstElementChild)} |