var q=s=>{throw TypeError(s)};var E=(s,i,e)=>i.has(s)||q("Cannot "+e);var t=(s,i,e)=>(E(s,i,"read from private field"),e?e.call(s):i.get(s)),p=(s,i,e)=>i.has(s)?q("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(s):i.set(s,e),o=(s,i,e,r)=>(E(s,i,"write to private field"),r?r.call(s,e):i.set(s,e),e),L=(s,i,e)=>(E(s,i,"access private method"),e);import{U as M}from"./chunks/Utils.js?ver=1.4.1";import"./chunks/Translator.js?ver=1.4.1";import"./chunks/vue.esm-bundler.js?ver=1.4.1";import"./chunks/Arr.js?ver=1.4.1";import"./chunks/dayjs.min.js?ver=1.4.1";import"./chunks/timezone.js?ver=1.4.1";document.addEventListener("DOMContentLoaded",()=>{var e,r,h,a,c,f,d,w,A,y,k;class s{constructor(l){p(this,y);p(this,e);p(this,r);p(this,h);p(this,a);p(this,c);p(this,f,"");p(this,d,!1);p(this,w,l=>{var m;l.preventDefault();const u=t(this,r),U=(m=t(this,c))==null?void 0:m.value,b=u.value;t(this,A).call(this,U,b)});p(this,A,(l,u)=>{t(this,r).classList.add("is-active"),t(this,d)?t(this,a).parentElement.style.display="none":t(this,a).parentElement.style.display="block";const b=`${window.fluentcart_search_bar_vars.rest.url}/public/product-search/`;if(this.isLinkedWithShopApp()){const n={};u?n.wildcard=u:n.wildcard="",l&&(n["product-categories"]=l),window.fluentCartShopApps[0].applyFilters(n);return}let m=new URL(b);const g={post_title:u,url_mode:t(this,f),termId:l||""};if(Object.keys(g).length>0)for(let[n,S]of Object.entries(g))m.searchParams.append(n,S);const B=m.href;if(u)fetch(B).then(n=>n.json()).then(n=>{const S=n.htmlView;t(this,a).innerHTML=S,t(this,a).parentElement.style.display="block";const v=t(this,a).parentElement.querySelector("h5");v&&(v.style.display="block"),S.trim()===""&&(t(this,a).innerHTML='<li class="is-empty">No results found.</li>',v&&(v.style.display="none"))}).catch(n=>{});else{L(this,y,k).call(this);return}});o(this,e,l),o(this,c,t(this,e).querySelector("[data-fluent-cart-search-bar-app-taxonomy]")),o(this,r,t(this,e).querySelector("[data-fluent-cart-search-bar]")),o(this,h,t(this,e).querySelector("[data-fluent-cart-search-clear]")),o(this,a,t(this,e).querySelector("[data-fluent-cart-search-bar-lists-wrapper]")),o(this,f,t(this,e).dataset.urlMode||""),this.init(),o(this,d,t(this,e).dataset.linkWithShopApp||!1)}isLinkedWithShopApp(){const l=Array.isArray(window.fluentCartShopApps)&&window.fluentCartShopApps.length>0;return t(this,d)&&l}init(){const l=M.debounce(t(this,w),300);t(this,r).addEventListener("keyup",l),t(this,c)&&t(this,c).addEventListener("change",l),t(this,a).parentElement.style.display="none",t(this,r).addEventListener("input",()=>{t(this,r).value.trim()!==""?t(this,h).style.display="block":t(this,h).style.display="none"}),t(this,h).addEventListener("click",()=>{t(this,r).value="",t(this,h).style.display="none",L(this,y,k).call(this)})}}e=new WeakMap,r=new WeakMap,h=new WeakMap,a=new WeakMap,c=new WeakMap,f=new WeakMap,d=new WeakMap,w=new WeakMap,A=new WeakMap,y=new WeakSet,k=function(){t(this,r).classList.remove("is-active"),t(this,a).parentElement.style.display="none",t(this,a).innerHTML="",t(this,d)&&typeof window.fluentCartShopApps<"u"&&window.fluentCartShopApps.length>0&&window.fluentCartShopApps[0].applyFilters({wildcard:"","product-categories":""})},document.querySelectorAll("[data-fluent-cart-search-bar-app-wrapper]").forEach(C=>{new s(C)})});
