{"version":3,"file":"js/application-0bf41c54c3bfeb780fa6.js","sources":["webpack:///webpack/bootstrap","webpack:///./app/javascript/controllers sync _controller\\.js$","webpack:///./app/javascript/controllers/index.js","webpack:///./app/javascript/controllers/reveal_controller.js","webpack:///./app/javascript/controllers/select_toggle_controller.js","webpack:///./app/javascript/controllers/stepper_controller.js","webpack:///./app/javascript/packs/application.js","webpack:///./node_modules/@babel/runtime/regenerator/index.js","webpack:///./node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable.js","webpack:///./node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable_stream_source_element.js","webpack:///./node_modules/@hotwired/turbo-rails/app/javascript/turbo/index.js","webpack:///./node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js","webpack:///./node_modules/@stimulus/core/dist/action.js","webpack:///./node_modules/@stimulus/core/dist/action_descriptor.js","webpack:///./node_modules/@stimulus/core/dist/application.js","webpack:///./node_modules/@stimulus/core/dist/binding.js","webpack:///./node_modules/@stimulus/core/dist/binding_observer.js","webpack:///./node_modules/@stimulus/core/dist/blessing.js","webpack:///./node_modules/@stimulus/core/dist/class_map.js","webpack:///./node_modules/@stimulus/core/dist/class_properties.js","webpack:///./node_modules/@stimulus/core/dist/context.js","webpack:///./node_modules/@stimulus/core/dist/controller.js","webpack:///./node_modules/@stimulus/core/dist/data_map.js","webpack:///./node_modules/@stimulus/core/dist/definition.js","webpack:///./node_modules/@stimulus/core/dist/dispatcher.js","webpack:///./node_modules/@stimulus/core/dist/event_listener.js","webpack:///./node_modules/@stimulus/core/dist/guide.js","webpack:///./node_modules/@stimulus/core/dist/index.js","webpack:///./node_modules/@stimulus/core/dist/inheritable_statics.js","webpack:///./node_modules/@stimulus/core/dist/module.js","webpack:///./node_modules/@stimulus/core/dist/router.js","webpack:///./node_modules/@stimulus/core/dist/schema.js","webpack:///./node_modules/@stimulus/core/dist/scope.js","webpack:///./node_modules/@stimulus/core/dist/scope_observer.js","webpack:///./node_modules/@stimulus/core/dist/selectors.js","webpack:///./node_modules/@stimulus/core/dist/string_helpers.js","webpack:///./node_modules/@stimulus/core/dist/target_properties.js","webpack:///./node_modules/@stimulus/core/dist/target_set.js","webpack:///./node_modules/@stimulus/core/dist/value_observer.js","webpack:///./node_modules/@stimulus/core/dist/value_properties.js","webpack:///./node_modules/@stimulus/multimap/dist/index.js","webpack:///./node_modules/@stimulus/multimap/dist/indexed_multimap.js","webpack:///./node_modules/@stimulus/multimap/dist/multimap.js","webpack:///./node_modules/@stimulus/multimap/dist/set_operations.js","webpack:///./node_modules/@stimulus/mutation-observers/dist/attribute_observer.js","webpack:///./node_modules/@stimulus/mutation-observers/dist/element_observer.js","webpack:///./node_modules/@stimulus/mutation-observers/dist/index.js","webpack:///./node_modules/@stimulus/mutation-observers/dist/string_map_observer.js","webpack:///./node_modules/@stimulus/mutation-observers/dist/token_list_observer.js","webpack:///./node_modules/@stimulus/mutation-observers/dist/value_list_observer.js","webpack:///./node_modules/@stimulus/webpack-helpers/dist/index.js","webpack:///./node_modules/regenerator-runtime/runtime.js","webpack:///./node_modules/stimulus/index.js","webpack:///./node_modules/stimulus/webpack-helpers.js"],"sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t};\n\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t\"application\": 0\n \t};\n\n\n\n \t// script path function\n \tfunction jsonpScriptSrc(chunkId) {\n \t\treturn __webpack_require__.p + \"js/\" + ({}[chunkId]||chunkId) + \"-\" + {\"0\":\"cdc0b7333b8832904bc5\"}[chunkId] + \".chunk.js\"\n \t}\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 \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId) {\n \t\tvar promises = [];\n\n\n \t\t// JSONP chunk loading for javascript\n\n \t\tvar installedChunkData = installedChunks[chunkId];\n \t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n \t\t\t// a Promise means \"currently loading\".\n \t\t\tif(installedChunkData) {\n \t\t\t\tpromises.push(installedChunkData[2]);\n \t\t\t} else {\n \t\t\t\t// setup Promise in chunk cache\n \t\t\t\tvar promise = new Promise(function(resolve, reject) {\n \t\t\t\t\tinstalledChunkData = installedChunks[chunkId] = [resolve, reject];\n \t\t\t\t});\n \t\t\t\tpromises.push(installedChunkData[2] = promise);\n\n \t\t\t\t// start chunk loading\n \t\t\t\tvar script = document.createElement('script');\n \t\t\t\tvar onScriptComplete;\n\n \t\t\t\tscript.charset = 'utf-8';\n \t\t\t\tscript.timeout = 120;\n \t\t\t\tif (__webpack_require__.nc) {\n \t\t\t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n \t\t\t\t}\n \t\t\t\tscript.src = jsonpScriptSrc(chunkId);\n\n \t\t\t\t// create error before stack unwound to get useful stacktrace later\n \t\t\t\tvar error = new Error();\n \t\t\t\tonScriptComplete = function (event) {\n \t\t\t\t\t// avoid mem leaks in IE.\n \t\t\t\t\tscript.onerror = script.onload = null;\n \t\t\t\t\tclearTimeout(timeout);\n \t\t\t\t\tvar chunk = installedChunks[chunkId];\n \t\t\t\t\tif(chunk !== 0) {\n \t\t\t\t\t\tif(chunk) {\n \t\t\t\t\t\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n \t\t\t\t\t\t\tvar realSrc = event && event.target && event.target.src;\n \t\t\t\t\t\t\terror.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';\n \t\t\t\t\t\t\terror.name = 'ChunkLoadError';\n \t\t\t\t\t\t\terror.type = errorType;\n \t\t\t\t\t\t\terror.request = realSrc;\n \t\t\t\t\t\t\tchunk[1](error);\n \t\t\t\t\t\t}\n \t\t\t\t\t\tinstalledChunks[chunkId] = undefined;\n \t\t\t\t\t}\n \t\t\t\t};\n \t\t\t\tvar timeout = setTimeout(function(){\n \t\t\t\t\tonScriptComplete({ type: 'timeout', target: script });\n \t\t\t\t}, 120000);\n \t\t\t\tscript.onerror = script.onload = onScriptComplete;\n \t\t\t\tdocument.head.appendChild(script);\n \t\t\t}\n \t\t}\n \t\treturn Promise.all(promises);\n \t};\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 \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./app/javascript/packs/application.js\");\n","var map = {\n\t\"./reveal_controller.js\": \"./app/javascript/controllers/reveal_controller.js\",\n\t\"./select_toggle_controller.js\": \"./app/javascript/controllers/select_toggle_controller.js\",\n\t\"./stepper_controller.js\": \"./app/javascript/controllers/stepper_controller.js\"\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = \"./app/javascript/controllers sync recursive _controller\\\\.js$\";","// Load all the controllers within this directory and all subdirectories.\n// Controller files must be named *_controller.js.\n\nimport { Application } from 'stimulus'\nimport { definitionsFromContext } from 'stimulus/webpack-helpers'\n\nconst application = Application.start()\nconst context = require.context('controllers', true, /_controller\\.js$/)\napplication.load(definitionsFromContext(context))\n","import { Controller } from 'stimulus'\n\nexport default class extends Controller {\n static targets = ['content']\n static classes = ['hidden']\n\n show () {\n this.contentTarget.classList.remove(this.hiddenClass)\n }\n\n hide () {\n this.contentTarget.classList.add(this.hiddenClass)\n }\n}\n","import { Controller } from 'stimulus'\n\nexport default class extends Controller {\n static targets = ['select', 'match', 'toggleable']\n\n connect () {\n this.toggle()\n }\n\n toggle () {\n const checkedOption = this.selectTarget.querySelector(':checked')\n const matchTargetIsSelected = checkedOption && checkedOption.isSameNode(this.matchTarget)\n this.toggleableTarget.hidden = !matchTargetIsSelected\n this.toggleableTarget.querySelectorAll('input').forEach(function (element) {\n element.disabled = !matchTargetIsSelected\n })\n }\n}\n","import { Controller } from 'stimulus'\n\nexport default class extends Controller {\n static targets = ['step', 'progress']\n static values = { step: Number }\n static classes = ['invalid']\n\n next (event) {\n if (this.isLastStep) {\n return\n }\n\n if (event.target.matches('form')) {\n return event.preventDefault()\n }\n\n if (this.validateCurrentStep()) {\n this.stepValue++\n }\n }\n\n previous () {\n this.stepValue--\n }\n\n validateCurrentStep (event) {\n let valid = true\n this.currentStep.querySelectorAll('input, select').forEach(element => {\n const formField = element.closest('.form-field')\n if (element.checkValidity()) {\n formField && formField.classList.remove(this.invalidClass)\n } else {\n formField && formField.classList.add(this.invalidClass)\n valid = false\n }\n })\n\n if (event && !valid) {\n event.preventDefault()\n event.stopPropagation()\n }\n\n return valid\n }\n\n stepValueChanged () {\n this.showCurrentStep()\n this.scrollIntoViewIfNeeded()\n this.updateProgress()\n }\n\n showCurrentStep () {\n this.stepTargets.forEach((element, step) => {\n element.hidden = step !== this.stepValue\n })\n }\n\n scrollIntoViewIfNeeded () {\n const isInView = this.currentStep.offsetTop > window.scrollY\n if (isInView) {\n return\n }\n\n this.currentStep.scrollIntoView({ behavior: 'smooth' })\n }\n\n updateProgress () {\n if (!this.hasProgressTarget) {\n return\n }\n\n this.progressTarget.style.width = `${(this.stepValue + 1) / this.stepTargets.length * 100}%`\n this.progressTarget.innerText = `Seite ${this.stepValue + 1}/${this.stepTargets.length}`\n }\n\n get currentStep () {\n return this.stepTargets.find(element => !element.hidden)\n }\n\n get isLastStep () {\n const lastStep = this.stepTargets[this.stepTargets.length - 1]\n return lastStep === this.currentStep\n }\n}\n","import '@hotwired/turbo-rails'\nimport 'controllers'\n","module.exports = require(\"regenerator-runtime\");\n","import _regeneratorRuntime from \"@babel/runtime/regenerator\";\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nvar consumer;\nexport function getConsumer() {\n return _getConsumer.apply(this, arguments);\n}\n\nfunction _getConsumer() {\n _getConsumer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {\n var _yield$import, createConsumer;\n\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (!consumer) {\n _context.next = 2;\n break;\n }\n\n return _context.abrupt(\"return\", consumer);\n\n case 2:\n _context.next = 4;\n return import(\"@rails/actioncable/src\");\n\n case 4:\n _yield$import = _context.sent;\n createConsumer = _yield$import.createConsumer;\n return _context.abrupt(\"return\", setConsumer(createConsumer()));\n\n case 7:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee);\n }));\n return _getConsumer.apply(this, arguments);\n}\n\nexport function setConsumer(newConsumer) {\n return consumer = newConsumer;\n}\nexport function subscribeTo(_x, _x2) {\n return _subscribeTo.apply(this, arguments);\n}\n\nfunction _subscribeTo() {\n _subscribeTo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(channel, mixin) {\n var _yield$getConsumer, subscriptions;\n\n return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return getConsumer();\n\n case 2:\n _yield$getConsumer = _context2.sent;\n subscriptions = _yield$getConsumer.subscriptions;\n return _context2.abrupt(\"return\", subscriptions.create(channel, mixin));\n\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2);\n }));\n return _subscribeTo.apply(this, arguments);\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nimport _regeneratorRuntime from \"@babel/runtime/regenerator\";\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nimport { connectStreamSource, disconnectStreamSource } from \"@hotwired/turbo\";\nimport { subscribeTo } from \"./cable\";\n\nvar TurboCableStreamSourceElement = /*#__PURE__*/function (_HTMLElement) {\n _inherits(TurboCableStreamSourceElement, _HTMLElement);\n\n var _super = _createSuper(TurboCableStreamSourceElement);\n\n function TurboCableStreamSourceElement() {\n _classCallCheck(this, TurboCableStreamSourceElement);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(TurboCableStreamSourceElement, [{\n key: \"connectedCallback\",\n value: function () {\n var _connectedCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n connectStreamSource(this);\n _context.next = 3;\n return subscribeTo(this.channel, {\n received: this.dispatchMessageEvent.bind(this)\n });\n\n case 3:\n this.subscription = _context.sent;\n\n case 4:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function connectedCallback() {\n return _connectedCallback.apply(this, arguments);\n }\n\n return connectedCallback;\n }()\n }, {\n key: \"disconnectedCallback\",\n value: function disconnectedCallback() {\n disconnectStreamSource(this);\n if (this.subscription) this.subscription.unsubscribe();\n }\n }, {\n key: \"dispatchMessageEvent\",\n value: function dispatchMessageEvent(data) {\n var event = new MessageEvent(\"message\", {\n data: data\n });\n return this.dispatchEvent(event);\n }\n }, {\n key: \"channel\",\n get: function get() {\n var channel = this.getAttribute(\"channel\");\n var signed_stream_name = this.getAttribute(\"signed-stream-name\");\n return {\n channel: channel,\n signed_stream_name: signed_stream_name\n };\n }\n }]);\n\n return TurboCableStreamSourceElement;\n}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));\n\ncustomElements.define(\"turbo-cable-stream-source\", TurboCableStreamSourceElement);","import \"./cable_stream_source_element\";\nimport * as Turbo from \"@hotwired/turbo\";\nexport { Turbo };\nimport * as cable from \"./cable\";\nexport { cable };","var _templateObject, _templateObject2;\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nimport _regeneratorRuntime from \"@babel/runtime/regenerator\";\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n/*\nTurbo 7.0.0-beta.5\nCopyright © 2021 Basecamp, LLC\n */\n(function () {\n if (window.Reflect === undefined || window.customElements === undefined || window.customElements.polyfillWrapFlushCallback) {\n return;\n }\n\n var BuiltInHTMLElement = HTMLElement;\n var wrapperForTheName = {\n 'HTMLElement': function HTMLElement() {\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\n }\n };\n window.HTMLElement = wrapperForTheName['HTMLElement'];\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\n HTMLElement.prototype.constructor = HTMLElement;\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\n})();\n\nvar submittersByForm = new WeakMap();\n\nfunction findSubmitterFromClickTarget(target) {\n var element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;\n var candidate = element ? element.closest(\"input, button\") : null;\n return (candidate === null || candidate === void 0 ? void 0 : candidate.type) == \"submit\" ? candidate : null;\n}\n\nfunction clickCaptured(event) {\n var submitter = findSubmitterFromClickTarget(event.target);\n\n if (submitter && submitter.form) {\n submittersByForm.set(submitter.form, submitter);\n }\n}\n\n(function () {\n if (\"SubmitEvent\" in window) return;\n addEventListener(\"click\", clickCaptured, true);\n Object.defineProperty(Event.prototype, \"submitter\", {\n get: function get() {\n if (this.type == \"submit\" && this.target instanceof HTMLFormElement) {\n return submittersByForm.get(this.target);\n }\n }\n });\n})();\n\nvar FrameLoadingStyle;\n\n(function (FrameLoadingStyle) {\n FrameLoadingStyle[\"eager\"] = \"eager\";\n FrameLoadingStyle[\"lazy\"] = \"lazy\";\n})(FrameLoadingStyle || (FrameLoadingStyle = {}));\n\nvar FrameElement = /*#__PURE__*/function (_HTMLElement) {\n _inherits(FrameElement, _HTMLElement);\n\n var _super = _createSuper(FrameElement);\n\n function FrameElement() {\n var _this;\n\n _classCallCheck(this, FrameElement);\n\n _this = _super.call(this);\n _this.loaded = Promise.resolve();\n _this.delegate = new FrameElement.delegateConstructor(_assertThisInitialized(_this));\n return _this;\n }\n\n _createClass(FrameElement, [{\n key: \"connectedCallback\",\n value: function connectedCallback() {\n this.delegate.connect();\n }\n }, {\n key: \"disconnectedCallback\",\n value: function disconnectedCallback() {\n this.delegate.disconnect();\n }\n }, {\n key: \"attributeChangedCallback\",\n value: function attributeChangedCallback(name) {\n if (name == \"loading\") {\n this.delegate.loadingStyleChanged();\n } else if (name == \"src\") {\n this.delegate.sourceURLChanged();\n } else {\n this.delegate.disabledChanged();\n }\n }\n }, {\n key: \"src\",\n get: function get() {\n return this.getAttribute(\"src\");\n },\n set: function set(value) {\n if (value) {\n this.setAttribute(\"src\", value);\n } else {\n this.removeAttribute(\"src\");\n }\n }\n }, {\n key: \"loading\",\n get: function get() {\n return frameLoadingStyleFromString(this.getAttribute(\"loading\") || \"\");\n },\n set: function set(value) {\n if (value) {\n this.setAttribute(\"loading\", value);\n } else {\n this.removeAttribute(\"loading\");\n }\n }\n }, {\n key: \"disabled\",\n get: function get() {\n return this.hasAttribute(\"disabled\");\n },\n set: function set(value) {\n if (value) {\n this.setAttribute(\"disabled\", \"\");\n } else {\n this.removeAttribute(\"disabled\");\n }\n }\n }, {\n key: \"autoscroll\",\n get: function get() {\n return this.hasAttribute(\"autoscroll\");\n },\n set: function set(value) {\n if (value) {\n this.setAttribute(\"autoscroll\", \"\");\n } else {\n this.removeAttribute(\"autoscroll\");\n }\n }\n }, {\n key: \"complete\",\n get: function get() {\n return !this.delegate.isLoading;\n }\n }, {\n key: \"isActive\",\n get: function get() {\n return this.ownerDocument === document && !this.isPreview;\n }\n }, {\n key: \"isPreview\",\n get: function get() {\n var _a, _b;\n\n return (_b = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.documentElement) === null || _b === void 0 ? void 0 : _b.hasAttribute(\"data-turbo-preview\");\n }\n }], [{\n key: \"observedAttributes\",\n get: function get() {\n return [\"disabled\", \"loading\", \"src\"];\n }\n }]);\n\n return FrameElement;\n}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));\n\nfunction frameLoadingStyleFromString(style) {\n switch (style.toLowerCase()) {\n case \"lazy\":\n return FrameLoadingStyle.lazy;\n\n default:\n return FrameLoadingStyle.eager;\n }\n}\n\nfunction expandURL(locatable) {\n return new URL(locatable.toString(), document.baseURI);\n}\n\nfunction getAnchor(url) {\n var anchorMatch;\n\n if (url.hash) {\n return url.hash.slice(1);\n } else if (anchorMatch = url.href.match(/#(.*)$/)) {\n return anchorMatch[1];\n } else {\n return \"\";\n }\n}\n\nfunction getExtension(url) {\n return (getLastPathComponent(url).match(/\\.[^.]*$/) || [])[0] || \"\";\n}\n\nfunction isHTML(url) {\n return !!getExtension(url).match(/^(?:|\\.(?:htm|html|xhtml))$/);\n}\n\nfunction isPrefixedBy(baseURL, url) {\n var prefix = getPrefix(url);\n return baseURL.href === expandURL(prefix).href || baseURL.href.startsWith(prefix);\n}\n\nfunction toCacheKey(url) {\n var anchorLength = url.hash.length;\n\n if (anchorLength < 2) {\n return url.href;\n } else {\n return url.href.slice(0, -anchorLength);\n }\n}\n\nfunction urlsAreEqual(left, right) {\n return expandURL(left).href == expandURL(right).href;\n}\n\nfunction getPathComponents(url) {\n return url.pathname.split(\"/\").slice(1);\n}\n\nfunction getLastPathComponent(url) {\n return getPathComponents(url).slice(-1)[0];\n}\n\nfunction getPrefix(url) {\n return addTrailingSlash(url.origin + url.pathname);\n}\n\nfunction addTrailingSlash(value) {\n return value.endsWith(\"/\") ? value : value + \"/\";\n}\n\nvar FetchResponse = /*#__PURE__*/function () {\n function FetchResponse(response) {\n _classCallCheck(this, FetchResponse);\n\n this.response = response;\n }\n\n _createClass(FetchResponse, [{\n key: \"succeeded\",\n get: function get() {\n return this.response.ok;\n }\n }, {\n key: \"failed\",\n get: function get() {\n return !this.succeeded;\n }\n }, {\n key: \"clientError\",\n get: function get() {\n return this.statusCode >= 400 && this.statusCode <= 499;\n }\n }, {\n key: \"serverError\",\n get: function get() {\n return this.statusCode >= 500 && this.statusCode <= 599;\n }\n }, {\n key: \"redirected\",\n get: function get() {\n return this.response.redirected;\n }\n }, {\n key: \"location\",\n get: function get() {\n return expandURL(this.response.url);\n }\n }, {\n key: \"isHTML\",\n get: function get() {\n return this.contentType && this.contentType.match(/^(?:text\\/([^\\s;,]+\\b)?html|application\\/xhtml\\+xml)\\b/);\n }\n }, {\n key: \"statusCode\",\n get: function get() {\n return this.response.status;\n }\n }, {\n key: \"contentType\",\n get: function get() {\n return this.header(\"Content-Type\");\n }\n }, {\n key: \"responseText\",\n get: function get() {\n return this.response.text();\n }\n }, {\n key: \"responseHTML\",\n get: function get() {\n if (this.isHTML) {\n return this.response.text();\n } else {\n return Promise.resolve(undefined);\n }\n }\n }, {\n key: \"header\",\n value: function header(name) {\n return this.response.headers.get(name);\n }\n }]);\n\n return FetchResponse;\n}();\n\nfunction dispatch(eventName) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n target = _ref.target,\n cancelable = _ref.cancelable,\n detail = _ref.detail;\n\n var event = new CustomEvent(eventName, {\n cancelable: cancelable,\n bubbles: true,\n detail: detail\n });\n void (target || document.documentElement).dispatchEvent(event);\n return event;\n}\n\nfunction nextAnimationFrame() {\n return new Promise(function (resolve) {\n return requestAnimationFrame(function () {\n return resolve();\n });\n });\n}\n\nfunction nextEventLoopTick() {\n return new Promise(function (resolve) {\n return setTimeout(function () {\n return resolve();\n }, 0);\n });\n}\n\nfunction nextMicrotask() {\n return Promise.resolve();\n}\n\nfunction parseHTMLDocument() {\n var html = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"\";\n return new DOMParser().parseFromString(html, \"text/html\");\n}\n\nfunction unindent(strings) {\n for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n values[_key - 1] = arguments[_key];\n }\n\n var lines = interpolate(strings, values).replace(/^\\n/, \"\").split(\"\\n\");\n var match = lines[0].match(/^\\s+/);\n var indent = match ? match[0].length : 0;\n return lines.map(function (line) {\n return line.slice(indent);\n }).join(\"\\n\");\n}\n\nfunction interpolate(strings, values) {\n return strings.reduce(function (result, string, i) {\n var value = values[i] == undefined ? \"\" : values[i];\n return result + string + value;\n }, \"\");\n}\n\nfunction uuid() {\n return Array.apply(null, {\n length: 36\n }).map(function (_, i) {\n if (i == 8 || i == 13 || i == 18 || i == 23) {\n return \"-\";\n } else if (i == 14) {\n return \"4\";\n } else if (i == 19) {\n return (Math.floor(Math.random() * 4) + 8).toString(16);\n } else {\n return Math.floor(Math.random() * 15).toString(16);\n }\n }).join(\"\");\n}\n\nvar FetchMethod;\n\n(function (FetchMethod) {\n FetchMethod[FetchMethod[\"get\"] = 0] = \"get\";\n FetchMethod[FetchMethod[\"post\"] = 1] = \"post\";\n FetchMethod[FetchMethod[\"put\"] = 2] = \"put\";\n FetchMethod[FetchMethod[\"patch\"] = 3] = \"patch\";\n FetchMethod[FetchMethod[\"delete\"] = 4] = \"delete\";\n})(FetchMethod || (FetchMethod = {}));\n\nfunction fetchMethodFromString(method) {\n switch (method.toLowerCase()) {\n case \"get\":\n return FetchMethod.get;\n\n case \"post\":\n return FetchMethod.post;\n\n case \"put\":\n return FetchMethod.put;\n\n case \"patch\":\n return FetchMethod.patch;\n\n case \"delete\":\n return FetchMethod.delete;\n }\n}\n\nvar FetchRequest = /*#__PURE__*/function () {\n function FetchRequest(delegate, method, location) {\n var body = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new URLSearchParams();\n\n _classCallCheck(this, FetchRequest);\n\n this.abortController = new AbortController();\n this.delegate = delegate;\n this.method = method;\n this.headers = this.defaultHeaders;\n\n if (this.isIdempotent) {\n this.url = mergeFormDataEntries(location, _toConsumableArray(body.entries()));\n } else {\n this.body = body;\n this.url = location;\n }\n }\n\n _createClass(FetchRequest, [{\n key: \"location\",\n get: function get() {\n return this.url;\n }\n }, {\n key: \"params\",\n get: function get() {\n return this.url.searchParams;\n }\n }, {\n key: \"entries\",\n get: function get() {\n return this.body ? Array.from(this.body.entries()) : [];\n }\n }, {\n key: \"cancel\",\n value: function cancel() {\n this.abortController.abort();\n }\n }, {\n key: \"perform\",\n value: function () {\n var _perform = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {\n var _a, _b, fetchOptions, response;\n\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n fetchOptions = this.fetchOptions;\n (_b = (_a = this.delegate).prepareHeadersForRequest) === null || _b === void 0 ? void 0 : _b.call(_a, this.headers, this);\n dispatch(\"turbo:before-fetch-request\", {\n detail: {\n fetchOptions: fetchOptions\n }\n });\n _context.prev = 3;\n this.delegate.requestStarted(this);\n _context.next = 7;\n return fetch(this.url.href, fetchOptions);\n\n case 7:\n response = _context.sent;\n _context.next = 10;\n return this.receive(response);\n\n case 10:\n return _context.abrupt(\"return\", _context.sent);\n\n case 13:\n _context.prev = 13;\n _context.t0 = _context[\"catch\"](3);\n this.delegate.requestErrored(this, _context.t0);\n throw _context.t0;\n\n case 17:\n _context.prev = 17;\n this.delegate.requestFinished(this);\n return _context.finish(17);\n\n case 20:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this, [[3, 13, 17, 20]]);\n }));\n\n function perform() {\n return _perform.apply(this, arguments);\n }\n\n return perform;\n }()\n }, {\n key: \"receive\",\n value: function () {\n var _receive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(response) {\n var fetchResponse, event;\n return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n fetchResponse = new FetchResponse(response);\n event = dispatch(\"turbo:before-fetch-response\", {\n cancelable: true,\n detail: {\n fetchResponse: fetchResponse\n }\n });\n\n if (event.defaultPrevented) {\n this.delegate.requestPreventedHandlingResponse(this, fetchResponse);\n } else if (fetchResponse.succeeded) {\n this.delegate.requestSucceededWithResponse(this, fetchResponse);\n } else {\n this.delegate.requestFailedWithResponse(this, fetchResponse);\n }\n\n return _context2.abrupt(\"return\", fetchResponse);\n\n case 4:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n\n function receive(_x) {\n return _receive.apply(this, arguments);\n }\n\n return receive;\n }()\n }, {\n key: \"fetchOptions\",\n get: function get() {\n return {\n method: FetchMethod[this.method].toUpperCase(),\n credentials: \"same-origin\",\n headers: this.headers,\n redirect: \"follow\",\n body: this.body,\n signal: this.abortSignal\n };\n }\n }, {\n key: \"defaultHeaders\",\n get: function get() {\n return {\n \"Accept\": \"text/html, application/xhtml+xml\"\n };\n }\n }, {\n key: \"isIdempotent\",\n get: function get() {\n return this.method == FetchMethod.get;\n }\n }, {\n key: \"abortSignal\",\n get: function get() {\n return this.abortController.signal;\n }\n }]);\n\n return FetchRequest;\n}();\n\nfunction mergeFormDataEntries(url, entries) {\n var currentSearchParams = new URLSearchParams(url.search);\n\n var _iterator = _createForOfIteratorHelper(entries),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var _ref4 = _step.value;\n\n var _ref3 = _slicedToArray(_ref4, 2);\n\n var name = _ref3[0];\n var value = _ref3[1];\n if (value instanceof File) continue;\n\n if (currentSearchParams.has(name)) {\n currentSearchParams.delete(name);\n url.searchParams.set(name, value);\n } else {\n url.searchParams.append(name, value);\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return url;\n}\n\nvar AppearanceObserver = /*#__PURE__*/function () {\n function AppearanceObserver(delegate, element) {\n var _this2 = this;\n\n _classCallCheck(this, AppearanceObserver);\n\n this.started = false;\n\n this.intersect = function (entries) {\n var lastEntry = entries.slice(-1)[0];\n\n if (lastEntry === null || lastEntry === void 0 ? void 0 : lastEntry.isIntersecting) {\n _this2.delegate.elementAppearedInViewport(_this2.element);\n }\n };\n\n this.delegate = delegate;\n this.element = element;\n this.intersectionObserver = new IntersectionObserver(this.intersect);\n }\n\n _createClass(AppearanceObserver, [{\n key: \"start\",\n value: function start() {\n if (!this.started) {\n this.started = true;\n this.intersectionObserver.observe(this.element);\n }\n }\n }, {\n key: \"stop\",\n value: function stop() {\n if (this.started) {\n this.started = false;\n this.intersectionObserver.unobserve(this.element);\n }\n }\n }]);\n\n return AppearanceObserver;\n}();\n\nvar StreamMessage = /*#__PURE__*/function () {\n function StreamMessage(html) {\n _classCallCheck(this, StreamMessage);\n\n this.templateElement = document.createElement(\"template\");\n this.templateElement.innerHTML = html;\n }\n\n _createClass(StreamMessage, [{\n key: \"fragment\",\n get: function get() {\n var fragment = document.createDocumentFragment();\n\n var _iterator2 = _createForOfIteratorHelper(this.foreignElements),\n _step2;\n\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var element = _step2.value;\n fragment.appendChild(document.importNode(element, true));\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n\n return fragment;\n }\n }, {\n key: \"foreignElements\",\n get: function get() {\n return this.templateChildren.reduce(function (streamElements, child) {\n if (child.tagName.toLowerCase() == \"turbo-stream\") {\n return [].concat(_toConsumableArray(streamElements), [child]);\n } else {\n return streamElements;\n }\n }, []);\n }\n }, {\n key: \"templateChildren\",\n get: function get() {\n return Array.from(this.templateElement.content.children);\n }\n }], [{\n key: \"wrap\",\n value: function wrap(message) {\n if (typeof message == \"string\") {\n return new this(message);\n } else {\n return message;\n }\n }\n }]);\n\n return StreamMessage;\n}();\n\nStreamMessage.contentType = \"text/vnd.turbo-stream.html\";\nvar FormSubmissionState;\n\n(function (FormSubmissionState) {\n FormSubmissionState[FormSubmissionState[\"initialized\"] = 0] = \"initialized\";\n FormSubmissionState[FormSubmissionState[\"requesting\"] = 1] = \"requesting\";\n FormSubmissionState[FormSubmissionState[\"waiting\"] = 2] = \"waiting\";\n FormSubmissionState[FormSubmissionState[\"receiving\"] = 3] = \"receiving\";\n FormSubmissionState[FormSubmissionState[\"stopping\"] = 4] = \"stopping\";\n FormSubmissionState[FormSubmissionState[\"stopped\"] = 5] = \"stopped\";\n})(FormSubmissionState || (FormSubmissionState = {}));\n\nvar FormEnctype;\n\n(function (FormEnctype) {\n FormEnctype[\"urlEncoded\"] = \"application/x-www-form-urlencoded\";\n FormEnctype[\"multipart\"] = \"multipart/form-data\";\n FormEnctype[\"plain\"] = \"text/plain\";\n})(FormEnctype || (FormEnctype = {}));\n\nfunction formEnctypeFromString(encoding) {\n switch (encoding.toLowerCase()) {\n case FormEnctype.multipart:\n return FormEnctype.multipart;\n\n case FormEnctype.plain:\n return FormEnctype.plain;\n\n default:\n return FormEnctype.urlEncoded;\n }\n}\n\nvar FormSubmission = /*#__PURE__*/function () {\n function FormSubmission(delegate, formElement, submitter) {\n var mustRedirect = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n\n _classCallCheck(this, FormSubmission);\n\n this.state = FormSubmissionState.initialized;\n this.delegate = delegate;\n this.formElement = formElement;\n this.submitter = submitter;\n this.formData = buildFormData(formElement, submitter);\n this.fetchRequest = new FetchRequest(this, this.method, this.location, this.body);\n this.mustRedirect = mustRedirect;\n }\n\n _createClass(FormSubmission, [{\n key: \"method\",\n get: function get() {\n var _a;\n\n var method = ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute(\"formmethod\")) || this.formElement.getAttribute(\"method\") || \"\";\n return fetchMethodFromString(method.toLowerCase()) || FetchMethod.get;\n }\n }, {\n key: \"action\",\n get: function get() {\n var _a;\n\n return ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute(\"formaction\")) || this.formElement.action;\n }\n }, {\n key: \"location\",\n get: function get() {\n return expandURL(this.action);\n }\n }, {\n key: \"body\",\n get: function get() {\n if (this.enctype == FormEnctype.urlEncoded || this.method == FetchMethod.get) {\n return new URLSearchParams(this.stringFormData);\n } else {\n return this.formData;\n }\n }\n }, {\n key: \"enctype\",\n get: function get() {\n var _a;\n\n return formEnctypeFromString(((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute(\"formenctype\")) || this.formElement.enctype);\n }\n }, {\n key: \"isIdempotent\",\n get: function get() {\n return this.fetchRequest.isIdempotent;\n }\n }, {\n key: \"stringFormData\",\n get: function get() {\n return _toConsumableArray(this.formData).reduce(function (entries, _ref5) {\n var _ref6 = _slicedToArray(_ref5, 2),\n name = _ref6[0],\n value = _ref6[1];\n\n return entries.concat(typeof value == \"string\" ? [[name, value]] : []);\n }, []);\n }\n }, {\n key: \"start\",\n value: function () {\n var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {\n var _FormSubmissionState, initialized, requesting;\n\n return _regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _FormSubmissionState = FormSubmissionState, initialized = _FormSubmissionState.initialized, requesting = _FormSubmissionState.requesting;\n\n if (!(this.state == initialized)) {\n _context3.next = 4;\n break;\n }\n\n this.state = requesting;\n return _context3.abrupt(\"return\", this.fetchRequest.perform());\n\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this);\n }));\n\n function start() {\n return _start.apply(this, arguments);\n }\n\n return start;\n }()\n }, {\n key: \"stop\",\n value: function stop() {\n var _FormSubmissionState2 = FormSubmissionState,\n stopping = _FormSubmissionState2.stopping,\n stopped = _FormSubmissionState2.stopped;\n\n if (this.state != stopping && this.state != stopped) {\n this.state = stopping;\n this.fetchRequest.cancel();\n return true;\n }\n }\n }, {\n key: \"prepareHeadersForRequest\",\n value: function prepareHeadersForRequest(headers, request) {\n if (!request.isIdempotent) {\n var token = getCookieValue(getMetaContent(\"csrf-param\")) || getMetaContent(\"csrf-token\");\n\n if (token) {\n headers[\"X-CSRF-Token\"] = token;\n }\n\n headers[\"Accept\"] = [StreamMessage.contentType, headers[\"Accept\"]].join(\", \");\n }\n }\n }, {\n key: \"requestStarted\",\n value: function requestStarted(request) {\n this.state = FormSubmissionState.waiting;\n dispatch(\"turbo:submit-start\", {\n target: this.formElement,\n detail: {\n formSubmission: this\n }\n });\n this.delegate.formSubmissionStarted(this);\n }\n }, {\n key: \"requestPreventedHandlingResponse\",\n value: function requestPreventedHandlingResponse(request, response) {\n this.result = {\n success: response.succeeded,\n fetchResponse: response\n };\n }\n }, {\n key: \"requestSucceededWithResponse\",\n value: function requestSucceededWithResponse(request, response) {\n if (response.clientError || response.serverError) {\n this.delegate.formSubmissionFailedWithResponse(this, response);\n } else if (this.requestMustRedirect(request) && responseSucceededWithoutRedirect(response)) {\n var error = new Error(\"Form responses must redirect to another location\");\n this.delegate.formSubmissionErrored(this, error);\n } else {\n this.state = FormSubmissionState.receiving;\n this.result = {\n success: true,\n fetchResponse: response\n };\n this.delegate.formSubmissionSucceededWithResponse(this, response);\n }\n }\n }, {\n key: \"requestFailedWithResponse\",\n value: function requestFailedWithResponse(request, response) {\n this.result = {\n success: false,\n fetchResponse: response\n };\n this.delegate.formSubmissionFailedWithResponse(this, response);\n }\n }, {\n key: \"requestErrored\",\n value: function requestErrored(request, error) {\n this.result = {\n success: false,\n error: error\n };\n this.delegate.formSubmissionErrored(this, error);\n }\n }, {\n key: \"requestFinished\",\n value: function requestFinished(request) {\n this.state = FormSubmissionState.stopped;\n dispatch(\"turbo:submit-end\", {\n target: this.formElement,\n detail: Object.assign({\n formSubmission: this\n }, this.result)\n });\n this.delegate.formSubmissionFinished(this);\n }\n }, {\n key: \"requestMustRedirect\",\n value: function requestMustRedirect(request) {\n return !request.isIdempotent && this.mustRedirect;\n }\n }]);\n\n return FormSubmission;\n}();\n\nfunction buildFormData(formElement, submitter) {\n var formData = new FormData(formElement);\n var name = submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"name\");\n var value = submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"value\");\n\n if (name && value != null && formData.get(name) != value) {\n formData.append(name, value);\n }\n\n return formData;\n}\n\nfunction getCookieValue(cookieName) {\n if (cookieName != null) {\n var cookies = document.cookie ? document.cookie.split(\"; \") : [];\n var cookie = cookies.find(function (cookie) {\n return cookie.startsWith(cookieName);\n });\n\n if (cookie) {\n var value = cookie.split(\"=\").slice(1).join(\"=\");\n return value ? decodeURIComponent(value) : undefined;\n }\n }\n}\n\nfunction getMetaContent(name) {\n var element = document.querySelector(\"meta[name=\\\"\".concat(name, \"\\\"]\"));\n return element && element.content;\n}\n\nfunction responseSucceededWithoutRedirect(response) {\n return response.statusCode == 200 && !response.redirected;\n}\n\nvar Snapshot = /*#__PURE__*/function () {\n function Snapshot(element) {\n _classCallCheck(this, Snapshot);\n\n this.element = element;\n }\n\n _createClass(Snapshot, [{\n key: \"children\",\n get: function get() {\n return _toConsumableArray(this.element.children);\n }\n }, {\n key: \"hasAnchor\",\n value: function hasAnchor(anchor) {\n return this.getElementForAnchor(anchor) != null;\n }\n }, {\n key: \"getElementForAnchor\",\n value: function getElementForAnchor(anchor) {\n try {\n return this.element.querySelector(\"[id='\".concat(anchor, \"'], a[name='\").concat(anchor, \"']\"));\n } catch (_a) {\n return null;\n }\n }\n }, {\n key: \"isConnected\",\n get: function get() {\n return this.element.isConnected;\n }\n }, {\n key: \"firstAutofocusableElement\",\n get: function get() {\n return this.element.querySelector(\"[autofocus]\");\n }\n }, {\n key: \"permanentElements\",\n get: function get() {\n return _toConsumableArray(this.element.querySelectorAll(\"[id][data-turbo-permanent]\"));\n }\n }, {\n key: \"getPermanentElementById\",\n value: function getPermanentElementById(id) {\n return this.element.querySelector(\"#\".concat(id, \"[data-turbo-permanent]\"));\n }\n }, {\n key: \"getPermanentElementMapForSnapshot\",\n value: function getPermanentElementMapForSnapshot(snapshot) {\n var permanentElementMap = {};\n\n var _iterator3 = _createForOfIteratorHelper(this.permanentElements),\n _step3;\n\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var currentPermanentElement = _step3.value;\n var id = currentPermanentElement.id;\n var newPermanentElement = snapshot.getPermanentElementById(id);\n\n if (newPermanentElement) {\n permanentElementMap[id] = [currentPermanentElement, newPermanentElement];\n }\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n\n return permanentElementMap;\n }\n }]);\n\n return Snapshot;\n}();\n\nvar FormInterceptor = /*#__PURE__*/function () {\n function FormInterceptor(delegate, element) {\n var _this3 = this;\n\n _classCallCheck(this, FormInterceptor);\n\n this.submitBubbled = function (event) {\n if (event.target instanceof HTMLFormElement) {\n var form = event.target;\n var submitter = event.submitter || undefined;\n\n if (_this3.delegate.shouldInterceptFormSubmission(form, submitter)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n\n _this3.delegate.formSubmissionIntercepted(form, submitter);\n }\n }\n };\n\n this.delegate = delegate;\n this.element = element;\n }\n\n _createClass(FormInterceptor, [{\n key: \"start\",\n value: function start() {\n this.element.addEventListener(\"submit\", this.submitBubbled);\n }\n }, {\n key: \"stop\",\n value: function stop() {\n this.element.removeEventListener(\"submit\", this.submitBubbled);\n }\n }]);\n\n return FormInterceptor;\n}();\n\nvar View = /*#__PURE__*/function () {\n function View(delegate, element) {\n _classCallCheck(this, View);\n\n this.delegate = delegate;\n this.element = element;\n }\n\n _createClass(View, [{\n key: \"scrollToAnchor\",\n value: function scrollToAnchor(anchor) {\n var element = this.snapshot.getElementForAnchor(anchor);\n\n if (element) {\n this.scrollToElement(element);\n } else {\n this.scrollToPosition({\n x: 0,\n y: 0\n });\n }\n }\n }, {\n key: \"scrollToElement\",\n value: function scrollToElement(element) {\n element.scrollIntoView();\n }\n }, {\n key: \"scrollToPosition\",\n value: function scrollToPosition(_ref7) {\n var x = _ref7.x,\n y = _ref7.y;\n this.scrollRoot.scrollTo(x, y);\n }\n }, {\n key: \"scrollRoot\",\n get: function get() {\n return window;\n }\n }, {\n key: \"render\",\n value: function () {\n var _render = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(renderer) {\n var isPreview, shouldRender, snapshot;\n return _regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n if (!this.renderer) {\n _context4.next = 2;\n break;\n }\n\n throw new Error(\"rendering is already in progress\");\n\n case 2:\n isPreview = renderer.isPreview, shouldRender = renderer.shouldRender, snapshot = renderer.newSnapshot;\n\n if (!shouldRender) {\n _context4.next = 17;\n break;\n }\n\n _context4.prev = 4;\n this.renderer = renderer;\n this.prepareToRenderSnapshot(renderer);\n this.delegate.viewWillRenderSnapshot(snapshot, isPreview);\n _context4.next = 10;\n return this.renderSnapshot(renderer);\n\n case 10:\n this.delegate.viewRenderedSnapshot(snapshot, isPreview);\n this.finishRenderingSnapshot(renderer);\n\n case 12:\n _context4.prev = 12;\n delete this.renderer;\n return _context4.finish(12);\n\n case 15:\n _context4.next = 18;\n break;\n\n case 17:\n this.invalidate();\n\n case 18:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, this, [[4,, 12, 15]]);\n }));\n\n function render(_x2) {\n return _render.apply(this, arguments);\n }\n\n return render;\n }()\n }, {\n key: \"invalidate\",\n value: function invalidate() {\n this.delegate.viewInvalidated();\n }\n }, {\n key: \"prepareToRenderSnapshot\",\n value: function prepareToRenderSnapshot(renderer) {\n this.markAsPreview(renderer.isPreview);\n renderer.prepareToRender();\n }\n }, {\n key: \"markAsPreview\",\n value: function markAsPreview(isPreview) {\n if (isPreview) {\n this.element.setAttribute(\"data-turbo-preview\", \"\");\n } else {\n this.element.removeAttribute(\"data-turbo-preview\");\n }\n }\n }, {\n key: \"renderSnapshot\",\n value: function () {\n var _renderSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(renderer) {\n return _regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return renderer.render();\n\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5);\n }));\n\n function renderSnapshot(_x3) {\n return _renderSnapshot.apply(this, arguments);\n }\n\n return renderSnapshot;\n }()\n }, {\n key: \"finishRenderingSnapshot\",\n value: function finishRenderingSnapshot(renderer) {\n renderer.finishRendering();\n }\n }]);\n\n return View;\n}();\n\nvar FrameView = /*#__PURE__*/function (_View) {\n _inherits(FrameView, _View);\n\n var _super2 = _createSuper(FrameView);\n\n function FrameView() {\n _classCallCheck(this, FrameView);\n\n return _super2.apply(this, arguments);\n }\n\n _createClass(FrameView, [{\n key: \"invalidate\",\n value: function invalidate() {\n this.element.innerHTML = \"\";\n }\n }, {\n key: \"snapshot\",\n get: function get() {\n return new Snapshot(this.element);\n }\n }]);\n\n return FrameView;\n}(View);\n\nvar LinkInterceptor = /*#__PURE__*/function () {\n function LinkInterceptor(delegate, element) {\n var _this4 = this;\n\n _classCallCheck(this, LinkInterceptor);\n\n this.clickBubbled = function (event) {\n if (_this4.respondsToEventTarget(event.target)) {\n _this4.clickEvent = event;\n } else {\n delete _this4.clickEvent;\n }\n };\n\n this.linkClicked = function (event) {\n if (_this4.clickEvent && _this4.respondsToEventTarget(event.target) && event.target instanceof Element) {\n if (_this4.delegate.shouldInterceptLinkClick(event.target, event.detail.url)) {\n _this4.clickEvent.preventDefault();\n\n event.preventDefault();\n\n _this4.delegate.linkClickIntercepted(event.target, event.detail.url);\n }\n }\n\n delete _this4.clickEvent;\n };\n\n this.willVisit = function () {\n delete _this4.clickEvent;\n };\n\n this.delegate = delegate;\n this.element = element;\n }\n\n _createClass(LinkInterceptor, [{\n key: \"start\",\n value: function start() {\n this.element.addEventListener(\"click\", this.clickBubbled);\n document.addEventListener(\"turbo:click\", this.linkClicked);\n document.addEventListener(\"turbo:before-visit\", this.willVisit);\n }\n }, {\n key: \"stop\",\n value: function stop() {\n this.element.removeEventListener(\"click\", this.clickBubbled);\n document.removeEventListener(\"turbo:click\", this.linkClicked);\n document.removeEventListener(\"turbo:before-visit\", this.willVisit);\n }\n }, {\n key: \"respondsToEventTarget\",\n value: function respondsToEventTarget(target) {\n var element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;\n return element && element.closest(\"turbo-frame, html\") == this.element;\n }\n }]);\n\n return LinkInterceptor;\n}();\n\nvar Bardo = /*#__PURE__*/function () {\n function Bardo(permanentElementMap) {\n _classCallCheck(this, Bardo);\n\n this.permanentElementMap = permanentElementMap;\n }\n\n _createClass(Bardo, [{\n key: \"enter\",\n value: function enter() {\n for (var id in this.permanentElementMap) {\n var _this$permanentElemen = _slicedToArray(this.permanentElementMap[id], 2),\n newPermanentElement = _this$permanentElemen[1];\n\n this.replaceNewPermanentElementWithPlaceholder(newPermanentElement);\n }\n }\n }, {\n key: \"leave\",\n value: function leave() {\n for (var id in this.permanentElementMap) {\n var _this$permanentElemen2 = _slicedToArray(this.permanentElementMap[id], 1),\n currentPermanentElement = _this$permanentElemen2[0];\n\n this.replaceCurrentPermanentElementWithClone(currentPermanentElement);\n this.replacePlaceholderWithPermanentElement(currentPermanentElement);\n }\n }\n }, {\n key: \"replaceNewPermanentElementWithPlaceholder\",\n value: function replaceNewPermanentElementWithPlaceholder(permanentElement) {\n var placeholder = createPlaceholderForPermanentElement(permanentElement);\n permanentElement.replaceWith(placeholder);\n }\n }, {\n key: \"replaceCurrentPermanentElementWithClone\",\n value: function replaceCurrentPermanentElementWithClone(permanentElement) {\n var clone = permanentElement.cloneNode(true);\n permanentElement.replaceWith(clone);\n }\n }, {\n key: \"replacePlaceholderWithPermanentElement\",\n value: function replacePlaceholderWithPermanentElement(permanentElement) {\n var placeholder = this.getPlaceholderById(permanentElement.id);\n placeholder === null || placeholder === void 0 ? void 0 : placeholder.replaceWith(permanentElement);\n }\n }, {\n key: \"getPlaceholderById\",\n value: function getPlaceholderById(id) {\n return this.placeholders.find(function (element) {\n return element.content == id;\n });\n }\n }, {\n key: \"placeholders\",\n get: function get() {\n return _toConsumableArray(document.querySelectorAll(\"meta[name=turbo-permanent-placeholder][content]\"));\n }\n }], [{\n key: \"preservingPermanentElements\",\n value: function preservingPermanentElements(permanentElementMap, callback) {\n var bardo = new this(permanentElementMap);\n bardo.enter();\n callback();\n bardo.leave();\n }\n }]);\n\n return Bardo;\n}();\n\nfunction createPlaceholderForPermanentElement(permanentElement) {\n var element = document.createElement(\"meta\");\n element.setAttribute(\"name\", \"turbo-permanent-placeholder\");\n element.setAttribute(\"content\", permanentElement.id);\n return element;\n}\n\nvar Renderer = /*#__PURE__*/function () {\n function Renderer(currentSnapshot, newSnapshot, isPreview) {\n var _this5 = this;\n\n _classCallCheck(this, Renderer);\n\n this.currentSnapshot = currentSnapshot;\n this.newSnapshot = newSnapshot;\n this.isPreview = isPreview;\n this.promise = new Promise(function (resolve, reject) {\n return _this5.resolvingFunctions = {\n resolve: resolve,\n reject: reject\n };\n });\n }\n\n _createClass(Renderer, [{\n key: \"shouldRender\",\n get: function get() {\n return true;\n }\n }, {\n key: \"prepareToRender\",\n value: function prepareToRender() {\n return;\n }\n }, {\n key: \"finishRendering\",\n value: function finishRendering() {\n if (this.resolvingFunctions) {\n this.resolvingFunctions.resolve();\n delete this.resolvingFunctions;\n }\n }\n }, {\n key: \"createScriptElement\",\n value: function createScriptElement(element) {\n if (element.getAttribute(\"data-turbo-eval\") == \"false\") {\n return element;\n } else {\n var createdScriptElement = document.createElement(\"script\");\n createdScriptElement.textContent = element.textContent;\n createdScriptElement.async = false;\n copyElementAttributes(createdScriptElement, element);\n return createdScriptElement;\n }\n }\n }, {\n key: \"preservingPermanentElements\",\n value: function preservingPermanentElements(callback) {\n Bardo.preservingPermanentElements(this.permanentElementMap, callback);\n }\n }, {\n key: \"focusFirstAutofocusableElement\",\n value: function focusFirstAutofocusableElement() {\n var element = this.connectedSnapshot.firstAutofocusableElement;\n\n if (elementIsFocusable(element)) {\n element.focus();\n }\n }\n }, {\n key: \"connectedSnapshot\",\n get: function get() {\n return this.newSnapshot.isConnected ? this.newSnapshot : this.currentSnapshot;\n }\n }, {\n key: \"currentElement\",\n get: function get() {\n return this.currentSnapshot.element;\n }\n }, {\n key: \"newElement\",\n get: function get() {\n return this.newSnapshot.element;\n }\n }, {\n key: \"permanentElementMap\",\n get: function get() {\n return this.currentSnapshot.getPermanentElementMapForSnapshot(this.newSnapshot);\n }\n }]);\n\n return Renderer;\n}();\n\nfunction copyElementAttributes(destinationElement, sourceElement) {\n for (var _i2 = 0, _arr2 = _toConsumableArray(sourceElement.attributes); _i2 < _arr2.length; _i2++) {\n var _ref9 = _arr2[_i2];\n var name = _ref9.name;\n var value = _ref9.value;\n destinationElement.setAttribute(name, value);\n }\n}\n\nfunction elementIsFocusable(element) {\n return element && typeof element.focus == \"function\";\n}\n\nvar FrameRenderer = /*#__PURE__*/function (_Renderer) {\n _inherits(FrameRenderer, _Renderer);\n\n var _super3 = _createSuper(FrameRenderer);\n\n function FrameRenderer() {\n _classCallCheck(this, FrameRenderer);\n\n return _super3.apply(this, arguments);\n }\n\n _createClass(FrameRenderer, [{\n key: \"shouldRender\",\n get: function get() {\n return true;\n }\n }, {\n key: \"render\",\n value: function () {\n var _render2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {\n var _this6 = this;\n\n return _regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return nextAnimationFrame();\n\n case 2:\n this.preservingPermanentElements(function () {\n _this6.loadFrameElement();\n });\n this.scrollFrameIntoView();\n _context6.next = 6;\n return nextAnimationFrame();\n\n case 6:\n this.focusFirstAutofocusableElement();\n\n case 7:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, this);\n }));\n\n function render() {\n return _render2.apply(this, arguments);\n }\n\n return render;\n }()\n }, {\n key: \"loadFrameElement\",\n value: function loadFrameElement() {\n var _a;\n\n var destinationRange = document.createRange();\n destinationRange.selectNodeContents(this.currentElement);\n destinationRange.deleteContents();\n var frameElement = this.newElement;\n var sourceRange = (_a = frameElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.createRange();\n\n if (sourceRange) {\n sourceRange.selectNodeContents(frameElement);\n this.currentElement.appendChild(sourceRange.extractContents());\n }\n }\n }, {\n key: \"scrollFrameIntoView\",\n value: function scrollFrameIntoView() {\n if (this.currentElement.autoscroll || this.newElement.autoscroll) {\n var element = this.currentElement.firstElementChild;\n var block = readScrollLogicalPosition(this.currentElement.getAttribute(\"data-autoscroll-block\"), \"end\");\n\n if (element) {\n element.scrollIntoView({\n block: block\n });\n return true;\n }\n }\n\n return false;\n }\n }]);\n\n return FrameRenderer;\n}(Renderer);\n\nfunction readScrollLogicalPosition(value, defaultValue) {\n if (value == \"end\" || value == \"start\" || value == \"center\" || value == \"nearest\") {\n return value;\n } else {\n return defaultValue;\n }\n}\n\nvar ProgressBar = /*#__PURE__*/function () {\n function ProgressBar() {\n var _this7 = this;\n\n _classCallCheck(this, ProgressBar);\n\n this.hiding = false;\n this.value = 0;\n this.visible = false;\n\n this.trickle = function () {\n _this7.setValue(_this7.value + Math.random() / 100);\n };\n\n this.stylesheetElement = this.createStylesheetElement();\n this.progressElement = this.createProgressElement();\n this.installStylesheetElement();\n this.setValue(0);\n }\n\n _createClass(ProgressBar, [{\n key: \"show\",\n value: function show() {\n if (!this.visible) {\n this.visible = true;\n this.installProgressElement();\n this.startTrickling();\n }\n }\n }, {\n key: \"hide\",\n value: function hide() {\n var _this8 = this;\n\n if (this.visible && !this.hiding) {\n this.hiding = true;\n this.fadeProgressElement(function () {\n _this8.uninstallProgressElement();\n\n _this8.stopTrickling();\n\n _this8.visible = false;\n _this8.hiding = false;\n });\n }\n }\n }, {\n key: \"setValue\",\n value: function setValue(value) {\n this.value = value;\n this.refresh();\n }\n }, {\n key: \"installStylesheetElement\",\n value: function installStylesheetElement() {\n document.head.insertBefore(this.stylesheetElement, document.head.firstChild);\n }\n }, {\n key: \"installProgressElement\",\n value: function installProgressElement() {\n this.progressElement.style.width = \"0\";\n this.progressElement.style.opacity = \"1\";\n document.documentElement.insertBefore(this.progressElement, document.body);\n this.refresh();\n }\n }, {\n key: \"fadeProgressElement\",\n value: function fadeProgressElement(callback) {\n this.progressElement.style.opacity = \"0\";\n setTimeout(callback, ProgressBar.animationDuration * 1.5);\n }\n }, {\n key: \"uninstallProgressElement\",\n value: function uninstallProgressElement() {\n if (this.progressElement.parentNode) {\n document.documentElement.removeChild(this.progressElement);\n }\n }\n }, {\n key: \"startTrickling\",\n value: function startTrickling() {\n if (!this.trickleInterval) {\n this.trickleInterval = window.setInterval(this.trickle, ProgressBar.animationDuration);\n }\n }\n }, {\n key: \"stopTrickling\",\n value: function stopTrickling() {\n window.clearInterval(this.trickleInterval);\n delete this.trickleInterval;\n }\n }, {\n key: \"refresh\",\n value: function refresh() {\n var _this9 = this;\n\n requestAnimationFrame(function () {\n _this9.progressElement.style.width = \"\".concat(10 + _this9.value * 90, \"%\");\n });\n }\n }, {\n key: \"createStylesheetElement\",\n value: function createStylesheetElement() {\n var element = document.createElement(\"style\");\n element.type = \"text/css\";\n element.textContent = ProgressBar.defaultCSS;\n return element;\n }\n }, {\n key: \"createProgressElement\",\n value: function createProgressElement() {\n var element = document.createElement(\"div\");\n element.className = \"turbo-progress-bar\";\n return element;\n }\n }], [{\n key: \"defaultCSS\",\n get: function get() {\n return unindent(_templateObject || (_templateObject = _taggedTemplateLiteral([\"\\n .turbo-progress-bar {\\n position: fixed;\\n display: block;\\n top: 0;\\n left: 0;\\n height: 3px;\\n background: #0076ff;\\n z-index: 9999;\\n transition:\\n width \", \"ms ease-out,\\n opacity \", \"ms \", \"ms ease-in;\\n transform: translate3d(0, 0, 0);\\n }\\n \"])), ProgressBar.animationDuration, ProgressBar.animationDuration / 2, ProgressBar.animationDuration / 2);\n }\n }]);\n\n return ProgressBar;\n}();\n\nProgressBar.animationDuration = 300;\n\nvar HeadSnapshot = /*#__PURE__*/function (_Snapshot) {\n _inherits(HeadSnapshot, _Snapshot);\n\n var _super4 = _createSuper(HeadSnapshot);\n\n function HeadSnapshot() {\n var _this10;\n\n _classCallCheck(this, HeadSnapshot);\n\n _this10 = _super4.apply(this, arguments);\n _this10.detailsByOuterHTML = _this10.children.reduce(function (result, element) {\n var outerHTML = element.outerHTML;\n var details = outerHTML in result ? result[outerHTML] : {\n type: elementType(element),\n tracked: elementIsTracked(element),\n elements: []\n };\n return Object.assign(Object.assign({}, result), _defineProperty({}, outerHTML, Object.assign(Object.assign({}, details), {\n elements: [].concat(_toConsumableArray(details.elements), [element])\n })));\n }, {});\n return _this10;\n }\n\n _createClass(HeadSnapshot, [{\n key: \"trackedElementSignature\",\n get: function get() {\n var _this11 = this;\n\n return Object.keys(this.detailsByOuterHTML).filter(function (outerHTML) {\n return _this11.detailsByOuterHTML[outerHTML].tracked;\n }).join(\"\");\n }\n }, {\n key: \"getScriptElementsNotInSnapshot\",\n value: function getScriptElementsNotInSnapshot(snapshot) {\n return this.getElementsMatchingTypeNotInSnapshot(\"script\", snapshot);\n }\n }, {\n key: \"getStylesheetElementsNotInSnapshot\",\n value: function getStylesheetElementsNotInSnapshot(snapshot) {\n return this.getElementsMatchingTypeNotInSnapshot(\"stylesheet\", snapshot);\n }\n }, {\n key: \"getElementsMatchingTypeNotInSnapshot\",\n value: function getElementsMatchingTypeNotInSnapshot(matchedType, snapshot) {\n var _this12 = this;\n\n return Object.keys(this.detailsByOuterHTML).filter(function (outerHTML) {\n return !(outerHTML in snapshot.detailsByOuterHTML);\n }).map(function (outerHTML) {\n return _this12.detailsByOuterHTML[outerHTML];\n }).filter(function (_ref10) {\n var type = _ref10.type;\n return type == matchedType;\n }).map(function (_ref11) {\n var _ref11$elements = _slicedToArray(_ref11.elements, 1),\n element = _ref11$elements[0];\n\n return element;\n });\n }\n }, {\n key: \"provisionalElements\",\n get: function get() {\n var _this13 = this;\n\n return Object.keys(this.detailsByOuterHTML).reduce(function (result, outerHTML) {\n var _this13$detailsByOute = _this13.detailsByOuterHTML[outerHTML],\n type = _this13$detailsByOute.type,\n tracked = _this13$detailsByOute.tracked,\n elements = _this13$detailsByOute.elements;\n\n if (type == null && !tracked) {\n return [].concat(_toConsumableArray(result), _toConsumableArray(elements));\n } else if (elements.length > 1) {\n return [].concat(_toConsumableArray(result), _toConsumableArray(elements.slice(1)));\n } else {\n return result;\n }\n }, []);\n }\n }, {\n key: \"getMetaValue\",\n value: function getMetaValue(name) {\n var element = this.findMetaElementByName(name);\n return element ? element.getAttribute(\"content\") : null;\n }\n }, {\n key: \"findMetaElementByName\",\n value: function findMetaElementByName(name) {\n var _this14 = this;\n\n return Object.keys(this.detailsByOuterHTML).reduce(function (result, outerHTML) {\n var _this14$detailsByOute = _slicedToArray(_this14.detailsByOuterHTML[outerHTML].elements, 1),\n element = _this14$detailsByOute[0];\n\n return elementIsMetaElementWithName(element, name) ? element : result;\n }, undefined);\n }\n }]);\n\n return HeadSnapshot;\n}(Snapshot);\n\nfunction elementType(element) {\n if (elementIsScript(element)) {\n return \"script\";\n } else if (elementIsStylesheet(element)) {\n return \"stylesheet\";\n }\n}\n\nfunction elementIsTracked(element) {\n return element.getAttribute(\"data-turbo-track\") == \"reload\";\n}\n\nfunction elementIsScript(element) {\n var tagName = element.tagName.toLowerCase();\n return tagName == \"script\";\n}\n\nfunction elementIsStylesheet(element) {\n var tagName = element.tagName.toLowerCase();\n return tagName == \"style\" || tagName == \"link\" && element.getAttribute(\"rel\") == \"stylesheet\";\n}\n\nfunction elementIsMetaElementWithName(element, name) {\n var tagName = element.tagName.toLowerCase();\n return tagName == \"meta\" && element.getAttribute(\"name\") == name;\n}\n\nvar PageSnapshot = /*#__PURE__*/function (_Snapshot2) {\n _inherits(PageSnapshot, _Snapshot2);\n\n var _super5 = _createSuper(PageSnapshot);\n\n function PageSnapshot(element, headSnapshot) {\n var _this15;\n\n _classCallCheck(this, PageSnapshot);\n\n _this15 = _super5.call(this, element);\n _this15.headSnapshot = headSnapshot;\n return _this15;\n }\n\n _createClass(PageSnapshot, [{\n key: \"clone\",\n value: function clone() {\n return new PageSnapshot(this.element.cloneNode(true), this.headSnapshot);\n }\n }, {\n key: \"headElement\",\n get: function get() {\n return this.headSnapshot.element;\n }\n }, {\n key: \"rootLocation\",\n get: function get() {\n var _a;\n\n var root = (_a = this.getSetting(\"root\")) !== null && _a !== void 0 ? _a : \"/\";\n return expandURL(root);\n }\n }, {\n key: \"cacheControlValue\",\n get: function get() {\n return this.getSetting(\"cache-control\");\n }\n }, {\n key: \"isPreviewable\",\n get: function get() {\n return this.cacheControlValue != \"no-preview\";\n }\n }, {\n key: \"isCacheable\",\n get: function get() {\n return this.cacheControlValue != \"no-cache\";\n }\n }, {\n key: \"isVisitable\",\n get: function get() {\n return this.getSetting(\"visit-control\") != \"reload\";\n }\n }, {\n key: \"getSetting\",\n value: function getSetting(name) {\n return this.headSnapshot.getMetaValue(\"turbo-\".concat(name));\n }\n }], [{\n key: \"fromHTMLString\",\n value: function fromHTMLString() {\n var html = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"\";\n return this.fromDocument(parseHTMLDocument(html));\n }\n }, {\n key: \"fromElement\",\n value: function fromElement(element) {\n return this.fromDocument(element.ownerDocument);\n }\n }, {\n key: \"fromDocument\",\n value: function fromDocument(_ref12) {\n var head = _ref12.head,\n body = _ref12.body;\n return new this(body, new HeadSnapshot(head));\n }\n }]);\n\n return PageSnapshot;\n}(Snapshot);\n\nvar TimingMetric;\n\n(function (TimingMetric) {\n TimingMetric[\"visitStart\"] = \"visitStart\";\n TimingMetric[\"requestStart\"] = \"requestStart\";\n TimingMetric[\"requestEnd\"] = \"requestEnd\";\n TimingMetric[\"visitEnd\"] = \"visitEnd\";\n})(TimingMetric || (TimingMetric = {}));\n\nvar VisitState;\n\n(function (VisitState) {\n VisitState[\"initialized\"] = \"initialized\";\n VisitState[\"started\"] = \"started\";\n VisitState[\"canceled\"] = \"canceled\";\n VisitState[\"failed\"] = \"failed\";\n VisitState[\"completed\"] = \"completed\";\n})(VisitState || (VisitState = {}));\n\nvar defaultOptions = {\n action: \"advance\",\n historyChanged: false\n};\nvar SystemStatusCode;\n\n(function (SystemStatusCode) {\n SystemStatusCode[SystemStatusCode[\"networkFailure\"] = 0] = \"networkFailure\";\n SystemStatusCode[SystemStatusCode[\"timeoutFailure\"] = -1] = \"timeoutFailure\";\n SystemStatusCode[SystemStatusCode[\"contentTypeMismatch\"] = -2] = \"contentTypeMismatch\";\n})(SystemStatusCode || (SystemStatusCode = {}));\n\nvar Visit = /*#__PURE__*/function () {\n function Visit(delegate, location, restorationIdentifier) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n\n _classCallCheck(this, Visit);\n\n this.identifier = uuid();\n this.timingMetrics = {};\n this.followedRedirect = false;\n this.historyChanged = false;\n this.scrolled = false;\n this.snapshotCached = false;\n this.state = VisitState.initialized;\n this.delegate = delegate;\n this.location = location;\n this.restorationIdentifier = restorationIdentifier || uuid();\n\n var _Object$assign2 = Object.assign(Object.assign({}, defaultOptions), options),\n action = _Object$assign2.action,\n historyChanged = _Object$assign2.historyChanged,\n referrer = _Object$assign2.referrer,\n snapshotHTML = _Object$assign2.snapshotHTML,\n response = _Object$assign2.response;\n\n this.action = action;\n this.historyChanged = historyChanged;\n this.referrer = referrer;\n this.snapshotHTML = snapshotHTML;\n this.response = response;\n }\n\n _createClass(Visit, [{\n key: \"adapter\",\n get: function get() {\n return this.delegate.adapter;\n }\n }, {\n key: \"view\",\n get: function get() {\n return this.delegate.view;\n }\n }, {\n key: \"history\",\n get: function get() {\n return this.delegate.history;\n }\n }, {\n key: \"restorationData\",\n get: function get() {\n return this.history.getRestorationDataForIdentifier(this.restorationIdentifier);\n }\n }, {\n key: \"start\",\n value: function start() {\n if (this.state == VisitState.initialized) {\n this.recordTimingMetric(TimingMetric.visitStart);\n this.state = VisitState.started;\n this.adapter.visitStarted(this);\n this.delegate.visitStarted(this);\n }\n }\n }, {\n key: \"cancel\",\n value: function cancel() {\n if (this.state == VisitState.started) {\n if (this.request) {\n this.request.cancel();\n }\n\n this.cancelRender();\n this.state = VisitState.canceled;\n }\n }\n }, {\n key: \"complete\",\n value: function complete() {\n if (this.state == VisitState.started) {\n this.recordTimingMetric(TimingMetric.visitEnd);\n this.state = VisitState.completed;\n this.adapter.visitCompleted(this);\n this.delegate.visitCompleted(this);\n }\n }\n }, {\n key: \"fail\",\n value: function fail() {\n if (this.state == VisitState.started) {\n this.state = VisitState.failed;\n this.adapter.visitFailed(this);\n }\n }\n }, {\n key: \"changeHistory\",\n value: function changeHistory() {\n var _a;\n\n if (!this.historyChanged) {\n var actionForHistory = this.location.href === ((_a = this.referrer) === null || _a === void 0 ? void 0 : _a.href) ? \"replace\" : this.action;\n var method = this.getHistoryMethodForAction(actionForHistory);\n this.history.update(method, this.location, this.restorationIdentifier);\n this.historyChanged = true;\n }\n }\n }, {\n key: \"issueRequest\",\n value: function issueRequest() {\n if (this.hasPreloadedResponse()) {\n this.simulateRequest();\n } else if (this.shouldIssueRequest() && !this.request) {\n this.request = new FetchRequest(this, FetchMethod.get, this.location);\n this.request.perform();\n }\n }\n }, {\n key: \"simulateRequest\",\n value: function simulateRequest() {\n if (this.response) {\n this.startRequest();\n this.recordResponse();\n this.finishRequest();\n }\n }\n }, {\n key: \"startRequest\",\n value: function startRequest() {\n this.recordTimingMetric(TimingMetric.requestStart);\n this.adapter.visitRequestStarted(this);\n }\n }, {\n key: \"recordResponse\",\n value: function recordResponse() {\n var response = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.response;\n this.response = response;\n\n if (response) {\n var statusCode = response.statusCode;\n\n if (isSuccessful(statusCode)) {\n this.adapter.visitRequestCompleted(this);\n } else {\n this.adapter.visitRequestFailedWithStatusCode(this, statusCode);\n }\n }\n }\n }, {\n key: \"finishRequest\",\n value: function finishRequest() {\n this.recordTimingMetric(TimingMetric.requestEnd);\n this.adapter.visitRequestFinished(this);\n }\n }, {\n key: \"loadResponse\",\n value: function loadResponse() {\n var _this16 = this;\n\n if (this.response) {\n var _this$response = this.response,\n statusCode = _this$response.statusCode,\n responseHTML = _this$response.responseHTML;\n this.render( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {\n return _regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n _this16.cacheSnapshot();\n\n if (!(isSuccessful(statusCode) && responseHTML != null)) {\n _context7.next = 8;\n break;\n }\n\n _context7.next = 4;\n return _this16.view.renderPage(PageSnapshot.fromHTMLString(responseHTML));\n\n case 4:\n _this16.adapter.visitRendered(_this16);\n\n _this16.complete();\n\n _context7.next = 12;\n break;\n\n case 8:\n _context7.next = 10;\n return _this16.view.renderError(PageSnapshot.fromHTMLString(responseHTML));\n\n case 10:\n _this16.adapter.visitRendered(_this16);\n\n _this16.fail();\n\n case 12:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7);\n })));\n }\n }\n }, {\n key: \"getCachedSnapshot\",\n value: function getCachedSnapshot() {\n var snapshot = this.view.getCachedSnapshotForLocation(this.location) || this.getPreloadedSnapshot();\n\n if (snapshot && (!getAnchor(this.location) || snapshot.hasAnchor(getAnchor(this.location)))) {\n if (this.action == \"restore\" || snapshot.isPreviewable) {\n return snapshot;\n }\n }\n }\n }, {\n key: \"getPreloadedSnapshot\",\n value: function getPreloadedSnapshot() {\n if (this.snapshotHTML) {\n return PageSnapshot.fromHTMLString(this.snapshotHTML);\n }\n }\n }, {\n key: \"hasCachedSnapshot\",\n value: function hasCachedSnapshot() {\n return this.getCachedSnapshot() != null;\n }\n }, {\n key: \"loadCachedSnapshot\",\n value: function loadCachedSnapshot() {\n var _this17 = this;\n\n var snapshot = this.getCachedSnapshot();\n\n if (snapshot) {\n var isPreview = this.shouldIssueRequest();\n this.render( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {\n return _regeneratorRuntime.wrap(function _callee8$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n _this17.cacheSnapshot();\n\n _context8.next = 3;\n return _this17.view.renderPage(snapshot, isPreview);\n\n case 3:\n _this17.adapter.visitRendered(_this17);\n\n if (!isPreview) {\n _this17.complete();\n }\n\n case 5:\n case \"end\":\n return _context8.stop();\n }\n }\n }, _callee8);\n })));\n }\n }\n }, {\n key: \"followRedirect\",\n value: function followRedirect() {\n if (this.redirectedToLocation && !this.followedRedirect) {\n this.location = this.redirectedToLocation;\n this.history.replace(this.redirectedToLocation, this.restorationIdentifier);\n this.followedRedirect = true;\n }\n }\n }, {\n key: \"requestStarted\",\n value: function requestStarted() {\n this.startRequest();\n }\n }, {\n key: \"requestPreventedHandlingResponse\",\n value: function requestPreventedHandlingResponse(request, response) {}\n }, {\n key: \"requestSucceededWithResponse\",\n value: function () {\n var _requestSucceededWithResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(request, response) {\n var responseHTML;\n return _regeneratorRuntime.wrap(function _callee9$(_context9) {\n while (1) {\n switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return response.responseHTML;\n\n case 2:\n responseHTML = _context9.sent;\n\n if (responseHTML == undefined) {\n this.recordResponse({\n statusCode: SystemStatusCode.contentTypeMismatch\n });\n } else {\n this.redirectedToLocation = response.redirected ? response.location : undefined;\n this.recordResponse({\n statusCode: response.statusCode,\n responseHTML: responseHTML\n });\n }\n\n case 4:\n case \"end\":\n return _context9.stop();\n }\n }\n }, _callee9, this);\n }));\n\n function requestSucceededWithResponse(_x4, _x5) {\n return _requestSucceededWithResponse.apply(this, arguments);\n }\n\n return requestSucceededWithResponse;\n }()\n }, {\n key: \"requestFailedWithResponse\",\n value: function () {\n var _requestFailedWithResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(request, response) {\n var responseHTML;\n return _regeneratorRuntime.wrap(function _callee10$(_context10) {\n while (1) {\n switch (_context10.prev = _context10.next) {\n case 0:\n _context10.next = 2;\n return response.responseHTML;\n\n case 2:\n responseHTML = _context10.sent;\n\n if (responseHTML == undefined) {\n this.recordResponse({\n statusCode: SystemStatusCode.contentTypeMismatch\n });\n } else {\n this.recordResponse({\n statusCode: response.statusCode,\n responseHTML: responseHTML\n });\n }\n\n case 4:\n case \"end\":\n return _context10.stop();\n }\n }\n }, _callee10, this);\n }));\n\n function requestFailedWithResponse(_x6, _x7) {\n return _requestFailedWithResponse.apply(this, arguments);\n }\n\n return requestFailedWithResponse;\n }()\n }, {\n key: \"requestErrored\",\n value: function requestErrored(request, error) {\n this.recordResponse({\n statusCode: SystemStatusCode.networkFailure\n });\n }\n }, {\n key: \"requestFinished\",\n value: function requestFinished() {\n this.finishRequest();\n }\n }, {\n key: \"performScroll\",\n value: function performScroll() {\n if (!this.scrolled) {\n if (this.action == \"restore\") {\n this.scrollToRestoredPosition() || this.scrollToTop();\n } else {\n this.scrollToAnchor() || this.scrollToTop();\n }\n\n this.scrolled = true;\n }\n }\n }, {\n key: \"scrollToRestoredPosition\",\n value: function scrollToRestoredPosition() {\n var scrollPosition = this.restorationData.scrollPosition;\n\n if (scrollPosition) {\n this.view.scrollToPosition(scrollPosition);\n return true;\n }\n }\n }, {\n key: \"scrollToAnchor\",\n value: function scrollToAnchor() {\n if (getAnchor(this.location) != null) {\n this.view.scrollToAnchor(getAnchor(this.location));\n return true;\n }\n }\n }, {\n key: \"scrollToTop\",\n value: function scrollToTop() {\n this.view.scrollToPosition({\n x: 0,\n y: 0\n });\n }\n }, {\n key: \"recordTimingMetric\",\n value: function recordTimingMetric(metric) {\n this.timingMetrics[metric] = new Date().getTime();\n }\n }, {\n key: \"getTimingMetrics\",\n value: function getTimingMetrics() {\n return Object.assign({}, this.timingMetrics);\n }\n }, {\n key: \"getHistoryMethodForAction\",\n value: function getHistoryMethodForAction(action) {\n switch (action) {\n case \"replace\":\n return history.replaceState;\n\n case \"advance\":\n case \"restore\":\n return history.pushState;\n }\n }\n }, {\n key: \"hasPreloadedResponse\",\n value: function hasPreloadedResponse() {\n return _typeof(this.response) == \"object\";\n }\n }, {\n key: \"shouldIssueRequest\",\n value: function shouldIssueRequest() {\n return this.action == \"restore\" ? !this.hasCachedSnapshot() : true;\n }\n }, {\n key: \"cacheSnapshot\",\n value: function cacheSnapshot() {\n if (!this.snapshotCached) {\n this.view.cacheSnapshot();\n this.snapshotCached = true;\n }\n }\n }, {\n key: \"render\",\n value: function () {\n var _render3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(callback) {\n var _this18 = this;\n\n return _regeneratorRuntime.wrap(function _callee11$(_context11) {\n while (1) {\n switch (_context11.prev = _context11.next) {\n case 0:\n this.cancelRender();\n _context11.next = 3;\n return new Promise(function (resolve) {\n _this18.frame = requestAnimationFrame(function () {\n return resolve();\n });\n });\n\n case 3:\n callback();\n delete this.frame;\n this.performScroll();\n\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }\n }, _callee11, this);\n }));\n\n function render(_x8) {\n return _render3.apply(this, arguments);\n }\n\n return render;\n }()\n }, {\n key: \"cancelRender\",\n value: function cancelRender() {\n if (this.frame) {\n cancelAnimationFrame(this.frame);\n delete this.frame;\n }\n }\n }]);\n\n return Visit;\n}();\n\nfunction isSuccessful(statusCode) {\n return statusCode >= 200 && statusCode < 300;\n}\n\nvar BrowserAdapter = /*#__PURE__*/function () {\n function BrowserAdapter(session) {\n var _this19 = this;\n\n _classCallCheck(this, BrowserAdapter);\n\n this.progressBar = new ProgressBar();\n\n this.showProgressBar = function () {\n _this19.progressBar.show();\n };\n\n this.session = session;\n }\n\n _createClass(BrowserAdapter, [{\n key: \"visitProposedToLocation\",\n value: function visitProposedToLocation(location, options) {\n this.navigator.startVisit(location, uuid(), options);\n }\n }, {\n key: \"visitStarted\",\n value: function visitStarted(visit) {\n visit.issueRequest();\n visit.changeHistory();\n visit.loadCachedSnapshot();\n }\n }, {\n key: \"visitRequestStarted\",\n value: function visitRequestStarted(visit) {\n this.progressBar.setValue(0);\n\n if (visit.hasCachedSnapshot() || visit.action != \"restore\") {\n this.showProgressBarAfterDelay();\n } else {\n this.showProgressBar();\n }\n }\n }, {\n key: \"visitRequestCompleted\",\n value: function visitRequestCompleted(visit) {\n visit.loadResponse();\n }\n }, {\n key: \"visitRequestFailedWithStatusCode\",\n value: function visitRequestFailedWithStatusCode(visit, statusCode) {\n switch (statusCode) {\n case SystemStatusCode.networkFailure:\n case SystemStatusCode.timeoutFailure:\n case SystemStatusCode.contentTypeMismatch:\n return this.reload();\n\n default:\n return visit.loadResponse();\n }\n }\n }, {\n key: \"visitRequestFinished\",\n value: function visitRequestFinished(visit) {\n this.progressBar.setValue(1);\n this.hideProgressBar();\n }\n }, {\n key: \"visitCompleted\",\n value: function visitCompleted(visit) {\n visit.followRedirect();\n }\n }, {\n key: \"pageInvalidated\",\n value: function pageInvalidated() {\n this.reload();\n }\n }, {\n key: \"visitFailed\",\n value: function visitFailed(visit) {}\n }, {\n key: \"visitRendered\",\n value: function visitRendered(visit) {}\n }, {\n key: \"showProgressBarAfterDelay\",\n value: function showProgressBarAfterDelay() {\n this.progressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay);\n }\n }, {\n key: \"hideProgressBar\",\n value: function hideProgressBar() {\n this.progressBar.hide();\n\n if (this.progressBarTimeout != null) {\n window.clearTimeout(this.progressBarTimeout);\n delete this.progressBarTimeout;\n }\n }\n }, {\n key: \"reload\",\n value: function reload() {\n window.location.reload();\n }\n }, {\n key: \"navigator\",\n get: function get() {\n return this.session.navigator;\n }\n }]);\n\n return BrowserAdapter;\n}();\n\nvar FormSubmitObserver = /*#__PURE__*/function () {\n function FormSubmitObserver(delegate) {\n var _this20 = this;\n\n _classCallCheck(this, FormSubmitObserver);\n\n this.started = false;\n\n this.submitCaptured = function () {\n removeEventListener(\"submit\", _this20.submitBubbled, false);\n addEventListener(\"submit\", _this20.submitBubbled, false);\n };\n\n this.submitBubbled = function (event) {\n if (!event.defaultPrevented) {\n var form = event.target instanceof HTMLFormElement ? event.target : undefined;\n var submitter = event.submitter || undefined;\n\n if (form) {\n var method = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"formmethod\")) || form.method;\n\n if (method != \"dialog\" && _this20.delegate.willSubmitForm(form, submitter)) {\n event.preventDefault();\n\n _this20.delegate.formSubmitted(form, submitter);\n }\n }\n }\n };\n\n this.delegate = delegate;\n }\n\n _createClass(FormSubmitObserver, [{\n key: \"start\",\n value: function start() {\n if (!this.started) {\n addEventListener(\"submit\", this.submitCaptured, true);\n this.started = true;\n }\n }\n }, {\n key: \"stop\",\n value: function stop() {\n if (this.started) {\n removeEventListener(\"submit\", this.submitCaptured, true);\n this.started = false;\n }\n }\n }]);\n\n return FormSubmitObserver;\n}();\n\nvar FrameRedirector = /*#__PURE__*/function () {\n function FrameRedirector(element) {\n _classCallCheck(this, FrameRedirector);\n\n this.element = element;\n this.linkInterceptor = new LinkInterceptor(this, element);\n this.formInterceptor = new FormInterceptor(this, element);\n }\n\n _createClass(FrameRedirector, [{\n key: \"start\",\n value: function start() {\n this.linkInterceptor.start();\n this.formInterceptor.start();\n }\n }, {\n key: \"stop\",\n value: function stop() {\n this.linkInterceptor.stop();\n this.formInterceptor.stop();\n }\n }, {\n key: \"shouldInterceptLinkClick\",\n value: function shouldInterceptLinkClick(element, url) {\n return this.shouldRedirect(element);\n }\n }, {\n key: \"linkClickIntercepted\",\n value: function linkClickIntercepted(element, url) {\n var frame = this.findFrameElement(element);\n\n if (frame) {\n frame.src = url;\n }\n }\n }, {\n key: \"shouldInterceptFormSubmission\",\n value: function shouldInterceptFormSubmission(element, submitter) {\n return this.shouldRedirect(element, submitter);\n }\n }, {\n key: \"formSubmissionIntercepted\",\n value: function formSubmissionIntercepted(element, submitter) {\n var frame = this.findFrameElement(element);\n\n if (frame) {\n frame.delegate.formSubmissionIntercepted(element, submitter);\n }\n }\n }, {\n key: \"shouldRedirect\",\n value: function shouldRedirect(element, submitter) {\n var frame = this.findFrameElement(element);\n return frame ? frame != element.closest(\"turbo-frame\") : false;\n }\n }, {\n key: \"findFrameElement\",\n value: function findFrameElement(element) {\n var id = element.getAttribute(\"data-turbo-frame\");\n\n if (id && id != \"_top\") {\n var frame = this.element.querySelector(\"#\".concat(id, \":not([disabled])\"));\n\n if (frame instanceof FrameElement) {\n return frame;\n }\n }\n }\n }]);\n\n return FrameRedirector;\n}();\n\nvar History = /*#__PURE__*/function () {\n function History(delegate) {\n var _this21 = this;\n\n _classCallCheck(this, History);\n\n this.restorationIdentifier = uuid();\n this.restorationData = {};\n this.started = false;\n this.pageLoaded = false;\n\n this.onPopState = function (event) {\n if (_this21.shouldHandlePopState()) {\n var _ref15 = event.state || {},\n turbo = _ref15.turbo;\n\n if (turbo) {\n _this21.location = new URL(window.location.href);\n var restorationIdentifier = turbo.restorationIdentifier;\n _this21.restorationIdentifier = restorationIdentifier;\n\n _this21.delegate.historyPoppedToLocationWithRestorationIdentifier(_this21.location, restorationIdentifier);\n }\n }\n };\n\n this.onPageLoad = /*#__PURE__*/function () {\n var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(event) {\n return _regeneratorRuntime.wrap(function _callee12$(_context12) {\n while (1) {\n switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return nextMicrotask();\n\n case 2:\n _this21.pageLoaded = true;\n\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }\n }, _callee12);\n }));\n\n return function (_x9) {\n return _ref16.apply(this, arguments);\n };\n }();\n\n this.delegate = delegate;\n }\n\n _createClass(History, [{\n key: \"start\",\n value: function start() {\n if (!this.started) {\n addEventListener(\"popstate\", this.onPopState, false);\n addEventListener(\"load\", this.onPageLoad, false);\n this.started = true;\n this.replace(new URL(window.location.href));\n }\n }\n }, {\n key: \"stop\",\n value: function stop() {\n if (this.started) {\n removeEventListener(\"popstate\", this.onPopState, false);\n removeEventListener(\"load\", this.onPageLoad, false);\n this.started = false;\n }\n }\n }, {\n key: \"push\",\n value: function push(location, restorationIdentifier) {\n this.update(history.pushState, location, restorationIdentifier);\n }\n }, {\n key: \"replace\",\n value: function replace(location, restorationIdentifier) {\n this.update(history.replaceState, location, restorationIdentifier);\n }\n }, {\n key: \"update\",\n value: function update(method, location) {\n var restorationIdentifier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : uuid();\n var state = {\n turbo: {\n restorationIdentifier: restorationIdentifier\n }\n };\n method.call(history, state, \"\", location.href);\n this.location = location;\n this.restorationIdentifier = restorationIdentifier;\n }\n }, {\n key: \"getRestorationDataForIdentifier\",\n value: function getRestorationDataForIdentifier(restorationIdentifier) {\n return this.restorationData[restorationIdentifier] || {};\n }\n }, {\n key: \"updateRestorationData\",\n value: function updateRestorationData(additionalData) {\n var restorationIdentifier = this.restorationIdentifier;\n var restorationData = this.restorationData[restorationIdentifier];\n this.restorationData[restorationIdentifier] = Object.assign(Object.assign({}, restorationData), additionalData);\n }\n }, {\n key: \"assumeControlOfScrollRestoration\",\n value: function assumeControlOfScrollRestoration() {\n var _a;\n\n if (!this.previousScrollRestoration) {\n this.previousScrollRestoration = (_a = history.scrollRestoration) !== null && _a !== void 0 ? _a : \"auto\";\n history.scrollRestoration = \"manual\";\n }\n }\n }, {\n key: \"relinquishControlOfScrollRestoration\",\n value: function relinquishControlOfScrollRestoration() {\n if (this.previousScrollRestoration) {\n history.scrollRestoration = this.previousScrollRestoration;\n delete this.previousScrollRestoration;\n }\n }\n }, {\n key: \"shouldHandlePopState\",\n value: function shouldHandlePopState() {\n return this.pageIsLoaded();\n }\n }, {\n key: \"pageIsLoaded\",\n value: function pageIsLoaded() {\n return this.pageLoaded || document.readyState == \"complete\";\n }\n }]);\n\n return History;\n}();\n\nvar LinkClickObserver = /*#__PURE__*/function () {\n function LinkClickObserver(delegate) {\n var _this22 = this;\n\n _classCallCheck(this, LinkClickObserver);\n\n this.started = false;\n\n this.clickCaptured = function () {\n removeEventListener(\"click\", _this22.clickBubbled, false);\n addEventListener(\"click\", _this22.clickBubbled, false);\n };\n\n this.clickBubbled = function (event) {\n if (_this22.clickEventIsSignificant(event)) {\n var link = _this22.findLinkFromClickTarget(event.target);\n\n if (link) {\n var _location = _this22.getLocationForLink(link);\n\n if (_this22.delegate.willFollowLinkToLocation(link, _location)) {\n event.preventDefault();\n\n _this22.delegate.followedLinkToLocation(link, _location);\n }\n }\n }\n };\n\n this.delegate = delegate;\n }\n\n _createClass(LinkClickObserver, [{\n key: \"start\",\n value: function start() {\n if (!this.started) {\n addEventListener(\"click\", this.clickCaptured, true);\n this.started = true;\n }\n }\n }, {\n key: \"stop\",\n value: function stop() {\n if (this.started) {\n removeEventListener(\"click\", this.clickCaptured, true);\n this.started = false;\n }\n }\n }, {\n key: \"clickEventIsSignificant\",\n value: function clickEventIsSignificant(event) {\n return !(event.target && event.target.isContentEditable || event.defaultPrevented || event.which > 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey);\n }\n }, {\n key: \"findLinkFromClickTarget\",\n value: function findLinkFromClickTarget(target) {\n if (target instanceof Element) {\n return target.closest(\"a[href]:not([target^=_]):not([download])\");\n }\n }\n }, {\n key: \"getLocationForLink\",\n value: function getLocationForLink(link) {\n return expandURL(link.getAttribute(\"href\") || \"\");\n }\n }]);\n\n return LinkClickObserver;\n}();\n\nfunction isAction(action) {\n return action == \"advance\" || action == \"replace\" || action == \"restore\";\n}\n\nvar Navigator = /*#__PURE__*/function () {\n function Navigator(delegate) {\n _classCallCheck(this, Navigator);\n\n this.delegate = delegate;\n }\n\n _createClass(Navigator, [{\n key: \"proposeVisit\",\n value: function proposeVisit(location) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (this.delegate.allowsVisitingLocation(location)) {\n this.delegate.visitProposedToLocation(location, options);\n }\n }\n }, {\n key: \"startVisit\",\n value: function startVisit(locatable, restorationIdentifier) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n this.stop();\n this.currentVisit = new Visit(this, expandURL(locatable), restorationIdentifier, Object.assign({\n referrer: this.location\n }, options));\n this.currentVisit.start();\n }\n }, {\n key: \"submitForm\",\n value: function submitForm(form, submitter) {\n this.stop();\n this.formSubmission = new FormSubmission(this, form, submitter, true);\n\n if (this.formSubmission.isIdempotent) {\n this.proposeVisit(this.formSubmission.fetchRequest.url, {\n action: this.getActionForFormSubmission(this.formSubmission)\n });\n } else {\n this.formSubmission.start();\n }\n }\n }, {\n key: \"stop\",\n value: function stop() {\n if (this.formSubmission) {\n this.formSubmission.stop();\n delete this.formSubmission;\n }\n\n if (this.currentVisit) {\n this.currentVisit.cancel();\n delete this.currentVisit;\n }\n }\n }, {\n key: \"adapter\",\n get: function get() {\n return this.delegate.adapter;\n }\n }, {\n key: \"view\",\n get: function get() {\n return this.delegate.view;\n }\n }, {\n key: \"history\",\n get: function get() {\n return this.delegate.history;\n }\n }, {\n key: \"formSubmissionStarted\",\n value: function formSubmissionStarted(formSubmission) {}\n }, {\n key: \"formSubmissionSucceededWithResponse\",\n value: function () {\n var _formSubmissionSucceededWithResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(formSubmission, fetchResponse) {\n var responseHTML, statusCode, visitOptions;\n return _regeneratorRuntime.wrap(function _callee13$(_context13) {\n while (1) {\n switch (_context13.prev = _context13.next) {\n case 0:\n if (!(formSubmission == this.formSubmission)) {\n _context13.next = 5;\n break;\n }\n\n _context13.next = 3;\n return fetchResponse.responseHTML;\n\n case 3:\n responseHTML = _context13.sent;\n\n if (responseHTML) {\n if (formSubmission.method != FetchMethod.get) {\n this.view.clearSnapshotCache();\n }\n\n statusCode = fetchResponse.statusCode;\n visitOptions = {\n response: {\n statusCode: statusCode,\n responseHTML: responseHTML\n }\n };\n this.proposeVisit(fetchResponse.location, visitOptions);\n }\n\n case 5:\n case \"end\":\n return _context13.stop();\n }\n }\n }, _callee13, this);\n }));\n\n function formSubmissionSucceededWithResponse(_x10, _x11) {\n return _formSubmissionSucceededWithResponse.apply(this, arguments);\n }\n\n return formSubmissionSucceededWithResponse;\n }()\n }, {\n key: \"formSubmissionFailedWithResponse\",\n value: function () {\n var _formSubmissionFailedWithResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(formSubmission, fetchResponse) {\n var responseHTML, snapshot;\n return _regeneratorRuntime.wrap(function _callee14$(_context14) {\n while (1) {\n switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return fetchResponse.responseHTML;\n\n case 2:\n responseHTML = _context14.sent;\n\n if (!responseHTML) {\n _context14.next = 8;\n break;\n }\n\n snapshot = PageSnapshot.fromHTMLString(responseHTML);\n _context14.next = 7;\n return this.view.renderPage(snapshot);\n\n case 7:\n this.view.clearSnapshotCache();\n\n case 8:\n case \"end\":\n return _context14.stop();\n }\n }\n }, _callee14, this);\n }));\n\n function formSubmissionFailedWithResponse(_x12, _x13) {\n return _formSubmissionFailedWithResponse.apply(this, arguments);\n }\n\n return formSubmissionFailedWithResponse;\n }()\n }, {\n key: \"formSubmissionErrored\",\n value: function formSubmissionErrored(formSubmission, error) {\n console.error(error);\n }\n }, {\n key: \"formSubmissionFinished\",\n value: function formSubmissionFinished(formSubmission) {}\n }, {\n key: \"visitStarted\",\n value: function visitStarted(visit) {\n this.delegate.visitStarted(visit);\n }\n }, {\n key: \"visitCompleted\",\n value: function visitCompleted(visit) {\n this.delegate.visitCompleted(visit);\n }\n }, {\n key: \"location\",\n get: function get() {\n return this.history.location;\n }\n }, {\n key: \"restorationIdentifier\",\n get: function get() {\n return this.history.restorationIdentifier;\n }\n }, {\n key: \"getActionForFormSubmission\",\n value: function getActionForFormSubmission(formSubmission) {\n var formElement = formSubmission.formElement,\n submitter = formSubmission.submitter;\n var action = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"data-turbo-action\")) || formElement.getAttribute(\"data-turbo-action\");\n return isAction(action) ? action : \"advance\";\n }\n }]);\n\n return Navigator;\n}();\n\nvar PageStage;\n\n(function (PageStage) {\n PageStage[PageStage[\"initial\"] = 0] = \"initial\";\n PageStage[PageStage[\"loading\"] = 1] = \"loading\";\n PageStage[PageStage[\"interactive\"] = 2] = \"interactive\";\n PageStage[PageStage[\"complete\"] = 3] = \"complete\";\n})(PageStage || (PageStage = {}));\n\nvar PageObserver = /*#__PURE__*/function () {\n function PageObserver(delegate) {\n var _this23 = this;\n\n _classCallCheck(this, PageObserver);\n\n this.stage = PageStage.initial;\n this.started = false;\n\n this.interpretReadyState = function () {\n var readyState = _this23.readyState;\n\n if (readyState == \"interactive\") {\n _this23.pageIsInteractive();\n } else if (readyState == \"complete\") {\n _this23.pageIsComplete();\n }\n };\n\n this.pageWillUnload = function () {\n _this23.delegate.pageWillUnload();\n };\n\n this.delegate = delegate;\n }\n\n _createClass(PageObserver, [{\n key: \"start\",\n value: function start() {\n if (!this.started) {\n if (this.stage == PageStage.initial) {\n this.stage = PageStage.loading;\n }\n\n document.addEventListener(\"readystatechange\", this.interpretReadyState, false);\n addEventListener(\"pagehide\", this.pageWillUnload, false);\n this.started = true;\n }\n }\n }, {\n key: \"stop\",\n value: function stop() {\n if (this.started) {\n document.removeEventListener(\"readystatechange\", this.interpretReadyState, false);\n removeEventListener(\"pagehide\", this.pageWillUnload, false);\n this.started = false;\n }\n }\n }, {\n key: \"pageIsInteractive\",\n value: function pageIsInteractive() {\n if (this.stage == PageStage.loading) {\n this.stage = PageStage.interactive;\n this.delegate.pageBecameInteractive();\n }\n }\n }, {\n key: \"pageIsComplete\",\n value: function pageIsComplete() {\n this.pageIsInteractive();\n\n if (this.stage == PageStage.interactive) {\n this.stage = PageStage.complete;\n this.delegate.pageLoaded();\n }\n }\n }, {\n key: \"readyState\",\n get: function get() {\n return document.readyState;\n }\n }]);\n\n return PageObserver;\n}();\n\nvar ScrollObserver = /*#__PURE__*/function () {\n function ScrollObserver(delegate) {\n var _this24 = this;\n\n _classCallCheck(this, ScrollObserver);\n\n this.started = false;\n\n this.onScroll = function () {\n _this24.updatePosition({\n x: window.pageXOffset,\n y: window.pageYOffset\n });\n };\n\n this.delegate = delegate;\n }\n\n _createClass(ScrollObserver, [{\n key: \"start\",\n value: function start() {\n if (!this.started) {\n addEventListener(\"scroll\", this.onScroll, false);\n this.onScroll();\n this.started = true;\n }\n }\n }, {\n key: \"stop\",\n value: function stop() {\n if (this.started) {\n removeEventListener(\"scroll\", this.onScroll, false);\n this.started = false;\n }\n }\n }, {\n key: \"updatePosition\",\n value: function updatePosition(position) {\n this.delegate.scrollPositionChanged(position);\n }\n }]);\n\n return ScrollObserver;\n}();\n\nvar StreamObserver = /*#__PURE__*/function () {\n function StreamObserver(delegate) {\n var _this25 = this;\n\n _classCallCheck(this, StreamObserver);\n\n this.sources = new Set();\n this.started = false;\n\n this.inspectFetchResponse = function (event) {\n var response = fetchResponseFromEvent(event);\n\n if (response && fetchResponseIsStream(response)) {\n event.preventDefault();\n\n _this25.receiveMessageResponse(response);\n }\n };\n\n this.receiveMessageEvent = function (event) {\n if (_this25.started && typeof event.data == \"string\") {\n _this25.receiveMessageHTML(event.data);\n }\n };\n\n this.delegate = delegate;\n }\n\n _createClass(StreamObserver, [{\n key: \"start\",\n value: function start() {\n if (!this.started) {\n this.started = true;\n addEventListener(\"turbo:before-fetch-response\", this.inspectFetchResponse, false);\n }\n }\n }, {\n key: \"stop\",\n value: function stop() {\n if (this.started) {\n this.started = false;\n removeEventListener(\"turbo:before-fetch-response\", this.inspectFetchResponse, false);\n }\n }\n }, {\n key: \"connectStreamSource\",\n value: function connectStreamSource(source) {\n if (!this.streamSourceIsConnected(source)) {\n this.sources.add(source);\n source.addEventListener(\"message\", this.receiveMessageEvent, false);\n }\n }\n }, {\n key: \"disconnectStreamSource\",\n value: function disconnectStreamSource(source) {\n if (this.streamSourceIsConnected(source)) {\n this.sources.delete(source);\n source.removeEventListener(\"message\", this.receiveMessageEvent, false);\n }\n }\n }, {\n key: \"streamSourceIsConnected\",\n value: function streamSourceIsConnected(source) {\n return this.sources.has(source);\n }\n }, {\n key: \"receiveMessageResponse\",\n value: function () {\n var _receiveMessageResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(response) {\n var html;\n return _regeneratorRuntime.wrap(function _callee15$(_context15) {\n while (1) {\n switch (_context15.prev = _context15.next) {\n case 0:\n _context15.next = 2;\n return response.responseHTML;\n\n case 2:\n html = _context15.sent;\n\n if (html) {\n this.receiveMessageHTML(html);\n }\n\n case 4:\n case \"end\":\n return _context15.stop();\n }\n }\n }, _callee15, this);\n }));\n\n function receiveMessageResponse(_x14) {\n return _receiveMessageResponse.apply(this, arguments);\n }\n\n return receiveMessageResponse;\n }()\n }, {\n key: \"receiveMessageHTML\",\n value: function receiveMessageHTML(html) {\n this.delegate.receivedMessageFromStream(new StreamMessage(html));\n }\n }]);\n\n return StreamObserver;\n}();\n\nfunction fetchResponseFromEvent(event) {\n var _a;\n\n var fetchResponse = (_a = event.detail) === null || _a === void 0 ? void 0 : _a.fetchResponse;\n\n if (fetchResponse instanceof FetchResponse) {\n return fetchResponse;\n }\n}\n\nfunction fetchResponseIsStream(response) {\n var _a;\n\n var contentType = (_a = response.contentType) !== null && _a !== void 0 ? _a : \"\";\n return contentType.startsWith(StreamMessage.contentType);\n}\n\nvar ErrorRenderer = /*#__PURE__*/function (_Renderer2) {\n _inherits(ErrorRenderer, _Renderer2);\n\n var _super6 = _createSuper(ErrorRenderer);\n\n function ErrorRenderer() {\n _classCallCheck(this, ErrorRenderer);\n\n return _super6.apply(this, arguments);\n }\n\n _createClass(ErrorRenderer, [{\n key: \"render\",\n value: function () {\n var _render4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {\n return _regeneratorRuntime.wrap(function _callee16$(_context16) {\n while (1) {\n switch (_context16.prev = _context16.next) {\n case 0:\n this.replaceHeadAndBody();\n this.activateScriptElements();\n\n case 2:\n case \"end\":\n return _context16.stop();\n }\n }\n }, _callee16, this);\n }));\n\n function render() {\n return _render4.apply(this, arguments);\n }\n\n return render;\n }()\n }, {\n key: \"replaceHeadAndBody\",\n value: function replaceHeadAndBody() {\n var _document = document,\n documentElement = _document.documentElement,\n head = _document.head,\n body = _document.body;\n documentElement.replaceChild(this.newHead, head);\n documentElement.replaceChild(this.newElement, body);\n }\n }, {\n key: \"activateScriptElements\",\n value: function activateScriptElements() {\n var _iterator4 = _createForOfIteratorHelper(this.scriptElements),\n _step4;\n\n try {\n for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {\n var replaceableElement = _step4.value;\n var parentNode = replaceableElement.parentNode;\n\n if (parentNode) {\n var element = this.createScriptElement(replaceableElement);\n parentNode.replaceChild(element, replaceableElement);\n }\n }\n } catch (err) {\n _iterator4.e(err);\n } finally {\n _iterator4.f();\n }\n }\n }, {\n key: \"newHead\",\n get: function get() {\n return this.newSnapshot.headSnapshot.element;\n }\n }, {\n key: \"scriptElements\",\n get: function get() {\n return _toConsumableArray(document.documentElement.querySelectorAll(\"script\"));\n }\n }]);\n\n return ErrorRenderer;\n}(Renderer);\n\nvar PageRenderer = /*#__PURE__*/function (_Renderer3) {\n _inherits(PageRenderer, _Renderer3);\n\n var _super7 = _createSuper(PageRenderer);\n\n function PageRenderer() {\n _classCallCheck(this, PageRenderer);\n\n return _super7.apply(this, arguments);\n }\n\n _createClass(PageRenderer, [{\n key: \"shouldRender\",\n get: function get() {\n return this.newSnapshot.isVisitable && this.trackedElementsAreIdentical;\n }\n }, {\n key: \"prepareToRender\",\n value: function prepareToRender() {\n this.mergeHead();\n }\n }, {\n key: \"render\",\n value: function () {\n var _render5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {\n return _regeneratorRuntime.wrap(function _callee17$(_context17) {\n while (1) {\n switch (_context17.prev = _context17.next) {\n case 0:\n this.replaceBody();\n\n case 1:\n case \"end\":\n return _context17.stop();\n }\n }\n }, _callee17, this);\n }));\n\n function render() {\n return _render5.apply(this, arguments);\n }\n\n return render;\n }()\n }, {\n key: \"finishRendering\",\n value: function finishRendering() {\n _get(_getPrototypeOf(PageRenderer.prototype), \"finishRendering\", this).call(this);\n\n if (!this.isPreview) {\n this.focusFirstAutofocusableElement();\n }\n }\n }, {\n key: \"currentHeadSnapshot\",\n get: function get() {\n return this.currentSnapshot.headSnapshot;\n }\n }, {\n key: \"newHeadSnapshot\",\n get: function get() {\n return this.newSnapshot.headSnapshot;\n }\n }, {\n key: \"newElement\",\n get: function get() {\n return this.newSnapshot.element;\n }\n }, {\n key: \"mergeHead\",\n value: function mergeHead() {\n this.copyNewHeadStylesheetElements();\n this.copyNewHeadScriptElements();\n this.removeCurrentHeadProvisionalElements();\n this.copyNewHeadProvisionalElements();\n }\n }, {\n key: \"replaceBody\",\n value: function replaceBody() {\n var _this26 = this;\n\n this.preservingPermanentElements(function () {\n _this26.activateNewBody();\n\n _this26.assignNewBody();\n });\n }\n }, {\n key: \"trackedElementsAreIdentical\",\n get: function get() {\n return this.currentHeadSnapshot.trackedElementSignature == this.newHeadSnapshot.trackedElementSignature;\n }\n }, {\n key: \"copyNewHeadStylesheetElements\",\n value: function copyNewHeadStylesheetElements() {\n var _iterator5 = _createForOfIteratorHelper(this.newHeadStylesheetElements),\n _step5;\n\n try {\n for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {\n var element = _step5.value;\n document.head.appendChild(element);\n }\n } catch (err) {\n _iterator5.e(err);\n } finally {\n _iterator5.f();\n }\n }\n }, {\n key: \"copyNewHeadScriptElements\",\n value: function copyNewHeadScriptElements() {\n var _iterator6 = _createForOfIteratorHelper(this.newHeadScriptElements),\n _step6;\n\n try {\n for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {\n var element = _step6.value;\n document.head.appendChild(this.createScriptElement(element));\n }\n } catch (err) {\n _iterator6.e(err);\n } finally {\n _iterator6.f();\n }\n }\n }, {\n key: \"removeCurrentHeadProvisionalElements\",\n value: function removeCurrentHeadProvisionalElements() {\n var _iterator7 = _createForOfIteratorHelper(this.currentHeadProvisionalElements),\n _step7;\n\n try {\n for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {\n var element = _step7.value;\n document.head.removeChild(element);\n }\n } catch (err) {\n _iterator7.e(err);\n } finally {\n _iterator7.f();\n }\n }\n }, {\n key: \"copyNewHeadProvisionalElements\",\n value: function copyNewHeadProvisionalElements() {\n var _iterator8 = _createForOfIteratorHelper(this.newHeadProvisionalElements),\n _step8;\n\n try {\n for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {\n var element = _step8.value;\n document.head.appendChild(element);\n }\n } catch (err) {\n _iterator8.e(err);\n } finally {\n _iterator8.f();\n }\n }\n }, {\n key: \"activateNewBody\",\n value: function activateNewBody() {\n document.adoptNode(this.newElement);\n this.activateNewBodyScriptElements();\n }\n }, {\n key: \"activateNewBodyScriptElements\",\n value: function activateNewBodyScriptElements() {\n var _iterator9 = _createForOfIteratorHelper(this.newBodyScriptElements),\n _step9;\n\n try {\n for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {\n var inertScriptElement = _step9.value;\n var activatedScriptElement = this.createScriptElement(inertScriptElement);\n inertScriptElement.replaceWith(activatedScriptElement);\n }\n } catch (err) {\n _iterator9.e(err);\n } finally {\n _iterator9.f();\n }\n }\n }, {\n key: \"assignNewBody\",\n value: function assignNewBody() {\n if (document.body && this.newElement instanceof HTMLBodyElement) {\n document.body.replaceWith(this.newElement);\n } else {\n document.documentElement.appendChild(this.newElement);\n }\n }\n }, {\n key: \"newHeadStylesheetElements\",\n get: function get() {\n return this.newHeadSnapshot.getStylesheetElementsNotInSnapshot(this.currentHeadSnapshot);\n }\n }, {\n key: \"newHeadScriptElements\",\n get: function get() {\n return this.newHeadSnapshot.getScriptElementsNotInSnapshot(this.currentHeadSnapshot);\n }\n }, {\n key: \"currentHeadProvisionalElements\",\n get: function get() {\n return this.currentHeadSnapshot.provisionalElements;\n }\n }, {\n key: \"newHeadProvisionalElements\",\n get: function get() {\n return this.newHeadSnapshot.provisionalElements;\n }\n }, {\n key: \"newBodyScriptElements\",\n get: function get() {\n return _toConsumableArray(this.newElement.querySelectorAll(\"script\"));\n }\n }]);\n\n return PageRenderer;\n}(Renderer);\n\nvar SnapshotCache = /*#__PURE__*/function () {\n function SnapshotCache(size) {\n _classCallCheck(this, SnapshotCache);\n\n this.keys = [];\n this.snapshots = {};\n this.size = size;\n }\n\n _createClass(SnapshotCache, [{\n key: \"has\",\n value: function has(location) {\n return toCacheKey(location) in this.snapshots;\n }\n }, {\n key: \"get\",\n value: function get(location) {\n if (this.has(location)) {\n var snapshot = this.read(location);\n this.touch(location);\n return snapshot;\n }\n }\n }, {\n key: \"put\",\n value: function put(location, snapshot) {\n this.write(location, snapshot);\n this.touch(location);\n return snapshot;\n }\n }, {\n key: \"clear\",\n value: function clear() {\n this.snapshots = {};\n }\n }, {\n key: \"read\",\n value: function read(location) {\n return this.snapshots[toCacheKey(location)];\n }\n }, {\n key: \"write\",\n value: function write(location, snapshot) {\n this.snapshots[toCacheKey(location)] = snapshot;\n }\n }, {\n key: \"touch\",\n value: function touch(location) {\n var key = toCacheKey(location);\n var index = this.keys.indexOf(key);\n if (index > -1) this.keys.splice(index, 1);\n this.keys.unshift(key);\n this.trim();\n }\n }, {\n key: \"trim\",\n value: function trim() {\n var _iterator10 = _createForOfIteratorHelper(this.keys.splice(this.size)),\n _step10;\n\n try {\n for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {\n var key = _step10.value;\n delete this.snapshots[key];\n }\n } catch (err) {\n _iterator10.e(err);\n } finally {\n _iterator10.f();\n }\n }\n }]);\n\n return SnapshotCache;\n}();\n\nvar PageView = /*#__PURE__*/function (_View2) {\n _inherits(PageView, _View2);\n\n var _super8 = _createSuper(PageView);\n\n function PageView() {\n var _this27;\n\n _classCallCheck(this, PageView);\n\n _this27 = _super8.apply(this, arguments);\n _this27.snapshotCache = new SnapshotCache(10);\n _this27.lastRenderedLocation = new URL(location.href);\n return _this27;\n }\n\n _createClass(PageView, [{\n key: \"renderPage\",\n value: function renderPage(snapshot) {\n var isPreview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var renderer = new PageRenderer(this.snapshot, snapshot, isPreview);\n return this.render(renderer);\n }\n }, {\n key: \"renderError\",\n value: function renderError(snapshot) {\n var renderer = new ErrorRenderer(this.snapshot, snapshot, false);\n this.render(renderer);\n }\n }, {\n key: \"clearSnapshotCache\",\n value: function clearSnapshotCache() {\n this.snapshotCache.clear();\n }\n }, {\n key: \"cacheSnapshot\",\n value: function () {\n var _cacheSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {\n var snapshot, _location2;\n\n return _regeneratorRuntime.wrap(function _callee18$(_context18) {\n while (1) {\n switch (_context18.prev = _context18.next) {\n case 0:\n if (!this.shouldCacheSnapshot) {\n _context18.next = 6;\n break;\n }\n\n this.delegate.viewWillCacheSnapshot();\n snapshot = this.snapshot, _location2 = this.lastRenderedLocation;\n _context18.next = 5;\n return nextEventLoopTick();\n\n case 5:\n this.snapshotCache.put(_location2, snapshot.clone());\n\n case 6:\n case \"end\":\n return _context18.stop();\n }\n }\n }, _callee18, this);\n }));\n\n function cacheSnapshot() {\n return _cacheSnapshot.apply(this, arguments);\n }\n\n return cacheSnapshot;\n }()\n }, {\n key: \"getCachedSnapshotForLocation\",\n value: function getCachedSnapshotForLocation(location) {\n return this.snapshotCache.get(location);\n }\n }, {\n key: \"snapshot\",\n get: function get() {\n return PageSnapshot.fromElement(this.element);\n }\n }, {\n key: \"shouldCacheSnapshot\",\n get: function get() {\n return this.snapshot.isCacheable;\n }\n }]);\n\n return PageView;\n}(View);\n\nvar Session = /*#__PURE__*/function () {\n function Session() {\n _classCallCheck(this, Session);\n\n this.navigator = new Navigator(this);\n this.history = new History(this);\n this.view = new PageView(this, document.documentElement);\n this.adapter = new BrowserAdapter(this);\n this.pageObserver = new PageObserver(this);\n this.linkClickObserver = new LinkClickObserver(this);\n this.formSubmitObserver = new FormSubmitObserver(this);\n this.scrollObserver = new ScrollObserver(this);\n this.streamObserver = new StreamObserver(this);\n this.frameRedirector = new FrameRedirector(document.documentElement);\n this.enabled = true;\n this.progressBarDelay = 500;\n this.started = false;\n }\n\n _createClass(Session, [{\n key: \"start\",\n value: function start() {\n if (!this.started) {\n this.pageObserver.start();\n this.linkClickObserver.start();\n this.formSubmitObserver.start();\n this.scrollObserver.start();\n this.streamObserver.start();\n this.frameRedirector.start();\n this.history.start();\n this.started = true;\n this.enabled = true;\n }\n }\n }, {\n key: \"disable\",\n value: function disable() {\n this.enabled = false;\n }\n }, {\n key: \"stop\",\n value: function stop() {\n if (this.started) {\n this.pageObserver.stop();\n this.linkClickObserver.stop();\n this.formSubmitObserver.stop();\n this.scrollObserver.stop();\n this.streamObserver.stop();\n this.frameRedirector.stop();\n this.history.stop();\n this.started = false;\n }\n }\n }, {\n key: \"registerAdapter\",\n value: function registerAdapter(adapter) {\n this.adapter = adapter;\n }\n }, {\n key: \"visit\",\n value: function visit(location) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n this.navigator.proposeVisit(expandURL(location), options);\n }\n }, {\n key: \"connectStreamSource\",\n value: function connectStreamSource(source) {\n this.streamObserver.connectStreamSource(source);\n }\n }, {\n key: \"disconnectStreamSource\",\n value: function disconnectStreamSource(source) {\n this.streamObserver.disconnectStreamSource(source);\n }\n }, {\n key: \"renderStreamMessage\",\n value: function renderStreamMessage(message) {\n document.documentElement.appendChild(StreamMessage.wrap(message).fragment);\n }\n }, {\n key: \"clearCache\",\n value: function clearCache() {\n this.view.clearSnapshotCache();\n }\n }, {\n key: \"setProgressBarDelay\",\n value: function setProgressBarDelay(delay) {\n this.progressBarDelay = delay;\n }\n }, {\n key: \"location\",\n get: function get() {\n return this.history.location;\n }\n }, {\n key: \"restorationIdentifier\",\n get: function get() {\n return this.history.restorationIdentifier;\n }\n }, {\n key: \"historyPoppedToLocationWithRestorationIdentifier\",\n value: function historyPoppedToLocationWithRestorationIdentifier(location) {\n if (this.enabled) {\n this.navigator.proposeVisit(location, {\n action: \"restore\",\n historyChanged: true\n });\n } else {\n this.adapter.pageInvalidated();\n }\n }\n }, {\n key: \"scrollPositionChanged\",\n value: function scrollPositionChanged(position) {\n this.history.updateRestorationData({\n scrollPosition: position\n });\n }\n }, {\n key: \"willFollowLinkToLocation\",\n value: function willFollowLinkToLocation(link, location) {\n return elementIsNavigable(link) && this.locationIsVisitable(location) && this.applicationAllowsFollowingLinkToLocation(link, location);\n }\n }, {\n key: \"followedLinkToLocation\",\n value: function followedLinkToLocation(link, location) {\n var action = this.getActionForLink(link);\n this.visit(location.href, {\n action: action\n });\n }\n }, {\n key: \"allowsVisitingLocation\",\n value: function allowsVisitingLocation(location) {\n return this.applicationAllowsVisitingLocation(location);\n }\n }, {\n key: \"visitProposedToLocation\",\n value: function visitProposedToLocation(location, options) {\n extendURLWithDeprecatedProperties(location);\n this.adapter.visitProposedToLocation(location, options);\n }\n }, {\n key: \"visitStarted\",\n value: function visitStarted(visit) {\n extendURLWithDeprecatedProperties(visit.location);\n this.notifyApplicationAfterVisitingLocation(visit.location);\n }\n }, {\n key: \"visitCompleted\",\n value: function visitCompleted(visit) {\n this.notifyApplicationAfterPageLoad(visit.getTimingMetrics());\n }\n }, {\n key: \"willSubmitForm\",\n value: function willSubmitForm(form, submitter) {\n return elementIsNavigable(form) && elementIsNavigable(submitter);\n }\n }, {\n key: \"formSubmitted\",\n value: function formSubmitted(form, submitter) {\n this.navigator.submitForm(form, submitter);\n }\n }, {\n key: \"pageBecameInteractive\",\n value: function pageBecameInteractive() {\n this.view.lastRenderedLocation = this.location;\n this.notifyApplicationAfterPageLoad();\n }\n }, {\n key: \"pageLoaded\",\n value: function pageLoaded() {\n this.history.assumeControlOfScrollRestoration();\n }\n }, {\n key: \"pageWillUnload\",\n value: function pageWillUnload() {\n this.history.relinquishControlOfScrollRestoration();\n }\n }, {\n key: \"receivedMessageFromStream\",\n value: function receivedMessageFromStream(message) {\n this.renderStreamMessage(message);\n }\n }, {\n key: \"viewWillCacheSnapshot\",\n value: function viewWillCacheSnapshot() {\n this.notifyApplicationBeforeCachingSnapshot();\n }\n }, {\n key: \"viewWillRenderSnapshot\",\n value: function viewWillRenderSnapshot(_ref17, isPreview) {\n var element = _ref17.element;\n this.notifyApplicationBeforeRender(element);\n }\n }, {\n key: \"viewRenderedSnapshot\",\n value: function viewRenderedSnapshot(snapshot, isPreview) {\n this.view.lastRenderedLocation = this.history.location;\n this.notifyApplicationAfterRender();\n }\n }, {\n key: \"viewInvalidated\",\n value: function viewInvalidated() {\n this.adapter.pageInvalidated();\n }\n }, {\n key: \"applicationAllowsFollowingLinkToLocation\",\n value: function applicationAllowsFollowingLinkToLocation(link, location) {\n var event = this.notifyApplicationAfterClickingLinkToLocation(link, location);\n return !event.defaultPrevented;\n }\n }, {\n key: \"applicationAllowsVisitingLocation\",\n value: function applicationAllowsVisitingLocation(location) {\n var event = this.notifyApplicationBeforeVisitingLocation(location);\n return !event.defaultPrevented;\n }\n }, {\n key: \"notifyApplicationAfterClickingLinkToLocation\",\n value: function notifyApplicationAfterClickingLinkToLocation(link, location) {\n return dispatch(\"turbo:click\", {\n target: link,\n detail: {\n url: location.href\n },\n cancelable: true\n });\n }\n }, {\n key: \"notifyApplicationBeforeVisitingLocation\",\n value: function notifyApplicationBeforeVisitingLocation(location) {\n return dispatch(\"turbo:before-visit\", {\n detail: {\n url: location.href\n },\n cancelable: true\n });\n }\n }, {\n key: \"notifyApplicationAfterVisitingLocation\",\n value: function notifyApplicationAfterVisitingLocation(location) {\n return dispatch(\"turbo:visit\", {\n detail: {\n url: location.href\n }\n });\n }\n }, {\n key: \"notifyApplicationBeforeCachingSnapshot\",\n value: function notifyApplicationBeforeCachingSnapshot() {\n return dispatch(\"turbo:before-cache\");\n }\n }, {\n key: \"notifyApplicationBeforeRender\",\n value: function notifyApplicationBeforeRender(newBody) {\n return dispatch(\"turbo:before-render\", {\n detail: {\n newBody: newBody\n }\n });\n }\n }, {\n key: \"notifyApplicationAfterRender\",\n value: function notifyApplicationAfterRender() {\n return dispatch(\"turbo:render\");\n }\n }, {\n key: \"notifyApplicationAfterPageLoad\",\n value: function notifyApplicationAfterPageLoad() {\n var timing = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return dispatch(\"turbo:load\", {\n detail: {\n url: this.location.href,\n timing: timing\n }\n });\n }\n }, {\n key: \"getActionForLink\",\n value: function getActionForLink(link) {\n var action = link.getAttribute(\"data-turbo-action\");\n return isAction(action) ? action : \"advance\";\n }\n }, {\n key: \"locationIsVisitable\",\n value: function locationIsVisitable(location) {\n return isPrefixedBy(location, this.snapshot.rootLocation) && isHTML(location);\n }\n }, {\n key: \"snapshot\",\n get: function get() {\n return this.view.snapshot;\n }\n }]);\n\n return Session;\n}();\n\nfunction elementIsNavigable(element) {\n var container = element === null || element === void 0 ? void 0 : element.closest(\"[data-turbo]\");\n\n if (container) {\n return container.getAttribute(\"data-turbo\") != \"false\";\n } else {\n return true;\n }\n}\n\nfunction extendURLWithDeprecatedProperties(url) {\n Object.defineProperties(url, deprecatedLocationPropertyDescriptors);\n}\n\nvar deprecatedLocationPropertyDescriptors = {\n absoluteURL: {\n get: function get() {\n return this.toString();\n }\n }\n};\n\nvar FrameController = /*#__PURE__*/function () {\n function FrameController(element) {\n _classCallCheck(this, FrameController);\n\n this.resolveVisitPromise = function () {};\n\n this.connected = false;\n this.hasBeenLoaded = false;\n this.settingSourceURL = false;\n this.element = element;\n this.view = new FrameView(this, this.element);\n this.appearanceObserver = new AppearanceObserver(this, this.element);\n this.linkInterceptor = new LinkInterceptor(this, this.element);\n this.formInterceptor = new FormInterceptor(this, this.element);\n }\n\n _createClass(FrameController, [{\n key: \"connect\",\n value: function connect() {\n if (!this.connected) {\n this.connected = true;\n\n if (this.loadingStyle == FrameLoadingStyle.lazy) {\n this.appearanceObserver.start();\n }\n\n this.linkInterceptor.start();\n this.formInterceptor.start();\n this.sourceURLChanged();\n }\n }\n }, {\n key: \"disconnect\",\n value: function disconnect() {\n if (this.connected) {\n this.connected = false;\n this.appearanceObserver.stop();\n this.linkInterceptor.stop();\n this.formInterceptor.stop();\n }\n }\n }, {\n key: \"disabledChanged\",\n value: function disabledChanged() {\n if (this.loadingStyle == FrameLoadingStyle.eager) {\n this.loadSourceURL();\n }\n }\n }, {\n key: \"sourceURLChanged\",\n value: function sourceURLChanged() {\n if (this.loadingStyle == FrameLoadingStyle.eager || this.hasBeenLoaded) {\n this.loadSourceURL();\n }\n }\n }, {\n key: \"loadingStyleChanged\",\n value: function loadingStyleChanged() {\n if (this.loadingStyle == FrameLoadingStyle.lazy) {\n this.appearanceObserver.start();\n } else {\n this.appearanceObserver.stop();\n this.loadSourceURL();\n }\n }\n }, {\n key: \"loadSourceURL\",\n value: function () {\n var _loadSourceURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {\n var previousURL;\n return _regeneratorRuntime.wrap(function _callee19$(_context19) {\n while (1) {\n switch (_context19.prev = _context19.next) {\n case 0:\n if (!(!this.settingSourceURL && this.enabled && this.isActive && this.sourceURL != this.currentURL)) {\n _context19.next = 16;\n break;\n }\n\n previousURL = this.currentURL;\n this.currentURL = this.sourceURL;\n\n if (!this.sourceURL) {\n _context19.next = 16;\n break;\n }\n\n _context19.prev = 4;\n this.element.loaded = this.visit(this.sourceURL);\n this.appearanceObserver.stop();\n _context19.next = 9;\n return this.element.loaded;\n\n case 9:\n this.hasBeenLoaded = true;\n _context19.next = 16;\n break;\n\n case 12:\n _context19.prev = 12;\n _context19.t0 = _context19[\"catch\"](4);\n this.currentURL = previousURL;\n throw _context19.t0;\n\n case 16:\n case \"end\":\n return _context19.stop();\n }\n }\n }, _callee19, this, [[4, 12]]);\n }));\n\n function loadSourceURL() {\n return _loadSourceURL.apply(this, arguments);\n }\n\n return loadSourceURL;\n }()\n }, {\n key: \"loadResponse\",\n value: function () {\n var _loadResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(fetchResponse) {\n var html, _parseHTMLDocument, body, snapshot, renderer;\n\n return _regeneratorRuntime.wrap(function _callee20$(_context20) {\n while (1) {\n switch (_context20.prev = _context20.next) {\n case 0:\n if (fetchResponse.redirected) {\n this.sourceURL = fetchResponse.response.url;\n }\n\n _context20.prev = 1;\n _context20.next = 4;\n return fetchResponse.responseHTML;\n\n case 4:\n html = _context20.sent;\n\n if (!html) {\n _context20.next = 15;\n break;\n }\n\n _parseHTMLDocument = parseHTMLDocument(html), body = _parseHTMLDocument.body;\n _context20.t0 = Snapshot;\n _context20.next = 10;\n return this.extractForeignFrameElement(body);\n\n case 10:\n _context20.t1 = _context20.sent;\n snapshot = new _context20.t0(_context20.t1);\n renderer = new FrameRenderer(this.view.snapshot, snapshot, false);\n _context20.next = 15;\n return this.view.render(renderer);\n\n case 15:\n _context20.next = 21;\n break;\n\n case 17:\n _context20.prev = 17;\n _context20.t2 = _context20[\"catch\"](1);\n console.error(_context20.t2);\n this.view.invalidate();\n\n case 21:\n case \"end\":\n return _context20.stop();\n }\n }\n }, _callee20, this, [[1, 17]]);\n }));\n\n function loadResponse(_x15) {\n return _loadResponse.apply(this, arguments);\n }\n\n return loadResponse;\n }()\n }, {\n key: \"elementAppearedInViewport\",\n value: function elementAppearedInViewport(element) {\n this.loadSourceURL();\n }\n }, {\n key: \"shouldInterceptLinkClick\",\n value: function shouldInterceptLinkClick(element, url) {\n return this.shouldInterceptNavigation(element);\n }\n }, {\n key: \"linkClickIntercepted\",\n value: function linkClickIntercepted(element, url) {\n this.navigateFrame(element, url);\n }\n }, {\n key: \"shouldInterceptFormSubmission\",\n value: function shouldInterceptFormSubmission(element, submitter) {\n return this.shouldInterceptNavigation(element, submitter);\n }\n }, {\n key: \"formSubmissionIntercepted\",\n value: function formSubmissionIntercepted(element, submitter) {\n if (this.formSubmission) {\n this.formSubmission.stop();\n }\n\n this.formSubmission = new FormSubmission(this, element, submitter);\n\n if (this.formSubmission.fetchRequest.isIdempotent) {\n this.navigateFrame(element, this.formSubmission.fetchRequest.url.href);\n } else {\n var fetchRequest = this.formSubmission.fetchRequest;\n this.prepareHeadersForRequest(fetchRequest.headers, fetchRequest);\n this.formSubmission.start();\n }\n }\n }, {\n key: \"prepareHeadersForRequest\",\n value: function prepareHeadersForRequest(headers, request) {\n headers[\"Turbo-Frame\"] = this.id;\n }\n }, {\n key: \"requestStarted\",\n value: function requestStarted(request) {\n this.element.setAttribute(\"busy\", \"\");\n }\n }, {\n key: \"requestPreventedHandlingResponse\",\n value: function requestPreventedHandlingResponse(request, response) {\n this.resolveVisitPromise();\n }\n }, {\n key: \"requestSucceededWithResponse\",\n value: function () {\n var _requestSucceededWithResponse2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(request, response) {\n return _regeneratorRuntime.wrap(function _callee21$(_context21) {\n while (1) {\n switch (_context21.prev = _context21.next) {\n case 0:\n _context21.next = 2;\n return this.loadResponse(response);\n\n case 2:\n this.resolveVisitPromise();\n\n case 3:\n case \"end\":\n return _context21.stop();\n }\n }\n }, _callee21, this);\n }));\n\n function requestSucceededWithResponse(_x16, _x17) {\n return _requestSucceededWithResponse2.apply(this, arguments);\n }\n\n return requestSucceededWithResponse;\n }()\n }, {\n key: \"requestFailedWithResponse\",\n value: function requestFailedWithResponse(request, response) {\n console.error(response);\n this.resolveVisitPromise();\n }\n }, {\n key: \"requestErrored\",\n value: function requestErrored(request, error) {\n console.error(error);\n this.resolveVisitPromise();\n }\n }, {\n key: \"requestFinished\",\n value: function requestFinished(request) {\n this.element.removeAttribute(\"busy\");\n }\n }, {\n key: \"formSubmissionStarted\",\n value: function formSubmissionStarted(formSubmission) {\n var frame = this.findFrameElement(formSubmission.formElement);\n frame.setAttribute(\"busy\", \"\");\n }\n }, {\n key: \"formSubmissionSucceededWithResponse\",\n value: function formSubmissionSucceededWithResponse(formSubmission, response) {\n var frame = this.findFrameElement(formSubmission.formElement);\n frame.delegate.loadResponse(response);\n }\n }, {\n key: \"formSubmissionFailedWithResponse\",\n value: function formSubmissionFailedWithResponse(formSubmission, fetchResponse) {\n this.element.delegate.loadResponse(fetchResponse);\n }\n }, {\n key: \"formSubmissionErrored\",\n value: function formSubmissionErrored(formSubmission, error) {\n console.error(error);\n }\n }, {\n key: \"formSubmissionFinished\",\n value: function formSubmissionFinished(formSubmission) {\n var frame = this.findFrameElement(formSubmission.formElement);\n frame.removeAttribute(\"busy\");\n }\n }, {\n key: \"viewWillRenderSnapshot\",\n value: function viewWillRenderSnapshot(snapshot, isPreview) {}\n }, {\n key: \"viewRenderedSnapshot\",\n value: function viewRenderedSnapshot(snapshot, isPreview) {}\n }, {\n key: \"viewInvalidated\",\n value: function viewInvalidated() {}\n }, {\n key: \"visit\",\n value: function () {\n var _visit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(url) {\n var _this28 = this;\n\n var request;\n return _regeneratorRuntime.wrap(function _callee22$(_context22) {\n while (1) {\n switch (_context22.prev = _context22.next) {\n case 0:\n request = new FetchRequest(this, FetchMethod.get, expandURL(url));\n return _context22.abrupt(\"return\", new Promise(function (resolve) {\n _this28.resolveVisitPromise = function () {\n _this28.resolveVisitPromise = function () {};\n\n resolve();\n };\n\n request.perform();\n }));\n\n case 2:\n case \"end\":\n return _context22.stop();\n }\n }\n }, _callee22, this);\n }));\n\n function visit(_x18) {\n return _visit.apply(this, arguments);\n }\n\n return visit;\n }()\n }, {\n key: \"navigateFrame\",\n value: function navigateFrame(element, url) {\n var frame = this.findFrameElement(element);\n frame.src = url;\n }\n }, {\n key: \"findFrameElement\",\n value: function findFrameElement(element) {\n var _a;\n\n var id = element.getAttribute(\"data-turbo-frame\") || this.element.getAttribute(\"target\");\n return (_a = getFrameElementById(id)) !== null && _a !== void 0 ? _a : this.element;\n }\n }, {\n key: \"extractForeignFrameElement\",\n value: function () {\n var _extractForeignFrameElement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(container) {\n var element, id;\n return _regeneratorRuntime.wrap(function _callee23$(_context23) {\n while (1) {\n switch (_context23.prev = _context23.next) {\n case 0:\n id = CSS.escape(this.id);\n _context23.prev = 1;\n\n if (!(element = activateElement(container.querySelector(\"turbo-frame#\".concat(id)), this.currentURL))) {\n _context23.next = 4;\n break;\n }\n\n return _context23.abrupt(\"return\", element);\n\n case 4:\n if (!(element = activateElement(container.querySelector(\"turbo-frame[src][recurse~=\".concat(id, \"]\")), this.currentURL))) {\n _context23.next = 10;\n break;\n }\n\n _context23.next = 7;\n return element.loaded;\n\n case 7:\n _context23.next = 9;\n return this.extractForeignFrameElement(element);\n\n case 9:\n return _context23.abrupt(\"return\", _context23.sent);\n\n case 10:\n console.error(\"Response has no matching element\"));\n _context23.next = 16;\n break;\n\n case 13:\n _context23.prev = 13;\n _context23.t0 = _context23[\"catch\"](1);\n console.error(_context23.t0);\n\n case 16:\n return _context23.abrupt(\"return\", new FrameElement());\n\n case 17:\n case \"end\":\n return _context23.stop();\n }\n }\n }, _callee23, this, [[1, 13]]);\n }));\n\n function extractForeignFrameElement(_x19) {\n return _extractForeignFrameElement.apply(this, arguments);\n }\n\n return extractForeignFrameElement;\n }()\n }, {\n key: \"shouldInterceptNavigation\",\n value: function shouldInterceptNavigation(element, submitter) {\n var id = element.getAttribute(\"data-turbo-frame\") || this.element.getAttribute(\"target\");\n\n if (!this.enabled || id == \"_top\") {\n return false;\n }\n\n if (id) {\n var frameElement = getFrameElementById(id);\n\n if (frameElement) {\n return !frameElement.disabled;\n }\n }\n\n if (!elementIsNavigable(element)) {\n return false;\n }\n\n if (submitter && !elementIsNavigable(submitter)) {\n return false;\n }\n\n return true;\n }\n }, {\n key: \"id\",\n get: function get() {\n return this.element.id;\n }\n }, {\n key: \"enabled\",\n get: function get() {\n return !this.element.disabled;\n }\n }, {\n key: \"sourceURL\",\n get: function get() {\n if (this.element.src) {\n return this.element.src;\n }\n },\n set: function set(sourceURL) {\n this.settingSourceURL = true;\n this.element.src = sourceURL !== null && sourceURL !== void 0 ? sourceURL : null;\n this.settingSourceURL = false;\n }\n }, {\n key: \"loadingStyle\",\n get: function get() {\n return this.element.loading;\n }\n }, {\n key: \"isLoading\",\n get: function get() {\n return this.formSubmission !== undefined || this.resolveVisitPromise !== undefined;\n }\n }, {\n key: \"isActive\",\n get: function get() {\n return this.element.isActive && this.connected;\n }\n }]);\n\n return FrameController;\n}();\n\nfunction getFrameElementById(id) {\n if (id != null) {\n var element = document.getElementById(id);\n\n if (element instanceof FrameElement) {\n return element;\n }\n }\n}\n\nfunction activateElement(element, currentURL) {\n if (element) {\n var src = element.getAttribute(\"src\");\n\n if (src != null && currentURL != null && urlsAreEqual(src, currentURL)) {\n throw new Error(\"Matching element has a source URL which references itself\"));\n }\n\n if (element.ownerDocument !== document) {\n element = document.importNode(element, true);\n }\n\n if (element instanceof FrameElement) {\n element.connectedCallback();\n return element;\n }\n }\n}\n\nvar StreamActions = {\n append: function append() {\n var _a;\n\n (_a = this.targetElement) === null || _a === void 0 ? void 0 : _a.append(this.templateContent);\n },\n prepend: function prepend() {\n var _a;\n\n (_a = this.targetElement) === null || _a === void 0 ? void 0 : _a.prepend(this.templateContent);\n },\n remove: function remove() {\n var _a;\n\n (_a = this.targetElement) === null || _a === void 0 ? void 0 : _a.remove();\n },\n replace: function replace() {\n var _a;\n\n (_a = this.targetElement) === null || _a === void 0 ? void 0 : _a.replaceWith(this.templateContent);\n },\n update: function update() {\n if (this.targetElement) {\n this.targetElement.innerHTML = \"\";\n this.targetElement.append(this.templateContent);\n }\n }\n};\n\nvar StreamElement = /*#__PURE__*/function (_HTMLElement2) {\n _inherits(StreamElement, _HTMLElement2);\n\n var _super9 = _createSuper(StreamElement);\n\n function StreamElement() {\n _classCallCheck(this, StreamElement);\n\n return _super9.apply(this, arguments);\n }\n\n _createClass(StreamElement, [{\n key: \"connectedCallback\",\n value: function () {\n var _connectedCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {\n return _regeneratorRuntime.wrap(function _callee24$(_context24) {\n while (1) {\n switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n _context24.next = 3;\n return this.render();\n\n case 3:\n _context24.next = 8;\n break;\n\n case 5:\n _context24.prev = 5;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(_context24.t0);\n\n case 8:\n _context24.prev = 8;\n this.disconnect();\n return _context24.finish(8);\n\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }\n }, _callee24, this, [[0, 5, 8, 11]]);\n }));\n\n function connectedCallback() {\n return _connectedCallback.apply(this, arguments);\n }\n\n return connectedCallback;\n }()\n }, {\n key: \"render\",\n value: function () {\n var _render6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {\n var _this29 = this;\n\n var _a;\n\n return _regeneratorRuntime.wrap(function _callee26$(_context26) {\n while (1) {\n switch (_context26.prev = _context26.next) {\n case 0:\n return _context26.abrupt(\"return\", (_a = this.renderPromise) !== null && _a !== void 0 ? _a : this.renderPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {\n return _regeneratorRuntime.wrap(function _callee25$(_context25) {\n while (1) {\n switch (_context25.prev = _context25.next) {\n case 0:\n if (!_this29.dispatchEvent(_this29.beforeRenderEvent)) {\n _context25.next = 4;\n break;\n }\n\n _context25.next = 3;\n return nextAnimationFrame();\n\n case 3:\n _this29.performAction();\n\n case 4:\n case \"end\":\n return _context25.stop();\n }\n }\n }, _callee25);\n }))());\n\n case 1:\n case \"end\":\n return _context26.stop();\n }\n }\n }, _callee26, this);\n }));\n\n function render() {\n return _render6.apply(this, arguments);\n }\n\n return render;\n }()\n }, {\n key: \"disconnect\",\n value: function disconnect() {\n try {\n this.remove();\n } catch (_a) {}\n }\n }, {\n key: \"performAction\",\n get: function get() {\n if (this.action) {\n var actionFunction = StreamActions[this.action];\n\n if (actionFunction) {\n return actionFunction;\n }\n\n this.raise(\"unknown action\");\n }\n\n this.raise(\"action attribute is missing\");\n }\n }, {\n key: \"targetElement\",\n get: function get() {\n var _a;\n\n if (this.target) {\n return (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.getElementById(this.target);\n }\n\n this.raise(\"target attribute is missing\");\n }\n }, {\n key: \"templateContent\",\n get: function get() {\n return this.templateElement.content;\n }\n }, {\n key: \"templateElement\",\n get: function get() {\n if (this.firstElementChild instanceof HTMLTemplateElement) {\n return this.firstElementChild;\n }\n\n this.raise(\"first child element must be a