iBet uBet web content aggregator. Adding the entire web to your favor.
iBet uBet web content aggregator. Adding the entire web to your favor.



Link to original content: http://ecdb.com/_nuxt/r34_53Kp.js
import{_ as te}from"./wMmrnhvC.js";import{u as ae}from"./Ym6uCvCk.js";import{o,G as u,X as le,d as X,r as d,b7 as se,k as V,z as F,L as J,n as D,w as L,f as t,aa as oe,O as g,C as m,c as O,e as T,V as P,W as K,t as j,at as ne,v as re,aD as ie,aC as k,R as Z,b8 as ue,b9 as de,_ as ce,ba as fe,u as we,D as pe,bb as he,az as Q,P as ge,Q as ve,q as ye,ae as W,T as me,a6 as be,s as Se}from"./llFuKhWI.js";import{T as xe}from"./C-7E03RX.js";import{I as ke,a as Ce}from"./CGuxoV3j.js";import{_ as _e}from"./B-ANVB1o.js";import{C as Ie}from"./CnGBFLmb.js";import{I as $e}from"./bW3CfTUf.js";import{I as Be,a as Y}from"./DsnHU5bB.js";const ze={xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 32 32"},Te=le('',2),Ee=[Te];function He(E,$){return o(),u("svg",ze,[...Ee])}const qe={render:He},Ae={class:"tw-py-1"},Ne=X({__name:"SearchSuggestions",props:{query:{default:""}},emits:["highlightedUrl"],setup(E,{expose:$,emit:a}){const H=a,h=E,q=["Retailers","Countries","Product Categories"],A={Store:{partition:"Retailers",icon:Be},Company:{partition:"Retailers",icon:qe},Marketplace:{partition:"Retailers",icon:$e},Country:{partition:"Countries",icon:Y},Category:{partition:"Product Categories",icon:Y}},x=d(),c=d(),N=se(x),v=d(!1),s=d(!0),f=d({}),n=d(null),R=d("60vh"),B=V(()=>Object.values(f.value).flat().length>0),b=V(()=>q.map(i=>(f.value[i]??[]).map(y=>y.url)).flat()),C=V(()=>b.value.findIndex(i=>i===n.value));async function U(i={}){if(h.query){v.value=!0,r();const{results:y}=await $fetch(Z.API.SEARCH.GET_SUGGESTIONS({},{query:h.query,pagesize:"3"})),_=y.reduce((S,p)=>{const{partition:I}=A[p.type];return I&&(S[I]=[...S[I]??[],p]),S},{});s.value=!!i.hidden,f.value=_,v.value=!1}}const G=ue(()=>U(),de.MS200);function l(){f.value={}}function e(){s.value=!0}function M(){s.value=!1}function r(){n.value=null,H("highlightedUrl",n.value)}function w(i){var _,S;if(!B.value)return;M(),n.value?n.value=b.value[C.value+(i==="next"?1:-1)]:n.value=b.value[i==="next"?0:b.value.length-1];const y=(S=(_=c.value)==null?void 0:_.find(p=>p.$el.getAttribute("href")===n.value))==null?void 0:S.$el;y&&y.scrollIntoView(!1),H("highlightedUrl",n.value)}function ee(){n.value?n.value=null:e()}return F(()=>h.query,()=>{G()}),F([s,()=>h.query],()=>{if(!s.value&&h.query){const i=window.innerHeight-N.bottom.value-10;R.value=i>150?`${i}px`:"100vh"}}),J(()=>{U({hidden:!0})}),$({hideSuggestions:e,showSuggestions:M,highlightNext:()=>w("next"),highlightPrevious:()=>w("previous"),clearHighlight:r,clearSuggestions:l}),(i,y)=>{const _=_e,S=ce;return o(),u("div",{ref_key:"refSearchSuggestions",ref:x,class:"tw-relative tw-w-full",onKeyup:y[0]||(y[0]=k(p=>ee(),["escape"]))},[D(ie,{"enter-active-class":"tw-transition-opacity tw-duration-300 tw-ease-in-out","leave-active-class":"tw-transition-opacity tw-duration-300 tw-ease-in-out","enter-from-class":"tw-opacity-0","leave-to-class":"tw-opacity-0"},{default:L(()=>[!t(s)&&h.query?(o(),u("div",{key:0,class:"tw-z-10 tw-absolute tw-w-full tw-min-w-80 tw-min-h-14 tw-rounded-md tw-border tw-border-bluegray-100 tw-bg-white tw-overflow-y-auto",style:oe({maxHeight:t(R)})},[t(B)?m("",!0):(o(),u("p",{key:0,class:g(["tw-px-5 tw-py-4",{"tw-opacity-25":t(v)}])}," Sorry, we couldn't find any suggestions based on your search input. ",2)),t(v)?(o(),O(_,{key:1,"background-color":("Colors"in i?i.Colors:t(Ie)).bluegray_400},null,8,["background-color"])):m("",!0),T("ul",Ae,[(o(),u(P,null,K(q,p=>{var I;return o(),u(P,null,[(I=t(f)[p])!=null&&I.length?(o(),u("li",{key:p,class:"tw-w-full tw-text-left tw-font-bold tw-px-5 tw-py-2.5"},j(p),1)):m("",!0),(o(!0),u(P,null,K(t(f)[p],z=>(o(),u("li",{key:`${p}${z.url}`},[D(S,{ref_for:!0,ref_key:"refSuggestions",ref:c,to:z.url,class:g(["tw-inline-block tw-cursor-pointer tw-w-full tw-text-left tw-text-bluegray-700 tw-bg-white hover:tw-bg-mint-200 hover:tw-text-mint-900 focus:tw-bg-mint-200 focus:tw-text-mint-900 tw-font-medium tw-px-8 tw-py-2.5 focus:tw-outline-none tw-transition-colors",{"!tw-bg-mint-200 !tw-text-mint-900":t(n)===z.url}])},{default:L(()=>[(o(),O(ne(A[z.type].icon),{class:"tw-inline tw-mr-1 -tw-translate-y-0.25",width:"24",height:"24"})),re(" "+j(z.title),1)]),_:2},1032,["to","class"])]))),128))],64)}),64))])],4)):m("",!0)]),_:1})],544)}}}),Re=["disabled","data-gtm","placeholder","data-testid","aria-describedby"],Ue=["disabled"],Me=["disabled","data-gtm"],Pe=["id"],We=X({__name:"SearchInput",props:{value:{default:""},disabled:{type:Boolean,default:!1},focusOnLoad:{type:Boolean,default:!1},showClearIcon:{type:Boolean,default:!1},showSearchIcon:{type:Boolean,default:!1},showSearchButton:{type:Boolean,default:!1},showSuggestions:{type:Boolean,default:!1},clearOnSearch:{type:Boolean,default:!1},searchAllTypes:{type:Boolean,default:!1},dataGtm:{default:null},placeholder:{default:""},doubleBorder:{type:Boolean,default:!1},size:{default:"default"}},setup(E){const $=ae("$8FSSrExGOj"),a=E,{setAndNavigate:H,filter:h,status:q}=fe(),A=we(),{isNuxtReady:x}=pe(),c=d(),N=d(),v=d(),s=d(a.value),f=d(!1),n=d(null);function R(){var l;s.value="",h.value.type=null,A.name===Z.SEARCH().replace("/","")&&C(),(l=v.value)==null||l.focus()}function B(){var l;(l=v.value)==null||l.select()}function b(){var l;(l=v.value)==null||l.focus()}async function C(){var l;await H({query:s.value.trim(),type:a.searchAllTypes?null:h.value.type,pagesize:h.value.pagesize}),a.clearOnSearch&&(s.value="",(l=c.value)==null||l.clearSuggestions())}function U(){var l,e;n.value?(l=c.value)==null||l.clearHighlight():(e=c.value)==null||e.hideSuggestions()}async function G(){n.value?await Se(n.value):C()}return he(N,()=>{var l;(l=c.value)==null||l.hideSuggestions()}),F(q,l=>{l!=="pending"&&Q(()=>{b()})}),J(()=>{a.focusOnLoad&&Q(()=>{b(),B()})}),(l,e)=>{const M=te;return o(),u(P,null,[T("div",me({ref_key:"refSearchInput",ref:N},l.$attrs,{class:["tw-relative tw-text-bluegray-700 tw-rounded-sm tw-m-auto tw-bg-white tw-max-w-3xl",{"tw-p-0":!a.doubleBorder,"tw-p-1 tw-border tw-border-bluegray-100":a.doubleBorder,"tw-flex tw-flex-wrap":a.showSearchButton}]}),[T("div",{class:g(["tw-relative tw-block",{"tw-grow":a.showSearchButton,"tw-h-14":a.size==="default","tw-h-8":a.size==="small"}])},[ge(T("input",{ref_key:"refInput",ref:v,"onUpdate:modelValue":e[0]||(e[0]=r=>ye(s)?s.value=r:null),class:g(["tw-placeholder-bluegray-400 input tw-h-full",{"tw-rounded-r-none":a.showSearchButton}]),disabled:!t(x)||a.disabled||t(f),"data-gtm":a.dataGtm,placeholder:a.placeholder,"aria-label":"Search","data-testid":("TESTID"in l?l.TESTID:t(xe)).SEARCH.INPUT,"aria-describedby":l.$slots.helpText?`search-input-help-text-${t($)}`:void 0,enterkeyhint:"done",onClick:e[1]||(e[1]=r=>{var w;return B(),(w=t(c))==null?void 0:w.showSuggestions()}),onKeyup:[e[2]||(e[2]=k(r=>G(),["enter"])),e[3]||(e[3]=k(r=>U(),["escape"])),e[6]||(e[6]=k(r=>{var w;return(w=t(c))==null?void 0:w.highlightPrevious()},["up"])),e[7]||(e[7]=k(r=>{var w;return(w=t(c))==null?void 0:w.highlightNext()},["down"]))],onKeydown:[e[4]||(e[4]=k(W(()=>{},["prevent"]),["up"])),e[5]||(e[5]=k(W(()=>{},["prevent"]),["down"]))]},null,42,Re),[[ve,t(s)]]),T("div",{class:g(["tw-absolute tw-right-0 tw-top-0 tw-pr-3 tw-h-full before:tw-content-['full_search_with_⏎'] before:tw-absolute before:tw-text-nowrap before:tw-h-full before:tw-flex before:tw-items-center before:tw-justify-end before:tw-top-0 before:tw-w-96 before:-tw-left-96 before:tw-pointer-events-none before:tw-pr-4",{"before:tw-text-transparent":!t(s)||a.size==="small","before:tw-text-bluegray-300":!!t(s)&&a.size==="default"}])},[a.showClearIcon&&t(s)?(o(),u("button",{key:0,class:"tw-m-0 tw-p-0 tw-mr-2 tw-text-bluegray-400 tw-h-full","aria-label":"Clear search",type:"reset",disabled:!t(x)||a.disabled||t(f),onClick:e[8]||(e[8]=r=>R())},[D(t(ke),{class:g(["is-translateY-1 is-scale-1_2",{"tw-text-bluegray-500":a.size==="small"}]),width:"16"},null,8,["class"])],8,Ue)):m("",!0),a.showSearchIcon?(o(),u("button",{key:1,class:g(["tw-m-0 tw-p-0 tw-mr-2 tw-h-full",{"tw-text-bluegray-400":!t(s),"tw-text-mint":!!t(s)}]),type:"button","aria-label":"Search",disabled:!t(x)||a.disabled||t(f),"data-gtm":a.dataGtm,onClick:e[9]||(e[9]=r=>C())},[D(t(Ce),{class:g(["is-translateY-1 is-scale-1_2",{"tw-text-bluegray-500":a.size==="small"}])},null,8,["class"])],10,Me)):m("",!0)],2)],2),a.showSearchButton?(o(),O(M,{key:0,class:g(["!tw-rounded-l-none",{"!tw-h-14":a.size==="default","!tw-h-8":a.size==="small"}]),size:"large",label:"Search",disabled:!t(x)||a.disabled||t(f),onClick:e[10]||(e[10]=r=>C())},null,8,["class","disabled"])):m("",!0),a.showSuggestions?(o(),O(Ne,{key:1,ref_key:"refSearchSuggestions",ref:c,class:g(a.doubleBorder?"tw-top-3":"tw-top-2"),query:t(s),onHighlightedUrl:e[11]||(e[11]=r=>n.value=r)},null,8,["class","query"])):m("",!0)],16),l.$slots.helpText?(o(),u("div",{key:0,id:`search-input-help-text-${t($)}`,class:"search-input__help-text tw-py-1 tw-cursor-pointer tw-my-0 tw-mx-auto tw-text-gray-500 tw-text-xs tw-max-w-[90%]",onClick:e[12]||(e[12]=r=>b())},[be(l.$slots,"helpText")],8,Pe)):m("",!0)],64)}}});export{qe as I,We as _};