diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2b2f3a..cc61ca6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,4 +14,6 @@ jobs: with: fail_on_unmatched_files: true files: | - dist/searchbox.min.js \ No newline at end of file + dist/searchbox.iife.js + dist/searchbox.js + dist/searchbox.umd.cjs \ No newline at end of file diff --git a/README.md b/README.md index f429e54..e5fd653 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Play with the [demo](https://bausw-com.github.io/searchbox/demo.html) ## Features -- Backend-less, runs in the browser from pre-built index (see [Pagefind](https://pagefind.app/)) +- Backend-less, runs in the browser from a pre-built index (see [Pagefind](https://pagefind.app/)) - Ideal for small websites, documentation pages and blogs - Highly customizable @@ -47,136 +47,115 @@ Play with the [demo](https://bausw-com.github.io/searchbox/demo.html) Download a [release](https://github.com/bausw-com/searchbox/releases) or use a CDN: -1. Create `` element: - ```html - - + + - - - - - + + + + ``` ## Configuration options ```ts -export interface IOptions { - /** - * Dropdown alignment relative to the `anchor`. - */ - align?: 'left' | 'right'; - - /** - * Dropdown anchor element for positioning and alignment. If not specified, the `input` will be used. - */ - anchor?: HTMLElement; - - /** - * The name of the Pagefind's "filter" property to be used as a category for grouping results. Use one of the properties returned by `pagefind.filters();`. - * https://pagefind.app/docs/api/#filtering - */ - category?: string; - - /** - * A custom search function. Can be used to request external API. - */ - customSearch?: (term: string, suggestions: boolean) => Promise; - - /** - * A custom delay (in milliseconds) between the input focus and when the dropdown is shown. - */ - dropdownDelay?: number; - - /** - * Grouping function or a parameter name. The function should return group identifier as string. - */ - groupBy?: string | ((doc: IResultItemDoc) => string); - - /** - * Pagefind filters - * https://pagefind.app/docs/api/#filtering - */ - filters?: Record; - - /** - * The name of the "meta" property to be used as an image in the search results (typically, this would be "image"). - */ - image?: string; - - /** - * Max. number of results to return (default: 100) - */ - limit?: number; - - /** - * Path to `pagefind.js` script - */ - pagefind: string; - - /** - * A custom HTML element where the results will be rendered instead of the dropdown. Is specified, the dropdown won't be shown. - */ - results?: HTMLElement; - - /** - * Custom renderer functions. Supported functions: `header`, `footer`, `item`. - */ - renderers?: IRenderers; - - /** - * Pagefind sorting - * https://pagefind.app/docs/api/#sorting-results - */ - sort?: Record; - - /** - * I18n strings override. See `src/strings.ts`. - */ - strings?: Record; - - /** - * Whether to use suggestions - */ - suggestions?: boolean; - - /** - * A custom function that transforms the result (each item). - */ - transform?: TTransformFunc; - - /** - * Dropdown width (default: 100%) - */ - width?: number; -} +/** + * Dropdown alignment relative to the `anchor`. + */ +export let align: 'left' | 'right' | undefined = undefined; + +/** + * Dropdown anchor element for positioning and alignment. If not specified, the `input` will be used. + */ +export let anchor: string | undefined = undefined; + +/** + * The name of the Pagefind's "filter" property to be used as a category for grouping results. Use one of the properties returned by `pagefind.filters();`. + * https://pagefind.app/docs/api/#filtering +*/ +export let category: string | undefined = undefined; + +/** + * A custom search function. Can be used to request external API. + */ +export let customSearch: ((term: string, suggestions: boolean) => Promise) | undefined = undefined; + +/** + * A custom delay (in milliseconds) between the input focus and when the dropdown is shown. + */ +export let dropdownDelay: number | undefined = undefined; + +/** + * Grouping function or a parameter name. The function should return group identifier as string. + */ +export let groupBy: string | ((doc: IResultItemDoc) => string) | undefined = undefined; + +/** + * Pagefind filters + * https://pagefind.app/docs/api/#filtering + */ +export let filters: Record | undefined = undefined; + +/** + * The name of the "meta" property to be used as an image in the search results (typically, this would be "image"). +*/ +export let image: string | undefined = undefined; + +/** + * Max. number of results to return (default: 100) + */ +export let limit: number = 100; + +/** + * Path to `pagefind.js` script + */ +export let pagefind: string; + +/** + * Custom renderer functions. Supported functions: `header`, `footer`, `item`. + */ +export let renderers: IRenderers | undefined = undefined; + +/** + * A custom HTML element where the results will be rendered instead of the dropdown. Is specified, the dropdown won't be shown. + */ +export let results: string | undefined = undefined; + +/** + * Pagefind sorting + * https://pagefind.app/docs/api/#sorting-results + */ +export let sort: Record | undefined = undefined; + +/** + * I18n strings override. See `src/strings.ts`. + */ +export let strings: Record | undefined = undefined; + +/** + * Whether to use suggestions + */ +export let suggestions: boolean = false; + +/** + * A custom function that transforms the result (each item). + */ +export let transform: TTransformFunc | undefined = undefined; + +/** + * Dropdown width (default: 100%) + */ +export let width: string | undefined = undefined; ``` ## Credits - [Pagefind](https://pagefind.app/) - A fully static search library that aims to perform well on large sites, while using as little of your users’ bandwidth as possible, and without hosting any infrastructure -## Sponspor +## Sponsor -This project is sponsored by [BAUSW](https://bausw.com) - no-code business apps for the construction industry. +This project is sponsored by [BAUSW](https://bausw.com "Construction site diary and other digital solutions for engineers.") - Construction site diary and other digital solutions for engineers. ## License diff --git a/demo.html b/demo.html index 6dcd758..6b99315 100644 --- a/demo.html +++ b/demo.html @@ -24,6 +24,9 @@ display: flex; padding: 0.2rem 0.4rem; } + .search-input .search-box { + width: 100%; + } .search-input > *:not(:last-child) { margin-right: 5px; } @@ -60,7 +63,6 @@ box-shadow: 3px 2px 4px rgba(0, 0, 0, 0.075); } - @@ -69,7 +71,17 @@
- + + + +
@@ -83,45 +95,21 @@

Usage

-        <!-- 1. Create input element -->
-<div id="search">
-  <input type="search" />
-</div>
+        <script async defer type="module" src="https://cdn.jsdelivr.net/gh/bausw-com/searchbox/dist/searchbox.js"></script>
 
-<!-- 2. Include Searchbox into your website -->
-<script type="module" src="https://cdn.jsdelivr.net/gh/bausw-com/searchbox@0.2.4/dist/searchbox.min.js"></script>
-
-<!-- 3. Configure Searchbox instance -->
-<script>
-window.addEventListener('DOMContentLoaded', () => {
-  const searchbox = new Searchbox({
-    props: {
-      options: {
-        // Replace this with your Pagefind's build path
-        pagefind: '/_pagefind/pagefind.js',
-      },
-    },
-    target: document.querySelector('#search')
-  });
-});
-</script>
+<search-box pagefind="https://pagefind.app/_pagefind/pagefind.js"> + <input type="search" placeholder="Search..." /> +</search-box>
- + + diff --git a/dist/searchbox.iife.js b/dist/searchbox.iife.js new file mode 100644 index 0000000..6606020 --- /dev/null +++ b/dist/searchbox.iife.js @@ -0,0 +1 @@ +var altcha=function(){"use strict";var Mn=Object.defineProperty;var Pn=(B,G,ne)=>G in B?Mn(B,G,{enumerable:!0,configurable:!0,writable:!0,value:ne}):B[G]=ne;var z=(B,G,ne)=>(Pn(B,typeof G!="symbol"?G+"":G,ne),ne);function B(){}function G(n,e){for(const t in e)n[t]=e[t];return n}function ne(n){return n()}function Ue(){return Object.create(null)}function xe(n){n.forEach(ne)}function We(n){return typeof n=="function"}function ke(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}let De;function Ve(n,e){return n===e?!0:(De||(De=document.createElement("a")),De.href=e,n===De.href)}function It(n){return Object.keys(n).length===0}function Je(n,e,t,r){if(n){const s=Ke(n,e,t,r);return n[0](s)}}function Ke(n,e,t,r){return n[1]&&r?G(t.ctx.slice(),n[1](r(e))):t.ctx}function Ge(n,e,t,r){if(n[2]&&r){const s=n[2](r(t));if(e.dirty===void 0)return s;if(typeof s=="object"){const i=[],o=Math.max(e.dirty.length,s.length);for(let l=0;l32){const e=[],t=n.ctx.length/32;for(let r=0;rn.removeEventListener(e,t,r)}function Rt(n){return function(e){return e.preventDefault(),n.call(this,e)}}function $(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}const qt=["width","height"];function Ze(n,e){const t=Object.getOwnPropertyDescriptors(n.__proto__);for(const r in e)e[r]==null?n.removeAttribute(r):r==="style"?n.style.cssText=e[r]:r==="__value"?n.value=n[r]=e[r]:t[r]&&t[r].set&&qt.indexOf(r)===-1?n[r]=e[r]:$(n,r,e[r])}function Ft(n){return Array.from(n.childNodes)}function se(n,e){e=""+e,n.data!==e&&(n.data=e)}function de(n,e,t){n.classList.toggle(e,!!t)}function Ut(n,e,{bubbles:t=!1,cancelable:r=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:r})}class Wt{constructor(e=!1){z(this,"is_svg",!1);z(this,"e");z(this,"n");z(this,"t");z(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,r=null){this.e||(this.is_svg?this.e=zt(t.nodeName):this.e=E(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(r)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let t=0;t{e[t.slot||"default"]=!0}),e}let we;function ve(n){we=n}function Ae(){if(!we)throw new Error("Function called outside component initialization");return we}function Me(n){Ae().$$.on_mount.push(n)}function Jt(n){Ae().$$.after_update.push(n)}function et(n){Ae().$$.on_destroy.push(n)}function tt(){const n=Ae();return(e,t,{cancelable:r=!1}={})=>{const s=n.$$.callbacks[e];if(s){const i=Ut(e,t,{cancelable:r});return s.slice().forEach(o=>{o.call(n,i)}),!i.defaultPrevented}return!0}}const he=[],ee=[];let ge=[];const Pe=[],Kt=Promise.resolve();let je=!1;function Gt(){je||(je=!0,Kt.then(p))}function He(n){ge.push(n)}function Qt(n){Pe.push(n)}const ze=new Set;let me=0;function p(){if(me!==0)return;const n=we;do{try{for(;men.indexOf(r)===-1?e.push(r):t.push(r)),t.forEach(r=>r()),ge=e}const Ne=new Set;let le;function be(){le={r:0,c:[],p:le}}function _e(){le.r||xe(le.c),le=le.p}function N(n,e){n&&n.i&&(Ne.delete(n),n.i(e))}function I(n,e,t,r){if(n&&n.o){if(Ne.has(n))return;Ne.add(n),le.c.push(()=>{Ne.delete(n),r&&(t&&n.d(1),r())}),n.o(e)}else r&&r()}function pe(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Zt(n,e){const t={},r={},s={$$scope:1};let i=n.length;for(;i--;){const o=n[i],l=e[i];if(l){for(const c in o)c in l||(r[c]=1);for(const c in l)s[c]||(t[c]=l[c],s[c]=1);n[i]=l}else for(const c in o)s[c]=1}for(const o in r)o in t||(t[o]=void 0);return t}function en(n,e,t){const r=n.$$.props[e];r!==void 0&&(n.$$.bound[r]=t,t(n.$$.ctx[r]))}function ye(n){n&&n.c()}function ce(n,e,t){const{fragment:r,after_update:s}=n.$$;r&&r.m(e,t),He(()=>{const i=n.$$.on_mount.map(ne).filter(We);n.$$.on_destroy?n.$$.on_destroy.push(...i):xe(i),n.$$.on_mount=[]}),s.forEach(He)}function ue(n,e){const t=n.$$;t.fragment!==null&&(Yt(t.after_update),xe(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function tn(n,e){n.$$.dirty[0]===-1&&(he.push(n),Gt(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const _=a.length?a[0]:T;return f.ctx&&s(f.ctx[g],f.ctx[g]=_)&&(!f.skip_bound&&f.bound[g]&&f.bound[g](_),d&&tn(n,g)),T}):[],f.update(),d=!0,xe(f.before_update),f.fragment=r?r(f.ctx):!1,e.target){if(e.hydrate){const g=Ft(e.target);f.fragment&&f.fragment.l(g),g.forEach(L)}else f.fragment&&f.fragment.c();e.intro&&N(n.$$.fragment),ce(n,e.target,e.anchor),p()}ve(c)}let nt;typeof HTMLElement=="function"&&(nt=class extends HTMLElement{constructor(e,t,r){super();z(this,"$$ctor");z(this,"$$s");z(this,"$$c");z(this,"$$cn",!1);z(this,"$$d",{});z(this,"$$r",!1);z(this,"$$p_d",{});z(this,"$$l",{});z(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,r&&this.attachShadow({mode:"open"})}addEventListener(e,t,r){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const s=this.$$c.$on(e,t);this.$$l_u.set(t,s)}super.addEventListener(e,t,r)}removeEventListener(e,t,r){if(super.removeEventListener(e,t,r),this.$$c){const s=this.$$l_u.get(t);s&&(s(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(i){return()=>{let o;return{c:function(){o=E("slot"),i!=="default"&&$(o,"name",i)},m:function(f,d){D(f,o,d)},d:function(f){f&&L(o)}}}};if(await Promise.resolve(),!this.$$cn)return;const t={},r=Vt(this);for(const i of this.$$s)i in r&&(t[i]=[e(i)]);for(const i of this.attributes){const o=this.$$g_p(i.name);o in this.$$d||(this.$$d[o]=Oe(o,i.value,this.$$p_d,"toProp"))}this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const s=()=>{this.$$r=!0;for(const i in this.$$p_d)if(this.$$d[i]=this.$$c.$$.ctx[this.$$c.$$.props[i]],this.$$p_d[i].reflect){const o=Oe(i,this.$$d[i],this.$$p_d,"toAttribute");o==null?this.removeAttribute(this.$$p_d[i].attribute||i):this.setAttribute(this.$$p_d[i].attribute||i,o)}this.$$r=!1};this.$$c.$$.after_update.push(s),s();for(const i in this.$$l)for(const o of this.$$l[i]){const l=this.$$c.$on(i,o);this.$$l_u.set(o,l)}this.$$l={}}}attributeChangedCallback(e,t,r){var s;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Oe(e,r,this.$$p_d,"toProp"),(s=this.$$c)==null||s.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Oe(n,e,t,r){var i;const s=(i=t[n])==null?void 0:i.type;if(e=s==="Boolean"&&typeof e!="boolean"?e!=null:e,!r||!t[n])return e;if(r==="toAttribute")switch(s){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(s){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function $e(n,e,t,r,s,i){let o=class extends nt{constructor(){super(n,t,s),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(l=>(e[l].attribute||l).toLowerCase())}};return Object.keys(e).forEach(l=>{Object.defineProperty(o.prototype,l,{get(){return this.$$c&&l in this.$$c?this.$$c[l]:this.$$d[l]},set(c){var f;c=Oe(l,c,e),this.$$d[l]=c,(f=this.$$c)==null||f.$set({[l]:c})}})}),r.forEach(l=>{Object.defineProperty(o.prototype,l,{get(){var c;return(c=this.$$c)==null?void 0:c[l]}})}),i&&(o=i(o)),n.element=o,o}class Te{constructor(){z(this,"$$");z(this,"$$set")}$destroy(){ue(this,1),this.$destroy=B}$on(e,t){if(!We(t))return B;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(t),()=>{const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}$set(e){this.$$set&&!It(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const nn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(nn);function rn(n){let e,t,r,s;const i=n[10].default,o=Je(i,n,n[9],null);return{c(){e=E("div"),o&&o.c(),$(e,"class","searchbox-dropdown")},m(l,c){D(l,e,c),o&&o.m(e,null),n[11](e),t=!0,r||(s=re(e,"mousedown",sn),r=!0)},p(l,[c]){o&&o.p&&(!t||c&512)&&Qe(o,i,l,l[9],t?Ge(i,l[9],c,null):Xe(l[9]),null)},i(l){t||(N(o,l),t=!0)},o(l){I(o,l),t=!1},d(l){l&&L(e),o&&o.d(l),n[11](null),r=!1,s()}}}function sn(n){n.currentTarget.tagName!=="A"&&n.preventDefault()}function on(n,e,t){let r,{$$slots:s={},$$scope:i}=e,{align:o="left"}=e,{anchor:l=null}=e,{offset:c=[0,-1]}=e,{animationDuration:f=350}=e,{input:d}=e,{pageOffset:g=20}=e,{width:T=null}=e,a,_;et(()=>{_&&_.classList.remove("searchbox-dropdown-visible")}),Me(()=>{_=l?document.querySelector(l):d});function v(){if(_&&a){const m=_.getBoundingClientRect(),y=document.documentElement.clientHeight,S=document.documentElement.clientWidth,V=parseInt(r.borderTopWidth,10)+parseInt(r.borderBottomWidth,10),k=Math.min(y-g*2,y-g-m.bottom);t(0,a.style.width=`${T||m.width+"px"}`,a),t(0,a.style.top=`${m.bottom+c[1]}px`,a),o==="right"?(t(0,a.style.left="auto",a),t(0,a.style.right=`${S-(m.right+c[0])}px`,a)):(t(0,a.style.left=`${m.left+c[0]}px`,a),t(0,a.style.right="auto",a)),t(0,a.style.maxHeight=`${k}px`,a);const A=[...a.childNodes].reduce((F,h)=>h instanceof Element?F+Math.max(h.getBoundingClientRect().height,h.scrollHeight):F,V);t(0,a.style.height=`${Math.min(k,A)}px`,a),_.classList.add("searchbox-dropdown-visible"),setTimeout(()=>{a&&t(0,a.style.height="auto",a)},f)}}function x(m){ee[m?"unshift":"push"](()=>{a=m,t(0,a)})}return n.$$set=m=>{"align"in m&&t(1,o=m.align),"anchor"in m&&t(2,l=m.anchor),"offset"in m&&t(3,c=m.offset),"animationDuration"in m&&t(4,f=m.animationDuration),"input"in m&&t(5,d=m.input),"pageOffset"in m&&t(6,g=m.pageOffset),"width"in m&&t(7,T=m.width),"$$scope"in m&&t(9,i=m.$$scope)},n.$$.update=()=>{n.$$.dirty&1&&(r=a&&getComputedStyle(a))},[a,o,l,c,f,d,g,T,v,i,s,x]}class rt extends Te{constructor(e){super(),Ee(this,e,on,rn,ke,{align:1,anchor:2,offset:3,animationDuration:4,input:5,pageOffset:6,width:7,position:8})}get align(){return this.$$.ctx[1]}set align(e){this.$$set({align:e}),p()}get anchor(){return this.$$.ctx[2]}set anchor(e){this.$$set({anchor:e}),p()}get offset(){return this.$$.ctx[3]}set offset(e){this.$$set({offset:e}),p()}get animationDuration(){return this.$$.ctx[4]}set animationDuration(e){this.$$set({animationDuration:e}),p()}get input(){return this.$$.ctx[5]}set input(e){this.$$set({input:e}),p()}get pageOffset(){return this.$$.ctx[6]}set pageOffset(e){this.$$set({pageOffset:e}),p()}get width(){return this.$$.ctx[7]}set width(e){this.$$set({width:e}),p()}get position(){return this.$$.ctx[8]}}$e(rt,{align:{},anchor:{},offset:{},animationDuration:{},input:{},pageOffset:{},width:{}},["default"],["position"],!0);function ln(n){let e;return{c(){e=E("div")},m(t,r){D(t,e,r),n[3](e)},p:B,i:B,o:B,d(t){t&&L(e),n[3](null)}}}function cn(n,e,t){let r,{args:s}=e,{renderer:i}=e,o;Jt(()=>{r instanceof Element?o.replaceWith(r):r&&t(0,o.innerHTML=r,o)});function l(c){ee[c?"unshift":"push"](()=>{o=c,t(0,o)})}return n.$$set=c=>{"args"in c&&t(1,s=c.args),"renderer"in c&&t(2,i=c.renderer)},n.$$.update=()=>{n.$$.dirty&6&&(r=i(...s))},[o,s,i,l]}class Be extends Te{constructor(e){super(),Ee(this,e,cn,ln,ke,{args:1,renderer:2})}get args(){return this.$$.ctx[1]}set args(e){this.$$set({args:e}),p()}get renderer(){return this.$$.ctx[2]}set renderer(e){this.$$set({renderer:e}),p()}}$e(Be,{args:{},renderer:{}},[],[],!0);function st(n,e,t){const r=n.slice();return r[10]=e[t],r}function un(n){var S,V;let e,t,r,s,i,o=n[3].doc.title+"",l,c,f,d,g,T,a,_,v=n[3].doc.image&&ot(n),x=((S=n[5])==null?void 0:S.length)&&it(n),m=n[3].doc.excerpt&&ct(n),y=!n[1]&&((V=n[3].children)==null?void 0:V.length)&&ut(n);return{c(){e=E("a"),v&&v.c(),t=Q(),r=E("div"),s=E("div"),i=new Wt(!1),l=Q(),x&&x.c(),c=Q(),m&&m.c(),g=Q(),y&&y.c(),T=Ce(),i.a=l,$(s,"class","searchbox-results-title"),$(e,"href",f=n[3].doc.link),$(e,"class","searchbox-results-link"),$(e,"tabindex","-1"),$(e,"data-ref",d=n[3].ref)},m(k,A){D(k,e,A),v&&v.m(e,null),C(e,t),C(e,r),C(r,s),i.m(o,s),C(s,l),x&&x.m(s,null),C(r,c),m&&m.m(r,null),D(k,g,A),y&&y.m(k,A),D(k,T,A),a||(_=re(e,"click",n[6]),a=!0)},p(k,A){var F,h;k[3].doc.image?v?v.p(k,A):(v=ot(k),v.c(),v.m(e,t)):v&&(v.d(1),v=null),A&8&&o!==(o=k[3].doc.title+"")&&i.p(o),(F=k[5])!=null&&F.length?x?x.p(k,A):(x=it(k),x.c(),x.m(s,null)):x&&(x.d(1),x=null),k[3].doc.excerpt?m?m.p(k,A):(m=ct(k),m.c(),m.m(r,null)):m&&(m.d(1),m=null),A&8&&f!==(f=k[3].doc.link)&&$(e,"href",f),A&8&&d!==(d=k[3].ref)&&$(e,"data-ref",d),!k[1]&&((h=k[3].children)!=null&&h.length)?y?y.p(k,A):(y=ut(k),y.c(),y.m(T.parentNode,T)):y&&(y.d(1),y=null)},i:B,o:B,d(k){k&&(L(e),L(g),L(T)),v&&v.d(),x&&x.d(),m&&m.d(),y&&y.d(k),a=!1,_()}}}function fn(n){let e,t;return e=new Be({props:{renderer:n[4],args:[n[3]]}}),{c(){ye(e.$$.fragment)},m(r,s){ce(e,r,s),t=!0},p(r,s){const i={};s&16&&(i.renderer=r[4]),s&8&&(i.args=[r[3]]),e.$set(i)},i(r){t||(N(e.$$.fragment,r),t=!0)},o(r){I(e.$$.fragment,r),t=!1},d(r){ue(e,r)}}}function ot(n){let e,t,r;return{c(){e=E("div"),t=E("img"),Ve(t.src,r=n[3].doc.image)||$(t,"src",r),$(t,"alt",""),$(t,"width","48"),$(e,"class","searchbox-results-image")},m(s,i){D(s,e,i),C(e,t)},p(s,i){i&8&&!Ve(t.src,r=s[3].doc.image)&&$(t,"src",r)},d(s){s&&L(e)}}}function it(n){let e,t=pe(n[5]),r=[];for(let s=0;s{c[T]=null}),_e(),r=c[t],r?r.p(d,g):(r=c[t]=l[t](d),r.c()),N(r,1),r.m(e,null)),(!s||g&1)&&de(e,"searchbox-results-item-expanded",d[0])},i(d){s||(N(r),s=!0)},o(d){I(r),s=!1},d(d){d&&L(e),c[t].d(),i=!1,o()}}}function dn(n,e,t){let r,{expanded:s=!1}=e,{forceExpanded:i=!1}=e,{i18n:o}=e,{item:l}=e,{renderer:c=null}=e;const f=tt();function d(a){l.doc.link||(a.stopPropagation(),a.preventDefault(),f("click",l))}function g(){f("expand",l)}const T=()=>g();return n.$$set=a=>{"expanded"in a&&t(0,s=a.expanded),"forceExpanded"in a&&t(1,i=a.forceExpanded),"i18n"in a&&t(2,o=a.i18n),"item"in a&&t(3,l=a.item),"renderer"in a&&t(4,c=a.renderer)},n.$$.update=()=>{var a,_,v;n.$$.dirty&8&&t(5,r=Array.isArray((a=l==null?void 0:l.doc)==null?void 0:a.labels)?l.doc.labels:(v=(_=l==null?void 0:l.doc)==null?void 0:_.labels)==null?void 0:v.split(/[\,\;]/).filter(x=>!!x))},[s,i,o,l,c,r,d,g,T]}class ft extends Te{constructor(e){super(),Ee(this,e,dn,an,ke,{expanded:0,forceExpanded:1,i18n:2,item:3,renderer:4})}get expanded(){return this.$$.ctx[0]}set expanded(e){this.$$set({expanded:e}),p()}get forceExpanded(){return this.$$.ctx[1]}set forceExpanded(e){this.$$set({forceExpanded:e}),p()}get i18n(){return this.$$.ctx[2]}set i18n(e){this.$$set({i18n:e}),p()}get item(){return this.$$.ctx[3]}set item(e){this.$$set({item:e}),p()}get renderer(){return this.$$.ctx[4]}set renderer(e){this.$$set({renderer:e}),p()}}$e(ft,{expanded:{type:"Boolean"},forceExpanded:{type:"Boolean"},i18n:{},item:{},renderer:{}},[],[],!0);function at(n,e,t){const r=n.slice();return r[31]=e[t],r}function dt(n,e,t){const r=n.slice();return r[34]=e[t],r}function ht(n){let e,t,r;return t=new Be({props:{renderer:n[4].header,args:[n[5]]}}),{c(){e=E("div"),ye(t.$$.fragment),$(e,"class","searchbox-results-header")},m(s,i){D(s,e,i),ce(t,e,null),r=!0},p(s,i){const o={};i[0]&16&&(o.renderer=s[4].header),i[0]&32&&(o.args=[s[5]]),t.$set(o)},i(s){r||(N(t.$$.fragment,s),r=!0)},o(s){I(t.$$.fragment,s),r=!1},d(s){s&&L(e),ue(t)}}}function gt(n){let e,t,r,s,i=n[8].length>2&&mt(n),o=pe(n[8].slice(1)),l=[];for(let c=0;c2?i?i.p(c,f):(i=mt(c),i.c(),i.m(r,s)):i&&(i.d(1),i=null),f[0]&8449){o=pe(c[8].slice(1));let d;for(d=0;dI(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o1&>(n);const v=[bn,mn,gn,hn],x=[];function m(h,O){var J;return h[2]?0:h[3]?1:(J=h[9])!=null&&J.length?h[12]?3:-1:2}~(i=m(n))&&(o=x[i]=v[i](n));let y=((A=n[9])==null?void 0:A.length)>n[6]&&pt(n),S=((F=n[4])==null?void 0:F.footer)&&yt(n);return{c(){a&&a.c(),e=Q(),_&&_.c(),t=Q(),r=E("div"),s=E("ul"),o&&o.c(),l=Q(),y&&y.c(),c=Q(),S&&S.c(),f=Ce(),$(r,"class","searchbox-results-items")},m(h,O){a&&a.m(h,O),D(h,e,O),_&&_.m(h,O),D(h,t,O),D(h,r,O),C(r,s),~i&&x[i].m(s,null),C(s,l),y&&y.m(s,null),n[25](r),D(h,c,O),S&&S.m(h,O),D(h,f,O),d=!0,g||(T=re(r,"scroll",n[26]),g=!0)},p(h,O){var M,Y,oe,fe;(M=h[4])!=null&&M.header?a?(a.p(h,O),O[0]&16&&N(a,1)):(a=ht(h),a.c(),N(a,1),a.m(e.parentNode,e)):a&&(be(),I(a,1,1,()=>{a=null}),_e()),((Y=h[8])==null?void 0:Y.length)>1?_?_.p(h,O):(_=gt(h),_.c(),_.m(t.parentNode,t)):_&&(_.d(1),_=null);let J=i;i=m(h),i===J?~i&&x[i].p(h,O):(o&&(be(),I(x[J],1,1,()=>{x[J]=null}),_e()),~i?(o=x[i],o?o.p(h,O):(o=x[i]=v[i](h),o.c()),N(o,1),o.m(s,l)):o=null),((oe=h[9])==null?void 0:oe.length)>h[6]?y?y.p(h,O):(y=pt(h),y.c(),y.m(s,null)):y&&(y.d(1),y=null),(fe=h[4])!=null&&fe.footer?S?(S.p(h,O),O[0]&16&&N(S,1)):(S=yt(h),S.c(),N(S,1),S.m(f.parentNode,f)):S&&(be(),I(S,1,1,()=>{S=null}),_e())},i(h){d||(N(a),N(o),N(S),d=!0)},o(h){I(a),I(o),I(S),d=!1},d(h){h&&(L(e),L(t),L(r),L(c),L(f)),a&&a.d(h),_&&_.d(h),~i&&x[i].d(),y&&y.d(),n[25](null),S&&S.d(h),g=!1,T()}}}let xt=10;function pn(n,e,t){let r,s,i,{category:o=null}=e,{i18n:l}=e,{loading:c=!1}=e,{message:f=null}=e,{renderers:d=null}=e,{result:g=null}=e;const T=tt();let a,_=xt,v=[],x=!1;Me(()=>{requestAnimationFrame(()=>{A()})});function m(b,w,R){const q=o==="*"?b:b==null?void 0:b.filter(U=>U.doc.category===o);return t(11,x=(q==null?void 0:q.length)===1),q==null?void 0:q.reduce((U,P)=>{var j;return U.push(P),(j=P.children)!=null&&j.length&&(x||v.includes(P.ref))&&U.push(...P.children),U},[])}function y(b){(r==null?void 0:r.length)===2?t(0,o=r[1]):((r==null?void 0:r.length)===1||!(r!=null&&r.includes(o)))&&t(0,o="*")}function S(b){T("category",b)}function V(b){T("selection",b)}function k(b){v.includes(b.ref)?t(7,v=v.filter(w=>w!==b.ref)):t(7,v=[...v,b.ref])}function A(){(a==null?void 0:a.scrollTop)>5,(a==null?void 0:a.scrollTop)+(a==null?void 0:a.clientHeight)>=(a==null?void 0:a.scrollHeight)-50&&F()}function F(){t(6,_=_+xt)}function h(){a&&t(10,a.scrollTop=0,a)}function O(b,w="focus"){const R=[].slice.call(a.querySelectorAll("a[tabindex]"));let q=a.querySelector("a:hover, a."+w);q||(b=0,q=R[0]);const U=Math.max(0,Math.min(R.length-1,R.indexOf(q)+b)),P=R[U];q==null||q.classList.remove(w),P.classList.add(w);const j=P.getAttribute("data-ref"),Se=j&&g.items.find(Z=>Z.ref===j);Se&&T("selection",Se),P.scrollIntoView({behavior:"smooth"})}const J=()=>S("*"),M=b=>S(b),Y=b=>V(b.detail),oe=b=>k(b.detail),fe=()=>F();function ie(b){ee[b?"unshift":"push"](()=>{a=b,t(10,a)})}const ae=()=>A();return n.$$set=b=>{"category"in b&&t(0,o=b.category),"i18n"in b&&t(1,l=b.i18n),"loading"in b&&t(2,c=b.loading),"message"in b&&t(3,f=b.message),"renderers"in b&&t(4,d=b.renderers),"result"in b&&t(5,g=b.result)},n.$$.update=()=>{var b;n.$$.dirty[0]&32&&t(8,r=(b=g==null?void 0:g.items)==null?void 0:b.reduce((w,R)=>(R.doc.category&&!w.includes(R.doc.category)&&w.push(R.doc.category),w),["*"])),n.$$.dirty[0]&256&&y(),n.$$.dirty[0]&161&&t(9,s=m(g==null?void 0:g.items)),n.$$.dirty[0]&576&&t(12,i=s==null?void 0:s.slice(0,_))},[o,l,c,f,d,g,_,v,r,s,a,x,i,S,V,k,A,F,h,O,J,M,Y,oe,fe,ie,ae]}class Re extends Te{constructor(e){super(),Ee(this,e,pn,_n,ke,{category:0,i18n:1,loading:2,message:3,renderers:4,result:5,scrollToTop:18,navigateItems:19},null,[-1,-1])}get category(){return this.$$.ctx[0]}set category(e){this.$$set({category:e}),p()}get i18n(){return this.$$.ctx[1]}set i18n(e){this.$$set({i18n:e}),p()}get loading(){return this.$$.ctx[2]}set loading(e){this.$$set({loading:e}),p()}get message(){return this.$$.ctx[3]}set message(e){this.$$set({message:e}),p()}get renderers(){return this.$$.ctx[4]}set renderers(e){this.$$set({renderers:e}),p()}get result(){return this.$$.ctx[5]}set result(e){this.$$set({result:e}),p()}get scrollToTop(){return this.$$.ctx[18]}get navigateItems(){return this.$$.ctx[19]}}$e(Re,{category:{},i18n:{},loading:{type:"Boolean"},message:{},renderers:{},result:{}},[],["scrollToTop","navigateItems"],!0);const yn={all:"All",loading:"Loading...",load_more:"Load more",more_on_this_page:"{count} more on this page",no_results:"No results found."};function kt(n,e){let t;return(...r)=>{t&&clearTimeout(t),t=setTimeout(()=>{n(...r)},e)}}function xn(n){Pt(n,"svelte-1t9xdi2",":root{--searchbox-border-color:rgb(219, 219, 219);--searchbox-active-color:rgb(19, 58, 165);--searchbox-active-bg-color:rgb(233, 238, 250);--searchbox-muted-color:rgb(119, 119, 119);--searchbox-muted-bg-color:rgb(247, 247, 247);--searchbox-mark-bg:rgb(250, 248, 205);--searchbox-spacer:0.5rem;--searchbox-spacer-lg:1rem}.searchbox-results-categories{background-color:var(--searchbox-muted-bg-color);border-bottom:1px solid var(--searchbox-border-color);font-size:0.8rem;padding:0 var(--searchbox-spacer)}.searchbox-results-categories-wrap{overflow-y:visible;overflow-x:auto;margin:0 0 -1px 0}.searchbox-results-categories ul{display:flex;margin:0;padding:0;list-style:none}.searchbox-results-categories li{margin-right:var(--searchbox-spacer-lg)}.searchbox-results-categories a,.searchbox-results-categories [role=button]{border-bottom:1px solid transparent;color:var(--searchbox-muted-color);cursor:pointer;display:inline-block;padding:var(--searchbox-spacer) 0;white-space:nowrap}.searchbox-results-categories a.active,.searchbox-results-categories [role=button].active{border-bottom-color:var(--searchbox-active-color);color:var(--searchbox-active-color)}.searchbox-results-items{flex-grow:1;overflow-y:auto;overflow-x:hidden}.searchbox-results-items mark{background-color:var(--searchbox-mark-bg);color:currentColor;padding:0}.searchbox-results-items ul{margin:0;padding:0;list-style:none}.searchbox-results-items a{color:var(--searchbox-active-color)}.searchbox-results-header{background-color:var(--searchbox-muted-bg-color);border-bottom:1px solid var(--searchbox-border-color);padding:var(--searchbox-spacer)}.searchbox-results-footer{background-color:var(--searchbox-muted-bg-color);border-top:1px solid var(--searchbox-border-color);padding:var(--searchbox-spacer)}.searchbox-results:not(.compact) .searchbox-results-item:not(:last-child){border-bottom:1px solid var(--searchbox-border-color)}.searchbox-results-text{color:var(--searchbox-muted-color);padding:var(--searchbox-spacer)}.searchbox-results-load-more{color:var(--searchbox-muted-color)}.searchbox-results-load-more button{background:transparent;border:none;box-shadow:none;color:currentColor;cursor:pointer;font-size:0.8rem;outline:none;margin:0;padding:var(--searchbox-spacer);width:100%}.searchbox-results-item:not(:last-child){border-bottom:1px solid var(--searchbox-border-color)}.searchbox-results-link{display:flex;padding:var(--searchbox-spacer);text-decoration:none}.searchbox-results-link:hover{text-decoration:none}.searchbox-results-link.focus,.searchbox-results-link:hover{background-color:var(--searchbox-active-bg-color)}.searchbox-results-image{color:var(--searchbox-muted-color);margin-right:var(--searchbox-spacer)}.searchbox-results-excerpt{color:var(--searchbox-muted-color);font-size:0.8rem;margin-top:var(--searchbox-spacer)}.searchbox-results-excerpt code{font-size:0.8rem}.searchbox-results-excerpt h1,.searchbox-results-excerpt h2,.searchbox-results-excerpt h3,.searchbox-results-excerpt h4,.searchbox-results-excerpt h5,.searchbox-results-excerpt h6{font-size:0.8rem}.searchbox-results-excerpt p{margin-top:0}.searchbox-results-excerpt p:last-child{margin-bottom:0}.searchbox-results-expand{background-color:var(--searchbox-muted-bg-color);color:var(--searchbox-active-color)}.searchbox-results-expand button{background:transparent;border:none;box-shadow:none;color:currentColor;cursor:pointer;font-size:0.8rem;outline:none;margin:0;padding:var(--searchbox-spacer)}.searchbox-results-item-expanded .searchbox-results-expand{color:var(--searchbox-muted-color)}.searchbox-results-label{border:1px solid var(--searchbox-border-color);border-radius:1rem;color:var(--searchbox-muted-color);font-size:0.8rem;margin-left:var(--searchbox-spacer);padding:2px 6px}.searchbox-dropdown{background:white;border:1px solid var(--searchbox-border-color);display:flex;flex-direction:column;height:0;overflow:hidden;position:fixed;transition:height 0.3s;z-index:10000}")}function wt(n){let e,t,r={anchor:n[2],align:n[1],input:n[11],width:n[5],$$slots:{default:[kn]},$$scope:{ctx:n}};return e=new rt({props:r}),n[35](e),{c(){ye(e.$$.fragment)},m(s,i){ce(e,s,i),t=!0},p(s,i){const o={};i[0]&4&&(o.anchor=s[2]),i[0]&2&&(o.align=s[1]),i[0]&2048&&(o.input=s[11]),i[0]&32&&(o.width=s[5]),i[0]&29977|i[1]&64&&(o.$$scope={dirty:i,ctx:s}),e.$set(o)},i(s){t||(N(e.$$.fragment,s),t=!0)},o(s){I(e.$$.fragment,s),t=!1},d(s){n[35](null),ue(e,s)}}}function kn(n){let e,t,r;function s(o){n[32](o)}let i={renderers:n[3],i18n:n[15],loading:n[12],message:n[10],result:n[4]?n[14]:n[13]};return n[0]!==void 0&&(i.category=n[0]),e=new Re({props:i}),n[31](e),ee.push(()=>en(e,"category",s)),e.$on("category",n[33]),e.$on("selection",n[34]),{c(){ye(e.$$.fragment)},m(o,l){ce(e,o,l),r=!0},p(o,l){const c={};l[0]&8&&(c.renderers=o[3]),l[0]&4096&&(c.loading=o[12]),l[0]&1024&&(c.message=o[10]),l[0]&24592&&(c.result=o[4]?o[14]:o[13]),!t&&l[0]&1&&(t=!0,c.category=o[0],Qt(()=>t=!1)),e.$set(c)},i(o){r||(N(e.$$.fragment,o),r=!0)},o(o){I(e.$$.fragment,o),r=!1},d(o){n[31](null),ue(e,o)}}}function wn(n){let e,t,r;const s=n[30].default,i=Je(s,n,n[37],null);let o=n[6]&&wt(n),l=[n[18]],c={};for(let f=0;f{o=null}),_e()),Ze(e,c=Zt(l,[d[0]&262144&&f[18]]))},i(f){r||(N(i,f),N(o),r=!0)},o(f){I(i,f),I(o),r=!1},d(f){f&&L(e),i&&i.d(f),o&&o.d(),n[36](null)}}}function vn(n,e,t){const r=["align","anchor","category","customSearch","dropdownDelay","groupBy","filters","image","limit","pagefind","renderers","results","sort","strings","suggestions","transform","width"];let s=Ye(e,r),{$$slots:i={},$$scope:o}=e,{align:l=void 0}=e,{anchor:c=void 0}=e,{category:f="*"}=e,{customSearch:d=void 0}=e,{dropdownDelay:g=void 0}=e,{groupBy:T=void 0}=e,{filters:a=void 0}=e,{image:_=void 0}=e,{limit:v=100}=e,{pagefind:x}=e,{renderers:m=void 0}=e,{results:y=void 0}=e,{sort:S=void 0}=e,{strings:V=void 0}=e,{suggestions:k=!1}=e,{transform:A=void 0}=e,{width:F=void 0}=e;const h=kt(Sn,150),O=kt(En,10);let J,M,Y,oe,fe=null,ie=!1,ae,b=Object.assign({},yn,V||{}),w,R=!1,q,U,P=null,j=!1,Se,Z;et(()=>{document.removeEventListener("scroll",$t),w.removeEventListener("focus",Lt),w.removeEventListener("blur",St),w.removeEventListener("input",Ct),w.removeEventListener("keydown",Dt),ae&&ae.removeEventListener("submit",Tt),Z&&Z.$destroy()}),Me(()=>{x?import(x).then(u=>{if(!u||typeof u.search!="function")throw new Error(`Imported module ${x} is not a recognizable Pagefind module.`);q=u}).catch(u=>{Et(u)}):Et("Parameter 'pagefind' is empty."),$n(),ae=w.closest("form"),document.addEventListener("scroll",$t),w.addEventListener("focus",Lt),w.addEventListener("blur",St),w.addEventListener("input",Ct),w.addEventListener("keydown",Dt),ae&&ae.addEventListener("submit",Tt),y&&(oe=document.querySelector(y),oe.innerHTML="",Z=new Re({target:oe,props:{category:f,i18n:b}}),Z.$on("category",u=>{Fe(u.detail)}))});function Et(u){t(10,fe=String(u)),console.log(u)}function En(){requestAnimationFrame(()=>{J&&j&&J.position()})}function $n(){t(11,w=Y.parentElement.querySelector("input")),w||(t(11,w=document.createElement("input")),t(11,w.type="search",w),Y.parentElement.appendChild(w))}async function Tn(u){return t(12,R=!0),P=null,d(u,!0).then(H=>{t(14,Se=Nt(H))}).finally(()=>{t(12,R=!1)})}async function qe(u){return t(12,R=!0),P=null,(d?d(u,!1):Ln(u)).then(H=>{t(0,f="*"),t(13,U=Nt(H)),Z?Z.$set({category:f,result:U}):requestAnimationFrame(()=>{M&&j&&M.scrollToTop(),O()})}).finally(()=>{t(12,R=!1)})}function Fe(u){t(0,f=u),M&&j&&M.scrollToTop(),Z&&Z.$set({category:f})}function $t(){j&&O()}function Tt(u){u.preventDefault(),qe(w.value.trim())}function St(){ie=!1,requestAnimationFrame(()=>{ie||t(6,j=!1)})}function Lt(){ie=!0,(R||U!=null&&U.items)&&setTimeout(()=>{ie&&t(6,j=!0)},g||0)}function Dt(u){var K,H;u.key==="Enter"?(K=P==null?void 0:P.doc)!=null&&K.link?location.assign((H=P==null?void 0:P.doc)==null?void 0:H.link):(qe(w.value.trim()),w.blur()):u.key==="Escape"?ie&&(u.preventDefault(),w.blur()):u.key==="ArrowUp"||u.key==="Tab"&&u.shiftKey?(u.preventDefault(),M==null||M.navigateItems(-1)):u.key==="ArrowDown"||u.key==="Tab"?(u.preventDefault(),M==null||M.navigateItems(1)):u.key==="Shift"?u.preventDefault():h(w.value.trim())}function Ct(){h(w.value.trim())}function At(u){k?(t(11,w.value=u.doc.suggestion||u.doc.title,w),w.setSelectionRange(w.value.length,w.value.length)):P=u}function Sn(u){u?(ie&&!j&&t(6,j=!0),k?Tn(u):qe(u)):(t(13,U=null),j&&t(6,j=!1))}async function Ln(u){let K=[];if(x){const H=await q.search(u,{filters:a,sort:S});K=(await Promise.all(H.results.slice(0,v).map(async W=>({id:W.id,data:await W.data()})))).map(W=>{var Le,Ot,Bt;return{ref:W.id,doc:{category:f?(Le=W.data.filters[f])==null?void 0:Le[0]:void 0,image:_?(Ot=W.data.meta)==null?void 0:Ot[_]:void 0,link:W.data.url,title:(Bt=W.data.meta)==null?void 0:Bt.title,excerpt:W.data.excerpt}}})}return{items:K}}function Nt(u){return A&&(u.items=u.items.map(K=>(K.doc=A(K.doc,K,u),K))),T&&(u=Dn(u)),u}function Dn(u){const K=u.items.reduce((H,te)=>{const W=typeof T=="function"?T(te.doc):te.doc[T];return H.set(W,[...H.get(W)||[],te]),H},new Map);return u.items=[...K.values()].reduce((H,te)=>(H.push({...te[0],children:te.slice(1)}),H),[]).sort((H,te)=>{var W,Le;return((W=H.children)==null?void 0:W.length)>((Le=te.children)==null?void 0:Le.length)?-1:1}),u}function Cn(u){ee[u?"unshift":"push"](()=>{M=u,t(8,M)})}function An(u){f=u,t(0,f)}const Nn=u=>Fe(u.detail),On=u=>At(u.detail);function Bn(u){ee[u?"unshift":"push"](()=>{J=u,t(7,J)})}function In(u){ee[u?"unshift":"push"](()=>{Y=u,t(9,Y)})}return n.$$set=u=>{e=G(G({},e),Mt(u)),t(18,s=Ye(e,r)),"align"in u&&t(1,l=u.align),"anchor"in u&&t(2,c=u.anchor),"category"in u&&t(0,f=u.category),"customSearch"in u&&t(19,d=u.customSearch),"dropdownDelay"in u&&t(20,g=u.dropdownDelay),"groupBy"in u&&t(21,T=u.groupBy),"filters"in u&&t(22,a=u.filters),"image"in u&&t(23,_=u.image),"limit"in u&&t(24,v=u.limit),"pagefind"in u&&t(25,x=u.pagefind),"renderers"in u&&t(3,m=u.renderers),"results"in u&&t(26,y=u.results),"sort"in u&&t(27,S=u.sort),"strings"in u&&t(28,V=u.strings),"suggestions"in u&&t(4,k=u.suggestions),"transform"in u&&t(29,A=u.transform),"width"in u&&t(5,F=u.width),"$$scope"in u&&t(37,o=u.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&64&&j&&O()},[f,l,c,m,k,F,j,J,M,Y,fe,w,R,U,Se,b,Fe,At,s,d,g,T,a,_,v,x,y,S,V,A,i,Cn,An,Nn,On,Bn,In,o]}class vt extends Te{constructor(e){super(),Ee(this,e,vn,wn,ke,{align:1,anchor:2,category:0,customSearch:19,dropdownDelay:20,groupBy:21,filters:22,image:23,limit:24,pagefind:25,renderers:3,results:26,sort:27,strings:28,suggestions:4,transform:29,width:5},xn,[-1,-1])}get align(){return this.$$.ctx[1]}set align(e){this.$$set({align:e}),p()}get anchor(){return this.$$.ctx[2]}set anchor(e){this.$$set({anchor:e}),p()}get category(){return this.$$.ctx[0]}set category(e){this.$$set({category:e}),p()}get customSearch(){return this.$$.ctx[19]}set customSearch(e){this.$$set({customSearch:e}),p()}get dropdownDelay(){return this.$$.ctx[20]}set dropdownDelay(e){this.$$set({dropdownDelay:e}),p()}get groupBy(){return this.$$.ctx[21]}set groupBy(e){this.$$set({groupBy:e}),p()}get filters(){return this.$$.ctx[22]}set filters(e){this.$$set({filters:e}),p()}get image(){return this.$$.ctx[23]}set image(e){this.$$set({image:e}),p()}get limit(){return this.$$.ctx[24]}set limit(e){this.$$set({limit:e}),p()}get pagefind(){return this.$$.ctx[25]}set pagefind(e){this.$$set({pagefind:e}),p()}get renderers(){return this.$$.ctx[3]}set renderers(e){this.$$set({renderers:e}),p()}get results(){return this.$$.ctx[26]}set results(e){this.$$set({results:e}),p()}get sort(){return this.$$.ctx[27]}set sort(e){this.$$set({sort:e}),p()}get strings(){return this.$$.ctx[28]}set strings(e){this.$$set({strings:e}),p()}get suggestions(){return this.$$.ctx[4]}set suggestions(e){this.$$set({suggestions:e}),p()}get transform(){return this.$$.ctx[29]}set transform(e){this.$$set({transform:e}),p()}get width(){return this.$$.ctx[5]}set width(e){this.$$set({width:e}),p()}}return customElements.define("search-box",$e(vt,{align:{},anchor:{},category:{},customSearch:{},dropdownDelay:{},groupBy:{},filters:{},image:{},limit:{},pagefind:{},renderers:{},results:{},sort:{},strings:{},suggestions:{type:"Boolean"},transform:{},width:{}},["default"],[],!1)),vt}(); diff --git a/dist/searchbox.js b/dist/searchbox.js new file mode 100644 index 0000000..5ce94e9 --- /dev/null +++ b/dist/searchbox.js @@ -0,0 +1,2492 @@ +var Vt = Object.defineProperty; +var Jt = (n, e, t) => e in n ? Vt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; +var H = (n, e, t) => (Jt(n, typeof e != "symbol" ? e + "" : e, t), t); +function K() { +} +function Ce(n, e) { + for (const t in e) + n[t] = e[t]; + return ( + /** @type {T & S} */ + n + ); +} +function wt(n) { + return n(); +} +function et() { + return /* @__PURE__ */ Object.create(null); +} +function we(n) { + n.forEach(wt); +} +function vt(n) { + return typeof n == "function"; +} +function ve(n, e) { + return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function"; +} +let Se; +function tt(n, e) { + return n === e ? !0 : (Se || (Se = document.createElement("a")), Se.href = e, n === Se.href); +} +function Kt(n) { + return Object.keys(n).length === 0; +} +function Et(n, e, t, r) { + if (n) { + const s = $t(n, e, t, r); + return n[0](s); + } +} +function $t(n, e, t, r) { + return n[1] && r ? Ce(t.ctx.slice(), n[1](r(e))) : t.ctx; +} +function Tt(n, e, t, r) { + if (n[2] && r) { + const s = n[2](r(t)); + if (e.dirty === void 0) + return s; + if (typeof s == "object") { + const i = [], o = Math.max(e.dirty.length, s.length); + for (let l = 0; l < o; l += 1) + i[l] = e.dirty[l] | s[l]; + return i; + } + return e.dirty | s; + } + return e.dirty; +} +function St(n, e, t, r, s, i) { + if (s) { + const o = $t(e, t, r, i); + n.p(o, s); + } +} +function Lt(n) { + if (n.ctx.length > 32) { + const e = [], t = n.ctx.length / 32; + for (let r = 0; r < t; r++) + e[r] = -1; + return e; + } + return -1; +} +function Gt(n) { + const e = {}; + for (const t in n) + t[0] !== "$" && (e[t] = n[t]); + return e; +} +function nt(n, e) { + const t = {}; + e = new Set(e); + for (const r in n) + !e.has(r) && r[0] !== "$" && (t[r] = n[r]); + return t; +} +function A(n, e) { + n.appendChild(e); +} +function Qt(n, e, t) { + const r = Xt(n); + if (!r.getElementById(e)) { + const s = T("style"); + s.id = e, s.textContent = t, Yt(r, s); + } +} +function Xt(n) { + if (!n) + return document; + const e = n.getRootNode ? n.getRootNode() : n.ownerDocument; + return e && /** @type {ShadowRoot} */ + e.host ? ( + /** @type {ShadowRoot} */ + e + ) : n.ownerDocument; +} +function Yt(n, e) { + return A( + /** @type {Document} */ + n.head || n, + e + ), e.sheet; +} +function D(n, e, t) { + n.insertBefore(e, t || null); +} +function L(n) { + n.parentNode && n.parentNode.removeChild(n); +} +function ze(n, e) { + for (let t = 0; t < n.length; t += 1) + n[t] && n[t].d(e); +} +function T(n) { + return document.createElement(n); +} +function Zt(n) { + return document.createElementNS("http://www.w3.org/2000/svg", n); +} +function Y(n) { + return document.createTextNode(n); +} +function G() { + return Y(" "); +} +function Ae() { + return Y(""); +} +function re(n, e, t, r) { + return n.addEventListener(e, t, r), () => n.removeEventListener(e, t, r); +} +function en(n) { + return function(e) { + return e.preventDefault(), n.call(this, e); + }; +} +function $(n, e, t) { + t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t); +} +const tn = ["width", "height"]; +function rt(n, e) { + const t = Object.getOwnPropertyDescriptors(n.__proto__); + for (const r in e) + e[r] == null ? n.removeAttribute(r) : r === "style" ? n.style.cssText = e[r] : r === "__value" ? n.value = n[r] = e[r] : t[r] && t[r].set && tn.indexOf(r) === -1 ? n[r] = e[r] : $(n, r, e[r]); +} +function nn(n) { + return Array.from(n.childNodes); +} +function se(n, e) { + e = "" + e, n.data !== e && (n.data = /** @type {string} */ + e); +} +function me(n, e, t) { + n.classList.toggle(e, !!t); +} +function rn(n, e, { bubbles: t = !1, cancelable: r = !1 } = {}) { + return new CustomEvent(n, { detail: e, bubbles: t, cancelable: r }); +} +class sn { + constructor(e = !1) { + /** + * @private + * @default false + */ + H(this, "is_svg", !1); + /** parent for creating node */ + H(this, "e"); + /** html tag nodes */ + H(this, "n"); + /** target */ + H(this, "t"); + /** anchor */ + H(this, "a"); + this.is_svg = e, this.e = this.n = null; + } + /** + * @param {string} html + * @returns {void} + */ + c(e) { + this.h(e); + } + /** + * @param {string} html + * @param {HTMLElement | SVGElement} target + * @param {HTMLElement | SVGElement} anchor + * @returns {void} + */ + m(e, t, r = null) { + this.e || (this.is_svg ? this.e = Zt( + /** @type {keyof SVGElementTagNameMap} */ + t.nodeName + ) : this.e = T( + /** @type {keyof HTMLElementTagNameMap} */ + t.nodeType === 11 ? "TEMPLATE" : t.nodeName + ), this.t = t.tagName !== "TEMPLATE" ? t : ( + /** @type {HTMLTemplateElement} */ + t.content + ), this.c(e)), this.i(r); + } + /** + * @param {string} html + * @returns {void} + */ + h(e) { + this.e.innerHTML = e, this.n = Array.from( + this.e.nodeName === "TEMPLATE" ? this.e.content.childNodes : this.e.childNodes + ); + } + /** + * @returns {void} */ + i(e) { + for (let t = 0; t < this.n.length; t += 1) + D(this.t, this.n[t], e); + } + /** + * @param {string} html + * @returns {void} + */ + p(e) { + this.d(), this.h(e), this.i(this.a); + } + /** + * @returns {void} */ + d() { + this.n.forEach(L); + } +} +function on(n) { + const e = {}; + return n.childNodes.forEach( + /** @param {Element} node */ + (t) => { + e[t.slot || "default"] = !0; + } + ), e; +} +let ke; +function ye(n) { + ke = n; +} +function Ne() { + if (!ke) + throw new Error("Function called outside component initialization"); + return ke; +} +function Re(n) { + Ne().$$.on_mount.push(n); +} +function ln(n) { + Ne().$$.after_update.push(n); +} +function Dt(n) { + Ne().$$.on_destroy.push(n); +} +function Ct() { + const n = Ne(); + return (e, t, { cancelable: r = !1 } = {}) => { + const s = n.$$.callbacks[e]; + if (s) { + const i = rn( + /** @type {string} */ + e, + t, + { cancelable: r } + ); + return s.slice().forEach((o) => { + o.call(n, i); + }), !i.defaultPrevented; + } + return !0; + }; +} +const ae = [], ee = []; +let de = []; +const Pe = [], cn = /* @__PURE__ */ Promise.resolve(); +let je = !1; +function un() { + je || (je = !0, cn.then(x)); +} +function He(n) { + de.push(n); +} +function fn(n) { + Pe.push(n); +} +const Me = /* @__PURE__ */ new Set(); +let fe = 0; +function x() { + if (fe !== 0) + return; + const n = ke; + do { + try { + for (; fe < ae.length; ) { + const e = ae[fe]; + fe++, ye(e), an(e.$$); + } + } catch (e) { + throw ae.length = 0, fe = 0, e; + } + for (ye(null), ae.length = 0, fe = 0; ee.length; ) + ee.pop()(); + for (let e = 0; e < de.length; e += 1) { + const t = de[e]; + Me.has(t) || (Me.add(t), t()); + } + de.length = 0; + } while (ae.length); + for (; Pe.length; ) + Pe.pop()(); + je = !1, Me.clear(), ye(n); +} +function an(n) { + if (n.fragment !== null) { + n.update(), we(n.before_update); + const e = n.dirty; + n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(He); + } +} +function dn(n) { + const e = [], t = []; + de.forEach((r) => n.indexOf(r) === -1 ? e.push(r) : t.push(r)), t.forEach((r) => r()), de = e; +} +const Le = /* @__PURE__ */ new Set(); +let le; +function he() { + le = { + r: 0, + c: [], + p: le + // parent group + }; +} +function ge() { + le.r || we(le.c), le = le.p; +} +function N(n, e) { + n && n.i && (Le.delete(n), n.i(e)); +} +function B(n, e, t, r) { + if (n && n.o) { + if (Le.has(n)) + return; + Le.add(n), le.c.push(() => { + Le.delete(n), r && (t && n.d(1), r()); + }), n.o(e); + } else + r && r(); +} +function be(n) { + return (n == null ? void 0 : n.length) !== void 0 ? n : Array.from(n); +} +function hn(n, e) { + const t = {}, r = {}, s = { $$scope: 1 }; + let i = n.length; + for (; i--; ) { + const o = n[i], l = e[i]; + if (l) { + for (const c in o) + c in l || (r[c] = 1); + for (const c in l) + s[c] || (t[c] = l[c], s[c] = 1); + n[i] = l; + } else + for (const c in o) + s[c] = 1; + } + for (const o in r) + o in t || (t[o] = void 0); + return t; +} +function gn(n, e, t) { + const r = n.$$.props[e]; + r !== void 0 && (n.$$.bound[r] = t, t(n.$$.ctx[r])); +} +function _e(n) { + n && n.c(); +} +function ce(n, e, t) { + const { fragment: r, after_update: s } = n.$$; + r && r.m(e, t), He(() => { + const i = n.$$.on_mount.map(wt).filter(vt); + n.$$.on_destroy ? n.$$.on_destroy.push(...i) : we(i), n.$$.on_mount = []; + }), s.forEach(He); +} +function ue(n, e) { + const t = n.$$; + t.fragment !== null && (dn(t.after_update), we(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); +} +function mn(n, e) { + n.$$.dirty[0] === -1 && (ae.push(n), un(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; +} +function Ee(n, e, t, r, s, i, o = null, l = [-1]) { + const c = ke; + ye(n); + const f = n.$$ = { + fragment: null, + ctx: [], + // state + props: i, + update: K, + not_equal: s, + bound: et(), + // lifecycle + on_mount: [], + on_destroy: [], + on_disconnect: [], + before_update: [], + after_update: [], + context: new Map(e.context || (c ? c.$$.context : [])), + // everything else + callbacks: et(), + dirty: l, + skip_bound: !1, + root: e.target || c.$$.root + }; + o && o(f.root); + let d = !1; + if (f.ctx = t ? t(n, e.props || {}, (g, E, ...a) => { + const _ = a.length ? a[0] : E; + return f.ctx && s(f.ctx[g], f.ctx[g] = _) && (!f.skip_bound && f.bound[g] && f.bound[g](_), d && mn(n, g)), E; + }) : [], f.update(), d = !0, we(f.before_update), f.fragment = r ? r(f.ctx) : !1, e.target) { + if (e.hydrate) { + const g = nn(e.target); + f.fragment && f.fragment.l(g), g.forEach(L); + } else + f.fragment && f.fragment.c(); + e.intro && N(n.$$.fragment), ce(n, e.target, e.anchor), x(); + } + ye(c); +} +let At; +typeof HTMLElement == "function" && (At = class extends HTMLElement { + constructor(e, t, r) { + super(); + /** The Svelte component constructor */ + H(this, "$$ctor"); + /** Slots */ + H(this, "$$s"); + /** The Svelte component instance */ + H(this, "$$c"); + /** Whether or not the custom element is connected */ + H(this, "$$cn", !1); + /** Component props data */ + H(this, "$$d", {}); + /** `true` if currently in the process of reflecting component props back to attributes */ + H(this, "$$r", !1); + /** @type {Record} Props definition (name, reflected, type etc) */ + H(this, "$$p_d", {}); + /** @type {Record} Event listeners */ + H(this, "$$l", {}); + /** @type {Map} Event listener unsubscribe functions */ + H(this, "$$l_u", /* @__PURE__ */ new Map()); + this.$$ctor = e, this.$$s = t, r && this.attachShadow({ mode: "open" }); + } + addEventListener(e, t, r) { + if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) { + const s = this.$$c.$on(e, t); + this.$$l_u.set(t, s); + } + super.addEventListener(e, t, r); + } + removeEventListener(e, t, r) { + if (super.removeEventListener(e, t, r), this.$$c) { + const s = this.$$l_u.get(t); + s && (s(), this.$$l_u.delete(t)); + } + } + async connectedCallback() { + if (this.$$cn = !0, !this.$$c) { + let e = function(i) { + return () => { + let o; + return { + c: function() { + o = T("slot"), i !== "default" && $(o, "name", i); + }, + /** + * @param {HTMLElement} target + * @param {HTMLElement} [anchor] + */ + m: function(f, d) { + D(f, o, d); + }, + d: function(f) { + f && L(o); + } + }; + }; + }; + if (await Promise.resolve(), !this.$$cn) + return; + const t = {}, r = on(this); + for (const i of this.$$s) + i in r && (t[i] = [e(i)]); + for (const i of this.attributes) { + const o = this.$$g_p(i.name); + o in this.$$d || (this.$$d[o] = De(o, i.value, this.$$p_d, "toProp")); + } + this.$$c = new this.$$ctor({ + target: this.shadowRoot || this, + props: { + ...this.$$d, + $$slots: t, + $$scope: { + ctx: [] + } + } + }); + const s = () => { + this.$$r = !0; + for (const i in this.$$p_d) + if (this.$$d[i] = this.$$c.$$.ctx[this.$$c.$$.props[i]], this.$$p_d[i].reflect) { + const o = De( + i, + this.$$d[i], + this.$$p_d, + "toAttribute" + ); + o == null ? this.removeAttribute(this.$$p_d[i].attribute || i) : this.setAttribute(this.$$p_d[i].attribute || i, o); + } + this.$$r = !1; + }; + this.$$c.$$.after_update.push(s), s(); + for (const i in this.$$l) + for (const o of this.$$l[i]) { + const l = this.$$c.$on(i, o); + this.$$l_u.set(o, l); + } + this.$$l = {}; + } + } + // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte + // and setting attributes through setAttribute etc, this is helpful + attributeChangedCallback(e, t, r) { + var s; + this.$$r || (e = this.$$g_p(e), this.$$d[e] = De(e, r, this.$$p_d, "toProp"), (s = this.$$c) == null || s.$set({ [e]: this.$$d[e] })); + } + disconnectedCallback() { + this.$$cn = !1, Promise.resolve().then(() => { + this.$$cn || (this.$$c.$destroy(), this.$$c = void 0); + }); + } + $$g_p(e) { + return Object.keys(this.$$p_d).find( + (t) => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e + ) || e; + } +}); +function De(n, e, t, r) { + var i; + const s = (i = t[n]) == null ? void 0 : i.type; + if (e = s === "Boolean" && typeof e != "boolean" ? e != null : e, !r || !t[n]) + return e; + if (r === "toAttribute") + switch (s) { + case "Object": + case "Array": + return e == null ? null : JSON.stringify(e); + case "Boolean": + return e ? "" : null; + case "Number": + return e ?? null; + default: + return e; + } + else + switch (s) { + case "Object": + case "Array": + return e && JSON.parse(e); + case "Boolean": + return e; + case "Number": + return e != null ? +e : e; + default: + return e; + } +} +function $e(n, e, t, r, s, i) { + let o = class extends At { + constructor() { + super(n, t, s), this.$$p_d = e; + } + static get observedAttributes() { + return Object.keys(e).map( + (l) => (e[l].attribute || l).toLowerCase() + ); + } + }; + return Object.keys(e).forEach((l) => { + Object.defineProperty(o.prototype, l, { + get() { + return this.$$c && l in this.$$c ? this.$$c[l] : this.$$d[l]; + }, + set(c) { + var f; + c = De(l, c, e), this.$$d[l] = c, (f = this.$$c) == null || f.$set({ [l]: c }); + } + }); + }), r.forEach((l) => { + Object.defineProperty(o.prototype, l, { + get() { + var c; + return (c = this.$$c) == null ? void 0 : c[l]; + } + }); + }), i && (o = i(o)), n.element = /** @type {any} */ + o, o; +} +class Te { + constructor() { + /** + * ### PRIVATE API + * + * Do not use, may change at any time + * + * @type {any} + */ + H(this, "$$"); + /** + * ### PRIVATE API + * + * Do not use, may change at any time + * + * @type {any} + */ + H(this, "$$set"); + } + /** @returns {void} */ + $destroy() { + ue(this, 1), this.$destroy = K; + } + /** + * @template {Extract} K + * @param {K} type + * @param {((e: Events[K]) => void) | null | undefined} callback + * @returns {() => void} + */ + $on(e, t) { + if (!vt(t)) + return K; + const r = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); + return r.push(t), () => { + const s = r.indexOf(t); + s !== -1 && r.splice(s, 1); + }; + } + /** + * @param {Partial} props + * @returns {void} + */ + $set(e) { + this.$$set && !Kt(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + } +} +const bn = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(bn); +function _n(n) { + let e, t, r, s; + const i = ( + /*#slots*/ + n[10].default + ), o = Et( + i, + n, + /*$$scope*/ + n[9], + null + ); + return { + c() { + e = T("div"), o && o.c(), $(e, "class", "searchbox-dropdown"); + }, + m(l, c) { + D(l, e, c), o && o.m(e, null), n[11](e), t = !0, r || (s = re(e, "mousedown", pn), r = !0); + }, + p(l, [c]) { + o && o.p && (!t || c & /*$$scope*/ + 512) && St( + o, + i, + l, + /*$$scope*/ + l[9], + t ? Tt( + i, + /*$$scope*/ + l[9], + c, + null + ) : Lt( + /*$$scope*/ + l[9] + ), + null + ); + }, + i(l) { + t || (N(o, l), t = !0); + }, + o(l) { + B(o, l), t = !1; + }, + d(l) { + l && L(e), o && o.d(l), n[11](null), r = !1, s(); + } + }; +} +function pn(n) { + n.currentTarget.tagName !== "A" && n.preventDefault(); +} +function xn(n, e, t) { + let r, { $$slots: s = {}, $$scope: i } = e, { align: o = "left" } = e, { anchor: l = null } = e, { offset: c = [0, -1] } = e, { animationDuration: f = 350 } = e, { input: d } = e, { pageOffset: g = 20 } = e, { width: E = null } = e, a, _; + Dt(() => { + _ && _.classList.remove("searchbox-dropdown-visible"); + }), Re(() => { + _ = l ? document.querySelector(l) : d; + }); + function v() { + if (_ && a) { + const m = _.getBoundingClientRect(), p = document.documentElement.clientHeight, S = document.documentElement.clientWidth, W = parseInt(r.borderTopWidth, 10) + parseInt(r.borderBottomWidth, 10), k = Math.min(p - g * 2, p - g - m.bottom); + t(0, a.style.width = `${E || m.width + "px"}`, a), t(0, a.style.top = `${m.bottom + c[1]}px`, a), o === "right" ? (t(0, a.style.left = "auto", a), t(0, a.style.right = `${S - (m.right + c[0])}px`, a)) : (t(0, a.style.left = `${m.left + c[0]}px`, a), t(0, a.style.right = "auto", a)), t(0, a.style.maxHeight = `${k}px`, a); + const C = [...a.childNodes].reduce( + (q, h) => h instanceof Element ? q + Math.max(h.getBoundingClientRect().height, h.scrollHeight) : q, + W + ); + t(0, a.style.height = `${Math.min(k, C)}px`, a), _.classList.add("searchbox-dropdown-visible"), setTimeout( + () => { + a && t(0, a.style.height = "auto", a); + }, + f + ); + } + } + function y(m) { + ee[m ? "unshift" : "push"](() => { + a = m, t(0, a); + }); + } + return n.$$set = (m) => { + "align" in m && t(1, o = m.align), "anchor" in m && t(2, l = m.anchor), "offset" in m && t(3, c = m.offset), "animationDuration" in m && t(4, f = m.animationDuration), "input" in m && t(5, d = m.input), "pageOffset" in m && t(6, g = m.pageOffset), "width" in m && t(7, E = m.width), "$$scope" in m && t(9, i = m.$$scope); + }, n.$$.update = () => { + n.$$.dirty & /*el*/ + 1 && (r = a && getComputedStyle(a)); + }, [ + a, + o, + l, + c, + f, + d, + g, + E, + v, + i, + s, + y + ]; +} +class Nt extends Te { + constructor(e) { + super(), Ee(this, e, xn, _n, ve, { + align: 1, + anchor: 2, + offset: 3, + animationDuration: 4, + input: 5, + pageOffset: 6, + width: 7, + position: 8 + }); + } + get align() { + return this.$$.ctx[1]; + } + set align(e) { + this.$$set({ align: e }), x(); + } + get anchor() { + return this.$$.ctx[2]; + } + set anchor(e) { + this.$$set({ anchor: e }), x(); + } + get offset() { + return this.$$.ctx[3]; + } + set offset(e) { + this.$$set({ offset: e }), x(); + } + get animationDuration() { + return this.$$.ctx[4]; + } + set animationDuration(e) { + this.$$set({ animationDuration: e }), x(); + } + get input() { + return this.$$.ctx[5]; + } + set input(e) { + this.$$set({ input: e }), x(); + } + get pageOffset() { + return this.$$.ctx[6]; + } + set pageOffset(e) { + this.$$set({ pageOffset: e }), x(); + } + get width() { + return this.$$.ctx[7]; + } + set width(e) { + this.$$set({ width: e }), x(); + } + get position() { + return this.$$.ctx[8]; + } +} +$e(Nt, { align: {}, anchor: {}, offset: {}, animationDuration: {}, input: {}, pageOffset: {}, width: {} }, ["default"], ["position"], !0); +function yn(n) { + let e; + return { + c() { + e = T("div"); + }, + m(t, r) { + D(t, e, r), n[3](e); + }, + p: K, + i: K, + o: K, + d(t) { + t && L(e), n[3](null); + } + }; +} +function kn(n, e, t) { + let r, { args: s } = e, { renderer: i } = e, o; + ln(() => { + r instanceof Element ? o.replaceWith(r) : r && t(0, o.innerHTML = r, o); + }); + function l(c) { + ee[c ? "unshift" : "push"](() => { + o = c, t(0, o); + }); + } + return n.$$set = (c) => { + "args" in c && t(1, s = c.args), "renderer" in c && t(2, i = c.renderer); + }, n.$$.update = () => { + n.$$.dirty & /*renderer, args*/ + 6 && (r = i(...s)); + }, [o, s, i, l]; +} +class Oe extends Te { + constructor(e) { + super(), Ee(this, e, kn, yn, ve, { args: 1, renderer: 2 }); + } + get args() { + return this.$$.ctx[1]; + } + set args(e) { + this.$$set({ args: e }), x(); + } + get renderer() { + return this.$$.ctx[2]; + } + set renderer(e) { + this.$$set({ renderer: e }), x(); + } +} +$e(Oe, { args: {}, renderer: {} }, [], [], !0); +function st(n, e, t) { + const r = n.slice(); + return r[10] = e[t], r; +} +function wn(n) { + var S, W; + let e, t, r, s, i, o = ( + /*item*/ + n[3].doc.title + "" + ), l, c, f, d, g, E, a, _, v = ( + /*item*/ + n[3].doc.image && ot(n) + ), y = ( + /*labels*/ + ((S = n[5]) == null ? void 0 : S.length) && it(n) + ), m = ( + /*item*/ + n[3].doc.excerpt && ct(n) + ), p = !/*forceExpanded*/ + n[1] && /*item*/ + ((W = n[3].children) == null ? void 0 : W.length) && ut(n); + return { + c() { + e = T("a"), v && v.c(), t = G(), r = T("div"), s = T("div"), i = new sn(!1), l = G(), y && y.c(), c = G(), m && m.c(), g = G(), p && p.c(), E = Ae(), i.a = l, $(s, "class", "searchbox-results-title"), $(e, "href", f = /*item*/ + n[3].doc.link), $(e, "class", "searchbox-results-link"), $(e, "tabindex", "-1"), $(e, "data-ref", d = /*item*/ + n[3].ref); + }, + m(k, C) { + D(k, e, C), v && v.m(e, null), A(e, t), A(e, r), A(r, s), i.m(o, s), A(s, l), y && y.m(s, null), A(r, c), m && m.m(r, null), D(k, g, C), p && p.m(k, C), D(k, E, C), a || (_ = re( + e, + "click", + /*onClick*/ + n[6] + ), a = !0); + }, + p(k, C) { + var q, h; + /*item*/ + k[3].doc.image ? v ? v.p(k, C) : (v = ot(k), v.c(), v.m(e, t)) : v && (v.d(1), v = null), C & /*item*/ + 8 && o !== (o = /*item*/ + k[3].doc.title + "") && i.p(o), /*labels*/ + (q = k[5]) != null && q.length ? y ? y.p(k, C) : (y = it(k), y.c(), y.m(s, null)) : y && (y.d(1), y = null), /*item*/ + k[3].doc.excerpt ? m ? m.p(k, C) : (m = ct(k), m.c(), m.m(r, null)) : m && (m.d(1), m = null), C & /*item*/ + 8 && f !== (f = /*item*/ + k[3].doc.link) && $(e, "href", f), C & /*item*/ + 8 && d !== (d = /*item*/ + k[3].ref) && $(e, "data-ref", d), !/*forceExpanded*/ + k[1] && /*item*/ + ((h = k[3].children) != null && h.length) ? p ? p.p(k, C) : (p = ut(k), p.c(), p.m(E.parentNode, E)) : p && (p.d(1), p = null); + }, + i: K, + o: K, + d(k) { + k && (L(e), L(g), L(E)), v && v.d(), y && y.d(), m && m.d(), p && p.d(k), a = !1, _(); + } + }; +} +function vn(n) { + let e, t; + return e = new Oe({ + props: { + renderer: ( + /*renderer*/ + n[4] + ), + args: [ + /*item*/ + n[3] + ] + } + }), { + c() { + _e(e.$$.fragment); + }, + m(r, s) { + ce(e, r, s), t = !0; + }, + p(r, s) { + const i = {}; + s & /*renderer*/ + 16 && (i.renderer = /*renderer*/ + r[4]), s & /*item*/ + 8 && (i.args = [ + /*item*/ + r[3] + ]), e.$set(i); + }, + i(r) { + t || (N(e.$$.fragment, r), t = !0); + }, + o(r) { + B(e.$$.fragment, r), t = !1; + }, + d(r) { + ue(e, r); + } + }; +} +function ot(n) { + let e, t, r; + return { + c() { + e = T("div"), t = T("img"), tt(t.src, r = /*item*/ + n[3].doc.image) || $(t, "src", r), $(t, "alt", ""), $(t, "width", "48"), $(e, "class", "searchbox-results-image"); + }, + m(s, i) { + D(s, e, i), A(e, t); + }, + p(s, i) { + i & /*item*/ + 8 && !tt(t.src, r = /*item*/ + s[3].doc.image) && $(t, "src", r); + }, + d(s) { + s && L(e); + } + }; +} +function it(n) { + let e, t = be( + /*labels*/ + n[5] + ), r = []; + for (let s = 0; s < t.length; s += 1) + r[s] = lt(st(n, t, s)); + return { + c() { + for (let s = 0; s < r.length; s += 1) + r[s].c(); + e = Ae(); + }, + m(s, i) { + for (let o = 0; o < r.length; o += 1) + r[o] && r[o].m(s, i); + D(s, e, i); + }, + p(s, i) { + if (i & /*labels*/ + 32) { + t = be( + /*labels*/ + s[5] + ); + let o; + for (o = 0; o < t.length; o += 1) { + const l = st(s, t, o); + r[o] ? r[o].p(l, i) : (r[o] = lt(l), r[o].c(), r[o].m(e.parentNode, e)); + } + for (; o < r.length; o += 1) + r[o].d(1); + r.length = t.length; + } + }, + d(s) { + s && L(e), ze(r, s); + } + }; +} +function lt(n) { + let e, t = ( + /*label*/ + n[10] + "" + ), r; + return { + c() { + e = T("span"), r = Y(t), $(e, "class", "searchbox-results-label"); + }, + m(s, i) { + D(s, e, i), A(e, r); + }, + p(s, i) { + i & /*labels*/ + 32 && t !== (t = /*label*/ + s[10] + "") && se(r, t); + }, + d(s) { + s && L(e); + } + }; +} +function ct(n) { + let e, t = ( + /*item*/ + n[3].doc.excerpt + "" + ); + return { + c() { + e = T("div"), $(e, "class", "searchbox-results-excerpt"); + }, + m(r, s) { + D(r, e, s), e.innerHTML = t; + }, + p(r, s) { + s & /*item*/ + 8 && t !== (t = /*item*/ + r[3].doc.excerpt + "") && (e.innerHTML = t); + }, + d(r) { + r && L(e); + } + }; +} +function ut(n) { + let e, t, r = ( + /*i18n*/ + n[2].more_on_this_page.replace("{count}", String( + /*item*/ + n[3].children.length + )) + "" + ), s, i, o; + return { + c() { + e = T("div"), t = T("button"), s = Y(r), $(t, "type", "button"), $(e, "class", "searchbox-results-expand"); + }, + m(l, c) { + D(l, e, c), A(e, t), A(t, s), i || (o = re( + t, + "click", + /*click_handler*/ + n[8] + ), i = !0); + }, + p(l, c) { + c & /*i18n, item*/ + 12 && r !== (r = /*i18n*/ + l[2].more_on_this_page.replace("{count}", String( + /*item*/ + l[3].children.length + )) + "") && se(s, r); + }, + d(l) { + l && L(e), i = !1, o(); + } + }; +} +function En(n) { + let e, t, r, s, i, o; + const l = [vn, wn], c = []; + function f(d, g) { + return ( + /*renderer*/ + d[4] ? 0 : 1 + ); + } + return t = f(n), r = c[t] = l[t](n), { + c() { + e = T("li"), r.c(), $(e, "class", "searchbox-results-item"), me( + e, + "searchbox-results-item-expanded", + /*expanded*/ + n[0] + ); + }, + m(d, g) { + D(d, e, g), c[t].m(e, null), s = !0, i || (o = re( + e, + "click", + /*onClick*/ + n[6] + ), i = !0); + }, + p(d, [g]) { + let E = t; + t = f(d), t === E ? c[t].p(d, g) : (he(), B(c[E], 1, 1, () => { + c[E] = null; + }), ge(), r = c[t], r ? r.p(d, g) : (r = c[t] = l[t](d), r.c()), N(r, 1), r.m(e, null)), (!s || g & /*expanded*/ + 1) && me( + e, + "searchbox-results-item-expanded", + /*expanded*/ + d[0] + ); + }, + i(d) { + s || (N(r), s = !0); + }, + o(d) { + B(r), s = !1; + }, + d(d) { + d && L(e), c[t].d(), i = !1, o(); + } + }; +} +function $n(n, e, t) { + let r, { expanded: s = !1 } = e, { forceExpanded: i = !1 } = e, { i18n: o } = e, { item: l } = e, { renderer: c = null } = e; + const f = Ct(); + function d(a) { + l.doc.link || (a.stopPropagation(), a.preventDefault(), f("click", l)); + } + function g() { + f("expand", l); + } + const E = () => g(); + return n.$$set = (a) => { + "expanded" in a && t(0, s = a.expanded), "forceExpanded" in a && t(1, i = a.forceExpanded), "i18n" in a && t(2, o = a.i18n), "item" in a && t(3, l = a.item), "renderer" in a && t(4, c = a.renderer); + }, n.$$.update = () => { + var a, _, v; + n.$$.dirty & /*item*/ + 8 && t(5, r = Array.isArray((a = l == null ? void 0 : l.doc) == null ? void 0 : a.labels) ? l.doc.labels : (v = (_ = l == null ? void 0 : l.doc) == null ? void 0 : _.labels) == null ? void 0 : v.split(/[\,\;]/).filter((y) => !!y)); + }, [ + s, + i, + o, + l, + c, + r, + d, + g, + E + ]; +} +class Ot extends Te { + constructor(e) { + super(), Ee(this, e, $n, En, ve, { + expanded: 0, + forceExpanded: 1, + i18n: 2, + item: 3, + renderer: 4 + }); + } + get expanded() { + return this.$$.ctx[0]; + } + set expanded(e) { + this.$$set({ expanded: e }), x(); + } + get forceExpanded() { + return this.$$.ctx[1]; + } + set forceExpanded(e) { + this.$$set({ forceExpanded: e }), x(); + } + get i18n() { + return this.$$.ctx[2]; + } + set i18n(e) { + this.$$set({ i18n: e }), x(); + } + get item() { + return this.$$.ctx[3]; + } + set item(e) { + this.$$set({ item: e }), x(); + } + get renderer() { + return this.$$.ctx[4]; + } + set renderer(e) { + this.$$set({ renderer: e }), x(); + } +} +$e(Ot, { expanded: { type: "Boolean" }, forceExpanded: { type: "Boolean" }, i18n: {}, item: {}, renderer: {} }, [], [], !0); +function ft(n, e, t) { + const r = n.slice(); + return r[31] = e[t], r; +} +function at(n, e, t) { + const r = n.slice(); + return r[34] = e[t], r; +} +function dt(n) { + let e, t, r; + return t = new Oe({ + props: { + renderer: ( + /*renderers*/ + n[4].header + ), + args: [ + /*result*/ + n[5] + ] + } + }), { + c() { + e = T("div"), _e(t.$$.fragment), $(e, "class", "searchbox-results-header"); + }, + m(s, i) { + D(s, e, i), ce(t, e, null), r = !0; + }, + p(s, i) { + const o = {}; + i[0] & /*renderers*/ + 16 && (o.renderer = /*renderers*/ + s[4].header), i[0] & /*result*/ + 32 && (o.args = [ + /*result*/ + s[5] + ]), t.$set(o); + }, + i(s) { + r || (N(t.$$.fragment, s), r = !0); + }, + o(s) { + B(t.$$.fragment, s), r = !1; + }, + d(s) { + s && L(e), ue(t); + } + }; +} +function ht(n) { + let e, t, r, s, i = ( + /*categories*/ + n[8].length > 2 && gt(n) + ), o = be( + /*categories*/ + n[8].slice(1) + ), l = []; + for (let c = 0; c < o.length; c += 1) + l[c] = mt(at(n, o, c)); + return { + c() { + e = T("div"), t = T("div"), r = T("ul"), i && i.c(), s = G(); + for (let c = 0; c < l.length; c += 1) + l[c].c(); + $(t, "class", "searchbox-results-categories-wrap"), $(e, "class", "searchbox-results-categories"); + }, + m(c, f) { + D(c, e, f), A(e, t), A(t, r), i && i.m(r, null), A(r, s); + for (let d = 0; d < l.length; d += 1) + l[d] && l[d].m(r, null); + }, + p(c, f) { + if (/*categories*/ + c[8].length > 2 ? i ? i.p(c, f) : (i = gt(c), i.c(), i.m(r, s)) : i && (i.d(1), i = null), f[0] & /*category, categories, onCategoryClick*/ + 8449) { + o = be( + /*categories*/ + c[8].slice(1) + ); + let d; + for (d = 0; d < o.length; d += 1) { + const g = at(c, o, d); + l[d] ? l[d].p(g, f) : (l[d] = mt(g), l[d].c(), l[d].m(r, null)); + } + for (; d < l.length; d += 1) + l[d].d(1); + l.length = o.length; + } + }, + d(c) { + c && L(e), i && i.d(), ze(l, c); + } + }; +} +function gt(n) { + let e, t, r = ( + /*i18n*/ + n[1].all + "" + ), s, i, o; + return { + c() { + e = T("li"), t = T("span"), s = Y(r), $(t, "role", "button"), me( + t, + "active", + /*category*/ + n[0] === "*" + ); + }, + m(l, c) { + D(l, e, c), A(e, t), A(t, s), i || (o = re( + t, + "click", + /*click_handler*/ + n[20] + ), i = !0); + }, + p(l, c) { + c[0] & /*i18n*/ + 2 && r !== (r = /*i18n*/ + l[1].all + "") && se(s, r), c[0] & /*category*/ + 1 && me( + t, + "active", + /*category*/ + l[0] === "*" + ); + }, + d(l) { + l && L(e), i = !1, o(); + } + }; +} +function mt(n) { + let e, t, r = ( + /*cat*/ + n[34] + "" + ), s, i, o, l; + function c() { + return ( + /*click_handler_1*/ + n[21]( + /*cat*/ + n[34] + ) + ); + } + return { + c() { + e = T("li"), t = T("span"), s = Y(r), i = G(), $(t, "role", "button"), me( + t, + "active", + /*category*/ + n[0] === /*cat*/ + n[34] + ); + }, + m(f, d) { + D(f, e, d), A(e, t), A(t, s), A(e, i), o || (l = re(t, "click", c), o = !0); + }, + p(f, d) { + n = f, d[0] & /*categories*/ + 256 && r !== (r = /*cat*/ + n[34] + "") && se(s, r), d[0] & /*category, categories*/ + 257 && me( + t, + "active", + /*category*/ + n[0] === /*cat*/ + n[34] + ); + }, + d(f) { + f && L(e), o = !1, l(); + } + }; +} +function Tn(n) { + let e, t, r = be( + /*slicedFilteredItems*/ + n[12] + ), s = []; + for (let o = 0; o < r.length; o += 1) + s[o] = bt(ft(n, r, o)); + const i = (o) => B(s[o], 1, 1, () => { + s[o] = null; + }); + return { + c() { + for (let o = 0; o < s.length; o += 1) + s[o].c(); + e = Ae(); + }, + m(o, l) { + for (let c = 0; c < s.length; c += 1) + s[c] && s[c].m(o, l); + D(o, e, l), t = !0; + }, + p(o, l) { + if (l[0] & /*slicedFilteredItems, i18n, forceExpanded, renderers, expandedItems, onItemClick, onItemExpand*/ + 55442) { + r = be( + /*slicedFilteredItems*/ + o[12] + ); + let c; + for (c = 0; c < r.length; c += 1) { + const f = ft(o, r, c); + s[c] ? (s[c].p(f, l), N(s[c], 1)) : (s[c] = bt(f), s[c].c(), N(s[c], 1), s[c].m(e.parentNode, e)); + } + for (he(), c = r.length; c < s.length; c += 1) + i(c); + ge(); + } + }, + i(o) { + if (!t) { + for (let l = 0; l < r.length; l += 1) + N(s[l]); + t = !0; + } + }, + o(o) { + s = s.filter(Boolean); + for (let l = 0; l < s.length; l += 1) + B(s[l]); + t = !1; + }, + d(o) { + o && L(e), ze(s, o); + } + }; +} +function Sn(n) { + let e, t = ( + /*i18n*/ + n[1].no_results + "" + ), r; + return { + c() { + e = T("li"), r = Y(t), $(e, "class", "searchbox-results-text"); + }, + m(s, i) { + D(s, e, i), A(e, r); + }, + p(s, i) { + i[0] & /*i18n*/ + 2 && t !== (t = /*i18n*/ + s[1].no_results + "") && se(r, t); + }, + i: K, + o: K, + d(s) { + s && L(e); + } + }; +} +function Ln(n) { + let e, t; + return { + c() { + e = T("li"), t = Y( + /*message*/ + n[3] + ), $(e, "class", "searchbox-results-text"); + }, + m(r, s) { + D(r, e, s), A(e, t); + }, + p(r, s) { + s[0] & /*message*/ + 8 && se( + t, + /*message*/ + r[3] + ); + }, + i: K, + o: K, + d(r) { + r && L(e); + } + }; +} +function Dn(n) { + let e, t = ( + /*i18n*/ + n[1].loading + "" + ), r; + return { + c() { + e = T("li"), r = Y(t), $(e, "class", "searchbox-results-text"); + }, + m(s, i) { + D(s, e, i), A(e, r); + }, + p(s, i) { + i[0] & /*i18n*/ + 2 && t !== (t = /*i18n*/ + s[1].loading + "") && se(r, t); + }, + i: K, + o: K, + d(s) { + s && L(e); + } + }; +} +function bt(n) { + var r; + let e, t; + return e = new Ot({ + props: { + item: ( + /*item*/ + n[31] + ), + i18n: ( + /*i18n*/ + n[1] + ), + forceExpanded: ( + /*forceExpanded*/ + n[11] + ), + renderer: ( + /*renderers*/ + (r = n[4]) == null ? void 0 : r.item + ), + expanded: ( + /*expandedItems*/ + n[7].includes( + /*item*/ + n[31].ref + ) + ) + } + }), e.$on( + "click", + /*click_handler_2*/ + n[22] + ), e.$on( + "expand", + /*expand_handler*/ + n[23] + ), { + c() { + _e(e.$$.fragment); + }, + m(s, i) { + ce(e, s, i), t = !0; + }, + p(s, i) { + var l; + const o = {}; + i[0] & /*slicedFilteredItems*/ + 4096 && (o.item = /*item*/ + s[31]), i[0] & /*i18n*/ + 2 && (o.i18n = /*i18n*/ + s[1]), i[0] & /*forceExpanded*/ + 2048 && (o.forceExpanded = /*forceExpanded*/ + s[11]), i[0] & /*renderers*/ + 16 && (o.renderer = /*renderers*/ + (l = s[4]) == null ? void 0 : l.item), i[0] & /*expandedItems, slicedFilteredItems*/ + 4224 && (o.expanded = /*expandedItems*/ + s[7].includes( + /*item*/ + s[31].ref + )), e.$set(o); + }, + i(s) { + t || (N(e.$$.fragment, s), t = !0); + }, + o(s) { + B(e.$$.fragment, s), t = !1; + }, + d(s) { + ue(e, s); + } + }; +} +function _t(n) { + let e, t, r = ( + /*i18n*/ + n[1].load_more + "" + ), s, i, o; + return { + c() { + e = T("li"), t = T("button"), s = Y(r), $(t, "type", "button"), $(e, "class", "searchbox-results-load-more"); + }, + m(l, c) { + D(l, e, c), A(e, t), A(t, s), i || (o = re(t, "click", en( + /*click_handler_3*/ + n[24] + )), i = !0); + }, + p(l, c) { + c[0] & /*i18n*/ + 2 && r !== (r = /*i18n*/ + l[1].load_more + "") && se(s, r); + }, + d(l) { + l && L(e), i = !1, o(); + } + }; +} +function pt(n) { + let e, t, r; + return t = new Oe({ + props: { + renderer: ( + /*renderers*/ + n[4].footer + ), + args: [ + /*result*/ + n[5] + ] + } + }), { + c() { + e = T("div"), _e(t.$$.fragment), $(e, "class", "searchbox-results-footer"); + }, + m(s, i) { + D(s, e, i), ce(t, e, null), r = !0; + }, + p(s, i) { + const o = {}; + i[0] & /*renderers*/ + 16 && (o.renderer = /*renderers*/ + s[4].footer), i[0] & /*result*/ + 32 && (o.args = [ + /*result*/ + s[5] + ]), t.$set(o); + }, + i(s) { + r || (N(t.$$.fragment, s), r = !0); + }, + o(s) { + B(t.$$.fragment, s), r = !1; + }, + d(s) { + s && L(e), ue(t); + } + }; +} +function Cn(n) { + var W, k, C, q; + let e, t, r, s, i, o, l, c, f, d, g, E, a = ( + /*renderers*/ + ((W = n[4]) == null ? void 0 : W.header) && dt(n) + ), _ = ( + /*categories*/ + ((k = n[8]) == null ? void 0 : k.length) > 1 && ht(n) + ); + const v = [Dn, Ln, Sn, Tn], y = []; + function m(h, O) { + var V; + return ( + /*loading*/ + h[2] ? 0 : ( + /*message*/ + h[3] ? 1 : ( + /*filteredItems*/ + (V = h[9]) != null && V.length ? ( + /*slicedFilteredItems*/ + h[12] ? 3 : -1 + ) : 2 + ) + ) + ); + } + ~(i = m(n)) && (o = y[i] = v[i](n)); + let p = ( + /*filteredItems*/ + ((C = n[9]) == null ? void 0 : C.length) > /*maxItems*/ + n[6] && _t(n) + ), S = ( + /*renderers*/ + ((q = n[4]) == null ? void 0 : q.footer) && pt(n) + ); + return { + c() { + a && a.c(), e = G(), _ && _.c(), t = G(), r = T("div"), s = T("ul"), o && o.c(), l = G(), p && p.c(), c = G(), S && S.c(), f = Ae(), $(r, "class", "searchbox-results-items"); + }, + m(h, O) { + a && a.m(h, O), D(h, e, O), _ && _.m(h, O), D(h, t, O), D(h, r, O), A(r, s), ~i && y[i].m(s, null), A(s, l), p && p.m(s, null), n[25](r), D(h, c, O), S && S.m(h, O), D(h, f, O), d = !0, g || (E = re( + r, + "scroll", + /*scroll_handler*/ + n[26] + ), g = !0); + }, + p(h, O) { + var I, Q, te, oe; + /*renderers*/ + (I = h[4]) != null && I.header ? a ? (a.p(h, O), O[0] & /*renderers*/ + 16 && N(a, 1)) : (a = dt(h), a.c(), N(a, 1), a.m(e.parentNode, e)) : a && (he(), B(a, 1, 1, () => { + a = null; + }), ge()), /*categories*/ + ((Q = h[8]) == null ? void 0 : Q.length) > 1 ? _ ? _.p(h, O) : (_ = ht(h), _.c(), _.m(t.parentNode, t)) : _ && (_.d(1), _ = null); + let V = i; + i = m(h), i === V ? ~i && y[i].p(h, O) : (o && (he(), B(y[V], 1, 1, () => { + y[V] = null; + }), ge()), ~i ? (o = y[i], o ? o.p(h, O) : (o = y[i] = v[i](h), o.c()), N(o, 1), o.m(s, l)) : o = null), /*filteredItems*/ + ((te = h[9]) == null ? void 0 : te.length) > /*maxItems*/ + h[6] ? p ? p.p(h, O) : (p = _t(h), p.c(), p.m(s, null)) : p && (p.d(1), p = null), /*renderers*/ + (oe = h[4]) != null && oe.footer ? S ? (S.p(h, O), O[0] & /*renderers*/ + 16 && N(S, 1)) : (S = pt(h), S.c(), N(S, 1), S.m(f.parentNode, f)) : S && (he(), B(S, 1, 1, () => { + S = null; + }), ge()); + }, + i(h) { + d || (N(a), N(o), N(S), d = !0); + }, + o(h) { + B(a), B(o), B(S), d = !1; + }, + d(h) { + h && (L(e), L(t), L(r), L(c), L(f)), a && a.d(h), _ && _.d(h), ~i && y[i].d(), p && p.d(), n[25](null), S && S.d(h), g = !1, E(); + } + }; +} +let xt = 10; +function An(n, e, t) { + let r, s, i, { category: o = null } = e, { i18n: l } = e, { loading: c = !1 } = e, { message: f = null } = e, { renderers: d = null } = e, { result: g = null } = e; + const E = Ct(); + let a, _ = xt, v = [], y = !1; + Re(() => { + requestAnimationFrame(() => { + C(); + }); + }); + function m(b, w, z) { + const R = o === "*" ? b : b == null ? void 0 : b.filter((F) => F.doc.category === o); + return t(11, y = (R == null ? void 0 : R.length) === 1), R == null ? void 0 : R.reduce( + (F, M) => { + var P; + return F.push(M), (P = M.children) != null && P.length && (y || v.includes(M.ref)) && F.push(...M.children), F; + }, + [] + ); + } + function p(b) { + (r == null ? void 0 : r.length) === 2 ? t(0, o = r[1]) : ((r == null ? void 0 : r.length) === 1 || !(r != null && r.includes(o))) && t(0, o = "*"); + } + function S(b) { + E("category", b); + } + function W(b) { + E("selection", b); + } + function k(b) { + v.includes(b.ref) ? t(7, v = v.filter((w) => w !== b.ref)) : t(7, v = [...v, b.ref]); + } + function C() { + (a == null ? void 0 : a.scrollTop) > 5, (a == null ? void 0 : a.scrollTop) + (a == null ? void 0 : a.clientHeight) >= (a == null ? void 0 : a.scrollHeight) - 50 && q(); + } + function q() { + t(6, _ = _ + xt); + } + function h() { + a && t(10, a.scrollTop = 0, a); + } + function O(b, w = "focus") { + const z = [].slice.call(a.querySelectorAll("a[tabindex]")); + let R = a.querySelector("a:hover, a." + w); + R || (b = 0, R = z[0]); + const F = Math.max(0, Math.min(z.length - 1, z.indexOf(R) + b)), M = z[F]; + R == null || R.classList.remove(w), M.classList.add(w); + const P = M.getAttribute("data-ref"), pe = P && g.items.find((X) => X.ref === P); + pe && E("selection", pe), M.scrollIntoView({ behavior: "smooth" }); + } + const V = () => S("*"), I = (b) => S(b), Q = (b) => W(b.detail), te = (b) => k(b.detail), oe = () => q(); + function ne(b) { + ee[b ? "unshift" : "push"](() => { + a = b, t(10, a); + }); + } + const ie = () => C(); + return n.$$set = (b) => { + "category" in b && t(0, o = b.category), "i18n" in b && t(1, l = b.i18n), "loading" in b && t(2, c = b.loading), "message" in b && t(3, f = b.message), "renderers" in b && t(4, d = b.renderers), "result" in b && t(5, g = b.result); + }, n.$$.update = () => { + var b; + n.$$.dirty[0] & /*result*/ + 32 && t(8, r = (b = g == null ? void 0 : g.items) == null ? void 0 : b.reduce( + (w, z) => (z.doc.category && !w.includes(z.doc.category) && w.push(z.doc.category), w), + ["*"] + )), n.$$.dirty[0] & /*categories*/ + 256 && p(), n.$$.dirty[0] & /*result, category, expandedItems*/ + 161 && t(9, s = m(g == null ? void 0 : g.items)), n.$$.dirty[0] & /*filteredItems, maxItems*/ + 576 && t(12, i = s == null ? void 0 : s.slice(0, _)); + }, [ + o, + l, + c, + f, + d, + g, + _, + v, + r, + s, + a, + y, + i, + S, + W, + k, + C, + q, + h, + O, + V, + I, + Q, + te, + oe, + ne, + ie + ]; +} +class qe extends Te { + constructor(e) { + super(), Ee( + this, + e, + An, + Cn, + ve, + { + category: 0, + i18n: 1, + loading: 2, + message: 3, + renderers: 4, + result: 5, + scrollToTop: 18, + navigateItems: 19 + }, + null, + [-1, -1] + ); + } + get category() { + return this.$$.ctx[0]; + } + set category(e) { + this.$$set({ category: e }), x(); + } + get i18n() { + return this.$$.ctx[1]; + } + set i18n(e) { + this.$$set({ i18n: e }), x(); + } + get loading() { + return this.$$.ctx[2]; + } + set loading(e) { + this.$$set({ loading: e }), x(); + } + get message() { + return this.$$.ctx[3]; + } + set message(e) { + this.$$set({ message: e }), x(); + } + get renderers() { + return this.$$.ctx[4]; + } + set renderers(e) { + this.$$set({ renderers: e }), x(); + } + get result() { + return this.$$.ctx[5]; + } + set result(e) { + this.$$set({ result: e }), x(); + } + get scrollToTop() { + return this.$$.ctx[18]; + } + get navigateItems() { + return this.$$.ctx[19]; + } +} +$e(qe, { category: {}, i18n: {}, loading: { type: "Boolean" }, message: {}, renderers: {}, result: {} }, [], ["scrollToTop", "navigateItems"], !0); +const Nn = { + all: "All", + loading: "Loading...", + load_more: "Load more", + more_on_this_page: "{count} more on this page", + no_results: "No results found." +}; +function yt(n, e) { + let t; + return (...r) => { + t && clearTimeout(t), t = setTimeout(() => { + n(...r); + }, e); + }; +} +function On(n) { + Qt(n, "svelte-1t9xdi2", ":root{--searchbox-border-color:rgb(219, 219, 219);--searchbox-active-color:rgb(19, 58, 165);--searchbox-active-bg-color:rgb(233, 238, 250);--searchbox-muted-color:rgb(119, 119, 119);--searchbox-muted-bg-color:rgb(247, 247, 247);--searchbox-mark-bg:rgb(250, 248, 205);--searchbox-spacer:0.5rem;--searchbox-spacer-lg:1rem}.searchbox-results-categories{background-color:var(--searchbox-muted-bg-color);border-bottom:1px solid var(--searchbox-border-color);font-size:0.8rem;padding:0 var(--searchbox-spacer)}.searchbox-results-categories-wrap{overflow-y:visible;overflow-x:auto;margin:0 0 -1px 0}.searchbox-results-categories ul{display:flex;margin:0;padding:0;list-style:none}.searchbox-results-categories li{margin-right:var(--searchbox-spacer-lg)}.searchbox-results-categories a,.searchbox-results-categories [role=button]{border-bottom:1px solid transparent;color:var(--searchbox-muted-color);cursor:pointer;display:inline-block;padding:var(--searchbox-spacer) 0;white-space:nowrap}.searchbox-results-categories a.active,.searchbox-results-categories [role=button].active{border-bottom-color:var(--searchbox-active-color);color:var(--searchbox-active-color)}.searchbox-results-items{flex-grow:1;overflow-y:auto;overflow-x:hidden}.searchbox-results-items mark{background-color:var(--searchbox-mark-bg);color:currentColor;padding:0}.searchbox-results-items ul{margin:0;padding:0;list-style:none}.searchbox-results-items a{color:var(--searchbox-active-color)}.searchbox-results-header{background-color:var(--searchbox-muted-bg-color);border-bottom:1px solid var(--searchbox-border-color);padding:var(--searchbox-spacer)}.searchbox-results-footer{background-color:var(--searchbox-muted-bg-color);border-top:1px solid var(--searchbox-border-color);padding:var(--searchbox-spacer)}.searchbox-results:not(.compact) .searchbox-results-item:not(:last-child){border-bottom:1px solid var(--searchbox-border-color)}.searchbox-results-text{color:var(--searchbox-muted-color);padding:var(--searchbox-spacer)}.searchbox-results-load-more{color:var(--searchbox-muted-color)}.searchbox-results-load-more button{background:transparent;border:none;box-shadow:none;color:currentColor;cursor:pointer;font-size:0.8rem;outline:none;margin:0;padding:var(--searchbox-spacer);width:100%}.searchbox-results-item:not(:last-child){border-bottom:1px solid var(--searchbox-border-color)}.searchbox-results-link{display:flex;padding:var(--searchbox-spacer);text-decoration:none}.searchbox-results-link:hover{text-decoration:none}.searchbox-results-link.focus,.searchbox-results-link:hover{background-color:var(--searchbox-active-bg-color)}.searchbox-results-image{color:var(--searchbox-muted-color);margin-right:var(--searchbox-spacer)}.searchbox-results-excerpt{color:var(--searchbox-muted-color);font-size:0.8rem;margin-top:var(--searchbox-spacer)}.searchbox-results-excerpt code{font-size:0.8rem}.searchbox-results-excerpt h1,.searchbox-results-excerpt h2,.searchbox-results-excerpt h3,.searchbox-results-excerpt h4,.searchbox-results-excerpt h5,.searchbox-results-excerpt h6{font-size:0.8rem}.searchbox-results-excerpt p{margin-top:0}.searchbox-results-excerpt p:last-child{margin-bottom:0}.searchbox-results-expand{background-color:var(--searchbox-muted-bg-color);color:var(--searchbox-active-color)}.searchbox-results-expand button{background:transparent;border:none;box-shadow:none;color:currentColor;cursor:pointer;font-size:0.8rem;outline:none;margin:0;padding:var(--searchbox-spacer)}.searchbox-results-item-expanded .searchbox-results-expand{color:var(--searchbox-muted-color)}.searchbox-results-label{border:1px solid var(--searchbox-border-color);border-radius:1rem;color:var(--searchbox-muted-color);font-size:0.8rem;margin-left:var(--searchbox-spacer);padding:2px 6px}.searchbox-dropdown{background:white;border:1px solid var(--searchbox-border-color);display:flex;flex-direction:column;height:0;overflow:hidden;position:fixed;transition:height 0.3s;z-index:10000}"); +} +function kt(n) { + let e, t, r = { + anchor: ( + /*anchor*/ + n[2] + ), + align: ( + /*align*/ + n[1] + ), + input: ( + /*input*/ + n[11] + ), + width: ( + /*width*/ + n[5] + ), + $$slots: { default: [Bn] }, + $$scope: { ctx: n } + }; + return e = new Nt({ props: r }), n[35](e), { + c() { + _e(e.$$.fragment); + }, + m(s, i) { + ce(e, s, i), t = !0; + }, + p(s, i) { + const o = {}; + i[0] & /*anchor*/ + 4 && (o.anchor = /*anchor*/ + s[2]), i[0] & /*align*/ + 2 && (o.align = /*align*/ + s[1]), i[0] & /*input*/ + 2048 && (o.input = /*input*/ + s[11]), i[0] & /*width*/ + 32 && (o.width = /*width*/ + s[5]), i[0] & /*renderers, loading, error, suggestions, suggestionsResult, result, dropdownResults, category*/ + 29977 | i[1] & /*$$scope*/ + 64 && (o.$$scope = { dirty: i, ctx: s }), e.$set(o); + }, + i(s) { + t || (N(e.$$.fragment, s), t = !0); + }, + o(s) { + B(e.$$.fragment, s), t = !1; + }, + d(s) { + n[35](null), ue(e, s); + } + }; +} +function Bn(n) { + let e, t, r; + function s(o) { + n[32](o); + } + let i = { + renderers: ( + /*renderers*/ + n[3] + ), + i18n: ( + /*i18n*/ + n[15] + ), + loading: ( + /*loading*/ + n[12] + ), + message: ( + /*error*/ + n[10] + ), + result: ( + /*suggestions*/ + n[4] ? ( + /*suggestionsResult*/ + n[14] + ) : ( + /*result*/ + n[13] + ) + ) + }; + return ( + /*category*/ + n[0] !== void 0 && (i.category = /*category*/ + n[0]), e = new qe({ props: i }), n[31](e), ee.push(() => gn(e, "category", s)), e.$on( + "category", + /*category_handler*/ + n[33] + ), e.$on( + "selection", + /*selection_handler*/ + n[34] + ), { + c() { + _e(e.$$.fragment); + }, + m(o, l) { + ce(e, o, l), r = !0; + }, + p(o, l) { + const c = {}; + l[0] & /*renderers*/ + 8 && (c.renderers = /*renderers*/ + o[3]), l[0] & /*loading*/ + 4096 && (c.loading = /*loading*/ + o[12]), l[0] & /*error*/ + 1024 && (c.message = /*error*/ + o[10]), l[0] & /*suggestions, suggestionsResult, result*/ + 24592 && (c.result = /*suggestions*/ + o[4] ? ( + /*suggestionsResult*/ + o[14] + ) : ( + /*result*/ + o[13] + )), !t && l[0] & /*category*/ + 1 && (t = !0, c.category = /*category*/ + o[0], fn(() => t = !1)), e.$set(c); + }, + i(o) { + r || (N(e.$$.fragment, o), r = !0); + }, + o(o) { + B(e.$$.fragment, o), r = !1; + }, + d(o) { + n[31](null), ue(e, o); + } + } + ); +} +function In(n) { + let e, t, r; + const s = ( + /*#slots*/ + n[30].default + ), i = Et( + s, + n, + /*$$scope*/ + n[37], + null + ); + let o = ( + /*showDropdown*/ + n[6] && kt(n) + ), l = [ + /*$$restProps*/ + n[18] + ], c = {}; + for (let f = 0; f < l.length; f += 1) + c = Ce(c, l[f]); + return { + c() { + e = T("div"), i && i.c(), t = G(), o && o.c(), rt(e, c); + }, + m(f, d) { + D(f, e, d), i && i.m(e, null), A(e, t), o && o.m(e, null), n[36](e), r = !0; + }, + p(f, d) { + i && i.p && (!r || d[1] & /*$$scope*/ + 64) && St( + i, + s, + f, + /*$$scope*/ + f[37], + r ? Tt( + s, + /*$$scope*/ + f[37], + d, + null + ) : Lt( + /*$$scope*/ + f[37] + ), + null + ), /*showDropdown*/ + f[6] ? o ? (o.p(f, d), d[0] & /*showDropdown*/ + 64 && N(o, 1)) : (o = kt(f), o.c(), N(o, 1), o.m(e, null)) : o && (he(), B(o, 1, 1, () => { + o = null; + }), ge()), rt(e, c = hn(l, [d[0] & /*$$restProps*/ + 262144 && /*$$restProps*/ + f[18]])); + }, + i(f) { + r || (N(i, f), N(o), r = !0); + }, + o(f) { + B(i, f), B(o), r = !1; + }, + d(f) { + f && L(e), i && i.d(f), o && o.d(), n[36](null); + } + }; +} +function Mn(n, e, t) { + const r = [ + "align", + "anchor", + "category", + "customSearch", + "dropdownDelay", + "groupBy", + "filters", + "image", + "limit", + "pagefind", + "renderers", + "results", + "sort", + "strings", + "suggestions", + "transform", + "width" + ]; + let s = nt(e, r), { $$slots: i = {}, $$scope: o } = e, { align: l = void 0 } = e, { anchor: c = void 0 } = e, { category: f = "*" } = e, { customSearch: d = void 0 } = e, { dropdownDelay: g = void 0 } = e, { groupBy: E = void 0 } = e, { filters: a = void 0 } = e, { image: _ = void 0 } = e, { limit: v = 100 } = e, { pagefind: y } = e, { renderers: m = void 0 } = e, { results: p = void 0 } = e, { sort: S = void 0 } = e, { strings: W = void 0 } = e, { suggestions: k = !1 } = e, { transform: C = void 0 } = e, { width: q = void 0 } = e; + const h = yt(Pt, 150), O = yt(Bt, 10); + let V, I, Q, te, oe = null, ne = !1, ie, b = Object.assign({}, Nn, W || {}), w, z = !1, R, F, M = null, P = !1, pe, X; + Dt(() => { + document.removeEventListener("scroll", Ue), w.removeEventListener("focus", Je), w.removeEventListener("blur", Ve), w.removeEventListener("input", Ge), w.removeEventListener("keydown", Ke), ie && ie.removeEventListener("submit", We), X && X.$destroy(); + }), Re(() => { + y ? import( + /* @vite-ignore */ + y + ).then((u) => { + if (!u || typeof u.search != "function") + throw new Error(`Imported module ${y} is not a recognizable Pagefind module.`); + R = u; + }).catch((u) => { + Fe(u); + }) : Fe("Parameter 'pagefind' is empty."), It(), ie = w.closest("form"), document.addEventListener("scroll", Ue), w.addEventListener("focus", Je), w.addEventListener("blur", Ve), w.addEventListener("input", Ge), w.addEventListener("keydown", Ke), ie && ie.addEventListener("submit", We), p && (te = document.querySelector(p), te.innerHTML = "", X = new qe({ + target: te, + props: { category: f, i18n: b } + }), X.$on("category", (u) => { + Ie(u.detail); + })); + }); + function Fe(u) { + t(10, oe = String(u)), console.log(u); + } + function Bt() { + requestAnimationFrame(() => { + V && P && V.position(); + }); + } + function It() { + t(11, w = Q.parentElement.querySelector("input")), w || (t(11, w = document.createElement("input")), t(11, w.type = "search", w), Q.parentElement.appendChild(w)); + } + async function Mt(u) { + return t(12, z = !0), M = null, d(u, !0).then((j) => { + t(14, pe = Xe(j)); + }).finally(() => { + t(12, z = !1); + }); + } + async function Be(u) { + return t(12, z = !0), M = null, (d ? d(u, !1) : jt(u)).then((j) => { + t(0, f = "*"), t(13, F = Xe(j)), X ? X.$set({ category: f, result: F }) : requestAnimationFrame(() => { + I && P && I.scrollToTop(), O(); + }); + }).finally(() => { + t(12, z = !1); + }); + } + function Ie(u) { + t(0, f = u), I && P && I.scrollToTop(), X && X.$set({ category: f }); + } + function Ue() { + P && O(); + } + function We(u) { + u.preventDefault(), Be(w.value.trim()); + } + function Ve() { + ne = !1, requestAnimationFrame(() => { + ne || t(6, P = !1); + }); + } + function Je() { + ne = !0, (z || F != null && F.items) && setTimeout( + () => { + ne && t(6, P = !0); + }, + g || 0 + ); + } + function Ke(u) { + var J, j; + u.key === "Enter" ? (J = M == null ? void 0 : M.doc) != null && J.link ? location.assign((j = M == null ? void 0 : M.doc) == null ? void 0 : j.link) : (Be(w.value.trim()), w.blur()) : u.key === "Escape" ? ne && (u.preventDefault(), w.blur()) : u.key === "ArrowUp" || u.key === "Tab" && u.shiftKey ? (u.preventDefault(), I == null || I.navigateItems(-1)) : u.key === "ArrowDown" || u.key === "Tab" ? (u.preventDefault(), I == null || I.navigateItems(1)) : u.key === "Shift" ? u.preventDefault() : h(w.value.trim()); + } + function Ge() { + h(w.value.trim()); + } + function Qe(u) { + k ? (t(11, w.value = u.doc.suggestion || u.doc.title, w), w.setSelectionRange(w.value.length, w.value.length)) : M = u; + } + function Pt(u) { + u ? (ne && !P && t(6, P = !0), k ? Mt(u) : Be(u)) : (t(13, F = null), P && t(6, P = !1)); + } + async function jt(u) { + let J = []; + if (y) { + const j = await R.search(u, { filters: a, sort: S }); + J = (await Promise.all(j.results.slice(0, v).map(async (U) => ({ id: U.id, data: await U.data() })))).map((U) => { + var xe, Ye, Ze; + return { + ref: U.id, + doc: { + category: f ? (xe = U.data.filters[f]) == null ? void 0 : xe[0] : void 0, + image: _ ? (Ye = U.data.meta) == null ? void 0 : Ye[_] : void 0, + link: U.data.url, + title: (Ze = U.data.meta) == null ? void 0 : Ze.title, + excerpt: U.data.excerpt + } + }; + }); + } + return { items: J }; + } + function Xe(u) { + return C && (u.items = u.items.map((J) => (J.doc = C(J.doc, J, u), J))), E && (u = Ht(u)), u; + } + function Ht(u) { + const J = u.items.reduce( + (j, Z) => { + const U = typeof E == "function" ? E(Z.doc) : Z.doc[E]; + return j.set(U, [...j.get(U) || [], Z]), j; + }, + /* @__PURE__ */ new Map() + ); + return u.items = [...J.values()].reduce( + (j, Z) => (j.push({ ...Z[0], children: Z.slice(1) }), j), + [] + ).sort((j, Z) => { + var U, xe; + return ((U = j.children) == null ? void 0 : U.length) > ((xe = Z.children) == null ? void 0 : xe.length) ? -1 : 1; + }), u; + } + function zt(u) { + ee[u ? "unshift" : "push"](() => { + I = u, t(8, I); + }); + } + function Rt(u) { + f = u, t(0, f); + } + const qt = (u) => Ie(u.detail), Ft = (u) => Qe(u.detail); + function Ut(u) { + ee[u ? "unshift" : "push"](() => { + V = u, t(7, V); + }); + } + function Wt(u) { + ee[u ? "unshift" : "push"](() => { + Q = u, t(9, Q); + }); + } + return n.$$set = (u) => { + e = Ce(Ce({}, e), Gt(u)), t(18, s = nt(e, r)), "align" in u && t(1, l = u.align), "anchor" in u && t(2, c = u.anchor), "category" in u && t(0, f = u.category), "customSearch" in u && t(19, d = u.customSearch), "dropdownDelay" in u && t(20, g = u.dropdownDelay), "groupBy" in u && t(21, E = u.groupBy), "filters" in u && t(22, a = u.filters), "image" in u && t(23, _ = u.image), "limit" in u && t(24, v = u.limit), "pagefind" in u && t(25, y = u.pagefind), "renderers" in u && t(3, m = u.renderers), "results" in u && t(26, p = u.results), "sort" in u && t(27, S = u.sort), "strings" in u && t(28, W = u.strings), "suggestions" in u && t(4, k = u.suggestions), "transform" in u && t(29, C = u.transform), "width" in u && t(5, q = u.width), "$$scope" in u && t(37, o = u.$$scope); + }, n.$$.update = () => { + n.$$.dirty[0] & /*showDropdown*/ + 64 && P && O(); + }, [ + f, + l, + c, + m, + k, + q, + P, + V, + I, + Q, + oe, + w, + z, + F, + pe, + b, + Ie, + Qe, + s, + d, + g, + E, + a, + _, + v, + y, + p, + S, + W, + C, + i, + zt, + Rt, + qt, + Ft, + Ut, + Wt, + o + ]; +} +class Pn extends Te { + constructor(e) { + super(), Ee( + this, + e, + Mn, + In, + ve, + { + align: 1, + anchor: 2, + category: 0, + customSearch: 19, + dropdownDelay: 20, + groupBy: 21, + filters: 22, + image: 23, + limit: 24, + pagefind: 25, + renderers: 3, + results: 26, + sort: 27, + strings: 28, + suggestions: 4, + transform: 29, + width: 5 + }, + On, + [-1, -1] + ); + } + get align() { + return this.$$.ctx[1]; + } + set align(e) { + this.$$set({ align: e }), x(); + } + get anchor() { + return this.$$.ctx[2]; + } + set anchor(e) { + this.$$set({ anchor: e }), x(); + } + get category() { + return this.$$.ctx[0]; + } + set category(e) { + this.$$set({ category: e }), x(); + } + get customSearch() { + return this.$$.ctx[19]; + } + set customSearch(e) { + this.$$set({ customSearch: e }), x(); + } + get dropdownDelay() { + return this.$$.ctx[20]; + } + set dropdownDelay(e) { + this.$$set({ dropdownDelay: e }), x(); + } + get groupBy() { + return this.$$.ctx[21]; + } + set groupBy(e) { + this.$$set({ groupBy: e }), x(); + } + get filters() { + return this.$$.ctx[22]; + } + set filters(e) { + this.$$set({ filters: e }), x(); + } + get image() { + return this.$$.ctx[23]; + } + set image(e) { + this.$$set({ image: e }), x(); + } + get limit() { + return this.$$.ctx[24]; + } + set limit(e) { + this.$$set({ limit: e }), x(); + } + get pagefind() { + return this.$$.ctx[25]; + } + set pagefind(e) { + this.$$set({ pagefind: e }), x(); + } + get renderers() { + return this.$$.ctx[3]; + } + set renderers(e) { + this.$$set({ renderers: e }), x(); + } + get results() { + return this.$$.ctx[26]; + } + set results(e) { + this.$$set({ results: e }), x(); + } + get sort() { + return this.$$.ctx[27]; + } + set sort(e) { + this.$$set({ sort: e }), x(); + } + get strings() { + return this.$$.ctx[28]; + } + set strings(e) { + this.$$set({ strings: e }), x(); + } + get suggestions() { + return this.$$.ctx[4]; + } + set suggestions(e) { + this.$$set({ suggestions: e }), x(); + } + get transform() { + return this.$$.ctx[29]; + } + set transform(e) { + this.$$set({ transform: e }), x(); + } + get width() { + return this.$$.ctx[5]; + } + set width(e) { + this.$$set({ width: e }), x(); + } +} +customElements.define("search-box", $e(Pn, { align: {}, anchor: {}, category: {}, customSearch: {}, dropdownDelay: {}, groupBy: {}, filters: {}, image: {}, limit: {}, pagefind: {}, renderers: {}, results: {}, sort: {}, strings: {}, suggestions: { type: "Boolean" }, transform: {}, width: {} }, ["default"], [], !1)); +export { + Pn as default +}; diff --git a/dist/searchbox.min.js b/dist/searchbox.min.js deleted file mode 100644 index 1c85bdd..0000000 --- a/dist/searchbox.min.js +++ /dev/null @@ -1,2 +0,0 @@ -(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(":root{--searchbox-border-color: rgb(219, 219, 219);--searchbox-active-color: rgb(19, 58, 165);--searchbox-active-bg-color: rgb(233, 238, 250);--searchbox-muted-color: rgb(119, 119, 119);--searchbox-muted-bg-color: rgb(247, 247, 247);--searchbox-mark-bg: rgb(250, 248, 205);--searchbox-spacer: .5rem;--searchbox-spacer-lg: 1rem}.searchbox-results-categories{background-color:var(--searchbox-muted-bg-color);border-bottom:1px solid var(--searchbox-border-color);font-size:.8rem;padding:0 var(--searchbox-spacer)}.searchbox-results-categories-wrap{overflow-y:visible;overflow-x:auto;margin:0 0 -1px}.searchbox-results-categories ul{display:flex;margin:0;padding:0;list-style:none}.searchbox-results-categories li{margin-right:var(--searchbox-spacer-lg)}.searchbox-results-categories a,.searchbox-results-categories [role=button]{border-bottom:1px solid transparent;color:var(--searchbox-muted-color);cursor:pointer;display:inline-block;padding:var(--searchbox-spacer) 0;white-space:nowrap}.searchbox-results-categories a.active,.searchbox-results-categories [role=button].active{border-bottom-color:var(--searchbox-active-color);color:var(--searchbox-active-color)}.searchbox-results-items{flex-grow:1;overflow-y:auto;overflow-x:hidden}.searchbox-results-items mark{background-color:var(--searchbox-mark-bg);color:currentColor;padding:0}.searchbox-results-items ul{margin:0;padding:0;list-style:none}.searchbox-results-items a{color:var(--searchbox-active-color)}.searchbox-results-header{background-color:var(--searchbox-muted-bg-color);border-bottom:1px solid var(--searchbox-border-color);padding:var(--searchbox-spacer)}.searchbox-results-footer{background-color:var(--searchbox-muted-bg-color);border-top:1px solid var(--searchbox-border-color);padding:var(--searchbox-spacer)}.searchbox-results:not(.compact) .searchbox-results-item:not(:last-child){border-bottom:1px solid var(--searchbox-border-color)}.searchbox-results-text{color:var(--searchbox-muted-color);padding:var(--searchbox-spacer)}.searchbox-results-load-more{color:var(--searchbox-muted-color)}.searchbox-results-load-more button{background:transparent;border:none;box-shadow:none;color:currentColor;cursor:pointer;font-size:.8rem;outline:none;margin:0;padding:var(--searchbox-spacer);width:100%}.searchbox-results-item:not(:last-child){border-bottom:1px solid var(--searchbox-border-color)}.searchbox-results-link{display:flex;padding:var(--searchbox-spacer);text-decoration:none}.searchbox-results-link:hover{text-decoration:none}.searchbox-results-link.focus,.searchbox-results-link:hover{background-color:var(--searchbox-active-bg-color)}.searchbox-results-image{color:var(--searchbox-muted-color);margin-right:var(--searchbox-spacer)}.searchbox-results-excerpt{color:var(--searchbox-muted-color);font-size:.8rem;margin-top:var(--searchbox-spacer)}.searchbox-results-excerpt code,.searchbox-results-excerpt h1,.searchbox-results-excerpt h2,.searchbox-results-excerpt h3,.searchbox-results-excerpt h4,.searchbox-results-excerpt h5,.searchbox-results-excerpt h6{font-size:.8rem}.searchbox-results-excerpt p{margin-top:0}.searchbox-results-excerpt p:last-child{margin-bottom:0}.searchbox-results-expand{background-color:var(--searchbox-muted-bg-color);color:var(--searchbox-active-color)}.searchbox-results-expand button{background:transparent;border:none;box-shadow:none;color:currentColor;cursor:pointer;font-size:.8rem;outline:none;margin:0;padding:var(--searchbox-spacer)}.searchbox-results-item-expanded .searchbox-results-expand{color:var(--searchbox-muted-color)}.searchbox-results-label{border:1px solid var(--searchbox-border-color);border-radius:1rem;color:var(--searchbox-muted-color);font-size:.8rem;margin-left:var(--searchbox-spacer);padding:2px 6px}.searchbox-dropdown{background:white;border:1px solid var(--searchbox-border-color);display:flex;flex-direction:column;height:0;overflow:hidden;position:fixed;transition:height .3s;z-index:10000}")),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})(); -var mt=Object.defineProperty;var pt=(t,e,n)=>e in t?mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Z=(t,e,n)=>(pt(t,typeof e!="symbol"?e+"":e,n),n);const bt="modulepreload",kt=function(t){return"/"+t},Re={},yt=function(e,n,r){if(!n||n.length===0)return e();const l=document.getElementsByTagName("link");return Promise.all(n.map(o=>{if(o=kt(o),o in Re)return;Re[o]=!0;const i=o.endsWith(".css"),s=i?'[rel="stylesheet"]':"";if(!!r)for(let a=l.length-1;a>=0;a--){const g=l[a];if(g.href===o&&(!i||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${s}`))return;const c=document.createElement("link");if(c.rel=i?"stylesheet":bt,i||(c.as="script",c.crossOrigin=""),c.href=o,document.head.appendChild(c),i)return new Promise((a,g)=>{c.addEventListener("load",a),c.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${o}`)))})})).then(()=>e()).catch(o=>{const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=o,window.dispatchEvent(i),!i.defaultPrevented)throw o})};function q(){}function wt(t,e){for(const n in e)t[n]=e[n];return t}function rt(t){return t()}function qe(){return Object.create(null)}function pe(t){t.forEach(rt)}function it(t){return typeof t=="function"}function be(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let Le;function Fe(t,e){return t===e?!0:(Le||(Le=document.createElement("a")),Le.href=e,t===Le.href)}function Et(t){return Object.keys(t).length===0}function vt(t,e,n,r){if(t){const l=ot(t,e,n,r);return t[0](l)}}function ot(t,e,n,r){return t[1]&&r?wt(n.ctx.slice(),t[1](r(e))):n.ctx}function Tt(t,e,n,r){if(t[2]&&r){const l=t[2](r(n));if(e.dirty===void 0)return l;if(typeof l=="object"){const o=[],i=Math.max(e.dirty.length,l.length);for(let s=0;s32){const e=[],n=t.ctx.length/32;for(let r=0;rt.removeEventListener(e,n,r)}function Dt(t){return function(e){return e.preventDefault(),t.call(this,e)}}function L(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Nt(t){return Array.from(t.childNodes)}function $(t,e){e=""+e,t.data!==e&&(t.data=e)}function ae(t,e,n){t.classList.toggle(e,!!n)}function At(t,e,{bubbles:n=!1,cancelable:r=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:r})}class It{constructor(e=!1){Z(this,"is_svg",!1);Z(this,"e");Z(this,"n");Z(this,"t");Z(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,n,r=null){this.e||(this.is_svg?this.e=Ct(n.nodeName):this.e=C(n.nodeType===11?"TEMPLATE":n.nodeName),this.t=n.tagName!=="TEMPLATE"?n:n.content,this.c(e)),this.i(r)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let n=0;n{const l=t.$$.callbacks[e];if(l){const o=At(e,n,{cancelable:r});return l.slice().forEach(i=>{i.call(t,o)}),!o.defaultPrevented}return!0}}const se=[],Q=[];let fe=[];const Ae=[],Bt=Promise.resolve();let Ie=!1;function Pt(){Ie||(Ie=!0,Bt.then(ct))}function Me(t){fe.push(t)}function Ot(t){Ae.push(t)}const Ne=new Set;let oe=0;function ct(){if(oe!==0)return;const t=me;do{try{for(;oet.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),fe=e}const Se=new Set;let le;function ue(){le={r:0,c:[],p:le}}function ce(){le.r||pe(le.c),le=le.p}function N(t,e){t&&t.i&&(Se.delete(t),t.i(e))}function B(t,e,n,r){if(t&&t.o){if(Se.has(t))return;Se.add(t),le.c.push(()=>{Se.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function de(t){return(t==null?void 0:t.length)!==void 0?t:Array.from(t)}function qt(t,e,n){const r=t.$$.props[e];r!==void 0&&(t.$$.bound[r]=n,n(t.$$.ctx[r]))}function he(t){t&&t.c()}function re(t,e,n){const{fragment:r,after_update:l}=t.$$;r&&r.m(e,n),Me(()=>{const o=t.$$.on_mount.map(rt).filter(it);t.$$.on_destroy?t.$$.on_destroy.push(...o):pe(o),t.$$.on_mount=[]}),l.forEach(Me)}function ie(t,e){const n=t.$$;n.fragment!==null&&(Rt(n.after_update),pe(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Ft(t,e){t.$$.dirty[0]===-1&&(se.push(t),Pt(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const E=d.length?d[0]:_;return c.ctx&&l(c.ctx[g],c.ctx[g]=E)&&(!c.skip_bound&&c.bound[g]&&c.bound[g](E),a&&Ft(t,g)),_}):[],c.update(),a=!0,pe(c.before_update),c.fragment=r?r(c.ctx):!1,e.target){if(e.hydrate){const g=Nt(e.target);c.fragment&&c.fragment.l(g),g.forEach(T)}else c.fragment&&c.fragment.c();e.intro&&N(t.$$.fragment),re(t,e.target,e.anchor),ct()}ge(f)}class we{constructor(){Z(this,"$$");Z(this,"$$set")}$destroy(){ie(this,1),this.$destroy=q}$on(e,n){if(!it(n))return q;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const l=r.indexOf(n);l!==-1&&r.splice(l,1)}}$set(e){this.$$set&&!Et(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const jt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(jt);function Ut(t){let e,n,r,l;const o=t[9].default,i=vt(o,t,t[8],null);return{c(){e=C("div"),i&&i.c(),L(e,"class","searchbox-dropdown")},m(s,f){S(s,e,f),i&&i.m(e,null),t[10](e),n=!0,r||(l=x(e,"mousedown",Wt),r=!0)},p(s,[f]){i&&i.p&&(!n||f&256)&&Lt(i,o,s,s[8],n?Tt(o,s[8],f,null):St(s[8]),null)},i(s){n||(N(i,s),n=!0)},o(s){B(i,s),n=!1},d(s){s&&T(e),i&&i.d(s),t[10](null),r=!1,l()}}}function Wt(t){t.currentTarget.tagName!=="A"&&t.preventDefault()}function zt(t,e,n){let r,{$$slots:l={},$$scope:o}=e,{align:i="left"}=e,{anchor:s}=e,{offset:f=[0,-1]}=e,{animationDuration:c=350}=e,{pageOffset:a=20}=e,{width:g=null}=e,_;ft(()=>{s&&s.classList.remove("searchbox-dropdown-visible")});function d(){if(s&&_){const u=s.getBoundingClientRect(),k=document.documentElement.clientHeight,D=document.documentElement.clientWidth,b=parseInt(r.borderTopWidth,10)+parseInt(r.borderBottomWidth,10),y=Math.min(k-a*2,k-a-u.bottom);n(0,_.style.width=`${g||u.width}px`,_),n(0,_.style.top=`${u.bottom+f[1]}px`,_),i==="right"?(n(0,_.style.left="auto",_),n(0,_.style.right=`${D-(u.right+f[0])}px`,_)):(n(0,_.style.left=`${u.left+f[0]}px`,_),n(0,_.style.right="auto",_)),n(0,_.style.maxHeight=`${y}px`,_);const I=[..._.childNodes].reduce((w,v)=>v instanceof Element?w+Math.max(v.getBoundingClientRect().height,v.scrollHeight):w,b);n(0,_.style.height=`${Math.min(y,I)}px`,_),s.classList.add("searchbox-dropdown-visible"),setTimeout(()=>{_&&n(0,_.style.height="auto",_)},c)}}function E(u){Q[u?"unshift":"push"](()=>{_=u,n(0,_)})}return t.$$set=u=>{"align"in u&&n(1,i=u.align),"anchor"in u&&n(2,s=u.anchor),"offset"in u&&n(3,f=u.offset),"animationDuration"in u&&n(4,c=u.animationDuration),"pageOffset"in u&&n(5,a=u.pageOffset),"width"in u&&n(6,g=u.width),"$$scope"in u&&n(8,o=u.$$scope)},t.$$.update=()=>{t.$$.dirty&1&&(r=_&&getComputedStyle(_))},[_,i,s,f,c,a,g,d,o,l,E]}class Vt extends we{constructor(e){super(),ye(this,e,zt,Ut,be,{align:1,anchor:2,offset:3,animationDuration:4,pageOffset:5,width:6,position:7})}get position(){return this.$$.ctx[7]}}function Kt(t){let e;return{c(){e=C("div")},m(n,r){S(n,e,r),t[3](e)},p:q,i:q,o:q,d(n){n&&T(e),t[3](null)}}}function Gt(t,e,n){let r,{args:l}=e,{renderer:o}=e,i;Mt(()=>{r instanceof Element?i.replaceWith(r):r&&n(0,i.innerHTML=r,i)});function s(f){Q[f?"unshift":"push"](()=>{i=f,n(0,i)})}return t.$$set=f=>{"args"in f&&n(1,l=f.args),"renderer"in f&&n(2,o=f.renderer)},t.$$.update=()=>{t.$$.dirty&6&&(r=o(...l))},[i,l,o,s]}class Pe extends we{constructor(e){super(),ye(this,e,Gt,Kt,be,{args:1,renderer:2})}}function je(t,e,n){const r=t.slice();return r[10]=e[n],r}function Jt(t){var y,I;let e,n,r,l,o,i=t[3].doc.title+"",s,f,c,a,g,_,d,E,u=t[3].doc.image&&Ue(t),k=((y=t[5])==null?void 0:y.length)&&We(t),D=t[3].doc.excerpt&&Ve(t),b=!t[1]&&((I=t[3].children)==null?void 0:I.length)&&Ke(t);return{c(){e=C("a"),u&&u.c(),n=z(),r=C("div"),l=C("div"),o=new It(!1),s=z(),k&&k.c(),f=z(),D&&D.c(),g=z(),b&&b.c(),_=ke(),o.a=s,L(l,"class","searchbox-results-title"),L(e,"href",c=t[3].doc.link),L(e,"class","searchbox-results-link"),L(e,"tabindex","-1"),L(e,"data-ref",a=t[3].ref)},m(w,v){S(w,e,v),u&&u.m(e,null),A(e,n),A(e,r),A(r,l),o.m(i,l),A(l,s),k&&k.m(l,null),A(r,f),D&&D.m(r,null),S(w,g,v),b&&b.m(w,v),S(w,_,v),d||(E=x(e,"click",t[6]),d=!0)},p(w,v){var j,m;w[3].doc.image?u?u.p(w,v):(u=Ue(w),u.c(),u.m(e,n)):u&&(u.d(1),u=null),v&8&&i!==(i=w[3].doc.title+"")&&o.p(i),(j=w[5])!=null&&j.length?k?k.p(w,v):(k=We(w),k.c(),k.m(l,null)):k&&(k.d(1),k=null),w[3].doc.excerpt?D?D.p(w,v):(D=Ve(w),D.c(),D.m(r,null)):D&&(D.d(1),D=null),v&8&&c!==(c=w[3].doc.link)&&L(e,"href",c),v&8&&a!==(a=w[3].ref)&&L(e,"data-ref",a),!w[1]&&((m=w[3].children)!=null&&m.length)?b?b.p(w,v):(b=Ke(w),b.c(),b.m(_.parentNode,_)):b&&(b.d(1),b=null)},i:q,o:q,d(w){w&&(T(e),T(g),T(_)),u&&u.d(),k&&k.d(),D&&D.d(),b&&b.d(w),d=!1,E()}}}function Qt(t){let e,n;return e=new Pe({props:{renderer:t[4],args:[t[3]]}}),{c(){he(e.$$.fragment)},m(r,l){re(e,r,l),n=!0},p(r,l){const o={};l&16&&(o.renderer=r[4]),l&8&&(o.args=[r[3]]),e.$set(o)},i(r){n||(N(e.$$.fragment,r),n=!0)},o(r){B(e.$$.fragment,r),n=!1},d(r){ie(e,r)}}}function Ue(t){let e,n,r;return{c(){e=C("div"),n=C("img"),Fe(n.src,r=t[3].doc.image)||L(n,"src",r),L(n,"alt",""),L(n,"width","48"),L(e,"class","searchbox-results-image")},m(l,o){S(l,e,o),A(e,n)},p(l,o){o&8&&!Fe(n.src,r=l[3].doc.image)&&L(n,"src",r)},d(l){l&&T(e)}}}function We(t){let e,n=de(t[5]),r=[];for(let l=0;l{f[_]=null}),ce(),r=f[n],r?r.p(a,g):(r=f[n]=s[n](a),r.c()),N(r,1),r.m(e,null)),(!l||g&1)&&ae(e,"searchbox-results-item-expanded",a[0])},i(a){l||(N(r),l=!0)},o(a){B(r),l=!1},d(a){a&&T(e),f[n].d(),o=!1,i()}}}function Yt(t,e,n){let r,{expanded:l=!1}=e,{forceExpanded:o=!1}=e,{i18n:i}=e,{item:s}=e,{renderer:f=null}=e;const c=ut();function a(d){s.doc.link||(d.stopPropagation(),d.preventDefault(),c("click",s))}function g(){c("expand",s)}const _=()=>g();return t.$$set=d=>{"expanded"in d&&n(0,l=d.expanded),"forceExpanded"in d&&n(1,o=d.forceExpanded),"i18n"in d&&n(2,i=d.i18n),"item"in d&&n(3,s=d.item),"renderer"in d&&n(4,f=d.renderer)},t.$$.update=()=>{var d,E,u;t.$$.dirty&8&&n(5,r=Array.isArray((d=s==null?void 0:s.doc)==null?void 0:d.labels)?s.doc.labels:(u=(E=s==null?void 0:s.doc)==null?void 0:E.labels)==null?void 0:u.split(/[\,\;]/).filter(k=>!!k))},[l,o,i,s,f,r,a,g,_]}class Zt extends we{constructor(e){super(),ye(this,e,Yt,Xt,be,{expanded:0,forceExpanded:1,i18n:2,item:3,renderer:4})}}function Ge(t,e,n){const r=t.slice();return r[31]=e[n],r}function Je(t,e,n){const r=t.slice();return r[34]=e[n],r}function Qe(t){let e,n,r;return n=new Pe({props:{renderer:t[4].header,args:[t[5]]}}),{c(){e=C("div"),he(n.$$.fragment),L(e,"class","searchbox-results-header")},m(l,o){S(l,e,o),re(n,e,null),r=!0},p(l,o){const i={};o[0]&16&&(i.renderer=l[4].header),o[0]&32&&(i.args=[l[5]]),n.$set(i)},i(l){r||(N(n.$$.fragment,l),r=!0)},o(l){B(n.$$.fragment,l),r=!1},d(l){l&&T(e),ie(n)}}}function Xe(t){let e,n,r,l,o=t[8].length>2&&Ye(t),i=de(t[8].slice(1)),s=[];for(let f=0;f2?o?o.p(f,c):(o=Ye(f),o.c(),o.m(r,l)):o&&(o.d(1),o=null),c[0]&8449){i=de(f[8].slice(1));let a;for(a=0;aB(l[i],1,1,()=>{l[i]=null});return{c(){for(let i=0;i1&&Xe(t);const u=[tn,en,$t,xt],k=[];function D(m,M){var V;return m[2]?0:m[3]?1:(V=m[9])!=null&&V.length?m[12]?3:-1:2}~(o=D(t))&&(i=k[o]=u[o](t));let b=((v=t[9])==null?void 0:v.length)>t[6]&&$e(t),y=((j=t[4])==null?void 0:j.footer)&&et(t);return{c(){d&&d.c(),e=z(),E&&E.c(),n=z(),r=C("div"),l=C("ul"),i&&i.c(),s=z(),b&&b.c(),f=z(),y&&y.c(),c=ke(),L(r,"class","searchbox-results-items")},m(m,M){d&&d.m(m,M),S(m,e,M),E&&E.m(m,M),S(m,n,M),S(m,r,M),A(r,l),~o&&k[o].m(l,null),A(l,s),b&&b.m(l,null),t[25](r),S(m,f,M),y&&y.m(m,M),S(m,c,M),a=!0,g||(_=x(r,"scroll",t[26]),g=!0)},p(m,M){var X,Y,ee,te;(X=m[4])!=null&&X.header?d?(d.p(m,M),M[0]&16&&N(d,1)):(d=Qe(m),d.c(),N(d,1),d.m(e.parentNode,e)):d&&(ue(),B(d,1,1,()=>{d=null}),ce()),((Y=m[8])==null?void 0:Y.length)>1?E?E.p(m,M):(E=Xe(m),E.c(),E.m(n.parentNode,n)):E&&(E.d(1),E=null);let V=o;o=D(m),o===V?~o&&k[o].p(m,M):(i&&(ue(),B(k[V],1,1,()=>{k[V]=null}),ce()),~o?(i=k[o],i?i.p(m,M):(i=k[o]=u[o](m),i.c()),N(i,1),i.m(l,s)):i=null),((ee=m[9])==null?void 0:ee.length)>m[6]?b?b.p(m,M):(b=$e(m),b.c(),b.m(l,null)):b&&(b.d(1),b=null),(te=m[4])!=null&&te.footer?y?(y.p(m,M),M[0]&16&&N(y,1)):(y=et(m),y.c(),N(y,1),y.m(c.parentNode,c)):y&&(ue(),B(y,1,1,()=>{y=null}),ce())},i(m){a||(N(d),N(i),N(y),a=!0)},o(m){B(d),B(i),B(y),a=!1},d(m){m&&(T(e),T(n),T(r),T(f),T(c)),d&&d.d(m),E&&E.d(m),~o&&k[o].d(),b&&b.d(),t[25](null),y&&y.d(m),g=!1,_()}}}let tt=10;function ln(t,e,n){let r,l,o,{category:i=null}=e,{i18n:s}=e,{loading:f=!1}=e,{message:c=null}=e,{renderers:a=null}=e,{result:g=null}=e;const _=ut();let d,E=tt,u=[],k=!1;st(()=>{requestAnimationFrame(()=>{v()})});function D(p,F,U){const O=i==="*"?p:p==null?void 0:p.filter(G=>G.doc.category===i);return n(11,k=(O==null?void 0:O.length)===1),O==null?void 0:O.reduce((G,W)=>{var ne;return G.push(W),(ne=W.children)!=null&&ne.length&&(k||u.includes(W.ref))&&G.push(...W.children),G},[])}function b(p){(r==null?void 0:r.length)===2?n(0,i=r[1]):((r==null?void 0:r.length)===1||!(r!=null&&r.includes(i)))&&n(0,i="*")}function y(p){_("category",p)}function I(p){_("selection",p)}function w(p){u.includes(p.ref)?n(7,u=u.filter(F=>F!==p.ref)):n(7,u=[...u,p.ref])}function v(){(d==null?void 0:d.scrollTop)>5,(d==null?void 0:d.scrollTop)+(d==null?void 0:d.clientHeight)>=(d==null?void 0:d.scrollHeight)-50&&j()}function j(){n(6,E=E+tt)}function m(){d&&n(10,d.scrollTop=0,d)}function M(p,F="focus"){const U=[].slice.call(d.querySelectorAll("a[tabindex]"));let O=d.querySelector("a:hover, a."+F);O||(p=0,O=U[0]);const G=Math.max(0,Math.min(U.length-1,U.indexOf(O)+p)),W=U[G];O==null||O.classList.remove(F),W.classList.add(F);const ne=W.getAttribute("data-ref"),Te=ne&&g.items.find(De=>De.ref===ne);Te&&_("selection",Te),W.scrollIntoView({behavior:"smooth"})}const V=()=>y("*"),X=p=>y(p),Y=p=>I(p.detail),ee=p=>w(p.detail),te=()=>j();function Ee(p){Q[p?"unshift":"push"](()=>{d=p,n(10,d)})}const ve=()=>v();return t.$$set=p=>{"category"in p&&n(0,i=p.category),"i18n"in p&&n(1,s=p.i18n),"loading"in p&&n(2,f=p.loading),"message"in p&&n(3,c=p.message),"renderers"in p&&n(4,a=p.renderers),"result"in p&&n(5,g=p.result)},t.$$.update=()=>{var p;t.$$.dirty[0]&32&&n(8,r=(p=g==null?void 0:g.items)==null?void 0:p.reduce((F,U)=>(U.doc.category&&!F.includes(U.doc.category)&&F.push(U.doc.category),F),["*"])),t.$$.dirty[0]&256&&b(),t.$$.dirty[0]&161&&n(9,l=D(g==null?void 0:g.items)),t.$$.dirty[0]&576&&n(12,o=l==null?void 0:l.slice(0,E))},[i,s,f,c,a,g,E,u,r,l,d,k,o,y,I,w,v,j,m,M,V,X,Y,ee,te,Ee,ve]}class at extends we{constructor(e){super(),ye(this,e,ln,nn,be,{category:0,i18n:1,loading:2,message:3,renderers:4,result:5,scrollToTop:18,navigateItems:19},null,[-1,-1])}get scrollToTop(){return this.$$.ctx[18]}get navigateItems(){return this.$$.ctx[19]}}const rn={all:"All",loading:"Loading...",load_more:"Load more",more_on_this_page:"{count} more on this page",no_results:"No results found."};function nt(t,e){let n;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>{t(...r)},e)}}function lt(t){let e,n,r={anchor:t[0].anchor||t[7],align:t[0].align,width:t[0].width,$$slots:{default:[on]},$$scope:{ctx:t}};return e=new Vt({props:r}),t[19](e),{c(){he(e.$$.fragment)},m(l,o){re(e,l,o),n=!0},p(l,o){const i={};o[0]&129&&(i.anchor=l[0].anchor||l[7]),o[0]&1&&(i.align=l[0].align),o[0]&1&&(i.width=l[0].width),o[0]&1877|o[1]&4096&&(i.$$scope={dirty:o,ctx:l}),e.$set(i)},i(l){n||(N(e.$$.fragment,l),n=!0)},o(l){B(e.$$.fragment,l),n=!1},d(l){t[19](null),ie(e,l)}}}function on(t){let e,n,r;function l(i){t[16](i)}let o={renderers:t[0].renderers,i18n:t[11],loading:t[8],message:t[6],result:t[0].suggestions?t[10]:t[9]};return t[2]!==void 0&&(o.category=t[2]),e=new at({props:o}),t[15](e),Q.push(()=>qt(e,"category",l)),e.$on("category",t[17]),e.$on("selection",t[18]),{c(){he(e.$$.fragment)},m(i,s){re(e,i,s),r=!0},p(i,s){const f={};s[0]&1&&(f.renderers=i[0].renderers),s[0]&256&&(f.loading=i[8]),s[0]&64&&(f.message=i[6]),s[0]&1537&&(f.result=i[0].suggestions?i[10]:i[9]),!n&&s[0]&4&&(n=!0,f.category=i[2],Ot(()=>n=!1)),e.$set(f)},i(i){r||(N(e.$$.fragment,i),r=!0)},o(i){B(e.$$.fragment,i),r=!1},d(i){t[15](null),ie(e,i)}}}function sn(t){let e,n,r,l,o=t[1]&<(t);return{c(){e=C("div"),n=z(),o&&o.c(),r=ke()},m(i,s){S(i,e,s),t[14](e),S(i,n,s),o&&o.m(i,s),S(i,r,s),l=!0},p(i,s){i[1]?o?(o.p(i,s),s[0]&2&&N(o,1)):(o=lt(i),o.c(),N(o,1),o.m(r.parentNode,r)):o&&(ue(),B(o,1,1,()=>{o=null}),ce())},i(i){l||(N(o),l=!0)},o(i){B(o),l=!1},d(i){i&&(T(e),T(n),T(r)),t[14](null),o&&o.d(i)}}}function fn(t,e,n){let r,{options:l}=e;const o=nt(O,150),i=nt(m,10);let s="*",f,c,a,g=null,_=!1,d,E=Object.assign({},rn,l.strings||{}),u,k=!1,D,b,y=null,I=!1,w,v;ft(()=>{document.removeEventListener("scroll",ee),u.removeEventListener("focus",ve),u.removeEventListener("blur",Ee),u.removeEventListener("input",F),u.removeEventListener("keydown",p),d&&d.removeEventListener("submit",te),v&&v.$destroy()}),st(()=>{l.pagefind?yt(()=>import(l.pagefind),[]).then(h=>{if(!h||typeof h.search!="function")throw new Error(`Imported module ${l.pagefind} is not a recognizable Pagefind module.`);D=h}).catch(h=>{j(h)}):j("Parameter 'pagefind' is empty."),M(),d=u.closest("form"),document.addEventListener("scroll",ee),u.addEventListener("focus",ve),u.addEventListener("blur",Ee),u.addEventListener("input",F),u.addEventListener("keydown",p),d&&d.addEventListener("submit",te),l.results&&(n(0,l.results.innerHTML="",l),v=new at({target:l.results,props:{category:s,i18n:E}}),v.$on("category",h=>{Y(h.detail)}))});function j(h){n(6,g=String(h)),console.log(h)}function m(){requestAnimationFrame(()=>{f&&I&&f.position()})}function M(){n(7,u=a.parentElement.querySelector("input")),u||(n(7,u=document.createElement("input")),n(7,u.type="search",u),a.parentElement.appendChild(u))}async function V(h){return n(8,k=!0),y=null,l.customSearch(h,!0).then(P=>{n(10,w=W(P))}).finally(()=>{n(8,k=!1)})}async function X(h){return n(8,k=!0),y=null,(l.customSearch?l.customSearch(h,!1):G(h)).then(P=>{n(2,s="*"),n(9,b=W(P)),v?v.$set({category:s,result:b}):requestAnimationFrame(()=>{c&&I&&c.scrollToTop(),i()})}).finally(()=>{n(8,k=!1)})}function Y(h){n(2,s=h),c&&I&&c.scrollToTop(),v&&v.$set({category:s})}function ee(){I&&i()}function te(h){h.preventDefault(),X(u.value.trim())}function Ee(){_=!1,requestAnimationFrame(()=>{_||n(1,I=!1)})}function ve(){_=!0,(k||b!=null&&b.items)&&setTimeout(()=>{_&&n(1,I=!0)},l.dropdownDelay||0)}function p(h){var R,P;h.key==="Enter"?(R=y==null?void 0:y.doc)!=null&&R.link?location.assign((P=y==null?void 0:y.doc)==null?void 0:P.link):(X(u.value.trim()),u.blur()):h.key==="Escape"?_&&(h.preventDefault(),u.blur()):h.key==="ArrowUp"||h.key==="Tab"&&h.shiftKey?(h.preventDefault(),c==null||c.navigateItems(-1)):h.key==="ArrowDown"||h.key==="Tab"?(h.preventDefault(),c==null||c.navigateItems(1)):h.key==="Shift"?h.preventDefault():o(u.value.trim())}function F(){o(u.value.trim())}function U(h){l.suggestions?(n(7,u.value=h.doc.suggestion||h.doc.title,u),u.setSelectionRange(u.value.length,u.value.length)):y=h}function O(h){h?(_&&!I&&n(1,I=!0),l.suggestions?V(h):X(h)):(n(9,b=null),I&&n(1,I=!1))}async function G(h){let R=[];if(D){const P=await D.search(h,{filters:l.filters,sort:l.sort});R=(await Promise.all(P.results.slice(0,r).map(async H=>({id:H.id,data:await H.data()})))).map(H=>{var _e,Oe,He;return{ref:H.id,doc:{category:l.category?(_e=H.data.filters[l.category])==null?void 0:_e[0]:void 0,image:l.image?(Oe=H.data.meta)==null?void 0:Oe[l.image]:void 0,link:H.data.url,title:(He=H.data.meta)==null?void 0:He.title,excerpt:H.data.excerpt}}})}return{items:R}}function W(h){return l.transform&&(h.items=h.items.map(R=>(R.doc=l.transform(R.doc,R,h),R))),l.groupBy&&(h=ne(h)),h}function ne(h){const R=h.items.reduce((P,J)=>{const H=typeof l.groupBy=="function"?l.groupBy(J.doc):J.doc[l.groupBy];return P.set(H,[...P.get(H)||[],J]),P},new Map);return h.items=[...R.values()].reduce((P,J)=>(P.push({...J[0],children:J.slice(1)}),P),[]).sort((P,J)=>{var H,_e;return((H=P.children)==null?void 0:H.length)>((_e=J.children)==null?void 0:_e.length)?-1:1}),h}function Te(h){Q[h?"unshift":"push"](()=>{a=h,n(5,a)})}function De(h){Q[h?"unshift":"push"](()=>{c=h,n(4,c)})}function dt(h){s=h,n(2,s)}const ht=h=>Y(h.detail),_t=h=>U(h.detail);function gt(h){Q[h?"unshift":"push"](()=>{f=h,n(3,f)})}return t.$$set=h=>{"options"in h&&n(0,l=h.options)},t.$$.update=()=>{t.$$.dirty[0]&1&&(r=+l.limit||100),t.$$.dirty[0]&2&&I&&i()},[l,I,s,f,c,a,g,u,k,b,w,E,Y,U,Te,De,dt,ht,_t,gt]}class un extends we{constructor(e){super(),ye(this,e,fn,sn,be,{options:0},null,[-1,-1])}}Object.assign(window,{Searchbox:un}); diff --git a/dist/searchbox.umd.cjs b/dist/searchbox.umd.cjs new file mode 100644 index 0000000..0c7d24b --- /dev/null +++ b/dist/searchbox.umd.cjs @@ -0,0 +1 @@ +(function(O,R){typeof exports=="object"&&typeof module<"u"?module.exports=R():typeof define=="function"&&define.amd?define(R):(O=typeof globalThis<"u"?globalThis:O||self,O.altcha=R())})(this,function(){"use strict";var Mn=Object.defineProperty;var Pn=(O,R,ne)=>R in O?Mn(O,R,{enumerable:!0,configurable:!0,writable:!0,value:ne}):O[R]=ne;var z=(O,R,ne)=>(Pn(O,typeof R!="symbol"?R+"":R,ne),ne);function O(){}function R(n,e){for(const t in e)n[t]=e[t];return n}function ne(n){return n()}function Ue(){return Object.create(null)}function xe(n){n.forEach(ne)}function We(n){return typeof n=="function"}function ke(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}let De;function Ve(n,e){return n===e?!0:(De||(De=document.createElement("a")),De.href=e,n===De.href)}function It(n){return Object.keys(n).length===0}function Je(n,e,t,r){if(n){const s=Ke(n,e,t,r);return n[0](s)}}function Ke(n,e,t,r){return n[1]&&r?R(t.ctx.slice(),n[1](r(e))):t.ctx}function Ge(n,e,t,r){if(n[2]&&r){const s=n[2](r(t));if(e.dirty===void 0)return s;if(typeof s=="object"){const i=[],o=Math.max(e.dirty.length,s.length);for(let l=0;l32){const e=[],t=n.ctx.length/32;for(let r=0;rn.removeEventListener(e,t,r)}function Rt(n){return function(e){return e.preventDefault(),n.call(this,e)}}function $(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}const qt=["width","height"];function Ze(n,e){const t=Object.getOwnPropertyDescriptors(n.__proto__);for(const r in e)e[r]==null?n.removeAttribute(r):r==="style"?n.style.cssText=e[r]:r==="__value"?n.value=n[r]=e[r]:t[r]&&t[r].set&&qt.indexOf(r)===-1?n[r]=e[r]:$(n,r,e[r])}function Ft(n){return Array.from(n.childNodes)}function se(n,e){e=""+e,n.data!==e&&(n.data=e)}function de(n,e,t){n.classList.toggle(e,!!t)}function Ut(n,e,{bubbles:t=!1,cancelable:r=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:r})}class Wt{constructor(e=!1){z(this,"is_svg",!1);z(this,"e");z(this,"n");z(this,"t");z(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,r=null){this.e||(this.is_svg?this.e=zt(t.nodeName):this.e=E(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(r)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let t=0;t{e[t.slot||"default"]=!0}),e}let we;function ve(n){we=n}function Ae(){if(!we)throw new Error("Function called outside component initialization");return we}function Me(n){Ae().$$.on_mount.push(n)}function Jt(n){Ae().$$.after_update.push(n)}function et(n){Ae().$$.on_destroy.push(n)}function tt(){const n=Ae();return(e,t,{cancelable:r=!1}={})=>{const s=n.$$.callbacks[e];if(s){const i=Ut(e,t,{cancelable:r});return s.slice().forEach(o=>{o.call(n,i)}),!i.defaultPrevented}return!0}}const he=[],ee=[];let ge=[];const Pe=[],Kt=Promise.resolve();let je=!1;function Gt(){je||(je=!0,Kt.then(p))}function He(n){ge.push(n)}function Qt(n){Pe.push(n)}const ze=new Set;let me=0;function p(){if(me!==0)return;const n=we;do{try{for(;men.indexOf(r)===-1?e.push(r):t.push(r)),t.forEach(r=>r()),ge=e}const Ne=new Set;let le;function be(){le={r:0,c:[],p:le}}function _e(){le.r||xe(le.c),le=le.p}function N(n,e){n&&n.i&&(Ne.delete(n),n.i(e))}function I(n,e,t,r){if(n&&n.o){if(Ne.has(n))return;Ne.add(n),le.c.push(()=>{Ne.delete(n),r&&(t&&n.d(1),r())}),n.o(e)}else r&&r()}function pe(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Zt(n,e){const t={},r={},s={$$scope:1};let i=n.length;for(;i--;){const o=n[i],l=e[i];if(l){for(const c in o)c in l||(r[c]=1);for(const c in l)s[c]||(t[c]=l[c],s[c]=1);n[i]=l}else for(const c in o)s[c]=1}for(const o in r)o in t||(t[o]=void 0);return t}function en(n,e,t){const r=n.$$.props[e];r!==void 0&&(n.$$.bound[r]=t,t(n.$$.ctx[r]))}function ye(n){n&&n.c()}function ce(n,e,t){const{fragment:r,after_update:s}=n.$$;r&&r.m(e,t),He(()=>{const i=n.$$.on_mount.map(ne).filter(We);n.$$.on_destroy?n.$$.on_destroy.push(...i):xe(i),n.$$.on_mount=[]}),s.forEach(He)}function ue(n,e){const t=n.$$;t.fragment!==null&&(Yt(t.after_update),xe(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function tn(n,e){n.$$.dirty[0]===-1&&(he.push(n),Gt(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const _=a.length?a[0]:T;return f.ctx&&s(f.ctx[g],f.ctx[g]=_)&&(!f.skip_bound&&f.bound[g]&&f.bound[g](_),d&&tn(n,g)),T}):[],f.update(),d=!0,xe(f.before_update),f.fragment=r?r(f.ctx):!1,e.target){if(e.hydrate){const g=Ft(e.target);f.fragment&&f.fragment.l(g),g.forEach(L)}else f.fragment&&f.fragment.c();e.intro&&N(n.$$.fragment),ce(n,e.target,e.anchor),p()}ve(c)}let nt;typeof HTMLElement=="function"&&(nt=class extends HTMLElement{constructor(e,t,r){super();z(this,"$$ctor");z(this,"$$s");z(this,"$$c");z(this,"$$cn",!1);z(this,"$$d",{});z(this,"$$r",!1);z(this,"$$p_d",{});z(this,"$$l",{});z(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,r&&this.attachShadow({mode:"open"})}addEventListener(e,t,r){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const s=this.$$c.$on(e,t);this.$$l_u.set(t,s)}super.addEventListener(e,t,r)}removeEventListener(e,t,r){if(super.removeEventListener(e,t,r),this.$$c){const s=this.$$l_u.get(t);s&&(s(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(i){return()=>{let o;return{c:function(){o=E("slot"),i!=="default"&&$(o,"name",i)},m:function(f,d){D(f,o,d)},d:function(f){f&&L(o)}}}};if(await Promise.resolve(),!this.$$cn)return;const t={},r=Vt(this);for(const i of this.$$s)i in r&&(t[i]=[e(i)]);for(const i of this.attributes){const o=this.$$g_p(i.name);o in this.$$d||(this.$$d[o]=Oe(o,i.value,this.$$p_d,"toProp"))}this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const s=()=>{this.$$r=!0;for(const i in this.$$p_d)if(this.$$d[i]=this.$$c.$$.ctx[this.$$c.$$.props[i]],this.$$p_d[i].reflect){const o=Oe(i,this.$$d[i],this.$$p_d,"toAttribute");o==null?this.removeAttribute(this.$$p_d[i].attribute||i):this.setAttribute(this.$$p_d[i].attribute||i,o)}this.$$r=!1};this.$$c.$$.after_update.push(s),s();for(const i in this.$$l)for(const o of this.$$l[i]){const l=this.$$c.$on(i,o);this.$$l_u.set(o,l)}this.$$l={}}}attributeChangedCallback(e,t,r){var s;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Oe(e,r,this.$$p_d,"toProp"),(s=this.$$c)==null||s.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Oe(n,e,t,r){var i;const s=(i=t[n])==null?void 0:i.type;if(e=s==="Boolean"&&typeof e!="boolean"?e!=null:e,!r||!t[n])return e;if(r==="toAttribute")switch(s){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(s){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function $e(n,e,t,r,s,i){let o=class extends nt{constructor(){super(n,t,s),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(l=>(e[l].attribute||l).toLowerCase())}};return Object.keys(e).forEach(l=>{Object.defineProperty(o.prototype,l,{get(){return this.$$c&&l in this.$$c?this.$$c[l]:this.$$d[l]},set(c){var f;c=Oe(l,c,e),this.$$d[l]=c,(f=this.$$c)==null||f.$set({[l]:c})}})}),r.forEach(l=>{Object.defineProperty(o.prototype,l,{get(){var c;return(c=this.$$c)==null?void 0:c[l]}})}),i&&(o=i(o)),n.element=o,o}class Te{constructor(){z(this,"$$");z(this,"$$set")}$destroy(){ue(this,1),this.$destroy=O}$on(e,t){if(!We(t))return O;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(t),()=>{const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}$set(e){this.$$set&&!It(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const nn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(nn);function rn(n){let e,t,r,s;const i=n[10].default,o=Je(i,n,n[9],null);return{c(){e=E("div"),o&&o.c(),$(e,"class","searchbox-dropdown")},m(l,c){D(l,e,c),o&&o.m(e,null),n[11](e),t=!0,r||(s=re(e,"mousedown",sn),r=!0)},p(l,[c]){o&&o.p&&(!t||c&512)&&Qe(o,i,l,l[9],t?Ge(i,l[9],c,null):Xe(l[9]),null)},i(l){t||(N(o,l),t=!0)},o(l){I(o,l),t=!1},d(l){l&&L(e),o&&o.d(l),n[11](null),r=!1,s()}}}function sn(n){n.currentTarget.tagName!=="A"&&n.preventDefault()}function on(n,e,t){let r,{$$slots:s={},$$scope:i}=e,{align:o="left"}=e,{anchor:l=null}=e,{offset:c=[0,-1]}=e,{animationDuration:f=350}=e,{input:d}=e,{pageOffset:g=20}=e,{width:T=null}=e,a,_;et(()=>{_&&_.classList.remove("searchbox-dropdown-visible")}),Me(()=>{_=l?document.querySelector(l):d});function v(){if(_&&a){const m=_.getBoundingClientRect(),y=document.documentElement.clientHeight,S=document.documentElement.clientWidth,J=parseInt(r.borderTopWidth,10)+parseInt(r.borderBottomWidth,10),k=Math.min(y-g*2,y-g-m.bottom);t(0,a.style.width=`${T||m.width+"px"}`,a),t(0,a.style.top=`${m.bottom+c[1]}px`,a),o==="right"?(t(0,a.style.left="auto",a),t(0,a.style.right=`${S-(m.right+c[0])}px`,a)):(t(0,a.style.left=`${m.left+c[0]}px`,a),t(0,a.style.right="auto",a)),t(0,a.style.maxHeight=`${k}px`,a);const A=[...a.childNodes].reduce((U,h)=>h instanceof Element?U+Math.max(h.getBoundingClientRect().height,h.scrollHeight):U,J);t(0,a.style.height=`${Math.min(k,A)}px`,a),_.classList.add("searchbox-dropdown-visible"),setTimeout(()=>{a&&t(0,a.style.height="auto",a)},f)}}function x(m){ee[m?"unshift":"push"](()=>{a=m,t(0,a)})}return n.$$set=m=>{"align"in m&&t(1,o=m.align),"anchor"in m&&t(2,l=m.anchor),"offset"in m&&t(3,c=m.offset),"animationDuration"in m&&t(4,f=m.animationDuration),"input"in m&&t(5,d=m.input),"pageOffset"in m&&t(6,g=m.pageOffset),"width"in m&&t(7,T=m.width),"$$scope"in m&&t(9,i=m.$$scope)},n.$$.update=()=>{n.$$.dirty&1&&(r=a&&getComputedStyle(a))},[a,o,l,c,f,d,g,T,v,i,s,x]}class rt extends Te{constructor(e){super(),Ee(this,e,on,rn,ke,{align:1,anchor:2,offset:3,animationDuration:4,input:5,pageOffset:6,width:7,position:8})}get align(){return this.$$.ctx[1]}set align(e){this.$$set({align:e}),p()}get anchor(){return this.$$.ctx[2]}set anchor(e){this.$$set({anchor:e}),p()}get offset(){return this.$$.ctx[3]}set offset(e){this.$$set({offset:e}),p()}get animationDuration(){return this.$$.ctx[4]}set animationDuration(e){this.$$set({animationDuration:e}),p()}get input(){return this.$$.ctx[5]}set input(e){this.$$set({input:e}),p()}get pageOffset(){return this.$$.ctx[6]}set pageOffset(e){this.$$set({pageOffset:e}),p()}get width(){return this.$$.ctx[7]}set width(e){this.$$set({width:e}),p()}get position(){return this.$$.ctx[8]}}$e(rt,{align:{},anchor:{},offset:{},animationDuration:{},input:{},pageOffset:{},width:{}},["default"],["position"],!0);function ln(n){let e;return{c(){e=E("div")},m(t,r){D(t,e,r),n[3](e)},p:O,i:O,o:O,d(t){t&&L(e),n[3](null)}}}function cn(n,e,t){let r,{args:s}=e,{renderer:i}=e,o;Jt(()=>{r instanceof Element?o.replaceWith(r):r&&t(0,o.innerHTML=r,o)});function l(c){ee[c?"unshift":"push"](()=>{o=c,t(0,o)})}return n.$$set=c=>{"args"in c&&t(1,s=c.args),"renderer"in c&&t(2,i=c.renderer)},n.$$.update=()=>{n.$$.dirty&6&&(r=i(...s))},[o,s,i,l]}class Be extends Te{constructor(e){super(),Ee(this,e,cn,ln,ke,{args:1,renderer:2})}get args(){return this.$$.ctx[1]}set args(e){this.$$set({args:e}),p()}get renderer(){return this.$$.ctx[2]}set renderer(e){this.$$set({renderer:e}),p()}}$e(Be,{args:{},renderer:{}},[],[],!0);function st(n,e,t){const r=n.slice();return r[10]=e[t],r}function un(n){var S,J;let e,t,r,s,i,o=n[3].doc.title+"",l,c,f,d,g,T,a,_,v=n[3].doc.image&&ot(n),x=((S=n[5])==null?void 0:S.length)&&it(n),m=n[3].doc.excerpt&&ct(n),y=!n[1]&&((J=n[3].children)==null?void 0:J.length)&&ut(n);return{c(){e=E("a"),v&&v.c(),t=Q(),r=E("div"),s=E("div"),i=new Wt(!1),l=Q(),x&&x.c(),c=Q(),m&&m.c(),g=Q(),y&&y.c(),T=Ce(),i.a=l,$(s,"class","searchbox-results-title"),$(e,"href",f=n[3].doc.link),$(e,"class","searchbox-results-link"),$(e,"tabindex","-1"),$(e,"data-ref",d=n[3].ref)},m(k,A){D(k,e,A),v&&v.m(e,null),C(e,t),C(e,r),C(r,s),i.m(o,s),C(s,l),x&&x.m(s,null),C(r,c),m&&m.m(r,null),D(k,g,A),y&&y.m(k,A),D(k,T,A),a||(_=re(e,"click",n[6]),a=!0)},p(k,A){var U,h;k[3].doc.image?v?v.p(k,A):(v=ot(k),v.c(),v.m(e,t)):v&&(v.d(1),v=null),A&8&&o!==(o=k[3].doc.title+"")&&i.p(o),(U=k[5])!=null&&U.length?x?x.p(k,A):(x=it(k),x.c(),x.m(s,null)):x&&(x.d(1),x=null),k[3].doc.excerpt?m?m.p(k,A):(m=ct(k),m.c(),m.m(r,null)):m&&(m.d(1),m=null),A&8&&f!==(f=k[3].doc.link)&&$(e,"href",f),A&8&&d!==(d=k[3].ref)&&$(e,"data-ref",d),!k[1]&&((h=k[3].children)!=null&&h.length)?y?y.p(k,A):(y=ut(k),y.c(),y.m(T.parentNode,T)):y&&(y.d(1),y=null)},i:O,o:O,d(k){k&&(L(e),L(g),L(T)),v&&v.d(),x&&x.d(),m&&m.d(),y&&y.d(k),a=!1,_()}}}function fn(n){let e,t;return e=new Be({props:{renderer:n[4],args:[n[3]]}}),{c(){ye(e.$$.fragment)},m(r,s){ce(e,r,s),t=!0},p(r,s){const i={};s&16&&(i.renderer=r[4]),s&8&&(i.args=[r[3]]),e.$set(i)},i(r){t||(N(e.$$.fragment,r),t=!0)},o(r){I(e.$$.fragment,r),t=!1},d(r){ue(e,r)}}}function ot(n){let e,t,r;return{c(){e=E("div"),t=E("img"),Ve(t.src,r=n[3].doc.image)||$(t,"src",r),$(t,"alt",""),$(t,"width","48"),$(e,"class","searchbox-results-image")},m(s,i){D(s,e,i),C(e,t)},p(s,i){i&8&&!Ve(t.src,r=s[3].doc.image)&&$(t,"src",r)},d(s){s&&L(e)}}}function it(n){let e,t=pe(n[5]),r=[];for(let s=0;s{c[T]=null}),_e(),r=c[t],r?r.p(d,g):(r=c[t]=l[t](d),r.c()),N(r,1),r.m(e,null)),(!s||g&1)&&de(e,"searchbox-results-item-expanded",d[0])},i(d){s||(N(r),s=!0)},o(d){I(r),s=!1},d(d){d&&L(e),c[t].d(),i=!1,o()}}}function dn(n,e,t){let r,{expanded:s=!1}=e,{forceExpanded:i=!1}=e,{i18n:o}=e,{item:l}=e,{renderer:c=null}=e;const f=tt();function d(a){l.doc.link||(a.stopPropagation(),a.preventDefault(),f("click",l))}function g(){f("expand",l)}const T=()=>g();return n.$$set=a=>{"expanded"in a&&t(0,s=a.expanded),"forceExpanded"in a&&t(1,i=a.forceExpanded),"i18n"in a&&t(2,o=a.i18n),"item"in a&&t(3,l=a.item),"renderer"in a&&t(4,c=a.renderer)},n.$$.update=()=>{var a,_,v;n.$$.dirty&8&&t(5,r=Array.isArray((a=l==null?void 0:l.doc)==null?void 0:a.labels)?l.doc.labels:(v=(_=l==null?void 0:l.doc)==null?void 0:_.labels)==null?void 0:v.split(/[\,\;]/).filter(x=>!!x))},[s,i,o,l,c,r,d,g,T]}class ft extends Te{constructor(e){super(),Ee(this,e,dn,an,ke,{expanded:0,forceExpanded:1,i18n:2,item:3,renderer:4})}get expanded(){return this.$$.ctx[0]}set expanded(e){this.$$set({expanded:e}),p()}get forceExpanded(){return this.$$.ctx[1]}set forceExpanded(e){this.$$set({forceExpanded:e}),p()}get i18n(){return this.$$.ctx[2]}set i18n(e){this.$$set({i18n:e}),p()}get item(){return this.$$.ctx[3]}set item(e){this.$$set({item:e}),p()}get renderer(){return this.$$.ctx[4]}set renderer(e){this.$$set({renderer:e}),p()}}$e(ft,{expanded:{type:"Boolean"},forceExpanded:{type:"Boolean"},i18n:{},item:{},renderer:{}},[],[],!0);function at(n,e,t){const r=n.slice();return r[31]=e[t],r}function dt(n,e,t){const r=n.slice();return r[34]=e[t],r}function ht(n){let e,t,r;return t=new Be({props:{renderer:n[4].header,args:[n[5]]}}),{c(){e=E("div"),ye(t.$$.fragment),$(e,"class","searchbox-results-header")},m(s,i){D(s,e,i),ce(t,e,null),r=!0},p(s,i){const o={};i[0]&16&&(o.renderer=s[4].header),i[0]&32&&(o.args=[s[5]]),t.$set(o)},i(s){r||(N(t.$$.fragment,s),r=!0)},o(s){I(t.$$.fragment,s),r=!1},d(s){s&&L(e),ue(t)}}}function gt(n){let e,t,r,s,i=n[8].length>2&&mt(n),o=pe(n[8].slice(1)),l=[];for(let c=0;c2?i?i.p(c,f):(i=mt(c),i.c(),i.m(r,s)):i&&(i.d(1),i=null),f[0]&8449){o=pe(c[8].slice(1));let d;for(d=0;dI(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o1&>(n);const v=[bn,mn,gn,hn],x=[];function m(h,B){var K;return h[2]?0:h[3]?1:(K=h[9])!=null&&K.length?h[12]?3:-1:2}~(i=m(n))&&(o=x[i]=v[i](n));let y=((A=n[9])==null?void 0:A.length)>n[6]&&pt(n),S=((U=n[4])==null?void 0:U.footer)&&yt(n);return{c(){a&&a.c(),e=Q(),_&&_.c(),t=Q(),r=E("div"),s=E("ul"),o&&o.c(),l=Q(),y&&y.c(),c=Q(),S&&S.c(),f=Ce(),$(r,"class","searchbox-results-items")},m(h,B){a&&a.m(h,B),D(h,e,B),_&&_.m(h,B),D(h,t,B),D(h,r,B),C(r,s),~i&&x[i].m(s,null),C(s,l),y&&y.m(s,null),n[25](r),D(h,c,B),S&&S.m(h,B),D(h,f,B),d=!0,g||(T=re(r,"scroll",n[26]),g=!0)},p(h,B){var M,Y,oe,fe;(M=h[4])!=null&&M.header?a?(a.p(h,B),B[0]&16&&N(a,1)):(a=ht(h),a.c(),N(a,1),a.m(e.parentNode,e)):a&&(be(),I(a,1,1,()=>{a=null}),_e()),((Y=h[8])==null?void 0:Y.length)>1?_?_.p(h,B):(_=gt(h),_.c(),_.m(t.parentNode,t)):_&&(_.d(1),_=null);let K=i;i=m(h),i===K?~i&&x[i].p(h,B):(o&&(be(),I(x[K],1,1,()=>{x[K]=null}),_e()),~i?(o=x[i],o?o.p(h,B):(o=x[i]=v[i](h),o.c()),N(o,1),o.m(s,l)):o=null),((oe=h[9])==null?void 0:oe.length)>h[6]?y?y.p(h,B):(y=pt(h),y.c(),y.m(s,null)):y&&(y.d(1),y=null),(fe=h[4])!=null&&fe.footer?S?(S.p(h,B),B[0]&16&&N(S,1)):(S=yt(h),S.c(),N(S,1),S.m(f.parentNode,f)):S&&(be(),I(S,1,1,()=>{S=null}),_e())},i(h){d||(N(a),N(o),N(S),d=!0)},o(h){I(a),I(o),I(S),d=!1},d(h){h&&(L(e),L(t),L(r),L(c),L(f)),a&&a.d(h),_&&_.d(h),~i&&x[i].d(),y&&y.d(),n[25](null),S&&S.d(h),g=!1,T()}}}let xt=10;function pn(n,e,t){let r,s,i,{category:o=null}=e,{i18n:l}=e,{loading:c=!1}=e,{message:f=null}=e,{renderers:d=null}=e,{result:g=null}=e;const T=tt();let a,_=xt,v=[],x=!1;Me(()=>{requestAnimationFrame(()=>{A()})});function m(b,w,q){const F=o==="*"?b:b==null?void 0:b.filter(W=>W.doc.category===o);return t(11,x=(F==null?void 0:F.length)===1),F==null?void 0:F.reduce((W,P)=>{var j;return W.push(P),(j=P.children)!=null&&j.length&&(x||v.includes(P.ref))&&W.push(...P.children),W},[])}function y(b){(r==null?void 0:r.length)===2?t(0,o=r[1]):((r==null?void 0:r.length)===1||!(r!=null&&r.includes(o)))&&t(0,o="*")}function S(b){T("category",b)}function J(b){T("selection",b)}function k(b){v.includes(b.ref)?t(7,v=v.filter(w=>w!==b.ref)):t(7,v=[...v,b.ref])}function A(){(a==null?void 0:a.scrollTop)>5,(a==null?void 0:a.scrollTop)+(a==null?void 0:a.clientHeight)>=(a==null?void 0:a.scrollHeight)-50&&U()}function U(){t(6,_=_+xt)}function h(){a&&t(10,a.scrollTop=0,a)}function B(b,w="focus"){const q=[].slice.call(a.querySelectorAll("a[tabindex]"));let F=a.querySelector("a:hover, a."+w);F||(b=0,F=q[0]);const W=Math.max(0,Math.min(q.length-1,q.indexOf(F)+b)),P=q[W];F==null||F.classList.remove(w),P.classList.add(w);const j=P.getAttribute("data-ref"),Se=j&&g.items.find(Z=>Z.ref===j);Se&&T("selection",Se),P.scrollIntoView({behavior:"smooth"})}const K=()=>S("*"),M=b=>S(b),Y=b=>J(b.detail),oe=b=>k(b.detail),fe=()=>U();function ie(b){ee[b?"unshift":"push"](()=>{a=b,t(10,a)})}const ae=()=>A();return n.$$set=b=>{"category"in b&&t(0,o=b.category),"i18n"in b&&t(1,l=b.i18n),"loading"in b&&t(2,c=b.loading),"message"in b&&t(3,f=b.message),"renderers"in b&&t(4,d=b.renderers),"result"in b&&t(5,g=b.result)},n.$$.update=()=>{var b;n.$$.dirty[0]&32&&t(8,r=(b=g==null?void 0:g.items)==null?void 0:b.reduce((w,q)=>(q.doc.category&&!w.includes(q.doc.category)&&w.push(q.doc.category),w),["*"])),n.$$.dirty[0]&256&&y(),n.$$.dirty[0]&161&&t(9,s=m(g==null?void 0:g.items)),n.$$.dirty[0]&576&&t(12,i=s==null?void 0:s.slice(0,_))},[o,l,c,f,d,g,_,v,r,s,a,x,i,S,J,k,A,U,h,B,K,M,Y,oe,fe,ie,ae]}class Re extends Te{constructor(e){super(),Ee(this,e,pn,_n,ke,{category:0,i18n:1,loading:2,message:3,renderers:4,result:5,scrollToTop:18,navigateItems:19},null,[-1,-1])}get category(){return this.$$.ctx[0]}set category(e){this.$$set({category:e}),p()}get i18n(){return this.$$.ctx[1]}set i18n(e){this.$$set({i18n:e}),p()}get loading(){return this.$$.ctx[2]}set loading(e){this.$$set({loading:e}),p()}get message(){return this.$$.ctx[3]}set message(e){this.$$set({message:e}),p()}get renderers(){return this.$$.ctx[4]}set renderers(e){this.$$set({renderers:e}),p()}get result(){return this.$$.ctx[5]}set result(e){this.$$set({result:e}),p()}get scrollToTop(){return this.$$.ctx[18]}get navigateItems(){return this.$$.ctx[19]}}$e(Re,{category:{},i18n:{},loading:{type:"Boolean"},message:{},renderers:{},result:{}},[],["scrollToTop","navigateItems"],!0);const yn={all:"All",loading:"Loading...",load_more:"Load more",more_on_this_page:"{count} more on this page",no_results:"No results found."};function kt(n,e){let t;return(...r)=>{t&&clearTimeout(t),t=setTimeout(()=>{n(...r)},e)}}function xn(n){Pt(n,"svelte-1t9xdi2",":root{--searchbox-border-color:rgb(219, 219, 219);--searchbox-active-color:rgb(19, 58, 165);--searchbox-active-bg-color:rgb(233, 238, 250);--searchbox-muted-color:rgb(119, 119, 119);--searchbox-muted-bg-color:rgb(247, 247, 247);--searchbox-mark-bg:rgb(250, 248, 205);--searchbox-spacer:0.5rem;--searchbox-spacer-lg:1rem}.searchbox-results-categories{background-color:var(--searchbox-muted-bg-color);border-bottom:1px solid var(--searchbox-border-color);font-size:0.8rem;padding:0 var(--searchbox-spacer)}.searchbox-results-categories-wrap{overflow-y:visible;overflow-x:auto;margin:0 0 -1px 0}.searchbox-results-categories ul{display:flex;margin:0;padding:0;list-style:none}.searchbox-results-categories li{margin-right:var(--searchbox-spacer-lg)}.searchbox-results-categories a,.searchbox-results-categories [role=button]{border-bottom:1px solid transparent;color:var(--searchbox-muted-color);cursor:pointer;display:inline-block;padding:var(--searchbox-spacer) 0;white-space:nowrap}.searchbox-results-categories a.active,.searchbox-results-categories [role=button].active{border-bottom-color:var(--searchbox-active-color);color:var(--searchbox-active-color)}.searchbox-results-items{flex-grow:1;overflow-y:auto;overflow-x:hidden}.searchbox-results-items mark{background-color:var(--searchbox-mark-bg);color:currentColor;padding:0}.searchbox-results-items ul{margin:0;padding:0;list-style:none}.searchbox-results-items a{color:var(--searchbox-active-color)}.searchbox-results-header{background-color:var(--searchbox-muted-bg-color);border-bottom:1px solid var(--searchbox-border-color);padding:var(--searchbox-spacer)}.searchbox-results-footer{background-color:var(--searchbox-muted-bg-color);border-top:1px solid var(--searchbox-border-color);padding:var(--searchbox-spacer)}.searchbox-results:not(.compact) .searchbox-results-item:not(:last-child){border-bottom:1px solid var(--searchbox-border-color)}.searchbox-results-text{color:var(--searchbox-muted-color);padding:var(--searchbox-spacer)}.searchbox-results-load-more{color:var(--searchbox-muted-color)}.searchbox-results-load-more button{background:transparent;border:none;box-shadow:none;color:currentColor;cursor:pointer;font-size:0.8rem;outline:none;margin:0;padding:var(--searchbox-spacer);width:100%}.searchbox-results-item:not(:last-child){border-bottom:1px solid var(--searchbox-border-color)}.searchbox-results-link{display:flex;padding:var(--searchbox-spacer);text-decoration:none}.searchbox-results-link:hover{text-decoration:none}.searchbox-results-link.focus,.searchbox-results-link:hover{background-color:var(--searchbox-active-bg-color)}.searchbox-results-image{color:var(--searchbox-muted-color);margin-right:var(--searchbox-spacer)}.searchbox-results-excerpt{color:var(--searchbox-muted-color);font-size:0.8rem;margin-top:var(--searchbox-spacer)}.searchbox-results-excerpt code{font-size:0.8rem}.searchbox-results-excerpt h1,.searchbox-results-excerpt h2,.searchbox-results-excerpt h3,.searchbox-results-excerpt h4,.searchbox-results-excerpt h5,.searchbox-results-excerpt h6{font-size:0.8rem}.searchbox-results-excerpt p{margin-top:0}.searchbox-results-excerpt p:last-child{margin-bottom:0}.searchbox-results-expand{background-color:var(--searchbox-muted-bg-color);color:var(--searchbox-active-color)}.searchbox-results-expand button{background:transparent;border:none;box-shadow:none;color:currentColor;cursor:pointer;font-size:0.8rem;outline:none;margin:0;padding:var(--searchbox-spacer)}.searchbox-results-item-expanded .searchbox-results-expand{color:var(--searchbox-muted-color)}.searchbox-results-label{border:1px solid var(--searchbox-border-color);border-radius:1rem;color:var(--searchbox-muted-color);font-size:0.8rem;margin-left:var(--searchbox-spacer);padding:2px 6px}.searchbox-dropdown{background:white;border:1px solid var(--searchbox-border-color);display:flex;flex-direction:column;height:0;overflow:hidden;position:fixed;transition:height 0.3s;z-index:10000}")}function wt(n){let e,t,r={anchor:n[2],align:n[1],input:n[11],width:n[5],$$slots:{default:[kn]},$$scope:{ctx:n}};return e=new rt({props:r}),n[35](e),{c(){ye(e.$$.fragment)},m(s,i){ce(e,s,i),t=!0},p(s,i){const o={};i[0]&4&&(o.anchor=s[2]),i[0]&2&&(o.align=s[1]),i[0]&2048&&(o.input=s[11]),i[0]&32&&(o.width=s[5]),i[0]&29977|i[1]&64&&(o.$$scope={dirty:i,ctx:s}),e.$set(o)},i(s){t||(N(e.$$.fragment,s),t=!0)},o(s){I(e.$$.fragment,s),t=!1},d(s){n[35](null),ue(e,s)}}}function kn(n){let e,t,r;function s(o){n[32](o)}let i={renderers:n[3],i18n:n[15],loading:n[12],message:n[10],result:n[4]?n[14]:n[13]};return n[0]!==void 0&&(i.category=n[0]),e=new Re({props:i}),n[31](e),ee.push(()=>en(e,"category",s)),e.$on("category",n[33]),e.$on("selection",n[34]),{c(){ye(e.$$.fragment)},m(o,l){ce(e,o,l),r=!0},p(o,l){const c={};l[0]&8&&(c.renderers=o[3]),l[0]&4096&&(c.loading=o[12]),l[0]&1024&&(c.message=o[10]),l[0]&24592&&(c.result=o[4]?o[14]:o[13]),!t&&l[0]&1&&(t=!0,c.category=o[0],Qt(()=>t=!1)),e.$set(c)},i(o){r||(N(e.$$.fragment,o),r=!0)},o(o){I(e.$$.fragment,o),r=!1},d(o){n[31](null),ue(e,o)}}}function wn(n){let e,t,r;const s=n[30].default,i=Je(s,n,n[37],null);let o=n[6]&&wt(n),l=[n[18]],c={};for(let f=0;f{o=null}),_e()),Ze(e,c=Zt(l,[d[0]&262144&&f[18]]))},i(f){r||(N(i,f),N(o),r=!0)},o(f){I(i,f),I(o),r=!1},d(f){f&&L(e),i&&i.d(f),o&&o.d(),n[36](null)}}}function vn(n,e,t){const r=["align","anchor","category","customSearch","dropdownDelay","groupBy","filters","image","limit","pagefind","renderers","results","sort","strings","suggestions","transform","width"];let s=Ye(e,r),{$$slots:i={},$$scope:o}=e,{align:l=void 0}=e,{anchor:c=void 0}=e,{category:f="*"}=e,{customSearch:d=void 0}=e,{dropdownDelay:g=void 0}=e,{groupBy:T=void 0}=e,{filters:a=void 0}=e,{image:_=void 0}=e,{limit:v=100}=e,{pagefind:x}=e,{renderers:m=void 0}=e,{results:y=void 0}=e,{sort:S=void 0}=e,{strings:J=void 0}=e,{suggestions:k=!1}=e,{transform:A=void 0}=e,{width:U=void 0}=e;const h=kt(Sn,150),B=kt(En,10);let K,M,Y,oe,fe=null,ie=!1,ae,b=Object.assign({},yn,J||{}),w,q=!1,F,W,P=null,j=!1,Se,Z;et(()=>{document.removeEventListener("scroll",$t),w.removeEventListener("focus",Lt),w.removeEventListener("blur",St),w.removeEventListener("input",Ct),w.removeEventListener("keydown",Dt),ae&&ae.removeEventListener("submit",Tt),Z&&Z.$destroy()}),Me(()=>{x?import(x).then(u=>{if(!u||typeof u.search!="function")throw new Error(`Imported module ${x} is not a recognizable Pagefind module.`);F=u}).catch(u=>{Et(u)}):Et("Parameter 'pagefind' is empty."),$n(),ae=w.closest("form"),document.addEventListener("scroll",$t),w.addEventListener("focus",Lt),w.addEventListener("blur",St),w.addEventListener("input",Ct),w.addEventListener("keydown",Dt),ae&&ae.addEventListener("submit",Tt),y&&(oe=document.querySelector(y),oe.innerHTML="",Z=new Re({target:oe,props:{category:f,i18n:b}}),Z.$on("category",u=>{Fe(u.detail)}))});function Et(u){t(10,fe=String(u)),console.log(u)}function En(){requestAnimationFrame(()=>{K&&j&&K.position()})}function $n(){t(11,w=Y.parentElement.querySelector("input")),w||(t(11,w=document.createElement("input")),t(11,w.type="search",w),Y.parentElement.appendChild(w))}async function Tn(u){return t(12,q=!0),P=null,d(u,!0).then(H=>{t(14,Se=Nt(H))}).finally(()=>{t(12,q=!1)})}async function qe(u){return t(12,q=!0),P=null,(d?d(u,!1):Ln(u)).then(H=>{t(0,f="*"),t(13,W=Nt(H)),Z?Z.$set({category:f,result:W}):requestAnimationFrame(()=>{M&&j&&M.scrollToTop(),B()})}).finally(()=>{t(12,q=!1)})}function Fe(u){t(0,f=u),M&&j&&M.scrollToTop(),Z&&Z.$set({category:f})}function $t(){j&&B()}function Tt(u){u.preventDefault(),qe(w.value.trim())}function St(){ie=!1,requestAnimationFrame(()=>{ie||t(6,j=!1)})}function Lt(){ie=!0,(q||W!=null&&W.items)&&setTimeout(()=>{ie&&t(6,j=!0)},g||0)}function Dt(u){var G,H;u.key==="Enter"?(G=P==null?void 0:P.doc)!=null&&G.link?location.assign((H=P==null?void 0:P.doc)==null?void 0:H.link):(qe(w.value.trim()),w.blur()):u.key==="Escape"?ie&&(u.preventDefault(),w.blur()):u.key==="ArrowUp"||u.key==="Tab"&&u.shiftKey?(u.preventDefault(),M==null||M.navigateItems(-1)):u.key==="ArrowDown"||u.key==="Tab"?(u.preventDefault(),M==null||M.navigateItems(1)):u.key==="Shift"?u.preventDefault():h(w.value.trim())}function Ct(){h(w.value.trim())}function At(u){k?(t(11,w.value=u.doc.suggestion||u.doc.title,w),w.setSelectionRange(w.value.length,w.value.length)):P=u}function Sn(u){u?(ie&&!j&&t(6,j=!0),k?Tn(u):qe(u)):(t(13,W=null),j&&t(6,j=!1))}async function Ln(u){let G=[];if(x){const H=await F.search(u,{filters:a,sort:S});G=(await Promise.all(H.results.slice(0,v).map(async V=>({id:V.id,data:await V.data()})))).map(V=>{var Le,Ot,Bt;return{ref:V.id,doc:{category:f?(Le=V.data.filters[f])==null?void 0:Le[0]:void 0,image:_?(Ot=V.data.meta)==null?void 0:Ot[_]:void 0,link:V.data.url,title:(Bt=V.data.meta)==null?void 0:Bt.title,excerpt:V.data.excerpt}}})}return{items:G}}function Nt(u){return A&&(u.items=u.items.map(G=>(G.doc=A(G.doc,G,u),G))),T&&(u=Dn(u)),u}function Dn(u){const G=u.items.reduce((H,te)=>{const V=typeof T=="function"?T(te.doc):te.doc[T];return H.set(V,[...H.get(V)||[],te]),H},new Map);return u.items=[...G.values()].reduce((H,te)=>(H.push({...te[0],children:te.slice(1)}),H),[]).sort((H,te)=>{var V,Le;return((V=H.children)==null?void 0:V.length)>((Le=te.children)==null?void 0:Le.length)?-1:1}),u}function Cn(u){ee[u?"unshift":"push"](()=>{M=u,t(8,M)})}function An(u){f=u,t(0,f)}const Nn=u=>Fe(u.detail),On=u=>At(u.detail);function Bn(u){ee[u?"unshift":"push"](()=>{K=u,t(7,K)})}function In(u){ee[u?"unshift":"push"](()=>{Y=u,t(9,Y)})}return n.$$set=u=>{e=R(R({},e),Mt(u)),t(18,s=Ye(e,r)),"align"in u&&t(1,l=u.align),"anchor"in u&&t(2,c=u.anchor),"category"in u&&t(0,f=u.category),"customSearch"in u&&t(19,d=u.customSearch),"dropdownDelay"in u&&t(20,g=u.dropdownDelay),"groupBy"in u&&t(21,T=u.groupBy),"filters"in u&&t(22,a=u.filters),"image"in u&&t(23,_=u.image),"limit"in u&&t(24,v=u.limit),"pagefind"in u&&t(25,x=u.pagefind),"renderers"in u&&t(3,m=u.renderers),"results"in u&&t(26,y=u.results),"sort"in u&&t(27,S=u.sort),"strings"in u&&t(28,J=u.strings),"suggestions"in u&&t(4,k=u.suggestions),"transform"in u&&t(29,A=u.transform),"width"in u&&t(5,U=u.width),"$$scope"in u&&t(37,o=u.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&64&&j&&B()},[f,l,c,m,k,U,j,K,M,Y,fe,w,q,W,Se,b,Fe,At,s,d,g,T,a,_,v,x,y,S,J,A,i,Cn,An,Nn,On,Bn,In,o]}class vt extends Te{constructor(e){super(),Ee(this,e,vn,wn,ke,{align:1,anchor:2,category:0,customSearch:19,dropdownDelay:20,groupBy:21,filters:22,image:23,limit:24,pagefind:25,renderers:3,results:26,sort:27,strings:28,suggestions:4,transform:29,width:5},xn,[-1,-1])}get align(){return this.$$.ctx[1]}set align(e){this.$$set({align:e}),p()}get anchor(){return this.$$.ctx[2]}set anchor(e){this.$$set({anchor:e}),p()}get category(){return this.$$.ctx[0]}set category(e){this.$$set({category:e}),p()}get customSearch(){return this.$$.ctx[19]}set customSearch(e){this.$$set({customSearch:e}),p()}get dropdownDelay(){return this.$$.ctx[20]}set dropdownDelay(e){this.$$set({dropdownDelay:e}),p()}get groupBy(){return this.$$.ctx[21]}set groupBy(e){this.$$set({groupBy:e}),p()}get filters(){return this.$$.ctx[22]}set filters(e){this.$$set({filters:e}),p()}get image(){return this.$$.ctx[23]}set image(e){this.$$set({image:e}),p()}get limit(){return this.$$.ctx[24]}set limit(e){this.$$set({limit:e}),p()}get pagefind(){return this.$$.ctx[25]}set pagefind(e){this.$$set({pagefind:e}),p()}get renderers(){return this.$$.ctx[3]}set renderers(e){this.$$set({renderers:e}),p()}get results(){return this.$$.ctx[26]}set results(e){this.$$set({results:e}),p()}get sort(){return this.$$.ctx[27]}set sort(e){this.$$set({sort:e}),p()}get strings(){return this.$$.ctx[28]}set strings(e){this.$$set({strings:e}),p()}get suggestions(){return this.$$.ctx[4]}set suggestions(e){this.$$set({suggestions:e}),p()}get transform(){return this.$$.ctx[29]}set transform(e){this.$$set({transform:e}),p()}get width(){return this.$$.ctx[5]}set width(e){this.$$set({width:e}),p()}}return customElements.define("search-box",$e(vt,{align:{},anchor:{},category:{},customSearch:{},dropdownDelay:{},groupBy:{},filters:{},image:{},limit:{},pagefind:{},renderers:{},results:{},sort:{},strings:{},suggestions:{type:"Boolean"},transform:{},width:{}},["default"],[],!1)),vt}); diff --git a/index.html b/index.html index b247c49..52240f8 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,9 @@ .search-input > *:not(:last-child) { margin-right: 5px; } + .search-input .search-box { + width: 100%; + } .search-input input { border: 0; font-size: 100%; @@ -60,6 +63,7 @@ box-shadow: 3px 2px 4px rgba(0, 0, 0, 0.075); } +
@@ -81,30 +95,22 @@

Usage

-        <!-- 1. Create input element -->
-<div id="search">
-  <input type="search" />
-</div>
+        <script async defer type="module" src="https://cdn.jsdelivr.net/gh/bausw-com/searchbox/dist/searchbox.js"></script>
 
-<!-- 2. Include Searchbox into your website -->
-<script type="module" src="https://cdn.jsdelivr.net/gh/bausw-com/searchbox@0.2.4/dist/searchbox.min.js"></script>
-
-<!-- 3. Configure Searchbox instance -->
-<script>
-window.addEventListener('DOMContentLoaded', () => {
-  const searchbox = new Searchbox({
-    props: {
-      options: {
-        // Replace this with your Pagefind's build path
-        pagefind: '/_pagefind/pagefind.js',
-      },
-    },
-    target: document.querySelector('#search')
-  });
-});
-</script>
+<search-box pagefind="https://pagefind.app/_pagefind/pagefind.js"> + <input type="search" placeholder="Search..." /> +</search-box>
- + + + + diff --git a/package-lock.json b/package-lock.json index 7d86a24..997a227 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,24 +1,23 @@ { "name": "searchbox", - "version": "0.2.4", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "searchbox", - "version": "0.2.4", + "version": "0.3.0", "license": "MIT", "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^2.4.5", + "@sveltejs/vite-plugin-svelte": "^2.5.3", "@tsconfig/svelte": "^4.0.1", - "sass": "^1.66.1", - "svelte": "^4.2.0", - "svelte-check": "^3.5.1", - "svelte-preprocess": "^5.0.4", + "sass": "^1.69.5", + "svelte": "^4.2.7", + "svelte-check": "^3.6.2", + "svelte-preprocess": "^5.1.1", "tslib": "^2.6.2", - "typescript": "^5.2.2", - "vite": "^4.4.9", - "vite-plugin-css-injected-by-js": "^3.3.0" + "typescript": "^5.3.2", + "vite": "^4.5.0" } }, "node_modules/@ampproject/remapping": { @@ -425,9 +424,9 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", - "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", @@ -470,16 +469,16 @@ } }, "node_modules/@sveltejs/vite-plugin-svelte": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.4.5.tgz", - "integrity": "sha512-UJKsFNwhzCVuiZd06jM/psscyNJNDwjQC+qIeb7GBJK9iWeQCcIyfcPWDvbCudfcJggY9jtxJeeaZH7uny93FQ==", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.5.3.tgz", + "integrity": "sha512-erhNtXxE5/6xGZz/M9eXsmI7Pxa6MS7jyTy06zN3Ck++ldrppOnOlJwHHTsMC7DHDQdgUp4NAc4cDNQ9eGdB/w==", "dev": true, "dependencies": { - "@sveltejs/vite-plugin-svelte-inspector": "^1.0.3", + "@sveltejs/vite-plugin-svelte-inspector": "^1.0.4", "debug": "^4.3.4", "deepmerge": "^4.3.1", "kleur": "^4.1.5", - "magic-string": "^0.30.2", + "magic-string": "^0.30.3", "svelte-hmr": "^0.15.3", "vitefu": "^0.2.4" }, @@ -487,7 +486,7 @@ "node": "^14.18.0 || >= 16" }, "peerDependencies": { - "svelte": "^3.54.0 || ^4.0.0", + "svelte": "^3.54.0 || ^4.0.0 || ^5.0.0-next.0", "vite": "^4.0.0" } }, @@ -515,21 +514,21 @@ "dev": true }, "node_modules/@types/estree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz", - "integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", "dev": true }, "node_modules/@types/pug": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.6.tgz", - "integrity": "sha512-SnHmG9wN1UVmagJOnyo/qkk0Z7gejYxOYYmaAwr5u2yFYfsupN3sg10kyzN8Hep/2zbHxCnsumxOoRIRMBwKCg==", + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.10.tgz", + "integrity": "sha512-Sk/uYFOBAB7mb74XcpizmH0KOR2Pv3D2Hmrh1Dmy5BmK3MpdSa5kqZcg6EKBdklU0bFXX9gCfzvpnyUehrPIuA==", "dev": true }, "node_modules/acorn": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", - "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -780,9 +779,9 @@ } }, "node_modules/fast-glob": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", - "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -955,9 +954,9 @@ } }, "node_modules/is-reference": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.1.tgz", - "integrity": "sha512-baJJdQLiYaJdvFbJqXrcGv3WU3QCzBlUcI5QhbesIm6/xPsvmO+2CDoi/GMOFBQEQm+PXkwOPrp9KK5ozZsp2w==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz", + "integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==", "dev": true, "dependencies": { "@types/estree": "*" @@ -979,9 +978,9 @@ "dev": true }, "node_modules/magic-string": { - "version": "0.30.3", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.3.tgz", - "integrity": "sha512-B7xGbll2fG/VjP+SWg4sX3JynwIU0mjoTc6MPpKNuIvftk6u6vqhDnk1R80b8C2GBR6ywqy+1DcKBrevBg+bmw==", + "version": "0.30.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", "dev": true, "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" @@ -1076,9 +1075,9 @@ "dev": true }, "node_modules/nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", "dev": true, "funding": [ { @@ -1162,9 +1161,9 @@ } }, "node_modules/postcss": { - "version": "8.4.29", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.29.tgz", - "integrity": "sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "dev": true, "funding": [ { @@ -1253,9 +1252,9 @@ } }, "node_modules/rollup": { - "version": "3.28.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.28.1.tgz", - "integrity": "sha512-R9OMQmIHJm9znrU3m3cpE8uhN0fGdXiawME7aZIpQqvpS/85+Vt1Hq1/yVIcYfOmaQiHjvXkQAoJukvLpau6Yw==", + "version": "3.29.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", + "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -1316,9 +1315,9 @@ } }, "node_modules/sass": { - "version": "1.66.1", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.66.1.tgz", - "integrity": "sha512-50c+zTsZOJVgFfTgwwEzkjA3/QACgdNsKueWPyAR0mRINIvLAStVQBbPg14iuqEQ74NPDbXzJARJ/O4SI1zftA==", + "version": "1.69.5", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.5.tgz", + "integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==", "dev": true, "dependencies": { "chokidar": ">=3.0.0 <4.0.0", @@ -1369,9 +1368,9 @@ } }, "node_modules/svelte": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.0.tgz", - "integrity": "sha512-kVsdPjDbLrv74SmLSUzAsBGquMs4MPgWGkGLpH+PjOYnFOziAvENVzgJmyOCV2gntxE32aNm8/sqNKD6LbIpeQ==", + "version": "4.2.7", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.7.tgz", + "integrity": "sha512-UExR1KS7raTdycsUrKLtStayu4hpdV3VZQgM0akX8XbXgLBlosdE/Sf3crOgyh9xIjqSYB3UEBuUlIQKRQX2hg==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.1", @@ -1385,7 +1384,7 @@ "estree-walker": "^3.0.3", "is-reference": "^3.0.1", "locate-character": "^3.0.0", - "magic-string": "^0.30.0", + "magic-string": "^0.30.4", "periscopic": "^3.1.0" }, "engines": { @@ -1393,9 +1392,9 @@ } }, "node_modules/svelte-check": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-3.5.1.tgz", - "integrity": "sha512-+Zb4iHxAhdUtcUg/WJPRjlS1RJalIsWAe9Mz6G1zyznSs7dDkT7VUBdXc3q7Iwg49O/VrZgyJRvOJkjuBfKjFA==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-3.6.2.tgz", + "integrity": "sha512-E6iFh4aUCGJLRz6QZXH3gcN/VFfkzwtruWSRmlKrLWQTiO6VzLsivR6q02WYLGNAGecV3EocqZuCDrC2uttZ0g==", "dev": true, "dependencies": { "@jridgewell/trace-mapping": "^0.3.17", @@ -1404,14 +1403,14 @@ "import-fresh": "^3.2.1", "picocolors": "^1.0.0", "sade": "^1.7.4", - "svelte-preprocess": "^5.0.4", + "svelte-preprocess": "^5.1.0", "typescript": "^5.0.3" }, "bin": { "svelte-check": "bin/svelte-check" }, "peerDependencies": { - "svelte": "^3.55.0 || ^4.0.0-next.0 || ^4.0.0" + "svelte": "^3.55.0 || ^4.0.0-next.0 || ^4.0.0 || ^5.0.0-next.0" } }, "node_modules/svelte-hmr": { @@ -1427,9 +1426,9 @@ } }, "node_modules/svelte-preprocess": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-5.0.4.tgz", - "integrity": "sha512-ABia2QegosxOGsVlsSBJvoWeXy1wUKSfF7SWJdTjLAbx/Y3SrVevvvbFNQqrSJw89+lNSsM58SipmZJ5SRi5iw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-5.1.1.tgz", + "integrity": "sha512-p/Dp4hmrBW5mrCCq29lEMFpIJT2FZsRlouxEc5qpbOmXRbaFs7clLs8oKPwD3xCFyZfv1bIhvOzpQkhMEVQdMw==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -1452,7 +1451,7 @@ "sass": "^1.26.8", "stylus": "^0.55.0", "sugarss": "^2.0.0 || ^3.0.0 || ^4.0.0", - "svelte": "^3.23.0 || ^4.0.0-next.0 || ^4.0.0", + "svelte": "^3.23.0 || ^4.0.0-next.0 || ^4.0.0 || ^5.0.0-next.0", "typescript": ">=3.9.5 || ^4.0.0 || ^5.0.0" }, "peerDependenciesMeta": { @@ -1519,9 +1518,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz", + "integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -1532,9 +1531,9 @@ } }, "node_modules/vite": { - "version": "4.4.9", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.4.9.tgz", - "integrity": "sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.0.tgz", + "integrity": "sha512-ulr8rNLA6rkyFAlVWw2q5YJ91v098AFQ2R0PRFwPzREXOUJQPtFUG0t+/ZikhaOCDqFoDhN6/v8Sq0o4araFAw==", "dev": true, "dependencies": { "esbuild": "^0.18.10", @@ -1586,22 +1585,13 @@ } } }, - "node_modules/vite-plugin-css-injected-by-js": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/vite-plugin-css-injected-by-js/-/vite-plugin-css-injected-by-js-3.3.0.tgz", - "integrity": "sha512-xG+jyHNCmUqi/TXp6q88wTJGeAOrNLSyUUTp4qEQ9QZLGcHWQQsCsSSKa59rPMQr8sOzfzmWDd8enGqfH/dBew==", - "dev": true, - "peerDependencies": { - "vite": ">2.0.0-0" - } - }, "node_modules/vitefu": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-0.2.4.tgz", - "integrity": "sha512-fanAXjSaf9xXtOOeno8wZXIhgia+CZury481LsDaV++lSvcU2R9Ch2bPh3PYFyoHW+w9LqAeYRISVQjUIew14g==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-0.2.5.tgz", + "integrity": "sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==", "dev": true, "peerDependencies": { - "vite": "^3.0.0 || ^4.0.0" + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0" }, "peerDependenciesMeta": { "vite": { diff --git a/package.json b/package.json index 11da845..0dc15af 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "searchbox", "description": "A backend-less website search built on top of Pagefind.", - "version": "0.2.4", + "version": "0.3.0", "type": "module", - "main": "dist/searchbox.min.js", + "main": "dist/searchbox.js", + "module": "dist/searchbox.js", "author": "Daniel Regeci; BAU Software s.r.o.; https://bausw.com", "license": "MIT", "files": [ @@ -33,15 +34,14 @@ "check": "svelte-check --tsconfig ./tsconfig.json" }, "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^2.4.5", + "@sveltejs/vite-plugin-svelte": "^2.5.3", "@tsconfig/svelte": "^4.0.1", - "sass": "^1.66.1", - "svelte": "^4.2.0", - "svelte-check": "^3.5.1", - "svelte-preprocess": "^5.0.4", + "sass": "^1.69.5", + "svelte": "^4.2.7", + "svelte-check": "^3.6.2", + "svelte-preprocess": "^5.1.1", "tslib": "^2.6.2", - "typescript": "^5.2.2", - "vite": "^4.4.9", - "vite-plugin-css-injected-by-js": "^3.3.0" + "typescript": "^5.3.2", + "vite": "^4.5.0" } } diff --git a/src/Searchbox.svelte b/src/Searchbox.svelte index d796ce7..1e31d03 100644 --- a/src/Searchbox.svelte +++ b/src/Searchbox.svelte @@ -1,34 +1,125 @@ + + -
- -{#if showDropdown} - - onCategoryChange(ev.detail)} - on:selection={(ev) => onSelection(ev.detail)} - /> - -{/if} \ No newline at end of file +
+ + + {#if showDropdown} + + onCategoryChange(ev.detail)} + on:selection={(ev) => onSelection(ev.detail)} + /> + + {/if} +
+ + diff --git a/src/demo.ts b/src/demo.ts deleted file mode 100644 index ccecd37..0000000 --- a/src/demo.ts +++ /dev/null @@ -1,19 +0,0 @@ -import './searchbox.scss' -import Searchbox from './Searchbox.svelte' - -const searchbox = new Searchbox({ - props: { - options: { - anchor: document.querySelector('#search .search-input'), - category: 'section', - pagefind: 'https://pagefind.app/_pagefind/pagefind.js', - renderers: { - footer: () => ``, - }, - groupBy: 'title', - }, - }, - target: document.querySelector('#search') -}) - -export default searchbox; diff --git a/src/lib/components/Dropdown.svelte b/src/lib/components/Dropdown.svelte index 13fea9f..593a868 100644 --- a/src/lib/components/Dropdown.svelte +++ b/src/lib/components/Dropdown.svelte @@ -1,23 +1,29 @@ +
\ No newline at end of file diff --git a/src/lib/components/ResultItem.svelte b/src/lib/components/ResultItem.svelte index 4dcce8c..1cc85a4 100644 --- a/src/lib/components/ResultItem.svelte +++ b/src/lib/components/ResultItem.svelte @@ -28,6 +28,7 @@ +
  • {#if renderer} diff --git a/src/lib/components/Results.svelte b/src/lib/components/Results.svelte index db242e7..9154939 100644 --- a/src/lib/components/Results.svelte +++ b/src/lib/components/Results.svelte @@ -132,11 +132,13 @@ {#if categories.length > 2}
  • + onCategoryClick('*')}>{i18n.all}
  • {/if} {#each categories.slice(1) as cat}
  • + onCategoryClick(cat)}>{cat}
  • diff --git a/src/main.ts b/src/main.ts index bb30e84..c5c35a7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,10 +1,3 @@ -import './searchbox.scss' import Searchbox from './Searchbox.svelte' -if (typeof 'window' !== void 0) { - Object.assign(window, { - Searchbox, - }); -} - export default Searchbox; diff --git a/src/searchbox.scss b/src/searchbox.scss deleted file mode 100644 index 84ddd03..0000000 --- a/src/searchbox.scss +++ /dev/null @@ -1,201 +0,0 @@ -:root { - --searchbox-border-color: rgb(219, 219, 219); - --searchbox-active-color: rgb(19, 58, 165); - --searchbox-active-bg-color: rgb(233, 238, 250); - --searchbox-muted-color: rgb(119, 119, 119); - --searchbox-muted-bg-color: rgb(247, 247, 247); - --searchbox-mark-bg: rgb(250, 248, 205); - --searchbox-spacer: 0.5rem; - --searchbox-spacer-lg: 1rem; -} - -.searchbox { - &-results { - &-categories { - background-color: var(--searchbox-muted-bg-color); - border-bottom: 1px solid var(--searchbox-border-color); - font-size: 0.8rem; - padding: 0 var(--searchbox-spacer); - - &-wrap { - overflow-y: visible; - overflow-x: auto; - margin: 0 0 -1px 0; - } - - ul { - display: flex; - margin: 0; - padding: 0; - list-style: none; - } - - li { - margin-right: var(--searchbox-spacer-lg); - } - - a, - [role='button'] { - border-bottom: 1px solid transparent; - color: var(--searchbox-muted-color); - cursor: pointer; - display: inline-block; - padding: var(--searchbox-spacer) 0; - white-space: nowrap; - - &.active { - border-bottom-color: var(--searchbox-active-color); - color: var(--searchbox-active-color); - } - } - } - - &-items { - flex-grow: 1; - overflow-y: auto; - overflow-x: hidden; - - mark { - background-color: var(--searchbox-mark-bg); - color: currentColor; - padding: 0; - } - - ul { - margin: 0; - padding: 0; - list-style: none; - } - - a { - color: var(--searchbox-active-color); - } - } - - &-header { - background-color: var(--searchbox-muted-bg-color); - border-bottom: 1px solid var(--searchbox-border-color); - padding: var(--searchbox-spacer); - } - - &-footer { - background-color: var(--searchbox-muted-bg-color); - border-top: 1px solid var(--searchbox-border-color); - padding: var(--searchbox-spacer); - } - - &:not(.compact) &-item:not(:last-child) { - border-bottom: 1px solid var(--searchbox-border-color); - } - - &-text { - color: var(--searchbox-muted-color); - padding: var(--searchbox-spacer); - } - - &-load-more { - color: var(--searchbox-muted-color); - - button { - background: transparent; - border: none; - box-shadow: none; - color: currentColor; - cursor: pointer; - font-size: 0.8rem; - outline: none; - margin: 0; - padding: var(--searchbox-spacer); - width: 100%; - } - } - - &-item:not(:last-child) { - border-bottom: 1px solid var(--searchbox-border-color); - } - - &-link { - display: flex; - padding: var(--searchbox-spacer); - text-decoration: none; - - &:hover { - text-decoration: none; - } - - &.focus, - &:hover { - background-color: var(--searchbox-active-bg-color); - } - } - - &-image { - color: var(--searchbox-muted-color); - margin-right: var(--searchbox-spacer); - } - - &-excerpt { - color: var(--searchbox-muted-color); - font-size: 0.8rem; - margin-top: var(--searchbox-spacer); - - code { - font-size: 0.8rem; - } - - h1, h2, h3, h4, h5, h6 { - font-size: 0.8rem; - } - - p { - margin-top: 0; - - &:last-child { - margin-bottom: 0; - } - } - } - - &-expand { - background-color: var(--searchbox-muted-bg-color); - color: var(--searchbox-active-color); - - button { - background: transparent; - border: none; - box-shadow: none; - color: currentColor; - cursor: pointer; - font-size: 0.8rem; - outline: none; - margin: 0; - padding: var(--searchbox-spacer); - } - } - - &-item-expanded &-expand { - color: var(--searchbox-muted-color); - } - - &-label { - border: 1px solid var(--searchbox-border-color); - border-radius: 1rem; - color: var(--searchbox-muted-color); - font-size: 0.8rem; - margin-left: var(--searchbox-spacer); - padding: 2px 6px; - } - } - - &-dropdown { - background: white; - border: 1px solid var(--searchbox-border-color); - display: flex; - flex-direction: column; - height: 0; - overflow: hidden; - position: fixed; - transition: height 0.3s; - z-index: 10000; - } -} diff --git a/src/types.ts b/src/types.ts index 666d0c6..978568a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,96 +4,6 @@ export type TTransformFunc = ( result: IResult ) => IResultItemDoc; -export interface IOptions { - /** - * Dropdown alignment relative to the `anchor`. - */ - align?: 'left' | 'right'; - - /** - * Dropdown anchor element for positioning and alignment. If not specified, the `input` will be used. - */ - anchor?: HTMLElement; - - /** - * The name of the Pagefind's "filter" property to be used as a category for grouping results. Use one of the properties returned by `pagefind.filters();`. - * https://pagefind.app/docs/api/#filtering - */ - category?: string; - - /** - * A custom search function. Can be used to request external API. - */ - customSearch?: (term: string, suggestions: boolean) => Promise; - - /** - * A custom delay (in milliseconds) between the input focus and when the dropdown is shown. - */ - dropdownDelay?: number; - - /** - * Grouping function or a parameter name. The function should return group identifier as string. - */ - groupBy?: string | ((doc: IResultItemDoc) => string); - - /** - * Pagefind filters - * https://pagefind.app/docs/api/#filtering - */ - filters?: Record; - - /** - * The name of the "meta" property to be used as an image in the search results (typically, this would be "image"). - */ - image?: string; - - /** - * Max. number of results to return (default: 100) - */ - limit?: number; - - /** - * Path to `pagefind.js` script - */ - pagefind: string; - - /** - * A custom HTML element where the results will be rendered instead of the dropdown. Is specified, the dropdown won't be shown. - */ - results?: HTMLElement; - - /** - * Custom renderer functions. Supported functions: `header`, `footer`, `item`. - */ - renderers?: IRenderers; - - /** - * Pagefind sorting - * https://pagefind.app/docs/api/#sorting-results - */ - sort?: Record; - - /** - * I18n strings override. See `src/strings.ts`. - */ - strings?: Record; - - /** - * Whether to use suggestions - */ - suggestions?: boolean; - - /** - * A custom function that transforms the result (each item). - */ - transform?: TTransformFunc; - - /** - * Dropdown width (default: 100%) - */ - width?: number; -} - export interface IResultItemDoc { category?: string; excerpt?: string; diff --git a/vite.config.ts b/vite.config.ts index e5288ed..4eb3902 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,16 +1,23 @@ -import { defineConfig } from 'vite' -import { svelte } from '@sveltejs/vite-plugin-svelte' -import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js' +import { defineConfig } from "vite"; +import { svelte } from "@sveltejs/vite-plugin-svelte"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [svelte(), cssInjectedByJsPlugin()], + plugins: [ + svelte({ + compilerOptions: { + customElement: true, + }, + }), + ], build: { - rollupOptions: { - input: ['src/main.ts'], - output: { - entryFileNames: `searchbox.min.js`, - } + target: "modules", + lib: { + entry: "src/main.ts", + name: "altcha", + formats: ["iife", "es", "umd"], }, - } -}) + minify: "esbuild", + rollupOptions: {}, + }, +});