1"use strict";(self.webpackChunkavocado_mattress=self.webpackChunkavocado_mattress||[]).push([[622],{9241(e,t,r){r.d(t,{A:()=>z});var o=r(1425),i={class:"search-form",action:"/search"},c={class:"input"};var n=["id","value","placeholder","autocomplete"];r(2892);const s={name:"SearchInput",props:{modelValue:{type:[String,Number],default:""},placeholder:{type:String,default:"Search the Store..."},autocomplete:{type:String,default:""},id:{type:String,default:"searchq"}},emits:["update:model-value","keyup","focus"],methods:{onKeyUp:function(){this.$emit("keyup")},onFocus:function(){this.$emit("focus")},updateValue:function(e){this.update(e.target.value)},update:function(e){this.$emit("update:model-value",e)},clearInput:function(){return""!=this.modelValue?this.update(""):""}}};var a=r(6262);const l=(0,a.A)(s,[["render",function(e,t,r,i,c,s){return(0,o.uX)(),(0,o.CE)("input",{class:"search-input input--text",id:r.id,value:r.modelValue,"aria-label":"Search",name:"q",placeholder:r.placeholder,type:"text",maxlength:"50",content:"width=device-width, initial-scale=1.0, maximum-scale=5.0",autofocus:"",autocomplete:r.autocomplete,onInput:t[0]||(t[0]=function(){return s.updateValue&&s.updateValue.apply(s,arguments)}),onFocus:t[1]||(t[1]=function(){return s.onFocus&&s.onFocus.apply(s,arguments)})},null,40,n)}],["__scopeId","data-v-c4f86ada"]]),u=l;var d={key:0,class:"predictive-search-modal__content bg-white"},h={class:"predictive-search__content"},p={class:"predictive-search__products-container"},f={key:0,class:"predictive-search__products-list"},m=["href"],v={key:1,class:"predictive-search__text"};r(2675),r(9463),r(2259),r(5700),r(8706),r(2008),r(1629),r(5276),r(3792),r(2062),r(4782),r(9572),r(7945),r(4185),r(3851),r(1278),r(9432),r(6099),r(3362),r(7764),r(3500),r(2953);var y=["id"],b=["href"],g={class:"product-tile__image"},S=["src","alt"],w={class:"product-tile__title"};var k=r(9198),_=r(9622);function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function j(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=O(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=O(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==O(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const M={name:"ProductTileSimpleB",props:function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach(function(t){j(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({product:{type:Object,required:!0}},(0,_.o)()),computed:{imageUrl:function(){var e=this.product.images[0],t=e.tiny||e.src;return this.imageCrop(this.imageSize(t,"160x160"),"center")},imageAlt:function(){return this.product.images[0].alt}},methods:{imageSize:k.R9,imageCrop:k.CO}},C=(0,a.A)(M,[["render",function(e,t,r,i,c,n){return(0,o.uX)(),(0,o.CE)("div",{class:"product-tile",id:e.id},[(0,o.Lk)("a",{class:"product-tile__link",href:r.product.url},[(0,o.Lk)("div",g,[(0,o.Lk)("img",{src:n.imageUrl,alt:n.imageAlt,width:"50",height:"50",loading:"lazy"},null,8,S)]),(0,o.Lk)("div",w,(0,o.v_)(r.product.title),1)],8,b)],8,y)}],["__scopeId","data-v-52b5eea4"]]);var E=r(810),R=r(8547);function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?T(Object(r),!0).forEach(function(t){V(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function V(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=L(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=L(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==L(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const q={name:"PredictiveSearchModal",components:{ProductTileSimple:C},inject:["mq"],props:{searchTerm:{type:String,default:""}},data:function(){return{searchResults:{},showModal:!1,alignment:"left"}},computed:x(x({},(0,E.n2)(R.eg)),{},{maxResults:function(){return"mobile"===this.mq.current?4:8},searchProducts:function(){var e=this;return this.searchResults.products?this.searchResults.products.filter(function(e){return e.tags.indexOf("hide-product")<0}).slice(0,this.maxResults).map(function(t){return e.mapProductJSON(t)}):[]},modalPosition:function(){return"mobile"===this.mq.current?{}:{left:"left"===this.alignment?"0":"auto",right:"right"===this.alignment?"0":"auto"}},searchTermEncoded:function(){return encodeURIComponent(this.searchTerm)},searchResultsText:function(){var e=this.searchResults.products.length,t=1!==e,r="".concat(e," ").concat(1===e?"RESULT":"RESULTS");return"".concat(t?"ALL ":"").concat(r)}}),watch:{$mq:function(){"mobile"!==this.mq.current&&document.querySelector("body").classList.remove("no-overflow")},searchTerm:function(){this.searchTerm.length<=0&&this.close()}},mounted:function(){var e=this;this.$watch("showModal",function(t){t?(window.addEventListener("resize",e.setModalWidth),document.addEventListener("click",e.handleClickOutside)):(window.removeEventListener("resize",e.setModalWidth),document.removeEventListener("click",e.handleClickOutside))})},unmounted:function(){this.fullOverlayStore.setVisibility(!1)},methods:{handleClickOutside:function(e){var t=e.target;this.showModal&&!(0,k.VZ)(t,["predictive-search-modal","search-form"])&&this.close()},mapProductJSON:function(e){var t;return{title:e.title,handle:e.handle,url:e.url,images:[{src:(null===(t=e.featured_image)||void 0===t?void 0:t.url)||e.image||"",alt:e.title}]}},show:function(){this.searchTerm.length<=0||(this.setModalWidth(),this.showModal=!0,"mobile"!==this.mq.current||document.querySelector("body").classList.add("no-overflow"))},close:function(){this.showModal=!1,document.querySelector("body").classList.remove("no-overflow")},getSearchResults:function(){var e=this;this.show(),this.searchTerm?fetch("/search/suggest.json?q=".concat(this.searchTermEncoded)+"&resources[type]=product,page,article,collection&resources[fields]=title,product_type,variants.title,variants.sku,vendor&resources[options][unavailable_products]=hide").then(function(e){return e.json()}).then(function(t){t&&t.resources&&t.resources.results&&(e.searchResults=e.searchTerm?t.resources.results:{})}).catch(function(e){return console.error("error fetching search results",e.message)}):this.searchResults={}},setModalWidth:function(){if(this.$refs.predictiveSearchModal){var e=this.$refs.predictiveSearchModal,t=e.getBoundingClientRect(),r=e.parentElement;if("mobile"!==this.mq.current){var o=r.getBoundingClientRect(),i=o.left+o.width/2<=window.innerWidth/2?"left":"right";this.alignment=i;var c="left"===this.alignment?window.innerWidth-t.left:t.left+t.width;e.style.width="".concat(c,"px")}else e.style.width=null}}}},F=(0,a.A)(q,[["render",function(e,t,r,i,c,n){var s=(0,o.g2)("product-tile-simple");return(0,o.uX)(),(0,o.CE)("div",{class:"predictive-search-modal",ref:"predictiveSearchModal",style:(0,o.Tr)(n.modalPosition)},[(0,o.bF)(o.eB,{name:"fade-collapse"},{default:(0,o.k6)(function(){return[c.showModal?((0,o.uX)(),(0,o.CE)("div",d,[(0,o.Lk)("div",h,[(0,o.Lk)("div",p,[n.searchProducts.length>0?((0,o.uX)(),(0,o.CE)("div",f,[((0,o.uX)(!0),(0,o.CE)(o.FK,null,(0,o.pI)(n.searchProducts,function(e,t){return(0,o.uX)(),(0,o.CE)("div",{class:(0,o.C4)(["predictive-search__products-list-item",{"predictive-search__products-list-item--link":t===n.maxResults-1}]),key:t},[t<n.maxResults-1?((0,o.uX)(),(0,o.Wv)(s,{key:0,product:e},null,8,["product"])):((0,o.uX)(),(0,o.CE)("a",{key:1,class:"link",href:"/search?type=product&q=".concat(n.searchTermEncoded)},"SEE "+(0,o.v_)(n.searchResultsText),9,m))],2)}
1),128))])):((0,o.uX)(),(0,o.CE)("div",v,'There are no products for "'+(0,o.v_)(r.searchTerm)+'"',1))])])])):(0,o.Q3)("v-if",!0)]}),_:1})],4)}],["__scopeId","data-v-b08dfa2a"]]);var $=r(3483),I=r(9202);const X={name:"SearchForm",components:{SearchInput:u,PredictiveSearchModal:F,VButton:$.A,VIcon:I.A},props:{inputPlaceholder:{type:String,default:""},searchIconSize:{type:String,default:"20px"},searchPageForm:{type:Boolean},enablePredictiveSearch:Boolean,id:{type:String,default:"searchq"}},emits:["close-search"],data:function(){return{searchValue:"",isMounted:!1}},computed:{placeholder:function(){return this.inputPlaceholder||"Search the store..."},showSearchModal:function(){return!!this.isMounted&&this.$refs.predictiveSearchModal.showModal}},mounted:function(){this.isMounted=!0},methods:{closeClick:function(){this.$refs.searchInput.clearInput(),this.enablePredictiveSearch&&this.$refs.predictiveSearchModal.close(),this.$emit("close-search")},showSearchResults:function(){this.$refs.predictiveSearchModal&&this.$refs.predictiveSearchModal.getSearchResults()},closeSearchResults:function(){this.$refs.predictiveSearchModal&&this.$refs.predictiveSearchModal.close()},openSearchResults:function(){this.searchValue.length<=0||this.$refs.predictiveSearchModal||this.$refs.predictiveSearchModal.show()}}},z=(0,a.A)(X,[["render",function(e,t,r,n,s,a){var l=(0,o.g2)("search-input"),u=(0,o.g2)("v-icon"),d=(0,o.g2)("v-button"),h=(0,o.g2)("predictive-search-modal");return(0,o.uX)(),(0,o.CE)("form",i,[t[2]||(t[2]=(0,o.Lk)("input",{type:"hidden",name:"type",value:"article,page,product"},null,-1)),t[3]||(t[3]=(0,o.Lk)("input",{type:"hidden",name:"options[prefix]",value:"last"},null,-1)),(0,o.Lk)("div",c,[t[1]||(t[1]=(0,o.Lk)("label",{class:"u-sr-only",for:"searchq"},"Search",-1)),(0,o.bF)(l,{id:r.id,ref:"searchInput",modelValue:s.searchValue,"onUpdate:modelValue":[t[0]||(t[0]=function(e){return s.searchValue=e}),a.showSearchResults],placeholder:a.placeholder,autocomplete:r.enablePredictiveSearch?"off":"on",onFocus:a.openSearchResults},null,8,["id","modelValue","placeholder","autocomplete","onUpdate:modelValue","onFocus"])]),r.searchPageForm?(0,o.Q3)("v-if",!0):((0,o.uX)(),(0,o.Wv)(d,{key:0,class:"search-form__submit",type:"submit",label:"Search"},{default:(0,o.k6)(function(){return[(0,o.bF)(u,{"fill-class":"svg-muted",name:"search",size:r.searchIconSize},null,8,["size"])]}),_:1})),r.searchPageForm?(0,o.Q3)("v-if",!0):((0,o.uX)(),(0,o.Wv)(d,{key:1,class:"search-form__close",is:"div","aria-label":"Close Search",tabindex:"0",onClick:a.closeClick,onKeyup:(0,o.jR)(a.closeClick,["enter"])},{default:(0,o.k6)(function(){return[(0,o.bF)(u,{class:"color-black","fill-class":"svg-muted",name:"close",size:"28px"})]}),_:1},8,["onClick","onKeyup"])),r.searchPageForm?((0,o.uX)(),(0,o.Wv)(d,{key:2,class:"search-form__submit search-page-form_submit",type:"submit",label:"Search"},{default:(0,o.k6)(function(){return[(0,o.bF)(u,{name:"search",size:"22px"})]}),_:1})):(0,o.Q3)("v-if",!0),r.enablePredictiveSearch?((0,o.uX)(),(0,o.Wv)(h,{key:3,ref:"predictiveSearchModal","search-term":s.searchValue},null,8,["search-term"])):(0,o.Q3)("v-if",!0)])}],["__scopeId","data-v-74cfb392"]])}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.