mk-sdk-git 1.1.43 → 1.1.45
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-core.js +1 -1
- package/dist/mk-sdk.js +1 -1
- package/package.json +1 -1
- package/src/core/config.js +4 -0
- package/src/core/pageContext.js +11 -4
- package/src/index.js +2 -1
- package/src/tryon/anchor.js +18 -8
- package/src/tryon/automount.js +176 -67
- package/src/tryon/bridge.js +10 -10
package/dist/mk-core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var Cr=Object.defineProperty;var v=(t,e)=>{for(var r in e)Cr(t,r,{get:e[r],enumerable:!0})};var wt={collectorUrl:"https://api-collector.mk3dlabs.com",appUrl:"https://mkfashion.mk3dlabs.com/visualizer",apiUrl:"https://mkfashion-new-api.mk3dlabs.com"},vr={},$=null;function xt(){if($)return $;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(c){return null}},r=e("data-mk-project")||e("data-mk-client")||window.__MK&&(window.__MK.projectId||window.__MK.clientSlug)||null,n=e("data-mk-product")||window.__MK&&window.__MK.product||"mk-fashion",o=e("data-mk-collector")||window.__MK&&window.__MK.collectorUrl||vr.collectorUrl||wt.collectorUrl;return $={projectId:r,product:n,collectorUrl:o,appUrl:window.__MK&&window.__MK.appUrl||wt.appUrl,apiUrl:window.__MK&&window.__MK.apiUrl||wt.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:window.__MK&&window.__MK.batchIntervalMs||8e3,batchMaxSize:window.__MK&&window.__MK.batchMaxSize||20,engagementIntervalMs:15e3},$}function m(){return $||xt()}function f(...t){let e=m();e&&e.debug&&typeof console!="undefined"&&console.log("[mk-sdk]",...t)}var ce="_mk_vid",ae="_mk_sid",K=null,H=null;function Y(){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 le(){if(K)return K;try{let t=localStorage.getItem(ce);return t||(t="v_"+Y(),localStorage.setItem(ce,t)),K=t,t}catch(t){return K="v_"+Y(),K}}function se(){if(H)return H;try{let t=sessionStorage.getItem(ae);return t||(t="s_"+Y(),sessionStorage.setItem(ae,t)),H=t,t}catch(t){return H="s_"+Y(),H}}var ue=[/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],de={imageUrl:1,image:1,thumbnail:1,photo:1,imageBase64:1,src:1},bt=2e3;function pe(t){for(let e=0;e<ue.length;e++)if(ue[e].test(t))return!0;return!1}function fe(t){if(!t||typeof t!="object"||Array.isArray(t))return typeof t=="string"&&t.length>bt?t.slice(0,200)+"...[truncated "+t.length+"B]":t;let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||pe(r))continue;let n=t[r];if(de[r]){e[r+"Present"]=!!n;continue}if(typeof n=="string"&&n.length>bt){e[r]=n.slice(0,200)+"...[truncated "+n.length+"B]";continue}if(n&&typeof n=="object"&&!Array.isArray(n)){e[r]=kr(n);continue}e[r]=n}return e}function kr(t){let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||pe(r))continue;let n=t[r];if(de[r]){e[r+"Present"]=!!n;continue}if(typeof n=="string"&&n.length>bt){e[r]=n.slice(0,200)+"...[truncated]";continue}e[r]=n}return e}var Z=[],_t=null,M=null,Sr=["off","pdp_tryon","pdp","all","tryon_engaged"],V,Ct=null,Q="unknown",B=[],j=null;function he(){let t=m();return"mk_engaged_"+(t&&t.projectId||"")}function vt(){if(j!==null)return j;try{j=localStorage.getItem(he())==="1"}catch(t){j=!1}return j}function ye(){if(!vt()){j=!0;try{localStorage.setItem(he(),"1")}catch(t){}tt(!1)}}var Tr=/^purchase$/;function ge(t,e){if(V===void 0)return"hold";if(V==="off")return"drop";if(V==="all"||e&&Tr.test(e))return"collect";switch(V){case"pdp":return t==="pdp"?"collect":"drop";case"tryon_engaged":if(vt())return"collect";case"pdp_tryon":return t!=="pdp"?"drop":Q==="available"?"collect":Q==="unavailable"?"drop":"hold";default:return"collect"}}function tt(t){if(!B.length)return;let e=[];for(let r of B){let n=ge(r._pt,r.name);n==="collect"?be(r.name,r.params,r.ts):n==="hold"&&!t&&e.push(r)}B=e}function kt(t){V=Sr.indexOf(t)>=0?t:"all",tt(!1)}function we(t){Q=t==="available"?"available":"unavailable",tt(!1)}function xe(t){tt(!0),M=t,Ct=t&&t.pageType||null,Q="unknown"}function u(t,e,r){if(!m().projectId){(u._pre=u._pre||[]).push({name:t,params:e,ts:r||Date.now()}),u._pre.length>50&&u._pre.shift();return}if(u._pre&&u._pre.length){let o=u._pre;u._pre=[];for(let i of o)me(i.name,i.params,i.ts)}me(t,e,r)}function me(t,e,r){let n=ge(Ct,t);if(n==="collect"){be(t,e,r);return}if(n==="drop"){f("descartado (escopo)",t);return}B.push({name:t,params:e,ts:r||Date.now(),_pt:Ct}),B.length>300&&B.shift()}function be(t,e,r){let n=m(),o=fe(e||{}),i="page_"+Ar(t);if(Z.push({name:i,ts:r||Date.now(),params:o}),f("queued",t,o),n.observe)try{window.postMessage({__mkpixel:!0,event:{name:i,params:o},site:M?{pageType:M.pageType,platform:M.platform,url:M.url}:null},"*")}catch(c){}if(Z.length>=n.batchMaxSize){I();return}_t||(_t=setTimeout(()=>{_t=null,I()},n.batchIntervalMs))}function Ar(t){if(typeof t!="string"||!t)return"unknown";let e=t.replace(/^on/,"");return e=e.replace(/[A-Z]/g,(r,n)=>(n>0?"_":"")+r.toLowerCase()),e.indexOf("page_")===0&&(e=e.slice(5)),e}function I(t){if(Z.length===0)return;let e=m();if(!e.projectId||!e.collectorUrl)return;let r=Z.splice(0,50),n=JSON.stringify({product:e.product||void 0,visitorId:le(),sessionId:se(),engaged:vt()||void 0,events:r,site:M||void 0}),o=e.collectorUrl+"/v1/track";try{fetch(o,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","X-MK-Project-Id":e.projectId},body:n}).catch(()=>{})}catch(i){try{navigator.sendBeacon&&navigator.sendBeacon(o+"?projectId="+encodeURIComponent(e.projectId),new Blob([n],{type:"text/plain"}))}catch(c){}}}function _e(){try{window.addEventListener("pagehide",()=>I(!0)),window.addEventListener("beforeunload",()=>I(!0)),document.addEventListener("visibilitychange",()=>{document.hidden&&I(!0)})}catch(t){}}function L(t){let e=[];try{let r=document.querySelectorAll('script[type="application/ld+json"]');for(let n of r){let o;try{o=JSON.parse(n.textContent)}catch(c){continue}let i=[];Array.isArray(o)?i.push(...o):o["@graph"]?i.push(...o["@graph"]):i.push(o);for(let c of i){if(!c||!c["@type"])continue;let a=Array.isArray(c["@type"])?c["@type"]:[c["@type"]];(!t||t.some(l=>a.includes(l)))&&e.push(c)}}}catch(r){}return e}var Ce=["off","pdp_tryon","pdp","all","tryon_engaged"],Lr="all",Er=30*60*1e3,N=null;function O(){if(N)return N;let t=m();return!t.projectId||!t.apiUrl?(N=Promise.resolve(null),N):(N=fetch(t.apiUrl+"/projects/"+t.projectId).then(e=>e.ok?e.json():null).then(e=>e&&e.project||e||null).catch(()=>null),N)}function ve(t){let e=t&&t.analytic&&t.analytic.scope;return Ce.indexOf(e)>=0?e:Lr}var ke=t=>"mk_scope_"+t;function Se(t){try{let e=localStorage.getItem(ke(t));if(!e)return null;let r=JSON.parse(e);return!r||typeof r.exp!="number"||r.exp<Date.now()?null:Ce.indexOf(r.scope)>=0?r.scope:null}catch(e){return null}}function Te(t,e){try{localStorage.setItem(ke(t),JSON.stringify({scope:e,exp:Date.now()+Er}))}catch(r){}}var At={};v(At,{addToCart:()=>$r,detect:()=>Dr,getCartSummary:()=>Fr,id:()=>Or,openCartDrawer:()=>Kr,resolveSku:()=>Ur,skipRedirect:()=>qr});var rt={};v(rt,{addToCart:()=>Pr,detect:()=>Rr,getCartSummary:()=>Tt,id:()=>Ir,openCartDrawer:()=>Nr,resolveSku:()=>St});var Ir="shopify";function Rr(){return!!(window.Shopify||window.ShopifyAnalytics)}function St(){let t=window;return t.ShopifyAnalytics&&t.ShopifyAnalytics.meta&&t.ShopifyAnalytics.meta.product?{value:String(t.ShopifyAnalytics.meta.product.id),source:"shopify"}:null}var et=t=>String(t==null?"":t).trim().toLowerCase();async function Pr({size:t,color:e,sku:r,quantity:n}){let o=(location.pathname.split("/products/")[1]||"").split(/[?#]/)[0];if(!o)throw new Error("shopify: sem handle de produto na URL (n\xE3o \xE9 PDP?)");let c=(await fetch("/products/"+o+".js").then(p=>p.json())).variants||[],a=p=>[p.option1,p.option2,p.option3].concat(String(p.title||"").split("/")).map(et).filter(Boolean),l=(p,S)=>a(p).indexOf(et(S))>=0,h=p=>(!t||l(p,t))&&(!e||l(p,e)),d=null;if((t||e)&&(d=c.find(p=>h(p)&&p.available)||c.find(h)),!d&&r&&(d=c.find(p=>et(p.sku)===et(r))),d||(d=c.find(p=>p.available)||c[0]),!d)throw new Error("shopify: variante n\xE3o encontrada");let g=Ae(),s=null;if(g&&typeof g.getSectionsToRender=="function")try{s=g.getSectionsToRender().map(p=>({id:p.id,selector:p.selector||"#"+p.id})).filter(p=>p.id)}catch(p){}let y={items:[{id:d.id,quantity:n||1}]};s&&s.length&&(y.sections=s.map(p=>p.id).join(","),y.sections_url=location.pathname);let x=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(y)});if(!x.ok)throw new Error("shopify: /cart/add.js HTTP "+x.status);let b=await x.json().catch(()=>({}));return g&&s&&b.sections&&jr(g,s,b.sections),{platform:"shopify",variantId:d.id,size:d.title,sku:d.sku||null}}function Ae(){return document.querySelector("cart-drawer, cart-notification")}function jr(t,e,r){for(let n of e){let o=r[n.id];if(o)try{let i=null;if(typeof t.getSectionInnerHTML=="function")i=t.getSectionInnerHTML(o,n.selector);else{let a=new DOMParser().parseFromString(o,"text/html").querySelector(n.selector);i=a?a.innerHTML:null}let c=document.querySelector(n.selector);c&&i!=null&&(c.innerHTML=i)}catch(i){}}}async function Tt(){try{let t=await fetch("/cart.js",{headers:{Accept:"application/json"}}).then(e=>e.json());return{value:(Number(t.total_price)||0)/100,itemCount:Number(t.item_count)||0,currency:t.currency||null}}catch(t){return null}}var Mr=["[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 Br(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=Ae();if(t&&typeof t.open=="function")return setTimeout(()=>{try{t.open()}catch(r){}},200),!0;let e=null;for(let r of Mr)try{if(e=[...document.querySelectorAll(r)].find(Br),e)break}catch(n){}return e?(setTimeout(()=>{try{e.click()}catch(r){}},300),!0):!1}var Or="zerezes",qr=!0;function Dr(){try{if(!(window.Shopify||window.ShopifyAnalytics))return!1;let t=window.Shopify&&window.Shopify.shop||"";return/(^|\.)zerezes\./i.test(location.hostname)||/cs-zerezes/i.test(t)}catch(t){return!1}}var Ur=St,Fr=Tt;function zr(){let t=[...document.querySelectorAll(".lens-selection__button, [data-has-lens-basket]")];return t.find(e=>{let r=e.getBoundingClientRect();return r.width>0&&r.height>0})||t[0]||null}async function $r(){let t=zr();if(!t)throw new Error("zerezes: bot\xE3o de sele\xE7\xE3o de lentes n\xE3o encontrado");try{window.postMessage({source:"mkfashion-app",action:"close_request"},"*")}catch(e){}return setTimeout(()=>{try{t.click()}catch(e){}},250),{platform:"zerezes",nativeFlow:"lens-selection"}}function Kr(){return!0}var Et={};v(Et,{addToCart:()=>Wr,detect:()=>Vr,getCartSummary:()=>Gr,id:()=>Hr,resolveSku:()=>Jr});var Hr="hybris";function Vr(){return!!(window.ACC&&window.ACC.config)}function Jr(){let t=(location.pathname||"").match(/\/p\/([^/?#]+)/);return t&&t[1]?{value:decodeURIComponent(t[1]),source:"hybris/url"}:null}var Le=t=>String(t==null?"":t).trim().toLowerCase();async function Wr({size:t,quantity:e}){let r=[...document.querySelectorAll('.js-product-select-size, a[data-code], [class*="select-size"]')].filter(y=>y.getAttribute&&y.getAttribute("data-code")),n=t?r.find(y=>Le(y.textContent)===Le(t)):null;n||(n=r.find(y=>y.offsetParent!==null)||r[0]);let o=n&&n.getAttribute("data-code");if(!o)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"]'),c=i&&i.querySelector('[name="CSRFToken"]'),a=c&&c.value,l=i&&i.getAttribute("action")||"/cart/add";if(!a)throw new Error("hybris: CSRFToken n\xE3o encontrado");let h=new URLSearchParams;h.set("productCodePost",o),h.set("qty",String(e||1)),h.set("CSRFToken",a);let d=await fetch(l,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:h.toString()});if(!d.ok)throw new Error("hybris: "+l+" HTTP "+d.status);let g=null,s=null;try{let y=await d.clone().json(),x=y&&y.cartData;x&&(g=Lt(x.total!=null?x.total:x.totalPrice),s=x.totalUnitCount!=null?Number(x.totalUnitCount):Array.isArray(x.products)?x.products.length:null)}catch(y){}return{platform:"hybris",productCode:o,size:n.textContent.trim(),cartValue:g,itemCount:s,currency:"BRL"}}function Lt(t){if(t==null||t==="")return null;if(typeof t=="number")return Number.isFinite(t)?t:null;let e=String(t).replace(/[^\d.,]/g,"");if(!e)return null;let r=e.indexOf(",")>e.indexOf(".")?parseFloat(e.replace(/\./g,"").replace(",",".")):parseFloat(e.replace(/,/g,""));return Number.isFinite(r)?r:null}async function Gr(){try{let t=await fetch("/cart/async?nocache="+Date.now(),{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(c=>c.ok?c.text():"");if(!t)return null;let e=new DOMParser().parseFromString(t,"text/html"),r=e.querySelector(".minicart-total .price")||e.querySelector(".floating-cart--cart-total"),n=r?Lt(r.textContent):null,o=e.querySelector(".mini-badge"),i=o?parseInt(o.textContent,10)||0:null;return n==null&&i==null?null:{value:n,itemCount:i,currency:"BRL"}}catch(t){}try{let t=[".minicart-total .price",".js-cart-total",".cart-total",".total-price",".grand-total"];for(let e of t){let r=document.querySelector(e),n=r&&Lt(r.textContent);if(n)return{value:n,itemCount:null,currency:"BRL"}}}catch(t){}return null}var It={};v(It,{addToCart:()=>Qr,detect:()=>Yr,getCartSummary:()=>tn,id:()=>Xr,resolveSku:()=>Zr});var Xr="vtex";function Yr(){return!!(window.vtex||window.vtexjs||window.vtxctx||window.skuJson_0)}function Zr(){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 nt=t=>String(t==null?"":t).trim().toLowerCase();async function Qr({size:t,quantity:e}){let r=window.skuJson_0&&window.skuJson_0.skus||[];if(!r.length)throw new Error("vtex: skuJson_0 indispon\xEDvel");let n=i=>nt(i.skuname)===nt(t)||i.dimensions&&Object.values(i.dimensions).some(c=>nt(c)===nt(t)),o=t?r.find(i=>n(i)&&i.available)||r.find(n):null;if(o||(o=r.find(i=>i.available)||r[0]),!o)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(o.sku,10),quantity:e||1,seller:"1"}]),{platform:"vtex",skuId:o.sku,size:o.skuname||t};throw new Error("vtex: vtexjs.checkout indispon\xEDvel")}function tn(){try{let t=window.vtexjs&&window.vtexjs.checkout&&window.vtexjs.checkout.orderForm;if(t&&typeof t.value=="number"){let e=t.storePreferencesData&&t.storePreferencesData.currencyCode||"BRL",r=(t.items||[]).reduce((n,o)=>n+(Number(o.quantity)||1),0);return{value:t.value/100,itemCount:r,currency:e}}}catch(t){}return null}var Rt={};v(Rt,{addToCart:()=>cn,detect:()=>nn,getCartSummary:()=>ln,id:()=>en,openCartDrawer:()=>an,resolveSku:()=>on,skipRedirect:()=>rn});var en="nuvemshop",rn=!0;function nn(){return!!(window.LS&&(window.LS.cart||window.LS.addToCart))}function on(){try{let t=window.LS,e=t&&t.variants||[],r=document.querySelector('[name="variant_id"]'),n=r&&r.value?e.find(o=>String(o.id)===String(r.value)):null;if(n||(n=e.find(o=>o.available!==!1&&o.sku)||e.find(o=>o.sku)||e[0]),n&&n.sku)return{value:String(n.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 ot=t=>String(t==null?"":t).trim().toLowerCase();async function cn({size:t,quantity:e}){let r=document.getElementById("product_form")||document.querySelector('.js-product-form, form[action*="/comprar"]');if(!r)throw new Error("nuvemshop: #product_form n\xE3o encontrado");t&&r.querySelectorAll('select[name^="variation"]').forEach(c=>{let a=[...c.options].find(l=>ot(l.textContent).includes(ot(t))||ot(l.value)===ot(t));a&&(c.value=a.value,c.dispatchEvent(new Event("change",{bubbles:!0})))});let n=r.querySelector('[name="quantity"]');n&&e&&(n.value=String(e)),await new Promise(c=>setTimeout(c,400));let o=r.querySelector(".js-addtocart")||document.querySelector(".js-addtocart");return o?o.click():typeof r.requestSubmit=="function"?r.requestSubmit():r.submit(),await new Promise(c=>setTimeout(c,1200)),{platform:"nuvemshop",variantId:(r.querySelector('[name="variant_id"]')||{}).value||null}}function an(){try{if([...document.querySelectorAll('.modal-cart, #ajax-cart-details, [class*="cart-modal" i], [class*="modal-cart" i]')].find(n=>n.getBoundingClientRect().width>0))return!0;let e=[...document.querySelectorAll(".js-toggle-cart")],r=e.find(n=>{let o=n.getBoundingClientRect();return o.width>0&&o.height>0})||e[0];if(r)return setTimeout(()=>{try{r.click()}catch(n){}},300),!0}catch(t){}return!1}function ln(){try{let t=window.LS,e=t&&t.cart;if(!e)return null;let r=t.currency&&t.currency.code||"BRL",n=Array.isArray(e.items)?e.items.reduce((i,c)=>i+(Number(c.quantity)||1),0):Number(e.items)||0,o=e.subtotal!=null?Number(e.subtotal):null;return{value:o!=null?o/100:null,itemCount:n,currency:r}}catch(t){return null}}var Pt={};v(Pt,{addToCart:()=>fn,detect:()=>dn,getCartSummary:()=>mn,id:()=>sn,openCartDrawer:()=>yn,resolveSku:()=>pn,skipRedirect:()=>un});var sn="wake",un=!0;function dn(){return!!(window.StorefrontClient||typeof window.addOrCreateCheckout=="function"||typeof window.addToCartClick=="function")}function pn(){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 r=(location.pathname||"").match(/-(\d+)\/?(?:[?#]|$)/);if(r)return{value:r[1],source:"wake/url"}}catch(t){}return null}var Ee=t=>String(t==null?"":t).trim().toLowerCase();async function fn({size:t,quantity:e}){if(t){let i=[...document.querySelectorAll("input[attribute-value]")].find(c=>Ee(c.getAttribute("attribute-value"))===Ee(t));if(i){try{i.checked=!0}catch(c){}try{typeof window.selectAttribute=="function"?window.selectAttribute(i):i.click()}catch(c){}await new Promise(c=>setTimeout(c,600))}}let r=document.querySelector('[name="product-variant-id"]'),n=r&&r.value;if(!n)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(n),quantity:e||1,customization:[]}]))throw new Error("wake: addOrCreateCheckout retornou false");return{platform:"wake",productVariantId:n,size:t||null}}function Ie(t){if(t==null)return null;let e=String(t).match(/([\d.]+,\d{2}|\d+(?:\.\d{2})?)/),r=(e?e[1]:String(t)).replace(/[^\d.,]/g,"");if(!r)return null;let n=r.indexOf(",")>r.indexOf(".")?parseFloat(r.replace(/\./g,"").replace(",",".")):parseFloat(r.replace(/,/g,""));return Number.isFinite(n)&&n>0?n:null}async function mn(){try{let t=()=>{let o=document.querySelector(".mc-subtotal__value")||document.querySelector(".mc-subtotal");return o?Ie(o.textContent):null},e=t();if(e==null&&typeof window.loadMiniCart=="function"){try{window.loadMiniCart()}catch(o){}await new Promise(o=>setTimeout(o,700)),e=t()}e==null&&(e=hn());let r=document.querySelector('.mc-products__count, [class*="mc-"][class*="count" i], [class*="minicart" i] [class*="count" i]'),n=r&&parseInt(String(r.textContent||"").replace(/\D/g,""),10)||null;if(e!=null)return{value:e,itemCount:n,currency:"BRL"}}catch(t){}return null}function hn(){try{let t=document.querySelector('[class*="mini-cart" i], .mini-cart')||document;for(let e of t.querySelectorAll("div,span,p,li,strong,b")){if(e.children.length>2)continue;let r=(e.textContent||"").replace(/\s+/g," ").trim();if(!(!/R\$/.test(r)||/frete|faltam|gr[aá]tis|desconto|economi/i.test(r))&&/^(sub)?total\b/i.test(r)){let n=Ie(r);if(n)return n}}}catch(t){}return null}function yn(){if(typeof window.setCartDivVisibility!="function")return!1;try{typeof window.loadMiniCart=="function"&&window.loadMiniCart()}catch(t){}return setTimeout(()=>{try{let t=document.querySelector('[class*="mini-cart" i], .mini-cart');if(t&&t.getBoundingClientRect().width>0)return;window.setCartDivVisibility()}catch(t){}},350),!0}var Bt={};v(Bt,{addToCart:()=>_n,cartUrl:()=>xn,detect:()=>bn,getCartSummary:()=>Cn,id:()=>gn,openCartDrawer:()=>vn,skipRedirect:()=>wn});var jt="/api/v2/front",Mt={"Content-Type":"application/json",Accept:"application/json","App-Token":"wapstore"},Re=t=>String(t==null?"":t).trim().toLowerCase(),gn="wapstore",wn=!0,xn="/checkout/carrinho";function bn(){try{if(document.querySelector('script[src*="/tema/"][src*="/dist/assets/"]')||/(?:^|;\s*)produto\/visitado=/.test(document.cookie))return!0}catch(t){}return!1}function Pe(t){if(!t||typeof t!="object")return null;let e=t.subtotal&&t.subtotal.valor;return e==null?null:{value:e,itemCount:t.quantidadeItens!=null?t.quantidadeItens:null,currency:"BRL"}}async function _n({size:t,quantity:e}){let r=await fetch(jt+"/url/product/detail?url="+encodeURIComponent(location.pathname),{headers:Mt}).then(s=>s.json()),n=(r&&(r.produto||r.data||r)||{}).conteudo||{},o=n.atributos&&n.atributos.simples&&n.atributos.simples.valores||[];if(!o.length)throw new Error("wapstore: sem variante de compra (atributos.simples)");let i=t?o.find(s=>Re(s.label)===Re(t)):null;i=i||o.find(s=>s.selecionado)||o.find(s=>(s.estoque||0)>0)||o[0];let c=i&&i.carrinho;if(!c||!c.itens||!c.itens.length)throw new Error("wapstore: variante sem payload de carrinho");let a=c.itens.map(s=>Object.assign({},s,{quantidade:String(e||s.quantidade||1)})),l=await fetch(jt+"/checkout/cart",{method:"POST",headers:Mt,body:JSON.stringify({itens:a,tipo:c.tipo||"produto"})});if(!l.ok)throw new Error("wapstore: add HTTP "+l.status);let h=await l.json().catch(()=>({})),d=Pe(h),g={platform:"wapstore",idProduto:a[0]&&a[0].idProduto,size:i&&i.label||null};return d&&(g.cartValue=d.value,g.itemCount=d.itemCount,g.currency=d.currency),g}async function Cn(){try{let t=await fetch(jt+"/checkout/cart",{headers:Mt}).then(e=>e.json());return Pe(t)}catch(t){}return null}function vn(){try{let t=document.querySelector(".common-sheet.side-cart, .side-cart");if(t&&t.getBoundingClientRect().width>0)return!0;let e=document.querySelector('.button-cart, [class*="button-cart"]');if(e)return e.click(),!0}catch(t){}return!1}var Nt={};v(Nt,{addToCart:()=>In,detect:()=>An,getCartSummary:()=>Rn,id:()=>kn,openCartDrawer:()=>Pn,resolveSku:()=>Ln,skipRedirect:()=>Sn});var kn="linx",Sn=!0;function Tn(t){if(t==null)return null;let e=String(t).match(/([\d.]+,\d{2}|\d+(?:\.\d{2})?)/),r=(e?e[1]:String(t)).replace(/[^\d.,]/g,"");if(!r)return null;let n=r.indexOf(",")>r.indexOf(".")?parseFloat(r.replace(/\./g,"").replace(",",".")):parseFloat(r.replace(/,/g,""));return Number.isFinite(n)&&n>0?n:null}function An(){return typeof window.carrinhoLateral=="function"&&typeof window.addToCart=="function"}function Ln(){try{let t=(location.pathname.match(/-p(\d+)\/?(?:[?#]|$)/)||[])[1];if(t)return{value:t,source:"linx/url-pid"};let e=(String(document.body.className||"").match(/context-product-(\d+)/)||[])[1];if(e)return{value:e,source:"linx/context"}}catch(t){}return null}function En(){let t=[...document.querySelectorAll('.add-to-cart, [data-action="add-to-cart"]')];return t.find(e=>{let r=e.getBoundingClientRect();return r.width>0&&r.height>0})||t[0]||null}async function In(){let t=En();if(!t)throw new Error("linx: bot\xE3o .add-to-cart n\xE3o encontrado");return t.click(),await new Promise(e=>setTimeout(e,1400)),{platform:"linx"}}function Rn(){try{let t=document.querySelector("#mini-cart");if(!t)return null;let e=null;for(let n of t.querySelectorAll("div,span,p,li,strong,b,td")){if(n.children.length>2)continue;let o=(n.textContent||"").replace(/\s+/g," ").trim();if(/^(sub)?total\b/i.test(o)&&/R\$/.test(o)&&(e=Tn(o),e))break}if(e==null)return null;let r=(t.textContent||"").match(/cont[ée]m\s+(\d+)\s+ite/i);return{value:e,itemCount:r?parseInt(r[1],10):null,currency:"BRL"}}catch(t){}return null}function Pn(){try{let e=typeof window.carrinhoLateral=="function"?window.carrinhoLateral():null;if(e&&typeof e.openCart=="function"){try{typeof e.fetchHTML=="function"&&e.fetchHTML()}catch(r){}return setTimeout(()=>{try{e.openCart()}catch(r){}},400),!0}}catch(e){}let t=document.querySelector("#mini-cart");if(t){try{t.classList.add("open")}catch(e){}return!0}return!1}var qt={};v(qt,{addToCart:()=>J,detect:()=>Mn,id:()=>jn,resolveSku:()=>Ot});var jn="generic";function Mn(){return!0}function Ot(){let t=L(["Product"]);if(t[0]){let e=t[0],r=e.sku||e.mpn||e.gtin13||e.productID;if(r)return{value:String(r),source:"jsonld"}}try{let e=document.querySelector('[itemprop="sku"]');if(e){let r=e.getAttribute("content")||(e.textContent||"").trim();if(r)return{value:String(r),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 Bn=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora/i,Nn=/continuar|como comprar|lista|desejos|favorito/i;async function J(){let t=document.querySelectorAll("button,[role=button],input[type=submit]");for(let e of t){let r=(e.textContent||e.value||"").replace(/\s+/g," ").trim();if(r&&r.length<40&&Bn.test(r)&&!Nn.test(r))try{return e.click(),{platform:"native-click",clicked:r}}catch(n){}}return{platform:"none",error:"bot\xE3o de carrinho nativo n\xE3o encontrado"}}var Me=[At,rt,Et,It,Rt,Pt,Bt,Nt],On=[["woocommerce",()=>!!(window.wc_add_to_cart_params||window.woocommerce_params)],["lojaintegrada",()=>!!window.LojaIntegrada]],it;function q(){return it||(it=Me.find(t=>{try{return t.detect()}catch(e){return!1}})||qt,it)}function Be(){let t=Me.find(e=>{try{return e.detect()}catch(r){return!1}});if(t)return t.id;for(let[e,r]of On)try{if(r())return e}catch(n){}return null}function D(){let t=q();if(t.id!=="generic"&&t.resolveSku)try{let e=t.resolveSku();if(e)return e}catch(e){}return Ot()}async function Ne(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},r=q();try{let n=r.addToCart?await r.addToCart(e):await J(e);return f("cart: adicionado",n),Dt(),je(r,n,e.sku),n}catch(n){f('cart: adapter "'+r.id+'" falhou \u2014 fallback clique nativo',n&&n.message);let o=await J(e);return Dt(),je(r,o,e.sku),o}}async function je(t,e,r){try{let n=null;e&&e.cartValue!=null?n={value:e.cartValue,itemCount:e.itemCount!=null?e.itemCount:null,currency:e.currency||null}:t&&t.getCartSummary&&(n=await t.getCartSummary()),n&&n.value!=null&&(n.value>0||(n.itemCount||0)>0)&&u("cart_value",{via:"tryon",value:n.value,itemCount:n.itemCount!=null?n.itemCount:null,currency:n.currency||null,sku:r||null})}catch(n){}}async function Ut(){let t=q();if(t&&t.getCartSummary)try{return await t.getCartSummary()}catch(e){}return null}async function Oe(t){t=t||{};let e=q(),r={platform:e.id};try{let n=D();r.sku=n&&n.value||null;let o={size:t.size||null,color:t.color||null,sku:r.sku,quantity:t.quantity||1};r.added=e.addToCart?await e.addToCart(o):await J(o),Dt();try{await Ft()}catch(i){}r.cart=await Ut(),r.ok=!0}catch(n){r.ok=!1,r.error=n&&n.message||String(n)}return r}function Dt(){["cart:refresh","cart:updated","cart:build","ajaxProduct:added","product:added-to-cart"].forEach(t=>{try{document.dispatchEvent(new CustomEvent(t))}catch(e){}})}async function Ft(){let t=q(),e=m(),r=null;try{r=await O()}catch(i){}let n=r&&r.template&&r.template.cart||r&&r.cart||{},o=n.afterAdd||n.behavior||e.cartBehavior;if(o||(o=e.cartRedirect===!1?"none":"auto"),o==="none")return!1;if(o==="auto"||o==="drawer"){let i=n.openSelector||e.cartOpenSelector;if(i){let c=document.querySelector(i);if(c)return setTimeout(()=>{try{c.click()}catch(a){}},300),!1}else if(t&&t.openCartDrawer){let c=!1;try{c=t.openCartDrawer()}catch(a){}if(c)return!1}}return!0}function qe(){let t=q();if(t&&t.skipRedirect)return;let e=t&&t.cartUrl||"/cart";setTimeout(()=>{try{window.location.href=e}catch(r){}},250)}var qn=/\/(thank[_-]?you|orders?\/|pedido[_-]?(confirmado|realizado|finalizado|sucesso)|sucesso|order[_-]?confirmation|compra[_-]?(finalizada|concluida)|orderplaced)/i,Dn=/\/(my[_-]?account|minha[_-]?conta|account|conta|customer|cliente|profile|perfil|wishlist|favoritos)(\/|$)/i,Un=/\/checkout/i,Fn=/\/(cart|carrinho|sacola|bag)(\/|$|\?|#)/i,zn=/\/(products?|produtos?|p)\//i,$n=/\/(collections?|categoria|categorias|c|departamento)\//i,Kn=/\/(search|busca|s)(\/|\?)/i;function De(){try{if(window.__mkPageType)return window.__mkPageType}catch(r){}let t=(location.pathname||"").toLowerCase(),e=Dn.test(t);try{let r=L();for(let n of r){let o=Array.isArray(n["@type"])?n["@type"]:[n["@type"]];if((o.includes("Order")||o.includes("Invoice"))&&!e)return"purchase";if(o.includes("Product"))return"pdp";if(o.includes("SearchResultsPage"))return"search";if(o.includes("CollectionPage")||o.includes("ItemList"))return"category"}}catch(r){}return t==="/"||t===""||t==="/home"||t==="/index.html"?"home":qn.test(t)&&!e?"purchase":Un.test(t)?"checkout":Fn.test(t)?"cart":zn.test(t)?"pdp":$n.test(t)?"category":Kn.test(t)?"search":"other"}function Ue(t){let e=null;try{let r=new URLSearchParams(location.search),n=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],o={};for(let i of n){let c=r.get(i);c&&(o[i.replace("utm_","")]=c)}Object.keys(o).length&&(e=o)}catch(r){}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:Hn()}}function Hn(){return Be()}var zt={},Vn=null,W=0,Fe=!1;function ze(t){Fe||(Fe=!0,$e(t),Jn(),Wn(),Gn(),Xn(),Yn(t))}function $e(t){zt={};let e=De(),r=Ue(e);if(xe(r),u("view",{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:e}),typeof t=="function")try{t(e,r)}catch(n){}}function Jn(){if(!document.body)return;let t={A:1,BUTTON:1,INPUT:1,SELECT:1,TEXTAREA:1},e=0;document.body.addEventListener("click",r=>{try{let n=Date.now();if(n-e<100)return;e=n;let o=r.target;for(let a=0;a<5&&o&&o!==document.body&&!(t[o.tagName]||o.getAttribute&&o.getAttribute("role")==="button");a++)o=o.parentElement;if(!o||!t[o.tagName]&&!(o.getAttribute&&o.getAttribute("role")==="button"))return;let i={tag:o.tagName},c=o.tagName==="INPUT"||o.tagName==="TEXTAREA"?o.value:o.textContent;i.text=(c||"").replace(/\s+/g," ").trim().substring(0,100),o.href&&(i.href=String(o.href).substring(0,500)),o.id&&(i.id=o.id),o.className&&typeof o.className=="string"&&(i.classes=o.className.trim().substring(0,200)),u("click",i)}catch(n){}},{capture:!0,passive:!0})}function Wn(){let t=[25,50,75,100],e=null,r=()=>{try{let n=window.scrollY||document.documentElement.scrollTop||0,o=Math.max(document.body&&document.body.scrollHeight||0,document.documentElement&&document.documentElement.scrollHeight||0);if(o<=0)return;let i=Math.min(100,Math.floor((n+window.innerHeight)/o*100));for(let c of t)i>=c&&!zt[c]&&(zt[c]=!0,u("scroll_depth",{depth:c}))}catch(n){}};r(),window.addEventListener("scroll",()=>{e||(e=setTimeout(()=>{e=null,r()},250))},{passive:!0})}function Gn(){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 r="other",n=(e.className||"").toLowerCase(),o=(e.action||"").toLowerCase();e.querySelector('input[type="search"], input[name="q"], input[name="s"]')?r="search":/newsletter|subscribe|mailchimp/.test(n+o)?r="newsletter":/contact|contato/.test(n+o)&&(r="contact"),u("form_submit",{form_id:e.id||"",form_type:r})}catch(e){}},{capture:!0})}function Xn(){let t=m();W=Date.now(),Vn=setInterval(()=>{if(document.hidden)return;let e=Date.now(),r=Math.round((e-W)/1e3);W=e,r>0&&r<60&&u("engagement",{url:location.pathname,dwellSec:r})},t.engagementIntervalMs),document.addEventListener("visibilitychange",()=>{if(document.hidden){let e=Math.round((Date.now()-W)/1e3);e>0&&e<600&&u("engagement",{url:location.pathname,dwellSec:e})}W=Date.now()})}function Yn(t){let e=location.href,r=()=>{location.href!==e&&(e=location.href,$e(t))};try{let n=history.pushState,o=history.replaceState;history.pushState=function(){n.apply(this,arguments),setTimeout(r,0)},history.replaceState=function(){o.apply(this,arguments),setTimeout(r,0)},window.addEventListener("popstate",r)}catch(n){}}function Kt(){let t=D(),e=L(["Product"]);if(e.length>0){let o=e[0],i=Array.isArray(o.offers)?o.offers[0]:o.offers;return{sku:t?t.value:o.sku||o.mpn||o.gtin13||o.productID||null,skuSource:t?t.source:null,name:typeof o.name=="string"?o.name:null,price:i&&parseFloat(i.price||i.lowPrice)||null||Ke(),currency:i?i.priceCurrency:null,brand:o.brand?typeof o.brand=="string"?o.brand:o.brand.name:null,category:o.category||null}}let r=o=>{let i=document.querySelector('meta[property="og:'+o+'"], meta[property="product:'+o+'"]');return i?i.getAttribute("content"):null},n=o=>{let i=document.querySelector('[itemprop="'+o+'"]');return i?i.getAttribute("content")||(i.textContent||"").trim():null};if(t||r("type")==="product"||r("price:amount")||n("name")){let o=n("price")||r("price:amount"),i=o&&parseFloat(String(o).replace(",","."))||null;return{sku:t?t.value:null,skuSource:t?t.source:null,name:n("name")||r("title")||document.title||null,price:(i&&i>0?i:null)||Ke(),currency:n("priceCurrency")||r("price:currency")||null,brand:n("brand")||null,category:null}}return null}function Ke(){try{let t=window.dataLayer;if(!Array.isArray(t))return null;for(let e=t.length-1;e>=0;e--){let r=t[e];if(!r||typeof r!="object")continue;let n=r.ecommerce||r,o=n&&n.items||null,i=n&&n.detail&&n.detail.products||n&&n.products||r.products||null,c=Array.isArray(o)&&o[0]&&o[0].price||Array.isArray(i)&&i[0]&&i[0].price||null,a=$t(c!=null?String(c):"");if(a)return a}}catch(t){}return null}function R(){try{let t=location.pathname+location.search,e=t.match(/order[_-]?confirmation\/([\w-]+)/i)||t.match(/[?&]order[_-]?id=([\w-]+)/i)||t.match(/\/orders?\/([\w-]{4,})/i)||t.match(/pedido[_-]?(?:confirmado|realizado|finalizado)?\/([\w-]+)/i);return e?e[1]:null}catch(t){return null}}function Ht(){let t=L(["Order","Invoice"]);if(t.length>0){let o=t[0],i=o.totalPaymentDue?parseFloat(o.totalPaymentDue.price):parseFloat(o.price||o.total);return{orderId:o.orderNumber||o.confirmationNumber||o.identifier||R(),revenue:Number.isFinite(i)?i:null,currency:o.totalPaymentDue&&o.totalPaymentDue.priceCurrency||o.priceCurrency||null,source:"jsonld"}}try{let o=window.Shopify&&window.Shopify.checkout;if(o&&o.total_price!=null){let i=parseFloat(o.total_price);return{orderId:(o.order_id!=null?String(o.order_id):null)||o.token||R(),revenue:Number.isFinite(i)?i:null,currency:o.currency||null,itemCount:Array.isArray(o.line_items)?o.line_items.length:null,source:"shopify"}}}catch(o){}try{if(Array.isArray(window.dataLayer))for(let o=window.dataLayer.length-1;o>=0;o--){let i=window.dataLayer[o],c=i&&i.ecommerce||i&&i.ecommerce_data&&i.ecommerce_data.ecommerce;if(c&&(i.event==="purchase"||c.purchase)){let a=c.purchase&&c.purchase.actionField,l=parseFloat(a&&(a.revenue||a.value)||c.value||c.revenue);return{orderId:a&&(a.id||a.transaction_id)||c.transaction_id||c.transactionId||R(),revenue:Number.isFinite(l)?l:null,currency:c.currency||c.currencyCode||a&&a.currency||null,itemCount:(c.purchase&&c.purchase.products||c.items||c.products||[]).length||null,source:"datalayer"}}}}catch(o){}let e=document.querySelector('meta[property="order:total"], meta[name="order-total"]');if(e&&e.content)return{orderId:R(),revenue:parseFloat(e.content)||null,source:"meta"};let r=Zn();if(r)return r;let n=R();return n?{orderId:n,revenue:null,source:"url"}:null}function Zn(){try{let t=document.querySelector(".orderTotalPrice");if(t){let r=String(t.value||t.getAttribute("value")||t.textContent||"").trim(),n=r.split(/\s+/),o=$t(n.length>1?n[n.length-1]:r);if(o)return{orderId:He(),revenue:o,currency:(n.length>1?n[0]:null)||null,source:"dom"}}let e=[".order-total","#order-total",".total-price",".order__total","[data-order-total]",".summary-total",".grand-total"];for(let r of e){let n=document.querySelector(r);if(n){let o=$t(n.value||n.textContent);if(o)return{orderId:He(),revenue:o,source:"dom"}}}return null}catch(t){return null}}function He(){try{let t=document.querySelector(".orderID");if(t&&(t.value||t.getAttribute("value")))return t.value||t.getAttribute("value");let r=(document.body.innerText||"").match(/(?:pedido|order|n[º°o]\.?)\s*#?\s*([A-Z0-9-]{4,})/i);return r?r[1]:null}catch(t){return null}}function $t(t){if(!t)return null;let e=String(t).replace(/[^\d.,]/g,"");if(!e)return null;let r;e.indexOf(",")>e.indexOf(".")?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");let n=parseFloat(r);return Number.isFinite(n)&&n>0?n:null}function Ve(){let t=L(["ItemList","CollectionPage"]);if(t.length===0)return null;let e=t[0],r=e.itemListElement||e.mainEntity&&e.mainEntity.itemListElement||[],n=[];for(let o of r.slice(0,50)){let i=o.item||o;i&&(i.sku||i.productID||i.name)&&n.push(i.sku||i.productID||i.name)}return n.length>0?{count:n.length,skus:n.slice(0,20)}:null}var Je=!1,ct=[/\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],Qn=[/^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 G(t,e){for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}function Xe(t){switch(t){case"pdp":{let e=Kt();u("view_item",e||{sku:null});break}case"category":case"search":{let e=Ve();u("view_item_list",e||{count:0});break}case"cart":Ut().then(e=>u("view_cart",e&&e.value!=null?{value:e.value,itemCount:e.itemCount,currency:e.currency}:{})).catch(()=>u("view_cart",{}));break;case"checkout":u("begin_checkout",{});break;case"purchase":to();break}}var We=500,Ge=16;function to(){let t=!1,e=0,r=(o,i)=>{t||(t=!0,eo(o,i))};try{window.addEventListener("pagehide",()=>r(Ht(),!0),{once:!0})}catch(o){}let n=()=>{if(t)return;let o=Ht();if(o&&o.revenue!=null)return r(o);if(e++>=Ge)return f("purchase: receita n\xE3o apareceu em "+We*Ge+"ms \u2014 emitindo sem valor"),r(o);setTimeout(n,We)};n()}function eo(t,e){if(t&&!t.orderId&&(t.orderId=R()),t&&t.orderId){let r="_mk_purch_"+t.orderId;try{if(sessionStorage.getItem(r)){f("purchase j\xE1 contado",t.orderId);return}sessionStorage.setItem(r,"1")}catch(n){}}else if(Je)return;if(Je=!0,u("purchase",t||{revenue:null,_note:"no_order_data_extracted"}),f("purchase emitido",t),e)try{I(!0)}catch(r){}}function Ye(){if(!document.body)return;let t=0;document.body.addEventListener("click",e=>{try{let r=Date.now();if(r-t<150)return;let n=e.target;for(let a=0;a<5&&n&&n!==document.body&&!(n.tagName==="BUTTON"||n.tagName==="A"||n.getAttribute&&n.getAttribute("role")==="button");a++)n=n.parentElement;if(!n)return;let o=n.tagName!=="A",i=(n.textContent||"").replace(/\s+/g," ").trim();if(!i||i.length>80)return;let c=!1;if((G([ct[0]],i)||o&&G([ct[1]],i)||o&&G([ct[2]],i)||G(ct.slice(3),i))&&(c=!0),c){t=r;let a=Kt();u("add_to_cart",{via:"click",buttonText:i,sku:a?a.sku:null,price:a?a.price:null});return}o&&G(Qn,i)&&(t=r,u("begin_checkout",{via:"click",buttonText:i}))}catch(r){}},{capture:!0,passive:!0})}var at={};v(at,{available:()=>io,id:()=>ro,iframeSrc:()=>oo,modalSize:()=>no,onMounted:()=>co});var ro="mk-fashion",no={width:430,height:800};function oo(t,e){let r=encodeURIComponent(e).replace(/\./g,"%2E");return m().appUrl+"/"+t+"/"+r}async function io(t,e){let r=m().apiUrl+"/availability/"+t+"?sku="+encodeURIComponent(e),n=await fetch(r);if(!n.ok)throw new Error("availability HTTP "+n.status);return n.json()}function co(){}var Vt={};v(Vt,{available:()=>po,id:()=>ao,iframeSrc:()=>uo,modalSize:()=>lo,onMounted:()=>go});var ao="mk-makeup",lo={width:1160,height:700};function so(){return window.__MK&&window.__MK.pulpoarUrl||"https://plugin.pulpoar.com/vto"}function uo(t){return so()+"/"+encodeURIComponent(t)}function po(){return Promise.resolve({available:!0})}var fo="https://cdn.jsdelivr.net/npm/@pulpoar/plugin-sdk@latest/dist/index.iife.js",lt=null;function mo(){return window.pulpoar?Promise.resolve(window.pulpoar):lt||(lt=new Promise(t=>{try{let e=document.createElement("script");e.src=fo,e.async=!0,e.onload=()=>t(window.pulpoar||null),e.onerror=()=>t(null),(document.head||document.documentElement).appendChild(e)}catch(e){t(null)}}),lt)}async function ho(t){try{if(window.Shopify||window.ShopifyAnalytics){let e=(location.pathname.split("/products/")[1]||"").split(/[?#]/)[0];if(e){let r=window.ShopifyAnalytics&&window.ShopifyAnalytics.meta,n=new URLSearchParams(location.search).get("variant")||r&&r.selectedVariantId,i=(await fetch("/products/"+e+".js").then(l=>l.json())).variants||[],c=n?i.find(l=>String(l.id)===String(n)):null;if(c&&c.sku)return c.sku;let a=i.find(l=>l.available)||i[0];if(a&&a.sku)return a.sku}}}catch(e){}return t||null}function yo(t){let e=Array.isArray(t)?t[0]:t;return!e||typeof e!="object"?{quantity:1}:{sku:e.sku||e.slug||e.key||e.variant_key||e.barcode||null,color:e.color||e.shade||e.colorName||null,size:e.size||null,quantity:1}}function go(t,e){mo().then(async r=>{if(!r){f("pulpoar: SDK n\xE3o carregou");return}let n=await ho(e.identifier);if(f("pulpoar variante p/ cat\xE1logo",n),n)try{r.applyVariantsWithCatalog([String(n)],o=>{e.track("product_loaded",{via:"makeup",applied:Array.isArray(o)?o.length:0})})}catch(o){f("pulpoar applyVariantsWithCatalog falhou",o&&o.message)}try{r.onReady(()=>e.fire("onReady",{}))}catch(o){}try{r.onAddToCart(o=>{f("pulpoar onAddToCart",o),e.handleAddToCart(yo(o),"makeup")})}catch(o){}try{r.onGoToProduct(o=>e.fire("onGoToProduct",o))}catch(o){}})}var wo={"mk-fashion":at,"mk-makeup":Vt};function st(t){return wo[t]||at}var A=null,T=null,dt=!1,pt=!1,U=null,Ze={},Jt=null,ut=0,k={onReady:null,onClose:null,onAddToCart:null,onProductLoaded:null,onError:null,onInteraction:null,onGenerationComplete:null},xo={gregory:"698c7e791d3129430f15dddd"};function tr(t){return t?xo[String(t).toLowerCase()]||t:null}async function F(t,e){let r=tr(t),n=String(e||"").trim();return st(m().product).available(r,n)}async function er(t,e){e||(e=t,t="698c7e791d3129430f15dddd");try{return(await F(t,e)).available===!0}catch(r){return!1}}async function ft(t){if(t=t||{},dt)return;let e=tr(t.projectId||t.projectid||t.store),r=String(t.identifier||t.sku||"").trim();if(!e||!r){console.error("[mk-sdk] open: projectId e identifier obrigatorios");return}let n=e+":"+r;if(Ze[n]!==!0){try{if(!(await F(e,r)).available){alert("Produto nao disponivel para prova virtual.");return}}catch(i){alert("Produto nao encontrado ou indisponivel.");return}Ze[n]=!0}let o=st(m().product).modalSize||{width:430,height:800};U={projectId:e,identifier:r,width:t.width||o.width,height:t.height||o.height},pt=!1,or(),bo(U),dt=!0,ut=Date.now(),u("modal_opened",{projectId:e,identifier:r})}function Gt(){if(!dt)return;let t=pt;if(pt=!1,_o(),dt=!1,E("onClose"),u("modal_closed",{projectId:U&&U.projectId,identifier:U&&U.identifier}),t)try{qe()}catch(e){}}function rr(t){try{let e=fr();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 bo(t){A=document.createElement("div"),A.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,.8);display:flex;align-items:center;justify-content:center;z-index:2147483647;",rr(!0);let e=document.createElement("div"),r=typeof t.width=="number"?t.width+"px":t.width,n=typeof t.height=="number"?t.height+"px":t.height;e.style.cssText="position:relative;width:"+r+";height:"+n+";max-width:100vw;max-height:100dvh;border-radius:12px;overflow:hidden;background:#fff;",T=document.createElement("iframe");let o=st(m().product);T.src=o.iframeSrc(t.projectId,t.identifier),T.style.cssText="width:100%;height:100%;border:none;",T.setAttribute("allow","camera *; microphone *"),T.setAttribute("allowfullscreen","true"),e.appendChild(T),A.appendChild(e),document.body.appendChild(A);try{o.onMounted(T,{projectId:t.projectId,identifier:t.identifier,handleAddToCart:ir,track:u,fire:E})}catch(i){f("launcher.onMounted falhou",i&&i.message)}f("try-on modal aberto",T.src)}function _o(){A&&A.parentNode&&A.parentNode.removeChild(A),A=null,T=null,rr(!1)}var Qe=!1;function nr(){or()}function or(){Qe||(Qe=!0,window.addEventListener("message",t=>{let e=t.data;if(!e||e.source!=="mkfashion-app")return;let r=e.action,n=e.data||{};switch(r){case"close_request":Gt();break;case"ready":E("onReady",n);break;case"product_loaded":E("onProductLoaded",n),u("product_loaded",Wt(n));break;case"interaction":{E("onInteraction",n),n&&n.method&&(Jt=n.method),u(Co(n),Wt(n));break}case"add_to_cart":ir(n,"tryon");break;case"generation_start":ut=Date.now();break;case"generation_complete":E("onGenerationComplete",n),u("generation_complete",{method:n.method||Jt||"unknown",durationMs:ut?Date.now()-ut:null,success:n.success!==!1,imageUrlPresent:!!n.imageUrl});break;case"generation_error":E("onError",n),u("generation_error",{method:Jt||"unknown",error:n&&n.error});break}}))}function ir(t,e){if(u("add_to_cart",Object.assign({via:e||"tryon"},Wt(t))),typeof k.onAddToCart=="function"){E("onAddToCart",t);return}Ne(t).then(()=>Ft()).then(r=>{pt=!!r}).catch(()=>{})}function Co(t){return t&&t.action,"interaction"}function Wt(t){if(!t||typeof t!="object")return t;let e={};for(let r in t){if(r==="imageUrl"||r==="image"||r==="product"){r==="product"&&t[r]?(e.productSku=t[r].sku||null,e.productName=t[r].name||null):e[r+"Present"]=!!t[r];continue}e[r]=t[r]}return e}function E(t,e){if(typeof k[t]=="function")try{k[t](e)}catch(r){console.error("[mk-sdk]",r)}}function cr(t){k.onReady=t}function ar(t){k.onClose=t}function lr(t){k.onAddToCart=t}function sr(t){k.onProductLoaded=t}function ur(t){k.onError=t}function dr(t){k.onInteraction=t}function pr(t){k.onGenerationComplete=t}var ko=767,So=1024,To=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora|^comprar$|finalizar compra|eu quero/i,Ao=/continuar|como comprar|lista|desejos|favorito|looks|cupom/i;function Xt(t){try{let e=t.getBoundingClientRect();if(e.width<=0||e.height<=0)return!1;let r=getComputedStyle(t);return r.display!=="none"&&r.visibility!=="hidden"&&r.opacity!=="0"}catch(e){return!1}}function Lo(t){if(!t)return!1;try{let e=document.querySelector(t);return!!e&&Xt(e)}catch(e){return!1}}function Eo(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(n=>{let o=t[n];o&&o.mkAnchor===1&&o.anchor&&typeof o.anchor=="object"&&(e=!0)}),!e)return t;let r={};return["mobile","tablet","desktop"].forEach(n=>{let o=t[n];if(o){if(o.selector){r[n]=o;return}if(o.mkAnchor===1&&o.anchor&&typeof o.anchor=="object"){let i=o.anchor[n]||o.anchor.desktop||o.anchor.mobile||o.anchor.tablet;i&&i.selector&&(r[n]=i)}}}),["bpMobile","bpTablet","breakpoint"].forEach(n=>{t[n]!=null&&(r[n]=t[n])}),r}function Yt(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(l=>l[1]&&l[1].selector);if(e.length===0)return null;if(e.length===1)return e[0][1];let r=e.filter(([,l])=>Lo(l.selector));if(r.length===1)return r[0][1];let n=window.innerWidth||1024,o=Number(t.bpMobile)||Number(t.breakpoint)||ko,i=Number(t.bpTablet)||So,c=l=>(e.find(h=>h[0]===l)||[])[1],a=n<=o?["mobile","tablet","desktop"]:n<=i?["tablet","desktop","mobile"]:["desktop","tablet","mobile"];for(let l of a){let h=c(l);if(h)return h}return e[0][1]}function mr(){let t=m(),e=Yt(t&&t.anchor);if(e&&e.selector)try{let n=document.querySelector(e.selector);if(n&&Xt(n))return{el:n,position:e.position||"afterend",mode:e.mode||"flow",style:e.style||"",align:e.align||"top-left",selector:e.selector}}catch(n){}let r=document.querySelectorAll('button, [role="button"], a.btn, a.button, input[type="submit"], input[type="button"]');for(let n of r){let o=Eo(n);if(!(!o||o.length>40)&&!Ao.test(o)&&To.test(o)&&Xt(n))return{el:n,position:"afterend",mode:"flow",style:"",selector:null}}return null}var C="'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Zt={none:"0",sm:"4px",md:"8px",pill:"9999px"},Qt={none:"0",sm:"4px",md:"8px",lg:"16px"},Ro='<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>',Po='<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 w(t,e={}){let r=document.createElement(t);if(e.style&&(r.style.cssText=e.style),e.text!=null&&(r.textContent=e.text),e.html!=null&&(r.innerHTML=e.html),e.attrs)for(let n in e.attrs)r.setAttribute(n,e.attrs[n]);if(e.on)for(let n in e.on)r.addEventListener(n,e.on[n]);if(e.children)for(let n of e.children)n&&r.appendChild(n);return r}function mt(t,e){let r=Number(e)>0?Number(e):24;return w("span",{style:`width:${r}px;height:${r}px;padding:2px;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:Ro})}function hr(t){return w("span",{style:`width:12px;height:12px;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:Po})}function ht(t){return t.borderWidth>0&&t.borderColor?`${t.borderWidth}px solid ${t.borderColor}`:"none"}function yt(){if(!document.getElementById("mk-jakarta-font"))try{document.head.appendChild(w("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 jo(t){return t.subtext?w("span",{style:`display:flex;align-items:center;justify-content:center;padding:4px;background:${t.badgeBgColor};font-family:${C};font-weight:700;font-size:16px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,text:t.subtext}):null}function yr(t,e){yt();let r=w("span",{style:"display:inline-flex;align-items:center;gap:4px;",children:[mt(t.textColor,t.iconSize),w("span",{text:t.text,style:`font-family:${C};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 w("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:${ht(t)};border-radius:${t.borderRadiusPx};font-family:${C};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[r,jo(t)],on:{mouseenter:n=>{n.currentTarget.style.opacity="0.85"},mouseleave:n=>{n.currentTarget.style.opacity="1"},click:n=>{try{n.preventDefault(),n.stopPropagation()}catch(o){}try{e&&e()}catch(o){}}}})}function Bo(t){return t.subtext?w("span",{style:`display:flex;align-items:center;gap:4px;padding:4px;background:${t.badgeBgColor};font-family:${C};font-weight:600;font-size:10px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,children:[hr(t.badgeTextColor),w("span",{text:t.subtext})]}):null}function No(t,e){return w("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:${ht(t)};border-radius:${t.borderRadiusPx};filter:drop-shadow(0 0 6px rgba(0,0,0,0.08));font-family:${C};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[mt(t.textColor,t.iconSize),w("span",{text:t.text,style:`font-family:${C};font-weight:700;font-size:${t.fontSize}px;color:${t.textColor};white-space:nowrap;line-height:1;`})],on:{mouseenter:r=>{r.currentTarget.style.opacity="0.85"},mouseleave:r=>{r.currentTarget.style.opacity="1"},click:r=>{try{r.preventDefault(),r.stopPropagation()}catch(n){}try{e&&e()}catch(n){}}}})}function gr(t,e){yt();let r=w("div",{style:"display:flex;flex-direction:column;gap:4px;",children:[t.cardTitle&&w("p",{text:t.cardTitle,style:`margin:0;font-family:${C};font-weight:700;font-size:16px;letter-spacing:1px;text-transform:uppercase;color:${t.cardTitleColor};line-height:1.2;`}),t.cardDescription&&w("p",{html:t.cardDescription,style:`margin:0;font-family:${C};font-weight:400;font-size:12px;max-width:177px;line-height:1.2;color:${t.cardTextColor};`})]}),n=w("div",{style:"display:flex;flex-direction:column;justify-content:space-between;gap:16px;flex:1 1 0;min-width:0;",children:[r,t.cardFooter&&w("p",{text:t.cardFooter,style:`margin:0;font-family:${C};font-weight:400;font-size:10px;color:${t.cardTextColor};line-height:1.2;`})]}),o=w("div",{style:"display:flex;flex-direction:column;align-items:flex-end;flex:1 1 0;min-width:0;",children:[Bo(t),No(t,e)]}),i=w("div",{style:"display:flex;gap:16px;align-items:stretch;width:100%;flex:1;box-sizing:border-box;",children:[n,o]});return w("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:${C};`,children:[i]})}var qo={style:"gregory-black",text:"Provar Virtualmente",fontSize:14,iconSize:24,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 te(t,e){let r=(e?t&&t.mobile:t&&t.desktop)||t&&t.desktop||t&&t.mobile||{},n={...qo,...r};return n.style==="gregory-card"&&e&&(n.style="gregory-black"),n.borderRadiusPx=Zt[n.borderRadius]!=null?Zt[n.borderRadius]:"0",n.cardBorderRadiusPx=Qt[n.cardBorderRadius]!=null?Qt[n.cardBorderRadius]:"0",n.fontSize=Number(n.fontSize)||14,n.iconSize=Number(n.iconSize)||24,n.borderWidth=Number(n.borderWidth)||0,n}var ee={"gregory-black":yr,"gregory-card":gr},$i=Object.keys(ee);function wr(t,e){return(ee[t.style]||ee["gregory-black"])(t,e)}function Do(){return"abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)]+Math.random().toString(36).slice(2,11)}var X=null;function fr(){return X}function Uo(t,e){let r;try{r=document.createElement("iframe"),r.setAttribute("aria-hidden","true"),r.style.cssText="display:none!important;width:0;height:0;border:0;position:absolute;left:-9999px;",(document.body||document.documentElement).appendChild(r);let n=r.contentWindow&&r.contentWindow.Element&&r.contentWindow.Element.prototype&&r.contentWindow.Element.prototype.attachShadow;if(typeof n=="function"){let o=n.call(t,e);return r.remove(),o}}catch(n){}try{r&&r.remove()}catch(n){}return t.attachShadow(e)}var Fo=/^(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 zo(t){return!t||typeof t!="string"?"":t.split(";").map(e=>e.trim()).filter(Boolean).filter(e=>Fo.test(e.split(":")[0].trim().toLowerCase())).join(";")}var gt=null,re=!1,ne={},xr=!1,oe=null;function br(){return oe||(oe=O().then(t=>t&&t.template&&t.template.tryOnButton||null).catch(()=>null)),oe}function $o(){if(xr)return;xr=!0;let t=null;try{window.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{gt&&z("pdp")},200)})}catch(e){}}function ie(){let t=X;if(t){if(typeof t.__mkCleanup=="function")try{t.__mkCleanup()}catch(e){}t.parentNode&&t.parentNode.removeChild(t)}X=null,gt=null}var Ko={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 Ho(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 Vo(t,e,r){let o=!Ko[t.tagName]?t:t.parentElement||document.body;try{getComputedStyle(o).position==="static"&&(o.style.position="relative")}catch(d){}if(o===t){e.style.cssText="position:absolute;z-index:2147483000;"+Ho(r),t.appendChild(e);return}e.style.cssText="position:absolute;z-index:2147483000;",o.appendChild(e);let i=()=>{try{let d=t.getBoundingClientRect(),g=o.getBoundingClientRect(),s=e.offsetWidth,y=e.offsetHeight,x=d.top-g.top+o.scrollTop,b=d.left-g.left+o.scrollLeft,p=r||"top-left",S=x,_=b;p.indexOf("bottom")===0?S=x+d.height-y:(p.indexOf("middle")===0||p==="center")&&(S=x+(d.height-y)/2),p.indexOf("right")>=0?_=b+d.width-s:p.indexOf("center")>=0&&(_=b+(d.width-s)/2),e.style.top=S+"px",e.style.left=_+"px"}catch(d){}};i();let c=()=>i();window.addEventListener("resize",c);let a=setTimeout(i,600),l=setTimeout(i,1500),h=null;try{if(t.tagName==="IMG"&&!t.complete&&t.addEventListener("load",i,{once:!0}),typeof ResizeObserver=="function"){h=new ResizeObserver(()=>i());try{h.observe(t)}catch(d){}try{h.observe(o)}catch(d){}}}catch(d){}e.__mkCleanup=()=>{window.removeEventListener("resize",c),clearTimeout(a),clearTimeout(l);try{t.removeEventListener("load",i)}catch(d){}try{h&&h.disconnect()}catch(d){}}}function Jo(t,e,r){try{return t.insertAdjacentElement(r||"afterend",e),!0}catch(n){try{return t.parentNode.insertBefore(e,t.nextSibling),!0}catch(o){return!1}}}async function z(t){let e=m();if(t!=="pdp"){ie();return}if(!e.projectId)return;if(!e._anchorFromPicker){let l=await br();l&&l.anchor&&(e.anchor=l.anchor)}if(re)return;let r=D(),n=r&&r.value,o=!!e.forceButton,i=Yt(e.anchor),c=[n||"demo",i?[i.selector,i.position,i.mode,i.align,i.style].join("~"):"heuristic"].join("|"),a=X;if(!(a&>===c)){if(a&&ie(),!n&&!o){f("auto-mount: SKU n\xE3o resolvido na PDP");return}re=!0;try{let l=o;o||(ne[n]||(ne[n]=F(e.projectId,n).then(_=>!!(_&&_.available)).catch(()=>!1)),l=await ne[n]);try{we(l?"available":"unavailable")}catch(_){}if(!l){f("auto-mount: produto sem try-on",n);return}let h=await br(),d=window.matchMedia("(max-width: 767px)").matches,g=te(h,d),s=mr(),y=s&&s.mode||"flow",x=wr(g,()=>{let _=D(),P=_&&_.value||n||"";ye(),u("button_clicked",{sku:P,style:g.style,mode:y}),ft({projectId:e.projectId,identifier:P})}),b=document.createElement("div");b.id=Do(),X=b,Uo(b,{mode:"closed"}).appendChild(x),["click","mousedown","mouseup","pointerdown","pointerup","touchstart"].forEach(_=>{try{b.addEventListener(_,P=>{P.stopPropagation()},!1)}catch(P){}});let S=!1;if(s&&s.el&&s.el.parentNode&&(y==="overlay"?(Vo(s.el,b,s.align),S=!0):(b.style.cssText="display:contents;",S=Jo(s.el,b,s.position))),S||(b.style.cssText="position:fixed;left:16px;bottom:16px;z-index:2147483000;",document.body.appendChild(b)),s&&s.style){let _=zo(s.style);if(_)try{x.style.cssText+=";"+_}catch(P){}}gt=c,$o(),f("auto-mount: bot\xE3o injetado",{style:g.style,sku:n,anchorFound:!!s,position:s&&s.position,mode:y,forced:o}),u("button_rendered",{style:g.style,sku:n||null,skuSource:r&&r.source,anchorFound:!!s,position:s?s.position:null,mode:y,forced:o})}finally{re=!1}}}function _r(){try{let t=m(),e={anchor:t.anchor,forceButton:t.forceButton};window.addEventListener("message",r=>{if(r.source!==window)return;let n=r.data;!n||!n.__mkCmd||(n.__mkCmd==="remount"||n.__mkCmd==="applyRecipe"?(t.anchor=n.anchor||null,t._anchorFromPicker=!0,t.forceButton=!0,z("pdp")):n.__mkCmd==="cancelPreview"&&(t.anchor=e.anchor,t._anchorFromPicker=!1,t.forceButton=e.forceButton,ie(),z("pdp")))})}catch(t){}}(function(){"use strict";try{let r=function(){try{_e(),_r(),nr(),e.autoTrack!==!1&&(ze((o,i)=>{Xe(o,i),z(o)}),Ye()),f("mk-sdk iniciado",{projectId:e.projectId,collectorUrl:e.collectorUrl})}catch(o){e.debug&&console.error("[mk-sdk] init erro",o)}},e=xt();if(e.projectId){let o=Se(e.projectId);o&&kt(o),O().then(i=>{let c=ve(i);kt(c),Te(e.projectId,c),f("escopo de coleta",c)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r();let n={open:ft,close:Gt,isAvailable:er,getAvailability:F,onReady:cr,onClose:ar,onAddToCart:lr,onProductLoaded:sr,onError:ur,onInteraction:dr,onGenerationComplete:pr,testCart:Oe,_version:"0.1.0",_isMkSdk:!0};typeof window!="undefined"&&(window.mk=n)}catch(e){typeof console!="undefined"&&console.error("[mk-sdk] boot fatal",e)}})();})();
|
|
1
|
+
(()=>{var jr=Object.defineProperty;var C=(t,e)=>{for(var r in e)jr(t,r,{get:e[r],enumerable:!0})};var kt={collectorUrl:"https://api-collector.mk3dlabs.com",appUrl:"https://mkfashion.mk3dlabs.com/visualizer",apiUrl:"https://mkfashion-new-api.mk3dlabs.com"},Mr={},$=null;function St(){if($)return $;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(c){return null}},r=e("data-mk-project")||e("data-mk-client")||window.__MK&&(window.__MK.projectId||window.__MK.clientSlug)||null,n=e("data-mk-product")||window.__MK&&window.__MK.product||"mk-fashion",o=e("data-mk-collector")||window.__MK&&window.__MK.collectorUrl||Mr.collectorUrl||kt.collectorUrl;return $={projectId:r,product:n,collectorUrl:o,appUrl:window.__MK&&window.__MK.appUrl||kt.appUrl,apiUrl:window.__MK&&window.__MK.apiUrl||kt.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,anchors:window.__MK&&window.__MK.anchors||null,cards:window.__MK&&window.__MK.cards||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:window.__MK&&window.__MK.batchIntervalMs||8e3,batchMaxSize:window.__MK&&window.__MK.batchMaxSize||20,engagementIntervalMs:15e3},$}function m(){return $||St()}function y(...t){let e=m();e&&e.debug&&typeof console!="undefined"&&console.log("[mk-sdk]",...t)}var ye="_mk_vid",ge="_mk_sid",H=null,V=null;function et(){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 we(){if(H)return H;try{let t=localStorage.getItem(ye);return t||(t="v_"+et(),localStorage.setItem(ye,t)),H=t,t}catch(t){return H="v_"+et(),H}}function xe(){if(V)return V;try{let t=sessionStorage.getItem(ge);return t||(t="s_"+et(),sessionStorage.setItem(ge,t)),V=t,t}catch(t){return V="s_"+et(),V}}var be=[/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],_e={imageUrl:1,image:1,thumbnail:1,photo:1,imageBase64:1,src:1},Tt=2e3;function Ce(t){for(let e=0;e<be.length;e++)if(be[e].test(t))return!0;return!1}function ve(t){if(!t||typeof t!="object"||Array.isArray(t))return typeof t=="string"&&t.length>Tt?t.slice(0,200)+"...[truncated "+t.length+"B]":t;let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||Ce(r))continue;let n=t[r];if(_e[r]){e[r+"Present"]=!!n;continue}if(typeof n=="string"&&n.length>Tt){e[r]=n.slice(0,200)+"...[truncated "+n.length+"B]";continue}if(n&&typeof n=="object"&&!Array.isArray(n)){e[r]=Br(n);continue}e[r]=n}return e}function Br(t){let e={};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||Ce(r))continue;let n=t[r];if(_e[r]){e[r+"Present"]=!!n;continue}if(typeof n=="string"&&n.length>Tt){e[r]=n.slice(0,200)+"...[truncated]";continue}e[r]=n}return e}var rt=[],At=null,M=null,Or=["off","pdp_tryon","pdp","all","tryon_engaged"],J,Et=null,nt="unknown",B=[],j=null;function Se(){let t=m();return"mk_engaged_"+(t&&t.projectId||"")}function Lt(){if(j!==null)return j;try{j=localStorage.getItem(Se())==="1"}catch(t){j=!1}return j}function It(){if(!Lt()){j=!0;try{localStorage.setItem(Se(),"1")}catch(t){}ot(!1)}}var qr=/^purchase$/;function Te(t,e){if(J===void 0)return"hold";if(J==="off")return"drop";if(J==="all"||e&&qr.test(e))return"collect";switch(J){case"pdp":return t==="pdp"?"collect":"drop";case"tryon_engaged":if(Lt())return"collect";case"pdp_tryon":return t!=="pdp"?"drop":nt==="available"?"collect":nt==="unavailable"?"drop":"hold";default:return"collect"}}function ot(t){if(!B.length)return;let e=[];for(let r of B){let n=Te(r._pt,r.name);n==="collect"?Le(r.name,r.params,r.ts):n==="hold"&&!t&&e.push(r)}B=e}function Rt(t){J=Or.indexOf(t)>=0?t:"all",ot(!1)}function Ae(t){nt=t==="available"?"available":"unavailable",ot(!1)}function Ee(t){ot(!0),M=t,Et=t&&t.pageType||null,nt="unknown"}function u(t,e,r){if(!m().projectId){(u._pre=u._pre||[]).push({name:t,params:e,ts:r||Date.now()}),u._pre.length>50&&u._pre.shift();return}if(u._pre&&u._pre.length){let o=u._pre;u._pre=[];for(let i of o)ke(i.name,i.params,i.ts)}ke(t,e,r)}function ke(t,e,r){let n=Te(Et,t);if(n==="collect"){Le(t,e,r);return}if(n==="drop"){y("descartado (escopo)",t);return}B.push({name:t,params:e,ts:r||Date.now(),_pt:Et}),B.length>300&&B.shift()}function Le(t,e,r){let n=m(),o=ve(e||{}),i="page_"+Nr(t);if(rt.push({name:i,ts:r||Date.now(),params:o}),y("queued",t,o),n.observe)try{window.postMessage({__mkpixel:!0,event:{name:i,params:o},site:M?{pageType:M.pageType,platform:M.platform,url:M.url}:null},"*")}catch(c){}if(rt.length>=n.batchMaxSize){E();return}At||(At=setTimeout(()=>{At=null,E()},n.batchIntervalMs))}function Nr(t){if(typeof t!="string"||!t)return"unknown";let e=t.replace(/^on/,"");return e=e.replace(/[A-Z]/g,(r,n)=>(n>0?"_":"")+r.toLowerCase()),e.indexOf("page_")===0&&(e=e.slice(5)),e}function E(t){if(rt.length===0)return;let e=m();if(!e.projectId||!e.collectorUrl)return;let r=rt.splice(0,50),n=JSON.stringify({product:e.product||void 0,visitorId:we(),sessionId:xe(),engaged:Lt()||void 0,events:r,site:M||void 0}),o=e.collectorUrl+"/v1/track";try{fetch(o,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","X-MK-Project-Id":e.projectId},body:n}).catch(()=>{})}catch(i){try{navigator.sendBeacon&&navigator.sendBeacon(o+"?projectId="+encodeURIComponent(e.projectId),new Blob([n],{type:"text/plain"}))}catch(c){}}}function Ie(){try{window.addEventListener("pagehide",()=>E(!0)),window.addEventListener("beforeunload",()=>E(!0)),document.addEventListener("visibilitychange",()=>{document.hidden&&E(!0)})}catch(t){}}function T(t){let e=[];try{let r=document.querySelectorAll('script[type="application/ld+json"]');for(let n of r){let o;try{o=JSON.parse(n.textContent)}catch(c){continue}let i=[];Array.isArray(o)?i.push(...o):o["@graph"]?i.push(...o["@graph"]):i.push(o);for(let c of i){if(!c||!c["@type"])continue;let a=Array.isArray(c["@type"])?c["@type"]:[c["@type"]];(!t||t.some(s=>a.includes(s)))&&e.push(c)}}}catch(r){}return e}var Re=["off","pdp_tryon","pdp","all","tryon_engaged"],Dr="all",Ur=30*60*1e3,O=null;function q(){if(O)return O;let t=m();return!t.projectId||!t.apiUrl?(O=Promise.resolve(null),O):(O=fetch(t.apiUrl+"/projects/"+t.projectId).then(e=>e.ok?e.json():null).then(e=>e&&e.project||e||null).catch(()=>null),O)}function Pe(t){let e=t&&t.analytic&&t.analytic.scope;return Re.indexOf(e)>=0?e:Dr}var je=t=>"mk_scope_"+t;function Me(t){try{let e=localStorage.getItem(je(t));if(!e)return null;let r=JSON.parse(e);return!r||typeof r.exp!="number"||r.exp<Date.now()?null:Re.indexOf(r.scope)>=0?r.scope:null}catch(e){return null}}function Be(t,e){try{localStorage.setItem(je(t),JSON.stringify({scope:e,exp:Date.now()+Ur}))}catch(r){}}var Mt={};C(Mt,{addToCart:()=>tn,detect:()=>Xr,getCartSummary:()=>Zr,id:()=>Wr,openCartDrawer:()=>en,resolveSku:()=>Yr,skipRedirect:()=>Gr});var ct={};C(ct,{addToCart:()=>Kr,detect:()=>zr,getCartSummary:()=>jt,id:()=>Fr,openCartDrawer:()=>Jr,resolveSku:()=>Pt});var Fr="shopify";function zr(){return!!(window.Shopify||window.ShopifyAnalytics)}function Pt(){let t=window;return t.ShopifyAnalytics&&t.ShopifyAnalytics.meta&&t.ShopifyAnalytics.meta.product?{value:String(t.ShopifyAnalytics.meta.product.id),source:"shopify"}:null}var it=t=>String(t==null?"":t).trim().toLowerCase();async function Kr({size:t,color:e,sku:r,quantity:n}){let o=(location.pathname.split("/products/")[1]||"").split(/[?#]/)[0];if(!o)throw new Error("shopify: sem handle de produto na URL (n\xE3o \xE9 PDP?)");let c=(await fetch("/products/"+o+".js").then(d=>d.json())).variants||[],a=d=>[d.option1,d.option2,d.option3].concat(String(d.title||"").split("/")).map(it).filter(Boolean),s=(d,K)=>a(d).indexOf(it(K))>=0,l=d=>(!t||s(d,t))&&(!e||s(d,e)),f=null;if((t||e)&&(f=c.find(d=>l(d)&&d.available)||c.find(l)),!f&&r&&(f=c.find(d=>it(d.sku)===it(r))),f||(f=c.find(d=>d.available)||c[0]),!f)throw new Error("shopify: variante n\xE3o encontrada");let x=Oe(),p=null;if(x&&typeof x.getSectionsToRender=="function")try{p=x.getSectionsToRender().map(d=>({id:d.id,selector:d.selector||"#"+d.id})).filter(d=>d.id)}catch(d){}let w={items:[{id:f.id,quantity:n||1}]};p&&p.length&&(w.sections=p.map(d=>d.id).join(","),w.sections_url=location.pathname);let h=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!h.ok)throw new Error("shopify: /cart/add.js HTTP "+h.status);let b=await h.json().catch(()=>({}));return x&&p&&b.sections&&$r(x,p,b.sections),{platform:"shopify",variantId:f.id,size:f.title,sku:f.sku||null}}function Oe(){return document.querySelector("cart-drawer, cart-notification")}function $r(t,e,r){for(let n of e){let o=r[n.id];if(o)try{let i=null;if(typeof t.getSectionInnerHTML=="function")i=t.getSectionInnerHTML(o,n.selector);else{let a=new DOMParser().parseFromString(o,"text/html").querySelector(n.selector);i=a?a.innerHTML:null}let c=document.querySelector(n.selector);c&&i!=null&&(c.innerHTML=i)}catch(i){}}}async function jt(){try{let t=await fetch("/cart.js",{headers:{Accept:"application/json"}}).then(e=>e.json());return{value:(Number(t.total_price)||0)/100,itemCount:Number(t.item_count)||0,currency:t.currency||null}}catch(t){return null}}var Hr=["[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 Vr(t){try{let e=t.getBoundingClientRect();return e.width>0&&e.height>0&&getComputedStyle(t).visibility!=="hidden"}catch(e){return!1}}function Jr(){let t=Oe();if(t&&typeof t.open=="function")return setTimeout(()=>{try{t.open()}catch(r){}},200),!0;let e=null;for(let r of Hr)try{if(e=[...document.querySelectorAll(r)].find(Vr),e)break}catch(n){}return e?(setTimeout(()=>{try{e.click()}catch(r){}},300),!0):!1}var Wr="zerezes",Gr=!0;function Xr(){try{if(!(window.Shopify||window.ShopifyAnalytics))return!1;let t=window.Shopify&&window.Shopify.shop||"";return/(^|\.)zerezes\./i.test(location.hostname)||/cs-zerezes/i.test(t)}catch(t){return!1}}var Yr=Pt,Zr=jt;function Qr(){let t=[...document.querySelectorAll(".lens-selection__button, [data-has-lens-basket]")];return t.find(e=>{let r=e.getBoundingClientRect();return r.width>0&&r.height>0})||t[0]||null}async function tn(){let t=Qr();if(!t)throw new Error("zerezes: bot\xE3o de sele\xE7\xE3o de lentes n\xE3o encontrado");try{window.postMessage({source:"mkfashion-app",action:"close_request"},"*")}catch(e){}return setTimeout(()=>{try{t.click()}catch(e){}},250),{platform:"zerezes",nativeFlow:"lens-selection"}}function en(){return!0}var Ot={};C(Ot,{addToCart:()=>cn,detect:()=>nn,getCartSummary:()=>an,id:()=>rn,resolveSku:()=>on});var rn="hybris";function nn(){return!!(window.ACC&&window.ACC.config)}function on(){let t=(location.pathname||"").match(/\/p\/([^/?#]+)/);return t&&t[1]?{value:decodeURIComponent(t[1]),source:"hybris/url"}:null}var qe=t=>String(t==null?"":t).trim().toLowerCase();async function cn({size:t,quantity:e}){let r=[...document.querySelectorAll('.js-product-select-size, a[data-code], [class*="select-size"]')].filter(w=>w.getAttribute&&w.getAttribute("data-code")),n=t?r.find(w=>qe(w.textContent)===qe(t)):null;n||(n=r.find(w=>w.offsetParent!==null)||r[0]);let o=n&&n.getAttribute("data-code");if(!o)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"]'),c=i&&i.querySelector('[name="CSRFToken"]'),a=c&&c.value,s=i&&i.getAttribute("action")||"/cart/add";if(!a)throw new Error("hybris: CSRFToken n\xE3o encontrado");let l=new URLSearchParams;l.set("productCodePost",o),l.set("qty",String(e||1)),l.set("CSRFToken",a);let f=await fetch(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:l.toString()});if(!f.ok)throw new Error("hybris: "+s+" HTTP "+f.status);let x=null,p=null;try{let w=await f.clone().json(),h=w&&w.cartData;h&&(x=Bt(h.total!=null?h.total:h.totalPrice),p=h.totalUnitCount!=null?Number(h.totalUnitCount):Array.isArray(h.products)?h.products.length:null)}catch(w){}return{platform:"hybris",productCode:o,size:n.textContent.trim(),cartValue:x,itemCount:p,currency:"BRL"}}function Bt(t){if(t==null||t==="")return null;if(typeof t=="number")return Number.isFinite(t)?t:null;let e=String(t).replace(/[^\d.,]/g,"");if(!e)return null;let r=e.indexOf(",")>e.indexOf(".")?parseFloat(e.replace(/\./g,"").replace(",",".")):parseFloat(e.replace(/,/g,""));return Number.isFinite(r)?r:null}async function an(){try{let t=await fetch("/cart/async?nocache="+Date.now(),{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(c=>c.ok?c.text():"");if(!t)return null;let e=new DOMParser().parseFromString(t,"text/html"),r=e.querySelector(".minicart-total .price")||e.querySelector(".floating-cart--cart-total"),n=r?Bt(r.textContent):null,o=e.querySelector(".mini-badge"),i=o?parseInt(o.textContent,10)||0:null;return n==null&&i==null?null:{value:n,itemCount:i,currency:"BRL"}}catch(t){}try{let t=[".minicart-total .price",".js-cart-total",".cart-total",".total-price",".grand-total"];for(let e of t){let r=document.querySelector(e),n=r&&Bt(r.textContent);if(n)return{value:n,itemCount:null,currency:"BRL"}}}catch(t){}return null}var qt={};C(qt,{addToCart:()=>dn,detect:()=>sn,getCartSummary:()=>fn,id:()=>ln,resolveSku:()=>un});var ln="vtex";function sn(){return!!(window.vtex||window.vtexjs||window.vtxctx||window.skuJson_0)}function un(){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 at=t=>String(t==null?"":t).trim().toLowerCase();async function dn({size:t,quantity:e}){let r=window.skuJson_0&&window.skuJson_0.skus||[];if(!r.length)throw new Error("vtex: skuJson_0 indispon\xEDvel");let n=i=>at(i.skuname)===at(t)||i.dimensions&&Object.values(i.dimensions).some(c=>at(c)===at(t)),o=t?r.find(i=>n(i)&&i.available)||r.find(n):null;if(o||(o=r.find(i=>i.available)||r[0]),!o)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(o.sku,10),quantity:e||1,seller:"1"}]),{platform:"vtex",skuId:o.sku,size:o.skuname||t};throw new Error("vtex: vtexjs.checkout indispon\xEDvel")}function fn(){try{let t=window.vtexjs&&window.vtexjs.checkout&&window.vtexjs.checkout.orderForm;if(t&&typeof t.value=="number"){let e=t.storePreferencesData&&t.storePreferencesData.currencyCode||"BRL",r=(t.items||[]).reduce((n,o)=>n+(Number(o.quantity)||1),0);return{value:t.value/100,itemCount:r,currency:e}}}catch(t){}return null}var Nt={};C(Nt,{addToCart:()=>gn,detect:()=>hn,getCartSummary:()=>xn,id:()=>pn,openCartDrawer:()=>wn,resolveSku:()=>yn,skipRedirect:()=>mn});var pn="nuvemshop",mn=!0;function hn(){return!!(window.LS&&(window.LS.cart||window.LS.addToCart))}function yn(){try{let t=window.LS,e=t&&t.variants||[],r=document.querySelector('[name="variant_id"]'),n=r&&r.value?e.find(o=>String(o.id)===String(r.value)):null;if(n||(n=e.find(o=>o.available!==!1&&o.sku)||e.find(o=>o.sku)||e[0]),n&&n.sku)return{value:String(n.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 lt=t=>String(t==null?"":t).trim().toLowerCase();async function gn({size:t,quantity:e}){let r=document.getElementById("product_form")||document.querySelector('.js-product-form, form[action*="/comprar"]');if(!r)throw new Error("nuvemshop: #product_form n\xE3o encontrado");t&&r.querySelectorAll('select[name^="variation"]').forEach(c=>{let a=[...c.options].find(s=>lt(s.textContent).includes(lt(t))||lt(s.value)===lt(t));a&&(c.value=a.value,c.dispatchEvent(new Event("change",{bubbles:!0})))});let n=r.querySelector('[name="quantity"]');n&&e&&(n.value=String(e)),await new Promise(c=>setTimeout(c,400));let o=r.querySelector(".js-addtocart")||document.querySelector(".js-addtocart");return o?o.click():typeof r.requestSubmit=="function"?r.requestSubmit():r.submit(),await new Promise(c=>setTimeout(c,1200)),{platform:"nuvemshop",variantId:(r.querySelector('[name="variant_id"]')||{}).value||null}}function wn(){try{if([...document.querySelectorAll('.modal-cart, #ajax-cart-details, [class*="cart-modal" i], [class*="modal-cart" i]')].find(n=>n.getBoundingClientRect().width>0))return!0;let e=[...document.querySelectorAll(".js-toggle-cart")],r=e.find(n=>{let o=n.getBoundingClientRect();return o.width>0&&o.height>0})||e[0];if(r)return setTimeout(()=>{try{r.click()}catch(n){}},300),!0}catch(t){}return!1}function xn(){try{let t=window.LS,e=t&&t.cart;if(!e)return null;let r=t.currency&&t.currency.code||"BRL",n=Array.isArray(e.items)?e.items.reduce((i,c)=>i+(Number(c.quantity)||1),0):Number(e.items)||0,o=e.subtotal!=null?Number(e.subtotal):null;return{value:o!=null?o/100:null,itemCount:n,currency:r}}catch(t){return null}}var Dt={};C(Dt,{addToCart:()=>kn,detect:()=>Cn,getCartSummary:()=>Sn,id:()=>bn,openCartDrawer:()=>An,resolveSku:()=>vn,skipRedirect:()=>_n});var bn="wake",_n=!0;function Cn(){return!!(window.StorefrontClient||typeof window.addOrCreateCheckout=="function"||typeof window.addToCartClick=="function")}function vn(){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 r=(location.pathname||"").match(/-(\d+)\/?(?:[?#]|$)/);if(r)return{value:r[1],source:"wake/url"}}catch(t){}return null}var Ne=t=>String(t==null?"":t).trim().toLowerCase();async function kn({size:t,quantity:e}){if(t){let i=[...document.querySelectorAll("input[attribute-value]")].find(c=>Ne(c.getAttribute("attribute-value"))===Ne(t));if(i){try{i.checked=!0}catch(c){}try{typeof window.selectAttribute=="function"?window.selectAttribute(i):i.click()}catch(c){}await new Promise(c=>setTimeout(c,600))}}let r=document.querySelector('[name="product-variant-id"]'),n=r&&r.value;if(!n)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(n),quantity:e||1,customization:[]}]))throw new Error("wake: addOrCreateCheckout retornou false");return{platform:"wake",productVariantId:n,size:t||null}}function De(t){if(t==null)return null;let e=String(t).match(/([\d.]+,\d{2}|\d+(?:\.\d{2})?)/),r=(e?e[1]:String(t)).replace(/[^\d.,]/g,"");if(!r)return null;let n=r.indexOf(",")>r.indexOf(".")?parseFloat(r.replace(/\./g,"").replace(",",".")):parseFloat(r.replace(/,/g,""));return Number.isFinite(n)&&n>0?n:null}async function Sn(){try{let t=()=>{let o=document.querySelector(".mc-subtotal__value")||document.querySelector(".mc-subtotal");return o?De(o.textContent):null},e=t();if(e==null&&typeof window.loadMiniCart=="function"){try{window.loadMiniCart()}catch(o){}await new Promise(o=>setTimeout(o,700)),e=t()}e==null&&(e=Tn());let r=document.querySelector('.mc-products__count, [class*="mc-"][class*="count" i], [class*="minicart" i] [class*="count" i]'),n=r&&parseInt(String(r.textContent||"").replace(/\D/g,""),10)||null;if(e!=null)return{value:e,itemCount:n,currency:"BRL"}}catch(t){}return null}function Tn(){try{let t=document.querySelector('[class*="mini-cart" i], .mini-cart')||document;for(let e of t.querySelectorAll("div,span,p,li,strong,b")){if(e.children.length>2)continue;let r=(e.textContent||"").replace(/\s+/g," ").trim();if(!(!/R\$/.test(r)||/frete|faltam|gr[aá]tis|desconto|economi/i.test(r))&&/^(sub)?total\b/i.test(r)){let n=De(r);if(n)return n}}}catch(t){}return null}function An(){if(typeof window.setCartDivVisibility!="function")return!1;try{typeof window.loadMiniCart=="function"&&window.loadMiniCart()}catch(t){}return setTimeout(()=>{try{let t=document.querySelector('[class*="mini-cart" i], .mini-cart');if(t&&t.getBoundingClientRect().width>0)return;window.setCartDivVisibility()}catch(t){}},350),!0}var zt={};C(zt,{addToCart:()=>Pn,cartUrl:()=>In,detect:()=>Rn,getCartSummary:()=>jn,id:()=>En,openCartDrawer:()=>Mn,skipRedirect:()=>Ln});var Ut="/api/v2/front",Ft={"Content-Type":"application/json",Accept:"application/json","App-Token":"wapstore"},Ue=t=>String(t==null?"":t).trim().toLowerCase(),En="wapstore",Ln=!0,In="/checkout/carrinho";function Rn(){try{if(document.querySelector('script[src*="/tema/"][src*="/dist/assets/"]')||/(?:^|;\s*)produto\/visitado=/.test(document.cookie))return!0}catch(t){}return!1}function Fe(t){if(!t||typeof t!="object")return null;let e=t.subtotal&&t.subtotal.valor;return e==null?null:{value:e,itemCount:t.quantidadeItens!=null?t.quantidadeItens:null,currency:"BRL"}}async function Pn({size:t,quantity:e}){let r=await fetch(Ut+"/url/product/detail?url="+encodeURIComponent(location.pathname),{headers:Ft}).then(p=>p.json()),n=(r&&(r.produto||r.data||r)||{}).conteudo||{},o=n.atributos&&n.atributos.simples&&n.atributos.simples.valores||[];if(!o.length)throw new Error("wapstore: sem variante de compra (atributos.simples)");let i=t?o.find(p=>Ue(p.label)===Ue(t)):null;i=i||o.find(p=>p.selecionado)||o.find(p=>(p.estoque||0)>0)||o[0];let c=i&&i.carrinho;if(!c||!c.itens||!c.itens.length)throw new Error("wapstore: variante sem payload de carrinho");let a=c.itens.map(p=>Object.assign({},p,{quantidade:String(e||p.quantidade||1)})),s=await fetch(Ut+"/checkout/cart",{method:"POST",headers:Ft,body:JSON.stringify({itens:a,tipo:c.tipo||"produto"})});if(!s.ok)throw new Error("wapstore: add HTTP "+s.status);let l=await s.json().catch(()=>({})),f=Fe(l),x={platform:"wapstore",idProduto:a[0]&&a[0].idProduto,size:i&&i.label||null};return f&&(x.cartValue=f.value,x.itemCount=f.itemCount,x.currency=f.currency),x}async function jn(){try{let t=await fetch(Ut+"/checkout/cart",{headers:Ft}).then(e=>e.json());return Fe(t)}catch(t){}return null}function Mn(){try{let t=document.querySelector(".common-sheet.side-cart, .side-cart");if(t&&t.getBoundingClientRect().width>0)return!0;let e=document.querySelector('.button-cart, [class*="button-cart"]');if(e)return e.click(),!0}catch(t){}return!1}var Kt={};C(Kt,{addToCart:()=>Fn,detect:()=>Nn,getCartSummary:()=>zn,id:()=>Bn,openCartDrawer:()=>Kn,resolveSku:()=>Dn,skipRedirect:()=>On});var Bn="linx",On=!0;function qn(t){if(t==null)return null;let e=String(t).match(/([\d.]+,\d{2}|\d+(?:\.\d{2})?)/),r=(e?e[1]:String(t)).replace(/[^\d.,]/g,"");if(!r)return null;let n=r.indexOf(",")>r.indexOf(".")?parseFloat(r.replace(/\./g,"").replace(",",".")):parseFloat(r.replace(/,/g,""));return Number.isFinite(n)&&n>0?n:null}function Nn(){return typeof window.carrinhoLateral=="function"&&typeof window.addToCart=="function"}function Dn(){try{let t=(location.pathname.match(/-p(\d+)\/?(?:[?#]|$)/)||[])[1];if(t)return{value:t,source:"linx/url-pid"};let e=(String(document.body.className||"").match(/context-product-(\d+)/)||[])[1];if(e)return{value:e,source:"linx/context"}}catch(t){}return null}function Un(){let t=[...document.querySelectorAll('.add-to-cart, [data-action="add-to-cart"]')];return t.find(e=>{let r=e.getBoundingClientRect();return r.width>0&&r.height>0})||t[0]||null}async function Fn(){let t=Un();if(!t)throw new Error("linx: bot\xE3o .add-to-cart n\xE3o encontrado");return t.click(),await new Promise(e=>setTimeout(e,1400)),{platform:"linx"}}function zn(){try{let t=document.querySelector("#mini-cart");if(!t)return null;let e=null;for(let n of t.querySelectorAll("div,span,p,li,strong,b,td")){if(n.children.length>2)continue;let o=(n.textContent||"").replace(/\s+/g," ").trim();if(/^(sub)?total\b/i.test(o)&&/R\$/.test(o)&&(e=qn(o),e))break}if(e==null)return null;let r=(t.textContent||"").match(/cont[ée]m\s+(\d+)\s+ite/i);return{value:e,itemCount:r?parseInt(r[1],10):null,currency:"BRL"}}catch(t){}return null}function Kn(){try{let e=typeof window.carrinhoLateral=="function"?window.carrinhoLateral():null;if(e&&typeof e.openCart=="function"){try{typeof e.fetchHTML=="function"&&e.fetchHTML()}catch(r){}return setTimeout(()=>{try{e.openCart()}catch(r){}},400),!0}}catch(e){}let t=document.querySelector("#mini-cart");if(t){try{t.classList.add("open")}catch(e){}return!0}return!1}var Ht={};C(Ht,{addToCart:()=>W,detect:()=>Hn,id:()=>$n,resolveSku:()=>$t});var $n="generic";function Hn(){return!0}function $t(){let t=T(["Product"]);if(t[0]){let e=t[0],r=e.sku||e.mpn||e.gtin13||e.productID;if(r)return{value:String(r),source:"jsonld"}}try{let e=document.querySelector('[itemprop="sku"]');if(e){let r=e.getAttribute("content")||(e.textContent||"").trim();if(r)return{value:String(r),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 Vn=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora/i,Jn=/continuar|como comprar|lista|desejos|favorito/i;async function W(){let t=document.querySelectorAll("button,[role=button],input[type=submit]");for(let e of t){let r=(e.textContent||e.value||"").replace(/\s+/g," ").trim();if(r&&r.length<40&&Vn.test(r)&&!Jn.test(r))try{return e.click(),{platform:"native-click",clicked:r}}catch(n){}}return{platform:"none",error:"bot\xE3o de carrinho nativo n\xE3o encontrado"}}var Ke=[Mt,ct,Ot,qt,Nt,Dt,zt,Kt],Wn=[["woocommerce",()=>!!(window.wc_add_to_cart_params||window.woocommerce_params)],["lojaintegrada",()=>!!window.LojaIntegrada]],st;function N(){return st||(st=Ke.find(t=>{try{return t.detect()}catch(e){return!1}})||Ht,st)}function $e(){let t=Ke.find(e=>{try{return e.detect()}catch(r){return!1}});if(t)return t.id;for(let[e,r]of Wn)try{if(r())return e}catch(n){}return null}function D(){let t=N();if(t.id!=="generic"&&t.resolveSku)try{let e=t.resolveSku();if(e)return e}catch(e){}return $t()}async function He(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},r=N();try{let n=r.addToCart?await r.addToCart(e):await W(e);return y("cart: adicionado",n),Vt(),ze(r,n,e.sku),n}catch(n){y('cart: adapter "'+r.id+'" falhou \u2014 fallback clique nativo',n&&n.message);let o=await W(e);return Vt(),ze(r,o,e.sku),o}}async function ze(t,e,r){try{let n=null;e&&e.cartValue!=null?n={value:e.cartValue,itemCount:e.itemCount!=null?e.itemCount:null,currency:e.currency||null}:t&&t.getCartSummary&&(n=await t.getCartSummary()),n&&n.value!=null&&(n.value>0||(n.itemCount||0)>0)&&u("cart_value",{via:"tryon",value:n.value,itemCount:n.itemCount!=null?n.itemCount:null,currency:n.currency||null,sku:r||null})}catch(n){}}async function Jt(){let t=N();if(t&&t.getCartSummary)try{return await t.getCartSummary()}catch(e){}return null}async function Ve(t){t=t||{};let e=N(),r={platform:e.id};try{let n=D();r.sku=n&&n.value||null;let o={size:t.size||null,color:t.color||null,sku:r.sku,quantity:t.quantity||1};r.added=e.addToCart?await e.addToCart(o):await W(o),Vt();try{await Wt()}catch(i){}r.cart=await Jt(),r.ok=!0}catch(n){r.ok=!1,r.error=n&&n.message||String(n)}return r}function Vt(){["cart:refresh","cart:updated","cart:build","ajaxProduct:added","product:added-to-cart"].forEach(t=>{try{document.dispatchEvent(new CustomEvent(t))}catch(e){}})}async function Wt(){let t=N(),e=m(),r=null;try{r=await q()}catch(i){}let n=r&&r.template&&r.template.cart||r&&r.cart||{},o=n.afterAdd||n.behavior||e.cartBehavior;if(o||(o=e.cartRedirect===!1?"none":"auto"),o==="none")return!1;if(o==="auto"||o==="drawer"){let i=n.openSelector||e.cartOpenSelector;if(i){let c=document.querySelector(i);if(c)return setTimeout(()=>{try{c.click()}catch(a){}},300),!1}else if(t&&t.openCartDrawer){let c=!1;try{c=t.openCartDrawer()}catch(a){}if(c)return!1}}return!0}function Je(){let t=N();if(t&&t.skipRedirect)return;let e=t&&t.cartUrl||"/cart";setTimeout(()=>{try{window.location.href=e}catch(r){}},250)}var Gn=/\/(thank[_-]?you|orders?\/|pedido[_-]?(confirmado|realizado|finalizado|sucesso)|sucesso|order[_-]?confirmation|compra[_-]?(finalizada|concluida)|orderplaced)/i,Xn=/\/(my[_-]?account|minha[_-]?conta|account|conta|customer|cliente|profile|perfil|wishlist|favoritos)(\/|$)/i,Yn=/\/checkout/i,Zn=/\/(cart|carrinho|sacola|bag)(\/|$|\?|#)/i,We=/\/(products?|produtos?|p)\//i,Qn=/\/(collections?|categoria|categorias|c|departamento)\//i,to=/\/(search|busca|s)(\/|\?)/i;function Ge(){try{if(window.__mkPageType)return window.__mkPageType}catch(r){}let t=(location.pathname||"").toLowerCase(),e=Xn.test(t);try{let r=T(),n=0,o=!1,i=!1;for(let c of r){let a=Array.isArray(c["@type"])?c["@type"]:[c["@type"]];if((a.includes("Order")||a.includes("Invoice"))&&!e)return"purchase";a.includes("SearchResultsPage")&&(o=!0),(a.includes("CollectionPage")||a.includes("ItemList"))&&(i=!0),a.includes("Product")&&n++}if(o)return"search";if(i)return"category";if(n===1)return"pdp";if(n>1)return We.test(t)?"pdp":"category"}catch(r){}return t==="/"||t===""||t==="/home"||t==="/index.html"?"home":Gn.test(t)&&!e?"purchase":Yn.test(t)?"checkout":Zn.test(t)?"cart":We.test(t)?"pdp":Qn.test(t)?"category":to.test(t)?"search":"other"}function Xe(t){let e=null;try{let r=new URLSearchParams(location.search),n=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],o={};for(let i of n){let c=r.get(i);c&&(o[i.replace("utm_","")]=c)}Object.keys(o).length&&(e=o)}catch(r){}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:eo()}}function eo(){return $e()}var Gt={},ro=null,G=0,Ye=!1;function Ze(t){Ye||(Ye=!0,Qe(t),no(),oo(),io(),co(),ao(t))}function Qe(t){Gt={};let e=Ge(),r=Xe(e);if(Ee(r),u("view",{url:location.href,pathname:location.pathname,referrer:document.referrer||null,title:document.title||null,pageType:e}),typeof t=="function")try{t(e,r)}catch(n){}}function no(){if(!document.body)return;let t={A:1,BUTTON:1,INPUT:1,SELECT:1,TEXTAREA:1},e=0;document.body.addEventListener("click",r=>{try{let n=Date.now();if(n-e<100)return;e=n;let o=r.target;for(let a=0;a<5&&o&&o!==document.body&&!(t[o.tagName]||o.getAttribute&&o.getAttribute("role")==="button");a++)o=o.parentElement;if(!o||!t[o.tagName]&&!(o.getAttribute&&o.getAttribute("role")==="button"))return;let i={tag:o.tagName},c=o.tagName==="INPUT"||o.tagName==="TEXTAREA"?o.value:o.textContent;i.text=(c||"").replace(/\s+/g," ").trim().substring(0,100),o.href&&(i.href=String(o.href).substring(0,500)),o.id&&(i.id=o.id),o.className&&typeof o.className=="string"&&(i.classes=o.className.trim().substring(0,200)),u("click",i)}catch(n){}},{capture:!0,passive:!0})}function oo(){let t=[25,50,75,100],e=null,r=()=>{try{let n=window.scrollY||document.documentElement.scrollTop||0,o=Math.max(document.body&&document.body.scrollHeight||0,document.documentElement&&document.documentElement.scrollHeight||0);if(o<=0)return;let i=Math.min(100,Math.floor((n+window.innerHeight)/o*100));for(let c of t)i>=c&&!Gt[c]&&(Gt[c]=!0,u("scroll_depth",{depth:c}))}catch(n){}};r(),window.addEventListener("scroll",()=>{e||(e=setTimeout(()=>{e=null,r()},250))},{passive:!0})}function io(){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 r="other",n=(e.className||"").toLowerCase(),o=(e.action||"").toLowerCase();e.querySelector('input[type="search"], input[name="q"], input[name="s"]')?r="search":/newsletter|subscribe|mailchimp/.test(n+o)?r="newsletter":/contact|contato/.test(n+o)&&(r="contact"),u("form_submit",{form_id:e.id||"",form_type:r})}catch(e){}},{capture:!0})}function co(){let t=m();G=Date.now(),ro=setInterval(()=>{if(document.hidden)return;let e=Date.now(),r=Math.round((e-G)/1e3);G=e,r>0&&r<60&&u("engagement",{url:location.pathname,dwellSec:r})},t.engagementIntervalMs),document.addEventListener("visibilitychange",()=>{if(document.hidden){let e=Math.round((Date.now()-G)/1e3);e>0&&e<600&&u("engagement",{url:location.pathname,dwellSec:e})}G=Date.now()})}function ao(t){let e=location.href,r=()=>{location.href!==e&&(e=location.href,Qe(t))};try{let n=history.pushState,o=history.replaceState;history.pushState=function(){n.apply(this,arguments),setTimeout(r,0)},history.replaceState=function(){o.apply(this,arguments),setTimeout(r,0)},window.addEventListener("popstate",r)}catch(n){}}function Yt(){let t=D(),e=T(["Product"]);if(e.length>0){let o=e[0],i=Array.isArray(o.offers)?o.offers[0]:o.offers;return{sku:t?t.value:o.sku||o.mpn||o.gtin13||o.productID||null,skuSource:t?t.source:null,name:typeof o.name=="string"?o.name:null,price:i&&parseFloat(i.price||i.lowPrice)||null||tr(),currency:i?i.priceCurrency:null,brand:o.brand?typeof o.brand=="string"?o.brand:o.brand.name:null,category:o.category||null}}let r=o=>{let i=document.querySelector('meta[property="og:'+o+'"], meta[property="product:'+o+'"]');return i?i.getAttribute("content"):null},n=o=>{let i=document.querySelector('[itemprop="'+o+'"]');return i?i.getAttribute("content")||(i.textContent||"").trim():null};if(t||r("type")==="product"||r("price:amount")||n("name")){let o=n("price")||r("price:amount"),i=o&&parseFloat(String(o).replace(",","."))||null;return{sku:t?t.value:null,skuSource:t?t.source:null,name:n("name")||r("title")||document.title||null,price:(i&&i>0?i:null)||tr(),currency:n("priceCurrency")||r("price:currency")||null,brand:n("brand")||null,category:null}}return null}function tr(){try{let t=window.dataLayer;if(!Array.isArray(t))return null;for(let e=t.length-1;e>=0;e--){let r=t[e];if(!r||typeof r!="object")continue;let n=r.ecommerce||r,o=n&&n.items||null,i=n&&n.detail&&n.detail.products||n&&n.products||r.products||null,c=Array.isArray(o)&&o[0]&&o[0].price||Array.isArray(i)&&i[0]&&i[0].price||null,a=Xt(c!=null?String(c):"");if(a)return a}}catch(t){}return null}function L(){try{let t=location.pathname+location.search,e=t.match(/order[_-]?confirmation\/([\w-]+)/i)||t.match(/[?&]order[_-]?id=([\w-]+)/i)||t.match(/\/orders?\/([\w-]{4,})/i)||t.match(/pedido[_-]?(?:confirmado|realizado|finalizado)?\/([\w-]+)/i);return e?e[1]:null}catch(t){return null}}function Zt(){let t=T(["Order","Invoice"]);if(t.length>0){let o=t[0],i=o.totalPaymentDue?parseFloat(o.totalPaymentDue.price):parseFloat(o.price||o.total);return{orderId:o.orderNumber||o.confirmationNumber||o.identifier||L(),revenue:Number.isFinite(i)?i:null,currency:o.totalPaymentDue&&o.totalPaymentDue.priceCurrency||o.priceCurrency||null,source:"jsonld"}}try{let o=window.Shopify&&window.Shopify.checkout;if(o&&o.total_price!=null){let i=parseFloat(o.total_price);return{orderId:(o.order_id!=null?String(o.order_id):null)||o.token||L(),revenue:Number.isFinite(i)?i:null,currency:o.currency||null,itemCount:Array.isArray(o.line_items)?o.line_items.length:null,source:"shopify"}}}catch(o){}try{if(Array.isArray(window.dataLayer))for(let o=window.dataLayer.length-1;o>=0;o--){let i=window.dataLayer[o],c=i&&i.ecommerce||i&&i.ecommerce_data&&i.ecommerce_data.ecommerce;if(c&&(i.event==="purchase"||c.purchase)){let a=c.purchase&&c.purchase.actionField,s=parseFloat(a&&(a.revenue||a.value)||c.value||c.revenue);return{orderId:a&&(a.id||a.transaction_id)||c.transaction_id||c.transactionId||L(),revenue:Number.isFinite(s)?s:null,currency:c.currency||c.currencyCode||a&&a.currency||null,itemCount:(c.purchase&&c.purchase.products||c.items||c.products||[]).length||null,source:"datalayer"}}}}catch(o){}let e=document.querySelector('meta[property="order:total"], meta[name="order-total"]');if(e&&e.content)return{orderId:L(),revenue:parseFloat(e.content)||null,source:"meta"};let r=lo();if(r)return r;let n=L();return n?{orderId:n,revenue:null,source:"url"}:null}function lo(){try{let t=document.querySelector(".orderTotalPrice");if(t){let r=String(t.value||t.getAttribute("value")||t.textContent||"").trim(),n=r.split(/\s+/),o=Xt(n.length>1?n[n.length-1]:r);if(o)return{orderId:er(),revenue:o,currency:(n.length>1?n[0]:null)||null,source:"dom"}}let e=[".order-total","#order-total",".total-price",".order__total","[data-order-total]",".summary-total",".grand-total"];for(let r of e){let n=document.querySelector(r);if(n){let o=Xt(n.value||n.textContent);if(o)return{orderId:er(),revenue:o,source:"dom"}}}return null}catch(t){return null}}function er(){try{let t=document.querySelector(".orderID");if(t&&(t.value||t.getAttribute("value")))return t.value||t.getAttribute("value");let r=(document.body.innerText||"").match(/(?:pedido|order|n[º°o]\.?)\s*#?\s*([A-Z0-9-]{4,})/i);return r?r[1]:null}catch(t){return null}}function Xt(t){if(!t)return null;let e=String(t).replace(/[^\d.,]/g,"");if(!e)return null;let r;e.indexOf(",")>e.indexOf(".")?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");let n=parseFloat(r);return Number.isFinite(n)&&n>0?n:null}function rr(){let t=T(["ItemList","CollectionPage"]);if(t.length===0)return null;let e=t[0],r=e.itemListElement||e.mainEntity&&e.mainEntity.itemListElement||[],n=[];for(let o of r.slice(0,50)){let i=o.item||o;i&&(i.sku||i.productID||i.name)&&n.push(i.sku||i.productID||i.name)}return n.length>0?{count:n.length,skus:n.slice(0,20)}:null}var nr=!1,ut=[/\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],so=[/^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 X(t,e){for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}function cr(t){switch(t){case"pdp":{let e=Yt();u("view_item",e||{sku:null});break}case"category":case"search":{let e=rr();u("view_item_list",e||{count:0});break}case"cart":Jt().then(e=>u("view_cart",e&&e.value!=null?{value:e.value,itemCount:e.itemCount,currency:e.currency}:{})).catch(()=>u("view_cart",{}));break;case"checkout":u("begin_checkout",{});break;case"purchase":uo();break}}var or=500,ir=16;function uo(){let t=!1,e=0,r=(o,i)=>{t||(t=!0,fo(o,i))};try{window.addEventListener("pagehide",()=>r(Zt(),!0),{once:!0})}catch(o){}let n=()=>{if(t)return;let o=Zt();if(o&&o.revenue!=null)return r(o);if(e++>=ir)return y("purchase: receita n\xE3o apareceu em "+or*ir+"ms \u2014 emitindo sem valor"),r(o);setTimeout(n,or)};n()}function fo(t,e){if(t&&!t.orderId&&(t.orderId=L()),t&&t.orderId){let r="_mk_purch_"+t.orderId;try{if(sessionStorage.getItem(r)){y("purchase j\xE1 contado",t.orderId);return}sessionStorage.setItem(r,"1")}catch(n){}}else if(nr)return;if(nr=!0,u("purchase",t||{revenue:null,_note:"no_order_data_extracted"}),y("purchase emitido",t),e)try{E(!0)}catch(r){}}function ar(){if(!document.body)return;let t=0;document.body.addEventListener("click",e=>{try{let r=Date.now();if(r-t<150)return;let n=e.target;for(let a=0;a<5&&n&&n!==document.body&&!(n.tagName==="BUTTON"||n.tagName==="A"||n.getAttribute&&n.getAttribute("role")==="button");a++)n=n.parentElement;if(!n)return;let o=n.tagName!=="A",i=(n.textContent||"").replace(/\s+/g," ").trim();if(!i||i.length>80)return;let c=!1;if((X([ut[0]],i)||o&&X([ut[1]],i)||o&&X([ut[2]],i)||X(ut.slice(3),i))&&(c=!0),c){t=r;let a=Yt();u("add_to_cart",{via:"click",buttonText:i,sku:a?a.sku:null,price:a?a.price:null});return}o&&X(so,i)&&(t=r,u("begin_checkout",{via:"click",buttonText:i}))}catch(r){}},{capture:!0,passive:!0})}var dt={};C(dt,{available:()=>yo,id:()=>po,iframeSrc:()=>ho,modalSize:()=>mo,onMounted:()=>go});var po="mk-fashion",mo={width:430,height:800};function ho(t,e){let r=encodeURIComponent(e).replace(/\./g,"%2E");return m().appUrl+"/"+t+"/"+r}async function yo(t,e){let r=m().apiUrl+"/availability/"+t+"?sku="+encodeURIComponent(e),n=await fetch(r);if(!n.ok)throw new Error("availability HTTP "+n.status);return n.json()}function go(){}var Qt={};C(Qt,{available:()=>Co,id:()=>wo,iframeSrc:()=>_o,modalSize:()=>xo,onMounted:()=>Ao});var wo="mk-makeup",xo={width:1160,height:700};function bo(){return window.__MK&&window.__MK.pulpoarUrl||"https://plugin.pulpoar.com/vto"}function _o(t){return bo()+"/"+encodeURIComponent(t)}function Co(){return Promise.resolve({available:!0})}var vo="https://cdn.jsdelivr.net/npm/@pulpoar/plugin-sdk@latest/dist/index.iife.js",ft=null;function ko(){return window.pulpoar?Promise.resolve(window.pulpoar):ft||(ft=new Promise(t=>{try{let e=document.createElement("script");e.src=vo,e.async=!0,e.onload=()=>t(window.pulpoar||null),e.onerror=()=>t(null),(document.head||document.documentElement).appendChild(e)}catch(e){t(null)}}),ft)}async function So(t){try{if(window.Shopify||window.ShopifyAnalytics){let e=(location.pathname.split("/products/")[1]||"").split(/[?#]/)[0];if(e){let r=window.ShopifyAnalytics&&window.ShopifyAnalytics.meta,n=new URLSearchParams(location.search).get("variant")||r&&r.selectedVariantId,i=(await fetch("/products/"+e+".js").then(s=>s.json())).variants||[],c=n?i.find(s=>String(s.id)===String(n)):null;if(c&&c.sku)return c.sku;let a=i.find(s=>s.available)||i[0];if(a&&a.sku)return a.sku}}}catch(e){}return t||null}function To(t){let e=Array.isArray(t)?t[0]:t;return!e||typeof e!="object"?{quantity:1}:{sku:e.sku||e.slug||e.key||e.variant_key||e.barcode||null,color:e.color||e.shade||e.colorName||null,size:e.size||null,quantity:1}}function Ao(t,e){ko().then(async r=>{if(!r){y("pulpoar: SDK n\xE3o carregou");return}let n=await So(e.identifier);if(y("pulpoar variante p/ cat\xE1logo",n),n)try{r.applyVariantsWithCatalog([String(n)],o=>{e.track("product_loaded",{via:"makeup",applied:Array.isArray(o)?o.length:0})})}catch(o){y("pulpoar applyVariantsWithCatalog falhou",o&&o.message)}try{r.onReady(()=>e.fire("onReady",{}))}catch(o){}try{r.onAddToCart(o=>{y("pulpoar onAddToCart",o),e.handleAddToCart(To(o),"makeup")})}catch(o){}try{r.onGoToProduct(o=>e.fire("onGoToProduct",o))}catch(o){}})}var Eo={"mk-fashion":dt,"mk-makeup":Qt};function pt(t){return Eo[t]||dt}var S=null,k=null,ht=!1,yt=!1,U=null,lr={},te=null,mt=0,v={onReady:null,onClose:null,onAddToCart:null,onProductLoaded:null,onError:null,onInteraction:null,onGenerationComplete:null},Lo={gregory:"698c7e791d3129430f15dddd"};function ur(t){return t?Lo[String(t).toLowerCase()]||t:null}async function I(t,e){let r=ur(t),n=String(e||"").trim();return pt(m().product).available(r,n)}async function dr(t,e){e||(e=t,t="698c7e791d3129430f15dddd");try{return(await I(t,e)).available===!0}catch(r){return!1}}async function Y(t){if(t=t||{},ht)return;let e=ur(t.projectId||t.projectid||t.store),r=String(t.identifier||t.sku||"").trim();if(!e||!r){console.error("[mk-sdk] open: projectId e identifier obrigatorios");return}let n=e+":"+r;if(lr[n]!==!0){try{if(!(await I(e,r)).available){alert("Produto nao disponivel para prova virtual.");return}}catch(i){alert("Produto nao encontrado ou indisponivel.");return}lr[n]=!0}let o=pt(m().product).modalSize||{width:430,height:800};U={projectId:e,identifier:r,width:t.width||o.width,height:t.height||o.height},yt=!1,mr(),Io(U),ht=!0,mt=Date.now(),u("modal_opened",{projectId:e,identifier:r})}function re(){if(!ht)return;let t=yt;if(yt=!1,Ro(),ht=!1,A("onClose"),u("modal_closed",{projectId:U&&U.projectId,identifier:U&&U.identifier}),t)try{Je()}catch(e){}}function fr(t){try{vr().forEach(e=>{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 Io(t){S=document.createElement("div"),S.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,.8);display:flex;align-items:center;justify-content:center;z-index:2147483647;",fr(!0);let e=document.createElement("div"),r=typeof t.width=="number"?t.width+"px":t.width,n=typeof t.height=="number"?t.height+"px":t.height;e.style.cssText="position:relative;width:"+r+";height:"+n+";max-width:100vw;max-height:100dvh;border-radius:12px;overflow:hidden;background:#fff;",k=document.createElement("iframe");let o=pt(m().product);k.src=o.iframeSrc(t.projectId,t.identifier),k.style.cssText="width:100%;height:100%;border:none;",k.setAttribute("allow","camera *; microphone *"),k.setAttribute("allowfullscreen","true"),e.appendChild(k),S.appendChild(e),document.body.appendChild(S);try{o.onMounted(k,{projectId:t.projectId,identifier:t.identifier,handleAddToCart:hr,track:u,fire:A})}catch(i){y("launcher.onMounted falhou",i&&i.message)}y("try-on modal aberto",k.src)}function Ro(){S&&S.parentNode&&S.parentNode.removeChild(S),S=null,k=null,fr(!1)}var sr=!1;function pr(){mr()}function mr(){sr||(sr=!0,window.addEventListener("message",t=>{let e=t.data;if(!e||e.source!=="mkfashion-app")return;let r=e.action,n=e.data||{};switch(r){case"close_request":re();break;case"ready":A("onReady",n);break;case"product_loaded":A("onProductLoaded",n),u("product_loaded",ee(n));break;case"interaction":{A("onInteraction",n),n&&n.method&&(te=n.method),u(Po(n),ee(n));break}case"add_to_cart":hr(n,"tryon");break;case"generation_start":mt=Date.now();break;case"generation_complete":A("onGenerationComplete",n),u("generation_complete",{method:n.method||te||"unknown",durationMs:mt?Date.now()-mt:null,success:n.success!==!1,imageUrlPresent:!!n.imageUrl});break;case"generation_error":A("onError",n),u("generation_error",{method:te||"unknown",error:n&&n.error});break}}))}function hr(t,e){if(u("add_to_cart",Object.assign({via:e||"tryon"},ee(t))),typeof v.onAddToCart=="function"){A("onAddToCart",t);return}He(t).then(()=>Wt()).then(r=>{yt=!!r}).catch(()=>{})}function Po(t){return t&&t.action,"interaction"}function ee(t){if(!t||typeof t!="object")return t;let e={};for(let r in t){if(r==="imageUrl"||r==="image"||r==="product"){r==="product"&&t[r]?(e.productSku=t[r].sku||null,e.productName=t[r].name||null):e[r+"Present"]=!!t[r];continue}e[r]=t[r]}return e}function A(t,e){if(typeof v[t]=="function")try{v[t](e)}catch(r){console.error("[mk-sdk]",r)}}function yr(t){v.onReady=t}function gr(t){v.onClose=t}function wr(t){v.onAddToCart=t}function xr(t){v.onProductLoaded=t}function br(t){v.onError=t}function _r(t){v.onInteraction=t}function Cr(t){v.onGenerationComplete=t}var Mo=767,Bo=1024,Oo=/(adicionar\s*(à|a|ao)?\s*(sacola|carrinho|cesta|bolsa))|adicionar ao carrinho|add to (cart|bag)|comprar agora|^comprar$|finalizar compra|eu quero/i,qo=/continuar|como comprar|lista|desejos|favorito|looks|cupom/i;function ne(t){try{let e=t.getBoundingClientRect();if(e.width<=0||e.height<=0)return!1;let r=getComputedStyle(t);return r.display!=="none"&&r.visibility!=="hidden"&&r.opacity!=="0"}catch(e){return!1}}function No(t){if(!t)return!1;try{let e=document.querySelector(t);return!!e&&ne(e)}catch(e){return!1}}function Do(t){return(t.tagName==="INPUT"?t.value||"":t.textContent||"").replace(/\s+/g," ").trim()}function Uo(t){if(!t||typeof t!="object"||t.selector)return t;let e=!1;if(["mobile","tablet","desktop"].forEach(n=>{let o=t[n];o&&o.mkAnchor===1&&o.anchor&&typeof o.anchor=="object"&&(e=!0)}),!e)return t;let r={};return["mobile","tablet","desktop"].forEach(n=>{let o=t[n];if(o){if(o.selector){r[n]=o;return}if(o.mkAnchor===1&&o.anchor&&typeof o.anchor=="object"){let i=o.anchor[n]||o.anchor.desktop||o.anchor.mobile||o.anchor.tablet;i&&i.selector&&(r[n]=i)}}}),["bpMobile","bpTablet","breakpoint"].forEach(n=>{t[n]!=null&&(r[n]=t[n])}),r}function gt(t){if(!t||typeof t!="object")return null;if(t=Uo(t),t.selector)return t;let e=[["mobile",t.mobile],["tablet",t.tablet],["desktop",t.desktop]].filter(s=>s[1]&&s[1].selector);if(e.length===0)return null;if(e.length===1)return e[0][1];let r=e.filter(([,s])=>No(s.selector));if(r.length===1)return r[0][1];let n=window.innerWidth||1024,o=Number(t.bpMobile)||Number(t.breakpoint)||Mo,i=Number(t.bpTablet)||Bo,c=s=>(e.find(l=>l[0]===s)||[])[1],a=n<=o?["mobile","tablet","desktop"]:n<=i?["tablet","desktop","mobile"]:["desktop","tablet","mobile"];for(let s of a){let l=c(s);if(l)return l}return e[0][1]}function oe(t){let e=gt(t);if(e&&e.selector)try{let r=document.querySelector(e.selector);if(r&&ne(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){}return null}function kr(){let t=m(),e=oe(t&&t.anchor);if(e)return e;let r=document.querySelectorAll('button, [role="button"], a.btn, a.button, input[type="submit"], input[type="button"]');for(let n of r){let o=Do(n);if(!(!o||o.length>40)&&!qo.test(o)&&Oo.test(o)&&ne(n))return{el:n,position:"afterend",mode:"flow",style:"",selector:null}}return null}var _="'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",ie={none:"0",sm:"4px",md:"8px",pill:"9999px"},ce={none:"0",sm:"4px",md:"8px",lg:"16px"},Fo='<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>',zo='<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 g(t,e={}){let r=document.createElement(t);if(e.style&&(r.style.cssText=e.style),e.text!=null&&(r.textContent=e.text),e.html!=null&&(r.innerHTML=e.html),e.attrs)for(let n in e.attrs)r.setAttribute(n,e.attrs[n]);if(e.on)for(let n in e.on)r.addEventListener(n,e.on[n]);if(e.children)for(let n of e.children)n&&r.appendChild(n);return r}function wt(t,e){let r=Number(e)>0?Number(e):24;return g("span",{style:`width:${r}px;height:${r}px;padding:2px;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:Fo})}function Sr(t){return g("span",{style:`width:12px;height:12px;display:inline-flex;align-items:center;justify-content:center;color:${t};flex-shrink:0;`,html:zo})}function xt(t){return t.borderWidth>0&&t.borderColor?`${t.borderWidth}px solid ${t.borderColor}`:"none"}function bt(){if(!document.getElementById("mk-jakarta-font"))try{document.head.appendChild(g("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 Ko(t){return t.subtext?g("span",{style:`display:flex;align-items:center;justify-content:center;padding:4px;background:${t.badgeBgColor};font-family:${_};font-weight:700;font-size:16px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,text:t.subtext}):null}function Tr(t,e){bt();let r=g("span",{style:"display:inline-flex;align-items:center;gap:4px;",children:[wt(t.textColor,t.iconSize),g("span",{text:t.text,style:`font-family:${_};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 g("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:${xt(t)};border-radius:${t.borderRadiusPx};font-family:${_};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[r,Ko(t)],on:{mouseenter:n=>{n.currentTarget.style.opacity="0.85"},mouseleave:n=>{n.currentTarget.style.opacity="1"},click:n=>{try{n.preventDefault(),n.stopPropagation()}catch(o){}try{e&&e()}catch(o){}}}})}function Ho(t){return t.subtext?g("span",{style:`display:flex;align-items:center;gap:4px;padding:4px;background:${t.badgeBgColor};font-family:${_};font-weight:600;font-size:10px;text-transform:uppercase;color:${t.badgeTextColor};line-height:1;white-space:nowrap;`,children:[Sr(t.badgeTextColor),g("span",{text:t.subtext})]}):null}function Vo(t,e){return g("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:${xt(t)};border-radius:${t.borderRadiusPx};filter:drop-shadow(0 0 6px rgba(0,0,0,0.08));font-family:${_};cursor:pointer;transition:opacity 0.2s ease;line-height:1;-webkit-appearance:none;appearance:none;`,children:[wt(t.textColor,t.iconSize),g("span",{text:t.text,style:`font-family:${_};font-weight:700;font-size:${t.fontSize}px;color:${t.textColor};white-space:nowrap;line-height:1;`})],on:{mouseenter:r=>{r.currentTarget.style.opacity="0.85"},mouseleave:r=>{r.currentTarget.style.opacity="1"},click:r=>{try{r.preventDefault(),r.stopPropagation()}catch(n){}try{e&&e()}catch(n){}}}})}function Ar(t,e){bt();let r=g("div",{style:"display:flex;flex-direction:column;gap:4px;",children:[t.cardTitle&&g("p",{text:t.cardTitle,style:`margin:0;font-family:${_};font-weight:700;font-size:16px;letter-spacing:1px;text-transform:uppercase;color:${t.cardTitleColor};line-height:1.2;`}),t.cardDescription&&g("p",{html:t.cardDescription,style:`margin:0;font-family:${_};font-weight:400;font-size:12px;max-width:177px;line-height:1.2;color:${t.cardTextColor};`})]}),n=g("div",{style:"display:flex;flex-direction:column;justify-content:space-between;gap:16px;flex:1 1 0;min-width:0;",children:[r,t.cardFooter&&g("p",{text:t.cardFooter,style:`margin:0;font-family:${_};font-weight:400;font-size:10px;color:${t.cardTextColor};line-height:1.2;`})]}),o=g("div",{style:"display:flex;flex-direction:column;align-items:flex-end;flex:1 1 0;min-width:0;",children:[Ho(t),Vo(t,e)]}),i=g("div",{style:"display:flex;gap:16px;align-items:stretch;width:100%;flex:1;box-sizing:border-box;",children:[n,o]});return g("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:${_};`,children:[i]})}var Wo={style:"gregory-black",text:"Provar Virtualmente",fontSize:14,iconSize:24,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 _t(t,e){let r=(e?t&&t.mobile:t&&t.desktop)||t&&t.desktop||t&&t.mobile||{},n={...Wo,...r};return n.style==="gregory-card"&&e&&(n.style="gregory-black"),n.borderRadiusPx=ie[n.borderRadius]!=null?ie[n.borderRadius]:"0",n.cardBorderRadiusPx=ce[n.cardBorderRadius]!=null?ce[n.cardBorderRadius]:"0",n.fontSize=Number(n.fontSize)||14,n.iconSize=Number(n.iconSize)||24,n.borderWidth=Number(n.borderWidth)||0,n}var ae={"gregory-black":Tr,"gregory-card":Ar},ec=Object.keys(ae);function Er(t,e){return(ae[t.style]||ae["gregory-black"])(t,e)}function Go(){return"abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)]+Math.random().toString(36).slice(2,11)}var tt=null,R=[];function vr(){return[tt].concat(R).filter(Boolean)}function Xo(t,e){let r;try{r=document.createElement("iframe"),r.setAttribute("aria-hidden","true"),r.style.cssText="display:none!important;width:0;height:0;border:0;position:absolute;left:-9999px;",(document.body||document.documentElement).appendChild(r);let n=r.contentWindow&&r.contentWindow.Element&&r.contentWindow.Element.prototype&&r.contentWindow.Element.prototype.attachShadow;if(typeof n=="function"){let o=n.call(t,e);return r.remove(),o}}catch(n){}try{r&&r.remove()}catch(n){}return t.attachShadow(e)}var Yo=/^(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 Zo(t){return!t||typeof t!="string"?"":t.split(";").map(e=>e.trim()).filter(Boolean).filter(e=>Yo.test(e.split(":")[0].trim().toLowerCase())).join(";")}var Ct=null,le=!1,F={},Lr=!1,se=null;function de(){return se||(se=q().then(t=>t&&t.template&&t.template.tryOnButton||null).catch(()=>null)),se}function Qo(){if(Lr)return;Lr=!0;let t=null;try{window.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{Ct&&z("pdp")},200)})}catch(e){}}function fe(t){if(t){if(typeof t.__mkCleanup=="function")try{t.__mkCleanup()}catch(e){}t.parentNode&&t.parentNode.removeChild(t)}}function pe(){fe(tt),R.forEach(fe),tt=null,R=[],Ct=null}var ti={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 ei(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 ri(t,e,r){let o=!ti[t.tagName]?t:t.parentElement||document.body;try{getComputedStyle(o).position==="static"&&(o.style.position="relative")}catch(f){}if(o===t){e.style.cssText="position:absolute;z-index:2147483000;"+ei(r),t.appendChild(e);return}e.style.cssText="position:absolute;z-index:2147483000;",o.appendChild(e);let i=()=>{try{let f=t.getBoundingClientRect(),x=o.getBoundingClientRect(),p=e.offsetWidth,w=e.offsetHeight,h=f.top-x.top+o.scrollTop,b=f.left-x.left+o.scrollLeft,d=r||"top-left",K=h,vt=b;d.indexOf("bottom")===0?K=h+f.height-w:(d.indexOf("middle")===0||d==="center")&&(K=h+(f.height-w)/2),d.indexOf("right")>=0?vt=b+f.width-p:d.indexOf("center")>=0&&(vt=b+(f.width-p)/2),e.style.top=K+"px",e.style.left=vt+"px"}catch(f){}};i();let c=()=>i();window.addEventListener("resize",c);let a=setTimeout(i,600),s=setTimeout(i,1500),l=null;try{if(t.tagName==="IMG"&&!t.complete&&t.addEventListener("load",i,{once:!0}),typeof ResizeObserver=="function"){l=new ResizeObserver(()=>i());try{l.observe(t)}catch(f){}try{l.observe(o)}catch(f){}}}catch(f){}e.__mkCleanup=()=>{window.removeEventListener("resize",c),clearTimeout(a),clearTimeout(s);try{t.removeEventListener("load",i)}catch(f){}try{l&&l.disconnect()}catch(f){}}}function ni(t,e,r){try{return t.insertAdjacentElement(r||"afterend",e),!0}catch(n){try{return t.parentNode.insertBefore(e,t.nextSibling),!0}catch(o){return!1}}}async function z(t){let e=m();if(t!=="pdp"){pe();return}if(!e.projectId)return;if(!e._anchorFromPicker){let l=await de();l&&l.anchor&&(e.anchor=l.anchor),l&&l.anchors&&(e.anchors=l.anchors)}if(le)return;let r=D(),n=r&&r.value,o=!!e.forceButton,i=l=>l?[l.selector,l.position,l.mode,l.align,l.style].join("~"):"heuristic",c=Array.isArray(e.anchors)?e.anchors:[],a=[n||"demo",i(gt(e.anchor))].concat(c.map(l=>i(gt(l)))).join("|"),s=tt;if(!(s&&Ct===a)){if(s&&pe(),!n&&!o){y("auto-mount: SKU n\xE3o resolvido na PDP");return}le=!0;try{let l=o;o||(F[n]||(F[n]=I(e.projectId,n).then(b=>!!(b&&b.available)).catch(()=>!1)),l=await F[n]);try{Ae(l?"available":"unavailable")}catch(b){}if(!l){y("auto-mount: produto sem try-on",n);return}let f=await de(),x=window.matchMedia("(max-width: 767px)").matches,p=_t(f,x),w=()=>{let b=D(),d=b&&b.value||n||"";It(),u("button_clicked",{sku:d,style:p.style}),Y({projectId:e.projectId,identifier:d})},h=kr();tt=me(h,p,w),R=[];for(let b of c){let d=oe(b);d&&R.push(me(d,p,w))}Ct=a,Qo(),y("auto-mount: bot\xE3o injetado",{style:p.style,sku:n,anchorFound:!!h,mode:h&&h.mode,extras:R.length,forced:o}),u("button_rendered",{style:p.style,sku:n||null,skuSource:r&&r.source,anchorFound:!!h,position:h?h.position:null,mode:h?h.mode:null,extras:R.length,forced:o})}finally{le=!1}}}function me(t,e,r){let n=t&&t.mode||"flow",o=Er(e,r),i=document.createElement("div");i.id=Go(),Xo(i,{mode:"closed"}).appendChild(o),["click","mousedown","mouseup","pointerdown","pointerup","touchstart"].forEach(s=>{try{i.addEventListener(s,l=>{l.stopPropagation()},!1)}catch(l){}});let a=!1;if(t&&t.el&&t.el.parentNode&&(n==="overlay"?(ri(t.el,i,t.align),a=!0):(i.style.cssText="display:contents;",a=ni(t.el,i,t.position))),a||(i.style.cssText="position:fixed;left:16px;bottom:16px;z-index:2147483000;",document.body.appendChild(i)),t&&t.style){let s=Zo(t.style);if(s)try{o.style.cssText+=";"+s}catch(l){}}return i}function Rr(){try{let t=m(),e={anchor:t.anchor,anchors:t.anchors,forceButton:t.forceButton};window.addEventListener("message",r=>{if(r.source!==window)return;let n=r.data;!n||!n.__mkCmd||(n.__mkCmd==="remount"||n.__mkCmd==="applyRecipe"?(t.anchor=n.anchor||null,t.anchors=n.anchors||null,t._anchorFromPicker=!0,t.forceButton=!0,z("pdp")):n.__mkCmd==="cancelPreview"&&(t.anchor=e.anchor,t.anchors=e.anchors,t._anchorFromPicker=!1,t.forceButton=e.forceButton,pe(),z("pdp")))})}catch(t){}}var P=null,Z=null,he=null,Q=new Map;function oi(t,e){try{if(e.skuAttr){let o=e.skuSelector?t.querySelector(e.skuSelector):t,i=o&&o.getAttribute(e.skuAttr);if(i)return String(i).trim()}if(e.skuSelector&&!e.skuAttr){let o=t.querySelector(e.skuSelector),i=o&&(o.getAttribute("content")||o.textContent||"").trim();if(i)return i}let r=t.querySelector(e.linkSelector||"a[href]"),n=r&&r.getAttribute("href");if(n){let o=n.match(/-p(\d+)|[?&]variant=(\d+)|\/produtos?\/([\w-]+)|\/products?\/([\w-]+)|-(\d+)(?:[/?#]|$)/);if(o)return o[1]||o[2]||o[3]||o[4]||o[5]}}catch(r){}return null}async function ii(t,e,r){if(Q.has(t))return;let n=oi(t,e);if(!n||(F[n]||(F[n]=I(m().projectId,n).then(l=>!!(l&&l.available)).catch(()=>!1)),!await F[n]||Q.has(t)||!t.isConnected))return;let c={el:e.anchorWithin&&t.querySelector(e.anchorWithin)||t,mode:e.mode||"overlay",align:e.align||"top-left",position:e.position||"afterbegin",style:e.style||""},s=me(c,r,()=>{It(),u("button_clicked",{sku:n,gallery:!0,style:r.style}),Y({projectId:m().projectId,identifier:n})});Q.set(t,s),u("button_rendered",{gallery:!0,sku:n,style:r.style})}function ue(t){try{document.querySelectorAll(t.cardSelector).forEach(e=>{e.__mkCard||(e.__mkCard=!0,P.observe(e))})}catch(e){}}function Ir(){if(P){try{P.disconnect()}catch(t){}P=null}if(Z){try{Z.disconnect()}catch(t){}Z=null}clearTimeout(he),Q.forEach(t=>fe(t)),Q.clear()}async function Pr(t){let e=m();if(t==="pdp"||t==="cart"||t==="checkout"||t==="purchase"){Ir();return}if(!e.projectId)return;let r=await de(),n=e.cards||r&&r.cards||null;if(!n||!n.cardSelector){Ir();return}if(P){ue(n);return}if(typeof IntersectionObserver!="function")return;let o=_t(r,window.matchMedia("(max-width: 767px)").matches);P=new IntersectionObserver(i=>{for(let c of i)c.isIntersecting&&(P.unobserve(c.target),ii(c.target,n,o))},{rootMargin:"300px"}),ue(n);try{Z=new MutationObserver(()=>{clearTimeout(he),he=setTimeout(()=>ue(n),250)}),Z.observe(document.body,{childList:!0,subtree:!0})}catch(i){}y("auto-mount galeria ativa",{cardSelector:n.cardSelector})}(function(){"use strict";try{let r=function(){try{Ie(),Rr(),pr(),e.autoTrack!==!1&&(Ze((o,i)=>{cr(o,i),z(o),Pr(o)}),ar()),y("mk-sdk iniciado",{projectId:e.projectId,collectorUrl:e.collectorUrl})}catch(o){e.debug&&console.error("[mk-sdk] init erro",o)}},e=St();if(e.projectId){let o=Me(e.projectId);o&&Rt(o),q().then(i=>{let c=Pe(i);Rt(c),Be(e.projectId,c),y("escopo de coleta",c)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r();let n={open:Y,close:re,isAvailable:dr,getAvailability:I,onReady:yr,onClose:gr,onAddToCart:wr,onProductLoaded:xr,onError:br,onInteraction:_r,onGenerationComplete:Cr,testCart:Ve,_version:"0.1.0",_isMkSdk:!0};typeof window!="undefined"&&(window.mk=n)}catch(e){typeof console!="undefined"&&console.error("[mk-sdk] boot fatal",e)}})();})();
|
package/dist/mk-sdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{(function(){try{let a=function(){try{var t=JSON.parse(localStorage.getItem(o));return t&&d.test(t.v)&&t.exp>Date.now()?t.v:null}catch(u){return null}};var m=a;if(window.__mkBooted)return;window.__mkBooted=!0;var o="mk_sdk_v",i=10*60*1e3,d=/^\d+\.\d+\.\d+$/,e=document.currentScript||document.querySelector("script[data-mk-project]")||document.querySelector('script[src*="mk-sdk"]'),s=a()||"1.1.
|
|
1
|
+
(()=>{(function(){try{let a=function(){try{var t=JSON.parse(localStorage.getItem(o));return t&&d.test(t.v)&&t.exp>Date.now()?t.v:null}catch(u){return null}};var m=a;if(window.__mkBooted)return;window.__mkBooted=!0;var o="mk_sdk_v",i=10*60*1e3,d=/^\d+\.\d+\.\d+$/,e=document.currentScript||document.querySelector("script[data-mk-project]")||document.querySelector('script[src*="mk-sdk"]'),s=a()||"1.1.45",n=document.createElement("script");if(n.src="https://cdn.jsdelivr.net/npm/mk-sdk-git@"+s+"/dist/mk-core.js",n.async=!0,e&&e.attributes)for(var r=0;r<e.attributes.length;r++){var c=e.attributes[r];c.name.indexOf("data-")===0&&n.setAttribute(c.name,c.value)}(document.head||document.documentElement).appendChild(n),fetch("https://api-collector.mk3dlabs.com/v1/sdk/version").then(function(t){return t.ok?t.json():null}).then(function(t){var u=t&&t.version;d.test(u)&&localStorage.setItem(o,JSON.stringify({v:u,exp:Date.now()+i}))}).catch(function(){})}catch(a){}})();})();
|
package/package.json
CHANGED
package/src/core/config.js
CHANGED
|
@@ -62,6 +62,10 @@ export function resolveConfig() {
|
|
|
62
62
|
forceButton: !!(window.__MK && window.__MK.forceButton),
|
|
63
63
|
// anchor: posição customizada do botão { selector, position } (receita / picker).
|
|
64
64
|
anchor: (window.__MK && window.__MK.anchor) || null,
|
|
65
|
+
// anchors[]: âncoras EXTRAS (além da primária) — recipe ou __MK. Cada uma = +1 botão.
|
|
66
|
+
anchors: (window.__MK && window.__MK.anchors) || null,
|
|
67
|
+
// cards: config da GALERIA/listagem (botão por card) — recipe ou __MK.
|
|
68
|
+
cards: (window.__MK && window.__MK.cards) || null,
|
|
65
69
|
// cartRedirect: após adicionar ao carrinho pelo provador, leva o usuário ao /cart (default: sim).
|
|
66
70
|
cartRedirect: !(window.__MK && window.__MK.cartRedirect === false),
|
|
67
71
|
// cartBehavior: o que fazer após adicionar — 'redirect' (vai pro /cart), 'drawer'
|
package/src/core/pageContext.js
CHANGED
|
@@ -27,16 +27,23 @@ export function detectPageType() {
|
|
|
27
27
|
const p = (location.pathname || '').toLowerCase();
|
|
28
28
|
const isAccountArea = ACCOUNT_URL.test(p); // veta purchase falso em área de conta
|
|
29
29
|
|
|
30
|
-
// 2. JSON-LD @type
|
|
30
|
+
// 2. JSON-LD @type — conta os Products: 1 = PDP, VÁRIOS = listagem (category).
|
|
31
|
+
// Sem isto, uma listagem com vários JSON-LD Product (ex.: eora/Nuvemshop, 1 por
|
|
32
|
+
// card) casava o 1º Product e virava 'pdp' por engano.
|
|
31
33
|
try {
|
|
32
34
|
const ld = readJsonLd();
|
|
35
|
+
let products = 0, sawSearch = false, sawCollection = false;
|
|
33
36
|
for (const item of ld) {
|
|
34
37
|
const types = Array.isArray(item['@type']) ? item['@type'] : [item['@type']];
|
|
35
38
|
if ((types.includes('Order') || types.includes('Invoice')) && !isAccountArea) return 'purchase';
|
|
36
|
-
if (types.includes('
|
|
37
|
-
if (types.includes('
|
|
38
|
-
if (types.includes('
|
|
39
|
+
if (types.includes('SearchResultsPage')) sawSearch = true;
|
|
40
|
+
if (types.includes('CollectionPage') || types.includes('ItemList')) sawCollection = true;
|
|
41
|
+
if (types.includes('Product')) products++;
|
|
39
42
|
}
|
|
43
|
+
if (sawSearch) return 'search';
|
|
44
|
+
if (sawCollection) return 'category';
|
|
45
|
+
if (products === 1) return 'pdp';
|
|
46
|
+
if (products > 1) return PDP_URL.test(p) ? 'pdp' : 'category'; // multi-Product fora de URL de produto = listagem
|
|
40
47
|
} catch (_) {}
|
|
41
48
|
|
|
42
49
|
// 3. URL patterns
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { startAutoTrack } from './core/autoTrack.js';
|
|
|
6
6
|
import { initUnloadFlush, setCollectionScope } from './core/transport.js';
|
|
7
7
|
import { fetchProjectRecipe, resolveScope, readCachedScope, cacheScope } from './core/projectRecipe.js';
|
|
8
8
|
import { onPageView, initFunnelClickTracking } from './ecommerce/funnel.js';
|
|
9
|
-
import { maybeMountButton, initPickerBridge } from './tryon/automount.js';
|
|
9
|
+
import { maybeMountButton, maybeMountGallery, initPickerBridge } from './tryon/automount.js';
|
|
10
10
|
import { cartSelfTest } from './platforms/index.js';
|
|
11
11
|
import * as tryon from './tryon/bridge.js';
|
|
12
12
|
|
|
@@ -41,6 +41,7 @@ import * as tryon from './tryon/bridge.js';
|
|
|
41
41
|
startAutoTrack((pageType, ctx) => {
|
|
42
42
|
onPageView(pageType, ctx);
|
|
43
43
|
maybeMountButton(pageType);
|
|
44
|
+
maybeMountGallery(pageType);
|
|
44
45
|
});
|
|
45
46
|
initFunnelClickTracking();
|
|
46
47
|
}
|
package/src/tryon/anchor.js
CHANGED
|
@@ -96,20 +96,30 @@ export function pickAnchorVariant(anchor) {
|
|
|
96
96
|
return slots[0][1];
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Resolve um OBJETO de âncora (slots desktop/mobile/tablet) pro elemento VISÍVEL
|
|
101
|
+
* atual — SÓ override, sem heurística. Usado pelos botões EXTRAS (uma âncora extra
|
|
102
|
+
* que não casa/visível simplesmente não monta, não cai no botão de compra).
|
|
103
|
+
* Retorna { el, position, mode, style, align, selector } | null.
|
|
104
|
+
*/
|
|
105
|
+
export function resolveAnchorObj(anchorObj) {
|
|
106
|
+
const variant = pickAnchorVariant(anchorObj);
|
|
104
107
|
if (variant && variant.selector) {
|
|
105
108
|
try {
|
|
106
109
|
const o = document.querySelector(variant.selector);
|
|
107
|
-
// Exige VISÍVEL: se a âncora configurada existe mas está oculta no layout
|
|
108
|
-
// atual (ex.: dashboard só tem desktop e o seletor some no mobile), não
|
|
109
|
-
// ancora num elemento 0x0 — cai na heurística pra o botão não sumir.
|
|
110
110
|
if (o && isVisible(o)) return { el: o, position: variant.position || 'afterend', mode: variant.mode || 'flow', style: variant.style || '', align: variant.align || 'top-left', selector: variant.selector };
|
|
111
111
|
} catch (_) {}
|
|
112
112
|
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function resolveAnchor() {
|
|
117
|
+
const cfg = getConfig();
|
|
118
|
+
|
|
119
|
+
// 1. Override (receita / picker) — variante escolhida por visibilidade/breakpoint.
|
|
120
|
+
// Exige VISÍVEL: âncora oculta no layout atual cai na heurística pro botão não sumir.
|
|
121
|
+
const o = resolveAnchorObj(cfg && cfg.anchor);
|
|
122
|
+
if (o) return o;
|
|
113
123
|
|
|
114
124
|
// 2. Heurística: o botão de carrinho nativo visível é a âncora natural
|
|
115
125
|
const candidates = document.querySelectorAll(
|
package/src/tryon/automount.js
CHANGED
|
@@ -8,7 +8,7 @@ import { track, setTryonState, markEngaged } from '../core/transport.js';
|
|
|
8
8
|
import { fetchProjectRecipe } from '../core/projectRecipe.js';
|
|
9
9
|
import { resolveSku } from '../ecommerce/extractors.js';
|
|
10
10
|
import { getAvailability, open } from './bridge.js';
|
|
11
|
-
import { resolveAnchor, pickAnchorVariant } from './anchor.js';
|
|
11
|
+
import { resolveAnchor, resolveAnchorObj, pickAnchorVariant } from './anchor.js';
|
|
12
12
|
import { renderButton, normalizeButtonConfig } from './buttons/registry.js';
|
|
13
13
|
|
|
14
14
|
// Id do host ALEATÓRIO por inicialização — sem prefixo semântico (mk/tryon),
|
|
@@ -20,10 +20,13 @@ function randomHostId() {
|
|
|
20
20
|
const c = 'abcdefghijklmnopqrstuvwxyz';
|
|
21
21
|
return c[Math.floor(Math.random() * 26)] + Math.random().toString(36).slice(2, 11);
|
|
22
22
|
}
|
|
23
|
-
let hostEl = null;
|
|
23
|
+
let hostEl = null; // host do botão PRIMÁRIO (id aleatório/efêmero)
|
|
24
|
+
let extraHosts = []; // hosts dos botões EXTRAS (template.tryOnButton.anchors[]) — aditivo
|
|
24
25
|
|
|
25
|
-
/** Host
|
|
26
|
+
/** Host primário (compat). */
|
|
26
27
|
export function getButtonHost() { return hostEl; }
|
|
28
|
+
/** Todos os hosts montados (primário + extras) — usado p/ esconder durante o modal. */
|
|
29
|
+
export function getButtonHosts() { return [hostEl].concat(extraHosts).filter(Boolean); }
|
|
27
30
|
|
|
28
31
|
// attachShadow imune a monkey-patch da loja. Uma loja pode reescrever
|
|
29
32
|
// Element.prototype.attachShadow pra forçar mode:'open' no nosso host e injetar
|
|
@@ -94,13 +97,16 @@ function ensureResizeWatch() {
|
|
|
94
97
|
} catch (_) {}
|
|
95
98
|
}
|
|
96
99
|
|
|
100
|
+
function destroyHost(h) {
|
|
101
|
+
if (!h) return;
|
|
102
|
+
if (typeof h.__mkCleanup === 'function') { try { h.__mkCleanup(); } catch (_) {} }
|
|
103
|
+
if (h.parentNode) h.parentNode.removeChild(h);
|
|
104
|
+
}
|
|
97
105
|
function removeButton() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (typeof h.__mkCleanup === 'function') { try { h.__mkCleanup(); } catch (_) {} }
|
|
101
|
-
if (h.parentNode) h.parentNode.removeChild(h);
|
|
102
|
-
}
|
|
106
|
+
destroyHost(hostEl);
|
|
107
|
+
extraHosts.forEach(destroyHost);
|
|
103
108
|
hostEl = null;
|
|
109
|
+
extraHosts = [];
|
|
104
110
|
mountedKey = null;
|
|
105
111
|
}
|
|
106
112
|
|
|
@@ -210,6 +216,7 @@ export async function maybeMountButton(pageType) {
|
|
|
210
216
|
if (!cfg._anchorFromPicker) {
|
|
211
217
|
const tpl0 = await getTemplateCached();
|
|
212
218
|
if (tpl0 && tpl0.anchor) cfg.anchor = tpl0.anchor;
|
|
219
|
+
if (tpl0 && tpl0.anchors) cfg.anchors = tpl0.anchors; // âncoras extras da dashboard
|
|
213
220
|
}
|
|
214
221
|
|
|
215
222
|
if (mounting) return;
|
|
@@ -220,10 +227,10 @@ export async function maybeMountButton(pageType) {
|
|
|
220
227
|
// key canônico (campos em ordem FIXA — não depende da ordem das chaves do objeto).
|
|
221
228
|
// Assim preview e save com a mesma config geram o MESMO key e o botão NÃO é
|
|
222
229
|
// re-montado ("pula"/desce) ao salvar.
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
const fp = (v) => v ? [v.selector, v.position, v.mode, v.align, v.style].join('~') : 'heuristic';
|
|
231
|
+
const extraAnchors = Array.isArray(cfg.anchors) ? cfg.anchors : [];
|
|
232
|
+
const key = [sku || 'demo', fp(pickAnchorVariant(cfg.anchor))]
|
|
233
|
+
.concat(extraAnchors.map((a) => fp(pickAnchorVariant(a)))).join('|');
|
|
227
234
|
|
|
228
235
|
const existing = hostEl;
|
|
229
236
|
if (existing && mountedKey === key) return; // mesmo produto + mesma âncora
|
|
@@ -251,75 +258,74 @@ export async function maybeMountButton(pageType) {
|
|
|
251
258
|
const isMobile = window.matchMedia('(max-width: 767px)').matches;
|
|
252
259
|
const config = normalizeButtonConfig(tpl, isMobile);
|
|
253
260
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const btn = renderButton(config, () => {
|
|
261
|
+
// clique do botão — na PDP re-resolve o SKU (caso troquem a variante depois).
|
|
262
|
+
// Emite o clique IMEDIATAMENTE (antes de qualquer async que possa abortar o open).
|
|
263
|
+
const onClick = () => {
|
|
258
264
|
const live = resolveSku();
|
|
259
265
|
const id = (live && live.value) || sku || '';
|
|
260
|
-
//
|
|
261
|
-
|
|
262
|
-
markEngaged(); // escopo tryon_engaged: clicar no provador marca o visitante (tag infinita)
|
|
263
|
-
track('button_clicked', { sku: id, style: config.style, mode });
|
|
266
|
+
markEngaged(); // escopo tryon_engaged: clicar no provador marca o visitante
|
|
267
|
+
track('button_clicked', { sku: id, style: config.style });
|
|
264
268
|
open({ projectId: cfg.projectId, identifier: id });
|
|
265
|
-
}
|
|
269
|
+
};
|
|
266
270
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
hostEl =
|
|
270
|
-
// Shadow FECHADO: host.shadowRoot retorna null pra scripts da página, então a
|
|
271
|
-
// loja não consegue alcançar e repintar o botão (ex.: tema que faz
|
|
272
|
-
// host.shadowRoot.querySelector('button').style.background = ...). A aparência
|
|
273
|
-
// é 100% da dashboard. A SDK mantém a referência interna; o picker fala por
|
|
274
|
-
// postMessage, então nada nosso quebra.
|
|
275
|
-
const shadow = pristineAttachShadow(host, { mode: 'closed' });
|
|
276
|
-
shadow.appendChild(btn);
|
|
277
|
-
|
|
278
|
-
// O host costuma ficar SOBREPOSTO à imagem do produto (mode overlay). Qualquer
|
|
279
|
-
// evento de ponteiro que vaze do botão NÃO pode chegar aos handlers da loja
|
|
280
|
-
// (zoom/galeria/lightbox abria a imagem "de trás" junto com o provador).
|
|
281
|
-
// Contém na borda do host (fase de bubble → roda depois do handler do botão).
|
|
282
|
-
['click', 'mousedown', 'mouseup', 'pointerdown', 'pointerup', 'touchstart'].forEach((evt) => {
|
|
283
|
-
try { host.addEventListener(evt, (e) => { e.stopPropagation(); }, false); } catch (_) {}
|
|
284
|
-
});
|
|
271
|
+
// 1) botão PRIMÁRIO — âncora da dashboard ou heurística (comportamento de sempre)
|
|
272
|
+
const primary = resolveAnchor();
|
|
273
|
+
hostEl = mountOne(primary, config, onClick);
|
|
285
274
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
// Sem margem forçada (o gap natural do container cuida); ajuste fino via CSS extra.
|
|
294
|
-
host.style.cssText = 'display:contents;';
|
|
295
|
-
placed = insertByPosition(anchor.el, host, anchor.position);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
if (!placed) {
|
|
299
|
-
host.style.cssText = 'position:fixed;left:16px;bottom:16px;z-index:2147483000;';
|
|
300
|
-
document.body.appendChild(host);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// CSS extra (offset/escala/css) sempre no BOTÃO — assim não conflita com o
|
|
304
|
-
// transform de centralização que o overlay aplica no host (align center/meios).
|
|
305
|
-
// Só posição/geometria entram aqui; pintura/tipografia são da dashboard.
|
|
306
|
-
if (anchor && anchor.style) {
|
|
307
|
-
const safe = sanitizeAnchorStyle(anchor.style);
|
|
308
|
-
if (safe) { try { btn.style.cssText += ';' + safe; } catch (_) {} }
|
|
275
|
+
// 2) botões EXTRAS — template.tryOnButton.anchors[] (ADITIVO): cada âncora extra
|
|
276
|
+
// que casar/visível vira +1 botão pro MESMO produto; não casou → não monta.
|
|
277
|
+
// Sem anchors[], nada muda (extraHosts vazio).
|
|
278
|
+
extraHosts = [];
|
|
279
|
+
for (const ax of extraAnchors) {
|
|
280
|
+
const a = resolveAnchorObj(ax);
|
|
281
|
+
if (a) extraHosts.push(mountOne(a, config, onClick));
|
|
309
282
|
}
|
|
310
283
|
|
|
311
284
|
mountedKey = key;
|
|
312
285
|
ensureResizeWatch();
|
|
313
|
-
log('auto-mount: botão injetado', { style: config.style, sku, anchorFound: !!
|
|
286
|
+
log('auto-mount: botão injetado', { style: config.style, sku, anchorFound: !!primary, mode: primary && primary.mode, extras: extraHosts.length, forced: force });
|
|
314
287
|
track('button_rendered', {
|
|
315
288
|
style: config.style, sku: sku || null, skuSource: skuRes && skuRes.source,
|
|
316
|
-
anchorFound: !!
|
|
289
|
+
anchorFound: !!primary, position: primary ? primary.position : null, mode: primary ? primary.mode : null, extras: extraHosts.length, forced: force
|
|
317
290
|
});
|
|
318
291
|
} finally {
|
|
319
292
|
mounting = false;
|
|
320
293
|
}
|
|
321
294
|
}
|
|
322
295
|
|
|
296
|
+
// Monta UM botão (host + shadow FECHADO + posicionamento) numa âncora resolvida.
|
|
297
|
+
// anchor = { el, mode, align, position, style } | null (null → fallback fixo).
|
|
298
|
+
// Retorna o host. Reusado pelo primário, pelos extras e (fase 2) pela galeria.
|
|
299
|
+
function mountOne(anchor, config, onClick) {
|
|
300
|
+
const mode = (anchor && anchor.mode) || 'flow';
|
|
301
|
+
const btn = renderButton(config, onClick);
|
|
302
|
+
|
|
303
|
+
const host = document.createElement('div');
|
|
304
|
+
host.id = randomHostId(); // id efêmero/aleatório — sem hook estável p/ a loja mirar
|
|
305
|
+
// Shadow FECHADO: a loja não alcança nem repinta o botão; aparência 100% da dashboard.
|
|
306
|
+
const shadow = pristineAttachShadow(host, { mode: 'closed' });
|
|
307
|
+
shadow.appendChild(btn);
|
|
308
|
+
|
|
309
|
+
// contém eventos de ponteiro na borda do host (não vazam pro zoom/galeria/lightbox)
|
|
310
|
+
['click', 'mousedown', 'mouseup', 'pointerdown', 'pointerup', 'touchstart'].forEach((evt) => {
|
|
311
|
+
try { host.addEventListener(evt, (e) => { e.stopPropagation(); }, false); } catch (_) {}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
let placed = false;
|
|
315
|
+
if (anchor && anchor.el && anchor.el.parentNode) {
|
|
316
|
+
if (mode === 'overlay') { placeOverlay(anchor.el, host, anchor.align); placed = true; }
|
|
317
|
+
else { host.style.cssText = 'display:contents;'; placed = insertByPosition(anchor.el, host, anchor.position); }
|
|
318
|
+
}
|
|
319
|
+
if (!placed) { host.style.cssText = 'position:fixed;left:16px;bottom:16px;z-index:2147483000;'; document.body.appendChild(host); }
|
|
320
|
+
|
|
321
|
+
// CSS extra (offset/escala/css) sempre no BOTÃO — não conflita com o transform do overlay.
|
|
322
|
+
if (anchor && anchor.style) {
|
|
323
|
+
const safe = sanitizeAnchorStyle(anchor.style);
|
|
324
|
+
if (safe) { try { btn.style.cssText += ';' + safe; } catch (_) {} }
|
|
325
|
+
}
|
|
326
|
+
return host;
|
|
327
|
+
}
|
|
328
|
+
|
|
323
329
|
/**
|
|
324
330
|
* Canal de preview pro picker do addon: ao receber um anchor, re-injeta o botão
|
|
325
331
|
* naquela posição (forçado, ignora disponibilidade) pra visualização ao vivo.
|
|
@@ -327,25 +333,28 @@ export async function maybeMountButton(pageType) {
|
|
|
327
333
|
export function initPickerBridge() {
|
|
328
334
|
try {
|
|
329
335
|
const cfg = getConfig();
|
|
330
|
-
const original = { anchor: cfg.anchor, forceButton: cfg.forceButton };
|
|
336
|
+
const original = { anchor: cfg.anchor, anchors: cfg.anchors, forceButton: cfg.forceButton };
|
|
331
337
|
window.addEventListener('message', (e) => {
|
|
332
338
|
if (e.source !== window) return;
|
|
333
339
|
const d = e.data;
|
|
334
340
|
if (!d || !d.__mkCmd) return;
|
|
335
341
|
if (d.__mkCmd === 'remount') {
|
|
336
342
|
cfg.anchor = d.anchor || null; // preview da variante sendo editada (plano)
|
|
343
|
+
cfg.anchors = d.anchors || null; // extras (se houver) — preview com todos os botões
|
|
337
344
|
cfg._anchorFromPicker = true; // picker vence a dashboard durante o preview
|
|
338
345
|
cfg.forceButton = true; // preview sempre mostra o botão
|
|
339
346
|
maybeMountButton('pdp'); // re-monta só se a config (key) mudou
|
|
340
347
|
} else if (d.__mkCmd === 'applyRecipe') {
|
|
341
|
-
// pós-save: aplica a receita completa. Sem removeButton —
|
|
342
|
-
// mesma do preview (key igual),
|
|
348
|
+
// pós-save: aplica a receita completa (principal + extras). Sem removeButton —
|
|
349
|
+
// se a posição é a mesma do preview (key igual), não re-monta (não "pula").
|
|
343
350
|
cfg.anchor = d.anchor || null;
|
|
351
|
+
cfg.anchors = d.anchors || null;
|
|
344
352
|
cfg._anchorFromPicker = true;
|
|
345
353
|
cfg.forceButton = true;
|
|
346
354
|
maybeMountButton('pdp');
|
|
347
355
|
} else if (d.__mkCmd === 'cancelPreview') {
|
|
348
356
|
cfg.anchor = original.anchor; // restaura o estado anterior ao picker
|
|
357
|
+
cfg.anchors = original.anchors;
|
|
349
358
|
cfg._anchorFromPicker = false; // volta a deixar a dashboard mandar
|
|
350
359
|
cfg.forceButton = original.forceButton;
|
|
351
360
|
removeButton();
|
|
@@ -354,3 +363,103 @@ export function initPickerBridge() {
|
|
|
354
363
|
});
|
|
355
364
|
} catch (_) {}
|
|
356
365
|
}
|
|
366
|
+
|
|
367
|
+
// ─── Galeria/listagem: 1 botão por CARD de produto (category/search) ──────────
|
|
368
|
+
// Config (recipe template.tryOnButton.cards ou __MK.cards):
|
|
369
|
+
// { cardSelector, skuAttr?, skuSelector?, linkSelector?, anchorWithin?,
|
|
370
|
+
// position?, mode?, align?, style? }
|
|
371
|
+
// Disponibilidade LAZY: só checa o produto quando o card entra na viewport
|
|
372
|
+
// (IntersectionObserver). MutationObserver monta nos cards que aparecem depois
|
|
373
|
+
// (scroll infinito / filtro). Reusa mountOne + availCache.
|
|
374
|
+
let galleryIO = null; // IntersectionObserver (availability lazy)
|
|
375
|
+
let galleryMO = null; // MutationObserver (cards novos)
|
|
376
|
+
let galleryScanT = null; // debounce do scan
|
|
377
|
+
const galleryHosts = new Map(); // card -> host
|
|
378
|
+
|
|
379
|
+
// SKU do card: data-attr explícito (preferido) > texto de sub-elemento > href do link.
|
|
380
|
+
function cardSku(card, cc) {
|
|
381
|
+
try {
|
|
382
|
+
if (cc.skuAttr) {
|
|
383
|
+
const el = cc.skuSelector ? card.querySelector(cc.skuSelector) : card;
|
|
384
|
+
const v = el && el.getAttribute(cc.skuAttr);
|
|
385
|
+
if (v) return String(v).trim();
|
|
386
|
+
}
|
|
387
|
+
if (cc.skuSelector && !cc.skuAttr) {
|
|
388
|
+
const el = card.querySelector(cc.skuSelector);
|
|
389
|
+
const t = el && ((el.getAttribute('content') || el.textContent) || '').trim();
|
|
390
|
+
if (t) return t;
|
|
391
|
+
}
|
|
392
|
+
const link = card.querySelector(cc.linkSelector || 'a[href]');
|
|
393
|
+
const href = link && link.getAttribute('href');
|
|
394
|
+
if (href) {
|
|
395
|
+
const m = href.match(/-p(\d+)|[?&]variant=(\d+)|\/produtos?\/([\w-]+)|\/products?\/([\w-]+)|-(\d+)(?:[/?#]|$)/);
|
|
396
|
+
if (m) return m[1] || m[2] || m[3] || m[4] || m[5];
|
|
397
|
+
}
|
|
398
|
+
} catch (_) {}
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
async function mountCard(card, cc, config) {
|
|
403
|
+
if (galleryHosts.has(card)) return;
|
|
404
|
+
const sku = cardSku(card, cc);
|
|
405
|
+
if (!sku) return;
|
|
406
|
+
if (!availCache[sku]) {
|
|
407
|
+
availCache[sku] = getAvailability(getConfig().projectId, sku).then((r) => !!(r && r.available)).catch(() => false);
|
|
408
|
+
}
|
|
409
|
+
const available = await availCache[sku];
|
|
410
|
+
if (!available || galleryHosts.has(card) || !card.isConnected) return;
|
|
411
|
+
const anchorEl = (cc.anchorWithin && card.querySelector(cc.anchorWithin)) || card;
|
|
412
|
+
const anchor = { el: anchorEl, mode: cc.mode || 'overlay', align: cc.align || 'top-left', position: cc.position || 'afterbegin', style: cc.style || '' };
|
|
413
|
+
const onClick = () => { markEngaged(); track('button_clicked', { sku, gallery: true, style: config.style }); open({ projectId: getConfig().projectId, identifier: sku }); };
|
|
414
|
+
const host = mountOne(anchor, config, onClick);
|
|
415
|
+
galleryHosts.set(card, host);
|
|
416
|
+
track('button_rendered', { gallery: true, sku, style: config.style });
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function scanCards(cc) {
|
|
420
|
+
try {
|
|
421
|
+
document.querySelectorAll(cc.cardSelector).forEach((card) => {
|
|
422
|
+
if (card.__mkCard) return; // já observado
|
|
423
|
+
card.__mkCard = true;
|
|
424
|
+
galleryIO.observe(card);
|
|
425
|
+
});
|
|
426
|
+
} catch (_) {}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function removeGallery() {
|
|
430
|
+
if (galleryIO) { try { galleryIO.disconnect(); } catch (_) {} galleryIO = null; }
|
|
431
|
+
if (galleryMO) { try { galleryMO.disconnect(); } catch (_) {} galleryMO = null; }
|
|
432
|
+
clearTimeout(galleryScanT);
|
|
433
|
+
galleryHosts.forEach((h) => destroyHost(h));
|
|
434
|
+
galleryHosts.clear();
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** Chamado a cada pageview (junto do maybeMountButton). Monta a galeria em listagem. */
|
|
438
|
+
export async function maybeMountGallery(pageType) {
|
|
439
|
+
const cfg = getConfig();
|
|
440
|
+
// Galeria vale em qualquer LISTAGEM (category/search/home/other) — só NÃO em
|
|
441
|
+
// PDP (tem o botão próprio) nem carrinho/checkout/compra. Isso cobre URLs de
|
|
442
|
+
// categoria que não casam os padrões (ex.: eora /oculos-de-sol/ vira 'other').
|
|
443
|
+
if (pageType === 'pdp' || pageType === 'cart' || pageType === 'checkout' || pageType === 'purchase') { removeGallery(); return; }
|
|
444
|
+
if (!cfg.projectId) return;
|
|
445
|
+
const tpl = await getTemplateCached();
|
|
446
|
+
const cc = cfg.cards || (tpl && tpl.cards) || null;
|
|
447
|
+
if (!cc || !cc.cardSelector) { removeGallery(); return; }
|
|
448
|
+
if (galleryIO) { scanCards(cc); return; } // já ativo → só pega cards novos
|
|
449
|
+
if (typeof IntersectionObserver !== 'function') return;
|
|
450
|
+
|
|
451
|
+
const config = normalizeButtonConfig(tpl, window.matchMedia('(max-width: 767px)').matches);
|
|
452
|
+
galleryIO = new IntersectionObserver((entries) => {
|
|
453
|
+
for (const ent of entries) {
|
|
454
|
+
if (!ent.isIntersecting) continue;
|
|
455
|
+
galleryIO.unobserve(ent.target); // checa disponibilidade só uma vez por card
|
|
456
|
+
mountCard(ent.target, cc, config);
|
|
457
|
+
}
|
|
458
|
+
}, { rootMargin: '300px' }); // pré-carrega um pouco antes de entrar na tela
|
|
459
|
+
scanCards(cc);
|
|
460
|
+
try {
|
|
461
|
+
galleryMO = new MutationObserver(() => { clearTimeout(galleryScanT); galleryScanT = setTimeout(() => scanCards(cc), 250); });
|
|
462
|
+
galleryMO.observe(document.body, { childList: true, subtree: true });
|
|
463
|
+
} catch (_) {}
|
|
464
|
+
log('auto-mount galeria ativa', { cardSelector: cc.cardSelector });
|
|
465
|
+
}
|
package/src/tryon/bridge.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { getConfig, log } from '../core/config.js';
|
|
5
5
|
import { track } from '../core/transport.js';
|
|
6
6
|
import { addToCart as cartAdd, openCartAfterAdd, redirectToCart } from '../platforms/index.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getButtonHosts } from './automount.js';
|
|
8
8
|
import { resolveLauncher } from './launchers/index.js';
|
|
9
9
|
|
|
10
10
|
let modal = null;
|
|
@@ -99,15 +99,15 @@ export function close() {
|
|
|
99
99
|
// que ele suma independente de z-index/stacking context da loja.
|
|
100
100
|
function toggleTryonButton(hide) {
|
|
101
101
|
try {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
102
|
+
getButtonHosts().forEach((h) => {
|
|
103
|
+
if (hide) {
|
|
104
|
+
if (h.dataset.mkPrevDisplay === undefined) h.dataset.mkPrevDisplay = h.style.display;
|
|
105
|
+
h.style.display = 'none';
|
|
106
|
+
} else {
|
|
107
|
+
h.style.display = h.dataset.mkPrevDisplay || '';
|
|
108
|
+
delete h.dataset.mkPrevDisplay;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
111
|
} catch (_) {}
|
|
112
112
|
}
|
|
113
113
|
|