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A,UAAWoB,EAAO,YAAEhB,EAAW,aAAEE,EAAY,MAAEL,EAAK,sBAAEQ,GAA0BT,GACjFqB,EAAUC,GAAaV,EAAcX,GACtCsB,EAAcC,OAAOC,WAC3BrB,EAAYsB,MAAMC,KAAO,GAAGN,KAC5Bf,EAAaoB,MAAMC,KAAO,GAAGL,KACzBC,EAAcd,EACdW,EAAQQ,UAAUC,OAAO,2BAGzBT,EAAQQ,UAAUE,IAAI,0BAC1B,EAESC,EAA4B,KACrC,MAAMC,EAAaC,SAASC,iBAAiB,oBAC7C,GAAIF,EAAWG,OAAQ,CACnB,MAAMC,EAAkBC,MAAMC,KAAKN,GAC9BhB,KAAKhB,GAAcD,EAAoBC,KACvCuC,QAAQvC,QAA4BwC,IAAdxC,IAC3BoC,EAAgBK,QAAQtB,GACxBK,OAAOkB,iBAAiB,UAAU,KAC9BN,EAAgBK,QAAQtB,EAAa,GAE7C,G,MAEkB,oBAAXK,QACPS,SAASS,iBAAiB,mBAAoBX,G","sources":["webpack://tmv2-components/webpack/universalModuleDefinition","webpack://tmv2-components/webpack/bootstrap","webpack://tmv2-components/webpack/runtime/define property getters","webpack://tmv2-components/webpack/runtime/hasOwnProperty shorthand","webpack://tmv2-components/webpack/runtime/make namespace object","webpack://tmv2-components/./src/ratioContainer/ratioContainer.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"ratiocontainer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ratiocontainer\"] = factory();\n\telse\n\t\troot[\"ratiocontainer\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export const initializeContainer = (container) => {\r\n const ratio = container.getAttribute(\"data-ratio\");\r\n const widthToSwitchToColumnAttr = container.getAttribute(\"data-widthToSwitchToColumn\");\r\n const leftElement = container.querySelector(\".ratio-container__left\");\r\n const rightElement = container.querySelector(\".ratio-container__right\");\r\n if (!ratio || !widthToSwitchToColumnAttr || !leftElement || !rightElement) {\r\n console.error(\"Missing or invalid attributes/elements for ratio-container:\", container);\r\n return undefined;\r\n }\r\n const widthToSwitchToColumn = parseInt(widthToSwitchToColumnAttr, 10);\r\n if (isNaN(widthToSwitchToColumn)) {\r\n console.error(\"Invalid widthToSwitchToColumn value:\", container);\r\n return undefined;\r\n }\r\n return {\r\n container,\r\n leftElement,\r\n rightElement,\r\n ratio,\r\n widthToSwitchToColumn,\r\n };\r\n};\r\nexport const getFlexValues = (ratio) => {\r\n const [leftRatio, rightRatio] = ratio.split(\":\").map(Number);\r\n const total = leftRatio + rightRatio;\r\n return [(leftRatio / total) * 100, (rightRatio / total) * 100];\r\n};\r\nexport const updateLayout = (container) => {\r\n const { container: element, leftElement, rightElement, ratio, widthToSwitchToColumn } = container;\r\n const [leftFlex, rightFlex] = getFlexValues(ratio);\r\n const windowWidth = window.innerWidth;\r\n leftElement.style.flex = `${leftFlex}%`;\r\n rightElement.style.flex = `${rightFlex}%`;\r\n if (windowWidth > widthToSwitchToColumn) {\r\n element.classList.remove(\"ratio-container__column\");\r\n }\r\n else {\r\n element.classList.add(\"ratio-container__column\");\r\n }\r\n};\r\nexport const initializeRatioContainers = () => {\r\n const containers = document.querySelectorAll(\".ratio-container\");\r\n if (containers.length) {\r\n const ratioContainers = Array.from(containers)\r\n .map((container) => initializeContainer(container))\r\n .filter((container) => container !== undefined);\r\n ratioContainers.forEach(updateLayout);\r\n window.addEventListener(\"resize\", () => {\r\n ratioContainers.forEach(updateLayout);\r\n });\r\n }\r\n};\r\nif (typeof window !== \"undefined\") {\r\n document.addEventListener(\"DOMContentLoaded\", initializeRatioContainers);\r\n}\r\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","initializeContainer","container","ratio","getAttribute","widthToSwitchToColumnAttr","leftElement","querySelector","rightElement","console","error","widthToSwitchToColumn","parseInt","isNaN","getFlexValues","leftRatio","rightRatio","split","map","Number","total","updateLayout","element","leftFlex","rightFlex","windowWidth","window","innerWidth","style","flex","classList","remove","add","initializeRatioContainers","containers","document","querySelectorAll","length","ratioContainers","Array","from","filter","undefined","forEach","addEventListener"],"sourceRoot":""}