umami_search_web_components-1.0.x-dev/modules/umami_search_web_components_adv/lit/search-web-components.min.js
modules/umami_search_web_components_adv/lit/search-web-components.min.js
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
class t extends Event{constructor(t,s,e){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.callback=s,this.subscribe=e??!1}}
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
class s{constructor(t,s,e,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(t,s)=>{this.unsubscribe&&(this.unsubscribe!==s&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=t,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(t,s)),this.unsubscribe=s},this.host=t,void 0!==s.context){const t=s;this.context=t.context,this.callback=t.callback,this.subscribe=t.subscribe??!1}else this.context=s,this.callback=e,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new t(this.context,this.t,this.subscribe))}}
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class e{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,s=!1){const e=s||!Object.is(t,this.o);this.o=t,e&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(const[t,{disposer:s}]of this.subscriptions)t(this.o,s)},void 0!==t&&(this.value=t)}addCallback(t,s,e){if(!e)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:s});const{disposer:i}=this.subscriptions.get(t);t(this.value,i)}clearCallbacks(){this.subscriptions.clear()}}
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class i extends Event{constructor(t){super("context-provider",{bubbles:!0,composed:!0}),this.context=t}}class n extends e{constructor(s,e,i){super(void 0!==e.context?e.initialValue:i),this.onContextRequest=t=>{const s=t.composedPath()[0];t.context===this.context&&s!==this.host&&(t.stopPropagation(),this.addCallback(t.callback,s,t.subscribe))},this.onProviderRequest=s=>{const e=s.composedPath()[0];if(s.context!==this.context||e===this.host)return;const i=new Set;for(const[s,{consumerHost:e}]of this.subscriptions)i.has(s)||(i.add(s),e.dispatchEvent(new t(this.context,s,!0)));s.stopPropagation()},this.host=s,void 0!==e.context?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new i(this.context))}}
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class r{constructor(){this.pendingContextRequests=new Map,this.onContextProvider=s=>{const e=this.pendingContextRequests.get(s.context);if(void 0===e)return;this.pendingContextRequests.delete(s.context);const{requests:i}=e;for(const{elementRef:e,callbackRef:n}of i){const i=e.deref(),r=n.deref();void 0===i||void 0===r||i.dispatchEvent(new t(s.context,r,!0))}},this.onContextRequest=t=>{if(!0!==t.subscribe)return;const s=t.composedPath()[0],e=t.callback;let i=this.pendingContextRequests.get(t.context);void 0===i&&this.pendingContextRequests.set(t.context,i={callbacks:new WeakMap,requests:[]});let n=i.callbacks.get(s);void 0===n&&i.callbacks.set(s,n=new WeakSet),n.has(e)||(n.add(e),i.requests.push({elementRef:new WeakRef(s),callbackRef:new WeakRef(e)}))}}attach(t){t.addEventListener("context-request",this.onContextRequest),t.addEventListener("context-provider",this.onContextProvider)}detach(t){t.removeEventListener("context-request",this.onContextRequest),t.removeEventListener("context-provider",this.onContextProvider)}}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const h=Symbol("search-context"),o=t=>(s,e)=>{void 0!==e?e.addInitializer((()=>{customElements.define(t,s)})):customElements.define(t,s)}
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,l=globalThis,c=l.ShadowRoot&&(void 0===l.ShadyCSS||l.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,a=Symbol(),u=new WeakMap;
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class d{constructor(t,s,e){if(this._$cssResult$=!0,e!==a)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=s}get styleSheet(){let t=this.o;const s=this.t;if(c&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=u.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&u.set(s,t))}return t}toString(){return this.cssText}}const p=c?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let s="";for(const e of t.cssRules)s+=e.cssText;return(t=>new d("string"==typeof t?t:t+"",void 0,a))(s)})(t):t
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,{is:f,defineProperty:b,getOwnPropertyDescriptor:v,getOwnPropertyNames:$,getOwnPropertySymbols:m,getPrototypeOf:g}=Object,y=globalThis,w=y.trustedTypes,S=w?w.emptyScript:"",O=y.reactiveElementPolyfillSupport,x=(t,s)=>t,_={toAttribute(t,s){switch(s){case Boolean:t=t?S:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,s){let e=t;switch(s){case Boolean:e=null!==t;break;case Number:e=null===t?null:Number(t);break;case Object:case Array:try{e=JSON.parse(t)}catch(t){e=null}}return e}},k=(t,s)=>!f(t,s),R={attribute:!0,type:String,converter:_,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),y.litPropertyMetadata??=new WeakMap;class j extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=R){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const e=Symbol(),i=this.getPropertyDescriptor(t,e,s);void 0!==i&&b(this.prototype,t,i)}}static getPropertyDescriptor(t,s,e){const{get:i,set:n}=v(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t}};return{get(){return i?.call(this)},set(s){const r=i?.call(this);n.call(this,s),this.requestUpdate(t,r,e)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??R}static _$Ei(){if(this.hasOwnProperty(x("elementProperties")))return;const t=g(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(x("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(x("properties"))){const t=this.properties,s=[...$(t),...m(t)];for(const e of s)this.createProperty(e,t[e])}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,e]of s)this.elementProperties.set(t,e)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const e=this._$Eu(t,s);void 0!==e&&this._$Eh.set(e,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const s=[];if(Array.isArray(t)){const e=new Set(t.flat(1/0).reverse());for(const t of e)s.unshift(p(t))}else void 0!==t&&s.push(p(t));return s}static _$Eu(t,s){const e=s.attribute;return!1===e?void 0:"string"==typeof e?e:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,s=this.constructor.elementProperties;for(const e of s.keys())this.hasOwnProperty(e)&&(t.set(e,this[e]),delete this[e]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,s)=>{if(c)t.adoptedStyleSheets=s.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of s){const s=document.createElement("style"),i=l.litNonce;void 0!==i&&s.setAttribute("nonce",i),s.textContent=e.cssText,t.appendChild(s)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,s,e){this._$AK(t,e)}_$EO(t,s){const e=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,e);if(void 0!==i&&!0===e.reflect){const n=(void 0!==e.converter?.toAttribute?e.converter:_).toAttribute(s,e.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,s){const e=this.constructor,i=e._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=e.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:_;this._$Em=i,this[i]=n.fromAttribute(s,t.type),this._$Em=null}}requestUpdate(t,s,e,i=!1,n){if(void 0!==t){if(e??=this.constructor.getPropertyOptions(t),!(e.hasChanged??k)(i?n:this[t],s))return;this.C(t,s,e)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,s,e){this._$AL.has(t)||this._$AL.set(t,s),!0===e.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,e]of t)!0!==e.wrapped||this._$AL.has(s)||void 0===this[s]||this.C(s,this[s],e)}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$ET()}catch(s){throw t=!1,this._$ET(),s}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EO(t,this[t]))),this._$ET()}updated(t){}firstUpdated(t){}}j.elementStyles=[],j.shadowRootOptions={mode:"open"},j[x("elementProperties")]=new Map,j[x("finalized")]=new Map,O?.({ReactiveElement:j}),(y.reactiveElementVersions??=[]).push("2.0.2");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const L={attribute:!0,type:String,converter:_,reflect:!1,hasChanged:k},P=(t=L,s,e)=>{const{kind:i,metadata:n}=e;let r=globalThis.litPropertyMetadata.get(n);if(void 0===r&&globalThis.litPropertyMetadata.set(n,r=new Map),r.set(e.name,t),"accessor"===i){const{name:i}=e;return{set(e){const n=s.get.call(this);s.set.call(this,e),this.requestUpdate(i,n,t)},init(s){return void 0!==s&&this.C(i,void 0,t),s}}}if("setter"===i){const{name:i}=e;return function(e){const n=this[i];s.call(this,e),this.requestUpdate(i,n,t)}}throw Error("Unsupported decorator location: "+i)};function E(t){return(s,e)=>"object"==typeof e?P(t,s,e):((t,s,e)=>{const i=s.hasOwnProperty(e);return s.constructor.createProperty(e,i?{...t,wrapped:!0}:t),i?Object.getOwnPropertyDescriptor(s,e):void 0})(t,s,e)
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/}function A(t){return E({...t,state:!0,attribute:!1})}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const C=globalThis,U=C.trustedTypes,T=U?U.createPolicy("lit-html",{createHTML:t=>t}):void 0,M="$lit$",H=`lit$${(Math.random()+"").slice(9)}$`,D="?"+H,q=`<${D}>`,B=document,F=()=>B.createComment(""),N=t=>null===t||"object"!=typeof t&&"function"!=typeof t,I=Array.isArray,W=t=>I(t)||"function"==typeof t?.[Symbol.iterator],K="[ \t\n\f\r]",V=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,z=/-->/g,J=/>/g,Z=RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Q=/'/g,G=/"/g,X=/^(?:script|style|textarea|title)$/i,Y=(t=>(s,...e)=>({_$litType$:t,strings:s,values:e}))(1),tt=Symbol.for("lit-noChange"),st=Symbol.for("lit-nothing"),et=new WeakMap,it=B.createTreeWalker(B,129);function nt(t,s){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==T?T.createHTML(s):s}const rt=(t,s)=>{const e=t.length-1,i=[];let n,r=2===s?"<svg>":"",h=V;for(let s=0;s<e;s++){const e=t[s];let o,l,c=-1,a=0;for(;a<e.length&&(h.lastIndex=a,l=h.exec(e),null!==l);)a=h.lastIndex,h===V?"!--"===l[1]?h=z:void 0!==l[1]?h=J:void 0!==l[2]?(X.test(l[2])&&(n=RegExp("</"+l[2],"g")),h=Z):void 0!==l[3]&&(h=Z):h===Z?">"===l[0]?(h=n??V,c=-1):void 0===l[1]?c=-2:(c=h.lastIndex-l[2].length,o=l[1],h=void 0===l[3]?Z:'"'===l[3]?G:Q):h===G||h===Q?h=Z:h===z||h===J?h=V:(h=Z,n=void 0);const u=h===Z&&t[s+1].startsWith("/>")?" ":"";r+=h===V?e+q:c>=0?(i.push(o),e.slice(0,c)+M+e.slice(c)+H+u):e+H+(-2===c?s:u)}return[nt(t,r+(t[e]||"<?>")+(2===s?"</svg>":"")),i]};class ht{constructor({strings:t,_$litType$:s},e){let i;this.parts=[];let n=0,r=0;const h=t.length-1,o=this.parts,[l,c]=rt(t,s);if(this.el=ht.createElement(l,e),it.currentNode=this.el.content,2===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=it.nextNode())&&o.length<h;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(M)){const s=c[r++],e=i.getAttribute(t).split(H),h=/([.?@])?(.*)/.exec(s);o.push({type:1,index:n,name:h[2],strings:e,ctor:"."===h[1]?ut:"?"===h[1]?dt:"@"===h[1]?pt:at}),i.removeAttribute(t)}else t.startsWith(H)&&(o.push({type:6,index:n}),i.removeAttribute(t));if(X.test(i.tagName)){const t=i.textContent.split(H),s=t.length-1;if(s>0){i.textContent=U?U.emptyScript:"";for(let e=0;e<s;e++)i.append(t[e],F()),it.nextNode(),o.push({type:2,index:++n});i.append(t[s],F())}}}else if(8===i.nodeType)if(i.data===D)o.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(H,t+1));)o.push({type:7,index:n}),t+=H.length-1}n++}}static createElement(t,s){const e=B.createElement("template");return e.innerHTML=t,e}}function ot(t,s,e=t,i){if(s===tt)return s;let n=void 0!==i?e._$Co?.[i]:e._$Cl;const r=N(s)?void 0:s._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),void 0===r?n=void 0:(n=new r(t),n._$AT(t,e,i)),void 0!==i?(e._$Co??=[])[i]=n:e._$Cl=n),void 0!==n&&(s=ot(t,n._$AS(t,s.values),n,i)),s}class lt{constructor(t,s){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:s},parts:e}=this._$AD,i=(t?.creationScope??B).importNode(s,!0);it.currentNode=i;let n=it.nextNode(),r=0,h=0,o=e[0];for(;void 0!==o;){if(r===o.index){let s;2===o.type?s=new ct(n,n.nextSibling,this,t):1===o.type?s=new o.ctor(n,o.name,o.strings,this,t):6===o.type&&(s=new ft(n,this,t)),this._$AV.push(s),o=e[++h]}r!==o?.index&&(n=it.nextNode(),r++)}return it.currentNode=B,i}p(t){let s=0;for(const e of this._$AV)void 0!==e&&(void 0!==e.strings?(e._$AI(t,e,s),s+=e.strings.length-2):e._$AI(t[s])),s++}}class ct{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,s,e,i){this.type=2,this._$AH=st,this._$AN=void 0,this._$AA=t,this._$AB=s,this._$AM=e,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const s=this._$AM;return void 0!==s&&11===t?.nodeType&&(t=s.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,s=this){t=ot(this,t,s),N(t)?t===st||null==t||""===t?(this._$AH!==st&&this._$AR(),this._$AH=st):t!==this._$AH&&t!==tt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):W(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==st&&N(this._$AH)?this._$AA.nextSibling.data=t:this.$(B.createTextNode(t)),this._$AH=t}g(t){const{values:s,_$litType$:e}=t,i="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=ht.createElement(nt(e.h,e.h[0]),this.options)),e);if(this._$AH?._$AD===i)this._$AH.p(s);else{const t=new lt(i,this),e=t.u(this.options);t.p(s),this.$(e),this._$AH=t}}_$AC(t){let s=et.get(t.strings);return void 0===s&&et.set(t.strings,s=new ht(t)),s}T(t){I(this._$AH)||(this._$AH=[],this._$AR());const s=this._$AH;let e,i=0;for(const n of t)i===s.length?s.push(e=new ct(this.k(F()),this.k(F()),this,this.options)):e=s[i],e._$AI(n),i++;i<s.length&&(this._$AR(e&&e._$AB.nextSibling,i),s.length=i)}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class at{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,s,e,i,n){this.type=1,this._$AH=st,this._$AN=void 0,this.element=t,this.name=s,this._$AM=i,this.options=n,e.length>2||""!==e[0]||""!==e[1]?(this._$AH=Array(e.length-1).fill(new String),this.strings=e):this._$AH=st}_$AI(t,s=this,e,i){const n=this.strings;let r=!1;if(void 0===n)t=ot(this,t,s,0),r=!N(t)||t!==this._$AH&&t!==tt,r&&(this._$AH=t);else{const i=t;let h,o;for(t=n[0],h=0;h<n.length-1;h++)o=ot(this,i[e+h],s,h),o===tt&&(o=this._$AH[h]),r||=!N(o)||o!==this._$AH[h],o===st?t=st:t!==st&&(t+=(o??"")+n[h+1]),this._$AH[h]=o}r&&!i&&this.O(t)}O(t){t===st?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class ut extends at{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===st?void 0:t}}class dt extends at{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==st)}}class pt extends at{constructor(t,s,e,i,n){super(t,s,e,i,n),this.type=5}_$AI(t,s=this){if((t=ot(this,t,s,0)??st)===tt)return;const e=this._$AH,i=t===st&&e!==st||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,n=t!==st&&(e===st||i);i&&this.element.removeEventListener(this.name,this,e),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class ft{constructor(t,s,e){this.element=t,this.type=6,this._$AN=void 0,this._$AM=s,this.options=e}get _$AU(){return this._$AM._$AU}_$AI(t){ot(this,t)}}const bt={j:M,P:H,A:D,C:1,M:rt,L:lt,R:W,V:ot,D:ct,I:at,H:dt,N:pt,U:ut,B:ft},vt=C.litHtmlPolyfillSupport;vt?.(ht,ct),(C.litHtmlVersions??=[]).push("3.1.0");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
class $t extends j{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,s,e)=>{const i=e?.renderBefore??s;let n=i._$litPart$;if(void 0===n){const t=e?.renderBefore??null;i._$litPart$=n=new ct(s.insertBefore(F(),t),t,void 0,e??{})}return n._$AI(t),n})(s,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return tt}}$t._$litElement$=!0,$t.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:$t});const mt=globalThis.litElementPolyfillSupport;mt?.({LitElement:$t}),(globalThis.litElementVersions??=[]).push("4.0.2");var gt=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};class yt extends $t{constructor(){super(...arguments),this.uid=this.genUniqId()}createRenderRoot(){return this.style.display="block",this}updateContext(t){const s=new CustomEvent("update-context",{bubbles:!0,composed:!0});s.context=t,this.dispatchEvent(s)}applyFacet(t,s,e=!1){const i=new URLSearchParams(this.context?.query?.toString()),n=`f:${t}`;if(e&&i.delete(n),i.get(n)){let t=i.get(n)?.split(",")??[];t.includes(s)?t=t.filter((t=>t!==s)):t.push(s),t.length>0?i.set(n,t.join(",")):i.delete(n)}else i.set(n,s);i.delete("page"),this.getResults(i)}clearFacet(t){const s=new URLSearchParams(this.context?.query?.toString()),e=`f:${t}`;s.delete(e),s.delete("page"),this.getResults(s)}clearFacets(){const t=new URLSearchParams(this.context?.query?.toString()),s=[];t.forEach(((t,e)=>{e.startsWith("f:")&&s.push(e)})),s.forEach((s=>t.delete(s))),t.has("page")&&t.delete("page"),this.getResults(t)}async getResults(t){const s=new URL(window.location.href);s.search=t.toString();const e={...this.context};e.query=t;let i=t;this.context?.additionalParams&&(i=new URLSearchParams({...Object.fromEntries(new URLSearchParams(this.context.additionalParams)),...Object.fromEntries(t)})),[e.response]=await Promise.all([yt.doSearch(e.url??"",i)]),this.context={...e},this.updateContext(e),this.context.updateUrl&&window.history.pushState(null,"",s.toString())}static async doSearch(t,s){const e=new URLSearchParams(s.toString());let i=0;for(const[t,n]of s.entries()){if(!t.startsWith("f:"))continue;e.delete(t);const s=n.split(","),r=t.replace("f:","");s.forEach((t=>{e.append(`f[${i}]`,`${r}:${t}`),i++}))}const n=new URL(t);return n.search=e.toString(),yt.doFetch(n).then((t=>t))}static async doFetch(t,s=void 0){const e=new Headers(s);return fetch(t,{headers:e,cache:"no-store"}).then((async t=>{const s=await t.text();if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}. Message:${s}`);return Promise.resolve(JSON.parse(s))})).catch((t=>console.error("Error in fetching:",t)))}safeIdentifier(t){return t.replace(/\W/g,"-")}genUniqId(t=""){return(t?`${t}-`:"")+Math.random().toString(36).slice(2,9)}}gt([
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
function({context:t,subscribe:e}){return(i,n)=>{"object"==typeof n?n.addInitializer((function(){new s(this,{context:t,callback:t=>{this[n.name]=t},subscribe:e})})):i.constructor.addInitializer((i=>{new s(i,{context:t,callback:t=>{i[n]=t},subscribe:e})}))}}({context:h,subscribe:!0}),E({attribute:!1})],yt.prototype,"context",void 0),gt([A()],yt.prototype,"uid",void 0);var wt=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let St=class extends $t{constructor(){super(...arguments),this.context={url:"",query:new URLSearchParams(window.location.search),responseReady:!1,defaultPerPage:"10",updateUrl:!0,resultDisplay:"list",additionalParams:""},this.url="",this.additionalParams="",this.defaultPerPage="10",this.defaultResultDisplay="list",this.noPageUrlUpdate=!1,this.root=new r}createRenderRoot(){return this.style.display="block",this}async connectedCallback(){super.connectedCallback();const t={...this.context};let s;if(this.url){const[e,i]=this.url.split("?");e.startsWith("/")?t.url=new URL(e,document.baseURI).href:t.url=e,i&&(s=new URLSearchParams(i))}if(t.defaultPerPage=this.defaultPerPage,t.resultDisplay=this.defaultResultDisplay,this.noPageUrlUpdate&&(t.updateUrl=!1),t.query&&!this.noPageUrlUpdate||(t.query=new URLSearchParams),s){let e=!0;const i=["q","page","limit","sort","order"];t.query.forEach(((t,s)=>{(i.includes(s)&&""!==t||s.startsWith("f:"))&&(e=!1)})),(0===t.query.size||e)&&(t.query=s,this.context.query=s)}t.additionalParams=this.additionalParams;let e=t.query;if(this.additionalParams&&(e=new URLSearchParams({...Object.fromEntries(new URLSearchParams(this.additionalParams)),...Object.fromEntries(e)})),t.response=await yt.doSearch(t.url??"",e),t.responseReady=!0,t.updateUrl){const s=new URL(window.location.href);s.search=t.query.toString(),window.history.pushState(null,"",s.toString())}this.context=t,this.addEventListener("update-context",(t=>{this.context={...this.context,...t.context}}))}};wt([function({context:t}){return(s,e)=>{const i=new WeakMap;if("object"==typeof e)return e.addInitializer((function(){i.set(this,new n(this,{context:t}))})),{get(){return s.get.call(this)},set(t){return i.get(this)?.setValue(t),s.set.call(this,t)},init(t){return i.get(this)?.setValue(t),t}};{s.constructor.addInitializer((s=>{i.set(s,new n(s,{context:t}))}));const r=Object.getOwnPropertyDescriptor(s,e);let h;if(void 0===r){const t=new WeakMap;h={get:function(){return t.get(this)},set:function(s){i.get(this).setValue(s),t.set(this,s)},configurable:!0,enumerable:!0}}else{const t=r.set;h={...r,set:function(s){i.get(this).setValue(s),t?.call(this,s)}}}return void Object.defineProperty(s,e,h)}}}({context:h}),A()],St.prototype,"context",void 0),wt([E()],St.prototype,"url",void 0),wt([E()],St.prototype,"additionalParams",void 0),wt([E()],St.prototype,"defaultPerPage",void 0),wt([E()],St.prototype,"defaultResultDisplay",void 0),wt([E({type:Boolean})],St.prototype,"noPageUrlUpdate",void 0),St=wt([o("search-root")],St);
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const Ot=2,xt=t=>(...s)=>({_$litDirective$:t,values:s});class _t{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,s,e){this._$Ct=t,this._$AM=s,this._$Ci=e}_$AS(t,s){return this.update(t,s)}update(t,s){return this.render(...s)}}
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const{D:kt}=bt,Rt=()=>document.createComment(""),jt=(t,s,e)=>{const i=t._$AA.parentNode,n=void 0===s?t._$AB:s._$AA;if(void 0===e){const s=i.insertBefore(Rt(),n),r=i.insertBefore(Rt(),n);e=new kt(s,r,t,t.options)}else{const s=e._$AB.nextSibling,r=e._$AM,h=r!==t;if(h){let s;e._$AQ?.(t),e._$AM=t,void 0!==e._$AP&&(s=t._$AU)!==r._$AU&&e._$AP(s)}if(s!==n||h){let t=e._$AA;for(;t!==s;){const s=t.nextSibling;i.insertBefore(t,n),t=s}}}return e},Lt=(t,s,e=t)=>(t._$AI(s,e),t),Pt={},Et=t=>{t._$AP?.(!1,!0);let s=t._$AA;const e=t._$AB.nextSibling;for(;s!==e;){const t=s.nextSibling;s.remove(),s=t}},At=(t,s,e)=>{const i=new Map;for(let n=s;n<=e;n++)i.set(t[n],n);return i},Ct=xt(class extends _t{constructor(t){if(super(t),t.type!==Ot)throw Error("repeat() can only be used in text expressions")}ht(t,s,e){let i;void 0===e?e=s:void 0!==s&&(i=s);const n=[],r=[];let h=0;for(const s of t)n[h]=i?i(s,h):h,r[h]=e(s,h),h++;return{values:r,keys:n}}render(t,s,e){return this.ht(t,s,e).values}update(t,[s,e,i]){const n=(t=>t._$AH)(t),{values:r,keys:h}=this.ht(s,e,i);if(!Array.isArray(n))return this.dt=h,r;const o=this.dt??=[],l=[];let c,a,u=0,d=n.length-1,p=0,f=r.length-1;for(;u<=d&&p<=f;)if(null===n[u])u++;else if(null===n[d])d--;else if(o[u]===h[p])l[p]=Lt(n[u],r[p]),u++,p++;else if(o[d]===h[f])l[f]=Lt(n[d],r[f]),d--,f--;else if(o[u]===h[f])l[f]=Lt(n[u],r[f]),jt(t,l[f+1],n[u]),u++,f--;else if(o[d]===h[p])l[p]=Lt(n[d],r[p]),jt(t,n[u],n[d]),d--,p++;else if(void 0===c&&(c=At(h,p,f),a=At(o,u,d)),c.has(o[u]))if(c.has(o[d])){const s=a.get(h[p]),e=void 0!==s?n[s]:null;if(null===e){const s=jt(t,n[u]);Lt(s,r[p]),l[p]=s}else l[p]=Lt(e,r[p]),jt(t,n[u],e),n[s]=null;p++}else Et(n[d]),d--;else Et(n[u]),u++;for(;p<=f;){const s=jt(t,l[f+1]);Lt(s,r[p]),l[p++]=s}for(;u<=d;){const t=n[u++];null!==t&&Et(t)}return this.dt=h,((t,s=Pt)=>{t._$AH=s})(t,l),tt}});
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/var Ut=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};class Tt extends yt{constructor(){super(...arguments),this.key="",this.overrideLabel="",this.showLabel=!1,this.showCount=!1,this.showReset=!1,this.resetText="Reset (@count)",this.collapsible=!1,this.closed=!1,this.showCountInCollapseLabel=!1,this.preferAttributes=!1,this.urlAlias="",this.optionsOpen=!0,this.facetConfigLoaded=!1}connectedCallback(){super.connectedCallback(),this.optionsOpen=!this.closed}updated(t){if(this.facetConfigLoaded||!this.context?.responseReady)return;const s=this._getFacetData();this.urlAlias=s.settings.url_alias,this.showLabel=this._configOrAttribute(s.settings.show_title,this.showLabel),this.showCount=this._configOrAttribute(s.settings.widget.show_numbers,this.showCount),this.showReset=this._configOrAttribute(s.settings.widget.showReset,this.showReset),this.resetText=this._configOrAttribute(s.settings.widget.resetText,this.resetText),this.collapsible=this._configOrAttribute(s.settings.widget.collapsible,this.collapsible),this.closed=this._configOrAttribute(s.settings.widget.closed,this.closed),this.showCountInCollapseLabel=this._configOrAttribute(s.settings.widget.showCountInCollapseLabel,this.showCountInCollapseLabel),this.facetConfigLoaded=!0}_configOrAttribute(t,s){return this.preferAttributes?s:!("boolean"!=typeof s||!t&&!s)||(void 0!==t?t:s)}_getOptionId(t){const s=t.replace(/\W/g,"-");return`option-${this.uid}-${s}`}_getFacetData(){return this.context?.response?.facets.find((t=>t.key===this.key))}_getLabelElement(){const t=this._getFacetData(),s=this.overrideLabel?this.overrideLabel:t.label;return Y`<div class="facet-label ${t.key}">${s}</div>`}_getCollapsibleLabelElement(){const t=this._getFacetData(),s=this.overrideLabel?this.overrideLabel:t.label;return Y`<button
aria-expanded="${this.optionsOpen}"
class="facet-label ${t.key} ${this.optionsOpen?"open":""}"
@click=${()=>this.optionsOpen=!this.optionsOpen}
aria-controls="${"facet-collapse-"+this.uid}"
>
${s}${this.showCountInCollapseLabel&&t.active_values?.length?`(${t.active_values.length})`:null}
</button>`}wrapCollapsible(t,s){return Y`
${t}
<div
id="${"facet-collapse-"+this.uid}"
class="facet-options ${this.optionsOpen?"open":""}"
>
${this.optionsOpen?s:null}
</div>
`}_getResetElement(){const t=this._getFacetData();return this.showReset&&t.active_values&&0!==t.active_values.length?Y`<button
class="${this.key} facet reset"
@click="${()=>this.clearFacet(this.urlAlias)}"
>
${this.resetText.replaceAll("@count",""+t.active_values.length)}
</button>`:Y``}shouldRender(){return!(!this.context?.response||void 0===this._getFacetData()||0===this._getFacetData().count)}render(){this.classList.add(this.safeIdentifier(this.key))}}Ut([E()],Tt.prototype,"key",void 0),Ut([E()],Tt.prototype,"overrideLabel",void 0),Ut([E({type:Boolean})],Tt.prototype,"showLabel",void 0),Ut([E({type:Boolean})],Tt.prototype,"showCount",void 0),Ut([E({type:Boolean})],Tt.prototype,"showReset",void 0),Ut([E()],Tt.prototype,"resetText",void 0),Ut([E({type:Boolean})],Tt.prototype,"collapsible",void 0),Ut([E({type:Boolean})],Tt.prototype,"closed",void 0),Ut([E({type:Boolean})],Tt.prototype,"showCountInCollapseLabel",void 0),Ut([E({type:Boolean})],Tt.prototype,"preferAttributes",void 0),Ut([E({attribute:!1})],Tt.prototype,"urlAlias",void 0),Ut([A()],Tt.prototype,"optionsOpen",void 0),Ut([A()],Tt.prototype,"facetConfigLoaded",void 0),Ut([A()],Tt.prototype,"facet",void 0);var Mt=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let Ht=class extends Tt{constructor(){super(...arguments),this.useRadios=!1}connectedCallback(){super.connectedCallback(),this.useRadios=this._configOrAttribute(this.facet?.settings.widget.useRadios,this.useRadios)}applyFacet(t,s,e=!1){this.useRadios&&this.context?.query?.delete(`f:${t}`),super.applyFacet(t,s,e)}_getOptions(){const t=this._getFacetData();return Y`
<ul>
${Ct(t.results,(t=>t.key),(s=>{const e=this.genUniqId(`${t.key}-${this.safeIdentifier(s.key)}`);return Y`
<li
class="facet ${this.useRadios?"radio":"checkbox"} ${s.active?"selected":""}"
>
<input
type="${this.useRadios?"radio":"checkbox"}"
id=${e}
name="${s.key}"
value="${s.key}"
.checked=${s.active??!1}
?checked=${s.active??!1}
@click=${()=>this.applyFacet(this.urlAlias,s.key)}
/>
<label for="${e}"
>${s.label}${this.showCount?` (${s.count})`:null}</label
>
</li>
`}))}
</ul>
`}render(){return super.render(),this.shouldRender()?this.collapsible?this.wrapCollapsible(this._getCollapsibleLabelElement(),Y`${this._getOptions()} ${this._getResetElement()}`):Y`
${this.showLabel?this._getLabelElement():null} ${this._getOptions()}
${this._getResetElement()}
`:null}};Mt([E({type:Boolean})],Ht.prototype,"useRadios",void 0),Ht=Mt([o("facet-checkbox")],Ht);var Dt=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let qt=class extends Tt{constructor(){super(...arguments),this.selectLabel="Choose an option"}connectedCallback(){super.connectedCallback(),this.selectLabel=this._configOrAttribute(this.facet?.settings.widget.useRadios,this.selectLabel)}applyFacet(t,s,e=!1){s?super.applyFacet(t,s,e):this.clearFacet(t)}_getLabelElementSelect(){const t=this._getFacetData(),s=this.overrideLabel?this.overrideLabel:t.label;return Y`<label
for="facet-select-${this.uid}"
class="facet-label ${t.key}"
>${s}</label
>`}_getOptionElement(t){return Y` <option
value=${t.key}
?selected=${t.active??!1}
>
${t.label}${this.showCount?` (${t.count})`:null}
</option>`}_getAllOptionsElements(){const t=this._getFacetData();return Y`
<option value="" ?selected="${(t.active_values?.length??0)<=0}">
${this.selectLabel}
</option>
${Ct(t.results,(t=>t.key),(t=>Y`${this._getOptionElement(t)}`))}
`}_getSelectElement(){return Y`
<select
id="facet-select-${this.uid}"
@change="${t=>{const s=t.currentTarget;this.applyFacet(this.urlAlias,s.value,!0)}}"
>
${this._getAllOptionsElements()}
</select>
`}render(){return super.render(),this.shouldRender()?this.collapsible?this.wrapCollapsible(this._getCollapsibleLabelElement(),Y`${this._getSelectElement()} ${this._getResetElement()}`):Y` ${this.showLabel?this._getLabelElementSelect():null}
${this._getSelectElement()} ${this._getResetElement()}`:null}};Dt([E()],qt.prototype,"selectLabel",void 0),qt=Dt([o("facet-dropdown")],qt);
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const Bt=(t,s)=>{const e=t._$AN;if(void 0===e)return!1;for(const t of e)t._$AO?.(s,!1),Bt(t,s);return!0},Ft=t=>{let s,e;do{if(void 0===(s=t._$AM))break;e=s._$AN,e.delete(t),t=s}while(0===e?.size)},Nt=t=>{for(let s;s=t._$AM;t=s){let e=s._$AN;if(void 0===e)s._$AN=e=new Set;else if(e.has(t))break;e.add(t),Kt(s)}};function It(t){void 0!==this._$AN?(Ft(this),this._$AM=t,Nt(this)):this._$AM=t}function Wt(t,s=!1,e=0){const i=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(s)if(Array.isArray(i))for(let t=e;t<i.length;t++)Bt(i[t],!1),Ft(i[t]);else null!=i&&(Bt(i,!1),Ft(i));else Bt(this,t)}const Kt=t=>{t.type==Ot&&(t._$AP??=Wt,t._$AQ??=It)};class Vt extends _t{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,s,e){super._$AT(t,s,e),Nt(this),this.isConnected=t._$AU}_$AO(t,s=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),s&&(Bt(this,t),Ft(this))}setValue(t){if((t=>void 0===t.strings)(this._$Ct))this._$Ct._$AI(t,this);else{const s=[...this._$Ct._$AH];s[this._$Ci]=t,this._$Ct._$AI(s,this,0)}}disconnected(){}reconnected(){}}
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const zt=()=>new Jt;class Jt{}const Zt=new WeakMap,Qt=xt(class extends Vt{render(t){return st}update(t,[s]){const e=s!==this.G;return e&&void 0!==this.G&&this.ot(void 0),(e||this.rt!==this.lt)&&(this.G=s,this.ct=t.options?.host,this.ot(this.lt=t.element)),st}ot(t){if("function"==typeof this.G){const s=this.ct??globalThis;let e=Zt.get(s);void 0===e&&(e=new WeakMap,Zt.set(s,e)),void 0!==e.get(this.G)&&this.G.call(this.ct,void 0),e.set(this.G,t),void 0!==t&&this.G.call(this.ct,t)}else this.G.value=t}get rt(){return"function"==typeof this.G?Zt.get(this.ct??globalThis)?.get(this.G):this.G?.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}});var Gt=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};const Xt=t=>{class s extends t{constructor(){super(...arguments),this.htmlSelectLabel="Choose an option",this.multipleSelect=!1,this.dropdownOpen=!1,this.required=!1,this.focusedOption=null,this.focusOnOpen=!1,this.searchTerm="",this.inputRef=zt(),this.listboxRef=zt(),this.selectActions={Close:0,CloseSelect:1,First:2,Last:3,Next:4,Open:5,PageDown:6,PageUp:7,Previous:8,Select:9,Type:10}}updated(t){super.updated(t),this.focusOnOpen&&(this._setOptionFocus(this._getNextOption(this.selectActions.First)),this.focusOnOpen=!1)}getHtmlLabel(){return""}getOptionId(t){const s=this.safeIdentifier(this.getOptionKey(t));return`option-${this.uid}-${s}`}getOptionKey(t){return""}getOptionValue(t){return""}getOptionLabel(t){return""}getAllOptions(){return[]}isOptionSelected(t){return!0}hasSelectedOptions(){return!1}getHtmlSelectLabel(){return this.htmlSelectLabel}optionMouseDown(t,s){t.preventDefault()}clearSelection(t){t.preventDefault()}applySelection(t){}getSelectedOptions(){return[]}filterOptions(t){return[]}_getHtmlLabelElement(){return this.getHtmlLabel()?Y`<label id="combo-label-${this.uid}" class="combo-label"
>${this.getHtmlLabel()}</label
>`:Y``}_getOptionElement(t){return Y`
<div
role="option"
id=${this.getOptionId(t)}
class="combo-option ${this.isOptionSelected(t)?"selected":null}"
aria-selected="${this.isOptionSelected(t)}"
@mousedown=${s=>this.optionMouseDown(s,t)}
data-value="${this.getOptionValue(t)}"
>
${this.getOptionLabel(t)}
</div>
`}_getAllOptionsElements(){return Y`
<div
role="option"
id="select-label-${this.uid}"
class="combo-option combo-option-label${this.required?" disabled":null}"
aria-selected=${!this.hasSelectedOptions()}
@mousedown=${this.required?null:this.clearSelection}
aria-disabled="${this.required}"
>
${this.htmlSelectLabel}
</div>
${Ct(this.getAllOptions(),(t=>this.getOptionId(t)),(t=>this._getOptionElement(t)))}
`}_getHtmlSelectLabelElement(){return Y`
<div
${Qt(this.inputRef)}
id="combo-input-${this.uid}"
role="combobox"
tabindex="0"
class="combo-input ${this.dropdownOpen?"open":null}"
aria-controls="combo-listbox-${this.uid}"
aria-expanded="${this.dropdownOpen}"
aria-haspopup="listbox"
aria-labelledby="combo-label-${this.uid}"
@blur=${this.close}
@focusout=${this.close}
@click=${this.toggleDropdown}
@keydown=${t=>this.onSelectKeyDown(t)}
>
${this.getHtmlSelectLabel()}
</div>
`}_getHtmlSelectElement(){return Y`
<div
${Qt(this.listboxRef)}
class="combo-options ${this.dropdownOpen?"open":null}"
role="listbox"
id="combo-listbox-${this.uid}"
aria-labelledby="combo-label-${this.uid}"
tabindex="-1"
>
${this.dropdownOpen?this._getAllOptionsElements():null}
</div>
`}close(){this.dropdownOpen=!1,this.focusedOption=null}_getActionFromKey(t){const{key:s,altKey:e,ctrlKey:i,metaKey:n}=t;if(!this.dropdownOpen&&["ArrowDown","ArrowUp","Enter"," "].includes(s))return this.selectActions.Open;if("Home"===s)return this.selectActions.First;if("End"===s)return this.selectActions.Last;if("Backspace"===s||"Clear"===s||1===s.length&&" "!==s&&!e&&!i&&!n)return this.selectActions.Type;if(this.dropdownOpen){if("ArrowUp"===s&&e)return this.selectActions.CloseSelect;if("ArrowDown"===s&&!e)return this.selectActions.Next;if("ArrowUp"===s)return this.selectActions.Previous;if("PageUp"===s)return this.selectActions.PageUp;if("PageDown"===s)return this.selectActions.PageDown;if("Escape"===s)return this.selectActions.Close;if("Enter"===s||" "===s)return this.selectActions.CloseSelect}return-1}onSelectKeyDown(t){const{key:s}=t,e=this._getActionFromKey(t);switch(e){case this.selectActions.Last:case this.selectActions.First:case this.selectActions.Next:case this.selectActions.Previous:case this.selectActions.PageUp:case this.selectActions.PageDown:t.preventDefault(),this._setOptionFocus(this._getNextOption(e));break;case this.selectActions.CloseSelect:t.preventDefault(),this.applySelection(t),this.multipleSelect||this.close();break;case this.selectActions.Close:t.preventDefault(),this.dropdownOpen=!1;break;case this.selectActions.Type:this._typeSearch(s);break;case this.selectActions.Open:t.preventDefault(),this.focusOnOpen=!0,this.dropdownOpen=!0}}toggleDropdown(){const t=this.getSelectedOptions();this.dropdownOpen=!this.dropdownOpen,this.dropdownOpen?t.length>0&&this.inputRef.value?.setAttribute("aria-activedescendant",this.getOptionId(t[0])):this.inputRef.value?.removeAttribute("aria-activedescendant")}_typeSearch(t){this.dropdownOpen=!0;const s=this._getSearchTerm(t),e=this._searchOptions(s);if(!e)return window.clearTimeout(this.searchTimeout),void(this.searchTerm="");this._setOptionFocus(e)}_searchOptions(t){const s=this.filterOptions(t),e=t.split(""),i=e.every((t=>t===e[0]));if(0!==s.length||i){if(s[0])return this.getOptionId(s[0]);if(i){const t=this.filterOptions(e[0]);if(0===t.length)return;return this.getOptionId(t[(e.length-1)%t.length])}}}_getNextOption(t){const s=this.getAllOptions(),e=`select-label-${this.uid}`;if(!this.focusedOption)return e;let i=s.findIndex((t=>this.focusedOption?.id===this.getOptionId(t)));i=-1===i?0:i+1;const n=s.length+1;let r;switch(t){case this.selectActions.First:r=0;break;case this.selectActions.Last:r=n-1;break;case this.selectActions.Previous:r=Math.max(0,i-1);break;case this.selectActions.Next:r=Math.min(n,i+1);break;case this.selectActions.PageUp:r=Math.max(0,i-10);break;case this.selectActions.PageDown:r=Math.min(n-1,i+10);break;default:r=i}return 0===r?e:this.getOptionId(s[r-1])}_getSearchTerm(t){return"number"==typeof this.searchTimeout&&window.clearTimeout(this.searchTimeout),this.searchTimeout=window.setTimeout((()=>{this.searchTerm=""}),500),this.searchTerm+=t,this.searchTerm}_elementInView(t){const s=this.querySelector(`#${t}`);if(!s)return!0;var e=s.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}_isScrollable(){const t=this.listboxRef.value;return void 0!==t&&t.clientHeight<t.scrollHeight}_maintainScrollVisibility(t){const s=this.querySelector(`#${t}`),e=this.listboxRef.value;if(!e)return;const{offsetHeight:i,offsetTop:n}=s,{offsetHeight:r,scrollTop:h}=e,o=n+i>h+r;n<h?e.scrollTo(0,n):o&&e.scrollTo(0,n-r+i)}_setOptionFocus(t){this.focusedOption=this.querySelector(`#${t}`),this.inputRef.value?.setAttribute("aria-activedescendant",t),this.listboxRef.value?.querySelectorAll(".focused")?.forEach((t=>{t.classList.remove("focused")})),this.focusedOption?.classList.add("focused"),this._isScrollable()&&this._maintainScrollVisibility(t),this._elementInView(t)||this.focusedOption?.scrollIntoView({behavior:"smooth",block:"nearest"}),this.inputRef.value?.focus()}}return Gt([E()],s.prototype,"htmlSelectLabel",void 0),Gt([E({type:Boolean})],s.prototype,"multipleSelect",void 0),Gt([A()],s.prototype,"dropdownOpen",void 0),Gt([E({type:Boolean})],s.prototype,"required",void 0),Gt([A()],s.prototype,"focusedOption",void 0),Gt([A()],s.prototype,"focusOnOpen",void 0),Gt([A()],s.prototype,"searchTimeout",void 0),Gt([A()],s.prototype,"searchTerm",void 0),s};var Yt=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let ts=class extends(Xt(Tt)){connectedCallback(){super.connectedCallback(),this.htmlSelectLabel=this._configOrAttribute(this.facet?.settings.widget.useRadios,this.htmlSelectLabel),this.required=this._configOrAttribute(this.facet?.settings.widget.useRadios,this.required),this.multipleSelect=this._configOrAttribute(this.facet?.settings.widget.useRadios,this.multipleSelect)}applyFacet(t,s,e=!1){super.applyFacet(t,s,!this.multipleSelect),this.multipleSelect||this.close()}getHtmlLabel(){return this.overrideLabel?this.overrideLabel:this._getFacetData().label}getOptionKey(t){return t.key}getOptionValue(t){return t.key}getOptionLabel(t){return`${t.label}${this.showCount?` (${t.count})`:""}`}getAllOptions(){return this._getFacetData().results}isOptionSelected(t){return t.active??!1}hasSelectedOptions(){return(this._getFacetData()?.active_values?.length??0)>0}getHtmlSelectLabel(){if(this.hasSelectedOptions()){return this.getSelectedOptions().map((t=>t.label)).join(", ")}return this.htmlSelectLabel}optionMouseDown(t,s){t.preventDefault(),this.applyFacet(this.urlAlias,s.key)}clearSelection(t){t.preventDefault(),this.clearFacet(this.urlAlias),this.close()}applySelection(t){this.focusedOption&&this.focusedOption.dataset.value?this.applyFacet(this.urlAlias,this.focusedOption.dataset.value):(this.clearFacet(this.urlAlias),this.close())}getSelectedOptions(){return this._getFacetData().results.filter((t=>t.active))}filterOptions(t){return this.getAllOptions().filter((s=>s.label.toLowerCase().startsWith(t)))}render(){return super.render(),this.shouldRender()?this.collapsible?this.wrapCollapsible(this._getCollapsibleLabelElement(),Y`${this._getHtmlSelectLabelElement()}
${this._getHtmlSelectElement()} ${this._getResetElement()}`):Y`
${this.showLabel?this._getHtmlLabelElement():null}
${this._getHtmlSelectLabelElement()} ${this._getHtmlSelectElement()}
${this._getResetElement()}
`:null}};ts=Yt([o("facet-dropdown-html")],ts);var ss=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let es=class extends yt{constructor(){super(...arguments),this.removeText="Remove @value",this.resetText="Reset (@count)",this.showReset=!1,this.showIndividual=!1}_getApplied(){const t=[],s=this?.context?.query;if(!s)return t;for(const[e,i]of s.entries()){if(!e.startsWith("f:"))continue;const s=i.split(","),n=e.replace("f:","");s.forEach((s=>{t.push({key:e,facetKey:n,value:s})}))}return t}_getResetElement(){return Y`
<li class="applied reset">
<button class="applied-button-reset" @click=${()=>this.clearFacets()}>
${this.resetText.replaceAll("@count",""+this._getApplied().length)}
</button>
</li>
`}_getIndividualFacets(t){return Y`
${Ct(t,(t=>`${t.key}:${t.value}`),(t=>{const s=this.removeText.replace("@value",t.value);return Y`
<li class="applied facet">
<div @click=${()=>this.applyFacet(t.facetKey,t.value)}>
${t.value}
</div>
<button
@click=${()=>this.applyFacet(t.facetKey,t.value)}
class="applied-button-remove"
>
${s}
</button>
</li>
`}))}
`}render(){if(!this.context?.response)return null;const t=this._getApplied();return 0===t.length?null:Y`
<ul class="applied-facets">
${this.showIndividual?this._getIndividualFacets(t):null}
${this.showReset?this._getResetElement():null}
</ul>
`}};ss([E()],es.prototype,"removeText",void 0),ss([E()],es.prototype,"resetText",void 0),ss([E({type:Boolean})],es.prototype,"showReset",void 0),ss([E({type:Boolean})],es.prototype,"showIndividual",void 0),es=ss([o("search-applied-facets")],es);var is=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let ns=class extends $t{constructor(){super(...arguments),this.url="",this.submitText="Search",this.ariaLabelText="",this.placeHolderText=""}createRenderRoot(){return this.style.display="block",this}_submit(t){t.preventDefault(),t.currentTarget instanceof Element&&window.location.replace(this.url+"?q="+t?.currentTarget?.querySelector("input")?.value?.trim())}render(){return Y`
<form class="search-box" @submit="${t=>this._submit(t)}">
<input
class="search-box-input"
type="text"
placeholder="${this.placeHolderText}"
aria-label="${this.ariaLabelText}"
/>
<button class="search-box-submit" type="submit">
${this.submitText}
</button>
</form>
`}};is([E({attribute:!0})],ns.prototype,"url",void 0),is([E({attribute:!0})],ns.prototype,"submitText",void 0),is([E({attribute:!0})],ns.prototype,"ariaLabelText",void 0),is([E({attribute:!0})],ns.prototype,"placeHolderText",void 0),ns=is([o("search-box")],ns);var rs=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let hs=class extends yt{constructor(){super(...arguments),this.placeHolderText="",this.labelText="",this.clearText="Remove"}_querySearch(t){t.preventDefault();const s=this.querySelector("input"),e=s?.value.trim(),i=new URLSearchParams;e?i.set("q",e??""):i.delete("q"),this.getResults(i)}_clearSearch(){const t=new URLSearchParams;this.getResults(t)}render(){return Y`
<form class="search-input" @submit="${this._querySearch}">
<span>
<input
class="search-input-input"
type="text"
.value="${this?.context?.query?.get("q")??""}"
placeholder="${this.placeHolderText}"
/>
${this?.context?.query?.get("q")?Y`<button
class="search-input-clear"
type="button"
@click=${()=>{this._clearSearch()}}
>
${this.clearText}
</button>`:null}
</span>
<button class="search-input-submit" type="submit">
${this.labelText}
</button>
</form>
`}};rs([E()],hs.prototype,"placeHolderText",void 0),rs([E()],hs.prototype,"labelText",void 0),rs([E()],hs.prototype,"clearText",void 0),hs=rs([o("search-input")],hs);var os=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let ls=class extends yt{createRenderRoot(){return this.style.display="none",this}render(){if(!this.context?.responseReady)return null;const t=this.context?.response?.search_results_count;return t?(this.classList.add("no-results-hidden"),this.classList.remove("no-results-visible"),this.style.setProperty("display","none")):(this.classList.add("no-results-visible"),this.classList.remove("no-results-hidden"),this.style.removeProperty("display")),""}};ls=os([o("search-no-results-message")],ls);var cs=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let as=class extends yt{constructor(){super(...arguments),this.data={}}render(){return Y`
<details open style="overflow-x: scroll">
<summary>Item</summary>
<pre>${JSON.stringify(this.data,null,2)}</pre>
</details>
`}};cs([E({attribute:!0,type:Object})],as.prototype,"data",void 0),as=cs([o("search-result-element-default")],as);
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
class us extends _t{constructor(t){if(super(t),this.et=st,t.type!==Ot)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===st||null==t)return this.vt=void 0,this.et=t;if(t===tt)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.et)return this.vt;this.et=t;const s=[t];return s.raw=s,this.vt={_$litType$:this.constructor.resultType,strings:s,values:[]}}}us.directiveName="unsafeHTML",us.resultType=1;const ds=xt(us);var ps=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let fs=class extends yt{constructor(){super(...arguments),this.settings={},this.data={}}render(){return this?.settings?.field&&this.data&&this.data[this?.settings?.field]?Y`${ds(this.data[this?.settings.field])}`:null}};ps([E({type:Object})],fs.prototype,"settings",void 0),ps([E({type:Object})],fs.prototype,"data",void 0),fs=ps([o("search-result-element-rendered")],fs);var bs=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let vs=class extends yt{constructor(){super(...arguments),this.summaryText="@start - @end of @total"}_getNumbers(){const t=this.context?.response?.search_results_page??0,s=parseInt(this.context?.response?.search_results_per_page?this.context?.response.search_results_per_page:this.context?.defaultPerPage),e=this.context?.response?.search_results_count,i=t*s,n={start:0,end:0,total:e};n.start=0===e?0:t*s+1;const r=+i+s;return n.end=r>e?e:r,n}_getSummaryElement(){const t=this._getNumbers(),s=this.context?.response?.took?this.context?.response?.took/1e3:"",e=this.summaryText.replaceAll("@start",""+t.start).replaceAll("@end",""+t.end).replaceAll("@total",""+t.total).replaceAll("@searchQuery",this.context?.query?.get("q")??"").replaceAll("@time",""+s);return Y`${e}`}render(){return this.context?.response?Y`<div>${this._getSummaryElement()}</div>`:null}};bs([E()],vs.prototype,"summaryText",void 0),vs=bs([o("search-result-summary")],vs);
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const $s=Symbol.for(""),ms=t=>{if(t?.r===$s)return t?._$litStatic$},gs=new Map,ys=(t=>(s,...e)=>{const i=e.length;let n,r;const h=[],o=[];let l,c=0,a=!1;for(;c<i;){for(l=s[c];c<i&&void 0!==(r=e[c],n=ms(r));)l+=n+s[++c],a=!0;c!==i&&o.push(r),h.push(l),c++}if(c===i&&h.push(s[i]),a){const t=h.join("$$lit$$");void 0===(s=gs.get(t))&&(h.raw=h,gs.set(t,s=h)),e=o}return t(s,...e)})(Y);var ws=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let Ss=class extends yt{constructor(){super(...arguments),this.resultField="",this.mappings=[],this.configLoaded=!1,this.processedMappings={}}updated(t){!this.configLoaded&&this.context?.responseReady&&(this.resultField||(this.resultField=this.context.response?.swc_results.field??""),0===this.mappings.length&&(this.mappings=this.context.response?.swc_results.mappings??[]),this.mappings.forEach((t=>{t.keys.forEach((s=>{this.processedMappings[s]={element:t.element,settings:t.settings}}))})),this.configLoaded=!0)}_mapResult(t){return this.processedMappings[`${t[this.resultField]}-${this.context?.resultDisplay}`]?this.processedMappings[`${t[this.resultField]}-${this.context?.resultDisplay}`]:this.processedMappings[`default-${this.context?.resultDisplay}`]?this.processedMappings[`default-${this.context?.resultDisplay}`]:this.processedMappings[t[this.resultField]]?this.processedMappings[t[this.resultField]]:this.processedMappings.default?this.processedMappings.default:void console.warn("No element mapping found for: ",t)}_getResults(){const t=this.context?.response?.search_results??[];return 0===t.length?null:ys`
<div>
<ul class="${this.context?.resultDisplay}">
${Ct(t,(t=>t.id),(t=>{const s=this._mapResult(t);return s?customElements.get(s.element)?ys`<li
class="result-${this.safeIdentifier(t[this.resultField])}"
>
<${(t=>({_$litStatic$:t,r:$s}))(s.element)}
.data=${t}
.settings=${s.settings}
/>
</li>`:(console.warn(s.element+" is not defined as a custom element for element mapping:",t),null):null}))}
</ul>
</div>
`}render(){return this.configLoaded?ys`${this._getResults()} `:null}};ws([E()],Ss.prototype,"resultField",void 0),ws([E({type:Object})],Ss.prototype,"mappings",void 0),ws([A()],Ss.prototype,"configLoaded",void 0),ws([A()],Ss.prototype,"processedMappings",void 0),Ss=ws([o("search-results")],Ss);var Os=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let xs=class extends(Xt(yt)){constructor(){super(...arguments),this.required=!0,this.type="select",this.labelText="Per page",this.options=[],this.indexConfigLoaded=!1}updated(t){!this.indexConfigLoaded&&this.context?.responseReady&&(this.indexConfigLoaded=!0,0===this.options.length&&this.context.response?.swc_page_sizes&&(this.options=this.context.response?.swc_page_sizes))}_queryPerPage(t){const s=new URLSearchParams(this.context?.query?.toString()??""),e=""+this?.context?.defaultPerPage,i=""+this?.context?.response?.search_results_per_page;t?s.set("limit",t):s.set("limit",e),t!==i&&s.delete("page"),t===e&&s.delete("limit"),this.getResults(s)}_getSelected(){const t=""+this?.context?.defaultPerPage,s=""+this?.context?.response?.search_results_per_page;let e=this.options.find((s=>s.key===t));return this.context?.response?.search_results_per_page&&(e=this.options.find((t=>t.key===s))),e}_getSelectOption(){return Y` ${Ct(this.options,(t=>t.key),(t=>Y`<option
value=${t.key}
?selected=${this._getSelected()?.key===t.key}
>
${t.label}
</option>`))}`}_getListOption(){return Y` ${Ct(this.options,(t=>t.key),(t=>Y`<li>
<button
class="${this._getSelected()?.key===t.key?"selected":null}"
value=${t.key}
@click=${s=>{s.preventDefault(),this._queryPerPage(""+t.key)}}
>
${t.label}
</button>
</li>`))}`}_getSelect(){return Y`
${this.labelText?Y`<label for="per-page-${this.uid}">${this.labelText}</label>`:null}
<select
id="per-page-${this.uid}"
name="result count"
@change="${t=>{t.preventDefault();const s=t.currentTarget.value;this._queryPerPage(s)}}"
required
>
${this._getSelectOption()}
</select>
`}_getList(){return Y`
${this.labelText?Y`<label for="per-page-${this.uid}">${this.labelText}</label>`:null}
<ul id="sort-${this.uid}">
${this._getListOption()}
</ul>
`}_getHtml(){return Y`
${this._getHtmlLabelElement()} ${this._getHtmlSelectLabelElement()}
${this._getHtmlSelectElement()}
`}render(){if(0===this.options.length||!this.context?.response)return null;switch(this.type){case"select":return this._getSelect();case"list":return this._getList();case"html":return this._getHtml()}}getHtmlLabel(){return this.labelText}getOptionKey(t){return t.key?""+t.key:""+t.value}getOptionValue(t){return t.value?""+t.value:""+t.key}getOptionLabel(t){return""+t.label}getAllOptions(){return this.options}isOptionSelected(t){const s=this._getSelected();return!!s&&this.getOptionValue(s)===this.getOptionValue(t)}hasSelectedOptions(){return!!this._getSelected()}getHtmlSelectLabel(){return this._getSelected()?""+this._getSelected()?.label:this.htmlSelectLabel}optionMouseDown(t,s){t.preventDefault(),this._queryPerPage(""+this.getOptionValue(s)),this.close()}applySelection(t){this.focusedOption&&this.focusedOption.dataset.value&&this._queryPerPage(this.focusedOption.dataset.value)}getSelectedOptions(){const t=this._getSelected();return t?[t]:[]}filterOptions(t){return this.getAllOptions().filter((s=>(""+s.label).toLowerCase().startsWith(t)))}};Os([E()],xs.prototype,"type",void 0),Os([E()],xs.prototype,"labelText",void 0),Os([E({type:Array})],xs.prototype,"options",void 0),Os([A()],xs.prototype,"indexConfigLoaded",void 0),xs=Os([o("search-results-per-page")],xs);var _s=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let ks=class extends yt{constructor(){super(...arguments),this.prevLabel="<",this.nextLabel=">",this.showNextPrev=!1,this.showFirstLast=!1,this.firstLabel="First page",this.lastLabel="Last page",this.pagesToDisplay=0}_changePage(t){const s=new URLSearchParams(this.context?.query?.toString()??"");0!==t?s.set("page",""+t):s.delete("page"),this.getResults(s)}_getCurrentPageElement(){const t=this.context?.response?.search_results_page??0;return ys`<button class="page current" aria-pressed="true">
${t+1}
</button>`}_getWrappingPagesElements(){const t=[],s=[],e=this.context?.response?.search_results_page??0,i=this.context?.response?.search_results_pages??0;for(let n=1;n<=this.pagesToDisplay;n++)e-n>=0&&t.unshift(ys` <button
class="prev page"
@click=${()=>this._changePage(e-n)}
>
${e-n+1}
</button>`),e+n<i&&s.push(ys` <button
class="next page"
@click=${()=>this._changePage(e+n)}
>
${e+n+1}
</button>`);return{prev:t,next:s}}_getWrappingButtonElements(){const t=this.context?.response?.search_results_page??0,s=this.context?.response?.search_results_pages??0,e=ys` ${this.showNextPrev?ys` <button
class="prev"
?disabled=${0===t}
@click=${()=>this._changePage(t-1)}
>
${this.prevLabel}
</button>`:null}`;return{next:ys` ${this.showNextPrev?ys` <button
class="next"
?disabled=${t===s-1}
@click=${()=>this._changePage(t+1)}
>
${this.nextLabel}
</button>`:null}`,prev:e,first:ys` ${this.showFirstLast&&0!==t?ys`<button class="first" @click=${()=>this._changePage(0)}>
${this.firstLabel}
</button>`:null}`,last:ys` ${this.showFirstLast&&t!==s-1?ys`<button
class="last"
@click=${()=>this._changePage(s-1)}
>
${this.lastLabel}
</button>`:null}`}}render(){const t=this._getWrappingPagesElements(),s=this._getWrappingButtonElements();return ys`
<div class="pager">
${s.first} ${s.prev}
${t.prev.length>0?t.prev:null}
${this._getCurrentPageElement()}
${t.next.length>0?t.next:null}
${s.next} ${s.last}
</div>
`}};_s([E()],ks.prototype,"prevLabel",void 0),_s([E()],ks.prototype,"nextLabel",void 0),_s([E({type:Boolean})],ks.prototype,"showNextPrev",void 0),_s([E({type:Boolean})],ks.prototype,"showFirstLast",void 0),_s([E()],ks.prototype,"firstLabel",void 0),_s([E()],ks.prototype,"lastLabel",void 0),_s([E({type:Number})],ks.prototype,"pagesToDisplay",void 0),ks=_s([o("search-simple-pager")],ks);var Rs=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let js=class extends(Xt(yt)){constructor(){super(...arguments),this.required=!0,this.type="select",this.labelText="Sort",this.sorts=[],this.indexConfigLoaded=!1}updated(t){!this.indexConfigLoaded&&this.context?.responseReady&&(this.indexConfigLoaded=!0,0===this.sorts.length&&this.context.response?.swc_sorts&&(this.sorts=this.context.response?.swc_sorts))}_querySort(t,s){const e=new URLSearchParams(this.context?.query?.toString()??"");t?(e.set("sort",t),e.set("order",s)):(e.delete("sort"),e.delete("order")),this.getResults(e)}_getSelected(){const t=this.context?.query?.get("sort")+"|"+this.context?.query?.get("order");let s={label:"Relevance",key:"search_api_relevance",order:"desc"};return this.sorts.find((s=>`${s.key}|${s.order}`===t))&&(s=this.sorts.find((s=>`${s.key}|${s.order}`===t))),s}_getSelectOptions(){const t=this._getSelected(),s=t?.key+"|"+t?.order;return Y`${Ct(this.sorts,(t=>t.key),(t=>{const e=t.key+"|"+t.order;return Y`<option value=${e} ?selected=${e===s}>
${t.label}
</option>`}))}`}_getListOptions(){const t=this._getSelected(),s=t?.key+"|"+t?.order;return Y`${Ct(this.sorts,(t=>t.key),(t=>{const e=t.key+"|"+t.order;return Y`<li>
<button
class="${e===s?"selected":null}"
value=${e}
@click=${s=>{s.preventDefault(),this._querySort(t.key,t.order)}}
>
${t.label}
</button>
</li>`}))}`}_getSelect(){return Y`
${this.labelText?Y`<label for="sort-${this.uid}">${this.labelText}</label>`:null}
<select
id="sort-${this.uid}"
name="sort"
@change="${t=>{t.preventDefault();const s=t.currentTarget,[e,i]=s.value.split("|");this._querySort(e,i)}}"
required
>
${this._getSelectOptions()}
</select>
`}_getList(){return Y`
${this.labelText?Y`<label for="sort-${this.uid}">${this.labelText}</label>`:null}
<ul id="sort-${this.uid}">
${this._getListOptions()}
</ul>
`}_getHtml(){return Y`
${this._getHtmlLabelElement()} ${this._getHtmlSelectLabelElement()}
${this._getHtmlSelectElement()}
`}render(){if(0===this.sorts.length||!this.context?.response)return null;switch(this.type){case"select":return this._getSelect();case"list":return this._getList();case"html":return this._getHtml()}}getHtmlLabel(){return this.labelText}getOptionKey(t){return`${t.key}-${t.order}`}getOptionValue(t){return`${t.key}|${t.order}`}getOptionLabel(t){return""+t.label}getAllOptions(){return this.sorts}isOptionSelected(t){const s=this._getSelected();return!!s&&this.getOptionValue(s)===this.getOptionValue(t)}hasSelectedOptions(){return!!this._getSelected()}getHtmlSelectLabel(){return this._getSelected()?""+this._getSelected()?.label:this.htmlSelectLabel}optionMouseDown(t,s){t.preventDefault(),this._querySort(s.key,s.order),this.close()}applySelection(t){if(this.focusedOption&&this.focusedOption.dataset.value){const[t,s]=this.focusedOption.dataset.value.split("|");this._querySort(t,s)}}getSelectedOptions(){const t=this._getSelected();return t?[t]:[]}filterOptions(t){return this.getAllOptions().filter((s=>(""+s.label).toLowerCase().startsWith(t)))}};Rs([E()],js.prototype,"type",void 0),Rs([E()],js.prototype,"labelText",void 0),Rs([E({type:Array})],js.prototype,"sorts",void 0),Rs([A()],js.prototype,"indexConfigLoaded",void 0),js=Rs([o("search-sort")],js);var Ls=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let Ps=class extends yt{constructor(){super(...arguments),this.displayText="This is some example display text"}render(){return this.context?.response?Y`
<div>
<h2>Example advanced component</h2>
<div>${this.displayText}</div>
<div class="providedby">Provided by <a href="https://git.drupalcode.org/project/umami_search_web_components/-/blob/1.0.x/modules/umami_search_web_components_adv/lit/src/search-example/search-example.ts">umami_search_web_components_adv</a></div>
</div>
`:null}};Ls([E()],Ps.prototype,"displayText",void 0),Ps=Ls([o("search-example")],Ps);var Es=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let As=class extends yt{constructor(){super(...arguments),this.data={},this.settings={}}render(){return Y`
<div>
<div class="details-img">
<div class="image">
<img src="${this.data.image}"/>
</div>
<div class="details">
<h2>
<a href="${this.data.url}" rel="bookmark">
<span class="field field--name-title">${this.data.title}</span>
</a>
</h2>
<ul class="info">
${this.data.servings?Y`<li><span class="label"><strong>Servings: </strong></span><span class="value">${this.data.servings}</span></li>`:null}
${this.data.servings?Y`<li><span class="label"><strong>Difficulty: </strong></span><span class="value">${this.data.difficulty}</span></li>`:null}
${this.data.servings?Y`<li><span class="label"><strong>Prep time: </strong></span><span class="value">${this.data.preparation_time}min</span></li>`:null}
${this.data.servings?Y`<li><span class="label"><strong>Cooking time: </strong></span><span class="value">${this.data.cooking_time}min</span></li>`:null}
</ul>
<div class="summary">
${ds(this.data.summary)}
</div>
<div class="providedby">Provided by <a href="https://git.drupalcode.org/project/umami_search_web_components/-/blob/1.0.x/modules/umami_search_web_components_adv/lit/src/search-result-recipe/search-result-recipe.ts">umami_search_web_components_adv</a></div>
</div>
</div>
</div>
`}};Es([E({type:Object})],As.prototype,"data",void 0),Es([E({type:Object})],As.prototype,"settings",void 0),As=Es([o("search-result-recipe")],As);var Cs=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let Us=class extends Tt{_getOptions(){const t=this._getFacetData();return Y`
<ul>
${Ct(t.results,(t=>t.key),(t=>Y`
<li class="facet button ${t.active?"selected":""}">
<button
class="${this.key}"
type="button"
name="${t.key}"
value="${t.key}"
aria-pressed="${t.active??!1}"
@click=${()=>this.applyFacet(this.urlAlias,t.key)}
>${t.label}${this.showCount?` (${t.count})`:null}
</li>
`))}
</ul>
`}render(){return super.render(),this.shouldRender()?this.collapsible?this.wrapCollapsible(this._getCollapsibleLabelElement(),Y`${this._getOptions()} ${this._getResetElement()}`):Y`
${this.showLabel?this._getLabelElement():null} ${this._getOptions()}
${this._getResetElement()}
`:null}};Us=Cs([o("facet-button")],Us);var Ts=function(t,s,e,i){for(var n,r=arguments.length,h=r<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i,o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(s,e,h):n(s,e))||h);return r>3&&h&&Object.defineProperty(s,e,h),h};let Ms=class extends yt{constructor(){super(...arguments),this.options=[],this.indexConfigLoaded=!1}updated(t){!this.indexConfigLoaded&&this.context?.responseReady&&(this.indexConfigLoaded=!0,0===this.options.length&&this.context.response?.swc_displays&&(this.options=this.context.response?.swc_displays))}_getOptionElement(t){return ys`<li>
<button
class="${t.key} ${t.key===this.context?.resultDisplay?"selected":""}"
aria-pressed="${t.key===this.context?.resultDisplay}"
@click="${()=>{const s={...this.context};s.resultDisplay=""+t.key,this.updateContext(s)}}"
>
${t.label}
</button>
</li>`}_getAllOptions(){return ys` <ul>
${Ct(this.options,(t=>t.key),(t=>ys`${this._getOptionElement(t)}`))}
</ul>`}render(){return ys`${this._getAllOptions()} `}};Ts([E({type:Object})],Ms.prototype,"options",void 0),Ts([A()],Ms.prototype,"indexConfigLoaded",void 0),Ms=Ts([o("search-results-switcher")],Ms);var Hs={SearchRoot:St,FacetButton:Us,FacetCheckbox:Ht,FacetDropdown:qt,FacetDropdownHtml:ts,SearchAppliedFacets:es,SearchBox:ns,SearchInput:hs,SearchNoResultsMessage:ls,SearchResultElementDefault:as,SearchResultElementRendered:fs,SearchResultSummary:vs,SearchResults:Ss,SearchResultsPerPage:xs,SearchResultsSwitcher:Ms,SearchSimplePager:ks,SearchSort:js,SearchExample:Ps,SearchResultRecipe:As};export{Hs as default};
