import{_ as k}from"./index.97f2ba43.js";import{_ as N,o as c,s as u,F as f,z as g,m as o,n as _,e as F,N as C,v as y,K as A,L as S,y as v,l as h,q as w,j as O,c as b,w as m,x as $}from"./entry.4a1e3e7a.js";import{_ as P}from"./index.9eeff355.js";import{_ as T}from"./index.b20a02b0.js";import{a as V}from"./algoliasearch.umd.2009ff03.js";import{X as L}from"./x.aa03620d.js";import{_ as B}from"./client-only.954f79ef.js";import"./index.533f36eb.js";import"./ONE_OZ_SALE_STRINGS.14609bc1.js";import"./chevron-down.d9e4ca3d.js";import"./index.362fb190.js";import"./index.fe59aa4c.js";import"./star.657407f3.js";import"./createProductTags.f1acaa5d.js";class z{constructor({algoliaAppId:e,algoliaApiKey:s,searchIndexNames:r,searchOptions:n}){this.client=V(e,s),this.searchIndices={},this.currentIndexName="",this.searchOptions=n,r.forEach(({algoliaName:a,displayName:l,isDefault:i})=>{i&&(this.currentIndexName=l),this.searchIndices[l]=this.client.initIndex(a)})}get searchIndex(){return this.searchIndices[this.currentIndexName]}set searchIndex(e){this.currentIndexName=e}search({facetFilters:e="",filters:s="",query:r=""}){const n=this;return n.searchIndex.search(r,{...n.searchOptions,filters:s,facetFilters:e})}}const G={maxValuesPerFacet:500,sortFacetValuesBy:"alpha",hitsPerPage:1e3,attributesToRetrieve:["objectID","name","custom_url","url_path","image","image_src_set","vanillin_free","phthalate_free","shippable_by_air","diffuser_base_approved","min_price","max_price","display_price","soy_performance","best_for_soy_wax","rating","soap_safe","lotion_safe","no_acceleration","no_discoloration","clean_scent","new_product"],facets:["prop_65_free","diffuser_base_approved","shippable_by_air","lotion_safe","phthalate_free","searchable_categories","searchable_notes","searchable_seasons","soap_safe","vanillin_free","best_for_soy_wax","no_acceleration","no_discoloration","clean_scent"]};class R{constructor({displayName:e,propertyName:s,groupName:r}){this.displayName=e,this.propertyName=s,this.groupName=r}get id(){return this.displayName}}class q extends R{constructor({displayName:e,groupName:s,facetCount:r}){super({displayName:e,propertyName:e,groupName:s}),this.facetCount=r}get filterValue(){return`${this.groupName}:"${this.propertyName}"`}get count(){return this.facetCount}}function x({facetCounts:t,groupName:e}){const s=t[e]||{},r=[];return Object.entries(s).forEach(([n,a])=>{const l=new q({groupName:e,displayName:n,facetCount:a});r.push(l)}),r}class U extends R{constructor({displayName:e,propertyName:s,groupName:r}){super({displayName:e,propertyName:s,groupName:r}),this.facetCount=0}get filterValue(){return`${this.propertyName}:true`}set count(e){this.facetCount=e}get count(){return this.facetCount}inGroup(e){return this.groupName===e}}class H{constructor(){this.facets=[]}register(e){e.forEach(({groupName:s,facets:r})=>{Object.entries(r).forEach(([n,a])=>{const l=new U({displayName:n,propertyName:a,groupName:s});this.facets.push(l)})})}getGroup(e){const s=[];return this.facets.forEach(r=>{r.inGroup(e)&&s.push(r)}),s}updateCounts(e){this.facets.forEach(s=>{const r=e[s.propertyName];r&&r.true?s.count=r.true:s.count=0})}}class X{constructor(){this.staticFacets=new H,this.staticFacets.register([{groupName:"Fragrance Details",facets:{"Clean Scent":"clean_scent","Best for Soy Wax":"best_for_soy_wax","Phthalate Free":"phthalate_free","Prop 65 Free":"prop_65_free","Shippable By Air":"shippable_by_air","Vanillin Free":"vanillin_free"}},{groupName:"Application",facets:{"Diffuser Base Approved":"diffuser_base_approved","Lotion Safe":"lotion_safe","Soap Safe":"soap_safe"}},{groupName:"Soap Making",facets:{"No Acceleration":"no_acceleration","No Discoloration":"no_discoloration"}}])}parse(e){return this.staticFacets.updateCounts(e),[{groupName:"Seasons",facets:x({facetCounts:e,groupName:"searchable_seasons"})},{groupName:"Categories",facets:x({facetCounts:e,groupName:"searchable_categories"})},{groupName:"Fragrance Notes",facets:x({facetCounts:e,groupName:"searchable_notes"})},{groupName:"Fragrance Details",facets:this.staticFacets.getGroup("Fragrance Details")},{groupName:"Application",facets:this.staticFacets.getGroup("Application")},{groupName:"Soap Making",facets:this.staticFacets.getGroup("Soap Making")}]}}const K={Seasons:"facet-group-seasons",Categories:"facet-group-categories","Fragrance Notes":"facet-group-fragrance-notes","Fragrance Details":"facet-group-fragrance-details",Application:"facet-group-application","Soap Making":"facet-group-soap-making"},Y={props:{loading:{type:Boolean,default:!1},facetGroups:{type:Array,required:!0},selectedFilters:{type:Object,required:!0}},data(){return{FACET_CLASS_MAP:K}},methods:{onToggleFilter(t){this.$emit("toggle-filter",t)},toggleFilter(){this.$emit("toggle-filter",{displayName:this.facet.displayName,filterValue:this.facet.filterValue})}}},J=t=>(A("data-v-5ad20e6e"),t=t(),S(),t),Q={class:"facet-sidebar"},Z=J(()=>_("div",{class:"facet-skeleton-title"},null,-1)),W={class:"facet-skeleton-tags"},ee={class:"facet-group-title"},te={class:"facet-siderbar-facets"},se=["aria-pressed","onClick"],ae={class:"facet-sidebar-button-count"};function re(t,e,s,r,n,a){return c(),u("div",Q,[s.loading?(c(!0),u(f,{key:0},g([...Array(5)],l=>(c(),u("div",{key:l,class:"facet-skeleton"},[Z,o(),_("div",W,[(c(!0),u(f,null,g([...Array(5)],i=>(c(),u("div",{key:i,class:"facet-skeleton-tag"}))),128))])]))),128)):F("",!0),o(),(c(!0),u(f,null,g(s.facetGroups,l=>(c(),u("div",{key:l.groupName,class:C([n.FACET_CLASS_MAP[l.groupName],"facet-group"]),onToggleFilter:e[0]||(e[0]=(...i)=>a.onToggleFilter&&a.onToggleFilter(...i))},[l.facets.length>0?(c(),u(f,{key:0},[_("h3",ee,y(l.groupName),1),o(),_("div",te,[(c(!0),u(f,null,g(l.facets,i=>(c(),u("button",{key:i.id,class:C([Object.keys(s.selectedFilters).includes(i.displayName)&&"active","facet-sidebar-button"]),"aria-pressed":Object.keys(s.selectedFilters).includes(i.displayName),onClick:p=>a.onToggleFilter({displayName:i.displayName,filterValue:i.filterValue})},[o(y(i.displayName)+" ",1),_("span",ae,y(i.facetCount),1)],10,se))),128))])],64)):F("",!0)],34))),128))])}const ne=N(Y,[["render",re],["__scopeId","data-v-5ad20e6e"]]);const ce={components:{XIcon:L},props:{selectedFilters:{type:Object,required:!0}},computed:{anyFilters(){return Object.keys(this.selectedFilters).length>0}},methods:{unselectFilter(t,e){this.$emit("toggle-filter",{displayName:e,filterValue:t})}}},oe={class:"filter-row"},ie={key:0},le=["onClick"],ue={class:"at-text"};function de(t,e,s,r,n,a){const l=v("XIcon");return c(),u("fieldset",oe,[a.anyFilters?(c(),u("legend",ie,"Applied filters:")):F("",!0),o(),(c(!0),u(f,null,g(s.selectedFilters,(i,p)=>(c(),u("button",{key:i,class:"filter-row-button",onClick:I=>a.unselectFilter(i,p)},[_("span",ue,y(p)+`. Click to remove this filter. `,1),o(" "+y(p)+" ",1),h(l,{class:"filter-row-button-icon"})],8,le))),128)),o(),a.anyFilters?(c(),u("button",{key:1,class:"filter-row-button filter-row-button-clear",onClick:e[0]||(e[0]=i=>t.$emit("clear-all"))},` Clear All Filters `)):F("",!0)])}const _e=N(ce,[["render",de],["__scopeId","data-v-43e8fc81"]]);const pe={components:{OneOzPromoInfo:k,Select:P,Button:w,Container:O,FacetSidebar:ne,FilterRow:_e,ProductThumb:T},beforeRouteUpdate(){this.search()},props:{searchIndexNames:{type:Array,required:!0}},data(){return{loading:!1,mobileMenuOpen:!1,searchClient:new z({algoliaAppId:this.$config.public.ALGOLIA_APPLICATION_ID,algoliaApiKey:this.$config.public.ALGOLIA_API_KEY,searchIndexNames:this.searchIndexNames,searchOptions:G}),facetParser:new X,fragrances:[],selectedFilters:{},facetGroups:[]}},computed:{resultsCountText(){const t=this.fragrances.length;return t===1?"1 fragrance":`${t} fragrances`},searchIndices(){return Object.keys(this.searchClient.searchIndices)},searchIndicesForSelect(){const t=[];return this.searchIndices.forEach(e=>{t.push({label:e,value:e})}),t},anyResults(){return this.fragrances.length>0}},watch:{selectedFilters(){this.search()},searchIndices(){this.search()},mobileMenuOpen(){this.freezePage()}},created(){this.getParamsFromUrl(),this.search()},activated(){this.getParamsFromUrl(),this.search()},methods:{getParamsFromUrl(){const t=["_kx","utm_medium","utm_source","utm_term","utm_campaign","utm_content"],e=this.$route.query;t.forEach(s=>{delete e[s]}),e.order&&(this.searchClient.searchIndex=e.order,delete e.order),Object.keys(e).length===0?this.selectedFilters={}:this.selectedFilters=e},freezePage(){if(this.$mq.mini.value){const t=document.querySelector("body"),e="fragrance-finder-no-scroll";this.mobileMenuOpen?t.classList.add(e):t.classList.remove(e)}},search(){this.loading=!0,this.searchClient.search({filters:Object.values(this.selectedFilters).join(" AND ")}).then(t=>{this.fragrances=t.hits,this.noteData=t.facets.searchable_notes,this.facetGroups=this.facetParser.parse(t.facets)},t=>{console.error(t)}).finally(()=>{this.loading=!1})},toggleMenu(){this.mobileMenuOpen=!this.mobileMenuOpen},changeSearchIndex(t){this.searchClient.searchIndex=t,this.updateRoutes(),this.search()},clearAll(){this.selectedFilters={},this.updateRoutes()},toggleFilter(t){if(this.selectedFilters[t.displayName]){const e={...this.selectedFilters};delete e[t.displayName],this.selectedFilters=e}else this.selectedFilters={[t.displayName]:t.filterValue,...this.selectedFilters};this.updateRoutes()},updateRoutes(){this.$router.push({query:{order:this.searchClient.currentIndexName,...this.selectedFilters}})},urlFor(t){return t.url_path||`/${t.custom_url}/`}}},M=t=>(A("data-v-fadeb0d4"),t=t(),S(),t),he={class:"fragrance-finder"},fe={class:"fragrance-finder-head"},ge={class:"fragrance-finder-results"},me={class:"fragrance-finder-info-select_wrap"},ye=M(()=>_("span",{class:"fragrance-finder-info-select_wrap-label"}," Sort by: ",-1)),Fe=["value"],be={class:"fragrance-finder-sidebar-head"},Ne=M(()=>_("h2",null,"Filter",-1)),xe={class:"fragrance-finder-sidebar-buttons"},Ce={class:"fragrance-oil-finder-grid"};function ve(t,e,s,r,n,a){const l=k,i=v("FilterRow"),p=w,I=P,j=v("FacetSidebar"),D=T,E=O;return c(),b(E,null,{default:m(()=>[h(l),o(),Object.values(n.selectedFilters).length>0?(c(),b(i,{key:0,"selected-filters":n.selectedFilters,onClearAll:a.clearAll,onToggleFilter:a.toggleFilter},null,8,["selected-filters","onClearAll","onToggleFilter"])):F("",!0),o(),_("div",he,[_("div",fe,[h(p,{layout:"inverted",size:"small",color:"navy",class:"mini-only",onClick:a.toggleMenu},{default:m(()=>[o(` Show Filter `)]),_:1},8,["onClick"]),o(),_("span",ge,y(a.resultsCountText),1)]),o(),_("label",me,[ye,o(),h(I,{class:"fragrance-finder-info-select","model-value":n.searchClient.currentIndexName,"onUpdate:modelValue":a.changeSearchIndex},{default:m(()=>[(c(!0),u(f,null,g(a.searchIndicesForSelect,d=>(c(),u("option",{key:d.value,value:d.value},y(d.label),9,Fe))),128))]),_:1},8,["model-value","onUpdate:modelValue"])]),o(),_("div",{class:C(["fragrance-finder-sidebar",n.mobileMenuOpen&&"fragrance-finder-sidebar-open"])},[_("div",be,[Ne,o(),h(p,{size:"small",color:"gray",onClick:a.toggleMenu},{default:m(()=>[o("Close")]),_:1},8,["onClick"])]),o(),h(j,{loading:n.loading&&!a.anyResults,"facet-groups":n.facetGroups,"selected-filters":n.selectedFilters,onToggleFilter:a.toggleFilter},null,8,["loading","facet-groups","selected-filters","onToggleFilter"]),o(),_("div",xe,[h(p,{size:"small","rounded-corners":!1,disabled:Object.keys(n.selectedFilters).length===0,onClick:a.clearAll},{default:m(()=>[o(` Reset All Filters `)]),_:1},8,["disabled","onClick"]),o(),h(p,{color:"gray",size:"small","rounded-corners":!1,class:"mini-only",onClick:a.toggleMenu},{default:m(()=>[o(` Done `)]),_:1},8,["onClick"])])],2),o(),_("div",Ce,[n.loading&&!a.anyResults?(c(!0),u(f,{key:0},g([...Array(30)],d=>(c(),u("div",{key:d,class:"skeleton"}))),128)):(c(!0),u(f,{key:1},g(n.fragrances,d=>(c(),b(D,{id:d.objectID,key:d.objectID,src:d.image,srcset:d.image_src_set,"price-range":[d.min_price,d.max_price],href:a.urlFor(d),"is-new":d.new_product,name:d.name,rating:Math.round(d.rating),sizes:"175px"},null,8,["id","src","srcset","price-range","href","is-new","name","rating"]))),128))])])]),_:1})}const Ie=N(pe,[["render",ve],["__scopeId","data-v-fadeb0d4"]]),ke=[{displayName:"Alphabetical",algoliaName:"Cs_Fragrance",isDefault:!0},{displayName:"Newest",algoliaName:"Cs_Fragrance_by_newest"},{displayName:"Price: Low to High",algoliaName:"Cs_Fragrance_by_price"},{displayName:"Highest Rated",algoliaName:"Cs_Fragrance_by_reviews"}],Ae={setup(){$({title:"Fragrance Oil Finder"})},data(){return{searchIndexNames:ke}}};function Se(t,e,s,r,n,a){const l=Ie,i=B;return c(),b(i,null,{default:m(()=>[h(l,{"search-index-names":n.searchIndexNames},null,8,["search-index-names"])]),_:1})}const Ge=N(Ae,[["render",Se]]);export{Ge as default};