mk-sdk-git 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mk-sdk.js CHANGED
@@ -1 +1 @@
1
- (()=>{var Ke=Object.defineProperty;var E=(t,e)=>{for(var o in e)Ke(t,o,{get:e[o],enumerable:!0})};var lt={collectorUrl:"https://api-collector.mk3dlabs.com",appUrl:"https://mkfashion.mk3dlabs.com/visualizer",apiUrl:"https://mkfashion-new-api.mk3dlabs.com"},He={},N=null;function st(){if(N)return N;let t=null;try{t=document.currentScript||document.querySelector("script[data-mk-project]")||document.querySelector('script[src*="mk-sdk"]')||document.querySelector('script[src*="mk-pixel"]')}catch(i){}let e=i=>{try{return t&&t.getAttribute(i)}catch(a){return null}},o=e("data-mk-project")||e("data-mk-client")||window.__MK&&(window.__MK.projectId||window.__MK.clientSlug)||null,r=e("data-mk-product")||window.__MK&&window.__MK.product||"mk-fashion",n=e("data-mk-collector")||window.__MK&&window.__MK.collectorUrl||He.collectorUrl||lt.collectorUrl;return N={projectId:o,product:r,collectorUrl:n,appUrl:window.__MK&&window.__MK.appUrl||lt.appUrl,apiUrl:window.__MK&&window.__MK.apiUrl||lt.apiUrl,debug:!!(e("data-mk-debug")!==null||window.__MK&&window.__MK.debug||/[?&]mkdebug\b/.test(location.search)),observe:!!(window.__MK&&window.__MK.observe),forceButton:!!(window.__MK&&window.__MK.forceButton),anchor:window.__MK&&window.__MK.anchor||null,cartRedirect:!(window.__MK&&window.__MK.cartRedirect===!1),cartBehavior:window.__MK&&window.__MK.cartBehavior||null,cartOpenSelector:window.__MK&&window.__MK.cartOpenSelector||null,autoTrack:e("data-mk-no-autotrack")===null,batchIntervalMs:2e3,batchMaxSize:20,engagementIntervalMs:15e3},N}function f(){return N||st()}function h(...t){let e=f();e&&e.debug&&typeof console!="undefined"&&console.log("[mk-sdk]",...t)}var Ft="_mk_vid",qt="_mk_sid",M=null,U=null;function K(){return typeof crypto!="undefined"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function zt(){if(M)return M;try{let t=localStorage.getItem(Ft);return t||(t="v_"+K(),localStorage.setItem(Ft,t)),M=t,t}catch(t){return M="v_"+K(),M}}function $t(){if(U)return U;try{let t=sessionStorage.getItem(qt);return t||(t="s_"+K(),sessionStorage.setItem(qt,t)),U=t,t}catch(t){return U="s_"+K(),U}}var Kt=[/email/i,/e-?mail/i,/cpf/i,/cnpj/i,/phone/i,/telefone/i,/celular/i,/address/i,/endereco/i,/cep/i,/zip/i,/card/i,/cartao/i,/cvv/i,/password/i,/senha/i,/token/i,/\bnome\b/i,/fullname/i,/firstname/i,/lastname/i,/sobrenome/i,/birth/i,/nascimento/i,/rg\b/i],Ht={imageUrl:1,image:1,thumbnail:1,photo:1,imageBase64:1,src:1},ut=2e3;function Jt(t){for(let e=0;e<Kt.length;e++)if(Kt[e].test(t))return!0;return!1}function Vt(t){if(!t||typeof t!="object"||Array.isArray(t))return typeof t=="string"&&t.length>ut?t.slice(0,200)+"...[truncated "+t.length+"B]":t;let e={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||Jt(o))continue;let r=t[o];if(Ht[o]){e[o+"Present"]=!!r;continue}if(typeof r=="string"&&r.length>ut){e[o]=r.slice(0,200)+"...[truncated "+r.length+"B]";continue}if(r&&typeof r=="object"&&!Array.isArray(r)){e[o]=Je(r);continue}e[o]=r}return e}function Je(t){let e={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||Jt(o))continue;let r=t[o];if(Ht[o]){e[o+"Present"]=!!r;continue}if(typeof r=="string"&&r.length>ut){e[o]=r.slice(0,200)+"...[truncated]";continue}e[o]=r}return e}var H=[],dt=null,L=null,Ve=["off","pdp_tryon","pdp","all"],pt,ft=null,J="unknown",I=[];function Wt(t){if(pt===void 0)return"hold";switch(pt){case"off":return"drop";case"all":return"collect";case"pdp":return t==="pdp"?"collect":"drop";case"pdp_tryon":return t!=="pdp"?"drop":J==="available"?"collect":J==="unavailable"?"drop":"hold";default:return"collect"}}function mt(t){if(!I.length)return;let e=[];for(let o of I){let r=Wt(o._pt);r==="collect"?Zt(o.name,o.params,o.ts):r==="hold"&&!t&&e.push(o)}I=e}function ht(t){pt=Ve.indexOf(t)>=0?t:"all",mt(!1)}function Xt(t){J=t==="available"?"available":"unavailable",mt(!1)}function Yt(t){mt(!0),L=t,ft=t&&t.pageType||null,J="unknown"}function l(t,e,o){if(!f().projectId){(l._pre=l._pre||[]).push({name:t,params:e,ts:o||Date.now()}),l._pre.length>50&&l._pre.shift();return}if(l._pre&&l._pre.length){let n=l._pre;l._pre=[];for(let i of n)Gt(i.name,i.params,i.ts)}Gt(t,e,o)}function Gt(t,e,o){let r=Wt(ft);if(r==="collect"){Zt(t,e,o);return}if(r==="drop"){h("descartado (escopo)",t);return}I.push({name:t,params:e,ts:o||Date.now(),_pt:ft}),I.length>300&&I.shift()}function Zt(t,e,o){let r=f(),n=Vt(e||{}),i="page_"+Ge(t);if(H.push({name:i,ts:o||Date.now(),params:n}),h("queued",t,n),r.observe)try{window.postMessage({__mkpixel:!0,event:{name:i,params:n},site:L?{pageType:L.pageType,platform:L.platform,url:L.url}:null},"*")}catch(a){}if(H.length>=r.batchMaxSize){D();return}dt||(dt=setTimeout(()=>{dt=null,D()},r.batchIntervalMs))}function Ge(t){if(typeof t!="string"||!t)return"unknown";let e=t.replace(/^on/,"");return e=e.replace(/[A-Z]/g,(o,r)=>(r>0?"_":"")+o.toLowerCase()),e.indexOf("page_")===0&&(e=e.slice(5)),e}function D(t){if(H.length===0)return;let e=f();if(!e.projectId||!e.collectorUrl)return;let o=H.splice(0,50),r=JSON.stringify({product:e.product||void 0,visitorId:zt(),sessionId:$t(),events:o,site:L||void 0}),n=e.collectorUrl+"/v1/track";if(t&&navigator.sendBeacon)try{let i=new Blob([r],{type:"application/json"});navigator.sendBeacon(n+"?projectId="+encodeURIComponent(e.projectId),i);return}catch(i){}fetch(n,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","X-MK-Project-Id":e.projectId},body:r}).catch(()=>{})}function Qt(){try{window.addEventListener("pagehide",()=>D(!0)),window.addEventListener("beforeunload",()=>D(!0)),document.addEventListener("visibilitychange",()=>{document.hidden&&D(!0)})}catch(t){}}function C(t){let e=[];try{let o=document.querySelectorAll('script[type="application/ld+json"]');for(let r of o){let n;try{n=JSON.parse(r.textContent)}catch(a){continue}let i=[];Array.isArray(n)?i.push(...n):n["@graph"]?i.push(...n["@graph"]):i.push(n);for(let a of i){if(!a||!a["@type"])continue;let s=Array.isArray(a["@type"])?a["@type"]:[a["@type"]];(!t||t.some(u=>s.includes(u)))&&e.push(a)}}}catch(o){}return e}var te=["off","pdp_tryon","pdp","all"],We="all",Xe=30*60*1e3,P=null;function R(){if(P)return P;let t=f();return!t.projectId||!t.apiUrl?(P=Promise.resolve(null),P):(P=fetch(t.apiUrl+"/projects/"+t.projectId).then(e=>e.ok?e.json():null).then(e=>e&&e.project||e||null).catch(()=>null),P)}function ee(t){let e=t&&t.analytic&&t.analytic.scope;return te.indexOf(e)>=0?e:We}var re=t=>"mk_scope_"+t;function oe(t){try{let e=localStorage.getItem(re(t));if(!e)return null;let o=JSON.parse(e);return!o||typeof o.exp!="number"||o.exp<Date.now()?null:te.indexOf(o.scope)>=0?o.scope:null}catch(e){return null}}function ne(t,e){try{localStorage.setItem(re(t),JSON.stringify({scope:e,exp:Date.now()+Xe}))}catch(o){}}var gt={};E(gt,{addToCart:()=>tr,detect:()=>Ze,id:()=>Ye,openCartDrawer:()=>or,resolveSku:()=>Qe});var Ye="shopify";function Ze(){return!!(window.Shopify||window.ShopifyAnalytics)}function Qe(){let t=window;return t.ShopifyAnalytics&&t.ShopifyAnalytics.meta&&t.ShopifyAnalytics.meta.product?{value:String(t.ShopifyAnalytics.meta.product.id),source:"shopify"}:null}var V=t=>String(t==null?"":t).trim().toLowerCase();async function tr({size:t,color:e,sku:o,quantity:r}){let n=(location.pathname.split("/products/")[1]||"").split(/[?#]/)[0];if(!n)throw new Error("shopify: sem handle de produto na URL (n\xE3o \xE9 PDP?)");let a=(await fetch("/products/"+n+".js").then(c=>c.json())).variants||[],s=c=>[c.option1,c.option2,c.option3].concat(String(c.title||"").split("/")).map(V).filter(Boolean),u=(c,x)=>s(c).indexOf(V(x))>=0,d=c=>(!t||u(c,t))&&(!e||u(c,e)),m=null;if((t||e)&&(m=a.find(c=>d(c)&&c.available)||a.find(d)),!m&&o&&(m=a.find(c=>V(c.sku)===V(o))),m||(m=a.find(c=>c.available)||a[0]),!m)throw new Error("shopify: variante n\xE3o encontrada");let g=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:m.id,quantity:r||1}]})});if(!g.ok)throw new Error("shopify: /cart/add.js HTTP "+g.status);return{platform:"shopify",variantId:m.id,size:m.title,sku:m.sku||null}}var er=["[data-cart-drawer-toggle]",'[data-action="open-cart-drawer"]','[data-action="open-cart"]',".js-cart-drawer-open",".js-drawer-open-cart",".cart-drawer-toggle",".js-cart-toggle",'[aria-controls="CartDrawer"]','[aria-controls="cart-drawer"]',"#cart-icon-bubble","#lk-cart-icon",".header__cart",".site-header__cart",".cart-link",".header-cart",'a[href="/cart"]','a[href$="/cart"]'];function rr(t){try{let e=t.getBoundingClientRect();return e.width>0&&e.height>0&&getComputedStyle(t).visibility!=="hidden"}catch(e){return!1}}function or(){let t=null;for(let e of er)try{if(t=[...document.querySelectorAll(e)].find(rr),t)break}catch(o){}return t?(setTimeout(()=>{try{t.click()}catch(e){}},300),!0):!1}var yt={};E(yt,{addToCart:()=>cr,detect:()=>ir,id:()=>nr,resolveSku:()=>ar});var nr="hybris";function ir(){return!!(window.ACC&&window.ACC.config)}function ar(){let t=(location.pathname||"").match(/\/p\/([^/?#]+)/);return t&&t[1]?{value:decodeURIComponent(t[1]),source:"hybris/url"}:null}var ie=t=>String(t==null?"":t).trim().toLowerCase();async function cr({size:t,quantity:e}){let o=[...document.querySelectorAll('.js-product-select-size, a[data-code], [class*="select-size"]')].filter(g=>g.getAttribute&&g.getAttribute("data-code")),r=t?o.find(g=>ie(g.textContent)===ie(t)):null;r||(r=o.find(g=>g.offsetParent!==null)||o[0]);let n=r&&r.getAttribute("data-code");if(!n)throw new Error("hybris: variante (data-code) n\xE3o encontrada");let i=document.getElementById("product--add-to-cart-form")||document.querySelector('form[action*="/cart/add"]'),a=i&&i.querySelector('[name="CSRFToken"]'),s=a&&a.value,u=i&&i.getAttribute("action")||"/cart/add";if(!s)throw new Error("hybris: CSRFToken n\xE3o encontrado");let d=new URLSearchParams;d.set("productCodePost",n),d.set("qty",String(e||1)),d.set("CSRFToken",s);let m=await fetch(u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:d.toString()});if(!m.ok)throw new Error("hybris: "+u+" HTTP "+m.status);return{platform:"hybris",productCode:n,size:r.textContent.trim()}}var wt={};E(wt,{addToCart:()=>dr,detect:()=>sr,id:()=>lr,resolveSku:()=>ur});var lr="vtex";function sr(){return!!(window.vtex||window.vtexjs||window.vtxctx||window.skuJson_0)}function ur(){let t=window;return t.vtxctx&&t.vtxctx.skus&&t.vtxctx.skus[0]?{value:String(t.vtxctx.skus[0]),source:"vtex/vtxctx"}:t.skuJson_0&&t.skuJson_0.skus&&t.skuJson_0.skus[0]?{value:String(t.skuJson_0.skus[0].sku),source:"vtex/skuJson"}:null}var G=t=>String(t==null?"":t).trim().toLowerCase();async function dr({size:t,quantity:e}){let o=window.skuJson_0&&window.skuJson_0.skus||[];if(!o.length)throw new Error("vtex: skuJson_0 indispon\xEDvel");let r=i=>G(i.skuname)===G(t)||i.dimensions&&Object.values(i.dimensions).some(a=>G(a)===G(t)),n=t?o.find(i=>r(i)&&i.available)||o.find(r):null;if(n||(n=o.find(i=>i.available)||o[0]),!n)throw new Error("vtex: variante n\xE3o encontrada");if(window.vtexjs&&window.vtexjs.checkout&&window.vtexjs.checkout.addToCart)return await window.vtexjs.checkout.addToCart([{id:parseInt(n.sku,10),quantity:e||1,seller:"1"}]),{platform:"vtex",skuId:n.sku,size:n.skuname||t};throw new Error("vtex: vtexjs.checkout indispon\xEDvel")}var xt={};E(xt,{addToCart:()=>gr,detect:()=>mr,id:()=>pr,resolveSku:()=>hr,skipRedirect:()=>fr});var pr="nuvemshop",fr=!0;function mr(){return!!(window.LS&&(window.LS.cart||window.LS.addToCart))}function hr(){try{let t=window.LS,e=t&&t.variants||[],o=document.querySelector('[name="variant_id"]'),r=o&&o.value?e.find(n=>String(n.id)===String(o.value)):null;if(r||(r=e.find(n=>n.available!==!1&&n.sku)||e.find(n=>n.sku)||e[0]),r&&r.sku)return{value:String(r.sku),source:"nuvemshop/variant"};if(t&&t.product&&t.product.sku)return{value:String(t.product.sku),source:"nuvemshop/product"}}catch(t){}return null}var W=t=>String(t==null?"":t).trim().toLowerCase();async function gr({size:t,quantity:e}){let o=document.getElementById("product_form")||document.querySelector('.js-product-form, form[action*="/comprar"]');if(!o)throw new Error("nuvemshop: #product_form n\xE3o encontrado");t&&o.querySelectorAll('select[name^="variation"]').forEach(i=>{let a=[...i.options].find(s=>W(s.textContent).includes(W(t))||W(s.value)===W(t));a&&(i.value=a.value,i.dispatchEvent(new Event("change",{bubbles:!0})))});let r=o.querySelector('[name="quantity"]');return r&&e&&(r.value=String(e)),await new Promise(i=>setTimeout(i,400)),typeof o.requestSubmit=="function"?o.requestSubmit():o.submit(),{platform:"nuvemshop",variantId:(o.querySelector('[name="variant_id"]')||{}).value||null}}var bt={};E(bt,{addToCart:()=>kr,detect:()=>xr,id:()=>yr,resolveSku:()=>br,skipRedirect:()=>wr});var yr="wake",wr=!0;function xr(){return!!(window.StorefrontClient||typeof window.addOrCreateCheckout=="function"||typeof window.addToCartClick=="function")}function br(){try{let t=document.querySelector('input[name="product-id"], [data-product-id]'),e=t?t.value||t.getAttribute("data-product-id"):null;if(e)return{value:String(e).trim(),source:"wake/product-id"};let o=(location.pathname||"").match(/-(\d+)\/?(?:[?#]|$)/);if(o)return{value:o[1],source:"wake/url"}}catch(t){}return null}var ae=t=>String(t==null?"":t).trim().toLowerCase();async function kr({size:t,quantity:e}){if(t){let i=[...document.querySelectorAll("input[attribute-value]")].find(a=>ae(a.getAttribute("attribute-value"))===ae(t));if(i){try{i.checked=!0}catch(a){}try{typeof window.selectAttribute=="function"?window.selectAttribute(i):i.click()}catch(a){}await new Promise(a=>setTimeout(a,600))}}let o=document.querySelector('[name="product-variant-id"]'),r=o&&o.value;if(!r)throw new Error("wake: product-variant-id n\xE3o encontrado");if(typeof window.addOrCreateCheckout!="function")throw new Error("wake: addOrCreateCheckout indispon\xEDvel");if(!await window.addOrCreateCheckout([{productVariantId:Number(r),quantity:e||1,customization:[]}]))throw new Error("wake: addOrCreateCheckout retornou false");return{platform:"wake",productVariantId:r,size:t||null}}var _t={};E(_t,{addToCart:()=>X,detect:()=>Cr,id:()=>_r,resolveSku:()=>kt});var _r="generic";function Cr(){return!0}function kt(){let t=C(["Product"]);if(t[0]){let e=t[0],o=e.sku||e.mpn||e.gtin13||e.productID;if(o)return{value:String(o),source:"jsonld"}}try{let e=document.querySelector('[itemprop="sku"]');if(e){let o=e.getAttribute("content")||(e.textContent||"").trim();if(o)return{value:String(o),source:"microdata"}}}catch(e){}try{let e=window.konfidencyData;if(e&&e.product&&e.product.variants&&e.product.variants[0])return{value:String(e.product.variants[0]),source:"konfidency"}}catch(e){}return null}var vr=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora/i,Sr=/continuar|como comprar|lista|desejos|favorito/i;async function X(){let t=document.querySelectorAll("button,[role=button],input[type=submit]");for(let e of t){let o=(e.textContent||e.value||"").replace(/\s+/g," ").trim();if(o&&o.length<40&&vr.test(o)&&!Sr.test(o))try{return e.click(),{platform:"native-click",clicked:o}}catch(r){}}return{platform:"none",error:"bot\xE3o de carrinho nativo n\xE3o encontrado"}}var le=[gt,yt,wt,xt,bt],Tr=[["woocommerce",()=>!!(window.wc_add_to_cart_params||window.woocommerce_params)],["lojaintegrada",()=>!!window.LojaIntegrada]],Y;function Ct(){return Y||(Y=le.find(t=>{try{return t.detect()}catch(e){return!1}})||_t,Y)}function se(){let t=le.find(e=>{try{return e.detect()}catch(o){return!1}});if(t)return t.id;for(let[e,o]of Tr)try{if(o())return e}catch(r){}return null}function F(){let t=Ct();if(t.id!=="generic"&&t.resolveSku)try{let e=t.resolveSku();if(e)return e}catch(e){}return kt()}async function ue(t){t=t||{};let e={size:t.size||t.selectedSize||t.tamanho||null,color:t.color||t.selectedColor||t.colour||t.cor||null,sku:t.sku||t.identifier||t.selectedIdentifier||null,quantity:t.quantity||1},o=Ct();try{let r=o.addToCart?await o.addToCart(e):await X(e);return h("cart: adicionado",r),ce(),r}catch(r){h('cart: adapter "'+o.id+'" falhou \u2014 fallback clique nativo',r&&r.message);let n=await X(e);return ce(),n}}function ce(){["cart:refresh","cart:updated","cart:build","ajaxProduct:added","product:added-to-cart"].forEach(t=>{try{document.dispatchEvent(new CustomEvent(t))}catch(e){}})}async function de(){let t=Ct(),e=f(),o=null;try{o=await R()}catch(a){}let r=o&&o.template&&o.template.cart||o&&o.cart||{},n=r.afterAdd||r.behavior||e.cartBehavior;if(n||(n=e.cartRedirect===!1?"none":"auto"),n==="none")return;if(n==="auto"||n==="drawer"){let a=r.openSelector||e.cartOpenSelector;if(a){let s=document.querySelector(a);if(s){setTimeout(()=>{try{s.click()}catch(u){}},300);return}}else if(t&&t.openCartDrawer){let s=!1;try{s=t.openCartDrawer()}catch(u){}if(s)return}}if(t&&t.skipRedirect)return;let i=t&&t.cartUrl||"/cart";setTimeout(()=>{try{window.location.href=i}catch(a){}},250)}var Ar=/\/(thank[_-]?you|orders?\/|pedido[_-]?(confirmado|realizado|finalizado|sucesso)|sucesso|order[_-]?confirmation|compra[_-]?(finalizada|concluida)|orderplaced)/i,Er=/\/checkout/i,Lr=/\/(cart|carrinho|sacola|bag)(\/|$|\?|#)/i,Ir=/\/(products?|produtos?|p)\//i,Pr=/\/(collections?|categoria|categorias|c|departamento)\//i,Rr=/\/(search|busca|s)(\/|\?)/i;function pe(){try{if(window.__mkPageType)return window.__mkPageType}catch(e){}try{let e=C();for(let o of e){let r=Array.isArray(o["@type"])?o["@type"]:[o["@type"]];if(r.includes("Order")||r.includes("Invoice"))return"purchase";if(r.includes("Product"))return"pdp";if(r.includes("SearchResultsPage"))return"search";if(r.includes("CollectionPage")||r.includes("ItemList"))return"category"}}catch(e){}let t=(location.pathname||"").toLowerCase();return t==="/"||t===""||t==="/home"||t==="/index.html"?"home":Ar.test(t)?"purchase":Er.test(t)?"checkout":Lr.test(t)?"cart":Ir.test(t)?"pdp":Pr.test(t)?"category":Rr.test(t)?"search":"other"}function fe(t){let e=null;try{let o=new URLSearchParams(location.search),r=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],n={};for(let i of r){let a=o.get(i);a&&(n[i.replace("utm_","")]=a)}Object.keys(n).length&&(e=n)}catch(o){}return{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:t,utm:e,userAgent:navigator.userAgent,language:navigator.language,viewport:window.innerWidth+"x"+window.innerHeight,platform:jr()}}function jr(){return se()}var vt={},Br=null,q=0,me=!1;function he(t){me||(me=!0,ge(t),Or(),Nr(),Mr(),Ur(),Dr(t))}function ge(t){vt={};let e=pe(),o=fe(e);if(Yt(o),l("view",{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:e}),typeof t=="function")try{t(e,o)}catch(r){}}function Or(){if(!document.body)return;let t={A:1,BUTTON:1,INPUT:1,SELECT:1,TEXTAREA:1},e=0;document.body.addEventListener("click",o=>{try{let r=Date.now();if(r-e<100)return;e=r;let n=o.target;for(let s=0;s<5&&n&&n!==document.body&&!(t[n.tagName]||n.getAttribute&&n.getAttribute("role")==="button");s++)n=n.parentElement;if(!n||!t[n.tagName]&&!(n.getAttribute&&n.getAttribute("role")==="button"))return;let i={tag:n.tagName},a=n.tagName==="INPUT"||n.tagName==="TEXTAREA"?n.value:n.textContent;i.text=(a||"").replace(/\s+/g," ").trim().substring(0,100),n.href&&(i.href=String(n.href).substring(0,500)),n.id&&(i.id=n.id),n.className&&typeof n.className=="string"&&(i.classes=n.className.trim().substring(0,200)),l("click",i)}catch(r){}},{capture:!0,passive:!0})}function Nr(){let t=[25,50,75,100],e=null,o=()=>{try{let r=window.scrollY||document.documentElement.scrollTop||0,n=Math.max(document.body&&document.body.scrollHeight||0,document.documentElement&&document.documentElement.scrollHeight||0);if(n<=0)return;let i=Math.min(100,Math.floor((r+window.innerHeight)/n*100));for(let a of t)i>=a&&!vt[a]&&(vt[a]=!0,l("scroll_depth",{depth:a}))}catch(r){}};o(),window.addEventListener("scroll",()=>{e||(e=setTimeout(()=>{e=null,o()},250))},{passive:!0})}function Mr(){document.body&&document.body.addEventListener("submit",t=>{try{let e=t.target;if(!e||e.tagName!=="FORM"||e.querySelector('input[type="password"], input[name*="card"], input[name*="cpf"]'))return;let o="other",r=(e.className||"").toLowerCase(),n=(e.action||"").toLowerCase();e.querySelector('input[type="search"], input[name="q"], input[name="s"]')?o="search":/newsletter|subscribe|mailchimp/.test(r+n)?o="newsletter":/contact|contato/.test(r+n)&&(o="contact"),l("form_submit",{form_id:e.id||"",form_type:o})}catch(e){}},{capture:!0})}function Ur(){let t=f();q=Date.now(),Br=setInterval(()=>{if(document.hidden)return;let e=Date.now(),o=Math.round((e-q)/1e3);q=e,o>0&&o<60&&l("engagement",{url:location.pathname,dwellSec:o})},t.engagementIntervalMs),document.addEventListener("visibilitychange",()=>{if(document.hidden){let e=Math.round((Date.now()-q)/1e3);e>0&&e<600&&l("engagement",{url:location.pathname,dwellSec:e})}q=Date.now()})}function Dr(t){let e=location.href,o=()=>{location.href!==e&&(e=location.href,ge(t))};try{let r=history.pushState,n=history.replaceState;history.pushState=function(){r.apply(this,arguments),setTimeout(o,0)},history.replaceState=function(){n.apply(this,arguments),setTimeout(o,0)},window.addEventListener("popstate",o)}catch(r){}}function St(){let t=F(),e=C(["Product"]);if(e.length>0){let n=e[0],i=Array.isArray(n.offers)?n.offers[0]:n.offers;return{sku:t?t.value:n.sku||n.mpn||n.gtin13||n.productID||null,skuSource:t?t.source:null,name:typeof n.name=="string"?n.name:null,price:i&&parseFloat(i.price||i.lowPrice)||null,currency:i?i.priceCurrency:null,brand:n.brand?typeof n.brand=="string"?n.brand:n.brand.name:null,category:n.category||null}}let o=n=>{let i=document.querySelector('meta[property="og:'+n+'"], meta[property="product:'+n+'"]');return i?i.getAttribute("content"):null},r=n=>{let i=document.querySelector('[itemprop="'+n+'"]');return i?i.getAttribute("content")||(i.textContent||"").trim():null};if(t||o("type")==="product"||o("price:amount")||r("name")){let n=r("price")||o("price:amount");return{sku:t?t.value:null,skuSource:t?t.source:null,name:r("name")||o("title")||document.title||null,price:n&&parseFloat(String(n).replace(",","."))||null,currency:r("priceCurrency")||o("price:currency")||null,brand:r("brand")||null,category:null}}return null}function ye(){let t=C(["Order","Invoice"]);if(t.length>0){let r=t[0],n=r.totalPaymentDue?parseFloat(r.totalPaymentDue.price):parseFloat(r.price||r.total);return{orderId:r.orderNumber||r.confirmationNumber||r.identifier||null,revenue:Number.isFinite(n)?n:null,currency:r.totalPaymentDue&&r.totalPaymentDue.priceCurrency||r.priceCurrency||null,source:"jsonld"}}try{if(Array.isArray(window.dataLayer))for(let r=window.dataLayer.length-1;r>=0;r--){let n=window.dataLayer[r];if(n&&n.event==="purchase"&&n.ecommerce){let i=n.ecommerce;return{orderId:i.transaction_id||i.transactionId||null,revenue:parseFloat(i.value||i.revenue)||null,currency:i.currency||i.currencyCode||null,itemCount:(i.items||i.products||[]).length||null,source:"datalayer"}}}}catch(r){}let e=document.querySelector('meta[property="order:total"], meta[name="order-total"]');if(e&&e.content)return{orderId:null,revenue:parseFloat(e.content)||null,source:"meta"};let o=Fr();return o||null}function Fr(){try{let t=[".order-total","#order-total",".total-price",".order__total","[data-order-total]",".summary-total",".grand-total"];for(let e of t){let o=document.querySelector(e);if(o){let r=zr(o.textContent);if(r)return{orderId:qr(),revenue:r,source:"dom"}}}return null}catch(t){return null}}function qr(){try{let e=(document.body.innerText||"").match(/(?:pedido|order|n[º°o]\.?)\s*#?\s*([A-Z0-9-]{4,})/i);return e?e[1]:null}catch(t){return null}}function zr(t){if(!t)return null;let e=String(t).replace(/[^\d.,]/g,"");if(!e)return null;let o;e.indexOf(",")>e.indexOf(".")?o=e.replace(/\./g,"").replace(",","."):o=e.replace(/,/g,"");let r=parseFloat(o);return Number.isFinite(r)&&r>0?r:null}function we(){let t=C(["ItemList","CollectionPage"]);if(t.length===0)return null;let e=t[0],o=e.itemListElement||e.mainEntity&&e.mainEntity.itemListElement||[],r=[];for(let n of o.slice(0,50)){let i=n.item||n;i&&(i.sku||i.productID||i.name)&&r.push(i.sku||i.productID||i.name)}return r.length>0?{count:r.length,skus:r.slice(0,20)}:null}var xe=!1,Z=[/\b(adicionar|adic\.?|colocar|incluir|jogar)\b.{0,30}\b(carrinho|sacola|sacolinha|bag)\b/i,/\bcomprar\b(?!\s+(em|por|sem))/i,/\bcomprar\s*$/i,/^add\s+to\s+(cart|bag)\b/i,/^buy\s+(now|it|this)\b/i,/^(sacolinha|carrinho|sacola)$/i],$r=[/^finalizar(\s+(compra|pedido|pagamento))?\b/i,/^(fechar|confirmar)\s+(compra|pedido|pagamento)\b/i,/^pagar(\s+(agora|pedido))?\b/i,/^(complete|place)\s+(purchase|order)\b/i,/^checkout$/i];function z(t,e){for(let o=0;o<t.length;o++)if(t[o].test(e))return!0;return!1}function be(t){switch(t){case"pdp":{let e=St();l("view_item",e||{sku:null});break}case"category":case"search":{let e=we();l("view_item_list",e||{count:0});break}case"cart":l("view_cart",{});break;case"checkout":l("begin_checkout",{});break;case"purchase":Kr();break}}function Kr(){let t=ye();if(t&&t.orderId){let e="_mk_purch_"+t.orderId;try{if(sessionStorage.getItem(e)){h("purchase j\xE1 contado",t.orderId);return}sessionStorage.setItem(e,"1")}catch(o){}}else if(xe)return;xe=!0,l("purchase",t||{revenue:null,_note:"no_order_data_extracted"}),h("purchase emitido",t)}function ke(){if(!document.body)return;let t=0;document.body.addEventListener("click",e=>{try{let o=Date.now();if(o-t<150)return;let r=e.target;for(let s=0;s<5&&r&&r!==document.body&&!(r.tagName==="BUTTON"||r.tagName==="A"||r.getAttribute&&r.getAttribute("role")==="button");s++)r=r.parentElement;if(!r)return;let n=r.tagName!=="A",i=(r.textContent||"").replace(/\s+/g," ").trim();if(!i||i.length>80)return;let a=!1;if((z([Z[0]],i)||n&&z([Z[1]],i)||n&&z([Z[2]],i)||z(Z.slice(3),i))&&(a=!0),a){t=o;let s=St();l("add_to_cart",{via:"click",buttonText:i,sku:s?s.sku:null,price:s?s.price:null});return}n&&z($r,i)&&(t=o,l("begin_checkout",{via:"click",buttonText:i}))}catch(o){}},{capture:!0,passive:!0})}var _=null,v=null,tt=!1,et=!1,j=null,_e={},Tt=null,Q=0,b={onReady:null,onClose:null,onAddToCart:null,onProductLoaded:null,onError:null,onInteraction:null,onGenerationComplete:null},Hr={gregory:"698c7e791d3129430f15dddd"};function ve(t){return t?Hr[String(t).toLowerCase()]||t:null}async function B(t,e){let o=f(),r=ve(t);e=String(e||"").trim();let n=o.apiUrl+"/availability/"+r+"?sku="+encodeURIComponent(e),i=await fetch(n);if(!i.ok)throw new Error("availability HTTP "+i.status);return i.json()}async function Se(t,e){e||(e=t,t="698c7e791d3129430f15dddd");try{return(await B(t,e)).available===!0}catch(o){return!1}}async function rt(t){if(t=t||{},tt)return;let e=ve(t.projectId||t.projectid||t.store),o=String(t.identifier||t.sku||"").trim();if(!e||!o){console.error("[mk-sdk] open: projectId e identifier obrigatorios");return}let r=e+":"+o;if(_e[r]!==!0){try{if(!(await B(e,o)).available){alert("Produto nao disponivel para prova virtual.");return}}catch(n){alert("Produto nao encontrado ou indisponivel.");return}_e[r]=!0}j={projectId:e,identifier:o,width:t.width||430,height:t.height||800},et=!1,Ee(),Jr(j),tt=!0,Q=Date.now(),l("modal_opened",{projectId:e,identifier:o})}function Et(){if(!tt)return;let t=et;if(et=!1,Vr(),tt=!1,T("onClose"),l("modal_closed",{projectId:j&&j.projectId,identifier:j&&j.identifier}),t)try{de()}catch(e){}}function Te(t){try{let e=document.getElementById("mk-tryon-button-host");if(!e)return;t?(e.dataset.mkPrevDisplay===void 0&&(e.dataset.mkPrevDisplay=e.style.display),e.style.display="none"):(e.style.display=e.dataset.mkPrevDisplay||"",delete e.dataset.mkPrevDisplay)}catch(e){}}function Jr(t){_=document.createElement("div"),_.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,.8);display:flex;align-items:center;justify-content:center;z-index:2147483647;",Te(!0);let e=document.createElement("div"),o=typeof t.width=="number"?t.width+"px":t.width,r=typeof t.height=="number"?t.height+"px":t.height;e.style.cssText="position:relative;width:"+o+";height:"+r+";max-width:100vw;max-height:100dvh;border-radius:12px;overflow:hidden;background:#fff;",v=document.createElement("iframe");let n=encodeURIComponent(t.identifier).replace(/\./g,"%2E");v.src=f().appUrl+"/"+t.projectId+"/"+n,v.style.cssText="width:100%;height:100%;border:none;",v.setAttribute("allow","camera *; microphone *"),v.setAttribute("allowfullscreen","true"),e.appendChild(v),_.appendChild(e),document.body.appendChild(_),h("try-on modal aberto",v.src)}function Vr(){_&&_.parentNode&&_.parentNode.removeChild(_),_=null,v=null,Te(!1)}var Ce=!1;function Ae(){Ee()}function Ee(){Ce||(Ce=!0,window.addEventListener("message",t=>{let e=t.data;if(!e||e.source!=="mkfashion-app")return;let o=e.action,r=e.data||{};switch(o){case"close_request":Et();break;case"ready":T("onReady",r);break;case"product_loaded":T("onProductLoaded",r),l("product_loaded",At(r));break;case"interaction":{T("onInteraction",r),r&&r.method&&(Tt=r.method),l(Gr(r),At(r));break}case"add_to_cart":l("add_to_cart",Object.assign({via:"tryon"},At(r))),typeof b.onAddToCart=="function"?T("onAddToCart",r):ue(r).then(()=>{et=!0}).catch(()=>{});break;case"generation_start":Q=Date.now();break;case"generation_complete":T("onGenerationComplete",r),l("generation_complete",{method:r.method||Tt||"unknown",durationMs:Q?Date.now()-Q:null,success:r.success!==!1,imageUrlPresent:!!r.imageUrl});break;case"generation_error":T("onError",r),l("generation_error",{method:Tt||"unknown",error:r&&r.error});break}}))}function Gr(t){return t&&t.action,"interaction"}function At(t){if(!t||typeof t!="object")return t;let e={};for(let o in t){if(o==="imageUrl"||o==="image"||o==="product"){o==="product"&&t[o]?(e.productSku=t[o].sku||null,e.productName=t[o].name||null):e[o+"Present"]=!!t[o];continue}e[o]=t[o]}return e}function T(t,e){if(typeof b[t]=="function")try{b[t](e)}catch(o){console.error("[mk-sdk]",o)}}function Le(t){b.onReady=t}function Ie(t){b.onClose=t}function Pe(t){b.onAddToCart=t}function Re(t){b.onProductLoaded=t}function je(t){b.onError=t}function Be(t){b.onInteraction=t}function Oe(t){b.onGenerationComplete=t}var Xr=767,Yr=1024,Zr=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora|^comprar$|finalizar compra|eu quero/i,Qr=/continuar|como comprar|lista|desejos|favorito|looks|cupom/i;function Lt(t){try{let e=t.getBoundingClientRect();if(e.width<=0||e.height<=0)return!1;let o=getComputedStyle(t);return o.display!=="none"&&o.visibility!=="hidden"&&o.opacity!=="0"}catch(e){return!1}}function to(t){if(!t)return!1;try{let e=document.querySelector(t);return!!e&&Lt(e)}catch(e){return!1}}function eo(t){return(t.tagName==="INPUT"?t.value||"":t.textContent||"").replace(/\s+/g," ").trim()}function ro(t){if(!t||typeof t!="object"||t.selector)return t;let e=!1;if(["mobile","tablet","desktop"].forEach(r=>{let n=t[r];n&&n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"&&(e=!0)}),!e)return t;let o={};return["mobile","tablet","desktop"].forEach(r=>{let n=t[r];if(n){if(n.selector){o[r]=n;return}if(n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"){let i=n.anchor[r]||n.anchor.desktop||n.anchor.mobile||n.anchor.tablet;i&&i.selector&&(o[r]=i)}}}),["bpMobile","bpTablet","breakpoint"].forEach(r=>{t[r]!=null&&(o[r]=t[r])}),o}function It(t){if(!t||typeof t!="object")return null;if(t=ro(t),t.selector)return t;let e=[["mobile",t.mobile],["tablet",t.tablet],["desktop",t.desktop]].filter(u=>u[1]&&u[1].selector);if(e.length===0)return null;if(e.length===1)return e[0][1];let o=e.filter(([,u])=>to(u.selector));if(o.length===1)return o[0][1];let r=window.innerWidth||1024,n=Number(t.bpMobile)||Number(t.breakpoint)||Xr,i=Number(t.bpTablet)||Yr,a=u=>(e.find(d=>d[0]===u)||[])[1],s=r<=n?["mobile","tablet","desktop"]:r<=i?["tablet","desktop","mobile"]:["desktop","tablet","mobile"];for(let u of s){let d=a(u);if(d)return d}return e[0][1]}function Ne(){let t=f(),e=It(t&&t.anchor);if(e&&e.selector)try{let r=document.querySelector(e.selector);if(r&&Lt(r))return{el:r,position:e.position||"afterend",mode:e.mode||"flow",style:e.style||"",align:e.align||"top-left",selector:e.selector}}catch(r){}let o=document.querySelectorAll('button, [role="button"], a.btn, a.button, input[type="submit"], input[type="button"]');for(let r of o){let n=eo(r);if(!(!n||n.length>40)&&!Qr.test(n)&&Zr.test(n)&&Lt(r))return{el:r,position:"afterend",mode:"flow",style:"",selector:null}}return null}var w="'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Pt={none:"0",sm:"4px",md:"8px",pill:"9999px"},Rt={none:"0",sm:"4px",md:"8px",lg:"16px"},oo='<svg viewBox="0 0 17.5263 20.6862" fill="none" xmlns="http://www.w3.org/2000/svg" style="display:block;width:100%;height:100%"><g><path d="M8.49995 12.1862C10.1568 12.1862 11.5 10.8431 11.5 9.18622C11.5 7.52936 10.1568 6.18622 8.49995 6.18622C6.8431 6.18622 5.49995 7.52936 5.49995 9.18622C5.49995 10.8431 6.8431 12.1862 8.49995 12.1862Z" stroke="currentColor" shape-rendering="crispEdges"/><path d="M0.5 9.11152C0.5 6.56953 0.5 5.29894 1.1099 4.38664C1.375 3.9902 1.71424 3.65088 2.10821 3.38809C2.6945 2.9958 3.42899 2.85564 4.55351 2.80588C5.09013 2.80588 5.55183 2.39949 5.65687 1.87284C5.73715 1.48708 5.94572 1.14138 6.24735 0.894155C6.54898 0.646934 6.92516 0.51336 7.31231 0.516006H9.9734C10.7779 0.516006 11.4709 1.08412 11.6288 1.87284C11.7339 2.39949 12.1956 2.80588 12.7322 2.80588C13.8559 2.85564 12.9129 4.67413 13.5 5.06559C13.8949 5.32932 15.1484 3.80355 15.5 4.02647C16.1099 4.93876 16.7857 6.56953 16.7857 9.11152C16.7857 11.6535 16.7857 12.9233 16.1758 13.8364C15.9107 14.2328 15.5715 14.5722 15.1775 14.835C14.2647 15.4445 12.9936 15.4445 10.4522 15.4445H6.83351C4.29213 15.4445 3.02103 15.4445 2.10821 14.835C1.71446 14.5718 1.3755 14.2322 1.11071 13.8356C0.933802 13.5672 0.803519 13.2698 0.725557 12.9564" stroke="currentColor" stroke-linecap="round"/><path d="M12.676 0.607931C12.9446 -0.178095 14.0307 -0.2019 14.3491 0.536515L14.3761 0.60838L14.7385 1.66839C14.8216 1.91149 14.9559 2.13395 15.1322 2.32076C15.3086 2.50757 15.5229 2.65439 15.7608 2.75131L15.8583 2.78769L16.9183 3.14971C17.7044 3.41831 17.7282 4.50437 16.9902 4.82283L16.9183 4.84978L15.8583 5.21225C15.6151 5.29526 15.3926 5.42947 15.2057 5.60582C15.0188 5.78218 14.8719 5.99657 14.7749 6.23453L14.7385 6.33155L14.3765 7.39201C14.1079 8.17803 13.0219 8.20184 12.7039 7.46387L12.676 7.39201L12.314 6.332C12.231 6.08881 12.0968 5.86627 11.9204 5.67938C11.744 5.49249 11.5297 5.3456 11.2917 5.24863L11.1947 5.21225L10.1347 4.85022C9.34817 4.58163 9.32437 3.49557 10.0628 3.17756L10.1347 3.14971L11.1947 2.78769C11.4378 2.70462 11.6602 2.57039 11.847 2.39404C12.0339 2.21769 12.1807 2.00333 12.2776 1.76541L12.314 1.66839L12.676 0.607931Z" fill="currentColor"/></g></svg>',no='<svg viewBox="0 0 11.6122 12.7248" fill="none" xmlns="http://www.w3.org/2000/svg" style="display:block;width:12px;height:12px"><path d="M4.09055 2.01133C4.43939 0.9905 5.84989 0.959583 6.26347 1.91858L6.29847 2.01192L6.76922 3.38858C6.8771 3.7043 7.05144 3.99321 7.28047 4.23583C7.5095 4.47845 7.7879 4.66912 8.09689 4.795L8.22347 4.84225L9.60014 5.31242C10.621 5.66125 10.6519 7.07175 9.69347 7.48533L9.60014 7.52033L8.22347 7.99108C7.90764 8.09889 7.61862 8.2732 7.3759 8.50223C7.13318 8.73127 6.94241 9.0097 6.81647 9.31875L6.76922 9.44475L6.29905 10.822C5.95022 11.8428 4.53972 11.8737 4.12672 10.9153L4.09055 10.822L3.62039 9.44533C3.51258 9.12951 3.33827 8.84048 3.10924 8.59776C2.8802 8.35504 2.60177 8.16427 2.29272 8.03833L2.16672 7.99108L0.790054 7.52092C-0.231363 7.17208 -0.26228 5.76158 0.69672 5.34858L0.790054 5.31242L2.16672 4.84225C2.48244 4.73437 2.77135 4.56003 3.01397 4.331C3.25658 4.10197 3.44726 3.82357 3.57314 3.51458L3.62039 3.38858L4.09055 2.01133ZM9.86147 0C9.9706 0 10.0775 0.0306123 10.1701 0.0883584C10.2627 0.146104 10.3373 0.228668 10.3853 0.326667L10.4133 0.394917L10.6175 0.993417L11.2166 1.19758C11.3259 1.23474 11.4218 1.30353 11.492 1.39523C11.5623 1.48693 11.6037 1.59741 11.611 1.71268C11.6184 1.82795 11.5914 1.94281 11.5334 2.04271C11.4755 2.14261 11.3891 2.22305 11.2854 2.27383L11.2166 2.30183L10.6181 2.506L10.4139 3.10508C10.3767 3.21442 10.3078 3.31024 10.2161 3.38041C10.1244 3.45058 10.0139 3.49194 9.89859 3.49925C9.78333 3.50656 9.66849 3.47949 9.56863 3.42147C9.46876 3.36345 9.38837 3.27709 9.33764 3.17333L9.30964 3.10508L9.10547 2.50658L8.50639 2.30242C8.39702 2.26526 8.30115 2.19647 8.23092 2.10477C8.16069 2.01307 8.11926 1.90259 8.11189 1.78732C8.10452 1.67205 8.13153 1.55719 8.18951 1.45729C8.24749 1.35739 8.33381 1.27695 8.43755 1.22617L8.50639 1.19817L9.10489 0.994L9.30905 0.394917C9.34839 0.279665 9.42281 0.179613 9.52187 0.108791C9.62094 0.0379686 9.73969 -0.0000730808 9.86147 0Z" fill="currentColor"/></svg>';function p(t,e={}){let o=document.createElement(t);if(e.style&&(o.style.cssText=e.style),e.text!=null&&(o.textContent=e.text),e.html!=null&&(o.innerHTML=e.html),e.attrs)for(let r in e.attrs)o.setAttribute(r,e.attrs[r]);if(e.on)for(let r in e.on)o.addEventListener(r,e.on[r]);if(e.children)for(let r of e.children)r&&o.appendChild(r);return o}function ot(t){return p("span",{style:`width:24px;height:24px;padding:2px;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:oo})}function Me(t){return p("span",{style:`width:12px;height:12px;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:no})}function nt(t){return t.borderWidth>0&&t.borderColor?`${t.borderWidth}px solid ${t.borderColor}`:"none"}function it(){if(!document.getElementById("mk-jakarta-font"))try{document.head.appendChild(p("link",{attrs:{id:"mk-jakarta-font",rel:"stylesheet",href:"https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap"}}))}catch(t){}}function io(t){return t.subtext?p("span",{style:`display:flex;align-items:center;justify-content:center;padding:4px;background:${t.badgeBgColor};font-family:${w};font-weight:700;font-size:16px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,text:t.subtext}):null}function Ue(t,e){it();let o=p("span",{style:"display:inline-flex;align-items:center;gap:4px;",children:[ot(t.textColor),p("span",{text:t.text,style:`font-family:${w};font-weight:700;font-size:${t.fontSize}px;text-transform:uppercase;letter-spacing:2px;color:${t.textColor};white-space:nowrap;text-align:center;line-height:1;`})]});return p("button",{attrs:{type:"button"},style:`display:flex;align-items:center;justify-content:center;gap:8px;padding:8px;width:100%;max-width:238px;box-sizing:border-box;background:${t.bgColor};border:${nt(t)};border-radius:${t.borderRadiusPx};font-family:${w};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[o,io(t)],on:{mouseenter:r=>{r.currentTarget.style.opacity="0.85"},mouseleave:r=>{r.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(r){}}}})}function co(t){return t.subtext?p("span",{style:`display:flex;align-items:center;gap:4px;padding:4px;background:${t.badgeBgColor};font-family:${w};font-weight:600;font-size:10px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,children:[Me(t.badgeTextColor),p("span",{text:t.subtext})]}):null}function lo(t,e){return p("button",{attrs:{type:"button"},style:`display:flex;align-items:center;justify-content:center;gap:8px;padding:8px 12px 8px 8px;width:100%;margin-top:auto;box-sizing:border-box;background:${t.bgColor};border:${nt(t)};border-radius:${t.borderRadiusPx};filter:drop-shadow(0 0 6px rgba(0,0,0,0.08));font-family:${w};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[ot(t.textColor),p("span",{text:t.text,style:`font-family:${w};font-weight:700;font-size:${t.fontSize}px;color:${t.textColor};white-space:nowrap;line-height:1;`})],on:{mouseenter:o=>{o.currentTarget.style.opacity="0.85"},mouseleave:o=>{o.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(o){}}}})}function De(t,e){it();let o=p("div",{style:"display:flex;flex-direction:column;gap:4px;",children:[t.cardTitle&&p("p",{text:t.cardTitle,style:`margin:0;font-family:${w};font-weight:700;font-size:16px;letter-spacing:1px;text-transform:uppercase;color:${t.cardTitleColor};line-height:1.2;`}),t.cardDescription&&p("p",{html:t.cardDescription,style:`margin:0;font-family:${w};font-weight:400;font-size:12px;max-width:177px;line-height:1.2;color:${t.cardTextColor};`})]}),r=p("div",{style:"display:flex;flex-direction:column;justify-content:space-between;gap:16px;flex:1 1 0;min-width:0;",children:[o,t.cardFooter&&p("p",{text:t.cardFooter,style:`margin:0;font-family:${w};font-weight:400;font-size:10px;color:${t.cardTextColor};line-height:1.2;`})]}),n=p("div",{style:"display:flex;flex-direction:column;align-items:flex-end;flex:1 1 0;min-width:0;",children:[co(t),lo(t,e)]}),i=p("div",{style:"display:flex;gap:16px;align-items:stretch;width:100%;flex:1;box-sizing:border-box;",children:[r,n]});return p("div",{style:`display:flex;flex-direction:column;align-items:flex-start;padding:12px;width:100%;max-width:402px;min-height:140px;box-sizing:border-box;background:${t.cardBgColor};border-radius:${t.cardBorderRadiusPx};font-family:${w};`,children:[i]})}var uo={style:"gregory-black",text:"Provar Virtualmente",fontSize:14,subtext:"",bgColor:"#1E1E1E",textColor:"#FFFFFF",badgeBgColor:"#C51A1B",badgeTextColor:"#FFFFFF",borderRadius:"md",borderColor:"#1E1E1E",borderWidth:0,cardTitle:"",cardDescription:"",cardFooter:"",cardBgColor:"#F6F6F6",cardTitleColor:"#1E1E1E",cardTextColor:"#717171",cardBorderRadius:"md"};function jt(t,e){let o=(e?t&&t.mobile:t&&t.desktop)||t&&t.desktop||t&&t.mobile||{},r={...uo,...o};return r.style==="gregory-card"&&e&&(r.style="gregory-black"),r.borderRadiusPx=Pt[r.borderRadius]!=null?Pt[r.borderRadius]:"0",r.cardBorderRadiusPx=Rt[r.cardBorderRadius]!=null?Rt[r.cardBorderRadius]:"0",r.fontSize=Number(r.fontSize)||14,r.borderWidth=Number(r.borderWidth)||0,r}var Bt={"gregory-black":Ue,"gregory-card":De},cn=Object.keys(Bt);function Fe(t,e){return(Bt[t.style]||Bt["gregory-black"])(t,e)}var Ut="mk-tryon-button-host",po=/^(transform|transform-origin|margin|margin-(top|right|bottom|left)|position|inset|top|right|bottom|left|z-index|width|min-width|max-width|height|min-height|max-height)$/i;function fo(t){return!t||typeof t!="string"?"":t.split(";").map(e=>e.trim()).filter(Boolean).filter(e=>po.test(e.split(":")[0].trim().toLowerCase())).join(";")}var at=null,Ot=!1,Nt={},qe=!1,Mt=null;function ze(){return Mt||(Mt=R().then(t=>t&&t.template&&t.template.tryOnButton||null).catch(()=>null)),Mt}function mo(){if(qe)return;qe=!0;let t=null;try{window.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{at&&O("pdp")},200)})}catch(e){}}function Dt(){let t=document.getElementById(Ut);if(t){if(typeof t.__mkCleanup=="function")try{t.__mkCleanup()}catch(e){}t.parentNode&&t.parentNode.removeChild(t)}at=null}var ho={IMG:1,INPUT:1,VIDEO:1,CANVAS:1,EMBED:1,OBJECT:1,IFRAME:1,BR:1,HR:1,SELECT:1,TEXTAREA:1,SVG:1};function go(t){switch(t){case"top-center":return"top:0;left:50%;transform:translateX(-50%);";case"top-right":return"top:0;right:0;";case"middle-left":return"top:50%;left:0;transform:translateY(-50%);";case"center":return"top:50%;left:50%;transform:translate(-50%,-50%);";case"middle-right":return"top:50%;right:0;transform:translateY(-50%);";case"bottom-left":return"bottom:0;left:0;";case"bottom-center":return"bottom:0;left:50%;transform:translateX(-50%);";case"bottom-right":return"bottom:0;right:0;";case"top-left":default:return"top:0;left:0;"}}function yo(t,e,o){let n=!ho[t.tagName]?t:t.parentElement||document.body;try{getComputedStyle(n).position==="static"&&(n.style.position="relative")}catch(d){}if(n===t){e.style.cssText="position:absolute;z-index:2147483000;"+go(o),t.appendChild(e);return}e.style.cssText="position:absolute;z-index:2147483000;",n.appendChild(e);let i=()=>{try{let d=t.getBoundingClientRect(),m=n.getBoundingClientRect(),g=e.offsetWidth,c=e.offsetHeight,x=d.top-m.top+n.scrollTop,A=d.left-m.left+n.scrollLeft,y=o||"top-left",$=x,S=A;y.indexOf("bottom")===0?$=x+d.height-c:(y.indexOf("middle")===0||y==="center")&&($=x+(d.height-c)/2),y.indexOf("right")>=0?S=A+d.width-g:y.indexOf("center")>=0&&(S=A+(d.width-g)/2),e.style.top=$+"px",e.style.left=S+"px"}catch(d){}};i();let a=()=>i();window.addEventListener("resize",a);let s=setTimeout(i,600),u=setTimeout(i,1500);e.__mkCleanup=()=>{window.removeEventListener("resize",a),clearTimeout(s),clearTimeout(u)}}function wo(t,e,o){try{return t.insertAdjacentElement(o||"afterend",e),!0}catch(r){try{return t.parentNode.insertBefore(e,t.nextSibling),!0}catch(n){return!1}}}async function O(t){let e=f();if(t!=="pdp"){Dt();return}if(!e.projectId)return;if(!e._anchorFromPicker){let u=await ze();u&&u.anchor&&(e.anchor=u.anchor)}if(Ot)return;let o=F(),r=o&&o.value,n=!!e.forceButton,i=It(e.anchor),a=[r||"demo",i?[i.selector,i.position,i.mode,i.align,i.style].join("~"):"heuristic"].join("|"),s=document.getElementById(Ut);if(!(s&&at===a)){if(s&&Dt(),!r&&!n){h("auto-mount: SKU n\xE3o resolvido na PDP");return}Ot=!0;try{let u=n;n||(Nt[r]||(Nt[r]=B(e.projectId,r).then(k=>!!(k&&k.available)).catch(()=>!1)),u=await Nt[r]);try{Xt(u?"available":"unavailable")}catch(k){}if(!u){h("auto-mount: produto sem try-on",r);return}let d=await ze(),m=window.matchMedia("(max-width: 767px)").matches,g=jt(d,m),c=Ne(),x=c&&c.mode||"flow",A=Fe(g,()=>{let k=F(),ct=k&&k.value||r||"";l("button_clicked",{sku:ct,style:g.style,mode:x}),rt({projectId:e.projectId,identifier:ct})}),y=document.createElement("div");y.id=Ut,y.attachShadow({mode:"closed"}).appendChild(A);let S=!1;if(c&&c.el&&c.el.parentNode&&(x==="overlay"?(yo(c.el,y,c.align),S=!0):(y.style.cssText="display:contents;",S=wo(c.el,y,c.position))),S||(y.style.cssText="position:fixed;left:16px;bottom:16px;z-index:2147483000;",document.body.appendChild(y)),c&&c.style){let k=fo(c.style);if(k)try{A.style.cssText+=";"+k}catch(ct){}}at=a,mo(),h("auto-mount: bot\xE3o injetado",{style:g.style,sku:r,anchorFound:!!c,position:c&&c.position,mode:x,forced:n}),l("button_rendered",{style:g.style,sku:r||null,skuSource:o&&o.source,anchorFound:!!c,position:c?c.position:null,mode:x,forced:n})}finally{Ot=!1}}}function $e(){try{let t=f(),e={anchor:t.anchor,forceButton:t.forceButton};window.addEventListener("message",o=>{if(o.source!==window)return;let r=o.data;!r||!r.__mkCmd||(r.__mkCmd==="remount"||r.__mkCmd==="applyRecipe"?(t.anchor=r.anchor||null,t._anchorFromPicker=!0,t.forceButton=!0,O("pdp")):r.__mkCmd==="cancelPreview"&&(t.anchor=e.anchor,t._anchorFromPicker=!1,t.forceButton=e.forceButton,Dt(),O("pdp")))})}catch(t){}}(function(){"use strict";try{let o=function(){try{Qt(),$e(),Ae(),e.autoTrack!==!1&&(he((n,i)=>{be(n,i),O(n)}),ke()),h("mk-sdk iniciado",{projectId:e.projectId,collectorUrl:e.collectorUrl})}catch(n){e.debug&&console.error("[mk-sdk] init erro",n)}},e=st();if(e.projectId){let n=oe(e.projectId);n&&ht(n),R().then(i=>{let a=ee(i);ht(a),ne(e.projectId,a),h("escopo de coleta",a)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o):o();let r={open:rt,close:Et,isAvailable:Se,getAvailability:B,onReady:Le,onClose:Ie,onAddToCart:Pe,onProductLoaded:Re,onError:je,onInteraction:Be,onGenerationComplete:Oe,_version:"0.1.0",_isMkSdk:!0};typeof window!="undefined"&&(window.mk=r)}catch(e){typeof console!="undefined"&&console.error("[mk-sdk] boot fatal",e)}})();})();
1
+ (()=>{var He=Object.defineProperty;var E=(t,e)=>{for(var o in e)He(t,o,{get:e[o],enumerable:!0})};var st={collectorUrl:"https://api-collector.mk3dlabs.com",appUrl:"https://mkfashion.mk3dlabs.com/visualizer",apiUrl:"https://mkfashion-new-api.mk3dlabs.com"},Ve={},N=null;function ut(){if(N)return N;let t=null;try{t=document.currentScript||document.querySelector("script[data-mk-project]")||document.querySelector('script[src*="mk-sdk"]')||document.querySelector('script[src*="mk-pixel"]')}catch(i){}let e=i=>{try{return t&&t.getAttribute(i)}catch(a){return null}},o=e("data-mk-project")||e("data-mk-client")||window.__MK&&(window.__MK.projectId||window.__MK.clientSlug)||null,r=e("data-mk-product")||window.__MK&&window.__MK.product||"mk-fashion",n=e("data-mk-collector")||window.__MK&&window.__MK.collectorUrl||Ve.collectorUrl||st.collectorUrl;return N={projectId:o,product:r,collectorUrl:n,appUrl:window.__MK&&window.__MK.appUrl||st.appUrl,apiUrl:window.__MK&&window.__MK.apiUrl||st.apiUrl,debug:!!(e("data-mk-debug")!==null||window.__MK&&window.__MK.debug||/[?&]mkdebug\b/.test(location.search)),observe:!!(window.__MK&&window.__MK.observe),forceButton:!!(window.__MK&&window.__MK.forceButton),anchor:window.__MK&&window.__MK.anchor||null,cartRedirect:!(window.__MK&&window.__MK.cartRedirect===!1),cartBehavior:window.__MK&&window.__MK.cartBehavior||null,cartOpenSelector:window.__MK&&window.__MK.cartOpenSelector||null,autoTrack:e("data-mk-no-autotrack")===null,batchIntervalMs:2e3,batchMaxSize:20,engagementIntervalMs:15e3},N}function f(){return N||ut()}function h(...t){let e=f();e&&e.debug&&typeof console!="undefined"&&console.log("[mk-sdk]",...t)}var Ft="_mk_vid",qt="_mk_sid",M=null,D=null;function K(){return typeof crypto!="undefined"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function zt(){if(M)return M;try{let t=localStorage.getItem(Ft);return t||(t="v_"+K(),localStorage.setItem(Ft,t)),M=t,t}catch(t){return M="v_"+K(),M}}function $t(){if(D)return D;try{let t=sessionStorage.getItem(qt);return t||(t="s_"+K(),sessionStorage.setItem(qt,t)),D=t,t}catch(t){return D="s_"+K(),D}}var Kt=[/email/i,/e-?mail/i,/cpf/i,/cnpj/i,/phone/i,/telefone/i,/celular/i,/address/i,/endereco/i,/cep/i,/zip/i,/card/i,/cartao/i,/cvv/i,/password/i,/senha/i,/token/i,/\bnome\b/i,/fullname/i,/firstname/i,/lastname/i,/sobrenome/i,/birth/i,/nascimento/i,/rg\b/i],Ht={imageUrl:1,image:1,thumbnail:1,photo:1,imageBase64:1,src:1},dt=2e3;function Vt(t){for(let e=0;e<Kt.length;e++)if(Kt[e].test(t))return!0;return!1}function Jt(t){if(!t||typeof t!="object"||Array.isArray(t))return typeof t=="string"&&t.length>dt?t.slice(0,200)+"...[truncated "+t.length+"B]":t;let e={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||Vt(o))continue;let r=t[o];if(Ht[o]){e[o+"Present"]=!!r;continue}if(typeof r=="string"&&r.length>dt){e[o]=r.slice(0,200)+"...[truncated "+r.length+"B]";continue}if(r&&typeof r=="object"&&!Array.isArray(r)){e[o]=Je(r);continue}e[o]=r}return e}function Je(t){let e={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||Vt(o))continue;let r=t[o];if(Ht[o]){e[o+"Present"]=!!r;continue}if(typeof r=="string"&&r.length>dt){e[o]=r.slice(0,200)+"...[truncated]";continue}e[o]=r}return e}var H=[],pt=null,L=null,Ge=["off","pdp_tryon","pdp","all"],ft,mt=null,V="unknown",I=[];function Wt(t){if(ft===void 0)return"hold";switch(ft){case"off":return"drop";case"all":return"collect";case"pdp":return t==="pdp"?"collect":"drop";case"pdp_tryon":return t!=="pdp"?"drop":V==="available"?"collect":V==="unavailable"?"drop":"hold";default:return"collect"}}function ht(t){if(!I.length)return;let e=[];for(let o of I){let r=Wt(o._pt);r==="collect"?Zt(o.name,o.params,o.ts):r==="hold"&&!t&&e.push(o)}I=e}function gt(t){ft=Ge.indexOf(t)>=0?t:"all",ht(!1)}function Xt(t){V=t==="available"?"available":"unavailable",ht(!1)}function Yt(t){ht(!0),L=t,mt=t&&t.pageType||null,V="unknown"}function l(t,e,o){if(!f().projectId){(l._pre=l._pre||[]).push({name:t,params:e,ts:o||Date.now()}),l._pre.length>50&&l._pre.shift();return}if(l._pre&&l._pre.length){let n=l._pre;l._pre=[];for(let i of n)Gt(i.name,i.params,i.ts)}Gt(t,e,o)}function Gt(t,e,o){let r=Wt(mt);if(r==="collect"){Zt(t,e,o);return}if(r==="drop"){h("descartado (escopo)",t);return}I.push({name:t,params:e,ts:o||Date.now(),_pt:mt}),I.length>300&&I.shift()}function Zt(t,e,o){let r=f(),n=Jt(e||{}),i="page_"+We(t);if(H.push({name:i,ts:o||Date.now(),params:n}),h("queued",t,n),r.observe)try{window.postMessage({__mkpixel:!0,event:{name:i,params:n},site:L?{pageType:L.pageType,platform:L.platform,url:L.url}:null},"*")}catch(a){}if(H.length>=r.batchMaxSize){U();return}pt||(pt=setTimeout(()=>{pt=null,U()},r.batchIntervalMs))}function We(t){if(typeof t!="string"||!t)return"unknown";let e=t.replace(/^on/,"");return e=e.replace(/[A-Z]/g,(o,r)=>(r>0?"_":"")+o.toLowerCase()),e.indexOf("page_")===0&&(e=e.slice(5)),e}function U(t){if(H.length===0)return;let e=f();if(!e.projectId||!e.collectorUrl)return;let o=H.splice(0,50),r=JSON.stringify({product:e.product||void 0,visitorId:zt(),sessionId:$t(),events:o,site:L||void 0}),n=e.collectorUrl+"/v1/track";if(t&&navigator.sendBeacon)try{let i=new Blob([r],{type:"application/json"});navigator.sendBeacon(n+"?projectId="+encodeURIComponent(e.projectId),i);return}catch(i){}fetch(n,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","X-MK-Project-Id":e.projectId},body:r}).catch(()=>{})}function Qt(){try{window.addEventListener("pagehide",()=>U(!0)),window.addEventListener("beforeunload",()=>U(!0)),document.addEventListener("visibilitychange",()=>{document.hidden&&U(!0)})}catch(t){}}function _(t){let e=[];try{let o=document.querySelectorAll('script[type="application/ld+json"]');for(let r of o){let n;try{n=JSON.parse(r.textContent)}catch(a){continue}let i=[];Array.isArray(n)?i.push(...n):n["@graph"]?i.push(...n["@graph"]):i.push(n);for(let a of i){if(!a||!a["@type"])continue;let s=Array.isArray(a["@type"])?a["@type"]:[a["@type"]];(!t||t.some(u=>s.includes(u)))&&e.push(a)}}}catch(o){}return e}var te=["off","pdp_tryon","pdp","all"],Xe="all",Ye=30*60*1e3,P=null;function R(){if(P)return P;let t=f();return!t.projectId||!t.apiUrl?(P=Promise.resolve(null),P):(P=fetch(t.apiUrl+"/projects/"+t.projectId).then(e=>e.ok?e.json():null).then(e=>e&&e.project||e||null).catch(()=>null),P)}function ee(t){let e=t&&t.analytic&&t.analytic.scope;return te.indexOf(e)>=0?e:Xe}var re=t=>"mk_scope_"+t;function oe(t){try{let e=localStorage.getItem(re(t));if(!e)return null;let o=JSON.parse(e);return!o||typeof o.exp!="number"||o.exp<Date.now()?null:te.indexOf(o.scope)>=0?o.scope:null}catch(e){return null}}function ne(t,e){try{localStorage.setItem(re(t),JSON.stringify({scope:e,exp:Date.now()+Ye}))}catch(o){}}var yt={};E(yt,{addToCart:()=>er,detect:()=>Qe,id:()=>Ze,openCartDrawer:()=>nr,resolveSku:()=>tr});var Ze="shopify";function Qe(){return!!(window.Shopify||window.ShopifyAnalytics)}function tr(){let t=window;return t.ShopifyAnalytics&&t.ShopifyAnalytics.meta&&t.ShopifyAnalytics.meta.product?{value:String(t.ShopifyAnalytics.meta.product.id),source:"shopify"}:null}var J=t=>String(t==null?"":t).trim().toLowerCase();async function er({size:t,color:e,sku:o,quantity:r}){let n=(location.pathname.split("/products/")[1]||"").split(/[?#]/)[0];if(!n)throw new Error("shopify: sem handle de produto na URL (n\xE3o \xE9 PDP?)");let a=(await fetch("/products/"+n+".js").then(c=>c.json())).variants||[],s=c=>[c.option1,c.option2,c.option3].concat(String(c.title||"").split("/")).map(J).filter(Boolean),u=(c,x)=>s(c).indexOf(J(x))>=0,d=c=>(!t||u(c,t))&&(!e||u(c,e)),m=null;if((t||e)&&(m=a.find(c=>d(c)&&c.available)||a.find(d)),!m&&o&&(m=a.find(c=>J(c.sku)===J(o))),m||(m=a.find(c=>c.available)||a[0]),!m)throw new Error("shopify: variante n\xE3o encontrada");let g=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:m.id,quantity:r||1}]})});if(!g.ok)throw new Error("shopify: /cart/add.js HTTP "+g.status);return{platform:"shopify",variantId:m.id,size:m.title,sku:m.sku||null}}var rr=["[data-cart-drawer-toggle]",'[data-action="open-cart-drawer"]','[data-action="open-cart"]',".js-cart-drawer-open",".js-drawer-open-cart",".cart-drawer-toggle",".js-cart-toggle",'[aria-controls="CartDrawer"]','[aria-controls="cart-drawer"]',"#cart-icon-bubble","#lk-cart-icon",".header__cart",".site-header__cart",".cart-link",".header-cart",'a[href="/cart"]','a[href$="/cart"]'];function or(t){try{let e=t.getBoundingClientRect();return e.width>0&&e.height>0&&getComputedStyle(t).visibility!=="hidden"}catch(e){return!1}}function nr(){let t=null;for(let e of rr)try{if(t=[...document.querySelectorAll(e)].find(or),t)break}catch(o){}return t?(setTimeout(()=>{try{t.click()}catch(e){}},300),!0):!1}var wt={};E(wt,{addToCart:()=>lr,detect:()=>ar,id:()=>ir,openCartDrawer:()=>ur,resolveSku:()=>cr});var ir="hybris";function ar(){return!!(window.ACC&&window.ACC.config)}function cr(){let t=(location.pathname||"").match(/\/p\/([^/?#]+)/);return t&&t[1]?{value:decodeURIComponent(t[1]),source:"hybris/url"}:null}var ie=t=>String(t==null?"":t).trim().toLowerCase();async function lr({size:t,quantity:e}){let o=[...document.querySelectorAll('.js-product-select-size, a[data-code], [class*="select-size"]')].filter(g=>g.getAttribute&&g.getAttribute("data-code")),r=t?o.find(g=>ie(g.textContent)===ie(t)):null;r||(r=o.find(g=>g.offsetParent!==null)||o[0]);let n=r&&r.getAttribute("data-code");if(!n)throw new Error("hybris: variante (data-code) n\xE3o encontrada");let i=document.getElementById("product--add-to-cart-form")||document.querySelector('form[action*="/cart/add"]'),a=i&&i.querySelector('[name="CSRFToken"]'),s=a&&a.value,u=i&&i.getAttribute("action")||"/cart/add";if(!s)throw new Error("hybris: CSRFToken n\xE3o encontrado");let d=new URLSearchParams;d.set("productCodePost",n),d.set("qty",String(e||1)),d.set("CSRFToken",s);let m=await fetch(u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:d.toString()});if(!m.ok)throw new Error("hybris: "+u+" HTTP "+m.status);return{platform:"hybris",productCode:n,size:r.textContent.trim()}}function sr(t){try{let e=t.getBoundingClientRect();return e.width>0&&e.height>0&&getComputedStyle(t).visibility!=="hidden"}catch(e){return!1}}function ur(){let t=document.querySelector(".js-load-mini-cart-menu");if(!t||!sr(t)||(window.innerWidth||0)<992)return!1;try{window.ACC&&window.ACC.minicart&&typeof window.ACC.minicart.updateMiniCartDisplay=="function"&&window.ACC.minicart.updateMiniCartDisplay()}catch(e){}return setTimeout(()=>{try{t.click()}catch(e){}},350),!0}var xt={};E(xt,{addToCart:()=>mr,detect:()=>pr,id:()=>dr,resolveSku:()=>fr});var dr="vtex";function pr(){return!!(window.vtex||window.vtexjs||window.vtxctx||window.skuJson_0)}function fr(){let t=window;return t.vtxctx&&t.vtxctx.skus&&t.vtxctx.skus[0]?{value:String(t.vtxctx.skus[0]),source:"vtex/vtxctx"}:t.skuJson_0&&t.skuJson_0.skus&&t.skuJson_0.skus[0]?{value:String(t.skuJson_0.skus[0].sku),source:"vtex/skuJson"}:null}var G=t=>String(t==null?"":t).trim().toLowerCase();async function mr({size:t,quantity:e}){let o=window.skuJson_0&&window.skuJson_0.skus||[];if(!o.length)throw new Error("vtex: skuJson_0 indispon\xEDvel");let r=i=>G(i.skuname)===G(t)||i.dimensions&&Object.values(i.dimensions).some(a=>G(a)===G(t)),n=t?o.find(i=>r(i)&&i.available)||o.find(r):null;if(n||(n=o.find(i=>i.available)||o[0]),!n)throw new Error("vtex: variante n\xE3o encontrada");if(window.vtexjs&&window.vtexjs.checkout&&window.vtexjs.checkout.addToCart)return await window.vtexjs.checkout.addToCart([{id:parseInt(n.sku,10),quantity:e||1,seller:"1"}]),{platform:"vtex",skuId:n.sku,size:n.skuname||t};throw new Error("vtex: vtexjs.checkout indispon\xEDvel")}var bt={};E(bt,{addToCart:()=>xr,detect:()=>yr,id:()=>hr,resolveSku:()=>wr,skipRedirect:()=>gr});var hr="nuvemshop",gr=!0;function yr(){return!!(window.LS&&(window.LS.cart||window.LS.addToCart))}function wr(){try{let t=window.LS,e=t&&t.variants||[],o=document.querySelector('[name="variant_id"]'),r=o&&o.value?e.find(n=>String(n.id)===String(o.value)):null;if(r||(r=e.find(n=>n.available!==!1&&n.sku)||e.find(n=>n.sku)||e[0]),r&&r.sku)return{value:String(r.sku),source:"nuvemshop/variant"};if(t&&t.product&&t.product.sku)return{value:String(t.product.sku),source:"nuvemshop/product"}}catch(t){}return null}var W=t=>String(t==null?"":t).trim().toLowerCase();async function xr({size:t,quantity:e}){let o=document.getElementById("product_form")||document.querySelector('.js-product-form, form[action*="/comprar"]');if(!o)throw new Error("nuvemshop: #product_form n\xE3o encontrado");t&&o.querySelectorAll('select[name^="variation"]').forEach(i=>{let a=[...i.options].find(s=>W(s.textContent).includes(W(t))||W(s.value)===W(t));a&&(i.value=a.value,i.dispatchEvent(new Event("change",{bubbles:!0})))});let r=o.querySelector('[name="quantity"]');return r&&e&&(r.value=String(e)),await new Promise(i=>setTimeout(i,400)),typeof o.requestSubmit=="function"?o.requestSubmit():o.submit(),{platform:"nuvemshop",variantId:(o.querySelector('[name="variant_id"]')||{}).value||null}}var Ct={};E(Ct,{addToCart:()=>vr,detect:()=>kr,id:()=>br,resolveSku:()=>_r,skipRedirect:()=>Cr});var br="wake",Cr=!0;function kr(){return!!(window.StorefrontClient||typeof window.addOrCreateCheckout=="function"||typeof window.addToCartClick=="function")}function _r(){try{let t=document.querySelector('input[name="product-id"], [data-product-id]'),e=t?t.value||t.getAttribute("data-product-id"):null;if(e)return{value:String(e).trim(),source:"wake/product-id"};let o=(location.pathname||"").match(/-(\d+)\/?(?:[?#]|$)/);if(o)return{value:o[1],source:"wake/url"}}catch(t){}return null}var ae=t=>String(t==null?"":t).trim().toLowerCase();async function vr({size:t,quantity:e}){if(t){let i=[...document.querySelectorAll("input[attribute-value]")].find(a=>ae(a.getAttribute("attribute-value"))===ae(t));if(i){try{i.checked=!0}catch(a){}try{typeof window.selectAttribute=="function"?window.selectAttribute(i):i.click()}catch(a){}await new Promise(a=>setTimeout(a,600))}}let o=document.querySelector('[name="product-variant-id"]'),r=o&&o.value;if(!r)throw new Error("wake: product-variant-id n\xE3o encontrado");if(typeof window.addOrCreateCheckout!="function")throw new Error("wake: addOrCreateCheckout indispon\xEDvel");if(!await window.addOrCreateCheckout([{productVariantId:Number(r),quantity:e||1,customization:[]}]))throw new Error("wake: addOrCreateCheckout retornou false");return{platform:"wake",productVariantId:r,size:t||null}}var _t={};E(_t,{addToCart:()=>X,detect:()=>Tr,id:()=>Sr,resolveSku:()=>kt});var Sr="generic";function Tr(){return!0}function kt(){let t=_(["Product"]);if(t[0]){let e=t[0],o=e.sku||e.mpn||e.gtin13||e.productID;if(o)return{value:String(o),source:"jsonld"}}try{let e=document.querySelector('[itemprop="sku"]');if(e){let o=e.getAttribute("content")||(e.textContent||"").trim();if(o)return{value:String(o),source:"microdata"}}}catch(e){}try{let e=window.konfidencyData;if(e&&e.product&&e.product.variants&&e.product.variants[0])return{value:String(e.product.variants[0]),source:"konfidency"}}catch(e){}return null}var Ar=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora/i,Er=/continuar|como comprar|lista|desejos|favorito/i;async function X(){let t=document.querySelectorAll("button,[role=button],input[type=submit]");for(let e of t){let o=(e.textContent||e.value||"").replace(/\s+/g," ").trim();if(o&&o.length<40&&Ar.test(o)&&!Er.test(o))try{return e.click(),{platform:"native-click",clicked:o}}catch(r){}}return{platform:"none",error:"bot\xE3o de carrinho nativo n\xE3o encontrado"}}var le=[yt,wt,xt,bt,Ct],Lr=[["woocommerce",()=>!!(window.wc_add_to_cart_params||window.woocommerce_params)],["lojaintegrada",()=>!!window.LojaIntegrada]],Y;function Z(){return Y||(Y=le.find(t=>{try{return t.detect()}catch(e){return!1}})||_t,Y)}function se(){let t=le.find(e=>{try{return e.detect()}catch(o){return!1}});if(t)return t.id;for(let[e,o]of Lr)try{if(o())return e}catch(r){}return null}function F(){let t=Z();if(t.id!=="generic"&&t.resolveSku)try{let e=t.resolveSku();if(e)return e}catch(e){}return kt()}async function ue(t){t=t||{};let e={size:t.size||t.selectedSize||t.tamanho||null,color:t.color||t.selectedColor||t.colour||t.cor||null,sku:t.sku||t.identifier||t.selectedIdentifier||null,quantity:t.quantity||1},o=Z();try{let r=o.addToCart?await o.addToCart(e):await X(e);return h("cart: adicionado",r),ce(),r}catch(r){h('cart: adapter "'+o.id+'" falhou \u2014 fallback clique nativo',r&&r.message);let n=await X(e);return ce(),n}}function ce(){["cart:refresh","cart:updated","cart:build","ajaxProduct:added","product:added-to-cart"].forEach(t=>{try{document.dispatchEvent(new CustomEvent(t))}catch(e){}})}async function de(){let t=Z(),e=f(),o=null;try{o=await R()}catch(i){}let r=o&&o.template&&o.template.cart||o&&o.cart||{},n=r.afterAdd||r.behavior||e.cartBehavior;if(n||(n=e.cartRedirect===!1?"none":"auto"),n==="none")return!1;if(n==="auto"||n==="drawer"){let i=r.openSelector||e.cartOpenSelector;if(i){let a=document.querySelector(i);if(a)return setTimeout(()=>{try{a.click()}catch(s){}},300),!1}else if(t&&t.openCartDrawer){let a=!1;try{a=t.openCartDrawer()}catch(s){}if(a)return!1}}return!0}function pe(){let t=Z();if(t&&t.skipRedirect)return;let e=t&&t.cartUrl||"/cart";setTimeout(()=>{try{window.location.href=e}catch(o){}},250)}var Ir=/\/(thank[_-]?you|orders?\/|pedido[_-]?(confirmado|realizado|finalizado|sucesso)|sucesso|order[_-]?confirmation|compra[_-]?(finalizada|concluida)|orderplaced)/i,Pr=/\/checkout/i,Rr=/\/(cart|carrinho|sacola|bag)(\/|$|\?|#)/i,jr=/\/(products?|produtos?|p)\//i,Br=/\/(collections?|categoria|categorias|c|departamento)\//i,Or=/\/(search|busca|s)(\/|\?)/i;function fe(){try{if(window.__mkPageType)return window.__mkPageType}catch(e){}try{let e=_();for(let o of e){let r=Array.isArray(o["@type"])?o["@type"]:[o["@type"]];if(r.includes("Order")||r.includes("Invoice"))return"purchase";if(r.includes("Product"))return"pdp";if(r.includes("SearchResultsPage"))return"search";if(r.includes("CollectionPage")||r.includes("ItemList"))return"category"}}catch(e){}let t=(location.pathname||"").toLowerCase();return t==="/"||t===""||t==="/home"||t==="/index.html"?"home":Ir.test(t)?"purchase":Pr.test(t)?"checkout":Rr.test(t)?"cart":jr.test(t)?"pdp":Br.test(t)?"category":Or.test(t)?"search":"other"}function me(t){let e=null;try{let o=new URLSearchParams(location.search),r=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],n={};for(let i of r){let a=o.get(i);a&&(n[i.replace("utm_","")]=a)}Object.keys(n).length&&(e=n)}catch(o){}return{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:t,utm:e,userAgent:navigator.userAgent,language:navigator.language,viewport:window.innerWidth+"x"+window.innerHeight,platform:Nr()}}function Nr(){return se()}var vt={},Mr=null,q=0,he=!1;function ge(t){he||(he=!0,ye(t),Dr(),Ur(),Fr(),qr(),zr(t))}function ye(t){vt={};let e=fe(),o=me(e);if(Yt(o),l("view",{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:e}),typeof t=="function")try{t(e,o)}catch(r){}}function Dr(){if(!document.body)return;let t={A:1,BUTTON:1,INPUT:1,SELECT:1,TEXTAREA:1},e=0;document.body.addEventListener("click",o=>{try{let r=Date.now();if(r-e<100)return;e=r;let n=o.target;for(let s=0;s<5&&n&&n!==document.body&&!(t[n.tagName]||n.getAttribute&&n.getAttribute("role")==="button");s++)n=n.parentElement;if(!n||!t[n.tagName]&&!(n.getAttribute&&n.getAttribute("role")==="button"))return;let i={tag:n.tagName},a=n.tagName==="INPUT"||n.tagName==="TEXTAREA"?n.value:n.textContent;i.text=(a||"").replace(/\s+/g," ").trim().substring(0,100),n.href&&(i.href=String(n.href).substring(0,500)),n.id&&(i.id=n.id),n.className&&typeof n.className=="string"&&(i.classes=n.className.trim().substring(0,200)),l("click",i)}catch(r){}},{capture:!0,passive:!0})}function Ur(){let t=[25,50,75,100],e=null,o=()=>{try{let r=window.scrollY||document.documentElement.scrollTop||0,n=Math.max(document.body&&document.body.scrollHeight||0,document.documentElement&&document.documentElement.scrollHeight||0);if(n<=0)return;let i=Math.min(100,Math.floor((r+window.innerHeight)/n*100));for(let a of t)i>=a&&!vt[a]&&(vt[a]=!0,l("scroll_depth",{depth:a}))}catch(r){}};o(),window.addEventListener("scroll",()=>{e||(e=setTimeout(()=>{e=null,o()},250))},{passive:!0})}function Fr(){document.body&&document.body.addEventListener("submit",t=>{try{let e=t.target;if(!e||e.tagName!=="FORM"||e.querySelector('input[type="password"], input[name*="card"], input[name*="cpf"]'))return;let o="other",r=(e.className||"").toLowerCase(),n=(e.action||"").toLowerCase();e.querySelector('input[type="search"], input[name="q"], input[name="s"]')?o="search":/newsletter|subscribe|mailchimp/.test(r+n)?o="newsletter":/contact|contato/.test(r+n)&&(o="contact"),l("form_submit",{form_id:e.id||"",form_type:o})}catch(e){}},{capture:!0})}function qr(){let t=f();q=Date.now(),Mr=setInterval(()=>{if(document.hidden)return;let e=Date.now(),o=Math.round((e-q)/1e3);q=e,o>0&&o<60&&l("engagement",{url:location.pathname,dwellSec:o})},t.engagementIntervalMs),document.addEventListener("visibilitychange",()=>{if(document.hidden){let e=Math.round((Date.now()-q)/1e3);e>0&&e<600&&l("engagement",{url:location.pathname,dwellSec:e})}q=Date.now()})}function zr(t){let e=location.href,o=()=>{location.href!==e&&(e=location.href,ye(t))};try{let r=history.pushState,n=history.replaceState;history.pushState=function(){r.apply(this,arguments),setTimeout(o,0)},history.replaceState=function(){n.apply(this,arguments),setTimeout(o,0)},window.addEventListener("popstate",o)}catch(r){}}function St(){let t=F(),e=_(["Product"]);if(e.length>0){let n=e[0],i=Array.isArray(n.offers)?n.offers[0]:n.offers;return{sku:t?t.value:n.sku||n.mpn||n.gtin13||n.productID||null,skuSource:t?t.source:null,name:typeof n.name=="string"?n.name:null,price:i&&parseFloat(i.price||i.lowPrice)||null,currency:i?i.priceCurrency:null,brand:n.brand?typeof n.brand=="string"?n.brand:n.brand.name:null,category:n.category||null}}let o=n=>{let i=document.querySelector('meta[property="og:'+n+'"], meta[property="product:'+n+'"]');return i?i.getAttribute("content"):null},r=n=>{let i=document.querySelector('[itemprop="'+n+'"]');return i?i.getAttribute("content")||(i.textContent||"").trim():null};if(t||o("type")==="product"||o("price:amount")||r("name")){let n=r("price")||o("price:amount");return{sku:t?t.value:null,skuSource:t?t.source:null,name:r("name")||o("title")||document.title||null,price:n&&parseFloat(String(n).replace(",","."))||null,currency:r("priceCurrency")||o("price:currency")||null,brand:r("brand")||null,category:null}}return null}function we(){let t=_(["Order","Invoice"]);if(t.length>0){let r=t[0],n=r.totalPaymentDue?parseFloat(r.totalPaymentDue.price):parseFloat(r.price||r.total);return{orderId:r.orderNumber||r.confirmationNumber||r.identifier||null,revenue:Number.isFinite(n)?n:null,currency:r.totalPaymentDue&&r.totalPaymentDue.priceCurrency||r.priceCurrency||null,source:"jsonld"}}try{if(Array.isArray(window.dataLayer))for(let r=window.dataLayer.length-1;r>=0;r--){let n=window.dataLayer[r];if(n&&n.event==="purchase"&&n.ecommerce){let i=n.ecommerce;return{orderId:i.transaction_id||i.transactionId||null,revenue:parseFloat(i.value||i.revenue)||null,currency:i.currency||i.currencyCode||null,itemCount:(i.items||i.products||[]).length||null,source:"datalayer"}}}}catch(r){}let e=document.querySelector('meta[property="order:total"], meta[name="order-total"]');if(e&&e.content)return{orderId:null,revenue:parseFloat(e.content)||null,source:"meta"};let o=$r();return o||null}function $r(){try{let t=[".order-total","#order-total",".total-price",".order__total","[data-order-total]",".summary-total",".grand-total"];for(let e of t){let o=document.querySelector(e);if(o){let r=Hr(o.textContent);if(r)return{orderId:Kr(),revenue:r,source:"dom"}}}return null}catch(t){return null}}function Kr(){try{let e=(document.body.innerText||"").match(/(?:pedido|order|n[º°o]\.?)\s*#?\s*([A-Z0-9-]{4,})/i);return e?e[1]:null}catch(t){return null}}function Hr(t){if(!t)return null;let e=String(t).replace(/[^\d.,]/g,"");if(!e)return null;let o;e.indexOf(",")>e.indexOf(".")?o=e.replace(/\./g,"").replace(",","."):o=e.replace(/,/g,"");let r=parseFloat(o);return Number.isFinite(r)&&r>0?r:null}function xe(){let t=_(["ItemList","CollectionPage"]);if(t.length===0)return null;let e=t[0],o=e.itemListElement||e.mainEntity&&e.mainEntity.itemListElement||[],r=[];for(let n of o.slice(0,50)){let i=n.item||n;i&&(i.sku||i.productID||i.name)&&r.push(i.sku||i.productID||i.name)}return r.length>0?{count:r.length,skus:r.slice(0,20)}:null}var be=!1,Q=[/\b(adicionar|adic\.?|colocar|incluir|jogar)\b.{0,30}\b(carrinho|sacola|sacolinha|bag)\b/i,/\bcomprar\b(?!\s+(em|por|sem))/i,/\bcomprar\s*$/i,/^add\s+to\s+(cart|bag)\b/i,/^buy\s+(now|it|this)\b/i,/^(sacolinha|carrinho|sacola)$/i],Vr=[/^finalizar(\s+(compra|pedido|pagamento))?\b/i,/^(fechar|confirmar)\s+(compra|pedido|pagamento)\b/i,/^pagar(\s+(agora|pedido))?\b/i,/^(complete|place)\s+(purchase|order)\b/i,/^checkout$/i];function z(t,e){for(let o=0;o<t.length;o++)if(t[o].test(e))return!0;return!1}function Ce(t){switch(t){case"pdp":{let e=St();l("view_item",e||{sku:null});break}case"category":case"search":{let e=xe();l("view_item_list",e||{count:0});break}case"cart":l("view_cart",{});break;case"checkout":l("begin_checkout",{});break;case"purchase":Jr();break}}function Jr(){let t=we();if(t&&t.orderId){let e="_mk_purch_"+t.orderId;try{if(sessionStorage.getItem(e)){h("purchase j\xE1 contado",t.orderId);return}sessionStorage.setItem(e,"1")}catch(o){}}else if(be)return;be=!0,l("purchase",t||{revenue:null,_note:"no_order_data_extracted"}),h("purchase emitido",t)}function ke(){if(!document.body)return;let t=0;document.body.addEventListener("click",e=>{try{let o=Date.now();if(o-t<150)return;let r=e.target;for(let s=0;s<5&&r&&r!==document.body&&!(r.tagName==="BUTTON"||r.tagName==="A"||r.getAttribute&&r.getAttribute("role")==="button");s++)r=r.parentElement;if(!r)return;let n=r.tagName!=="A",i=(r.textContent||"").replace(/\s+/g," ").trim();if(!i||i.length>80)return;let a=!1;if((z([Q[0]],i)||n&&z([Q[1]],i)||n&&z([Q[2]],i)||z(Q.slice(3),i))&&(a=!0),a){t=o;let s=St();l("add_to_cart",{via:"click",buttonText:i,sku:s?s.sku:null,price:s?s.price:null});return}n&&z(Vr,i)&&(t=o,l("begin_checkout",{via:"click",buttonText:i}))}catch(o){}},{capture:!0,passive:!0})}var k=null,v=null,et=!1,rt=!1,j=null,_e={},Tt=null,tt=0,b={onReady:null,onClose:null,onAddToCart:null,onProductLoaded:null,onError:null,onInteraction:null,onGenerationComplete:null},Gr={gregory:"698c7e791d3129430f15dddd"};function Se(t){return t?Gr[String(t).toLowerCase()]||t:null}async function B(t,e){let o=f(),r=Se(t);e=String(e||"").trim();let n=o.apiUrl+"/availability/"+r+"?sku="+encodeURIComponent(e),i=await fetch(n);if(!i.ok)throw new Error("availability HTTP "+i.status);return i.json()}async function Te(t,e){e||(e=t,t="698c7e791d3129430f15dddd");try{return(await B(t,e)).available===!0}catch(o){return!1}}async function ot(t){if(t=t||{},et)return;let e=Se(t.projectId||t.projectid||t.store),o=String(t.identifier||t.sku||"").trim();if(!e||!o){console.error("[mk-sdk] open: projectId e identifier obrigatorios");return}let r=e+":"+o;if(_e[r]!==!0){try{if(!(await B(e,o)).available){alert("Produto nao disponivel para prova virtual.");return}}catch(n){alert("Produto nao encontrado ou indisponivel.");return}_e[r]=!0}j={projectId:e,identifier:o,width:t.width||430,height:t.height||800},rt=!1,Le(),Wr(j),et=!0,tt=Date.now(),l("modal_opened",{projectId:e,identifier:o})}function Et(){if(!et)return;let t=rt;if(rt=!1,Xr(),et=!1,T("onClose"),l("modal_closed",{projectId:j&&j.projectId,identifier:j&&j.identifier}),t)try{pe()}catch(e){}}function Ae(t){try{let e=document.getElementById("mk-tryon-button-host");if(!e)return;t?(e.dataset.mkPrevDisplay===void 0&&(e.dataset.mkPrevDisplay=e.style.display),e.style.display="none"):(e.style.display=e.dataset.mkPrevDisplay||"",delete e.dataset.mkPrevDisplay)}catch(e){}}function Wr(t){k=document.createElement("div"),k.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,.8);display:flex;align-items:center;justify-content:center;z-index:2147483647;",Ae(!0);let e=document.createElement("div"),o=typeof t.width=="number"?t.width+"px":t.width,r=typeof t.height=="number"?t.height+"px":t.height;e.style.cssText="position:relative;width:"+o+";height:"+r+";max-width:100vw;max-height:100dvh;border-radius:12px;overflow:hidden;background:#fff;",v=document.createElement("iframe");let n=encodeURIComponent(t.identifier).replace(/\./g,"%2E");v.src=f().appUrl+"/"+t.projectId+"/"+n,v.style.cssText="width:100%;height:100%;border:none;",v.setAttribute("allow","camera *; microphone *"),v.setAttribute("allowfullscreen","true"),e.appendChild(v),k.appendChild(e),document.body.appendChild(k),h("try-on modal aberto",v.src)}function Xr(){k&&k.parentNode&&k.parentNode.removeChild(k),k=null,v=null,Ae(!1)}var ve=!1;function Ee(){Le()}function Le(){ve||(ve=!0,window.addEventListener("message",t=>{let e=t.data;if(!e||e.source!=="mkfashion-app")return;let o=e.action,r=e.data||{};switch(o){case"close_request":Et();break;case"ready":T("onReady",r);break;case"product_loaded":T("onProductLoaded",r),l("product_loaded",At(r));break;case"interaction":{T("onInteraction",r),r&&r.method&&(Tt=r.method),l(Yr(r),At(r));break}case"add_to_cart":l("add_to_cart",Object.assign({via:"tryon"},At(r))),typeof b.onAddToCart=="function"?T("onAddToCart",r):ue(r).then(()=>de()).then(n=>{rt=!!n}).catch(()=>{});break;case"generation_start":tt=Date.now();break;case"generation_complete":T("onGenerationComplete",r),l("generation_complete",{method:r.method||Tt||"unknown",durationMs:tt?Date.now()-tt:null,success:r.success!==!1,imageUrlPresent:!!r.imageUrl});break;case"generation_error":T("onError",r),l("generation_error",{method:Tt||"unknown",error:r&&r.error});break}}))}function Yr(t){return t&&t.action,"interaction"}function At(t){if(!t||typeof t!="object")return t;let e={};for(let o in t){if(o==="imageUrl"||o==="image"||o==="product"){o==="product"&&t[o]?(e.productSku=t[o].sku||null,e.productName=t[o].name||null):e[o+"Present"]=!!t[o];continue}e[o]=t[o]}return e}function T(t,e){if(typeof b[t]=="function")try{b[t](e)}catch(o){console.error("[mk-sdk]",o)}}function Ie(t){b.onReady=t}function Pe(t){b.onClose=t}function Re(t){b.onAddToCart=t}function je(t){b.onProductLoaded=t}function Be(t){b.onError=t}function Oe(t){b.onInteraction=t}function Ne(t){b.onGenerationComplete=t}var Qr=767,to=1024,eo=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora|^comprar$|finalizar compra|eu quero/i,ro=/continuar|como comprar|lista|desejos|favorito|looks|cupom/i;function Lt(t){try{let e=t.getBoundingClientRect();if(e.width<=0||e.height<=0)return!1;let o=getComputedStyle(t);return o.display!=="none"&&o.visibility!=="hidden"&&o.opacity!=="0"}catch(e){return!1}}function oo(t){if(!t)return!1;try{let e=document.querySelector(t);return!!e&&Lt(e)}catch(e){return!1}}function no(t){return(t.tagName==="INPUT"?t.value||"":t.textContent||"").replace(/\s+/g," ").trim()}function io(t){if(!t||typeof t!="object"||t.selector)return t;let e=!1;if(["mobile","tablet","desktop"].forEach(r=>{let n=t[r];n&&n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"&&(e=!0)}),!e)return t;let o={};return["mobile","tablet","desktop"].forEach(r=>{let n=t[r];if(n){if(n.selector){o[r]=n;return}if(n.mkAnchor===1&&n.anchor&&typeof n.anchor=="object"){let i=n.anchor[r]||n.anchor.desktop||n.anchor.mobile||n.anchor.tablet;i&&i.selector&&(o[r]=i)}}}),["bpMobile","bpTablet","breakpoint"].forEach(r=>{t[r]!=null&&(o[r]=t[r])}),o}function It(t){if(!t||typeof t!="object")return null;if(t=io(t),t.selector)return t;let e=[["mobile",t.mobile],["tablet",t.tablet],["desktop",t.desktop]].filter(u=>u[1]&&u[1].selector);if(e.length===0)return null;if(e.length===1)return e[0][1];let o=e.filter(([,u])=>oo(u.selector));if(o.length===1)return o[0][1];let r=window.innerWidth||1024,n=Number(t.bpMobile)||Number(t.breakpoint)||Qr,i=Number(t.bpTablet)||to,a=u=>(e.find(d=>d[0]===u)||[])[1],s=r<=n?["mobile","tablet","desktop"]:r<=i?["tablet","desktop","mobile"]:["desktop","tablet","mobile"];for(let u of s){let d=a(u);if(d)return d}return e[0][1]}function Me(){let t=f(),e=It(t&&t.anchor);if(e&&e.selector)try{let r=document.querySelector(e.selector);if(r&&Lt(r))return{el:r,position:e.position||"afterend",mode:e.mode||"flow",style:e.style||"",align:e.align||"top-left",selector:e.selector}}catch(r){}let o=document.querySelectorAll('button, [role="button"], a.btn, a.button, input[type="submit"], input[type="button"]');for(let r of o){let n=no(r);if(!(!n||n.length>40)&&!ro.test(n)&&eo.test(n)&&Lt(r))return{el:r,position:"afterend",mode:"flow",style:"",selector:null}}return null}var w="'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Pt={none:"0",sm:"4px",md:"8px",pill:"9999px"},Rt={none:"0",sm:"4px",md:"8px",lg:"16px"},ao='<svg viewBox="0 0 17.5263 20.6862" fill="none" xmlns="http://www.w3.org/2000/svg" style="display:block;width:100%;height:100%"><g><path d="M8.49995 12.1862C10.1568 12.1862 11.5 10.8431 11.5 9.18622C11.5 7.52936 10.1568 6.18622 8.49995 6.18622C6.8431 6.18622 5.49995 7.52936 5.49995 9.18622C5.49995 10.8431 6.8431 12.1862 8.49995 12.1862Z" stroke="currentColor" shape-rendering="crispEdges"/><path d="M0.5 9.11152C0.5 6.56953 0.5 5.29894 1.1099 4.38664C1.375 3.9902 1.71424 3.65088 2.10821 3.38809C2.6945 2.9958 3.42899 2.85564 4.55351 2.80588C5.09013 2.80588 5.55183 2.39949 5.65687 1.87284C5.73715 1.48708 5.94572 1.14138 6.24735 0.894155C6.54898 0.646934 6.92516 0.51336 7.31231 0.516006H9.9734C10.7779 0.516006 11.4709 1.08412 11.6288 1.87284C11.7339 2.39949 12.1956 2.80588 12.7322 2.80588C13.8559 2.85564 12.9129 4.67413 13.5 5.06559C13.8949 5.32932 15.1484 3.80355 15.5 4.02647C16.1099 4.93876 16.7857 6.56953 16.7857 9.11152C16.7857 11.6535 16.7857 12.9233 16.1758 13.8364C15.9107 14.2328 15.5715 14.5722 15.1775 14.835C14.2647 15.4445 12.9936 15.4445 10.4522 15.4445H6.83351C4.29213 15.4445 3.02103 15.4445 2.10821 14.835C1.71446 14.5718 1.3755 14.2322 1.11071 13.8356C0.933802 13.5672 0.803519 13.2698 0.725557 12.9564" stroke="currentColor" stroke-linecap="round"/><path d="M12.676 0.607931C12.9446 -0.178095 14.0307 -0.2019 14.3491 0.536515L14.3761 0.60838L14.7385 1.66839C14.8216 1.91149 14.9559 2.13395 15.1322 2.32076C15.3086 2.50757 15.5229 2.65439 15.7608 2.75131L15.8583 2.78769L16.9183 3.14971C17.7044 3.41831 17.7282 4.50437 16.9902 4.82283L16.9183 4.84978L15.8583 5.21225C15.6151 5.29526 15.3926 5.42947 15.2057 5.60582C15.0188 5.78218 14.8719 5.99657 14.7749 6.23453L14.7385 6.33155L14.3765 7.39201C14.1079 8.17803 13.0219 8.20184 12.7039 7.46387L12.676 7.39201L12.314 6.332C12.231 6.08881 12.0968 5.86627 11.9204 5.67938C11.744 5.49249 11.5297 5.3456 11.2917 5.24863L11.1947 5.21225L10.1347 4.85022C9.34817 4.58163 9.32437 3.49557 10.0628 3.17756L10.1347 3.14971L11.1947 2.78769C11.4378 2.70462 11.6602 2.57039 11.847 2.39404C12.0339 2.21769 12.1807 2.00333 12.2776 1.76541L12.314 1.66839L12.676 0.607931Z" fill="currentColor"/></g></svg>',co='<svg viewBox="0 0 11.6122 12.7248" fill="none" xmlns="http://www.w3.org/2000/svg" style="display:block;width:12px;height:12px"><path d="M4.09055 2.01133C4.43939 0.9905 5.84989 0.959583 6.26347 1.91858L6.29847 2.01192L6.76922 3.38858C6.8771 3.7043 7.05144 3.99321 7.28047 4.23583C7.5095 4.47845 7.7879 4.66912 8.09689 4.795L8.22347 4.84225L9.60014 5.31242C10.621 5.66125 10.6519 7.07175 9.69347 7.48533L9.60014 7.52033L8.22347 7.99108C7.90764 8.09889 7.61862 8.2732 7.3759 8.50223C7.13318 8.73127 6.94241 9.0097 6.81647 9.31875L6.76922 9.44475L6.29905 10.822C5.95022 11.8428 4.53972 11.8737 4.12672 10.9153L4.09055 10.822L3.62039 9.44533C3.51258 9.12951 3.33827 8.84048 3.10924 8.59776C2.8802 8.35504 2.60177 8.16427 2.29272 8.03833L2.16672 7.99108L0.790054 7.52092C-0.231363 7.17208 -0.26228 5.76158 0.69672 5.34858L0.790054 5.31242L2.16672 4.84225C2.48244 4.73437 2.77135 4.56003 3.01397 4.331C3.25658 4.10197 3.44726 3.82357 3.57314 3.51458L3.62039 3.38858L4.09055 2.01133ZM9.86147 0C9.9706 0 10.0775 0.0306123 10.1701 0.0883584C10.2627 0.146104 10.3373 0.228668 10.3853 0.326667L10.4133 0.394917L10.6175 0.993417L11.2166 1.19758C11.3259 1.23474 11.4218 1.30353 11.492 1.39523C11.5623 1.48693 11.6037 1.59741 11.611 1.71268C11.6184 1.82795 11.5914 1.94281 11.5334 2.04271C11.4755 2.14261 11.3891 2.22305 11.2854 2.27383L11.2166 2.30183L10.6181 2.506L10.4139 3.10508C10.3767 3.21442 10.3078 3.31024 10.2161 3.38041C10.1244 3.45058 10.0139 3.49194 9.89859 3.49925C9.78333 3.50656 9.66849 3.47949 9.56863 3.42147C9.46876 3.36345 9.38837 3.27709 9.33764 3.17333L9.30964 3.10508L9.10547 2.50658L8.50639 2.30242C8.39702 2.26526 8.30115 2.19647 8.23092 2.10477C8.16069 2.01307 8.11926 1.90259 8.11189 1.78732C8.10452 1.67205 8.13153 1.55719 8.18951 1.45729C8.24749 1.35739 8.33381 1.27695 8.43755 1.22617L8.50639 1.19817L9.10489 0.994L9.30905 0.394917C9.34839 0.279665 9.42281 0.179613 9.52187 0.108791C9.62094 0.0379686 9.73969 -0.0000730808 9.86147 0Z" fill="currentColor"/></svg>';function p(t,e={}){let o=document.createElement(t);if(e.style&&(o.style.cssText=e.style),e.text!=null&&(o.textContent=e.text),e.html!=null&&(o.innerHTML=e.html),e.attrs)for(let r in e.attrs)o.setAttribute(r,e.attrs[r]);if(e.on)for(let r in e.on)o.addEventListener(r,e.on[r]);if(e.children)for(let r of e.children)r&&o.appendChild(r);return o}function nt(t){return p("span",{style:`width:24px;height:24px;padding:2px;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:ao})}function De(t){return p("span",{style:`width:12px;height:12px;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:co})}function it(t){return t.borderWidth>0&&t.borderColor?`${t.borderWidth}px solid ${t.borderColor}`:"none"}function at(){if(!document.getElementById("mk-jakarta-font"))try{document.head.appendChild(p("link",{attrs:{id:"mk-jakarta-font",rel:"stylesheet",href:"https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap"}}))}catch(t){}}function lo(t){return t.subtext?p("span",{style:`display:flex;align-items:center;justify-content:center;padding:4px;background:${t.badgeBgColor};font-family:${w};font-weight:700;font-size:16px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,text:t.subtext}):null}function Ue(t,e){at();let o=p("span",{style:"display:inline-flex;align-items:center;gap:4px;",children:[nt(t.textColor),p("span",{text:t.text,style:`font-family:${w};font-weight:700;font-size:${t.fontSize}px;text-transform:uppercase;letter-spacing:2px;color:${t.textColor};white-space:nowrap;text-align:center;line-height:1;`})]});return p("button",{attrs:{type:"button"},style:`display:flex;align-items:center;justify-content:center;gap:8px;padding:8px;width:100%;max-width:238px;box-sizing:border-box;background:${t.bgColor};border:${it(t)};border-radius:${t.borderRadiusPx};font-family:${w};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[o,lo(t)],on:{mouseenter:r=>{r.currentTarget.style.opacity="0.85"},mouseleave:r=>{r.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(r){}}}})}function uo(t){return t.subtext?p("span",{style:`display:flex;align-items:center;gap:4px;padding:4px;background:${t.badgeBgColor};font-family:${w};font-weight:600;font-size:10px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,children:[De(t.badgeTextColor),p("span",{text:t.subtext})]}):null}function po(t,e){return p("button",{attrs:{type:"button"},style:`display:flex;align-items:center;justify-content:center;gap:8px;padding:8px 12px 8px 8px;width:100%;margin-top:auto;box-sizing:border-box;background:${t.bgColor};border:${it(t)};border-radius:${t.borderRadiusPx};filter:drop-shadow(0 0 6px rgba(0,0,0,0.08));font-family:${w};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[nt(t.textColor),p("span",{text:t.text,style:`font-family:${w};font-weight:700;font-size:${t.fontSize}px;color:${t.textColor};white-space:nowrap;line-height:1;`})],on:{mouseenter:o=>{o.currentTarget.style.opacity="0.85"},mouseleave:o=>{o.currentTarget.style.opacity="1"},click:()=>{try{e&&e()}catch(o){}}}})}function Fe(t,e){at();let o=p("div",{style:"display:flex;flex-direction:column;gap:4px;",children:[t.cardTitle&&p("p",{text:t.cardTitle,style:`margin:0;font-family:${w};font-weight:700;font-size:16px;letter-spacing:1px;text-transform:uppercase;color:${t.cardTitleColor};line-height:1.2;`}),t.cardDescription&&p("p",{html:t.cardDescription,style:`margin:0;font-family:${w};font-weight:400;font-size:12px;max-width:177px;line-height:1.2;color:${t.cardTextColor};`})]}),r=p("div",{style:"display:flex;flex-direction:column;justify-content:space-between;gap:16px;flex:1 1 0;min-width:0;",children:[o,t.cardFooter&&p("p",{text:t.cardFooter,style:`margin:0;font-family:${w};font-weight:400;font-size:10px;color:${t.cardTextColor};line-height:1.2;`})]}),n=p("div",{style:"display:flex;flex-direction:column;align-items:flex-end;flex:1 1 0;min-width:0;",children:[uo(t),po(t,e)]}),i=p("div",{style:"display:flex;gap:16px;align-items:stretch;width:100%;flex:1;box-sizing:border-box;",children:[r,n]});return p("div",{style:`display:flex;flex-direction:column;align-items:flex-start;padding:12px;width:100%;max-width:402px;min-height:140px;box-sizing:border-box;background:${t.cardBgColor};border-radius:${t.cardBorderRadiusPx};font-family:${w};`,children:[i]})}var mo={style:"gregory-black",text:"Provar Virtualmente",fontSize:14,subtext:"",bgColor:"#1E1E1E",textColor:"#FFFFFF",badgeBgColor:"#C51A1B",badgeTextColor:"#FFFFFF",borderRadius:"md",borderColor:"#1E1E1E",borderWidth:0,cardTitle:"",cardDescription:"",cardFooter:"",cardBgColor:"#F6F6F6",cardTitleColor:"#1E1E1E",cardTextColor:"#717171",cardBorderRadius:"md"};function jt(t,e){let o=(e?t&&t.mobile:t&&t.desktop)||t&&t.desktop||t&&t.mobile||{},r={...mo,...o};return r.style==="gregory-card"&&e&&(r.style="gregory-black"),r.borderRadiusPx=Pt[r.borderRadius]!=null?Pt[r.borderRadius]:"0",r.cardBorderRadiusPx=Rt[r.cardBorderRadius]!=null?Rt[r.cardBorderRadius]:"0",r.fontSize=Number(r.fontSize)||14,r.borderWidth=Number(r.borderWidth)||0,r}var Bt={"gregory-black":Ue,"gregory-card":Fe},un=Object.keys(Bt);function qe(t,e){return(Bt[t.style]||Bt["gregory-black"])(t,e)}var Dt="mk-tryon-button-host",ho=/^(transform|transform-origin|margin|margin-(top|right|bottom|left)|position|inset|top|right|bottom|left|z-index|width|min-width|max-width|height|min-height|max-height)$/i;function go(t){return!t||typeof t!="string"?"":t.split(";").map(e=>e.trim()).filter(Boolean).filter(e=>ho.test(e.split(":")[0].trim().toLowerCase())).join(";")}var ct=null,Ot=!1,Nt={},ze=!1,Mt=null;function $e(){return Mt||(Mt=R().then(t=>t&&t.template&&t.template.tryOnButton||null).catch(()=>null)),Mt}function yo(){if(ze)return;ze=!0;let t=null;try{window.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{ct&&O("pdp")},200)})}catch(e){}}function Ut(){let t=document.getElementById(Dt);if(t){if(typeof t.__mkCleanup=="function")try{t.__mkCleanup()}catch(e){}t.parentNode&&t.parentNode.removeChild(t)}ct=null}var wo={IMG:1,INPUT:1,VIDEO:1,CANVAS:1,EMBED:1,OBJECT:1,IFRAME:1,BR:1,HR:1,SELECT:1,TEXTAREA:1,SVG:1};function xo(t){switch(t){case"top-center":return"top:0;left:50%;transform:translateX(-50%);";case"top-right":return"top:0;right:0;";case"middle-left":return"top:50%;left:0;transform:translateY(-50%);";case"center":return"top:50%;left:50%;transform:translate(-50%,-50%);";case"middle-right":return"top:50%;right:0;transform:translateY(-50%);";case"bottom-left":return"bottom:0;left:0;";case"bottom-center":return"bottom:0;left:50%;transform:translateX(-50%);";case"bottom-right":return"bottom:0;right:0;";case"top-left":default:return"top:0;left:0;"}}function bo(t,e,o){let n=!wo[t.tagName]?t:t.parentElement||document.body;try{getComputedStyle(n).position==="static"&&(n.style.position="relative")}catch(d){}if(n===t){e.style.cssText="position:absolute;z-index:2147483000;"+xo(o),t.appendChild(e);return}e.style.cssText="position:absolute;z-index:2147483000;",n.appendChild(e);let i=()=>{try{let d=t.getBoundingClientRect(),m=n.getBoundingClientRect(),g=e.offsetWidth,c=e.offsetHeight,x=d.top-m.top+n.scrollTop,A=d.left-m.left+n.scrollLeft,y=o||"top-left",$=x,S=A;y.indexOf("bottom")===0?$=x+d.height-c:(y.indexOf("middle")===0||y==="center")&&($=x+(d.height-c)/2),y.indexOf("right")>=0?S=A+d.width-g:y.indexOf("center")>=0&&(S=A+(d.width-g)/2),e.style.top=$+"px",e.style.left=S+"px"}catch(d){}};i();let a=()=>i();window.addEventListener("resize",a);let s=setTimeout(i,600),u=setTimeout(i,1500);e.__mkCleanup=()=>{window.removeEventListener("resize",a),clearTimeout(s),clearTimeout(u)}}function Co(t,e,o){try{return t.insertAdjacentElement(o||"afterend",e),!0}catch(r){try{return t.parentNode.insertBefore(e,t.nextSibling),!0}catch(n){return!1}}}async function O(t){let e=f();if(t!=="pdp"){Ut();return}if(!e.projectId)return;if(!e._anchorFromPicker){let u=await $e();u&&u.anchor&&(e.anchor=u.anchor)}if(Ot)return;let o=F(),r=o&&o.value,n=!!e.forceButton,i=It(e.anchor),a=[r||"demo",i?[i.selector,i.position,i.mode,i.align,i.style].join("~"):"heuristic"].join("|"),s=document.getElementById(Dt);if(!(s&&ct===a)){if(s&&Ut(),!r&&!n){h("auto-mount: SKU n\xE3o resolvido na PDP");return}Ot=!0;try{let u=n;n||(Nt[r]||(Nt[r]=B(e.projectId,r).then(C=>!!(C&&C.available)).catch(()=>!1)),u=await Nt[r]);try{Xt(u?"available":"unavailable")}catch(C){}if(!u){h("auto-mount: produto sem try-on",r);return}let d=await $e(),m=window.matchMedia("(max-width: 767px)").matches,g=jt(d,m),c=Me(),x=c&&c.mode||"flow",A=qe(g,()=>{let C=F(),lt=C&&C.value||r||"";l("button_clicked",{sku:lt,style:g.style,mode:x}),ot({projectId:e.projectId,identifier:lt})}),y=document.createElement("div");y.id=Dt,y.attachShadow({mode:"closed"}).appendChild(A);let S=!1;if(c&&c.el&&c.el.parentNode&&(x==="overlay"?(bo(c.el,y,c.align),S=!0):(y.style.cssText="display:contents;",S=Co(c.el,y,c.position))),S||(y.style.cssText="position:fixed;left:16px;bottom:16px;z-index:2147483000;",document.body.appendChild(y)),c&&c.style){let C=go(c.style);if(C)try{A.style.cssText+=";"+C}catch(lt){}}ct=a,yo(),h("auto-mount: bot\xE3o injetado",{style:g.style,sku:r,anchorFound:!!c,position:c&&c.position,mode:x,forced:n}),l("button_rendered",{style:g.style,sku:r||null,skuSource:o&&o.source,anchorFound:!!c,position:c?c.position:null,mode:x,forced:n})}finally{Ot=!1}}}function Ke(){try{let t=f(),e={anchor:t.anchor,forceButton:t.forceButton};window.addEventListener("message",o=>{if(o.source!==window)return;let r=o.data;!r||!r.__mkCmd||(r.__mkCmd==="remount"||r.__mkCmd==="applyRecipe"?(t.anchor=r.anchor||null,t._anchorFromPicker=!0,t.forceButton=!0,O("pdp")):r.__mkCmd==="cancelPreview"&&(t.anchor=e.anchor,t._anchorFromPicker=!1,t.forceButton=e.forceButton,Ut(),O("pdp")))})}catch(t){}}(function(){"use strict";try{let o=function(){try{Qt(),Ke(),Ee(),e.autoTrack!==!1&&(ge((n,i)=>{Ce(n,i),O(n)}),ke()),h("mk-sdk iniciado",{projectId:e.projectId,collectorUrl:e.collectorUrl})}catch(n){e.debug&&console.error("[mk-sdk] init erro",n)}},e=ut();if(e.projectId){let n=oe(e.projectId);n&&gt(n),R().then(i=>{let a=ee(i);gt(a),ne(e.projectId,a),h("escopo de coleta",a)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o):o();let r={open:ot,close:Et,isAvailable:Te,getAvailability:B,onReady:Ie,onClose:Pe,onAddToCart:Re,onProductLoaded:je,onError:Be,onInteraction:Oe,onGenerationComplete:Ne,_version:"0.1.0",_isMkSdk:!0};typeof window!="undefined"&&(window.mk=r)}catch(e){typeof console!="undefined"&&console.error("[mk-sdk] boot fatal",e)}})();})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mk-sdk-git",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "SDK de tracking de e-commerce + try-on da MetaKosmos (core tracker, roda em todas as páginas)",
5
5
  "main": "dist/mk-sdk.js",
6
6
  "files": [
@@ -42,3 +42,26 @@ export async function addToCart({ size, quantity }) {
42
42
  if (!resp.ok) throw new Error('hybris: ' + action + ' HTTP ' + resp.status);
43
43
  return { platform: 'hybris', productCode: code, size: el.textContent.trim() };
44
44
  }
45
+
46
+ function isVis(el) {
47
+ try { const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0 && getComputedStyle(el).visibility !== 'hidden'; }
48
+ catch (_) { return false; }
49
+ }
50
+
51
+ /**
52
+ * Abre o mini-cart flutuante do Hybris (ex.: Marisa). Atualiza o display via
53
+ * ACC.minicart.updateMiniCartDisplay() (pega o /cart fresco) e clica o toggle.
54
+ * O flutuante é desktop (hidden-sm/xs, ~md+); abaixo de 992px retorna false →
55
+ * o chamador redireciona pro /cart (degrada gracioso no mobile).
56
+ */
57
+ export function openCartDrawer() {
58
+ const toggle = document.querySelector('.js-load-mini-cart-menu');
59
+ if (!toggle || !isVis(toggle)) return false;
60
+ if ((window.innerWidth || 0) < 992) return false; // mini-cart flutuante é md+
61
+ try {
62
+ if (window.ACC && window.ACC.minicart && typeof window.ACC.minicart.updateMiniCartDisplay === 'function')
63
+ window.ACC.minicart.updateMiniCartDisplay();
64
+ } catch (_) {}
65
+ setTimeout(() => { try { toggle.click(); } catch (_) {} }, 350);
66
+ return true;
67
+ }
@@ -81,35 +81,40 @@ function notifyTheme() {
81
81
  // • 'drawer' → abre a sacola lateral do tema (clica cartOpenSelector), sem sair da página
82
82
  // • 'redirect' → leva o usuário ao /cart (default histórico)
83
83
  // • 'none' → só adiciona, não faz nada
84
- // Ação pós-add: NÃO roda junto do add (o provador segue aberto pro NPS). O bridge
85
- // chama isto AO FECHAR o modal, pra não interromper o fluxo do provador.
86
- export async function afterAddToCart() {
84
+ // Chamado NO ADD (provador segue aberto pro NPS): abre a sacola lateral na hora,
85
+ // ATRÁS do modal (z-index do modal é máximo), pra o usuário já ver o item quando
86
+ // fechar o provador. Sem config por loja. Recipe/__MK forçam redirect|none|drawer
87
+ // ou um openSelector exato. cartRedirect:false legado vira 'none'.
88
+ // Retorna true se o tema NÃO tem sacola e ainda falta redirecionar — o bridge faz
89
+ // isso AO FECHAR (redirecionar no add navegaria e mataria o NPS).
90
+ export async function openCartAfterAdd() {
87
91
  const plat = currentPlatform();
88
92
  const cfg = getConfig();
89
93
  let recipe = null;
90
94
  try { recipe = await fetchProjectRecipe(); } catch (_) {}
91
95
  const rc = (recipe && recipe.template && recipe.template.cart) || (recipe && recipe.cart) || {};
92
96
 
93
- // Default = 'auto': abre a sacola lateral se o tema tiver uma, senão redirect.
94
- // Sem config por loja. Recipe/__MK podem forçar 'redirect' | 'none' | 'drawer'
95
- // ou dar um openSelector exato. cartRedirect:false legado vira 'none'.
96
97
  let behavior = rc.afterAdd || rc.behavior || cfg.cartBehavior;
97
98
  if (!behavior) behavior = (cfg.cartRedirect === false) ? 'none' : 'auto';
98
- if (behavior === 'none') return;
99
+ if (behavior === 'none') return false;
99
100
 
100
101
  if (behavior === 'auto' || behavior === 'drawer') {
101
102
  const openSelector = rc.openSelector || cfg.cartOpenSelector;
102
103
  if (openSelector) {
103
104
  const el = document.querySelector(openSelector);
104
- if (el) { setTimeout(() => { try { el.click(); } catch (_) {} }, 300); return; }
105
+ if (el) { setTimeout(() => { try { el.click(); } catch (_) {} }, 300); return false; }
105
106
  } else if (plat && plat.openCartDrawer) {
106
- // a plataforma detecta e abre a sacola; se conseguiu, pronto (sem redirect)
107
107
  let opened = false; try { opened = plat.openCartDrawer(); } catch (_) {}
108
- if (opened) return;
108
+ if (opened) return false; // sacola aberta atrás do modal → sem redirect
109
109
  }
110
- // não achou sacola → cai no redirect (degrada gracioso)
110
+ // 'drawer'/'auto' sem sacola detectada redireciona ao fechar
111
111
  }
112
+ return true; // sinaliza redirect (feito no close pra não matar o NPS)
113
+ }
112
114
 
115
+ // Redirect pro carrinho — chamado no CLOSE quando o tema não tem sacola.
116
+ export function redirectToCart() {
117
+ const plat = currentPlatform();
113
118
  if (plat && plat.skipRedirect) return;
114
119
  const url = (plat && plat.cartUrl) || '/cart';
115
120
  setTimeout(() => { try { window.location.href = url; } catch (_) {} }, 250);
@@ -3,12 +3,12 @@
3
3
 
4
4
  import { getConfig, log } from '../core/config.js';
5
5
  import { track } from '../core/transport.js';
6
- import { addToCart as cartAdd, afterAddToCart } from '../platforms/index.js';
6
+ import { addToCart as cartAdd, openCartAfterAdd, redirectToCart } from '../platforms/index.js';
7
7
 
8
8
  let modal = null;
9
9
  let iframe = null;
10
10
  let isOpen = false;
11
- let pendingAfterAdd = false; // houve add_to_cart nesta sessão? ação pós-add ao FECHAR
11
+ let pendingRedirect = false; // tema sem sacolaredireciona ao FECHAR (preserva o NPS)
12
12
  let currentConfig = null;
13
13
  let availabilityChecked = {};
14
14
  let photoMethod = null; // qrcode | gallery | camera (recebido via interaction)
@@ -67,7 +67,7 @@ export async function open(options) {
67
67
  }
68
68
 
69
69
  currentConfig = { projectId, identifier, width: options.width || 430, height: options.height || 800 };
70
- pendingAfterAdd = false;
70
+ pendingRedirect = false;
71
71
  setupMessageListener();
72
72
  openModal(currentConfig);
73
73
  isOpen = true;
@@ -78,14 +78,15 @@ export async function open(options) {
78
78
 
79
79
  export function close() {
80
80
  if (!isOpen) return;
81
- const didAdd = pendingAfterAdd;
82
- pendingAfterAdd = false;
81
+ const redirect = pendingRedirect;
82
+ pendingRedirect = false;
83
83
  hideModal();
84
84
  isOpen = false;
85
85
  fire('onClose');
86
86
  track('modal_closed', { projectId: currentConfig && currentConfig.projectId, identifier: currentConfig && currentConfig.identifier });
87
- // agora (modal fechado, NPS rolou) abre a sacola / redireciona
88
- if (didAdd) { try { afterAddToCart(); } catch (_) {} }
87
+ // a sacola abriu no add (atrás do modal). Aqui o redirect dos temas sem
88
+ // sacola feito agora pra não navegar durante o NPS.
89
+ if (redirect) { try { redirectToCart(); } catch (_) {} }
89
90
  }
90
91
 
91
92
  // ─── Modal DOM ────────────────────────────────────────────────────────────
@@ -176,9 +177,13 @@ function setupMessageListener() {
176
177
  if (typeof callbacks.onAddToCart === 'function') {
177
178
  fire('onAddToCart', payload); // cliente cuida (compat SDK v2)
178
179
  } else {
179
- // mk-sdk adiciona sozinho (zero-touch). NÃO fecha o provador ele segue
180
- // aberto pro NPS. A ação pós-add (drawer/redirect) roda ao fechar (close()).
181
- cartAdd(payload).then(() => { pendingAfterAdd = true; }).catch(() => {});
180
+ // mk-sdk adiciona sozinho (zero-touch) e abre a sacola (atrás do
181
+ // provador, que segue aberto pro NPS). Tema sem sacola marca redirect
182
+ // pro fechamento (não navega agora pra não matar o NPS).
183
+ cartAdd(payload)
184
+ .then(() => openCartAfterAdd())
185
+ .then((needRedirect) => { pendingRedirect = !!needRedirect; })
186
+ .catch(() => {});
182
187
  }
183
188
  break;
184
189
  case 'generation_start':