var t,e,n,i,r,s,o,l,h,a,c,u,f={},d=[],p=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,g=Array.isArray;function _(t,e){for(var n in e)t[n]=e[n];return t}function m(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function y(e,n,i){var r,s,o,l={};for(o in n)"key"==o?r=n[o]:"ref"==o?s=n[o]:l[o]=n[o];if(arguments.length>2&&(l.children=arguments.length>3?t.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===l[o]&&(l[o]=e.defaultProps[o]);return x(e,l,r,s,null)}function x(t,i,r,s,o){var l={type:t,props:i,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==o?++n:o,__i:-1,__u:0};return null==o&&null!=e.vnode&&e.vnode(l),l}function w(t){return t.children}function b(t,e){this.props=t,this.context=e}function v(t,e){if(null==e)return t.__?v(t.__,t.__i+1):null;for(var n;ec&&i.sort(o),t=i.shift(),c=i.length,t.__d&&(r=void 0,l=(s=(n=t).__v).__e,h=[],a=[],n.__P&&((r=_({},s)).__v=s.__v+1,e.vnode&&e.vnode(r),M(n.__P,r,s,n.__n,n.__P.namespaceURI,32&s.__u?[l]:null,h,null==l?v(s):l,!!(32&s.__u),a),r.__v=s.__v,r.__.__k[r.__i]=r,D(h,r,a),r.__e!=l&&k(r)));S.__r=0}function C(t,e,n,i,r,s,o,l,h,a,c){var u,p,_,m,y,b,k=i&&i.__k||d,A=e.length;for(h=function(t,e,n,i,r){var s,o,l,h,a,c=n.length,u=c,f=0;for(t.__k=new Array(r),s=0;s0?x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=t,o.__b=t.__b+1,l=null,-1!=(a=o.__i=N(o,n,h,u))&&(u--,(l=n[a])&&(l.__u|=2)),null==l||null==l.__v?(-1==a&&(r>c?f--:rh?f--:f++,o.__u|=4))):t.__k[s]=null;if(u)for(s=0;s(c?1:0))for(r=n-1,s=n+1;r>=0||s=0?r--:s++])&&!(2&a.__u)&&l==a.key&&h==a.type)return o;return-1}function z(t,e,n){"-"==e[0]?t.setProperty(e,null==n?"":n):t[e]=null==n?"":"number"!=typeof n||p.test(e)?n:n+"px"}function j(t,e,n,i,r){var s,o;t:if("style"==e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof i&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||z(t.style,e,"");if(n)for(e in n)i&&n[e]==i[e]||z(t.style,e,n[e])}else if("o"==e[0]&&"n"==e[1])s=e!=(e=e.replace(l,"$1")),o=e.toLowerCase(),e=o in t||"onFocusOut"==e||"onFocusIn"==e?o.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?i?n.u=i.u:(n.u=h,t.addEventListener(e,s?c:a,s)):t.removeEventListener(e,s?c:a,s);else{if("http://www.w3.org/2000/svg"==r)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=e&&"height"!=e&&"href"!=e&&"list"!=e&&"form"!=e&&"tabIndex"!=e&&"download"!=e&&"rowSpan"!=e&&"colSpan"!=e&&"role"!=e&&"popover"!=e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null==n||!1===n&&"-"!=e[4]?t.removeAttribute(e):t.setAttribute(e,"popover"==e&&1==n?"":n))}}function I(t){return function(n){if(this.l){var i=this.l[n.type+t];if(null==n.t)n.t=h++;else if(n.t0?t:g(t)?t.map(L):_({},t)}function B(n,i,r,s,o,l,h,a,c){var u,d,p,_,y,x,w,b=r.props,k=i.props,A=i.type;if("svg"==A?o="http://www.w3.org/2000/svg":"math"==A?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),null!=l)for(u=0;u=n.__.length&&n.__.push({}),n.__[t]}function tt(t){return q=1,function(t,e){var n=Y($++,2);if(n.t=t,!n.__c&&(n.__=[ut(void 0,e),function(t){var e=n.__N?n.__N[0]:n.__[0],i=n.t(e,t);e!==i&&(n.__N=[i,n.__[1]],n.__c.setState({}))}],n.__c=H,!H.__f)){var i=function(t,e,i){if(!n.__c.__H)return!0;var s=n.__c.__H.__.filter(function(t){return!!t.__c});if(s.every(function(t){return!t.__N}))return!r||r.call(this,t,e,i);var o=n.__c.props!==t;return s.forEach(function(t){if(t.__N){var e=t.__[0];t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(o=!0)}}),r&&r.call(this,t,e,i)||o};H.__f=!0;var r=H.shouldComponentUpdate,s=H.componentWillUpdate;H.componentWillUpdate=function(t,e,n){if(this.__e){var o=r;r=void 0,i(t,e,n),r=o}s&&s.call(this,t,e,n)},H.shouldComponentUpdate=i}return n.__N||n.__}(ut,t)}function et(t,e){var n=Y($++,3);!W.__s&&ct(n.__H,e)&&(n.__=t,n.u=e,H.__H.__h.push(n))}function nt(t){return q=5,it(function(){return{current:t}},[])}function it(t,e){var n=Y($++,7);return ct(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function rt(t){var e=H.context[t.__c],n=Y($++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(H)),e.props.value):t.__}function st(){for(var t;t=K.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ht),t.__H.__h.forEach(at),t.__H.__h=[]}catch(e){t.__H.__h=[],W.__e(e,t.__v)}}W.__b=function(t){H=null,J&&J(t)},W.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Z&&Z(t,e)},W.__r=function(t){V&&V(t),$=0;var e=(H=t.__c).__H;e&&(F===H?(e.__h=[],H.__h=[],e.__.forEach(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(e.__h.forEach(ht),e.__h.forEach(at),e.__h=[],$=0)),F=H},W.diffed=function(t){G&&G(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(1!==K.push(e)&&R===W.requestAnimationFrame||((R=W.requestAnimationFrame)||lt)(st)),e.__H.__.forEach(function(t){t.u&&(t.__H=t.u),t.u=void 0})),F=H=null},W.__c=function(t,e){e.some(function(t){try{t.__h.forEach(ht),t.__h=t.__h.filter(function(t){return!t.__||at(t)})}catch(n){e.some(function(t){t.__h&&(t.__h=[])}),e=[],W.__e(n,t.__v)}}),Q&&Q(t,e)},W.unmount=function(t){X&&X(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(t){try{ht(t)}catch(t){e=t}}),n.__H=void 0,e&&W.__e(e,n.__v))};var ot="function"==typeof requestAnimationFrame;function lt(t){var e,n=function(){clearTimeout(i),ot&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,35);ot&&(e=requestAnimationFrame(n))}function ht(t){var e=H,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),H=e}function at(t){var e=H;t.__c=t.__(),H=e}function ct(t,e){return!t||t.length!==e.length||e.some(function(e,n){return e!==t[n]})}function ut(t,e){return"function"==typeof e?e(t):e}const ft={showPopup:!1,setShowPopup:t=>{},searchValue:"",setSearchValue:t=>{},filter:"",searchIndex:null,indexStatus:"initial",t:t=>window.Spiritix?.t?.[t]||t,inputRef:null},dt=function(t){function e(t){var n,i;return this.getChildContext||(n=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(t){this.props.value!=t.value&&n.forEach(function(t){t.__e=!0,A(t)})},this.sub=function(t){n.add(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n&&n.delete(t),e&&e.call(t)}}),t.children}return e.__c="__cC"+u++,e.__=t,e.Provider=e.__l=(e.Consumer=function(t,e){return t.children(e)}).contextType=e,e}(ft);function pt(t){return y("svg",Object.assign({},t,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",focusable:"false","aria-hidden":"true"}),"\n ",y("circle",{cx:"11",cy:"11",r:"8"}),"\n ",y("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),"\n ")}function gt(t){return y("svg",Object.assign({},t,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",height:"24",width:"24",fill:"none",stroke:"currentColor","stroke-width":"2",focusable:"false","aria-hidden":"true"})," \n ",y("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"}),"\n ")}function _t(t){return y("svg",Object.assign({},t,{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",width:"40px",height:"40px",viewBox:"0 0 40 40","enable-background":"new 0 0 40 40",xmlSpace:"preserve",focusable:"false","aria-hidden":"true"}),"\n ",y("path",{opacity:"0.2",fill:"currentColor",d:"M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"}),"\n ",y("path",{fill:"currentColor",d:"M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0C22.32,8.481,24.301,9.057,26.013,10.047z"},"\n ",y("animateTransform",{attributeType:"xml",attributeName:"transform",type:"rotate",from:"0 20 20",to:"360 20 20",dur:"0.5s",repeatCount:"indefinite"}),"\n "),"\n ")}function mt({text:t,highlight:e}){const n=function({text:t,highlight:e}){let n="";e?.split(" ").forEach((t,e)=>{const i=String(t).replace(/\W/g,"\\&");e>0?n+="|^"+i+"|\\s"+i:n="^"+i+"|\\s"+i});const i=new RegExp(`${n}`,"ig");let r=t?.matchAll(i);const s=[];for(const t of r)s.push({startIdx:t?.index,endIdx:(t?.index||0)+(t?.[0].length||0)});return s}({text:t,highlight:e}),i=[];let r=0;return n.forEach(e=>{r===e.startIdx?(i.push({text:t?.slice(e.startIdx,e.endIdx),type:"highlight"}),r=e.endIdx):(i.push({text:t?.slice(r,e.startIdx),type:"normal"}),i.push({text:t?.slice(e.startIdx,e.endIdx),type:"highlight"}),r=e.endIdx)}),r50){t="..."+t?.slice(n-20);const{parts:r}=mt({text:t,highlight:e});i=r}}const s=i.map((t,e)=>"highlight"===t?.type?y(yt,{key:e,word:t.text,isExcerpt:n}):y("span",{key:e},t.text));return y(w,null,"\n ",s,"\n ")}function wt({post:t}){const{searchValue:e}=rt(dt),{title:n,excerpt:i,url:r}=t;return y("a",{"data-sx-search-item":!0,className:"py-3 -mx-2 sm:-mx-3.5 px-2 sm:px-3.5 cursor-pointer block rounded-xl focus:outline-none \n hover:bg-gray-50 dark:hover:bg-gray-50/2 focus:bg-gray-100 dark:focus:bg-gray-50/5\n ",href:r},"\n ",y("div",{className:"text-base font-medium leading-tight text-gray-900 dark:text-gray-100"},"\n ",y(xt,{text:n,highlight:e,isExcerpt:!1}),"\n "),"\n ",y("p",{className:"text-gray-600 dark:text-gray-400 leading-normal text-sm mt-0 mb-0 truncate"},"\n ",y(xt,{text:i,highlight:e,isExcerpt:!0}),"\n "),"\n ")}function bt({posts:t}){const{t:e,filter:n}=rt(dt);return t?.length?y("div",{className:"flex flex-col py-3 px-4 sm:px-7 first:border-none border-t border-gray-950/5 dark:border-gray-50/5"},"\n ",n?null:y("div",{className:"uppercase text-xs text-gray-400 font-semibold mb-1 tracking-wide"},e("Posts")),"\n ",t?.slice(0,50).map(t=>y(wt,{key:t.slug,post:t})),"\n "):null}function vt({tag:t}){const{searchValue:e}=rt(dt),{name:n,url:i}=t;return y("a",{"data-sx-search-item":!0,className:"py-3 -mx-2 sm:-mx-3.5 px-2 sm:px-3.5 cursor-pointer flex items-center rounded-xl focus:outline-none \n hover:bg-gray-50 dark:hover:bg-gray-50/2 focus:bg-gray-100 dark:focus:bg-gray-50/5\n ",href:i},"\n ",y("p",{className:"me-2 text-sm font-bold text-gray-400"},"#"),"\n ",y("div",{className:"text-base font-medium leading-tight text-gray-900 dark:text-gray-100 truncate"},"\n ",y(xt,{text:n,highlight:e,isExcerpt:!1}),"\n "),"\n ")}function kt({tags:t}){const{t:e}=rt(dt);return t?.length?y("div",{className:"py-3 px-4 sm:px-7 first:border-none border-t border-gray-950/5 dark:border-gray-50/5"},"\n ",y("div",{className:"uppercase text-xs text-gray-400 font-semibold mb-1 tracking-wide"},e("Tags")),"\n ",t.map(t=>y(vt,{key:t.slug,tag:t})),"\n "):null}function At({author:t}){const{name:e,profile_image:n}=t,i=e?.charAt(0);return n?.length?y("img",{className:"rounded-full bg-gray-200 dark:bg-gray-800 w-7 h-7 me-2 object-cover",src:n,alt:e}):i?y("div",{className:"rounded-full bg-gray-200 dark:bg-gray-800 w-7 h-7 me-2 flex items-center justify-center font-bold border border-gray-950/5 dark:border-gray-50/5"},"\n ",y("span",{className:"text-gray-800 dark:text-gray-200"},i),"\n "):null}function St({author:t}){const{searchValue:e}=rt(dt),{name:n,url:i}=t;return y("a",{"data-sx-search-item":!0,className:"py-3 -mx-2 sm:-mx-3.5 px-2 sm:px-3.5 cursor-pointer flex items-center rounded-xl focus:outline-none \n hover:bg-gray-50 dark:hover:bg-gray-50/2 focus:bg-gray-100 dark:focus:bg-gray-50/5\n ",href:i},"\n ",y(At,{author:t}),"\n ",y("div",{className:"text-base font-medium leading-tight text-gray-900 dark:text-gray-100 truncate"},"\n ",y(xt,{text:n,highlight:e,isExcerpt:!1}),"\n "),"\n ")}function Ct({authors:t}){const{t:e}=rt(dt);return t?.length?y("div",{className:"py-3 px-4 sm:px-7 first:border-none border-t border-gray-950/5 dark:border-gray-50/5"},"\n ",y("div",{className:"uppercase text-xs text-gray-400 font-semibold mb-1 tracking-wide"},e("Authors")),"\n ",t.map(t=>y(St,{key:t.slug,author:t})),"\n "):null}function Et({posts:t,authors:e,tags:n}){const i=nt(null);return et(()=>{const t=t=>{const e=Array.from(i.current?.querySelectorAll("[data-sx-search-item]")||[]);if(document.activeElement?.hasAttribute("data-sx-search-item")){if(document.activeElement?.hasAttribute("data-sx-search-item")){const n=e.findIndex(t=>t===document.activeElement),i=e[n-1],r=e[n+1];"ArrowDown"===t.key&&r&&r?.focus(),"ArrowUp"===t.key&&i&&i?.focus()}}else"ArrowDown"===t.key&&e[0]?.focus(),"ArrowUp"===t.key&&e.at(-1)?.focus()};return window.addEventListener("keyup",t),()=>window.removeEventListener("keyup",t)},[]),y("div",{ref:i,className:"scrollbar-width-thin overflow-y-auto max-h-[calc(100vh-172px)] sm:max-h-[70vh] -mt-px"},"\n ",y(Ct,{authors:e}),"\n ",y(kt,{tags:n}),"\n ",y(bt,{posts:t}),"\n ")}function Nt(){const{searchValue:t="",filter:e,searchIndex:n,indexStatus:i,t:r}=rt(dt);let s=[],o=[],l=[];if("completed"===i&&t){const i=n?.search(t||"");o=i?.posts||[],l=e?[]:i?.authors||[],s=e?[]:i?.tags||[]}else if("completed"===i&&!t&&e){const t=n?.sample(50);o=t?.posts||[]}return o?.length||l?.length||s?.length?y(w,null,"\n ",y("div",{className:"border-t border-gray-950/5 dark:border-gray-50/5"}),"\n ",y(Et,{posts:o,authors:l,tags:s}),"\n "):t&&"completed"===i?y(w,null,"\n ",y("div",{className:"border-t border-gray-950/5 dark:border-gray-50/5"}),"\n ",y("div",{className:"py-4 px-7"},"\n ",y("p",{className:"text-base leading-normal"},"\n ",r("No matches found"),"\n "),"\n "),"\n "):"failed"===i?y(w,null,"\n ",y("div",{className:"border-t border-gray-950/5 dark:border-gray-50/5"}),"\n ",y("div",{className:"py-4 px-7"},"\n ",y("p",{className:"text-base leading-normal"},"\n ",r("Something went wrong, please try again."),"\n "),"\n "),"\n "):null}function zt(){const{setSearchValue:t,searchValue:e="",setShowPopup:n,inputRef:i,indexStatus:r,t:s}=rt(dt);return et(()=>{setTimeout(()=>{i?.current?.focus()},150)},[i]),y("div",{className:"z-10 relative flex items-center py-5 px-4 sm:px-7"},"\n ",y("div",{className:"flex-none flex items-center justify-center w-6 h-6 me-3"},"\n ",e?null:y(pt,{className:"flex-none w-6 h-6 text-gray-400 dark:text-gray-500",title:s("Quick search...")}),"\n\n ",e?y("button",{className:"relative top-px w-6 h-6",title:s("Clear"),onClick:()=>t("")},"\n ",y(gt,{className:"flex-none w-6 h-6 text-gray-400 hover:text-gray-950 dark:text-gray-500 dark:hover:text-gray-50 transition-colors"}),"\n "):null,"\n "),"\n\n ",y("input",{ref:i,value:e||"",onInput:e=>t(e.currentTarget.value),onKeyDown:t=>{"ArrowUp"!==t.key&&"ArrowDown"!==t.key||t.preventDefault()},name:"search",className:"grow -my-4.5 py-4.5 -ms-3 ps-3 text-base leading-7 bg-transparent focus-visible:outline-none placeholder:text-gray-400 dark:placeholder:text-gray-500 outline-none truncate",placeholder:s("Quick search..."),autoComplete:"off"}),"\n\n ",!["completed","failed"].includes(r)&&e?y(_t,{className:"flex-none h-7 w-7 ms-1 -me-1"}):null,"\n\n ",y("button",{className:"sm:hidden ms-3 text-sm text-gray-500",title:s("Close"),onClick:()=>n(!1)},"\n ",s("Close"),"\n "),"\n ")}function jt(){const{setShowPopup:t,showPopup:e}=rt(dt),n=e=>{e.target===e.currentTarget&&t(!1)};return et(()=>{const e=e=>{"Escape"===e.key&&t(!1)};return window.addEventListener("keyup",e),()=>window.removeEventListener("keyup",e)},[t]),et(()=>{const t=document.getElementById("sx-viewport");t?.toggleAttribute("inert",e)},[e]),e?y("div",{className:"fixed z-3999999 top-0 start-0 w-full h-full overflow-hidden has-animation",style:{"--animation-duration":"150ms"},role:"dialog","aria-modal":"true"},"\n ",y("div",{onClick:n,className:"absolute inset-0 z-0 block bg-black/20 dark:bg-black/50 backdrop-blur-xs animate-fade"},"\n "),"\n\n ",y("div",{onClick:n,className:"h-screen w-screen pt-20 antialiased z-50 relative px-outer"},"\n ",y("div",{className:"relative bg-white dark:bg-gray-950 w-full max-w-lg rounded-2xl shadow-pretty dark:shadow-xl m-auto translate-z-0 animate-slide-up"},"\n ",y("div",{className:"hidden dark:block absolute inset-0 -z-10 rounded-inherit bg-white/5 ring-1 ring-gray-50/10"}),"\n ",y(zt,null)," \n ",y(Nt,null),"\n "),"\n "),"\n "):null} /**! * FlexSearch.js v0.8.205 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */var It;function Mt(t,e,n){const i=typeof n,r=typeof t;if("undefined"!==i){if("undefined"!==r){if(n){if("function"===r&&i===r)return function(e){return t(n(e))};if((e=t.constructor)===n.constructor){if(e===Array)return n.concat(t);if(e===Map){var s=new Map(n);for(var o of t)s.set(o[0],o[1]);return s}if(e===Set){for(s of(o=new Set(n),t.values()))o.add(s);return o}}}return t}return n}return"undefined"===r?e:t}function Pt(t,e){return void 0===t?e:t}function Dt(){return Object.create(null)}function Lt(t){return"string"==typeof t}function Bt(t){return"object"==typeof t}function Tt(t,e){if(Lt(e))t=t[e];else for(let n=0;t&&n1?this.addMatcher(t,e):(this.mapper||(this.mapper=new Map),this.mapper.set(t,e),this.cache&&qt(this),this)},It.addMatcher=function(t,e){return"object"==typeof t?this.addReplacer(t,e):t.length<2&&(this.dedupe||this.mapper)?this.addMapper(t,e):(this.matcher||(this.matcher=new Map),this.matcher.set(t,e),this.h+=(this.h?"|":"")+t,this.J=null,this.cache&&qt(this),this)},It.addReplacer=function(t,e){return"string"==typeof t?this.addMatcher(t,e):(this.replacer||(this.replacer=[]),this.replacer.push(t,e),this.cache&&qt(this),this)},It.encode=function(t,e){if(this.cache&&t.length<=this.H)if(this.F){if(this.B.has(t))return this.B.get(t)}else this.F=setTimeout(qt,50,this);this.normalize&&(t="function"==typeof this.normalize?this.normalize(t):Ft?t.normalize("NFKD").replace(Ft,"").toLowerCase():t.toLowerCase()),this.prepare&&(t=this.prepare(t)),this.numeric&&t.length>3&&(t=t.replace($t,"$1 $2").replace(Ht,"$1 $2").replace(Ut,"$1 "));const n=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let i,r,s=[],o=Dt(),l=this.split||""===this.split?t.split(this.split):[t];for(let t,a,c=0;cthis.maxlength)){if(e){if(o[t])continue;o[t]=1}else{if(i===t)continue;i=t}if(n)s.push(t);else if(!this.filter||("function"==typeof this.filter?this.filter(t):!this.filter.has(t))){if(this.cache&&t.length<=this.I)if(this.F){var h=this.D.get(t);if(h||""===h){h&&s.push(h);continue}}else this.F=setTimeout(qt,50,this);if(this.stemmer){let e;for(this.K||(this.K=new RegExp("(?!^)("+this.A+")$"));e!==t&&t.length>2;)e=t,t=t.replace(this.K,t=>this.stemmer.get(t))}if(t&&(this.mapper||this.dedupe&&t.length>1)){h="";for(let e,n,i=0,r="";i1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),t=t.replace(this.J,t=>this.matcher.get(t))),t&&this.replacer)for(h=0;t&&hthis.L&&(this.D.clear(),this.I=this.I/1.1|0)),t){if(t!==a)if(e){if(o[t])continue;o[t]=1}else{if(r===t)continue;r=t}s.push(t)}}}return this.finalize&&(s=this.finalize(s)||s),this.cache&&t.length<=this.H&&(this.B.set(t,s),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0)),s},Wt.prototype.set=function(t,e){this.cache.set(this.h=t,e),this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)},Wt.prototype.get=function(t){const e=this.cache.get(t);return e&&this.h!==t&&(this.cache.delete(t),this.cache.set(this.h=t,e)),e},Wt.prototype.remove=function(t){for(const e of this.cache){const n=e[0];e[1].includes(t)&&this.cache.delete(n)}},Wt.prototype.clear=function(){this.cache.clear(),this.h=""};const Jt={normalize:!1,numeric:!1,dedupe:!1},Vt={},Gt=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]),Qt=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Xt=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"],Zt={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"ß":2,d:3,t:3,l:4,m:5,n:5,r:6};var Yt={Exact:Jt,Default:Vt,Normalize:Vt,LatinBalance:{mapper:Gt},LatinAdvanced:{mapper:Gt,matcher:Qt,replacer:Xt},LatinExtra:{mapper:Gt,replacer:Xt.concat([/(?!^)[aeo]/g,""]),matcher:Qt},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(t){for(let n=0;n=s.length)e-=s.length;else{const o=(e=s[i?"splice":"slice"](e,n)).length;if(o&&(r=r.length?r.concat(e):e,n-=o,i&&(t.length-=o),!n))break;e=0}return r}function ee(t){if(!this||this.constructor!==ee)return new ee(t);this.index=t?[t]:[],this.length=t?t.length:0;const e=this;return new Proxy([],{get:(t,n)=>"length"===n?e.length:"push"===n?function(t){e.index[e.index.length-1].push(t),e.length++}:"pop"===n?function(){if(e.length)return e.length--,e.index[e.index.length-1].pop()}:"indexOf"===n?function(t){let n=0;for(let i,r,s=0;s=0)return n+r;n+=i.length}return-1}:"includes"===n?function(t){for(let n=0;n(t=n/2**31|0,(e.index[t]||(e.index[t]=[]))[n]=i,e.length++,!0)})}function ne(t=8){if(!this||this.constructor!==ne)return new ne(t);this.index=Dt(),this.h=[],this.size=0,t>32?(this.B=se,this.A=BigInt(t)):(this.B=re,this.A=t)}function ie(t=8){if(!this||this.constructor!==ie)return new ie(t);this.index=Dt(),this.h=[],this.size=0,t>32?(this.B=se,this.A=BigInt(t)):(this.B=re,this.A=t)}function re(t){let e=2**this.A-1;if("number"==typeof t)return t&e;let n=0,i=this.A+1;for(let r=0;r=this.priority*this.priority*3):(he=setTimeout(de,0),ae=Date.now()),ce){const n=this;return new Promise(i=>{setTimeout(function(){i(n[t+"Async"].apply(n,e))},0)})}const r=this[t].apply(this,e);return n=r.then?r:new Promise(t=>t(r)),i&&n.then(i),n}}ee.prototype.clear=function(){this.index.length=0},ee.prototype.push=function(){},ne.prototype.get=function(t){const e=this.index[this.B(t)];return e&&e.get(t)},ne.prototype.set=function(t,e){var n=this.B(t);let i=this.index[n];i?(n=i.size,i.set(t,e),(n-=i.size)&&this.size++):(this.index[n]=i=new Map([[t,e]]),this.h.push(i),this.size++)},ie.prototype.add=function(t){var e=this.B(t);let n=this.index[e];n?(e=n.size,n.add(t),(e-=n.size)&&this.size++):(this.index[e]=n=new Set([t]),this.h.push(n),this.size++)},(It=ne.prototype).has=ie.prototype.has=function(t){const e=this.index[this.B(t)];return e&&e.has(t)},It.delete=ie.prototype.delete=function(t){const e=this.index[this.B(t)];e&&e.delete(t)&&this.size--},It.clear=ie.prototype.clear=function(){this.index=Dt(),this.h=[],this.size=0},It.values=ie.prototype.values=function*(){for(let t=0;t1e9&&(ge=0),s.h[++ge]=function(){e(s)},s.worker.postMessage({id:ge,task:"init",factory:i,options:t})}):(this.priority=t.priority||4,this.encoder=e||null,this.worker.postMessage({task:"init",factory:i,options:t}),this)}if(!this||this.constructor!==_e)return new _e(t);let i="undefined"!=typeof self?self._factory:"undefined"!=typeof window?window._factory:null;i&&(i=i.toString());const r="undefined"==typeof window,s=this,o=function(t,e,n){return e?"undefined"!=typeof module?new(require("worker_threads").Worker)(__dirname+"/worker/node.js"):import("worker_threads").then(function(t){return new t.Worker(import.meta.dirname+"/node/node.mjs")}):t?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ue.toString()],{type:"text/javascript"}))):new window.Worker("string"==typeof n?n:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js","module/worker/worker.js"),{type:"module"})}(i,r,t.worker);return o.then?o.then(function(t){return n.call(s,t)}):n.call(this,o)}function me(t){_e.prototype[t]=function(){const e=this,n=[].slice.call(arguments);var i=n[n.length-1];let r;return"function"==typeof i&&(r=i,n.pop()),i=new Promise(function(i){"export"===t&&"function"==typeof n[0]&&(n[0]=null),ge>1e9&&(ge=0),e.h[++ge]=i,e.worker.postMessage({task:t,id:ge,args:n})}),r?(i.then(r),this):i}}function ye(t,e,n,i,r,s){if(t=t[r],i===n.length-1)e[r]=s||t;else if(t)if(t.constructor===Array)for(e=e[r]=Array(t.length),r=0;re?t.slice(n,n+e):t,i?Le.call(this,t):t;let r=[];for(let s,o,l=0;l=o){n-=o;continue}s=s.slice(n,n+e),o=s.length,n=0}if(o>e&&(s=s.slice(0,e),o=e),!r.length&&o>=e)return i?Le.call(this,s):s;if(r.push(s),!(e-=o))break}return r=r.length>1?[].concat.apply([],r):r[0],i?Le.call(this,r):r}function be(t,e,n,i){var r=i[0];if(r[0]&&r[0].query)return t[e].apply(t,r);if(!("and"!==e&&"not"!==e||t.result.length||t.await||r.suggest))return i.length>1&&(r=i[i.length-1]),(i=r.resolve)?t.await||t.result:t;let s,o,l,h,a,c=[],u=0,f=0;for(e=0;e1&&(n=n[e].apply(n,t.slice(1))),n}function ke(t,e,n,i,r,s,o){return t.length&&(this.result.length&&t.push(this.result),t.length<2?this.result=t[0]:(this.result=Ie(t,e,n,!1,this.h),n=0)),r&&(this.await=null),r?this.resolve(e,n,i,o):this}function Ae(t,e,n,i,r,s,o){if(!s&&!this.result.length)return r?this.result:this;let l;if(t.length)if(this.result.length&&t.unshift(this.result),t.length<2)this.result=t[0];else{let i=0;for(let e,n,r=0;r1?A.join(" "):A[0])&&k){for(var S=k.length,C=(P.split?k.replace(P.split,""):k).length-A.length,E="",N=0,z=0;z-1&&(E=(j?k.substring(0,j):"")+o+k.substring(j,j+I)+l+(j+I=h)break}else _+=(_?" ":"")+(k=m[v]),h&&y.push({text:k})}if(b=e.length*(s.length-2),d||p||h&&_.length-b>h)if(v=w-x,d>0&&(v+=d),p>0&&(v+=p),v<=(b=h+b-2*f))m=d?x-(d>0?d:0):x-((b-v)/2|0),y=p?w+(p>0?p:0):m+b,a||(m>0&&" "!==_.charAt(m)&&" "!==_.charAt(m-1)&&((m=_.indexOf(" ",m))<0&&(m=0)),y<_.length&&" "!==_.charAt(y-1)&&" "!==_.charAt(y)&&((y=_.lastIndexOf(" ",y))=y.length-1){if(t>=y.length){v[n+1]=1,t>=m.length&&(b[n+1]=1);continue}S-=f}if(_=y[t].text,I=p&&A[n]){if(!(I>0)){v[n+1]=1;continue}if(_.length>I){if(v[n+1]=1,!a)continue;_=_.substring(0,I)}(I-=_.length)||(I=-1),A[n]=I}if(S+_.length+1<=h)_=" "+_,w[n]+=_;else{if(!a){v[n+1]=1;continue}(M=h-S-1)>0&&(_=" "+_.substring(0,M),w[n]+=_),v[n+1]=1}}else{if(v[n])continue;if(t-=C,x[t]){S-=f,v[n]=1,b[n]=1;continue}if(t<=0){if(t<0){v[n]=1,b[n]=1;continue}S-=f}if(_=y[t].text,I=d&&k[n]){if(!(I>0)){v[n]=1;continue}if(_.length>I){if(v[n]=1,!a)continue;_=_.substring(_.length-I)}(I-=_.length)||(I=-1),k[n]=I}if(S+_.length+1<=h)_+=" ",w[n]=_+w[n];else{if(!a){v[n]=1;continue}(M=_.length+1-(h-S))>=0&&M<_.length&&(_=_.substring(M)+" ",w[n]=_+w[n]),v[n]=1}}else{let e;if(_=y[t].match,d&&(k[n]=d),p&&(A[n]=p),n&&S++,t?!n&&f&&(S+=f):(b[n]=1,v[n]=1),t>=m.length-1||t1?Ie(c,n,i,o,s):(c=c[0])&&n&&c.length>n||i?c.slice(i,n+i):c;else{if(tn||i)&&(c=c.slice(i,n+i));else{r=[];for(let t,e=0;ei)i-=t.length;else if((n&&t.length>n||i)&&(t=t.slice(i,n+i),n-=t.length,i&&(i-=t.length)),r.push(t),!n)break;c=r}}return c}function Ie(t,e,n,i,r){const s=[],o=Dt();let l;var h=t.length;let a;if(i){for(r=h-1;r>=0;r--)if(a=(i=t[r])&&i.length)for(h=0;h=0;u--){c=t[u];for(let t=0;t0&&((n&&e>n||i)&&(t=t.slice(i,i+n)),r&&(t=Le.call(this,t))),t):[]}function Le(t){if(!this||!this.store)return t;if(this.db)return this.index.get(this.field[0]).db.enrich(t);const e=Array(t.length);for(let n,i=0;i1?n:n[0]}function Ue(t,e=0){let n=[],i=[];e&&(e=25e4/e*5e3|0);for(const r of t.entries())i.push(r),i.length===e&&(n.push(i),i=[]);return i.length&&n.push(i),n}function $e(t,e){e||(e=new Map);for(let n,i=0;i=0){if(r.length>1)return r.splice(s,1),1;if(delete t[l],n)return 1;o=1}else{if(o)return 1;n++}}}else for(let r of t.entries())i=r[0],Je(r[1],e)?n++:t.delete(i);return n}me("add"),me("append"),me("search"),me("update"),me("remove"),me("clear"),me("export"),me("import"),_e.prototype.searchCache=Kt,fe(_e.prototype),Be.prototype.add=function(t,e,n){if(Bt(t)&&(t=Tt(e=t,this.key)),e&&(t||0===t)){if(!n&&this.reg.has(t))return this.update(t,e);for(let s,o=0;o1?je(r,1,0,0,h,a):r[0],t)})}return g?r:new Ne(r.length>1?je(r,1,0,0,h,a):r[0],this)}}g||o||!(u=u||this.field)||(Lt(u)?o=u:(u.constructor===Array&&1===u.length&&(u=u[0]),o=u.field||u.index)),u&&u.constructor!==Array&&(u=[u])}u||(u=this.field),x=(this.worker||this.db)&&!i&&[];for(let o,l,a,k=0;k-1&&(r.length>1?r.splice(s,1):n.delete(e))}this.store&&this.store.delete(t),this.reg.delete(t)}return this.cache&&this.cache.remove(t),this},It.clear=function(){const t=[];for(const e of this.index.values()){const n=e.clear();n.then&&t.push(n)}if(this.tag)for(const t of this.tag.values())t.clear();return this.store&&this.store.clear(),this.cache&&this.cache.clear(),t.length?Promise.all(t):this},It.contain=function(t){return this.db?this.index.get(this.field[0]).db.has(t):this.reg.has(t)},It.cleanup=function(){for(const t of this.index.values())t.cleanup();return this},It.get=function(t){return this.db?this.index.get(this.field[0]).db.enrich(t).then(function(t){return t[0]&&t[0].doc||null}):this.store.get(t)||null},It.set=function(t,e){return"object"==typeof t&&(t=Tt(e=t,this.key)),this.store.set(t,e),this},It.searchCache=Kt,It.export=function(t,e,n=0,i=0){if(n2?n[0]:"";if(n=n.length>2?n[2]:n[1],this.worker&&i)return this.index.get(i).import(t);if(e){if("string"==typeof e&&(e=JSON.parse(e)),i)return this.index.get(i).import(n,e);switch(n){case"reg":this.fastupdate=!1,this.reg=qe(e,this.reg);for(let t,e=0;e=0&&e.splice(n,1)}}else Je(this.map,t),this.depth&&Je(this.ctx,t);e||this.reg.delete(t)}return this.db&&(this.commit_task.push({del:t}),this.M&&nn(this)),this.cache&&this.cache.remove(t),this};const Ve={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};function Ge(t,e,n,i,r,s,o){let l,h;if(!(l=e[n])||o&&!l[o]){if(o?((e=l||(e[n]=Dt()))[o]=1,h=t.ctx,(l=h.get(o))?h=l:h.set(o,h=t.keystore?new ne(t.keystore):new Map)):(h=t.map,e[n]=1),(l=h.get(n))?h=l:h.set(n,h=l=[]),s)for(let n,s=0;s1?e+(i||0)<=t?n+(r||0):(t-1)/(e+(i||0))*(n+(r||0))+1|0:0}function Xe(t,e,n,i,r,s,o){let l=t.length,h=t;if(l>1)h=je(t,e,n,i,r,s,o);else if(1===l)return o?we.call(null,t[0],n,i):new Ne(t[0],this);return o?h:new Ne(h,this)}function Ze(t,e,n,i,r,s,o){return t=tn(this,t,e,n,i,r,s,o),this.db?t.then(function(t){return r?t||[]:new Ne(t,this)}):t&&t.length?r?we.call(this,t,n,i):new Ne(t,this):r?[]:new Ne([],this)}function Ye(t,e,n,i){let r=[];if(t&&t.length){if(t.length<=i)return void e.push(t);for(let e,n=0;nn)&&(h=n,n=e,e=h),t.db?t.db.get(e,n,i,r,s,o,l):t=n?(t=t.ctx.get(n))&&t.get(e):t.map.get(e)}function en(t,e){if(!this||this.constructor!==en)return new en(t);if(t){var n=Lt(t)?t:t.preset;n&&(t=Object.assign({},Ve[n],t))}else t={};const i=!0===(n=t.context)?{depth:1}:n||{},r=Lt(t.encoder)?Yt[t.encoder]:t.encode||t.encoder||{};this.encoder=r.encode?r:"object"==typeof r?new Rt(r):{encode:r},this.resolution=t.resolution||9,this.tokenize=n=(n=t.tokenize)&&"default"!==n&&"exact"!==n&&n||"strict",this.depth="strict"===n&&i.depth||0,this.bidirectional=!1!==i.bidirectional,this.fastupdate=!!t.fastupdate,this.score=t.score||null,(n=t.keystore||0)&&(this.keystore=n),this.map=n?new ne(n):new Map,this.ctx=n?new ne(n):new Map,this.reg=e||(this.fastupdate?n?new ne(n):new Map:n?new ie(n):new Set),this.N=i.resolution||3,this.rtl=r.rtl||t.rtl||!1,this.cache=(n=t.cache||null)&&new Wt(n),this.resolve=!1!==t.resolve,(n=t.db)&&(this.db=this.mount(n)),this.M=!1!==t.commit,this.commit_task=[],this.commit_timer=null,this.priority=t.priority||4}function nn(t){t.commit_timer||(t.commit_timer=setTimeout(function(){t.commit_timer=null,t.db.commit(t)},1))}en.prototype.add=function(t,e,n,i){if(e&&(t||0===t)){if(!i&&!n&&this.reg.has(t))return this.update(t,e);i=this.depth;const a=(e=this.encoder.encode(e,!i)).length;if(a){const c=Dt(),u=Dt(),f=this.resolution;for(let d=0;d2){for(let e,i,l,h,a=1;a2){for(let i,h=0;hh;s--){o=p.substring(h,s),i=this.rtl?r-1-h:h;var l=this.score?this.score(e,p,d,o,i):Qe(f,a,d,r,i);Ge(this,u,o,l,t,n)}break}case"bidirectional":case"reverse":if(r>1){for(l=r-1;l>0;l--){o=p[this.rtl?r-1-l:l]+o;var h=this.score?this.score(e,p,d,o,l):Qe(f,a,d,r,l);Ge(this,u,o,h,t,n)}o=""}case"forward":if(r>1){for(l=0;l1&&do)?o:p,this.score?this.score(e,o,d,p,l-1):Qe(r+(a/2>r?0:1),a,d,s-1,l-1),t,n,h?p:o)}}}}this.fastupdate||this.reg.add(t)}}return this.db&&(this.commit_task.push(n?{ins:t}:{del:t}),this.M&&nn(this)),this},en.prototype.search=function(t,e,n){if(n||(e||"object"!=typeof t?"object"==typeof e&&(n=e,e=0):(n=t,t="")),n&&n.cache)return n.cache=!1,t=this.searchCache(t,e,n),n.cache=!0,t;let i,r,s,o,l,h,a,c,u=[],f=0;n&&(t=n.query||t,e=n.limit||e,f=n.offset||0,r=n.context,s=n.suggest,c=(o=n.resolve)&&n.enrich,h=n.boost,a=n.resolution,l=this.db&&n.tag),void 0===o&&(o=this.resolve),r=this.depth&&!1!==r;let d=this.encoder.encode(t,!r);if(i=d.length,e=e||(o?100:0),1===i)return Ze.call(this,d[0],"",e,f,o,c,l);if(2===i&&r&&!s)return Ze.call(this,d[1],d[0],e,f,o,c,l);let p,g=Dt(),_=0;if(r&&(p=d[0],_=1),a||0===a||(a=p?this.N:this.resolution),this.db){if(this.db.search&&!1!==(n=this.db.search(this,d,e,f,s,o,c,l)))return n;const t=this;return async function(){for(let e,n;_n.add(t,e)):this.add(t,e)},It.cleanup=function(){return this.fastupdate?(Je(this.map),this.depth&&Je(this.ctx),this):this},It.searchCache=Kt,It.export=function(t,e,n=0,i=0){let r,s;switch(i){case 0:r="reg",s=Re(this.reg);break;case 1:r="cfg",s=null;break;case 2:r="map",s=Ue(this.map,this.reg.size);break;case 3:r="ctx",s=He(this.ctx,this.reg.size);break;default:return}return Ke.call(this,t,e,r,s,n,i)},It.import=function(t,e){if(e)switch("string"==typeof e&&(e=JSON.parse(e)),t=t.split("."),"json"===t[t.length-1]&&t.pop(),3===t.length&&t.shift(),t=t.length>1?t[1]:t[0],t){case"reg":this.fastupdate=!1,this.reg=qe(e,this.reg);break;case"map":this.map=$e(e,this.map);break;case"ctx":this.ctx=Fe(e,this.ctx)}},It.serialize=function(t=!0){let e="",n="",i="";if(this.reg.size){let t;for(var r of this.reg.keys())t||(t=typeof r),e+=(e?",":"")+("string"===t?'"'+r+'"':r);e="index.reg=new Set(["+e+"]);",n=We(this.map,t),n="index.map=new Map(["+n+"]);";for(const e of this.ctx.entries()){r=e[0];let n=We(e[1],t);n="new Map(["+n+"])",n='["'+r+'",'+n+"]",i+=(i?",":"")+n}i="index.ctx=new Map(["+i+"]);"}return t?"function inject(index){"+e+n+i+"}":e+n+i},fe(en.prototype);const rn="undefined"!=typeof window&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),sn=["map","ctx","tag","reg","cfg"],on=Dt();function ln(t,e,n){const i=t.value;let r,s=0;for(let t,o=0;o=0){if(r=1,!(t.length>1)){i[o]=[];break}t.splice(n,1)}s+=t.length}if(n)break}s?r&&t.update(i):t.delete(),t.continue()}function hn(t,e){return new Promise((n,i)=>{t.onsuccess=t.oncomplete=function(){e&&e(this.result),e=null,n(this.result)},t.onerror=t.onblocked=i,t=null})}It=function t(e,n={}){if(!this||this.constructor!==t)return new t(e,n);"object"==typeof e&&(n=e,e=e.name),e||console.info("Default storage space was used, because a name was not passed."),this.id="flexsearch"+(e?":"+e.toLowerCase().replace(/[^a-z0-9_\-]/g,""):""),this.field=n.field?n.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"",this.type=n.type,this.fastupdate=this.support_tag_search=!1,this.db=null,this.h={}}.prototype,It.mount=function(t){return t.index?t.mount(this):(t.db=this,this.open())},It.open=function(){if(this.db)return this.db;let t=this;navigator.storage&&navigator.storage.persist(),on[t.id]||(on[t.id]=[]),on[t.id].push(t.field);const e=rn.open(t.id,1);return e.onupgradeneeded=function(){const e=t.db=this.result;for(let n,i=0;i=r.length){i-=r.length;continue}const t=n?i+Math.min(r.length-i,n):r.length;for(let n=i;n=t.length?[]:e||n?(t=t.slice(n,n+e),i?r.enrich(t):t):t})},It.enrich=function(t){"object"!=typeof t&&(t=[t]);const e=this.db.transaction("reg","readonly").objectStore("reg"),n=[];for(let i=0;i{let e=[];for(const n of t)e.push(...dn(n));return e}};function fn(t){return t>=19968&&t<=40959||t>=12352&&t<=12543||t>=44032&&t<=55203||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=191471||t>=196608&&t<=205743||t>=191472&&t<=192095||t>=63744&&t<=64255||t>=194560&&t<=195103}function dn(t){const e=[];let n="";for(const i of t){const t=i.codePointAt(0);t&&fn(t)?(n&&(e.push(n),n=""),e.push(i)):n+=i}return n&&e.push(n),e}const pn=new an.Encoder({...cn.Default,...un});class gn{constructor({contentApiUrl:t,contentApiKey:e,dir:n="ltr",filter:i=""}){this.contentApiUrl=t,this.contentApiKey=e,this.dir=n,this.filter=i;const r="rtl"===n,s="rtl"===n?"reverse":"forward";this.postsIndex=new an.Document({tokenize:s,rtl:r,document:{id:"id",index:["title","excerpt"],store:!0},encoder:pn}),this.authorsIndex=new an.Document({tokenize:s,rtl:r,document:{id:"id",index:["name"],store:!0},encoder:pn}),this.tagsIndex=new an.Document({tokenize:s,rtl:r,document:{id:"id",index:["name"],store:!0},encoder:pn}),this.init=this.init.bind(this),this.search=this.search.bind(this),this.sample=this.sample.bind(this)}async#t(){let t=[];if(!this.filter)return[];const e=async(t=1)=>{const e=new URLSearchParams({filter:`tags:[${this.filter}]`,limit:"100",fields:"id,slug,title,excerpt,url,updated_at,visibility",order:"updated_at DESC",page:`${t}`}),n=`${this.contentApiUrl}/posts/?key=${this.contentApiKey}&${e}`,i=await fetch(n);return await i.json()},n=await e(1);if(t=n?.posts||[],n?.meta?.pagination?.pages>1){const i=Math.min(n.meta.pagination.pages,10),r=[];for(let t=2;t<=i;t++)r.push(e(t));(await Promise.allSettled(r)).forEach((e,n)=>{"rejected"!==e.status?t.push(...e.value?.posts||[]):console.error("Error fetching filtered posts with page="+(n+2))})}return t}async#e(){if(this.filter)return this.#t();const t=`${this.contentApiUrl}/search-index/posts/?key=${this.contentApiKey}`,e=await fetch(t);return(await e.json()).posts}async#n(){try{const t=`${this.contentApiUrl}/search-index/authors/?key=${this.contentApiKey}`,e=await fetch(t);return(await e.json()).authors}catch(t){return console.error("Error fetching authors:",t),window.Spiritix.safeReportError?.(t),[]}}async#i(){try{const t=`${this.contentApiUrl}/search-index/tags/?key=${this.contentApiKey}`,e=await fetch(t);return(await e.json()).tags}catch(t){return console.error("Error fetching tags:",t),window.Spiritix.safeReportError?.(t),[]}}#r(t){t.forEach(t=>{this.postsIndex.add(t)})}#s(t){t.forEach(t=>{!t?.url||/\/404\/$/.test(t.url)||this.authorsIndex.add(t)})}#o(t){t.forEach(t=>{!t?.url||/\/404\/$/.test(t.url)||this.tagsIndex.add(t)})}async init(){const[t,e,n]=await Promise.all([this.#e(),this.#n(),this.#i()]);t.length>0&&this.#r(t),e.length>0&&this.#s(e),n.length>0&&this.#o(n)}#l(t){const e=[],n={};return t.forEach(t=>{t.result.forEach(t=>{!n[t.id]&&t.doc&&(e.push(t.doc),n[t.id]=!0)})}),e}search(t){const e=this.postsIndex.search(t,{enrich:!0}),n=this.authorsIndex.search(t,{enrich:!0}),i=this.tagsIndex.search(t,{enrich:!0});return{posts:this.#l(e),authors:this.#l(n),tags:this.#l(i)}}sample(t=100){const e=[];if(this.postsIndex.store&&"function"==typeof this.postsIndex.store[Symbol.iterator])for(const[n,i]of this.postsIndex.store){if(e.length>=t)break;i&&e.push(i)}return{posts:e,authors:[],tags:[]}}}function _n({contentApiUrl:t,contentApiKey:e,dir:n}){const[i,r]=tt(!1),[s,o]=tt(""),[l,h]=tt(""),[a,c]=tt([]),u=nt(null),f=nt(null),d=it(()=>document.querySelectorAll("[data-ghost-search]")||[],[]),p=function(t,e){return q=8,it(function(){return t},e)}(i=>{let r=a.find(t=>t.filter===i);if(r||(r={filter:i||"",status:"initial",index:new gn({contentApiUrl:t,contentApiKey:e,dir:n,filter:i}),retries:0},c(a.concat({...r}))),r={...r},"initial"===r.status){r.status="started",c(t=>t.map(t=>t.filter===r.filter?{...r}:t));const t=performance.now();f.current=t,r.index.init().then(()=>{r.status="completed"}).catch(t=>{r.retries+=1,r.status=r.retries>=3?"failed":"initial",window.Spiritix.safeReportError?.(t)}).finally(()=>{const e="initial"===r.status?100:0;setTimeout(()=>{t===f.current&&c(t=>t.map(t=>t.filter===r.filter?{...r}:t))},e)})}},[a,t,e,n]);et(()=>{i&&p(s)},[i,p]),et(()=>{const t=t=>{if(t.preventDefault(),t.currentTarget instanceof Element){const e=t.currentTarget,n=e?.getAttribute("data-ghost-search")?.trim()||"";n&&p(n)}};return d.forEach(e=>e.addEventListener("mouseenter",t)),()=>d.forEach(e=>e.removeEventListener("mouseenter",t))},[d,p]),et(()=>{const t=t=>{if(t.preventDefault(),t.currentTarget instanceof Element){const e=t.currentTarget,n=e?.getAttribute("data-ghost-search")?.trim()||"";o(n)}r(!0);const e=document.createElement("input");e.style.opacity="0",e.style.position="fixed",e.style.top="0",document.body.appendChild(e),e.focus(),setTimeout(()=>{u?.current?.focus(),document.body.removeChild(e)},150)};return d.forEach(e=>e.addEventListener("click",t)),()=>d.forEach(e=>e.removeEventListener("click",t))},[d]),et(()=>{const t=()=>{const[t]=window.location.hash.substring(1).split("?");"/search"!==t&&"/search/"!==t||(r(!0),window.history.replaceState("",document.title,window.location.pathname))};return t(),window.addEventListener("hashchange",t,!1),()=>window.removeEventListener("hashchange",t,!1)},[]),et(()=>{if(!d?.length)return;const t=t=>{if("k"===t.key&&t.metaKey)return r(!0),t.preventDefault(),t.stopPropagation(),!1};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[d]),et(()=>(document.body.classList.toggle("has-modal",i),i||(f.current=null,h(""),o(""),c(t=>t.map(t=>({...t,status:"completed"!==t.status?"initial":t.status,retries:0})))),()=>document.body.classList.toggle("has-modal",!1)),[i]);const g=a.find(t=>t.filter===s);if(!g)return null;const _={showPopup:i,setShowPopup:r,searchValue:l,setSearchValue:h,filter:s,searchIndex:g.index,indexStatus:g.status,t:t=>window.Spiritix?.t?.[t]||t,inputRef:u};return y(dt.Provider,{value:_},"\n ",y(jt,null),"\n ")}function mn(t){if(t=t?.replace("_","-"),!t||t.indexOf("-")<0)return t;return function(t){if("string"==typeof t&&t.indexOf("-")>-1){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch(t){}return e||t}return t}(t.split("-")[0])}function yn(){const t=document.documentElement.getAttribute("data-sx-content-api-url")?.replace(/\/+$/,""),e=document.documentElement.getAttribute("data-sx-content-api-key"),n=document.documentElement.getAttribute("lang")||"en",i=function(t){try{if(Intl?.Locale){const e=new Intl.Locale(t),n=e?.getTextInfo?.();if(n?.direction)return n.direction}}catch(t){}return t.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(mn(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}(n)||"ltr";return{contentApiUrl:t,contentApiKey:e,locale:n,dir:i}}!function(){const{contentApiUrl:n,contentApiKey:i,dir:r}=yn(),s=function(){const t=document.createElement("div");return t.id="sx-search-root",document.body.appendChild(t),t}();if(!n||!i)throw Error("Spritix Search: Content API key or URL not found!");!function(n,i){var r,s,o;i==document&&(i=document.documentElement),e.__&&e.__(n,i),r=i.__k,s=[],o=[],M(i,n=i.__k=y(w,null,[n]),r||f,f,i.namespaceURI,r?null:i.firstChild?t.call(i.childNodes):null,s,r?r.__e:i.firstChild,!1,o),D(s,n,o)}(y(_n,{contentApiUrl:n,contentApiKey:i,dir:r}),s)}();