UNPKG

@ecomplus/widget-product-card

Version:
2 lines 34.1 kB
var widgetProductCard=function(t){function e(e){for(var r,s,a=e[0],c=e[1],d=e[3]||[],l=0,p=[];l<a.length;l++)s=a[l],Object.prototype.hasOwnProperty.call(i,s)&&i[s]&&p.push(i[s][0]),i[s]=0;for(r in c)Object.prototype.hasOwnProperty.call(c,r)&&(t[r]=c[r]);for(u&&u(e),d.forEach((function(t){if(void 0===i[t]){i[t]=null;var e=document.createElement("link");o.nc&&e.setAttribute("nonce",o.nc),e.rel="prefetch",e.as="script",e.href=n(t),document.head.appendChild(e)}}));p.length;)p.shift()()}var r={},i={0:0};function n(t){return o.p+"widget-product-card."+({}[t]||t)+".min.js"}function o(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,o),i.l=!0,i.exports}o.e=function(t){var e=[],r=i[t];if(0!==r)if(r)e.push(r[2]);else{var s=new Promise((function(e,n){r=i[t]=[e,n]}));e.push(r[2]=s);var a,c=document.createElement("script");c.charset="utf-8",c.timeout=120,o.nc&&c.setAttribute("nonce",o.nc),c.src=n(t);var u=new Error;a=function(e){c.onerror=c.onload=null,clearTimeout(d);var r=i[t];if(0!==r){if(r){var n=e&&("load"===e.type?"missing":e.type),o=e&&e.target&&e.target.src;u.message="Loading chunk "+t+" failed.\n("+n+": "+o+")",u.name="ChunkLoadError",u.type=n,u.request=o,r[1](u)}i[t]=void 0}};var d=setTimeout((function(){a({type:"timeout",target:c})}),12e4);c.onerror=c.onload=a,document.head.appendChild(c)}return Promise.all(e)},o.m=t,o.c=r,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(r,i,function(e){return t[e]}.bind(null,i));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="/assets/vendor/",o.oe=function(t){throw console.error(t),t};var s=window.webpackJsonpwidgetProductCard=window.webpackJsonpwidgetProductCard||[],a=s.push.bind(s);s.push=e,s=s.slice();for(var c=0;c<s.length;c++)e(s[c]);var u=a;return o(o.s=24)}([function(t,e){t.exports=void 0},function(t,e,r){"use strict";function i(t,e,r,i,n,o,s,a){var c,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=r,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),s?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},u._ssrRegister=c):n&&(c=a?function(){n.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:n),c)if(u.functional){u._injectStyles=c;var d=u.render;u.render=function(t,e){return c.call(e),d(t,e)}}else{var l=u.beforeCreate;u.beforeCreate=l?[].concat(l,c):[c]}return{exports:t,options:u}}r.d(e,"a",(function(){return i}))},function(t,e){t.exports=void 0},function(t,e){t.exports=void 0},function(t,e){t.exports=lozad},function(t,e,r){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var r=function(t,e){var r=t[1]||"",i=t[3];if(!i)return r;if(e&&"function"==typeof btoa){var n=(s=i,a=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(c," */")),o=i.sources.map((function(t){return"/*# sourceURL=".concat(i.sourceRoot||"").concat(t," */")}));return[r].concat(o).concat([n]).join("\n")}var s,a,c;return[r].join("\n")}(e,t);return e[2]?"@media ".concat(e[2]," {").concat(r,"}"):r})).join("")},e.i=function(t,r,i){"string"==typeof t&&(t=[[null,t,""]]);var n={};if(i)for(var o=0;o<this.length;o++){var s=this[o][0];null!=s&&(n[s]=!0)}for(var a=0;a<t.length;a++){var c=[].concat(t[a]);i&&n[c[0]]||(r&&(c[2]?c[2]="".concat(r," and ").concat(c[2]):c[2]=r),e.push(c))}},e}},function(t,e,r){"use strict";function i(t,e){for(var r=[],i={},n=0;n<e.length;n++){var o=e[n],s=o[0],a={id:t+":"+n,css:o[1],media:o[2],sourceMap:o[3]};i[s]?i[s].parts.push(a):r.push(i[s]={id:s,parts:[a]})}return r}r.r(e),r.d(e,"default",(function(){return f}));var n="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!n)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var o={},s=n&&(document.head||document.getElementsByTagName("head")[0]),a=null,c=0,u=!1,d=function(){},l=null,p="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function f(t,e,r,n){u=r,l=n||{};var s=i(t,e);return h(s),function(e){for(var r=[],n=0;n<s.length;n++){var a=s[n];(c=o[a.id]).refs--,r.push(c)}e?h(s=i(t,e)):s=[];for(n=0;n<r.length;n++){var c;if(0===(c=r[n]).refs){for(var u=0;u<c.parts.length;u++)c.parts[u]();delete o[c.id]}}}}function h(t){for(var e=0;e<t.length;e++){var r=t[e],i=o[r.id];if(i){i.refs++;for(var n=0;n<i.parts.length;n++)i.parts[n](r.parts[n]);for(;n<r.parts.length;n++)i.parts.push(m(r.parts[n]));i.parts.length>r.parts.length&&(i.parts.length=r.parts.length)}else{var s=[];for(n=0;n<r.parts.length;n++)s.push(m(r.parts[n]));o[r.id]={id:r.id,refs:1,parts:s}}}}function _(){var t=document.createElement("style");return t.type="text/css",s.appendChild(t),t}function m(t){var e,r,i=document.querySelector('style[data-vue-ssr-id~="'+t.id+'"]');if(i){if(u)return d;i.parentNode.removeChild(i)}if(p){var n=c++;i=a||(a=_()),e=v.bind(null,i,n,!1),r=v.bind(null,i,n,!0)}else i=_(),e=y.bind(null,i),r=function(){i.parentNode.removeChild(i)};return e(t),function(i){if(i){if(i.css===t.css&&i.media===t.media&&i.sourceMap===t.sourceMap)return;e(t=i)}else r()}}var b,g=(b=[],function(t,e){return b[t]=e,b.filter(Boolean).join("\n")});function v(t,e,r,i){var n=r?"":i.css;if(t.styleSheet)t.styleSheet.cssText=g(e,n);else{var o=document.createTextNode(n),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(o,s[e]):t.appendChild(o)}}function y(t,e){var r=e.css,i=e.media,n=e.sourceMap;if(i&&t.setAttribute("media",i),l.ssrId&&t.setAttribute("data-vue-ssr-id",e.id),n&&(r+="\n/*# sourceURL="+n.sources[0]+" */",r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */"),t.styleSheet)t.styleSheet.cssText=r;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(r))}}},function(t,e){t.exports=void 0},function(t,e,r){"use strict";r.d(e,"b",(function(){return o})),r.d(e,"a",(function(){return s}));var i=r(2),n=r.n(i);const o=(t,e=n.a)=>{const r=e.getCustomer().favorites||[],i=s(t,e);if(i){const e=r.indexOf(t);r.splice(e,1)}else r.push(t);return e.requestApi("/me.json","patch",{favorites:r}),!i},s=(t,e)=>{const{favorites:r}=e.getCustomer();return r&&r.includes(t)}},function(t,e){t.exports=void 0},function(t,e,r){"use strict";var i={name:"ALink",props:{href:String,to:[String,Object]},computed:{isRouter(){return!!this.$router&&(!this.href||Boolean(this.$router.options.routes.find(({path:t})=>t===this.href)))}}},n=r(1),o=Object(n.a)(i,(function(){var t=this.$createElement;return(this._self._c||t)(this.isRouter?"router-link":"a",{tag:"component",attrs:{href:this.isRouter?null:this.href,to:this.isRouter?this.to||this.href:null}},[this._t("default")],2)}),[],!1,null,null,null);e.a=o.exports},function(t,e,r){"use strict";var i=r(0),n=r(4),o=r.n(n);var s={name:"APicture",props:{src:[String,Object],fallbackSrc:String,alt:String,canCalcHeight:{type:Boolean,default:!0},placeholder:{type:String,default:"/assets/img-placeholder.png"},containerBreakpoints:{type:Object,default:()=>({zoom:null,big:800,[i.$ecomConfig.get("default_img_size")||"normal"]:400})},lozadOptions:{type:Object,default:()=>({rootMargin:"350px 0px",threshold:0})}},data:()=>({sources:[],imgWidth:0,imgHeight:0,height:null,opacity:null}),computed:{defaultImgObj(){return"object"==typeof this.src&&this.src?Object(i.img)(this.src)||this.src:{}},localFallbackSrc(){const{src:t,defaultImgObj:e,fallbackSrc:r}=this;if(r)return r;const i="object"==typeof t?t.zoom?t.zoom.url:e.url:t;return i?i.replace(/\.webp$/,""):this.placeholder},localAlt(){const{alt:t,src:e,defaultImgObj:r}=this;return t||(e?r.alt||"Product":"No image")}},methods:{updateSources(){const t=[];let e;if("object"==typeof this.src){const{clientWidth:t,clientHeight:r}=this.$el,i=((t,e,r,i)=>{let n,o;for(const s in i){const a=i[s];if(void 0!==a&&t[s]){if(void 0!==o)if(null===a){if(o>=e)continue}else if(a<e||a-50<=r||null!==o&&a>o)continue;n=s,o=a}}return n})(this.src,t,r,this.containerBreakpoints),n=this.src[i],{url:o,size:s}=n||this.defaultImgObj;e=o,s&&([this.imgWidth,this.imgHeight]=s.split("x").map(t=>parseInt(t,10)),t&&this.imgHeight&&this.canCalcHeight&&(this.height=(t>=this.imgWidth?this.imgHeight:t*this.imgHeight/this.imgWidth)+"px"))}else e=this.src;e&&(e.endsWith(".webp")?t.push({srcset:e,type:"image/webp"},{srcset:/\/imgs\/[0-9]{3}px/.test(e)?e.replace(/\/imgs\/[0-9]{3}px/,""):e.replace(/\.webp$/,""),type:"image/"+(".png"===e.substr(-9,4)?"png":"jpeg")}):e.endsWith(".avif")?t.push({srcset:e,type:"image/avif"},{srcset:e.replace(".avif",".webp"),type:"image/webp"}):t.push({srcset:e})),this.sources=t}},mounted(){this.updateSources(),this.$nextTick(()=>{const t=this.$el;o()(t,{...this.lozadOptions,loaded:t=>{const{localFallbackSrc:e}=this,r="IMG"===t.tagName?t:t.lastChild;r.style.opacity=0,this.imgHeight&&(r.height=this.imgHeight,r.width=this.imgWidth),r.onerror=function(){console.error(new Error("Image load error"),this),t.style.display="none";const r=document.createElement("IMG");r.src=e,t.parentNode.insertBefore(r,t.nextSibling)},r.onload=()=>{this.opacity=0,t.classList.add("loaded"),this.$nextTick(()=>{this.opacity=r.style.opacity=null,this.$emit("load")})}}}).observe()})}},a=(r(18),r(1)),c=Object(a.a)(s,(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("picture",{staticClass:"picture",style:{height:t.height,opacity:t.opacity},attrs:{"data-iesrc":t.localFallbackSrc,"data-alt":t.localAlt}},[t.sources.length?t._l(t.sources,(function(t,e){var i=t.srcset,n=t.type;return r("source",{key:e,attrs:{srcset:i,type:n}})})):r("source",{attrs:{srcset:t.localFallbackSrc}})],2)}),[],!1,null,null,null);e.a=c.exports},function(t,e,r){"use strict";var i=r(27),n=r(0),o=(t,e)=>new Promise(r=>{const i="object"==typeof window&&window.storefront;if(i){const n=()=>{let n=i.info&&i.info[t];return!!(n&&(e&&(n=n[e]),n&&Object.keys(n).length))&&(r(n),!0)};n()||i.on("info:"+t,n)}});const s=(t,e)=>{const{type:r,value:i}=e;let n;if(i)return n="percentage"===r?t*(100-i)/100:t-i,n>0?n:0};var a={name:"APrices",props:{product:{type:Object,required:!0},isLiteral:Boolean,isBig:Boolean,isAmountTotal:Boolean,installmentsOption:Object,discountOption:Object,discountText:{type:[String,Boolean],default:""},canShowPriceOptions:{type:Boolean,default:!0}},data(){return{installmentsNumber:0,monthlyInterest:0,discount:{type:null,value:0},extraDiscount:{type:null,value:0,min_amount:0},discountLabel:this.discountText,pointsProgramName:null,pointsMinPrice:0,earnPointsFactor:0}},computed:{i19asOf:()=>Object(n.i18n)(i.d),i19from:()=>Object(n.i18n)(i.r),i19interestFree:()=>Object(n.i18n)(i.t),i19of:()=>Object(n.i18n)(i.z),i19to:()=>Object(n.i18n)(i.W),i19upTo:()=>Object(n.i18n)(i.bb),i19youEarn:()=>Object(n.i18n)(i.eb),price(){const t=Object(n.price)(this.product);return this.extraDiscount.value&&(!this.extraDiscount.min_amount||t>this.extraDiscount.min_amount)?s(t,this.extraDiscount):t},comparePrice(){return Object(n.onPromotion)(this.product)?this.product.base_price:this.extraDiscount.value?Object(n.price)(this.product):void 0},hasVariedPrices(){const{variations:t}=this.product;if(t){const e=Object(n.price)(this.product);for(let r=0;r<t.length;r++){if(Object(n.price)({...this.product,...t[r]})>e)return!0}}return!1},priceWithDiscount(){return this.canShowPriceOptions&&s(this.price,this.discount)},installmentValue(){if(this.canShowPriceOptions&&this.installmentsNumber>=2){if(this.monthlyInterest){const t=this.monthlyInterest/100;return this.price*t/(1-Math.pow(1+t,-this.installmentsNumber))}return this.price/this.installmentsNumber}return 0}},methods:{formatMoney:n.formatMoney,updateInstallments(t){if(t){this.monthlyInterest=t.monthly_interest;const e=t.min_installment||5,r=parseInt(this.price/e,10);this.installmentsNumber=Math.min(r,t.max_number)}},updateDiscount(t){!t||t.min_amount&&!(t.min_amount<=this.price)||this.isAmountTotal&&"total"!==t.apply_at||(this.discount=t,!this.discountText&&!1!==this.discountText&&t.label&&(this.discountLabel="via "+t.label))}},watch:{price:{handler(t){this.$emit("fix-price",t)},immediate:!0}},created(){this.canShowPriceOptions&&(this.discountOption?this.updateDiscount(this.discountOption):o("apply_discount").then(t=>{t.available_extra_discount&&(this.extraDiscount=t.available_extra_discount)}),this.installmentsOption?this.updateInstallments(this.installmentsOption):o("list_payments").then(t=>{this.updateInstallments(t.installments_option),this.updateDiscount(t.discount_option);const e=t.loyalty_points_programs;this.isLiteral&&e&&this.$nextTick(()=>{for(const t in e){const r=e[t];if(r&&r.earn_percentage>0){this.pointsMinPrice=r.min_subtotal_to_earn,this.pointsProgramName=r.name,this.earnPointsFactor=r.earn_percentage/100;break}}})}))}},c=(r(20),r(1)),u=Object(c.a)(a,(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"prices",class:{"prices--literal":t.isLiteral,"prices--big":t.isBig}},[t.comparePrice?r("span",{staticClass:"prices__compare"},[t.isLiteral?[r("small",[t._v(" "+t._s(t.i19from)+" ")]),r("s",[t._v(t._s(t.formatMoney(t.comparePrice)))]),r("small",[t._v(" "+t._s(t.i19to)+" ")])]:r("s",[t._v(t._s(t.formatMoney(t.comparePrice)))])],2):t._e(),r("strong",{staticClass:"prices__value"},[t.hasVariedPrices?r("small",[t._v(" "+t._s(t.i19asOf)+" ")]):t._e(),t._v(" "+t._s(t.formatMoney(t.price))+" ")]),r("transition-group",{attrs:{"enter-active-class":"animated slideInDown"}},[t.earnPointsFactor>0&&!(t.pointsMinPrice>t.price)?r("div",{key:"points",staticClass:"prices__points"},[r("i",{staticClass:"i-check-circle"}),t._v(" "+t._s(t.i19youEarn)+" "),r("span",[t._v(" +"+t._s((t.earnPointsFactor*t.price).toFixed(1))+" ")]),r("em",[t._v(t._s(t.pointsProgramName))])]):t._e(),t.installmentsNumber>1&&t.installmentValue?r("div",{key:"installments",staticClass:"prices__installments"},[t.isLiteral?r("small",[t._v(" "+t._s(t.i19upTo)+" ")]):t._e(),t._v(" "+t._s(t.installmentsNumber)+"x "),t.isLiteral?r("small",[t._v(" "+t._s(t.i19of)+" ")]):t._e(),r("span",[t._v(" "+t._s(t.formatMoney(t.installmentValue))+" ")]),!t.monthlyInterest&&t.isLiteral?r("small",[t._v(" "+t._s(t.i19interestFree)+" ")]):t._e()]):t._e(),"number"==typeof t.priceWithDiscount&&t.priceWithDiscount<t.price?r("div",{key:"discount",staticClass:"prices__discount"},["string"==typeof t.discountLabel&&t.discountLabel?[r("span",[t._v(" "+t._s(t.formatMoney(t.priceWithDiscount))+" ")]),r("small",{staticClass:"prices__discount-label"},[t._v(" "+t._s(t.discountLabel)+" ")])]:[r("small",[t._v(" "+t._s(t.i19asOf)+" ")]),r("span",[t._v(" "+t._s(t.formatMoney(t.priceWithDiscount))+" ")])]],2):t._e()])],1)}),[],!1,null,null,null);e.a=u.exports},function(t,e){t.exports=void 0},function(t,e,r){var i=r(19);i.__esModule&&(i=i.default),"string"==typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);(0,r(6).default)("8b7473ca",i,!0,{})},function(t,e,r){var i=r(21);i.__esModule&&(i=i.default),"string"==typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);(0,r(6).default)("2c6ad45e",i,!0,{})},function(t,e,r){var i=r(23);i.__esModule&&(i=i.default),"string"==typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);(0,r(6).default)("9d3e525e",i,!0,{})},,function(t,e,r){"use strict";r(14)},function(t,e,r){(e=r(5)(!1)).push([t.i,".picture{display:inline-block;overflow:hidden;transition:opacity .2s;width:100%}.picture:not(.loaded){background:linear-gradient(25deg,var(--light) 40%,var(--gray) 200%);font-size:0;height:100%;min-height:50px;opacity:.3}.picture img{height:auto;margin:0 auto;max-width:100%;width:auto}",""]),t.exports=e},function(t,e,r){"use strict";r(15)},function(t,e,r){(e=r(5)(!1)).push([t.i,".prices{line-height:var(--line-height-sm)}.prices small:not(.prices__discount-label){text-transform:lowercase}.prices:not(.prices--big){font-size:var(--font-size-sm)}.prices:not(.prices--big) .prices__installments{font-weight:var(--font-light)}.prices__value{display:block;font-size:var(--font-size-lg)}.prices__value small{font-size:var(--font-size-sm)}.prices--big{font-size:var(--font-size)}.prices--big .prices__value{font-size:var(--h1);margin-bottom:var(--spacer-1)}.prices--literal .prices__discount span,.prices--literal .prices__installments span{font-weight:var(--font-bold)}.prices--literal small{font-size:100%}.prices__points{color:var(--secondary);margin-bottom:var(--spacer-2)}.prices:not(.prices--literal) .prices__compare{color:var(--gray)}",""]),t.exports=e},function(t,e,r){"use strict";r(16)},function(t,e,r){(e=r(5)(!1)).push([t.i,".product-card{border-radius:var(--border-radius);font-size:var(--font-size);height:100%;padding:var(--spacer-2);position:relative}.product-card>section{display:flex;flex-direction:column;height:100%}.product-card__prices{display:flex;flex:1;flex-direction:column;justify-content:flex-end}.product-card__offer-stamp{background-color:var(--success);border-radius:var(--border-radius);color:var(--success-yiq);font-size:80%;line-height:2.2;min-width:55px;opacity:.9;position:absolute;right:0;text-align:center;top:1rem;transition:border-radius .3s;z-index:9}.product-card__offer-stamp i,.product-card__offer-stamp svg{font-size:85%;opacity:.8}.product-card__link{outline:none}.product-card__pictures{align-items:center;display:flex;overflow:hidden;position:relative;text-align:center}.product-card__picture{display:block;flex:0 0 100%;position:absolute}.product-card__picture img{max-width:100%}.product-card__picture:not(:last-child){opacity:0}.product-card__picture:not(:last-child).picture{background-color:none}.product-card__picture.loaded:last-child{opacity:1;position:inherit;transition:opacity .15s ease-out .1s}.product-card__pictures{height:180px}@media(min-width:576px){.product-card__pictures{height:200px}}@media(min-width:992px){.product-card__pictures{height:250px}}.product-card__picture img{max-height:180px}@media(min-width:576px){.product-card__picture img{max-height:200px}}@media(min-width:992px){.product-card__picture img{max-height:250px}}.product-card__name{--max-lines:3;-webkit-line-clamp:var(--max-lines);-webkit-box-orient:vertical;display:-webkit-box;font-size:var(--font-size-sm);font-weight:var(--font-normal);line-height:var(--line-height-sm);overflow:hidden;padding-top:var(--spacer-1);z-index:1}@media(min-width:992px){.product-card__name{--max-lines:2}}.product-card__favorite{font-size:var(--font-size-lg);position:absolute;top:var(--spacer-1);z-index:9}.product-card__favorite .active{color:var(--red)}.product-card__buy{margin-top:var(--spacer-1);position:relative}.product-card__buy-loading{left:var(--spacer-2);margin-top:-8px;position:absolute;top:50%}@media(hover:hover){.product-card:hover{box-shadow:var(--box-shadow-sm)}.product-card:hover .product-card__offer-stamp{border-bottom-right-radius:0;border-top-right-radius:0}.product-card:hover .product-card__picture.loaded{opacity:1;position:inherit}.product-card:hover .product-card__picture.loaded+.picture{opacity:0;position:absolute;z-index:-1}.product-card:hover .product-card__buy{opacity:1}.product-card:hover .product-card__favorite{opacity:.7}}.product-card--inactive,.product-card--inactive img{opacity:.7}.product-card--small .product-card__pictures{height:90px}@media(min-width:576px){.product-card--small .product-card__pictures{height:100px}}@media(min-width:992px){.product-card--small .product-card__pictures{height:125px}}.product-card--small .product-card__picture img{max-height:90px}@media(min-width:576px){.product-card--small .product-card__picture img{max-height:100px}}@media(min-width:992px){.product-card--small .product-card__picture img{max-height:125px}}.product-card--small .product-card__name{--max-lines:2;margin-bottom:0;padding-top:var(--spacer-2)}.product-card--small .product-card__buy{bottom:var(--spacer-3);position:absolute;right:var(--spacer-3)}",""]),t.exports=e},function(t,e,r){"use strict";r.r(e);var i=r(3),n=r.n(i),o=r(4),s=r.n(o),a=r(0),c=r(13),u=r.n(c),d=r(27),l=r(7),p=r(9),f=r.n(p),h=r(10),_=r(11),m=r(12),b=r(2),g=r.n(b),v=r(8);const y=(t,e)=>{if("object"==typeof window){t=`productCard${t}Html`;const r="function"==typeof window[t]?window[t](e):window[t];if("string"==typeof r)return r}};var x={name:"ProductCard",components:{ALink:h.a,APicture:_.a,APrices:m.a},props:{product:Object,productId:String,isSmall:Boolean,headingTag:{type:String,default:"h3"},buyText:String,transitionClass:{type:String,default:"animated fadeIn"},canAddToCart:{type:Boolean,default:!0},ecomPassport:{type:Object,default:()=>g.a},accountUrl:{type:String,default:"/app/#/account/"},isLoaded:Boolean,installmentsOption:Object,discountOption:Object,stamps:{type:Array,default:()=>window.productCardStamps||[]}},data:()=>({body:{},isLoading:!1,isWaitingBuy:!1,isHovered:!1,isFavorite:!1,error:""}),computed:{i19addToFavorites:()=>Object(a.i18n)(d.c),i19outOfStock:()=>Object(a.i18n)(d.G),i19unavailable:()=>Object(a.i18n)(d.X),i19uponRequest:()=>"Sob consulta",isWithoutPrice(){return!Object(a.price)(this.body)},ratingHtml(){return y("Rating",this.body)},buyHtml(){return y("Buy",this.body)},footerHtml(){return y("Footer",this.body)},name(){return Object(a.name)(this.body)},strBuy(){return this.buyText||"object"==typeof window&&window.productCardBuyText||Object(a.i18n)(d.f)},isInStock(){return Object(a.inStock)(this.body)},isActive(){return this.body.available&&this.body.visible&&this.isInStock},isLogged:()=>g.a.checkAuthorization(),discount(){const{body:t}=this;return Object(a.onPromotion)(t)?Math.round(100*(t.base_price-Object(a.price)(t))/t.base_price):0},validStamps(){return Array.isArray(this.stamps)?this.stamps.filter(t=>!!(t&&t.img&&Array.isArray(t.skus)&&t.skus.length)&&t.skus.includes(this.body.sku)):[]}},methods:{setBody(t){this.body=Object.assign({},t),delete this.body.body_html,delete this.body.body_text,delete this.body.inventory_records,delete this.body.price_change_records,this.isFavorite=Object(v.a)(this.body._id,this.ecomPassport)},fetchItem(){this.productId&&(this.isLoading=!0,Object(l.store)({url:`/products/${this.productId}.json`}).then(({data:t})=>{this.$emit("update:product",t),this.setBody(t),this.$emit("update:is-loaded",!0)}).catch(t=>{console.error(t),this.body.name&&this.body.slug&&this.body.pictures||(this.error=Object(a.i18n)(d.j))}).finally(()=>{this.isLoading=!1}))},toggleFavorite(){this.isLogged&&(this.isFavorite=Object(v.b)(this.body._id,this.ecomPassport))},buy(){const t=this.body;this.$emit("buy",{product:t}),this.canAddToCart&&(this.isWaitingBuy=!0,Object(l.store)({url:`/products/${t._id}.json`}).then(({data:e})=>{const i=["variations","customizations","kit_composition"];for(let t=0;t<i.length;t++){const o=e[i[t]];if(o&&o.length)return Promise.all([r.e(2),r.e(1)]).then(r.bind(null,65)).then(t=>{new n.a({render:r=>r(t.default,{props:{product:e}})}).$mount(this.$refs.quickview)})}const{quantity:o,price:s}=e;f.a.addProduct({...t,quantity:o,price:s})}).catch(e=>{console.error(e),window.location="/"+t.slug}).finally(()=>{this.isWaitingBuy=!1}))}},created(){this.product&&(this.setBody(this.product),void 0===this.product.available&&(this.body.available=!0),void 0===this.product.visible&&(this.body.visible=!0)),this.isLoaded||this.fetchItem()}},w=(r(22),r(1)),O=Object(w.a)(x,(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"product-card",class:{"product-card--inactive":t.body._id&&!t.isActive,"product-card--small":t.isSmall},attrs:{"data-product-id":t.body._id,"data-sku":t.body.sku},on:{mouseover:function(e){t.isHovered=!0}}},[r("transition",{attrs:{"enter-active-class":t.transitionClass}},[t.isLoading?t._e():r("section",[t._t("discount-tag",(function(){return[t.isActive&&t.discount>0?r("span",{staticClass:"product-card__offer-stamp"},[r("i",{staticClass:"i-arrow-down"}),t._v(" "),r("b",[t._v(t._s(t.discount))]),t._v("% ")]):t._e()]}),null,{discount:t.discount}),t._t("stamps",(function(){return[t.validStamps.length?r("div",{staticClass:"product-card__stamps"},t._l(t.validStamps,(function(t,e){return r("span",{key:"s-"+e,class:"product-card__stamps-"+ +(""+(t.id||"").toLowerCase().replace(/\s/g,"-"))},[r("img",{attrs:{src:t.img,alt:t.id}})])})),0):t._e()]})),t._t("body",(function(){return[r("a-link",{staticClass:"product-card__link",attrs:{href:"/"+t.body.slug,title:t.name}},[t._t("header"),r("div",{staticClass:"product-card__pictures"},[t.body.pictures&&t.body.pictures.length?t._l(t.body.pictures.slice(0,2).reverse(),(function(e,i){return 1===t.body.pictures.length||1===i||t.isHovered?r("a-picture",{key:i,staticClass:"product-card__picture",attrs:{src:e,"can-calc-height":!1}}):t._e()})):r("a-picture",{staticClass:"product-card__picture"})],2),t._t("title",(function(){return[r(t.headingTag,{tag:"component",staticClass:"product-card__name"},[t._v(" "+t._s(t.name)+" ")])]}))],2)]})),t._t("rating",(function(){return[t._m(0)]})),t.body.available&&t.body.visible?t.isInStock?t.isWithoutPrice?t._t("without-price",(function(){return[r("p",{staticClass:"badge badge-info mt-auto"},[t._v(" "+t._s(t.i19uponRequest)+" ")])]})):[t._t("prices",(function(){return[r("a-prices",{staticClass:"product-card__prices",attrs:{product:t.body,"installments-option":t.installmentsOption,"discount-option":t.discountOption}})]})),r("div",{staticClass:"product-card__buy fade",on:{click:t.buy}},[t._t("buy",(function(){return[t.buyHtml?r("div",{domProps:{innerHTML:t._s(t.buyHtml)}}):t._e(),r("button",{staticClass:"btn btn-primary",class:t.isSmall?"btn-sm":"btn-block",attrs:{type:"button",disabled:t.isWaitingBuy}},[t.isWaitingBuy?r("span",{staticClass:"product-card__buy-loading spinner-grow spinner-grow-sm",attrs:{role:"status"}},[r("span",{staticClass:"sr-only"},[t._v("Loading...")])]):t._e(),t._t("buy-button-content",(function(){return[r("i",{staticClass:"i-shopping-bag mr-1"}),t._v(" "+t._s(t.strBuy)+" ")]}))],2)]}))],2)]:t._t("out-of-stock",(function(){return[r("p",{staticClass:"badge badge-dark mt-auto"},[t._v(" "+t._s(t.i19outOfStock)+" ")])]})):t._t("unavailable",(function(){return[r("p",{staticClass:"badge badge-warning mt-auto"},[t._v(" "+t._s(t.i19unavailable)+" ")])]})),t._t("favorite",(function(){return[r("a",{staticClass:"btn product-card__favorite fade",attrs:{href:t.isLogged?null:t.accountUrl,"aria-label":t.i19addToFavorites},on:{click:t.toggleFavorite}},[r("i",{staticClass:"i-heart mr-1",class:t.isFavorite?"active":null})])]})),t._t("footer",(function(){return[t.footerHtml?r("div",{domProps:{innerHTML:t._s(t.footerHtml)}}):t._e()]}))],2)]),t.isLoading?[t._t("default"),t.error?r("div",{staticClass:"alert alert-warning small",attrs:{role:"alert"}},[t._v(" "+t._s(t.error)+" ")]):t._e()]:t._e(),r("div",{ref:"quickview"})],2)}),[function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"product-card__rating",attrs:{"data-sku":this.body.sku},domProps:{innerHTML:this._s(this.ratingHtml)}})}],!1,null,null,null).exports;e.default=(t={},e="product-card")=>{t.buyText&&(window.productCardBuyText=t.buyText),t.buy&&(window.productCardBuyHtml=t.buy),t.footer&&(window.productCardFooterHtml=t.footer);const r=window.storefront&&window.storefront.getScopedSlots,i=document.querySelectorAll("."+e),o=[];for(let t=0;t<i.length;t++)if(i[t]){const{productId:e,toRender:r}=i[t].dataset;r&&-1===o.indexOf(e)&&o.push(e)}let c;if(o.length>=4&&o.length<=70&&!t.skipSearchApi){const t=new u.a;c=t.setPageSize(o.length).setProductIds(o).fetch(!0,{timeout:5e3}).then(()=>{const e=t.getItems();for(let t=0;t<2;t++)d(i[t]);return e}).catch(t=>{console.error(t)})}else c=Promise.resolve();const d=i=>{if(i){const{productId:o,sku:s,toRender:u}=i.dataset;if(u){let u;c.then(t=>{Array.isArray(t)&&(u=t.find(({_id:t})=>t===o))}).finally(()=>{let c;if(u){if(c=!0,!u.available||!u.visible||!Object(a.inStock)(u)){const t=i.parentNode&&i.parentNode.parentNode;t&&"LI"===t.tagName&&t.parentNode.appendChild(t)}}else{const t=i.parentNode;if(t&&(u=t.dataset.product,"string"==typeof u))try{u=JSON.parse(u)}catch(t){u=void 0}}((i,o,s,a,c)=>{new n.a({render:n=>n(O,{class:"product-card"!==e?e:null,attrs:{"data-product-id":o,"data-sku":s},props:{...t.props,productId:o,product:a,isLoaded:c,transitionClass:null},scopedSlots:"function"==typeof r?r(i,n):void 0})}).$mount(i)})(i,o,s,u,c)})}}};s()(i,{rootMargin:"350px 0px",threshold:0,load:d}).observe()}},function(t,e){t.exports=void 0},function(t,e){t.exports=void 0},function(t,e,r){"use strict";r.d(e,"b",(function(){return i})),r.d(e,"c",(function(){return n})),r.d(e,"a",(function(){return o})),r.d(e,"d",(function(){return s})),r.d(e,"e",(function(){return a})),r.d(e,"f",(function(){return c})),r.d(e,"g",(function(){return u})),r.d(e,"h",(function(){return d})),r.d(e,"i",(function(){return l})),r.d(e,"j",(function(){return p})),r.d(e,"k",(function(){return f})),r.d(e,"l",(function(){return h})),r.d(e,"m",(function(){return _})),r.d(e,"n",(function(){return m})),r.d(e,"o",(function(){return b})),r.d(e,"p",(function(){return g})),r.d(e,"q",(function(){return v})),r.d(e,"r",(function(){return y})),r.d(e,"s",(function(){return x})),r.d(e,"t",(function(){return w})),r.d(e,"u",(function(){return O})),r.d(e,"v",(function(){return C})),r.d(e,"w",(function(){return j})),r.d(e,"x",(function(){return k})),r.d(e,"y",(function(){return S})),r.d(e,"z",(function(){return P})),r.d(e,"A",(function(){return A})),r.d(e,"B",(function(){return T})),r.d(e,"C",(function(){return I})),r.d(e,"D",(function(){return L})),r.d(e,"E",(function(){return z})),r.d(e,"F",(function(){return B})),r.d(e,"G",(function(){return M})),r.d(e,"H",(function(){return N})),r.d(e,"I",(function(){return $})),r.d(e,"J",(function(){return F})),r.d(e,"K",(function(){return E})),r.d(e,"L",(function(){return H})),r.d(e,"M",(function(){return R})),r.d(e,"N",(function(){return D})),r.d(e,"O",(function(){return W})),r.d(e,"P",(function(){return U})),r.d(e,"Q",(function(){return q})),r.d(e,"R",(function(){return V})),r.d(e,"S",(function(){return G})),r.d(e,"T",(function(){return J})),r.d(e,"U",(function(){return Q})),r.d(e,"V",(function(){return X})),r.d(e,"W",(function(){return Y})),r.d(e,"X",(function(){return Z})),r.d(e,"Y",(function(){return K})),r.d(e,"Z",(function(){return tt})),r.d(e,"ab",(function(){return et})),r.d(e,"bb",(function(){return rt})),r.d(e,"cb",(function(){return it})),r.d(e,"db",(function(){return nt})),r.d(e,"eb",(function(){return ot})),r.d(e,"fb",(function(){return st}));const i={en_us:"Add to cart",pt_br:"Adicionar ao carrinho"},n={en_us:"Add to favorites",pt_br:"Adicionar aos favoritos"},o={en_us:"Add $1 to earn",pt_br:"Adicione $1 para ganhar"},s={en_us:"As of",pt_br:"A partir de"},a={en_us:"At sight",pt_br:"À vista"},c={en_us:"Buy",pt_br:"Comprar"},u={en_us:"Buy kit",pt_br:"Comprar kit"},d={en_us:"Calculate shipping",pt_br:"Calcular frete"},l={en_us:"Close",pt_br:"Fechar"},p={en_us:"Connection error, click product to try again",pt_br:"Erro de conexão, clique no produto para tentar novamente"},f={en_us:"Days",pt_br:"Dias"},h={en_us:"Discount of",pt_br:"Desconto de"},_={en_us:"Email",pt_br:"E-mail"},m={en_us:"Ends in",pt_br:"Acaba em"},b={en_us:"Free",pt_br:"Grátis"},g={en_us:"Free shipping",pt_br:"Frete grátis"},v={en_us:"Free shipping from",pt_br:"Frete grátis a partir de"},y={en_us:"From",pt_br:"De"},x={en_us:"Fullscreen",pt_br:"Tela cheia"},w={en_us:"Interest free",pt_br:"Sem juros"},O={en_us:"Item",pt_br:"Item"},C={en_us:"Unable to load product information, please check your internet connection.",pt_br:"Não foi possível carregar informações do produto, por favor verifique sua conexão."},j={en_us:"Max quantity",pt_br:"Quantidade máxima"},k={en_us:"Minimum quantity",pt_br:"Quantidade mínima"},S={en_us:"Next",pt_br:"Próximo"},P={en_us:"Of",pt_br:"De"},A={en_us:"Of discount",pt_br:"De desconto"},T={en_us:"Offer",pt_br:"Oferta"},I={en_us:"On",pt_br:"No"},L={en_us:"On freight",pt_br:"No frete"},z={en_us:"Only",pt_br:"Apenas"},B={en_us:"Open gallery",pt_br:"Abrir galería"},M={en_us:"Out of stock",pt_br:"Sem estoque"},N={en_us:"Payment options",pt_br:"Opções de pagamento"},$={en_us:"Per unit",pt_br:"Por unidade"},F={en_us:"Pick up today",pt_br:"Retire hoje"},E={en_us:"Previous",pt_br:"Anterior"},H={en_us:"Production deadline",pt_br:"Prazo de produção"},R={en_us:"Quantity",pt_br:"Quantidade"},D={en_us:"Receive today",pt_br:"Receba hoje"},W={en_us:"Remove from favorites",pt_br:"Remover dos favoritos"},U={en_us:"Retry",pt_br:"Tentar novamente"},q={en_us:"See more info",pt_br:"Veja mais informações"},V={en_us:"Select",pt_br:"Selecionar"},G={en_us:"Select variation",pt_br:"Selecionar variação"},J={en_us:"Please select an option in each field above",pt_br:"Por favor selecione uma opção em cada campo acima"},Q={en_us:"Share",pt_br:"Compartilhar"},X={en_us:"Share on Facebook",pt_br:"Compartilhar no Facebook"},Y={en_us:"To",pt_br:"Por"},Z={en_us:"Unavailable",pt_br:"Indisponível"},K={en_us:"Units",pt_br:"Unidades"},tt={en_us:"Units in stock",pt_br:"Unidades em estoque"},et={en_us:"Until tomorrow",pt_br:"Até amanhã"},rt={en_us:"Up to",pt_br:"Até"},it={en_us:"Video",pt_br:"Vídeo"},nt={en_us:"Working days",pt_br:"Dias úteis"},ot={en_us:"You earn",pt_br:"Você ganha"},st={en_us:"Zip code",pt_br:"CEP"}}]).default; //# sourceMappingURL=widget-product-card.var.min.js.map