{"version":3,"sources":["webpack:///./src/tc/js/components/Component.js","webpack:///./src/tc/js/components/PhoneSwap.js"],"names":["domTree","WeakMap","configuration","Component","el","config","arguments","length","undefined","_classCallCheck","this","Error","$el","jQuery","$","set","hasOwnProperty","dom","setupDefaults","addListeners","get","elements","__webpack_require__","PhoneSwap","_this","_possibleConstructorReturn","__proto__","Object","getPrototypeOf","call","setPPCFranchiseId","setLocalizedFranchiseId","idInQueryString","localizedFID","ppcFID","setPPCFranchiseIdCookie","parsePhoneNumbers","swap","$phoneElements","phoneNumbers","idCookieName","metadataCookieName","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_step","_iterator","Symbol","iterator","next","done","origNum","value","getAttribute","includes","replace","addPhoneNumberToList","strippedNum","err","return","num","push","data","fid","URL","window","location","searchParams","isValidFranchiseId","getFranchiseIdFromCookie","_jsCookie2","default","expires","cookieName","yoTrackInfo","_typeof","numbers","yotrackId","id","YoTrack","api","swapPhones","line","console","log","getMetadata","metadata","isSEMSession"],"mappings":"ohBAAA,IAAMA,EAAU,IAAIC,QACdC,EAAgB,IAAID,QA4BpBE,aAOJ,SAAAA,EAAYC,GAAgB,IAAZC,EAAYC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,MAC1B,+FAD0BG,CAAAC,KAAAP,QACR,IAAPC,EACT,MAAM,IAAIO,MAAM,wEASlBD,KAAKE,IAAMR,aAAcS,EAAST,EAAKU,EAAEV,GAEjB,IAApBM,KAAKE,IAAIL,SAEbP,EAAQe,IAAIL,SACZR,EAAca,IAAIL,KAAML,GAEpBK,KAAKL,OAAOW,eAAe,SAC7BN,KAAKO,IAAMP,KAAKL,OAAOY,KAGzBP,KAAKQ,gBACLR,KAAKS,0IAuCL,OAAOjB,EAAckB,IAAIV,gCA6BnBW,GACNA,OACKX,KAAKO,IACLI,GAGLrB,EAAQe,IAAIL,KAAMW,mBAYlB,OAAOrB,EAAQoB,IAAIV,yBAIRP,ikBCrJfmB,EAAA,UACAA,EAAA,6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7BA,EAAMrD,KAAK2D,yBAAyB3D,KAAK8B,cAM3C9B,KAAKwB,OAAS6B,kDAGQA,GACtBO,EAAAC,QAAQxD,IAAIL,KAAK8B,aAAcuB,GAAOS,QAAS,sDAGxBC,GACvB,IAAMV,EAAMO,EAAAC,QAAQnD,IAAIqD,GAExB,OAAI/D,KAAK0D,mBAAmBL,GACnBA,EAGF,gDAGUA,GACjB,YAAmB,IAARA,GAA+B,OAARA,GAAwB,cAARA,GAA+B,KAARA,iCASzE,GAAKrD,KAAK0D,mBAAmB1D,KAAKwB,SAAwC,IAA7BxB,KAAK6B,aAAahC,OAA/D,CAIA,IAAMmE,EAAc5D,EAAE,2BAA2BgD,KAAK,oBACtD,GAA6B,iBAAzB,IAAQY,EAAR,YAAAC,EAAQD,IAA2B,CAErC,IAAME,EAAUlE,KAAK6B,aAEfsC,EAAYH,EAAYI,GACxBL,EAAa/D,KAAK+B,mBAExBwB,OAAOc,QAAQF,EACb,SAACnB,EAAKsB,GACAtB,EAEFO,OAAOc,QAAQF,EACb,SAACnB,EAAKsB,GACJA,EAAIC,WAAWL,EACb,SAAClB,EAAKwB,GACJC,QAAQC,IAAI,UAAW1B,GACvByB,QAAQC,IAAI,iBAAkBF,OAItCF,EAAIC,WAAWL,EACb,SAAClB,EAAKwB,GACJC,QAAQC,IAAI,UAAW1B,GACvByB,QAAQC,IAAI,iBAAkBF,KAIpCF,EAAIK,YAAY,SAAC3B,EAAK4B,GACpBhB,EAAAC,QAAQxD,IAAI0D,EAAYa,GAAYd,QAAS,IAC7CW,QAAQC,IAAI,cAAeE,KAG7BN,EAAIO,aAAa,SAAC7B,EAAK6B,GACrBJ,QAAQC,IAAI,mBAAoBG,4BAQ7BhE","file":"36.9c991a4454aeccf9889b.js","sourcesContent":["const domTree = new WeakMap();\nconst configuration = new WeakMap();\n\n/**\n * Component is a class that should be extended for every component that's being made. It\n * is a helper class to keep the code uniform.\n *\n * __PLEASE NOTE__: This is only to be extended, not instantiated.\n *\n * @example\n * import Component from 'component';\n *\n * class Foo extends Component {\n * construction(el){\n * super(el);\n * }\n *\n * setupDefaults(){\n * // ...defaults go here\n * }\n *\n * addListeners(){\n * // ...listeners go here\n * }\n * }\n *\n * // Create a new Foo component\n * new Foo('.foo');\n */\nclass Component {\n /**\n * Component constructor - see {@link config} on how to pass in additional configuration to the constructor\n *\n * @param {string|Object} el - Main DOM element, you can pass a string such as `'.foo'` __or__ a jQuery object such as `$('.foo')`\n * @param {Object} [config={ }] - Additional component configuration; reachable with `this.config`\n */\n constructor(el, config = {}){\n if (typeof el === 'undefined') {\n throw new Error('You must provide an element as a String type or a jQuery object type');\n }\n\n /**\n * Main class element, this will be a jQuery instance\n * This can be reachable at any time in your superclass with `this.$el`\n *\n * @type {Object}\n */\n this.$el = el instanceof jQuery ? el : $(el);\n\n if (this.$el.length === 0) return;\n\n domTree.set(this, {});\n configuration.set(this, config);\n\n if (this.config.hasOwnProperty('dom')) {\n this.dom = this.config.dom;\n }\n\n this.setupDefaults();\n this.addListeners();\n }\n\n /**\n * This method is used for override;\n * It's called directly after the element and configuration have been set up\n * @abstract\n */\n setupDefaults(){}\n\n /**\n * This method is used for override;\n * It's called directly after `setupDefaults()`, so everything is ready and setup at this point.\n * @abstract\n */\n addListeners(){}\n\n /**\n * Get component configuration\n *\n * @example\n * class Foo extends Component {\n * construction(el, config){\n * super(el, config);\n * }\n *\n * setupDefaults(){\n * console.log(this.config.name); // Outputs \"Foo\"\n * }\n * }\n *\n * // Create a new Foo component with some configuration\n * new Foo('.foo', {\n * name: 'Foo'\n * });\n *\n * @type {Object}\n */\n get config(){\n return configuration.get(this);\n }\n\n /**\n * Set DOM object\n *\n * @example\n * class Foo extends Component {\n * construction(el){\n * super(el);\n * }\n *\n * setupDefaults(){\n * this.dom = {\n * $container: this.$el.find('.container')\n * }\n * }\n *\n * addListeners(){\n * //DOM object is available\n * console.log(this.dom.$container);\n * }\n * }\n *\n * // Create a new Foo component\n * new Foo('.foo');\n *\n * @type {Object}\n */\n set dom(elements){\n elements = {\n ...this.dom,\n ...elements\n };\n\n domTree.set(this, elements);\n }\n\n /**\n * Get DOM object\n *\n * @example\n * this.dom\n *\n * @type {Object}\n */\n get dom(){\n return domTree.get(this);\n }\n}\n\nexport default Component;\n\n\n\n// WEBPACK FOOTER //\n// ./src/tc/js/components/Component.js","import Component from 'component';\nimport Cookies from 'js-cookie';\n\nclass PhoneSwap extends Component {\n constructor(el) {\n super(el);\n\n this.setPPCFranchiseId();\n this.setLocalizedFranchiseId();\n\n // If the PPC query params exists, then skip this and go right to the phone swap\n if (!this.idInQueryString) {\n if (typeof this.localizedFID !== 'undefined') {\n this.ppcFID = this.localizedFID;\n this.setPPCFranchiseIdCookie(this.ppcFID);\n }\n }\n\n this.parsePhoneNumbers();\n this.swap();\n }\n\n setupDefaults() {\n this.$phoneElements = this.$el;\n this.phoneNumbers = [];\n this.ppcFID = null; //Franchise ID passed in from PPC campaign\n this.localizedFID = null; //Franchise ID of the localized franchise\n this.idCookieName = 'yotrack-fid';\n this.metadataCookieName = 'YoTrackMetaDataWidget';\n this.idInQueryString = false;\n }\n\n parsePhoneNumbers() {\n for(const item of this.$phoneElements) {\n let origNum = item.getAttribute('href');\n\n if (origNum.includes('tel:')) {\n origNum = origNum.replace('tel:', '');\n\n if (origNum !== '') {\n this.addPhoneNumberToList(origNum);\n\n const strippedNum = origNum.replace(/\\D/g, '');\n this.addPhoneNumberToList(strippedNum);\n }\n }\n }\n }\n\n addPhoneNumberToList(num) {\n if (!this.phoneNumbers.includes(num)) {\n this.phoneNumbers.push(num);\n }\n }\n\n // Get FID of the current localized page\n setLocalizedFranchiseId() {\n this.localizedFID = $('[data-fid]').data('fid');\n }\n\n // Get FID associated with a particular PPC campaign\n setPPCFranchiseId() {\n const url = new URL(window.location);\n let fid = url.searchParams.get('fid');\n\n if (!this.isValidFranchiseId(fid)) {\n fid = this.getFranchiseIdFromCookie(this.idCookieName);\n } else {\n this.idInQueryString = true;\n this.setPPCFranchiseIdCookie(fid);\n }\n\n this.ppcFID = fid;\n }\n\n setPPCFranchiseIdCookie(fid) {\n Cookies.set(this.idCookieName, fid, { expires: 14 });\n }\n\n getFranchiseIdFromCookie(cookieName) {\n const fid = Cookies.get(cookieName);\n\n if (this.isValidFranchiseId(fid)) {\n return fid;\n }\n\n return null;\n }\n\n isValidFranchiseId(fid) {\n if (typeof fid === 'undefined' || fid === null || fid === 'undefined' || fid === '') {\n return false;\n }\n\n return true;\n }\n\n\n swap() {\n if (!this.isValidFranchiseId(this.ppcFID) || this.phoneNumbers.length === 0) {\n return;\n }\n //get info attached to body tag. jquery will automatically parse JSON\n const yoTrackInfo = $('[data-hfc-yotrack-info]').data('hfc-yotrack-info');\n if (typeof (yoTrackInfo) === 'object') {\n\n const numbers = this.phoneNumbers;\n //yotrack id is embedded in html attribute\n const yotrackId = yoTrackInfo.id;\n const cookieName = this.metadataCookieName;\n\n window.YoTrack(yotrackId,\n (err, api) => {\n if (err) {\n\n window.YoTrack(yotrackId,\n (err, api) => {\n api.swapPhones(numbers,\n (err, line) => {\n console.log('Error: ', err)\n console.log('Phone Number: ', line)\n })\n })\n } else {\n api.swapPhones(numbers,\n (err, line) => {\n console.log('Error: ', err)\n console.log('Phone Number: ', line)\n })\n }\n\n api.getMetadata((err, metadata) => {\n Cookies.set(cookieName, metadata, { expires: 1 });\n console.log('Meta-data: ', metadata)\n });\n\n api.isSEMSession((err, isSEMSession) => {\n console.log('Is SEM Session: ', isSEMSession /*true or false*/);\n });\n });\n }\n }\n}\n\n\nexport default PhoneSwap;\n\n\n\n// WEBPACK FOOTER //\n// ./src/tc/js/components/PhoneSwap.js"],"sourceRoot":""}