mirror of https://github.com/jpanther/congo.git
11 lines
27 KiB
JavaScript
11 lines
27 KiB
JavaScript
e=this,t=function(){"use strict";function V(e,s){var t=Object.keys(e),n;return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),s&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),t.push.apply(t,n)),t}function u(n){for(var e=1,t;e<arguments.length;e++)t=null!=arguments[e]?arguments[e]:{},e%2?V(Object(t),!0).forEach(function(e){y(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):V(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))});return n}function w(e){return w="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},w(e)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function R(s,n){for(var t=0,e;t<n.length;t++)e=n[t],e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(s,e.key,e)}function n(e,t,n){return t&&R(e.prototype,t),n&&R(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(t,"prototype",{value:Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),writable:!1}),e&&j(t,e)}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function j(e,t){return j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},j(e,t)}function eu(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return 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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,s=p(e),o;return t?(o=p(this).constructor,n=Reflect.construct(s,arguments,o)):n=s.apply(this,arguments),eu(this,n)}}function l(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return g(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?g(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,s=new Array(e);t<e;t++)s[t]=n[t];return s}function o(e){return Array.isArray?Array.isArray(e):"[object Array]"===M(e)}function i(e){return"string"==typeof e}function z(e){return"number"==typeof e}function ec(e){return!0===e||!1===e||function(e){return T(e)&&null!==e}(e)&&"[object Boolean]"==M(e)}function T(e){return"object"===w(e)}function s(e){return null!=e}function E(e){return!e.trim().length}function M(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var ea=function(e){return"Invalid value for key ".concat(e)},eo=function(e){return"Pattern length exceeds max of ".concat(e,".")},A=Object.prototype.hasOwnProperty,es=function(){function e(o){var s=this,n;t(this,e),this._keys=[],this._keyMap={},n=0,o.forEach(function(t){var e=k(t);n+=e.weight,s._keys.push(e),s._keyMap[e.id]=e,n+=e.weight}),this._keys.forEach(function(e){e.weight/=n})}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 k(e){var n=null,s=null,a=null,r=1,t;if(i(e)||o(e))a=e,n=B(e),s=x(e);else{if(!A.call(e,"name"))throw new Error(function(e){return"Missing ".concat(e," property in key")}("name"));if(t=e.name,a=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=B(t),s=x(t)}return{path:n,id:s,weight:r,src:a}}function B(e){return o(e)?e:e.split(".")}function x(e){return o(e)?e.join("."):e}var $={useExtendedSearch:!1,getFn:function(a,t){var e=[],n=!1;return function d(c,a,r){if(s(c))if(a[r]){if(t=c[a[r]],!s(t))return;if(r===a.length-1&&(i(t)||z(t)||ec(t)))e.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(t));else if(o(t)){n=!0;for(var t,l=0,u=t.length;l<u;l+=1)d(t[l],a,r+1)}else a.length&&d(t,a,r+1)}else e.push(c)}(a,i(t)?t.split("."):t,0),n?e:e[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},e=u(u(u(u({},{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}),$),Q=/[^ ]+/g;function X(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,e=new Map,t=Math.pow(10,s);return{get:function(i){if(s=i.match(Q).length,e.has(s))return e.get(s);var s,a=1/Math.pow(s,.5*n),o=parseFloat(Math.round(a*t)/t);return e.set(s,o),o},clear:function(){e.clear()}}}v=function(){function a(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=n.getFn,i=void 0===s?e.getFn:s,o=n.fieldNormWeight,r=void 0===o?e.fieldNormWeight:o;t(this,a),this.norm=X(r,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return n(a,[{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,i(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();i(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(t){this.records.splice(t,1);for(var e=t,n=this.size();e<n;e+=1)this.records[e].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)&&!E(e)){var n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}}},{key:"_addObject",value:function(n,a){var e=this,t={i:a,$:{}};this.keys.forEach(function(c,r){var a=e.getFn(n,c.path),l;s(a)&&(o(a)?!function(){for(l=[],c=[{nestedArrIndex:-1,value:a}];c.length;){var l,c,d=c.pop(),u=d.nestedArrIndex,n=d.value,h;s(n)&&(i(n)&&!E(n)?(h={v:n,i:u,n:e.norm.get(n)},l.push(h)):o(n)&&n.forEach(function(e,t){c.push({nestedArrIndex:t,value:e})}))}t.$[r]=l}():E(a)||(l={v:a,n:e.norm.get(a)},t.$[r]=l))}),this.records.push(t)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),a}();function D(i,c){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=n.getFn,a=void 0===s?e.getFn:s,o=n.fieldNormWeight,r=void 0===o?e.fieldNormWeight:o,t=new v({getFn:a,fieldNormWeight:r});return t.setKeys(i.map(k)),t.setSources(c),t.create(),t}function m(f){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.errors,m=void 0===o?0:o,i=t.currentLocation,u=void 0===i?0:i,r=t.expectedLocation,d=void 0===r?0:r,l=t.distance,s=void 0===l?e.distance:l,a=t.ignoreLocation,h=void 0===a?e.ignoreLocation:a,n=m/f.length,c;return h?n:(c=Math.abs(d-u),s?n+c/s:c?1:n)}function G(){for(var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.minMatchCharLength,o=[],t=-1,a=-1,n=0,c=s.length,r;n<c;n+=1)r=s[n],r&&-1===t?t=n:r||-1===t||((a=n-1)-t+1>=i&&o.push([t,a]),t=-1);return s[n-1]&&n-t>=i&&o.push([t,n-1]),o}d=32;function Y(n){for(var t={},e=0,s=n.length,o;e<s;e+=1)o=n.charAt(e),t[o]=(t[o]||0)|1<<s-e-1;return t}H=function(){function s(g){var E=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=n.location,C=void 0===l?e.location:l,c=n.threshold,x=void 0===c?e.threshold:c,u=n.distance,O=void 0===u?e.distance:u,m=n.includeMatches,_=void 0===m?e.includeMatches:m,p=n.findAllMatches,A=void 0===p?e.findAllMatches:p,v=n.minMatchCharLength,y=void 0===v?e.minMatchCharLength:v,r=n.isCaseSensitive,b=void 0===r?e.isCaseSensitive:r,f=n.ignoreLocation,w=void 0===f?e.ignoreLocation:f,a,i,j;if(t(this,s),this.options={location:C,threshold:x,distance:O,includeMatches:_,findAllMatches:A,minMatchCharLength:y,isCaseSensitive:b,ignoreLocation:w},this.pattern=b?g:g.toLowerCase(),this.chunks=[],this.pattern.length)if(a=function(e,t){E.chunks.push({pattern:e,alphabet:Y(e),startIndex:t})},i=this.pattern.length,i>d){for(var o=0,h=i%d,k=i-h;o<k;)a(this.pattern.substr(o,d),o),o+=d;h&&(j=i-d,a(this.pattern.substr(j),j))}else a(this.pattern,0)}return n(s,[{key:"searchIn",value:function(n){var c=this.options,b=c.isCaseSensitive,i=c.includeMatches;if(b||(n=n.toLowerCase()),this.pattern===n)return a={isMatch:!0,score:0},i&&(a.indices=[[0,n.length-1]]),a;var a,t=this.options,v=t.location,g=t.distance,j=t.threshold,h=t.findAllMatches,f=t.minMatchCharLength,p=t.ignoreLocation,o=[],r=0,s=!1,u;return this.chunks.forEach(function(t){var w=t.pattern,b=t.alphabet,y=t.startIndex,a=function(C,o,W){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},R=i.location,V=void 0===R?e.location:R,L=i.distance,b=void 0===L?e.distance:L,D=i.threshold,$=void 0===D?e.threshold:D,H=i.findAllMatches,B=void 0===H?e.findAllMatches:H,T=i.minMatchCharLength,F=void 0===T?e.minMatchCharLength:T,M=i.includeMatches,S=void 0===M?e.includeMatches:M,A=i.ignoreLocation,y=void 0===A?e.ignoreLocation:A,I,O,j,s,n,v,z,E,N;if(o.length>d)throw new Error(eo(d));for(var _,u=o.length,h=C.length,t=Math.max(0,Math.min(V,h)),c=$,r=t,p=F>1||S,k=p?Array(h):[];(_=C.indexOf(o,r))>-1;)if(I=m(o,{currentLocation:_,expectedLocation:t,distance:b,ignoreLocation:y}),c=Math.min(I,c),r=_+u,p)for(O=0;O<u;)k[_+O]=1,O+=1;r=-1;for(var g=[],w=1,f=u+h,U=1<<u-1,a=0;a<u;a+=1){for(j=0,s=f;j<s;)m(o,{errors:a,currentLocation:t+s,expectedLocation:t,distance:b,ignoreLocation:y})<=c?j=s:f=s,s=Math.floor((f-j)/2+j);f=s;var P=Math.max(1,t-s+1),x=B?h:Math.min(t+s,h)+u,l=Array(x+2);l[x+1]=(1<<a)-1;for(n=x;n>=P;n-=1)if(v=n-1,z=W[C.charAt(v)],p&&(k[v]=+!!z),l[n]=(l[n+1]<<1|1)&z,a&&(l[n]|=(g[n+1]|g[n])<<1|1|g[n+1]),l[n]&U&&(w=m(o,{errors:a,currentLocation:v,expectedLocation:t,distance:b,ignoreLocation:y}))<=c){if(c=w,(r=v)<=t)break;P=Math.max(1,2*t-r)}if(m(o,{errors:a+1,currentLocation:t,expectedLocation:t,distance:b,ignoreLocation:y})>c)break;g=l}return E={isMatch:r>=0,score:Math.max(.001,w)},p&&(N=G(k,F),N.length?S&&(E.indices=N):E.isMatch=!1),E}(n,w,b,{location:v+y,distance:g,threshold:j,findAllMatches:h,minMatchCharLength:f,includeMatches:i,ignoreLocation:p}),u=a.isMatch,_=a.score,c=a.indices;u&&(s=!0),r+=_,u&&c&&(o=[].concat(l(o),l(c)))}),u={isMatch:s,score:s?r/this.chunks.length:1},s&&i&&(u.indices=o),u}}]),s}(),a=function(){function e(n){t(this,e),this.pattern=n}return n(e,[{key:"search",value:function(){}}],[{key:"isMultiMatch",value:function(e){return I(e,this.multiRegex)}},{key:"isSingleMatch",value:function(e){return I(e,this.singleRegex)}}]),e}();function I(t,n){var e=t.match(n);return e?e[1]:null}var v,d,H,a,e3=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(t){var e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"exact"}},{key:"multiRegex",get:function(){return/^="(.*)"$/}},{key:"singleRegex",get:function(){return/^=(.*)$/}}]),e}(a),en=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{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/^!(.*)$/}}]),e}(a),W=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(t){var e=t.startsWith(this.pattern);return{isMatch:e,score:e?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/^\^(.*)$/}}]),e}(a),U=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{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/^!\^(.*)$/}}]),e}(a),K=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{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/^(.*)\$$/}}]),e}(a),q=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{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/^!(.*)\$$/}}]),e}(a),P=function(o){r(s,o);var i=c(s);function s(f){var a,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.location,_=void 0===r?e.location:r,l=n.threshold,j=void 0===l?e.threshold:l,u=n.distance,v=void 0===u?e.distance:u,m=n.includeMatches,p=void 0===m?e.includeMatches:m,o=n.findAllMatches,g=void 0===o?e.findAllMatches:o,h=n.minMatchCharLength,b=void 0===h?e.minMatchCharLength:h,d=n.isCaseSensitive,y=void 0===d?e.isCaseSensitive:d,c=n.ignoreLocation,w=void 0===c?e.ignoreLocation:c;return t(this,s),(a=i.call(this,f))._bitapSearch=new H(f,{location:_,threshold:j,distance:v,includeMatches:p,findAllMatches:g,minMatchCharLength:b,isCaseSensitive:y,ignoreLocation:w}),a}return n(s,[{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/^(.*)$/}}]),s}(a),L=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(o){for(var e,t=0,n=[],i=this.pattern.length,s;(e=o.indexOf(this.pattern,t))>-1;)t=e+i,n.push([e,t-1]);return s=!!n.length,{isMatch:s,score:s?0:1,indices:n}}}],[{key:"type",get:function(){return"include"}},{key:"multiRegex",get:function(){return/^'"(.*)"$/}},{key:"singleRegex",get:function(){return/^'(.*)$/}}]),e}(a),b=[e3,L,W,U,q,K,en,P],F=b.length,Z=/ +(?=([^"]*"[^"]*")*[^"]*$)/,h;function J(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.split("|").map(function(u){for(var r=u.trim().split(Z).filter(function(e){return e&&!!e.trim()}),s=[],o=0,h=r.length,c,l,i,d;o<h;o+=1){for(var a=r[o],n=!1,t=-1;!n&&++t<F;)c=b[t],l=c.isMultiMatch(a),l&&(s.push(new c(l,e)),n=!0);if(!n)for(t=-1;++t<F;)if(i=b[t],d=i.isSingleMatch(a),d){s.push(new i(d,e));break}}return s})}var ee=new Set([P.type,L.type]),et=function(){function s(h){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isCaseSensitive,a=void 0===i?e.isCaseSensitive:i,r=n.includeMatches,j=void 0===r?e.includeMatches:r,l=n.minMatchCharLength,v=void 0===l?e.minMatchCharLength:l,u=n.ignoreLocation,f=void 0===u?e.ignoreLocation:u,m=n.findAllMatches,p=void 0===m?e.findAllMatches:m,o=n.location,g=void 0===o?e.location:o,d=n.threshold,b=void 0===d?e.threshold:d,c=n.distance,y=void 0===c?e.distance:c;t(this,s),this.query=null,this.options={isCaseSensitive:a,includeMatches:j,minMatchCharLength:v,findAllMatches:p,ignoreLocation:f,location:g,threshold:b,distance:y},this.pattern=a?h:h.toLowerCase(),this.query=J(this.pattern,this.options)}return n(s,[{key:"searchIn",value:function(n){if(o=this.query,!o)return{isMatch:!1,score:1};c=this.options,h=c.includeMatches,n=c.isCaseSensitive?n:n.toLowerCase();for(var o,c,h,t=0,e=[],s=0,i=0,v=o.length,m,a,p,j,f;i<v;i+=1){m=o[i],e.length=0,t=0;for(a=0,p=m.length;a<p;a+=1){var d=m[a],r=d.search(n),g=r.isMatch,u=r.indices,b=r.score;if(!g){s=0,t=0,e.length=0;break}t+=1,s+=b,h&&(j=d.constructor.type,ee.has(j)?e=[].concat(l(e),l(u)):e.push(u))}if(t)return f={isMatch:!0,score:s/t},h&&(f.indices=e),f}return{isMatch:!1,score:1}}}],[{key:"condition",value:function(t,e){return e.useExtendedSearch}}]),s}(),f=[];function C(e,t){for(var n=0,o=f.length,s;n<o;n+=1)if(s=f[n],s.condition(e,t))return new s(e,t);return new H(e,t)}var O="$and",ei="$or",S="$path",er="$val",_=function(e){return!(!e[O]&&!e[ei])},el=function(e){return!!e[S]},ed=function(e){return!o(e)&&T(e)&&!_(e)},N=function(e){return y({},O,Object.keys(e).map(function(t){return y({},t,e[t])}))};function e1(n,s){var t=s.ignoreFieldNorm,o=void 0===t?e.ignoreFieldNorm:t;n.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 e4(n,e){var t=n.matches;e.matches=[],s(t)&&t.forEach(function(t){if(s(t.indices)&&t.indices.length){var n={indices:t.indices,value:t.value};t.key&&(n.key=t.key.src),t.idx>-1&&(n.refIndex=t.idx),e.matches.push(n)}})}function e0(e,t){t.score=e.score}function e2(i,c){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=n.includeMatches,a=void 0===s?e.includeMatches:s,o=n.includeScore,r=void 0===o?e.includeScore:o,t=[];return a&&t.push(e4),r&&t.push(e0),i.map(function(e){var n=e.idx,s={item:c[n],refIndex:n};return t.length&&t.forEach(function(t){t(e,s)}),s})}return h=function(){function a(n){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;t(this,a),this.options=u(u({},e),s),this.options.useExtendedSearch,this._keyStore=new es(this.options.keys),this.setCollection(n,o)}return n(a,[{key:"setCollection",value:function(t,e){if(this._docs=t,e&&!(e instanceof v))throw new Error("Incorrect 'index' type");this._myIndex=e||D(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){s(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],e=0,n=this._docs.length,s;e<n;e+=1)s=this._docs[e],o(s,e)&&(this.removeAt(e),e-=1,n-=1,t.push(s));return t}},{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(n){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=a.limit,s=void 0===o?-1:o,e=this.options,r=e.includeMatches,c=e.includeScore,l=e.shouldSort,d=e.sortFn,u=e.ignoreFieldNorm,t=i(n)?i(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return e1(t,{ignoreFieldNorm:u}),l&&t.sort(d),z(s)&&s>-1&&(t=t.slice(0,s)),e2(t,this._docs,{includeMatches:r,includeScore:c})}},{key:"_searchStringList",value:function(t){var n=C(t,this.options),o=this._myIndex.records,e=[];return o.forEach(function(o){var t=o.v,a=o.i,r=o.n;if(s(t)){var i=n.searchIn(t),c=i.isMatch,l=i.score,d=i.indices;c&&e.push({item:t,idx:a,matches:[{score:l,value:t,norm:r,indices:d}]})}}),e}},{key:"_searchLogical",value:function(d){var t=this,a=function(e,n){var t=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).auto,s=void 0===t||t,a=function l(e){var t=Object.keys(e),a=el(e),r,c,d,u;if(!a&&t.length>1&&!_(e))return l(N(e));if(ed(e)){if(r=a?e[S]:t[0],c=a?e[er]:e[r],!i(c))throw new Error(ea(r));return d={keyId:x(r),pattern:c},s&&(d.searcher=C(c,n)),d}return u={children:[],operator:t[0]},t.forEach(function(n){var t=e[n];o(t)&&t.forEach(function(e){u.children.push(l(e))})}),u};return _(e)||(e=N(e)),a(e)}(d,this.options),r=function u(e,s,a){if(!e.children){var r=e.keyId,d=e.searcher,n=t._findMatches({key:t._keyStore.get(r),value:t._myIndex.getValueForItemAtKeyId(s,r),searcher:d}),c;return n&&n.length?[{idx:a,item:s,matches:n}]:[]}for(var o=[],i=0,h=e.children.length;i<h;i+=1)if(c=u(e.children[i],s,a),c.length)o.push.apply(o,l(c));else if(e.operator===O)return[];return o},c=this._myIndex.records,e={},n=[];return c.forEach(function(i){var o=i.$,t=i.i,c;s(o)&&(c=r(a,o,t),c.length&&(e[t]||(e[t]={idx:t,item:o,matches:[]},n.push(e[t])),c.forEach(function(s){var n,o=s.matches;(n=e[t].matches).push.apply(n,l(o))})))}),n}},{key:"_searchObjectList",value:function(r){var n=this,o=C(r,this.options),t=this._myIndex,i=t.keys,a=t.records,e=[];return a.forEach(function(r){var a=r.$,c=r.i,t;s(a)&&(t=[],i.forEach(function(e,s){t.push.apply(t,l(n._findMatches({key:e,value:a[s],searcher:o})))}),t.length&&e.push({idx:c,item:a,matches:t}))}),e}},{key:"_findMatches",value:function(t){var c=t.key,e=t.value,a=t.searcher;if(!s(e))return[];if(i=[],o(e))e.forEach(function(e){var t=e.v,o=e.i,r=e.n;if(s(t)){var n=a.searchIn(t),l=n.isMatch,d=n.score,u=n.indices;l&&i.push({score:d,key:c,value:t,idx:o,norm:r,indices:u})}});else{var i,r=e.v,l=e.n,n=a.searchIn(r),d=n.isMatch,u=n.score,h=n.indices;d&&i.push({score:u,key:c,value:r,norm:l,indices:h})}return i}}]),a}(),h.version="6.5.3",h.createIndex=D,h.parseIndex=function(n){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=s.getFn,a=void 0===i?e.getFn:i,o=s.fieldNormWeight,r=void 0===o?e.fieldNormWeight:o,c=n.keys,l=n.records,t=new v({getFn:a,fieldNormWeight:r});return t.setKeys(c),t.setIndexRecords(l),t},h.config=e,function(){f.push.apply(f,arguments)}(et),h},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Fuse=t();var e,t,fuse,showButton=document.getElementById("search-button"),scriptBundle,copyText,copiedText,hideButton=document.getElementById("close-search-button"),wrapper=document.getElementById("search-wrapper"),modal=document.getElementById("search-modal"),input=document.getElementById("search-query"),output=document.getElementById("search-results"),first=output.firstChild,last=output.lastChild,searchVisible=!1,indexed=!1,hasResults=!1;showButton.addEventListener("click",displaySearch),hideButton.addEventListener("click",hideSearch),wrapper.addEventListener("click",hideSearch),modal.addEventListener("click",function(e){return e.stopPropagation(),e.stopImmediatePropagation(),!1}),document.addEventListener("keydown",function(e){e.key=="/"&&(searchVisible||(e.preventDefault(),displaySearch())),e.key=="Escape"&&hideSearch(),e.key=="ArrowDown"&&searchVisible&&hasResults&&(e.preventDefault(),document.activeElement==input?first.focus():document.activeElement==last?last.focus():document.activeElement.parentElement.nextSibling.firstElementChild.focus()),e.key=="ArrowUp"&&searchVisible&&hasResults&&(e.preventDefault(),document.activeElement==input?input.focus():document.activeElement==first?input.focus():document.activeElement.parentElement.previousSibling.firstElementChild.focus())}),input.onkeyup=function(){executeQuery(this.value)};function displaySearch(){indexed||buildIndex(),searchVisible||(document.body.style.overflow="hidden",wrapper.style.visibility="visible",input.focus(),searchVisible=!0)}function hideSearch(){searchVisible&&(document.body.style.overflow="visible",wrapper.style.visibility="hidden",input.value="",output.innerHTML="",document.activeElement.blur(),searchVisible=!1)}function fetchJSON(n,t){var e=new XMLHttpRequest;e.onreadystatechange=function(){if(e.readyState===4)if(e.status===200){var n=JSON.parse(e.responseText);t&&t(n)}},e.open("GET",n),e.send()}function buildIndex(){var e=wrapper.getAttribute("data-url");fetchJSON(e+"index.json",function(e){var t={shouldSort:!0,ignoreLocation:!0,threshold:0,includeMatches:!0,keys:[{name:"title",weight:.8},{name:"section",weight:.2},{name:"summary",weight:.6},{name:"content",weight:.4}]};fuse=new Fuse(e,t),indexed=!0})}function executeQuery(n){let t=fuse.search(n),e="";t.length>0?(t.forEach(function(t){e=e+`<li class="mb-2">
|
|
<a class="flex items-center px-3 py-2 rounded-md appearance-none bg-neutral-100 dark:bg-neutral-700 focus:bg-primary-100 hover:bg-primary-100 dark:hover:bg-primary-900 dark:focus:bg-primary-900 focus:outline-dotted focus:outline-transparent focus:outline-2" href="${t.item.permalink}" tabindex="0">
|
|
<div class="grow">
|
|
<div class="-mb-1 text-lg font-bold">${t.item.title}</div>
|
|
<div class="text-sm text-neutral-500 dark:text-neutral-400">${t.item.section}<span class="px-2 text-primary-500">·</span>${t.item.date}</span></div>
|
|
<div class="text-sm italic">${t.item.summary}</div>
|
|
</div>
|
|
<div class="ml-2 ltr:block rtl:hidden text-neutral-500">→</div>
|
|
<div class="mr-2 ltr:hidden rtl:block text-neutral-500">←</div>
|
|
</a>
|
|
</li>`}),hasResults=!0):(e="",hasResults=!1),output.innerHTML=e,t.length>0&&(first=output.firstChild.firstElementChild,last=output.lastChild.firstElementChild)}scriptBundle=document.getElementById("script-bundle"),copyText=scriptBundle?scriptBundle.getAttribute("data-copy"):"Copy",copiedText=scriptBundle?scriptBundle.getAttribute("data-copied"):"Copied";function createCopyButton(t){const e=document.createElement("button");e.className="copy-button",e.type="button",e.ariaLabel=copyText,e.innerText=copyText,e.addEventListener("click",()=>copyCodeToClipboard(e,t)),addCopyButtonToDom(e,t)}async function copyCodeToClipboard(n,e){const t=e.querySelector(":last-child > .chroma > code").innerText;try{result=await navigator.permissions.query({name:"clipboard-write"}),result.state=="granted"||result.state=="prompt"?await navigator.clipboard.writeText(t):copyCodeBlockExecCommand(t,e)}catch(n){copyCodeBlockExecCommand(t,e)}finally{codeWasCopied(n)}}function copyCodeBlockExecCommand(o,t){const e=document.createElement("textArea");e.contentEditable="true",e.readOnly="false",e.className="copy-textarea",e.value=o,t.insertBefore(e,t.firstChild);const n=document.createRange();n.selectNodeContents(e);const s=window.getSelection();s.removeAllRanges(),s.addRange(n),e.setSelectionRange(0,999999),document.execCommand("copy"),t.removeChild(e)}function codeWasCopied(e){e.blur(),e.innerText=copiedText,setTimeout(function(){e.innerText=copyText},2e3)}function addCopyButtonToDom(n,e){e.insertBefore(n,e.firstChild);const t=document.createElement("div");t.className="highlight-wrapper",e.parentNode.insertBefore(t,e),t.appendChild(e)}window.addEventListener("DOMContentLoaded",e=>{document.querySelectorAll(".highlight").forEach(e=>createCopyButton(e))}) |