{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./app/frontend/packs/unit-adjustments.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","getBoundingClientRect","node","start","Date","now","Promise","resolve","requestAnimationFrame","check","rect","ready","width","height","elapsed","getAttribute","async","adjustIframes","content","document","querySelectorAll","iframes","iframe","contentWidth","offsetWidth","ratio","isNaN","setAttribute","applyAdjustments","imgs","img","style","adjustImages","adjustInteractiveContent","viz","getElementById","resizeObserver","ResizeObserver","entries","observe","watchInteractiveContent","setTimeout","contentArticleDiv","mainPanel","unitContent","querySelector","unitHeading","articleWidth","panelWidth","contentHeight","headingHeight","resizeTimer","addEventListener","window","clearTimeout"],"mappings":"aACE,IAAIA,EAAmB,CAAC,EAGxB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,CAAC,GAUX,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,OACf,CAIAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,GAEhE,EAGAZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,GACvD,EAOArB,EAAoBsB,EAAI,SAASD,EAAO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CE,aAAaH,GACbA,EAAcV,YAAW,KACvBxB,IACAgB,GAA0B,GACzB,IAAI,G","file":"js/unit-adjustments-c9db040b8cac650f341e.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/packs/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 865);\n","// Wait for getBoundingClientRect to return a non-zero rect\nfunction getBoundingClientRect(node) {\n const start = Date.now();\n return new Promise((resolve) => {\n function check() {\n const rect = node.getBoundingClientRect();\n const ready = rect.width > 0 && rect.height > 0;\n const elapsed = Date.now() - start;\n if (ready || elapsed > 5000) {\n const height = node.getAttribute('height');\n const width = node.getAttribute('width');\n\n if(height && width) {\n resolve({height: height, width: width});\n } else {\n resolve(rect);\n }\n return;\n }\n requestAnimationFrame(check);\n }\n requestAnimationFrame(check);\n });\n}\n\nasync function adjustIframes() {\n const content = document.querySelectorAll('.unit-content')[0];\n if (!content) {\n return;\n }\n const iframes = content.querySelectorAll('iframe');\n\n for (const iframe of iframes) {\n const { height, width } = await getBoundingClientRect(iframe);\n const contentWidth = content.offsetWidth;\n const ratio = height / width;\n if (!isNaN(ratio)) {\n iframe.setAttribute('width', contentWidth);\n iframe.setAttribute('height', contentWidth * ratio);\n }\n }\n}\n\nfunction adjustImages() {\n const content = document.querySelectorAll('.unit-content')[0];\n const imgs = content.querySelectorAll('img');\n\n for (const img of imgs) {\n if (img.style.height) {\n img.style.height = 'unset';\n }\n }\n}\n\nfunction applyAdjustments() {\n if(document.querySelectorAll('.unit-content')[0].offsetWidth > 0) {\n adjustImages();\n adjustIframes();\n adjustInteractiveContent();\n watchInteractiveContent();\n } else {\n setTimeout(applyAdjustments, 100);\n }\n}\n\n// Similar to adjustIframes, but for interactive content,\n// where the iframe takes up the majority of the space.\n// We manually calculate the width/height and set it on the tableau authoring web compoent\n// which then passes those values to the iframe it manages.\nexport async function adjustInteractiveContent() {\n const viz = document.getElementById('embedded-content');\n const contentArticleDiv = document.getElementById(\"th-content-article\");\n const mainPanel = document.getElementById(\"th-main-panel\");\n const unitContent = document.querySelector(\".unit-content-container\");\n const unitHeading = document.querySelector(\".th-content-unit-heading\");\n const padding = 5;\n if (viz && contentArticleDiv && mainPanel && unitContent && unitHeading) {\n const { width: articleWidth } = await getBoundingClientRect(contentArticleDiv);\n const { width: panelWidth } = await getBoundingClientRect(mainPanel);\n const { height: contentHeight } = await getBoundingClientRect(unitContent);\n const { height: headingHeight } = await getBoundingClientRect(unitHeading);\n viz.width = panelWidth - articleWidth;\n viz.height = contentHeight + headingHeight - padding;\n }\n}\n\nfunction watchInteractiveContent() {\n const viz = document.getElementById('embedded-content');\n const resizeObserver = new ResizeObserver((entries) => {\n adjustInteractiveContent();\n });\n\n if (viz) {\n resizeObserver.observe(viz);\n }\n}\n\nlet resizeTimer;\n\ndocument.addEventListener('DOMContentLoaded', () => {\n applyAdjustments();\n});\n\nwindow.addEventListener('resize', () => {\n clearTimeout(resizeTimer);\n resizeTimer = setTimeout(() => {\n adjustIframes();\n adjustInteractiveContent();\n }, 250);\n});\n"],"sourceRoot":""}