data-table.js
4 years ago
data-table.js.map
4 years ago
index.js
4 years ago
index.js.map
4 years ago
settings.js
4 years ago
settings.js.map
4 years ago
index.js
4576 lines
| 1 | // modules are defined as an array |
| 2 | // [ module function, map of requires ] |
| 3 | // |
| 4 | // map of requires is short require name -> numeric require |
| 5 | // |
| 6 | // anything defined in a previous bundle is accessed via the |
| 7 | // orig method which is the require for previous bundles |
| 8 | |
| 9 | (function (modules, entry, mainEntry, parcelRequireName, globalName) { |
| 10 | /* eslint-disable no-undef */ |
| 11 | var globalObject = |
| 12 | typeof globalThis !== 'undefined' |
| 13 | ? globalThis |
| 14 | : typeof self !== 'undefined' |
| 15 | ? self |
| 16 | : typeof window !== 'undefined' |
| 17 | ? window |
| 18 | : typeof global !== 'undefined' |
| 19 | ? global |
| 20 | : {}; |
| 21 | /* eslint-enable no-undef */ |
| 22 | |
| 23 | // Save the require from previous bundle to this closure if any |
| 24 | var previousRequire = |
| 25 | typeof globalObject[parcelRequireName] === 'function' && |
| 26 | globalObject[parcelRequireName]; |
| 27 | |
| 28 | var cache = previousRequire.cache || {}; |
| 29 | // Do not use `require` to prevent Webpack from trying to bundle this call |
| 30 | var nodeRequire = |
| 31 | typeof module !== 'undefined' && |
| 32 | typeof module.require === 'function' && |
| 33 | module.require.bind(module); |
| 34 | |
| 35 | function newRequire(name, jumped) { |
| 36 | if (!cache[name]) { |
| 37 | if (!modules[name]) { |
| 38 | // if we cannot find the module within our internal map or |
| 39 | // cache jump to the current global require ie. the last bundle |
| 40 | // that was added to the page. |
| 41 | var currentRequire = |
| 42 | typeof globalObject[parcelRequireName] === 'function' && |
| 43 | globalObject[parcelRequireName]; |
| 44 | if (!jumped && currentRequire) { |
| 45 | return currentRequire(name, true); |
| 46 | } |
| 47 | |
| 48 | // If there are other bundles on this page the require from the |
| 49 | // previous one is saved to 'previousRequire'. Repeat this as |
| 50 | // many times as there are bundles until the module is found or |
| 51 | // we exhaust the require chain. |
| 52 | if (previousRequire) { |
| 53 | return previousRequire(name, true); |
| 54 | } |
| 55 | |
| 56 | // Try the node require function if it exists. |
| 57 | if (nodeRequire && typeof name === 'string') { |
| 58 | return nodeRequire(name); |
| 59 | } |
| 60 | |
| 61 | var err = new Error("Cannot find module '" + name + "'"); |
| 62 | err.code = 'MODULE_NOT_FOUND'; |
| 63 | throw err; |
| 64 | } |
| 65 | |
| 66 | localRequire.resolve = resolve; |
| 67 | localRequire.cache = {}; |
| 68 | |
| 69 | var module = (cache[name] = new newRequire.Module(name)); |
| 70 | |
| 71 | modules[name][0].call( |
| 72 | module.exports, |
| 73 | localRequire, |
| 74 | module, |
| 75 | module.exports, |
| 76 | this |
| 77 | ); |
| 78 | } |
| 79 | |
| 80 | return cache[name].exports; |
| 81 | |
| 82 | function localRequire(x) { |
| 83 | var res = localRequire.resolve(x); |
| 84 | return res === false ? {} : newRequire(res); |
| 85 | } |
| 86 | |
| 87 | function resolve(x) { |
| 88 | var id = modules[name][1][x]; |
| 89 | return id != null ? id : x; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | function Module(moduleName) { |
| 94 | this.id = moduleName; |
| 95 | this.bundle = newRequire; |
| 96 | this.exports = {}; |
| 97 | } |
| 98 | |
| 99 | newRequire.isParcelRequire = true; |
| 100 | newRequire.Module = Module; |
| 101 | newRequire.modules = modules; |
| 102 | newRequire.cache = cache; |
| 103 | newRequire.parent = previousRequire; |
| 104 | newRequire.register = function (id, exports) { |
| 105 | modules[id] = [ |
| 106 | function (require, module) { |
| 107 | module.exports = exports; |
| 108 | }, |
| 109 | {}, |
| 110 | ]; |
| 111 | }; |
| 112 | |
| 113 | Object.defineProperty(newRequire, 'root', { |
| 114 | get: function () { |
| 115 | return globalObject[parcelRequireName]; |
| 116 | }, |
| 117 | }); |
| 118 | |
| 119 | globalObject[parcelRequireName] = newRequire; |
| 120 | |
| 121 | for (var i = 0; i < entry.length; i++) { |
| 122 | newRequire(entry[i]); |
| 123 | } |
| 124 | |
| 125 | if (mainEntry) { |
| 126 | // Expose entry point to Node, AMD or browser globals |
| 127 | // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js |
| 128 | var mainExports = newRequire(mainEntry); |
| 129 | |
| 130 | // CommonJS |
| 131 | if (typeof exports === 'object' && typeof module !== 'undefined') { |
| 132 | module.exports = mainExports; |
| 133 | |
| 134 | // RequireJS |
| 135 | } else if (typeof define === 'function' && define.amd) { |
| 136 | define(function () { |
| 137 | return mainExports; |
| 138 | }); |
| 139 | |
| 140 | // <script> |
| 141 | } else if (globalName) { |
| 142 | this[globalName] = mainExports; |
| 143 | } |
| 144 | } |
| 145 | })({"2CYCe":[function(require,module,exports) { |
| 146 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 147 | var _stimulus = require("@hotwired/stimulus"); |
| 148 | var _deleteDataController = require("./controllers/delete_data_controller"); |
| 149 | var _deleteDataControllerDefault = parcelHelpers.interopDefault(_deleteDataController); |
| 150 | window.Stimulus = (0, _stimulus.Application).start(); |
| 151 | Stimulus.register("delete-data", (0, _deleteDataControllerDefault.default)); |
| 152 | |
| 153 | },{"@hotwired/stimulus":"27q4D","./controllers/delete_data_controller":"ibNcV","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"27q4D":[function(require,module,exports) { |
| 154 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 155 | parcelHelpers.defineInteropFlag(exports); |
| 156 | parcelHelpers.export(exports, "Application", function() { |
| 157 | return Application; |
| 158 | }); |
| 159 | parcelHelpers.export(exports, "AttributeObserver", function() { |
| 160 | return AttributeObserver; |
| 161 | }); |
| 162 | parcelHelpers.export(exports, "Context", function() { |
| 163 | return Context; |
| 164 | }); |
| 165 | parcelHelpers.export(exports, "Controller", function() { |
| 166 | return Controller; |
| 167 | }); |
| 168 | parcelHelpers.export(exports, "ElementObserver", function() { |
| 169 | return ElementObserver; |
| 170 | }); |
| 171 | parcelHelpers.export(exports, "IndexedMultimap", function() { |
| 172 | return IndexedMultimap; |
| 173 | }); |
| 174 | parcelHelpers.export(exports, "Multimap", function() { |
| 175 | return Multimap; |
| 176 | }); |
| 177 | parcelHelpers.export(exports, "StringMapObserver", function() { |
| 178 | return StringMapObserver; |
| 179 | }); |
| 180 | parcelHelpers.export(exports, "TokenListObserver", function() { |
| 181 | return TokenListObserver; |
| 182 | }); |
| 183 | parcelHelpers.export(exports, "ValueListObserver", function() { |
| 184 | return ValueListObserver; |
| 185 | }); |
| 186 | parcelHelpers.export(exports, "add", function() { |
| 187 | return add; |
| 188 | }); |
| 189 | parcelHelpers.export(exports, "defaultSchema", function() { |
| 190 | return defaultSchema; |
| 191 | }); |
| 192 | parcelHelpers.export(exports, "del", function() { |
| 193 | return del; |
| 194 | }); |
| 195 | parcelHelpers.export(exports, "fetch", function() { |
| 196 | return fetch; |
| 197 | }); |
| 198 | parcelHelpers.export(exports, "prune", function() { |
| 199 | return prune; |
| 200 | }); |
| 201 | var _asyncToGeneratorJs = require("@swc/helpers/lib/_async_to_generator.js"); |
| 202 | var _asyncToGeneratorJsDefault = parcelHelpers.interopDefault(_asyncToGeneratorJs); |
| 203 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 204 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 205 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 206 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 207 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 208 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 209 | var _getJs = require("@swc/helpers/lib/_get.js"); |
| 210 | var _getJsDefault = parcelHelpers.interopDefault(_getJs); |
| 211 | var _getPrototypeOfJs = require("@swc/helpers/lib/_get_prototype_of.js"); |
| 212 | var _getPrototypeOfJsDefault = parcelHelpers.interopDefault(_getPrototypeOfJs); |
| 213 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 214 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 215 | var _slicedToArrayJs = require("@swc/helpers/lib/_sliced_to_array.js"); |
| 216 | var _slicedToArrayJsDefault = parcelHelpers.interopDefault(_slicedToArrayJs); |
| 217 | var _toConsumableArrayJs = require("@swc/helpers/lib/_to_consumable_array.js"); |
| 218 | var _toConsumableArrayJsDefault = parcelHelpers.interopDefault(_toConsumableArrayJs); |
| 219 | var _typeOfJs = require("@swc/helpers/lib/_type_of.js"); |
| 220 | var _typeOfJsDefault = parcelHelpers.interopDefault(_typeOfJs); |
| 221 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 222 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 223 | var _regeneratorRuntime = require("regenerator-runtime"); |
| 224 | var _regeneratorRuntimeDefault = parcelHelpers.interopDefault(_regeneratorRuntime); |
| 225 | /* |
| 226 | Stimulus 3.0.1 |
| 227 | Copyright © 2021 Basecamp, LLC |
| 228 | */ var EventListener = /*#__PURE__*/ function() { |
| 229 | "use strict"; |
| 230 | function EventListener(eventTarget, eventName, eventOptions) { |
| 231 | (0, _classCallCheckJsDefault.default)(this, EventListener); |
| 232 | this.eventTarget = eventTarget; |
| 233 | this.eventName = eventName; |
| 234 | this.eventOptions = eventOptions; |
| 235 | this.unorderedBindings = new Set(); |
| 236 | } |
| 237 | (0, _createClassJsDefault.default)(EventListener, [ |
| 238 | { |
| 239 | key: "connect", |
| 240 | value: function connect() { |
| 241 | this.eventTarget.addEventListener(this.eventName, this, this.eventOptions); |
| 242 | } |
| 243 | }, |
| 244 | { |
| 245 | key: "disconnect", |
| 246 | value: function disconnect() { |
| 247 | this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions); |
| 248 | } |
| 249 | }, |
| 250 | { |
| 251 | key: "bindingConnected", |
| 252 | value: function bindingConnected(binding) { |
| 253 | this.unorderedBindings.add(binding); |
| 254 | } |
| 255 | }, |
| 256 | { |
| 257 | key: "bindingDisconnected", |
| 258 | value: function bindingDisconnected(binding) { |
| 259 | this.unorderedBindings.delete(binding); |
| 260 | } |
| 261 | }, |
| 262 | { |
| 263 | key: "handleEvent", |
| 264 | value: function handleEvent(event) { |
| 265 | var extendedEvent = extendEvent(event); |
| 266 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 267 | try { |
| 268 | for(var _iterator = this.bindings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 269 | var binding = _step.value; |
| 270 | if (extendedEvent.immediatePropagationStopped) break; |
| 271 | else binding.handleEvent(extendedEvent); |
| 272 | } |
| 273 | } catch (err) { |
| 274 | _didIteratorError = true; |
| 275 | _iteratorError = err; |
| 276 | } finally{ |
| 277 | try { |
| 278 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 279 | _iterator.return(); |
| 280 | } |
| 281 | } finally{ |
| 282 | if (_didIteratorError) { |
| 283 | throw _iteratorError; |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | }, |
| 289 | { |
| 290 | key: "bindings", |
| 291 | get: function get() { |
| 292 | return Array.from(this.unorderedBindings).sort(function(left, right) { |
| 293 | var leftIndex = left.index, rightIndex = right.index; |
| 294 | return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0; |
| 295 | }); |
| 296 | } |
| 297 | } |
| 298 | ]); |
| 299 | return EventListener; |
| 300 | }(); |
| 301 | function extendEvent(event) { |
| 302 | if ("immediatePropagationStopped" in event) return event; |
| 303 | else { |
| 304 | var stopImmediatePropagation = event.stopImmediatePropagation; |
| 305 | return Object.assign(event, { |
| 306 | immediatePropagationStopped: false, |
| 307 | stopImmediatePropagation: function() { |
| 308 | this.immediatePropagationStopped = true; |
| 309 | stopImmediatePropagation.call(this); |
| 310 | } |
| 311 | }); |
| 312 | } |
| 313 | } |
| 314 | var Dispatcher = /*#__PURE__*/ function() { |
| 315 | "use strict"; |
| 316 | function Dispatcher(application) { |
| 317 | (0, _classCallCheckJsDefault.default)(this, Dispatcher); |
| 318 | this.application = application; |
| 319 | this.eventListenerMaps = new Map; |
| 320 | this.started = false; |
| 321 | } |
| 322 | (0, _createClassJsDefault.default)(Dispatcher, [ |
| 323 | { |
| 324 | key: "start", |
| 325 | value: function start() { |
| 326 | if (!this.started) { |
| 327 | this.started = true; |
| 328 | this.eventListeners.forEach(function(eventListener) { |
| 329 | return eventListener.connect(); |
| 330 | }); |
| 331 | } |
| 332 | } |
| 333 | }, |
| 334 | { |
| 335 | key: "stop", |
| 336 | value: function stop() { |
| 337 | if (this.started) { |
| 338 | this.started = false; |
| 339 | this.eventListeners.forEach(function(eventListener) { |
| 340 | return eventListener.disconnect(); |
| 341 | }); |
| 342 | } |
| 343 | } |
| 344 | }, |
| 345 | { |
| 346 | key: "eventListeners", |
| 347 | get: function get() { |
| 348 | return Array.from(this.eventListenerMaps.values()).reduce(function(listeners, map) { |
| 349 | return listeners.concat(Array.from(map.values())); |
| 350 | }, []); |
| 351 | } |
| 352 | }, |
| 353 | { |
| 354 | key: "bindingConnected", |
| 355 | value: function bindingConnected(binding) { |
| 356 | this.fetchEventListenerForBinding(binding).bindingConnected(binding); |
| 357 | } |
| 358 | }, |
| 359 | { |
| 360 | key: "bindingDisconnected", |
| 361 | value: function bindingDisconnected(binding) { |
| 362 | this.fetchEventListenerForBinding(binding).bindingDisconnected(binding); |
| 363 | } |
| 364 | }, |
| 365 | { |
| 366 | key: "handleError", |
| 367 | value: function handleError(error1, message) { |
| 368 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 369 | this.application.handleError(error1, "Error ".concat(message), detail); |
| 370 | } |
| 371 | }, |
| 372 | { |
| 373 | key: "fetchEventListenerForBinding", |
| 374 | value: function fetchEventListenerForBinding(binding) { |
| 375 | var eventTarget = binding.eventTarget, eventName = binding.eventName, eventOptions = binding.eventOptions; |
| 376 | return this.fetchEventListener(eventTarget, eventName, eventOptions); |
| 377 | } |
| 378 | }, |
| 379 | { |
| 380 | key: "fetchEventListener", |
| 381 | value: function fetchEventListener(eventTarget, eventName, eventOptions) { |
| 382 | var eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget); |
| 383 | var cacheKey = this.cacheKey(eventName, eventOptions); |
| 384 | var eventListener = eventListenerMap.get(cacheKey); |
| 385 | if (!eventListener) { |
| 386 | eventListener = this.createEventListener(eventTarget, eventName, eventOptions); |
| 387 | eventListenerMap.set(cacheKey, eventListener); |
| 388 | } |
| 389 | return eventListener; |
| 390 | } |
| 391 | }, |
| 392 | { |
| 393 | key: "createEventListener", |
| 394 | value: function createEventListener(eventTarget, eventName, eventOptions) { |
| 395 | var eventListener = new EventListener(eventTarget, eventName, eventOptions); |
| 396 | if (this.started) eventListener.connect(); |
| 397 | return eventListener; |
| 398 | } |
| 399 | }, |
| 400 | { |
| 401 | key: "fetchEventListenerMapForEventTarget", |
| 402 | value: function fetchEventListenerMapForEventTarget(eventTarget) { |
| 403 | var eventListenerMap = this.eventListenerMaps.get(eventTarget); |
| 404 | if (!eventListenerMap) { |
| 405 | eventListenerMap = new Map; |
| 406 | this.eventListenerMaps.set(eventTarget, eventListenerMap); |
| 407 | } |
| 408 | return eventListenerMap; |
| 409 | } |
| 410 | }, |
| 411 | { |
| 412 | key: "cacheKey", |
| 413 | value: function cacheKey(eventName, eventOptions) { |
| 414 | var parts = [ |
| 415 | eventName |
| 416 | ]; |
| 417 | Object.keys(eventOptions).sort().forEach(function(key) { |
| 418 | parts.push("".concat(eventOptions[key] ? "" : "!").concat(key)); |
| 419 | }); |
| 420 | return parts.join(":"); |
| 421 | } |
| 422 | } |
| 423 | ]); |
| 424 | return Dispatcher; |
| 425 | }(); |
| 426 | var descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#([^:]+?))(:(.+))?$/; |
| 427 | function parseActionDescriptorString(descriptorString) { |
| 428 | var source = descriptorString.trim(); |
| 429 | var matches = source.match(descriptorPattern) || []; |
| 430 | return { |
| 431 | eventTarget: parseEventTarget(matches[4]), |
| 432 | eventName: matches[2], |
| 433 | eventOptions: matches[9] ? parseEventOptions(matches[9]) : {}, |
| 434 | identifier: matches[5], |
| 435 | methodName: matches[7] |
| 436 | }; |
| 437 | } |
| 438 | function parseEventTarget(eventTargetName) { |
| 439 | if (eventTargetName == "window") return window; |
| 440 | else if (eventTargetName == "document") return document; |
| 441 | } |
| 442 | function parseEventOptions(eventOptions) { |
| 443 | return eventOptions.split(":").reduce(function(options, token) { |
| 444 | return Object.assign(options, (0, _definePropertyJsDefault.default)({}, token.replace(/^!/, ""), !/^!/.test(token))); |
| 445 | }, {}); |
| 446 | } |
| 447 | function stringifyEventTarget(eventTarget) { |
| 448 | if (eventTarget == window) return "window"; |
| 449 | else if (eventTarget == document) return "document"; |
| 450 | } |
| 451 | function camelize(value) { |
| 452 | return value.replace(/(?:[_-])([a-z0-9])/g, function(_, char) { |
| 453 | return char.toUpperCase(); |
| 454 | }); |
| 455 | } |
| 456 | function capitalize(value) { |
| 457 | return value.charAt(0).toUpperCase() + value.slice(1); |
| 458 | } |
| 459 | function dasherize(value) { |
| 460 | return value.replace(/([A-Z])/g, function(_, char) { |
| 461 | return "-".concat(char.toLowerCase()); |
| 462 | }); |
| 463 | } |
| 464 | function tokenize(value) { |
| 465 | return value.match(/[^\s]+/g) || []; |
| 466 | } |
| 467 | var Action = /*#__PURE__*/ function() { |
| 468 | "use strict"; |
| 469 | function Action(element, index, descriptor) { |
| 470 | (0, _classCallCheckJsDefault.default)(this, Action); |
| 471 | this.element = element; |
| 472 | this.index = index; |
| 473 | this.eventTarget = descriptor.eventTarget || element; |
| 474 | this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name"); |
| 475 | this.eventOptions = descriptor.eventOptions || {}; |
| 476 | this.identifier = descriptor.identifier || error("missing identifier"); |
| 477 | this.methodName = descriptor.methodName || error("missing method name"); |
| 478 | } |
| 479 | (0, _createClassJsDefault.default)(Action, [ |
| 480 | { |
| 481 | key: "toString", |
| 482 | value: function toString() { |
| 483 | var eventNameSuffix = this.eventTargetName ? "@".concat(this.eventTargetName) : ""; |
| 484 | return "".concat(this.eventName).concat(eventNameSuffix, "->").concat(this.identifier, "#").concat(this.methodName); |
| 485 | } |
| 486 | }, |
| 487 | { |
| 488 | key: "params", |
| 489 | get: function get() { |
| 490 | if (this.eventTarget instanceof Element) return this.getParamsFromEventTargetAttributes(this.eventTarget); |
| 491 | else return {}; |
| 492 | } |
| 493 | }, |
| 494 | { |
| 495 | key: "getParamsFromEventTargetAttributes", |
| 496 | value: function getParamsFromEventTargetAttributes(eventTarget) { |
| 497 | var params = {}; |
| 498 | var pattern = new RegExp("^data-".concat(this.identifier, "-(.+)-param$")); |
| 499 | var attributes = Array.from(eventTarget.attributes); |
| 500 | attributes.forEach(function(param) { |
| 501 | var name = param.name, value = param.value; |
| 502 | var match = name.match(pattern); |
| 503 | var key = match && match[1]; |
| 504 | if (key) Object.assign(params, (0, _definePropertyJsDefault.default)({}, camelize(key), typecast(value))); |
| 505 | }); |
| 506 | return params; |
| 507 | } |
| 508 | }, |
| 509 | { |
| 510 | key: "eventTargetName", |
| 511 | get: function get() { |
| 512 | return stringifyEventTarget(this.eventTarget); |
| 513 | } |
| 514 | } |
| 515 | ], [ |
| 516 | { |
| 517 | key: "forToken", |
| 518 | value: function forToken(token) { |
| 519 | return new this(token.element, token.index, parseActionDescriptorString(token.content)); |
| 520 | } |
| 521 | } |
| 522 | ]); |
| 523 | return Action; |
| 524 | }(); |
| 525 | var defaultEventNames = { |
| 526 | "a": function(e) { |
| 527 | return "click"; |
| 528 | }, |
| 529 | "button": function(e) { |
| 530 | return "click"; |
| 531 | }, |
| 532 | "form": function(e) { |
| 533 | return "submit"; |
| 534 | }, |
| 535 | "details": function(e) { |
| 536 | return "toggle"; |
| 537 | }, |
| 538 | "input": function(e) { |
| 539 | return e.getAttribute("type") == "submit" ? "click" : "input"; |
| 540 | }, |
| 541 | "select": function(e) { |
| 542 | return "change"; |
| 543 | }, |
| 544 | "textarea": function(e) { |
| 545 | return "input"; |
| 546 | } |
| 547 | }; |
| 548 | function getDefaultEventNameForElement(element) { |
| 549 | var tagName = element.tagName.toLowerCase(); |
| 550 | if (tagName in defaultEventNames) return defaultEventNames[tagName](element); |
| 551 | } |
| 552 | function error(message) { |
| 553 | throw new Error(message); |
| 554 | } |
| 555 | function typecast(value) { |
| 556 | try { |
| 557 | return JSON.parse(value); |
| 558 | } catch (o_O) { |
| 559 | return value; |
| 560 | } |
| 561 | } |
| 562 | var Binding = /*#__PURE__*/ function() { |
| 563 | "use strict"; |
| 564 | function Binding(context, action) { |
| 565 | (0, _classCallCheckJsDefault.default)(this, Binding); |
| 566 | this.context = context; |
| 567 | this.action = action; |
| 568 | } |
| 569 | (0, _createClassJsDefault.default)(Binding, [ |
| 570 | { |
| 571 | key: "index", |
| 572 | get: function get() { |
| 573 | return this.action.index; |
| 574 | } |
| 575 | }, |
| 576 | { |
| 577 | key: "eventTarget", |
| 578 | get: function get() { |
| 579 | return this.action.eventTarget; |
| 580 | } |
| 581 | }, |
| 582 | { |
| 583 | key: "eventOptions", |
| 584 | get: function get() { |
| 585 | return this.action.eventOptions; |
| 586 | } |
| 587 | }, |
| 588 | { |
| 589 | key: "identifier", |
| 590 | get: function get() { |
| 591 | return this.context.identifier; |
| 592 | } |
| 593 | }, |
| 594 | { |
| 595 | key: "handleEvent", |
| 596 | value: function handleEvent(event) { |
| 597 | if (this.willBeInvokedByEvent(event)) this.invokeWithEvent(event); |
| 598 | } |
| 599 | }, |
| 600 | { |
| 601 | key: "eventName", |
| 602 | get: function get() { |
| 603 | return this.action.eventName; |
| 604 | } |
| 605 | }, |
| 606 | { |
| 607 | key: "method", |
| 608 | get: function get() { |
| 609 | var method = this.controller[this.methodName]; |
| 610 | if (typeof method == "function") return method; |
| 611 | throw new Error('Action "'.concat(this.action, '" references undefined method "').concat(this.methodName, '"')); |
| 612 | } |
| 613 | }, |
| 614 | { |
| 615 | key: "invokeWithEvent", |
| 616 | value: function invokeWithEvent(event) { |
| 617 | var target = event.target, currentTarget = event.currentTarget; |
| 618 | try { |
| 619 | var params = this.action.params; |
| 620 | var actionEvent = Object.assign(event, { |
| 621 | params: params |
| 622 | }); |
| 623 | this.method.call(this.controller, actionEvent); |
| 624 | this.context.logDebugActivity(this.methodName, { |
| 625 | event: event, |
| 626 | target: target, |
| 627 | currentTarget: currentTarget, |
| 628 | action: this.methodName |
| 629 | }); |
| 630 | } catch (error2) { |
| 631 | var ref = this, identifier = ref.identifier, controller = ref.controller, element = ref.element, index = ref.index; |
| 632 | var detail = { |
| 633 | identifier: identifier, |
| 634 | controller: controller, |
| 635 | element: element, |
| 636 | index: index, |
| 637 | event: event |
| 638 | }; |
| 639 | this.context.handleError(error2, 'invoking action "'.concat(this.action, '"'), detail); |
| 640 | } |
| 641 | } |
| 642 | }, |
| 643 | { |
| 644 | key: "willBeInvokedByEvent", |
| 645 | value: function willBeInvokedByEvent(event) { |
| 646 | var eventTarget = event.target; |
| 647 | if (this.element === eventTarget) return true; |
| 648 | else if (eventTarget instanceof Element && this.element.contains(eventTarget)) return this.scope.containsElement(eventTarget); |
| 649 | else return this.scope.containsElement(this.action.element); |
| 650 | } |
| 651 | }, |
| 652 | { |
| 653 | key: "controller", |
| 654 | get: function get() { |
| 655 | return this.context.controller; |
| 656 | } |
| 657 | }, |
| 658 | { |
| 659 | key: "methodName", |
| 660 | get: function get() { |
| 661 | return this.action.methodName; |
| 662 | } |
| 663 | }, |
| 664 | { |
| 665 | key: "element", |
| 666 | get: function get() { |
| 667 | return this.scope.element; |
| 668 | } |
| 669 | }, |
| 670 | { |
| 671 | key: "scope", |
| 672 | get: function get() { |
| 673 | return this.context.scope; |
| 674 | } |
| 675 | } |
| 676 | ]); |
| 677 | return Binding; |
| 678 | }(); |
| 679 | var ElementObserver = /*#__PURE__*/ function() { |
| 680 | "use strict"; |
| 681 | function ElementObserver(element, delegate) { |
| 682 | var _this = this; |
| 683 | (0, _classCallCheckJsDefault.default)(this, ElementObserver); |
| 684 | this.mutationObserverInit = { |
| 685 | attributes: true, |
| 686 | childList: true, |
| 687 | subtree: true |
| 688 | }; |
| 689 | this.element = element; |
| 690 | this.started = false; |
| 691 | this.delegate = delegate; |
| 692 | this.elements = new Set; |
| 693 | this.mutationObserver = new MutationObserver(function(mutations) { |
| 694 | return _this.processMutations(mutations); |
| 695 | }); |
| 696 | } |
| 697 | (0, _createClassJsDefault.default)(ElementObserver, [ |
| 698 | { |
| 699 | key: "start", |
| 700 | value: function start() { |
| 701 | if (!this.started) { |
| 702 | this.started = true; |
| 703 | this.mutationObserver.observe(this.element, this.mutationObserverInit); |
| 704 | this.refresh(); |
| 705 | } |
| 706 | } |
| 707 | }, |
| 708 | { |
| 709 | key: "pause", |
| 710 | value: function pause(callback) { |
| 711 | if (this.started) { |
| 712 | this.mutationObserver.disconnect(); |
| 713 | this.started = false; |
| 714 | } |
| 715 | callback(); |
| 716 | if (!this.started) { |
| 717 | this.mutationObserver.observe(this.element, this.mutationObserverInit); |
| 718 | this.started = true; |
| 719 | } |
| 720 | } |
| 721 | }, |
| 722 | { |
| 723 | key: "stop", |
| 724 | value: function stop() { |
| 725 | if (this.started) { |
| 726 | this.mutationObserver.takeRecords(); |
| 727 | this.mutationObserver.disconnect(); |
| 728 | this.started = false; |
| 729 | } |
| 730 | } |
| 731 | }, |
| 732 | { |
| 733 | key: "refresh", |
| 734 | value: function refresh() { |
| 735 | if (this.started) { |
| 736 | var matches = new Set(this.matchElementsInTree()); |
| 737 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 738 | try { |
| 739 | for(var _iterator = Array.from(this.elements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 740 | var element = _step.value; |
| 741 | if (!matches.has(element)) this.removeElement(element); |
| 742 | } |
| 743 | } catch (err) { |
| 744 | _didIteratorError = true; |
| 745 | _iteratorError = err; |
| 746 | } finally{ |
| 747 | try { |
| 748 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 749 | _iterator.return(); |
| 750 | } |
| 751 | } finally{ |
| 752 | if (_didIteratorError) { |
| 753 | throw _iteratorError; |
| 754 | } |
| 755 | } |
| 756 | } |
| 757 | var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined; |
| 758 | try { |
| 759 | for(var _iterator1 = Array.from(matches)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){ |
| 760 | var element1 = _step1.value; |
| 761 | this.addElement(element1); |
| 762 | } |
| 763 | } catch (err) { |
| 764 | _didIteratorError1 = true; |
| 765 | _iteratorError1 = err; |
| 766 | } finally{ |
| 767 | try { |
| 768 | if (!_iteratorNormalCompletion1 && _iterator1.return != null) { |
| 769 | _iterator1.return(); |
| 770 | } |
| 771 | } finally{ |
| 772 | if (_didIteratorError1) { |
| 773 | throw _iteratorError1; |
| 774 | } |
| 775 | } |
| 776 | } |
| 777 | } |
| 778 | } |
| 779 | }, |
| 780 | { |
| 781 | key: "processMutations", |
| 782 | value: function processMutations(mutations) { |
| 783 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 784 | if (this.started) try { |
| 785 | for(var _iterator = mutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 786 | var mutation = _step.value; |
| 787 | this.processMutation(mutation); |
| 788 | } |
| 789 | } catch (err) { |
| 790 | _didIteratorError = true; |
| 791 | _iteratorError = err; |
| 792 | } finally{ |
| 793 | try { |
| 794 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 795 | _iterator.return(); |
| 796 | } |
| 797 | } finally{ |
| 798 | if (_didIteratorError) { |
| 799 | throw _iteratorError; |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | } |
| 804 | }, |
| 805 | { |
| 806 | key: "processMutation", |
| 807 | value: function processMutation(mutation) { |
| 808 | if (mutation.type == "attributes") this.processAttributeChange(mutation.target, mutation.attributeName); |
| 809 | else if (mutation.type == "childList") { |
| 810 | this.processRemovedNodes(mutation.removedNodes); |
| 811 | this.processAddedNodes(mutation.addedNodes); |
| 812 | } |
| 813 | } |
| 814 | }, |
| 815 | { |
| 816 | key: "processAttributeChange", |
| 817 | value: function processAttributeChange(node, attributeName) { |
| 818 | var element = node; |
| 819 | if (this.elements.has(element)) { |
| 820 | if (this.delegate.elementAttributeChanged && this.matchElement(element)) this.delegate.elementAttributeChanged(element, attributeName); |
| 821 | else this.removeElement(element); |
| 822 | } else if (this.matchElement(element)) this.addElement(element); |
| 823 | } |
| 824 | }, |
| 825 | { |
| 826 | key: "processRemovedNodes", |
| 827 | value: function processRemovedNodes(nodes) { |
| 828 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 829 | try { |
| 830 | for(var _iterator = Array.from(nodes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 831 | var node = _step.value; |
| 832 | var element = this.elementFromNode(node); |
| 833 | if (element) this.processTree(element, this.removeElement); |
| 834 | } |
| 835 | } catch (err) { |
| 836 | _didIteratorError = true; |
| 837 | _iteratorError = err; |
| 838 | } finally{ |
| 839 | try { |
| 840 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 841 | _iterator.return(); |
| 842 | } |
| 843 | } finally{ |
| 844 | if (_didIteratorError) { |
| 845 | throw _iteratorError; |
| 846 | } |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | }, |
| 851 | { |
| 852 | key: "processAddedNodes", |
| 853 | value: function processAddedNodes(nodes) { |
| 854 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 855 | try { |
| 856 | for(var _iterator = Array.from(nodes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 857 | var node = _step.value; |
| 858 | var element = this.elementFromNode(node); |
| 859 | if (element && this.elementIsActive(element)) this.processTree(element, this.addElement); |
| 860 | } |
| 861 | } catch (err) { |
| 862 | _didIteratorError = true; |
| 863 | _iteratorError = err; |
| 864 | } finally{ |
| 865 | try { |
| 866 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 867 | _iterator.return(); |
| 868 | } |
| 869 | } finally{ |
| 870 | if (_didIteratorError) { |
| 871 | throw _iteratorError; |
| 872 | } |
| 873 | } |
| 874 | } |
| 875 | } |
| 876 | }, |
| 877 | { |
| 878 | key: "matchElement", |
| 879 | value: function matchElement(element) { |
| 880 | return this.delegate.matchElement(element); |
| 881 | } |
| 882 | }, |
| 883 | { |
| 884 | key: "matchElementsInTree", |
| 885 | value: function matchElementsInTree() { |
| 886 | var tree = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.element; |
| 887 | return this.delegate.matchElementsInTree(tree); |
| 888 | } |
| 889 | }, |
| 890 | { |
| 891 | key: "processTree", |
| 892 | value: function processTree(tree, processor) { |
| 893 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 894 | try { |
| 895 | for(var _iterator = this.matchElementsInTree(tree)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 896 | var element = _step.value; |
| 897 | processor.call(this, element); |
| 898 | } |
| 899 | } catch (err) { |
| 900 | _didIteratorError = true; |
| 901 | _iteratorError = err; |
| 902 | } finally{ |
| 903 | try { |
| 904 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 905 | _iterator.return(); |
| 906 | } |
| 907 | } finally{ |
| 908 | if (_didIteratorError) { |
| 909 | throw _iteratorError; |
| 910 | } |
| 911 | } |
| 912 | } |
| 913 | } |
| 914 | }, |
| 915 | { |
| 916 | key: "elementFromNode", |
| 917 | value: function elementFromNode(node) { |
| 918 | if (node.nodeType == Node.ELEMENT_NODE) return node; |
| 919 | } |
| 920 | }, |
| 921 | { |
| 922 | key: "elementIsActive", |
| 923 | value: function elementIsActive(element) { |
| 924 | if (element.isConnected != this.element.isConnected) return false; |
| 925 | else return this.element.contains(element); |
| 926 | } |
| 927 | }, |
| 928 | { |
| 929 | key: "addElement", |
| 930 | value: function addElement(element) { |
| 931 | if (!this.elements.has(element)) { |
| 932 | if (this.elementIsActive(element)) { |
| 933 | this.elements.add(element); |
| 934 | if (this.delegate.elementMatched) this.delegate.elementMatched(element); |
| 935 | } |
| 936 | } |
| 937 | } |
| 938 | }, |
| 939 | { |
| 940 | key: "removeElement", |
| 941 | value: function removeElement(element) { |
| 942 | if (this.elements.has(element)) { |
| 943 | this.elements.delete(element); |
| 944 | if (this.delegate.elementUnmatched) this.delegate.elementUnmatched(element); |
| 945 | } |
| 946 | } |
| 947 | } |
| 948 | ]); |
| 949 | return ElementObserver; |
| 950 | }(); |
| 951 | var AttributeObserver = /*#__PURE__*/ function() { |
| 952 | "use strict"; |
| 953 | function AttributeObserver(element, attributeName, delegate) { |
| 954 | (0, _classCallCheckJsDefault.default)(this, AttributeObserver); |
| 955 | this.attributeName = attributeName; |
| 956 | this.delegate = delegate; |
| 957 | this.elementObserver = new ElementObserver(element, this); |
| 958 | } |
| 959 | (0, _createClassJsDefault.default)(AttributeObserver, [ |
| 960 | { |
| 961 | key: "element", |
| 962 | get: function get() { |
| 963 | return this.elementObserver.element; |
| 964 | } |
| 965 | }, |
| 966 | { |
| 967 | key: "selector", |
| 968 | get: function get() { |
| 969 | return "[".concat(this.attributeName, "]"); |
| 970 | } |
| 971 | }, |
| 972 | { |
| 973 | key: "start", |
| 974 | value: function start() { |
| 975 | this.elementObserver.start(); |
| 976 | } |
| 977 | }, |
| 978 | { |
| 979 | key: "pause", |
| 980 | value: function pause(callback) { |
| 981 | this.elementObserver.pause(callback); |
| 982 | } |
| 983 | }, |
| 984 | { |
| 985 | key: "stop", |
| 986 | value: function stop() { |
| 987 | this.elementObserver.stop(); |
| 988 | } |
| 989 | }, |
| 990 | { |
| 991 | key: "refresh", |
| 992 | value: function refresh() { |
| 993 | this.elementObserver.refresh(); |
| 994 | } |
| 995 | }, |
| 996 | { |
| 997 | key: "started", |
| 998 | get: function get() { |
| 999 | return this.elementObserver.started; |
| 1000 | } |
| 1001 | }, |
| 1002 | { |
| 1003 | key: "matchElement", |
| 1004 | value: function matchElement(element) { |
| 1005 | return element.hasAttribute(this.attributeName); |
| 1006 | } |
| 1007 | }, |
| 1008 | { |
| 1009 | key: "matchElementsInTree", |
| 1010 | value: function matchElementsInTree(tree) { |
| 1011 | var match = this.matchElement(tree) ? [ |
| 1012 | tree |
| 1013 | ] : []; |
| 1014 | var matches = Array.from(tree.querySelectorAll(this.selector)); |
| 1015 | return match.concat(matches); |
| 1016 | } |
| 1017 | }, |
| 1018 | { |
| 1019 | key: "elementMatched", |
| 1020 | value: function elementMatched(element) { |
| 1021 | if (this.delegate.elementMatchedAttribute) this.delegate.elementMatchedAttribute(element, this.attributeName); |
| 1022 | } |
| 1023 | }, |
| 1024 | { |
| 1025 | key: "elementUnmatched", |
| 1026 | value: function elementUnmatched(element) { |
| 1027 | if (this.delegate.elementUnmatchedAttribute) this.delegate.elementUnmatchedAttribute(element, this.attributeName); |
| 1028 | } |
| 1029 | }, |
| 1030 | { |
| 1031 | key: "elementAttributeChanged", |
| 1032 | value: function elementAttributeChanged(element, attributeName) { |
| 1033 | if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) this.delegate.elementAttributeValueChanged(element, attributeName); |
| 1034 | } |
| 1035 | } |
| 1036 | ]); |
| 1037 | return AttributeObserver; |
| 1038 | }(); |
| 1039 | var StringMapObserver = /*#__PURE__*/ function() { |
| 1040 | "use strict"; |
| 1041 | function StringMapObserver(element, delegate) { |
| 1042 | var _this = this; |
| 1043 | (0, _classCallCheckJsDefault.default)(this, StringMapObserver); |
| 1044 | this.element = element; |
| 1045 | this.delegate = delegate; |
| 1046 | this.started = false; |
| 1047 | this.stringMap = new Map; |
| 1048 | this.mutationObserver = new MutationObserver(function(mutations) { |
| 1049 | return _this.processMutations(mutations); |
| 1050 | }); |
| 1051 | } |
| 1052 | (0, _createClassJsDefault.default)(StringMapObserver, [ |
| 1053 | { |
| 1054 | key: "start", |
| 1055 | value: function start() { |
| 1056 | if (!this.started) { |
| 1057 | this.started = true; |
| 1058 | this.mutationObserver.observe(this.element, { |
| 1059 | attributes: true, |
| 1060 | attributeOldValue: true |
| 1061 | }); |
| 1062 | this.refresh(); |
| 1063 | } |
| 1064 | } |
| 1065 | }, |
| 1066 | { |
| 1067 | key: "stop", |
| 1068 | value: function stop() { |
| 1069 | if (this.started) { |
| 1070 | this.mutationObserver.takeRecords(); |
| 1071 | this.mutationObserver.disconnect(); |
| 1072 | this.started = false; |
| 1073 | } |
| 1074 | } |
| 1075 | }, |
| 1076 | { |
| 1077 | key: "refresh", |
| 1078 | value: function refresh() { |
| 1079 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 1080 | if (this.started) try { |
| 1081 | for(var _iterator = this.knownAttributeNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 1082 | var attributeName = _step.value; |
| 1083 | this.refreshAttribute(attributeName, null); |
| 1084 | } |
| 1085 | } catch (err) { |
| 1086 | _didIteratorError = true; |
| 1087 | _iteratorError = err; |
| 1088 | } finally{ |
| 1089 | try { |
| 1090 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 1091 | _iterator.return(); |
| 1092 | } |
| 1093 | } finally{ |
| 1094 | if (_didIteratorError) { |
| 1095 | throw _iteratorError; |
| 1096 | } |
| 1097 | } |
| 1098 | } |
| 1099 | } |
| 1100 | }, |
| 1101 | { |
| 1102 | key: "processMutations", |
| 1103 | value: function processMutations(mutations) { |
| 1104 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 1105 | if (this.started) try { |
| 1106 | for(var _iterator = mutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 1107 | var mutation = _step.value; |
| 1108 | this.processMutation(mutation); |
| 1109 | } |
| 1110 | } catch (err) { |
| 1111 | _didIteratorError = true; |
| 1112 | _iteratorError = err; |
| 1113 | } finally{ |
| 1114 | try { |
| 1115 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 1116 | _iterator.return(); |
| 1117 | } |
| 1118 | } finally{ |
| 1119 | if (_didIteratorError) { |
| 1120 | throw _iteratorError; |
| 1121 | } |
| 1122 | } |
| 1123 | } |
| 1124 | } |
| 1125 | }, |
| 1126 | { |
| 1127 | key: "processMutation", |
| 1128 | value: function processMutation(mutation) { |
| 1129 | var attributeName = mutation.attributeName; |
| 1130 | if (attributeName) this.refreshAttribute(attributeName, mutation.oldValue); |
| 1131 | } |
| 1132 | }, |
| 1133 | { |
| 1134 | key: "refreshAttribute", |
| 1135 | value: function refreshAttribute(attributeName, oldValue) { |
| 1136 | var key = this.delegate.getStringMapKeyForAttribute(attributeName); |
| 1137 | if (key != null) { |
| 1138 | if (!this.stringMap.has(attributeName)) this.stringMapKeyAdded(key, attributeName); |
| 1139 | var value = this.element.getAttribute(attributeName); |
| 1140 | if (this.stringMap.get(attributeName) != value) this.stringMapValueChanged(value, key, oldValue); |
| 1141 | if (value == null) { |
| 1142 | var _$oldValue = this.stringMap.get(attributeName); |
| 1143 | this.stringMap.delete(attributeName); |
| 1144 | if (_$oldValue) this.stringMapKeyRemoved(key, attributeName, _$oldValue); |
| 1145 | } else this.stringMap.set(attributeName, value); |
| 1146 | } |
| 1147 | } |
| 1148 | }, |
| 1149 | { |
| 1150 | key: "stringMapKeyAdded", |
| 1151 | value: function stringMapKeyAdded(key, attributeName) { |
| 1152 | if (this.delegate.stringMapKeyAdded) this.delegate.stringMapKeyAdded(key, attributeName); |
| 1153 | } |
| 1154 | }, |
| 1155 | { |
| 1156 | key: "stringMapValueChanged", |
| 1157 | value: function stringMapValueChanged(value, key, oldValue) { |
| 1158 | if (this.delegate.stringMapValueChanged) this.delegate.stringMapValueChanged(value, key, oldValue); |
| 1159 | } |
| 1160 | }, |
| 1161 | { |
| 1162 | key: "stringMapKeyRemoved", |
| 1163 | value: function stringMapKeyRemoved(key, attributeName, oldValue) { |
| 1164 | if (this.delegate.stringMapKeyRemoved) this.delegate.stringMapKeyRemoved(key, attributeName, oldValue); |
| 1165 | } |
| 1166 | }, |
| 1167 | { |
| 1168 | key: "knownAttributeNames", |
| 1169 | get: function get() { |
| 1170 | return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames))); |
| 1171 | } |
| 1172 | }, |
| 1173 | { |
| 1174 | key: "currentAttributeNames", |
| 1175 | get: function get() { |
| 1176 | return Array.from(this.element.attributes).map(function(attribute) { |
| 1177 | return attribute.name; |
| 1178 | }); |
| 1179 | } |
| 1180 | }, |
| 1181 | { |
| 1182 | key: "recordedAttributeNames", |
| 1183 | get: function get() { |
| 1184 | return Array.from(this.stringMap.keys()); |
| 1185 | } |
| 1186 | } |
| 1187 | ]); |
| 1188 | return StringMapObserver; |
| 1189 | }(); |
| 1190 | function add(map, key, value) { |
| 1191 | fetch(map, key).add(value); |
| 1192 | } |
| 1193 | function del(map, key, value) { |
| 1194 | fetch(map, key).delete(value); |
| 1195 | prune(map, key); |
| 1196 | } |
| 1197 | function fetch(map, key) { |
| 1198 | var values = map.get(key); |
| 1199 | if (!values) { |
| 1200 | values = new Set(); |
| 1201 | map.set(key, values); |
| 1202 | } |
| 1203 | return values; |
| 1204 | } |
| 1205 | function prune(map, key) { |
| 1206 | var values = map.get(key); |
| 1207 | if (values != null && values.size == 0) map.delete(key); |
| 1208 | } |
| 1209 | var Multimap = /*#__PURE__*/ function() { |
| 1210 | "use strict"; |
| 1211 | function Multimap() { |
| 1212 | (0, _classCallCheckJsDefault.default)(this, Multimap); |
| 1213 | this.valuesByKey = new Map(); |
| 1214 | } |
| 1215 | (0, _createClassJsDefault.default)(Multimap, [ |
| 1216 | { |
| 1217 | key: "keys", |
| 1218 | get: function get() { |
| 1219 | return Array.from(this.valuesByKey.keys()); |
| 1220 | } |
| 1221 | }, |
| 1222 | { |
| 1223 | key: "values", |
| 1224 | get: function get() { |
| 1225 | var sets = Array.from(this.valuesByKey.values()); |
| 1226 | return sets.reduce(function(values, set) { |
| 1227 | return values.concat(Array.from(set)); |
| 1228 | }, []); |
| 1229 | } |
| 1230 | }, |
| 1231 | { |
| 1232 | key: "size", |
| 1233 | get: function get() { |
| 1234 | var sets = Array.from(this.valuesByKey.values()); |
| 1235 | return sets.reduce(function(size, set) { |
| 1236 | return size + set.size; |
| 1237 | }, 0); |
| 1238 | } |
| 1239 | }, |
| 1240 | { |
| 1241 | key: "add", |
| 1242 | value: function add1(key, value) { |
| 1243 | add(this.valuesByKey, key, value); |
| 1244 | } |
| 1245 | }, |
| 1246 | { |
| 1247 | key: "delete", |
| 1248 | value: function _delete(key, value) { |
| 1249 | del(this.valuesByKey, key, value); |
| 1250 | } |
| 1251 | }, |
| 1252 | { |
| 1253 | key: "has", |
| 1254 | value: function has(key, value) { |
| 1255 | var values = this.valuesByKey.get(key); |
| 1256 | return values != null && values.has(value); |
| 1257 | } |
| 1258 | }, |
| 1259 | { |
| 1260 | key: "hasKey", |
| 1261 | value: function hasKey(key) { |
| 1262 | return this.valuesByKey.has(key); |
| 1263 | } |
| 1264 | }, |
| 1265 | { |
| 1266 | key: "hasValue", |
| 1267 | value: function hasValue(value) { |
| 1268 | var sets = Array.from(this.valuesByKey.values()); |
| 1269 | return sets.some(function(set) { |
| 1270 | return set.has(value); |
| 1271 | }); |
| 1272 | } |
| 1273 | }, |
| 1274 | { |
| 1275 | key: "getValuesForKey", |
| 1276 | value: function getValuesForKey(key) { |
| 1277 | var values = this.valuesByKey.get(key); |
| 1278 | return values ? Array.from(values) : []; |
| 1279 | } |
| 1280 | }, |
| 1281 | { |
| 1282 | key: "getKeysForValue", |
| 1283 | value: function getKeysForValue(value) { |
| 1284 | return Array.from(this.valuesByKey).filter(function(param) { |
| 1285 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), key = _param[0], values = _param[1]; |
| 1286 | return values.has(value); |
| 1287 | }).map(function(param) { |
| 1288 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), key = _param[0], values = _param[1]; |
| 1289 | return key; |
| 1290 | }); |
| 1291 | } |
| 1292 | } |
| 1293 | ]); |
| 1294 | return Multimap; |
| 1295 | }(); |
| 1296 | var IndexedMultimap = /*#__PURE__*/ function(Multimap) { |
| 1297 | "use strict"; |
| 1298 | (0, _inheritsJsDefault.default)(IndexedMultimap, Multimap); |
| 1299 | var _super = (0, _createSuperJsDefault.default)(IndexedMultimap); |
| 1300 | function IndexedMultimap() { |
| 1301 | (0, _classCallCheckJsDefault.default)(this, IndexedMultimap); |
| 1302 | var _this; |
| 1303 | _this = _super.call(this); |
| 1304 | _this.keysByValue = new Map; |
| 1305 | return _this; |
| 1306 | } |
| 1307 | (0, _createClassJsDefault.default)(IndexedMultimap, [ |
| 1308 | { |
| 1309 | key: "values", |
| 1310 | get: function get() { |
| 1311 | return Array.from(this.keysByValue.keys()); |
| 1312 | } |
| 1313 | }, |
| 1314 | { |
| 1315 | key: "add", |
| 1316 | value: function add1(key, value) { |
| 1317 | (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(IndexedMultimap.prototype), "add", this).call(this, key, value); |
| 1318 | add(this.keysByValue, value, key); |
| 1319 | } |
| 1320 | }, |
| 1321 | { |
| 1322 | key: "delete", |
| 1323 | value: function _delete(key, value) { |
| 1324 | (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(IndexedMultimap.prototype), "delete", this).call(this, key, value); |
| 1325 | del(this.keysByValue, value, key); |
| 1326 | } |
| 1327 | }, |
| 1328 | { |
| 1329 | key: "hasValue", |
| 1330 | value: function hasValue(value) { |
| 1331 | return this.keysByValue.has(value); |
| 1332 | } |
| 1333 | }, |
| 1334 | { |
| 1335 | key: "getKeysForValue", |
| 1336 | value: function getKeysForValue(value) { |
| 1337 | var set = this.keysByValue.get(value); |
| 1338 | return set ? Array.from(set) : []; |
| 1339 | } |
| 1340 | } |
| 1341 | ]); |
| 1342 | return IndexedMultimap; |
| 1343 | }(Multimap); |
| 1344 | var TokenListObserver = /*#__PURE__*/ function() { |
| 1345 | "use strict"; |
| 1346 | function TokenListObserver(element, attributeName, delegate) { |
| 1347 | (0, _classCallCheckJsDefault.default)(this, TokenListObserver); |
| 1348 | this.attributeObserver = new AttributeObserver(element, attributeName, this); |
| 1349 | this.delegate = delegate; |
| 1350 | this.tokensByElement = new Multimap; |
| 1351 | } |
| 1352 | (0, _createClassJsDefault.default)(TokenListObserver, [ |
| 1353 | { |
| 1354 | key: "started", |
| 1355 | get: function get() { |
| 1356 | return this.attributeObserver.started; |
| 1357 | } |
| 1358 | }, |
| 1359 | { |
| 1360 | key: "start", |
| 1361 | value: function start() { |
| 1362 | this.attributeObserver.start(); |
| 1363 | } |
| 1364 | }, |
| 1365 | { |
| 1366 | key: "pause", |
| 1367 | value: function pause(callback) { |
| 1368 | this.attributeObserver.pause(callback); |
| 1369 | } |
| 1370 | }, |
| 1371 | { |
| 1372 | key: "stop", |
| 1373 | value: function stop() { |
| 1374 | this.attributeObserver.stop(); |
| 1375 | } |
| 1376 | }, |
| 1377 | { |
| 1378 | key: "refresh", |
| 1379 | value: function refresh() { |
| 1380 | this.attributeObserver.refresh(); |
| 1381 | } |
| 1382 | }, |
| 1383 | { |
| 1384 | key: "element", |
| 1385 | get: function get() { |
| 1386 | return this.attributeObserver.element; |
| 1387 | } |
| 1388 | }, |
| 1389 | { |
| 1390 | key: "attributeName", |
| 1391 | get: function get() { |
| 1392 | return this.attributeObserver.attributeName; |
| 1393 | } |
| 1394 | }, |
| 1395 | { |
| 1396 | key: "elementMatchedAttribute", |
| 1397 | value: function elementMatchedAttribute(element) { |
| 1398 | this.tokensMatched(this.readTokensForElement(element)); |
| 1399 | } |
| 1400 | }, |
| 1401 | { |
| 1402 | key: "elementAttributeValueChanged", |
| 1403 | value: function elementAttributeValueChanged(element) { |
| 1404 | var ref = (0, _slicedToArrayJsDefault.default)(this.refreshTokensForElement(element), 2), unmatchedTokens = ref[0], matchedTokens = ref[1]; |
| 1405 | this.tokensUnmatched(unmatchedTokens); |
| 1406 | this.tokensMatched(matchedTokens); |
| 1407 | } |
| 1408 | }, |
| 1409 | { |
| 1410 | key: "elementUnmatchedAttribute", |
| 1411 | value: function elementUnmatchedAttribute(element) { |
| 1412 | this.tokensUnmatched(this.tokensByElement.getValuesForKey(element)); |
| 1413 | } |
| 1414 | }, |
| 1415 | { |
| 1416 | key: "tokensMatched", |
| 1417 | value: function tokensMatched(tokens) { |
| 1418 | var _this = this; |
| 1419 | tokens.forEach(function(token) { |
| 1420 | return _this.tokenMatched(token); |
| 1421 | }); |
| 1422 | } |
| 1423 | }, |
| 1424 | { |
| 1425 | key: "tokensUnmatched", |
| 1426 | value: function tokensUnmatched(tokens) { |
| 1427 | var _this = this; |
| 1428 | tokens.forEach(function(token) { |
| 1429 | return _this.tokenUnmatched(token); |
| 1430 | }); |
| 1431 | } |
| 1432 | }, |
| 1433 | { |
| 1434 | key: "tokenMatched", |
| 1435 | value: function tokenMatched(token) { |
| 1436 | this.delegate.tokenMatched(token); |
| 1437 | this.tokensByElement.add(token.element, token); |
| 1438 | } |
| 1439 | }, |
| 1440 | { |
| 1441 | key: "tokenUnmatched", |
| 1442 | value: function tokenUnmatched(token) { |
| 1443 | this.delegate.tokenUnmatched(token); |
| 1444 | this.tokensByElement.delete(token.element, token); |
| 1445 | } |
| 1446 | }, |
| 1447 | { |
| 1448 | key: "refreshTokensForElement", |
| 1449 | value: function refreshTokensForElement(element) { |
| 1450 | var previousTokens = this.tokensByElement.getValuesForKey(element); |
| 1451 | var currentTokens = this.readTokensForElement(element); |
| 1452 | var firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(function(param) { |
| 1453 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), previousToken = _param[0], currentToken = _param[1]; |
| 1454 | return !tokensAreEqual(previousToken, currentToken); |
| 1455 | }); |
| 1456 | if (firstDifferingIndex == -1) return [ |
| 1457 | [], |
| 1458 | [] |
| 1459 | ]; |
| 1460 | else return [ |
| 1461 | previousTokens.slice(firstDifferingIndex), |
| 1462 | currentTokens.slice(firstDifferingIndex) |
| 1463 | ]; |
| 1464 | } |
| 1465 | }, |
| 1466 | { |
| 1467 | key: "readTokensForElement", |
| 1468 | value: function readTokensForElement(element) { |
| 1469 | var attributeName = this.attributeName; |
| 1470 | var tokenString = element.getAttribute(attributeName) || ""; |
| 1471 | return parseTokenString(tokenString, element, attributeName); |
| 1472 | } |
| 1473 | } |
| 1474 | ]); |
| 1475 | return TokenListObserver; |
| 1476 | }(); |
| 1477 | function parseTokenString(tokenString, element, attributeName) { |
| 1478 | return tokenString.trim().split(/\s+/).filter(function(content) { |
| 1479 | return content.length; |
| 1480 | }).map(function(content, index) { |
| 1481 | return { |
| 1482 | element: element, |
| 1483 | attributeName: attributeName, |
| 1484 | content: content, |
| 1485 | index: index |
| 1486 | }; |
| 1487 | }); |
| 1488 | } |
| 1489 | function zip(left, right) { |
| 1490 | var length = Math.max(left.length, right.length); |
| 1491 | return Array.from({ |
| 1492 | length: length |
| 1493 | }, function(_, index) { |
| 1494 | return [ |
| 1495 | left[index], |
| 1496 | right[index] |
| 1497 | ]; |
| 1498 | }); |
| 1499 | } |
| 1500 | function tokensAreEqual(left, right) { |
| 1501 | return left && right && left.index == right.index && left.content == right.content; |
| 1502 | } |
| 1503 | var ValueListObserver = /*#__PURE__*/ function() { |
| 1504 | "use strict"; |
| 1505 | function ValueListObserver(element, attributeName, delegate) { |
| 1506 | (0, _classCallCheckJsDefault.default)(this, ValueListObserver); |
| 1507 | this.tokenListObserver = new TokenListObserver(element, attributeName, this); |
| 1508 | this.delegate = delegate; |
| 1509 | this.parseResultsByToken = new WeakMap; |
| 1510 | this.valuesByTokenByElement = new WeakMap; |
| 1511 | } |
| 1512 | (0, _createClassJsDefault.default)(ValueListObserver, [ |
| 1513 | { |
| 1514 | key: "started", |
| 1515 | get: function get() { |
| 1516 | return this.tokenListObserver.started; |
| 1517 | } |
| 1518 | }, |
| 1519 | { |
| 1520 | key: "start", |
| 1521 | value: function start() { |
| 1522 | this.tokenListObserver.start(); |
| 1523 | } |
| 1524 | }, |
| 1525 | { |
| 1526 | key: "stop", |
| 1527 | value: function stop() { |
| 1528 | this.tokenListObserver.stop(); |
| 1529 | } |
| 1530 | }, |
| 1531 | { |
| 1532 | key: "refresh", |
| 1533 | value: function refresh() { |
| 1534 | this.tokenListObserver.refresh(); |
| 1535 | } |
| 1536 | }, |
| 1537 | { |
| 1538 | key: "element", |
| 1539 | get: function get() { |
| 1540 | return this.tokenListObserver.element; |
| 1541 | } |
| 1542 | }, |
| 1543 | { |
| 1544 | key: "attributeName", |
| 1545 | get: function get() { |
| 1546 | return this.tokenListObserver.attributeName; |
| 1547 | } |
| 1548 | }, |
| 1549 | { |
| 1550 | key: "tokenMatched", |
| 1551 | value: function tokenMatched(token) { |
| 1552 | var element = token.element; |
| 1553 | var value = this.fetchParseResultForToken(token).value; |
| 1554 | if (value) { |
| 1555 | this.fetchValuesByTokenForElement(element).set(token, value); |
| 1556 | this.delegate.elementMatchedValue(element, value); |
| 1557 | } |
| 1558 | } |
| 1559 | }, |
| 1560 | { |
| 1561 | key: "tokenUnmatched", |
| 1562 | value: function tokenUnmatched(token) { |
| 1563 | var element = token.element; |
| 1564 | var value = this.fetchParseResultForToken(token).value; |
| 1565 | if (value) { |
| 1566 | this.fetchValuesByTokenForElement(element).delete(token); |
| 1567 | this.delegate.elementUnmatchedValue(element, value); |
| 1568 | } |
| 1569 | } |
| 1570 | }, |
| 1571 | { |
| 1572 | key: "fetchParseResultForToken", |
| 1573 | value: function fetchParseResultForToken(token) { |
| 1574 | var parseResult = this.parseResultsByToken.get(token); |
| 1575 | if (!parseResult) { |
| 1576 | parseResult = this.parseToken(token); |
| 1577 | this.parseResultsByToken.set(token, parseResult); |
| 1578 | } |
| 1579 | return parseResult; |
| 1580 | } |
| 1581 | }, |
| 1582 | { |
| 1583 | key: "fetchValuesByTokenForElement", |
| 1584 | value: function fetchValuesByTokenForElement(element) { |
| 1585 | var valuesByToken = this.valuesByTokenByElement.get(element); |
| 1586 | if (!valuesByToken) { |
| 1587 | valuesByToken = new Map; |
| 1588 | this.valuesByTokenByElement.set(element, valuesByToken); |
| 1589 | } |
| 1590 | return valuesByToken; |
| 1591 | } |
| 1592 | }, |
| 1593 | { |
| 1594 | key: "parseToken", |
| 1595 | value: function parseToken(token) { |
| 1596 | try { |
| 1597 | var value = this.delegate.parseValueForToken(token); |
| 1598 | return { |
| 1599 | value: value |
| 1600 | }; |
| 1601 | } catch (error3) { |
| 1602 | return { |
| 1603 | error: error3 |
| 1604 | }; |
| 1605 | } |
| 1606 | } |
| 1607 | } |
| 1608 | ]); |
| 1609 | return ValueListObserver; |
| 1610 | }(); |
| 1611 | var BindingObserver = /*#__PURE__*/ function() { |
| 1612 | "use strict"; |
| 1613 | function BindingObserver(context, delegate) { |
| 1614 | (0, _classCallCheckJsDefault.default)(this, BindingObserver); |
| 1615 | this.context = context; |
| 1616 | this.delegate = delegate; |
| 1617 | this.bindingsByAction = new Map; |
| 1618 | } |
| 1619 | (0, _createClassJsDefault.default)(BindingObserver, [ |
| 1620 | { |
| 1621 | key: "start", |
| 1622 | value: function start() { |
| 1623 | if (!this.valueListObserver) { |
| 1624 | this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this); |
| 1625 | this.valueListObserver.start(); |
| 1626 | } |
| 1627 | } |
| 1628 | }, |
| 1629 | { |
| 1630 | key: "stop", |
| 1631 | value: function stop() { |
| 1632 | if (this.valueListObserver) { |
| 1633 | this.valueListObserver.stop(); |
| 1634 | delete this.valueListObserver; |
| 1635 | this.disconnectAllActions(); |
| 1636 | } |
| 1637 | } |
| 1638 | }, |
| 1639 | { |
| 1640 | key: "element", |
| 1641 | get: function get() { |
| 1642 | return this.context.element; |
| 1643 | } |
| 1644 | }, |
| 1645 | { |
| 1646 | key: "identifier", |
| 1647 | get: function get() { |
| 1648 | return this.context.identifier; |
| 1649 | } |
| 1650 | }, |
| 1651 | { |
| 1652 | key: "actionAttribute", |
| 1653 | get: function get() { |
| 1654 | return this.schema.actionAttribute; |
| 1655 | } |
| 1656 | }, |
| 1657 | { |
| 1658 | key: "schema", |
| 1659 | get: function get() { |
| 1660 | return this.context.schema; |
| 1661 | } |
| 1662 | }, |
| 1663 | { |
| 1664 | key: "bindings", |
| 1665 | get: function get() { |
| 1666 | return Array.from(this.bindingsByAction.values()); |
| 1667 | } |
| 1668 | }, |
| 1669 | { |
| 1670 | key: "connectAction", |
| 1671 | value: function connectAction(action) { |
| 1672 | var binding = new Binding(this.context, action); |
| 1673 | this.bindingsByAction.set(action, binding); |
| 1674 | this.delegate.bindingConnected(binding); |
| 1675 | } |
| 1676 | }, |
| 1677 | { |
| 1678 | key: "disconnectAction", |
| 1679 | value: function disconnectAction(action) { |
| 1680 | var binding = this.bindingsByAction.get(action); |
| 1681 | if (binding) { |
| 1682 | this.bindingsByAction.delete(action); |
| 1683 | this.delegate.bindingDisconnected(binding); |
| 1684 | } |
| 1685 | } |
| 1686 | }, |
| 1687 | { |
| 1688 | key: "disconnectAllActions", |
| 1689 | value: function disconnectAllActions() { |
| 1690 | var _this = this; |
| 1691 | this.bindings.forEach(function(binding) { |
| 1692 | return _this.delegate.bindingDisconnected(binding); |
| 1693 | }); |
| 1694 | this.bindingsByAction.clear(); |
| 1695 | } |
| 1696 | }, |
| 1697 | { |
| 1698 | key: "parseValueForToken", |
| 1699 | value: function parseValueForToken(token) { |
| 1700 | var action = Action.forToken(token); |
| 1701 | if (action.identifier == this.identifier) return action; |
| 1702 | } |
| 1703 | }, |
| 1704 | { |
| 1705 | key: "elementMatchedValue", |
| 1706 | value: function elementMatchedValue(element, action) { |
| 1707 | this.connectAction(action); |
| 1708 | } |
| 1709 | }, |
| 1710 | { |
| 1711 | key: "elementUnmatchedValue", |
| 1712 | value: function elementUnmatchedValue(element, action) { |
| 1713 | this.disconnectAction(action); |
| 1714 | } |
| 1715 | } |
| 1716 | ]); |
| 1717 | return BindingObserver; |
| 1718 | }(); |
| 1719 | var ValueObserver = /*#__PURE__*/ function() { |
| 1720 | "use strict"; |
| 1721 | function ValueObserver(context, receiver) { |
| 1722 | (0, _classCallCheckJsDefault.default)(this, ValueObserver); |
| 1723 | this.context = context; |
| 1724 | this.receiver = receiver; |
| 1725 | this.stringMapObserver = new StringMapObserver(this.element, this); |
| 1726 | this.valueDescriptorMap = this.controller.valueDescriptorMap; |
| 1727 | this.invokeChangedCallbacksForDefaultValues(); |
| 1728 | } |
| 1729 | (0, _createClassJsDefault.default)(ValueObserver, [ |
| 1730 | { |
| 1731 | key: "start", |
| 1732 | value: function start() { |
| 1733 | this.stringMapObserver.start(); |
| 1734 | } |
| 1735 | }, |
| 1736 | { |
| 1737 | key: "stop", |
| 1738 | value: function stop() { |
| 1739 | this.stringMapObserver.stop(); |
| 1740 | } |
| 1741 | }, |
| 1742 | { |
| 1743 | key: "element", |
| 1744 | get: function get() { |
| 1745 | return this.context.element; |
| 1746 | } |
| 1747 | }, |
| 1748 | { |
| 1749 | key: "controller", |
| 1750 | get: function get() { |
| 1751 | return this.context.controller; |
| 1752 | } |
| 1753 | }, |
| 1754 | { |
| 1755 | key: "getStringMapKeyForAttribute", |
| 1756 | value: function getStringMapKeyForAttribute(attributeName) { |
| 1757 | if (attributeName in this.valueDescriptorMap) return this.valueDescriptorMap[attributeName].name; |
| 1758 | } |
| 1759 | }, |
| 1760 | { |
| 1761 | key: "stringMapKeyAdded", |
| 1762 | value: function stringMapKeyAdded(key, attributeName) { |
| 1763 | var descriptor = this.valueDescriptorMap[attributeName]; |
| 1764 | if (!this.hasValue(key)) this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue)); |
| 1765 | } |
| 1766 | }, |
| 1767 | { |
| 1768 | key: "stringMapValueChanged", |
| 1769 | value: function stringMapValueChanged(value, name, oldValue) { |
| 1770 | var descriptor = this.valueDescriptorNameMap[name]; |
| 1771 | if (value === null) return; |
| 1772 | if (oldValue === null) oldValue = descriptor.writer(descriptor.defaultValue); |
| 1773 | this.invokeChangedCallback(name, value, oldValue); |
| 1774 | } |
| 1775 | }, |
| 1776 | { |
| 1777 | key: "stringMapKeyRemoved", |
| 1778 | value: function stringMapKeyRemoved(key, attributeName, oldValue) { |
| 1779 | var descriptor = this.valueDescriptorNameMap[key]; |
| 1780 | if (this.hasValue(key)) this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue); |
| 1781 | else this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue); |
| 1782 | } |
| 1783 | }, |
| 1784 | { |
| 1785 | key: "invokeChangedCallbacksForDefaultValues", |
| 1786 | value: function invokeChangedCallbacksForDefaultValues() { |
| 1787 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 1788 | try { |
| 1789 | for(var _iterator = this.valueDescriptors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 1790 | var _value = _step.value, key = _value.key, name = _value.name, defaultValue = _value.defaultValue, writer = _value.writer; |
| 1791 | if (defaultValue != undefined && !this.controller.data.has(key)) this.invokeChangedCallback(name, writer(defaultValue), undefined); |
| 1792 | } |
| 1793 | } catch (err) { |
| 1794 | _didIteratorError = true; |
| 1795 | _iteratorError = err; |
| 1796 | } finally{ |
| 1797 | try { |
| 1798 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 1799 | _iterator.return(); |
| 1800 | } |
| 1801 | } finally{ |
| 1802 | if (_didIteratorError) { |
| 1803 | throw _iteratorError; |
| 1804 | } |
| 1805 | } |
| 1806 | } |
| 1807 | } |
| 1808 | }, |
| 1809 | { |
| 1810 | key: "invokeChangedCallback", |
| 1811 | value: function invokeChangedCallback(name, rawValue, rawOldValue) { |
| 1812 | var changedMethodName = "".concat(name, "Changed"); |
| 1813 | var changedMethod = this.receiver[changedMethodName]; |
| 1814 | if (typeof changedMethod == "function") { |
| 1815 | var descriptor = this.valueDescriptorNameMap[name]; |
| 1816 | var value = descriptor.reader(rawValue); |
| 1817 | var oldValue = rawOldValue; |
| 1818 | if (rawOldValue) oldValue = descriptor.reader(rawOldValue); |
| 1819 | changedMethod.call(this.receiver, value, oldValue); |
| 1820 | } |
| 1821 | } |
| 1822 | }, |
| 1823 | { |
| 1824 | key: "valueDescriptors", |
| 1825 | get: function get() { |
| 1826 | var valueDescriptorMap = this.valueDescriptorMap; |
| 1827 | return Object.keys(valueDescriptorMap).map(function(key) { |
| 1828 | return valueDescriptorMap[key]; |
| 1829 | }); |
| 1830 | } |
| 1831 | }, |
| 1832 | { |
| 1833 | key: "valueDescriptorNameMap", |
| 1834 | get: function get() { |
| 1835 | var _this = this; |
| 1836 | var descriptors = {}; |
| 1837 | Object.keys(this.valueDescriptorMap).forEach(function(key) { |
| 1838 | var descriptor = _this.valueDescriptorMap[key]; |
| 1839 | descriptors[descriptor.name] = descriptor; |
| 1840 | }); |
| 1841 | return descriptors; |
| 1842 | } |
| 1843 | }, |
| 1844 | { |
| 1845 | key: "hasValue", |
| 1846 | value: function hasValue(attributeName) { |
| 1847 | var descriptor = this.valueDescriptorNameMap[attributeName]; |
| 1848 | var hasMethodName = "has".concat(capitalize(descriptor.name)); |
| 1849 | return this.receiver[hasMethodName]; |
| 1850 | } |
| 1851 | } |
| 1852 | ]); |
| 1853 | return ValueObserver; |
| 1854 | }(); |
| 1855 | var TargetObserver = /*#__PURE__*/ function() { |
| 1856 | "use strict"; |
| 1857 | function TargetObserver(context, delegate) { |
| 1858 | (0, _classCallCheckJsDefault.default)(this, TargetObserver); |
| 1859 | this.context = context; |
| 1860 | this.delegate = delegate; |
| 1861 | this.targetsByName = new Multimap; |
| 1862 | } |
| 1863 | (0, _createClassJsDefault.default)(TargetObserver, [ |
| 1864 | { |
| 1865 | key: "start", |
| 1866 | value: function start() { |
| 1867 | if (!this.tokenListObserver) { |
| 1868 | this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this); |
| 1869 | this.tokenListObserver.start(); |
| 1870 | } |
| 1871 | } |
| 1872 | }, |
| 1873 | { |
| 1874 | key: "stop", |
| 1875 | value: function stop() { |
| 1876 | if (this.tokenListObserver) { |
| 1877 | this.disconnectAllTargets(); |
| 1878 | this.tokenListObserver.stop(); |
| 1879 | delete this.tokenListObserver; |
| 1880 | } |
| 1881 | } |
| 1882 | }, |
| 1883 | { |
| 1884 | key: "tokenMatched", |
| 1885 | value: function tokenMatched(param) { |
| 1886 | var element = param.element, name = param.content; |
| 1887 | if (this.scope.containsElement(element)) this.connectTarget(element, name); |
| 1888 | } |
| 1889 | }, |
| 1890 | { |
| 1891 | key: "tokenUnmatched", |
| 1892 | value: function tokenUnmatched(param) { |
| 1893 | var element = param.element, name = param.content; |
| 1894 | this.disconnectTarget(element, name); |
| 1895 | } |
| 1896 | }, |
| 1897 | { |
| 1898 | key: "connectTarget", |
| 1899 | value: function connectTarget(element, name) { |
| 1900 | var _a; |
| 1901 | if (!this.targetsByName.has(name, element)) { |
| 1902 | var _this = this; |
| 1903 | this.targetsByName.add(name, element); |
| 1904 | (_a = this.tokenListObserver) === null || _a === void 0 || _a.pause(function() { |
| 1905 | return _this.delegate.targetConnected(element, name); |
| 1906 | }); |
| 1907 | } |
| 1908 | } |
| 1909 | }, |
| 1910 | { |
| 1911 | key: "disconnectTarget", |
| 1912 | value: function disconnectTarget(element, name) { |
| 1913 | var _a; |
| 1914 | if (this.targetsByName.has(name, element)) { |
| 1915 | var _this = this; |
| 1916 | this.targetsByName.delete(name, element); |
| 1917 | (_a = this.tokenListObserver) === null || _a === void 0 || _a.pause(function() { |
| 1918 | return _this.delegate.targetDisconnected(element, name); |
| 1919 | }); |
| 1920 | } |
| 1921 | } |
| 1922 | }, |
| 1923 | { |
| 1924 | key: "disconnectAllTargets", |
| 1925 | value: function disconnectAllTargets() { |
| 1926 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined, _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined; |
| 1927 | try { |
| 1928 | for(var _iterator = this.targetsByName.keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion2 = (_step = _iterator.next()).done); _iteratorNormalCompletion2 = true){ |
| 1929 | var name = _step.value; |
| 1930 | try { |
| 1931 | for(var _iterator2 = this.targetsByName.getValuesForKey(name)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion = true){ |
| 1932 | var element = _step2.value; |
| 1933 | this.disconnectTarget(element, name); |
| 1934 | } |
| 1935 | } catch (err) { |
| 1936 | _didIteratorError = true; |
| 1937 | _iteratorError = err; |
| 1938 | } finally{ |
| 1939 | try { |
| 1940 | if (!_iteratorNormalCompletion && _iterator2.return != null) { |
| 1941 | _iterator2.return(); |
| 1942 | } |
| 1943 | } finally{ |
| 1944 | if (_didIteratorError) { |
| 1945 | throw _iteratorError; |
| 1946 | } |
| 1947 | } |
| 1948 | } |
| 1949 | } |
| 1950 | } catch (err) { |
| 1951 | _didIteratorError2 = true; |
| 1952 | _iteratorError2 = err; |
| 1953 | } finally{ |
| 1954 | try { |
| 1955 | if (!_iteratorNormalCompletion2 && _iterator.return != null) { |
| 1956 | _iterator.return(); |
| 1957 | } |
| 1958 | } finally{ |
| 1959 | if (_didIteratorError2) { |
| 1960 | throw _iteratorError2; |
| 1961 | } |
| 1962 | } |
| 1963 | } |
| 1964 | } |
| 1965 | }, |
| 1966 | { |
| 1967 | key: "attributeName", |
| 1968 | get: function get() { |
| 1969 | return "data-".concat(this.context.identifier, "-target"); |
| 1970 | } |
| 1971 | }, |
| 1972 | { |
| 1973 | key: "element", |
| 1974 | get: function get() { |
| 1975 | return this.context.element; |
| 1976 | } |
| 1977 | }, |
| 1978 | { |
| 1979 | key: "scope", |
| 1980 | get: function get() { |
| 1981 | return this.context.scope; |
| 1982 | } |
| 1983 | } |
| 1984 | ]); |
| 1985 | return TargetObserver; |
| 1986 | }(); |
| 1987 | var Context = /*#__PURE__*/ function() { |
| 1988 | "use strict"; |
| 1989 | function Context(module, scope) { |
| 1990 | var _this = this; |
| 1991 | (0, _classCallCheckJsDefault.default)(this, Context); |
| 1992 | this.logDebugActivity = function(functionName) { |
| 1993 | var detail = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; |
| 1994 | var identifier = _this.identifier, controller = _this.controller, element = _this.element; |
| 1995 | detail = Object.assign({ |
| 1996 | identifier: identifier, |
| 1997 | controller: controller, |
| 1998 | element: element |
| 1999 | }, detail); |
| 2000 | _this.application.logDebugActivity(_this.identifier, functionName, detail); |
| 2001 | }; |
| 2002 | this.module = module; |
| 2003 | this.scope = scope; |
| 2004 | this.controller = new module.controllerConstructor(this); |
| 2005 | this.bindingObserver = new BindingObserver(this, this.dispatcher); |
| 2006 | this.valueObserver = new ValueObserver(this, this.controller); |
| 2007 | this.targetObserver = new TargetObserver(this, this); |
| 2008 | try { |
| 2009 | this.controller.initialize(); |
| 2010 | this.logDebugActivity("initialize"); |
| 2011 | } catch (error4) { |
| 2012 | this.handleError(error4, "initializing controller"); |
| 2013 | } |
| 2014 | } |
| 2015 | (0, _createClassJsDefault.default)(Context, [ |
| 2016 | { |
| 2017 | key: "connect", |
| 2018 | value: function connect() { |
| 2019 | this.bindingObserver.start(); |
| 2020 | this.valueObserver.start(); |
| 2021 | this.targetObserver.start(); |
| 2022 | try { |
| 2023 | this.controller.connect(); |
| 2024 | this.logDebugActivity("connect"); |
| 2025 | } catch (error5) { |
| 2026 | this.handleError(error5, "connecting controller"); |
| 2027 | } |
| 2028 | } |
| 2029 | }, |
| 2030 | { |
| 2031 | key: "disconnect", |
| 2032 | value: function disconnect() { |
| 2033 | try { |
| 2034 | this.controller.disconnect(); |
| 2035 | this.logDebugActivity("disconnect"); |
| 2036 | } catch (error6) { |
| 2037 | this.handleError(error6, "disconnecting controller"); |
| 2038 | } |
| 2039 | this.targetObserver.stop(); |
| 2040 | this.valueObserver.stop(); |
| 2041 | this.bindingObserver.stop(); |
| 2042 | } |
| 2043 | }, |
| 2044 | { |
| 2045 | key: "application", |
| 2046 | get: function get() { |
| 2047 | return this.module.application; |
| 2048 | } |
| 2049 | }, |
| 2050 | { |
| 2051 | key: "identifier", |
| 2052 | get: function get() { |
| 2053 | return this.module.identifier; |
| 2054 | } |
| 2055 | }, |
| 2056 | { |
| 2057 | key: "schema", |
| 2058 | get: function get() { |
| 2059 | return this.application.schema; |
| 2060 | } |
| 2061 | }, |
| 2062 | { |
| 2063 | key: "dispatcher", |
| 2064 | get: function get() { |
| 2065 | return this.application.dispatcher; |
| 2066 | } |
| 2067 | }, |
| 2068 | { |
| 2069 | key: "element", |
| 2070 | get: function get() { |
| 2071 | return this.scope.element; |
| 2072 | } |
| 2073 | }, |
| 2074 | { |
| 2075 | key: "parentElement", |
| 2076 | get: function get() { |
| 2077 | return this.element.parentElement; |
| 2078 | } |
| 2079 | }, |
| 2080 | { |
| 2081 | key: "handleError", |
| 2082 | value: function handleError(error7, message) { |
| 2083 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 2084 | var ref = this, identifier = ref.identifier, controller = ref.controller, element = ref.element; |
| 2085 | detail = Object.assign({ |
| 2086 | identifier: identifier, |
| 2087 | controller: controller, |
| 2088 | element: element |
| 2089 | }, detail); |
| 2090 | this.application.handleError(error7, "Error ".concat(message), detail); |
| 2091 | } |
| 2092 | }, |
| 2093 | { |
| 2094 | key: "targetConnected", |
| 2095 | value: function targetConnected(element, name) { |
| 2096 | this.invokeControllerMethod("".concat(name, "TargetConnected"), element); |
| 2097 | } |
| 2098 | }, |
| 2099 | { |
| 2100 | key: "targetDisconnected", |
| 2101 | value: function targetDisconnected(element, name) { |
| 2102 | this.invokeControllerMethod("".concat(name, "TargetDisconnected"), element); |
| 2103 | } |
| 2104 | }, |
| 2105 | { |
| 2106 | key: "invokeControllerMethod", |
| 2107 | value: function invokeControllerMethod(methodName) { |
| 2108 | for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ |
| 2109 | args[_key - 1] = arguments[_key]; |
| 2110 | } |
| 2111 | var _controller; |
| 2112 | var controller = this.controller; |
| 2113 | if (typeof controller[methodName] == "function") (_controller = controller)[methodName].apply(_controller, (0, _toConsumableArrayJsDefault.default)(args)); |
| 2114 | } |
| 2115 | } |
| 2116 | ]); |
| 2117 | return Context; |
| 2118 | }(); |
| 2119 | function readInheritableStaticArrayValues(constructor1, propertyName) { |
| 2120 | var ancestors = getAncestorsForConstructor(constructor1); |
| 2121 | return Array.from(ancestors.reduce(function(values, constructor) { |
| 2122 | getOwnStaticArrayValues(constructor, propertyName).forEach(function(name) { |
| 2123 | return values.add(name); |
| 2124 | }); |
| 2125 | return values; |
| 2126 | }, new Set)); |
| 2127 | } |
| 2128 | function readInheritableStaticObjectPairs(constructor2, propertyName) { |
| 2129 | var ancestors = getAncestorsForConstructor(constructor2); |
| 2130 | return ancestors.reduce(function(pairs, constructor) { |
| 2131 | var _pairs; |
| 2132 | (_pairs = pairs).push.apply(_pairs, (0, _toConsumableArrayJsDefault.default)(getOwnStaticObjectPairs(constructor, propertyName))); |
| 2133 | return pairs; |
| 2134 | }, []); |
| 2135 | } |
| 2136 | function getAncestorsForConstructor(constructor) { |
| 2137 | var ancestors = []; |
| 2138 | while(constructor){ |
| 2139 | ancestors.push(constructor); |
| 2140 | constructor = Object.getPrototypeOf(constructor); |
| 2141 | } |
| 2142 | return ancestors.reverse(); |
| 2143 | } |
| 2144 | function getOwnStaticArrayValues(constructor, propertyName) { |
| 2145 | var definition = constructor[propertyName]; |
| 2146 | return Array.isArray(definition) ? definition : []; |
| 2147 | } |
| 2148 | function getOwnStaticObjectPairs(constructor, propertyName) { |
| 2149 | var definition = constructor[propertyName]; |
| 2150 | return definition ? Object.keys(definition).map(function(key) { |
| 2151 | return [ |
| 2152 | key, |
| 2153 | definition[key] |
| 2154 | ]; |
| 2155 | }) : []; |
| 2156 | } |
| 2157 | function bless(constructor) { |
| 2158 | return shadow(constructor, getBlessedProperties(constructor)); |
| 2159 | } |
| 2160 | function shadow(constructor, properties) { |
| 2161 | var shadowConstructor = extend(constructor); |
| 2162 | var shadowProperties = getShadowProperties(constructor.prototype, properties); |
| 2163 | Object.defineProperties(shadowConstructor.prototype, shadowProperties); |
| 2164 | return shadowConstructor; |
| 2165 | } |
| 2166 | function getBlessedProperties(constructor) { |
| 2167 | var blessings = readInheritableStaticArrayValues(constructor, "blessings"); |
| 2168 | return blessings.reduce(function(blessedProperties, blessing) { |
| 2169 | var properties = blessing(constructor); |
| 2170 | for(var key in properties){ |
| 2171 | var descriptor = blessedProperties[key] || {}; |
| 2172 | blessedProperties[key] = Object.assign(descriptor, properties[key]); |
| 2173 | } |
| 2174 | return blessedProperties; |
| 2175 | }, {}); |
| 2176 | } |
| 2177 | function getShadowProperties(prototype, properties) { |
| 2178 | return getOwnKeys(properties).reduce(function(shadowProperties, key) { |
| 2179 | var descriptor = getShadowedDescriptor(prototype, properties, key); |
| 2180 | if (descriptor) Object.assign(shadowProperties, (0, _definePropertyJsDefault.default)({}, key, descriptor)); |
| 2181 | return shadowProperties; |
| 2182 | }, {}); |
| 2183 | } |
| 2184 | function getShadowedDescriptor(prototype, properties, key) { |
| 2185 | var shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key); |
| 2186 | var shadowedByValue = shadowingDescriptor && "value" in shadowingDescriptor; |
| 2187 | if (!shadowedByValue) { |
| 2188 | var descriptor = Object.getOwnPropertyDescriptor(properties, key).value; |
| 2189 | if (shadowingDescriptor) { |
| 2190 | descriptor.get = shadowingDescriptor.get || descriptor.get; |
| 2191 | descriptor.set = shadowingDescriptor.set || descriptor.set; |
| 2192 | } |
| 2193 | return descriptor; |
| 2194 | } |
| 2195 | } |
| 2196 | var getOwnKeys = function() { |
| 2197 | if (typeof Object.getOwnPropertySymbols == "function") return function(object) { |
| 2198 | return (0, _toConsumableArrayJsDefault.default)(Object.getOwnPropertyNames(object)).concat((0, _toConsumableArrayJsDefault.default)(Object.getOwnPropertySymbols(object))); |
| 2199 | }; |
| 2200 | else return Object.getOwnPropertyNames; |
| 2201 | }(); |
| 2202 | var extend = function _target() { |
| 2203 | var extendWithReflect = function extendWithReflect(constructor) { |
| 2204 | function extended() { |
| 2205 | return Reflect.construct(constructor, arguments, this instanceof extended ? this.constructor : void 0); |
| 2206 | } |
| 2207 | extended.prototype = Object.create(constructor.prototype, { |
| 2208 | constructor: { |
| 2209 | value: extended |
| 2210 | } |
| 2211 | }); |
| 2212 | Reflect.setPrototypeOf(extended, constructor); |
| 2213 | return extended; |
| 2214 | }; |
| 2215 | var testReflectExtension = function testReflectExtension() { |
| 2216 | var a = function a() { |
| 2217 | this.a.call(this); |
| 2218 | }; |
| 2219 | var b = extendWithReflect(a); |
| 2220 | b.prototype.a = function() {}; |
| 2221 | return new b; |
| 2222 | }; |
| 2223 | try { |
| 2224 | testReflectExtension(); |
| 2225 | return extendWithReflect; |
| 2226 | } catch (error) { |
| 2227 | return function(constructor3) { |
| 2228 | return /*#__PURE__*/ function(constructor) { |
| 2229 | "use strict"; |
| 2230 | (0, _inheritsJsDefault.default)(extended, constructor); |
| 2231 | var _super = (0, _createSuperJsDefault.default)(extended); |
| 2232 | function extended() { |
| 2233 | (0, _classCallCheckJsDefault.default)(this, extended); |
| 2234 | return _super.apply(this, arguments); |
| 2235 | } |
| 2236 | return extended; |
| 2237 | }(constructor3); |
| 2238 | }; |
| 2239 | } |
| 2240 | }(); |
| 2241 | function blessDefinition(definition) { |
| 2242 | return { |
| 2243 | identifier: definition.identifier, |
| 2244 | controllerConstructor: bless(definition.controllerConstructor) |
| 2245 | }; |
| 2246 | } |
| 2247 | var Module = /*#__PURE__*/ function() { |
| 2248 | "use strict"; |
| 2249 | function Module(application, definition) { |
| 2250 | (0, _classCallCheckJsDefault.default)(this, Module); |
| 2251 | this.application = application; |
| 2252 | this.definition = blessDefinition(definition); |
| 2253 | this.contextsByScope = new WeakMap; |
| 2254 | this.connectedContexts = new Set; |
| 2255 | } |
| 2256 | (0, _createClassJsDefault.default)(Module, [ |
| 2257 | { |
| 2258 | key: "identifier", |
| 2259 | get: function get() { |
| 2260 | return this.definition.identifier; |
| 2261 | } |
| 2262 | }, |
| 2263 | { |
| 2264 | key: "controllerConstructor", |
| 2265 | get: function get() { |
| 2266 | return this.definition.controllerConstructor; |
| 2267 | } |
| 2268 | }, |
| 2269 | { |
| 2270 | key: "contexts", |
| 2271 | get: function get() { |
| 2272 | return Array.from(this.connectedContexts); |
| 2273 | } |
| 2274 | }, |
| 2275 | { |
| 2276 | key: "connectContextForScope", |
| 2277 | value: function connectContextForScope(scope) { |
| 2278 | var context = this.fetchContextForScope(scope); |
| 2279 | this.connectedContexts.add(context); |
| 2280 | context.connect(); |
| 2281 | } |
| 2282 | }, |
| 2283 | { |
| 2284 | key: "disconnectContextForScope", |
| 2285 | value: function disconnectContextForScope(scope) { |
| 2286 | var context = this.contextsByScope.get(scope); |
| 2287 | if (context) { |
| 2288 | this.connectedContexts.delete(context); |
| 2289 | context.disconnect(); |
| 2290 | } |
| 2291 | } |
| 2292 | }, |
| 2293 | { |
| 2294 | key: "fetchContextForScope", |
| 2295 | value: function fetchContextForScope(scope) { |
| 2296 | var context = this.contextsByScope.get(scope); |
| 2297 | if (!context) { |
| 2298 | context = new Context(this, scope); |
| 2299 | this.contextsByScope.set(scope, context); |
| 2300 | } |
| 2301 | return context; |
| 2302 | } |
| 2303 | } |
| 2304 | ]); |
| 2305 | return Module; |
| 2306 | }(); |
| 2307 | var ClassMap = /*#__PURE__*/ function() { |
| 2308 | "use strict"; |
| 2309 | function ClassMap(scope) { |
| 2310 | (0, _classCallCheckJsDefault.default)(this, ClassMap); |
| 2311 | this.scope = scope; |
| 2312 | } |
| 2313 | (0, _createClassJsDefault.default)(ClassMap, [ |
| 2314 | { |
| 2315 | key: "has", |
| 2316 | value: function has(name) { |
| 2317 | return this.data.has(this.getDataKey(name)); |
| 2318 | } |
| 2319 | }, |
| 2320 | { |
| 2321 | key: "get", |
| 2322 | value: function get(name) { |
| 2323 | return this.getAll(name)[0]; |
| 2324 | } |
| 2325 | }, |
| 2326 | { |
| 2327 | key: "getAll", |
| 2328 | value: function getAll(name) { |
| 2329 | var tokenString = this.data.get(this.getDataKey(name)) || ""; |
| 2330 | return tokenize(tokenString); |
| 2331 | } |
| 2332 | }, |
| 2333 | { |
| 2334 | key: "getAttributeName", |
| 2335 | value: function getAttributeName(name) { |
| 2336 | return this.data.getAttributeNameForKey(this.getDataKey(name)); |
| 2337 | } |
| 2338 | }, |
| 2339 | { |
| 2340 | key: "getDataKey", |
| 2341 | value: function getDataKey(name) { |
| 2342 | return "".concat(name, "-class"); |
| 2343 | } |
| 2344 | }, |
| 2345 | { |
| 2346 | key: "data", |
| 2347 | get: function get() { |
| 2348 | return this.scope.data; |
| 2349 | } |
| 2350 | } |
| 2351 | ]); |
| 2352 | return ClassMap; |
| 2353 | }(); |
| 2354 | var DataMap = /*#__PURE__*/ function() { |
| 2355 | "use strict"; |
| 2356 | function DataMap(scope) { |
| 2357 | (0, _classCallCheckJsDefault.default)(this, DataMap); |
| 2358 | this.scope = scope; |
| 2359 | } |
| 2360 | (0, _createClassJsDefault.default)(DataMap, [ |
| 2361 | { |
| 2362 | key: "element", |
| 2363 | get: function get() { |
| 2364 | return this.scope.element; |
| 2365 | } |
| 2366 | }, |
| 2367 | { |
| 2368 | key: "identifier", |
| 2369 | get: function get() { |
| 2370 | return this.scope.identifier; |
| 2371 | } |
| 2372 | }, |
| 2373 | { |
| 2374 | key: "get", |
| 2375 | value: function get(key) { |
| 2376 | var name = this.getAttributeNameForKey(key); |
| 2377 | return this.element.getAttribute(name); |
| 2378 | } |
| 2379 | }, |
| 2380 | { |
| 2381 | key: "set", |
| 2382 | value: function set(key, value) { |
| 2383 | var name = this.getAttributeNameForKey(key); |
| 2384 | this.element.setAttribute(name, value); |
| 2385 | return this.get(key); |
| 2386 | } |
| 2387 | }, |
| 2388 | { |
| 2389 | key: "has", |
| 2390 | value: function has(key) { |
| 2391 | var name = this.getAttributeNameForKey(key); |
| 2392 | return this.element.hasAttribute(name); |
| 2393 | } |
| 2394 | }, |
| 2395 | { |
| 2396 | key: "delete", |
| 2397 | value: function _delete(key) { |
| 2398 | if (this.has(key)) { |
| 2399 | var name = this.getAttributeNameForKey(key); |
| 2400 | this.element.removeAttribute(name); |
| 2401 | return true; |
| 2402 | } else return false; |
| 2403 | } |
| 2404 | }, |
| 2405 | { |
| 2406 | key: "getAttributeNameForKey", |
| 2407 | value: function getAttributeNameForKey(key) { |
| 2408 | return "data-".concat(this.identifier, "-").concat(dasherize(key)); |
| 2409 | } |
| 2410 | } |
| 2411 | ]); |
| 2412 | return DataMap; |
| 2413 | }(); |
| 2414 | var Guide = /*#__PURE__*/ function() { |
| 2415 | "use strict"; |
| 2416 | function Guide(logger) { |
| 2417 | (0, _classCallCheckJsDefault.default)(this, Guide); |
| 2418 | this.warnedKeysByObject = new WeakMap; |
| 2419 | this.logger = logger; |
| 2420 | } |
| 2421 | (0, _createClassJsDefault.default)(Guide, [ |
| 2422 | { |
| 2423 | key: "warn", |
| 2424 | value: function warn(object, key, message) { |
| 2425 | var warnedKeys = this.warnedKeysByObject.get(object); |
| 2426 | if (!warnedKeys) { |
| 2427 | warnedKeys = new Set; |
| 2428 | this.warnedKeysByObject.set(object, warnedKeys); |
| 2429 | } |
| 2430 | if (!warnedKeys.has(key)) { |
| 2431 | warnedKeys.add(key); |
| 2432 | this.logger.warn(message, object); |
| 2433 | } |
| 2434 | } |
| 2435 | } |
| 2436 | ]); |
| 2437 | return Guide; |
| 2438 | }(); |
| 2439 | function attributeValueContainsToken(attributeName, token) { |
| 2440 | return "[".concat(attributeName, '~="').concat(token, '"]'); |
| 2441 | } |
| 2442 | var TargetSet = /*#__PURE__*/ function() { |
| 2443 | "use strict"; |
| 2444 | function TargetSet(scope) { |
| 2445 | (0, _classCallCheckJsDefault.default)(this, TargetSet); |
| 2446 | this.scope = scope; |
| 2447 | } |
| 2448 | (0, _createClassJsDefault.default)(TargetSet, [ |
| 2449 | { |
| 2450 | key: "element", |
| 2451 | get: function get() { |
| 2452 | return this.scope.element; |
| 2453 | } |
| 2454 | }, |
| 2455 | { |
| 2456 | key: "identifier", |
| 2457 | get: function get() { |
| 2458 | return this.scope.identifier; |
| 2459 | } |
| 2460 | }, |
| 2461 | { |
| 2462 | key: "schema", |
| 2463 | get: function get() { |
| 2464 | return this.scope.schema; |
| 2465 | } |
| 2466 | }, |
| 2467 | { |
| 2468 | key: "has", |
| 2469 | value: function has(targetName) { |
| 2470 | return this.find(targetName) != null; |
| 2471 | } |
| 2472 | }, |
| 2473 | { |
| 2474 | key: "find", |
| 2475 | value: function find() { |
| 2476 | for(var _len = arguments.length, targetNames = new Array(_len), _key = 0; _key < _len; _key++){ |
| 2477 | targetNames[_key] = arguments[_key]; |
| 2478 | } |
| 2479 | var _this = this; |
| 2480 | return targetNames.reduce(function(target, targetName) { |
| 2481 | return target || _this.findTarget(targetName) || _this.findLegacyTarget(targetName); |
| 2482 | }, undefined); |
| 2483 | } |
| 2484 | }, |
| 2485 | { |
| 2486 | key: "findAll", |
| 2487 | value: function findAll() { |
| 2488 | for(var _len = arguments.length, targetNames = new Array(_len), _key = 0; _key < _len; _key++){ |
| 2489 | targetNames[_key] = arguments[_key]; |
| 2490 | } |
| 2491 | var _this = this; |
| 2492 | return targetNames.reduce(function(targets, targetName) { |
| 2493 | return (0, _toConsumableArrayJsDefault.default)(targets).concat((0, _toConsumableArrayJsDefault.default)(_this.findAllTargets(targetName)), (0, _toConsumableArrayJsDefault.default)(_this.findAllLegacyTargets(targetName))); |
| 2494 | }, []); |
| 2495 | } |
| 2496 | }, |
| 2497 | { |
| 2498 | key: "findTarget", |
| 2499 | value: function findTarget(targetName) { |
| 2500 | var selector = this.getSelectorForTargetName(targetName); |
| 2501 | return this.scope.findElement(selector); |
| 2502 | } |
| 2503 | }, |
| 2504 | { |
| 2505 | key: "findAllTargets", |
| 2506 | value: function findAllTargets(targetName) { |
| 2507 | var selector = this.getSelectorForTargetName(targetName); |
| 2508 | return this.scope.findAllElements(selector); |
| 2509 | } |
| 2510 | }, |
| 2511 | { |
| 2512 | key: "getSelectorForTargetName", |
| 2513 | value: function getSelectorForTargetName(targetName) { |
| 2514 | var attributeName = this.schema.targetAttributeForScope(this.identifier); |
| 2515 | return attributeValueContainsToken(attributeName, targetName); |
| 2516 | } |
| 2517 | }, |
| 2518 | { |
| 2519 | key: "findLegacyTarget", |
| 2520 | value: function findLegacyTarget(targetName) { |
| 2521 | var selector = this.getLegacySelectorForTargetName(targetName); |
| 2522 | return this.deprecate(this.scope.findElement(selector), targetName); |
| 2523 | } |
| 2524 | }, |
| 2525 | { |
| 2526 | key: "findAllLegacyTargets", |
| 2527 | value: function findAllLegacyTargets(targetName) { |
| 2528 | var _this = this; |
| 2529 | var selector = this.getLegacySelectorForTargetName(targetName); |
| 2530 | return this.scope.findAllElements(selector).map(function(element) { |
| 2531 | return _this.deprecate(element, targetName); |
| 2532 | }); |
| 2533 | } |
| 2534 | }, |
| 2535 | { |
| 2536 | key: "getLegacySelectorForTargetName", |
| 2537 | value: function getLegacySelectorForTargetName(targetName) { |
| 2538 | var targetDescriptor = "".concat(this.identifier, ".").concat(targetName); |
| 2539 | return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor); |
| 2540 | } |
| 2541 | }, |
| 2542 | { |
| 2543 | key: "deprecate", |
| 2544 | value: function deprecate(element, targetName) { |
| 2545 | if (element) { |
| 2546 | var identifier = this.identifier; |
| 2547 | var attributeName = this.schema.targetAttribute; |
| 2548 | var revisedAttributeName = this.schema.targetAttributeForScope(identifier); |
| 2549 | this.guide.warn(element, "target:".concat(targetName), "Please replace ".concat(attributeName, '="').concat(identifier, ".").concat(targetName, '" with ').concat(revisedAttributeName, '="').concat(targetName, '". ') + "The ".concat(attributeName, " attribute is deprecated and will be removed in a future version of Stimulus.")); |
| 2550 | } |
| 2551 | return element; |
| 2552 | } |
| 2553 | }, |
| 2554 | { |
| 2555 | key: "guide", |
| 2556 | get: function get() { |
| 2557 | return this.scope.guide; |
| 2558 | } |
| 2559 | } |
| 2560 | ]); |
| 2561 | return TargetSet; |
| 2562 | }(); |
| 2563 | var Scope = /*#__PURE__*/ function() { |
| 2564 | "use strict"; |
| 2565 | function Scope(schema, element2, identifier, logger) { |
| 2566 | var _this = this; |
| 2567 | (0, _classCallCheckJsDefault.default)(this, Scope); |
| 2568 | this.targets = new TargetSet(this); |
| 2569 | this.classes = new ClassMap(this); |
| 2570 | this.data = new DataMap(this); |
| 2571 | this.containsElement = function(element) { |
| 2572 | return element.closest(_this.controllerSelector) === _this.element; |
| 2573 | }; |
| 2574 | this.schema = schema; |
| 2575 | this.element = element2; |
| 2576 | this.identifier = identifier; |
| 2577 | this.guide = new Guide(logger); |
| 2578 | } |
| 2579 | (0, _createClassJsDefault.default)(Scope, [ |
| 2580 | { |
| 2581 | key: "findElement", |
| 2582 | value: function findElement(selector) { |
| 2583 | return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement); |
| 2584 | } |
| 2585 | }, |
| 2586 | { |
| 2587 | key: "findAllElements", |
| 2588 | value: function findAllElements(selector) { |
| 2589 | return (0, _toConsumableArrayJsDefault.default)(this.element.matches(selector) ? [ |
| 2590 | this.element |
| 2591 | ] : []).concat((0, _toConsumableArrayJsDefault.default)(this.queryElements(selector).filter(this.containsElement))); |
| 2592 | } |
| 2593 | }, |
| 2594 | { |
| 2595 | key: "queryElements", |
| 2596 | value: function queryElements(selector) { |
| 2597 | return Array.from(this.element.querySelectorAll(selector)); |
| 2598 | } |
| 2599 | }, |
| 2600 | { |
| 2601 | key: "controllerSelector", |
| 2602 | get: function get() { |
| 2603 | return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier); |
| 2604 | } |
| 2605 | } |
| 2606 | ]); |
| 2607 | return Scope; |
| 2608 | }(); |
| 2609 | var ScopeObserver = /*#__PURE__*/ function() { |
| 2610 | "use strict"; |
| 2611 | function ScopeObserver(element, schema, delegate) { |
| 2612 | (0, _classCallCheckJsDefault.default)(this, ScopeObserver); |
| 2613 | this.element = element; |
| 2614 | this.schema = schema; |
| 2615 | this.delegate = delegate; |
| 2616 | this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this); |
| 2617 | this.scopesByIdentifierByElement = new WeakMap; |
| 2618 | this.scopeReferenceCounts = new WeakMap; |
| 2619 | } |
| 2620 | (0, _createClassJsDefault.default)(ScopeObserver, [ |
| 2621 | { |
| 2622 | key: "start", |
| 2623 | value: function start() { |
| 2624 | this.valueListObserver.start(); |
| 2625 | } |
| 2626 | }, |
| 2627 | { |
| 2628 | key: "stop", |
| 2629 | value: function stop() { |
| 2630 | this.valueListObserver.stop(); |
| 2631 | } |
| 2632 | }, |
| 2633 | { |
| 2634 | key: "controllerAttribute", |
| 2635 | get: function get() { |
| 2636 | return this.schema.controllerAttribute; |
| 2637 | } |
| 2638 | }, |
| 2639 | { |
| 2640 | key: "parseValueForToken", |
| 2641 | value: function parseValueForToken(token) { |
| 2642 | var element = token.element, identifier = token.content; |
| 2643 | var scopesByIdentifier = this.fetchScopesByIdentifierForElement(element); |
| 2644 | var scope = scopesByIdentifier.get(identifier); |
| 2645 | if (!scope) { |
| 2646 | scope = this.delegate.createScopeForElementAndIdentifier(element, identifier); |
| 2647 | scopesByIdentifier.set(identifier, scope); |
| 2648 | } |
| 2649 | return scope; |
| 2650 | } |
| 2651 | }, |
| 2652 | { |
| 2653 | key: "elementMatchedValue", |
| 2654 | value: function elementMatchedValue(element, value) { |
| 2655 | var referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1; |
| 2656 | this.scopeReferenceCounts.set(value, referenceCount); |
| 2657 | if (referenceCount == 1) this.delegate.scopeConnected(value); |
| 2658 | } |
| 2659 | }, |
| 2660 | { |
| 2661 | key: "elementUnmatchedValue", |
| 2662 | value: function elementUnmatchedValue(element, value) { |
| 2663 | var referenceCount = this.scopeReferenceCounts.get(value); |
| 2664 | if (referenceCount) { |
| 2665 | this.scopeReferenceCounts.set(value, referenceCount - 1); |
| 2666 | if (referenceCount == 1) this.delegate.scopeDisconnected(value); |
| 2667 | } |
| 2668 | } |
| 2669 | }, |
| 2670 | { |
| 2671 | key: "fetchScopesByIdentifierForElement", |
| 2672 | value: function fetchScopesByIdentifierForElement(element) { |
| 2673 | var scopesByIdentifier = this.scopesByIdentifierByElement.get(element); |
| 2674 | if (!scopesByIdentifier) { |
| 2675 | scopesByIdentifier = new Map; |
| 2676 | this.scopesByIdentifierByElement.set(element, scopesByIdentifier); |
| 2677 | } |
| 2678 | return scopesByIdentifier; |
| 2679 | } |
| 2680 | } |
| 2681 | ]); |
| 2682 | return ScopeObserver; |
| 2683 | }(); |
| 2684 | var Router = /*#__PURE__*/ function() { |
| 2685 | "use strict"; |
| 2686 | function Router(application) { |
| 2687 | (0, _classCallCheckJsDefault.default)(this, Router); |
| 2688 | this.application = application; |
| 2689 | this.scopeObserver = new ScopeObserver(this.element, this.schema, this); |
| 2690 | this.scopesByIdentifier = new Multimap; |
| 2691 | this.modulesByIdentifier = new Map; |
| 2692 | } |
| 2693 | (0, _createClassJsDefault.default)(Router, [ |
| 2694 | { |
| 2695 | key: "element", |
| 2696 | get: function get() { |
| 2697 | return this.application.element; |
| 2698 | } |
| 2699 | }, |
| 2700 | { |
| 2701 | key: "schema", |
| 2702 | get: function get() { |
| 2703 | return this.application.schema; |
| 2704 | } |
| 2705 | }, |
| 2706 | { |
| 2707 | key: "logger", |
| 2708 | get: function get() { |
| 2709 | return this.application.logger; |
| 2710 | } |
| 2711 | }, |
| 2712 | { |
| 2713 | key: "controllerAttribute", |
| 2714 | get: function get() { |
| 2715 | return this.schema.controllerAttribute; |
| 2716 | } |
| 2717 | }, |
| 2718 | { |
| 2719 | key: "modules", |
| 2720 | get: function get() { |
| 2721 | return Array.from(this.modulesByIdentifier.values()); |
| 2722 | } |
| 2723 | }, |
| 2724 | { |
| 2725 | key: "contexts", |
| 2726 | get: function get() { |
| 2727 | return this.modules.reduce(function(contexts, module) { |
| 2728 | return contexts.concat(module.contexts); |
| 2729 | }, []); |
| 2730 | } |
| 2731 | }, |
| 2732 | { |
| 2733 | key: "start", |
| 2734 | value: function start() { |
| 2735 | this.scopeObserver.start(); |
| 2736 | } |
| 2737 | }, |
| 2738 | { |
| 2739 | key: "stop", |
| 2740 | value: function stop() { |
| 2741 | this.scopeObserver.stop(); |
| 2742 | } |
| 2743 | }, |
| 2744 | { |
| 2745 | key: "loadDefinition", |
| 2746 | value: function loadDefinition(definition) { |
| 2747 | this.unloadIdentifier(definition.identifier); |
| 2748 | var module = new Module(this.application, definition); |
| 2749 | this.connectModule(module); |
| 2750 | } |
| 2751 | }, |
| 2752 | { |
| 2753 | key: "unloadIdentifier", |
| 2754 | value: function unloadIdentifier(identifier) { |
| 2755 | var module = this.modulesByIdentifier.get(identifier); |
| 2756 | if (module) this.disconnectModule(module); |
| 2757 | } |
| 2758 | }, |
| 2759 | { |
| 2760 | key: "getContextForElementAndIdentifier", |
| 2761 | value: function getContextForElementAndIdentifier(element, identifier) { |
| 2762 | var module = this.modulesByIdentifier.get(identifier); |
| 2763 | if (module) return module.contexts.find(function(context) { |
| 2764 | return context.element == element; |
| 2765 | }); |
| 2766 | } |
| 2767 | }, |
| 2768 | { |
| 2769 | key: "handleError", |
| 2770 | value: function handleError(error8, message, detail) { |
| 2771 | this.application.handleError(error8, message, detail); |
| 2772 | } |
| 2773 | }, |
| 2774 | { |
| 2775 | key: "createScopeForElementAndIdentifier", |
| 2776 | value: function createScopeForElementAndIdentifier(element, identifier) { |
| 2777 | return new Scope(this.schema, element, identifier, this.logger); |
| 2778 | } |
| 2779 | }, |
| 2780 | { |
| 2781 | key: "scopeConnected", |
| 2782 | value: function scopeConnected(scope) { |
| 2783 | this.scopesByIdentifier.add(scope.identifier, scope); |
| 2784 | var module = this.modulesByIdentifier.get(scope.identifier); |
| 2785 | if (module) module.connectContextForScope(scope); |
| 2786 | } |
| 2787 | }, |
| 2788 | { |
| 2789 | key: "scopeDisconnected", |
| 2790 | value: function scopeDisconnected(scope) { |
| 2791 | this.scopesByIdentifier.delete(scope.identifier, scope); |
| 2792 | var module = this.modulesByIdentifier.get(scope.identifier); |
| 2793 | if (module) module.disconnectContextForScope(scope); |
| 2794 | } |
| 2795 | }, |
| 2796 | { |
| 2797 | key: "connectModule", |
| 2798 | value: function connectModule(module) { |
| 2799 | this.modulesByIdentifier.set(module.identifier, module); |
| 2800 | var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); |
| 2801 | scopes.forEach(function(scope) { |
| 2802 | return module.connectContextForScope(scope); |
| 2803 | }); |
| 2804 | } |
| 2805 | }, |
| 2806 | { |
| 2807 | key: "disconnectModule", |
| 2808 | value: function disconnectModule(module) { |
| 2809 | this.modulesByIdentifier.delete(module.identifier); |
| 2810 | var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); |
| 2811 | scopes.forEach(function(scope) { |
| 2812 | return module.disconnectContextForScope(scope); |
| 2813 | }); |
| 2814 | } |
| 2815 | } |
| 2816 | ]); |
| 2817 | return Router; |
| 2818 | }(); |
| 2819 | var defaultSchema = { |
| 2820 | controllerAttribute: "data-controller", |
| 2821 | actionAttribute: "data-action", |
| 2822 | targetAttribute: "data-target", |
| 2823 | targetAttributeForScope: function(identifier) { |
| 2824 | return "data-".concat(identifier, "-target"); |
| 2825 | } |
| 2826 | }; |
| 2827 | var Application = /*#__PURE__*/ function() { |
| 2828 | "use strict"; |
| 2829 | function Application() { |
| 2830 | var element = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : document.documentElement, schema = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultSchema; |
| 2831 | var _this = this; |
| 2832 | (0, _classCallCheckJsDefault.default)(this, Application); |
| 2833 | this.logger = console; |
| 2834 | this.debug = false; |
| 2835 | this.logDebugActivity = function(identifier, functionName) { |
| 2836 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 2837 | if (_this.debug) _this.logFormattedMessage(identifier, functionName, detail); |
| 2838 | }; |
| 2839 | this.element = element; |
| 2840 | this.schema = schema; |
| 2841 | this.dispatcher = new Dispatcher(this); |
| 2842 | this.router = new Router(this); |
| 2843 | } |
| 2844 | (0, _createClassJsDefault.default)(Application, [ |
| 2845 | { |
| 2846 | key: "start", |
| 2847 | value: function start() { |
| 2848 | var _this = this; |
| 2849 | return (0, _asyncToGeneratorJsDefault.default)((0, _regeneratorRuntimeDefault.default).mark(function _callee() { |
| 2850 | return (0, _regeneratorRuntimeDefault.default).wrap(function _callee$(_ctx) { |
| 2851 | while(1)switch(_ctx.prev = _ctx.next){ |
| 2852 | case 0: |
| 2853 | _ctx.next = 2; |
| 2854 | return domReady(); |
| 2855 | case 2: |
| 2856 | _this.logDebugActivity("application", "starting"); |
| 2857 | _this.dispatcher.start(); |
| 2858 | _this.router.start(); |
| 2859 | _this.logDebugActivity("application", "start"); |
| 2860 | case 6: |
| 2861 | case "end": |
| 2862 | return _ctx.stop(); |
| 2863 | } |
| 2864 | }, _callee); |
| 2865 | }))(); |
| 2866 | } |
| 2867 | }, |
| 2868 | { |
| 2869 | key: "stop", |
| 2870 | value: function stop() { |
| 2871 | this.logDebugActivity("application", "stopping"); |
| 2872 | this.dispatcher.stop(); |
| 2873 | this.router.stop(); |
| 2874 | this.logDebugActivity("application", "stop"); |
| 2875 | } |
| 2876 | }, |
| 2877 | { |
| 2878 | key: "register", |
| 2879 | value: function register(identifier, controllerConstructor) { |
| 2880 | if (controllerConstructor.shouldLoad) this.load({ |
| 2881 | identifier: identifier, |
| 2882 | controllerConstructor: controllerConstructor |
| 2883 | }); |
| 2884 | } |
| 2885 | }, |
| 2886 | { |
| 2887 | key: "load", |
| 2888 | value: function load(head) { |
| 2889 | for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ |
| 2890 | rest[_key - 1] = arguments[_key]; |
| 2891 | } |
| 2892 | var _this = this; |
| 2893 | var definitions = Array.isArray(head) ? head : [ |
| 2894 | head |
| 2895 | ].concat((0, _toConsumableArrayJsDefault.default)(rest)); |
| 2896 | definitions.forEach(function(definition) { |
| 2897 | return _this.router.loadDefinition(definition); |
| 2898 | }); |
| 2899 | } |
| 2900 | }, |
| 2901 | { |
| 2902 | key: "unload", |
| 2903 | value: function unload(head) { |
| 2904 | for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ |
| 2905 | rest[_key - 1] = arguments[_key]; |
| 2906 | } |
| 2907 | var _this = this; |
| 2908 | var identifiers = Array.isArray(head) ? head : [ |
| 2909 | head |
| 2910 | ].concat((0, _toConsumableArrayJsDefault.default)(rest)); |
| 2911 | identifiers.forEach(function(identifier) { |
| 2912 | return _this.router.unloadIdentifier(identifier); |
| 2913 | }); |
| 2914 | } |
| 2915 | }, |
| 2916 | { |
| 2917 | key: "controllers", |
| 2918 | get: function get() { |
| 2919 | return this.router.contexts.map(function(context) { |
| 2920 | return context.controller; |
| 2921 | }); |
| 2922 | } |
| 2923 | }, |
| 2924 | { |
| 2925 | key: "getControllerForElementAndIdentifier", |
| 2926 | value: function getControllerForElementAndIdentifier(element, identifier) { |
| 2927 | var context = this.router.getContextForElementAndIdentifier(element, identifier); |
| 2928 | return context ? context.controller : null; |
| 2929 | } |
| 2930 | }, |
| 2931 | { |
| 2932 | key: "handleError", |
| 2933 | value: function handleError(error9, message, detail) { |
| 2934 | var _a; |
| 2935 | this.logger.error("%s\n\n%o\n\n%o", message, error9, detail); |
| 2936 | (_a = window.onerror) === null || _a === void 0 || _a.call(window, message, "", 0, 0, error9); |
| 2937 | } |
| 2938 | }, |
| 2939 | { |
| 2940 | key: "logFormattedMessage", |
| 2941 | value: function logFormattedMessage(identifier, functionName) { |
| 2942 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 2943 | detail = Object.assign({ |
| 2944 | application: this |
| 2945 | }, detail); |
| 2946 | this.logger.groupCollapsed("".concat(identifier, " #").concat(functionName)); |
| 2947 | this.logger.log("details:", Object.assign({}, detail)); |
| 2948 | this.logger.groupEnd(); |
| 2949 | } |
| 2950 | } |
| 2951 | ], [ |
| 2952 | { |
| 2953 | key: "start", |
| 2954 | value: function start(element, schema) { |
| 2955 | var application = new Application(element, schema); |
| 2956 | application.start(); |
| 2957 | return application; |
| 2958 | } |
| 2959 | } |
| 2960 | ]); |
| 2961 | return Application; |
| 2962 | }(); |
| 2963 | function domReady() { |
| 2964 | return new Promise(function(resolve) { |
| 2965 | if (document.readyState == "loading") document.addEventListener("DOMContentLoaded", function() { |
| 2966 | return resolve(); |
| 2967 | }); |
| 2968 | else resolve(); |
| 2969 | }); |
| 2970 | } |
| 2971 | function ClassPropertiesBlessing(constructor) { |
| 2972 | var classes = readInheritableStaticArrayValues(constructor, "classes"); |
| 2973 | return classes.reduce(function(properties, classDefinition) { |
| 2974 | return Object.assign(properties, propertiesForClassDefinition(classDefinition)); |
| 2975 | }, {}); |
| 2976 | } |
| 2977 | function propertiesForClassDefinition(key) { |
| 2978 | var _obj; |
| 2979 | return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, "".concat(key, "Class"), { |
| 2980 | get: function() { |
| 2981 | var classes = this.classes; |
| 2982 | if (classes.has(key)) return classes.get(key); |
| 2983 | else { |
| 2984 | var attribute = classes.getAttributeName(key); |
| 2985 | throw new Error('Missing attribute "'.concat(attribute, '"')); |
| 2986 | } |
| 2987 | } |
| 2988 | }), (0, _definePropertyJsDefault.default)(_obj, "".concat(key, "Classes"), { |
| 2989 | get: function() { |
| 2990 | return this.classes.getAll(key); |
| 2991 | } |
| 2992 | }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(key), "Class"), { |
| 2993 | get: function() { |
| 2994 | return this.classes.has(key); |
| 2995 | } |
| 2996 | }), _obj; |
| 2997 | } |
| 2998 | function TargetPropertiesBlessing(constructor) { |
| 2999 | var targets = readInheritableStaticArrayValues(constructor, "targets"); |
| 3000 | return targets.reduce(function(properties, targetDefinition) { |
| 3001 | return Object.assign(properties, propertiesForTargetDefinition(targetDefinition)); |
| 3002 | }, {}); |
| 3003 | } |
| 3004 | function propertiesForTargetDefinition(name) { |
| 3005 | var _obj; |
| 3006 | return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, "".concat(name, "Target"), { |
| 3007 | get: function() { |
| 3008 | var target = this.targets.find(name); |
| 3009 | if (target) return target; |
| 3010 | else throw new Error('Missing target element "'.concat(name, '" for "').concat(this.identifier, '" controller')); |
| 3011 | } |
| 3012 | }), (0, _definePropertyJsDefault.default)(_obj, "".concat(name, "Targets"), { |
| 3013 | get: function() { |
| 3014 | return this.targets.findAll(name); |
| 3015 | } |
| 3016 | }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(name), "Target"), { |
| 3017 | get: function() { |
| 3018 | return this.targets.has(name); |
| 3019 | } |
| 3020 | }), _obj; |
| 3021 | } |
| 3022 | function ValuePropertiesBlessing(constructor) { |
| 3023 | var valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, "values"); |
| 3024 | var propertyDescriptorMap = { |
| 3025 | valueDescriptorMap: { |
| 3026 | get: function() { |
| 3027 | var _this = this; |
| 3028 | return valueDefinitionPairs.reduce(function(result, valueDefinitionPair) { |
| 3029 | var valueDescriptor = parseValueDefinitionPair(valueDefinitionPair); |
| 3030 | var attributeName = _this.data.getAttributeNameForKey(valueDescriptor.key); |
| 3031 | return Object.assign(result, (0, _definePropertyJsDefault.default)({}, attributeName, valueDescriptor)); |
| 3032 | }, {}); |
| 3033 | } |
| 3034 | } |
| 3035 | }; |
| 3036 | return valueDefinitionPairs.reduce(function(properties, valueDefinitionPair) { |
| 3037 | return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair)); |
| 3038 | }, propertyDescriptorMap); |
| 3039 | } |
| 3040 | function propertiesForValueDefinitionPair(valueDefinitionPair) { |
| 3041 | var definition = parseValueDefinitionPair(valueDefinitionPair); |
| 3042 | var key = definition.key, name = definition.name, read = definition.reader, write = definition.writer; |
| 3043 | var _obj; |
| 3044 | return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, name, { |
| 3045 | get: function() { |
| 3046 | var value = this.data.get(key); |
| 3047 | if (value !== null) return read(value); |
| 3048 | else return definition.defaultValue; |
| 3049 | }, |
| 3050 | set: function(value) { |
| 3051 | if (value === undefined) this.data.delete(key); |
| 3052 | else this.data.set(key, write(value)); |
| 3053 | } |
| 3054 | }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(name)), { |
| 3055 | get: function() { |
| 3056 | return this.data.has(key) || definition.hasCustomDefaultValue; |
| 3057 | } |
| 3058 | }), _obj; |
| 3059 | } |
| 3060 | function parseValueDefinitionPair(param) { |
| 3061 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), token = _param[0], typeDefinition = _param[1]; |
| 3062 | return valueDescriptorForTokenAndTypeDefinition(token, typeDefinition); |
| 3063 | } |
| 3064 | function parseValueTypeConstant(constant) { |
| 3065 | switch(constant){ |
| 3066 | case Array: |
| 3067 | return "array"; |
| 3068 | case Boolean: |
| 3069 | return "boolean"; |
| 3070 | case Number: |
| 3071 | return "number"; |
| 3072 | case Object: |
| 3073 | return "object"; |
| 3074 | case String: |
| 3075 | return "string"; |
| 3076 | } |
| 3077 | } |
| 3078 | function parseValueTypeDefault(defaultValue) { |
| 3079 | switch(typeof defaultValue === "undefined" ? "undefined" : (0, _typeOfJsDefault.default)(defaultValue)){ |
| 3080 | case "boolean": |
| 3081 | return "boolean"; |
| 3082 | case "number": |
| 3083 | return "number"; |
| 3084 | case "string": |
| 3085 | return "string"; |
| 3086 | } |
| 3087 | if (Array.isArray(defaultValue)) return "array"; |
| 3088 | if (Object.prototype.toString.call(defaultValue) === "[object Object]") return "object"; |
| 3089 | } |
| 3090 | function parseValueTypeObject(typeObject) { |
| 3091 | var typeFromObject = parseValueTypeConstant(typeObject.type); |
| 3092 | if (typeFromObject) { |
| 3093 | var defaultValueType = parseValueTypeDefault(typeObject.default); |
| 3094 | if (typeFromObject !== defaultValueType) throw new Error('Type "'.concat(typeFromObject, '" must match the type of the default value. Given default value: "').concat(typeObject.default, '" as "').concat(defaultValueType, '"')); |
| 3095 | return typeFromObject; |
| 3096 | } |
| 3097 | } |
| 3098 | function parseValueTypeDefinition(typeDefinition) { |
| 3099 | var typeFromObject = parseValueTypeObject(typeDefinition); |
| 3100 | var typeFromDefaultValue = parseValueTypeDefault(typeDefinition); |
| 3101 | var typeFromConstant = parseValueTypeConstant(typeDefinition); |
| 3102 | var type = typeFromObject || typeFromDefaultValue || typeFromConstant; |
| 3103 | if (type) return type; |
| 3104 | throw new Error('Unknown value type "'.concat(typeDefinition, '"')); |
| 3105 | } |
| 3106 | function defaultValueForDefinition(typeDefinition) { |
| 3107 | var constant = parseValueTypeConstant(typeDefinition); |
| 3108 | if (constant) return defaultValuesByType[constant]; |
| 3109 | var defaultValue = typeDefinition.default; |
| 3110 | if (defaultValue !== undefined) return defaultValue; |
| 3111 | return typeDefinition; |
| 3112 | } |
| 3113 | function valueDescriptorForTokenAndTypeDefinition(token, typeDefinition) { |
| 3114 | var key = "".concat(dasherize(token), "-value"); |
| 3115 | var type = parseValueTypeDefinition(typeDefinition); |
| 3116 | return { |
| 3117 | type: type, |
| 3118 | key: key, |
| 3119 | name: camelize(key), |
| 3120 | get defaultValue () { |
| 3121 | return defaultValueForDefinition(typeDefinition); |
| 3122 | }, |
| 3123 | get hasCustomDefaultValue () { |
| 3124 | return parseValueTypeDefault(typeDefinition) !== undefined; |
| 3125 | }, |
| 3126 | reader: readers[type], |
| 3127 | writer: writers[type] || writers.default |
| 3128 | }; |
| 3129 | } |
| 3130 | var defaultValuesByType = { |
| 3131 | get array () { |
| 3132 | return []; |
| 3133 | }, |
| 3134 | boolean: false, |
| 3135 | number: 0, |
| 3136 | get object () { |
| 3137 | return {}; |
| 3138 | }, |
| 3139 | string: "" |
| 3140 | }; |
| 3141 | var readers = { |
| 3142 | array: function(value) { |
| 3143 | var array = JSON.parse(value); |
| 3144 | if (!Array.isArray(array)) throw new TypeError("Expected array"); |
| 3145 | return array; |
| 3146 | }, |
| 3147 | boolean: function(value) { |
| 3148 | return !(value == "0" || value == "false"); |
| 3149 | }, |
| 3150 | number: function(value) { |
| 3151 | return Number(value); |
| 3152 | }, |
| 3153 | object: function(value) { |
| 3154 | var object = JSON.parse(value); |
| 3155 | if (object === null || typeof object != "object" || Array.isArray(object)) throw new TypeError("Expected object"); |
| 3156 | return object; |
| 3157 | }, |
| 3158 | string: function(value) { |
| 3159 | return value; |
| 3160 | } |
| 3161 | }; |
| 3162 | var writers = { |
| 3163 | default: writeString, |
| 3164 | array: writeJSON, |
| 3165 | object: writeJSON |
| 3166 | }; |
| 3167 | function writeJSON(value) { |
| 3168 | return JSON.stringify(value); |
| 3169 | } |
| 3170 | function writeString(value) { |
| 3171 | return "".concat(value); |
| 3172 | } |
| 3173 | var Controller = /*#__PURE__*/ function() { |
| 3174 | "use strict"; |
| 3175 | function Controller(context) { |
| 3176 | (0, _classCallCheckJsDefault.default)(this, Controller); |
| 3177 | this.context = context; |
| 3178 | } |
| 3179 | (0, _createClassJsDefault.default)(Controller, [ |
| 3180 | { |
| 3181 | key: "application", |
| 3182 | get: function get() { |
| 3183 | return this.context.application; |
| 3184 | } |
| 3185 | }, |
| 3186 | { |
| 3187 | key: "scope", |
| 3188 | get: function get() { |
| 3189 | return this.context.scope; |
| 3190 | } |
| 3191 | }, |
| 3192 | { |
| 3193 | key: "element", |
| 3194 | get: function get() { |
| 3195 | return this.scope.element; |
| 3196 | } |
| 3197 | }, |
| 3198 | { |
| 3199 | key: "identifier", |
| 3200 | get: function get() { |
| 3201 | return this.scope.identifier; |
| 3202 | } |
| 3203 | }, |
| 3204 | { |
| 3205 | key: "targets", |
| 3206 | get: function get() { |
| 3207 | return this.scope.targets; |
| 3208 | } |
| 3209 | }, |
| 3210 | { |
| 3211 | key: "classes", |
| 3212 | get: function get() { |
| 3213 | return this.scope.classes; |
| 3214 | } |
| 3215 | }, |
| 3216 | { |
| 3217 | key: "data", |
| 3218 | get: function get() { |
| 3219 | return this.scope.data; |
| 3220 | } |
| 3221 | }, |
| 3222 | { |
| 3223 | key: "initialize", |
| 3224 | value: function initialize() {} |
| 3225 | }, |
| 3226 | { |
| 3227 | key: "connect", |
| 3228 | value: function connect() {} |
| 3229 | }, |
| 3230 | { |
| 3231 | key: "disconnect", |
| 3232 | value: function disconnect() {} |
| 3233 | }, |
| 3234 | { |
| 3235 | key: "dispatch", |
| 3236 | value: function dispatch(eventName) { |
| 3237 | var ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _target = ref.target, target = _target === void 0 ? this.element : _target, _detail = ref.detail, detail = _detail === void 0 ? {} : _detail, _prefix = ref.prefix, prefix = _prefix === void 0 ? this.identifier : _prefix, _bubbles = ref.bubbles, bubbles = _bubbles === void 0 ? true : _bubbles, _cancelable = ref.cancelable, cancelable = _cancelable === void 0 ? true : _cancelable; |
| 3238 | var type = prefix ? "".concat(prefix, ":").concat(eventName) : eventName; |
| 3239 | var event = new CustomEvent(type, { |
| 3240 | detail: detail, |
| 3241 | bubbles: bubbles, |
| 3242 | cancelable: cancelable |
| 3243 | }); |
| 3244 | target.dispatchEvent(event); |
| 3245 | return event; |
| 3246 | } |
| 3247 | } |
| 3248 | ], [ |
| 3249 | { |
| 3250 | key: "shouldLoad", |
| 3251 | get: function get() { |
| 3252 | return true; |
| 3253 | } |
| 3254 | } |
| 3255 | ]); |
| 3256 | return Controller; |
| 3257 | }(); |
| 3258 | Controller.blessings = [ |
| 3259 | ClassPropertiesBlessing, |
| 3260 | TargetPropertiesBlessing, |
| 3261 | ValuePropertiesBlessing |
| 3262 | ]; |
| 3263 | Controller.targets = []; |
| 3264 | Controller.values = {}; |
| 3265 | |
| 3266 | },{"@swc/helpers/lib/_async_to_generator.js":"fKf1r","@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_define_property.js":"6IXzf","@swc/helpers/lib/_get.js":"5g4pb","@swc/helpers/lib/_get_prototype_of.js":"7Gb6H","@swc/helpers/lib/_inherits.js":"atvDk","@swc/helpers/lib/_sliced_to_array.js":"4IWLM","@swc/helpers/lib/_to_consumable_array.js":"cccKv","@swc/helpers/lib/_type_of.js":"9FF45","@swc/helpers/lib/_create_super.js":"5rW3S","regenerator-runtime":"7j2bv","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"fKf1r":[function(require,module,exports) { |
| 3267 | "use strict"; |
| 3268 | Object.defineProperty(exports, "__esModule", { |
| 3269 | value: true |
| 3270 | }); |
| 3271 | exports.default = _asyncToGenerator; |
| 3272 | function _asyncToGenerator(fn) { |
| 3273 | return function() { |
| 3274 | var self = this, args = arguments; |
| 3275 | return new Promise(function(resolve, reject) { |
| 3276 | var gen = fn.apply(self, args); |
| 3277 | function _next(value) { |
| 3278 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); |
| 3279 | } |
| 3280 | function _throw(err) { |
| 3281 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); |
| 3282 | } |
| 3283 | _next(undefined); |
| 3284 | }); |
| 3285 | }; |
| 3286 | } |
| 3287 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
| 3288 | try { |
| 3289 | var info = gen[key](arg); |
| 3290 | var value = info.value; |
| 3291 | } catch (error) { |
| 3292 | reject(error); |
| 3293 | return; |
| 3294 | } |
| 3295 | if (info.done) resolve(value); |
| 3296 | else Promise.resolve(value).then(_next, _throw); |
| 3297 | } |
| 3298 | |
| 3299 | },{}],"gNxF8":[function(require,module,exports) { |
| 3300 | "use strict"; |
| 3301 | Object.defineProperty(exports, "__esModule", { |
| 3302 | value: true |
| 3303 | }); |
| 3304 | exports.default = _classCallCheck; |
| 3305 | function _classCallCheck(instance, Constructor) { |
| 3306 | if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); |
| 3307 | } |
| 3308 | |
| 3309 | },{}],"iyoaN":[function(require,module,exports) { |
| 3310 | "use strict"; |
| 3311 | Object.defineProperty(exports, "__esModule", { |
| 3312 | value: true |
| 3313 | }); |
| 3314 | exports.default = _createClass; |
| 3315 | function _createClass(Constructor, protoProps, staticProps) { |
| 3316 | if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
| 3317 | if (staticProps) _defineProperties(Constructor, staticProps); |
| 3318 | return Constructor; |
| 3319 | } |
| 3320 | function _defineProperties(target, props) { |
| 3321 | for(var i = 0; i < props.length; i++){ |
| 3322 | var descriptor = props[i]; |
| 3323 | descriptor.enumerable = descriptor.enumerable || false; |
| 3324 | descriptor.configurable = true; |
| 3325 | if ("value" in descriptor) descriptor.writable = true; |
| 3326 | Object.defineProperty(target, descriptor.key, descriptor); |
| 3327 | } |
| 3328 | } |
| 3329 | |
| 3330 | },{}],"6IXzf":[function(require,module,exports) { |
| 3331 | "use strict"; |
| 3332 | Object.defineProperty(exports, "__esModule", { |
| 3333 | value: true |
| 3334 | }); |
| 3335 | exports.default = _defineProperty; |
| 3336 | function _defineProperty(obj, key, value) { |
| 3337 | if (key in obj) Object.defineProperty(obj, key, { |
| 3338 | value: value, |
| 3339 | enumerable: true, |
| 3340 | configurable: true, |
| 3341 | writable: true |
| 3342 | }); |
| 3343 | else obj[key] = value; |
| 3344 | return obj; |
| 3345 | } |
| 3346 | |
| 3347 | },{}],"5g4pb":[function(require,module,exports) { |
| 3348 | "use strict"; |
| 3349 | Object.defineProperty(exports, "__esModule", { |
| 3350 | value: true |
| 3351 | }); |
| 3352 | exports.default = _get; |
| 3353 | var _superPropBase = _interopRequireDefault(require("./_super_prop_base")); |
| 3354 | function _get(target, property, receiver) { |
| 3355 | return get(target, property, receiver); |
| 3356 | } |
| 3357 | function _interopRequireDefault(obj) { |
| 3358 | return obj && obj.__esModule ? obj : { |
| 3359 | default: obj |
| 3360 | }; |
| 3361 | } |
| 3362 | function get(target1, property1, receiver1) { |
| 3363 | if (typeof Reflect !== "undefined" && Reflect.get) get = Reflect.get; |
| 3364 | else get = function get(target, property, receiver) { |
| 3365 | var base = _superPropBase.default(target, property); |
| 3366 | if (!base) return; |
| 3367 | var desc = Object.getOwnPropertyDescriptor(base, property); |
| 3368 | if (desc.get) return desc.get.call(receiver || target); |
| 3369 | return desc.value; |
| 3370 | }; |
| 3371 | return get(target1, property1, receiver1); |
| 3372 | } |
| 3373 | |
| 3374 | },{"./_super_prop_base":"cT49D"}],"cT49D":[function(require,module,exports) { |
| 3375 | "use strict"; |
| 3376 | Object.defineProperty(exports, "__esModule", { |
| 3377 | value: true |
| 3378 | }); |
| 3379 | exports.default = _superPropBase; |
| 3380 | var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of")); |
| 3381 | function _superPropBase(object, property) { |
| 3382 | while(!Object.prototype.hasOwnProperty.call(object, property)){ |
| 3383 | object = _getPrototypeOf.default(object); |
| 3384 | if (object === null) break; |
| 3385 | } |
| 3386 | return object; |
| 3387 | } |
| 3388 | function _interopRequireDefault(obj) { |
| 3389 | return obj && obj.__esModule ? obj : { |
| 3390 | default: obj |
| 3391 | }; |
| 3392 | } |
| 3393 | |
| 3394 | },{"./_get_prototype_of":"7Gb6H"}],"7Gb6H":[function(require,module,exports) { |
| 3395 | "use strict"; |
| 3396 | Object.defineProperty(exports, "__esModule", { |
| 3397 | value: true |
| 3398 | }); |
| 3399 | exports.default = _getPrototypeOf; |
| 3400 | function _getPrototypeOf(o) { |
| 3401 | return getPrototypeOf(o); |
| 3402 | } |
| 3403 | function getPrototypeOf(o1) { |
| 3404 | getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) { |
| 3405 | return o.__proto__ || Object.getPrototypeOf(o); |
| 3406 | }; |
| 3407 | return getPrototypeOf(o1); |
| 3408 | } |
| 3409 | |
| 3410 | },{}],"atvDk":[function(require,module,exports) { |
| 3411 | "use strict"; |
| 3412 | Object.defineProperty(exports, "__esModule", { |
| 3413 | value: true |
| 3414 | }); |
| 3415 | exports.default = _inherits; |
| 3416 | var _setPrototypeOf = _interopRequireDefault(require("./_set_prototype_of")); |
| 3417 | function _inherits(subClass, superClass) { |
| 3418 | if (typeof superClass !== "function" && superClass !== null) throw new TypeError("Super expression must either be null or a function"); |
| 3419 | subClass.prototype = Object.create(superClass && superClass.prototype, { |
| 3420 | constructor: { |
| 3421 | value: subClass, |
| 3422 | writable: true, |
| 3423 | configurable: true |
| 3424 | } |
| 3425 | }); |
| 3426 | if (superClass) _setPrototypeOf.default(subClass, superClass); |
| 3427 | } |
| 3428 | function _interopRequireDefault(obj) { |
| 3429 | return obj && obj.__esModule ? obj : { |
| 3430 | default: obj |
| 3431 | }; |
| 3432 | } |
| 3433 | |
| 3434 | },{"./_set_prototype_of":"1rATD"}],"1rATD":[function(require,module,exports) { |
| 3435 | "use strict"; |
| 3436 | Object.defineProperty(exports, "__esModule", { |
| 3437 | value: true |
| 3438 | }); |
| 3439 | exports.default = _setPrototypeOf; |
| 3440 | function _setPrototypeOf(o, p) { |
| 3441 | return setPrototypeOf(o, p); |
| 3442 | } |
| 3443 | function setPrototypeOf(o1, p1) { |
| 3444 | setPrototypeOf = Object.setPrototypeOf || function setPrototypeOf(o, p) { |
| 3445 | o.__proto__ = p; |
| 3446 | return o; |
| 3447 | }; |
| 3448 | return setPrototypeOf(o1, p1); |
| 3449 | } |
| 3450 | |
| 3451 | },{}],"4IWLM":[function(require,module,exports) { |
| 3452 | "use strict"; |
| 3453 | Object.defineProperty(exports, "__esModule", { |
| 3454 | value: true |
| 3455 | }); |
| 3456 | exports.default = _slicedToArray; |
| 3457 | var _arrayWithHoles = _interopRequireDefault(require("./_array_with_holes")); |
| 3458 | var _iterableToArray = _interopRequireDefault(require("./_iterable_to_array")); |
| 3459 | var _nonIterableRest = _interopRequireDefault(require("./_non_iterable_rest")); |
| 3460 | var _unsupportedIterableToArray = _interopRequireDefault(require("./_unsupported_iterable_to_array")); |
| 3461 | function _slicedToArray(arr, i) { |
| 3462 | return _arrayWithHoles.default(arr) || _iterableToArray.default(arr, i) || _unsupportedIterableToArray.default(arr, i) || _nonIterableRest.default(); |
| 3463 | } |
| 3464 | function _interopRequireDefault(obj) { |
| 3465 | return obj && obj.__esModule ? obj : { |
| 3466 | default: obj |
| 3467 | }; |
| 3468 | } |
| 3469 | |
| 3470 | },{"./_array_with_holes":"kAkr9","./_iterable_to_array":"d0B07","./_non_iterable_rest":"bXNgi","./_unsupported_iterable_to_array":"jhPJb"}],"kAkr9":[function(require,module,exports) { |
| 3471 | "use strict"; |
| 3472 | Object.defineProperty(exports, "__esModule", { |
| 3473 | value: true |
| 3474 | }); |
| 3475 | exports.default = _arrayWithHoles; |
| 3476 | function _arrayWithHoles(arr) { |
| 3477 | if (Array.isArray(arr)) return arr; |
| 3478 | } |
| 3479 | |
| 3480 | },{}],"d0B07":[function(require,module,exports) { |
| 3481 | "use strict"; |
| 3482 | Object.defineProperty(exports, "__esModule", { |
| 3483 | value: true |
| 3484 | }); |
| 3485 | exports.default = _iterableToArray; |
| 3486 | function _iterableToArray(iter) { |
| 3487 | if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); |
| 3488 | } |
| 3489 | |
| 3490 | },{}],"bXNgi":[function(require,module,exports) { |
| 3491 | "use strict"; |
| 3492 | Object.defineProperty(exports, "__esModule", { |
| 3493 | value: true |
| 3494 | }); |
| 3495 | exports.default = _nonIterableRest; |
| 3496 | function _nonIterableRest() { |
| 3497 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 3498 | } |
| 3499 | |
| 3500 | },{}],"jhPJb":[function(require,module,exports) { |
| 3501 | "use strict"; |
| 3502 | Object.defineProperty(exports, "__esModule", { |
| 3503 | value: true |
| 3504 | }); |
| 3505 | exports.default = _unsupportedIterableToArray; |
| 3506 | var _arrayLikeToArray = _interopRequireDefault(require("./_array_like_to_array")); |
| 3507 | function _unsupportedIterableToArray(o, minLen) { |
| 3508 | if (!o) return; |
| 3509 | if (typeof o === "string") return _arrayLikeToArray.default(o, minLen); |
| 3510 | var n = Object.prototype.toString.call(o).slice(8, -1); |
| 3511 | if (n === "Object" && o.constructor) n = o.constructor.name; |
| 3512 | if (n === "Map" || n === "Set") return Array.from(n); |
| 3513 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray.default(o, minLen); |
| 3514 | } |
| 3515 | function _interopRequireDefault(obj) { |
| 3516 | return obj && obj.__esModule ? obj : { |
| 3517 | default: obj |
| 3518 | }; |
| 3519 | } |
| 3520 | |
| 3521 | },{"./_array_like_to_array":"4K9fh"}],"4K9fh":[function(require,module,exports) { |
| 3522 | "use strict"; |
| 3523 | Object.defineProperty(exports, "__esModule", { |
| 3524 | value: true |
| 3525 | }); |
| 3526 | exports.default = _arrayLikeToArray; |
| 3527 | function _arrayLikeToArray(arr, len) { |
| 3528 | if (len == null || len > arr.length) len = arr.length; |
| 3529 | for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; |
| 3530 | return arr2; |
| 3531 | } |
| 3532 | |
| 3533 | },{}],"cccKv":[function(require,module,exports) { |
| 3534 | "use strict"; |
| 3535 | Object.defineProperty(exports, "__esModule", { |
| 3536 | value: true |
| 3537 | }); |
| 3538 | exports.default = _toConsumableArray; |
| 3539 | var _arrayWithoutHoles = _interopRequireDefault(require("./_array_without_holes")); |
| 3540 | var _iterableToArray = _interopRequireDefault(require("./_iterable_to_array")); |
| 3541 | var _nonIterableSpread = _interopRequireDefault(require("./_non_iterable_spread")); |
| 3542 | var _unsupportedIterableToArray = _interopRequireDefault(require("./_unsupported_iterable_to_array")); |
| 3543 | function _toConsumableArray(arr) { |
| 3544 | return _arrayWithoutHoles.default(arr) || _iterableToArray.default(arr) || _unsupportedIterableToArray.default(arr) || _nonIterableSpread.default(); |
| 3545 | } |
| 3546 | function _interopRequireDefault(obj) { |
| 3547 | return obj && obj.__esModule ? obj : { |
| 3548 | default: obj |
| 3549 | }; |
| 3550 | } |
| 3551 | |
| 3552 | },{"./_array_without_holes":"26osg","./_iterable_to_array":"d0B07","./_non_iterable_spread":"nlNPL","./_unsupported_iterable_to_array":"jhPJb"}],"26osg":[function(require,module,exports) { |
| 3553 | "use strict"; |
| 3554 | Object.defineProperty(exports, "__esModule", { |
| 3555 | value: true |
| 3556 | }); |
| 3557 | exports.default = _arrayWithoutHoles; |
| 3558 | var _arrayLikeToArray = _interopRequireDefault(require("./_array_like_to_array")); |
| 3559 | function _arrayWithoutHoles(arr) { |
| 3560 | if (Array.isArray(arr)) return _arrayLikeToArray.default(arr); |
| 3561 | } |
| 3562 | function _interopRequireDefault(obj) { |
| 3563 | return obj && obj.__esModule ? obj : { |
| 3564 | default: obj |
| 3565 | }; |
| 3566 | } |
| 3567 | |
| 3568 | },{"./_array_like_to_array":"4K9fh"}],"nlNPL":[function(require,module,exports) { |
| 3569 | "use strict"; |
| 3570 | Object.defineProperty(exports, "__esModule", { |
| 3571 | value: true |
| 3572 | }); |
| 3573 | exports.default = _nonIterableSpread; |
| 3574 | function _nonIterableSpread() { |
| 3575 | throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 3576 | } |
| 3577 | |
| 3578 | },{}],"9FF45":[function(require,module,exports) { |
| 3579 | "use strict"; |
| 3580 | Object.defineProperty(exports, "__esModule", { |
| 3581 | value: true |
| 3582 | }); |
| 3583 | exports.default = _typeof; |
| 3584 | function _typeof(obj) { |
| 3585 | "@swc/helpers - typeof"; |
| 3586 | return obj && obj.constructor === Symbol ? "symbol" : typeof obj; |
| 3587 | } |
| 3588 | |
| 3589 | },{}],"5rW3S":[function(require,module,exports) { |
| 3590 | "use strict"; |
| 3591 | Object.defineProperty(exports, "__esModule", { |
| 3592 | value: true |
| 3593 | }); |
| 3594 | exports.default = _createSuper; |
| 3595 | var _isNativeReflectConstruct = _interopRequireDefault(require("./_is_native_reflect_construct")); |
| 3596 | var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of")); |
| 3597 | var _possibleConstructorReturn = _interopRequireDefault(require("./_possible_constructor_return")); |
| 3598 | function _createSuper(Derived) { |
| 3599 | var hasNativeReflectConstruct = _isNativeReflectConstruct.default(); |
| 3600 | return function _createSuperInternal() { |
| 3601 | var Super = _getPrototypeOf.default(Derived), result; |
| 3602 | if (hasNativeReflectConstruct) { |
| 3603 | var NewTarget = _getPrototypeOf.default(this).constructor; |
| 3604 | result = Reflect.construct(Super, arguments, NewTarget); |
| 3605 | } else result = Super.apply(this, arguments); |
| 3606 | return _possibleConstructorReturn.default(this, result); |
| 3607 | }; |
| 3608 | } |
| 3609 | function _interopRequireDefault(obj) { |
| 3610 | return obj && obj.__esModule ? obj : { |
| 3611 | default: obj |
| 3612 | }; |
| 3613 | } |
| 3614 | |
| 3615 | },{"./_is_native_reflect_construct":"aPH71","./_get_prototype_of":"7Gb6H","./_possible_constructor_return":"hAvqf"}],"aPH71":[function(require,module,exports) { |
| 3616 | "use strict"; |
| 3617 | Object.defineProperty(exports, "__esModule", { |
| 3618 | value: true |
| 3619 | }); |
| 3620 | exports.default = _isNativeReflectConstruct; |
| 3621 | function _isNativeReflectConstruct() { |
| 3622 | if (typeof Reflect === "undefined" || !Reflect.construct) return false; |
| 3623 | if (Reflect.construct.sham) return false; |
| 3624 | if (typeof Proxy === "function") return true; |
| 3625 | try { |
| 3626 | Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); |
| 3627 | return true; |
| 3628 | } catch (e) { |
| 3629 | return false; |
| 3630 | } |
| 3631 | } |
| 3632 | |
| 3633 | },{}],"hAvqf":[function(require,module,exports) { |
| 3634 | "use strict"; |
| 3635 | Object.defineProperty(exports, "__esModule", { |
| 3636 | value: true |
| 3637 | }); |
| 3638 | exports.default = _possibleConstructorReturn; |
| 3639 | var _assertThisInitialized = _interopRequireDefault(require("./_assert_this_initialized")); |
| 3640 | var _typeOf = _interopRequireDefault(require("./_type_of")); |
| 3641 | function _possibleConstructorReturn(self, call) { |
| 3642 | if (call && (_typeOf.default(call) === "object" || typeof call === "function")) return call; |
| 3643 | return _assertThisInitialized.default(self); |
| 3644 | } |
| 3645 | function _interopRequireDefault(obj) { |
| 3646 | return obj && obj.__esModule ? obj : { |
| 3647 | default: obj |
| 3648 | }; |
| 3649 | } |
| 3650 | |
| 3651 | },{"./_assert_this_initialized":"l7nF8","./_type_of":"9FF45"}],"l7nF8":[function(require,module,exports) { |
| 3652 | "use strict"; |
| 3653 | Object.defineProperty(exports, "__esModule", { |
| 3654 | value: true |
| 3655 | }); |
| 3656 | exports.default = _assertThisInitialized; |
| 3657 | function _assertThisInitialized(self) { |
| 3658 | if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
| 3659 | return self; |
| 3660 | } |
| 3661 | |
| 3662 | },{}],"7j2bv":[function(require,module,exports) { |
| 3663 | /** |
| 3664 | * Copyright (c) 2014-present, Facebook, Inc. |
| 3665 | * |
| 3666 | * This source code is licensed under the MIT license found in the |
| 3667 | * LICENSE file in the root directory of this source tree. |
| 3668 | */ var runtime = function(exports) { |
| 3669 | "use strict"; |
| 3670 | var define = function define(obj, key, value) { |
| 3671 | Object.defineProperty(obj, key, { |
| 3672 | value: value, |
| 3673 | enumerable: true, |
| 3674 | configurable: true, |
| 3675 | writable: true |
| 3676 | }); |
| 3677 | return obj[key]; |
| 3678 | }; |
| 3679 | var wrap = function wrap(innerFn, outerFn, self, tryLocsList) { |
| 3680 | // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. |
| 3681 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
| 3682 | var generator = Object.create(protoGenerator.prototype); |
| 3683 | var context = new Context(tryLocsList || []); |
| 3684 | // The ._invoke method unifies the implementations of the .next, |
| 3685 | // .throw, and .return methods. |
| 3686 | generator._invoke = makeInvokeMethod(innerFn, self, context); |
| 3687 | return generator; |
| 3688 | }; |
| 3689 | var tryCatch = // Try/catch helper to minimize deoptimizations. Returns a completion |
| 3690 | // record like context.tryEntries[i].completion. This interface could |
| 3691 | // have been (and was previously) designed to take a closure to be |
| 3692 | // invoked without arguments, but in all the cases we care about we |
| 3693 | // already have an existing method we want to call, so there's no need |
| 3694 | // to create a new function object. We can even get away with assuming |
| 3695 | // the method takes exactly one argument, since that happens to be true |
| 3696 | // in every case, so we don't have to touch the arguments object. The |
| 3697 | // only additional allocation required is the completion record, which |
| 3698 | // has a stable shape and so hopefully should be cheap to allocate. |
| 3699 | function tryCatch(fn, obj, arg) { |
| 3700 | try { |
| 3701 | return { |
| 3702 | type: "normal", |
| 3703 | arg: fn.call(obj, arg) |
| 3704 | }; |
| 3705 | } catch (err) { |
| 3706 | return { |
| 3707 | type: "throw", |
| 3708 | arg: err |
| 3709 | }; |
| 3710 | } |
| 3711 | }; |
| 3712 | var Generator = // Dummy constructor functions that we use as the .constructor and |
| 3713 | // .constructor.prototype properties for functions that return Generator |
| 3714 | // objects. For full spec compliance, you may wish to configure your |
| 3715 | // minifier not to mangle the names of these two functions. |
| 3716 | function Generator() {}; |
| 3717 | var GeneratorFunction = function GeneratorFunction() {}; |
| 3718 | var GeneratorFunctionPrototype = function GeneratorFunctionPrototype() {}; |
| 3719 | var defineIteratorMethods = // Helper for defining the .next, .throw, and .return methods of the |
| 3720 | // Iterator interface in terms of a single ._invoke method. |
| 3721 | function defineIteratorMethods(prototype) { |
| 3722 | [ |
| 3723 | "next", |
| 3724 | "throw", |
| 3725 | "return" |
| 3726 | ].forEach(function(method) { |
| 3727 | define(prototype, method, function(arg) { |
| 3728 | return this._invoke(method, arg); |
| 3729 | }); |
| 3730 | }); |
| 3731 | }; |
| 3732 | var AsyncIterator = function AsyncIterator(generator, PromiseImpl) { |
| 3733 | function invoke(method, arg, resolve, reject) { |
| 3734 | var record = tryCatch(generator[method], generator, arg); |
| 3735 | if (record.type === "throw") reject(record.arg); |
| 3736 | else { |
| 3737 | var result = record.arg; |
| 3738 | var value1 = result.value; |
| 3739 | if (value1 && typeof value1 === "object" && hasOwn.call(value1, "__await")) return PromiseImpl.resolve(value1.__await).then(function(value) { |
| 3740 | invoke("next", value, resolve, reject); |
| 3741 | }, function(err) { |
| 3742 | invoke("throw", err, resolve, reject); |
| 3743 | }); |
| 3744 | return PromiseImpl.resolve(value1).then(function(unwrapped) { |
| 3745 | // When a yielded Promise is resolved, its final value becomes |
| 3746 | // the .value of the Promise<{value,done}> result for the |
| 3747 | // current iteration. |
| 3748 | result.value = unwrapped; |
| 3749 | resolve(result); |
| 3750 | }, function(error) { |
| 3751 | // If a rejected Promise was yielded, throw the rejection back |
| 3752 | // into the async generator function so it can be handled there. |
| 3753 | return invoke("throw", error, resolve, reject); |
| 3754 | }); |
| 3755 | } |
| 3756 | } |
| 3757 | var previousPromise; |
| 3758 | function enqueue(method, arg) { |
| 3759 | function callInvokeWithMethodAndArg() { |
| 3760 | return new PromiseImpl(function(resolve, reject) { |
| 3761 | invoke(method, arg, resolve, reject); |
| 3762 | }); |
| 3763 | } |
| 3764 | return previousPromise = // If enqueue has been called before, then we want to wait until |
| 3765 | // all previous Promises have been resolved before calling invoke, |
| 3766 | // so that results are always delivered in the correct order. If |
| 3767 | // enqueue has not been called before, then it is important to |
| 3768 | // call invoke immediately, without waiting on a callback to fire, |
| 3769 | // so that the async generator function has the opportunity to do |
| 3770 | // any necessary setup in a predictable way. This predictability |
| 3771 | // is why the Promise constructor synchronously invokes its |
| 3772 | // executor callback, and why async functions synchronously |
| 3773 | // execute code before the first await. Since we implement simple |
| 3774 | // async functions in terms of async generators, it is especially |
| 3775 | // important to get this right, even though it requires care. |
| 3776 | previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later |
| 3777 | // invocations of the iterator. |
| 3778 | callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); |
| 3779 | } |
| 3780 | // Define the unified helper method that is used to implement .next, |
| 3781 | // .throw, and .return (see defineIteratorMethods). |
| 3782 | this._invoke = enqueue; |
| 3783 | }; |
| 3784 | var makeInvokeMethod = function makeInvokeMethod(innerFn, self, context) { |
| 3785 | var state = GenStateSuspendedStart; |
| 3786 | return function invoke(method, arg) { |
| 3787 | if (state === GenStateExecuting) throw new Error("Generator is already running"); |
| 3788 | if (state === GenStateCompleted) { |
| 3789 | if (method === "throw") throw arg; |
| 3790 | // Be forgiving, per 25.3.3.3.3 of the spec: |
| 3791 | // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
| 3792 | return doneResult(); |
| 3793 | } |
| 3794 | context.method = method; |
| 3795 | context.arg = arg; |
| 3796 | while(true){ |
| 3797 | var delegate = context.delegate; |
| 3798 | if (delegate) { |
| 3799 | var delegateResult = maybeInvokeDelegate(delegate, context); |
| 3800 | if (delegateResult) { |
| 3801 | if (delegateResult === ContinueSentinel) continue; |
| 3802 | return delegateResult; |
| 3803 | } |
| 3804 | } |
| 3805 | if (context.method === "next") // Setting context._sent for legacy support of Babel's |
| 3806 | // function.sent implementation. |
| 3807 | context.sent = context._sent = context.arg; |
| 3808 | else if (context.method === "throw") { |
| 3809 | if (state === GenStateSuspendedStart) { |
| 3810 | state = GenStateCompleted; |
| 3811 | throw context.arg; |
| 3812 | } |
| 3813 | context.dispatchException(context.arg); |
| 3814 | } else if (context.method === "return") context.abrupt("return", context.arg); |
| 3815 | state = GenStateExecuting; |
| 3816 | var record = tryCatch(innerFn, self, context); |
| 3817 | if (record.type === "normal") { |
| 3818 | // If an exception is thrown from innerFn, we leave state === |
| 3819 | // GenStateExecuting and loop back for another invocation. |
| 3820 | state = context.done ? GenStateCompleted : GenStateSuspendedYield; |
| 3821 | if (record.arg === ContinueSentinel) continue; |
| 3822 | return { |
| 3823 | value: record.arg, |
| 3824 | done: context.done |
| 3825 | }; |
| 3826 | } else if (record.type === "throw") { |
| 3827 | state = GenStateCompleted; |
| 3828 | // Dispatch the exception by looping back around to the |
| 3829 | // context.dispatchException(context.arg) call above. |
| 3830 | context.method = "throw"; |
| 3831 | context.arg = record.arg; |
| 3832 | } |
| 3833 | } |
| 3834 | }; |
| 3835 | }; |
| 3836 | var pushTryEntry = function pushTryEntry(locs) { |
| 3837 | var entry = { |
| 3838 | tryLoc: locs[0] |
| 3839 | }; |
| 3840 | if (1 in locs) entry.catchLoc = locs[1]; |
| 3841 | if (2 in locs) { |
| 3842 | entry.finallyLoc = locs[2]; |
| 3843 | entry.afterLoc = locs[3]; |
| 3844 | } |
| 3845 | this.tryEntries.push(entry); |
| 3846 | }; |
| 3847 | var resetTryEntry = function resetTryEntry(entry) { |
| 3848 | var record = entry.completion || {}; |
| 3849 | record.type = "normal"; |
| 3850 | delete record.arg; |
| 3851 | entry.completion = record; |
| 3852 | }; |
| 3853 | var Context = function Context(tryLocsList) { |
| 3854 | // The root entry object (effectively a try statement without a catch |
| 3855 | // or a finally block) gives us a place to store values thrown from |
| 3856 | // locations where there is no enclosing try statement. |
| 3857 | this.tryEntries = [ |
| 3858 | { |
| 3859 | tryLoc: "root" |
| 3860 | } |
| 3861 | ]; |
| 3862 | tryLocsList.forEach(pushTryEntry, this); |
| 3863 | this.reset(true); |
| 3864 | }; |
| 3865 | var values = function values(iterable) { |
| 3866 | if (iterable) { |
| 3867 | var iteratorMethod = iterable[iteratorSymbol]; |
| 3868 | if (iteratorMethod) return iteratorMethod.call(iterable); |
| 3869 | if (typeof iterable.next === "function") return iterable; |
| 3870 | if (!isNaN(iterable.length)) { |
| 3871 | var i = -1, next1 = function next() { |
| 3872 | while(++i < iterable.length)if (hasOwn.call(iterable, i)) { |
| 3873 | next.value = iterable[i]; |
| 3874 | next.done = false; |
| 3875 | return next; |
| 3876 | } |
| 3877 | next.value = undefined; |
| 3878 | next.done = true; |
| 3879 | return next; |
| 3880 | }; |
| 3881 | return next1.next = next1; |
| 3882 | } |
| 3883 | } |
| 3884 | // Return an iterator with no values. |
| 3885 | return { |
| 3886 | next: doneResult |
| 3887 | }; |
| 3888 | }; |
| 3889 | var doneResult = function doneResult() { |
| 3890 | return { |
| 3891 | value: undefined, |
| 3892 | done: true |
| 3893 | }; |
| 3894 | }; |
| 3895 | var Op = Object.prototype; |
| 3896 | var hasOwn = Op.hasOwnProperty; |
| 3897 | var undefined; // More compressible than void 0. |
| 3898 | var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
| 3899 | var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
| 3900 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
| 3901 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
| 3902 | try { |
| 3903 | // IE 8 has a broken Object.defineProperty that only works on DOM objects. |
| 3904 | define({}, ""); |
| 3905 | } catch (err) { |
| 3906 | define = function define(obj, key, value) { |
| 3907 | return obj[key] = value; |
| 3908 | }; |
| 3909 | } |
| 3910 | exports.wrap = wrap; |
| 3911 | var GenStateSuspendedStart = "suspendedStart"; |
| 3912 | var GenStateSuspendedYield = "suspendedYield"; |
| 3913 | var GenStateExecuting = "executing"; |
| 3914 | var GenStateCompleted = "completed"; |
| 3915 | // Returning this object from the innerFn has the same effect as |
| 3916 | // breaking out of the dispatch switch statement. |
| 3917 | var ContinueSentinel = {}; |
| 3918 | // This is a polyfill for %IteratorPrototype% for environments that |
| 3919 | // don't natively support it. |
| 3920 | var IteratorPrototype = {}; |
| 3921 | define(IteratorPrototype, iteratorSymbol, function() { |
| 3922 | return this; |
| 3923 | }); |
| 3924 | var getProto = Object.getPrototypeOf; |
| 3925 | var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
| 3926 | if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) // This environment has a native %IteratorPrototype%; use it instead |
| 3927 | // of the polyfill. |
| 3928 | IteratorPrototype = NativeIteratorPrototype; |
| 3929 | var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); |
| 3930 | GeneratorFunction.prototype = GeneratorFunctionPrototype; |
| 3931 | define(Gp, "constructor", GeneratorFunctionPrototype); |
| 3932 | define(GeneratorFunctionPrototype, "constructor", GeneratorFunction); |
| 3933 | GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); |
| 3934 | exports.isGeneratorFunction = function(genFun) { |
| 3935 | var ctor = typeof genFun === "function" && genFun.constructor; |
| 3936 | return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can |
| 3937 | // do is to check its .name property. |
| 3938 | (ctor.displayName || ctor.name) === "GeneratorFunction" : false; |
| 3939 | }; |
| 3940 | exports.mark = function(genFun) { |
| 3941 | if (Object.setPrototypeOf) Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
| 3942 | else { |
| 3943 | genFun.__proto__ = GeneratorFunctionPrototype; |
| 3944 | define(genFun, toStringTagSymbol, "GeneratorFunction"); |
| 3945 | } |
| 3946 | genFun.prototype = Object.create(Gp); |
| 3947 | return genFun; |
| 3948 | }; |
| 3949 | // Within the body of any async function, `await x` is transformed to |
| 3950 | // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test |
| 3951 | // `hasOwn.call(value, "__await")` to determine if the yielded value is |
| 3952 | // meant to be awaited. |
| 3953 | exports.awrap = function(arg) { |
| 3954 | return { |
| 3955 | __await: arg |
| 3956 | }; |
| 3957 | }; |
| 3958 | defineIteratorMethods(AsyncIterator.prototype); |
| 3959 | define(AsyncIterator.prototype, asyncIteratorSymbol, function() { |
| 3960 | return this; |
| 3961 | }); |
| 3962 | exports.AsyncIterator = AsyncIterator; |
| 3963 | // Note that simple async functions are implemented on top of |
| 3964 | // AsyncIterator objects; they just return a Promise for the value of |
| 3965 | // the final result produced by the iterator. |
| 3966 | exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { |
| 3967 | if (PromiseImpl === void 0) PromiseImpl = Promise; |
| 3968 | var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); |
| 3969 | return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. |
| 3970 | : iter.next().then(function(result) { |
| 3971 | return result.done ? result.value : iter.next(); |
| 3972 | }); |
| 3973 | }; |
| 3974 | // Call delegate.iterator[context.method](context.arg) and handle the |
| 3975 | // result, either by returning a { value, done } result from the |
| 3976 | // delegate iterator, or by modifying context.method and context.arg, |
| 3977 | // setting context.delegate to null, and returning the ContinueSentinel. |
| 3978 | function maybeInvokeDelegate(delegate, context) { |
| 3979 | var method = delegate.iterator[context.method]; |
| 3980 | if (method === undefined) { |
| 3981 | // A .throw or .return when the delegate iterator has no .throw |
| 3982 | // method always terminates the yield* loop. |
| 3983 | context.delegate = null; |
| 3984 | if (context.method === "throw") { |
| 3985 | // Note: ["return"] must be used for ES3 parsing compatibility. |
| 3986 | if (delegate.iterator["return"]) { |
| 3987 | // If the delegate iterator has a return method, give it a |
| 3988 | // chance to clean up. |
| 3989 | context.method = "return"; |
| 3990 | context.arg = undefined; |
| 3991 | maybeInvokeDelegate(delegate, context); |
| 3992 | if (context.method === "throw") // If maybeInvokeDelegate(context) changed context.method from |
| 3993 | // "return" to "throw", let that override the TypeError below. |
| 3994 | return ContinueSentinel; |
| 3995 | } |
| 3996 | context.method = "throw"; |
| 3997 | context.arg = new TypeError("The iterator does not provide a 'throw' method"); |
| 3998 | } |
| 3999 | return ContinueSentinel; |
| 4000 | } |
| 4001 | var record = tryCatch(method, delegate.iterator, context.arg); |
| 4002 | if (record.type === "throw") { |
| 4003 | context.method = "throw"; |
| 4004 | context.arg = record.arg; |
| 4005 | context.delegate = null; |
| 4006 | return ContinueSentinel; |
| 4007 | } |
| 4008 | var info = record.arg; |
| 4009 | if (!info) { |
| 4010 | context.method = "throw"; |
| 4011 | context.arg = new TypeError("iterator result is not an object"); |
| 4012 | context.delegate = null; |
| 4013 | return ContinueSentinel; |
| 4014 | } |
| 4015 | if (info.done) { |
| 4016 | // Assign the result of the finished delegate to the temporary |
| 4017 | // variable specified by delegate.resultName (see delegateYield). |
| 4018 | context[delegate.resultName] = info.value; |
| 4019 | // Resume execution at the desired location (see delegateYield). |
| 4020 | context.next = delegate.nextLoc; |
| 4021 | // If context.method was "throw" but the delegate handled the |
| 4022 | // exception, let the outer generator proceed normally. If |
| 4023 | // context.method was "next", forget context.arg since it has been |
| 4024 | // "consumed" by the delegate iterator. If context.method was |
| 4025 | // "return", allow the original .return call to continue in the |
| 4026 | // outer generator. |
| 4027 | if (context.method !== "return") { |
| 4028 | context.method = "next"; |
| 4029 | context.arg = undefined; |
| 4030 | } |
| 4031 | } else // Re-yield the result returned by the delegate method. |
| 4032 | return info; |
| 4033 | // The delegate iterator is finished, so forget it and continue with |
| 4034 | // the outer generator. |
| 4035 | context.delegate = null; |
| 4036 | return ContinueSentinel; |
| 4037 | } |
| 4038 | // Define Generator.prototype.{next,throw,return} in terms of the |
| 4039 | // unified ._invoke helper method. |
| 4040 | defineIteratorMethods(Gp); |
| 4041 | define(Gp, toStringTagSymbol, "Generator"); |
| 4042 | // A Generator should always return itself as the iterator object when the |
| 4043 | // @@iterator function is called on it. Some browsers' implementations of the |
| 4044 | // iterator prototype chain incorrectly implement this, causing the Generator |
| 4045 | // object to not be returned from this call. This ensures that doesn't happen. |
| 4046 | // See https://github.com/facebook/regenerator/issues/274 for more details. |
| 4047 | define(Gp, iteratorSymbol, function() { |
| 4048 | return this; |
| 4049 | }); |
| 4050 | define(Gp, "toString", function() { |
| 4051 | return "[object Generator]"; |
| 4052 | }); |
| 4053 | exports.keys = function(object) { |
| 4054 | var keys = []; |
| 4055 | for(var key1 in object)keys.push(key1); |
| 4056 | keys.reverse(); |
| 4057 | // Rather than returning an object with a next method, we keep |
| 4058 | // things simple and return the next function itself. |
| 4059 | return function next() { |
| 4060 | while(keys.length){ |
| 4061 | var key = keys.pop(); |
| 4062 | if (key in object) { |
| 4063 | next.value = key; |
| 4064 | next.done = false; |
| 4065 | return next; |
| 4066 | } |
| 4067 | } |
| 4068 | // To avoid creating an additional object, we just hang the .value |
| 4069 | // and .done properties off the next function object itself. This |
| 4070 | // also ensures that the minifier will not anonymize the function. |
| 4071 | next.done = true; |
| 4072 | return next; |
| 4073 | }; |
| 4074 | }; |
| 4075 | exports.values = values; |
| 4076 | Context.prototype = { |
| 4077 | constructor: Context, |
| 4078 | reset: function reset(skipTempReset) { |
| 4079 | this.prev = 0; |
| 4080 | this.next = 0; |
| 4081 | // Resetting context._sent for legacy support of Babel's |
| 4082 | // function.sent implementation. |
| 4083 | this.sent = this._sent = undefined; |
| 4084 | this.done = false; |
| 4085 | this.delegate = null; |
| 4086 | this.method = "next"; |
| 4087 | this.arg = undefined; |
| 4088 | this.tryEntries.forEach(resetTryEntry); |
| 4089 | if (!skipTempReset) { |
| 4090 | for(var name in this)// Not sure about the optimal order of these conditions: |
| 4091 | if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) this[name] = undefined; |
| 4092 | } |
| 4093 | }, |
| 4094 | stop: function stop() { |
| 4095 | this.done = true; |
| 4096 | var rootEntry = this.tryEntries[0]; |
| 4097 | var rootRecord = rootEntry.completion; |
| 4098 | if (rootRecord.type === "throw") throw rootRecord.arg; |
| 4099 | return this.rval; |
| 4100 | }, |
| 4101 | dispatchException: function dispatchException(exception) { |
| 4102 | var handle = function handle(loc, caught) { |
| 4103 | record.type = "throw"; |
| 4104 | record.arg = exception; |
| 4105 | context.next = loc; |
| 4106 | if (caught) { |
| 4107 | // If the dispatched exception was caught by a catch block, |
| 4108 | // then let that catch block handle the exception normally. |
| 4109 | context.method = "next"; |
| 4110 | context.arg = undefined; |
| 4111 | } |
| 4112 | return !!caught; |
| 4113 | }; |
| 4114 | if (this.done) throw exception; |
| 4115 | var context = this; |
| 4116 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4117 | var entry = this.tryEntries[i]; |
| 4118 | var record = entry.completion; |
| 4119 | if (entry.tryLoc === "root") // Exception thrown outside of any try block that could handle |
| 4120 | // it, so set the completion value of the entire function to |
| 4121 | // throw the exception. |
| 4122 | return handle("end"); |
| 4123 | if (entry.tryLoc <= this.prev) { |
| 4124 | var hasCatch = hasOwn.call(entry, "catchLoc"); |
| 4125 | var hasFinally = hasOwn.call(entry, "finallyLoc"); |
| 4126 | if (hasCatch && hasFinally) { |
| 4127 | if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true); |
| 4128 | else if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); |
| 4129 | } else if (hasCatch) { |
| 4130 | if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true); |
| 4131 | } else if (hasFinally) { |
| 4132 | if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); |
| 4133 | } else throw new Error("try statement without catch or finally"); |
| 4134 | } |
| 4135 | } |
| 4136 | }, |
| 4137 | abrupt: function abrupt(type, arg) { |
| 4138 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4139 | var entry = this.tryEntries[i]; |
| 4140 | if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { |
| 4141 | var finallyEntry = entry; |
| 4142 | break; |
| 4143 | } |
| 4144 | } |
| 4145 | if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) // Ignore the finally entry if control is not jumping to a |
| 4146 | // location outside the try/catch block. |
| 4147 | finallyEntry = null; |
| 4148 | var record = finallyEntry ? finallyEntry.completion : {}; |
| 4149 | record.type = type; |
| 4150 | record.arg = arg; |
| 4151 | if (finallyEntry) { |
| 4152 | this.method = "next"; |
| 4153 | this.next = finallyEntry.finallyLoc; |
| 4154 | return ContinueSentinel; |
| 4155 | } |
| 4156 | return this.complete(record); |
| 4157 | }, |
| 4158 | complete: function complete(record, afterLoc) { |
| 4159 | if (record.type === "throw") throw record.arg; |
| 4160 | if (record.type === "break" || record.type === "continue") this.next = record.arg; |
| 4161 | else if (record.type === "return") { |
| 4162 | this.rval = this.arg = record.arg; |
| 4163 | this.method = "return"; |
| 4164 | this.next = "end"; |
| 4165 | } else if (record.type === "normal" && afterLoc) this.next = afterLoc; |
| 4166 | return ContinueSentinel; |
| 4167 | }, |
| 4168 | finish: function finish(finallyLoc) { |
| 4169 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4170 | var entry = this.tryEntries[i]; |
| 4171 | if (entry.finallyLoc === finallyLoc) { |
| 4172 | this.complete(entry.completion, entry.afterLoc); |
| 4173 | resetTryEntry(entry); |
| 4174 | return ContinueSentinel; |
| 4175 | } |
| 4176 | } |
| 4177 | }, |
| 4178 | "catch": function(tryLoc) { |
| 4179 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4180 | var entry = this.tryEntries[i]; |
| 4181 | if (entry.tryLoc === tryLoc) { |
| 4182 | var record = entry.completion; |
| 4183 | if (record.type === "throw") { |
| 4184 | var thrown = record.arg; |
| 4185 | resetTryEntry(entry); |
| 4186 | } |
| 4187 | return thrown; |
| 4188 | } |
| 4189 | } |
| 4190 | // The context.catch method must only be called with a location |
| 4191 | // argument that corresponds to a known catch block. |
| 4192 | throw new Error("illegal catch attempt"); |
| 4193 | }, |
| 4194 | delegateYield: function delegateYield(iterable, resultName, nextLoc) { |
| 4195 | this.delegate = { |
| 4196 | iterator: values(iterable), |
| 4197 | resultName: resultName, |
| 4198 | nextLoc: nextLoc |
| 4199 | }; |
| 4200 | if (this.method === "next") // Deliberately forget the last sent value so that we don't |
| 4201 | // accidentally pass it on to the delegate. |
| 4202 | this.arg = undefined; |
| 4203 | return ContinueSentinel; |
| 4204 | } |
| 4205 | }; |
| 4206 | // Regardless of whether this script is executing as a CommonJS module |
| 4207 | // or not, return the runtime object so that we can declare the variable |
| 4208 | // regeneratorRuntime in the outer scope, which allows this module to be |
| 4209 | // injected easily by `bin/regenerator --include-runtime script.js`. |
| 4210 | return exports; |
| 4211 | }(module.exports); |
| 4212 | try { |
| 4213 | regeneratorRuntime = runtime; |
| 4214 | } catch (accidentalStrictMode) { |
| 4215 | // This module should not be running in strict mode, so the above |
| 4216 | // assignment should always work unless something is misconfigured. Just |
| 4217 | // in case runtime.js accidentally runs in strict mode, in modern engines |
| 4218 | // we can explicitly access globalThis. In older engines we can escape |
| 4219 | // strict mode using a global Function call. This could conceivably fail |
| 4220 | // if a Content Security Policy forbids using Function, but in that case |
| 4221 | // the proper solution is to fix the accidental strict mode problem. If |
| 4222 | // you've misconfigured your bundler to force strict mode and applied a |
| 4223 | // CSP to forbid Function, and you're not willing to fix either of those |
| 4224 | // problems, please detail your unique predicament in a GitHub issue. |
| 4225 | if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime; |
| 4226 | else Function("r", "regeneratorRuntime = r")(runtime); |
| 4227 | } |
| 4228 | |
| 4229 | },{}],"jIm8e":[function(require,module,exports) { |
| 4230 | exports.interopDefault = function(a) { |
| 4231 | return a && a.__esModule ? a : { |
| 4232 | default: a |
| 4233 | }; |
| 4234 | }; |
| 4235 | exports.defineInteropFlag = function(a) { |
| 4236 | Object.defineProperty(a, "__esModule", { |
| 4237 | value: true |
| 4238 | }); |
| 4239 | }; |
| 4240 | exports.exportAll = function(source, dest) { |
| 4241 | Object.keys(source).forEach(function(key) { |
| 4242 | if (key === "default" || key === "__esModule" || dest.hasOwnProperty(key)) return; |
| 4243 | Object.defineProperty(dest, key, { |
| 4244 | enumerable: true, |
| 4245 | get: function get() { |
| 4246 | return source[key]; |
| 4247 | } |
| 4248 | }); |
| 4249 | }); |
| 4250 | return dest; |
| 4251 | }; |
| 4252 | exports.export = function(dest, destName, get) { |
| 4253 | Object.defineProperty(dest, destName, { |
| 4254 | enumerable: true, |
| 4255 | get: get |
| 4256 | }); |
| 4257 | }; |
| 4258 | |
| 4259 | },{}],"ibNcV":[function(require,module,exports) { |
| 4260 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4261 | parcelHelpers.defineInteropFlag(exports); |
| 4262 | parcelHelpers.export(exports, "default", function() { |
| 4263 | return _class; |
| 4264 | }); |
| 4265 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 4266 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 4267 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 4268 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 4269 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 4270 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 4271 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 4272 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 4273 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 4274 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 4275 | var _stimulus = require("@hotwired/stimulus"); |
| 4276 | var _micromodal = require("micromodal"); |
| 4277 | var _micromodalDefault = parcelHelpers.interopDefault(_micromodal); |
| 4278 | document.addEventListener("DOMContentLoaded", function() { |
| 4279 | return (0, _micromodalDefault.default).init(); |
| 4280 | }); |
| 4281 | var _class = /*#__PURE__*/ function(Controller) { |
| 4282 | "use strict"; |
| 4283 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 4284 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 4285 | function _class() { |
| 4286 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 4287 | return _super.apply(this, arguments); |
| 4288 | } |
| 4289 | (0, _createClassJsDefault.default)(_class, [ |
| 4290 | { |
| 4291 | key: "isValidConfirmation", |
| 4292 | value: function isValidConfirmation(confirmationValue) { |
| 4293 | return confirmationValue.toLowerCase() === "delete all data"; |
| 4294 | } |
| 4295 | }, |
| 4296 | { |
| 4297 | key: "confirmationValueChanged", |
| 4298 | value: function confirmationValueChanged(confirmationValue) { |
| 4299 | this.inputTarget.value = confirmationValue; |
| 4300 | var disable = !this.isValidConfirmation(confirmationValue); |
| 4301 | this.submitTarget.toggleAttribute("disabled", disable); |
| 4302 | } |
| 4303 | }, |
| 4304 | { |
| 4305 | key: "updateConfirmation", |
| 4306 | value: function updateConfirmation(e) { |
| 4307 | this.confirmationValue = e.target.value; |
| 4308 | } |
| 4309 | }, |
| 4310 | { |
| 4311 | key: "open", |
| 4312 | value: function open() { |
| 4313 | this.confirmationValue = ""; |
| 4314 | (0, _micromodalDefault.default).show("delete-data-modal"); |
| 4315 | } |
| 4316 | }, |
| 4317 | { |
| 4318 | key: "close", |
| 4319 | value: function close(e) { |
| 4320 | if (e.target !== e.currentTarget) return; |
| 4321 | (0, _micromodalDefault.default).close("delete-data-modal"); |
| 4322 | } |
| 4323 | }, |
| 4324 | { |
| 4325 | key: "submit", |
| 4326 | value: function submit(e) { |
| 4327 | e.preventDefault(); |
| 4328 | if (!this.isValidConfirmation(this.confirmationValue)) return; |
| 4329 | var data = { |
| 4330 | action: "iawp_delete_data", |
| 4331 | delete_data_nonce: IAWP_DELETE_DATA_NONCE, |
| 4332 | confirmation: this.confirmationValue |
| 4333 | }; |
| 4334 | this.submitTarget.setAttribute("disabled", "disabled"); |
| 4335 | this.submitTarget.textContent = "Deleting data..."; |
| 4336 | jQuery.post(ajaxurl, data, function(response) { |
| 4337 | setTimeout(function() { |
| 4338 | document.location.reload(); |
| 4339 | }, 500); |
| 4340 | }); |
| 4341 | } |
| 4342 | } |
| 4343 | ]); |
| 4344 | return _class; |
| 4345 | }((0, _stimulus.Controller)); |
| 4346 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 4347 | confirmation: String |
| 4348 | }); |
| 4349 | (0, _definePropertyJsDefault.default)(_class, "targets", [ |
| 4350 | "submit", |
| 4351 | "input" |
| 4352 | ]); |
| 4353 | |
| 4354 | },{"@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_define_property.js":"6IXzf","@swc/helpers/lib/_inherits.js":"atvDk","@swc/helpers/lib/_create_super.js":"5rW3S","@hotwired/stimulus":"27q4D","micromodal":"dW4sP","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"dW4sP":[function(require,module,exports) { |
| 4355 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4356 | parcelHelpers.defineInteropFlag(exports); |
| 4357 | function e(e1, t1) { |
| 4358 | for(var o1 = 0; o1 < t1.length; o1++){ |
| 4359 | var n1 = t1[o1]; |
| 4360 | n1.enumerable = n1.enumerable || !1, n1.configurable = !0, "value" in n1 && (n1.writable = !0), Object.defineProperty(e1, n1.key, n1); |
| 4361 | } |
| 4362 | } |
| 4363 | function t(e2) { |
| 4364 | return function(e3) { |
| 4365 | if (Array.isArray(e3)) return o(e3); |
| 4366 | }(e2) || function(e4) { |
| 4367 | if ("undefined" != typeof Symbol && Symbol.iterator in Object(e4)) return Array.from(e4); |
| 4368 | }(e2) || function(e5, t2) { |
| 4369 | if (!e5) return; |
| 4370 | if ("string" == typeof e5) return o(e5, t2); |
| 4371 | var n2 = Object.prototype.toString.call(e5).slice(8, -1); |
| 4372 | "Object" === n2 && e5.constructor && (n2 = e5.constructor.name); |
| 4373 | if ("Map" === n2 || "Set" === n2) return Array.from(e5); |
| 4374 | if ("Arguments" === n2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return o(e5, t2); |
| 4375 | }(e2) || function() { |
| 4376 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 4377 | }(); |
| 4378 | } |
| 4379 | function o(e6, t3) { |
| 4380 | (null == t3 || t3 > e6.length) && (t3 = e6.length); |
| 4381 | for(var o2 = 0, n3 = new Array(t3); o2 < t3; o2++)n3[o2] = e6[o2]; |
| 4382 | return n3; |
| 4383 | } |
| 4384 | var n, i, a, r, s1, l = (n = [ |
| 4385 | "a[href]", |
| 4386 | "area[href]", |
| 4387 | 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', |
| 4388 | "select:not([disabled]):not([aria-hidden])", |
| 4389 | "textarea:not([disabled]):not([aria-hidden])", |
| 4390 | "button:not([disabled]):not([aria-hidden])", |
| 4391 | "iframe", |
| 4392 | "object", |
| 4393 | "embed", |
| 4394 | "[contenteditable]", |
| 4395 | '[tabindex]:not([tabindex^="-"])' |
| 4396 | ], i = function() { |
| 4397 | function o3(e7) { |
| 4398 | var n4 = e7.targetModal, i2 = e7.triggers, a2 = void 0 === i2 ? [] : i2, r2 = e7.onShow, s = void 0 === r2 ? function s() {} : r2, l1 = e7.onClose, c = void 0 === l1 ? function c() {} : l1, d = e7.openTrigger, u = void 0 === d ? "data-micromodal-trigger" : d, f = e7.closeTrigger, h = void 0 === f ? "data-micromodal-close" : f, v = e7.openClass, g = void 0 === v ? "is-open" : v, m = e7.disableScroll, b = void 0 !== m && m, y = e7.disableFocus, p = void 0 !== y && y, w = e7.awaitCloseAnimation, E = void 0 !== w && w, k = e7.awaitOpenAnimation, M = void 0 !== k && k, A = e7.debugMode, C = void 0 !== A && A; |
| 4399 | !function(e8, t4) { |
| 4400 | if (!(e8 instanceof t4)) throw new TypeError("Cannot call a class as a function"); |
| 4401 | }(this, o3), this.modal = document.getElementById(n4), this.config = { |
| 4402 | debugMode: C, |
| 4403 | disableScroll: b, |
| 4404 | openTrigger: u, |
| 4405 | closeTrigger: h, |
| 4406 | openClass: g, |
| 4407 | onShow: s, |
| 4408 | onClose: c, |
| 4409 | awaitCloseAnimation: E, |
| 4410 | awaitOpenAnimation: M, |
| 4411 | disableFocus: p |
| 4412 | }, a2.length > 0 && this.registerTriggers.apply(this, t(a2)), this.onClick = this.onClick.bind(this), this.onKeydown = this.onKeydown.bind(this); |
| 4413 | } |
| 4414 | var i1, a1, r1; |
| 4415 | return i1 = o3, a1 = [ |
| 4416 | { |
| 4417 | key: "registerTriggers", |
| 4418 | value: function value() { |
| 4419 | for(var _$e = this, t5 = arguments.length, _$o = new Array(t5), n5 = 0; n5 < t5; n5++)_$o[n5] = arguments[n5]; |
| 4420 | _$o.filter(Boolean).forEach(function(t6) { |
| 4421 | t6.addEventListener("click", function(t7) { |
| 4422 | return _$e.showModal(t7); |
| 4423 | }); |
| 4424 | }); |
| 4425 | } |
| 4426 | }, |
| 4427 | { |
| 4428 | key: "showModal", |
| 4429 | value: function value() { |
| 4430 | var _$e = this, t8 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null; |
| 4431 | if (this.activeElement = document.activeElement, this.modal.setAttribute("aria-hidden", "false"), this.modal.classList.add(this.config.openClass), this.scrollBehaviour("disable"), this.addEventListeners(), this.config.awaitOpenAnimation) { |
| 4432 | var _$o = function t9() { |
| 4433 | _$e.modal.removeEventListener("animationend", t9, !1), _$e.setFocusToFirstNode(); |
| 4434 | }; |
| 4435 | this.modal.addEventListener("animationend", _$o, !1); |
| 4436 | } else this.setFocusToFirstNode(); |
| 4437 | this.config.onShow(this.modal, this.activeElement, t8); |
| 4438 | } |
| 4439 | }, |
| 4440 | { |
| 4441 | key: "closeModal", |
| 4442 | value: function value() { |
| 4443 | var _$e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null, t10 = this.modal; |
| 4444 | if (this.modal.setAttribute("aria-hidden", "true"), this.removeEventListeners(), this.scrollBehaviour("enable"), this.activeElement && this.activeElement.focus && this.activeElement.focus(), this.config.onClose(this.modal, this.activeElement, _$e), this.config.awaitCloseAnimation) { |
| 4445 | var _$o = this.config.openClass; |
| 4446 | this.modal.addEventListener("animationend", function e9() { |
| 4447 | t10.classList.remove(_$o), t10.removeEventListener("animationend", e9, !1); |
| 4448 | }, !1); |
| 4449 | } else t10.classList.remove(this.config.openClass); |
| 4450 | } |
| 4451 | }, |
| 4452 | { |
| 4453 | key: "closeModalById", |
| 4454 | value: function value(e10) { |
| 4455 | this.modal = document.getElementById(e10), this.modal && this.closeModal(); |
| 4456 | } |
| 4457 | }, |
| 4458 | { |
| 4459 | key: "scrollBehaviour", |
| 4460 | value: function value(e11) { |
| 4461 | if (this.config.disableScroll) { |
| 4462 | var t11 = document.querySelector("body"); |
| 4463 | switch(e11){ |
| 4464 | case "enable": |
| 4465 | Object.assign(t11.style, { |
| 4466 | overflow: "" |
| 4467 | }); |
| 4468 | break; |
| 4469 | case "disable": |
| 4470 | Object.assign(t11.style, { |
| 4471 | overflow: "hidden" |
| 4472 | }); |
| 4473 | } |
| 4474 | } |
| 4475 | } |
| 4476 | }, |
| 4477 | { |
| 4478 | key: "addEventListeners", |
| 4479 | value: function value() { |
| 4480 | this.modal.addEventListener("touchstart", this.onClick), this.modal.addEventListener("click", this.onClick), document.addEventListener("keydown", this.onKeydown); |
| 4481 | } |
| 4482 | }, |
| 4483 | { |
| 4484 | key: "removeEventListeners", |
| 4485 | value: function value() { |
| 4486 | this.modal.removeEventListener("touchstart", this.onClick), this.modal.removeEventListener("click", this.onClick), document.removeEventListener("keydown", this.onKeydown); |
| 4487 | } |
| 4488 | }, |
| 4489 | { |
| 4490 | key: "onClick", |
| 4491 | value: function value(e12) { |
| 4492 | (e12.target.hasAttribute(this.config.closeTrigger) || e12.target.parentNode.hasAttribute(this.config.closeTrigger)) && (e12.preventDefault(), e12.stopPropagation(), this.closeModal(e12)); |
| 4493 | } |
| 4494 | }, |
| 4495 | { |
| 4496 | key: "onKeydown", |
| 4497 | value: function value(e13) { |
| 4498 | 27 === e13.keyCode && this.closeModal(e13), 9 === e13.keyCode && this.retainFocus(e13); |
| 4499 | } |
| 4500 | }, |
| 4501 | { |
| 4502 | key: "getFocusableNodes", |
| 4503 | value: function value() { |
| 4504 | var _$e = this.modal.querySelectorAll(n); |
| 4505 | return Array.apply(void 0, t(_$e)); |
| 4506 | } |
| 4507 | }, |
| 4508 | { |
| 4509 | key: "setFocusToFirstNode", |
| 4510 | value: function value() { |
| 4511 | var _$e = this; |
| 4512 | if (!this.config.disableFocus) { |
| 4513 | var t12 = this.getFocusableNodes(); |
| 4514 | if (0 !== t12.length) { |
| 4515 | var _$o = t12.filter(function(t13) { |
| 4516 | return !t13.hasAttribute(_$e.config.closeTrigger); |
| 4517 | }); |
| 4518 | _$o.length > 0 && _$o[0].focus(), 0 === _$o.length && t12[0].focus(); |
| 4519 | } |
| 4520 | } |
| 4521 | } |
| 4522 | }, |
| 4523 | { |
| 4524 | key: "retainFocus", |
| 4525 | value: function value(e14) { |
| 4526 | var t14 = this.getFocusableNodes(); |
| 4527 | if (0 !== t14.length) { |
| 4528 | if (t14 = t14.filter(function(e15) { |
| 4529 | return null !== e15.offsetParent; |
| 4530 | }), this.modal.contains(document.activeElement)) { |
| 4531 | var _$o = t14.indexOf(document.activeElement); |
| 4532 | e14.shiftKey && 0 === _$o && (t14[t14.length - 1].focus(), e14.preventDefault()), !e14.shiftKey && t14.length > 0 && _$o === t14.length - 1 && (t14[0].focus(), e14.preventDefault()); |
| 4533 | } else t14[0].focus(); |
| 4534 | } |
| 4535 | } |
| 4536 | } |
| 4537 | ], e(i1.prototype, a1), r1 && e(i1, r1), o3; |
| 4538 | }(), a = null, r = function r(e16) { |
| 4539 | if (!document.getElementById(e16)) return console.warn("MicroModal: \u2757Seems like you have missed %c'".concat(e16, "'"), "background-color: #f8f9fa;color: #50596c;font-weight: bold;", "ID somewhere in your code. Refer example below to resolve it."), console.warn("%cExample:", "background-color: #f8f9fa;color: #50596c;font-weight: bold;", '<div class="modal" id="'.concat(e16, '"></div>')), !1; |
| 4540 | }, s1 = function s1(e17, t15) { |
| 4541 | if (function(e18) { |
| 4542 | e18.length <= 0 && (console.warn("MicroModal: \u2757Please specify at least one %c'micromodal-trigger'", "background-color: #f8f9fa;color: #50596c;font-weight: bold;", "data attribute."), console.warn("%cExample:", "background-color: #f8f9fa;color: #50596c;font-weight: bold;", '<a href="#" data-micromodal-trigger="my-modal"></a>')); |
| 4543 | }(e17), !t15) return !0; |
| 4544 | for(var o4 in t15)r(o4); |
| 4545 | return !0; |
| 4546 | }, { |
| 4547 | init: function init(e19) { |
| 4548 | var o5 = Object.assign({}, { |
| 4549 | openTrigger: "data-micromodal-trigger" |
| 4550 | }, e19), n6 = t(document.querySelectorAll("[".concat(o5.openTrigger, "]"))), r = function(e20, t16) { |
| 4551 | var o6 = []; |
| 4552 | return e20.forEach(function(e21) { |
| 4553 | var n7 = e21.attributes[t16].value; |
| 4554 | void 0 === o6[n7] && (o6[n7] = []), o6[n7].push(e21); |
| 4555 | }), o6; |
| 4556 | }(n6, o5.openTrigger); |
| 4557 | if (!0 !== o5.debugMode || !1 !== s1(n6, r)) for(var l2 in r){ |
| 4558 | var c = r[l2]; |
| 4559 | o5.targetModal = l2, o5.triggers = t(c), a = new i(o5); |
| 4560 | } |
| 4561 | }, |
| 4562 | show: function show(e22, t17) { |
| 4563 | var o7 = t17 || {}; |
| 4564 | o7.targetModal = e22, !0 === o7.debugMode && !1 === r(e22) || (a && a.removeEventListeners(), (a = new i(o7)).showModal()); |
| 4565 | }, |
| 4566 | close: function close(e23) { |
| 4567 | e23 ? a.closeModalById(e23) : a.closeModal(); |
| 4568 | } |
| 4569 | }); |
| 4570 | "undefined" != typeof window && (window.MicroModal = l); |
| 4571 | exports.default = l; |
| 4572 | |
| 4573 | },{"@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}]},["2CYCe"], "2CYCe", "parcelRequirec571") |
| 4574 | |
| 4575 | //# sourceMappingURL=index.js.map |
| 4576 |