"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[941],{941:function(e,r,t){t.r(r),t.d(r,{default:function(){return search}});var a=t(3067),o=t(3412),n=t.n(o),getBaseDomain=e=>{if(e[0]===e[1])return".".concat(new URL(n().storeUrl).hostname);for(var r=e.map(e=>{try{var r=new URL(e).hostname,t=n().api.subDomainPrefix||[],a=new RegExp("^(".concat(["www",...t].join("|"),")\\."));return r.replace(a,"")}catch(e){return""}}).map(e=>e.split(".").reverse()),t=Math.min(...r.map(e=>e.length)),a=[],_loop=function(e){if(1!==new Set(r.map(r=>r[e])).size)return"break";a.push(r[0][e])},o=0;o<t&&"break"!==_loop(o);o++);if(a.length<2){var s="No common domain found for URLs: ".concat(e.join(", "));return console.warn("".concat(s,". Please check the Production URLs in the discovery.config file.")),""}return"."+a.reverse().join(".")};function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,a)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,a.Z)(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var randomUUID=()=>"function"==typeof crypto.randomUUID?crypto.randomUUID().replaceAll("-",""):(1e6*Math.random()).toFixed(0),createOrRefreshCookie=(e,r)=>{var t=n().secureSubdomain?getBaseDomain([n().storeUrl,n().secureSubdomain]):".".concat(new URL(n().storeUrl).hostname);return()=>{var a=function(e){for(var r of decodeURIComponent(document.cookie).split(";")){var[t,a]=r.trim().split("=");if(t===e)return a}}(e);return void 0===a&&(a=randomUUID()),document.cookie="".concat(e,"=").concat(a,"; max-age=").concat(r,"; domain=").concat(t,"; path=/;"),a}},s={anonymous:createOrRefreshCookie("vtex-search-anonymous",31536e3),session:createOrRefreshCookie("vtex-search-session",1800)},sendEvent=e=>fetch("https://sp.vtex.com/event-api/v1/".concat(n().api.storeId,"/event"),{method:"POST",body:JSON.stringify(_objectSpread(_objectSpread({},e),{},{userAgent:navigator.userAgent,anonymous:s.anonymous(),session:s.session()})),headers:{"content-type":"application/json"}}),isFullTextSearch=e=>"string"==typeof e.searchParams.get("q")&&/^\/s(\/)?$/g.test(e.pathname);setInterval(()=>sendEvent({type:"session.ping"}),6e4);var search=e=>{switch(e.name){case"search_select_item":var r,t,a=new URL(e.params.url);if(!isFullTextSearch(a))return;for(var o of null!==(n=e.params.items)&&void 0!==n?n:[]){var n,s,c,i=null!==(s=o.item_id)&&void 0!==s?s:o.item_variant,p=o.index;i&&p&&sendEvent({type:"search.click",productId:i,position:p,url:a.href,text:null!==(c=a.searchParams.get("q"))&&void 0!==c?c:"<empty>"})}break;case"intelligent_search_query":sendEvent({type:"search.query",url:e.params.url,text:e.params.term,misspelled:e.params.isTermMisspelled,match:e.params.totalCount,operator:e.params.logicalOperator,locale:e.params.locale});break;case"intelligent_search_autocomplete_query":sendEvent({type:"search.autocomplete.query",url:e.params.url,text:e.params.term,misspelled:e.params.isTermMisspelled,match:e.params.totalCount,operator:e.params.logicalOperator,locale:e.params.locale});break;case"intelligent_search_autocomplete_click":sendEvent(_objectSpread(_objectSpread({text:e.params.term,url:null!==(r=e.params.url)&&void 0!==r?r:"",productId:null!==(t=e.params.productId)&&void 0!==t?t:""},e.params.position&&{position:e.params.position}),{},{type:"search.autocomplete.click"}))}}}}]);