4 lines
1.7 KiB
JavaScript
4 lines
1.7 KiB
JavaScript
|
"use strict";(()=>{var o=(e,r,t)=>new Promise((s,a)=>{var n=i=>{try{c(t.next(i))}catch(l){a(l)}},h=i=>{try{c(t.throw(i))}catch(l){a(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(n,h);c((t=t.apply(e,r)).next())});Object.entries||(Object.entries=function(e){let r=[];for(let t of Object.keys(e))r.push([t,e[t]]);return r});Object.values||(Object.values=function(e){let r=[];for(let t of Object.keys(e))r.push(e[t]);return r});typeof Element!="undefined"&&(Element.prototype.scrollTo||(Element.prototype.scrollTo=function(e,r){typeof e=="object"?(this.scrollLeft=e.left,this.scrollTop=e.top):(this.scrollLeft=e,this.scrollTop=r)}),Element.prototype.replaceWith||(Element.prototype.replaceWith=function(...e){let r=this.parentNode;if(r){e.length===0&&r.removeChild(this);for(let t=e.length-1;t>=0;t--){let s=e[t];typeof s=="string"?s=document.createTextNode(s):s.parentNode&&s.parentNode.removeChild(s),t?r.insertBefore(this.previousSibling,s):r.replaceChild(s,this)}}}));var p;function u(e){return o(this,null,function*(){if(e=e.trim(),!e)return{items:[]};let t=yield(yield fetch(`${p}?s=${e}`,{credentials:"same-origin"})).json(),s=1e6;return{items:t.map(a=>(a.highlight||[""]).map(n=>({title:a.title,location:a.url.startsWith("/")?a.url.slice(1):a.url,terms:{[e]:!0},text:n.split("<em>").join("<mark>").split("</em>").join("</mark>"),score:--s})))}})}function f(e){return o(this,null,function*(){switch(e.type){case 0:return p=e.data,{type:1};case 2:return{type:3,data:yield u(e.data)};default:throw new TypeError("Invalid message type")}})}addEventListener("message",e=>o(void 0,null,function*(){postMessage(yield f(e.data))}));})();
|
||
|
//# sourceMappingURL=search.b6c651e9.min.js.map
|
||
|
|