mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-26 12:31:39 +01:00
1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
var e,t;e=this,t=function(){"use strict";var u,s,l,t,x,a,z,i,c,A,m,g;function B(a,d){var b=Object.keys(a),c;return Object.getOwnPropertySymbols&&(c=Object.getOwnPropertySymbols(a),d&&(c=c.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),b.push.apply(b,c)),b}function f(c){for(var a=1,b;a<arguments.length;a++)b=null!=arguments[a]?arguments[a]:{},a%2?B(Object(b),!0).forEach(function(a){J(c,a,b[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(b)):B(Object(b)).forEach(function(a){Object.defineProperty(c,a,Object.getOwnPropertyDescriptor(b,a))});return c}function n(a){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},n(a)}function j(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function y(d,c){for(var b=0,a;b<c.length;b++)a=c[b],a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(d,a.key,a)}function h(a,b,c){return b&&y(a.prototype,b),c&&y(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function J(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function q(a){return function(a){if(Array.isArray(a))return p(a)}(a)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||function(a,c){if(a){if("string"==typeof a)return p(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);return"Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b?Array.from(a):"Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?p(a,c):void 0}}(a)||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 p(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b<a;b++)d[b]=c[b];return d}function e(a){return Array.isArray?Array.isArray(a):"[object Array]"===D(a)}function d(a){return"string"==typeof a}function r(a){return"number"==typeof a}function O(a){return!0===a||!1===a||function(a){return function(a){return"object"===n(a)}(a)&&null!==a}(a)&&"[object Boolean]"==D(a)}function b(a){return null!=a}function o(a){return!a.trim().length}function D(a){return null==a?void 0===a?"[object Undefined]":"[object Null]":Object.prototype.toString.call(a)}u="Extended search is not available",s=function(a){return"Pattern length exceeds max of ".concat(a,".")},l=Object.prototype.hasOwnProperty,t=function(){function a(d){var c=this,b;j(this,a),this._keys=[],this._keyMap={},b=0,d.forEach(function(d){var a=E(d);b+=a.weight,c._keys.push(a),c._keyMap[a.id]=a,b+=a.weight}),this._keys.forEach(function(a){a.weight/=b})}return h(a,[{key:"get",value:function(a){return this._keyMap[a]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),a}();function E(a){var c=null,f=null,g=null,h=1,b;if(d(a)||e(a))g=a,c=v(a),f=w(a);else{if(!l.call(a,"name"))throw new Error(function(a){return"Missing ".concat(a," property in key")}("name"));if(b=a.name,g=b,l.call(a,"weight")&&(h=a.weight)<=0)throw new Error(function(a){return"Property 'weight' in key '".concat(a,"' must be a positive integer")}(b));c=v(b),f=w(b)}return{path:c,id:f,weight:h,src:g}}function v(a){return e(a)?a:a.split(".")}function w(a){return e(a)?a.join("."):a}x={useExtendedSearch:!1,getFn:function(g,c){var a=[],f=!1;return function k(j,g,h){var c,i,l;if(b(j))if(g[h]){if(c=j[g[h]],!b(c))return;if(h===g.length-1&&(d(c)||r(c)||O(c)))a.push(function(a){return null==a?"":function(a){if("string"==typeof a)return a;var b=a+"";return"0"==b&&1/a==-1/0?"-0":b}(a)}(c));else if(e(c)){f=!0;for(i=0,l=c.length;i<l;i+=1)k(c[i],g,h+1)}else g.length&&k(c,g,h+1)}else a.push(j)}(g,d(c)?c.split("."):c,0),f?a:a[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},a=f(f(f(f({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(a,b){return a.score===b.score?a.idx<b.idx?-1:1:a.score<b.score?-1:1}}),{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1}),{location:0,threshold:.6,distance:100}),x),z=/[^ ]+/g;function I(){var c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,a=new Map,b=Math.pow(10,d);return{get:function(f){var d=f.match(z).length,g,e;return a.has(d)?a.get(d):(g=1/Math.pow(d,.5*c),e=parseFloat(Math.round(g*b)/b),a.set(d,e),e)},clear:function(){a.clear()}}}i=function(){function c(){var b=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},d=b.getFn,f=void 0===d?a.getFn:d,e=b.fieldNormWeight,g=void 0===e?a.fieldNormWeight:e;j(this,c),this.norm=I(g,3),this.getFn=f,this.isCreated=!1,this.setIndexRecords()}return h(c,[{key:"setSources",value:function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=a}},{key:"setIndexRecords",value:function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=a}},{key:"setKeys",value:function(){var b=this,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=a,this._keysMap={},a.forEach(function(a,c){b._keysMap[a.id]=c})}},{key:"create",value:function(){var a=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,d(this.docs[0])?this.docs.forEach(function(b,c){a._addString(b,c)}):this.docs.forEach(function(b,c){a._addObject(b,c)}),this.norm.clear())}},{key:"add",value:function(a){var b=this.size();d(a)?this._addString(a,b):this._addObject(a,b)}},{key:"removeAt",value:function(b){this.records.splice(b,1);for(var a=b,c=this.size();a<c;a+=1)this.records[a].i-=1}},{key:"getValueForItemAtKeyId",value:function(a,b){return a[this._keysMap[b]]}},{key:"size",value:function(){return this.records.length}},{key:"_addString",value:function(a,c){if(b(a)&&!o(a)){var d={v:a,i:c,n:this.norm.get(a)};this.records.push(d)}}},{key:"_addObject",value:function(f,g){var a=this,c={i:g,$:{}};this.keys.forEach(function(i,h){var g=a.getFn(f,i.path),j;b(g)&&(e(g)?!function(){for(var j=[],i=[{nestedArrIndex:-1,value:g}],k,l,f,m;i.length;)k=i.pop(),l=k.nestedArrIndex,f=k.value,b(f)&&(d(f)&&!o(f)?(m={v:f,i:l,n:a.norm.get(f)},j.push(m)):e(f)&&f.forEach(function(a,b){i.push({nestedArrIndex:b,value:a})}));c.$[h]=j}():o(g)||(j={v:g,n:a.norm.get(g)},c.$[h]=j))}),this.records.push(c)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),c}();function C(f,j){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},d=c.getFn,g=void 0===d?a.getFn:d,e=c.fieldNormWeight,h=void 0===e?a.fieldNormWeight:e,b=new i({getFn:g,fieldNormWeight:h});return b.setKeys(f.map(E)),b.setSources(j),b.create(),b}function k(o){var b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=b.errors,n=void 0===e?0:e,f=b.currentLocation,l=void 0===f?0:f,h=b.expectedLocation,k=void 0===h?0:h,j=b.distance,d=void 0===j?a.distance:j,g=b.ignoreLocation,m=void 0===g?a.ignoreLocation:g,c=n/o.length,i;return m?c:(i=Math.abs(k-l),d?c+i/d:i?1:c)}function G(){for(var d=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.minMatchCharLength,e=[],b=-1,g=-1,c=0,i=d.length,h;c<i;c+=1)h=d[c],h&&-1===b?b=c:h||-1===b||((g=c-1)-b+1>=f&&e.push([b,g]),b=-1);return d[c-1]&&c-b>=f&&e.push([b,c-1]),e}c=32;function H(c){for(var b={},a=0,d=c.length,e;a<d;a+=1)e=c.charAt(a),b[e]=(b[e]||0)|1<<d-a-1;return b}A=function(){function b(q){var A=this,d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},k=d.location,z=void 0===k?a.location:k,i=d.threshold,y=void 0===i?a.threshold:i,l=d.distance,x=void 0===l?a.distance:l,n=d.includeMatches,v=void 0===n?a.includeMatches:n,p=d.findAllMatches,C=void 0===p?a.findAllMatches:p,r=d.minMatchCharLength,u=void 0===r?a.minMatchCharLength:r,h=d.isCaseSensitive,s=void 0===h?a.isCaseSensitive:h,o=d.ignoreLocation,w=void 0===o?a.ignoreLocation:o,g,f,e,m,B,t;if(j(this,b),this.options={location:z,threshold:y,distance:x,includeMatches:v,findAllMatches:C,minMatchCharLength:u,isCaseSensitive:s,ignoreLocation:w},this.pattern=s?q:q.toLowerCase(),this.chunks=[],this.pattern.length)if(g=function(a,b){A.chunks.push({pattern:a,alphabet:H(a),startIndex:b})},f=this.pattern.length,f>c){for(e=0,m=f%c,B=f-m;e<B;)g(this.pattern.substr(e,c),e),e+=c;m&&(t=f-c,g(this.pattern.substr(t),t))}else g(this.pattern,0)}return h(b,[{key:"searchIn",value:function(d){var j=this.options,t=j.isCaseSensitive,g=j.includeMatches,h,b,r,p,u,m,n,o,f,i,e,l;return t||(d=d.toLowerCase()),this.pattern===d?(h={isMatch:!0,score:0},g&&(h.indices=[[0,d.length-1]]),h):(b=this.options,r=b.location,p=b.distance,u=b.threshold,m=b.findAllMatches,n=b.minMatchCharLength,o=b.ignoreLocation,f=[],i=0,e=!1,this.chunks.forEach(function(b){var x=b.pattern,t=b.alphabet,v=b.startIndex,h=function(A,f,U){var g=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},N=g.location,S=void 0===N?a.location:N,M=g.distance,t=void 0===M?a.distance:M,K=g.threshold,T=void 0===K?a.threshold:K,P=g.findAllMatches,R=void 0===P?a.findAllMatches:P,I=g.minMatchCharLength,H=void 0===I?a.minMatchCharLength:I,F=g.includeMatches,E=void 0===F?a.includeMatches:F,D=g.ignoreLocation,v=void 0===D?a.ignoreLocation:D,w,m,n,b,j,i,p,C,Q,y,q,x,o,V,h,u,e,O,z,l,d,r,J,B,L;if(f.length>c)throw new Error(s(c));for(w,m=f.length,n=A.length,b=Math.max(0,Math.min(S,n)),j=T,i=b,p=H>1||E,C=p?Array(n):[];(w=A.indexOf(f,i))>-1;)if(Q=k(f,{currentLocation:w,expectedLocation:b,distance:t,ignoreLocation:v}),j=Math.min(Q,j),i=w+m,p)for(y=0;y<m;)C[w+y]=1,y+=1;i=-1;for(q=[],x=1,o=m+n,V=1<<m-1,h=0;h<m;h+=1){for(u=0,e=o;u<e;)k(f,{errors:h,currentLocation:b+e,expectedLocation:b,distance:t,ignoreLocation:v})<=j?u=e:o=e,e=Math.floor((o-u)/2+u);o=e,O=Math.max(1,b-e+1),z=R?n:Math.min(b+e,n)+m,l=Array(z+2),l[z+1]=(1<<h)-1;for(d=z;d>=O;d-=1)if(r=d-1,J=U[A.charAt(r)],p&&(C[r]=+!!J),l[d]=(l[d+1]<<1|1)&J,h&&(l[d]|=(q[d+1]|q[d])<<1|1|q[d+1]),l[d]&V&&(x=k(f,{errors:h,currentLocation:r,expectedLocation:b,distance:t,ignoreLocation:v}))<=j){if(j=x,(i=r)<=b)break;O=Math.max(1,2*b-i)}if(k(f,{errors:h+1,currentLocation:b,expectedLocation:b,distance:t,ignoreLocation:v})>j)break;q=l}return B={isMatch:i>=0,score:Math.max(.001,x)},p&&(L=G(C,H),L.length?E&&(B.indices=L):B.isMatch=!1),B}(d,x,t,{location:r+v,distance:p,threshold:u,findAllMatches:m,minMatchCharLength:n,includeMatches:g,ignoreLocation:o}),l=h.isMatch,w=h.score,j=h.indices;l&&(e=!0),i+=w,l&&j&&(f=[].concat(q(f),q(j)))}),l={isMatch:e,score:e?i/this.chunks.length:1},e&&g&&(l.indices=f),l)}}]),b}(),m=[];function F(a,b){for(var c=0,e=m.length,d;c<e;c+=1)if(d=m[c],d.condition(a,b))return new d(a,b);return new A(a,b)}function K(c,d){var b=d.ignoreFieldNorm,e=void 0===b?a.ignoreFieldNorm:b;c.forEach(function(a){var b=1;a.matches.forEach(function(a){var c=a.key,g=a.norm,d=a.score,f=c?c.weight:null;b*=Math.pow(0===d&&f?Number.EPSILON:d,(f||1)*(e?1:g))}),a.score=b})}function L(d,a){var c=d.matches;a.matches=[],b(c)&&c.forEach(function(c){if(b(c.indices)&&c.indices.length){var d={indices:c.indices,value:c.value};c.key&&(d.key=c.key.src),c.idx>-1&&(d.refIndex=c.idx),a.matches.push(d)}})}function M(a,b){b.score=a.score}function N(f,i){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},d=c.includeMatches,g=void 0===d?a.includeMatches:d,e=c.includeScore,h=void 0===e?a.includeScore:e,b=[];return g&&b.push(L),h&&b.push(M),f.map(function(a){var c=a.idx,d={item:i[c],refIndex:c};return b.length&&b.forEach(function(b){b(a,d)}),d})}return g=function(){function c(b){var d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=arguments.length>2?arguments[2]:void 0;if(j(this,c),this.options=f(f({},a),d),this.options.useExtendedSearch)throw new Error(u);this._keyStore=new t(this.options.keys),this.setCollection(b,e)}return h(c,[{key:"setCollection",value:function(b,a){if(this._docs=b,a&&!(a instanceof i))throw new Error("Incorrect 'index' type");this._myIndex=a||C(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(a){b(a)&&(this._docs.push(a),this._myIndex.add(a))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},b=[],a=0,c=this._docs.length,d;a<c;a+=1)d=this._docs[a],e(d,a)&&(this.removeAt(a),a-=1,c-=1,b.push(d));return b}},{key:"removeAt",value:function(a){this._docs.splice(a,1),this._myIndex.removeAt(a)}},{key:"getIndex",value:function(){return this._myIndex}},{key:"search",value:function(c){var g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},f=g.limit,e=void 0===f?-1:f,a=this.options,h=a.includeMatches,i=a.includeScore,j=a.shouldSort,k=a.sortFn,l=a.ignoreFieldNorm,b=d(c)?d(this._docs[0])?this._searchStringList(c):this._searchObjectList(c):this._searchLogical(c);return K(b,{ignoreFieldNorm:l}),j&&b.sort(k),r(e)&&e>-1&&(b=b.slice(0,e)),N(b,this._docs,{includeMatches:h,includeScore:i})}},{key:"_searchStringList",value:function(c){var d=F(c,this.options),e=this._myIndex.records,a=[];return e.forEach(function(e){var c=e.v,g=e.i,h=e.n,f,i,j,k;b(c)&&(f=d.searchIn(c),i=f.isMatch,j=f.score,k=f.indices,i&&a.push({item:c,idx:g,matches:[{score:j,value:c,norm:h,indices:k}]}))}),a}},{key:"_searchLogical",value:function(a){throw new Error("Logical search is not available")}},{key:"_searchObjectList",value:function(h){var d=this,e=F(h,this.options),c=this._myIndex,f=c.keys,g=c.records,a=[];return g.forEach(function(h){var g=h.$,i=h.i,c;b(g)&&(c=[],f.forEach(function(a,b){c.push.apply(c,q(d._findMatches({key:a,value:g[b],searcher:e})))}),c.length&&a.push({idx:i,item:g,matches:c}))}),a}},{key:"_findMatches",value:function(c){var i=c.key,a=c.value,g=c.searcher,f,h,j,d,k,l,m;return b(a)?(f=[],e(a)?a.forEach(function(a){var c=a.v,e=a.i,h=a.n,d,j,k,l;b(c)&&(d=g.searchIn(c),j=d.isMatch,k=d.score,l=d.indices,j&&f.push({score:k,key:i,value:c,idx:e,norm:h,indices:l}))}):(h=a.v,j=a.n,d=g.searchIn(h),k=d.isMatch,l=d.score,m=d.indices,k&&f.push({score:l,key:i,value:h,norm:j,indices:m})),f):[]}}]),c}(),g.version="6.5.3",g.createIndex=C,g.parseIndex=function(c){var d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},f=d.getFn,g=void 0===f?a.getFn:f,e=d.fieldNormWeight,h=void 0===e?a.fieldNormWeight:e,j=c.keys,k=c.records,b=new i({getFn:g,fieldNormWeight:h});return b.setKeys(j),b.setIndexRecords(k),b},g.config=a,g},"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 a=null,c=document.getElementById("searchResults"),b=document.getElementById("searchInput"),f=null,d=!1,i,g,h;window.onload=function(){var b=new XMLHttpRequest;b.onreadystatechange=function(){var c,d;b.readyState===4&&(b.status===200?(c=JSON.parse(b.responseText),c&&(d={distance:100,threshold:.4,ignoreLocation:!0,keys:["title","permalink","summary","content"]},a&&(d={isCaseSensitive:!!a.iscasesensitive&&a.iscasesensitive,includeScore:!!a.includescore&&a.includescore,includeMatches:!!a.includematches&&a.includematches,minMatchCharLength:a.minmatchcharlength?a.minmatchcharlength:1,shouldSort:!a.shouldsort||a.shouldsort,findAllMatches:!!a.findallmatches&&a.findallmatches,keys:a.keys?a.keys:["title","permalink","summary","content"],location:a.location?a.location:0,threshold:a.threshold?a.threshold:.4,distance:a.distance?a.distance:100,ignoreLocation:!a.ignorelocation||a.ignorelocation}),g=new Fuse(c,d))):console.log(b.responseText))},b.open("GET","../index.json"),b.send()};function e(a){document.querySelectorAll(".focus").forEach(function(a){a.classList.remove("focus")}),a?(a.focus(),document.activeElement=f=a,a.parentElement.classList.add("focus")):document.activeElement.parentElement.classList.add("focus")}function j(){d=!1,c.innerHTML=b.value="",b.focus()}b.onkeyup=function(a){if(g){const a=g.search(this.value.trim());if(a.length!==0){let b="";for(let c in a)b+=`<li class="post-entry"><header class="entry-header">${a[c].item.title} \xBB</header><a href="${a[c].item.permalink}" aria-label="${a[c].item.title}"></a></li>`;c.innerHTML=b,d=!0,h=c.firstChild,i=c.lastChild}else d=!1,c.innerHTML=""}},b.addEventListener("search",function(a){this.value||j()}),document.onkeydown=function(k){var a,l;let g=k.key;a=document.activeElement;let m=document.getElementById("searchbox").contains(a);if(a===b)for(l=document.getElementsByClassName("focus");l.length>0;)l[0].classList.remove("focus");else f&&(a=f);if(g==="Escape")j();else if(!d||!m)return;else g==="ArrowDown"?(k.preventDefault(),a==b?e(c.firstChild.lastChild):a.parentElement!=i&&e(a.parentElement.nextSibling.lastChild)):g==="ArrowUp"?(k.preventDefault(),a.parentElement==h?e(b):a!=b&&e(a.parentElement.previousSibling.lastChild)):g==="ArrowRight"&&a.click()}})() |