{"version":3,"sources":["webpack:///./src/feature/product-dynamic-price/product-dynamic-price.js","webpack:///./node_modules/core-js/modules/es.object.get-prototype-of.js"],"names":["ProductDynamicPrice","element","el","log","prices","JSON","parse","dataset","quantity","querySelector","priceExclVat","priceInclVat","message","action","activeClass","init","this","publishInitPrice","value","priceObj","getPrice","renderPrice","publishPrice","addEventListener","e","currentTarget","find","item","parseInt","priceExclVatDisplayText","priceInclVatDisplayText","innerHTML","classList","add","setAttribute","remove","removeAttribute","publish","window","BaseFeature","$","fails","toObject","nativeGetPrototypeOf","CORRECT_PROTOTYPE_GETTER","target","stat","forced","sham","getPrototypeOf","it"],"mappings":"o8BAEMA,E,YACL,WAAYC,GAAS,a,4FAAA,UACpB,wBAAMA,KAEDC,GAAKD,EACV,EAAKE,IAAI,oCACT,EAAKC,OAASC,KAAKC,MAAM,EAAKJ,GAAGK,QAAQH,QACzC,EAAKI,SAAW,EAAKN,GAAGO,cAAc,+CACtC,EAAKC,aAAe,EAAKR,GAAGO,cAAc,mDAC1C,EAAKE,aAAe,EAAKT,GAAGO,cAAc,mDAC1C,EAAKG,QAAU,EAAKV,GAAGO,cAAc,8CACrC,EAAKI,OAAS,EAAKX,GAAGO,cAAc,6CAEpC,EAAKK,YAAc,YAEnB,EAAKC,OAde,E,8RAiBd,WACNC,KAAKC,mBAEL,IAAIT,EAAWQ,KAAKR,SAASU,MACzBC,EAAWH,KAAKI,SAASZ,GAC7BQ,KAAKK,YAAYF,GACjBH,KAAKM,aAAaH,GAElBH,KAAKR,SAASe,iBAAiB,UAAU,SAACC,GACzC,EAAKrB,IAAI,UACTK,EAAWgB,EAAEC,cAAcP,MAC3BC,EAAW,EAAKC,SAASZ,GACzB,EAAKa,YAAYF,GACjB,EAAKG,aAAaH,Q,+BAIXX,GAIR,OAHmBQ,KAAXZ,OAEgBsB,MAAK,SAAAC,GAAI,OAAIC,SAASD,EAAKnB,SAAU,MAAQoB,SAASpB,EAAU,S,kCAI7EW,GAAU,IAEpBX,EAGGW,EAHHX,SACAqB,EAEGV,EAFHU,wBACAC,EACGX,EADHW,wBAGDd,KAAKN,aAAaqB,UAAYF,EAC9Bb,KAAKL,aAAaoB,UAAYD,EAE1BtB,GAAY,IACfQ,KAAKJ,QAAQoB,UAAUC,IAAIjB,KAAKF,aAChCE,KAAKH,OAAOqB,aAAa,WAAY,MAErClB,KAAKJ,QAAQoB,UAAUG,OAAOnB,KAAKF,aACnCE,KAAKH,OAAOuB,gBAAgB,e,mCAIjBjB,GACZH,KAAKqB,QAAQ,sBAAuBlB,K,yCAGlB,WAClBmB,OAAOf,iBAAiB,QAAQ,WAK/B,EAAKc,QAAQ,qBAAqB,W,oCAvEHE,GA4EnBvC,a,oBC9Ef,IAAIwC,EAAI,EAAQ,GACZC,EAAQ,EAAQ,GAChBC,EAAW,EAAQ,GACnBC,EAAuB,EAAQ,IAC/BC,EAA2B,EAAQ,IAMvCJ,EAAE,CAAEK,OAAQ,SAAUC,MAAM,EAAMC,OAJRN,GAAM,WAAcE,EAAqB,MAIJK,MAAOJ,GAA4B,CAChGK,eAAgB,SAAwBC,GACtC,OAAOP,EAAqBD,EAASQ","file":"17-74f8dcba.pkg.js","sourcesContent":["import BaseFeature from '../../foundation/base/base';\r\n\r\nclass ProductDynamicPrice extends BaseFeature {\r\n\tconstructor(element) {\r\n\t\tsuper(element);\r\n\r\n\t\tthis.el = element;\r\n\t\tthis.log('ProductDynamicPrice Feature Init');\r\n\t\tthis.prices = JSON.parse(this.el.dataset.prices);\r\n\t\tthis.quantity = this.el.querySelector('[data-js=\"product-dynamic-price__quantity\"]');\r\n\t\tthis.priceExclVat = this.el.querySelector('[data-js=\"product-dynamic-price__priceExclVat\"]');\r\n\t\tthis.priceInclVat = this.el.querySelector('[data-js=\"product-dynamic-price__priceInclVat\"]');\r\n\t\tthis.message = this.el.querySelector('[data-js=\"product-dynamic-price__message\"]');\r\n\t\tthis.action = this.el.querySelector('[data-js=\"product-dynamic-price__action\"]');\r\n\r\n\t\tthis.activeClass = 'is-active';\r\n\r\n\t\tthis.init();\r\n\t}\r\n\r\n\tinit() {\r\n\t\tthis.publishInitPrice();\r\n\r\n\t\tlet quantity = this.quantity.value;\r\n\t\tlet priceObj = this.getPrice(quantity);\r\n\t\tthis.renderPrice(priceObj);\r\n\t\tthis.publishPrice(priceObj);\r\n\r\n\t\tthis.quantity.addEventListener('change', (e) => {\r\n\t\t\tthis.log('change');\r\n\t\t\tquantity = e.currentTarget.value;\r\n\t\t\tpriceObj = this.getPrice(quantity);\r\n\t\t\tthis.renderPrice(priceObj);\r\n\t\t\tthis.publishPrice(priceObj);\r\n\t\t});\r\n\t}\r\n\r\n\tgetPrice(quantity) {\r\n\t\tconst { prices } = this;\r\n\r\n\t\tconst priceObj = prices.find(item => parseInt(item.quantity, 10) === parseInt(quantity, 10));\r\n\t\treturn priceObj;\r\n\t}\r\n\r\n\trenderPrice(priceObj) {\r\n\t\tconst {\r\n\t\t\tquantity,\r\n\t\t\tpriceExclVatDisplayText,\r\n\t\t\tpriceInclVatDisplayText\r\n\t\t} = priceObj;\r\n\r\n\t\tthis.priceExclVat.innerHTML = priceExclVatDisplayText;\r\n\t\tthis.priceInclVat.innerHTML = priceInclVatDisplayText;\r\n\r\n\t\tif (quantity >= 50) {\r\n\t\t\tthis.message.classList.add(this.activeClass);\r\n\t\t\tthis.action.setAttribute('disabled', '');\r\n\t\t} else {\r\n\t\t\tthis.message.classList.remove(this.activeClass);\r\n\t\t\tthis.action.removeAttribute('disabled');\r\n\t\t}\r\n\t}\r\n\r\n\tpublishPrice(priceObj) {\r\n\t\tthis.publish('dynamicPrice.change', priceObj);\r\n\t}\r\n\r\n\tpublishInitPrice() {\r\n\t\twindow.addEventListener('load', () => {\r\n\t\t\t/**\r\n\t\t\t\tDelay the publish until page is done so all components\r\n\t\t\t\twill receive the message\r\n\t\t\t */\r\n\t\t\tthis.publish('dynamicPrice.init', true);\r\n\t\t});\r\n\t}\r\n}\r\n\r\nexport default ProductDynamicPrice;\r\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar toObject = require('../internals/to-object');\nvar nativeGetPrototypeOf = require('../internals/object-get-prototype-of');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });\n\n// `Object.getPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-object.getprototypeof\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {\n getPrototypeOf: function getPrototypeOf(it) {\n return nativeGetPrototypeOf(toObject(it));\n }\n});\n\n"],"sourceRoot":""}