{"version":3,"file":"./modules/Squarelovin.xxxxxxxx.js","mappings":"mIAAA,MAAMA,EAAiB,8BAER,MAAMC,EACjB,YAAOC,CAAMC,EAAmBH,GAC5BI,MAAMC,KAAKC,SAASC,iBAAiBJ,IAAWK,QAAQC,IAAuBA,EAAKC,QAAQC,oBAAmBC,SAASC,IACpH,IAAIZ,EAAYY,GAChBA,EAAQH,QAAQC,kBAAoB,MAAM,GAElD,CAEA,WAAAG,CAAmBD,GAAA,KAAAA,QAAAA,EACfE,KAAKC,MACT,CAEQ,IAAAA,GACJ,IAAIC,EAAW,IAAIC,sBAAsBC,IACrCA,EAAQP,SAAQQ,IACPA,EAAMC,iBAEXN,KAAKO,wBACLL,EAASM,aAAY,GACvB,IAGNN,EAASO,QAAQT,KAAKF,QAC1B,CAEQ,qBAAAS,GACAhB,SAASmB,eAAe,2BAE0B,SAAlDV,KAAKF,QAAQa,aAAa,oBAC1BX,KAAKY,yBACGrB,SAASmB,eAAe,0BAChCV,KAAKa,iCAEb,CAEQ,sBAAAD,GACJ,MAAME,EAAgBd,KAAKe,sBAC3BD,EAAcE,KAAO,aACrBF,EAAcG,aAAa,QAAS,wCACpCH,EAAcG,aAAa,mBAAoB,WAC/CH,EAAcG,aAAa,2BAA4B,4BACvDH,EAAcG,aAAa,kBAAmB,SAC9C1B,SAAS2B,KAAKC,YAAYL,EAC9B,CAEQ,mBAAAC,GACJ,MAAMD,EAAgBvB,SAAS6B,cAAc,UAM7C,OALAN,EAAcO,GAAK,wBACnBP,EAAcQ,UAAY,iFACXtB,KAAKF,QAAQa,aAAa,8GAGlCG,CACX,CAEQ,8BAAAD,GACJ,MAAMC,EAAgBd,KAAKe,sBAC3BxB,SAAS2B,KAAKC,YAAYL,EAC9B,EAgBA5B,EAAYC,MAAMF,E,gDC1EtB,Q,QAA0B,O","sources":["webpack:///./modules/Squarelovin/Squarelovin.ts","webpack:///./modules/Squarelovin/index.ts"],"sourcesContent":["const moduleSelector = '[data-module=\"Squarelovin\"]';\r\n\r\nexport default class Squarelovin {\r\n static setup(selector: string = moduleSelector): void {\r\n Array.from(document.querySelectorAll(selector)).filter((node: HTMLElement) => !node.dataset.moduleInitialized).forEach((element: HTMLElement) => {\r\n new Squarelovin(element);\r\n element.dataset.moduleInitialized = 'true';\r\n });\r\n }\r\n\r\n constructor(public element: HTMLElement) {\r\n this.init();\r\n }\r\n\r\n private init() {\r\n let observer = new IntersectionObserver((entries) => {\r\n entries.forEach(entry => {\r\n if (!entry.isIntersecting) return;\r\n\r\n this.initSquarelovinScript();\r\n observer.disconnect();\r\n });\r\n });\r\n\r\n observer.observe(this.element);\r\n }\r\n\r\n private initSquarelovinScript() {\r\n if (document.getElementById(\"nx-squarelovin-script\"))\r\n return;\r\n if (this.element.getAttribute(\"data-cmp-enabled\") === \"true\") {\r\n this.createCmpScriptElement();\r\n } else if (!document.getElementById(\"nx-squarelovin-script\")) {\r\n this.createSquarelovinScriptElement();\r\n }\r\n }\r\n\r\n private createCmpScriptElement() {\r\n const scriptElement = this.createScriptElement();\r\n scriptElement.type = \"text/plain\";\r\n scriptElement.setAttribute(\"class\", \"cmplazyload cmplazyload__squarelovin\");\r\n scriptElement.setAttribute(\"data-cmp-preview\", \"600x600\");\r\n scriptElement.setAttribute(\"data-cmp-preview-connect\", \"cmplazyload__squarelovin\");\r\n scriptElement.setAttribute(\"data-cmp-vendor\", \"c8284\");\r\n document.body.appendChild(scriptElement);\r\n }\r\n\r\n private createScriptElement() {\r\n const scriptElement = document.createElement(\"script\");\r\n scriptElement.id = \"nx-squarelovin-script\";\r\n scriptElement.innerHTML = `const scriptElement = document.createElement(\"script\");\r\nscriptElement.src = \"${this.element.getAttribute(\"data-squarelovin-script-url\")}\";\r\nscriptElement.type = \"module\";\r\ndocument.body.appendChild(scriptElement);`;\r\n return scriptElement;\r\n }\r\n\r\n private createSquarelovinScriptElement() {\r\n const scriptElement = this.createScriptElement()\r\n document.body.appendChild(scriptElement);\r\n }\r\n}\r\n\r\n// Hot Module Replacement\r\nif (module.hot) {\r\n let nodesCache: HMRNodes[] = Array.from(document.querySelectorAll(moduleSelector)).map((element: Node) => ({ nodeToReplace: element, nodeOrigin: element.cloneNode(true) }));\r\n\r\n Squarelovin.setup(moduleSelector);\r\n\r\n module.hot.accept(() => {\r\n Squarelovin.setup(moduleSelector);\r\n });\r\n module.hot.dispose(() => {\r\n nodesCache.forEach(({ nodeToReplace, nodeOrigin }) => { nodeToReplace = nodeToReplace.parentElement.replaceChild(nodeOrigin.cloneNode(true), nodeToReplace) });\r\n });\r\n} else {\r\n Squarelovin.setup(moduleSelector);\r\n}\r\n","import Squarelovin from \"./Squarelovin\";\r\n\r\nexport default Squarelovin;"],"names":["moduleSelector","Squarelovin","setup","selector","Array","from","document","querySelectorAll","filter","node","dataset","moduleInitialized","forEach","element","constructor","this","init","observer","IntersectionObserver","entries","entry","isIntersecting","initSquarelovinScript","disconnect","observe","getElementById","getAttribute","createCmpScriptElement","createSquarelovinScriptElement","scriptElement","createScriptElement","type","setAttribute","body","appendChild","createElement","id","innerHTML"],"sourceRoot":""}