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IAAO,GAAE1C,cAA2B5D,IAAKyF,IAChDZ,EAAO0B,MAAQvC,EAEfH,EAAW2C,gBAAgB3B,GAC3B1H,EAAI,oBAAoB,GAE5B,CAIEsJ,KAyBF,OAtBA9B,EAAQvF,KAAK,aAAc,CAAEsF,eAC7BvH,EAAI,oBAQJuJ,YANAzJ,eAAe0J,IACb,MAAMC,QAAsB9C,IAC5Ba,EAAQvF,KAAK,aAAc,CAAEsF,WAAYkC,IACzCF,WAAWC,EAAmBhE,EAA2BiE,GAC3D,GAE8BjE,EAA2B+B,IAalD,CACLmC,cANoBA,IAAMlC,EAAQpG,IAAU,iBAO5CuI,QAbF,WACE3J,EAAI,cAEJ0G,EAAW2C,iBACb,EAUEO,sBAP6BC,GAC7BrC,EAAQpG,IAAY,wBAAyB,CAAEyI,WAO/CC,cANoBA,IAAMtC,EAAQpG,IAAc,iBAQpD,C","sources":["webpack://supersetEmbeddedSdk/webpack/universalModuleDefinition","webpack://supersetEmbeddedSdk/./node_modules/@superset-ui/switchboard/esm/switchboard.js","webpack://supersetEmbeddedSdk/webpack/bootstrap","webpack://supersetEmbeddedSdk/webpack/runtime/define property getters","webpack://supersetEmbeddedSdk/webpack/runtime/harmony module decorator","webpack://supersetEmbeddedSdk/webpack/runtime/hasOwnProperty shorthand","webpack://supersetEmbeddedSdk/webpack/runtime/make namespace object","webpack://supersetEmbeddedSdk/./src/const.ts","webpack://supersetEmbeddedSdk/./node_modules/jwt-decode/build/jwt-decode.esm.js","webpack://supersetEmbeddedSdk/./src/guestTokenRefresh.ts","webpack://supersetEmbeddedSdk/./src/index.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([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"supersetEmbeddedSdk\"] = factory();\n\telse\n\t\troot[\"supersetEmbeddedSdk\"] = factory();\n})(globalThis, () => {\nreturn ","(function () {var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;enterModule && enterModule(module);})();var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {return a;};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/**\n * A utility for communications between an iframe and its parent, used by the Superset embedded SDK.\n * This builds useful patterns on top of the basic functionality offered by MessageChannel.\n *\n * Both windows instantiate a Switchboard, passing in their MessagePorts.\n * Calling methods on the switchboard causes messages to be sent through the channel.\n */\nexport class Switchboard {\n\n\n\n\n\n\n // used to make unique ids\n\n\n\n\n constructor({ port, name = 'switchboard', debug = false }) {this.port = void 0;this.name = void 0;this.methods = {};this.incrementor = 1;this.debugMode = void 0;\n this.port = port;\n this.name = name;\n this.debugMode = debug;\n\n port.addEventListener('message', async (event) => {\n this.log('message received', event);\n const message = event.data;\n if (isGet(message)) {\n // find the method, call it, and reply with the result\n this.port.postMessage(await this.getMethodResult(message));\n } else if (isEmit(message)) {\n const { method, args } = message;\n // Find the method and call it, but no result necessary.\n // Should this multicast to a set of listeners?\n // Maybe, but that requires writing a bunch more code\n // and I haven't found a need for it yet.\n const executor = this.methods[method];\n if (executor) {\n executor(args);\n }\n }\n });\n }\n\n async getMethodResult({\n messageId,\n method,\n args })\n {\n const executor = this.methods[method];\n if (executor == null) {\n return {\n switchboardAction: Actions.ERROR,\n messageId,\n error: `[${this.name}] Method \"${method}\" is not defined` };\n\n }\n try {\n const result = await executor(args);\n return {\n switchboardAction: Actions.REPLY,\n messageId,\n result };\n\n } catch (err) {\n this.logError(err);\n return {\n switchboardAction: Actions.ERROR,\n messageId,\n error: `[${this.name}] Method \"${method}\" threw an error` };\n\n }\n }\n\n /**\n * Defines a method that can be \"called\" from the other side by sending an event.\n */\n defineMethod(methodName, executor) {\n this.methods[methodName] = executor;\n }\n\n /**\n * Calls a method registered on the other side, and returns the result.\n *\n * How this is accomplished:\n * This switchboard sends a \"get\" message over the channel describing which method to call with which arguments.\n * The other side's switchboard finds a method with that name, and calls it with the arguments.\n * It then packages up the returned value into a \"reply\" message, sending it back to us across the channel.\n * This switchboard has attached a listener on the channel, which will resolve with the result when a reply is detected.\n *\n * Instead of an arguments list, arguments are supplied as a map.\n *\n * @param method the name of the method to call\n * @param args arguments that will be supplied. Must be serializable, no functions or other nonense.\n * @returns whatever is returned from the method\n */\n get(method, args = undefined) {\n return new Promise((resolve, reject) => {\n // In order to \"call a method\" on the other side of the port,\n // we will send a message with a unique id\n const messageId = this.getNewMessageId();\n // attach a new listener to our port, and remove it when we get a response\n const listener = (event) => {\n const message = event.data;\n if (message.messageId !== messageId) return;\n this.port.removeEventListener('message', listener);\n if (isReply(message)) {\n resolve(message.result);\n } else {\n const errStr = isError(message) ?\n message.error :\n 'Unexpected response message';\n reject(new Error(errStr));\n }\n };\n this.port.addEventListener('message', listener);\n this.port.start();\n const message = {\n switchboardAction: Actions.GET,\n method,\n messageId,\n args };\n\n this.port.postMessage(message);\n });\n }\n\n /**\n * Emit calls a method on the other side just like get does.\n * But emit doesn't wait for a response, it just sends and forgets.\n *\n * @param method\n * @param args\n */\n emit(method, args = undefined) {\n const message = {\n switchboardAction: Actions.EMIT,\n method,\n args };\n\n this.port.postMessage(message);\n }\n\n start() {\n this.port.start();\n }\n\n log(...args) {\n if (this.debugMode) {\n console.debug(`[${this.name}]`, ...args);\n }\n }\n\n logError(...args) {\n console.error(`[${this.name}]`, ...args);\n }\n\n getNewMessageId() {\n // eslint-disable-next-line no-plusplus\n return `m_${this.name}_${this.incrementor++}`;\n } // @ts-ignore\n __reactstandin__regenerateByEval(key, code) {// @ts-ignore\n this[key] = eval(code);}}\n\n\n// Each message we send on the channel specifies an action we want the other side to cooperate with.\nvar Actions;\n\n\n\n\n\n\n// helper types/functions for making sure wires don't get crossed\n(function (Actions) {Actions[\"GET\"] = \"get\";Actions[\"REPLY\"] = \"reply\";Actions[\"EMIT\"] = \"emit\";Actions[\"ERROR\"] = \"error\";})(Actions || (Actions = {}));\n\n\n\n\n\n\n\n\n\n\n\nfunction isGet(message) {\n return message.switchboardAction === Actions.GET;\n}\n\n\n\n\n\n\n\nfunction isReply(message) {\n return message.switchboardAction === Actions.REPLY;\n}\n\n\n\n\n\n\n\nfunction isEmit(message) {\n return message.switchboardAction === Actions.EMIT;\n}\n\n\n\n\n\n\n\nfunction isError(message) {\n return message.switchboardAction === Actions.ERROR;\n};(function () {var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;if (!reactHotLoader) {return;}reactHotLoader.register(Switchboard, \"Switchboard\", \"/Users/aaron/work/superset/superset-frontend/packages/superset-ui-switchboard/src/switchboard.ts\");reactHotLoader.register(isGet, \"isGet\", \"/Users/aaron/work/superset/superset-frontend/packages/superset-ui-switchboard/src/switchboard.ts\");reactHotLoader.register(isReply, \"isReply\", \"/Users/aaron/work/superset/superset-frontend/packages/superset-ui-switchboard/src/switchboard.ts\");reactHotLoader.register(isEmit, \"isEmit\", \"/Users/aaron/work/superset/superset-frontend/packages/superset-ui-switchboard/src/switchboard.ts\");reactHotLoader.register(isError, \"isError\", \"/Users/aaron/work/superset/superset-frontend/packages/superset-ui-switchboard/src/switchboard.ts\");})();;(function () {var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;leaveModule && leaveModule(module);})();","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\tid: moduleId,\n\t\tloaded: false,\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Flag the module as loaded\n\tmodule.loaded = true;\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\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__.hmd = (module) => {\n\tmodule = Object.create(module);\n\tif (!module.children) module.children = [];\n\tObject.defineProperty(module, 'exports', {\n\t\tenumerable: true,\n\t\tset: () => {\n\t\t\tthrow new Error('ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ' + module.id);\n\t\t}\n\t});\n\treturn module;\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};","/*\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nexport const IFRAME_COMMS_MESSAGE_TYPE = \"__embedded_comms__\";\nexport const DASHBOARD_UI_FILTER_CONFIG_URL_PARAM_KEY: { [index: string]: any } = {\n visible: \"show_filters\",\n expanded: \"expand_filters\",\n}\n","function e(e){this.message=e}e.prototype=new Error,e.prototype.name=\"InvalidCharacterError\";var r=\"undefined\"!=typeof window&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,\"\");if(t.length%4==1)throw new e(\"'atob' failed: The string to be decoded is not correctly encoded.\");for(var n,o,a=0,i=0,c=\"\";o=t.charAt(i++);~o&&(n=a%4?64*n+o:o,a++%4)?c+=String.fromCharCode(255&n>>(-2*a&6)):0)o=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\".indexOf(o);return c};function t(e){var t=e.replace(/-/g,\"+\").replace(/_/g,\"/\");switch(t.length%4){case 0:break;case 2:t+=\"==\";break;case 3:t+=\"=\";break;default:throw\"Illegal base64url string!\"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,r){var t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t=\"0\"+t),\"%\"+t})))}(t)}catch(e){return r(t)}}function n(e){this.message=e}function o(e,r){if(\"string\"!=typeof e)throw new n(\"Invalid token specified\");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(\".\")[o]))}catch(e){throw new n(\"Invalid token specified: \"+e.message)}}n.prototype=new Error,n.prototype.name=\"InvalidTokenError\";export default o;export{n as InvalidTokenError};\n//# sourceMappingURL=jwt-decode.esm.js.map\n","/**\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\nimport jwt_decode from \"jwt-decode\";\n\nexport const REFRESH_TIMING_BUFFER_MS = 5000 // refresh guest token early to avoid failed superset requests\nexport const MIN_REFRESH_WAIT_MS = 10000 // avoid blasting requests as fast as the cpu can handle\nexport const DEFAULT_TOKEN_EXP_MS = 300000 // (5 min) used only when parsing guest token exp fails\n\n// when do we refresh the guest token?\nexport function getGuestTokenRefreshTiming(currentGuestToken: string) {\n const parsedJwt = jwt_decode>(currentGuestToken);\n // if exp is int, it is in seconds, but Date() takes milliseconds\n const exp = new Date(/[^0-9\\.]/g.test(parsedJwt.exp) ? parsedJwt.exp : parseFloat(parsedJwt.exp) * 1000);\n const isValidDate = exp.toString() !== 'Invalid Date';\n const ttl = isValidDate ? Math.max(MIN_REFRESH_WAIT_MS, exp.getTime() - Date.now()) : DEFAULT_TOKEN_EXP_MS;\n return ttl - REFRESH_TIMING_BUFFER_MS;\n}\n","/*\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {\n DASHBOARD_UI_FILTER_CONFIG_URL_PARAM_KEY,\n IFRAME_COMMS_MESSAGE_TYPE\n} from './const';\n\n// We can swap this out for the actual switchboard package once it gets published\nimport { Switchboard } from '@superset-ui/switchboard';\nimport { getGuestTokenRefreshTiming } from './guestTokenRefresh';\n\n/**\n * The function to fetch a guest token from your Host App's backend server.\n * The Host App backend must supply an API endpoint\n * which returns a guest token with appropriate resource access.\n */\nexport type GuestTokenFetchFn = () => Promise;\n\nexport type UiConfigType = {\n hideTitle?: boolean\n hideTab?: boolean\n hideChartControls?: boolean\n filters?: {\n [key: string]: boolean | undefined\n visible?: boolean\n expanded?: boolean\n }\n urlParams?: {\n [key: string]: any\n }\n}\n\nexport type EmbedDashboardParams = {\n /** The id provided by the embed configuration UI in Superset */\n id: string\n /** The domain where Superset can be located, with protocol, such as: https://superset.example.com */\n supersetDomain: string\n /** The html element within which to mount the iframe */\n mountPoint: HTMLElement\n /** A function to fetch a guest token from the Host App's backend server */\n fetchGuestToken: GuestTokenFetchFn\n /** The dashboard UI config: hideTitle, hideTab, hideChartControls, filters.visible, filters.expanded **/\n dashboardUiConfig?: UiConfigType\n /** Are we in debug mode? */\n debug?: boolean\n /** The iframe title attribute */\n iframeTitle?: string\n /** additional iframe sandbox attributes ex (allow-top-navigation, allow-popups-to-escape-sandbox) **/\n iframeSandboxExtras?: string[]\n}\n\nexport type Size = {\n width: number, height: number\n}\n\nexport type EmbeddedDashboard = {\n getScrollSize: () => Promise\n unmount: () => void\n getDashboardPermalink: (anchor: string) => Promise\n getActiveTabs: () => Promise\n}\n\n/**\n * Embeds a Superset dashboard into the page using an iframe.\n */\nexport async function embedDashboard({\n id,\n supersetDomain,\n mountPoint,\n fetchGuestToken,\n dashboardUiConfig,\n debug = false,\n iframeTitle = \"Embedded Dashboard\",\n iframeSandboxExtras = []\n}: EmbedDashboardParams): Promise {\n function log(...info: unknown[]) {\n if (debug) {\n console.debug(`[superset-embedded-sdk][dashboard ${id}]`, ...info);\n }\n }\n\n log('embedding');\n\n if (supersetDomain.endsWith(\"/\")) {\n supersetDomain = supersetDomain.slice(0, -1);\n }\n\n function calculateConfig() {\n let configNumber = 0\n if(dashboardUiConfig) {\n if(dashboardUiConfig.hideTitle) {\n configNumber += 1\n }\n if(dashboardUiConfig.hideTab) {\n configNumber += 2\n }\n if(dashboardUiConfig.hideChartControls) {\n configNumber += 8\n }\n }\n return configNumber\n }\n\n async function mountIframe(): Promise {\n return new Promise(resolve => {\n const iframe = document.createElement('iframe');\n const dashboardConfigUrlParams = dashboardUiConfig ? {uiConfig: `${calculateConfig()}`} : undefined;\n const filterConfig = dashboardUiConfig?.filters || {}\n const filterConfigKeys = Object.keys(filterConfig)\n const filterConfigUrlParams = Object.fromEntries(filterConfigKeys.map(\n key => [DASHBOARD_UI_FILTER_CONFIG_URL_PARAM_KEY[key], filterConfig[key]]))\n\n // Allow url query parameters from dashboardUiConfig.urlParams to override the ones from filterConfig\n const urlParams = {...dashboardConfigUrlParams, ...filterConfigUrlParams, ...dashboardUiConfig?.urlParams}\n const urlParamsString = Object.keys(urlParams).length ? '?' + new URLSearchParams(urlParams).toString() : ''\n\n // set up the iframe's sandbox configuration\n iframe.sandbox.add(\"allow-same-origin\"); // needed for postMessage to work\n iframe.sandbox.add(\"allow-scripts\"); // obviously the iframe needs scripts\n iframe.sandbox.add(\"allow-presentation\"); // for fullscreen charts\n iframe.sandbox.add(\"allow-downloads\"); // for downloading charts as image\n iframe.sandbox.add(\"allow-forms\"); // for forms to submit\n iframe.sandbox.add(\"allow-popups\"); // for exporting charts as csv\n // additional sandbox props\n iframeSandboxExtras.forEach((key: string) => {\n iframe.sandbox.add(key);\n });\n\n // add the event listener before setting src, to be 100% sure that we capture the load event\n iframe.addEventListener('load', () => {\n // MessageChannel allows us to send and receive messages smoothly between our window and the iframe\n // See https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API\n const commsChannel = new MessageChannel();\n const ourPort = commsChannel.port1;\n const theirPort = commsChannel.port2;\n\n // Send one of the message channel ports to the iframe to initialize embedded comms\n // See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage\n // we know the content window isn't null because we are in the load event handler.\n iframe.contentWindow!.postMessage(\n { type: IFRAME_COMMS_MESSAGE_TYPE, handshake: \"port transfer\" },\n supersetDomain,\n [theirPort],\n )\n log('sent message channel to the iframe');\n\n // return our port from the promise\n resolve(new Switchboard({ port: ourPort, name: 'superset-embedded-sdk', debug }));\n });\n iframe.src = `${supersetDomain}/embedded/${id}${urlParamsString}`;\n iframe.title = iframeTitle;\n //@ts-ignore\n mountPoint.replaceChildren(iframe);\n log('placed the iframe')\n });\n }\n\n const [guestToken, ourPort]: [string, Switchboard] = await Promise.all([\n fetchGuestToken(),\n mountIframe(),\n ]);\n\n ourPort.emit('guestToken', { guestToken });\n log('sent guest token');\n\n async function refreshGuestToken() {\n const newGuestToken = await fetchGuestToken();\n ourPort.emit('guestToken', { guestToken: newGuestToken });\n setTimeout(refreshGuestToken, getGuestTokenRefreshTiming(newGuestToken));\n }\n\n setTimeout(refreshGuestToken, getGuestTokenRefreshTiming(guestToken));\n\n function unmount() {\n log('unmounting');\n //@ts-ignore\n mountPoint.replaceChildren();\n }\n\n const getScrollSize = () => ourPort.get('getScrollSize');\n const getDashboardPermalink = (anchor: string) =>\n ourPort.get('getDashboardPermalink', { anchor });\n const getActiveTabs = () => ourPort.get('getActiveTabs')\n\n return {\n getScrollSize,\n unmount,\n getDashboardPermalink,\n getActiveTabs,\n };\n}\n"],"names":["root","factory","exports","module","define","amd","globalThis","enterModule","reactHotLoaderGlobal","undefined","__signature__","default","signature","a","Actions","reactHotLoader","leaveModule","Switchboard","constructor","port","name","debug","this","methods","incrementor","debugMode","addEventListener","async","event","log","message","data","isGet","postMessage","getMethodResult","isEmit","method","args","executor","messageId","switchboardAction","ERROR","error","result","REPLY","err","logError","defineMethod","methodName","get","Promise","resolve","reject","getNewMessageId","listener","removeEventListener","isReply","errStr","isError","Error","start","GET","emit","EMIT","console","__reactstandin__regenerateByEval","key","code","eval","register","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","id","loaded","__webpack_modules__","d","definition","o","Object","defineProperty","enumerable","hmd","create","children","set","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","DASHBOARD_UI_FILTER_CONFIG_URL_PARAM_KEY","visible","expanded","e","window","atob","bind","t","String","replace","length","n","i","c","charAt","fromCharCode","indexOf","decodeURIComponent","charCodeAt","toString","toUpperCase","getGuestTokenRefreshTiming","currentGuestToken","parsedJwt","header","JSON","parse","split","jwt_decode","exp","Date","test","parseFloat","Math","max","getTime","now","embedDashboard","supersetDomain","mountPoint","fetchGuestToken","dashboardUiConfig","iframeTitle","iframeSandboxExtras","info","calculateConfig","configNumber","hideTitle","hideTab","hideChartControls","endsWith","slice","guestToken","ourPort","all","iframe","document","createElement","dashboardConfigUrlParams","uiConfig","filterConfig","filters","filterConfigKeys","keys","urlParams","fromEntries","map","urlParamsString","URLSearchParams","sandbox","add","forEach","commsChannel","MessageChannel","port1","theirPort","port2","contentWindow","type","handshake","src","title","replaceChildren","mountIframe","setTimeout","refreshGuestToken","newGuestToken","getScrollSize","unmount","getDashboardPermalink","anchor","getActiveTabs"],"sourceRoot":""}