vendor: 1,797 bytes, lines 1-44
1(() => { 2 var __create = Object.create; 3 var __defProp = Object.defineProperty; 4 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 5 var __getOwnPropNames = Object.getOwnPropertyNames; 6 var __getProtoOf = Object.getPrototypeOf; 7 var __hasOwnProp = Object.prototype.hasOwnProperty; 8 var __esm = (fn, res, err) => function __init() { 9 if (err) throw err[0]; 10 try { 11 return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; 12 } catch (e) { 13 throw err = [e], e; 14 } 15 }; 16 var __commonJS = (cb, mod) => function __require() { 17 try { 18 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 19 } catch (e) { 20 throw mod = 0, e; 21 } 22 }; 23 var __export = (target, all) => { 24 for (var name in all) 25 __defProp(target, name, { get: all[name], enumerable: true }); 26 }; 27 var __copyProps = (to, from, except, desc) => { 28 if (from && typeof from === "object" || typeof from === "function") { 29 for (let key of __getOwnPropNames(from)) 30 if (!__hasOwnProp.call(to, key) && key !== except) 31 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 32 } 33 return to; 34 }; 35 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 36 // If the importer is in node compatibility mode or this is not an ESM 37 // file that has been converted to a CommonJS file using a Babel- 38 // compatible transform (i.e. "__esModule" has not been set), then set 39 // "default" to the CommonJS "module.exports" for node compatibility. 40 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 41 mod 42 )); 43 44
vendor: 424 bytes, lines 44-55
44// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/adapters.js 45 var adapters_default; 46 var init_adapters = __esm({ 47 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/adapters.js"() { 48 adapters_default = { 49 logger: typeof console !== "undefined" ? console : void 0, 50 WebSocket: typeof WebSocket !== "undefined" ? WebSocket : void 0 51 }; 52 } 53 }); 54 55
vendor: 486 bytes, lines 55-71
55// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/logger.js 56 var logger_default; 57 var init_logger = __esm({ 58 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/logger.js"() { 59 init_adapters(); 60 logger_default = { 61 log(...messages) { 62 if (this.enabled) { 63 messages.push(Date.now()); 64 adapters_default.logger.log("[ActionCable]", ...messages); 65 } 66 } 67 }; 68 } 69 }); 70 71
vendor: 4,389 bytes, lines 71-181
71// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/connection_monitor.js 72 var now, secondsSince, ConnectionMonitor, connection_monitor_default; 73 var init_connection_monitor = __esm({ 74 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/connection_monitor.js"() { 75 init_logger(); 76 now = () => (/* @__PURE__ */ new Date()).getTime(); 77 secondsSince = (time) => (now() - time) / 1e3; 78 ConnectionMonitor = class { 79 constructor(connection) { 80 this.visibilityDidChange = this.visibilityDidChange.bind(this); 81 this.connection = connection; 82 this.reconnectAttempts = 0; 83 } 84 start() { 85 if (!this.isRunning()) { 86 this.startedAt = now(); 87 delete this.stoppedAt; 88 this.startPolling(); 89 addEventListener("visibilitychange", this.visibilityDidChange); 90 logger_default.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`); 91 } 92 } 93 stop() { 94 if (this.isRunning()) { 95 this.stoppedAt = now(); 96 this.stopPolling(); 97 removeEventListener("visibilitychange", this.visibilityDidChange); 98 logger_default.log("ConnectionMonitor stopped"); 99 } 100 } 101 isRunning() { 102 return this.startedAt && !this.stoppedAt; 103 } 104 recordMessage() { 105 this.pingedAt = now(); 106 } 107 recordConnect() { 108 this.reconnectAttempts = 0; 109 delete this.disconnectedAt; 110 logger_default.log("ConnectionMonitor recorded connect"); 111 } 112 recordDisconnect() { 113 this.disconnectedAt = now(); 114 logger_default.log("ConnectionMonitor recorded disconnect"); 115 } 116 // Private 117 startPolling() { 118 this.stopPolling(); 119 this.poll(); 120 } 121 stopPolling() { 122 clearTimeout(this.pollTimeout); 123 } 124 poll() { 125 this.pollTimeout = setTimeout( 126 () => { 127 this.reconnectIfStale(); 128 this.poll(); 129 }, 130 this.getPollInterval() 131 ); 132 } 133 getPollInterval() { 134 const { staleThreshold, reconnectionBackoffRate } = this.constructor; 135 const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10)); 136 const jitterMax = this.reconnectAttempts === 0 ? 1 : reconnectionBackoffRate; 137 const jitter = jitterMax * Math.random(); 138 return staleThreshold * 1e3 * backoff * (1 + jitter); 139 } 140 reconnectIfStale() { 141 if (this.connectionIsStale()) { 142 logger_default.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`); 143 this.reconnectAttempts++; 144 if (this.disconnectedRecently()) { 145 logger_default.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(this.disconnectedAt)} s`); 146 } else { 147 logger_default.log("ConnectionMonitor reopening"); 148 this.connection.reopen(); 149 } 150 } 151 } 152 get refreshedAt() { 153 return this.pingedAt ? this.pingedAt : this.startedAt; 154 } 155 connectionIsStale() { 156 return secondsSince(this.refreshedAt) > this.constructor.staleThreshold; 157 } 158 disconnectedRecently() { 159 return this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold; 160 } 161 visibilityDidChange() { 162 if (document.visibilityState === "visible") { 163 setTimeout( 164 () => { 165 if (this.connectionIsStale() || !this.connection.isOpen()) { 166 logger_default.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`); 167 this.connection.reopen(); 168 } 169 }, 170 200 171 ); 172 } 173 } 174 }; 175 ConnectionMonitor.staleThreshold = 6; 176 ConnectionMonitor.reconnectionBackoffRate = 0.15; 177 connection_monitor_default = ConnectionMonitor; 178 } 179 }); 180 181
vendor: 863 bytes, lines 181-208
181// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/internal.js 182 var internal_default; 183 var init_internal = __esm({ 184 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/internal.js"() { 185 internal_default = { 186 "message_types": { 187 "welcome": "welcome", 188 "disconnect": "disconnect", 189 "ping": "ping", 190 "confirmation": "confirm_subscription", 191 "rejection": "reject_subscription" 192 }, 193 "disconnect_reasons": { 194 "unauthorized": "unauthorized", 195 "invalid_request": "invalid_request", 196 "server_restart": "server_restart", 197 "remote": "remote" 198 }, 199 "default_mount_path": "/cable", 200 "protocols": [ 201 "actioncable-v1-json", 202 "actioncable-unsupported" 203 ] 204 }; 205 } 206 }); 207 208
vendor: 6,293 bytes, lines 208-377
208// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/connection.js 209 var message_types, protocols, supportedProtocols, indexOf, Connection, connection_default; 210 var init_connection = __esm({ 211 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/connection.js"() { 212 init_adapters(); 213 init_connection_monitor(); 214 init_internal(); 215 init_logger(); 216 ({ message_types, protocols } = internal_default); 217 supportedProtocols = protocols.slice(0, protocols.length - 1); 218 indexOf = [].indexOf; 219 Connection = class { 220 constructor(consumer2) { 221 this.open = this.open.bind(this); 222 this.consumer = consumer2; 223 this.subscriptions = this.consumer.subscriptions; 224 this.monitor = new connection_monitor_default(this); 225 this.disconnected = true; 226 } 227 send(data) { 228 if (this.isOpen()) { 229 this.webSocket.send(JSON.stringify(data)); 230 return true; 231 } else { 232 return false; 233 } 234 } 235 open() { 236 if (this.isActive()) { 237 logger_default.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`); 238 return false; 239 } else { 240 const socketProtocols = [...protocols, ...this.consumer.subprotocols || []]; 241 logger_default.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`); 242 if (this.webSocket) { 243 this.uninstallEventHandlers(); 244 } 245 this.webSocket = new adapters_default.WebSocket(this.consumer.url, socketProtocols); 246 this.installEventHandlers(); 247 this.monitor.start(); 248 return true; 249 } 250 } 251 close({ allowReconnect } = { allowReconnect: true }) { 252 if (!allowReconnect) { 253 this.monitor.stop(); 254 } 255 if (this.isOpen()) { 256 return this.webSocket.close(); 257 } 258 } 259 reopen() { 260 logger_default.log(`Reopening WebSocket, current state is ${this.getState()}`); 261 if (this.isActive()) { 262 try { 263 return this.close(); 264 } catch (error2) { 265 logger_default.log("Failed to reopen WebSocket", error2); 266 } finally { 267 logger_default.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`); 268 setTimeout(this.open, this.constructor.reopenDelay); 269 } 270 } else { 271 return this.open(); 272 } 273 } 274 getProtocol() { 275 if (this.webSocket) { 276 return this.webSocket.protocol; 277 } 278 } 279 isOpen() { 280 return this.isState("open"); 281 } 282 isActive() { 283 return this.isState("open", "connecting"); 284 } 285 triedToReconnect() { 286 return this.monitor.reconnectAttempts > 0; 287 } 288 // Private 289 isProtocolSupported() { 290 return indexOf.call(supportedProtocols, this.getProtocol()) >= 0; 291 } 292 isState(...states) { 293 return indexOf.call(states, this.getState()) >= 0; 294 } 295 getState() { 296 if (this.webSocket) { 297 for (let state in adapters_default.WebSocket) { 298 if (adapters_default.WebSocket[state] === this.webSocket.readyState) { 299 return state.toLowerCase(); 300 } 301 } 302 } 303 return null; 304 } 305 installEventHandlers() { 306 for (let eventName in this.events) { 307 const handler = this.events[eventName].bind(this); 308 this.webSocket[`on${eventName}`] = handler; 309 } 310 } 311 uninstallEventHandlers() { 312 for (let eventName in this.events) { 313 this.webSocket[`on${eventName}`] = function() { 314 }; 315 } 316 } 317 }; 318 Connection.reopenDelay = 500; 319 Connection.prototype.events = { 320 message(event) { 321 if (!this.isProtocolSupported()) { 322 return; 323 } 324 const { identifier, message, reason, reconnect, type } = JSON.parse(event.data); 325 this.monitor.recordMessage(); 326 switch (type) { 327 case message_types.welcome: 328 if (this.triedToReconnect()) { 329 this.reconnectAttempted = true; 330 } 331 this.monitor.recordConnect(); 332 return this.subscriptions.reload(); 333 case message_types.disconnect: 334 logger_default.log(`Disconnecting. Reason: ${reason}`); 335 return this.close({ allowReconnect: reconnect }); 336 case message_types.ping: 337 return null; 338 case message_types.confirmation: 339 this.subscriptions.confirmSubscription(identifier); 340 if (this.reconnectAttempted) { 341 this.reconnectAttempted = false; 342 return this.subscriptions.notify(identifier, "connected", { reconnected: true }); 343 } else { 344 return this.subscriptions.notify(identifier, "connected", { reconnected: false }); 345 } 346 case message_types.rejection: 347 return this.subscriptions.reject(identifier); 348 default: 349 return this.subscriptions.notify(identifier, "received", message); 350 } 351 }, 352 open() { 353 logger_default.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`); 354 this.disconnected = false; 355 if (!this.isProtocolSupported()) { 356 logger_default.log("Protocol is unsupported. Stopping monitor and disconnecting."); 357 return this.close({ allowReconnect: false }); 358 } 359 }, 360 close(event) { 361 logger_default.log("WebSocket onclose event"); 362 if (this.disconnected) { 363 return; 364 } 365 this.disconnected = true; 366 this.monitor.recordDisconnect(); 367 return this.subscriptions.notifyAll("disconnected", { willAttemptReconnect: this.monitor.isRunning() }); 368 }, 369 error() { 370 logger_default.log("WebSocket onerror event"); 371 } 372 }; 373 connection_default = Connection; 374 } 375 }); 376 377
vendor: 1,172 bytes, lines 377-411
377// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/subscription.js 378 var extend, Subscription; 379 var init_subscription = __esm({ 380 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/subscription.js"() { 381 extend = function(object, properties) { 382 if (properties != null) { 383 for (let key in properties) { 384 const value = properties[key]; 385 object[key] = value; 386 } 387 } 388 return object; 389 }; 390 Subscription = class { 391 constructor(consumer2, params = {}, mixin) { 392 this.consumer = consumer2; 393 this.identifier = JSON.stringify(params); 394 extend(this, mixin); 395 } 396 // Perform a channel action with the optional data passed as an attribute 397 perform(action, data = {}) { 398 data.action = action; 399 return this.send(data); 400 } 401 send(data) { 402 return this.consumer.send({ command: "message", identifier: this.identifier, data: JSON.stringify(data) }); 403 } 404 unsubscribe() { 405 return this.consumer.subscriptions.remove(this); 406 } 407 }; 408 } 409 }); 410 411
vendor: 1,966 bytes, lines 411-459
411// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/subscription_guarantor.js 412 var SubscriptionGuarantor, subscription_guarantor_default; 413 var init_subscription_guarantor = __esm({ 414 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/subscription_guarantor.js"() { 415 init_logger(); 416 SubscriptionGuarantor = class { 417 constructor(subscriptions) { 418 this.subscriptions = subscriptions; 419 this.pendingSubscriptions = []; 420 } 421 guarantee(subscription) { 422 if (this.pendingSubscriptions.indexOf(subscription) == -1) { 423 logger_default.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`); 424 this.pendingSubscriptions.push(subscription); 425 } else { 426 logger_default.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`); 427 } 428 this.startGuaranteeing(); 429 } 430 forget(subscription) { 431 logger_default.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`); 432 this.pendingSubscriptions = this.pendingSubscriptions.filter((s) => s !== subscription); 433 } 434 startGuaranteeing() { 435 this.stopGuaranteeing(); 436 this.retrySubscribing(); 437 } 438 stopGuaranteeing() { 439 clearTimeout(this.retryTimeout); 440 } 441 retrySubscribing() { 442 this.retryTimeout = setTimeout( 443 () => { 444 if (this.subscriptions && typeof this.subscriptions.subscribe === "function") { 445 this.pendingSubscriptions.map((subscription) => { 446 logger_default.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`); 447 this.subscriptions.subscribe(subscription); 448 }); 449 } 450 }, 451 500 452 ); 453 } 454 }; 455 subscription_guarantor_default = SubscriptionGuarantor; 456 } 457 }); 458 459
vendor: 3,198 bytes, lines 459-540
459// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/subscriptions.js 460 var Subscriptions; 461 var init_subscriptions = __esm({ 462 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/subscriptions.js"() { 463 init_subscription(); 464 init_subscription_guarantor(); 465 init_logger(); 466 Subscriptions = class { 467 constructor(consumer2) { 468 this.consumer = consumer2; 469 this.guarantor = new subscription_guarantor_default(this); 470 this.subscriptions = []; 471 } 472 create(channelName, mixin) { 473 const channel = channelName; 474 const params = typeof channel === "object" ? channel : { channel }; 475 const subscription = new Subscription(this.consumer, params, mixin); 476 return this.add(subscription); 477 } 478 // Private 479 add(subscription) { 480 this.subscriptions.push(subscription); 481 this.consumer.ensureActiveConnection(); 482 this.notify(subscription, "initialized"); 483 this.subscribe(subscription); 484 return subscription; 485 } 486 remove(subscription) { 487 this.forget(subscription); 488 if (!this.findAll(subscription.identifier).length) { 489 this.sendCommand(subscription, "unsubscribe"); 490 } 491 return subscription; 492 } 493 reject(identifier) { 494 return this.findAll(identifier).map((subscription) => { 495 this.forget(subscription); 496 this.notify(subscription, "rejected"); 497 return subscription; 498 }); 499 } 500 forget(subscription) { 501 this.guarantor.forget(subscription); 502 this.subscriptions = this.subscriptions.filter((s) => s !== subscription); 503 return subscription; 504 } 505 findAll(identifier) { 506 return this.subscriptions.filter((s) => s.identifier === identifier); 507 } 508 reload() { 509 return this.subscriptions.map((subscription) => this.subscribe(subscription)); 510 } 511 notifyAll(callbackName, ...args) { 512 return this.subscriptions.map((subscription) => this.notify(subscription, callbackName, ...args)); 513 } 514 notify(subscription, callbackName, ...args) { 515 let subscriptions; 516 if (typeof subscription === "string") { 517 subscriptions = this.findAll(subscription); 518 } else { 519 subscriptions = [subscription]; 520 } 521 return subscriptions.map((subscription2) => typeof subscription2[callbackName] === "function" ? subscription2[callbackName](...args) : void 0); 522 } 523 subscribe(subscription) { 524 if (this.sendCommand(subscription, "subscribe")) { 525 this.guarantor.guarantee(subscription); 526 } 527 } 528 confirmSubscription(identifier) { 529 logger_default.log(`Subscription confirmed ${identifier}`); 530 this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription)); 531 } 532 sendCommand(subscription, command) { 533 const { identifier } = subscription; 534 return this.consumer.send({ command, identifier }); 535 } 536 }; 537 } 538 }); 539 540
vendor: 1,465 bytes, lines 540-591
540// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/consumer.js 541 function createWebSocketURL(url) { 542 if (typeof url === "function") { 543 url = url(); 544 } 545 if (url && !/^wss?:/i.test(url)) { 546 const a = document.createElement("a"); 547 a.href = url; 548 a.href = a.href; 549 a.protocol = a.protocol.replace("http", "ws"); 550 return a.href; 551 } else { 552 return url; 553 } 554 } 555 var Consumer; 556 var init_consumer = __esm({ 557 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/consumer.js"() { 558 init_connection(); 559 init_subscriptions(); 560 Consumer = class { 561 constructor(url) { 562 this._url = url; 563 this.subscriptions = new Subscriptions(this); 564 this.connection = new connection_default(this); 565 this.subprotocols = []; 566 } 567 get url() { 568 return createWebSocketURL(this._url); 569 } 570 send(data) { 571 return this.connection.send(data); 572 } 573 connect() { 574 return this.connection.open(); 575 } 576 disconnect() { 577 return this.connection.close({ allowReconnect: false }); 578 } 579 ensureActiveConnection() { 580 if (!this.connection.isActive()) { 581 return this.connection.open(); 582 } 583 } 584 addSubProtocol(subprotocol) { 585 this.subprotocols = [...this.subprotocols, subprotocol]; 586 } 587 }; 588 } 589 }); 590 591
vendor: 1,329 bytes, lines 591-630
591// node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/index.js 592 var src_exports = {}; 593 __export(src_exports, { 594 Connection: () => connection_default, 595 ConnectionMonitor: () => connection_monitor_default, 596 Consumer: () => Consumer, 597 INTERNAL: () => internal_default, 598 Subscription: () => Subscription, 599 SubscriptionGuarantor: () => subscription_guarantor_default, 600 Subscriptions: () => Subscriptions, 601 adapters: () => adapters_default, 602 createConsumer: () => createConsumer, 603 createWebSocketURL: () => createWebSocketURL, 604 getConfig: () => getConfig, 605 logger: () => logger_default 606 }); 607 function createConsumer(url = getConfig("url") || internal_default.default_mount_path) { 608 return new Consumer(url); 609 } 610 function getConfig(name) { 611 const element = document.head.querySelector(`meta[name='action-cable-${name}']`); 612 if (element) { 613 return element.getAttribute("content"); 614 } 615 } 616 var init_src = __esm({ 617 "node_modules/@hotwired/turbo-rails/node_modules/@rails/actioncable/src/index.js"() { 618 init_connection(); 619 init_connection_monitor(); 620 init_consumer(); 621 init_internal(); 622 init_subscription(); 623 init_subscriptions(); 624 init_subscription_guarantor(); 625 init_adapters(); 626 init_logger(); 627 } 628 }); 629 630
vendor: 257,840 bytes, lines 630-6980
630// node_modules/jquery/dist/jquery.js 631 var require_jquery = __commonJS({ 632 "node_modules/jquery/dist/jquery.js"(exports, module) { 633 (function(global2, factory) { 634 "use strict"; 635 if (typeof module === "object" && typeof module.exports === "object") { 636 module.exports = global2.document ? factory(global2, true) : function(w) { 637 if (!w.document) { 638 throw new Error("jQuery requires a window with a document"); 639 } 640 return factory(w); 641 }; 642 } else { 643 factory(global2); 644 } 645 })(typeof window !== "undefined" ? window : exports, function(window2, noGlobal) { 646 "use strict"; 647 var arr = []; 648 var getProto = Object.getPrototypeOf; 649 var slice = arr.slice; 650 var flat = arr.flat ? function(array) { 651 return arr.flat.call(array); 652 } : function(array) { 653 return arr.concat.apply([], array); 654 }; 655 var push = arr.push; 656 var indexOf2 = arr.indexOf; 657 var class2type = {}; 658 var toString = class2type.toString; 659 var hasOwn = class2type.hasOwnProperty; 660 var fnToString = hasOwn.toString; 661 var ObjectFunctionString = fnToString.call(Object); 662 var support = {}; 663 var isFunction = function isFunction2(obj) { 664 return typeof obj === "function" && typeof obj.nodeType !== "number" && typeof obj.item !== "function"; 665 }; 666 var isWindow = function isWindow2(obj) { 667 return obj != null && obj === obj.window; 668 }; 669 var document2 = window2.document; 670 var preservedScriptAttributes = { 671 type: true, 672 src: true, 673 nonce: true, 674 noModule: true 675 }; 676 function DOMEval(code, node, doc) { 677 doc = doc || document2; 678 var i, val, script = doc.createElement("script"); 679 script.text = code; 680 if (node) { 681 for (i in preservedScriptAttributes) { 682 val = node[i] || node.getAttribute && node.getAttribute(i); 683 if (val) { 684 script.setAttribute(i, val); 685 } 686 } 687 } 688 doc.head.appendChild(script).parentNode.removeChild(script); 689 } 690 function toType(obj) { 691 if (obj == null) { 692 return obj + ""; 693 } 694 return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj; 695 } 696 var version = "3.7.1", rhtmlSuffix = /HTML$/i, jQuery2 = function(selector, context) { 697 return new jQuery2.fn.init(selector, context); 698 }; 699 jQuery2.fn = jQuery2.prototype = { 700 // The current version of jQuery being used 701 jquery: version, 702 constructor: jQuery2, 703 // The default length of a jQuery object is 0 704 length: 0, 705 toArray: function() { 706 return slice.call(this); 707 }, 708 // Get the Nth element in the matched element set OR 709 // Get the whole matched element set as a clean array 710 get: function(num) { 711 if (num == null) { 712 return slice.call(this); 713 } 714 return num < 0 ? this[num + this.length] : this[num]; 715 }, 716 // Take an array of elements and push it onto the stack 717 // (returning the new matched element set) 718 pushStack: function(elems) { 719 var ret = jQuery2.merge(this.constructor(), elems); 720 ret.prevObject = this; 721 return ret; 722 }, 723 // Execute a callback for every element in the matched set. 724 each: function(callback) { 725 return jQuery2.each(this, callback); 726 }, 727 map: function(callback) { 728 return this.pushStack(jQuery2.map(this, function(elem, i) { 729 return callback.call(elem, i, elem); 730 })); 731 }, 732 slice: function() { 733 return this.pushStack(slice.apply(this, arguments)); 734 }, 735 first: function() { 736 return this.eq(0); 737 }, 738 last: function() { 739 return this.eq(-1); 740 }, 741 even: function() { 742 return this.pushStack(jQuery2.grep(this, function(_elem, i) { 743 return (i + 1) % 2; 744 })); 745 }, 746 odd: function() { 747 return this.pushStack(jQuery2.grep(this, function(_elem, i) { 748 return i % 2; 749 })); 750 }, 751 eq: function(i) { 752 var len = this.length, j = +i + (i < 0 ? len : 0); 753 return this.pushStack(j >= 0 && j < len ? [this[j]] : []); 754 }, 755 end: function() { 756 return this.prevObject || this.constructor(); 757 }, 758 // For internal use only. 759 // Behaves like an Array's method, not like a jQuery method. 760 push, 761 sort: arr.sort, 762 splice: arr.splice 763 }; 764 jQuery2.extend = jQuery2.fn.extend = function() { 765 var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; 766 if (typeof target === "boolean") { 767 deep = target; 768 target = arguments[i] || {}; 769 i++; 770 } 771 if (typeof target !== "object" && !isFunction(target)) { 772 target = {}; 773 } 774 if (i === length) { 775 target = this; 776 i--; 777 } 778 for (; i < length; i++) { 779 if ((options = arguments[i]) != null) { 780 for (name in options) { 781 copy = options[name]; 782 if (name === "__proto__" || target === copy) { 783 continue; 784 } 785 if (deep && copy && (jQuery2.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) { 786 src = target[name]; 787 if (copyIsArray && !Array.isArray(src)) { 788 clone = []; 789 } else if (!copyIsArray && !jQuery2.isPlainObject(src)) { 790 clone = {}; 791 } else { 792 clone = src; 793 } 794 copyIsArray = false; 795 target[name] = jQuery2.extend(deep, clone, copy); 796 } else if (copy !== void 0) { 797 target[name] = copy; 798 } 799 } 800 } 801 } 802 return target; 803 }; 804 jQuery2.extend({ 805 // Unique for each copy of jQuery on the page 806 expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""), 807 // Assume jQuery is ready without the ready module 808 isReady: true, 809 error: function(msg) { 810 throw new Error(msg); 811 }, 812 noop: function() { 813 }, 814 isPlainObject: function(obj) { 815 var proto, Ctor; 816 if (!obj || toString.call(obj) !== "[object Object]") { 817 return false; 818 } 819 proto = getProto(obj); 820 if (!proto) { 821 return true; 822 } 823 Ctor = hasOwn.call(proto, "constructor") && proto.constructor; 824 return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString; 825 }, 826 isEmptyObject: function(obj) { 827 var name; 828 for (name in obj) { 829 return false; 830 } 831 return true; 832 }, 833 // Evaluates a script in a provided context; falls back to the global one 834 // if not specified. 835 globalEval: function(code, options, doc) { 836 DOMEval(code, { nonce: options && options.nonce }, doc); 837 }, 838 each: function(obj, callback) { 839 var length, i = 0; 840 if (isArrayLike(obj)) { 841 length = obj.length; 842 for (; i < length; i++) { 843 if (callback.call(obj[i], i, obj[i]) === false) { 844 break; 845 } 846 } 847 } else { 848 for (i in obj) { 849 if (callback.call(obj[i], i, obj[i]) === false) { 850 break; 851 } 852 } 853 } 854 return obj; 855 }, 856 // Retrieve the text value of an array of DOM nodes 857 text: function(elem) { 858 var node, ret = "", i = 0, nodeType = elem.nodeType; 859 if (!nodeType) { 860 while (node = elem[i++]) { 861 ret += jQuery2.text(node); 862 } 863 } 864 if (nodeType === 1 || nodeType === 11) { 865 return elem.textContent; 866 } 867 if (nodeType === 9) { 868 return elem.documentElement.textContent; 869 } 870 if (nodeType === 3 || nodeType === 4) { 871 return elem.nodeValue; 872 } 873 return ret; 874 }, 875 // results is for internal usage only 876 makeArray: function(arr2, results) { 877 var ret = results || []; 878 if (arr2 != null) { 879 if (isArrayLike(Object(arr2))) { 880 jQuery2.merge( 881 ret, 882 typeof arr2 === "string" ? [arr2] : arr2 883 ); 884 } else { 885 push.call(ret, arr2); 886 } 887 } 888 return ret; 889 }, 890 inArray: function(elem, arr2, i) { 891 return arr2 == null ? -1 : indexOf2.call(arr2, elem, i); 892 }, 893 isXMLDoc: function(elem) { 894 var namespace = elem && elem.namespaceURI, docElem = elem && (elem.ownerDocument || elem).documentElement; 895 return !rhtmlSuffix.test(namespace || docElem && docElem.nodeName || "HTML"); 896 }, 897 // Support: Android <=4.0 only, PhantomJS 1 only 898 // push.apply(_, arraylike) throws on ancient WebKit 899 merge: function(first, second) { 900 var len = +second.length, j = 0, i = first.length; 901 for (; j < len; j++) { 902 first[i++] = second[j]; 903 } 904 first.length = i; 905 return first; 906 }, 907 grep: function(elems, callback, invert) { 908 var callbackInverse, matches2 = [], i = 0, length = elems.length, callbackExpect = !invert; 909 for (; i < length; i++) { 910 callbackInverse = !callback(elems[i], i); 911 if (callbackInverse !== callbackExpect) { 912 matches2.push(elems[i]); 913 } 914 } 915 return matches2; 916 }, 917 // arg is for internal usage only 918 map: function(elems, callback, arg) { 919 var length, value, i = 0, ret = []; 920 if (isArrayLike(elems)) { 921 length = elems.length; 922 for (; i < length; i++) { 923 value = callback(elems[i], i, arg); 924 if (value != null) { 925 ret.push(value); 926 } 927 } 928 } else { 929 for (i in elems) { 930 value = callback(elems[i], i, arg); 931 if (value != null) { 932 ret.push(value); 933 } 934 } 935 } 936 return flat(ret); 937 }, 938 // A global GUID counter for objects 939 guid: 1, 940 // jQuery.support is not used in Core but other projects attach their 941 // properties to it so it needs to exist. 942 support 943 }); 944 if (typeof Symbol === "function") { 945 jQuery2.fn[Symbol.iterator] = arr[Symbol.iterator]; 946 } 947 jQuery2.each( 948 "Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "), 949 function(_i, name) { 950 class2type["[object " + name + "]"] = name.toLowerCase(); 951 } 952 ); 953 function isArrayLike(obj) { 954 var length = !!obj && "length" in obj && obj.length, type = toType(obj); 955 if (isFunction(obj) || isWindow(obj)) { 956 return false; 957 } 958 return type === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj; 959 } 960 function nodeName(elem, name) { 961 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 962 } 963 var pop = arr.pop; 964 var sort = arr.sort; 965 var splice = arr.splice; 966 var whitespace = "[\\x20\\t\\r\\n\\f]"; 967 var rtrimCSS = new RegExp( 968 "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", 969 "g" 970 ); 971 jQuery2.contains = function(a, b) { 972 var bup = b && b.parentNode; 973 return a === bup || !!(bup && bup.nodeType === 1 && // Support: IE 9 - 11+ 974 // IE doesn't have `contains` on SVG. 975 (a.contains ? a.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16)); 976 }; 977 var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g; 978 function fcssescape(ch, asCodePoint) { 979 if (asCodePoint) { 980 if (ch === "\0") { 981 return "\uFFFD"; 982 } 983 return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + " "; 984 } 985 return "\\" + ch; 986 } 987 jQuery2.escapeSelector = function(sel) { 988 return (sel + "").replace(rcssescape, fcssescape); 989 }; 990 var preferredDoc = document2, pushNative = push; 991 (function() { 992 var i, Expr, outermostContext, sortInput, hasDuplicate, push2 = pushNative, document3, documentElement2, documentIsHTML, rbuggyQSA, matches2, expando = jQuery2.expando, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), nonnativeSelectorCache = createCache(), sortOrder = function(a, b) { 993 if (a === b) { 994 hasDuplicate = true; 995 } 996 return 0; 997 }, booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + // Operator (capture 2) 998 "*([*^$|!~]?=)" + whitespace + // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" 999 `*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(` + identifier + "))|)" + whitespace + "*\\]", pseudos = ":(" + identifier + `)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|` + attributes + ")*)|.*)\\)|)", rwhitespace = new RegExp(whitespace + "+", "g"), rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*"), rleadingCombinator = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"), rdescend = new RegExp(whitespace + "|>"), rpseudo = new RegExp(pseudos), ridentifier = new RegExp("^" + identifier + "$"), matchExpr = { 1000 ID: new RegExp("^#(" + identifier + ")"), 1001 CLASS: new RegExp("^\\.(" + identifier + ")"), 1002 TAG: new RegExp("^(" + identifier + "|[*])"), 1003 ATTR: new RegExp("^" + attributes), 1004 PSEUDO: new RegExp("^" + pseudos), 1005 CHILD: new RegExp( 1006 "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", 1007 "i" 1008 ), 1009 bool: new RegExp("^(?:" + booleans + ")$", "i"), 1010 // For use in libraries implementing .is() 1011 // We use this for POS matching in `select` 1012 needsContext: new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i") 1013 }, rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, rquickExpr2 = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, rsibling = /[+~]/, runescape = new RegExp("\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g"), funescape = function(escape, nonHex) { 1014 var high = "0x" + escape.slice(1) - 65536; 1015 if (nonHex) { 1016 return nonHex; 1017 } 1018 return high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320); 1019 }, unloadHandler = function() { 1020 setDocument(); 1021 }, inDisabledFieldset = addCombinator( 1022 function(elem) { 1023 return elem.disabled === true && nodeName(elem, "fieldset"); 1024 }, 1025 { dir: "parentNode", next: "legend" } 1026 ); 1027 function safeActiveElement() { 1028 try { 1029 return document3.activeElement; 1030 } catch (err) { 1031 } 1032 } 1033 try { 1034 push2.apply( 1035 arr = slice.call(preferredDoc.childNodes), 1036 preferredDoc.childNodes 1037 ); 1038 arr[preferredDoc.childNodes.length].nodeType; 1039 } catch (e) { 1040 push2 = { 1041 apply: function(target, els) { 1042 pushNative.apply(target, slice.call(els)); 1043 }, 1044 call: function(target) { 1045 pushNative.apply(target, slice.call(arguments, 1)); 1046 } 1047 }; 1048 } 1049 function find(selector, context, results, seed) { 1050 var m2, i2, elem, nid, match, groups, newSelector, newContext = context && context.ownerDocument, nodeType = context ? context.nodeType : 9; 1051 results = results || []; 1052 if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) { 1053 return results; 1054 } 1055 if (!seed) { 1056 setDocument(context); 1057 context = context || document3; 1058 if (documentIsHTML) { 1059 if (nodeType !== 11 && (match = rquickExpr2.exec(selector))) { 1060 if (m2 = match[1]) { 1061 if (nodeType === 9) { 1062 if (elem = context.getElementById(m2)) { 1063 if (elem.id === m2) { 1064 push2.call(results, elem); 1065 return results; 1066 } 1067 } else { 1068 return results; 1069 } 1070 } else { 1071 if (newContext && (elem = newContext.getElementById(m2)) && find.contains(context, elem) && elem.id === m2) { 1072 push2.call(results, elem); 1073 return results; 1074 } 1075 } 1076 } else if (match[2]) { 1077 push2.apply(results, context.getElementsByTagName(selector)); 1078 return results; 1079 } else if ((m2 = match[3]) && context.getElementsByClassName) { 1080 push2.apply(results, context.getElementsByClassName(m2)); 1081 return results; 1082 } 1083 } 1084 if (!nonnativeSelectorCache[selector + " "] && (!rbuggyQSA || !rbuggyQSA.test(selector))) { 1085 newSelector = selector; 1086 newContext = context; 1087 if (nodeType === 1 && (rdescend.test(selector) || rleadingCombinator.test(selector))) { 1088 newContext = rsibling.test(selector) && testContext(context.parentNode) || context; 1089 if (newContext != context || !support.scope) { 1090 if (nid = context.getAttribute("id")) { 1091 nid = jQuery2.escapeSelector(nid); 1092 } else { 1093 context.setAttribute("id", nid = expando); 1094 } 1095 } 1096 groups = tokenize2(selector); 1097 i2 = groups.length; 1098 while (i2--) { 1099 groups[i2] = (nid ? "#" + nid : ":scope") + " " + toSelector(groups[i2]); 1100 } 1101 newSelector = groups.join(","); 1102 } 1103 try { 1104 push2.apply( 1105 results, 1106 newContext.querySelectorAll(newSelector) 1107 ); 1108 return results; 1109 } catch (qsaError) { 1110 nonnativeSelectorCache(selector, true); 1111 } finally { 1112 if (nid === expando) { 1113 context.removeAttribute("id"); 1114 } 1115 } 1116 } 1117 } 1118 } 1119 return select(selector.replace(rtrimCSS, "$1"), context, results, seed); 1120 } 1121 function createCache() { 1122 var keys = []; 1123 function cache2(key, value) { 1124 if (keys.push(key + " ") > Expr.cacheLength) { 1125 delete cache2[keys.shift()]; 1126 } 1127 return cache2[key + " "] = value; 1128 } 1129 return cache2; 1130 } 1131 function markFunction(fn) { 1132 fn[expando] = true; 1133 return fn; 1134 } 1135 function assert(fn) { 1136 var el = document3.createElement("fieldset"); 1137 try { 1138 return !!fn(el); 1139 } catch (e) { 1140 return false; 1141 } finally { 1142 if (el.parentNode) { 1143 el.parentNode.removeChild(el); 1144 } 1145 el = null; 1146 } 1147 } 1148 function createInputPseudo(type) { 1149 return function(elem) { 1150 return nodeName(elem, "input") && elem.type === type; 1151 }; 1152 } 1153 function createButtonPseudo(type) { 1154 return function(elem) { 1155 return (nodeName(elem, "input") || nodeName(elem, "button")) && elem.type === type; 1156 }; 1157 } 1158 function createDisabledPseudo(disabled) { 1159 return function(elem) { 1160 if ("form" in elem) { 1161 if (elem.parentNode && elem.disabled === false) { 1162 if ("label" in elem) { 1163 if ("label" in elem.parentNode) { 1164 return elem.parentNode.disabled === disabled; 1165 } else { 1166 return elem.disabled === disabled; 1167 } 1168 } 1169 return elem.isDisabled === disabled || // Where there is no isDisabled, check manually 1170 elem.isDisabled !== !disabled && inDisabledFieldset(elem) === disabled; 1171 } 1172 return elem.disabled === disabled; 1173 } else if ("label" in elem) { 1174 return elem.disabled === disabled; 1175 } 1176 return false; 1177 }; 1178 } 1179 function createPositionalPseudo(fn) { 1180 return markFunction(function(argument) { 1181 argument = +argument; 1182 return markFunction(function(seed, matches3) { 1183 var j, matchIndexes = fn([], seed.length, argument), i2 = matchIndexes.length; 1184 while (i2--) { 1185 if (seed[j = matchIndexes[i2]]) { 1186 seed[j] = !(matches3[j] = seed[j]); 1187 } 1188 } 1189 }); 1190 }); 1191 } 1192 function testContext(context) { 1193 return context && typeof context.getElementsByTagName !== "undefined" && context; 1194 } 1195 function setDocument(node) { 1196 var subWindow, doc = node ? node.ownerDocument || node : preferredDoc; 1197 if (doc == document3 || doc.nodeType !== 9 || !doc.documentElement) { 1198 return document3; 1199 } 1200 document3 = doc; 1201 documentElement2 = document3.documentElement; 1202 documentIsHTML = !jQuery2.isXMLDoc(document3); 1203 matches2 = documentElement2.matches || documentElement2.webkitMatchesSelector || documentElement2.msMatchesSelector; 1204 if (documentElement2.msMatchesSelector && // Support: IE 11+, Edge 17 - 18+ 1205 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1206 // two documents; shallow comparisons work. 1207 // eslint-disable-next-line eqeqeq 1208 preferredDoc != document3 && (subWindow = document3.defaultView) && subWindow.top !== subWindow) { 1209 subWindow.addEventListener("unload", unloadHandler); 1210 } 1211 support.getById = assert(function(el) { 1212 documentElement2.appendChild(el).id = jQuery2.expando; 1213 return !document3.getElementsByName || !document3.getElementsByName(jQuery2.expando).length; 1214 }); 1215 support.disconnectedMatch = assert(function(el) { 1216 return matches2.call(el, "*"); 1217 }); 1218 support.scope = assert(function() { 1219 return document3.querySelectorAll(":scope"); 1220 }); 1221 support.cssHas = assert(function() { 1222 try { 1223 document3.querySelector(":has(*,:jqfake)"); 1224 return false; 1225 } catch (e) { 1226 return true; 1227 } 1228 }); 1229 if (support.getById) { 1230 Expr.filter.ID = function(id) { 1231 var attrId = id.replace(runescape, funescape); 1232 return function(elem) { 1233 return elem.getAttribute("id") === attrId; 1234 }; 1235 }; 1236 Expr.find.ID = function(id, context) { 1237 if (typeof context.getElementById !== "undefined" && documentIsHTML) { 1238 var elem = context.getElementById(id); 1239 return elem ? [elem] : []; 1240 } 1241 }; 1242 } else { 1243 Expr.filter.ID = function(id) { 1244 var attrId = id.replace(runescape, funescape); 1245 return function(elem) { 1246 var node2 = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); 1247 return node2 && node2.value === attrId; 1248 }; 1249 }; 1250 Expr.find.ID = function(id, context) { 1251 if (typeof context.getElementById !== "undefined" && documentIsHTML) { 1252 var node2, i2, elems, elem = context.getElementById(id); 1253 if (elem) { 1254 node2 = elem.getAttributeNode("id"); 1255 if (node2 && node2.value === id) { 1256 return [elem]; 1257 } 1258 elems = context.getElementsByName(id); 1259 i2 = 0; 1260 while (elem = elems[i2++]) { 1261 node2 = elem.getAttributeNode("id"); 1262 if (node2 && node2.value === id) { 1263 return [elem]; 1264 } 1265 } 1266 } 1267 return []; 1268 } 1269 }; 1270 } 1271 Expr.find.TAG = function(tag, context) { 1272 if (typeof context.getElementsByTagName !== "undefined") { 1273 return context.getElementsByTagName(tag); 1274 } else { 1275 return context.querySelectorAll(tag); 1276 } 1277 }; 1278 Expr.find.CLASS = function(className, context) { 1279 if (typeof context.getElementsByClassName !== "undefined" && documentIsHTML) { 1280 return context.getElementsByClassName(className); 1281 } 1282 }; 1283 rbuggyQSA = []; 1284 assert(function(el) { 1285 var input; 1286 documentElement2.appendChild(el).innerHTML = "<a id='" + expando + "' href='' disabled='disabled'></a><select id='" + expando + "-\r\\' disabled='disabled'><option selected=''></option></select>"; 1287 if (!el.querySelectorAll("[selected]").length) { 1288 rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")"); 1289 } 1290 if (!el.querySelectorAll("[id~=" + expando + "-]").length) { 1291 rbuggyQSA.push("~="); 1292 } 1293 if (!el.querySelectorAll("a#" + expando + "+*").length) { 1294 rbuggyQSA.push(".#.+[+~]"); 1295 } 1296 if (!el.querySelectorAll(":checked").length) { 1297 rbuggyQSA.push(":checked"); 1298 } 1299 input = document3.createElement("input"); 1300 input.setAttribute("type", "hidden"); 1301 el.appendChild(input).setAttribute("name", "D"); 1302 documentElement2.appendChild(el).disabled = true; 1303 if (el.querySelectorAll(":disabled").length !== 2) { 1304 rbuggyQSA.push(":enabled", ":disabled"); 1305 } 1306 input = document3.createElement("input"); 1307 input.setAttribute("name", ""); 1308 el.appendChild(input); 1309 if (!el.querySelectorAll("[name='']").length) { 1310 rbuggyQSA.push("\\[" + whitespace + "*name" + whitespace + "*=" + whitespace + `*(?:''|"")`); 1311 } 1312 }); 1313 if (!support.cssHas) { 1314 rbuggyQSA.push(":has"); 1315 } 1316 rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|")); 1317 sortOrder = function(a, b) { 1318 if (a === b) { 1319 hasDuplicate = true; 1320 return 0; 1321 } 1322 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 1323 if (compare) { 1324 return compare; 1325 } 1326 compare = (a.ownerDocument || a) == (b.ownerDocument || b) ? a.compareDocumentPosition(b) : ( 1327 // Otherwise we know they are disconnected 1328 1 1329 ); 1330 if (compare & 1 || !support.sortDetached && b.compareDocumentPosition(a) === compare) { 1331 if (a === document3 || a.ownerDocument == preferredDoc && find.contains(preferredDoc, a)) { 1332 return -1; 1333 } 1334 if (b === document3 || b.ownerDocument == preferredDoc && find.contains(preferredDoc, b)) { 1335 return 1; 1336 } 1337 return sortInput ? indexOf2.call(sortInput, a) - indexOf2.call(sortInput, b) : 0; 1338 } 1339 return compare & 4 ? -1 : 1; 1340 }; 1341 return document3; 1342 } 1343 find.matches = function(expr, elements) { 1344 return find(expr, null, null, elements); 1345 }; 1346 find.matchesSelector = function(elem, expr) { 1347 setDocument(elem); 1348 if (documentIsHTML && !nonnativeSelectorCache[expr + " "] && (!rbuggyQSA || !rbuggyQSA.test(expr))) { 1349 try { 1350 var ret = matches2.call(elem, expr); 1351 if (ret || support.disconnectedMatch || // As well, disconnected nodes are said to be in a document 1352 // fragment in IE 9 1353 elem.document && elem.document.nodeType !== 11) { 1354 return ret; 1355 } 1356 } catch (e) { 1357 nonnativeSelectorCache(expr, true); 1358 } 1359 } 1360 return find(expr, document3, null, [elem]).length > 0; 1361 }; 1362 find.contains = function(context, elem) { 1363 if ((context.ownerDocument || context) != document3) { 1364 setDocument(context); 1365 } 1366 return jQuery2.contains(context, elem); 1367 }; 1368 find.attr = function(elem, name) { 1369 if ((elem.ownerDocument || elem) != document3) { 1370 setDocument(elem); 1371 } 1372 var fn = Expr.attrHandle[name.toLowerCase()], val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ? fn(elem, name, !documentIsHTML) : void 0; 1373 if (val !== void 0) { 1374 return val; 1375 } 1376 return elem.getAttribute(name); 1377 }; 1378 find.error = function(msg) { 1379 throw new Error("Syntax error, unrecognized expression: " + msg); 1380 }; 1381 jQuery2.uniqueSort = function(results) { 1382 var elem, duplicates = [], j = 0, i2 = 0; 1383 hasDuplicate = !support.sortStable; 1384 sortInput = !support.sortStable && slice.call(results, 0); 1385 sort.call(results, sortOrder); 1386 if (hasDuplicate) { 1387 while (elem = results[i2++]) { 1388 if (elem === results[i2]) { 1389 j = duplicates.push(i2); 1390 } 1391 } 1392 while (j--) { 1393 splice.call(results, duplicates[j], 1); 1394 } 1395 } 1396 sortInput = null; 1397 return results; 1398 }; 1399 jQuery2.fn.uniqueSort = function() { 1400 return this.pushStack(jQuery2.uniqueSort(slice.apply(this))); 1401 }; 1402 Expr = jQuery2.expr = { 1403 // Can be adjusted by the user 1404 cacheLength: 50, 1405 createPseudo: markFunction, 1406 match: matchExpr, 1407 attrHandle: {}, 1408 find: {}, 1409 relative: { 1410 ">": { dir: "parentNode", first: true }, 1411 " ": { dir: "parentNode" }, 1412 "+": { dir: "previousSibling", first: true }, 1413 "~": { dir: "previousSibling" } 1414 }, 1415 preFilter: { 1416 ATTR: function(match) { 1417 match[1] = match[1].replace(runescape, funescape); 1418 match[3] = (match[3] || match[4] || match[5] || "").replace(runescape, funescape); 1419 if (match[2] === "~=") { 1420 match[3] = " " + match[3] + " "; 1421 } 1422 return match.slice(0, 4); 1423 }, 1424 CHILD: function(match) { 1425 match[1] = match[1].toLowerCase(); 1426 if (match[1].slice(0, 3) === "nth") { 1427 if (!match[3]) { 1428 find.error(match[0]); 1429 } 1430 match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd")); 1431 match[5] = +(match[7] + match[8] || match[3] === "odd"); 1432 } else if (match[3]) { 1433 find.error(match[0]); 1434 } 1435 return match; 1436 }, 1437 PSEUDO: function(match) { 1438 var excess, unquoted = !match[6] && match[2]; 1439 if (matchExpr.CHILD.test(match[0])) { 1440 return null; 1441 } 1442 if (match[3]) { 1443 match[2] = match[4] || match[5] || ""; 1444 } else if (unquoted && rpseudo.test(unquoted) && // Get excess from tokenize (recursively) 1445 (excess = tokenize2(unquoted, true)) && // advance to the next closing parenthesis 1446 (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) { 1447 match[0] = match[0].slice(0, excess); 1448 match[2] = unquoted.slice(0, excess); 1449 } 1450 return match.slice(0, 3); 1451 } 1452 }, 1453 filter: { 1454 TAG: function(nodeNameSelector) { 1455 var expectedNodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase(); 1456 return nodeNameSelector === "*" ? function() { 1457 return true; 1458 } : function(elem) { 1459 return nodeName(elem, expectedNodeName); 1460 }; 1461 }, 1462 CLASS: function(className) { 1463 var pattern = classCache[className + " "]; 1464 return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function(elem) { 1465 return pattern.test( 1466 typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" 1467 ); 1468 }); 1469 }, 1470 ATTR: function(name, operator, check) { 1471 return function(elem) { 1472 var result = find.attr(elem, name); 1473 if (result == null) { 1474 return operator === "!="; 1475 } 1476 if (!operator) { 1477 return true; 1478 } 1479 result += ""; 1480 if (operator === "=") { 1481 return result === check; 1482 } 1483 if (operator === "!=") { 1484 return result !== check; 1485 } 1486 if (operator === "^=") { 1487 return check && result.indexOf(check) === 0; 1488 } 1489 if (operator === "*=") { 1490 return check && result.indexOf(check) > -1; 1491 } 1492 if (operator === "$=") { 1493 return check && result.slice(-check.length) === check; 1494 } 1495 if (operator === "~=") { 1496 return (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1; 1497 } 1498 if (operator === "|=") { 1499 return result === check || result.slice(0, check.length + 1) === check + "-"; 1500 } 1501 return false; 1502 }; 1503 }, 1504 CHILD: function(type, what, _argument, first, last) { 1505 var simple = type.slice(0, 3) !== "nth", forward = type.slice(-4) !== "last", ofType = what === "of-type"; 1506 return first === 1 && last === 0 ? ( 1507 // Shortcut for :nth-*(n) 1508 function(elem) { 1509 return !!elem.parentNode; 1510 } 1511 ) : function(elem, _context, xml) { 1512 var cache2, outerCache, node, nodeIndex, start3, dir2 = simple !== forward ? "nextSibling" : "previousSibling", parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), useCache = !xml && !ofType, diff = false; 1513 if (parent) { 1514 if (simple) { 1515 while (dir2) { 1516 node = elem; 1517 while (node = node[dir2]) { 1518 if (ofType ? nodeName(node, name) : node.nodeType === 1) { 1519 return false; 1520 } 1521 } 1522 start3 = dir2 = type === "only" && !start3 && "nextSibling"; 1523 } 1524 return true; 1525 } 1526 start3 = [forward ? parent.firstChild : parent.lastChild]; 1527 if (forward && useCache) { 1528 outerCache = parent[expando] || (parent[expando] = {}); 1529 cache2 = outerCache[type] || []; 1530 nodeIndex = cache2[0] === dirruns && cache2[1]; 1531 diff = nodeIndex && cache2[2]; 1532 node = nodeIndex && parent.childNodes[nodeIndex]; 1533 while (node = ++nodeIndex && node && node[dir2] || // Fallback to seeking `elem` from the start 1534 (diff = nodeIndex = 0) || start3.pop()) { 1535 if (node.nodeType === 1 && ++diff && node === elem) { 1536 outerCache[type] = [dirruns, nodeIndex, diff]; 1537 break; 1538 } 1539 } 1540 } else { 1541 if (useCache) { 1542 outerCache = elem[expando] || (elem[expando] = {}); 1543 cache2 = outerCache[type] || []; 1544 nodeIndex = cache2[0] === dirruns && cache2[1]; 1545 diff = nodeIndex; 1546 } 1547 if (diff === false) { 1548 while (node = ++nodeIndex && node && node[dir2] || (diff = nodeIndex = 0) || start3.pop()) { 1549 if ((ofType ? nodeName(node, name) : node.nodeType === 1) && ++diff) { 1550 if (useCache) { 1551 outerCache = node[expando] || (node[expando] = {}); 1552 outerCache[type] = [dirruns, diff]; 1553 } 1554 if (node === elem) { 1555 break; 1556 } 1557 } 1558 } 1559 } 1560 } 1561 diff -= last; 1562 return diff === first || diff % first === 0 && diff / first >= 0; 1563 } 1564 }; 1565 }, 1566 PSEUDO: function(pseudo, argument) { 1567 var args, fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] || find.error("unsupported pseudo: " + pseudo); 1568 if (fn[expando]) { 1569 return fn(argument); 1570 } 1571 if (fn.length > 1) { 1572 args = [pseudo, pseudo, "", argument]; 1573 return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? markFunction(function(seed, matches3) { 1574 var idx, matched = fn(seed, argument), i2 = matched.length; 1575 while (i2--) { 1576 idx = indexOf2.call(seed, matched[i2]); 1577 seed[idx] = !(matches3[idx] = matched[i2]); 1578 } 1579 }) : function(elem) { 1580 return fn(elem, 0, args); 1581 }; 1582 } 1583 return fn; 1584 } 1585 }, 1586 pseudos: { 1587 // Potentially complex pseudos 1588 not: markFunction(function(selector) { 1589 var input = [], results = [], matcher = compile(selector.replace(rtrimCSS, "$1")); 1590 return matcher[expando] ? markFunction(function(seed, matches3, _context, xml) { 1591 var elem, unmatched = matcher(seed, null, xml, []), i2 = seed.length; 1592 while (i2--) { 1593 if (elem = unmatched[i2]) { 1594 seed[i2] = !(matches3[i2] = elem); 1595 } 1596 } 1597 }) : function(elem, _context, xml) { 1598 input[0] = elem; 1599 matcher(input, null, xml, results); 1600 input[0] = null; 1601 return !results.pop(); 1602 }; 1603 }), 1604 has: markFunction(function(selector) { 1605 return function(elem) { 1606 return find(selector, elem).length > 0; 1607 }; 1608 }), 1609 contains: markFunction(function(text) { 1610 text = text.replace(runescape, funescape); 1611 return function(elem) { 1612 return (elem.textContent || jQuery2.text(elem)).indexOf(text) > -1; 1613 }; 1614 }), 1615 // "Whether an element is represented by a :lang() selector 1616 // is based solely on the element's language value 1617 // being equal to the identifier C, 1618 // or beginning with the identifier C immediately followed by "-". 1619 // The matching of C against the element's language value is performed case-insensitively. 1620 // The identifier C does not have to be a valid language name." 1621 // https://www.w3.org/TR/selectors/#lang-pseudo 1622 lang: markFunction(function(lang) { 1623 if (!ridentifier.test(lang || "")) { 1624 find.error("unsupported lang: " + lang); 1625 } 1626 lang = lang.replace(runescape, funescape).toLowerCase(); 1627 return function(elem) { 1628 var elemLang; 1629 do { 1630 if (elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang")) { 1631 elemLang = elemLang.toLowerCase(); 1632 return elemLang === lang || elemLang.indexOf(lang + "-") === 0; 1633 } 1634 } while ((elem = elem.parentNode) && elem.nodeType === 1); 1635 return false; 1636 }; 1637 }), 1638 // Miscellaneous 1639 target: function(elem) { 1640 var hash = window2.location && window2.location.hash; 1641 return hash && hash.slice(1) === elem.id; 1642 }, 1643 root: function(elem) { 1644 return elem === documentElement2; 1645 }, 1646 focus: function(elem) { 1647 return elem === safeActiveElement() && document3.hasFocus() && !!(elem.type || elem.href || ~elem.tabIndex); 1648 }, 1649 // Boolean properties 1650 enabled: createDisabledPseudo(false), 1651 disabled: createDisabledPseudo(true), 1652 checked: function(elem) { 1653 return nodeName(elem, "input") && !!elem.checked || nodeName(elem, "option") && !!elem.selected; 1654 }, 1655 selected: function(elem) { 1656 if (elem.parentNode) { 1657 elem.parentNode.selectedIndex; 1658 } 1659 return elem.selected === true; 1660 }, 1661 // Contents 1662 empty: function(elem) { 1663 for (elem = elem.firstChild; elem; elem = elem.nextSibling) { 1664 if (elem.nodeType < 6) { 1665 return false; 1666 } 1667 } 1668 return true; 1669 }, 1670 parent: function(elem) { 1671 return !Expr.pseudos.empty(elem); 1672 }, 1673 // Element/input types 1674 header: function(elem) { 1675 return rheader.test(elem.nodeName); 1676 }, 1677 input: function(elem) { 1678 return rinputs.test(elem.nodeName); 1679 }, 1680 button: function(elem) { 1681 return nodeName(elem, "input") && elem.type === "button" || nodeName(elem, "button"); 1682 }, 1683 text: function(elem) { 1684 var attr; 1685 return nodeName(elem, "input") && elem.type === "text" && // Support: IE <10 only 1686 // New HTML5 attribute values (e.g., "search") appear 1687 // with elem.type === "text" 1688 ((attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text"); 1689 }, 1690 // Position-in-collection 1691 first: createPositionalPseudo(function() { 1692 return [0]; 1693 }), 1694 last: createPositionalPseudo(function(_matchIndexes, length) { 1695 return [length - 1]; 1696 }), 1697 eq: createPositionalPseudo(function(_matchIndexes, length, argument) { 1698 return [argument < 0 ? argument + length : argument]; 1699 }), 1700 even: createPositionalPseudo(function(matchIndexes, length) { 1701 var i2 = 0; 1702 for (; i2 < length; i2 += 2) { 1703 matchIndexes.push(i2); 1704 } 1705 return matchIndexes; 1706 }), 1707 odd: createPositionalPseudo(function(matchIndexes, length) { 1708 var i2 = 1; 1709 for (; i2 < length; i2 += 2) { 1710 matchIndexes.push(i2); 1711 } 1712 return matchIndexes; 1713 }), 1714 lt: createPositionalPseudo(function(matchIndexes, length, argument) { 1715 var i2; 1716 if (argument < 0) { 1717 i2 = argument + length; 1718 } else if (argument > length) { 1719 i2 = length; 1720 } else { 1721 i2 = argument; 1722 } 1723 for (; --i2 >= 0; ) { 1724 matchIndexes.push(i2); 1725 } 1726 return matchIndexes; 1727 }), 1728 gt: createPositionalPseudo(function(matchIndexes, length, argument) { 1729 var i2 = argument < 0 ? argument + length : argument; 1730 for (; ++i2 < length; ) { 1731 matchIndexes.push(i2); 1732 } 1733 return matchIndexes; 1734 }) 1735 } 1736 }; 1737 Expr.pseudos.nth = Expr.pseudos.eq; 1738 for (i in { radio: true, checkbox: true, file: true, password: true, image: true }) { 1739 Expr.pseudos[i] = createInputPseudo(i); 1740 } 1741 for (i in { submit: true, reset: true }) { 1742 Expr.pseudos[i] = createButtonPseudo(i); 1743 } 1744 function setFilters() { 1745 } 1746 setFilters.prototype = Expr.filters = Expr.pseudos; 1747 Expr.setFilters = new setFilters(); 1748 function tokenize2(selector, parseOnly) { 1749 var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + " "]; 1750 if (cached) { 1751 return parseOnly ? 0 : cached.slice(0); 1752 } 1753 soFar = selector; 1754 groups = []; 1755 preFilters = Expr.preFilter; 1756 while (soFar) { 1757 if (!matched || (match = rcomma.exec(soFar))) { 1758 if (match) { 1759 soFar = soFar.slice(match[0].length) || soFar; 1760 } 1761 groups.push(tokens = []); 1762 } 1763 matched = false; 1764 if (match = rleadingCombinator.exec(soFar)) { 1765 matched = match.shift(); 1766 tokens.push({ 1767 value: matched, 1768 // Cast descendant combinators to space 1769 type: match[0].replace(rtrimCSS, " ") 1770 }); 1771 soFar = soFar.slice(matched.length); 1772 } 1773 for (type in Expr.filter) { 1774 if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) { 1775 matched = match.shift(); 1776 tokens.push({ 1777 value: matched, 1778 type, 1779 matches: match 1780 }); 1781 soFar = soFar.slice(matched.length); 1782 } 1783 } 1784 if (!matched) { 1785 break; 1786 } 1787 } 1788 if (parseOnly) { 1789 return soFar.length; 1790 } 1791 return soFar ? find.error(selector) : ( 1792 // Cache the tokens 1793 tokenCache(selector, groups).slice(0) 1794 ); 1795 } 1796 function toSelector(tokens) { 1797 var i2 = 0, len = tokens.length, selector = ""; 1798 for (; i2 < len; i2++) { 1799 selector += tokens[i2].value; 1800 } 1801 return selector; 1802 } 1803 function addCombinator(matcher, combinator, base) { 1804 var dir2 = combinator.dir, skip = combinator.next, key = skip || dir2, checkNonElements = base && key === "parentNode", doneName = done++; 1805 return combinator.first ? ( 1806 // Check against closest ancestor/preceding element 1807 function(elem, context, xml) { 1808 while (elem = elem[dir2]) { 1809 if (elem.nodeType === 1 || checkNonElements) { 1810 return matcher(elem, context, xml); 1811 } 1812 } 1813 return false; 1814 } 1815 ) : ( 1816 // Check against all ancestor/preceding elements 1817 function(elem, context, xml) { 1818 var oldCache, outerCache, newCache = [dirruns, doneName]; 1819 if (xml) { 1820 while (elem = elem[dir2]) { 1821 if (elem.nodeType === 1 || checkNonElements) { 1822 if (matcher(elem, context, xml)) { 1823 return true; 1824 } 1825 } 1826 } 1827 } else { 1828 while (elem = elem[dir2]) { 1829 if (elem.nodeType === 1 || checkNonElements) { 1830 outerCache = elem[expando] || (elem[expando] = {}); 1831 if (skip && nodeName(elem, skip)) { 1832 elem = elem[dir2] || elem; 1833 } else if ((oldCache = outerCache[key]) && oldCache[0] === dirruns && oldCache[1] === doneName) { 1834 return newCache[2] = oldCache[2]; 1835 } else { 1836 outerCache[key] = newCache; 1837 if (newCache[2] = matcher(elem, context, xml)) { 1838 return true; 1839 } 1840 } 1841 } 1842 } 1843 } 1844 return false; 1845 } 1846 ); 1847 } 1848 function elementMatcher(matchers) { 1849 return matchers.length > 1 ? function(elem, context, xml) { 1850 var i2 = matchers.length; 1851 while (i2--) { 1852 if (!matchers[i2](elem, context, xml)) { 1853 return false; 1854 } 1855 } 1856 return true; 1857 } : matchers[0]; 1858 } 1859 function multipleContexts(selector, contexts, results) { 1860 var i2 = 0, len = contexts.length; 1861 for (; i2 < len; i2++) { 1862 find(selector, contexts[i2], results); 1863 } 1864 return results; 1865 } 1866 function condense(unmatched, map, filter, context, xml) { 1867 var elem, newUnmatched = [], i2 = 0, len = unmatched.length, mapped = map != null; 1868 for (; i2 < len; i2++) { 1869 if (elem = unmatched[i2]) { 1870 if (!filter || filter(elem, context, xml)) { 1871 newUnmatched.push(elem); 1872 if (mapped) { 1873 map.push(i2); 1874 } 1875 } 1876 } 1877 } 1878 return newUnmatched; 1879 } 1880 function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) { 1881 if (postFilter && !postFilter[expando]) { 1882 postFilter = setMatcher(postFilter); 1883 } 1884 if (postFinder && !postFinder[expando]) { 1885 postFinder = setMatcher(postFinder, postSelector); 1886 } 1887 return markFunction(function(seed, results, context, xml) { 1888 var temp, i2, elem, matcherOut, preMap = [], postMap = [], preexisting = results.length, elems = seed || multipleContexts( 1889 selector || "*", 1890 context.nodeType ? [context] : context, 1891 [] 1892 ), matcherIn = preFilter && (seed || !selector) ? condense(elems, preMap, preFilter, context, xml) : elems; 1893 if (matcher) { 1894 matcherOut = postFinder || (seed ? preFilter : preexisting || postFilter) ? ( 1895 // ...intermediate processing is necessary 1896 [] 1897 ) : ( 1898 // ...otherwise use results directly 1899 results 1900 ); 1901 matcher(matcherIn, matcherOut, context, xml); 1902 } else { 1903 matcherOut = matcherIn; 1904 } 1905 if (postFilter) { 1906 temp = condense(matcherOut, postMap); 1907 postFilter(temp, [], context, xml); 1908 i2 = temp.length; 1909 while (i2--) { 1910 if (elem = temp[i2]) { 1911 matcherOut[postMap[i2]] = !(matcherIn[postMap[i2]] = elem); 1912 } 1913 } 1914 } 1915 if (seed) { 1916 if (postFinder || preFilter) { 1917 if (postFinder) { 1918 temp = []; 1919 i2 = matcherOut.length; 1920 while (i2--) { 1921 if (elem = matcherOut[i2]) { 1922 temp.push(matcherIn[i2] = elem); 1923 } 1924 } 1925 postFinder(null, matcherOut = [], temp, xml); 1926 } 1927 i2 = matcherOut.length; 1928 while (i2--) { 1929 if ((elem = matcherOut[i2]) && (temp = postFinder ? indexOf2.call(seed, elem) : preMap[i2]) > -1) { 1930 seed[temp] = !(results[temp] = elem); 1931 } 1932 } 1933 } 1934 } else { 1935 matcherOut = condense( 1936 matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut 1937 ); 1938 if (postFinder) { 1939 postFinder(null, results, matcherOut, xml); 1940 } else { 1941 push2.apply(results, matcherOut); 1942 } 1943 } 1944 }); 1945 } 1946 function matcherFromTokens(tokens) { 1947 var checkContext, matcher, j, len = tokens.length, leadingRelative = Expr.relative[tokens[0].type], implicitRelative = leadingRelative || Expr.relative[" "], i2 = leadingRelative ? 1 : 0, matchContext = addCombinator(function(elem) { 1948 return elem === checkContext; 1949 }, implicitRelative, true), matchAnyContext = addCombinator(function(elem) { 1950 return indexOf2.call(checkContext, elem) > -1; 1951 }, implicitRelative, true), matchers = [function(elem, context, xml) { 1952 var ret = !leadingRelative && (xml || context != outermostContext) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml)); 1953 checkContext = null; 1954 return ret; 1955 }]; 1956 for (; i2 < len; i2++) { 1957 if (matcher = Expr.relative[tokens[i2].type]) { 1958 matchers = [addCombinator(elementMatcher(matchers), matcher)]; 1959 } else { 1960 matcher = Expr.filter[tokens[i2].type].apply(null, tokens[i2].matches); 1961 if (matcher[expando]) { 1962 j = ++i2; 1963 for (; j < len; j++) { 1964 if (Expr.relative[tokens[j].type]) { 1965 break; 1966 } 1967 } 1968 return setMatcher( 1969 i2 > 1 && elementMatcher(matchers), 1970 i2 > 1 && toSelector( 1971 // If the preceding token was a descendant combinator, insert an implicit any-element `*` 1972 tokens.slice(0, i2 - 1).concat({ value: tokens[i2 - 2].type === " " ? "*" : "" }) 1973 ).replace(rtrimCSS, "$1"), 1974 matcher, 1975 i2 < j && matcherFromTokens(tokens.slice(i2, j)), 1976 j < len && matcherFromTokens(tokens = tokens.slice(j)), 1977 j < len && toSelector(tokens) 1978 ); 1979 } 1980 matchers.push(matcher); 1981 } 1982 } 1983 return elementMatcher(matchers); 1984 } 1985 function matcherFromGroupMatchers(elementMatchers, setMatchers) { 1986 var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, superMatcher = function(seed, context, xml, results, outermost) { 1987 var elem, j, matcher, matchedCount = 0, i2 = "0", unmatched = seed && [], setMatched = [], contextBackup = outermostContext, elems = seed || byElement && Expr.find.TAG("*", outermost), dirrunsUnique = dirruns += contextBackup == null ? 1 : Math.random() || 0.1, len = elems.length; 1988 if (outermost) { 1989 outermostContext = context == document3 || context || outermost; 1990 } 1991 for (; i2 !== len && (elem = elems[i2]) != null; i2++) { 1992 if (byElement && elem) { 1993 j = 0; 1994 if (!context && elem.ownerDocument != document3) { 1995 setDocument(elem); 1996 xml = !documentIsHTML; 1997 } 1998 while (matcher = elementMatchers[j++]) { 1999 if (matcher(elem, context || document3, xml)) { 2000 push2.call(results, elem); 2001 break; 2002 } 2003 } 2004 if (outermost) { 2005 dirruns = dirrunsUnique; 2006 } 2007 } 2008 if (bySet) { 2009 if (elem = !matcher && elem) { 2010 matchedCount--; 2011 } 2012 if (seed) { 2013 unmatched.push(elem); 2014 } 2015 } 2016 } 2017 matchedCount += i2; 2018 if (bySet && i2 !== matchedCount) { 2019 j = 0; 2020 while (matcher = setMatchers[j++]) { 2021 matcher(unmatched, setMatched, context, xml); 2022 } 2023 if (seed) { 2024 if (matchedCount > 0) { 2025 while (i2--) { 2026 if (!(unmatched[i2] || setMatched[i2])) { 2027 setMatched[i2] = pop.call(results); 2028 } 2029 } 2030 } 2031 setMatched = condense(setMatched); 2032 } 2033 push2.apply(results, setMatched); 2034 if (outermost && !seed && setMatched.length > 0 && matchedCount + setMatchers.length > 1) { 2035 jQuery2.uniqueSort(results); 2036 } 2037 } 2038 if (outermost) { 2039 dirruns = dirrunsUnique; 2040 outermostContext = contextBackup; 2041 } 2042 return unmatched; 2043 }; 2044 return bySet ? markFunction(superMatcher) : superMatcher; 2045 } 2046 function compile(selector, match) { 2047 var i2, setMatchers = [], elementMatchers = [], cached = compilerCache[selector + " "]; 2048 if (!cached) { 2049 if (!match) { 2050 match = tokenize2(selector); 2051 } 2052 i2 = match.length; 2053 while (i2--) { 2054 cached = matcherFromTokens(match[i2]); 2055 if (cached[expando]) { 2056 setMatchers.push(cached); 2057 } else { 2058 elementMatchers.push(cached); 2059 } 2060 } 2061 cached = compilerCache( 2062 selector, 2063 matcherFromGroupMatchers(elementMatchers, setMatchers) 2064 ); 2065 cached.selector = selector; 2066 } 2067 return cached; 2068 } 2069 function select(selector, context, results, seed) { 2070 var i2, tokens, token, type, find2, compiled = typeof selector === "function" && selector, match = !seed && tokenize2(selector = compiled.selector || selector); 2071 results = results || []; 2072 if (match.length === 1) { 2073 tokens = match[0] = match[0].slice(0); 2074 if (tokens.length > 2 && (token = tokens[0]).type === "ID" && context.nodeType === 9 && documentIsHTML && Expr.relative[tokens[1].type]) { 2075 context = (Expr.find.ID( 2076 token.matches[0].replace(runescape, funescape), 2077 context 2078 ) || [])[0]; 2079 if (!context) { 2080 return results; 2081 } else if (compiled) { 2082 context = context.parentNode; 2083 } 2084 selector = selector.slice(tokens.shift().value.length); 2085 } 2086 i2 = matchExpr.needsContext.test(selector) ? 0 : tokens.length; 2087 while (i2--) { 2088 token = tokens[i2]; 2089 if (Expr.relative[type = token.type]) { 2090 break; 2091 } 2092 if (find2 = Expr.find[type]) { 2093 if (seed = find2( 2094 token.matches[0].replace(runescape, funescape), 2095 rsibling.test(tokens[0].type) && testContext(context.parentNode) || context 2096 )) { 2097 tokens.splice(i2, 1); 2098 selector = seed.length && toSelector(tokens); 2099 if (!selector) { 2100 push2.apply(results, seed); 2101 return results; 2102 } 2103 break; 2104 } 2105 } 2106 } 2107 } 2108 (compiled || compile(selector, match))( 2109 seed, 2110 context, 2111 !documentIsHTML, 2112 results, 2113 !context || rsibling.test(selector) && testContext(context.parentNode) || context 2114 ); 2115 return results; 2116 } 2117 support.sortStable = expando.split("").sort(sortOrder).join("") === expando; 2118 setDocument(); 2119 support.sortDetached = assert(function(el) { 2120 return el.compareDocumentPosition(document3.createElement("fieldset")) & 1; 2121 }); 2122 jQuery2.find = find; 2123 jQuery2.expr[":"] = jQuery2.expr.pseudos; 2124 jQuery2.unique = jQuery2.uniqueSort; 2125 find.compile = compile; 2126 find.select = select; 2127 find.setDocument = setDocument; 2128 find.tokenize = tokenize2; 2129 find.escape = jQuery2.escapeSelector; 2130 find.getText = jQuery2.text; 2131 find.isXML = jQuery2.isXMLDoc; 2132 find.selectors = jQuery2.expr; 2133 find.support = jQuery2.support; 2134 find.uniqueSort = jQuery2.uniqueSort; 2135 })(); 2136 var dir = function(elem, dir2, until) { 2137 var matched = [], truncate = until !== void 0; 2138 while ((elem = elem[dir2]) && elem.nodeType !== 9) { 2139 if (elem.nodeType === 1) { 2140 if (truncate && jQuery2(elem).is(until)) { 2141 break; 2142 } 2143 matched.push(elem); 2144 } 2145 } 2146 return matched; 2147 }; 2148 var siblings = function(n, elem) { 2149 var matched = []; 2150 for (; n; n = n.nextSibling) { 2151 if (n.nodeType === 1 && n !== elem) { 2152 matched.push(n); 2153 } 2154 } 2155 return matched; 2156 }; 2157 var rneedsContext = jQuery2.expr.match.needsContext; 2158 var rsingleTag = /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i; 2159 function winnow(elements, qualifier, not) { 2160 if (isFunction(qualifier)) { 2161 return jQuery2.grep(elements, function(elem, i) { 2162 return !!qualifier.call(elem, i, elem) !== not; 2163 }); 2164 } 2165 if (qualifier.nodeType) { 2166 return jQuery2.grep(elements, function(elem) { 2167 return elem === qualifier !== not; 2168 }); 2169 } 2170 if (typeof qualifier !== "string") { 2171 return jQuery2.grep(elements, function(elem) { 2172 return indexOf2.call(qualifier, elem) > -1 !== not; 2173 }); 2174 } 2175 return jQuery2.filter(qualifier, elements, not); 2176 } 2177 jQuery2.filter = function(expr, elems, not) { 2178 var elem = elems[0]; 2179 if (not) { 2180 expr = ":not(" + expr + ")"; 2181 } 2182 if (elems.length === 1 && elem.nodeType === 1) { 2183 return jQuery2.find.matchesSelector(elem, expr) ? [elem] : []; 2184 } 2185 return jQuery2.find.matches(expr, jQuery2.grep(elems, function(elem2) { 2186 return elem2.nodeType === 1; 2187 })); 2188 }; 2189 jQuery2.fn.extend({ 2190 find: function(selector) { 2191 var i, ret, len = this.length, self2 = this; 2192 if (typeof selector !== "string") { 2193 return this.pushStack(jQuery2(selector).filter(function() { 2194 for (i = 0; i < len; i++) { 2195 if (jQuery2.contains(self2[i], this)) { 2196 return true; 2197 } 2198 } 2199 })); 2200 } 2201 ret = this.pushStack([]); 2202 for (i = 0; i < len; i++) { 2203 jQuery2.find(selector, self2[i], ret); 2204 } 2205 return len > 1 ? jQuery2.uniqueSort(ret) : ret; 2206 }, 2207 filter: function(selector) { 2208 return this.pushStack(winnow(this, selector || [], false)); 2209 }, 2210 not: function(selector) { 2211 return this.pushStack(winnow(this, selector || [], true)); 2212 }, 2213 is: function(selector) { 2214 return !!winnow( 2215 this, 2216 // If this is a positional/relative selector, check membership in the returned set 2217 // so $("p:first").is("p:last") won't return true for a doc with two "p". 2218 typeof selector === "string" && rneedsContext.test(selector) ? jQuery2(selector) : selector || [], 2219 false 2220 ).length; 2221 } 2222 }); 2223 var rootjQuery, rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, init = jQuery2.fn.init = function(selector, context, root) { 2224 var match, elem; 2225 if (!selector) { 2226 return this; 2227 } 2228 root = root || rootjQuery; 2229 if (typeof selector === "string") { 2230 if (selector[0] === "<" && selector[selector.length - 1] === ">" && selector.length >= 3) { 2231 match = [null, selector, null]; 2232 } else { 2233 match = rquickExpr.exec(selector); 2234 } 2235 if (match && (match[1] || !context)) { 2236 if (match[1]) { 2237 context = context instanceof jQuery2 ? context[0] : context; 2238 jQuery2.merge(this, jQuery2.parseHTML( 2239 match[1], 2240 context && context.nodeType ? context.ownerDocument || context : document2, 2241 true 2242 )); 2243 if (rsingleTag.test(match[1]) && jQuery2.isPlainObject(context)) { 2244 for (match in context) { 2245 if (isFunction(this[match])) { 2246 this[match](context[match]); 2247 } else { 2248 this.attr(match, context[match]); 2249 } 2250 } 2251 } 2252 return this; 2253 } else { 2254 elem = document2.getElementById(match[2]); 2255 if (elem) { 2256 this[0] = elem; 2257 this.length = 1; 2258 } 2259 return this; 2260 } 2261 } else if (!context || context.jquery) { 2262 return (context || root).find(selector); 2263 } else { 2264 return this.constructor(context).find(selector); 2265 } 2266 } else if (selector.nodeType) { 2267 this[0] = selector; 2268 this.length = 1; 2269 return this; 2270 } else if (isFunction(selector)) { 2271 return root.ready !== void 0 ? root.ready(selector) : ( 2272 // Execute immediately if ready is not present 2273 selector(jQuery2) 2274 ); 2275 } 2276 return jQuery2.makeArray(selector, this); 2277 }; 2278 init.prototype = jQuery2.fn; 2279 rootjQuery = jQuery2(document2); 2280 var rparentsprev = /^(?:parents|prev(?:Until|All))/, guaranteedUnique = { 2281 children: true, 2282 contents: true, 2283 next: true, 2284 prev: true 2285 }; 2286 jQuery2.fn.extend({ 2287 has: function(target) { 2288 var targets = jQuery2(target, this), l = targets.length; 2289 return this.filter(function() { 2290 var i = 0; 2291 for (; i < l; i++) { 2292 if (jQuery2.contains(this, targets[i])) { 2293 return true; 2294 } 2295 } 2296 }); 2297 }, 2298 closest: function(selectors, context) { 2299 var cur, i = 0, l = this.length, matched = [], targets = typeof selectors !== "string" && jQuery2(selectors); 2300 if (!rneedsContext.test(selectors)) { 2301 for (; i < l; i++) { 2302 for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) { 2303 if (cur.nodeType < 11 && (targets ? targets.index(cur) > -1 : ( 2304 // Don't pass non-elements to jQuery#find 2305 cur.nodeType === 1 && jQuery2.find.matchesSelector(cur, selectors) 2306 ))) { 2307 matched.push(cur); 2308 break; 2309 } 2310 } 2311 } 2312 } 2313 return this.pushStack(matched.length > 1 ? jQuery2.uniqueSort(matched) : matched); 2314 }, 2315 // Determine the position of an element within the set 2316 index: function(elem) { 2317 if (!elem) { 2318 return this[0] && this[0].parentNode ? this.first().prevAll().length : -1; 2319 } 2320 if (typeof elem === "string") { 2321 return indexOf2.call(jQuery2(elem), this[0]); 2322 } 2323 return indexOf2.call( 2324 this, 2325 // If it receives a jQuery object, the first element is used 2326 elem.jquery ? elem[0] : elem 2327 ); 2328 }, 2329 add: function(selector, context) { 2330 return this.pushStack( 2331 jQuery2.uniqueSort( 2332 jQuery2.merge(this.get(), jQuery2(selector, context)) 2333 ) 2334 ); 2335 }, 2336 addBack: function(selector) { 2337 return this.add( 2338 selector == null ? this.prevObject : this.prevObject.filter(selector) 2339 ); 2340 } 2341 }); 2342 function sibling(cur, dir2) { 2343 while ((cur = cur[dir2]) && cur.nodeType !== 1) { 2344 } 2345 return cur; 2346 } 2347 jQuery2.each({ 2348 parent: function(elem) { 2349 var parent = elem.parentNode; 2350 return parent && parent.nodeType !== 11 ? parent : null; 2351 }, 2352 parents: function(elem) { 2353 return dir(elem, "parentNode"); 2354 }, 2355 parentsUntil: function(elem, _i, until) { 2356 return dir(elem, "parentNode", until); 2357 }, 2358 next: function(elem) { 2359 return sibling(elem, "nextSibling"); 2360 }, 2361 prev: function(elem) { 2362 return sibling(elem, "previousSibling"); 2363 }, 2364 nextAll: function(elem) { 2365 return dir(elem, "nextSibling"); 2366 }, 2367 prevAll: function(elem) { 2368 return dir(elem, "previousSibling"); 2369 }, 2370 nextUntil: function(elem, _i, until) { 2371 return dir(elem, "nextSibling", until); 2372 }, 2373 prevUntil: function(elem, _i, until) { 2374 return dir(elem, "previousSibling", until); 2375 }, 2376 siblings: function(elem) { 2377 return siblings((elem.parentNode || {}).firstChild, elem); 2378 }, 2379 children: function(elem) { 2380 return siblings(elem.firstChild); 2381 }, 2382 contents: function(elem) { 2383 if (elem.contentDocument != null && // Support: IE 11+ 2384 // <object> elements with no `data` attribute has an object 2385 // `contentDocument` with a `null` prototype. 2386 getProto(elem.contentDocument)) { 2387 return elem.contentDocument; 2388 } 2389 if (nodeName(elem, "template")) { 2390 elem = elem.content || elem; 2391 } 2392 return jQuery2.merge([], elem.childNodes); 2393 } 2394 }, function(name, fn) { 2395 jQuery2.fn[name] = function(until, selector) { 2396 var matched = jQuery2.map(this, fn, until); 2397 if (name.slice(-5) !== "Until") { 2398 selector = until; 2399 } 2400 if (selector && typeof selector === "string") { 2401 matched = jQuery2.filter(selector, matched); 2402 } 2403 if (this.length > 1) { 2404 if (!guaranteedUnique[name]) { 2405 jQuery2.uniqueSort(matched); 2406 } 2407 if (rparentsprev.test(name)) { 2408 matched.reverse(); 2409 } 2410 } 2411 return this.pushStack(matched); 2412 }; 2413 }); 2414 var rnothtmlwhite = /[^\x20\t\r\n\f]+/g; 2415 function createOptions(options) { 2416 var object = {}; 2417 jQuery2.each(options.match(rnothtmlwhite) || [], function(_, flag) { 2418 object[flag] = true; 2419 }); 2420 return object; 2421 } 2422 jQuery2.Callbacks = function(options) { 2423 options = typeof options === "string" ? createOptions(options) : jQuery2.extend({}, options); 2424 var firing, memory, fired, locked, list = [], queue = [], firingIndex = -1, fire2 = function() { 2425 locked = locked || options.once; 2426 fired = firing = true; 2427 for (; queue.length; firingIndex = -1) { 2428 memory = queue.shift(); 2429 while (++firingIndex < list.length) { 2430 if (list[firingIndex].apply(memory[0], memory[1]) === false && options.stopOnFalse) { 2431 firingIndex = list.length; 2432 memory = false; 2433 } 2434 } 2435 } 2436 if (!options.memory) { 2437 memory = false; 2438 } 2439 firing = false; 2440 if (locked) { 2441 if (memory) { 2442 list = []; 2443 } else { 2444 list = ""; 2445 } 2446 } 2447 }, self2 = { 2448 // Add a callback or a collection of callbacks to the list 2449 add: function() { 2450 if (list) { 2451 if (memory && !firing) { 2452 firingIndex = list.length - 1; 2453 queue.push(memory); 2454 } 2455 (function add2(args) { 2456 jQuery2.each(args, function(_, arg) { 2457 if (isFunction(arg)) { 2458 if (!options.unique || !self2.has(arg)) { 2459 list.push(arg); 2460 } 2461 } else if (arg && arg.length && toType(arg) !== "string") { 2462 add2(arg); 2463 } 2464 }); 2465 })(arguments); 2466 if (memory && !firing) { 2467 fire2(); 2468 } 2469 } 2470 return this; 2471 }, 2472 // Remove a callback from the list 2473 remove: function() { 2474 jQuery2.each(arguments, function(_, arg) { 2475 var index; 2476 while ((index = jQuery2.inArray(arg, list, index)) > -1) { 2477 list.splice(index, 1); 2478 if (index <= firingIndex) { 2479 firingIndex--; 2480 } 2481 } 2482 }); 2483 return this; 2484 }, 2485 // Check if a given callback is in the list. 2486 // If no argument is given, return whether or not list has callbacks attached. 2487 has: function(fn) { 2488 return fn ? jQuery2.inArray(fn, list) > -1 : list.length > 0; 2489 }, 2490 // Remove all callbacks from the list 2491 empty: function() { 2492 if (list) { 2493 list = []; 2494 } 2495 return this; 2496 }, 2497 // Disable .fire and .add 2498 // Abort any current/pending executions 2499 // Clear all callbacks and values 2500 disable: function() { 2501 locked = queue = []; 2502 list = memory = ""; 2503 return this; 2504 }, 2505 disabled: function() { 2506 return !list; 2507 }, 2508 // Disable .fire 2509 // Also disable .add unless we have memory (since it would have no effect) 2510 // Abort any pending executions 2511 lock: function() { 2512 locked = queue = []; 2513 if (!memory && !firing) { 2514 list = memory = ""; 2515 } 2516 return this; 2517 }, 2518 locked: function() { 2519 return !!locked; 2520 }, 2521 // Call all callbacks with the given context and arguments 2522 fireWith: function(context, args) { 2523 if (!locked) { 2524 args = args || []; 2525 args = [context, args.slice ? args.slice() : args]; 2526 queue.push(args); 2527 if (!firing) { 2528 fire2(); 2529 } 2530 } 2531 return this; 2532 }, 2533 // Call all the callbacks with the given arguments 2534 fire: function() { 2535 self2.fireWith(this, arguments); 2536 return this; 2537 }, 2538 // To know if the callbacks have already been called at least once 2539 fired: function() { 2540 return !!fired; 2541 } 2542 }; 2543 return self2; 2544 }; 2545 function Identity(v) { 2546 return v; 2547 } 2548 function Thrower(ex) { 2549 throw ex; 2550 } 2551 function adoptValue(value, resolve, reject, noValue) { 2552 var method; 2553 try { 2554 if (value && isFunction(method = value.promise)) { 2555 method.call(value).done(resolve).fail(reject); 2556 } else if (value && isFunction(method = value.then)) { 2557 method.call(value, resolve, reject); 2558 } else { 2559 resolve.apply(void 0, [value].slice(noValue)); 2560 } 2561 } catch (value2) { 2562 reject.apply(void 0, [value2]); 2563 } 2564 } 2565 jQuery2.extend({ 2566 Deferred: function(func) { 2567 var tuples = [ 2568 // action, add listener, callbacks, 2569 // ... .then handlers, argument index, [final state] 2570 [ 2571 "notify", 2572 "progress", 2573 jQuery2.Callbacks("memory"), 2574 jQuery2.Callbacks("memory"), 2575 2 2576 ], 2577 [ 2578 "resolve", 2579 "done", 2580 jQuery2.Callbacks("once memory"), 2581 jQuery2.Callbacks("once memory"), 2582 0, 2583 "resolved" 2584 ], 2585 [ 2586 "reject", 2587 "fail", 2588 jQuery2.Callbacks("once memory"), 2589 jQuery2.Callbacks("once memory"), 2590 1, 2591 "rejected" 2592 ] 2593 ], state = "pending", promise = { 2594 state: function() { 2595 return state; 2596 }, 2597 always: function() { 2598 deferred.done(arguments).fail(arguments); 2599 return this; 2600 }, 2601 "catch": function(fn) { 2602 return promise.then(null, fn); 2603 }, 2604 // Keep pipe for back-compat 2605 pipe: function() { 2606 var fns = arguments; 2607 return jQuery2.Deferred(function(newDefer) { 2608 jQuery2.each(tuples, function(_i, tuple) { 2609 var fn = isFunction(fns[tuple[4]]) && fns[tuple[4]]; 2610 deferred[tuple[1]](function() { 2611 var returned = fn && fn.apply(this, arguments); 2612 if (returned && isFunction(returned.promise)) { 2613 returned.promise().progress(newDefer.notify).done(newDefer.resolve).fail(newDefer.reject); 2614 } else { 2615 newDefer[tuple[0] + "With"]( 2616 this, 2617 fn ? [returned] : arguments 2618 ); 2619 } 2620 }); 2621 }); 2622 fns = null; 2623 }).promise(); 2624 }, 2625 then: function(onFulfilled, onRejected, onProgress) { 2626 var maxDepth = 0; 2627 function resolve(depth, deferred2, handler, special) { 2628 return function() { 2629 var that = this, args = arguments, mightThrow = function() { 2630 var returned, then; 2631 if (depth < maxDepth) { 2632 return; 2633 } 2634 returned = handler.apply(that, args); 2635 if (returned === deferred2.promise()) { 2636 throw new TypeError("Thenable self-resolution"); 2637 } 2638 then = returned && // Support: Promises/A+ section 2.3.4 2639 // https://promisesaplus.com/#point-64 2640 // Only check objects and functions for thenability 2641 (typeof returned === "object" || typeof returned === "function") && returned.then; 2642 if (isFunction(then)) { 2643 if (special) { 2644 then.call( 2645 returned, 2646 resolve(maxDepth, deferred2, Identity, special), 2647 resolve(maxDepth, deferred2, Thrower, special) 2648 ); 2649 } else { 2650 maxDepth++; 2651 then.call( 2652 returned, 2653 resolve(maxDepth, deferred2, Identity, special), 2654 resolve(maxDepth, deferred2, Thrower, special), 2655 resolve( 2656 maxDepth, 2657 deferred2, 2658 Identity, 2659 deferred2.notifyWith 2660 ) 2661 ); 2662 } 2663 } else { 2664 if (handler !== Identity) { 2665 that = void 0; 2666 args = [returned]; 2667 } 2668 (special || deferred2.resolveWith)(that, args); 2669 } 2670 }, process = special ? mightThrow : function() { 2671 try { 2672 mightThrow(); 2673 } catch (e) { 2674 if (jQuery2.Deferred.exceptionHook) { 2675 jQuery2.Deferred.exceptionHook( 2676 e, 2677 process.error 2678 ); 2679 } 2680 if (depth + 1 >= maxDepth) { 2681 if (handler !== Thrower) { 2682 that = void 0; 2683 args = [e]; 2684 } 2685 deferred2.rejectWith(that, args); 2686 } 2687 } 2688 }; 2689 if (depth) { 2690 process(); 2691 } else { 2692 if (jQuery2.Deferred.getErrorHook) { 2693 process.error = jQuery2.Deferred.getErrorHook(); 2694 } else if (jQuery2.Deferred.getStackHook) { 2695 process.error = jQuery2.Deferred.getStackHook(); 2696 } 2697 window2.setTimeout(process); 2698 } 2699 }; 2700 } 2701 return jQuery2.Deferred(function(newDefer) { 2702 tuples[0][3].add( 2703 resolve( 2704 0, 2705 newDefer, 2706 isFunction(onProgress) ? onProgress : Identity, 2707 newDefer.notifyWith 2708 ) 2709 ); 2710 tuples[1][3].add( 2711 resolve( 2712 0, 2713 newDefer, 2714 isFunction(onFulfilled) ? onFulfilled : Identity 2715 ) 2716 ); 2717 tuples[2][3].add( 2718 resolve( 2719 0, 2720 newDefer, 2721 isFunction(onRejected) ? onRejected : Thrower 2722 ) 2723 ); 2724 }).promise(); 2725 }, 2726 // Get a promise for this deferred 2727 // If obj is provided, the promise aspect is added to the object 2728 promise: function(obj) { 2729 return obj != null ? jQuery2.extend(obj, promise) : promise; 2730 } 2731 }, deferred = {}; 2732 jQuery2.each(tuples, function(i, tuple) { 2733 var list = tuple[2], stateString = tuple[5]; 2734 promise[tuple[1]] = list.add; 2735 if (stateString) { 2736 list.add( 2737 function() { 2738 state = stateString; 2739 }, 2740 // rejected_callbacks.disable 2741 // fulfilled_callbacks.disable 2742 tuples[3 - i][2].disable, 2743 // rejected_handlers.disable 2744 // fulfilled_handlers.disable 2745 tuples[3 - i][3].disable, 2746 // progress_callbacks.lock 2747 tuples[0][2].lock, 2748 // progress_handlers.lock 2749 tuples[0][3].lock 2750 ); 2751 } 2752 list.add(tuple[3].fire); 2753 deferred[tuple[0]] = function() { 2754 deferred[tuple[0] + "With"](this === deferred ? void 0 : this, arguments); 2755 return this; 2756 }; 2757 deferred[tuple[0] + "With"] = list.fireWith; 2758 }); 2759 promise.promise(deferred); 2760 if (func) { 2761 func.call(deferred, deferred); 2762 } 2763 return deferred; 2764 }, 2765 // Deferred helper 2766 when: function(singleValue) { 2767 var remaining = arguments.length, i = remaining, resolveContexts = Array(i), resolveValues = slice.call(arguments), primary = jQuery2.Deferred(), updateFunc = function(i2) { 2768 return function(value) { 2769 resolveContexts[i2] = this; 2770 resolveValues[i2] = arguments.length > 1 ? slice.call(arguments) : value; 2771 if (!--remaining) { 2772 primary.resolveWith(resolveContexts, resolveValues); 2773 } 2774 }; 2775 }; 2776 if (remaining <= 1) { 2777 adoptValue( 2778 singleValue, 2779 primary.done(updateFunc(i)).resolve, 2780 primary.reject, 2781 !remaining 2782 ); 2783 if (primary.state() === "pending" || isFunction(resolveValues[i] && resolveValues[i].then)) { 2784 return primary.then(); 2785 } 2786 } 2787 while (i--) { 2788 adoptValue(resolveValues[i], updateFunc(i), primary.reject); 2789 } 2790 return primary.promise(); 2791 } 2792 }); 2793 var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; 2794 jQuery2.Deferred.exceptionHook = function(error2, asyncError) { 2795 if (window2.console && window2.console.warn && error2 && rerrorNames.test(error2.name)) { 2796 window2.console.warn( 2797 "jQuery.Deferred exception: " + error2.message, 2798 error2.stack, 2799 asyncError 2800 ); 2801 } 2802 }; 2803 jQuery2.readyException = function(error2) { 2804 window2.setTimeout(function() { 2805 throw error2; 2806 }); 2807 }; 2808 var readyList = jQuery2.Deferred(); 2809 jQuery2.fn.ready = function(fn) { 2810 readyList.then(fn).catch(function(error2) { 2811 jQuery2.readyException(error2); 2812 }); 2813 return this; 2814 }; 2815 jQuery2.extend({ 2816 // Is the DOM ready to be used? Set to true once it occurs. 2817 isReady: false, 2818 // A counter to track how many items to wait for before 2819 // the ready event fires. See trac-6781 2820 readyWait: 1, 2821 // Handle when the DOM is ready 2822 ready: function(wait) { 2823 if (wait === true ? --jQuery2.readyWait : jQuery2.isReady) { 2824 return; 2825 } 2826 jQuery2.isReady = true; 2827 if (wait !== true && --jQuery2.readyWait > 0) { 2828 return; 2829 } 2830 readyList.resolveWith(document2, [jQuery2]); 2831 } 2832 }); 2833 jQuery2.ready.then = readyList.then; 2834 function completed() { 2835 document2.removeEventListener("DOMContentLoaded", completed); 2836 window2.removeEventListener("load", completed); 2837 jQuery2.ready(); 2838 } 2839 if (document2.readyState === "complete" || document2.readyState !== "loading" && !document2.documentElement.doScroll) { 2840 window2.setTimeout(jQuery2.ready); 2841 } else { 2842 document2.addEventListener("DOMContentLoaded", completed); 2843 window2.addEventListener("load", completed); 2844 } 2845 var access = function(elems, fn, key, value, chainable, emptyGet, raw) { 2846 var i = 0, len = elems.length, bulk = key == null; 2847 if (toType(key) === "object") { 2848 chainable = true; 2849 for (i in key) { 2850 access(elems, fn, i, key[i], true, emptyGet, raw); 2851 } 2852 } else if (value !== void 0) { 2853 chainable = true; 2854 if (!isFunction(value)) { 2855 raw = true; 2856 } 2857 if (bulk) { 2858 if (raw) { 2859 fn.call(elems, value); 2860 fn = null; 2861 } else { 2862 bulk = fn; 2863 fn = function(elem, _key, value2) { 2864 return bulk.call(jQuery2(elem), value2); 2865 }; 2866 } 2867 } 2868 if (fn) { 2869 for (; i < len; i++) { 2870 fn( 2871 elems[i], 2872 key, 2873 raw ? value : value.call(elems[i], i, fn(elems[i], key)) 2874 ); 2875 } 2876 } 2877 } 2878 if (chainable) { 2879 return elems; 2880 } 2881 if (bulk) { 2882 return fn.call(elems); 2883 } 2884 return len ? fn(elems[0], key) : emptyGet; 2885 }; 2886 var rmsPrefix = /^-ms-/, rdashAlpha = /-([a-z])/g; 2887 function fcamelCase(_all, letter) { 2888 return letter.toUpperCase(); 2889 } 2890 function camelCase(string) { 2891 return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase); 2892 } 2893 var acceptData = function(owner) { 2894 return owner.nodeType === 1 || owner.nodeType === 9 || !+owner.nodeType; 2895 }; 2896 function Data() { 2897 this.expando = jQuery2.expando + Data.uid++; 2898 } 2899 Data.uid = 1; 2900 Data.prototype = { 2901 cache: function(owner) { 2902 var value = owner[this.expando]; 2903 if (!value) { 2904 value = {}; 2905 if (acceptData(owner)) { 2906 if (owner.nodeType) { 2907 owner[this.expando] = value; 2908 } else { 2909 Object.defineProperty(owner, this.expando, { 2910 value, 2911 configurable: true 2912 }); 2913 } 2914 } 2915 } 2916 return value; 2917 }, 2918 set: function(owner, data, value) { 2919 var prop, cache2 = this.cache(owner); 2920 if (typeof data === "string") { 2921 cache2[camelCase(data)] = value; 2922 } else { 2923 for (prop in data) { 2924 cache2[camelCase(prop)] = data[prop]; 2925 } 2926 } 2927 return cache2; 2928 }, 2929 get: function(owner, key) { 2930 return key === void 0 ? this.cache(owner) : ( 2931 // Always use camelCase key (gh-2257) 2932 owner[this.expando] && owner[this.expando][camelCase(key)] 2933 ); 2934 }, 2935 access: function(owner, key, value) { 2936 if (key === void 0 || key && typeof key === "string" && value === void 0) { 2937 return this.get(owner, key); 2938 } 2939 this.set(owner, key, value); 2940 return value !== void 0 ? value : key; 2941 }, 2942 remove: function(owner, key) { 2943 var i, cache2 = owner[this.expando]; 2944 if (cache2 === void 0) { 2945 return; 2946 } 2947 if (key !== void 0) { 2948 if (Array.isArray(key)) { 2949 key = key.map(camelCase); 2950 } else { 2951 key = camelCase(key); 2952 key = key in cache2 ? [key] : key.match(rnothtmlwhite) || []; 2953 } 2954 i = key.length; 2955 while (i--) { 2956 delete cache2[key[i]]; 2957 } 2958 } 2959 if (key === void 0 || jQuery2.isEmptyObject(cache2)) { 2960 if (owner.nodeType) { 2961 owner[this.expando] = void 0; 2962 } else { 2963 delete owner[this.expando]; 2964 } 2965 } 2966 }, 2967 hasData: function(owner) { 2968 var cache2 = owner[this.expando]; 2969 return cache2 !== void 0 && !jQuery2.isEmptyObject(cache2); 2970 } 2971 }; 2972 var dataPriv = new Data(); 2973 var dataUser = new Data(); 2974 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, rmultiDash = /[A-Z]/g; 2975 function getData2(data) { 2976 if (data === "true") { 2977 return true; 2978 } 2979 if (data === "false") { 2980 return false; 2981 } 2982 if (data === "null") { 2983 return null; 2984 } 2985 if (data === +data + "") { 2986 return +data; 2987 } 2988 if (rbrace.test(data)) { 2989 return JSON.parse(data); 2990 } 2991 return data; 2992 } 2993 function dataAttr(elem, key, data) { 2994 var name; 2995 if (data === void 0 && elem.nodeType === 1) { 2996 name = "data-" + key.replace(rmultiDash, "-$&").toLowerCase(); 2997 data = elem.getAttribute(name); 2998 if (typeof data === "string") { 2999 try { 3000 data = getData2(data); 3001 } catch (e) { 3002 } 3003 dataUser.set(elem, key, data); 3004 } else { 3005 data = void 0; 3006 } 3007 } 3008 return data; 3009 } 3010 jQuery2.extend({ 3011 hasData: function(elem) { 3012 return dataUser.hasData(elem) || dataPriv.hasData(elem); 3013 }, 3014 data: function(elem, name, data) { 3015 return dataUser.access(elem, name, data); 3016 }, 3017 removeData: function(elem, name) { 3018 dataUser.remove(elem, name); 3019 }, 3020 // TODO: Now that all calls to _data and _removeData have been replaced 3021 // with direct calls to dataPriv methods, these can be deprecated. 3022 _data: function(elem, name, data) { 3023 return dataPriv.access(elem, name, data); 3024 }, 3025 _removeData: function(elem, name) { 3026 dataPriv.remove(elem, name); 3027 } 3028 }); 3029 jQuery2.fn.extend({ 3030 data: function(key, value) { 3031 var i, name, data, elem = this[0], attrs = elem && elem.attributes; 3032 if (key === void 0) { 3033 if (this.length) { 3034 data = dataUser.get(elem); 3035 if (elem.nodeType === 1 && !dataPriv.get(elem, "hasDataAttrs")) { 3036 i = attrs.length; 3037 while (i--) { 3038 if (attrs[i]) { 3039 name = attrs[i].name; 3040 if (name.indexOf("data-") === 0) { 3041 name = camelCase(name.slice(5)); 3042 dataAttr(elem, name, data[name]); 3043 } 3044 } 3045 } 3046 dataPriv.set(elem, "hasDataAttrs", true); 3047 } 3048 } 3049 return data; 3050 } 3051 if (typeof key === "object") { 3052 return this.each(function() { 3053 dataUser.set(this, key); 3054 }); 3055 } 3056 return access(this, function(value2) { 3057 var data2; 3058 if (elem && value2 === void 0) { 3059 data2 = dataUser.get(elem, key); 3060 if (data2 !== void 0) { 3061 return data2; 3062 } 3063 data2 = dataAttr(elem, key); 3064 if (data2 !== void 0) { 3065 return data2; 3066 } 3067 return; 3068 } 3069 this.each(function() { 3070 dataUser.set(this, key, value2); 3071 }); 3072 }, null, value, arguments.length > 1, null, true); 3073 }, 3074 removeData: function(key) { 3075 return this.each(function() { 3076 dataUser.remove(this, key); 3077 }); 3078 } 3079 }); 3080 jQuery2.extend({ 3081 queue: function(elem, type, data) { 3082 var queue; 3083 if (elem) { 3084 type = (type || "fx") + "queue"; 3085 queue = dataPriv.get(elem, type); 3086 if (data) { 3087 if (!queue || Array.isArray(data)) { 3088 queue = dataPriv.access(elem, type, jQuery2.makeArray(data)); 3089 } else { 3090 queue.push(data); 3091 } 3092 } 3093 return queue || []; 3094 } 3095 }, 3096 dequeue: function(elem, type) { 3097 type = type || "fx"; 3098 var queue = jQuery2.queue(elem, type), startLength = queue.length, fn = queue.shift(), hooks = jQuery2._queueHooks(elem, type), next = function() { 3099 jQuery2.dequeue(elem, type); 3100 }; 3101 if (fn === "inprogress") { 3102 fn = queue.shift(); 3103 startLength--; 3104 } 3105 if (fn) { 3106 if (type === "fx") { 3107 queue.unshift("inprogress"); 3108 } 3109 delete hooks.stop; 3110 fn.call(elem, next, hooks); 3111 } 3112 if (!startLength && hooks) { 3113 hooks.empty.fire(); 3114 } 3115 }, 3116 // Not public - generate a queueHooks object, or return the current one 3117 _queueHooks: function(elem, type) { 3118 var key = type + "queueHooks"; 3119 return dataPriv.get(elem, key) || dataPriv.access(elem, key, { 3120 empty: jQuery2.Callbacks("once memory").add(function() { 3121 dataPriv.remove(elem, [type + "queue", key]); 3122 }) 3123 }); 3124 } 3125 }); 3126 jQuery2.fn.extend({ 3127 queue: function(type, data) { 3128 var setter = 2; 3129 if (typeof type !== "string") { 3130 data = type; 3131 type = "fx"; 3132 setter--; 3133 } 3134 if (arguments.length < setter) { 3135 return jQuery2.queue(this[0], type); 3136 } 3137 return data === void 0 ? this : this.each(function() { 3138 var queue = jQuery2.queue(this, type, data); 3139 jQuery2._queueHooks(this, type); 3140 if (type === "fx" && queue[0] !== "inprogress") { 3141 jQuery2.dequeue(this, type); 3142 } 3143 }); 3144 }, 3145 dequeue: function(type) { 3146 return this.each(function() { 3147 jQuery2.dequeue(this, type); 3148 }); 3149 }, 3150 clearQueue: function(type) { 3151 return this.queue(type || "fx", []); 3152 }, 3153 // Get a promise resolved when queues of a certain type 3154 // are emptied (fx is the type by default) 3155 promise: function(type, obj) { 3156 var tmp, count = 1, defer = jQuery2.Deferred(), elements = this, i = this.length, resolve = function() { 3157 if (!--count) { 3158 defer.resolveWith(elements, [elements]); 3159 } 3160 }; 3161 if (typeof type !== "string") { 3162 obj = type; 3163 type = void 0; 3164 } 3165 type = type || "fx"; 3166 while (i--) { 3167 tmp = dataPriv.get(elements[i], type + "queueHooks"); 3168 if (tmp && tmp.empty) { 3169 count++; 3170 tmp.empty.add(resolve); 3171 } 3172 } 3173 resolve(); 3174 return defer.promise(obj); 3175 } 3176 }); 3177 var pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source; 3178 var rcssNum = new RegExp("^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i"); 3179 var cssExpand = ["Top", "Right", "Bottom", "Left"]; 3180 var documentElement = document2.documentElement; 3181 var isAttached = function(elem) { 3182 return jQuery2.contains(elem.ownerDocument, elem); 3183 }, composed = { composed: true }; 3184 if (documentElement.getRootNode) { 3185 isAttached = function(elem) { 3186 return jQuery2.contains(elem.ownerDocument, elem) || elem.getRootNode(composed) === elem.ownerDocument; 3187 }; 3188 } 3189 var isHiddenWithinTree = function(elem, el) { 3190 elem = el || elem; 3191 return elem.style.display === "none" || elem.style.display === "" && // Otherwise, check computed style 3192 // Support: Firefox <=43 - 45 3193 // Disconnected elements can have computed display: none, so first confirm that elem is 3194 // in the document. 3195 isAttached(elem) && jQuery2.css(elem, "display") === "none"; 3196 }; 3197 function adjustCSS(elem, prop, valueParts, tween) { 3198 var adjusted, scale, maxIterations = 20, currentValue = tween ? function() { 3199 return tween.cur(); 3200 } : function() { 3201 return jQuery2.css(elem, prop, ""); 3202 }, initial = currentValue(), unit = valueParts && valueParts[3] || (jQuery2.cssNumber[prop] ? "" : "px"), initialInUnit = elem.nodeType && (jQuery2.cssNumber[prop] || unit !== "px" && +initial) && rcssNum.exec(jQuery2.css(elem, prop)); 3203 if (initialInUnit && initialInUnit[3] !== unit) { 3204 initial = initial / 2; 3205 unit = unit || initialInUnit[3]; 3206 initialInUnit = +initial || 1; 3207 while (maxIterations--) { 3208 jQuery2.style(elem, prop, initialInUnit + unit); 3209 if ((1 - scale) * (1 - (scale = currentValue() / initial || 0.5)) <= 0) { 3210 maxIterations = 0; 3211 } 3212 initialInUnit = initialInUnit / scale; 3213 } 3214 initialInUnit = initialInUnit * 2; 3215 jQuery2.style(elem, prop, initialInUnit + unit); 3216 valueParts = valueParts || []; 3217 } 3218 if (valueParts) { 3219 initialInUnit = +initialInUnit || +initial || 0; 3220 adjusted = valueParts[1] ? initialInUnit + (valueParts[1] + 1) * valueParts[2] : +valueParts[2]; 3221 if (tween) { 3222 tween.unit = unit; 3223 tween.start = initialInUnit; 3224 tween.end = adjusted; 3225 } 3226 } 3227 return adjusted; 3228 } 3229 var defaultDisplayMap = {}; 3230 function getDefaultDisplay(elem) { 3231 var temp, doc = elem.ownerDocument, nodeName2 = elem.nodeName, display = defaultDisplayMap[nodeName2]; 3232 if (display) { 3233 return display; 3234 } 3235 temp = doc.body.appendChild(doc.createElement(nodeName2)); 3236 display = jQuery2.css(temp, "display"); 3237 temp.parentNode.removeChild(temp); 3238 if (display === "none") { 3239 display = "block"; 3240 } 3241 defaultDisplayMap[nodeName2] = display; 3242 return display; 3243 } 3244 function showHide(elements, show) { 3245 var display, elem, values = [], index = 0, length = elements.length; 3246 for (; index < length; index++) { 3247 elem = elements[index]; 3248 if (!elem.style) { 3249 continue; 3250 } 3251 display = elem.style.display; 3252 if (show) { 3253 if (display === "none") { 3254 values[index] = dataPriv.get(elem, "display") || null; 3255 if (!values[index]) { 3256 elem.style.display = ""; 3257 } 3258 } 3259 if (elem.style.display === "" && isHiddenWithinTree(elem)) { 3260 values[index] = getDefaultDisplay(elem); 3261 } 3262 } else { 3263 if (display !== "none") { 3264 values[index] = "none"; 3265 dataPriv.set(elem, "display", display); 3266 } 3267 } 3268 } 3269 for (index = 0; index < length; index++) { 3270 if (values[index] != null) { 3271 elements[index].style.display = values[index]; 3272 } 3273 } 3274 return elements; 3275 } 3276 jQuery2.fn.extend({ 3277 show: function() { 3278 return showHide(this, true); 3279 }, 3280 hide: function() { 3281 return showHide(this); 3282 }, 3283 toggle: function(state) { 3284 if (typeof state === "boolean") { 3285 return state ? this.show() : this.hide(); 3286 } 3287 return this.each(function() { 3288 if (isHiddenWithinTree(this)) { 3289 jQuery2(this).show(); 3290 } else { 3291 jQuery2(this).hide(); 3292 } 3293 }); 3294 } 3295 }); 3296 var rcheckableType = /^(?:checkbox|radio)$/i; 3297 var rtagName = /<([a-z][^\/\0>\x20\t\r\n\f]*)/i; 3298 var rscriptType = /^$|^module$|\/(?:java|ecma)script/i; 3299 (function() { 3300 var fragment = document2.createDocumentFragment(), div = fragment.appendChild(document2.createElement("div")), input = document2.createElement("input"); 3301 input.setAttribute("type", "radio"); 3302 input.setAttribute("checked", "checked"); 3303 input.setAttribute("name", "t"); 3304 div.appendChild(input); 3305 support.checkClone = div.cloneNode(true).cloneNode(true).lastChild.checked; 3306 div.innerHTML = "<textarea>x</textarea>"; 3307 support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue; 3308 div.innerHTML = "<option></option>"; 3309 support.option = !!div.lastChild; 3310 })(); 3311 var wrapMap = { 3312 // XHTML parsers do not magically insert elements in the 3313 // same way that tag soup parsers do. So we cannot shorten 3314 // this by omitting <tbody> or other required elements. 3315 thead: [1, "<table>", "</table>"], 3316 col: [2, "<table><colgroup>", "</colgroup></table>"], 3317 tr: [2, "<table><tbody>", "</tbody></table>"], 3318 td: [3, "<table><tbody><tr>", "</tr></tbody></table>"], 3319 _default: [0, "", ""] 3320 }; 3321 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 3322 wrapMap.th = wrapMap.td; 3323 if (!support.option) { 3324 wrapMap.optgroup = wrapMap.option = [1, "<select multiple='multiple'>", "</select>"]; 3325 } 3326 function getAll(context, tag) { 3327 var ret; 3328 if (typeof context.getElementsByTagName !== "undefined") { 3329 ret = context.getElementsByTagName(tag || "*"); 3330 } else if (typeof context.querySelectorAll !== "undefined") { 3331 ret = context.querySelectorAll(tag || "*"); 3332 } else { 3333 ret = []; 3334 } 3335 if (tag === void 0 || tag && nodeName(context, tag)) { 3336 return jQuery2.merge([context], ret); 3337 } 3338 return ret; 3339 } 3340 function setGlobalEval(elems, refElements) { 3341 var i = 0, l = elems.length; 3342 for (; i < l; i++) { 3343 dataPriv.set( 3344 elems[i], 3345 "globalEval", 3346 !refElements || dataPriv.get(refElements[i], "globalEval") 3347 ); 3348 } 3349 } 3350 var rhtml = /<|&#?\w+;/; 3351 function buildFragment(elems, context, scripts, selection, ignored) { 3352 var elem, tmp, tag, wrap, attached, j, fragment = context.createDocumentFragment(), nodes = [], i = 0, l = elems.length; 3353 for (; i < l; i++) { 3354 elem = elems[i]; 3355 if (elem || elem === 0) { 3356 if (toType(elem) === "object") { 3357 jQuery2.merge(nodes, elem.nodeType ? [elem] : elem); 3358 } else if (!rhtml.test(elem)) { 3359 nodes.push(context.createTextNode(elem)); 3360 } else { 3361 tmp = tmp || fragment.appendChild(context.createElement("div")); 3362 tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase(); 3363 wrap = wrapMap[tag] || wrapMap._default; 3364 tmp.innerHTML = wrap[1] + jQuery2.htmlPrefilter(elem) + wrap[2]; 3365 j = wrap[0]; 3366 while (j--) { 3367 tmp = tmp.lastChild; 3368 } 3369 jQuery2.merge(nodes, tmp.childNodes); 3370 tmp = fragment.firstChild; 3371 tmp.textContent = ""; 3372 } 3373 } 3374 } 3375 fragment.textContent = ""; 3376 i = 0; 3377 while (elem = nodes[i++]) { 3378 if (selection && jQuery2.inArray(elem, selection) > -1) { 3379 if (ignored) { 3380 ignored.push(elem); 3381 } 3382 continue; 3383 } 3384 attached = isAttached(elem); 3385 tmp = getAll(fragment.appendChild(elem), "script"); 3386 if (attached) { 3387 setGlobalEval(tmp); 3388 } 3389 if (scripts) { 3390 j = 0; 3391 while (elem = tmp[j++]) { 3392 if (rscriptType.test(elem.type || "")) { 3393 scripts.push(elem); 3394 } 3395 } 3396 } 3397 } 3398 return fragment; 3399 } 3400 var rtypenamespace = /^([^.]*)(?:\.(.+)|)/; 3401 function returnTrue() { 3402 return true; 3403 } 3404 function returnFalse() { 3405 return false; 3406 } 3407 function on(elem, types, selector, data, fn, one) { 3408 var origFn, type; 3409 if (typeof types === "object") { 3410 if (typeof selector !== "string") { 3411 data = data || selector; 3412 selector = void 0; 3413 } 3414 for (type in types) { 3415 on(elem, type, selector, data, types[type], one); 3416 } 3417 return elem; 3418 } 3419 if (data == null && fn == null) { 3420 fn = selector; 3421 data = selector = void 0; 3422 } else if (fn == null) { 3423 if (typeof selector === "string") { 3424 fn = data; 3425 data = void 0; 3426 } else { 3427 fn = data; 3428 data = selector; 3429 selector = void 0; 3430 } 3431 } 3432 if (fn === false) { 3433 fn = returnFalse; 3434 } else if (!fn) { 3435 return elem; 3436 } 3437 if (one === 1) { 3438 origFn = fn; 3439 fn = function(event) { 3440 jQuery2().off(event); 3441 return origFn.apply(this, arguments); 3442 }; 3443 fn.guid = origFn.guid || (origFn.guid = jQuery2.guid++); 3444 } 3445 return elem.each(function() { 3446 jQuery2.event.add(this, types, fn, data, selector); 3447 }); 3448 } 3449 jQuery2.event = { 3450 global: {}, 3451 add: function(elem, types, handler, data, selector) { 3452 var handleObjIn, eventHandle, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = dataPriv.get(elem); 3453 if (!acceptData(elem)) { 3454 return; 3455 } 3456 if (handler.handler) { 3457 handleObjIn = handler; 3458 handler = handleObjIn.handler; 3459 selector = handleObjIn.selector; 3460 } 3461 if (selector) { 3462 jQuery2.find.matchesSelector(documentElement, selector); 3463 } 3464 if (!handler.guid) { 3465 handler.guid = jQuery2.guid++; 3466 } 3467 if (!(events = elemData.events)) { 3468 events = elemData.events = /* @__PURE__ */ Object.create(null); 3469 } 3470 if (!(eventHandle = elemData.handle)) { 3471 eventHandle = elemData.handle = function(e) { 3472 return typeof jQuery2 !== "undefined" && jQuery2.event.triggered !== e.type ? jQuery2.event.dispatch.apply(elem, arguments) : void 0; 3473 }; 3474 } 3475 types = (types || "").match(rnothtmlwhite) || [""]; 3476 t = types.length; 3477 while (t--) { 3478 tmp = rtypenamespace.exec(types[t]) || []; 3479 type = origType = tmp[1]; 3480 namespaces = (tmp[2] || "").split(".").sort(); 3481 if (!type) { 3482 continue; 3483 } 3484 special = jQuery2.event.special[type] || {}; 3485 type = (selector ? special.delegateType : special.bindType) || type; 3486 special = jQuery2.event.special[type] || {}; 3487 handleObj = jQuery2.extend({ 3488 type, 3489 origType, 3490 data, 3491 handler, 3492 guid: handler.guid, 3493 selector, 3494 needsContext: selector && jQuery2.expr.match.needsContext.test(selector), 3495 namespace: namespaces.join(".") 3496 }, handleObjIn); 3497 if (!(handlers = events[type])) { 3498 handlers = events[type] = []; 3499 handlers.delegateCount = 0; 3500 if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) { 3501 if (elem.addEventListener) { 3502 elem.addEventListener(type, eventHandle); 3503 } 3504 } 3505 } 3506 if (special.add) { 3507 special.add.call(elem, handleObj); 3508 if (!handleObj.handler.guid) { 3509 handleObj.handler.guid = handler.guid; 3510 } 3511 } 3512 if (selector) { 3513 handlers.splice(handlers.delegateCount++, 0, handleObj); 3514 } else { 3515 handlers.push(handleObj); 3516 } 3517 jQuery2.event.global[type] = true; 3518 } 3519 }, 3520 // Detach an event or set of events from an element 3521 remove: function(elem, types, handler, selector, mappedTypes) { 3522 var j, origCount, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = dataPriv.hasData(elem) && dataPriv.get(elem); 3523 if (!elemData || !(events = elemData.events)) { 3524 return; 3525 } 3526 types = (types || "").match(rnothtmlwhite) || [""]; 3527 t = types.length; 3528 while (t--) { 3529 tmp = rtypenamespace.exec(types[t]) || []; 3530 type = origType = tmp[1]; 3531 namespaces = (tmp[2] || "").split(".").sort(); 3532 if (!type) { 3533 for (type in events) { 3534 jQuery2.event.remove(elem, type + types[t], handler, selector, true); 3535 } 3536 continue; 3537 } 3538 special = jQuery2.event.special[type] || {}; 3539 type = (selector ? special.delegateType : special.bindType) || type; 3540 handlers = events[type] || []; 3541 tmp = tmp[2] && new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)"); 3542 origCount = j = handlers.length; 3543 while (j--) { 3544 handleObj = handlers[j]; 3545 if ((mappedTypes || origType === handleObj.origType) && (!handler || handler.guid === handleObj.guid) && (!tmp || tmp.test(handleObj.namespace)) && (!selector || selector === handleObj.selector || selector === "**" && handleObj.selector)) { 3546 handlers.splice(j, 1); 3547 if (handleObj.selector) { 3548 handlers.delegateCount--; 3549 } 3550 if (special.remove) { 3551 special.remove.call(elem, handleObj); 3552 } 3553 } 3554 } 3555 if (origCount && !handlers.length) { 3556 if (!special.teardown || special.teardown.call(elem, namespaces, elemData.handle) === false) { 3557 jQuery2.removeEvent(elem, type, elemData.handle); 3558 } 3559 delete events[type]; 3560 } 3561 } 3562 if (jQuery2.isEmptyObject(events)) { 3563 dataPriv.remove(elem, "handle events"); 3564 } 3565 }, 3566 dispatch: function(nativeEvent) { 3567 var i, j, ret, matched, handleObj, handlerQueue, args = new Array(arguments.length), event = jQuery2.event.fix(nativeEvent), handlers = (dataPriv.get(this, "events") || /* @__PURE__ */ Object.create(null))[event.type] || [], special = jQuery2.event.special[event.type] || {}; 3568 args[0] = event; 3569 for (i = 1; i < arguments.length; i++) { 3570 args[i] = arguments[i]; 3571 } 3572 event.delegateTarget = this; 3573 if (special.preDispatch && special.preDispatch.call(this, event) === false) { 3574 return; 3575 } 3576 handlerQueue = jQuery2.event.handlers.call(this, event, handlers); 3577 i = 0; 3578 while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) { 3579 event.currentTarget = matched.elem; 3580 j = 0; 3581 while ((handleObj = matched.handlers[j++]) && !event.isImmediatePropagationStopped()) { 3582 if (!event.rnamespace || handleObj.namespace === false || event.rnamespace.test(handleObj.namespace)) { 3583 event.handleObj = handleObj; 3584 event.data = handleObj.data; 3585 ret = ((jQuery2.event.special[handleObj.origType] || {}).handle || handleObj.handler).apply(matched.elem, args); 3586 if (ret !== void 0) { 3587 if ((event.result = ret) === false) { 3588 event.preventDefault(); 3589 event.stopPropagation(); 3590 } 3591 } 3592 } 3593 } 3594 } 3595 if (special.postDispatch) { 3596 special.postDispatch.call(this, event); 3597 } 3598 return event.result; 3599 }, 3600 handlers: function(event, handlers) { 3601 var i, handleObj, sel, matchedHandlers, matchedSelectors, handlerQueue = [], delegateCount = handlers.delegateCount, cur = event.target; 3602 if (delegateCount && // Support: IE <=9 3603 // Black-hole SVG <use> instance trees (trac-13180) 3604 cur.nodeType && // Support: Firefox <=42 3605 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) 3606 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click 3607 // Support: IE 11 only 3608 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) 3609 !(event.type === "click" && event.button >= 1)) { 3610 for (; cur !== this; cur = cur.parentNode || this) { 3611 if (cur.nodeType === 1 && !(event.type === "click" && cur.disabled === true)) { 3612 matchedHandlers = []; 3613 matchedSelectors = {}; 3614 for (i = 0; i < delegateCount; i++) { 3615 handleObj = handlers[i]; 3616 sel = handleObj.selector + " "; 3617 if (matchedSelectors[sel] === void 0) { 3618 matchedSelectors[sel] = handleObj.needsContext ? jQuery2(sel, this).index(cur) > -1 : jQuery2.find(sel, this, null, [cur]).length; 3619 } 3620 if (matchedSelectors[sel]) { 3621 matchedHandlers.push(handleObj); 3622 } 3623 } 3624 if (matchedHandlers.length) { 3625 handlerQueue.push({ elem: cur, handlers: matchedHandlers }); 3626 } 3627 } 3628 } 3629 } 3630 cur = this; 3631 if (delegateCount < handlers.length) { 3632 handlerQueue.push({ elem: cur, handlers: handlers.slice(delegateCount) }); 3633 } 3634 return handlerQueue; 3635 }, 3636 addProp: function(name, hook) { 3637 Object.defineProperty(jQuery2.Event.prototype, name, { 3638 enumerable: true, 3639 configurable: true, 3640 get: isFunction(hook) ? function() { 3641 if (this.originalEvent) { 3642 return hook(this.originalEvent); 3643 } 3644 } : function() { 3645 if (this.originalEvent) { 3646 return this.originalEvent[name]; 3647 } 3648 }, 3649 set: function(value) { 3650 Object.defineProperty(this, name, { 3651 enumerable: true, 3652 configurable: true, 3653 writable: true, 3654 value 3655 }); 3656 } 3657 }); 3658 }, 3659 fix: function(originalEvent) { 3660 return originalEvent[jQuery2.expando] ? originalEvent : new jQuery2.Event(originalEvent); 3661 }, 3662 special: { 3663 load: { 3664 // Prevent triggered image.load events from bubbling to window.load 3665 noBubble: true 3666 }, 3667 click: { 3668 // Utilize native event to ensure correct state for checkable inputs 3669 setup: function(data) { 3670 var el = this || data; 3671 if (rcheckableType.test(el.type) && el.click && nodeName(el, "input")) { 3672 leverageNative(el, "click", true); 3673 } 3674 return false; 3675 }, 3676 trigger: function(data) { 3677 var el = this || data; 3678 if (rcheckableType.test(el.type) && el.click && nodeName(el, "input")) { 3679 leverageNative(el, "click"); 3680 } 3681 return true; 3682 }, 3683 // For cross-browser consistency, suppress native .click() on links 3684 // Also prevent it if we're currently inside a leveraged native-event stack 3685 _default: function(event) { 3686 var target = event.target; 3687 return rcheckableType.test(target.type) && target.click && nodeName(target, "input") && dataPriv.get(target, "click") || nodeName(target, "a"); 3688 } 3689 }, 3690 beforeunload: { 3691 postDispatch: function(event) { 3692 if (event.result !== void 0 && event.originalEvent) { 3693 event.originalEvent.returnValue = event.result; 3694 } 3695 } 3696 } 3697 } 3698 }; 3699 function leverageNative(el, type, isSetup) { 3700 if (!isSetup) { 3701 if (dataPriv.get(el, type) === void 0) { 3702 jQuery2.event.add(el, type, returnTrue); 3703 } 3704 return; 3705 } 3706 dataPriv.set(el, type, false); 3707 jQuery2.event.add(el, type, { 3708 namespace: false, 3709 handler: function(event) { 3710 var result, saved = dataPriv.get(this, type); 3711 if (event.isTrigger & 1 && this[type]) { 3712 if (!saved) { 3713 saved = slice.call(arguments); 3714 dataPriv.set(this, type, saved); 3715 this[type](); 3716 result = dataPriv.get(this, type); 3717 dataPriv.set(this, type, false); 3718 if (saved !== result) { 3719 event.stopImmediatePropagation(); 3720 event.preventDefault(); 3721 return result; 3722 } 3723 } else if ((jQuery2.event.special[type] || {}).delegateType) { 3724 event.stopPropagation(); 3725 } 3726 } else if (saved) { 3727 dataPriv.set(this, type, jQuery2.event.trigger( 3728 saved[0], 3729 saved.slice(1), 3730 this 3731 )); 3732 event.stopPropagation(); 3733 event.isImmediatePropagationStopped = returnTrue; 3734 } 3735 } 3736 }); 3737 } 3738 jQuery2.removeEvent = function(elem, type, handle) { 3739 if (elem.removeEventListener) { 3740 elem.removeEventListener(type, handle); 3741 } 3742 }; 3743 jQuery2.Event = function(src, props) { 3744 if (!(this instanceof jQuery2.Event)) { 3745 return new jQuery2.Event(src, props); 3746 } 3747 if (src && src.type) { 3748 this.originalEvent = src; 3749 this.type = src.type; 3750 this.isDefaultPrevented = src.defaultPrevented || src.defaultPrevented === void 0 && // Support: Android <=2.3 only 3751 src.returnValue === false ? returnTrue : returnFalse; 3752 this.target = src.target && src.target.nodeType === 3 ? src.target.parentNode : src.target; 3753 this.currentTarget = src.currentTarget; 3754 this.relatedTarget = src.relatedTarget; 3755 } else { 3756 this.type = src; 3757 } 3758 if (props) { 3759 jQuery2.extend(this, props); 3760 } 3761 this.timeStamp = src && src.timeStamp || Date.now(); 3762 this[jQuery2.expando] = true; 3763 }; 3764 jQuery2.Event.prototype = { 3765 constructor: jQuery2.Event, 3766 isDefaultPrevented: returnFalse, 3767 isPropagationStopped: returnFalse, 3768 isImmediatePropagationStopped: returnFalse, 3769 isSimulated: false, 3770 preventDefault: function() { 3771 var e = this.originalEvent; 3772 this.isDefaultPrevented = returnTrue; 3773 if (e && !this.isSimulated) { 3774 e.preventDefault(); 3775 } 3776 }, 3777 stopPropagation: function() { 3778 var e = this.originalEvent; 3779 this.isPropagationStopped = returnTrue; 3780 if (e && !this.isSimulated) { 3781 e.stopPropagation(); 3782 } 3783 }, 3784 stopImmediatePropagation: function() { 3785 var e = this.originalEvent; 3786 this.isImmediatePropagationStopped = returnTrue; 3787 if (e && !this.isSimulated) { 3788 e.stopImmediatePropagation(); 3789 } 3790 this.stopPropagation(); 3791 } 3792 }; 3793 jQuery2.each({ 3794 altKey: true, 3795 bubbles: true, 3796 cancelable: true, 3797 changedTouches: true, 3798 ctrlKey: true, 3799 detail: true, 3800 eventPhase: true, 3801 metaKey: true, 3802 pageX: true, 3803 pageY: true, 3804 shiftKey: true, 3805 view: true, 3806 "char": true, 3807 code: true, 3808 charCode: true, 3809 key: true, 3810 keyCode: true, 3811 button: true, 3812 buttons: true, 3813 clientX: true, 3814 clientY: true, 3815 offsetX: true, 3816 offsetY: true, 3817 pointerId: true, 3818 pointerType: true, 3819 screenX: true, 3820 screenY: true, 3821 targetTouches: true, 3822 toElement: true, 3823 touches: true, 3824 which: true 3825 }, jQuery2.event.addProp); 3826 jQuery2.each({ focus: "focusin", blur: "focusout" }, function(type, delegateType) { 3827 function focusMappedHandler(nativeEvent) { 3828 if (document2.documentMode) { 3829 var handle = dataPriv.get(this, "handle"), event = jQuery2.event.fix(nativeEvent); 3830 event.type = nativeEvent.type === "focusin" ? "focus" : "blur"; 3831 event.isSimulated = true; 3832 handle(nativeEvent); 3833 if (event.target === event.currentTarget) { 3834 handle(event); 3835 } 3836 } else { 3837 jQuery2.event.simulate( 3838 delegateType, 3839 nativeEvent.target, 3840 jQuery2.event.fix(nativeEvent) 3841 ); 3842 } 3843 } 3844 jQuery2.event.special[type] = { 3845 // Utilize native event if possible so blur/focus sequence is correct 3846 setup: function() { 3847 var attaches; 3848 leverageNative(this, type, true); 3849 if (document2.documentMode) { 3850 attaches = dataPriv.get(this, delegateType); 3851 if (!attaches) { 3852 this.addEventListener(delegateType, focusMappedHandler); 3853 } 3854 dataPriv.set(this, delegateType, (attaches || 0) + 1); 3855 } else { 3856 return false; 3857 } 3858 }, 3859 trigger: function() { 3860 leverageNative(this, type); 3861 return true; 3862 }, 3863 teardown: function() { 3864 var attaches; 3865 if (document2.documentMode) { 3866 attaches = dataPriv.get(this, delegateType) - 1; 3867 if (!attaches) { 3868 this.removeEventListener(delegateType, focusMappedHandler); 3869 dataPriv.remove(this, delegateType); 3870 } else { 3871 dataPriv.set(this, delegateType, attaches); 3872 } 3873 } else { 3874 return false; 3875 } 3876 }, 3877 // Suppress native focus or blur if we're currently inside 3878 // a leveraged native-event stack 3879 _default: function(event) { 3880 return dataPriv.get(event.target, type); 3881 }, 3882 delegateType 3883 }; 3884 jQuery2.event.special[delegateType] = { 3885 setup: function() { 3886 var doc = this.ownerDocument || this.document || this, dataHolder = document2.documentMode ? this : doc, attaches = dataPriv.get(dataHolder, delegateType); 3887 if (!attaches) { 3888 if (document2.documentMode) { 3889 this.addEventListener(delegateType, focusMappedHandler); 3890 } else { 3891 doc.addEventListener(type, focusMappedHandler, true); 3892 } 3893 } 3894 dataPriv.set(dataHolder, delegateType, (attaches || 0) + 1); 3895 }, 3896 teardown: function() { 3897 var doc = this.ownerDocument || this.document || this, dataHolder = document2.documentMode ? this : doc, attaches = dataPriv.get(dataHolder, delegateType) - 1; 3898 if (!attaches) { 3899 if (document2.documentMode) { 3900 this.removeEventListener(delegateType, focusMappedHandler); 3901 } else { 3902 doc.removeEventListener(type, focusMappedHandler, true); 3903 } 3904 dataPriv.remove(dataHolder, delegateType); 3905 } else { 3906 dataPriv.set(dataHolder, delegateType, attaches); 3907 } 3908 } 3909 }; 3910 }); 3911 jQuery2.each({ 3912 mouseenter: "mouseover", 3913 mouseleave: "mouseout", 3914 pointerenter: "pointerover", 3915 pointerleave: "pointerout" 3916 }, function(orig, fix) { 3917 jQuery2.event.special[orig] = { 3918 delegateType: fix, 3919 bindType: fix, 3920 handle: function(event) { 3921 var ret, target = this, related = event.relatedTarget, handleObj = event.handleObj; 3922 if (!related || related !== target && !jQuery2.contains(target, related)) { 3923 event.type = handleObj.origType; 3924 ret = handleObj.handler.apply(this, arguments); 3925 event.type = fix; 3926 } 3927 return ret; 3928 } 3929 }; 3930 }); 3931 jQuery2.fn.extend({ 3932 on: function(types, selector, data, fn) { 3933 return on(this, types, selector, data, fn); 3934 }, 3935 one: function(types, selector, data, fn) { 3936 return on(this, types, selector, data, fn, 1); 3937 }, 3938 off: function(types, selector, fn) { 3939 var handleObj, type; 3940 if (types && types.preventDefault && types.handleObj) { 3941 handleObj = types.handleObj; 3942 jQuery2(types.delegateTarget).off( 3943 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, 3944 handleObj.selector, 3945 handleObj.handler 3946 ); 3947 return this; 3948 } 3949 if (typeof types === "object") { 3950 for (type in types) { 3951 this.off(type, selector, types[type]); 3952 } 3953 return this; 3954 } 3955 if (selector === false || typeof selector === "function") { 3956 fn = selector; 3957 selector = void 0; 3958 } 3959 if (fn === false) { 3960 fn = returnFalse; 3961 } 3962 return this.each(function() { 3963 jQuery2.event.remove(this, types, fn, selector); 3964 }); 3965 } 3966 }); 3967 var rnoInnerhtml = /<script|<style|<link/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rcleanScript = /^\s*<!\[CDATA\[|\]\]>\s*$/g; 3968 function manipulationTarget(elem, content) { 3969 if (nodeName(elem, "table") && nodeName(content.nodeType !== 11 ? content : content.firstChild, "tr")) { 3970 return jQuery2(elem).children("tbody")[0] || elem; 3971 } 3972 return elem; 3973 } 3974 function disableScript(elem) { 3975 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; 3976 return elem; 3977 } 3978 function restoreScript(elem) { 3979 if ((elem.type || "").slice(0, 5) === "true/") { 3980 elem.type = elem.type.slice(5); 3981 } else { 3982 elem.removeAttribute("type"); 3983 } 3984 return elem; 3985 } 3986 function cloneCopyEvent(src, dest) { 3987 var i, l, type, pdataOld, udataOld, udataCur, events; 3988 if (dest.nodeType !== 1) { 3989 return; 3990 } 3991 if (dataPriv.hasData(src)) { 3992 pdataOld = dataPriv.get(src); 3993 events = pdataOld.events; 3994 if (events) { 3995 dataPriv.remove(dest, "handle events"); 3996 for (type in events) { 3997 for (i = 0, l = events[type].length; i < l; i++) { 3998 jQuery2.event.add(dest, type, events[type][i]); 3999 } 4000 } 4001 } 4002 } 4003 if (dataUser.hasData(src)) { 4004 udataOld = dataUser.access(src); 4005 udataCur = jQuery2.extend({}, udataOld); 4006 dataUser.set(dest, udataCur); 4007 } 4008 } 4009 function fixInput(src, dest) { 4010 var nodeName2 = dest.nodeName.toLowerCase(); 4011 if (nodeName2 === "input" && rcheckableType.test(src.type)) { 4012 dest.checked = src.checked; 4013 } else if (nodeName2 === "input" || nodeName2 === "textarea") { 4014 dest.defaultValue = src.defaultValue; 4015 } 4016 } 4017 function domManip(collection, args, callback, ignored) { 4018 args = flat(args); 4019 var fragment, first, scripts, hasScripts, node, doc, i = 0, l = collection.length, iNoClone = l - 1, value = args[0], valueIsFunction = isFunction(value); 4020 if (valueIsFunction || l > 1 && typeof value === "string" && !support.checkClone && rchecked.test(value)) { 4021 return collection.each(function(index) { 4022 var self2 = collection.eq(index); 4023 if (valueIsFunction) { 4024 args[0] = value.call(this, index, self2.html()); 4025 } 4026 domManip(self2, args, callback, ignored); 4027 }); 4028 } 4029 if (l) { 4030 fragment = buildFragment(args, collection[0].ownerDocument, false, collection, ignored); 4031 first = fragment.firstChild; 4032 if (fragment.childNodes.length === 1) { 4033 fragment = first; 4034 } 4035 if (first || ignored) { 4036 scripts = jQuery2.map(getAll(fragment, "script"), disableScript); 4037 hasScripts = scripts.length; 4038 for (; i < l; i++) { 4039 node = fragment; 4040 if (i !== iNoClone) { 4041 node = jQuery2.clone(node, true, true); 4042 if (hasScripts) { 4043 jQuery2.merge(scripts, getAll(node, "script")); 4044 } 4045 } 4046 callback.call(collection[i], node, i); 4047 } 4048 if (hasScripts) { 4049 doc = scripts[scripts.length - 1].ownerDocument; 4050 jQuery2.map(scripts, restoreScript); 4051 for (i = 0; i < hasScripts; i++) { 4052 node = scripts[i]; 4053 if (rscriptType.test(node.type || "") && !dataPriv.access(node, "globalEval") && jQuery2.contains(doc, node)) { 4054 if (node.src && (node.type || "").toLowerCase() !== "module") { 4055 if (jQuery2._evalUrl && !node.noModule) { 4056 jQuery2._evalUrl(node.src, { 4057 nonce: node.nonce || node.getAttribute("nonce") 4058 }, doc); 4059 } 4060 } else { 4061 DOMEval(node.textContent.replace(rcleanScript, ""), node, doc); 4062 } 4063 } 4064 } 4065 } 4066 } 4067 } 4068 return collection; 4069 } 4070 function remove(elem, selector, keepData) { 4071 var node, nodes = selector ? jQuery2.filter(selector, elem) : elem, i = 0; 4072 for (; (node = nodes[i]) != null; i++) { 4073 if (!keepData && node.nodeType === 1) { 4074 jQuery2.cleanData(getAll(node)); 4075 } 4076 if (node.parentNode) { 4077 if (keepData && isAttached(node)) { 4078 setGlobalEval(getAll(node, "script")); 4079 } 4080 node.parentNode.removeChild(node); 4081 } 4082 } 4083 return elem; 4084 } 4085 jQuery2.extend({ 4086 htmlPrefilter: function(html) { 4087 return html; 4088 }, 4089 clone: function(elem, dataAndEvents, deepDataAndEvents) { 4090 var i, l, srcElements, destElements, clone = elem.cloneNode(true), inPage = isAttached(elem); 4091 if (!support.noCloneChecked && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery2.isXMLDoc(elem)) { 4092 destElements = getAll(clone); 4093 srcElements = getAll(elem); 4094 for (i = 0, l = srcElements.length; i < l; i++) { 4095 fixInput(srcElements[i], destElements[i]); 4096 } 4097 } 4098 if (dataAndEvents) { 4099 if (deepDataAndEvents) { 4100 srcElements = srcElements || getAll(elem); 4101 destElements = destElements || getAll(clone); 4102 for (i = 0, l = srcElements.length; i < l; i++) { 4103 cloneCopyEvent(srcElements[i], destElements[i]); 4104 } 4105 } else { 4106 cloneCopyEvent(elem, clone); 4107 } 4108 } 4109 destElements = getAll(clone, "script"); 4110 if (destElements.length > 0) { 4111 setGlobalEval(destElements, !inPage && getAll(elem, "script")); 4112 } 4113 return clone; 4114 }, 4115 cleanData: function(elems) { 4116 var data, elem, type, special = jQuery2.event.special, i = 0; 4117 for (; (elem = elems[i]) !== void 0; i++) { 4118 if (acceptData(elem)) { 4119 if (data = elem[dataPriv.expando]) { 4120 if (data.events) { 4121 for (type in data.events) { 4122 if (special[type]) { 4123 jQuery2.event.remove(elem, type); 4124 } else { 4125 jQuery2.removeEvent(elem, type, data.handle); 4126 } 4127 } 4128 } 4129 elem[dataPriv.expando] = void 0; 4130 } 4131 if (elem[dataUser.expando]) { 4132 elem[dataUser.expando] = void 0; 4133 } 4134 } 4135 } 4136 } 4137 }); 4138 jQuery2.fn.extend({ 4139 detach: function(selector) { 4140 return remove(this, selector, true); 4141 }, 4142 remove: function(selector) { 4143 return remove(this, selector); 4144 }, 4145 text: function(value) { 4146 return access(this, function(value2) { 4147 return value2 === void 0 ? jQuery2.text(this) : this.empty().each(function() { 4148 if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { 4149 this.textContent = value2; 4150 } 4151 }); 4152 }, null, value, arguments.length); 4153 }, 4154 append: function() { 4155 return domManip(this, arguments, function(elem) { 4156 if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { 4157 var target = manipulationTarget(this, elem); 4158 target.appendChild(elem); 4159 } 4160 }); 4161 }, 4162 prepend: function() { 4163 return domManip(this, arguments, function(elem) { 4164 if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { 4165 var target = manipulationTarget(this, elem); 4166 target.insertBefore(elem, target.firstChild); 4167 } 4168 }); 4169 }, 4170 before: function() { 4171 return domManip(this, arguments, function(elem) { 4172 if (this.parentNode) { 4173 this.parentNode.insertBefore(elem, this); 4174 } 4175 }); 4176 }, 4177 after: function() { 4178 return domManip(this, arguments, function(elem) { 4179 if (this.parentNode) { 4180 this.parentNode.insertBefore(elem, this.nextSibling); 4181 } 4182 }); 4183 }, 4184 empty: function() { 4185 var elem, i = 0; 4186 for (; (elem = this[i]) != null; i++) { 4187 if (elem.nodeType === 1) { 4188 jQuery2.cleanData(getAll(elem, false)); 4189 elem.textContent = ""; 4190 } 4191 } 4192 return this; 4193 }, 4194 clone: function(dataAndEvents, deepDataAndEvents) { 4195 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 4196 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 4197 return this.map(function() { 4198 return jQuery2.clone(this, dataAndEvents, deepDataAndEvents); 4199 }); 4200 }, 4201 html: function(value) { 4202 return access(this, function(value2) { 4203 var elem = this[0] || {}, i = 0, l = this.length; 4204 if (value2 === void 0 && elem.nodeType === 1) { 4205 return elem.innerHTML; 4206 } 4207 if (typeof value2 === "string" && !rnoInnerhtml.test(value2) && !wrapMap[(rtagName.exec(value2) || ["", ""])[1].toLowerCase()]) { 4208 value2 = jQuery2.htmlPrefilter(value2); 4209 try { 4210 for (; i < l; i++) { 4211 elem = this[i] || {}; 4212 if (elem.nodeType === 1) { 4213 jQuery2.cleanData(getAll(elem, false)); 4214 elem.innerHTML = value2; 4215 } 4216 } 4217 elem = 0; 4218 } catch (e) { 4219 } 4220 } 4221 if (elem) { 4222 this.empty().append(value2); 4223 } 4224 }, null, value, arguments.length); 4225 }, 4226 replaceWith: function() { 4227 var ignored = []; 4228 return domManip(this, arguments, function(elem) { 4229 var parent = this.parentNode; 4230 if (jQuery2.inArray(this, ignored) < 0) { 4231 jQuery2.cleanData(getAll(this)); 4232 if (parent) { 4233 parent.replaceChild(elem, this); 4234 } 4235 } 4236 }, ignored); 4237 } 4238 }); 4239 jQuery2.each({ 4240 appendTo: "append", 4241 prependTo: "prepend", 4242 insertBefore: "before", 4243 insertAfter: "after", 4244 replaceAll: "replaceWith" 4245 }, function(name, original) { 4246 jQuery2.fn[name] = function(selector) { 4247 var elems, ret = [], insert = jQuery2(selector), last = insert.length - 1, i = 0; 4248 for (; i <= last; i++) { 4249 elems = i === last ? this : this.clone(true); 4250 jQuery2(insert[i])[original](elems); 4251 push.apply(ret, elems.get()); 4252 } 4253 return this.pushStack(ret); 4254 }; 4255 }); 4256 var rnumnonpx = new RegExp("^(" + pnum + ")(?!px)[a-z%]+$", "i"); 4257 var rcustomProp = /^--/; 4258 var getStyles = function(elem) { 4259 var view = elem.ownerDocument.defaultView; 4260 if (!view || !view.opener) { 4261 view = window2; 4262 } 4263 return view.getComputedStyle(elem); 4264 }; 4265 var swap = function(elem, options, callback) { 4266 var ret, name, old = {}; 4267 for (name in options) { 4268 old[name] = elem.style[name]; 4269 elem.style[name] = options[name]; 4270 } 4271 ret = callback.call(elem); 4272 for (name in options) { 4273 elem.style[name] = old[name]; 4274 } 4275 return ret; 4276 }; 4277 var rboxStyle = new RegExp(cssExpand.join("|"), "i"); 4278 (function() { 4279 function computeStyleTests() { 4280 if (!div) { 4281 return; 4282 } 4283 container.style.cssText = "position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0"; 4284 div.style.cssText = "position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%"; 4285 documentElement.appendChild(container).appendChild(div); 4286 var divStyle = window2.getComputedStyle(div); 4287 pixelPositionVal = divStyle.top !== "1%"; 4288 reliableMarginLeftVal = roundPixelMeasures(divStyle.marginLeft) === 12; 4289 div.style.right = "60%"; 4290 pixelBoxStylesVal = roundPixelMeasures(divStyle.right) === 36; 4291 boxSizingReliableVal = roundPixelMeasures(divStyle.width) === 36; 4292 div.style.position = "absolute"; 4293 scrollboxSizeVal = roundPixelMeasures(div.offsetWidth / 3) === 12; 4294 documentElement.removeChild(container); 4295 div = null; 4296 } 4297 function roundPixelMeasures(measure) { 4298 return Math.round(parseFloat(measure)); 4299 } 4300 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, reliableTrDimensionsVal, reliableMarginLeftVal, container = document2.createElement("div"), div = document2.createElement("div"); 4301 if (!div.style) { 4302 return; 4303 } 4304 div.style.backgroundClip = "content-box"; 4305 div.cloneNode(true).style.backgroundClip = ""; 4306 support.clearCloneStyle = div.style.backgroundClip === "content-box"; 4307 jQuery2.extend(support, { 4308 boxSizingReliable: function() { 4309 computeStyleTests(); 4310 return boxSizingReliableVal; 4311 }, 4312 pixelBoxStyles: function() { 4313 computeStyleTests(); 4314 return pixelBoxStylesVal; 4315 }, 4316 pixelPosition: function() { 4317 computeStyleTests(); 4318 return pixelPositionVal; 4319 }, 4320 reliableMarginLeft: function() { 4321 computeStyleTests(); 4322 return reliableMarginLeftVal; 4323 }, 4324 scrollboxSize: function() { 4325 computeStyleTests(); 4326 return scrollboxSizeVal; 4327 }, 4328 // Support: IE 9 - 11+, Edge 15 - 18+ 4329 // IE/Edge misreport `getComputedStyle` of table rows with width/height 4330 // set in CSS while `offset*` properties report correct values. 4331 // Behavior in IE 9 is more subtle than in newer versions & it passes 4332 // some versions of this test; make sure not to make it pass there! 4333 // 4334 // Support: Firefox 70+ 4335 // Only Firefox includes border widths 4336 // in computed dimensions. (gh-4529) 4337 reliableTrDimensions: function() { 4338 var table, tr, trChild, trStyle; 4339 if (reliableTrDimensionsVal == null) { 4340 table = document2.createElement("table"); 4341 tr = document2.createElement("tr"); 4342 trChild = document2.createElement("div"); 4343 table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; 4344 tr.style.cssText = "box-sizing:content-box;border:1px solid"; 4345 tr.style.height = "1px"; 4346 trChild.style.height = "9px"; 4347 trChild.style.display = "block"; 4348 documentElement.appendChild(table).appendChild(tr).appendChild(trChild); 4349 trStyle = window2.getComputedStyle(tr); 4350 reliableTrDimensionsVal = parseInt(trStyle.height, 10) + parseInt(trStyle.borderTopWidth, 10) + parseInt(trStyle.borderBottomWidth, 10) === tr.offsetHeight; 4351 documentElement.removeChild(table); 4352 } 4353 return reliableTrDimensionsVal; 4354 } 4355 }); 4356 })(); 4357 function curCSS(elem, name, computed) { 4358 var width, minWidth, maxWidth, ret, isCustomProp = rcustomProp.test(name), style = elem.style; 4359 computed = computed || getStyles(elem); 4360 if (computed) { 4361 ret = computed.getPropertyValue(name) || computed[name]; 4362 if (isCustomProp && ret) { 4363 ret = ret.replace(rtrimCSS, "$1") || void 0; 4364 } 4365 if (ret === "" && !isAttached(elem)) { 4366 ret = jQuery2.style(elem, name); 4367 } 4368 if (!support.pixelBoxStyles() && rnumnonpx.test(ret) && rboxStyle.test(name)) { 4369 width = style.width; 4370 minWidth = style.minWidth; 4371 maxWidth = style.maxWidth; 4372 style.minWidth = style.maxWidth = style.width = ret; 4373 ret = computed.width; 4374 style.width = width; 4375 style.minWidth = minWidth; 4376 style.maxWidth = maxWidth; 4377 } 4378 } 4379 return ret !== void 0 ? ( 4380 // Support: IE <=9 - 11 only 4381 // IE returns zIndex value as an integer. 4382 ret + "" 4383 ) : ret; 4384 } 4385 function addGetHookIf(conditionFn, hookFn) { 4386 return { 4387 get: function() { 4388 if (conditionFn()) { 4389 delete this.get; 4390 return; 4391 } 4392 return (this.get = hookFn).apply(this, arguments); 4393 } 4394 }; 4395 } 4396 var cssPrefixes = ["Webkit", "Moz", "ms"], emptyStyle = document2.createElement("div").style, vendorProps = {}; 4397 function vendorPropName(name) { 4398 var capName = name[0].toUpperCase() + name.slice(1), i = cssPrefixes.length; 4399 while (i--) { 4400 name = cssPrefixes[i] + capName; 4401 if (name in emptyStyle) { 4402 return name; 4403 } 4404 } 4405 } 4406 function finalPropName(name) { 4407 var final = jQuery2.cssProps[name] || vendorProps[name]; 4408 if (final) { 4409 return final; 4410 } 4411 if (name in emptyStyle) { 4412 return name; 4413 } 4414 return vendorProps[name] = vendorPropName(name) || name; 4415 } 4416 var rdisplayswap = /^(none|table(?!-c[ea]).+)/, cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssNormalTransform = { 4417 letterSpacing: "0", 4418 fontWeight: "400" 4419 }; 4420 function setPositiveNumber(_elem, value, subtract) { 4421 var matches2 = rcssNum.exec(value); 4422 return matches2 ? ( 4423 // Guard against undefined "subtract", e.g., when used as in cssHooks 4424 Math.max(0, matches2[2] - (subtract || 0)) + (matches2[3] || "px") 4425 ) : value; 4426 } 4427 function boxModelAdjustment(elem, dimension, box, isBorderBox, styles, computedVal) { 4428 var i = dimension === "width" ? 1 : 0, extra = 0, delta = 0, marginDelta = 0; 4429 if (box === (isBorderBox ? "border" : "content")) { 4430 return 0; 4431 } 4432 for (; i < 4; i += 2) { 4433 if (box === "margin") { 4434 marginDelta += jQuery2.css(elem, box + cssExpand[i], true, styles); 4435 } 4436 if (!isBorderBox) { 4437 delta += jQuery2.css(elem, "padding" + cssExpand[i], true, styles); 4438 if (box !== "padding") { 4439 delta += jQuery2.css(elem, "border" + cssExpand[i] + "Width", true, styles); 4440 } else { 4441 extra += jQuery2.css(elem, "border" + cssExpand[i] + "Width", true, styles); 4442 } 4443 } else { 4444 if (box === "content") { 4445 delta -= jQuery2.css(elem, "padding" + cssExpand[i], true, styles); 4446 } 4447 if (box !== "margin") { 4448 delta -= jQuery2.css(elem, "border" + cssExpand[i] + "Width", true, styles); 4449 } 4450 } 4451 } 4452 if (!isBorderBox && computedVal >= 0) { 4453 delta += Math.max(0, Math.ceil( 4454 elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)] - computedVal - delta - extra - 0.5 4455 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter 4456 // Use an explicit zero to avoid NaN (gh-3964) 4457 )) || 0; 4458 } 4459 return delta + marginDelta; 4460 } 4461 function getWidthOrHeight(elem, dimension, extra) { 4462 var styles = getStyles(elem), boxSizingNeeded = !support.boxSizingReliable() || extra, isBorderBox = boxSizingNeeded && jQuery2.css(elem, "boxSizing", false, styles) === "border-box", valueIsBorderBox = isBorderBox, val = curCSS(elem, dimension, styles), offsetProp = "offset" + dimension[0].toUpperCase() + dimension.slice(1); 4463 if (rnumnonpx.test(val)) { 4464 if (!extra) { 4465 return val; 4466 } 4467 val = "auto"; 4468 } 4469 if ((!support.boxSizingReliable() && isBorderBox || // Support: IE 10 - 11+, Edge 15 - 18+ 4470 // IE/Edge misreport `getComputedStyle` of table rows with width/height 4471 // set in CSS while `offset*` properties report correct values. 4472 // Interestingly, in some cases IE 9 doesn't suffer from this issue. 4473 !support.reliableTrDimensions() && nodeName(elem, "tr") || // Fall back to offsetWidth/offsetHeight when value is "auto" 4474 // This happens for inline elements with no explicit setting (gh-3571) 4475 val === "auto" || // Support: Android <=4.1 - 4.3 only 4476 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) 4477 !parseFloat(val) && jQuery2.css(elem, "display", false, styles) === "inline") && // Make sure the element is visible & connected 4478 elem.getClientRects().length) { 4479 isBorderBox = jQuery2.css(elem, "boxSizing", false, styles) === "border-box"; 4480 valueIsBorderBox = offsetProp in elem; 4481 if (valueIsBorderBox) { 4482 val = elem[offsetProp]; 4483 } 4484 } 4485 val = parseFloat(val) || 0; 4486 return val + boxModelAdjustment( 4487 elem, 4488 dimension, 4489 extra || (isBorderBox ? "border" : "content"), 4490 valueIsBorderBox, 4491 styles, 4492 // Provide the current computed size to request scroll gutter calculation (gh-3589) 4493 val 4494 ) + "px"; 4495 } 4496 jQuery2.extend({ 4497 // Add in style property hooks for overriding the default 4498 // behavior of getting and setting a style property 4499 cssHooks: { 4500 opacity: { 4501 get: function(elem, computed) { 4502 if (computed) { 4503 var ret = curCSS(elem, "opacity"); 4504 return ret === "" ? "1" : ret; 4505 } 4506 } 4507 } 4508 }, 4509 // Don't automatically add "px" to these possibly-unitless properties 4510 cssNumber: { 4511 animationIterationCount: true, 4512 aspectRatio: true, 4513 borderImageSlice: true, 4514 columnCount: true, 4515 flexGrow: true, 4516 flexShrink: true, 4517 fontWeight: true, 4518 gridArea: true, 4519 gridColumn: true, 4520 gridColumnEnd: true, 4521 gridColumnStart: true, 4522 gridRow: true, 4523 gridRowEnd: true, 4524 gridRowStart: true, 4525 lineHeight: true, 4526 opacity: true, 4527 order: true, 4528 orphans: true, 4529 scale: true, 4530 widows: true, 4531 zIndex: true, 4532 zoom: true, 4533 // SVG-related 4534 fillOpacity: true, 4535 floodOpacity: true, 4536 stopOpacity: true, 4537 strokeMiterlimit: true, 4538 strokeOpacity: true 4539 }, 4540 // Add in properties whose names you wish to fix before 4541 // setting or getting the value 4542 cssProps: {}, 4543 // Get and set the style property on a DOM Node 4544 style: function(elem, name, value, extra) { 4545 if (!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style) { 4546 return; 4547 } 4548 var ret, type, hooks, origName = camelCase(name), isCustomProp = rcustomProp.test(name), style = elem.style; 4549 if (!isCustomProp) { 4550 name = finalPropName(origName); 4551 } 4552 hooks = jQuery2.cssHooks[name] || jQuery2.cssHooks[origName]; 4553 if (value !== void 0) { 4554 type = typeof value; 4555 if (type === "string" && (ret = rcssNum.exec(value)) && ret[1]) { 4556 value = adjustCSS(elem, name, ret); 4557 type = "number"; 4558 } 4559 if (value == null || value !== value) { 4560 return; 4561 } 4562 if (type === "number" && !isCustomProp) { 4563 value += ret && ret[3] || (jQuery2.cssNumber[origName] ? "" : "px"); 4564 } 4565 if (!support.clearCloneStyle && value === "" && name.indexOf("background") === 0) { 4566 style[name] = "inherit"; 4567 } 4568 if (!hooks || !("set" in hooks) || (value = hooks.set(elem, value, extra)) !== void 0) { 4569 if (isCustomProp) { 4570 style.setProperty(name, value); 4571 } else { 4572 style[name] = value; 4573 } 4574 } 4575 } else { 4576 if (hooks && "get" in hooks && (ret = hooks.get(elem, false, extra)) !== void 0) { 4577 return ret; 4578 } 4579 return style[name]; 4580 } 4581 }, 4582 css: function(elem, name, extra, styles) { 4583 var val, num, hooks, origName = camelCase(name), isCustomProp = rcustomProp.test(name); 4584 if (!isCustomProp) { 4585 name = finalPropName(origName); 4586 } 4587 hooks = jQuery2.cssHooks[name] || jQuery2.cssHooks[origName]; 4588 if (hooks && "get" in hooks) { 4589 val = hooks.get(elem, true, extra); 4590 } 4591 if (val === void 0) { 4592 val = curCSS(elem, name, styles); 4593 } 4594 if (val === "normal" && name in cssNormalTransform) { 4595 val = cssNormalTransform[name]; 4596 } 4597 if (extra === "" || extra) { 4598 num = parseFloat(val); 4599 return extra === true || isFinite(num) ? num || 0 : val; 4600 } 4601 return val; 4602 } 4603 }); 4604 jQuery2.each(["height", "width"], function(_i, dimension) { 4605 jQuery2.cssHooks[dimension] = { 4606 get: function(elem, computed, extra) { 4607 if (computed) { 4608 return rdisplayswap.test(jQuery2.css(elem, "display")) && // Support: Safari 8+ 4609 // Table columns in Safari have non-zero offsetWidth & zero 4610 // getBoundingClientRect().width unless display is changed. 4611 // Support: IE <=11 only 4612 // Running getBoundingClientRect on a disconnected node 4613 // in IE throws an error. 4614 (!elem.getClientRects().length || !elem.getBoundingClientRect().width) ? swap(elem, cssShow, function() { 4615 return getWidthOrHeight(elem, dimension, extra); 4616 }) : getWidthOrHeight(elem, dimension, extra); 4617 } 4618 }, 4619 set: function(elem, value, extra) { 4620 var matches2, styles = getStyles(elem), scrollboxSizeBuggy = !support.scrollboxSize() && styles.position === "absolute", boxSizingNeeded = scrollboxSizeBuggy || extra, isBorderBox = boxSizingNeeded && jQuery2.css(elem, "boxSizing", false, styles) === "border-box", subtract = extra ? boxModelAdjustment( 4621 elem, 4622 dimension, 4623 extra, 4624 isBorderBox, 4625 styles 4626 ) : 0; 4627 if (isBorderBox && scrollboxSizeBuggy) { 4628 subtract -= Math.ceil( 4629 elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)] - parseFloat(styles[dimension]) - boxModelAdjustment(elem, dimension, "border", false, styles) - 0.5 4630 ); 4631 } 4632 if (subtract && (matches2 = rcssNum.exec(value)) && (matches2[3] || "px") !== "px") { 4633 elem.style[dimension] = value; 4634 value = jQuery2.css(elem, dimension); 4635 } 4636 return setPositiveNumber(elem, value, subtract); 4637 } 4638 }; 4639 }); 4640 jQuery2.cssHooks.marginLeft = addGetHookIf( 4641 support.reliableMarginLeft, 4642 function(elem, computed) { 4643 if (computed) { 4644 return (parseFloat(curCSS(elem, "marginLeft")) || elem.getBoundingClientRect().left - swap(elem, { marginLeft: 0 }, function() { 4645 return elem.getBoundingClientRect().left; 4646 })) + "px"; 4647 } 4648 } 4649 ); 4650 jQuery2.each({ 4651 margin: "", 4652 padding: "", 4653 border: "Width" 4654 }, function(prefix, suffix) { 4655 jQuery2.cssHooks[prefix + suffix] = { 4656 expand: function(value) { 4657 var i = 0, expanded = {}, parts = typeof value === "string" ? value.split(" ") : [value]; 4658 for (; i < 4; i++) { 4659 expanded[prefix + cssExpand[i] + suffix] = parts[i] || parts[i - 2] || parts[0]; 4660 } 4661 return expanded; 4662 } 4663 }; 4664 if (prefix !== "margin") { 4665 jQuery2.cssHooks[prefix + suffix].set = setPositiveNumber; 4666 } 4667 }); 4668 jQuery2.fn.extend({ 4669 css: function(name, value) { 4670 return access(this, function(elem, name2, value2) { 4671 var styles, len, map = {}, i = 0; 4672 if (Array.isArray(name2)) { 4673 styles = getStyles(elem); 4674 len = name2.length; 4675 for (; i < len; i++) { 4676 map[name2[i]] = jQuery2.css(elem, name2[i], false, styles); 4677 } 4678 return map; 4679 } 4680 return value2 !== void 0 ? jQuery2.style(elem, name2, value2) : jQuery2.css(elem, name2); 4681 }, name, value, arguments.length > 1); 4682 } 4683 }); 4684 function Tween(elem, options, prop, end, easing) { 4685 return new Tween.prototype.init(elem, options, prop, end, easing); 4686 } 4687 jQuery2.Tween = Tween; 4688 Tween.prototype = { 4689 constructor: Tween, 4690 init: function(elem, options, prop, end, easing, unit) { 4691 this.elem = elem; 4692 this.prop = prop; 4693 this.easing = easing || jQuery2.easing._default; 4694 this.options = options; 4695 this.start = this.now = this.cur(); 4696 this.end = end; 4697 this.unit = unit || (jQuery2.cssNumber[prop] ? "" : "px"); 4698 }, 4699 cur: function() { 4700 var hooks = Tween.propHooks[this.prop]; 4701 return hooks && hooks.get ? hooks.get(this) : Tween.propHooks._default.get(this); 4702 }, 4703 run: function(percent) { 4704 var eased, hooks = Tween.propHooks[this.prop]; 4705 if (this.options.duration) { 4706 this.pos = eased = jQuery2.easing[this.easing]( 4707 percent, 4708 this.options.duration * percent, 4709 0, 4710 1, 4711 this.options.duration 4712 ); 4713 } else { 4714 this.pos = eased = percent; 4715 } 4716 this.now = (this.end - this.start) * eased + this.start; 4717 if (this.options.step) { 4718 this.options.step.call(this.elem, this.now, this); 4719 } 4720 if (hooks && hooks.set) { 4721 hooks.set(this); 4722 } else { 4723 Tween.propHooks._default.set(this); 4724 } 4725 return this; 4726 } 4727 }; 4728 Tween.prototype.init.prototype = Tween.prototype; 4729 Tween.propHooks = { 4730 _default: { 4731 get: function(tween) { 4732 var result; 4733 if (tween.elem.nodeType !== 1 || tween.elem[tween.prop] != null && tween.elem.style[tween.prop] == null) { 4734 return tween.elem[tween.prop]; 4735 } 4736 result = jQuery2.css(tween.elem, tween.prop, ""); 4737 return !result || result === "auto" ? 0 : result; 4738 }, 4739 set: function(tween) { 4740 if (jQuery2.fx.step[tween.prop]) { 4741 jQuery2.fx.step[tween.prop](tween); 4742 } else if (tween.elem.nodeType === 1 && (jQuery2.cssHooks[tween.prop] || tween.elem.style[finalPropName(tween.prop)] != null)) { 4743 jQuery2.style(tween.elem, tween.prop, tween.now + tween.unit); 4744 } else { 4745 tween.elem[tween.prop] = tween.now; 4746 } 4747 } 4748 } 4749 }; 4750 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 4751 set: function(tween) { 4752 if (tween.elem.nodeType && tween.elem.parentNode) { 4753 tween.elem[tween.prop] = tween.now; 4754 } 4755 } 4756 }; 4757 jQuery2.easing = { 4758 linear: function(p) { 4759 return p; 4760 }, 4761 swing: function(p) { 4762 return 0.5 - Math.cos(p * Math.PI) / 2; 4763 }, 4764 _default: "swing" 4765 }; 4766 jQuery2.fx = Tween.prototype.init; 4767 jQuery2.fx.step = {}; 4768 var fxNow, inProgress, rfxtypes = /^(?:toggle|show|hide)$/, rrun = /queueHooks$/; 4769 function schedule() { 4770 if (inProgress) { 4771 if (document2.hidden === false && window2.requestAnimationFrame) { 4772 window2.requestAnimationFrame(schedule); 4773 } else { 4774 window2.setTimeout(schedule, jQuery2.fx.interval); 4775 } 4776 jQuery2.fx.tick(); 4777 } 4778 } 4779 function createFxNow() { 4780 window2.setTimeout(function() { 4781 fxNow = void 0; 4782 }); 4783 return fxNow = Date.now(); 4784 } 4785 function genFx(type, includeWidth) { 4786 var which, i = 0, attrs = { height: type }; 4787 includeWidth = includeWidth ? 1 : 0; 4788 for (; i < 4; i += 2 - includeWidth) { 4789 which = cssExpand[i]; 4790 attrs["margin" + which] = attrs["padding" + which] = type; 4791 } 4792 if (includeWidth) { 4793 attrs.opacity = attrs.width = type; 4794 } 4795 return attrs; 4796 } 4797 function createTween(value, prop, animation) { 4798 var tween, collection = (Animation.tweeners[prop] || []).concat(Animation.tweeners["*"]), index = 0, length = collection.length; 4799 for (; index < length; index++) { 4800 if (tween = collection[index].call(animation, prop, value)) { 4801 return tween; 4802 } 4803 } 4804 } 4805 function defaultPrefilter(elem, props, opts) { 4806 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, isBox = "width" in props || "height" in props, anim = this, orig = {}, style = elem.style, hidden = elem.nodeType && isHiddenWithinTree(elem), dataShow = dataPriv.get(elem, "fxshow"); 4807 if (!opts.queue) { 4808 hooks = jQuery2._queueHooks(elem, "fx"); 4809 if (hooks.unqueued == null) { 4810 hooks.unqueued = 0; 4811 oldfire = hooks.empty.fire; 4812 hooks.empty.fire = function() { 4813 if (!hooks.unqueued) { 4814 oldfire(); 4815 } 4816 }; 4817 } 4818 hooks.unqueued++; 4819 anim.always(function() { 4820 anim.always(function() { 4821 hooks.unqueued--; 4822 if (!jQuery2.queue(elem, "fx").length) { 4823 hooks.empty.fire(); 4824 } 4825 }); 4826 }); 4827 } 4828 for (prop in props) { 4829 value = props[prop]; 4830 if (rfxtypes.test(value)) { 4831 delete props[prop]; 4832 toggle = toggle || value === "toggle"; 4833 if (value === (hidden ? "hide" : "show")) { 4834 if (value === "show" && dataShow && dataShow[prop] !== void 0) { 4835 hidden = true; 4836 } else { 4837 continue; 4838 } 4839 } 4840 orig[prop] = dataShow && dataShow[prop] || jQuery2.style(elem, prop); 4841 } 4842 } 4843 propTween = !jQuery2.isEmptyObject(props); 4844 if (!propTween && jQuery2.isEmptyObject(orig)) { 4845 return; 4846 } 4847 if (isBox && elem.nodeType === 1) { 4848 opts.overflow = [style.overflow, style.overflowX, style.overflowY]; 4849 restoreDisplay = dataShow && dataShow.display; 4850 if (restoreDisplay == null) { 4851 restoreDisplay = dataPriv.get(elem, "display"); 4852 } 4853 display = jQuery2.css(elem, "display"); 4854 if (display === "none") { 4855 if (restoreDisplay) { 4856 display = restoreDisplay; 4857 } else { 4858 showHide([elem], true); 4859 restoreDisplay = elem.style.display || restoreDisplay; 4860 display = jQuery2.css(elem, "display"); 4861 showHide([elem]); 4862 } 4863 } 4864 if (display === "inline" || display === "inline-block" && restoreDisplay != null) { 4865 if (jQuery2.css(elem, "float") === "none") { 4866 if (!propTween) { 4867 anim.done(function() { 4868 style.display = restoreDisplay; 4869 }); 4870 if (restoreDisplay == null) { 4871 display = style.display; 4872 restoreDisplay = display === "none" ? "" : display; 4873 } 4874 } 4875 style.display = "inline-block"; 4876 } 4877 } 4878 } 4879 if (opts.overflow) { 4880 style.overflow = "hidden"; 4881 anim.always(function() { 4882 style.overflow = opts.overflow[0]; 4883 style.overflowX = opts.overflow[1]; 4884 style.overflowY = opts.overflow[2]; 4885 }); 4886 } 4887 propTween = false; 4888 for (prop in orig) { 4889 if (!propTween) { 4890 if (dataShow) { 4891 if ("hidden" in dataShow) { 4892 hidden = dataShow.hidden; 4893 } 4894 } else { 4895 dataShow = dataPriv.access(elem, "fxshow", { display: restoreDisplay }); 4896 } 4897 if (toggle) { 4898 dataShow.hidden = !hidden; 4899 } 4900 if (hidden) { 4901 showHide([elem], true); 4902 } 4903 anim.done(function() { 4904 if (!hidden) { 4905 showHide([elem]); 4906 } 4907 dataPriv.remove(elem, "fxshow"); 4908 for (prop in orig) { 4909 jQuery2.style(elem, prop, orig[prop]); 4910 } 4911 }); 4912 } 4913 propTween = createTween(hidden ? dataShow[prop] : 0, prop, anim); 4914 if (!(prop in dataShow)) { 4915 dataShow[prop] = propTween.start; 4916 if (hidden) { 4917 propTween.end = propTween.start; 4918 propTween.start = 0; 4919 } 4920 } 4921 } 4922 } 4923 function propFilter(props, specialEasing) { 4924 var index, name, easing, value, hooks; 4925 for (index in props) { 4926 name = camelCase(index); 4927 easing = specialEasing[name]; 4928 value = props[index]; 4929 if (Array.isArray(value)) { 4930 easing = value[1]; 4931 value = props[index] = value[0]; 4932 } 4933 if (index !== name) { 4934 props[name] = value; 4935 delete props[index]; 4936 } 4937 hooks = jQuery2.cssHooks[name]; 4938 if (hooks && "expand" in hooks) { 4939 value = hooks.expand(value); 4940 delete props[name]; 4941 for (index in value) { 4942 if (!(index in props)) { 4943 props[index] = value[index]; 4944 specialEasing[index] = easing; 4945 } 4946 } 4947 } else { 4948 specialEasing[name] = easing; 4949 } 4950 } 4951 } 4952 function Animation(elem, properties, options) { 4953 var result, stopped, index = 0, length = Animation.prefilters.length, deferred = jQuery2.Deferred().always(function() { 4954 delete tick.elem; 4955 }), tick = function() { 4956 if (stopped) { 4957 return false; 4958 } 4959 var currentTime = fxNow || createFxNow(), remaining = Math.max(0, animation.startTime + animation.duration - currentTime), temp = remaining / animation.duration || 0, percent = 1 - temp, index2 = 0, length2 = animation.tweens.length; 4960 for (; index2 < length2; index2++) { 4961 animation.tweens[index2].run(percent); 4962 } 4963 deferred.notifyWith(elem, [animation, percent, remaining]); 4964 if (percent < 1 && length2) { 4965 return remaining; 4966 } 4967 if (!length2) { 4968 deferred.notifyWith(elem, [animation, 1, 0]); 4969 } 4970 deferred.resolveWith(elem, [animation]); 4971 return false; 4972 }, animation = deferred.promise({ 4973 elem, 4974 props: jQuery2.extend({}, properties), 4975 opts: jQuery2.extend(true, { 4976 specialEasing: {}, 4977 easing: jQuery2.easing._default 4978 }, options), 4979 originalProperties: properties, 4980 originalOptions: options, 4981 startTime: fxNow || createFxNow(), 4982 duration: options.duration, 4983 tweens: [], 4984 createTween: function(prop, end) { 4985 var tween = jQuery2.Tween( 4986 elem, 4987 animation.opts, 4988 prop, 4989 end, 4990 animation.opts.specialEasing[prop] || animation.opts.easing 4991 ); 4992 animation.tweens.push(tween); 4993 return tween; 4994 }, 4995 stop: function(gotoEnd) { 4996 var index2 = 0, length2 = gotoEnd ? animation.tweens.length : 0; 4997 if (stopped) { 4998 return this; 4999 } 5000 stopped = true; 5001 for (; index2 < length2; index2++) { 5002 animation.tweens[index2].run(1); 5003 } 5004 if (gotoEnd) { 5005 deferred.notifyWith(elem, [animation, 1, 0]); 5006 deferred.resolveWith(elem, [animation, gotoEnd]); 5007 } else { 5008 deferred.rejectWith(elem, [animation, gotoEnd]); 5009 } 5010 return this; 5011 } 5012 }), props = animation.props; 5013 propFilter(props, animation.opts.specialEasing); 5014 for (; index < length; index++) { 5015 result = Animation.prefilters[index].call(animation, elem, props, animation.opts); 5016 if (result) { 5017 if (isFunction(result.stop)) { 5018 jQuery2._queueHooks(animation.elem, animation.opts.queue).stop = result.stop.bind(result); 5019 } 5020 return result; 5021 } 5022 } 5023 jQuery2.map(props, createTween, animation); 5024 if (isFunction(animation.opts.start)) { 5025 animation.opts.start.call(elem, animation); 5026 } 5027 animation.progress(animation.opts.progress).done(animation.opts.done, animation.opts.complete).fail(animation.opts.fail).always(animation.opts.always); 5028 jQuery2.fx.timer( 5029 jQuery2.extend(tick, { 5030 elem, 5031 anim: animation, 5032 queue: animation.opts.queue 5033 }) 5034 ); 5035 return animation; 5036 } 5037 jQuery2.Animation = jQuery2.extend(Animation, { 5038 tweeners: { 5039 "*": [function(prop, value) { 5040 var tween = this.createTween(prop, value); 5041 adjustCSS(tween.elem, prop, rcssNum.exec(value), tween); 5042 return tween; 5043 }] 5044 }, 5045 tweener: function(props, callback) { 5046 if (isFunction(props)) { 5047 callback = props; 5048 props = ["*"]; 5049 } else { 5050 props = props.match(rnothtmlwhite); 5051 } 5052 var prop, index = 0, length = props.length; 5053 for (; index < length; index++) { 5054 prop = props[index]; 5055 Animation.tweeners[prop] = Animation.tweeners[prop] || []; 5056 Animation.tweeners[prop].unshift(callback); 5057 } 5058 }, 5059 prefilters: [defaultPrefilter], 5060 prefilter: function(callback, prepend) { 5061 if (prepend) { 5062 Animation.prefilters.unshift(callback); 5063 } else { 5064 Animation.prefilters.push(callback); 5065 } 5066 } 5067 }); 5068 jQuery2.speed = function(speed, easing, fn) { 5069 var opt = speed && typeof speed === "object" ? jQuery2.extend({}, speed) : { 5070 complete: fn || !fn && easing || isFunction(speed) && speed, 5071 duration: speed, 5072 easing: fn && easing || easing && !isFunction(easing) && easing 5073 }; 5074 if (jQuery2.fx.off) { 5075 opt.duration = 0; 5076 } else { 5077 if (typeof opt.duration !== "number") { 5078 if (opt.duration in jQuery2.fx.speeds) { 5079 opt.duration = jQuery2.fx.speeds[opt.duration]; 5080 } else { 5081 opt.duration = jQuery2.fx.speeds._default; 5082 } 5083 } 5084 } 5085 if (opt.queue == null || opt.queue === true) { 5086 opt.queue = "fx"; 5087 } 5088 opt.old = opt.complete; 5089 opt.complete = function() { 5090 if (isFunction(opt.old)) { 5091 opt.old.call(this); 5092 } 5093 if (opt.queue) { 5094 jQuery2.dequeue(this, opt.queue); 5095 } 5096 }; 5097 return opt; 5098 }; 5099 jQuery2.fn.extend({ 5100 fadeTo: function(speed, to, easing, callback) { 5101 return this.filter(isHiddenWithinTree).css("opacity", 0).show().end().animate({ opacity: to }, speed, easing, callback); 5102 }, 5103 animate: function(prop, speed, easing, callback) { 5104 var empty = jQuery2.isEmptyObject(prop), optall = jQuery2.speed(speed, easing, callback), doAnimation = function() { 5105 var anim = Animation(this, jQuery2.extend({}, prop), optall); 5106 if (empty || dataPriv.get(this, "finish")) { 5107 anim.stop(true); 5108 } 5109 }; 5110 doAnimation.finish = doAnimation; 5111 return empty || optall.queue === false ? this.each(doAnimation) : this.queue(optall.queue, doAnimation); 5112 }, 5113 stop: function(type, clearQueue, gotoEnd) { 5114 var stopQueue = function(hooks) { 5115 var stop = hooks.stop; 5116 delete hooks.stop; 5117 stop(gotoEnd); 5118 }; 5119 if (typeof type !== "string") { 5120 gotoEnd = clearQueue; 5121 clearQueue = type; 5122 type = void 0; 5123 } 5124 if (clearQueue) { 5125 this.queue(type || "fx", []); 5126 } 5127 return this.each(function() { 5128 var dequeue = true, index = type != null && type + "queueHooks", timers = jQuery2.timers, data = dataPriv.get(this); 5129 if (index) { 5130 if (data[index] && data[index].stop) { 5131 stopQueue(data[index]); 5132 } 5133 } else { 5134 for (index in data) { 5135 if (data[index] && data[index].stop && rrun.test(index)) { 5136 stopQueue(data[index]); 5137 } 5138 } 5139 } 5140 for (index = timers.length; index--; ) { 5141 if (timers[index].elem === this && (type == null || timers[index].queue === type)) { 5142 timers[index].anim.stop(gotoEnd); 5143 dequeue = false; 5144 timers.splice(index, 1); 5145 } 5146 } 5147 if (dequeue || !gotoEnd) { 5148 jQuery2.dequeue(this, type); 5149 } 5150 }); 5151 }, 5152 finish: function(type) { 5153 if (type !== false) { 5154 type = type || "fx"; 5155 } 5156 return this.each(function() { 5157 var index, data = dataPriv.get(this), queue = data[type + "queue"], hooks = data[type + "queueHooks"], timers = jQuery2.timers, length = queue ? queue.length : 0; 5158 data.finish = true; 5159 jQuery2.queue(this, type, []); 5160 if (hooks && hooks.stop) { 5161 hooks.stop.call(this, true); 5162 } 5163 for (index = timers.length; index--; ) { 5164 if (timers[index].elem === this && timers[index].queue === type) { 5165 timers[index].anim.stop(true); 5166 timers.splice(index, 1); 5167 } 5168 } 5169 for (index = 0; index < length; index++) { 5170 if (queue[index] && queue[index].finish) { 5171 queue[index].finish.call(this); 5172 } 5173 } 5174 delete data.finish; 5175 }); 5176 } 5177 }); 5178 jQuery2.each(["toggle", "show", "hide"], function(_i, name) { 5179 var cssFn = jQuery2.fn[name]; 5180 jQuery2.fn[name] = function(speed, easing, callback) { 5181 return speed == null || typeof speed === "boolean" ? cssFn.apply(this, arguments) : this.animate(genFx(name, true), speed, easing, callback); 5182 }; 5183 }); 5184 jQuery2.each({ 5185 slideDown: genFx("show"), 5186 slideUp: genFx("hide"), 5187 slideToggle: genFx("toggle"), 5188 fadeIn: { opacity: "show" }, 5189 fadeOut: { opacity: "hide" }, 5190 fadeToggle: { opacity: "toggle" } 5191 }, function(name, props) { 5192 jQuery2.fn[name] = function(speed, easing, callback) { 5193 return this.animate(props, speed, easing, callback); 5194 }; 5195 }); 5196 jQuery2.timers = []; 5197 jQuery2.fx.tick = function() { 5198 var timer, i = 0, timers = jQuery2.timers; 5199 fxNow = Date.now(); 5200 for (; i < timers.length; i++) { 5201 timer = timers[i]; 5202 if (!timer() && timers[i] === timer) { 5203 timers.splice(i--, 1); 5204 } 5205 } 5206 if (!timers.length) { 5207 jQuery2.fx.stop(); 5208 } 5209 fxNow = void 0; 5210 }; 5211 jQuery2.fx.timer = function(timer) { 5212 jQuery2.timers.push(timer); 5213 jQuery2.fx.start(); 5214 }; 5215 jQuery2.fx.interval = 13; 5216 jQuery2.fx.start = function() { 5217 if (inProgress) { 5218 return; 5219 } 5220 inProgress = true; 5221 schedule(); 5222 }; 5223 jQuery2.fx.stop = function() { 5224 inProgress = null; 5225 }; 5226 jQuery2.fx.speeds = { 5227 slow: 600, 5228 fast: 200, 5229 // Default speed 5230 _default: 400 5231 }; 5232 jQuery2.fn.delay = function(time, type) { 5233 time = jQuery2.fx ? jQuery2.fx.speeds[time] || time : time; 5234 type = type || "fx"; 5235 return this.queue(type, function(next, hooks) { 5236 var timeout = window2.setTimeout(next, time); 5237 hooks.stop = function() { 5238 window2.clearTimeout(timeout); 5239 }; 5240 }); 5241 }; 5242 (function() { 5243 var input = document2.createElement("input"), select = document2.createElement("select"), opt = select.appendChild(document2.createElement("option")); 5244 input.type = "checkbox"; 5245 support.checkOn = input.value !== ""; 5246 support.optSelected = opt.selected; 5247 input = document2.createElement("input"); 5248 input.value = "t"; 5249 input.type = "radio"; 5250 support.radioValue = input.value === "t"; 5251 })(); 5252 var boolHook, attrHandle = jQuery2.expr.attrHandle; 5253 jQuery2.fn.extend({ 5254 attr: function(name, value) { 5255 return access(this, jQuery2.attr, name, value, arguments.length > 1); 5256 }, 5257 removeAttr: function(name) { 5258 return this.each(function() { 5259 jQuery2.removeAttr(this, name); 5260 }); 5261 } 5262 }); 5263 jQuery2.extend({ 5264 attr: function(elem, name, value) { 5265 var ret, hooks, nType = elem.nodeType; 5266 if (nType === 3 || nType === 8 || nType === 2) { 5267 return; 5268 } 5269 if (typeof elem.getAttribute === "undefined") { 5270 return jQuery2.prop(elem, name, value); 5271 } 5272 if (nType !== 1 || !jQuery2.isXMLDoc(elem)) { 5273 hooks = jQuery2.attrHooks[name.toLowerCase()] || (jQuery2.expr.match.bool.test(name) ? boolHook : void 0); 5274 } 5275 if (value !== void 0) { 5276 if (value === null) { 5277 jQuery2.removeAttr(elem, name); 5278 return; 5279 } 5280 if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== void 0) { 5281 return ret; 5282 } 5283 elem.setAttribute(name, value + ""); 5284 return value; 5285 } 5286 if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) { 5287 return ret; 5288 } 5289 ret = jQuery2.find.attr(elem, name); 5290 return ret == null ? void 0 : ret; 5291 }, 5292 attrHooks: { 5293 type: { 5294 set: function(elem, value) { 5295 if (!support.radioValue && value === "radio" && nodeName(elem, "input")) { 5296 var val = elem.value; 5297 elem.setAttribute("type", value); 5298 if (val) { 5299 elem.value = val; 5300 } 5301 return value; 5302 } 5303 } 5304 } 5305 }, 5306 removeAttr: function(elem, value) { 5307 var name, i = 0, attrNames = value && value.match(rnothtmlwhite); 5308 if (attrNames && elem.nodeType === 1) { 5309 while (name = attrNames[i++]) { 5310 elem.removeAttribute(name); 5311 } 5312 } 5313 } 5314 }); 5315 boolHook = { 5316 set: function(elem, value, name) { 5317 if (value === false) { 5318 jQuery2.removeAttr(elem, name); 5319 } else { 5320 elem.setAttribute(name, name); 5321 } 5322 return name; 5323 } 5324 }; 5325 jQuery2.each(jQuery2.expr.match.bool.source.match(/\w+/g), function(_i, name) { 5326 var getter = attrHandle[name] || jQuery2.find.attr; 5327 attrHandle[name] = function(elem, name2, isXML) { 5328 var ret, handle, lowercaseName = name2.toLowerCase(); 5329 if (!isXML) { 5330 handle = attrHandle[lowercaseName]; 5331 attrHandle[lowercaseName] = ret; 5332 ret = getter(elem, name2, isXML) != null ? lowercaseName : null; 5333 attrHandle[lowercaseName] = handle; 5334 } 5335 return ret; 5336 }; 5337 }); 5338 var rfocusable = /^(?:input|select|textarea|button)$/i, rclickable = /^(?:a|area)$/i; 5339 jQuery2.fn.extend({ 5340 prop: function(name, value) { 5341 return access(this, jQuery2.prop, name, value, arguments.length > 1); 5342 }, 5343 removeProp: function(name) { 5344 return this.each(function() { 5345 delete this[jQuery2.propFix[name] || name]; 5346 }); 5347 } 5348 }); 5349 jQuery2.extend({ 5350 prop: function(elem, name, value) { 5351 var ret, hooks, nType = elem.nodeType; 5352 if (nType === 3 || nType === 8 || nType === 2) { 5353 return; 5354 } 5355 if (nType !== 1 || !jQuery2.isXMLDoc(elem)) { 5356 name = jQuery2.propFix[name] || name; 5357 hooks = jQuery2.propHooks[name]; 5358 } 5359 if (value !== void 0) { 5360 if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== void 0) { 5361 return ret; 5362 } 5363 return elem[name] = value; 5364 } 5365 if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) { 5366 return ret; 5367 } 5368 return elem[name]; 5369 }, 5370 propHooks: { 5371 tabIndex: { 5372 get: function(elem) { 5373 var tabindex = jQuery2.find.attr(elem, "tabindex"); 5374 if (tabindex) { 5375 return parseInt(tabindex, 10); 5376 } 5377 if (rfocusable.test(elem.nodeName) || rclickable.test(elem.nodeName) && elem.href) { 5378 return 0; 5379 } 5380 return -1; 5381 } 5382 } 5383 }, 5384 propFix: { 5385 "for": "htmlFor", 5386 "class": "className" 5387 } 5388 }); 5389 if (!support.optSelected) { 5390 jQuery2.propHooks.selected = { 5391 get: function(elem) { 5392 var parent = elem.parentNode; 5393 if (parent && parent.parentNode) { 5394 parent.parentNode.selectedIndex; 5395 } 5396 return null; 5397 }, 5398 set: function(elem) { 5399 var parent = elem.parentNode; 5400 if (parent) { 5401 parent.selectedIndex; 5402 if (parent.parentNode) { 5403 parent.parentNode.selectedIndex; 5404 } 5405 } 5406 } 5407 }; 5408 } 5409 jQuery2.each([ 5410 "tabIndex", 5411 "readOnly", 5412 "maxLength", 5413 "cellSpacing", 5414 "cellPadding", 5415 "rowSpan", 5416 "colSpan", 5417 "useMap", 5418 "frameBorder", 5419 "contentEditable" 5420 ], function() { 5421 jQuery2.propFix[this.toLowerCase()] = this; 5422 }); 5423 function stripAndCollapse(value) { 5424 var tokens = value.match(rnothtmlwhite) || []; 5425 return tokens.join(" "); 5426 } 5427 function getClass(elem) { 5428 return elem.getAttribute && elem.getAttribute("class") || ""; 5429 } 5430 function classesToArray(value) { 5431 if (Array.isArray(value)) { 5432 return value; 5433 } 5434 if (typeof value === "string") { 5435 return value.match(rnothtmlwhite) || []; 5436 } 5437 return []; 5438 } 5439 jQuery2.fn.extend({ 5440 addClass: function(value) { 5441 var classNames, cur, curValue, className, i, finalValue; 5442 if (isFunction(value)) { 5443 return this.each(function(j) { 5444 jQuery2(this).addClass(value.call(this, j, getClass(this))); 5445 }); 5446 } 5447 classNames = classesToArray(value); 5448 if (classNames.length) { 5449 return this.each(function() { 5450 curValue = getClass(this); 5451 cur = this.nodeType === 1 && " " + stripAndCollapse(curValue) + " "; 5452 if (cur) { 5453 for (i = 0; i < classNames.length; i++) { 5454 className = classNames[i]; 5455 if (cur.indexOf(" " + className + " ") < 0) { 5456 cur += className + " "; 5457 } 5458 } 5459 finalValue = stripAndCollapse(cur); 5460 if (curValue !== finalValue) { 5461 this.setAttribute("class", finalValue); 5462 } 5463 } 5464 }); 5465 } 5466 return this; 5467 }, 5468 removeClass: function(value) { 5469 var classNames, cur, curValue, className, i, finalValue; 5470 if (isFunction(value)) { 5471 return this.each(function(j) { 5472 jQuery2(this).removeClass(value.call(this, j, getClass(this))); 5473 }); 5474 } 5475 if (!arguments.length) { 5476 return this.attr("class", ""); 5477 } 5478 classNames = classesToArray(value); 5479 if (classNames.length) { 5480 return this.each(function() { 5481 curValue = getClass(this); 5482 cur = this.nodeType === 1 && " " + stripAndCollapse(curValue) + " "; 5483 if (cur) { 5484 for (i = 0; i < classNames.length; i++) { 5485 className = classNames[i]; 5486 while (cur.indexOf(" " + className + " ") > -1) { 5487 cur = cur.replace(" " + className + " ", " "); 5488 } 5489 } 5490 finalValue = stripAndCollapse(cur); 5491 if (curValue !== finalValue) { 5492 this.setAttribute("class", finalValue); 5493 } 5494 } 5495 }); 5496 } 5497 return this; 5498 }, 5499 toggleClass: function(value, stateVal) { 5500 var classNames, className, i, self2, type = typeof value, isValidValue = type === "string" || Array.isArray(value); 5501 if (isFunction(value)) { 5502 return this.each(function(i2) { 5503 jQuery2(this).toggleClass( 5504 value.call(this, i2, getClass(this), stateVal), 5505 stateVal 5506 ); 5507 }); 5508 } 5509 if (typeof stateVal === "boolean" && isValidValue) { 5510 return stateVal ? this.addClass(value) : this.removeClass(value); 5511 } 5512 classNames = classesToArray(value); 5513 return this.each(function() { 5514 if (isValidValue) { 5515 self2 = jQuery2(this); 5516 for (i = 0; i < classNames.length; i++) { 5517 className = classNames[i]; 5518 if (self2.hasClass(className)) { 5519 self2.removeClass(className); 5520 } else { 5521 self2.addClass(className); 5522 } 5523 } 5524 } else if (value === void 0 || type === "boolean") { 5525 className = getClass(this); 5526 if (className) { 5527 dataPriv.set(this, "__className__", className); 5528 } 5529 if (this.setAttribute) { 5530 this.setAttribute( 5531 "class", 5532 className || value === false ? "" : dataPriv.get(this, "__className__") || "" 5533 ); 5534 } 5535 } 5536 }); 5537 }, 5538 hasClass: function(selector) { 5539 var className, elem, i = 0; 5540 className = " " + selector + " "; 5541 while (elem = this[i++]) { 5542 if (elem.nodeType === 1 && (" " + stripAndCollapse(getClass(elem)) + " ").indexOf(className) > -1) { 5543 return true; 5544 } 5545 } 5546 return false; 5547 } 5548 }); 5549 var rreturn = /\r/g; 5550 jQuery2.fn.extend({ 5551 val: function(value) { 5552 var hooks, ret, valueIsFunction, elem = this[0]; 5553 if (!arguments.length) { 5554 if (elem) { 5555 hooks = jQuery2.valHooks[elem.type] || jQuery2.valHooks[elem.nodeName.toLowerCase()]; 5556 if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== void 0) { 5557 return ret; 5558 } 5559 ret = elem.value; 5560 if (typeof ret === "string") { 5561 return ret.replace(rreturn, ""); 5562 } 5563 return ret == null ? "" : ret; 5564 } 5565 return; 5566 } 5567 valueIsFunction = isFunction(value); 5568 return this.each(function(i) { 5569 var val; 5570 if (this.nodeType !== 1) { 5571 return; 5572 } 5573 if (valueIsFunction) { 5574 val = value.call(this, i, jQuery2(this).val()); 5575 } else { 5576 val = value; 5577 } 5578 if (val == null) { 5579 val = ""; 5580 } else if (typeof val === "number") { 5581 val += ""; 5582 } else if (Array.isArray(val)) { 5583 val = jQuery2.map(val, function(value2) { 5584 return value2 == null ? "" : value2 + ""; 5585 }); 5586 } 5587 hooks = jQuery2.valHooks[this.type] || jQuery2.valHooks[this.nodeName.toLowerCase()]; 5588 if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === void 0) { 5589 this.value = val; 5590 } 5591 }); 5592 } 5593 }); 5594 jQuery2.extend({ 5595 valHooks: { 5596 option: { 5597 get: function(elem) { 5598 var val = jQuery2.find.attr(elem, "value"); 5599 return val != null ? val : ( 5600 // Support: IE <=10 - 11 only 5601 // option.text throws exceptions (trac-14686, trac-14858) 5602 // Strip and collapse whitespace 5603 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 5604 stripAndCollapse(jQuery2.text(elem)) 5605 ); 5606 } 5607 }, 5608 select: { 5609 get: function(elem) { 5610 var value, option, i, options = elem.options, index = elem.selectedIndex, one = elem.type === "select-one", values = one ? null : [], max = one ? index + 1 : options.length; 5611 if (index < 0) { 5612 i = max; 5613 } else { 5614 i = one ? index : 0; 5615 } 5616 for (; i < max; i++) { 5617 option = options[i]; 5618 if ((option.selected || i === index) && // Don't return options that are disabled or in a disabled optgroup 5619 !option.disabled && (!option.parentNode.disabled || !nodeName(option.parentNode, "optgroup"))) { 5620 value = jQuery2(option).val(); 5621 if (one) { 5622 return value; 5623 } 5624 values.push(value); 5625 } 5626 } 5627 return values; 5628 }, 5629 set: function(elem, value) { 5630 var optionSet, option, options = elem.options, values = jQuery2.makeArray(value), i = options.length; 5631 while (i--) { 5632 option = options[i]; 5633 if (option.selected = jQuery2.inArray(jQuery2.valHooks.option.get(option), values) > -1) { 5634 optionSet = true; 5635 } 5636 } 5637 if (!optionSet) { 5638 elem.selectedIndex = -1; 5639 } 5640 return values; 5641 } 5642 } 5643 } 5644 }); 5645 jQuery2.each(["radio", "checkbox"], function() { 5646 jQuery2.valHooks[this] = { 5647 set: function(elem, value) { 5648 if (Array.isArray(value)) { 5649 return elem.checked = jQuery2.inArray(jQuery2(elem).val(), value) > -1; 5650 } 5651 } 5652 }; 5653 if (!support.checkOn) { 5654 jQuery2.valHooks[this].get = function(elem) { 5655 return elem.getAttribute("value") === null ? "on" : elem.value; 5656 }; 5657 } 5658 }); 5659 var location2 = window2.location; 5660 var nonce2 = { guid: Date.now() }; 5661 var rquery = /\?/; 5662 jQuery2.parseXML = function(data) { 5663 var xml, parserErrorElem; 5664 if (!data || typeof data !== "string") { 5665 return null; 5666 } 5667 try { 5668 xml = new window2.DOMParser().parseFromString(data, "text/xml"); 5669 } catch (e) { 5670 } 5671 parserErrorElem = xml && xml.getElementsByTagName("parsererror")[0]; 5672 if (!xml || parserErrorElem) { 5673 jQuery2.error("Invalid XML: " + (parserErrorElem ? jQuery2.map(parserErrorElem.childNodes, function(el) { 5674 return el.textContent; 5675 }).join("\n") : data)); 5676 } 5677 return xml; 5678 }; 5679 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, stopPropagationCallback = function(e) { 5680 e.stopPropagation(); 5681 }; 5682 jQuery2.extend(jQuery2.event, { 5683 trigger: function(event, data, elem, onlyHandlers) { 5684 var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, eventPath = [elem || document2], type = hasOwn.call(event, "type") ? event.type : event, namespaces = hasOwn.call(event, "namespace") ? event.namespace.split(".") : []; 5685 cur = lastElement = tmp = elem = elem || document2; 5686 if (elem.nodeType === 3 || elem.nodeType === 8) { 5687 return; 5688 } 5689 if (rfocusMorph.test(type + jQuery2.event.triggered)) { 5690 return; 5691 } 5692 if (type.indexOf(".") > -1) { 5693 namespaces = type.split("."); 5694 type = namespaces.shift(); 5695 namespaces.sort(); 5696 } 5697 ontype = type.indexOf(":") < 0 && "on" + type; 5698 event = event[jQuery2.expando] ? event : new jQuery2.Event(type, typeof event === "object" && event); 5699 event.isTrigger = onlyHandlers ? 2 : 3; 5700 event.namespace = namespaces.join("."); 5701 event.rnamespace = event.namespace ? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; 5702 event.result = void 0; 5703 if (!event.target) { 5704 event.target = elem; 5705 } 5706 data = data == null ? [event] : jQuery2.makeArray(data, [event]); 5707 special = jQuery2.event.special[type] || {}; 5708 if (!onlyHandlers && special.trigger && special.trigger.apply(elem, data) === false) { 5709 return; 5710 } 5711 if (!onlyHandlers && !special.noBubble && !isWindow(elem)) { 5712 bubbleType = special.delegateType || type; 5713 if (!rfocusMorph.test(bubbleType + type)) { 5714 cur = cur.parentNode; 5715 } 5716 for (; cur; cur = cur.parentNode) { 5717 eventPath.push(cur); 5718 tmp = cur; 5719 } 5720 if (tmp === (elem.ownerDocument || document2)) { 5721 eventPath.push(tmp.defaultView || tmp.parentWindow || window2); 5722 } 5723 } 5724 i = 0; 5725 while ((cur = eventPath[i++]) && !event.isPropagationStopped()) { 5726 lastElement = cur; 5727 event.type = i > 1 ? bubbleType : special.bindType || type; 5728 handle = (dataPriv.get(cur, "events") || /* @__PURE__ */ Object.create(null))[event.type] && dataPriv.get(cur, "handle"); 5729 if (handle) { 5730 handle.apply(cur, data); 5731 } 5732 handle = ontype && cur[ontype]; 5733 if (handle && handle.apply && acceptData(cur)) { 5734 event.result = handle.apply(cur, data); 5735 if (event.result === false) { 5736 event.preventDefault(); 5737 } 5738 } 5739 } 5740 event.type = type; 5741 if (!onlyHandlers && !event.isDefaultPrevented()) { 5742 if ((!special._default || special._default.apply(eventPath.pop(), data) === false) && acceptData(elem)) { 5743 if (ontype && isFunction(elem[type]) && !isWindow(elem)) { 5744 tmp = elem[ontype]; 5745 if (tmp) { 5746 elem[ontype] = null; 5747 } 5748 jQuery2.event.triggered = type; 5749 if (event.isPropagationStopped()) { 5750 lastElement.addEventListener(type, stopPropagationCallback); 5751 } 5752 elem[type](); 5753 if (event.isPropagationStopped()) { 5754 lastElement.removeEventListener(type, stopPropagationCallback); 5755 } 5756 jQuery2.event.triggered = void 0; 5757 if (tmp) { 5758 elem[ontype] = tmp; 5759 } 5760 } 5761 } 5762 } 5763 return event.result; 5764 }, 5765 // Piggyback on a donor event to simulate a different one 5766 // Used only for `focus(in | out)` events 5767 simulate: function(type, elem, event) { 5768 var e = jQuery2.extend( 5769 new jQuery2.Event(), 5770 event, 5771 { 5772 type, 5773 isSimulated: true 5774 } 5775 ); 5776 jQuery2.event.trigger(e, null, elem); 5777 } 5778 }); 5779 jQuery2.fn.extend({ 5780 trigger: function(type, data) { 5781 return this.each(function() { 5782 jQuery2.event.trigger(type, data, this); 5783 }); 5784 }, 5785 triggerHandler: function(type, data) { 5786 var elem = this[0]; 5787 if (elem) { 5788 return jQuery2.event.trigger(type, data, elem, true); 5789 } 5790 } 5791 }); 5792 var rbracket = /\[\]$/, rCRLF = /\r?\n/g, rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, rsubmittable = /^(?:input|select|textarea|keygen)/i; 5793 function buildParams(prefix, obj, traditional, add2) { 5794 var name; 5795 if (Array.isArray(obj)) { 5796 jQuery2.each(obj, function(i, v) { 5797 if (traditional || rbracket.test(prefix)) { 5798 add2(prefix, v); 5799 } else { 5800 buildParams( 5801 prefix + "[" + (typeof v === "object" && v != null ? i : "") + "]", 5802 v, 5803 traditional, 5804 add2 5805 ); 5806 } 5807 }); 5808 } else if (!traditional && toType(obj) === "object") { 5809 for (name in obj) { 5810 buildParams(prefix + "[" + name + "]", obj[name], traditional, add2); 5811 } 5812 } else { 5813 add2(prefix, obj); 5814 } 5815 } 5816 jQuery2.param = function(a, traditional) { 5817 var prefix, s = [], add2 = function(key, valueOrFunction) { 5818 var value = isFunction(valueOrFunction) ? valueOrFunction() : valueOrFunction; 5819 s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value == null ? "" : value); 5820 }; 5821 if (a == null) { 5822 return ""; 5823 } 5824 if (Array.isArray(a) || a.jquery && !jQuery2.isPlainObject(a)) { 5825 jQuery2.each(a, function() { 5826 add2(this.name, this.value); 5827 }); 5828 } else { 5829 for (prefix in a) { 5830 buildParams(prefix, a[prefix], traditional, add2); 5831 } 5832 } 5833 return s.join("&"); 5834 }; 5835 jQuery2.fn.extend({ 5836 serialize: function() { 5837 return jQuery2.param(this.serializeArray()); 5838 }, 5839 serializeArray: function() { 5840 return this.map(function() { 5841 var elements = jQuery2.prop(this, "elements"); 5842 return elements ? jQuery2.makeArray(elements) : this; 5843 }).filter(function() { 5844 var type = this.type; 5845 return this.name && !jQuery2(this).is(":disabled") && rsubmittable.test(this.nodeName) && !rsubmitterTypes.test(type) && (this.checked || !rcheckableType.test(type)); 5846 }).map(function(_i, elem) { 5847 var val = jQuery2(this).val(); 5848 if (val == null) { 5849 return null; 5850 } 5851 if (Array.isArray(val)) { 5852 return jQuery2.map(val, function(val2) { 5853 return { name: elem.name, value: val2.replace(rCRLF, "\r\n") }; 5854 }); 5855 } 5856 return { name: elem.name, value: val.replace(rCRLF, "\r\n") }; 5857 }).get(); 5858 } 5859 }); 5860 var r20 = /%20/g, rhash = /#.*$/, rantiCache = /([?&])_=[^&]*/, rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, rnoContent = /^(?:GET|HEAD)$/, rprotocol = /^\/\//, prefilters = {}, transports = {}, allTypes = "*/".concat("*"), originAnchor = document2.createElement("a"); 5861 originAnchor.href = location2.href; 5862 function addToPrefiltersOrTransports(structure) { 5863 return function(dataTypeExpression, func) { 5864 if (typeof dataTypeExpression !== "string") { 5865 func = dataTypeExpression; 5866 dataTypeExpression = "*"; 5867 } 5868 var dataType, i = 0, dataTypes = dataTypeExpression.toLowerCase().match(rnothtmlwhite) || []; 5869 if (isFunction(func)) { 5870 while (dataType = dataTypes[i++]) { 5871 if (dataType[0] === "+") { 5872 dataType = dataType.slice(1) || "*"; 5873 (structure[dataType] = structure[dataType] || []).unshift(func); 5874 } else { 5875 (structure[dataType] = structure[dataType] || []).push(func); 5876 } 5877 } 5878 } 5879 }; 5880 } 5881 function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR) { 5882 var inspected = {}, seekingTransport = structure === transports; 5883 function inspect(dataType) { 5884 var selected; 5885 inspected[dataType] = true; 5886 jQuery2.each(structure[dataType] || [], function(_, prefilterOrFactory) { 5887 var dataTypeOrTransport = prefilterOrFactory(options, originalOptions, jqXHR); 5888 if (typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[dataTypeOrTransport]) { 5889 options.dataTypes.unshift(dataTypeOrTransport); 5890 inspect(dataTypeOrTransport); 5891 return false; 5892 } else if (seekingTransport) { 5893 return !(selected = dataTypeOrTransport); 5894 } 5895 }); 5896 return selected; 5897 } 5898 return inspect(options.dataTypes[0]) || !inspected["*"] && inspect("*"); 5899 } 5900 function ajaxExtend(target, src) { 5901 var key, deep, flatOptions = jQuery2.ajaxSettings.flatOptions || {}; 5902 for (key in src) { 5903 if (src[key] !== void 0) { 5904 (flatOptions[key] ? target : deep || (deep = {}))[key] = src[key]; 5905 } 5906 } 5907 if (deep) { 5908 jQuery2.extend(true, target, deep); 5909 } 5910 return target; 5911 } 5912 function ajaxHandleResponses(s, jqXHR, responses) { 5913 var ct, type, finalDataType, firstDataType, contents = s.contents, dataTypes = s.dataTypes; 5914 while (dataTypes[0] === "*") { 5915 dataTypes.shift(); 5916 if (ct === void 0) { 5917 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); 5918 } 5919 } 5920 if (ct) { 5921 for (type in contents) { 5922 if (contents[type] && contents[type].test(ct)) { 5923 dataTypes.unshift(type); 5924 break; 5925 } 5926 } 5927 } 5928 if (dataTypes[0] in responses) { 5929 finalDataType = dataTypes[0]; 5930 } else { 5931 for (type in responses) { 5932 if (!dataTypes[0] || s.converters[type + " " + dataTypes[0]]) { 5933 finalDataType = type; 5934 break; 5935 } 5936 if (!firstDataType) { 5937 firstDataType = type; 5938 } 5939 } 5940 finalDataType = finalDataType || firstDataType; 5941 } 5942 if (finalDataType) { 5943 if (finalDataType !== dataTypes[0]) { 5944 dataTypes.unshift(finalDataType); 5945 } 5946 return responses[finalDataType]; 5947 } 5948 } 5949 function ajaxConvert(s, response, jqXHR, isSuccess) { 5950 var conv2, current, conv, tmp, prev, converters = {}, dataTypes = s.dataTypes.slice(); 5951 if (dataTypes[1]) { 5952 for (conv in s.converters) { 5953 converters[conv.toLowerCase()] = s.converters[conv]; 5954 } 5955 } 5956 current = dataTypes.shift(); 5957 while (current) { 5958 if (s.responseFields[current]) { 5959 jqXHR[s.responseFields[current]] = response; 5960 } 5961 if (!prev && isSuccess && s.dataFilter) { 5962 response = s.dataFilter(response, s.dataType); 5963 } 5964 prev = current; 5965 current = dataTypes.shift(); 5966 if (current) { 5967 if (current === "*") { 5968 current = prev; 5969 } else if (prev !== "*" && prev !== current) { 5970 conv = converters[prev + " " + current] || converters["* " + current]; 5971 if (!conv) { 5972 for (conv2 in converters) { 5973 tmp = conv2.split(" "); 5974 if (tmp[1] === current) { 5975 conv = converters[prev + " " + tmp[0]] || converters["* " + tmp[0]]; 5976 if (conv) { 5977 if (conv === true) { 5978 conv = converters[conv2]; 5979 } else if (converters[conv2] !== true) { 5980 current = tmp[0]; 5981 dataTypes.unshift(tmp[1]); 5982 } 5983 break; 5984 } 5985 } 5986 } 5987 } 5988 if (conv !== true) { 5989 if (conv && s.throws) { 5990 response = conv(response); 5991 } else { 5992 try { 5993 response = conv(response); 5994 } catch (e) { 5995 return { 5996 state: "parsererror", 5997 error: conv ? e : "No conversion from " + prev + " to " + current 5998 }; 5999 } 6000 } 6001 } 6002 } 6003 } 6004 } 6005 return { state: "success", data: response }; 6006 } 6007 jQuery2.extend({ 6008 // Counter for holding the number of active queries 6009 active: 0, 6010 // Last-Modified header cache for next request 6011 lastModified: {}, 6012 etag: {}, 6013 ajaxSettings: { 6014 url: location2.href, 6015 type: "GET", 6016 isLocal: rlocalProtocol.test(location2.protocol), 6017 global: true, 6018 processData: true, 6019 async: true, 6020 contentType: "application/x-www-form-urlencoded; charset=UTF-8", 6021 /* 6022 timeout: 0, 6023 data: null, 6024 dataType: null, 6025 username: null, 6026 password: null, 6027 cache: null, 6028 throws: false, 6029 traditional: false, 6030 headers: {}, 6031 */ 6032 accepts: { 6033 "*": allTypes, 6034 text: "text/plain", 6035 html: "text/html", 6036 xml: "application/xml, text/xml", 6037 json: "application/json, text/javascript" 6038 }, 6039 contents: { 6040 xml: /\bxml\b/, 6041 html: /\bhtml/, 6042 json: /\bjson\b/ 6043 }, 6044 responseFields: { 6045 xml: "responseXML", 6046 text: "responseText", 6047 json: "responseJSON" 6048 }, 6049 // Data converters 6050 // Keys separate source (or catchall "*") and destination types with a single space 6051 converters: { 6052 // Convert anything to text 6053 "* text": String, 6054 // Text to html (true = no transformation) 6055 "text html": true, 6056 // Evaluate text as a json expression 6057 "text json": JSON.parse, 6058 // Parse text as xml 6059 "text xml": jQuery2.parseXML 6060 }, 6061 // For options that shouldn't be deep extended: 6062 // you can add your own custom options here if 6063 // and when you create one that shouldn't be 6064 // deep extended (see ajaxExtend) 6065 flatOptions: { 6066 url: true, 6067 context: true 6068 } 6069 }, 6070 // Creates a full fledged settings object into target 6071 // with both ajaxSettings and settings fields. 6072 // If target is omitted, writes into ajaxSettings. 6073 ajaxSetup: function(target, settings) { 6074 return settings ? ( 6075 // Building a settings object 6076 ajaxExtend(ajaxExtend(target, jQuery2.ajaxSettings), settings) 6077 ) : ( 6078 // Extending ajaxSettings 6079 ajaxExtend(jQuery2.ajaxSettings, target) 6080 ); 6081 }, 6082 ajaxPrefilter: addToPrefiltersOrTransports(prefilters), 6083 ajaxTransport: addToPrefiltersOrTransports(transports), 6084 // Main method 6085 ajax: function(url, options) { 6086 if (typeof url === "object") { 6087 options = url; 6088 url = void 0; 6089 } 6090 options = options || {}; 6091 var transport, cacheURL, responseHeadersString, responseHeaders, timeoutTimer, urlAnchor, completed2, fireGlobals, i, uncached, s = jQuery2.ajaxSetup({}, options), callbackContext = s.context || s, globalEventContext = s.context && (callbackContext.nodeType || callbackContext.jquery) ? jQuery2(callbackContext) : jQuery2.event, deferred = jQuery2.Deferred(), completeDeferred = jQuery2.Callbacks("once memory"), statusCode = s.statusCode || {}, requestHeaders = {}, requestHeadersNames = {}, strAbort = "canceled", jqXHR = { 6092 readyState: 0, 6093 // Builds headers hashtable if needed 6094 getResponseHeader: function(key) { 6095 var match; 6096 if (completed2) { 6097 if (!responseHeaders) { 6098 responseHeaders = {}; 6099 while (match = rheaders.exec(responseHeadersString)) { 6100 responseHeaders[match[1].toLowerCase() + " "] = (responseHeaders[match[1].toLowerCase() + " "] || []).concat(match[2]); 6101 } 6102 } 6103 match = responseHeaders[key.toLowerCase() + " "]; 6104 } 6105 return match == null ? null : match.join(", "); 6106 }, 6107 // Raw string 6108 getAllResponseHeaders: function() { 6109 return completed2 ? responseHeadersString : null; 6110 }, 6111 // Caches the header 6112 setRequestHeader: function(name, value) { 6113 if (completed2 == null) { 6114 name = requestHeadersNames[name.toLowerCase()] = requestHeadersNames[name.toLowerCase()] || name; 6115 requestHeaders[name] = value; 6116 } 6117 return this; 6118 }, 6119 // Overrides response content-type header 6120 overrideMimeType: function(type) { 6121 if (completed2 == null) { 6122 s.mimeType = type; 6123 } 6124 return this; 6125 }, 6126 // Status-dependent callbacks 6127 statusCode: function(map) { 6128 var code; 6129 if (map) { 6130 if (completed2) { 6131 jqXHR.always(map[jqXHR.status]); 6132 } else { 6133 for (code in map) { 6134 statusCode[code] = [statusCode[code], map[code]]; 6135 } 6136 } 6137 } 6138 return this; 6139 }, 6140 // Cancel the request 6141 abort: function(statusText) { 6142 var finalText = statusText || strAbort; 6143 if (transport) { 6144 transport.abort(finalText); 6145 } 6146 done(0, finalText); 6147 return this; 6148 } 6149 }; 6150 deferred.promise(jqXHR); 6151 s.url = ((url || s.url || location2.href) + "").replace(rprotocol, location2.protocol + "//"); 6152 s.type = options.method || options.type || s.method || s.type; 6153 s.dataTypes = (s.dataType || "*").toLowerCase().match(rnothtmlwhite) || [""]; 6154 if (s.crossDomain == null) { 6155 urlAnchor = document2.createElement("a"); 6156 try { 6157 urlAnchor.href = s.url; 6158 urlAnchor.href = urlAnchor.href; 6159 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== urlAnchor.protocol + "//" + urlAnchor.host; 6160 } catch (e) { 6161 s.crossDomain = true; 6162 } 6163 } 6164 if (s.data && s.processData && typeof s.data !== "string") { 6165 s.data = jQuery2.param(s.data, s.traditional); 6166 } 6167 inspectPrefiltersOrTransports(prefilters, s, options, jqXHR); 6168 if (completed2) { 6169 return jqXHR; 6170 } 6171 fireGlobals = jQuery2.event && s.global; 6172 if (fireGlobals && jQuery2.active++ === 0) { 6173 jQuery2.event.trigger("ajaxStart"); 6174 } 6175 s.type = s.type.toUpperCase(); 6176 s.hasContent = !rnoContent.test(s.type); 6177 cacheURL = s.url.replace(rhash, ""); 6178 if (!s.hasContent) { 6179 uncached = s.url.slice(cacheURL.length); 6180 if (s.data && (s.processData || typeof s.data === "string")) { 6181 cacheURL += (rquery.test(cacheURL) ? "&" : "?") + s.data; 6182 delete s.data; 6183 } 6184 if (s.cache === false) { 6185 cacheURL = cacheURL.replace(rantiCache, "$1"); 6186 uncached = (rquery.test(cacheURL) ? "&" : "?") + "_=" + nonce2.guid++ + uncached; 6187 } 6188 s.url = cacheURL + uncached; 6189 } else if (s.data && s.processData && (s.contentType || "").indexOf("application/x-www-form-urlencoded") === 0) { 6190 s.data = s.data.replace(r20, "+"); 6191 } 6192 if (s.ifModified) { 6193 if (jQuery2.lastModified[cacheURL]) { 6194 jqXHR.setRequestHeader("If-Modified-Since", jQuery2.lastModified[cacheURL]); 6195 } 6196 if (jQuery2.etag[cacheURL]) { 6197 jqXHR.setRequestHeader("If-None-Match", jQuery2.etag[cacheURL]); 6198 } 6199 } 6200 if (s.data && s.hasContent && s.contentType !== false || options.contentType) { 6201 jqXHR.setRequestHeader("Content-Type", s.contentType); 6202 } 6203 jqXHR.setRequestHeader( 6204 "Accept", 6205 s.dataTypes[0] && s.accepts[s.dataTypes[0]] ? s.accepts[s.dataTypes[0]] + (s.dataTypes[0] !== "*" ? ", " + allTypes + "; q=0.01" : "") : s.accepts["*"] 6206 ); 6207 for (i in s.headers) { 6208 jqXHR.setRequestHeader(i, s.headers[i]); 6209 } 6210 if (s.beforeSend && (s.beforeSend.call(callbackContext, jqXHR, s) === false || completed2)) { 6211 return jqXHR.abort(); 6212 } 6213 strAbort = "abort"; 6214 completeDeferred.add(s.complete); 6215 jqXHR.done(s.success); 6216 jqXHR.fail(s.error); 6217 transport = inspectPrefiltersOrTransports(transports, s, options, jqXHR); 6218 if (!transport) { 6219 done(-1, "No Transport"); 6220 } else { 6221 jqXHR.readyState = 1; 6222 if (fireGlobals) { 6223 globalEventContext.trigger("ajaxSend", [jqXHR, s]); 6224 } 6225 if (completed2) { 6226 return jqXHR; 6227 } 6228 if (s.async && s.timeout > 0) { 6229 timeoutTimer = window2.setTimeout(function() { 6230 jqXHR.abort("timeout"); 6231 }, s.timeout); 6232 } 6233 try { 6234 completed2 = false; 6235 transport.send(requestHeaders, done); 6236 } catch (e) { 6237 if (completed2) { 6238 throw e; 6239 } 6240 done(-1, e); 6241 } 6242 } 6243 function done(status, nativeStatusText, responses, headers) { 6244 var isSuccess, success, error2, response, modified, statusText = nativeStatusText; 6245 if (completed2) { 6246 return; 6247 } 6248 completed2 = true; 6249 if (timeoutTimer) { 6250 window2.clearTimeout(timeoutTimer); 6251 } 6252 transport = void 0; 6253 responseHeadersString = headers || ""; 6254 jqXHR.readyState = status > 0 ? 4 : 0; 6255 isSuccess = status >= 200 && status < 300 || status === 304; 6256 if (responses) { 6257 response = ajaxHandleResponses(s, jqXHR, responses); 6258 } 6259 if (!isSuccess && jQuery2.inArray("script", s.dataTypes) > -1 && jQuery2.inArray("json", s.dataTypes) < 0) { 6260 s.converters["text script"] = function() { 6261 }; 6262 } 6263 response = ajaxConvert(s, response, jqXHR, isSuccess); 6264 if (isSuccess) { 6265 if (s.ifModified) { 6266 modified = jqXHR.getResponseHeader("Last-Modified"); 6267 if (modified) { 6268 jQuery2.lastModified[cacheURL] = modified; 6269 } 6270 modified = jqXHR.getResponseHeader("etag"); 6271 if (modified) { 6272 jQuery2.etag[cacheURL] = modified; 6273 } 6274 } 6275 if (status === 204 || s.type === "HEAD") { 6276 statusText = "nocontent"; 6277 } else if (status === 304) { 6278 statusText = "notmodified"; 6279 } else { 6280 statusText = response.state; 6281 success = response.data; 6282 error2 = response.error; 6283 isSuccess = !error2; 6284 } 6285 } else { 6286 error2 = statusText; 6287 if (status || !statusText) { 6288 statusText = "error"; 6289 if (status < 0) { 6290 status = 0; 6291 } 6292 } 6293 } 6294 jqXHR.status = status; 6295 jqXHR.statusText = (nativeStatusText || statusText) + ""; 6296 if (isSuccess) { 6297 deferred.resolveWith(callbackContext, [success, statusText, jqXHR]); 6298 } else { 6299 deferred.rejectWith(callbackContext, [jqXHR, statusText, error2]); 6300 } 6301 jqXHR.statusCode(statusCode); 6302 statusCode = void 0; 6303 if (fireGlobals) { 6304 globalEventContext.trigger( 6305 isSuccess ? "ajaxSuccess" : "ajaxError", 6306 [jqXHR, s, isSuccess ? success : error2] 6307 ); 6308 } 6309 completeDeferred.fireWith(callbackContext, [jqXHR, statusText]); 6310 if (fireGlobals) { 6311 globalEventContext.trigger("ajaxComplete", [jqXHR, s]); 6312 if (!--jQuery2.active) { 6313 jQuery2.event.trigger("ajaxStop"); 6314 } 6315 } 6316 } 6317 return jqXHR; 6318 }, 6319 getJSON: function(url, data, callback) { 6320 return jQuery2.get(url, data, callback, "json"); 6321 }, 6322 getScript: function(url, callback) { 6323 return jQuery2.get(url, void 0, callback, "script"); 6324 } 6325 }); 6326 jQuery2.each(["get", "post"], function(_i, method) { 6327 jQuery2[method] = function(url, data, callback, type) { 6328 if (isFunction(data)) { 6329 type = type || callback; 6330 callback = data; 6331 data = void 0; 6332 } 6333 return jQuery2.ajax(jQuery2.extend({ 6334 url, 6335 type: method, 6336 dataType: type, 6337 data, 6338 success: callback 6339 }, jQuery2.isPlainObject(url) && url)); 6340 }; 6341 }); 6342 jQuery2.ajaxPrefilter(function(s) { 6343 var i; 6344 for (i in s.headers) { 6345 if (i.toLowerCase() === "content-type") { 6346 s.contentType = s.headers[i] || ""; 6347 } 6348 } 6349 }); 6350 jQuery2._evalUrl = function(url, options, doc) { 6351 return jQuery2.ajax({ 6352 url, 6353 // Make this explicit, since user can override this through ajaxSetup (trac-11264) 6354 type: "GET", 6355 dataType: "script", 6356 cache: true, 6357 async: false, 6358 global: false, 6359 // Only evaluate the response if it is successful (gh-4126) 6360 // dataFilter is not invoked for failure responses, so using it instead 6361 // of the default converter is kludgy but it works. 6362 converters: { 6363 "text script": function() { 6364 } 6365 }, 6366 dataFilter: function(response) { 6367 jQuery2.globalEval(response, options, doc); 6368 } 6369 }); 6370 }; 6371 jQuery2.fn.extend({ 6372 wrapAll: function(html) { 6373 var wrap; 6374 if (this[0]) { 6375 if (isFunction(html)) { 6376 html = html.call(this[0]); 6377 } 6378 wrap = jQuery2(html, this[0].ownerDocument).eq(0).clone(true); 6379 if (this[0].parentNode) { 6380 wrap.insertBefore(this[0]); 6381 } 6382 wrap.map(function() { 6383 var elem = this; 6384 while (elem.firstElementChild) { 6385 elem = elem.firstElementChild; 6386 } 6387 return elem; 6388 }).append(this); 6389 } 6390 return this; 6391 }, 6392 wrapInner: function(html) { 6393 if (isFunction(html)) { 6394 return this.each(function(i) { 6395 jQuery2(this).wrapInner(html.call(this, i)); 6396 }); 6397 } 6398 return this.each(function() { 6399 var self2 = jQuery2(this), contents = self2.contents(); 6400 if (contents.length) { 6401 contents.wrapAll(html); 6402 } else { 6403 self2.append(html); 6404 } 6405 }); 6406 }, 6407 wrap: function(html) { 6408 var htmlIsFunction = isFunction(html); 6409 return this.each(function(i) { 6410 jQuery2(this).wrapAll(htmlIsFunction ? html.call(this, i) : html); 6411 }); 6412 }, 6413 unwrap: function(selector) { 6414 this.parent(selector).not("body").each(function() { 6415 jQuery2(this).replaceWith(this.childNodes); 6416 }); 6417 return this; 6418 } 6419 }); 6420 jQuery2.expr.pseudos.hidden = function(elem) { 6421 return !jQuery2.expr.pseudos.visible(elem); 6422 }; 6423 jQuery2.expr.pseudos.visible = function(elem) { 6424 return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); 6425 }; 6426 jQuery2.ajaxSettings.xhr = function() { 6427 try { 6428 return new window2.XMLHttpRequest(); 6429 } catch (e) { 6430 } 6431 }; 6432 var xhrSuccessStatus = { 6433 // File protocol always yields status code 0, assume 200 6434 0: 200, 6435 // Support: IE <=9 only 6436 // trac-1450: sometimes IE returns 1223 when it should be 204 6437 1223: 204 6438 }, xhrSupported = jQuery2.ajaxSettings.xhr(); 6439 support.cors = !!xhrSupported && "withCredentials" in xhrSupported; 6440 support.ajax = xhrSupported = !!xhrSupported; 6441 jQuery2.ajaxTransport(function(options) { 6442 var callback, errorCallback; 6443 if (support.cors || xhrSupported && !options.crossDomain) { 6444 return { 6445 send: function(headers, complete) { 6446 var i, xhr = options.xhr(); 6447 xhr.open( 6448 options.type, 6449 options.url, 6450 options.async, 6451 options.username, 6452 options.password 6453 ); 6454 if (options.xhrFields) { 6455 for (i in options.xhrFields) { 6456 xhr[i] = options.xhrFields[i]; 6457 } 6458 } 6459 if (options.mimeType && xhr.overrideMimeType) { 6460 xhr.overrideMimeType(options.mimeType); 6461 } 6462 if (!options.crossDomain && !headers["X-Requested-With"]) { 6463 headers["X-Requested-With"] = "XMLHttpRequest"; 6464 } 6465 for (i in headers) { 6466 xhr.setRequestHeader(i, headers[i]); 6467 } 6468 callback = function(type) { 6469 return function() { 6470 if (callback) { 6471 callback = errorCallback = xhr.onload = xhr.onerror = xhr.onabort = xhr.ontimeout = xhr.onreadystatechange = null; 6472 if (type === "abort") { 6473 xhr.abort(); 6474 } else if (type === "error") { 6475 if (typeof xhr.status !== "number") { 6476 complete(0, "error"); 6477 } else { 6478 complete( 6479 // File: protocol always yields status 0; see trac-8605, trac-14207 6480 xhr.status, 6481 xhr.statusText 6482 ); 6483 } 6484 } else { 6485 complete( 6486 xhrSuccessStatus[xhr.status] || xhr.status, 6487 xhr.statusText, 6488 // Support: IE <=9 only 6489 // IE9 has no XHR2 but throws on binary (trac-11426) 6490 // For XHR2 non-text, let the caller handle it (gh-2498) 6491 (xhr.responseType || "text") !== "text" || typeof xhr.responseText !== "string" ? { binary: xhr.response } : { text: xhr.responseText }, 6492 xhr.getAllResponseHeaders() 6493 ); 6494 } 6495 } 6496 }; 6497 }; 6498 xhr.onload = callback(); 6499 errorCallback = xhr.onerror = xhr.ontimeout = callback("error"); 6500 if (xhr.onabort !== void 0) { 6501 xhr.onabort = errorCallback; 6502 } else { 6503 xhr.onreadystatechange = function() { 6504 if (xhr.readyState === 4) { 6505 window2.setTimeout(function() { 6506 if (callback) { 6507 errorCallback(); 6508 } 6509 }); 6510 } 6511 }; 6512 } 6513 callback = callback("abort"); 6514 try { 6515 xhr.send(options.hasContent && options.data || null); 6516 } catch (e) { 6517 if (callback) { 6518 throw e; 6519 } 6520 } 6521 }, 6522 abort: function() { 6523 if (callback) { 6524 callback(); 6525 } 6526 } 6527 }; 6528 } 6529 }); 6530 jQuery2.ajaxPrefilter(function(s) { 6531 if (s.crossDomain) { 6532 s.contents.script = false; 6533 } 6534 }); 6535 jQuery2.ajaxSetup({ 6536 accepts: { 6537 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" 6538 }, 6539 contents: { 6540 script: /\b(?:java|ecma)script\b/ 6541 }, 6542 converters: { 6543 "text script": function(text) { 6544 jQuery2.globalEval(text); 6545 return text; 6546 } 6547 } 6548 }); 6549 jQuery2.ajaxPrefilter("script", function(s) { 6550 if (s.cache === void 0) { 6551 s.cache = false; 6552 } 6553 if (s.crossDomain) { 6554 s.type = "GET"; 6555 } 6556 }); 6557 jQuery2.ajaxTransport("script", function(s) { 6558 if (s.crossDomain || s.scriptAttrs) { 6559 var script, callback; 6560 return { 6561 send: function(_, complete) { 6562 script = jQuery2("<script>").attr(s.scriptAttrs || {}).prop({ charset: s.scriptCharset, src: s.url }).on("load error", callback = function(evt) { 6563 script.remove(); 6564 callback = null; 6565 if (evt) { 6566 complete(evt.type === "error" ? 404 : 200, evt.type); 6567 } 6568 }); 6569 document2.head.appendChild(script[0]); 6570 }, 6571 abort: function() { 6572 if (callback) { 6573 callback(); 6574 } 6575 } 6576 }; 6577 } 6578 }); 6579 var oldCallbacks = [], rjsonp = /(=)\?(?=&|$)|\?\?/; 6580 jQuery2.ajaxSetup({ 6581 jsonp: "callback", 6582 jsonpCallback: function() { 6583 var callback = oldCallbacks.pop() || jQuery2.expando + "_" + nonce2.guid++; 6584 this[callback] = true; 6585 return callback; 6586 } 6587 }); 6588 jQuery2.ajaxPrefilter("json jsonp", function(s, originalSettings, jqXHR) { 6589 var callbackName, overwritten, responseContainer, jsonProp = s.jsonp !== false && (rjsonp.test(s.url) ? "url" : typeof s.data === "string" && (s.contentType || "").indexOf("application/x-www-form-urlencoded") === 0 && rjsonp.test(s.data) && "data"); 6590 if (jsonProp || s.dataTypes[0] === "jsonp") { 6591 callbackName = s.jsonpCallback = isFunction(s.jsonpCallback) ? s.jsonpCallback() : s.jsonpCallback; 6592 if (jsonProp) { 6593 s[jsonProp] = s[jsonProp].replace(rjsonp, "$1" + callbackName); 6594 } else if (s.jsonp !== false) { 6595 s.url += (rquery.test(s.url) ? "&" : "?") + s.jsonp + "=" + callbackName; 6596 } 6597 s.converters["script json"] = function() { 6598 if (!responseContainer) { 6599 jQuery2.error(callbackName + " was not called"); 6600 } 6601 return responseContainer[0]; 6602 }; 6603 s.dataTypes[0] = "json"; 6604 overwritten = window2[callbackName]; 6605 window2[callbackName] = function() { 6606 responseContainer = arguments; 6607 }; 6608 jqXHR.always(function() { 6609 if (overwritten === void 0) { 6610 jQuery2(window2).removeProp(callbackName); 6611 } else { 6612 window2[callbackName] = overwritten; 6613 } 6614 if (s[callbackName]) { 6615 s.jsonpCallback = originalSettings.jsonpCallback; 6616 oldCallbacks.push(callbackName); 6617 } 6618 if (responseContainer && isFunction(overwritten)) { 6619 overwritten(responseContainer[0]); 6620 } 6621 responseContainer = overwritten = void 0; 6622 }); 6623 return "script"; 6624 } 6625 }); 6626 support.createHTMLDocument = (function() { 6627 var body = document2.implementation.createHTMLDocument("").body; 6628 body.innerHTML = "<form></form><form></form>"; 6629 return body.childNodes.length === 2; 6630 })(); 6631 jQuery2.parseHTML = function(data, context, keepScripts) { 6632 if (typeof data !== "string") { 6633 return []; 6634 } 6635 if (typeof context === "boolean") { 6636 keepScripts = context; 6637 context = false; 6638 } 6639 var base, parsed, scripts; 6640 if (!context) { 6641 if (support.createHTMLDocument) { 6642 context = document2.implementation.createHTMLDocument(""); 6643 base = context.createElement("base"); 6644 base.href = document2.location.href; 6645 context.head.appendChild(base); 6646 } else { 6647 context = document2; 6648 } 6649 } 6650 parsed = rsingleTag.exec(data); 6651 scripts = !keepScripts && []; 6652 if (parsed) { 6653 return [context.createElement(parsed[1])]; 6654 } 6655 parsed = buildFragment([data], context, scripts); 6656 if (scripts && scripts.length) { 6657 jQuery2(scripts).remove(); 6658 } 6659 return jQuery2.merge([], parsed.childNodes); 6660 }; 6661 jQuery2.fn.load = function(url, params, callback) { 6662 var selector, type, response, self2 = this, off = url.indexOf(" "); 6663 if (off > -1) { 6664 selector = stripAndCollapse(url.slice(off)); 6665 url = url.slice(0, off); 6666 } 6667 if (isFunction(params)) { 6668 callback = params; 6669 params = void 0; 6670 } else if (params && typeof params === "object") { 6671 type = "POST"; 6672 } 6673 if (self2.length > 0) { 6674 jQuery2.ajax({ 6675 url, 6676 // If "type" variable is undefined, then "GET" method will be used. 6677 // Make value of this field explicit since 6678 // user can override it through ajaxSetup method 6679 type: type || "GET", 6680 dataType: "html", 6681 data: params 6682 }).done(function(responseText) { 6683 response = arguments; 6684 self2.html(selector ? ( 6685 // If a selector was specified, locate the right elements in a dummy div 6686 // Exclude scripts to avoid IE 'Permission Denied' errors 6687 jQuery2("<div>").append(jQuery2.parseHTML(responseText)).find(selector) 6688 ) : ( 6689 // Otherwise use the full result 6690 responseText 6691 )); 6692 }).always(callback && function(jqXHR, status) { 6693 self2.each(function() { 6694 callback.apply(this, response || [jqXHR.responseText, status, jqXHR]); 6695 }); 6696 }); 6697 } 6698 return this; 6699 }; 6700 jQuery2.expr.pseudos.animated = function(elem) { 6701 return jQuery2.grep(jQuery2.timers, function(fn) { 6702 return elem === fn.elem; 6703 }).length; 6704 }; 6705 jQuery2.offset = { 6706 setOffset: function(elem, options, i) { 6707 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, position = jQuery2.css(elem, "position"), curElem = jQuery2(elem), props = {}; 6708 if (position === "static") { 6709 elem.style.position = "relative"; 6710 } 6711 curOffset = curElem.offset(); 6712 curCSSTop = jQuery2.css(elem, "top"); 6713 curCSSLeft = jQuery2.css(elem, "left"); 6714 calculatePosition = (position === "absolute" || position === "fixed") && (curCSSTop + curCSSLeft).indexOf("auto") > -1; 6715 if (calculatePosition) { 6716 curPosition = curElem.position(); 6717 curTop = curPosition.top; 6718 curLeft = curPosition.left; 6719 } else { 6720 curTop = parseFloat(curCSSTop) || 0; 6721 curLeft = parseFloat(curCSSLeft) || 0; 6722 } 6723 if (isFunction(options)) { 6724 options = options.call(elem, i, jQuery2.extend({}, curOffset)); 6725 } 6726 if (options.top != null) { 6727 props.top = options.top - curOffset.top + curTop; 6728 } 6729 if (options.left != null) { 6730 props.left = options.left - curOffset.left + curLeft; 6731 } 6732 if ("using" in options) { 6733 options.using.call(elem, props); 6734 } else { 6735 curElem.css(props); 6736 } 6737 } 6738 }; 6739 jQuery2.fn.extend({ 6740 // offset() relates an element's border box to the document origin 6741 offset: function(options) { 6742 if (arguments.length) { 6743 return options === void 0 ? this : this.each(function(i) { 6744 jQuery2.offset.setOffset(this, options, i); 6745 }); 6746 } 6747 var rect, win, elem = this[0]; 6748 if (!elem) { 6749 return; 6750 } 6751 if (!elem.getClientRects().length) { 6752 return { top: 0, left: 0 }; 6753 } 6754 rect = elem.getBoundingClientRect(); 6755 win = elem.ownerDocument.defaultView; 6756 return { 6757 top: rect.top + win.pageYOffset, 6758 left: rect.left + win.pageXOffset 6759 }; 6760 }, 6761 // position() relates an element's margin box to its offset parent's padding box 6762 // This corresponds to the behavior of CSS absolute positioning 6763 position: function() { 6764 if (!this[0]) { 6765 return; 6766 } 6767 var offsetParent, offset, doc, elem = this[0], parentOffset = { top: 0, left: 0 }; 6768 if (jQuery2.css(elem, "position") === "fixed") { 6769 offset = elem.getBoundingClientRect(); 6770 } else { 6771 offset = this.offset(); 6772 doc = elem.ownerDocument; 6773 offsetParent = elem.offsetParent || doc.documentElement; 6774 while (offsetParent && (offsetParent === doc.body || offsetParent === doc.documentElement) && jQuery2.css(offsetParent, "position") === "static") { 6775 offsetParent = offsetParent.parentNode; 6776 } 6777 if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) { 6778 parentOffset = jQuery2(offsetParent).offset(); 6779 parentOffset.top += jQuery2.css(offsetParent, "borderTopWidth", true); 6780 parentOffset.left += jQuery2.css(offsetParent, "borderLeftWidth", true); 6781 } 6782 } 6783 return { 6784 top: offset.top - parentOffset.top - jQuery2.css(elem, "marginTop", true), 6785 left: offset.left - parentOffset.left - jQuery2.css(elem, "marginLeft", true) 6786 }; 6787 }, 6788 // This method will return documentElement in the following cases: 6789 // 1) For the element inside the iframe without offsetParent, this method will return 6790 // documentElement of the parent window 6791 // 2) For the hidden or detached element 6792 // 3) For body or html element, i.e. in case of the html node - it will return itself 6793 // 6794 // but those exceptions were never presented as a real life use-cases 6795 // and might be considered as more preferable results. 6796 // 6797 // This logic, however, is not guaranteed and can change at any point in the future 6798 offsetParent: function() { 6799 return this.map(function() { 6800 var offsetParent = this.offsetParent; 6801 while (offsetParent && jQuery2.css(offsetParent, "position") === "static") { 6802 offsetParent = offsetParent.offsetParent; 6803 } 6804 return offsetParent || documentElement; 6805 }); 6806 } 6807 }); 6808 jQuery2.each({ scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(method, prop) { 6809 var top = "pageYOffset" === prop; 6810 jQuery2.fn[method] = function(val) { 6811 return access(this, function(elem, method2, val2) { 6812 var win; 6813 if (isWindow(elem)) { 6814 win = elem; 6815 } else if (elem.nodeType === 9) { 6816 win = elem.defaultView; 6817 } 6818 if (val2 === void 0) { 6819 return win ? win[prop] : elem[method2]; 6820 } 6821 if (win) { 6822 win.scrollTo( 6823 !top ? val2 : win.pageXOffset, 6824 top ? val2 : win.pageYOffset 6825 ); 6826 } else { 6827 elem[method2] = val2; 6828 } 6829 }, method, val, arguments.length); 6830 }; 6831 }); 6832 jQuery2.each(["top", "left"], function(_i, prop) { 6833 jQuery2.cssHooks[prop] = addGetHookIf( 6834 support.pixelPosition, 6835 function(elem, computed) { 6836 if (computed) { 6837 computed = curCSS(elem, prop); 6838 return rnumnonpx.test(computed) ? jQuery2(elem).position()[prop] + "px" : computed; 6839 } 6840 } 6841 ); 6842 }); 6843 jQuery2.each({ Height: "height", Width: "width" }, function(name, type) { 6844 jQuery2.each({ 6845 padding: "inner" + name, 6846 content: type, 6847 "": "outer" + name 6848 }, function(defaultExtra, funcName) { 6849 jQuery2.fn[funcName] = function(margin, value) { 6850 var chainable = arguments.length && (defaultExtra || typeof margin !== "boolean"), extra = defaultExtra || (margin === true || value === true ? "margin" : "border"); 6851 return access(this, function(elem, type2, value2) { 6852 var doc; 6853 if (isWindow(elem)) { 6854 return funcName.indexOf("outer") === 0 ? elem["inner" + name] : elem.document.documentElement["client" + name]; 6855 } 6856 if (elem.nodeType === 9) { 6857 doc = elem.documentElement; 6858 return Math.max( 6859 elem.body["scroll" + name], 6860 doc["scroll" + name], 6861 elem.body["offset" + name], 6862 doc["offset" + name], 6863 doc["client" + name] 6864 ); 6865 } 6866 return value2 === void 0 ? ( 6867 // Get width or height on the element, requesting but not forcing parseFloat 6868 jQuery2.css(elem, type2, extra) 6869 ) : ( 6870 // Set width or height on the element 6871 jQuery2.style(elem, type2, value2, extra) 6872 ); 6873 }, type, chainable ? margin : void 0, chainable); 6874 }; 6875 }); 6876 }); 6877 jQuery2.each([ 6878 "ajaxStart", 6879 "ajaxStop", 6880 "ajaxComplete", 6881 "ajaxError", 6882 "ajaxSuccess", 6883 "ajaxSend" 6884 ], function(_i, type) { 6885 jQuery2.fn[type] = function(fn) { 6886 return this.on(type, fn); 6887 }; 6888 }); 6889 jQuery2.fn.extend({ 6890 bind: function(types, data, fn) { 6891 return this.on(types, null, data, fn); 6892 }, 6893 unbind: function(types, fn) { 6894 return this.off(types, null, fn); 6895 }, 6896 delegate: function(selector, types, data, fn) { 6897 return this.on(types, selector, data, fn); 6898 }, 6899 undelegate: function(selector, types, fn) { 6900 return arguments.length === 1 ? this.off(selector, "**") : this.off(types, selector || "**", fn); 6901 }, 6902 hover: function(fnOver, fnOut) { 6903 return this.on("mouseenter", fnOver).on("mouseleave", fnOut || fnOver); 6904 } 6905 }); 6906 jQuery2.each( 6907 "blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "), 6908 function(_i, name) { 6909 jQuery2.fn[name] = function(data, fn) { 6910 return arguments.length > 0 ? this.on(name, null, data, fn) : this.trigger(name); 6911 }; 6912 } 6913 ); 6914 var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g; 6915 jQuery2.proxy = function(fn, context) { 6916 var tmp, args, proxy; 6917 if (typeof context === "string") { 6918 tmp = fn[context]; 6919 context = fn; 6920 fn = tmp; 6921 } 6922 if (!isFunction(fn)) { 6923 return void 0; 6924 } 6925 args = slice.call(arguments, 2); 6926 proxy = function() { 6927 return fn.apply(context || this, args.concat(slice.call(arguments))); 6928 }; 6929 proxy.guid = fn.guid = fn.guid || jQuery2.guid++; 6930 return proxy; 6931 }; 6932 jQuery2.holdReady = function(hold) { 6933 if (hold) { 6934 jQuery2.readyWait++; 6935 } else { 6936 jQuery2.ready(true); 6937 } 6938 }; 6939 jQuery2.isArray = Array.isArray; 6940 jQuery2.parseJSON = JSON.parse; 6941 jQuery2.nodeName = nodeName; 6942 jQuery2.isFunction = isFunction; 6943 jQuery2.isWindow = isWindow; 6944 jQuery2.camelCase = camelCase; 6945 jQuery2.type = toType; 6946 jQuery2.now = Date.now; 6947 jQuery2.isNumeric = function(obj) { 6948 var type = jQuery2.type(obj); 6949 return (type === "number" || type === "string") && // parseFloat NaNs numeric-cast false positives ("") 6950 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 6951 // subtraction forces infinities to NaN 6952 !isNaN(obj - parseFloat(obj)); 6953 }; 6954 jQuery2.trim = function(text) { 6955 return text == null ? "" : (text + "").replace(rtrim, "$1"); 6956 }; 6957 if (typeof define === "function" && define.amd) { 6958 define("jquery", [], function() { 6959 return jQuery2; 6960 }); 6961 } 6962 var _jQuery = window2.jQuery, _$ = window2.$; 6963 jQuery2.noConflict = function(deep) { 6964 if (window2.$ === jQuery2) { 6965 window2.$ = _$; 6966 } 6967 if (deep && window2.jQuery === jQuery2) { 6968 window2.jQuery = _jQuery; 6969 } 6970 return jQuery2; 6971 }; 6972 if (typeof noGlobal === "undefined") { 6973 window2.jQuery = window2.$ = jQuery2; 6974 } 6975 return jQuery2; 6976 }); 6977 } 6978 }); 6979 6980
vendor: 70,684 bytes, lines 6980-8505
6980// node_modules/popper.js/dist/umd/popper.js 6981 var require_popper = __commonJS({ 6982 "node_modules/popper.js/dist/umd/popper.js"(exports, module) { 6983 (function(global2, factory) { 6984 typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.Popper = factory(); 6985 })(exports, (function() { 6986 "use strict"; 6987 var isBrowser = typeof window !== "undefined" && typeof document !== "undefined" && typeof navigator !== "undefined"; 6988 var timeoutDuration = (function() { 6989 var longerTimeoutBrowsers = ["Edge", "Trident", "Firefox"]; 6990 for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) { 6991 if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) { 6992 return 1; 6993 } 6994 } 6995 return 0; 6996 })(); 6997 function microtaskDebounce(fn) { 6998 var called = false; 6999 return function() { 7000 if (called) { 7001 return; 7002 } 7003 called = true; 7004 window.Promise.resolve().then(function() { 7005 called = false; 7006 fn(); 7007 }); 7008 }; 7009 } 7010 function taskDebounce(fn) { 7011 var scheduled = false; 7012 return function() { 7013 if (!scheduled) { 7014 scheduled = true; 7015 setTimeout(function() { 7016 scheduled = false; 7017 fn(); 7018 }, timeoutDuration); 7019 } 7020 }; 7021 } 7022 var supportsMicroTasks = isBrowser && window.Promise; 7023 var debounce2 = supportsMicroTasks ? microtaskDebounce : taskDebounce; 7024 function isFunction(functionToCheck) { 7025 var getType = {}; 7026 return functionToCheck && getType.toString.call(functionToCheck) === "[object Function]"; 7027 } 7028 function getStyleComputedProperty(element, property) { 7029 if (element.nodeType !== 1) { 7030 return []; 7031 } 7032 var window2 = element.ownerDocument.defaultView; 7033 var css = window2.getComputedStyle(element, null); 7034 return property ? css[property] : css; 7035 } 7036 function getParentNode(element) { 7037 if (element.nodeName === "HTML") { 7038 return element; 7039 } 7040 return element.parentNode || element.host; 7041 } 7042 function getScrollParent(element) { 7043 if (!element) { 7044 return document.body; 7045 } 7046 switch (element.nodeName) { 7047 case "HTML": 7048 case "BODY": 7049 return element.ownerDocument.body; 7050 case "#document": 7051 return element.body; 7052 } 7053 var _getStyleComputedProp = getStyleComputedProperty(element), overflow = _getStyleComputedProp.overflow, overflowX = _getStyleComputedProp.overflowX, overflowY = _getStyleComputedProp.overflowY; 7054 if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) { 7055 return element; 7056 } 7057 return getScrollParent(getParentNode(element)); 7058 } 7059 function getReferenceNode(reference) { 7060 return reference && reference.referenceNode ? reference.referenceNode : reference; 7061 } 7062 var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode); 7063 var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent); 7064 function isIE(version) { 7065 if (version === 11) { 7066 return isIE11; 7067 } 7068 if (version === 10) { 7069 return isIE10; 7070 } 7071 return isIE11 || isIE10; 7072 } 7073 function getOffsetParent(element) { 7074 if (!element) { 7075 return document.documentElement; 7076 } 7077 var noOffsetParent = isIE(10) ? document.body : null; 7078 var offsetParent = element.offsetParent || null; 7079 while (offsetParent === noOffsetParent && element.nextElementSibling) { 7080 offsetParent = (element = element.nextElementSibling).offsetParent; 7081 } 7082 var nodeName = offsetParent && offsetParent.nodeName; 7083 if (!nodeName || nodeName === "BODY" || nodeName === "HTML") { 7084 return element ? element.ownerDocument.documentElement : document.documentElement; 7085 } 7086 if (["TH", "TD", "TABLE"].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, "position") === "static") { 7087 return getOffsetParent(offsetParent); 7088 } 7089 return offsetParent; 7090 } 7091 function isOffsetContainer(element) { 7092 var nodeName = element.nodeName; 7093 if (nodeName === "BODY") { 7094 return false; 7095 } 7096 return nodeName === "HTML" || getOffsetParent(element.firstElementChild) === element; 7097 } 7098 function getRoot(node) { 7099 if (node.parentNode !== null) { 7100 return getRoot(node.parentNode); 7101 } 7102 return node; 7103 } 7104 function findCommonOffsetParent(element1, element2) { 7105 if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) { 7106 return document.documentElement; 7107 } 7108 var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING; 7109 var start3 = order ? element1 : element2; 7110 var end = order ? element2 : element1; 7111 var range = document.createRange(); 7112 range.setStart(start3, 0); 7113 range.setEnd(end, 0); 7114 var commonAncestorContainer = range.commonAncestorContainer; 7115 if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start3.contains(end)) { 7116 if (isOffsetContainer(commonAncestorContainer)) { 7117 return commonAncestorContainer; 7118 } 7119 return getOffsetParent(commonAncestorContainer); 7120 } 7121 var element1root = getRoot(element1); 7122 if (element1root.host) { 7123 return findCommonOffsetParent(element1root.host, element2); 7124 } else { 7125 return findCommonOffsetParent(element1, getRoot(element2).host); 7126 } 7127 } 7128 function getScroll(element) { 7129 var side = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "top"; 7130 var upperSide = side === "top" ? "scrollTop" : "scrollLeft"; 7131 var nodeName = element.nodeName; 7132 if (nodeName === "BODY" || nodeName === "HTML") { 7133 var html = element.ownerDocument.documentElement; 7134 var scrollingElement = element.ownerDocument.scrollingElement || html; 7135 return scrollingElement[upperSide]; 7136 } 7137 return element[upperSide]; 7138 } 7139 function includeScroll(rect, element) { 7140 var subtract = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false; 7141 var scrollTop = getScroll(element, "top"); 7142 var scrollLeft = getScroll(element, "left"); 7143 var modifier = subtract ? -1 : 1; 7144 rect.top += scrollTop * modifier; 7145 rect.bottom += scrollTop * modifier; 7146 rect.left += scrollLeft * modifier; 7147 rect.right += scrollLeft * modifier; 7148 return rect; 7149 } 7150 function getBordersSize(styles, axis) { 7151 var sideA = axis === "x" ? "Left" : "Top"; 7152 var sideB = sideA === "Left" ? "Right" : "Bottom"; 7153 return parseFloat(styles["border" + sideA + "Width"]) + parseFloat(styles["border" + sideB + "Width"]); 7154 } 7155 function getSize(axis, body, html, computedStyle) { 7156 return Math.max(body["offset" + axis], body["scroll" + axis], html["client" + axis], html["offset" + axis], html["scroll" + axis], isIE(10) ? parseInt(html["offset" + axis]) + parseInt(computedStyle["margin" + (axis === "Height" ? "Top" : "Left")]) + parseInt(computedStyle["margin" + (axis === "Height" ? "Bottom" : "Right")]) : 0); 7157 } 7158 function getWindowSizes(document2) { 7159 var body = document2.body; 7160 var html = document2.documentElement; 7161 var computedStyle = isIE(10) && getComputedStyle(html); 7162 return { 7163 height: getSize("Height", body, html, computedStyle), 7164 width: getSize("Width", body, html, computedStyle) 7165 }; 7166 } 7167 var classCallCheck = function(instance, Constructor) { 7168 if (!(instance instanceof Constructor)) { 7169 throw new TypeError("Cannot call a class as a function"); 7170 } 7171 }; 7172 var createClass = /* @__PURE__ */ (function() { 7173 function defineProperties(target, props) { 7174 for (var i = 0; i < props.length; i++) { 7175 var descriptor = props[i]; 7176 descriptor.enumerable = descriptor.enumerable || false; 7177 descriptor.configurable = true; 7178 if ("value" in descriptor) descriptor.writable = true; 7179 Object.defineProperty(target, descriptor.key, descriptor); 7180 } 7181 } 7182 return function(Constructor, protoProps, staticProps) { 7183 if (protoProps) defineProperties(Constructor.prototype, protoProps); 7184 if (staticProps) defineProperties(Constructor, staticProps); 7185 return Constructor; 7186 }; 7187 })(); 7188 var defineProperty = function(obj, key, value) { 7189 if (key in obj) { 7190 Object.defineProperty(obj, key, { 7191 value, 7192 enumerable: true, 7193 configurable: true, 7194 writable: true 7195 }); 7196 } else { 7197 obj[key] = value; 7198 } 7199 return obj; 7200 }; 7201 var _extends = Object.assign || function(target) { 7202 for (var i = 1; i < arguments.length; i++) { 7203 var source = arguments[i]; 7204 for (var key in source) { 7205 if (Object.prototype.hasOwnProperty.call(source, key)) { 7206 target[key] = source[key]; 7207 } 7208 } 7209 } 7210 return target; 7211 }; 7212 function getClientRect(offsets) { 7213 return _extends({}, offsets, { 7214 right: offsets.left + offsets.width, 7215 bottom: offsets.top + offsets.height 7216 }); 7217 } 7218 function getBoundingClientRect(element) { 7219 var rect = {}; 7220 try { 7221 if (isIE(10)) { 7222 rect = element.getBoundingClientRect(); 7223 var scrollTop = getScroll(element, "top"); 7224 var scrollLeft = getScroll(element, "left"); 7225 rect.top += scrollTop; 7226 rect.left += scrollLeft; 7227 rect.bottom += scrollTop; 7228 rect.right += scrollLeft; 7229 } else { 7230 rect = element.getBoundingClientRect(); 7231 } 7232 } catch (e) { 7233 } 7234 var result = { 7235 left: rect.left, 7236 top: rect.top, 7237 width: rect.right - rect.left, 7238 height: rect.bottom - rect.top 7239 }; 7240 var sizes = element.nodeName === "HTML" ? getWindowSizes(element.ownerDocument) : {}; 7241 var width = sizes.width || element.clientWidth || result.width; 7242 var height = sizes.height || element.clientHeight || result.height; 7243 var horizScrollbar = element.offsetWidth - width; 7244 var vertScrollbar = element.offsetHeight - height; 7245 if (horizScrollbar || vertScrollbar) { 7246 var styles = getStyleComputedProperty(element); 7247 horizScrollbar -= getBordersSize(styles, "x"); 7248 vertScrollbar -= getBordersSize(styles, "y"); 7249 result.width -= horizScrollbar; 7250 result.height -= vertScrollbar; 7251 } 7252 return getClientRect(result); 7253 } 7254 function getOffsetRectRelativeToArbitraryNode(children, parent) { 7255 var fixedPosition = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false; 7256 var isIE102 = isIE(10); 7257 var isHTML = parent.nodeName === "HTML"; 7258 var childrenRect = getBoundingClientRect(children); 7259 var parentRect = getBoundingClientRect(parent); 7260 var scrollParent = getScrollParent(children); 7261 var styles = getStyleComputedProperty(parent); 7262 var borderTopWidth = parseFloat(styles.borderTopWidth); 7263 var borderLeftWidth = parseFloat(styles.borderLeftWidth); 7264 if (fixedPosition && isHTML) { 7265 parentRect.top = Math.max(parentRect.top, 0); 7266 parentRect.left = Math.max(parentRect.left, 0); 7267 } 7268 var offsets = getClientRect({ 7269 top: childrenRect.top - parentRect.top - borderTopWidth, 7270 left: childrenRect.left - parentRect.left - borderLeftWidth, 7271 width: childrenRect.width, 7272 height: childrenRect.height 7273 }); 7274 offsets.marginTop = 0; 7275 offsets.marginLeft = 0; 7276 if (!isIE102 && isHTML) { 7277 var marginTop = parseFloat(styles.marginTop); 7278 var marginLeft = parseFloat(styles.marginLeft); 7279 offsets.top -= borderTopWidth - marginTop; 7280 offsets.bottom -= borderTopWidth - marginTop; 7281 offsets.left -= borderLeftWidth - marginLeft; 7282 offsets.right -= borderLeftWidth - marginLeft; 7283 offsets.marginTop = marginTop; 7284 offsets.marginLeft = marginLeft; 7285 } 7286 if (isIE102 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== "BODY") { 7287 offsets = includeScroll(offsets, parent); 7288 } 7289 return offsets; 7290 } 7291 function getViewportOffsetRectRelativeToArtbitraryNode(element) { 7292 var excludeScroll = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; 7293 var html = element.ownerDocument.documentElement; 7294 var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html); 7295 var width = Math.max(html.clientWidth, window.innerWidth || 0); 7296 var height = Math.max(html.clientHeight, window.innerHeight || 0); 7297 var scrollTop = !excludeScroll ? getScroll(html) : 0; 7298 var scrollLeft = !excludeScroll ? getScroll(html, "left") : 0; 7299 var offset2 = { 7300 top: scrollTop - relativeOffset.top + relativeOffset.marginTop, 7301 left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft, 7302 width, 7303 height 7304 }; 7305 return getClientRect(offset2); 7306 } 7307 function isFixed(element) { 7308 var nodeName = element.nodeName; 7309 if (nodeName === "BODY" || nodeName === "HTML") { 7310 return false; 7311 } 7312 if (getStyleComputedProperty(element, "position") === "fixed") { 7313 return true; 7314 } 7315 var parentNode = getParentNode(element); 7316 if (!parentNode) { 7317 return false; 7318 } 7319 return isFixed(parentNode); 7320 } 7321 function getFixedPositionOffsetParent(element) { 7322 if (!element || !element.parentElement || isIE()) { 7323 return document.documentElement; 7324 } 7325 var el = element.parentElement; 7326 while (el && getStyleComputedProperty(el, "transform") === "none") { 7327 el = el.parentElement; 7328 } 7329 return el || document.documentElement; 7330 } 7331 function getBoundaries(popper, reference, padding, boundariesElement) { 7332 var fixedPosition = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false; 7333 var boundaries = { top: 0, left: 0 }; 7334 var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference)); 7335 if (boundariesElement === "viewport") { 7336 boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition); 7337 } else { 7338 var boundariesNode = void 0; 7339 if (boundariesElement === "scrollParent") { 7340 boundariesNode = getScrollParent(getParentNode(reference)); 7341 if (boundariesNode.nodeName === "BODY") { 7342 boundariesNode = popper.ownerDocument.documentElement; 7343 } 7344 } else if (boundariesElement === "window") { 7345 boundariesNode = popper.ownerDocument.documentElement; 7346 } else { 7347 boundariesNode = boundariesElement; 7348 } 7349 var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition); 7350 if (boundariesNode.nodeName === "HTML" && !isFixed(offsetParent)) { 7351 var _getWindowSizes = getWindowSizes(popper.ownerDocument), height = _getWindowSizes.height, width = _getWindowSizes.width; 7352 boundaries.top += offsets.top - offsets.marginTop; 7353 boundaries.bottom = height + offsets.top; 7354 boundaries.left += offsets.left - offsets.marginLeft; 7355 boundaries.right = width + offsets.left; 7356 } else { 7357 boundaries = offsets; 7358 } 7359 } 7360 padding = padding || 0; 7361 var isPaddingNumber = typeof padding === "number"; 7362 boundaries.left += isPaddingNumber ? padding : padding.left || 0; 7363 boundaries.top += isPaddingNumber ? padding : padding.top || 0; 7364 boundaries.right -= isPaddingNumber ? padding : padding.right || 0; 7365 boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0; 7366 return boundaries; 7367 } 7368 function getArea(_ref) { 7369 var width = _ref.width, height = _ref.height; 7370 return width * height; 7371 } 7372 function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) { 7373 var padding = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 0; 7374 if (placement.indexOf("auto") === -1) { 7375 return placement; 7376 } 7377 var boundaries = getBoundaries(popper, reference, padding, boundariesElement); 7378 var rects = { 7379 top: { 7380 width: boundaries.width, 7381 height: refRect.top - boundaries.top 7382 }, 7383 right: { 7384 width: boundaries.right - refRect.right, 7385 height: boundaries.height 7386 }, 7387 bottom: { 7388 width: boundaries.width, 7389 height: boundaries.bottom - refRect.bottom 7390 }, 7391 left: { 7392 width: refRect.left - boundaries.left, 7393 height: boundaries.height 7394 } 7395 }; 7396 var sortedAreas = Object.keys(rects).map(function(key) { 7397 return _extends({ 7398 key 7399 }, rects[key], { 7400 area: getArea(rects[key]) 7401 }); 7402 }).sort(function(a, b) { 7403 return b.area - a.area; 7404 }); 7405 var filteredAreas = sortedAreas.filter(function(_ref2) { 7406 var width = _ref2.width, height = _ref2.height; 7407 return width >= popper.clientWidth && height >= popper.clientHeight; 7408 }); 7409 var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key; 7410 var variation = placement.split("-")[1]; 7411 return computedPlacement + (variation ? "-" + variation : ""); 7412 } 7413 function getReferenceOffsets(state, popper, reference) { 7414 var fixedPosition = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null; 7415 var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference)); 7416 return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition); 7417 } 7418 function getOuterSizes(element) { 7419 var window2 = element.ownerDocument.defaultView; 7420 var styles = window2.getComputedStyle(element); 7421 var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0); 7422 var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0); 7423 var result = { 7424 width: element.offsetWidth + y, 7425 height: element.offsetHeight + x 7426 }; 7427 return result; 7428 } 7429 function getOppositePlacement(placement) { 7430 var hash = { left: "right", right: "left", bottom: "top", top: "bottom" }; 7431 return placement.replace(/left|right|bottom|top/g, function(matched) { 7432 return hash[matched]; 7433 }); 7434 } 7435 function getPopperOffsets(popper, referenceOffsets, placement) { 7436 placement = placement.split("-")[0]; 7437 var popperRect = getOuterSizes(popper); 7438 var popperOffsets = { 7439 width: popperRect.width, 7440 height: popperRect.height 7441 }; 7442 var isHoriz = ["right", "left"].indexOf(placement) !== -1; 7443 var mainSide = isHoriz ? "top" : "left"; 7444 var secondarySide = isHoriz ? "left" : "top"; 7445 var measurement = isHoriz ? "height" : "width"; 7446 var secondaryMeasurement = !isHoriz ? "height" : "width"; 7447 popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2; 7448 if (placement === secondarySide) { 7449 popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement]; 7450 } else { 7451 popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)]; 7452 } 7453 return popperOffsets; 7454 } 7455 function find(arr, check) { 7456 if (Array.prototype.find) { 7457 return arr.find(check); 7458 } 7459 return arr.filter(check)[0]; 7460 } 7461 function findIndex(arr, prop, value) { 7462 if (Array.prototype.findIndex) { 7463 return arr.findIndex(function(cur) { 7464 return cur[prop] === value; 7465 }); 7466 } 7467 var match = find(arr, function(obj) { 7468 return obj[prop] === value; 7469 }); 7470 return arr.indexOf(match); 7471 } 7472 function runModifiers(modifiers2, data, ends) { 7473 var modifiersToRun = ends === void 0 ? modifiers2 : modifiers2.slice(0, findIndex(modifiers2, "name", ends)); 7474 modifiersToRun.forEach(function(modifier) { 7475 if (modifier["function"]) { 7476 console.warn("`modifier.function` is deprecated, use `modifier.fn`!"); 7477 } 7478 var fn = modifier["function"] || modifier.fn; 7479 if (modifier.enabled && isFunction(fn)) { 7480 data.offsets.popper = getClientRect(data.offsets.popper); 7481 data.offsets.reference = getClientRect(data.offsets.reference); 7482 data = fn(data, modifier); 7483 } 7484 }); 7485 return data; 7486 } 7487 function update() { 7488 if (this.state.isDestroyed) { 7489 return; 7490 } 7491 var data = { 7492 instance: this, 7493 styles: {}, 7494 arrowStyles: {}, 7495 attributes: {}, 7496 flipped: false, 7497 offsets: {} 7498 }; 7499 data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed); 7500 data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding); 7501 data.originalPlacement = data.placement; 7502 data.positionFixed = this.options.positionFixed; 7503 data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement); 7504 data.offsets.popper.position = this.options.positionFixed ? "fixed" : "absolute"; 7505 data = runModifiers(this.modifiers, data); 7506 if (!this.state.isCreated) { 7507 this.state.isCreated = true; 7508 this.options.onCreate(data); 7509 } else { 7510 this.options.onUpdate(data); 7511 } 7512 } 7513 function isModifierEnabled(modifiers2, modifierName) { 7514 return modifiers2.some(function(_ref) { 7515 var name = _ref.name, enabled = _ref.enabled; 7516 return enabled && name === modifierName; 7517 }); 7518 } 7519 function getSupportedPropertyName(property) { 7520 var prefixes = [false, "ms", "Webkit", "Moz", "O"]; 7521 var upperProp = property.charAt(0).toUpperCase() + property.slice(1); 7522 for (var i = 0; i < prefixes.length; i++) { 7523 var prefix = prefixes[i]; 7524 var toCheck = prefix ? "" + prefix + upperProp : property; 7525 if (typeof document.body.style[toCheck] !== "undefined") { 7526 return toCheck; 7527 } 7528 } 7529 return null; 7530 } 7531 function destroy() { 7532 this.state.isDestroyed = true; 7533 if (isModifierEnabled(this.modifiers, "applyStyle")) { 7534 this.popper.removeAttribute("x-placement"); 7535 this.popper.style.position = ""; 7536 this.popper.style.top = ""; 7537 this.popper.style.left = ""; 7538 this.popper.style.right = ""; 7539 this.popper.style.bottom = ""; 7540 this.popper.style.willChange = ""; 7541 this.popper.style[getSupportedPropertyName("transform")] = ""; 7542 } 7543 this.disableEventListeners(); 7544 if (this.options.removeOnDestroy) { 7545 this.popper.parentNode.removeChild(this.popper); 7546 } 7547 return this; 7548 } 7549 function getWindow(element) { 7550 var ownerDocument = element.ownerDocument; 7551 return ownerDocument ? ownerDocument.defaultView : window; 7552 } 7553 function attachToScrollParents(scrollParent, event, callback, scrollParents) { 7554 var isBody = scrollParent.nodeName === "BODY"; 7555 var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent; 7556 target.addEventListener(event, callback, { passive: true }); 7557 if (!isBody) { 7558 attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents); 7559 } 7560 scrollParents.push(target); 7561 } 7562 function setupEventListeners(reference, options, state, updateBound) { 7563 state.updateBound = updateBound; 7564 getWindow(reference).addEventListener("resize", state.updateBound, { passive: true }); 7565 var scrollElement = getScrollParent(reference); 7566 attachToScrollParents(scrollElement, "scroll", state.updateBound, state.scrollParents); 7567 state.scrollElement = scrollElement; 7568 state.eventsEnabled = true; 7569 return state; 7570 } 7571 function enableEventListeners() { 7572 if (!this.state.eventsEnabled) { 7573 this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate); 7574 } 7575 } 7576 function removeEventListeners(reference, state) { 7577 getWindow(reference).removeEventListener("resize", state.updateBound); 7578 state.scrollParents.forEach(function(target) { 7579 target.removeEventListener("scroll", state.updateBound); 7580 }); 7581 state.updateBound = null; 7582 state.scrollParents = []; 7583 state.scrollElement = null; 7584 state.eventsEnabled = false; 7585 return state; 7586 } 7587 function disableEventListeners() { 7588 if (this.state.eventsEnabled) { 7589 cancelAnimationFrame(this.scheduleUpdate); 7590 this.state = removeEventListeners(this.reference, this.state); 7591 } 7592 } 7593 function isNumeric(n) { 7594 return n !== "" && !isNaN(parseFloat(n)) && isFinite(n); 7595 } 7596 function setStyles(element, styles) { 7597 Object.keys(styles).forEach(function(prop) { 7598 var unit = ""; 7599 if (["width", "height", "top", "right", "bottom", "left"].indexOf(prop) !== -1 && isNumeric(styles[prop])) { 7600 unit = "px"; 7601 } 7602 element.style[prop] = styles[prop] + unit; 7603 }); 7604 } 7605 function setAttributes(element, attributes) { 7606 Object.keys(attributes).forEach(function(prop) { 7607 var value = attributes[prop]; 7608 if (value !== false) { 7609 element.setAttribute(prop, attributes[prop]); 7610 } else { 7611 element.removeAttribute(prop); 7612 } 7613 }); 7614 } 7615 function applyStyle(data) { 7616 setStyles(data.instance.popper, data.styles); 7617 setAttributes(data.instance.popper, data.attributes); 7618 if (data.arrowElement && Object.keys(data.arrowStyles).length) { 7619 setStyles(data.arrowElement, data.arrowStyles); 7620 } 7621 return data; 7622 } 7623 function applyStyleOnLoad(reference, popper, options, modifierOptions, state) { 7624 var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed); 7625 var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding); 7626 popper.setAttribute("x-placement", placement); 7627 setStyles(popper, { position: options.positionFixed ? "fixed" : "absolute" }); 7628 return options; 7629 } 7630 function getRoundedOffsets(data, shouldRound) { 7631 var _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference; 7632 var round = Math.round, floor = Math.floor; 7633 var noRound = function noRound2(v) { 7634 return v; 7635 }; 7636 var referenceWidth = round(reference.width); 7637 var popperWidth = round(popper.width); 7638 var isVertical = ["left", "right"].indexOf(data.placement) !== -1; 7639 var isVariation = data.placement.indexOf("-") !== -1; 7640 var sameWidthParity = referenceWidth % 2 === popperWidth % 2; 7641 var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1; 7642 var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor; 7643 var verticalToInteger = !shouldRound ? noRound : round; 7644 return { 7645 left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left), 7646 top: verticalToInteger(popper.top), 7647 bottom: verticalToInteger(popper.bottom), 7648 right: horizontalToInteger(popper.right) 7649 }; 7650 } 7651 var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent); 7652 function computeStyle(data, options) { 7653 var x = options.x, y = options.y; 7654 var popper = data.offsets.popper; 7655 var legacyGpuAccelerationOption = find(data.instance.modifiers, function(modifier) { 7656 return modifier.name === "applyStyle"; 7657 }).gpuAcceleration; 7658 if (legacyGpuAccelerationOption !== void 0) { 7659 console.warn("WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!"); 7660 } 7661 var gpuAcceleration = legacyGpuAccelerationOption !== void 0 ? legacyGpuAccelerationOption : options.gpuAcceleration; 7662 var offsetParent = getOffsetParent(data.instance.popper); 7663 var offsetParentRect = getBoundingClientRect(offsetParent); 7664 var styles = { 7665 position: popper.position 7666 }; 7667 var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox); 7668 var sideA = x === "bottom" ? "top" : "bottom"; 7669 var sideB = y === "right" ? "left" : "right"; 7670 var prefixedProperty = getSupportedPropertyName("transform"); 7671 var left = void 0, top = void 0; 7672 if (sideA === "bottom") { 7673 if (offsetParent.nodeName === "HTML") { 7674 top = -offsetParent.clientHeight + offsets.bottom; 7675 } else { 7676 top = -offsetParentRect.height + offsets.bottom; 7677 } 7678 } else { 7679 top = offsets.top; 7680 } 7681 if (sideB === "right") { 7682 if (offsetParent.nodeName === "HTML") { 7683 left = -offsetParent.clientWidth + offsets.right; 7684 } else { 7685 left = -offsetParentRect.width + offsets.right; 7686 } 7687 } else { 7688 left = offsets.left; 7689 } 7690 if (gpuAcceleration && prefixedProperty) { 7691 styles[prefixedProperty] = "translate3d(" + left + "px, " + top + "px, 0)"; 7692 styles[sideA] = 0; 7693 styles[sideB] = 0; 7694 styles.willChange = "transform"; 7695 } else { 7696 var invertTop = sideA === "bottom" ? -1 : 1; 7697 var invertLeft = sideB === "right" ? -1 : 1; 7698 styles[sideA] = top * invertTop; 7699 styles[sideB] = left * invertLeft; 7700 styles.willChange = sideA + ", " + sideB; 7701 } 7702 var attributes = { 7703 "x-placement": data.placement 7704 }; 7705 data.attributes = _extends({}, attributes, data.attributes); 7706 data.styles = _extends({}, styles, data.styles); 7707 data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles); 7708 return data; 7709 } 7710 function isModifierRequired(modifiers2, requestingName, requestedName) { 7711 var requesting = find(modifiers2, function(_ref) { 7712 var name = _ref.name; 7713 return name === requestingName; 7714 }); 7715 var isRequired = !!requesting && modifiers2.some(function(modifier) { 7716 return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order; 7717 }); 7718 if (!isRequired) { 7719 var _requesting = "`" + requestingName + "`"; 7720 var requested = "`" + requestedName + "`"; 7721 console.warn(requested + " modifier is required by " + _requesting + " modifier in order to work, be sure to include it before " + _requesting + "!"); 7722 } 7723 return isRequired; 7724 } 7725 function arrow(data, options) { 7726 var _data$offsets$arrow; 7727 if (!isModifierRequired(data.instance.modifiers, "arrow", "keepTogether")) { 7728 return data; 7729 } 7730 var arrowElement = options.element; 7731 if (typeof arrowElement === "string") { 7732 arrowElement = data.instance.popper.querySelector(arrowElement); 7733 if (!arrowElement) { 7734 return data; 7735 } 7736 } else { 7737 if (!data.instance.popper.contains(arrowElement)) { 7738 console.warn("WARNING: `arrow.element` must be child of its popper element!"); 7739 return data; 7740 } 7741 } 7742 var placement = data.placement.split("-")[0]; 7743 var _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference; 7744 var isVertical = ["left", "right"].indexOf(placement) !== -1; 7745 var len = isVertical ? "height" : "width"; 7746 var sideCapitalized = isVertical ? "Top" : "Left"; 7747 var side = sideCapitalized.toLowerCase(); 7748 var altSide = isVertical ? "left" : "top"; 7749 var opSide = isVertical ? "bottom" : "right"; 7750 var arrowElementSize = getOuterSizes(arrowElement)[len]; 7751 if (reference[opSide] - arrowElementSize < popper[side]) { 7752 data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize); 7753 } 7754 if (reference[side] + arrowElementSize > popper[opSide]) { 7755 data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide]; 7756 } 7757 data.offsets.popper = getClientRect(data.offsets.popper); 7758 var center = reference[side] + reference[len] / 2 - arrowElementSize / 2; 7759 var css = getStyleComputedProperty(data.instance.popper); 7760 var popperMarginSide = parseFloat(css["margin" + sideCapitalized]); 7761 var popperBorderSide = parseFloat(css["border" + sideCapitalized + "Width"]); 7762 var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide; 7763 sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0); 7764 data.arrowElement = arrowElement; 7765 data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ""), _data$offsets$arrow); 7766 return data; 7767 } 7768 function getOppositeVariation(variation) { 7769 if (variation === "end") { 7770 return "start"; 7771 } else if (variation === "start") { 7772 return "end"; 7773 } 7774 return variation; 7775 } 7776 var placements = ["auto-start", "auto", "auto-end", "top-start", "top", "top-end", "right-start", "right", "right-end", "bottom-end", "bottom", "bottom-start", "left-end", "left", "left-start"]; 7777 var validPlacements = placements.slice(3); 7778 function clockwise(placement) { 7779 var counter = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; 7780 var index = validPlacements.indexOf(placement); 7781 var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index)); 7782 return counter ? arr.reverse() : arr; 7783 } 7784 var BEHAVIORS = { 7785 FLIP: "flip", 7786 CLOCKWISE: "clockwise", 7787 COUNTERCLOCKWISE: "counterclockwise" 7788 }; 7789 function flip(data, options) { 7790 if (isModifierEnabled(data.instance.modifiers, "inner")) { 7791 return data; 7792 } 7793 if (data.flipped && data.placement === data.originalPlacement) { 7794 return data; 7795 } 7796 var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed); 7797 var placement = data.placement.split("-")[0]; 7798 var placementOpposite = getOppositePlacement(placement); 7799 var variation = data.placement.split("-")[1] || ""; 7800 var flipOrder = []; 7801 switch (options.behavior) { 7802 case BEHAVIORS.FLIP: 7803 flipOrder = [placement, placementOpposite]; 7804 break; 7805 case BEHAVIORS.CLOCKWISE: 7806 flipOrder = clockwise(placement); 7807 break; 7808 case BEHAVIORS.COUNTERCLOCKWISE: 7809 flipOrder = clockwise(placement, true); 7810 break; 7811 default: 7812 flipOrder = options.behavior; 7813 } 7814 flipOrder.forEach(function(step, index) { 7815 if (placement !== step || flipOrder.length === index + 1) { 7816 return data; 7817 } 7818 placement = data.placement.split("-")[0]; 7819 placementOpposite = getOppositePlacement(placement); 7820 var popperOffsets = data.offsets.popper; 7821 var refOffsets = data.offsets.reference; 7822 var floor = Math.floor; 7823 var overlapsRef = placement === "left" && floor(popperOffsets.right) > floor(refOffsets.left) || placement === "right" && floor(popperOffsets.left) < floor(refOffsets.right) || placement === "top" && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === "bottom" && floor(popperOffsets.top) < floor(refOffsets.bottom); 7824 var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left); 7825 var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right); 7826 var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top); 7827 var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom); 7828 var overflowsBoundaries = placement === "left" && overflowsLeft || placement === "right" && overflowsRight || placement === "top" && overflowsTop || placement === "bottom" && overflowsBottom; 7829 var isVertical = ["top", "bottom"].indexOf(placement) !== -1; 7830 var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === "start" && overflowsLeft || isVertical && variation === "end" && overflowsRight || !isVertical && variation === "start" && overflowsTop || !isVertical && variation === "end" && overflowsBottom); 7831 var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === "start" && overflowsRight || isVertical && variation === "end" && overflowsLeft || !isVertical && variation === "start" && overflowsBottom || !isVertical && variation === "end" && overflowsTop); 7832 var flippedVariation = flippedVariationByRef || flippedVariationByContent; 7833 if (overlapsRef || overflowsBoundaries || flippedVariation) { 7834 data.flipped = true; 7835 if (overlapsRef || overflowsBoundaries) { 7836 placement = flipOrder[index + 1]; 7837 } 7838 if (flippedVariation) { 7839 variation = getOppositeVariation(variation); 7840 } 7841 data.placement = placement + (variation ? "-" + variation : ""); 7842 data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement)); 7843 data = runModifiers(data.instance.modifiers, data, "flip"); 7844 } 7845 }); 7846 return data; 7847 } 7848 function keepTogether(data) { 7849 var _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference; 7850 var placement = data.placement.split("-")[0]; 7851 var floor = Math.floor; 7852 var isVertical = ["top", "bottom"].indexOf(placement) !== -1; 7853 var side = isVertical ? "right" : "bottom"; 7854 var opSide = isVertical ? "left" : "top"; 7855 var measurement = isVertical ? "width" : "height"; 7856 if (popper[side] < floor(reference[opSide])) { 7857 data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement]; 7858 } 7859 if (popper[opSide] > floor(reference[side])) { 7860 data.offsets.popper[opSide] = floor(reference[side]); 7861 } 7862 return data; 7863 } 7864 function toValue(str, measurement, popperOffsets, referenceOffsets) { 7865 var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/); 7866 var value = +split[1]; 7867 var unit = split[2]; 7868 if (!value) { 7869 return str; 7870 } 7871 if (unit.indexOf("%") === 0) { 7872 var element = void 0; 7873 switch (unit) { 7874 case "%p": 7875 element = popperOffsets; 7876 break; 7877 case "%": 7878 case "%r": 7879 default: 7880 element = referenceOffsets; 7881 } 7882 var rect = getClientRect(element); 7883 return rect[measurement] / 100 * value; 7884 } else if (unit === "vh" || unit === "vw") { 7885 var size = void 0; 7886 if (unit === "vh") { 7887 size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); 7888 } else { 7889 size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 7890 } 7891 return size / 100 * value; 7892 } else { 7893 return value; 7894 } 7895 } 7896 function parseOffset(offset2, popperOffsets, referenceOffsets, basePlacement) { 7897 var offsets = [0, 0]; 7898 var useHeight = ["right", "left"].indexOf(basePlacement) !== -1; 7899 var fragments = offset2.split(/(\+|\-)/).map(function(frag) { 7900 return frag.trim(); 7901 }); 7902 var divider = fragments.indexOf(find(fragments, function(frag) { 7903 return frag.search(/,|\s/) !== -1; 7904 })); 7905 if (fragments[divider] && fragments[divider].indexOf(",") === -1) { 7906 console.warn("Offsets separated by white space(s) are deprecated, use a comma (,) instead."); 7907 } 7908 var splitRegex = /\s*,\s*|\s+/; 7909 var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments]; 7910 ops = ops.map(function(op, index) { 7911 var measurement = (index === 1 ? !useHeight : useHeight) ? "height" : "width"; 7912 var mergeWithPrevious = false; 7913 return op.reduce(function(a, b) { 7914 if (a[a.length - 1] === "" && ["+", "-"].indexOf(b) !== -1) { 7915 a[a.length - 1] = b; 7916 mergeWithPrevious = true; 7917 return a; 7918 } else if (mergeWithPrevious) { 7919 a[a.length - 1] += b; 7920 mergeWithPrevious = false; 7921 return a; 7922 } else { 7923 return a.concat(b); 7924 } 7925 }, []).map(function(str) { 7926 return toValue(str, measurement, popperOffsets, referenceOffsets); 7927 }); 7928 }); 7929 ops.forEach(function(op, index) { 7930 op.forEach(function(frag, index2) { 7931 if (isNumeric(frag)) { 7932 offsets[index] += frag * (op[index2 - 1] === "-" ? -1 : 1); 7933 } 7934 }); 7935 }); 7936 return offsets; 7937 } 7938 function offset(data, _ref) { 7939 var offset2 = _ref.offset; 7940 var placement = data.placement, _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference; 7941 var basePlacement = placement.split("-")[0]; 7942 var offsets = void 0; 7943 if (isNumeric(+offset2)) { 7944 offsets = [+offset2, 0]; 7945 } else { 7946 offsets = parseOffset(offset2, popper, reference, basePlacement); 7947 } 7948 if (basePlacement === "left") { 7949 popper.top += offsets[0]; 7950 popper.left -= offsets[1]; 7951 } else if (basePlacement === "right") { 7952 popper.top += offsets[0]; 7953 popper.left += offsets[1]; 7954 } else if (basePlacement === "top") { 7955 popper.left += offsets[0]; 7956 popper.top -= offsets[1]; 7957 } else if (basePlacement === "bottom") { 7958 popper.left += offsets[0]; 7959 popper.top += offsets[1]; 7960 } 7961 data.popper = popper; 7962 return data; 7963 } 7964 function preventOverflow(data, options) { 7965 var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper); 7966 if (data.instance.reference === boundariesElement) { 7967 boundariesElement = getOffsetParent(boundariesElement); 7968 } 7969 var transformProp = getSupportedPropertyName("transform"); 7970 var popperStyles = data.instance.popper.style; 7971 var top = popperStyles.top, left = popperStyles.left, transform = popperStyles[transformProp]; 7972 popperStyles.top = ""; 7973 popperStyles.left = ""; 7974 popperStyles[transformProp] = ""; 7975 var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed); 7976 popperStyles.top = top; 7977 popperStyles.left = left; 7978 popperStyles[transformProp] = transform; 7979 options.boundaries = boundaries; 7980 var order = options.priority; 7981 var popper = data.offsets.popper; 7982 var check = { 7983 primary: function primary(placement) { 7984 var value = popper[placement]; 7985 if (popper[placement] < boundaries[placement] && !options.escapeWithReference) { 7986 value = Math.max(popper[placement], boundaries[placement]); 7987 } 7988 return defineProperty({}, placement, value); 7989 }, 7990 secondary: function secondary(placement) { 7991 var mainSide = placement === "right" ? "left" : "top"; 7992 var value = popper[mainSide]; 7993 if (popper[placement] > boundaries[placement] && !options.escapeWithReference) { 7994 value = Math.min(popper[mainSide], boundaries[placement] - (placement === "right" ? popper.width : popper.height)); 7995 } 7996 return defineProperty({}, mainSide, value); 7997 } 7998 }; 7999 order.forEach(function(placement) { 8000 var side = ["left", "top"].indexOf(placement) !== -1 ? "primary" : "secondary"; 8001 popper = _extends({}, popper, check[side](placement)); 8002 }); 8003 data.offsets.popper = popper; 8004 return data; 8005 } 8006 function shift(data) { 8007 var placement = data.placement; 8008 var basePlacement = placement.split("-")[0]; 8009 var shiftvariation = placement.split("-")[1]; 8010 if (shiftvariation) { 8011 var _data$offsets = data.offsets, reference = _data$offsets.reference, popper = _data$offsets.popper; 8012 var isVertical = ["bottom", "top"].indexOf(basePlacement) !== -1; 8013 var side = isVertical ? "left" : "top"; 8014 var measurement = isVertical ? "width" : "height"; 8015 var shiftOffsets = { 8016 start: defineProperty({}, side, reference[side]), 8017 end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement]) 8018 }; 8019 data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]); 8020 } 8021 return data; 8022 } 8023 function hide(data) { 8024 if (!isModifierRequired(data.instance.modifiers, "hide", "preventOverflow")) { 8025 return data; 8026 } 8027 var refRect = data.offsets.reference; 8028 var bound = find(data.instance.modifiers, function(modifier) { 8029 return modifier.name === "preventOverflow"; 8030 }).boundaries; 8031 if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) { 8032 if (data.hide === true) { 8033 return data; 8034 } 8035 data.hide = true; 8036 data.attributes["x-out-of-boundaries"] = ""; 8037 } else { 8038 if (data.hide === false) { 8039 return data; 8040 } 8041 data.hide = false; 8042 data.attributes["x-out-of-boundaries"] = false; 8043 } 8044 return data; 8045 } 8046 function inner(data) { 8047 var placement = data.placement; 8048 var basePlacement = placement.split("-")[0]; 8049 var _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference; 8050 var isHoriz = ["left", "right"].indexOf(basePlacement) !== -1; 8051 var subtractLength = ["top", "left"].indexOf(basePlacement) === -1; 8052 popper[isHoriz ? "left" : "top"] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? "width" : "height"] : 0); 8053 data.placement = getOppositePlacement(placement); 8054 data.offsets.popper = getClientRect(popper); 8055 return data; 8056 } 8057 var modifiers = { 8058 /** 8059 * Modifier used to shift the popper on the start or end of its reference 8060 * element.<br /> 8061 * It will read the variation of the `placement` property.<br /> 8062 * It can be one either `-end` or `-start`. 8063 * @memberof modifiers 8064 * @inner 8065 */ 8066 shift: { 8067 /** @prop {number} order=100 - Index used to define the order of execution */ 8068 order: 100, 8069 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 8070 enabled: true, 8071 /** @prop {ModifierFn} */ 8072 fn: shift 8073 }, 8074 /** 8075 * The `offset` modifier can shift your popper on both its axis. 8076 * 8077 * It accepts the following units: 8078 * - `px` or unit-less, interpreted as pixels 8079 * - `%` or `%r`, percentage relative to the length of the reference element 8080 * - `%p`, percentage relative to the length of the popper element 8081 * - `vw`, CSS viewport width unit 8082 * - `vh`, CSS viewport height unit 8083 * 8084 * For length is intended the main axis relative to the placement of the popper.<br /> 8085 * This means that if the placement is `top` or `bottom`, the length will be the 8086 * `width`. In case of `left` or `right`, it will be the `height`. 8087 * 8088 * You can provide a single value (as `Number` or `String`), or a pair of values 8089 * as `String` divided by a comma or one (or more) white spaces.<br /> 8090 * The latter is a deprecated method because it leads to confusion and will be 8091 * removed in v2.<br /> 8092 * Additionally, it accepts additions and subtractions between different units. 8093 * Note that multiplications and divisions aren't supported. 8094 * 8095 * Valid examples are: 8096 * ``` 8097 * 10 8098 * '10%' 8099 * '10, 10' 8100 * '10%, 10' 8101 * '10 + 10%' 8102 * '10 - 5vh + 3%' 8103 * '-10px + 5vh, 5px - 6%' 8104 * ``` 8105 * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap 8106 * > with their reference element, unfortunately, you will have to disable the `flip` modifier. 8107 * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373). 8108 * 8109 * @memberof modifiers 8110 * @inner 8111 */ 8112 offset: { 8113 /** @prop {number} order=200 - Index used to define the order of execution */ 8114 order: 200, 8115 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 8116 enabled: true, 8117 /** @prop {ModifierFn} */ 8118 fn: offset, 8119 /** @prop {Number|String} offset=0 8120 * The offset value as described in the modifier description 8121 */ 8122 offset: 0 8123 }, 8124 /** 8125 * Modifier used to prevent the popper from being positioned outside the boundary. 8126 * 8127 * A scenario exists where the reference itself is not within the boundaries.<br /> 8128 * We can say it has "escaped the boundaries" â or just "escaped".<br /> 8129 * In this case we need to decide whether the popper should either: 8130 * 8131 * - detach from the reference and remain "trapped" in the boundaries, or 8132 * - if it should ignore the boundary and "escape with its reference" 8133 * 8134 * When `escapeWithReference` is set to`true` and reference is completely 8135 * outside its boundaries, the popper will overflow (or completely leave) 8136 * the boundaries in order to remain attached to the edge of the reference. 8137 * 8138 * @memberof modifiers 8139 * @inner 8140 */ 8141 preventOverflow: { 8142 /** @prop {number} order=300 - Index used to define the order of execution */ 8143 order: 300, 8144 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 8145 enabled: true, 8146 /** @prop {ModifierFn} */ 8147 fn: preventOverflow, 8148 /** 8149 * @prop {Array} [priority=['left','right','top','bottom']] 8150 * Popper will try to prevent overflow following these priorities by default, 8151 * then, it could overflow on the left and on top of the `boundariesElement` 8152 */ 8153 priority: ["left", "right", "top", "bottom"], 8154 /** 8155 * @prop {number} padding=5 8156 * Amount of pixel used to define a minimum distance between the boundaries 8157 * and the popper. This makes sure the popper always has a little padding 8158 * between the edges of its container 8159 */ 8160 padding: 5, 8161 /** 8162 * @prop {String|HTMLElement} boundariesElement='scrollParent' 8163 * Boundaries used by the modifier. Can be `scrollParent`, `window`, 8164 * `viewport` or any DOM element. 8165 */ 8166 boundariesElement: "scrollParent" 8167 }, 8168 /** 8169 * Modifier used to make sure the reference and its popper stay near each other 8170 * without leaving any gap between the two. Especially useful when the arrow is 8171 * enabled and you want to ensure that it points to its reference element. 8172 * It cares only about the first axis. You can still have poppers with margin 8173 * between the popper and its reference element. 8174 * @memberof modifiers 8175 * @inner 8176 */ 8177 keepTogether: { 8178 /** @prop {number} order=400 - Index used to define the order of execution */ 8179 order: 400, 8180 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 8181 enabled: true, 8182 /** @prop {ModifierFn} */ 8183 fn: keepTogether 8184 }, 8185 /** 8186 * This modifier is used to move the `arrowElement` of the popper to make 8187 * sure it is positioned between the reference element and its popper element. 8188 * It will read the outer size of the `arrowElement` node to detect how many 8189 * pixels of conjunction are needed. 8190 * 8191 * It has no effect if no `arrowElement` is provided. 8192 * @memberof modifiers 8193 * @inner 8194 */ 8195 arrow: { 8196 /** @prop {number} order=500 - Index used to define the order of execution */ 8197 order: 500, 8198 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 8199 enabled: true, 8200 /** @prop {ModifierFn} */ 8201 fn: arrow, 8202 /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */ 8203 element: "[x-arrow]" 8204 }, 8205 /** 8206 * Modifier used to flip the popper's placement when it starts to overlap its 8207 * reference element. 8208 * 8209 * Requires the `preventOverflow` modifier before it in order to work. 8210 * 8211 * **NOTE:** this modifier will interrupt the current update cycle and will 8212 * restart it if it detects the need to flip the placement. 8213 * @memberof modifiers 8214 * @inner 8215 */ 8216 flip: { 8217 /** @prop {number} order=600 - Index used to define the order of execution */ 8218 order: 600, 8219 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 8220 enabled: true, 8221 /** @prop {ModifierFn} */ 8222 fn: flip, 8223 /** 8224 * @prop {String|Array} behavior='flip' 8225 * The behavior used to change the popper's placement. It can be one of 8226 * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid 8227 * placements (with optional variations) 8228 */ 8229 behavior: "flip", 8230 /** 8231 * @prop {number} padding=5 8232 * The popper will flip if it hits the edges of the `boundariesElement` 8233 */ 8234 padding: 5, 8235 /** 8236 * @prop {String|HTMLElement} boundariesElement='viewport' 8237 * The element which will define the boundaries of the popper position. 8238 * The popper will never be placed outside of the defined boundaries 8239 * (except if `keepTogether` is enabled) 8240 */ 8241 boundariesElement: "viewport", 8242 /** 8243 * @prop {Boolean} flipVariations=false 8244 * The popper will switch placement variation between `-start` and `-end` when 8245 * the reference element overlaps its boundaries. 8246 * 8247 * The original placement should have a set variation. 8248 */ 8249 flipVariations: false, 8250 /** 8251 * @prop {Boolean} flipVariationsByContent=false 8252 * The popper will switch placement variation between `-start` and `-end` when 8253 * the popper element overlaps its reference boundaries. 8254 * 8255 * The original placement should have a set variation. 8256 */ 8257 flipVariationsByContent: false 8258 }, 8259 /** 8260 * Modifier used to make the popper flow toward the inner of the reference element. 8261 * By default, when this modifier is disabled, the popper will be placed outside 8262 * the reference element. 8263 * @memberof modifiers 8264 * @inner 8265 */ 8266 inner: { 8267 /** @prop {number} order=700 - Index used to define the order of execution */ 8268 order: 700, 8269 /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */ 8270 enabled: false, 8271 /** @prop {ModifierFn} */ 8272 fn: inner 8273 }, 8274 /** 8275 * Modifier used to hide the popper when its reference element is outside of the 8276 * popper boundaries. It will set a `x-out-of-boundaries` attribute which can 8277 * be used to hide with a CSS selector the popper when its reference is 8278 * out of boundaries. 8279 * 8280 * Requires the `preventOverflow` modifier before it in order to work. 8281 * @memberof modifiers 8282 * @inner 8283 */ 8284 hide: { 8285 /** @prop {number} order=800 - Index used to define the order of execution */ 8286 order: 800, 8287 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 8288 enabled: true, 8289 /** @prop {ModifierFn} */ 8290 fn: hide 8291 }, 8292 /** 8293 * Computes the style that will be applied to the popper element to gets 8294 * properly positioned. 8295 * 8296 * Note that this modifier will not touch the DOM, it just prepares the styles 8297 * so that `applyStyle` modifier can apply it. This separation is useful 8298 * in case you need to replace `applyStyle` with a custom implementation. 8299 * 8300 * This modifier has `850` as `order` value to maintain backward compatibility 8301 * with previous versions of Popper.js. Expect the modifiers ordering method 8302 * to change in future major versions of the library. 8303 * 8304 * @memberof modifiers 8305 * @inner 8306 */ 8307 computeStyle: { 8308 /** @prop {number} order=850 - Index used to define the order of execution */ 8309 order: 850, 8310 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 8311 enabled: true, 8312 /** @prop {ModifierFn} */ 8313 fn: computeStyle, 8314 /** 8315 * @prop {Boolean} gpuAcceleration=true 8316 * If true, it uses the CSS 3D transformation to position the popper. 8317 * Otherwise, it will use the `top` and `left` properties 8318 */ 8319 gpuAcceleration: true, 8320 /** 8321 * @prop {string} [x='bottom'] 8322 * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin. 8323 * Change this if your popper should grow in a direction different from `bottom` 8324 */ 8325 x: "bottom", 8326 /** 8327 * @prop {string} [x='left'] 8328 * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin. 8329 * Change this if your popper should grow in a direction different from `right` 8330 */ 8331 y: "right" 8332 }, 8333 /** 8334 * Applies the computed styles to the popper element. 8335 * 8336 * All the DOM manipulations are limited to this modifier. This is useful in case 8337 * you want to integrate Popper.js inside a framework or view library and you 8338 * want to delegate all the DOM manipulations to it. 8339 * 8340 * Note that if you disable this modifier, you must make sure the popper element 8341 * has its position set to `absolute` before Popper.js can do its work! 8342 * 8343 * Just disable this modifier and define your own to achieve the desired effect. 8344 * 8345 * @memberof modifiers 8346 * @inner 8347 */ 8348 applyStyle: { 8349 /** @prop {number} order=900 - Index used to define the order of execution */ 8350 order: 900, 8351 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 8352 enabled: true, 8353 /** @prop {ModifierFn} */ 8354 fn: applyStyle, 8355 /** @prop {Function} */ 8356 onLoad: applyStyleOnLoad, 8357 /** 8358 * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier 8359 * @prop {Boolean} gpuAcceleration=true 8360 * If true, it uses the CSS 3D transformation to position the popper. 8361 * Otherwise, it will use the `top` and `left` properties 8362 */ 8363 gpuAcceleration: void 0 8364 } 8365 }; 8366 var Defaults = { 8367 /** 8368 * Popper's placement. 8369 * @prop {Popper.placements} placement='bottom' 8370 */ 8371 placement: "bottom", 8372 /** 8373 * Set this to true if you want popper to position it self in 'fixed' mode 8374 * @prop {Boolean} positionFixed=false 8375 */ 8376 positionFixed: false, 8377 /** 8378 * Whether events (resize, scroll) are initially enabled. 8379 * @prop {Boolean} eventsEnabled=true 8380 */ 8381 eventsEnabled: true, 8382 /** 8383 * Set to true if you want to automatically remove the popper when 8384 * you call the `destroy` method. 8385 * @prop {Boolean} removeOnDestroy=false 8386 */ 8387 removeOnDestroy: false, 8388 /** 8389 * Callback called when the popper is created.<br /> 8390 * By default, it is set to no-op.<br /> 8391 * Access Popper.js instance with `data.instance`. 8392 * @prop {onCreate} 8393 */ 8394 onCreate: function onCreate() { 8395 }, 8396 /** 8397 * Callback called when the popper is updated. This callback is not called 8398 * on the initialization/creation of the popper, but only on subsequent 8399 * updates.<br /> 8400 * By default, it is set to no-op.<br /> 8401 * Access Popper.js instance with `data.instance`. 8402 * @prop {onUpdate} 8403 */ 8404 onUpdate: function onUpdate() { 8405 }, 8406 /** 8407 * List of modifiers used to modify the offsets before they are applied to the popper. 8408 * They provide most of the functionalities of Popper.js. 8409 * @prop {modifiers} 8410 */ 8411 modifiers 8412 }; 8413 var Popper = (function() { 8414 function Popper2(reference, popper) { 8415 var _this = this; 8416 var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; 8417 classCallCheck(this, Popper2); 8418 this.scheduleUpdate = function() { 8419 return requestAnimationFrame(_this.update); 8420 }; 8421 this.update = debounce2(this.update.bind(this)); 8422 this.options = _extends({}, Popper2.Defaults, options); 8423 this.state = { 8424 isDestroyed: false, 8425 isCreated: false, 8426 scrollParents: [] 8427 }; 8428 this.reference = reference && reference.jquery ? reference[0] : reference; 8429 this.popper = popper && popper.jquery ? popper[0] : popper; 8430 this.options.modifiers = {}; 8431 Object.keys(_extends({}, Popper2.Defaults.modifiers, options.modifiers)).forEach(function(name) { 8432 _this.options.modifiers[name] = _extends({}, Popper2.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {}); 8433 }); 8434 this.modifiers = Object.keys(this.options.modifiers).map(function(name) { 8435 return _extends({ 8436 name 8437 }, _this.options.modifiers[name]); 8438 }).sort(function(a, b) { 8439 return a.order - b.order; 8440 }); 8441 this.modifiers.forEach(function(modifierOptions) { 8442 if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) { 8443 modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state); 8444 } 8445 }); 8446 this.update(); 8447 var eventsEnabled = this.options.eventsEnabled; 8448 if (eventsEnabled) { 8449 this.enableEventListeners(); 8450 } 8451 this.state.eventsEnabled = eventsEnabled; 8452 } 8453 createClass(Popper2, [{ 8454 key: "update", 8455 value: function update$$1() { 8456 return update.call(this); 8457 } 8458 }, { 8459 key: "destroy", 8460 value: function destroy$$1() { 8461 return destroy.call(this); 8462 } 8463 }, { 8464 key: "enableEventListeners", 8465 value: function enableEventListeners$$1() { 8466 return enableEventListeners.call(this); 8467 } 8468 }, { 8469 key: "disableEventListeners", 8470 value: function disableEventListeners$$1() { 8471 return disableEventListeners.call(this); 8472 } 8473 /** 8474 * Schedules an update. It will run on the next UI update available. 8475 * @method scheduleUpdate 8476 * @memberof Popper 8477 */ 8478 /** 8479 * Collection of utilities useful when writing custom modifiers. 8480 * Starting from version 1.7, this method is available only if you 8481 * include `popper-utils.js` before `popper.js`. 8482 * 8483 * **DEPRECATION**: This way to access PopperUtils is deprecated 8484 * and will be removed in v2! Use the PopperUtils module directly instead. 8485 * Due to the high instability of the methods contained in Utils, we can't 8486 * guarantee them to follow semver. Use them at your own risk! 8487 * @static 8488 * @private 8489 * @type {Object} 8490 * @deprecated since version 1.8 8491 * @member Utils 8492 * @memberof Popper 8493 */ 8494 }]); 8495 return Popper2; 8496 })(); 8497 Popper.Utils = (typeof window !== "undefined" ? window : global).PopperUtils; 8498 Popper.placements = placements; 8499 Popper.Defaults = Defaults; 8500 return Popper; 8501 })); 8502 } 8503 }); 8504 8505
vendor: 138,102 bytes, lines 8505-11800
8505// node_modules/bootstrap/dist/js/bootstrap.js 8506 var require_bootstrap = __commonJS({ 8507 "node_modules/bootstrap/dist/js/bootstrap.js"(exports, module) { 8508 (function(global2, factory) { 8509 typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_jquery(), require_popper()) : typeof define === "function" && define.amd ? define(["exports", "jquery", "popper.js"], factory) : (global2 = global2 || self, factory(global2.bootstrap = {}, global2.jQuery, global2.Popper)); 8510 })(exports, function(exports2, $3, Popper) { 8511 "use strict"; 8512 $3 = $3 && $3.hasOwnProperty("default") ? $3["default"] : $3; 8513 Popper = Popper && Popper.hasOwnProperty("default") ? Popper["default"] : Popper; 8514 function _defineProperties(target, props) { 8515 for (var i = 0; i < props.length; i++) { 8516 var descriptor = props[i]; 8517 descriptor.enumerable = descriptor.enumerable || false; 8518 descriptor.configurable = true; 8519 if ("value" in descriptor) descriptor.writable = true; 8520 Object.defineProperty(target, descriptor.key, descriptor); 8521 } 8522 } 8523 function _createClass(Constructor, protoProps, staticProps) { 8524 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 8525 if (staticProps) _defineProperties(Constructor, staticProps); 8526 return Constructor; 8527 } 8528 function _defineProperty(obj, key, value) { 8529 if (key in obj) { 8530 Object.defineProperty(obj, key, { 8531 value, 8532 enumerable: true, 8533 configurable: true, 8534 writable: true 8535 }); 8536 } else { 8537 obj[key] = value; 8538 } 8539 return obj; 8540 } 8541 function _objectSpread(target) { 8542 for (var i = 1; i < arguments.length; i++) { 8543 var source = arguments[i] != null ? arguments[i] : {}; 8544 var ownKeys = Object.keys(source); 8545 if (typeof Object.getOwnPropertySymbols === "function") { 8546 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { 8547 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 8548 })); 8549 } 8550 ownKeys.forEach(function(key) { 8551 _defineProperty(target, key, source[key]); 8552 }); 8553 } 8554 return target; 8555 } 8556 function _inheritsLoose(subClass, superClass) { 8557 subClass.prototype = Object.create(superClass.prototype); 8558 subClass.prototype.constructor = subClass; 8559 subClass.__proto__ = superClass; 8560 } 8561 var TRANSITION_END = "transitionend"; 8562 var MAX_UID = 1e6; 8563 var MILLISECONDS_MULTIPLIER = 1e3; 8564 function toType(obj) { 8565 return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); 8566 } 8567 function getSpecialTransitionEndEvent() { 8568 return { 8569 bindType: TRANSITION_END, 8570 delegateType: TRANSITION_END, 8571 handle: function handle(event) { 8572 if ($3(event.target).is(this)) { 8573 return event.handleObj.handler.apply(this, arguments); 8574 } 8575 return void 0; 8576 } 8577 }; 8578 } 8579 function transitionEndEmulator(duration) { 8580 var _this = this; 8581 var called = false; 8582 $3(this).one(Util.TRANSITION_END, function() { 8583 called = true; 8584 }); 8585 setTimeout(function() { 8586 if (!called) { 8587 Util.triggerTransitionEnd(_this); 8588 } 8589 }, duration); 8590 return this; 8591 } 8592 function setTransitionEndSupport() { 8593 $3.fn.emulateTransitionEnd = transitionEndEmulator; 8594 $3.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); 8595 } 8596 var Util = { 8597 TRANSITION_END: "bsTransitionEnd", 8598 getUID: function getUID(prefix) { 8599 do { 8600 prefix += ~~(Math.random() * MAX_UID); 8601 } while (document.getElementById(prefix)); 8602 return prefix; 8603 }, 8604 getSelectorFromElement: function getSelectorFromElement(element) { 8605 var selector = element.getAttribute("data-target"); 8606 if (!selector || selector === "#") { 8607 var hrefAttr = element.getAttribute("href"); 8608 selector = hrefAttr && hrefAttr !== "#" ? hrefAttr.trim() : ""; 8609 } 8610 try { 8611 return document.querySelector(selector) ? selector : null; 8612 } catch (err) { 8613 return null; 8614 } 8615 }, 8616 getTransitionDurationFromElement: function getTransitionDurationFromElement(element) { 8617 if (!element) { 8618 return 0; 8619 } 8620 var transitionDuration = $3(element).css("transition-duration"); 8621 var transitionDelay = $3(element).css("transition-delay"); 8622 var floatTransitionDuration = parseFloat(transitionDuration); 8623 var floatTransitionDelay = parseFloat(transitionDelay); 8624 if (!floatTransitionDuration && !floatTransitionDelay) { 8625 return 0; 8626 } 8627 transitionDuration = transitionDuration.split(",")[0]; 8628 transitionDelay = transitionDelay.split(",")[0]; 8629 return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; 8630 }, 8631 reflow: function reflow(element) { 8632 return element.offsetHeight; 8633 }, 8634 triggerTransitionEnd: function triggerTransitionEnd(element) { 8635 $3(element).trigger(TRANSITION_END); 8636 }, 8637 // TODO: Remove in v5 8638 supportsTransitionEnd: function supportsTransitionEnd() { 8639 return Boolean(TRANSITION_END); 8640 }, 8641 isElement: function isElement(obj) { 8642 return (obj[0] || obj).nodeType; 8643 }, 8644 typeCheckConfig: function typeCheckConfig(componentName, config2, configTypes) { 8645 for (var property in configTypes) { 8646 if (Object.prototype.hasOwnProperty.call(configTypes, property)) { 8647 var expectedTypes = configTypes[property]; 8648 var value = config2[property]; 8649 var valueType = value && Util.isElement(value) ? "element" : toType(value); 8650 if (!new RegExp(expectedTypes).test(valueType)) { 8651 throw new Error(componentName.toUpperCase() + ": " + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".')); 8652 } 8653 } 8654 } 8655 }, 8656 findShadowRoot: function findShadowRoot(element) { 8657 if (!document.documentElement.attachShadow) { 8658 return null; 8659 } 8660 if (typeof element.getRootNode === "function") { 8661 var root = element.getRootNode(); 8662 return root instanceof ShadowRoot ? root : null; 8663 } 8664 if (element instanceof ShadowRoot) { 8665 return element; 8666 } 8667 if (!element.parentNode) { 8668 return null; 8669 } 8670 return Util.findShadowRoot(element.parentNode); 8671 } 8672 }; 8673 setTransitionEndSupport(); 8674 var NAME = "alert"; 8675 var VERSION = "4.3.1"; 8676 var DATA_KEY = "bs.alert"; 8677 var EVENT_KEY = "." + DATA_KEY; 8678 var DATA_API_KEY = ".data-api"; 8679 var JQUERY_NO_CONFLICT = $3.fn[NAME]; 8680 var Selector = { 8681 DISMISS: '[data-dismiss="alert"]' 8682 }; 8683 var Event2 = { 8684 CLOSE: "close" + EVENT_KEY, 8685 CLOSED: "closed" + EVENT_KEY, 8686 CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY 8687 }; 8688 var ClassName = { 8689 ALERT: "alert", 8690 FADE: "fade", 8691 SHOW: "show" 8692 /** 8693 * ------------------------------------------------------------------------ 8694 * Class Definition 8695 * ------------------------------------------------------------------------ 8696 */ 8697 }; 8698 var Alert = /* @__PURE__ */ (function() { 8699 function Alert2(element) { 8700 this._element = element; 8701 } 8702 var _proto = Alert2.prototype; 8703 _proto.close = function close(element) { 8704 var rootElement = this._element; 8705 if (element) { 8706 rootElement = this._getRootElement(element); 8707 } 8708 var customEvent = this._triggerCloseEvent(rootElement); 8709 if (customEvent.isDefaultPrevented()) { 8710 return; 8711 } 8712 this._removeElement(rootElement); 8713 }; 8714 _proto.dispose = function dispose() { 8715 $3.removeData(this._element, DATA_KEY); 8716 this._element = null; 8717 }; 8718 _proto._getRootElement = function _getRootElement(element) { 8719 var selector = Util.getSelectorFromElement(element); 8720 var parent = false; 8721 if (selector) { 8722 parent = document.querySelector(selector); 8723 } 8724 if (!parent) { 8725 parent = $3(element).closest("." + ClassName.ALERT)[0]; 8726 } 8727 return parent; 8728 }; 8729 _proto._triggerCloseEvent = function _triggerCloseEvent(element) { 8730 var closeEvent = $3.Event(Event2.CLOSE); 8731 $3(element).trigger(closeEvent); 8732 return closeEvent; 8733 }; 8734 _proto._removeElement = function _removeElement(element) { 8735 var _this = this; 8736 $3(element).removeClass(ClassName.SHOW); 8737 if (!$3(element).hasClass(ClassName.FADE)) { 8738 this._destroyElement(element); 8739 return; 8740 } 8741 var transitionDuration = Util.getTransitionDurationFromElement(element); 8742 $3(element).one(Util.TRANSITION_END, function(event) { 8743 return _this._destroyElement(element, event); 8744 }).emulateTransitionEnd(transitionDuration); 8745 }; 8746 _proto._destroyElement = function _destroyElement(element) { 8747 $3(element).detach().trigger(Event2.CLOSED).remove(); 8748 }; 8749 Alert2._jQueryInterface = function _jQueryInterface(config2) { 8750 return this.each(function() { 8751 var $element = $3(this); 8752 var data = $element.data(DATA_KEY); 8753 if (!data) { 8754 data = new Alert2(this); 8755 $element.data(DATA_KEY, data); 8756 } 8757 if (config2 === "close") { 8758 data[config2](this); 8759 } 8760 }); 8761 }; 8762 Alert2._handleDismiss = function _handleDismiss(alertInstance) { 8763 return function(event) { 8764 if (event) { 8765 event.preventDefault(); 8766 } 8767 alertInstance.close(this); 8768 }; 8769 }; 8770 _createClass(Alert2, null, [{ 8771 key: "VERSION", 8772 get: function get() { 8773 return VERSION; 8774 } 8775 }]); 8776 return Alert2; 8777 })(); 8778 $3(document).on(Event2.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())); 8779 $3.fn[NAME] = Alert._jQueryInterface; 8780 $3.fn[NAME].Constructor = Alert; 8781 $3.fn[NAME].noConflict = function() { 8782 $3.fn[NAME] = JQUERY_NO_CONFLICT; 8783 return Alert._jQueryInterface; 8784 }; 8785 var NAME$1 = "button"; 8786 var VERSION$1 = "4.3.1"; 8787 var DATA_KEY$1 = "bs.button"; 8788 var EVENT_KEY$1 = "." + DATA_KEY$1; 8789 var DATA_API_KEY$1 = ".data-api"; 8790 var JQUERY_NO_CONFLICT$1 = $3.fn[NAME$1]; 8791 var ClassName$1 = { 8792 ACTIVE: "active", 8793 BUTTON: "btn", 8794 FOCUS: "focus" 8795 }; 8796 var Selector$1 = { 8797 DATA_TOGGLE_CARROT: '[data-toggle^="button"]', 8798 DATA_TOGGLE: '[data-toggle="buttons"]', 8799 INPUT: 'input:not([type="hidden"])', 8800 ACTIVE: ".active", 8801 BUTTON: ".btn" 8802 }; 8803 var Event$1 = { 8804 CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1, 8805 FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1) 8806 /** 8807 * ------------------------------------------------------------------------ 8808 * Class Definition 8809 * ------------------------------------------------------------------------ 8810 */ 8811 }; 8812 var Button = /* @__PURE__ */ (function() { 8813 function Button2(element) { 8814 this._element = element; 8815 } 8816 var _proto = Button2.prototype; 8817 _proto.toggle = function toggle() { 8818 var triggerChangeEvent = true; 8819 var addAriaPressed = true; 8820 var rootElement = $3(this._element).closest(Selector$1.DATA_TOGGLE)[0]; 8821 if (rootElement) { 8822 var input = this._element.querySelector(Selector$1.INPUT); 8823 if (input) { 8824 if (input.type === "radio") { 8825 if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) { 8826 triggerChangeEvent = false; 8827 } else { 8828 var activeElement = rootElement.querySelector(Selector$1.ACTIVE); 8829 if (activeElement) { 8830 $3(activeElement).removeClass(ClassName$1.ACTIVE); 8831 } 8832 } 8833 } 8834 if (triggerChangeEvent) { 8835 if (input.hasAttribute("disabled") || rootElement.hasAttribute("disabled") || input.classList.contains("disabled") || rootElement.classList.contains("disabled")) { 8836 return; 8837 } 8838 input.checked = !this._element.classList.contains(ClassName$1.ACTIVE); 8839 $3(input).trigger("change"); 8840 } 8841 input.focus(); 8842 addAriaPressed = false; 8843 } 8844 } 8845 if (addAriaPressed) { 8846 this._element.setAttribute("aria-pressed", !this._element.classList.contains(ClassName$1.ACTIVE)); 8847 } 8848 if (triggerChangeEvent) { 8849 $3(this._element).toggleClass(ClassName$1.ACTIVE); 8850 } 8851 }; 8852 _proto.dispose = function dispose() { 8853 $3.removeData(this._element, DATA_KEY$1); 8854 this._element = null; 8855 }; 8856 Button2._jQueryInterface = function _jQueryInterface(config2) { 8857 return this.each(function() { 8858 var data = $3(this).data(DATA_KEY$1); 8859 if (!data) { 8860 data = new Button2(this); 8861 $3(this).data(DATA_KEY$1, data); 8862 } 8863 if (config2 === "toggle") { 8864 data[config2](); 8865 } 8866 }); 8867 }; 8868 _createClass(Button2, null, [{ 8869 key: "VERSION", 8870 get: function get() { 8871 return VERSION$1; 8872 } 8873 }]); 8874 return Button2; 8875 })(); 8876 $3(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function(event) { 8877 event.preventDefault(); 8878 var button = event.target; 8879 if (!$3(button).hasClass(ClassName$1.BUTTON)) { 8880 button = $3(button).closest(Selector$1.BUTTON); 8881 } 8882 Button._jQueryInterface.call($3(button), "toggle"); 8883 }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function(event) { 8884 var button = $3(event.target).closest(Selector$1.BUTTON)[0]; 8885 $3(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type)); 8886 }); 8887 $3.fn[NAME$1] = Button._jQueryInterface; 8888 $3.fn[NAME$1].Constructor = Button; 8889 $3.fn[NAME$1].noConflict = function() { 8890 $3.fn[NAME$1] = JQUERY_NO_CONFLICT$1; 8891 return Button._jQueryInterface; 8892 }; 8893 var NAME$2 = "carousel"; 8894 var VERSION$2 = "4.3.1"; 8895 var DATA_KEY$2 = "bs.carousel"; 8896 var EVENT_KEY$2 = "." + DATA_KEY$2; 8897 var DATA_API_KEY$2 = ".data-api"; 8898 var JQUERY_NO_CONFLICT$2 = $3.fn[NAME$2]; 8899 var ARROW_LEFT_KEYCODE = 37; 8900 var ARROW_RIGHT_KEYCODE = 39; 8901 var TOUCHEVENT_COMPAT_WAIT = 500; 8902 var SWIPE_THRESHOLD = 40; 8903 var Default = { 8904 interval: 5e3, 8905 keyboard: true, 8906 slide: false, 8907 pause: "hover", 8908 wrap: true, 8909 touch: true 8910 }; 8911 var DefaultType = { 8912 interval: "(number|boolean)", 8913 keyboard: "boolean", 8914 slide: "(boolean|string)", 8915 pause: "(string|boolean)", 8916 wrap: "boolean", 8917 touch: "boolean" 8918 }; 8919 var Direction2 = { 8920 NEXT: "next", 8921 PREV: "prev", 8922 LEFT: "left", 8923 RIGHT: "right" 8924 }; 8925 var Event$2 = { 8926 SLIDE: "slide" + EVENT_KEY$2, 8927 SLID: "slid" + EVENT_KEY$2, 8928 KEYDOWN: "keydown" + EVENT_KEY$2, 8929 MOUSEENTER: "mouseenter" + EVENT_KEY$2, 8930 MOUSELEAVE: "mouseleave" + EVENT_KEY$2, 8931 TOUCHSTART: "touchstart" + EVENT_KEY$2, 8932 TOUCHMOVE: "touchmove" + EVENT_KEY$2, 8933 TOUCHEND: "touchend" + EVENT_KEY$2, 8934 POINTERDOWN: "pointerdown" + EVENT_KEY$2, 8935 POINTERUP: "pointerup" + EVENT_KEY$2, 8936 DRAG_START: "dragstart" + EVENT_KEY$2, 8937 LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2, 8938 CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2 8939 }; 8940 var ClassName$2 = { 8941 CAROUSEL: "carousel", 8942 ACTIVE: "active", 8943 SLIDE: "slide", 8944 RIGHT: "carousel-item-right", 8945 LEFT: "carousel-item-left", 8946 NEXT: "carousel-item-next", 8947 PREV: "carousel-item-prev", 8948 ITEM: "carousel-item", 8949 POINTER_EVENT: "pointer-event" 8950 }; 8951 var Selector$2 = { 8952 ACTIVE: ".active", 8953 ACTIVE_ITEM: ".active.carousel-item", 8954 ITEM: ".carousel-item", 8955 ITEM_IMG: ".carousel-item img", 8956 NEXT_PREV: ".carousel-item-next, .carousel-item-prev", 8957 INDICATORS: ".carousel-indicators", 8958 DATA_SLIDE: "[data-slide], [data-slide-to]", 8959 DATA_RIDE: '[data-ride="carousel"]' 8960 }; 8961 var PointerType = { 8962 TOUCH: "touch", 8963 PEN: "pen" 8964 /** 8965 * ------------------------------------------------------------------------ 8966 * Class Definition 8967 * ------------------------------------------------------------------------ 8968 */ 8969 }; 8970 var Carousel = /* @__PURE__ */ (function() { 8971 function Carousel2(element, config2) { 8972 this._items = null; 8973 this._interval = null; 8974 this._activeElement = null; 8975 this._isPaused = false; 8976 this._isSliding = false; 8977 this.touchTimeout = null; 8978 this.touchStartX = 0; 8979 this.touchDeltaX = 0; 8980 this._config = this._getConfig(config2); 8981 this._element = element; 8982 this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS); 8983 this._touchSupported = "ontouchstart" in document.documentElement || navigator.maxTouchPoints > 0; 8984 this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent); 8985 this._addEventListeners(); 8986 } 8987 var _proto = Carousel2.prototype; 8988 _proto.next = function next() { 8989 if (!this._isSliding) { 8990 this._slide(Direction2.NEXT); 8991 } 8992 }; 8993 _proto.nextWhenVisible = function nextWhenVisible() { 8994 if (!document.hidden && $3(this._element).is(":visible") && $3(this._element).css("visibility") !== "hidden") { 8995 this.next(); 8996 } 8997 }; 8998 _proto.prev = function prev() { 8999 if (!this._isSliding) { 9000 this._slide(Direction2.PREV); 9001 } 9002 }; 9003 _proto.pause = function pause(event) { 9004 if (!event) { 9005 this._isPaused = true; 9006 } 9007 if (this._element.querySelector(Selector$2.NEXT_PREV)) { 9008 Util.triggerTransitionEnd(this._element); 9009 this.cycle(true); 9010 } 9011 clearInterval(this._interval); 9012 this._interval = null; 9013 }; 9014 _proto.cycle = function cycle(event) { 9015 if (!event) { 9016 this._isPaused = false; 9017 } 9018 if (this._interval) { 9019 clearInterval(this._interval); 9020 this._interval = null; 9021 } 9022 if (this._config.interval && !this._isPaused) { 9023 this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); 9024 } 9025 }; 9026 _proto.to = function to(index) { 9027 var _this = this; 9028 this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM); 9029 var activeIndex = this._getItemIndex(this._activeElement); 9030 if (index > this._items.length - 1 || index < 0) { 9031 return; 9032 } 9033 if (this._isSliding) { 9034 $3(this._element).one(Event$2.SLID, function() { 9035 return _this.to(index); 9036 }); 9037 return; 9038 } 9039 if (activeIndex === index) { 9040 this.pause(); 9041 this.cycle(); 9042 return; 9043 } 9044 var direction = index > activeIndex ? Direction2.NEXT : Direction2.PREV; 9045 this._slide(direction, this._items[index]); 9046 }; 9047 _proto.dispose = function dispose() { 9048 $3(this._element).off(EVENT_KEY$2); 9049 $3.removeData(this._element, DATA_KEY$2); 9050 this._items = null; 9051 this._config = null; 9052 this._element = null; 9053 this._interval = null; 9054 this._isPaused = null; 9055 this._isSliding = null; 9056 this._activeElement = null; 9057 this._indicatorsElement = null; 9058 }; 9059 _proto._getConfig = function _getConfig(config2) { 9060 config2 = _objectSpread({}, Default, config2); 9061 Util.typeCheckConfig(NAME$2, config2, DefaultType); 9062 return config2; 9063 }; 9064 _proto._handleSwipe = function _handleSwipe() { 9065 var absDeltax = Math.abs(this.touchDeltaX); 9066 if (absDeltax <= SWIPE_THRESHOLD) { 9067 return; 9068 } 9069 var direction = absDeltax / this.touchDeltaX; 9070 if (direction > 0) { 9071 this.prev(); 9072 } 9073 if (direction < 0) { 9074 this.next(); 9075 } 9076 }; 9077 _proto._addEventListeners = function _addEventListeners() { 9078 var _this2 = this; 9079 if (this._config.keyboard) { 9080 $3(this._element).on(Event$2.KEYDOWN, function(event) { 9081 return _this2._keydown(event); 9082 }); 9083 } 9084 if (this._config.pause === "hover") { 9085 $3(this._element).on(Event$2.MOUSEENTER, function(event) { 9086 return _this2.pause(event); 9087 }).on(Event$2.MOUSELEAVE, function(event) { 9088 return _this2.cycle(event); 9089 }); 9090 } 9091 if (this._config.touch) { 9092 this._addTouchEventListeners(); 9093 } 9094 }; 9095 _proto._addTouchEventListeners = function _addTouchEventListeners() { 9096 var _this3 = this; 9097 if (!this._touchSupported) { 9098 return; 9099 } 9100 var start3 = function start4(event) { 9101 if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { 9102 _this3.touchStartX = event.originalEvent.clientX; 9103 } else if (!_this3._pointerEvent) { 9104 _this3.touchStartX = event.originalEvent.touches[0].clientX; 9105 } 9106 }; 9107 var move = function move2(event) { 9108 if (event.originalEvent.touches && event.originalEvent.touches.length > 1) { 9109 _this3.touchDeltaX = 0; 9110 } else { 9111 _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX; 9112 } 9113 }; 9114 var end = function end2(event) { 9115 if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { 9116 _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX; 9117 } 9118 _this3._handleSwipe(); 9119 if (_this3._config.pause === "hover") { 9120 _this3.pause(); 9121 if (_this3.touchTimeout) { 9122 clearTimeout(_this3.touchTimeout); 9123 } 9124 _this3.touchTimeout = setTimeout(function(event2) { 9125 return _this3.cycle(event2); 9126 }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval); 9127 } 9128 }; 9129 $3(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function(e) { 9130 return e.preventDefault(); 9131 }); 9132 if (this._pointerEvent) { 9133 $3(this._element).on(Event$2.POINTERDOWN, function(event) { 9134 return start3(event); 9135 }); 9136 $3(this._element).on(Event$2.POINTERUP, function(event) { 9137 return end(event); 9138 }); 9139 this._element.classList.add(ClassName$2.POINTER_EVENT); 9140 } else { 9141 $3(this._element).on(Event$2.TOUCHSTART, function(event) { 9142 return start3(event); 9143 }); 9144 $3(this._element).on(Event$2.TOUCHMOVE, function(event) { 9145 return move(event); 9146 }); 9147 $3(this._element).on(Event$2.TOUCHEND, function(event) { 9148 return end(event); 9149 }); 9150 } 9151 }; 9152 _proto._keydown = function _keydown(event) { 9153 if (/input|textarea/i.test(event.target.tagName)) { 9154 return; 9155 } 9156 switch (event.which) { 9157 case ARROW_LEFT_KEYCODE: 9158 event.preventDefault(); 9159 this.prev(); 9160 break; 9161 case ARROW_RIGHT_KEYCODE: 9162 event.preventDefault(); 9163 this.next(); 9164 break; 9165 default: 9166 } 9167 }; 9168 _proto._getItemIndex = function _getItemIndex(element) { 9169 this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : []; 9170 return this._items.indexOf(element); 9171 }; 9172 _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) { 9173 var isNextDirection = direction === Direction2.NEXT; 9174 var isPrevDirection = direction === Direction2.PREV; 9175 var activeIndex = this._getItemIndex(activeElement); 9176 var lastItemIndex = this._items.length - 1; 9177 var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex; 9178 if (isGoingToWrap && !this._config.wrap) { 9179 return activeElement; 9180 } 9181 var delta = direction === Direction2.PREV ? -1 : 1; 9182 var itemIndex = (activeIndex + delta) % this._items.length; 9183 return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex]; 9184 }; 9185 _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) { 9186 var targetIndex = this._getItemIndex(relatedTarget); 9187 var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM)); 9188 var slideEvent = $3.Event(Event$2.SLIDE, { 9189 relatedTarget, 9190 direction: eventDirectionName, 9191 from: fromIndex, 9192 to: targetIndex 9193 }); 9194 $3(this._element).trigger(slideEvent); 9195 return slideEvent; 9196 }; 9197 _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) { 9198 if (this._indicatorsElement) { 9199 var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE)); 9200 $3(indicators).removeClass(ClassName$2.ACTIVE); 9201 var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; 9202 if (nextIndicator) { 9203 $3(nextIndicator).addClass(ClassName$2.ACTIVE); 9204 } 9205 } 9206 }; 9207 _proto._slide = function _slide(direction, element) { 9208 var _this4 = this; 9209 var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM); 9210 var activeElementIndex = this._getItemIndex(activeElement); 9211 var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement); 9212 var nextElementIndex = this._getItemIndex(nextElement); 9213 var isCycling = Boolean(this._interval); 9214 var directionalClassName; 9215 var orderClassName; 9216 var eventDirectionName; 9217 if (direction === Direction2.NEXT) { 9218 directionalClassName = ClassName$2.LEFT; 9219 orderClassName = ClassName$2.NEXT; 9220 eventDirectionName = Direction2.LEFT; 9221 } else { 9222 directionalClassName = ClassName$2.RIGHT; 9223 orderClassName = ClassName$2.PREV; 9224 eventDirectionName = Direction2.RIGHT; 9225 } 9226 if (nextElement && $3(nextElement).hasClass(ClassName$2.ACTIVE)) { 9227 this._isSliding = false; 9228 return; 9229 } 9230 var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); 9231 if (slideEvent.isDefaultPrevented()) { 9232 return; 9233 } 9234 if (!activeElement || !nextElement) { 9235 return; 9236 } 9237 this._isSliding = true; 9238 if (isCycling) { 9239 this.pause(); 9240 } 9241 this._setActiveIndicatorElement(nextElement); 9242 var slidEvent = $3.Event(Event$2.SLID, { 9243 relatedTarget: nextElement, 9244 direction: eventDirectionName, 9245 from: activeElementIndex, 9246 to: nextElementIndex 9247 }); 9248 if ($3(this._element).hasClass(ClassName$2.SLIDE)) { 9249 $3(nextElement).addClass(orderClassName); 9250 Util.reflow(nextElement); 9251 $3(activeElement).addClass(directionalClassName); 9252 $3(nextElement).addClass(directionalClassName); 9253 var nextElementInterval = parseInt(nextElement.getAttribute("data-interval"), 10); 9254 if (nextElementInterval) { 9255 this._config.defaultInterval = this._config.defaultInterval || this._config.interval; 9256 this._config.interval = nextElementInterval; 9257 } else { 9258 this._config.interval = this._config.defaultInterval || this._config.interval; 9259 } 9260 var transitionDuration = Util.getTransitionDurationFromElement(activeElement); 9261 $3(activeElement).one(Util.TRANSITION_END, function() { 9262 $3(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE); 9263 $3(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName); 9264 _this4._isSliding = false; 9265 setTimeout(function() { 9266 return $3(_this4._element).trigger(slidEvent); 9267 }, 0); 9268 }).emulateTransitionEnd(transitionDuration); 9269 } else { 9270 $3(activeElement).removeClass(ClassName$2.ACTIVE); 9271 $3(nextElement).addClass(ClassName$2.ACTIVE); 9272 this._isSliding = false; 9273 $3(this._element).trigger(slidEvent); 9274 } 9275 if (isCycling) { 9276 this.cycle(); 9277 } 9278 }; 9279 Carousel2._jQueryInterface = function _jQueryInterface(config2) { 9280 return this.each(function() { 9281 var data = $3(this).data(DATA_KEY$2); 9282 var _config = _objectSpread({}, Default, $3(this).data()); 9283 if (typeof config2 === "object") { 9284 _config = _objectSpread({}, _config, config2); 9285 } 9286 var action = typeof config2 === "string" ? config2 : _config.slide; 9287 if (!data) { 9288 data = new Carousel2(this, _config); 9289 $3(this).data(DATA_KEY$2, data); 9290 } 9291 if (typeof config2 === "number") { 9292 data.to(config2); 9293 } else if (typeof action === "string") { 9294 if (typeof data[action] === "undefined") { 9295 throw new TypeError('No method named "' + action + '"'); 9296 } 9297 data[action](); 9298 } else if (_config.interval && _config.ride) { 9299 data.pause(); 9300 data.cycle(); 9301 } 9302 }); 9303 }; 9304 Carousel2._dataApiClickHandler = function _dataApiClickHandler(event) { 9305 var selector = Util.getSelectorFromElement(this); 9306 if (!selector) { 9307 return; 9308 } 9309 var target = $3(selector)[0]; 9310 if (!target || !$3(target).hasClass(ClassName$2.CAROUSEL)) { 9311 return; 9312 } 9313 var config2 = _objectSpread({}, $3(target).data(), $3(this).data()); 9314 var slideIndex = this.getAttribute("data-slide-to"); 9315 if (slideIndex) { 9316 config2.interval = false; 9317 } 9318 Carousel2._jQueryInterface.call($3(target), config2); 9319 if (slideIndex) { 9320 $3(target).data(DATA_KEY$2).to(slideIndex); 9321 } 9322 event.preventDefault(); 9323 }; 9324 _createClass(Carousel2, null, [{ 9325 key: "VERSION", 9326 get: function get() { 9327 return VERSION$2; 9328 } 9329 }, { 9330 key: "Default", 9331 get: function get() { 9332 return Default; 9333 } 9334 }]); 9335 return Carousel2; 9336 })(); 9337 $3(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler); 9338 $3(window).on(Event$2.LOAD_DATA_API, function() { 9339 var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE)); 9340 for (var i = 0, len = carousels.length; i < len; i++) { 9341 var $carousel = $3(carousels[i]); 9342 Carousel._jQueryInterface.call($carousel, $carousel.data()); 9343 } 9344 }); 9345 $3.fn[NAME$2] = Carousel._jQueryInterface; 9346 $3.fn[NAME$2].Constructor = Carousel; 9347 $3.fn[NAME$2].noConflict = function() { 9348 $3.fn[NAME$2] = JQUERY_NO_CONFLICT$2; 9349 return Carousel._jQueryInterface; 9350 }; 9351 var NAME$3 = "collapse"; 9352 var VERSION$3 = "4.3.1"; 9353 var DATA_KEY$3 = "bs.collapse"; 9354 var EVENT_KEY$3 = "." + DATA_KEY$3; 9355 var DATA_API_KEY$3 = ".data-api"; 9356 var JQUERY_NO_CONFLICT$3 = $3.fn[NAME$3]; 9357 var Default$1 = { 9358 toggle: true, 9359 parent: "" 9360 }; 9361 var DefaultType$1 = { 9362 toggle: "boolean", 9363 parent: "(string|element)" 9364 }; 9365 var Event$3 = { 9366 SHOW: "show" + EVENT_KEY$3, 9367 SHOWN: "shown" + EVENT_KEY$3, 9368 HIDE: "hide" + EVENT_KEY$3, 9369 HIDDEN: "hidden" + EVENT_KEY$3, 9370 CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3 9371 }; 9372 var ClassName$3 = { 9373 SHOW: "show", 9374 COLLAPSE: "collapse", 9375 COLLAPSING: "collapsing", 9376 COLLAPSED: "collapsed" 9377 }; 9378 var Dimension = { 9379 WIDTH: "width", 9380 HEIGHT: "height" 9381 }; 9382 var Selector$3 = { 9383 ACTIVES: ".show, .collapsing", 9384 DATA_TOGGLE: '[data-toggle="collapse"]' 9385 /** 9386 * ------------------------------------------------------------------------ 9387 * Class Definition 9388 * ------------------------------------------------------------------------ 9389 */ 9390 }; 9391 var Collapse = /* @__PURE__ */ (function() { 9392 function Collapse2(element, config2) { 9393 this._isTransitioning = false; 9394 this._element = element; 9395 this._config = this._getConfig(config2); 9396 this._triggerArray = [].slice.call(document.querySelectorAll('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]'))); 9397 var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE)); 9398 for (var i = 0, len = toggleList.length; i < len; i++) { 9399 var elem = toggleList[i]; 9400 var selector = Util.getSelectorFromElement(elem); 9401 var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function(foundElem) { 9402 return foundElem === element; 9403 }); 9404 if (selector !== null && filterElement.length > 0) { 9405 this._selector = selector; 9406 this._triggerArray.push(elem); 9407 } 9408 } 9409 this._parent = this._config.parent ? this._getParent() : null; 9410 if (!this._config.parent) { 9411 this._addAriaAndCollapsedClass(this._element, this._triggerArray); 9412 } 9413 if (this._config.toggle) { 9414 this.toggle(); 9415 } 9416 } 9417 var _proto = Collapse2.prototype; 9418 _proto.toggle = function toggle() { 9419 if ($3(this._element).hasClass(ClassName$3.SHOW)) { 9420 this.hide(); 9421 } else { 9422 this.show(); 9423 } 9424 }; 9425 _proto.show = function show() { 9426 var _this = this; 9427 if (this._isTransitioning || $3(this._element).hasClass(ClassName$3.SHOW)) { 9428 return; 9429 } 9430 var actives; 9431 var activesData; 9432 if (this._parent) { 9433 actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function(elem) { 9434 if (typeof _this._config.parent === "string") { 9435 return elem.getAttribute("data-parent") === _this._config.parent; 9436 } 9437 return elem.classList.contains(ClassName$3.COLLAPSE); 9438 }); 9439 if (actives.length === 0) { 9440 actives = null; 9441 } 9442 } 9443 if (actives) { 9444 activesData = $3(actives).not(this._selector).data(DATA_KEY$3); 9445 if (activesData && activesData._isTransitioning) { 9446 return; 9447 } 9448 } 9449 var startEvent = $3.Event(Event$3.SHOW); 9450 $3(this._element).trigger(startEvent); 9451 if (startEvent.isDefaultPrevented()) { 9452 return; 9453 } 9454 if (actives) { 9455 Collapse2._jQueryInterface.call($3(actives).not(this._selector), "hide"); 9456 if (!activesData) { 9457 $3(actives).data(DATA_KEY$3, null); 9458 } 9459 } 9460 var dimension = this._getDimension(); 9461 $3(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING); 9462 this._element.style[dimension] = 0; 9463 if (this._triggerArray.length) { 9464 $3(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr("aria-expanded", true); 9465 } 9466 this.setTransitioning(true); 9467 var complete = function complete2() { 9468 $3(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW); 9469 _this._element.style[dimension] = ""; 9470 _this.setTransitioning(false); 9471 $3(_this._element).trigger(Event$3.SHOWN); 9472 }; 9473 var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); 9474 var scrollSize = "scroll" + capitalizedDimension; 9475 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 9476 $3(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 9477 this._element.style[dimension] = this._element[scrollSize] + "px"; 9478 }; 9479 _proto.hide = function hide() { 9480 var _this2 = this; 9481 if (this._isTransitioning || !$3(this._element).hasClass(ClassName$3.SHOW)) { 9482 return; 9483 } 9484 var startEvent = $3.Event(Event$3.HIDE); 9485 $3(this._element).trigger(startEvent); 9486 if (startEvent.isDefaultPrevented()) { 9487 return; 9488 } 9489 var dimension = this._getDimension(); 9490 this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px"; 9491 Util.reflow(this._element); 9492 $3(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW); 9493 var triggerArrayLength = this._triggerArray.length; 9494 if (triggerArrayLength > 0) { 9495 for (var i = 0; i < triggerArrayLength; i++) { 9496 var trigger = this._triggerArray[i]; 9497 var selector = Util.getSelectorFromElement(trigger); 9498 if (selector !== null) { 9499 var $elem = $3([].slice.call(document.querySelectorAll(selector))); 9500 if (!$elem.hasClass(ClassName$3.SHOW)) { 9501 $3(trigger).addClass(ClassName$3.COLLAPSED).attr("aria-expanded", false); 9502 } 9503 } 9504 } 9505 } 9506 this.setTransitioning(true); 9507 var complete = function complete2() { 9508 _this2.setTransitioning(false); 9509 $3(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN); 9510 }; 9511 this._element.style[dimension] = ""; 9512 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 9513 $3(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 9514 }; 9515 _proto.setTransitioning = function setTransitioning(isTransitioning) { 9516 this._isTransitioning = isTransitioning; 9517 }; 9518 _proto.dispose = function dispose() { 9519 $3.removeData(this._element, DATA_KEY$3); 9520 this._config = null; 9521 this._parent = null; 9522 this._element = null; 9523 this._triggerArray = null; 9524 this._isTransitioning = null; 9525 }; 9526 _proto._getConfig = function _getConfig(config2) { 9527 config2 = _objectSpread({}, Default$1, config2); 9528 config2.toggle = Boolean(config2.toggle); 9529 Util.typeCheckConfig(NAME$3, config2, DefaultType$1); 9530 return config2; 9531 }; 9532 _proto._getDimension = function _getDimension() { 9533 var hasWidth = $3(this._element).hasClass(Dimension.WIDTH); 9534 return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; 9535 }; 9536 _proto._getParent = function _getParent() { 9537 var _this3 = this; 9538 var parent; 9539 if (Util.isElement(this._config.parent)) { 9540 parent = this._config.parent; 9541 if (typeof this._config.parent.jquery !== "undefined") { 9542 parent = this._config.parent[0]; 9543 } 9544 } else { 9545 parent = document.querySelector(this._config.parent); 9546 } 9547 var selector = '[data-toggle="collapse"][data-parent="' + this._config.parent + '"]'; 9548 var children = [].slice.call(parent.querySelectorAll(selector)); 9549 $3(children).each(function(i, element) { 9550 _this3._addAriaAndCollapsedClass(Collapse2._getTargetFromElement(element), [element]); 9551 }); 9552 return parent; 9553 }; 9554 _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) { 9555 var isOpen = $3(element).hasClass(ClassName$3.SHOW); 9556 if (triggerArray.length) { 9557 $3(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr("aria-expanded", isOpen); 9558 } 9559 }; 9560 Collapse2._getTargetFromElement = function _getTargetFromElement(element) { 9561 var selector = Util.getSelectorFromElement(element); 9562 return selector ? document.querySelector(selector) : null; 9563 }; 9564 Collapse2._jQueryInterface = function _jQueryInterface(config2) { 9565 return this.each(function() { 9566 var $this = $3(this); 9567 var data = $this.data(DATA_KEY$3); 9568 var _config = _objectSpread({}, Default$1, $this.data(), typeof config2 === "object" && config2 ? config2 : {}); 9569 if (!data && _config.toggle && /show|hide/.test(config2)) { 9570 _config.toggle = false; 9571 } 9572 if (!data) { 9573 data = new Collapse2(this, _config); 9574 $this.data(DATA_KEY$3, data); 9575 } 9576 if (typeof config2 === "string") { 9577 if (typeof data[config2] === "undefined") { 9578 throw new TypeError('No method named "' + config2 + '"'); 9579 } 9580 data[config2](); 9581 } 9582 }); 9583 }; 9584 _createClass(Collapse2, null, [{ 9585 key: "VERSION", 9586 get: function get() { 9587 return VERSION$3; 9588 } 9589 }, { 9590 key: "Default", 9591 get: function get() { 9592 return Default$1; 9593 } 9594 }]); 9595 return Collapse2; 9596 })(); 9597 $3(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function(event) { 9598 if (event.currentTarget.tagName === "A") { 9599 event.preventDefault(); 9600 } 9601 var $trigger = $3(this); 9602 var selector = Util.getSelectorFromElement(this); 9603 var selectors = [].slice.call(document.querySelectorAll(selector)); 9604 $3(selectors).each(function() { 9605 var $target = $3(this); 9606 var data = $target.data(DATA_KEY$3); 9607 var config2 = data ? "toggle" : $trigger.data(); 9608 Collapse._jQueryInterface.call($target, config2); 9609 }); 9610 }); 9611 $3.fn[NAME$3] = Collapse._jQueryInterface; 9612 $3.fn[NAME$3].Constructor = Collapse; 9613 $3.fn[NAME$3].noConflict = function() { 9614 $3.fn[NAME$3] = JQUERY_NO_CONFLICT$3; 9615 return Collapse._jQueryInterface; 9616 }; 9617 var NAME$4 = "dropdown"; 9618 var VERSION$4 = "4.3.1"; 9619 var DATA_KEY$4 = "bs.dropdown"; 9620 var EVENT_KEY$4 = "." + DATA_KEY$4; 9621 var DATA_API_KEY$4 = ".data-api"; 9622 var JQUERY_NO_CONFLICT$4 = $3.fn[NAME$4]; 9623 var ESCAPE_KEYCODE = 27; 9624 var SPACE_KEYCODE = 32; 9625 var TAB_KEYCODE = 9; 9626 var ARROW_UP_KEYCODE = 38; 9627 var ARROW_DOWN_KEYCODE = 40; 9628 var RIGHT_MOUSE_BUTTON_WHICH = 3; 9629 var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE); 9630 var Event$4 = { 9631 HIDE: "hide" + EVENT_KEY$4, 9632 HIDDEN: "hidden" + EVENT_KEY$4, 9633 SHOW: "show" + EVENT_KEY$4, 9634 SHOWN: "shown" + EVENT_KEY$4, 9635 CLICK: "click" + EVENT_KEY$4, 9636 CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4, 9637 KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4, 9638 KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4 9639 }; 9640 var ClassName$4 = { 9641 DISABLED: "disabled", 9642 SHOW: "show", 9643 DROPUP: "dropup", 9644 DROPRIGHT: "dropright", 9645 DROPLEFT: "dropleft", 9646 MENURIGHT: "dropdown-menu-right", 9647 MENULEFT: "dropdown-menu-left", 9648 POSITION_STATIC: "position-static" 9649 }; 9650 var Selector$4 = { 9651 DATA_TOGGLE: '[data-toggle="dropdown"]', 9652 FORM_CHILD: ".dropdown form", 9653 MENU: ".dropdown-menu", 9654 NAVBAR_NAV: ".navbar-nav", 9655 VISIBLE_ITEMS: ".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)" 9656 }; 9657 var AttachmentMap = { 9658 TOP: "top-start", 9659 TOPEND: "top-end", 9660 BOTTOM: "bottom-start", 9661 BOTTOMEND: "bottom-end", 9662 RIGHT: "right-start", 9663 RIGHTEND: "right-end", 9664 LEFT: "left-start", 9665 LEFTEND: "left-end" 9666 }; 9667 var Default$2 = { 9668 offset: 0, 9669 flip: true, 9670 boundary: "scrollParent", 9671 reference: "toggle", 9672 display: "dynamic" 9673 }; 9674 var DefaultType$2 = { 9675 offset: "(number|string|function)", 9676 flip: "boolean", 9677 boundary: "(string|element)", 9678 reference: "(string|element)", 9679 display: "string" 9680 /** 9681 * ------------------------------------------------------------------------ 9682 * Class Definition 9683 * ------------------------------------------------------------------------ 9684 */ 9685 }; 9686 var Dropdown = /* @__PURE__ */ (function() { 9687 function Dropdown2(element, config2) { 9688 this._element = element; 9689 this._popper = null; 9690 this._config = this._getConfig(config2); 9691 this._menu = this._getMenuElement(); 9692 this._inNavbar = this._detectNavbar(); 9693 this._addEventListeners(); 9694 } 9695 var _proto = Dropdown2.prototype; 9696 _proto.toggle = function toggle() { 9697 if (this._element.disabled || $3(this._element).hasClass(ClassName$4.DISABLED)) { 9698 return; 9699 } 9700 var parent = Dropdown2._getParentFromElement(this._element); 9701 var isActive = $3(this._menu).hasClass(ClassName$4.SHOW); 9702 Dropdown2._clearMenus(); 9703 if (isActive) { 9704 return; 9705 } 9706 var relatedTarget = { 9707 relatedTarget: this._element 9708 }; 9709 var showEvent = $3.Event(Event$4.SHOW, relatedTarget); 9710 $3(parent).trigger(showEvent); 9711 if (showEvent.isDefaultPrevented()) { 9712 return; 9713 } 9714 if (!this._inNavbar) { 9715 if (typeof Popper === "undefined") { 9716 throw new TypeError("Bootstrap's dropdowns require Popper.js (https://popper.js.org/)"); 9717 } 9718 var referenceElement = this._element; 9719 if (this._config.reference === "parent") { 9720 referenceElement = parent; 9721 } else if (Util.isElement(this._config.reference)) { 9722 referenceElement = this._config.reference; 9723 if (typeof this._config.reference.jquery !== "undefined") { 9724 referenceElement = this._config.reference[0]; 9725 } 9726 } 9727 if (this._config.boundary !== "scrollParent") { 9728 $3(parent).addClass(ClassName$4.POSITION_STATIC); 9729 } 9730 this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig()); 9731 } 9732 if ("ontouchstart" in document.documentElement && $3(parent).closest(Selector$4.NAVBAR_NAV).length === 0) { 9733 $3(document.body).children().on("mouseover", null, $3.noop); 9734 } 9735 this._element.focus(); 9736 this._element.setAttribute("aria-expanded", true); 9737 $3(this._menu).toggleClass(ClassName$4.SHOW); 9738 $3(parent).toggleClass(ClassName$4.SHOW).trigger($3.Event(Event$4.SHOWN, relatedTarget)); 9739 }; 9740 _proto.show = function show() { 9741 if (this._element.disabled || $3(this._element).hasClass(ClassName$4.DISABLED) || $3(this._menu).hasClass(ClassName$4.SHOW)) { 9742 return; 9743 } 9744 var relatedTarget = { 9745 relatedTarget: this._element 9746 }; 9747 var showEvent = $3.Event(Event$4.SHOW, relatedTarget); 9748 var parent = Dropdown2._getParentFromElement(this._element); 9749 $3(parent).trigger(showEvent); 9750 if (showEvent.isDefaultPrevented()) { 9751 return; 9752 } 9753 $3(this._menu).toggleClass(ClassName$4.SHOW); 9754 $3(parent).toggleClass(ClassName$4.SHOW).trigger($3.Event(Event$4.SHOWN, relatedTarget)); 9755 }; 9756 _proto.hide = function hide() { 9757 if (this._element.disabled || $3(this._element).hasClass(ClassName$4.DISABLED) || !$3(this._menu).hasClass(ClassName$4.SHOW)) { 9758 return; 9759 } 9760 var relatedTarget = { 9761 relatedTarget: this._element 9762 }; 9763 var hideEvent = $3.Event(Event$4.HIDE, relatedTarget); 9764 var parent = Dropdown2._getParentFromElement(this._element); 9765 $3(parent).trigger(hideEvent); 9766 if (hideEvent.isDefaultPrevented()) { 9767 return; 9768 } 9769 $3(this._menu).toggleClass(ClassName$4.SHOW); 9770 $3(parent).toggleClass(ClassName$4.SHOW).trigger($3.Event(Event$4.HIDDEN, relatedTarget)); 9771 }; 9772 _proto.dispose = function dispose() { 9773 $3.removeData(this._element, DATA_KEY$4); 9774 $3(this._element).off(EVENT_KEY$4); 9775 this._element = null; 9776 this._menu = null; 9777 if (this._popper !== null) { 9778 this._popper.destroy(); 9779 this._popper = null; 9780 } 9781 }; 9782 _proto.update = function update() { 9783 this._inNavbar = this._detectNavbar(); 9784 if (this._popper !== null) { 9785 this._popper.scheduleUpdate(); 9786 } 9787 }; 9788 _proto._addEventListeners = function _addEventListeners() { 9789 var _this = this; 9790 $3(this._element).on(Event$4.CLICK, function(event) { 9791 event.preventDefault(); 9792 event.stopPropagation(); 9793 _this.toggle(); 9794 }); 9795 }; 9796 _proto._getConfig = function _getConfig(config2) { 9797 config2 = _objectSpread({}, this.constructor.Default, $3(this._element).data(), config2); 9798 Util.typeCheckConfig(NAME$4, config2, this.constructor.DefaultType); 9799 return config2; 9800 }; 9801 _proto._getMenuElement = function _getMenuElement() { 9802 if (!this._menu) { 9803 var parent = Dropdown2._getParentFromElement(this._element); 9804 if (parent) { 9805 this._menu = parent.querySelector(Selector$4.MENU); 9806 } 9807 } 9808 return this._menu; 9809 }; 9810 _proto._getPlacement = function _getPlacement() { 9811 var $parentDropdown = $3(this._element.parentNode); 9812 var placement = AttachmentMap.BOTTOM; 9813 if ($parentDropdown.hasClass(ClassName$4.DROPUP)) { 9814 placement = AttachmentMap.TOP; 9815 if ($3(this._menu).hasClass(ClassName$4.MENURIGHT)) { 9816 placement = AttachmentMap.TOPEND; 9817 } 9818 } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) { 9819 placement = AttachmentMap.RIGHT; 9820 } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) { 9821 placement = AttachmentMap.LEFT; 9822 } else if ($3(this._menu).hasClass(ClassName$4.MENURIGHT)) { 9823 placement = AttachmentMap.BOTTOMEND; 9824 } 9825 return placement; 9826 }; 9827 _proto._detectNavbar = function _detectNavbar() { 9828 return $3(this._element).closest(".navbar").length > 0; 9829 }; 9830 _proto._getOffset = function _getOffset() { 9831 var _this2 = this; 9832 var offset = {}; 9833 if (typeof this._config.offset === "function") { 9834 offset.fn = function(data) { 9835 data.offsets = _objectSpread({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {}); 9836 return data; 9837 }; 9838 } else { 9839 offset.offset = this._config.offset; 9840 } 9841 return offset; 9842 }; 9843 _proto._getPopperConfig = function _getPopperConfig() { 9844 var popperConfig = { 9845 placement: this._getPlacement(), 9846 modifiers: { 9847 offset: this._getOffset(), 9848 flip: { 9849 enabled: this._config.flip 9850 }, 9851 preventOverflow: { 9852 boundariesElement: this._config.boundary 9853 } 9854 } 9855 // Disable Popper.js if we have a static display 9856 }; 9857 if (this._config.display === "static") { 9858 popperConfig.modifiers.applyStyle = { 9859 enabled: false 9860 }; 9861 } 9862 return popperConfig; 9863 }; 9864 Dropdown2._jQueryInterface = function _jQueryInterface(config2) { 9865 return this.each(function() { 9866 var data = $3(this).data(DATA_KEY$4); 9867 var _config = typeof config2 === "object" ? config2 : null; 9868 if (!data) { 9869 data = new Dropdown2(this, _config); 9870 $3(this).data(DATA_KEY$4, data); 9871 } 9872 if (typeof config2 === "string") { 9873 if (typeof data[config2] === "undefined") { 9874 throw new TypeError('No method named "' + config2 + '"'); 9875 } 9876 data[config2](); 9877 } 9878 }); 9879 }; 9880 Dropdown2._clearMenus = function _clearMenus(event) { 9881 if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === "keyup" && event.which !== TAB_KEYCODE)) { 9882 return; 9883 } 9884 var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE)); 9885 for (var i = 0, len = toggles.length; i < len; i++) { 9886 var parent = Dropdown2._getParentFromElement(toggles[i]); 9887 var context = $3(toggles[i]).data(DATA_KEY$4); 9888 var relatedTarget = { 9889 relatedTarget: toggles[i] 9890 }; 9891 if (event && event.type === "click") { 9892 relatedTarget.clickEvent = event; 9893 } 9894 if (!context) { 9895 continue; 9896 } 9897 var dropdownMenu = context._menu; 9898 if (!$3(parent).hasClass(ClassName$4.SHOW)) { 9899 continue; 9900 } 9901 if (event && (event.type === "click" && /input|textarea/i.test(event.target.tagName) || event.type === "keyup" && event.which === TAB_KEYCODE) && $3.contains(parent, event.target)) { 9902 continue; 9903 } 9904 var hideEvent = $3.Event(Event$4.HIDE, relatedTarget); 9905 $3(parent).trigger(hideEvent); 9906 if (hideEvent.isDefaultPrevented()) { 9907 continue; 9908 } 9909 if ("ontouchstart" in document.documentElement) { 9910 $3(document.body).children().off("mouseover", null, $3.noop); 9911 } 9912 toggles[i].setAttribute("aria-expanded", "false"); 9913 $3(dropdownMenu).removeClass(ClassName$4.SHOW); 9914 $3(parent).removeClass(ClassName$4.SHOW).trigger($3.Event(Event$4.HIDDEN, relatedTarget)); 9915 } 9916 }; 9917 Dropdown2._getParentFromElement = function _getParentFromElement(element) { 9918 var parent; 9919 var selector = Util.getSelectorFromElement(element); 9920 if (selector) { 9921 parent = document.querySelector(selector); 9922 } 9923 return parent || element.parentNode; 9924 }; 9925 Dropdown2._dataApiKeydownHandler = function _dataApiKeydownHandler(event) { 9926 if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $3(event.target).closest(Selector$4.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) { 9927 return; 9928 } 9929 event.preventDefault(); 9930 event.stopPropagation(); 9931 if (this.disabled || $3(this).hasClass(ClassName$4.DISABLED)) { 9932 return; 9933 } 9934 var parent = Dropdown2._getParentFromElement(this); 9935 var isActive = $3(parent).hasClass(ClassName$4.SHOW); 9936 if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { 9937 if (event.which === ESCAPE_KEYCODE) { 9938 var toggle = parent.querySelector(Selector$4.DATA_TOGGLE); 9939 $3(toggle).trigger("focus"); 9940 } 9941 $3(this).trigger("click"); 9942 return; 9943 } 9944 var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)); 9945 if (items.length === 0) { 9946 return; 9947 } 9948 var index = items.indexOf(event.target); 9949 if (event.which === ARROW_UP_KEYCODE && index > 0) { 9950 index--; 9951 } 9952 if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { 9953 index++; 9954 } 9955 if (index < 0) { 9956 index = 0; 9957 } 9958 items[index].focus(); 9959 }; 9960 _createClass(Dropdown2, null, [{ 9961 key: "VERSION", 9962 get: function get() { 9963 return VERSION$4; 9964 } 9965 }, { 9966 key: "Default", 9967 get: function get() { 9968 return Default$2; 9969 } 9970 }, { 9971 key: "DefaultType", 9972 get: function get() { 9973 return DefaultType$2; 9974 } 9975 }]); 9976 return Dropdown2; 9977 })(); 9978 $3(document).on(Event$4.KEYDOWN_DATA_API, Selector$4.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event$4.KEYDOWN_DATA_API, Selector$4.MENU, Dropdown._dataApiKeydownHandler).on(Event$4.CLICK_DATA_API + " " + Event$4.KEYUP_DATA_API, Dropdown._clearMenus).on(Event$4.CLICK_DATA_API, Selector$4.DATA_TOGGLE, function(event) { 9979 event.preventDefault(); 9980 event.stopPropagation(); 9981 Dropdown._jQueryInterface.call($3(this), "toggle"); 9982 }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function(e) { 9983 e.stopPropagation(); 9984 }); 9985 $3.fn[NAME$4] = Dropdown._jQueryInterface; 9986 $3.fn[NAME$4].Constructor = Dropdown; 9987 $3.fn[NAME$4].noConflict = function() { 9988 $3.fn[NAME$4] = JQUERY_NO_CONFLICT$4; 9989 return Dropdown._jQueryInterface; 9990 }; 9991 var NAME$5 = "modal"; 9992 var VERSION$5 = "4.3.1"; 9993 var DATA_KEY$5 = "bs.modal"; 9994 var EVENT_KEY$5 = "." + DATA_KEY$5; 9995 var DATA_API_KEY$5 = ".data-api"; 9996 var JQUERY_NO_CONFLICT$5 = $3.fn[NAME$5]; 9997 var ESCAPE_KEYCODE$1 = 27; 9998 var Default$3 = { 9999 backdrop: true, 10000 keyboard: true, 10001 focus: true, 10002 show: true 10003 }; 10004 var DefaultType$3 = { 10005 backdrop: "(boolean|string)", 10006 keyboard: "boolean", 10007 focus: "boolean", 10008 show: "boolean" 10009 }; 10010 var Event$5 = { 10011 HIDE: "hide" + EVENT_KEY$5, 10012 HIDDEN: "hidden" + EVENT_KEY$5, 10013 SHOW: "show" + EVENT_KEY$5, 10014 SHOWN: "shown" + EVENT_KEY$5, 10015 FOCUSIN: "focusin" + EVENT_KEY$5, 10016 RESIZE: "resize" + EVENT_KEY$5, 10017 CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5, 10018 KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5, 10019 MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5, 10020 MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5, 10021 CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5 10022 }; 10023 var ClassName$5 = { 10024 SCROLLABLE: "modal-dialog-scrollable", 10025 SCROLLBAR_MEASURER: "modal-scrollbar-measure", 10026 BACKDROP: "modal-backdrop", 10027 OPEN: "modal-open", 10028 FADE: "fade", 10029 SHOW: "show" 10030 }; 10031 var Selector$5 = { 10032 DIALOG: ".modal-dialog", 10033 MODAL_BODY: ".modal-body", 10034 DATA_TOGGLE: '[data-toggle="modal"]', 10035 DATA_DISMISS: '[data-dismiss="modal"]', 10036 FIXED_CONTENT: ".fixed-top, .fixed-bottom, .is-fixed, .sticky-top", 10037 STICKY_CONTENT: ".sticky-top" 10038 /** 10039 * ------------------------------------------------------------------------ 10040 * Class Definition 10041 * ------------------------------------------------------------------------ 10042 */ 10043 }; 10044 var Modal = /* @__PURE__ */ (function() { 10045 function Modal2(element, config2) { 10046 this._config = this._getConfig(config2); 10047 this._element = element; 10048 this._dialog = element.querySelector(Selector$5.DIALOG); 10049 this._backdrop = null; 10050 this._isShown = false; 10051 this._isBodyOverflowing = false; 10052 this._ignoreBackdropClick = false; 10053 this._isTransitioning = false; 10054 this._scrollbarWidth = 0; 10055 } 10056 var _proto = Modal2.prototype; 10057 _proto.toggle = function toggle(relatedTarget) { 10058 return this._isShown ? this.hide() : this.show(relatedTarget); 10059 }; 10060 _proto.show = function show(relatedTarget) { 10061 var _this = this; 10062 if (this._isShown || this._isTransitioning) { 10063 return; 10064 } 10065 if ($3(this._element).hasClass(ClassName$5.FADE)) { 10066 this._isTransitioning = true; 10067 } 10068 var showEvent = $3.Event(Event$5.SHOW, { 10069 relatedTarget 10070 }); 10071 $3(this._element).trigger(showEvent); 10072 if (this._isShown || showEvent.isDefaultPrevented()) { 10073 return; 10074 } 10075 this._isShown = true; 10076 this._checkScrollbar(); 10077 this._setScrollbar(); 10078 this._adjustDialog(); 10079 this._setEscapeEvent(); 10080 this._setResizeEvent(); 10081 $3(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function(event) { 10082 return _this.hide(event); 10083 }); 10084 $3(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function() { 10085 $3(_this._element).one(Event$5.MOUSEUP_DISMISS, function(event) { 10086 if ($3(event.target).is(_this._element)) { 10087 _this._ignoreBackdropClick = true; 10088 } 10089 }); 10090 }); 10091 this._showBackdrop(function() { 10092 return _this._showElement(relatedTarget); 10093 }); 10094 }; 10095 _proto.hide = function hide(event) { 10096 var _this2 = this; 10097 if (event) { 10098 event.preventDefault(); 10099 } 10100 if (!this._isShown || this._isTransitioning) { 10101 return; 10102 } 10103 var hideEvent = $3.Event(Event$5.HIDE); 10104 $3(this._element).trigger(hideEvent); 10105 if (!this._isShown || hideEvent.isDefaultPrevented()) { 10106 return; 10107 } 10108 this._isShown = false; 10109 var transition = $3(this._element).hasClass(ClassName$5.FADE); 10110 if (transition) { 10111 this._isTransitioning = true; 10112 } 10113 this._setEscapeEvent(); 10114 this._setResizeEvent(); 10115 $3(document).off(Event$5.FOCUSIN); 10116 $3(this._element).removeClass(ClassName$5.SHOW); 10117 $3(this._element).off(Event$5.CLICK_DISMISS); 10118 $3(this._dialog).off(Event$5.MOUSEDOWN_DISMISS); 10119 if (transition) { 10120 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 10121 $3(this._element).one(Util.TRANSITION_END, function(event2) { 10122 return _this2._hideModal(event2); 10123 }).emulateTransitionEnd(transitionDuration); 10124 } else { 10125 this._hideModal(); 10126 } 10127 }; 10128 _proto.dispose = function dispose() { 10129 [window, this._element, this._dialog].forEach(function(htmlElement) { 10130 return $3(htmlElement).off(EVENT_KEY$5); 10131 }); 10132 $3(document).off(Event$5.FOCUSIN); 10133 $3.removeData(this._element, DATA_KEY$5); 10134 this._config = null; 10135 this._element = null; 10136 this._dialog = null; 10137 this._backdrop = null; 10138 this._isShown = null; 10139 this._isBodyOverflowing = null; 10140 this._ignoreBackdropClick = null; 10141 this._isTransitioning = null; 10142 this._scrollbarWidth = null; 10143 }; 10144 _proto.handleUpdate = function handleUpdate() { 10145 this._adjustDialog(); 10146 }; 10147 _proto._getConfig = function _getConfig(config2) { 10148 config2 = _objectSpread({}, Default$3, config2); 10149 Util.typeCheckConfig(NAME$5, config2, DefaultType$3); 10150 return config2; 10151 }; 10152 _proto._showElement = function _showElement(relatedTarget) { 10153 var _this3 = this; 10154 var transition = $3(this._element).hasClass(ClassName$5.FADE); 10155 if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { 10156 document.body.appendChild(this._element); 10157 } 10158 this._element.style.display = "block"; 10159 this._element.removeAttribute("aria-hidden"); 10160 this._element.setAttribute("aria-modal", true); 10161 if ($3(this._dialog).hasClass(ClassName$5.SCROLLABLE)) { 10162 this._dialog.querySelector(Selector$5.MODAL_BODY).scrollTop = 0; 10163 } else { 10164 this._element.scrollTop = 0; 10165 } 10166 if (transition) { 10167 Util.reflow(this._element); 10168 } 10169 $3(this._element).addClass(ClassName$5.SHOW); 10170 if (this._config.focus) { 10171 this._enforceFocus(); 10172 } 10173 var shownEvent = $3.Event(Event$5.SHOWN, { 10174 relatedTarget 10175 }); 10176 var transitionComplete = function transitionComplete2() { 10177 if (_this3._config.focus) { 10178 _this3._element.focus(); 10179 } 10180 _this3._isTransitioning = false; 10181 $3(_this3._element).trigger(shownEvent); 10182 }; 10183 if (transition) { 10184 var transitionDuration = Util.getTransitionDurationFromElement(this._dialog); 10185 $3(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration); 10186 } else { 10187 transitionComplete(); 10188 } 10189 }; 10190 _proto._enforceFocus = function _enforceFocus() { 10191 var _this4 = this; 10192 $3(document).off(Event$5.FOCUSIN).on(Event$5.FOCUSIN, function(event) { 10193 if (document !== event.target && _this4._element !== event.target && $3(_this4._element).has(event.target).length === 0) { 10194 _this4._element.focus(); 10195 } 10196 }); 10197 }; 10198 _proto._setEscapeEvent = function _setEscapeEvent() { 10199 var _this5 = this; 10200 if (this._isShown && this._config.keyboard) { 10201 $3(this._element).on(Event$5.KEYDOWN_DISMISS, function(event) { 10202 if (event.which === ESCAPE_KEYCODE$1) { 10203 event.preventDefault(); 10204 _this5.hide(); 10205 } 10206 }); 10207 } else if (!this._isShown) { 10208 $3(this._element).off(Event$5.KEYDOWN_DISMISS); 10209 } 10210 }; 10211 _proto._setResizeEvent = function _setResizeEvent() { 10212 var _this6 = this; 10213 if (this._isShown) { 10214 $3(window).on(Event$5.RESIZE, function(event) { 10215 return _this6.handleUpdate(event); 10216 }); 10217 } else { 10218 $3(window).off(Event$5.RESIZE); 10219 } 10220 }; 10221 _proto._hideModal = function _hideModal() { 10222 var _this7 = this; 10223 this._element.style.display = "none"; 10224 this._element.setAttribute("aria-hidden", true); 10225 this._element.removeAttribute("aria-modal"); 10226 this._isTransitioning = false; 10227 this._showBackdrop(function() { 10228 $3(document.body).removeClass(ClassName$5.OPEN); 10229 _this7._resetAdjustments(); 10230 _this7._resetScrollbar(); 10231 $3(_this7._element).trigger(Event$5.HIDDEN); 10232 }); 10233 }; 10234 _proto._removeBackdrop = function _removeBackdrop() { 10235 if (this._backdrop) { 10236 $3(this._backdrop).remove(); 10237 this._backdrop = null; 10238 } 10239 }; 10240 _proto._showBackdrop = function _showBackdrop(callback) { 10241 var _this8 = this; 10242 var animate = $3(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : ""; 10243 if (this._isShown && this._config.backdrop) { 10244 this._backdrop = document.createElement("div"); 10245 this._backdrop.className = ClassName$5.BACKDROP; 10246 if (animate) { 10247 this._backdrop.classList.add(animate); 10248 } 10249 $3(this._backdrop).appendTo(document.body); 10250 $3(this._element).on(Event$5.CLICK_DISMISS, function(event) { 10251 if (_this8._ignoreBackdropClick) { 10252 _this8._ignoreBackdropClick = false; 10253 return; 10254 } 10255 if (event.target !== event.currentTarget) { 10256 return; 10257 } 10258 if (_this8._config.backdrop === "static") { 10259 _this8._element.focus(); 10260 } else { 10261 _this8.hide(); 10262 } 10263 }); 10264 if (animate) { 10265 Util.reflow(this._backdrop); 10266 } 10267 $3(this._backdrop).addClass(ClassName$5.SHOW); 10268 if (!callback) { 10269 return; 10270 } 10271 if (!animate) { 10272 callback(); 10273 return; 10274 } 10275 var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); 10276 $3(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration); 10277 } else if (!this._isShown && this._backdrop) { 10278 $3(this._backdrop).removeClass(ClassName$5.SHOW); 10279 var callbackRemove = function callbackRemove2() { 10280 _this8._removeBackdrop(); 10281 if (callback) { 10282 callback(); 10283 } 10284 }; 10285 if ($3(this._element).hasClass(ClassName$5.FADE)) { 10286 var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); 10287 $3(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration); 10288 } else { 10289 callbackRemove(); 10290 } 10291 } else if (callback) { 10292 callback(); 10293 } 10294 }; 10295 _proto._adjustDialog = function _adjustDialog() { 10296 var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; 10297 if (!this._isBodyOverflowing && isModalOverflowing) { 10298 this._element.style.paddingLeft = this._scrollbarWidth + "px"; 10299 } 10300 if (this._isBodyOverflowing && !isModalOverflowing) { 10301 this._element.style.paddingRight = this._scrollbarWidth + "px"; 10302 } 10303 }; 10304 _proto._resetAdjustments = function _resetAdjustments() { 10305 this._element.style.paddingLeft = ""; 10306 this._element.style.paddingRight = ""; 10307 }; 10308 _proto._checkScrollbar = function _checkScrollbar() { 10309 var rect = document.body.getBoundingClientRect(); 10310 this._isBodyOverflowing = rect.left + rect.right < window.innerWidth; 10311 this._scrollbarWidth = this._getScrollbarWidth(); 10312 }; 10313 _proto._setScrollbar = function _setScrollbar() { 10314 var _this9 = this; 10315 if (this._isBodyOverflowing) { 10316 var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT)); 10317 var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); 10318 $3(fixedContent).each(function(index, element) { 10319 var actualPadding2 = element.style.paddingRight; 10320 var calculatedPadding2 = $3(element).css("padding-right"); 10321 $3(element).data("padding-right", actualPadding2).css("padding-right", parseFloat(calculatedPadding2) + _this9._scrollbarWidth + "px"); 10322 }); 10323 $3(stickyContent).each(function(index, element) { 10324 var actualMargin = element.style.marginRight; 10325 var calculatedMargin = $3(element).css("margin-right"); 10326 $3(element).data("margin-right", actualMargin).css("margin-right", parseFloat(calculatedMargin) - _this9._scrollbarWidth + "px"); 10327 }); 10328 var actualPadding = document.body.style.paddingRight; 10329 var calculatedPadding = $3(document.body).css("padding-right"); 10330 $3(document.body).data("padding-right", actualPadding).css("padding-right", parseFloat(calculatedPadding) + this._scrollbarWidth + "px"); 10331 } 10332 $3(document.body).addClass(ClassName$5.OPEN); 10333 }; 10334 _proto._resetScrollbar = function _resetScrollbar() { 10335 var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT)); 10336 $3(fixedContent).each(function(index, element) { 10337 var padding2 = $3(element).data("padding-right"); 10338 $3(element).removeData("padding-right"); 10339 element.style.paddingRight = padding2 ? padding2 : ""; 10340 }); 10341 var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT)); 10342 $3(elements).each(function(index, element) { 10343 var margin = $3(element).data("margin-right"); 10344 if (typeof margin !== "undefined") { 10345 $3(element).css("margin-right", margin).removeData("margin-right"); 10346 } 10347 }); 10348 var padding = $3(document.body).data("padding-right"); 10349 $3(document.body).removeData("padding-right"); 10350 document.body.style.paddingRight = padding ? padding : ""; 10351 }; 10352 _proto._getScrollbarWidth = function _getScrollbarWidth() { 10353 var scrollDiv = document.createElement("div"); 10354 scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER; 10355 document.body.appendChild(scrollDiv); 10356 var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth; 10357 document.body.removeChild(scrollDiv); 10358 return scrollbarWidth; 10359 }; 10360 Modal2._jQueryInterface = function _jQueryInterface(config2, relatedTarget) { 10361 return this.each(function() { 10362 var data = $3(this).data(DATA_KEY$5); 10363 var _config = _objectSpread({}, Default$3, $3(this).data(), typeof config2 === "object" && config2 ? config2 : {}); 10364 if (!data) { 10365 data = new Modal2(this, _config); 10366 $3(this).data(DATA_KEY$5, data); 10367 } 10368 if (typeof config2 === "string") { 10369 if (typeof data[config2] === "undefined") { 10370 throw new TypeError('No method named "' + config2 + '"'); 10371 } 10372 data[config2](relatedTarget); 10373 } else if (_config.show) { 10374 data.show(relatedTarget); 10375 } 10376 }); 10377 }; 10378 _createClass(Modal2, null, [{ 10379 key: "VERSION", 10380 get: function get() { 10381 return VERSION$5; 10382 } 10383 }, { 10384 key: "Default", 10385 get: function get() { 10386 return Default$3; 10387 } 10388 }]); 10389 return Modal2; 10390 })(); 10391 $3(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function(event) { 10392 var _this10 = this; 10393 var target; 10394 var selector = Util.getSelectorFromElement(this); 10395 if (selector) { 10396 target = document.querySelector(selector); 10397 } 10398 var config2 = $3(target).data(DATA_KEY$5) ? "toggle" : _objectSpread({}, $3(target).data(), $3(this).data()); 10399 if (this.tagName === "A" || this.tagName === "AREA") { 10400 event.preventDefault(); 10401 } 10402 var $target = $3(target).one(Event$5.SHOW, function(showEvent) { 10403 if (showEvent.isDefaultPrevented()) { 10404 return; 10405 } 10406 $target.one(Event$5.HIDDEN, function() { 10407 if ($3(_this10).is(":visible")) { 10408 _this10.focus(); 10409 } 10410 }); 10411 }); 10412 Modal._jQueryInterface.call($3(target), config2, this); 10413 }); 10414 $3.fn[NAME$5] = Modal._jQueryInterface; 10415 $3.fn[NAME$5].Constructor = Modal; 10416 $3.fn[NAME$5].noConflict = function() { 10417 $3.fn[NAME$5] = JQUERY_NO_CONFLICT$5; 10418 return Modal._jQueryInterface; 10419 }; 10420 var uriAttrs = ["background", "cite", "href", "itemtype", "longdesc", "poster", "src", "xlink:href"]; 10421 var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; 10422 var DefaultWhitelist = { 10423 // Global attributes allowed on any supplied element below. 10424 "*": ["class", "dir", "id", "lang", "role", ARIA_ATTRIBUTE_PATTERN], 10425 a: ["target", "href", "title", "rel"], 10426 area: [], 10427 b: [], 10428 br: [], 10429 col: [], 10430 code: [], 10431 div: [], 10432 em: [], 10433 hr: [], 10434 h1: [], 10435 h2: [], 10436 h3: [], 10437 h4: [], 10438 h5: [], 10439 h6: [], 10440 i: [], 10441 img: ["src", "alt", "title", "width", "height"], 10442 li: [], 10443 ol: [], 10444 p: [], 10445 pre: [], 10446 s: [], 10447 small: [], 10448 span: [], 10449 sub: [], 10450 sup: [], 10451 strong: [], 10452 u: [], 10453 ul: [] 10454 /** 10455 * A pattern that recognizes a commonly useful subset of URLs that are safe. 10456 * 10457 * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts 10458 */ 10459 }; 10460 var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi; 10461 var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i; 10462 function allowedAttribute(attr, allowedAttributeList) { 10463 var attrName = attr.nodeName.toLowerCase(); 10464 if (allowedAttributeList.indexOf(attrName) !== -1) { 10465 if (uriAttrs.indexOf(attrName) !== -1) { 10466 return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)); 10467 } 10468 return true; 10469 } 10470 var regExp = allowedAttributeList.filter(function(attrRegex) { 10471 return attrRegex instanceof RegExp; 10472 }); 10473 for (var i = 0, l = regExp.length; i < l; i++) { 10474 if (attrName.match(regExp[i])) { 10475 return true; 10476 } 10477 } 10478 return false; 10479 } 10480 function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) { 10481 if (unsafeHtml.length === 0) { 10482 return unsafeHtml; 10483 } 10484 if (sanitizeFn && typeof sanitizeFn === "function") { 10485 return sanitizeFn(unsafeHtml); 10486 } 10487 var domParser = new window.DOMParser(); 10488 var createdDocument = domParser.parseFromString(unsafeHtml, "text/html"); 10489 var whitelistKeys = Object.keys(whiteList); 10490 var elements = [].slice.call(createdDocument.body.querySelectorAll("*")); 10491 var _loop = function _loop2(i2, len2) { 10492 var el = elements[i2]; 10493 var elName = el.nodeName.toLowerCase(); 10494 if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) { 10495 el.parentNode.removeChild(el); 10496 return "continue"; 10497 } 10498 var attributeList = [].slice.call(el.attributes); 10499 var whitelistedAttributes = [].concat(whiteList["*"] || [], whiteList[elName] || []); 10500 attributeList.forEach(function(attr) { 10501 if (!allowedAttribute(attr, whitelistedAttributes)) { 10502 el.removeAttribute(attr.nodeName); 10503 } 10504 }); 10505 }; 10506 for (var i = 0, len = elements.length; i < len; i++) { 10507 var _ret = _loop(i, len); 10508 if (_ret === "continue") continue; 10509 } 10510 return createdDocument.body.innerHTML; 10511 } 10512 var NAME$6 = "tooltip"; 10513 var VERSION$6 = "4.3.1"; 10514 var DATA_KEY$6 = "bs.tooltip"; 10515 var EVENT_KEY$6 = "." + DATA_KEY$6; 10516 var JQUERY_NO_CONFLICT$6 = $3.fn[NAME$6]; 10517 var CLASS_PREFIX = "bs-tooltip"; 10518 var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", "g"); 10519 var DISALLOWED_ATTRIBUTES = ["sanitize", "whiteList", "sanitizeFn"]; 10520 var DefaultType$4 = { 10521 animation: "boolean", 10522 template: "string", 10523 title: "(string|element|function)", 10524 trigger: "string", 10525 delay: "(number|object)", 10526 html: "boolean", 10527 selector: "(string|boolean)", 10528 placement: "(string|function)", 10529 offset: "(number|string|function)", 10530 container: "(string|element|boolean)", 10531 fallbackPlacement: "(string|array)", 10532 boundary: "(string|element)", 10533 sanitize: "boolean", 10534 sanitizeFn: "(null|function)", 10535 whiteList: "object" 10536 }; 10537 var AttachmentMap$1 = { 10538 AUTO: "auto", 10539 TOP: "top", 10540 RIGHT: "right", 10541 BOTTOM: "bottom", 10542 LEFT: "left" 10543 }; 10544 var Default$4 = { 10545 animation: true, 10546 template: '<div class="tooltip" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>', 10547 trigger: "hover focus", 10548 title: "", 10549 delay: 0, 10550 html: false, 10551 selector: false, 10552 placement: "top", 10553 offset: 0, 10554 container: false, 10555 fallbackPlacement: "flip", 10556 boundary: "scrollParent", 10557 sanitize: true, 10558 sanitizeFn: null, 10559 whiteList: DefaultWhitelist 10560 }; 10561 var HoverState = { 10562 SHOW: "show", 10563 OUT: "out" 10564 }; 10565 var Event$6 = { 10566 HIDE: "hide" + EVENT_KEY$6, 10567 HIDDEN: "hidden" + EVENT_KEY$6, 10568 SHOW: "show" + EVENT_KEY$6, 10569 SHOWN: "shown" + EVENT_KEY$6, 10570 INSERTED: "inserted" + EVENT_KEY$6, 10571 CLICK: "click" + EVENT_KEY$6, 10572 FOCUSIN: "focusin" + EVENT_KEY$6, 10573 FOCUSOUT: "focusout" + EVENT_KEY$6, 10574 MOUSEENTER: "mouseenter" + EVENT_KEY$6, 10575 MOUSELEAVE: "mouseleave" + EVENT_KEY$6 10576 }; 10577 var ClassName$6 = { 10578 FADE: "fade", 10579 SHOW: "show" 10580 }; 10581 var Selector$6 = { 10582 TOOLTIP: ".tooltip", 10583 TOOLTIP_INNER: ".tooltip-inner", 10584 ARROW: ".arrow" 10585 }; 10586 var Trigger = { 10587 HOVER: "hover", 10588 FOCUS: "focus", 10589 CLICK: "click", 10590 MANUAL: "manual" 10591 /** 10592 * ------------------------------------------------------------------------ 10593 * Class Definition 10594 * ------------------------------------------------------------------------ 10595 */ 10596 }; 10597 var Tooltip = /* @__PURE__ */ (function() { 10598 function Tooltip2(element, config2) { 10599 if (typeof Popper === "undefined") { 10600 throw new TypeError("Bootstrap's tooltips require Popper.js (https://popper.js.org/)"); 10601 } 10602 this._isEnabled = true; 10603 this._timeout = 0; 10604 this._hoverState = ""; 10605 this._activeTrigger = {}; 10606 this._popper = null; 10607 this.element = element; 10608 this.config = this._getConfig(config2); 10609 this.tip = null; 10610 this._setListeners(); 10611 } 10612 var _proto = Tooltip2.prototype; 10613 _proto.enable = function enable() { 10614 this._isEnabled = true; 10615 }; 10616 _proto.disable = function disable() { 10617 this._isEnabled = false; 10618 }; 10619 _proto.toggleEnabled = function toggleEnabled() { 10620 this._isEnabled = !this._isEnabled; 10621 }; 10622 _proto.toggle = function toggle(event) { 10623 if (!this._isEnabled) { 10624 return; 10625 } 10626 if (event) { 10627 var dataKey = this.constructor.DATA_KEY; 10628 var context = $3(event.currentTarget).data(dataKey); 10629 if (!context) { 10630 context = new this.constructor(event.currentTarget, this._getDelegateConfig()); 10631 $3(event.currentTarget).data(dataKey, context); 10632 } 10633 context._activeTrigger.click = !context._activeTrigger.click; 10634 if (context._isWithActiveTrigger()) { 10635 context._enter(null, context); 10636 } else { 10637 context._leave(null, context); 10638 } 10639 } else { 10640 if ($3(this.getTipElement()).hasClass(ClassName$6.SHOW)) { 10641 this._leave(null, this); 10642 return; 10643 } 10644 this._enter(null, this); 10645 } 10646 }; 10647 _proto.dispose = function dispose() { 10648 clearTimeout(this._timeout); 10649 $3.removeData(this.element, this.constructor.DATA_KEY); 10650 $3(this.element).off(this.constructor.EVENT_KEY); 10651 $3(this.element).closest(".modal").off("hide.bs.modal"); 10652 if (this.tip) { 10653 $3(this.tip).remove(); 10654 } 10655 this._isEnabled = null; 10656 this._timeout = null; 10657 this._hoverState = null; 10658 this._activeTrigger = null; 10659 if (this._popper !== null) { 10660 this._popper.destroy(); 10661 } 10662 this._popper = null; 10663 this.element = null; 10664 this.config = null; 10665 this.tip = null; 10666 }; 10667 _proto.show = function show() { 10668 var _this = this; 10669 if ($3(this.element).css("display") === "none") { 10670 throw new Error("Please use show on visible elements"); 10671 } 10672 var showEvent = $3.Event(this.constructor.Event.SHOW); 10673 if (this.isWithContent() && this._isEnabled) { 10674 $3(this.element).trigger(showEvent); 10675 var shadowRoot = Util.findShadowRoot(this.element); 10676 var isInTheDom = $3.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element); 10677 if (showEvent.isDefaultPrevented() || !isInTheDom) { 10678 return; 10679 } 10680 var tip = this.getTipElement(); 10681 var tipId = Util.getUID(this.constructor.NAME); 10682 tip.setAttribute("id", tipId); 10683 this.element.setAttribute("aria-describedby", tipId); 10684 this.setContent(); 10685 if (this.config.animation) { 10686 $3(tip).addClass(ClassName$6.FADE); 10687 } 10688 var placement = typeof this.config.placement === "function" ? this.config.placement.call(this, tip, this.element) : this.config.placement; 10689 var attachment = this._getAttachment(placement); 10690 this.addAttachmentClass(attachment); 10691 var container = this._getContainer(); 10692 $3(tip).data(this.constructor.DATA_KEY, this); 10693 if (!$3.contains(this.element.ownerDocument.documentElement, this.tip)) { 10694 $3(tip).appendTo(container); 10695 } 10696 $3(this.element).trigger(this.constructor.Event.INSERTED); 10697 this._popper = new Popper(this.element, tip, { 10698 placement: attachment, 10699 modifiers: { 10700 offset: this._getOffset(), 10701 flip: { 10702 behavior: this.config.fallbackPlacement 10703 }, 10704 arrow: { 10705 element: Selector$6.ARROW 10706 }, 10707 preventOverflow: { 10708 boundariesElement: this.config.boundary 10709 } 10710 }, 10711 onCreate: function onCreate(data) { 10712 if (data.originalPlacement !== data.placement) { 10713 _this._handlePopperPlacementChange(data); 10714 } 10715 }, 10716 onUpdate: function onUpdate(data) { 10717 return _this._handlePopperPlacementChange(data); 10718 } 10719 }); 10720 $3(tip).addClass(ClassName$6.SHOW); 10721 if ("ontouchstart" in document.documentElement) { 10722 $3(document.body).children().on("mouseover", null, $3.noop); 10723 } 10724 var complete = function complete2() { 10725 if (_this.config.animation) { 10726 _this._fixTransition(); 10727 } 10728 var prevHoverState = _this._hoverState; 10729 _this._hoverState = null; 10730 $3(_this.element).trigger(_this.constructor.Event.SHOWN); 10731 if (prevHoverState === HoverState.OUT) { 10732 _this._leave(null, _this); 10733 } 10734 }; 10735 if ($3(this.tip).hasClass(ClassName$6.FADE)) { 10736 var transitionDuration = Util.getTransitionDurationFromElement(this.tip); 10737 $3(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 10738 } else { 10739 complete(); 10740 } 10741 } 10742 }; 10743 _proto.hide = function hide(callback) { 10744 var _this2 = this; 10745 var tip = this.getTipElement(); 10746 var hideEvent = $3.Event(this.constructor.Event.HIDE); 10747 var complete = function complete2() { 10748 if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) { 10749 tip.parentNode.removeChild(tip); 10750 } 10751 _this2._cleanTipClass(); 10752 _this2.element.removeAttribute("aria-describedby"); 10753 $3(_this2.element).trigger(_this2.constructor.Event.HIDDEN); 10754 if (_this2._popper !== null) { 10755 _this2._popper.destroy(); 10756 } 10757 if (callback) { 10758 callback(); 10759 } 10760 }; 10761 $3(this.element).trigger(hideEvent); 10762 if (hideEvent.isDefaultPrevented()) { 10763 return; 10764 } 10765 $3(tip).removeClass(ClassName$6.SHOW); 10766 if ("ontouchstart" in document.documentElement) { 10767 $3(document.body).children().off("mouseover", null, $3.noop); 10768 } 10769 this._activeTrigger[Trigger.CLICK] = false; 10770 this._activeTrigger[Trigger.FOCUS] = false; 10771 this._activeTrigger[Trigger.HOVER] = false; 10772 if ($3(this.tip).hasClass(ClassName$6.FADE)) { 10773 var transitionDuration = Util.getTransitionDurationFromElement(tip); 10774 $3(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 10775 } else { 10776 complete(); 10777 } 10778 this._hoverState = ""; 10779 }; 10780 _proto.update = function update() { 10781 if (this._popper !== null) { 10782 this._popper.scheduleUpdate(); 10783 } 10784 }; 10785 _proto.isWithContent = function isWithContent() { 10786 return Boolean(this.getTitle()); 10787 }; 10788 _proto.addAttachmentClass = function addAttachmentClass(attachment) { 10789 $3(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment); 10790 }; 10791 _proto.getTipElement = function getTipElement() { 10792 this.tip = this.tip || $3(this.config.template)[0]; 10793 return this.tip; 10794 }; 10795 _proto.setContent = function setContent() { 10796 var tip = this.getTipElement(); 10797 this.setElementContent($3(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle()); 10798 $3(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW); 10799 }; 10800 _proto.setElementContent = function setElementContent($element, content) { 10801 if (typeof content === "object" && (content.nodeType || content.jquery)) { 10802 if (this.config.html) { 10803 if (!$3(content).parent().is($element)) { 10804 $element.empty().append(content); 10805 } 10806 } else { 10807 $element.text($3(content).text()); 10808 } 10809 return; 10810 } 10811 if (this.config.html) { 10812 if (this.config.sanitize) { 10813 content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn); 10814 } 10815 $element.html(content); 10816 } else { 10817 $element.text(content); 10818 } 10819 }; 10820 _proto.getTitle = function getTitle() { 10821 var title = this.element.getAttribute("data-original-title"); 10822 if (!title) { 10823 title = typeof this.config.title === "function" ? this.config.title.call(this.element) : this.config.title; 10824 } 10825 return title; 10826 }; 10827 _proto._getOffset = function _getOffset() { 10828 var _this3 = this; 10829 var offset = {}; 10830 if (typeof this.config.offset === "function") { 10831 offset.fn = function(data) { 10832 data.offsets = _objectSpread({}, data.offsets, _this3.config.offset(data.offsets, _this3.element) || {}); 10833 return data; 10834 }; 10835 } else { 10836 offset.offset = this.config.offset; 10837 } 10838 return offset; 10839 }; 10840 _proto._getContainer = function _getContainer() { 10841 if (this.config.container === false) { 10842 return document.body; 10843 } 10844 if (Util.isElement(this.config.container)) { 10845 return $3(this.config.container); 10846 } 10847 return $3(document).find(this.config.container); 10848 }; 10849 _proto._getAttachment = function _getAttachment(placement) { 10850 return AttachmentMap$1[placement.toUpperCase()]; 10851 }; 10852 _proto._setListeners = function _setListeners() { 10853 var _this4 = this; 10854 var triggers = this.config.trigger.split(" "); 10855 triggers.forEach(function(trigger) { 10856 if (trigger === "click") { 10857 $3(_this4.element).on(_this4.constructor.Event.CLICK, _this4.config.selector, function(event) { 10858 return _this4.toggle(event); 10859 }); 10860 } else if (trigger !== Trigger.MANUAL) { 10861 var eventIn = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSEENTER : _this4.constructor.Event.FOCUSIN; 10862 var eventOut = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSELEAVE : _this4.constructor.Event.FOCUSOUT; 10863 $3(_this4.element).on(eventIn, _this4.config.selector, function(event) { 10864 return _this4._enter(event); 10865 }).on(eventOut, _this4.config.selector, function(event) { 10866 return _this4._leave(event); 10867 }); 10868 } 10869 }); 10870 $3(this.element).closest(".modal").on("hide.bs.modal", function() { 10871 if (_this4.element) { 10872 _this4.hide(); 10873 } 10874 }); 10875 if (this.config.selector) { 10876 this.config = _objectSpread({}, this.config, { 10877 trigger: "manual", 10878 selector: "" 10879 }); 10880 } else { 10881 this._fixTitle(); 10882 } 10883 }; 10884 _proto._fixTitle = function _fixTitle() { 10885 var titleType = typeof this.element.getAttribute("data-original-title"); 10886 if (this.element.getAttribute("title") || titleType !== "string") { 10887 this.element.setAttribute("data-original-title", this.element.getAttribute("title") || ""); 10888 this.element.setAttribute("title", ""); 10889 } 10890 }; 10891 _proto._enter = function _enter(event, context) { 10892 var dataKey = this.constructor.DATA_KEY; 10893 context = context || $3(event.currentTarget).data(dataKey); 10894 if (!context) { 10895 context = new this.constructor(event.currentTarget, this._getDelegateConfig()); 10896 $3(event.currentTarget).data(dataKey, context); 10897 } 10898 if (event) { 10899 context._activeTrigger[event.type === "focusin" ? Trigger.FOCUS : Trigger.HOVER] = true; 10900 } 10901 if ($3(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) { 10902 context._hoverState = HoverState.SHOW; 10903 return; 10904 } 10905 clearTimeout(context._timeout); 10906 context._hoverState = HoverState.SHOW; 10907 if (!context.config.delay || !context.config.delay.show) { 10908 context.show(); 10909 return; 10910 } 10911 context._timeout = setTimeout(function() { 10912 if (context._hoverState === HoverState.SHOW) { 10913 context.show(); 10914 } 10915 }, context.config.delay.show); 10916 }; 10917 _proto._leave = function _leave(event, context) { 10918 var dataKey = this.constructor.DATA_KEY; 10919 context = context || $3(event.currentTarget).data(dataKey); 10920 if (!context) { 10921 context = new this.constructor(event.currentTarget, this._getDelegateConfig()); 10922 $3(event.currentTarget).data(dataKey, context); 10923 } 10924 if (event) { 10925 context._activeTrigger[event.type === "focusout" ? Trigger.FOCUS : Trigger.HOVER] = false; 10926 } 10927 if (context._isWithActiveTrigger()) { 10928 return; 10929 } 10930 clearTimeout(context._timeout); 10931 context._hoverState = HoverState.OUT; 10932 if (!context.config.delay || !context.config.delay.hide) { 10933 context.hide(); 10934 return; 10935 } 10936 context._timeout = setTimeout(function() { 10937 if (context._hoverState === HoverState.OUT) { 10938 context.hide(); 10939 } 10940 }, context.config.delay.hide); 10941 }; 10942 _proto._isWithActiveTrigger = function _isWithActiveTrigger() { 10943 for (var trigger in this._activeTrigger) { 10944 if (this._activeTrigger[trigger]) { 10945 return true; 10946 } 10947 } 10948 return false; 10949 }; 10950 _proto._getConfig = function _getConfig(config2) { 10951 var dataAttributes = $3(this.element).data(); 10952 Object.keys(dataAttributes).forEach(function(dataAttr) { 10953 if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) { 10954 delete dataAttributes[dataAttr]; 10955 } 10956 }); 10957 config2 = _objectSpread({}, this.constructor.Default, dataAttributes, typeof config2 === "object" && config2 ? config2 : {}); 10958 if (typeof config2.delay === "number") { 10959 config2.delay = { 10960 show: config2.delay, 10961 hide: config2.delay 10962 }; 10963 } 10964 if (typeof config2.title === "number") { 10965 config2.title = config2.title.toString(); 10966 } 10967 if (typeof config2.content === "number") { 10968 config2.content = config2.content.toString(); 10969 } 10970 Util.typeCheckConfig(NAME$6, config2, this.constructor.DefaultType); 10971 if (config2.sanitize) { 10972 config2.template = sanitizeHtml(config2.template, config2.whiteList, config2.sanitizeFn); 10973 } 10974 return config2; 10975 }; 10976 _proto._getDelegateConfig = function _getDelegateConfig() { 10977 var config2 = {}; 10978 if (this.config) { 10979 for (var key in this.config) { 10980 if (this.constructor.Default[key] !== this.config[key]) { 10981 config2[key] = this.config[key]; 10982 } 10983 } 10984 } 10985 return config2; 10986 }; 10987 _proto._cleanTipClass = function _cleanTipClass() { 10988 var $tip = $3(this.getTipElement()); 10989 var tabClass = $tip.attr("class").match(BSCLS_PREFIX_REGEX); 10990 if (tabClass !== null && tabClass.length) { 10991 $tip.removeClass(tabClass.join("")); 10992 } 10993 }; 10994 _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) { 10995 var popperInstance = popperData.instance; 10996 this.tip = popperInstance.popper; 10997 this._cleanTipClass(); 10998 this.addAttachmentClass(this._getAttachment(popperData.placement)); 10999 }; 11000 _proto._fixTransition = function _fixTransition() { 11001 var tip = this.getTipElement(); 11002 var initConfigAnimation = this.config.animation; 11003 if (tip.getAttribute("x-placement") !== null) { 11004 return; 11005 } 11006 $3(tip).removeClass(ClassName$6.FADE); 11007 this.config.animation = false; 11008 this.hide(); 11009 this.show(); 11010 this.config.animation = initConfigAnimation; 11011 }; 11012 Tooltip2._jQueryInterface = function _jQueryInterface(config2) { 11013 return this.each(function() { 11014 var data = $3(this).data(DATA_KEY$6); 11015 var _config = typeof config2 === "object" && config2; 11016 if (!data && /dispose|hide/.test(config2)) { 11017 return; 11018 } 11019 if (!data) { 11020 data = new Tooltip2(this, _config); 11021 $3(this).data(DATA_KEY$6, data); 11022 } 11023 if (typeof config2 === "string") { 11024 if (typeof data[config2] === "undefined") { 11025 throw new TypeError('No method named "' + config2 + '"'); 11026 } 11027 data[config2](); 11028 } 11029 }); 11030 }; 11031 _createClass(Tooltip2, null, [{ 11032 key: "VERSION", 11033 get: function get() { 11034 return VERSION$6; 11035 } 11036 }, { 11037 key: "Default", 11038 get: function get() { 11039 return Default$4; 11040 } 11041 }, { 11042 key: "NAME", 11043 get: function get() { 11044 return NAME$6; 11045 } 11046 }, { 11047 key: "DATA_KEY", 11048 get: function get() { 11049 return DATA_KEY$6; 11050 } 11051 }, { 11052 key: "Event", 11053 get: function get() { 11054 return Event$6; 11055 } 11056 }, { 11057 key: "EVENT_KEY", 11058 get: function get() { 11059 return EVENT_KEY$6; 11060 } 11061 }, { 11062 key: "DefaultType", 11063 get: function get() { 11064 return DefaultType$4; 11065 } 11066 }]); 11067 return Tooltip2; 11068 })(); 11069 $3.fn[NAME$6] = Tooltip._jQueryInterface; 11070 $3.fn[NAME$6].Constructor = Tooltip; 11071 $3.fn[NAME$6].noConflict = function() { 11072 $3.fn[NAME$6] = JQUERY_NO_CONFLICT$6; 11073 return Tooltip._jQueryInterface; 11074 }; 11075 var NAME$7 = "popover"; 11076 var VERSION$7 = "4.3.1"; 11077 var DATA_KEY$7 = "bs.popover"; 11078 var EVENT_KEY$7 = "." + DATA_KEY$7; 11079 var JQUERY_NO_CONFLICT$7 = $3.fn[NAME$7]; 11080 var CLASS_PREFIX$1 = "bs-popover"; 11081 var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", "g"); 11082 var Default$5 = _objectSpread({}, Tooltip.Default, { 11083 placement: "right", 11084 trigger: "click", 11085 content: "", 11086 template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' 11087 }); 11088 var DefaultType$5 = _objectSpread({}, Tooltip.DefaultType, { 11089 content: "(string|element|function)" 11090 }); 11091 var ClassName$7 = { 11092 FADE: "fade", 11093 SHOW: "show" 11094 }; 11095 var Selector$7 = { 11096 TITLE: ".popover-header", 11097 CONTENT: ".popover-body" 11098 }; 11099 var Event$7 = { 11100 HIDE: "hide" + EVENT_KEY$7, 11101 HIDDEN: "hidden" + EVENT_KEY$7, 11102 SHOW: "show" + EVENT_KEY$7, 11103 SHOWN: "shown" + EVENT_KEY$7, 11104 INSERTED: "inserted" + EVENT_KEY$7, 11105 CLICK: "click" + EVENT_KEY$7, 11106 FOCUSIN: "focusin" + EVENT_KEY$7, 11107 FOCUSOUT: "focusout" + EVENT_KEY$7, 11108 MOUSEENTER: "mouseenter" + EVENT_KEY$7, 11109 MOUSELEAVE: "mouseleave" + EVENT_KEY$7 11110 /** 11111 * ------------------------------------------------------------------------ 11112 * Class Definition 11113 * ------------------------------------------------------------------------ 11114 */ 11115 }; 11116 var Popover = /* @__PURE__ */ (function(_Tooltip) { 11117 _inheritsLoose(Popover2, _Tooltip); 11118 function Popover2() { 11119 return _Tooltip.apply(this, arguments) || this; 11120 } 11121 var _proto = Popover2.prototype; 11122 _proto.isWithContent = function isWithContent() { 11123 return this.getTitle() || this._getContent(); 11124 }; 11125 _proto.addAttachmentClass = function addAttachmentClass(attachment) { 11126 $3(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment); 11127 }; 11128 _proto.getTipElement = function getTipElement() { 11129 this.tip = this.tip || $3(this.config.template)[0]; 11130 return this.tip; 11131 }; 11132 _proto.setContent = function setContent() { 11133 var $tip = $3(this.getTipElement()); 11134 this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle()); 11135 var content = this._getContent(); 11136 if (typeof content === "function") { 11137 content = content.call(this.element); 11138 } 11139 this.setElementContent($tip.find(Selector$7.CONTENT), content); 11140 $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW); 11141 }; 11142 _proto._getContent = function _getContent() { 11143 return this.element.getAttribute("data-content") || this.config.content; 11144 }; 11145 _proto._cleanTipClass = function _cleanTipClass() { 11146 var $tip = $3(this.getTipElement()); 11147 var tabClass = $tip.attr("class").match(BSCLS_PREFIX_REGEX$1); 11148 if (tabClass !== null && tabClass.length > 0) { 11149 $tip.removeClass(tabClass.join("")); 11150 } 11151 }; 11152 Popover2._jQueryInterface = function _jQueryInterface(config2) { 11153 return this.each(function() { 11154 var data = $3(this).data(DATA_KEY$7); 11155 var _config = typeof config2 === "object" ? config2 : null; 11156 if (!data && /dispose|hide/.test(config2)) { 11157 return; 11158 } 11159 if (!data) { 11160 data = new Popover2(this, _config); 11161 $3(this).data(DATA_KEY$7, data); 11162 } 11163 if (typeof config2 === "string") { 11164 if (typeof data[config2] === "undefined") { 11165 throw new TypeError('No method named "' + config2 + '"'); 11166 } 11167 data[config2](); 11168 } 11169 }); 11170 }; 11171 _createClass(Popover2, null, [{ 11172 key: "VERSION", 11173 // Getters 11174 get: function get() { 11175 return VERSION$7; 11176 } 11177 }, { 11178 key: "Default", 11179 get: function get() { 11180 return Default$5; 11181 } 11182 }, { 11183 key: "NAME", 11184 get: function get() { 11185 return NAME$7; 11186 } 11187 }, { 11188 key: "DATA_KEY", 11189 get: function get() { 11190 return DATA_KEY$7; 11191 } 11192 }, { 11193 key: "Event", 11194 get: function get() { 11195 return Event$7; 11196 } 11197 }, { 11198 key: "EVENT_KEY", 11199 get: function get() { 11200 return EVENT_KEY$7; 11201 } 11202 }, { 11203 key: "DefaultType", 11204 get: function get() { 11205 return DefaultType$5; 11206 } 11207 }]); 11208 return Popover2; 11209 })(Tooltip); 11210 $3.fn[NAME$7] = Popover._jQueryInterface; 11211 $3.fn[NAME$7].Constructor = Popover; 11212 $3.fn[NAME$7].noConflict = function() { 11213 $3.fn[NAME$7] = JQUERY_NO_CONFLICT$7; 11214 return Popover._jQueryInterface; 11215 }; 11216 var NAME$8 = "scrollspy"; 11217 var VERSION$8 = "4.3.1"; 11218 var DATA_KEY$8 = "bs.scrollspy"; 11219 var EVENT_KEY$8 = "." + DATA_KEY$8; 11220 var DATA_API_KEY$6 = ".data-api"; 11221 var JQUERY_NO_CONFLICT$8 = $3.fn[NAME$8]; 11222 var Default$6 = { 11223 offset: 10, 11224 method: "auto", 11225 target: "" 11226 }; 11227 var DefaultType$6 = { 11228 offset: "number", 11229 method: "string", 11230 target: "(string|element)" 11231 }; 11232 var Event$8 = { 11233 ACTIVATE: "activate" + EVENT_KEY$8, 11234 SCROLL: "scroll" + EVENT_KEY$8, 11235 LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6 11236 }; 11237 var ClassName$8 = { 11238 DROPDOWN_ITEM: "dropdown-item", 11239 DROPDOWN_MENU: "dropdown-menu", 11240 ACTIVE: "active" 11241 }; 11242 var Selector$8 = { 11243 DATA_SPY: '[data-spy="scroll"]', 11244 ACTIVE: ".active", 11245 NAV_LIST_GROUP: ".nav, .list-group", 11246 NAV_LINKS: ".nav-link", 11247 NAV_ITEMS: ".nav-item", 11248 LIST_ITEMS: ".list-group-item", 11249 DROPDOWN: ".dropdown", 11250 DROPDOWN_ITEMS: ".dropdown-item", 11251 DROPDOWN_TOGGLE: ".dropdown-toggle" 11252 }; 11253 var OffsetMethod = { 11254 OFFSET: "offset", 11255 POSITION: "position" 11256 /** 11257 * ------------------------------------------------------------------------ 11258 * Class Definition 11259 * ------------------------------------------------------------------------ 11260 */ 11261 }; 11262 var ScrollSpy = /* @__PURE__ */ (function() { 11263 function ScrollSpy2(element, config2) { 11264 var _this = this; 11265 this._element = element; 11266 this._scrollElement = element.tagName === "BODY" ? window : element; 11267 this._config = this._getConfig(config2); 11268 this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS); 11269 this._offsets = []; 11270 this._targets = []; 11271 this._activeTarget = null; 11272 this._scrollHeight = 0; 11273 $3(this._scrollElement).on(Event$8.SCROLL, function(event) { 11274 return _this._process(event); 11275 }); 11276 this.refresh(); 11277 this._process(); 11278 } 11279 var _proto = ScrollSpy2.prototype; 11280 _proto.refresh = function refresh() { 11281 var _this2 = this; 11282 var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION; 11283 var offsetMethod = this._config.method === "auto" ? autoMethod : this._config.method; 11284 var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0; 11285 this._offsets = []; 11286 this._targets = []; 11287 this._scrollHeight = this._getScrollHeight(); 11288 var targets = [].slice.call(document.querySelectorAll(this._selector)); 11289 targets.map(function(element) { 11290 var target; 11291 var targetSelector = Util.getSelectorFromElement(element); 11292 if (targetSelector) { 11293 target = document.querySelector(targetSelector); 11294 } 11295 if (target) { 11296 var targetBCR = target.getBoundingClientRect(); 11297 if (targetBCR.width || targetBCR.height) { 11298 return [$3(target)[offsetMethod]().top + offsetBase, targetSelector]; 11299 } 11300 } 11301 return null; 11302 }).filter(function(item) { 11303 return item; 11304 }).sort(function(a, b) { 11305 return a[0] - b[0]; 11306 }).forEach(function(item) { 11307 _this2._offsets.push(item[0]); 11308 _this2._targets.push(item[1]); 11309 }); 11310 }; 11311 _proto.dispose = function dispose() { 11312 $3.removeData(this._element, DATA_KEY$8); 11313 $3(this._scrollElement).off(EVENT_KEY$8); 11314 this._element = null; 11315 this._scrollElement = null; 11316 this._config = null; 11317 this._selector = null; 11318 this._offsets = null; 11319 this._targets = null; 11320 this._activeTarget = null; 11321 this._scrollHeight = null; 11322 }; 11323 _proto._getConfig = function _getConfig(config2) { 11324 config2 = _objectSpread({}, Default$6, typeof config2 === "object" && config2 ? config2 : {}); 11325 if (typeof config2.target !== "string") { 11326 var id = $3(config2.target).attr("id"); 11327 if (!id) { 11328 id = Util.getUID(NAME$8); 11329 $3(config2.target).attr("id", id); 11330 } 11331 config2.target = "#" + id; 11332 } 11333 Util.typeCheckConfig(NAME$8, config2, DefaultType$6); 11334 return config2; 11335 }; 11336 _proto._getScrollTop = function _getScrollTop() { 11337 return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; 11338 }; 11339 _proto._getScrollHeight = function _getScrollHeight() { 11340 return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); 11341 }; 11342 _proto._getOffsetHeight = function _getOffsetHeight() { 11343 return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; 11344 }; 11345 _proto._process = function _process() { 11346 var scrollTop = this._getScrollTop() + this._config.offset; 11347 var scrollHeight = this._getScrollHeight(); 11348 var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); 11349 if (this._scrollHeight !== scrollHeight) { 11350 this.refresh(); 11351 } 11352 if (scrollTop >= maxScroll) { 11353 var target = this._targets[this._targets.length - 1]; 11354 if (this._activeTarget !== target) { 11355 this._activate(target); 11356 } 11357 return; 11358 } 11359 if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { 11360 this._activeTarget = null; 11361 this._clear(); 11362 return; 11363 } 11364 var offsetLength = this._offsets.length; 11365 for (var i = offsetLength; i--; ) { 11366 var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === "undefined" || scrollTop < this._offsets[i + 1]); 11367 if (isActiveTarget) { 11368 this._activate(this._targets[i]); 11369 } 11370 } 11371 }; 11372 _proto._activate = function _activate(target) { 11373 this._activeTarget = target; 11374 this._clear(); 11375 var queries = this._selector.split(",").map(function(selector) { 11376 return selector + '[data-target="' + target + '"],' + selector + '[href="' + target + '"]'; 11377 }); 11378 var $link = $3([].slice.call(document.querySelectorAll(queries.join(",")))); 11379 if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) { 11380 $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE); 11381 $link.addClass(ClassName$8.ACTIVE); 11382 } else { 11383 $link.addClass(ClassName$8.ACTIVE); 11384 $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_LINKS + ", " + Selector$8.LIST_ITEMS).addClass(ClassName$8.ACTIVE); 11385 $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE); 11386 } 11387 $3(this._scrollElement).trigger(Event$8.ACTIVATE, { 11388 relatedTarget: target 11389 }); 11390 }; 11391 _proto._clear = function _clear() { 11392 [].slice.call(document.querySelectorAll(this._selector)).filter(function(node) { 11393 return node.classList.contains(ClassName$8.ACTIVE); 11394 }).forEach(function(node) { 11395 return node.classList.remove(ClassName$8.ACTIVE); 11396 }); 11397 }; 11398 ScrollSpy2._jQueryInterface = function _jQueryInterface(config2) { 11399 return this.each(function() { 11400 var data = $3(this).data(DATA_KEY$8); 11401 var _config = typeof config2 === "object" && config2; 11402 if (!data) { 11403 data = new ScrollSpy2(this, _config); 11404 $3(this).data(DATA_KEY$8, data); 11405 } 11406 if (typeof config2 === "string") { 11407 if (typeof data[config2] === "undefined") { 11408 throw new TypeError('No method named "' + config2 + '"'); 11409 } 11410 data[config2](); 11411 } 11412 }); 11413 }; 11414 _createClass(ScrollSpy2, null, [{ 11415 key: "VERSION", 11416 get: function get() { 11417 return VERSION$8; 11418 } 11419 }, { 11420 key: "Default", 11421 get: function get() { 11422 return Default$6; 11423 } 11424 }]); 11425 return ScrollSpy2; 11426 })(); 11427 $3(window).on(Event$8.LOAD_DATA_API, function() { 11428 var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY)); 11429 var scrollSpysLength = scrollSpys.length; 11430 for (var i = scrollSpysLength; i--; ) { 11431 var $spy = $3(scrollSpys[i]); 11432 ScrollSpy._jQueryInterface.call($spy, $spy.data()); 11433 } 11434 }); 11435 $3.fn[NAME$8] = ScrollSpy._jQueryInterface; 11436 $3.fn[NAME$8].Constructor = ScrollSpy; 11437 $3.fn[NAME$8].noConflict = function() { 11438 $3.fn[NAME$8] = JQUERY_NO_CONFLICT$8; 11439 return ScrollSpy._jQueryInterface; 11440 }; 11441 var NAME$9 = "tab"; 11442 var VERSION$9 = "4.3.1"; 11443 var DATA_KEY$9 = "bs.tab"; 11444 var EVENT_KEY$9 = "." + DATA_KEY$9; 11445 var DATA_API_KEY$7 = ".data-api"; 11446 var JQUERY_NO_CONFLICT$9 = $3.fn[NAME$9]; 11447 var Event$9 = { 11448 HIDE: "hide" + EVENT_KEY$9, 11449 HIDDEN: "hidden" + EVENT_KEY$9, 11450 SHOW: "show" + EVENT_KEY$9, 11451 SHOWN: "shown" + EVENT_KEY$9, 11452 CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7 11453 }; 11454 var ClassName$9 = { 11455 DROPDOWN_MENU: "dropdown-menu", 11456 ACTIVE: "active", 11457 DISABLED: "disabled", 11458 FADE: "fade", 11459 SHOW: "show" 11460 }; 11461 var Selector$9 = { 11462 DROPDOWN: ".dropdown", 11463 NAV_LIST_GROUP: ".nav, .list-group", 11464 ACTIVE: ".active", 11465 ACTIVE_UL: "> li > .active", 11466 DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]', 11467 DROPDOWN_TOGGLE: ".dropdown-toggle", 11468 DROPDOWN_ACTIVE_CHILD: "> .dropdown-menu .active" 11469 /** 11470 * ------------------------------------------------------------------------ 11471 * Class Definition 11472 * ------------------------------------------------------------------------ 11473 */ 11474 }; 11475 var Tab = /* @__PURE__ */ (function() { 11476 function Tab2(element) { 11477 this._element = element; 11478 } 11479 var _proto = Tab2.prototype; 11480 _proto.show = function show() { 11481 var _this = this; 11482 if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $3(this._element).hasClass(ClassName$9.ACTIVE) || $3(this._element).hasClass(ClassName$9.DISABLED)) { 11483 return; 11484 } 11485 var target; 11486 var previous; 11487 var listElement = $3(this._element).closest(Selector$9.NAV_LIST_GROUP)[0]; 11488 var selector = Util.getSelectorFromElement(this._element); 11489 if (listElement) { 11490 var itemSelector = listElement.nodeName === "UL" || listElement.nodeName === "OL" ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE; 11491 previous = $3.makeArray($3(listElement).find(itemSelector)); 11492 previous = previous[previous.length - 1]; 11493 } 11494 var hideEvent = $3.Event(Event$9.HIDE, { 11495 relatedTarget: this._element 11496 }); 11497 var showEvent = $3.Event(Event$9.SHOW, { 11498 relatedTarget: previous 11499 }); 11500 if (previous) { 11501 $3(previous).trigger(hideEvent); 11502 } 11503 $3(this._element).trigger(showEvent); 11504 if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) { 11505 return; 11506 } 11507 if (selector) { 11508 target = document.querySelector(selector); 11509 } 11510 this._activate(this._element, listElement); 11511 var complete = function complete2() { 11512 var hiddenEvent = $3.Event(Event$9.HIDDEN, { 11513 relatedTarget: _this._element 11514 }); 11515 var shownEvent = $3.Event(Event$9.SHOWN, { 11516 relatedTarget: previous 11517 }); 11518 $3(previous).trigger(hiddenEvent); 11519 $3(_this._element).trigger(shownEvent); 11520 }; 11521 if (target) { 11522 this._activate(target, target.parentNode, complete); 11523 } else { 11524 complete(); 11525 } 11526 }; 11527 _proto.dispose = function dispose() { 11528 $3.removeData(this._element, DATA_KEY$9); 11529 this._element = null; 11530 }; 11531 _proto._activate = function _activate(element, container, callback) { 11532 var _this2 = this; 11533 var activeElements = container && (container.nodeName === "UL" || container.nodeName === "OL") ? $3(container).find(Selector$9.ACTIVE_UL) : $3(container).children(Selector$9.ACTIVE); 11534 var active = activeElements[0]; 11535 var isTransitioning = callback && active && $3(active).hasClass(ClassName$9.FADE); 11536 var complete = function complete2() { 11537 return _this2._transitionComplete(element, active, callback); 11538 }; 11539 if (active && isTransitioning) { 11540 var transitionDuration = Util.getTransitionDurationFromElement(active); 11541 $3(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 11542 } else { 11543 complete(); 11544 } 11545 }; 11546 _proto._transitionComplete = function _transitionComplete(element, active, callback) { 11547 if (active) { 11548 $3(active).removeClass(ClassName$9.ACTIVE); 11549 var dropdownChild = $3(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0]; 11550 if (dropdownChild) { 11551 $3(dropdownChild).removeClass(ClassName$9.ACTIVE); 11552 } 11553 if (active.getAttribute("role") === "tab") { 11554 active.setAttribute("aria-selected", false); 11555 } 11556 } 11557 $3(element).addClass(ClassName$9.ACTIVE); 11558 if (element.getAttribute("role") === "tab") { 11559 element.setAttribute("aria-selected", true); 11560 } 11561 Util.reflow(element); 11562 if (element.classList.contains(ClassName$9.FADE)) { 11563 element.classList.add(ClassName$9.SHOW); 11564 } 11565 if (element.parentNode && $3(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) { 11566 var dropdownElement = $3(element).closest(Selector$9.DROPDOWN)[0]; 11567 if (dropdownElement) { 11568 var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE)); 11569 $3(dropdownToggleList).addClass(ClassName$9.ACTIVE); 11570 } 11571 element.setAttribute("aria-expanded", true); 11572 } 11573 if (callback) { 11574 callback(); 11575 } 11576 }; 11577 Tab2._jQueryInterface = function _jQueryInterface(config2) { 11578 return this.each(function() { 11579 var $this = $3(this); 11580 var data = $this.data(DATA_KEY$9); 11581 if (!data) { 11582 data = new Tab2(this); 11583 $this.data(DATA_KEY$9, data); 11584 } 11585 if (typeof config2 === "string") { 11586 if (typeof data[config2] === "undefined") { 11587 throw new TypeError('No method named "' + config2 + '"'); 11588 } 11589 data[config2](); 11590 } 11591 }); 11592 }; 11593 _createClass(Tab2, null, [{ 11594 key: "VERSION", 11595 get: function get() { 11596 return VERSION$9; 11597 } 11598 }]); 11599 return Tab2; 11600 })(); 11601 $3(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function(event) { 11602 event.preventDefault(); 11603 Tab._jQueryInterface.call($3(this), "show"); 11604 }); 11605 $3.fn[NAME$9] = Tab._jQueryInterface; 11606 $3.fn[NAME$9].Constructor = Tab; 11607 $3.fn[NAME$9].noConflict = function() { 11608 $3.fn[NAME$9] = JQUERY_NO_CONFLICT$9; 11609 return Tab._jQueryInterface; 11610 }; 11611 var NAME$a = "toast"; 11612 var VERSION$a = "4.3.1"; 11613 var DATA_KEY$a = "bs.toast"; 11614 var EVENT_KEY$a = "." + DATA_KEY$a; 11615 var JQUERY_NO_CONFLICT$a = $3.fn[NAME$a]; 11616 var Event$a = { 11617 CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a, 11618 HIDE: "hide" + EVENT_KEY$a, 11619 HIDDEN: "hidden" + EVENT_KEY$a, 11620 SHOW: "show" + EVENT_KEY$a, 11621 SHOWN: "shown" + EVENT_KEY$a 11622 }; 11623 var ClassName$a = { 11624 FADE: "fade", 11625 HIDE: "hide", 11626 SHOW: "show", 11627 SHOWING: "showing" 11628 }; 11629 var DefaultType$7 = { 11630 animation: "boolean", 11631 autohide: "boolean", 11632 delay: "number" 11633 }; 11634 var Default$7 = { 11635 animation: true, 11636 autohide: true, 11637 delay: 500 11638 }; 11639 var Selector$a = { 11640 DATA_DISMISS: '[data-dismiss="toast"]' 11641 /** 11642 * ------------------------------------------------------------------------ 11643 * Class Definition 11644 * ------------------------------------------------------------------------ 11645 */ 11646 }; 11647 var Toast = /* @__PURE__ */ (function() { 11648 function Toast2(element, config2) { 11649 this._element = element; 11650 this._config = this._getConfig(config2); 11651 this._timeout = null; 11652 this._setListeners(); 11653 } 11654 var _proto = Toast2.prototype; 11655 _proto.show = function show() { 11656 var _this = this; 11657 $3(this._element).trigger(Event$a.SHOW); 11658 if (this._config.animation) { 11659 this._element.classList.add(ClassName$a.FADE); 11660 } 11661 var complete = function complete2() { 11662 _this._element.classList.remove(ClassName$a.SHOWING); 11663 _this._element.classList.add(ClassName$a.SHOW); 11664 $3(_this._element).trigger(Event$a.SHOWN); 11665 if (_this._config.autohide) { 11666 _this.hide(); 11667 } 11668 }; 11669 this._element.classList.remove(ClassName$a.HIDE); 11670 this._element.classList.add(ClassName$a.SHOWING); 11671 if (this._config.animation) { 11672 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 11673 $3(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 11674 } else { 11675 complete(); 11676 } 11677 }; 11678 _proto.hide = function hide(withoutTimeout) { 11679 var _this2 = this; 11680 if (!this._element.classList.contains(ClassName$a.SHOW)) { 11681 return; 11682 } 11683 $3(this._element).trigger(Event$a.HIDE); 11684 if (withoutTimeout) { 11685 this._close(); 11686 } else { 11687 this._timeout = setTimeout(function() { 11688 _this2._close(); 11689 }, this._config.delay); 11690 } 11691 }; 11692 _proto.dispose = function dispose() { 11693 clearTimeout(this._timeout); 11694 this._timeout = null; 11695 if (this._element.classList.contains(ClassName$a.SHOW)) { 11696 this._element.classList.remove(ClassName$a.SHOW); 11697 } 11698 $3(this._element).off(Event$a.CLICK_DISMISS); 11699 $3.removeData(this._element, DATA_KEY$a); 11700 this._element = null; 11701 this._config = null; 11702 }; 11703 _proto._getConfig = function _getConfig(config2) { 11704 config2 = _objectSpread({}, Default$7, $3(this._element).data(), typeof config2 === "object" && config2 ? config2 : {}); 11705 Util.typeCheckConfig(NAME$a, config2, this.constructor.DefaultType); 11706 return config2; 11707 }; 11708 _proto._setListeners = function _setListeners() { 11709 var _this3 = this; 11710 $3(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function() { 11711 return _this3.hide(true); 11712 }); 11713 }; 11714 _proto._close = function _close() { 11715 var _this4 = this; 11716 var complete = function complete2() { 11717 _this4._element.classList.add(ClassName$a.HIDE); 11718 $3(_this4._element).trigger(Event$a.HIDDEN); 11719 }; 11720 this._element.classList.remove(ClassName$a.SHOW); 11721 if (this._config.animation) { 11722 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 11723 $3(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 11724 } else { 11725 complete(); 11726 } 11727 }; 11728 Toast2._jQueryInterface = function _jQueryInterface(config2) { 11729 return this.each(function() { 11730 var $element = $3(this); 11731 var data = $element.data(DATA_KEY$a); 11732 var _config = typeof config2 === "object" && config2; 11733 if (!data) { 11734 data = new Toast2(this, _config); 11735 $element.data(DATA_KEY$a, data); 11736 } 11737 if (typeof config2 === "string") { 11738 if (typeof data[config2] === "undefined") { 11739 throw new TypeError('No method named "' + config2 + '"'); 11740 } 11741 data[config2](this); 11742 } 11743 }); 11744 }; 11745 _createClass(Toast2, null, [{ 11746 key: "VERSION", 11747 get: function get() { 11748 return VERSION$a; 11749 } 11750 }, { 11751 key: "DefaultType", 11752 get: function get() { 11753 return DefaultType$7; 11754 } 11755 }, { 11756 key: "Default", 11757 get: function get() { 11758 return Default$7; 11759 } 11760 }]); 11761 return Toast2; 11762 })(); 11763 $3.fn[NAME$a] = Toast._jQueryInterface; 11764 $3.fn[NAME$a].Constructor = Toast; 11765 $3.fn[NAME$a].noConflict = function() { 11766 $3.fn[NAME$a] = JQUERY_NO_CONFLICT$a; 11767 return Toast._jQueryInterface; 11768 }; 11769 (function() { 11770 if (typeof $3 === "undefined") { 11771 throw new TypeError("Bootstrap's JavaScript requires jQuery. jQuery must be included before Bootstrap's JavaScript."); 11772 } 11773 var version = $3.fn.jquery.split(" ")[0].split("."); 11774 var minMajor = 1; 11775 var ltMajor = 2; 11776 var minMinor = 9; 11777 var minPatch = 1; 11778 var maxMajor = 4; 11779 if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) { 11780 throw new Error("Bootstrap's JavaScript requires at least jQuery v1.9.1 but less than v4.0.0"); 11781 } 11782 })(); 11783 exports2.Util = Util; 11784 exports2.Alert = Alert; 11785 exports2.Button = Button; 11786 exports2.Carousel = Carousel; 11787 exports2.Collapse = Collapse; 11788 exports2.Dropdown = Dropdown; 11789 exports2.Modal = Modal; 11790 exports2.Popover = Popover; 11791 exports2.Scrollspy = ScrollSpy; 11792 exports2.Tab = Tab; 11793 exports2.Toast = Toast; 11794 exports2.Tooltip = Tooltip; 11795 Object.defineProperty(exports2, "__esModule", { value: true }); 11796 }); 11797 } 11798 }); 11799 11800
vendor: 113,634 bytes, lines 11800-14654
11800// node_modules/viewerjs/dist/viewer.js 11801 var require_viewer = __commonJS({ 11802 "node_modules/viewerjs/dist/viewer.js"(exports, module) { 11803 (function(global2, factory) { 11804 typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.Viewer = factory()); 11805 })(exports, (function() { 11806 "use strict"; 11807 function _classCallCheck(a, n) { 11808 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); 11809 } 11810 function _defineProperties(e, r) { 11811 for (var t = 0; t < r.length; t++) { 11812 var o = r[t]; 11813 o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o); 11814 } 11815 } 11816 function _createClass(e, r, t) { 11817 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { 11818 writable: false 11819 }), e; 11820 } 11821 function _defineProperty(e, r, t) { 11822 return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { 11823 value: t, 11824 enumerable: true, 11825 configurable: true, 11826 writable: true 11827 }) : e[r] = t, e; 11828 } 11829 function ownKeys(e, r) { 11830 var t = Object.keys(e); 11831 if (Object.getOwnPropertySymbols) { 11832 var o = Object.getOwnPropertySymbols(e); 11833 r && (o = o.filter(function(r2) { 11834 return Object.getOwnPropertyDescriptor(e, r2).enumerable; 11835 })), t.push.apply(t, o); 11836 } 11837 return t; 11838 } 11839 function _objectSpread2(e) { 11840 for (var r = 1; r < arguments.length; r++) { 11841 var t = null != arguments[r] ? arguments[r] : {}; 11842 r % 2 ? ownKeys(Object(t), true).forEach(function(r2) { 11843 _defineProperty(e, r2, t[r2]); 11844 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) { 11845 Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2)); 11846 }); 11847 } 11848 return e; 11849 } 11850 function _toPrimitive(t, r) { 11851 if ("object" != typeof t || !t) return t; 11852 var e = t[Symbol.toPrimitive]; 11853 if (void 0 !== e) { 11854 var i = e.call(t, r || "default"); 11855 if ("object" != typeof i) return i; 11856 throw new TypeError("@@toPrimitive must return a primitive value."); 11857 } 11858 return ("string" === r ? String : Number)(t); 11859 } 11860 function _toPropertyKey(t) { 11861 var i = _toPrimitive(t, "string"); 11862 return "symbol" == typeof i ? i : i + ""; 11863 } 11864 function _typeof(o) { 11865 "@babel/helpers - typeof"; 11866 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) { 11867 return typeof o2; 11868 } : function(o2) { 11869 return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2; 11870 }, _typeof(o); 11871 } 11872 var DEFAULTS = { 11873 /** 11874 * Enable a modal backdrop, specify `static` for a backdrop 11875 * which doesn't close the modal on click. 11876 * @type {boolean} 11877 */ 11878 backdrop: true, 11879 /** 11880 * Show the button on the top-right of the viewer. 11881 * @type {boolean} 11882 */ 11883 button: true, 11884 /** 11885 * Show the navbar. 11886 * @type {boolean | number} 11887 */ 11888 navbar: true, 11889 /** 11890 * Specify the visibility and the content of the title. 11891 * @type {boolean | number | Function | Array} 11892 */ 11893 title: true, 11894 /** 11895 * Show the toolbar. 11896 * @type {boolean | number | Object} 11897 */ 11898 toolbar: true, 11899 /** 11900 * Custom class name(s) to add to the viewer's root element. 11901 * @type {string} 11902 */ 11903 className: "", 11904 /** 11905 * Define where to put the viewer in modal mode. 11906 * @type {string | Element} 11907 */ 11908 container: "body", 11909 /** 11910 * Filter the images for viewing. Return true if the image is viewable. 11911 * @type {Function} 11912 */ 11913 filter: null, 11914 /** 11915 * Enable to request fullscreen when play. 11916 * {@link https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions} 11917 * @type {boolean|FullscreenOptions} 11918 */ 11919 fullscreen: true, 11920 /** 11921 * Define the extra attributes to inherit from the original image. 11922 * @type {Array} 11923 */ 11924 inheritedAttributes: ["crossOrigin", "decoding", "isMap", "loading", "referrerPolicy", "sizes", "srcset", "useMap"], 11925 /** 11926 * Define the initial coverage of the viewing image. 11927 * @type {number} 11928 */ 11929 initialCoverage: 0.9, 11930 /** 11931 * Define the initial index of the image for viewing. 11932 * @type {number} 11933 */ 11934 initialViewIndex: 0, 11935 /** 11936 * Enable inline mode. 11937 * @type {boolean} 11938 */ 11939 inline: false, 11940 /** 11941 * The amount of time to delay between automatically cycling an image when playing. 11942 * @type {number} 11943 */ 11944 interval: 5e3, 11945 /** 11946 * Enable keyboard support. 11947 * @type {boolean} 11948 */ 11949 keyboard: true, 11950 /** 11951 * Focus the viewer when initialized. 11952 * @type {boolean} 11953 */ 11954 focus: true, 11955 /** 11956 * Indicate if show a loading spinner when load image or not. 11957 * @type {boolean} 11958 */ 11959 loading: true, 11960 /** 11961 * Indicate if enable loop viewing or not. 11962 * @type {boolean} 11963 */ 11964 loop: true, 11965 /** 11966 * Min width of the viewer in inline mode. 11967 * @type {number} 11968 */ 11969 minWidth: 200, 11970 /** 11971 * Min height of the viewer in inline mode. 11972 * @type {number} 11973 */ 11974 minHeight: 100, 11975 /** 11976 * Enable to move the image. 11977 * @type {boolean} 11978 */ 11979 movable: true, 11980 /** 11981 * Enable to rotate the image. 11982 * @type {boolean} 11983 */ 11984 rotatable: true, 11985 /** 11986 * Enable to scale the image. 11987 * @type {boolean} 11988 */ 11989 scalable: true, 11990 /** 11991 * Enable to zoom the image. 11992 * @type {boolean} 11993 */ 11994 zoomable: true, 11995 /** 11996 * Enable to zoom the current image by dragging on the touch screen. 11997 * @type {boolean} 11998 */ 11999 zoomOnTouch: true, 12000 /** 12001 * Enable to zoom the image by wheeling mouse. 12002 * @type {boolean} 12003 */ 12004 zoomOnWheel: true, 12005 /** 12006 * Enable to slide to the next or previous image by swiping on the touch screen. 12007 * @type {boolean} 12008 */ 12009 slideOnTouch: true, 12010 /** 12011 * Indicate if toggle the image size between its natural size 12012 * and initial size when double click on the image or not. 12013 * @type {boolean} 12014 */ 12015 toggleOnDblclick: true, 12016 /** 12017 * Show the tooltip with image ratio (percentage) when zoom in or zoom out. 12018 * @type {boolean} 12019 */ 12020 tooltip: true, 12021 /** 12022 * Enable CSS3 Transition for some special elements. 12023 * @type {boolean} 12024 */ 12025 transition: true, 12026 /** 12027 * Define the CSS `z-index` value of viewer in modal mode. 12028 * @type {number} 12029 */ 12030 zIndex: 2015, 12031 /** 12032 * Define the CSS `z-index` value of viewer in inline mode. 12033 * @type {number} 12034 */ 12035 zIndexInline: 0, 12036 /** 12037 * Define the ratio when zoom the image by wheeling mouse. 12038 * @type {number} 12039 */ 12040 zoomRatio: 0.1, 12041 /** 12042 * Define the min ratio of the image when zoom out. 12043 * @type {number} 12044 */ 12045 minZoomRatio: 0.01, 12046 /** 12047 * Define the max ratio of the image when zoom in. 12048 * @type {number} 12049 */ 12050 maxZoomRatio: 100, 12051 /** 12052 * Define where to get the original image URL for viewing. 12053 * @type {string | Function} 12054 */ 12055 url: "src", 12056 /** 12057 * Event shortcuts. 12058 * @type {Function} 12059 */ 12060 ready: null, 12061 show: null, 12062 shown: null, 12063 hide: null, 12064 hidden: null, 12065 view: null, 12066 viewed: null, 12067 move: null, 12068 moved: null, 12069 rotate: null, 12070 rotated: null, 12071 scale: null, 12072 scaled: null, 12073 zoom: null, 12074 zoomed: null, 12075 play: null, 12076 stop: null 12077 }; 12078 var TEMPLATE = '<div class="viewer-container" tabindex="-1" touch-action="none"><div class="viewer-canvas"></div><div class="viewer-footer"><div class="viewer-title"></div><div class="viewer-toolbar"></div><div class="viewer-navbar"><ul class="viewer-list" role="navigation"></ul></div></div><div class="viewer-tooltip" role="alert" aria-hidden="true"></div><div class="viewer-button" data-viewer-action="mix" role="button"></div><div class="viewer-player"></div></div>'; 12079 var IS_BROWSER = typeof window !== "undefined" && typeof window.document !== "undefined"; 12080 var WINDOW = IS_BROWSER ? window : {}; 12081 var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? "ontouchstart" in WINDOW.document.documentElement : false; 12082 var HAS_POINTER_EVENT = IS_BROWSER ? "PointerEvent" in WINDOW : false; 12083 var NAMESPACE = "viewer"; 12084 var ACTION_MOVE = "move"; 12085 var ACTION_SWITCH = "switch"; 12086 var ACTION_ZOOM = "zoom"; 12087 var CLASS_ACTIVE = "".concat(NAMESPACE, "-active"); 12088 var CLASS_CLOSE = "".concat(NAMESPACE, "-close"); 12089 var CLASS_FADE = "".concat(NAMESPACE, "-fade"); 12090 var CLASS_FIXED = "".concat(NAMESPACE, "-fixed"); 12091 var CLASS_FULLSCREEN = "".concat(NAMESPACE, "-fullscreen"); 12092 var CLASS_FULLSCREEN_EXIT = "".concat(NAMESPACE, "-fullscreen-exit"); 12093 var CLASS_HIDE = "".concat(NAMESPACE, "-hide"); 12094 var CLASS_HIDE_MD_DOWN = "".concat(NAMESPACE, "-hide-md-down"); 12095 var CLASS_HIDE_SM_DOWN = "".concat(NAMESPACE, "-hide-sm-down"); 12096 var CLASS_HIDE_XS_DOWN = "".concat(NAMESPACE, "-hide-xs-down"); 12097 var CLASS_IN = "".concat(NAMESPACE, "-in"); 12098 var CLASS_INVISIBLE = "".concat(NAMESPACE, "-invisible"); 12099 var CLASS_LOADING = "".concat(NAMESPACE, "-loading"); 12100 var CLASS_MOVE = "".concat(NAMESPACE, "-move"); 12101 var CLASS_OPEN = "".concat(NAMESPACE, "-open"); 12102 var CLASS_SHOW = "".concat(NAMESPACE, "-show"); 12103 var CLASS_TRANSITION = "".concat(NAMESPACE, "-transition"); 12104 var EVENT_CLICK = "click"; 12105 var EVENT_DBLCLICK = "dblclick"; 12106 var EVENT_DRAG_START = "dragstart"; 12107 var EVENT_FOCUSIN = "focusin"; 12108 var EVENT_KEY_DOWN = "keydown"; 12109 var EVENT_LOAD = "load"; 12110 var EVENT_ERROR = "error"; 12111 var EVENT_TOUCH_END = IS_TOUCH_DEVICE ? "touchend touchcancel" : "mouseup"; 12112 var EVENT_TOUCH_MOVE = IS_TOUCH_DEVICE ? "touchmove" : "mousemove"; 12113 var EVENT_TOUCH_START = IS_TOUCH_DEVICE ? "touchstart" : "mousedown"; 12114 var EVENT_POINTER_DOWN = HAS_POINTER_EVENT ? "pointerdown" : EVENT_TOUCH_START; 12115 var EVENT_POINTER_MOVE = HAS_POINTER_EVENT ? "pointermove" : EVENT_TOUCH_MOVE; 12116 var EVENT_POINTER_UP = HAS_POINTER_EVENT ? "pointerup pointercancel" : EVENT_TOUCH_END; 12117 var EVENT_RESIZE = "resize"; 12118 var EVENT_TRANSITION_END = "transitionend"; 12119 var EVENT_WHEEL = "wheel"; 12120 var EVENT_READY = "ready"; 12121 var EVENT_SHOW = "show"; 12122 var EVENT_SHOWN = "shown"; 12123 var EVENT_HIDE = "hide"; 12124 var EVENT_HIDDEN = "hidden"; 12125 var EVENT_VIEW = "view"; 12126 var EVENT_VIEWED = "viewed"; 12127 var EVENT_MOVE = "move"; 12128 var EVENT_MOVED = "moved"; 12129 var EVENT_ROTATE = "rotate"; 12130 var EVENT_ROTATED = "rotated"; 12131 var EVENT_SCALE = "scale"; 12132 var EVENT_SCALED = "scaled"; 12133 var EVENT_ZOOM = "zoom"; 12134 var EVENT_ZOOMED = "zoomed"; 12135 var EVENT_PLAY = "play"; 12136 var EVENT_STOP = "stop"; 12137 var DATA_ACTION = "".concat(NAMESPACE, "Action"); 12138 var REGEXP_SPACES = /\s+/; 12139 var BUTTONS = ["zoom-in", "zoom-out", "one-to-one", "reset", "prev", "play", "next", "rotate-left", "rotate-right", "flip-horizontal", "flip-vertical"]; 12140 function isString(value) { 12141 return typeof value === "string"; 12142 } 12143 var isNaN2 = Number.isNaN || WINDOW.isNaN; 12144 function isNumber(value) { 12145 return typeof value === "number" && !isNaN2(value); 12146 } 12147 function isUndefined(value) { 12148 return typeof value === "undefined"; 12149 } 12150 function isObject(value) { 12151 return _typeof(value) === "object" && value !== null; 12152 } 12153 var hasOwnProperty = Object.prototype.hasOwnProperty; 12154 function isPlainObject(value) { 12155 if (!isObject(value)) { 12156 return false; 12157 } 12158 try { 12159 var constructor = value.constructor; 12160 var prototype = constructor.prototype; 12161 return constructor && prototype && hasOwnProperty.call(prototype, "isPrototypeOf"); 12162 } catch (error2) { 12163 return false; 12164 } 12165 } 12166 function isFunction(value) { 12167 return typeof value === "function"; 12168 } 12169 function forEach(data, callback) { 12170 if (data && isFunction(callback)) { 12171 if (Array.isArray(data) || isNumber(data.length)) { 12172 var length = data.length; 12173 var i; 12174 for (i = 0; i < length; i += 1) { 12175 if (callback.call(data, data[i], i, data) === false) { 12176 break; 12177 } 12178 } 12179 } else if (isObject(data)) { 12180 Object.keys(data).forEach(function(key) { 12181 callback.call(data, data[key], key, data); 12182 }); 12183 } 12184 } 12185 return data; 12186 } 12187 var assign = Object.assign || function assign2(obj) { 12188 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 12189 args[_key - 1] = arguments[_key]; 12190 } 12191 if (isObject(obj) && args.length > 0) { 12192 args.forEach(function(arg) { 12193 if (isObject(arg)) { 12194 Object.keys(arg).forEach(function(key) { 12195 obj[key] = arg[key]; 12196 }); 12197 } 12198 }); 12199 } 12200 return obj; 12201 }; 12202 var REGEXP_SUFFIX = /^(?:width|height|left|top|marginLeft|marginTop)$/; 12203 function setStyle(element, styles) { 12204 var style = element.style; 12205 forEach(styles, function(value, property) { 12206 if (REGEXP_SUFFIX.test(property) && isNumber(value)) { 12207 value += "px"; 12208 } 12209 style[property] = value; 12210 }); 12211 } 12212 function escapeHTMLEntities(value) { 12213 return isString(value) ? value.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">") : value; 12214 } 12215 function hasClass(element, value) { 12216 if (!element || !value) { 12217 return false; 12218 } 12219 return element.classList ? element.classList.contains(value) : element.className.split(REGEXP_SPACES).indexOf(value) > -1; 12220 } 12221 function addClass(element, value) { 12222 if (!element || !value) { 12223 return; 12224 } 12225 if (isNumber(element.length)) { 12226 forEach(element, function(elem) { 12227 addClass(elem, value); 12228 }); 12229 return; 12230 } 12231 if (element.classList) { 12232 element.classList.add(value); 12233 return; 12234 } 12235 var className = element.className.trim(); 12236 if (!className) { 12237 element.className = value; 12238 } else if (className.indexOf(value) < 0) { 12239 element.className = "".concat(className, " ").concat(value); 12240 } 12241 } 12242 function removeClass(element, value) { 12243 if (!element || !value) { 12244 return; 12245 } 12246 if (isNumber(element.length)) { 12247 forEach(element, function(elem) { 12248 removeClass(elem, value); 12249 }); 12250 return; 12251 } 12252 if (element.classList) { 12253 element.classList.remove(value); 12254 return; 12255 } 12256 var className = element.className; 12257 if (className && className.indexOf(value) >= 0) { 12258 element.className = className.split(REGEXP_SPACES).filter(function(item) { 12259 return item && item !== value; 12260 }).join(" "); 12261 } 12262 } 12263 function toggleClass(element, value, added) { 12264 if (!value) { 12265 return; 12266 } 12267 if (isNumber(element.length)) { 12268 forEach(element, function(elem) { 12269 toggleClass(elem, value, added); 12270 }); 12271 return; 12272 } 12273 if (added) { 12274 addClass(element, value); 12275 } else { 12276 removeClass(element, value); 12277 } 12278 } 12279 var REGEXP_HYPHENATE = /([a-z\d])([A-Z])/g; 12280 function hyphenate(value) { 12281 return value.replace(REGEXP_HYPHENATE, "$1-$2").toLowerCase(); 12282 } 12283 function getData2(element, name) { 12284 if (isObject(element[name])) { 12285 return element[name]; 12286 } 12287 if (element.dataset) { 12288 return element.dataset[name]; 12289 } 12290 return element.getAttribute("data-".concat(hyphenate(name))); 12291 } 12292 function setData2(element, name, data) { 12293 if (isObject(data)) { 12294 element[name] = data; 12295 } else if (element.dataset) { 12296 element.dataset[name] = data; 12297 } else { 12298 element.setAttribute("data-".concat(hyphenate(name)), data); 12299 } 12300 } 12301 var onceSupported = (function() { 12302 var supported = false; 12303 if (IS_BROWSER) { 12304 var once = false; 12305 var listener = function listener2() { 12306 }; 12307 var options = Object.defineProperty({}, "once", { 12308 get: function get() { 12309 supported = true; 12310 return once; 12311 }, 12312 /** 12313 * This setter can fix a `TypeError` in strict mode 12314 * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only} 12315 * @param {boolean} value - The value to set 12316 */ 12317 set: function set(value) { 12318 once = value; 12319 } 12320 }); 12321 WINDOW.addEventListener("test", listener, options); 12322 WINDOW.removeEventListener("test", listener, options); 12323 } 12324 return supported; 12325 })(); 12326 function removeListener(element, type, listener) { 12327 var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; 12328 var handler = listener; 12329 type.trim().split(REGEXP_SPACES).forEach(function(event) { 12330 if (!onceSupported) { 12331 var listeners = element.listeners; 12332 if (listeners && listeners[event] && listeners[event][listener]) { 12333 handler = listeners[event][listener]; 12334 delete listeners[event][listener]; 12335 if (Object.keys(listeners[event]).length === 0) { 12336 delete listeners[event]; 12337 } 12338 if (Object.keys(listeners).length === 0) { 12339 delete element.listeners; 12340 } 12341 } 12342 } 12343 element.removeEventListener(event, handler, options); 12344 }); 12345 } 12346 function addListener(element, type, listener) { 12347 var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; 12348 var _handler = listener; 12349 type.trim().split(REGEXP_SPACES).forEach(function(event) { 12350 if (options.once && !onceSupported) { 12351 var _element$listeners = element.listeners, listeners = _element$listeners === void 0 ? {} : _element$listeners; 12352 _handler = function handler() { 12353 delete listeners[event][listener]; 12354 element.removeEventListener(event, _handler, options); 12355 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 12356 args[_key2] = arguments[_key2]; 12357 } 12358 listener.apply(element, args); 12359 }; 12360 if (!listeners[event]) { 12361 listeners[event] = {}; 12362 } 12363 if (listeners[event][listener]) { 12364 element.removeEventListener(event, listeners[event][listener], options); 12365 } 12366 listeners[event][listener] = _handler; 12367 element.listeners = listeners; 12368 } 12369 element.addEventListener(event, _handler, options); 12370 }); 12371 } 12372 function dispatchEvent(element, type, data, options) { 12373 var event; 12374 if (isFunction(Event) && isFunction(CustomEvent)) { 12375 event = new CustomEvent(type, _objectSpread2({ 12376 bubbles: true, 12377 cancelable: true, 12378 detail: data 12379 }, options)); 12380 } else { 12381 event = document.createEvent("CustomEvent"); 12382 event.initCustomEvent(type, true, true, data); 12383 } 12384 return element.dispatchEvent(event); 12385 } 12386 function getOffset(element) { 12387 var box = element.getBoundingClientRect(); 12388 return { 12389 left: box.left + (window.pageXOffset - document.documentElement.clientLeft), 12390 top: box.top + (window.pageYOffset - document.documentElement.clientTop) 12391 }; 12392 } 12393 function getTransforms(_ref) { 12394 var rotate = _ref.rotate, scaleX = _ref.scaleX, scaleY = _ref.scaleY, translateX = _ref.translateX, translateY = _ref.translateY; 12395 var values = []; 12396 if (isNumber(translateX) && translateX !== 0) { 12397 values.push("translateX(".concat(translateX, "px)")); 12398 } 12399 if (isNumber(translateY) && translateY !== 0) { 12400 values.push("translateY(".concat(translateY, "px)")); 12401 } 12402 if (isNumber(rotate) && rotate !== 0) { 12403 values.push("rotate(".concat(rotate, "deg)")); 12404 } 12405 if (isNumber(scaleX) && scaleX !== 1) { 12406 values.push("scaleX(".concat(scaleX, ")")); 12407 } 12408 if (isNumber(scaleY) && scaleY !== 1) { 12409 values.push("scaleY(".concat(scaleY, ")")); 12410 } 12411 var transform = values.length ? values.join(" ") : "none"; 12412 return { 12413 WebkitTransform: transform, 12414 msTransform: transform, 12415 transform 12416 }; 12417 } 12418 function getImageNameFromURL(url) { 12419 return isString(url) ? decodeURIComponent(url.replace(/^.*\//, "").replace(/[?&#].*$/, "")) : ""; 12420 } 12421 var IS_SAFARI = WINDOW.navigator && /Version\/\d+(\.\d+)+?\s+Safari/i.test(WINDOW.navigator.userAgent); 12422 function getImageNaturalSizes(image, options, callback) { 12423 var newImage = document.createElement("img"); 12424 if (image.naturalWidth && !IS_SAFARI) { 12425 callback(image.naturalWidth, image.naturalHeight); 12426 return newImage; 12427 } 12428 var body = document.body || document.documentElement; 12429 newImage.onload = function() { 12430 callback(newImage.width, newImage.height); 12431 if (!IS_SAFARI) { 12432 body.removeChild(newImage); 12433 } 12434 }; 12435 forEach(options.inheritedAttributes, function(name) { 12436 var value = image.getAttribute(name); 12437 if (value !== null) { 12438 newImage.setAttribute(name, value); 12439 } 12440 }); 12441 newImage.src = image.src; 12442 if (!IS_SAFARI) { 12443 newImage.style.cssText = "left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;"; 12444 body.appendChild(newImage); 12445 } 12446 return newImage; 12447 } 12448 function getResponsiveClass(type) { 12449 switch (type) { 12450 case 2: 12451 return CLASS_HIDE_XS_DOWN; 12452 case 3: 12453 return CLASS_HIDE_SM_DOWN; 12454 case 4: 12455 return CLASS_HIDE_MD_DOWN; 12456 default: 12457 return ""; 12458 } 12459 } 12460 function getMaxZoomRatio(pointers) { 12461 var pointers2 = _objectSpread2({}, pointers); 12462 var ratios = []; 12463 forEach(pointers, function(pointer, pointerId) { 12464 delete pointers2[pointerId]; 12465 forEach(pointers2, function(pointer2) { 12466 var x1 = Math.abs(pointer.startX - pointer2.startX); 12467 var y1 = Math.abs(pointer.startY - pointer2.startY); 12468 var x2 = Math.abs(pointer.endX - pointer2.endX); 12469 var y2 = Math.abs(pointer.endY - pointer2.endY); 12470 var z1 = Math.sqrt(x1 * x1 + y1 * y1); 12471 var z2 = Math.sqrt(x2 * x2 + y2 * y2); 12472 var ratio = (z2 - z1) / z1; 12473 ratios.push(ratio); 12474 }); 12475 }); 12476 ratios.sort(function(a, b) { 12477 return Math.abs(a) < Math.abs(b); 12478 }); 12479 return ratios[0]; 12480 } 12481 function getPointer(_ref2, endOnly) { 12482 var pageX = _ref2.pageX, pageY = _ref2.pageY; 12483 var end = { 12484 endX: pageX, 12485 endY: pageY 12486 }; 12487 return endOnly ? end : _objectSpread2({ 12488 timeStamp: Date.now(), 12489 startX: pageX, 12490 startY: pageY 12491 }, end); 12492 } 12493 function getPointersCenter(pointers) { 12494 var pageX = 0; 12495 var pageY = 0; 12496 var count = 0; 12497 forEach(pointers, function(_ref3) { 12498 var startX = _ref3.startX, startY = _ref3.startY; 12499 pageX += startX; 12500 pageY += startY; 12501 count += 1; 12502 }); 12503 pageX /= count; 12504 pageY /= count; 12505 return { 12506 pageX, 12507 pageY 12508 }; 12509 } 12510 var render = { 12511 render: function render2() { 12512 this.initContainer(); 12513 this.initViewer(); 12514 this.initList(); 12515 this.renderViewer(); 12516 }, 12517 initBody: function initBody() { 12518 var ownerDocument = this.element.ownerDocument; 12519 var body = ownerDocument.body || ownerDocument.documentElement; 12520 this.body = body; 12521 this.scrollbarWidth = window.innerWidth - ownerDocument.documentElement.clientWidth; 12522 this.initialBodyPaddingRight = body.style.paddingRight; 12523 this.initialBodyComputedPaddingRight = window.getComputedStyle(body).paddingRight; 12524 }, 12525 initContainer: function initContainer() { 12526 this.containerData = { 12527 width: window.innerWidth, 12528 height: window.innerHeight 12529 }; 12530 }, 12531 initViewer: function initViewer() { 12532 var options = this.options, parent = this.parent; 12533 var viewerData; 12534 if (options.inline) { 12535 viewerData = { 12536 width: Math.max(parent.offsetWidth, options.minWidth), 12537 height: Math.max(parent.offsetHeight, options.minHeight) 12538 }; 12539 this.parentData = viewerData; 12540 } 12541 if (this.fulled || !viewerData) { 12542 viewerData = this.containerData; 12543 } 12544 this.viewerData = assign({}, viewerData); 12545 }, 12546 renderViewer: function renderViewer() { 12547 if (this.options.inline && !this.fulled) { 12548 setStyle(this.viewer, this.viewerData); 12549 } 12550 }, 12551 initList: function initList() { 12552 var _this = this; 12553 var element = this.element, options = this.options, list = this.list; 12554 var items = []; 12555 list.innerHTML = ""; 12556 forEach(this.images, function(image, index) { 12557 var src = image.src; 12558 var alt = image.alt || getImageNameFromURL(src); 12559 var url = _this.getImageURL(image); 12560 if (src || url) { 12561 var item = document.createElement("li"); 12562 var img = document.createElement("img"); 12563 forEach(options.inheritedAttributes, function(name) { 12564 var value = image.getAttribute(name); 12565 if (value !== null) { 12566 img.setAttribute(name, value); 12567 } 12568 }); 12569 if (options.navbar) { 12570 img.src = src || url; 12571 } 12572 img.alt = alt; 12573 img.setAttribute("data-original-url", url || src); 12574 item.setAttribute("data-index", index); 12575 item.setAttribute("data-viewer-action", "view"); 12576 item.setAttribute("role", "button"); 12577 if (options.keyboard) { 12578 item.setAttribute("tabindex", 0); 12579 } 12580 item.appendChild(img); 12581 list.appendChild(item); 12582 items.push(item); 12583 } 12584 }); 12585 this.items = items; 12586 forEach(items, function(item) { 12587 var image = item.firstElementChild; 12588 var onLoad; 12589 var onError; 12590 setData2(image, "filled", true); 12591 if (options.loading) { 12592 addClass(item, CLASS_LOADING); 12593 } 12594 addListener(image, EVENT_LOAD, onLoad = function onLoad2(event) { 12595 removeListener(image, EVENT_ERROR, onError); 12596 if (options.loading) { 12597 removeClass(item, CLASS_LOADING); 12598 } 12599 _this.loadImage(event); 12600 }, { 12601 once: true 12602 }); 12603 addListener(image, EVENT_ERROR, onError = function onError2() { 12604 removeListener(image, EVENT_LOAD, onLoad); 12605 if (options.loading) { 12606 removeClass(item, CLASS_LOADING); 12607 } 12608 }, { 12609 once: true 12610 }); 12611 }); 12612 if (options.transition) { 12613 addListener(element, EVENT_VIEWED, function() { 12614 addClass(list, CLASS_TRANSITION); 12615 }, { 12616 once: true 12617 }); 12618 } 12619 }, 12620 renderList: function renderList() { 12621 var index = this.index; 12622 var item = this.items[index]; 12623 if (!item) { 12624 return; 12625 } 12626 var next = item.nextElementSibling; 12627 var gutter = parseInt(window.getComputedStyle(next || item).marginLeft, 10); 12628 var offsetWidth = item.offsetWidth; 12629 var outerWidth = offsetWidth + gutter; 12630 setStyle(this.list, assign({ 12631 width: outerWidth * this.length - gutter 12632 }, getTransforms({ 12633 translateX: (this.viewerData.width - offsetWidth) / 2 - outerWidth * index 12634 }))); 12635 }, 12636 resetList: function resetList() { 12637 var list = this.list; 12638 list.innerHTML = ""; 12639 removeClass(list, CLASS_TRANSITION); 12640 setStyle(list, assign({ 12641 width: 0 12642 }, getTransforms({ 12643 translateX: 0 12644 }))); 12645 }, 12646 initImage: function initImage(done) { 12647 var _this2 = this; 12648 var options = this.options, image = this.image, viewerData = this.viewerData; 12649 var footerHeight = this.footer.offsetHeight; 12650 var viewerWidth = viewerData.width; 12651 var viewerHeight = Math.max(viewerData.height - footerHeight, footerHeight); 12652 var oldImageData = this.imageData || {}; 12653 var sizingImage; 12654 this.imageInitializing = { 12655 abort: function abort() { 12656 sizingImage.onload = null; 12657 } 12658 }; 12659 sizingImage = getImageNaturalSizes(image, options, function(naturalWidth, naturalHeight) { 12660 var aspectRatio = naturalWidth / naturalHeight; 12661 var initialCoverage = Math.max(0, Math.min(1, options.initialCoverage)); 12662 var width = viewerWidth; 12663 var height = viewerHeight; 12664 _this2.imageInitializing = false; 12665 if (viewerHeight * aspectRatio > viewerWidth) { 12666 height = viewerWidth / aspectRatio; 12667 } else { 12668 width = viewerHeight * aspectRatio; 12669 } 12670 initialCoverage = isNumber(initialCoverage) ? initialCoverage : 0.9; 12671 width = Math.min(width * initialCoverage, naturalWidth); 12672 height = Math.min(height * initialCoverage, naturalHeight); 12673 var left = (viewerWidth - width) / 2; 12674 var top = (viewerHeight - height) / 2; 12675 var imageData = { 12676 left, 12677 top, 12678 x: left, 12679 y: top, 12680 width, 12681 height, 12682 oldRatio: 1, 12683 ratio: width / naturalWidth, 12684 aspectRatio, 12685 naturalWidth, 12686 naturalHeight 12687 }; 12688 var initialImageData = assign({}, imageData); 12689 if (options.rotatable) { 12690 imageData.rotate = oldImageData.rotate || 0; 12691 initialImageData.rotate = 0; 12692 } 12693 if (options.scalable) { 12694 imageData.scaleX = oldImageData.scaleX || 1; 12695 imageData.scaleY = oldImageData.scaleY || 1; 12696 initialImageData.scaleX = 1; 12697 initialImageData.scaleY = 1; 12698 } 12699 _this2.imageData = imageData; 12700 _this2.initialImageData = initialImageData; 12701 if (done) { 12702 done(); 12703 } 12704 }); 12705 }, 12706 renderImage: function renderImage(done) { 12707 var _this3 = this; 12708 var image = this.image, imageData = this.imageData; 12709 setStyle(image, assign({ 12710 width: imageData.width, 12711 height: imageData.height, 12712 // XXX: Not to use translateX/Y to avoid image shaking when zooming 12713 marginLeft: imageData.x, 12714 marginTop: imageData.y 12715 }, getTransforms(imageData))); 12716 if (done) { 12717 if ((this.viewing || this.moving || this.rotating || this.scaling || this.zooming) && this.options.transition && hasClass(image, CLASS_TRANSITION)) { 12718 var onTransitionEnd = function onTransitionEnd2() { 12719 _this3.imageRendering = false; 12720 done(); 12721 }; 12722 this.imageRendering = { 12723 abort: function abort() { 12724 removeListener(image, EVENT_TRANSITION_END, onTransitionEnd); 12725 } 12726 }; 12727 addListener(image, EVENT_TRANSITION_END, onTransitionEnd, { 12728 once: true 12729 }); 12730 } else { 12731 done(); 12732 } 12733 } 12734 }, 12735 resetImage: function resetImage() { 12736 var image = this.image; 12737 if (image) { 12738 if (this.viewing) { 12739 this.viewing.abort(); 12740 } 12741 image.parentNode.removeChild(image); 12742 this.image = null; 12743 this.title.innerHTML = ""; 12744 } 12745 } 12746 }; 12747 var events = { 12748 bind: function bind() { 12749 var options = this.options, viewer = this.viewer, canvas = this.canvas; 12750 var document2 = this.element.ownerDocument; 12751 addListener(viewer, EVENT_CLICK, this.onClick = this.click.bind(this)); 12752 addListener(viewer, EVENT_DRAG_START, this.onDragStart = this.dragstart.bind(this)); 12753 addListener(canvas, EVENT_POINTER_DOWN, this.onPointerDown = this.pointerdown.bind(this)); 12754 addListener(document2, EVENT_POINTER_MOVE, this.onPointerMove = this.pointermove.bind(this)); 12755 addListener(document2, EVENT_POINTER_UP, this.onPointerUp = this.pointerup.bind(this)); 12756 addListener(document2, EVENT_KEY_DOWN, this.onKeyDown = this.keydown.bind(this)); 12757 addListener(window, EVENT_RESIZE, this.onResize = this.resize.bind(this)); 12758 if (options.zoomable && options.zoomOnWheel) { 12759 addListener(viewer, EVENT_WHEEL, this.onWheel = this.wheel.bind(this), { 12760 passive: false, 12761 capture: true 12762 }); 12763 } 12764 if (options.toggleOnDblclick) { 12765 addListener(canvas, EVENT_DBLCLICK, this.onDblclick = this.dblclick.bind(this)); 12766 } 12767 }, 12768 unbind: function unbind() { 12769 var options = this.options, viewer = this.viewer, canvas = this.canvas; 12770 var document2 = this.element.ownerDocument; 12771 removeListener(viewer, EVENT_CLICK, this.onClick); 12772 removeListener(viewer, EVENT_DRAG_START, this.onDragStart); 12773 removeListener(canvas, EVENT_POINTER_DOWN, this.onPointerDown); 12774 removeListener(document2, EVENT_POINTER_MOVE, this.onPointerMove); 12775 removeListener(document2, EVENT_POINTER_UP, this.onPointerUp); 12776 removeListener(document2, EVENT_KEY_DOWN, this.onKeyDown); 12777 removeListener(window, EVENT_RESIZE, this.onResize); 12778 if (options.zoomable && options.zoomOnWheel) { 12779 removeListener(viewer, EVENT_WHEEL, this.onWheel, { 12780 passive: false, 12781 capture: true 12782 }); 12783 } 12784 if (options.toggleOnDblclick) { 12785 removeListener(canvas, EVENT_DBLCLICK, this.onDblclick); 12786 } 12787 } 12788 }; 12789 var handlers = { 12790 click: function click(event) { 12791 var options = this.options, imageData = this.imageData; 12792 var target = event.target; 12793 var action = getData2(target, DATA_ACTION); 12794 if (!action && target.localName === "img" && target.parentElement.localName === "li") { 12795 target = target.parentElement; 12796 action = getData2(target, DATA_ACTION); 12797 } 12798 if (IS_TOUCH_DEVICE && event.isTrusted && target === this.canvas) { 12799 clearTimeout(this.clickCanvasTimeout); 12800 } 12801 switch (action) { 12802 case "mix": 12803 if (this.played) { 12804 this.stop(); 12805 } else if (options.inline) { 12806 if (this.fulled) { 12807 this.exit(); 12808 } else { 12809 this.full(); 12810 } 12811 } else { 12812 this.hide(); 12813 } 12814 break; 12815 case "hide": 12816 if (!this.pointerMoved) { 12817 this.hide(); 12818 } 12819 break; 12820 case "view": 12821 this.view(getData2(target, "index")); 12822 break; 12823 case "zoom-in": 12824 this.zoom(0.1, true); 12825 break; 12826 case "zoom-out": 12827 this.zoom(-0.1, true); 12828 break; 12829 case "one-to-one": 12830 this.toggle(); 12831 break; 12832 case "reset": 12833 this.reset(); 12834 break; 12835 case "prev": 12836 this.prev(options.loop); 12837 break; 12838 case "play": 12839 this.play(options.fullscreen); 12840 break; 12841 case "next": 12842 this.next(options.loop); 12843 break; 12844 case "rotate-left": 12845 this.rotate(-90); 12846 break; 12847 case "rotate-right": 12848 this.rotate(90); 12849 break; 12850 case "flip-horizontal": 12851 this.scaleX(-imageData.scaleX || -1); 12852 break; 12853 case "flip-vertical": 12854 this.scaleY(-imageData.scaleY || -1); 12855 break; 12856 default: 12857 if (this.played) { 12858 this.stop(); 12859 } 12860 } 12861 }, 12862 dblclick: function dblclick(event) { 12863 event.preventDefault(); 12864 if (this.viewed && event.target === this.image) { 12865 if (IS_TOUCH_DEVICE && event.isTrusted) { 12866 clearTimeout(this.doubleClickImageTimeout); 12867 } 12868 this.toggle(event.isTrusted ? event : event.detail && event.detail.originalEvent); 12869 } 12870 }, 12871 load: function load() { 12872 var _this = this; 12873 if (this.timeout) { 12874 clearTimeout(this.timeout); 12875 this.timeout = false; 12876 } 12877 var element = this.element, options = this.options, image = this.image, index = this.index, viewerData = this.viewerData; 12878 removeClass(image, CLASS_INVISIBLE); 12879 if (options.loading) { 12880 removeClass(this.canvas, CLASS_LOADING); 12881 } 12882 image.style.cssText = "height:0;" + "margin-left:".concat(viewerData.width / 2, "px;") + "margin-top:".concat(viewerData.height / 2, "px;") + "max-width:none!important;position:relative;width:0;"; 12883 this.initImage(function() { 12884 toggleClass(image, CLASS_MOVE, options.movable); 12885 toggleClass(image, CLASS_TRANSITION, options.transition); 12886 _this.renderImage(function() { 12887 _this.viewed = true; 12888 _this.viewing = false; 12889 if (isFunction(options.viewed)) { 12890 addListener(element, EVENT_VIEWED, options.viewed, { 12891 once: true 12892 }); 12893 } 12894 dispatchEvent(element, EVENT_VIEWED, { 12895 originalImage: _this.images[index], 12896 index, 12897 image 12898 }, { 12899 cancelable: false 12900 }); 12901 }); 12902 }); 12903 }, 12904 loadImage: function loadImage(event) { 12905 var image = event.target; 12906 var parent = image.parentNode; 12907 var parentWidth = parent.offsetWidth || 30; 12908 var parentHeight = parent.offsetHeight || 50; 12909 var filled = !!getData2(image, "filled"); 12910 getImageNaturalSizes(image, this.options, function(naturalWidth, naturalHeight) { 12911 var aspectRatio = naturalWidth / naturalHeight; 12912 var width = parentWidth; 12913 var height = parentHeight; 12914 if (parentHeight * aspectRatio > parentWidth) { 12915 if (filled) { 12916 width = parentHeight * aspectRatio; 12917 } else { 12918 height = parentWidth / aspectRatio; 12919 } 12920 } else if (filled) { 12921 height = parentWidth / aspectRatio; 12922 } else { 12923 width = parentHeight * aspectRatio; 12924 } 12925 setStyle(image, assign({ 12926 width, 12927 height 12928 }, getTransforms({ 12929 translateX: (parentWidth - width) / 2, 12930 translateY: (parentHeight - height) / 2 12931 }))); 12932 }); 12933 }, 12934 keydown: function keydown(event) { 12935 var options = this.options; 12936 if (!options.keyboard) { 12937 return; 12938 } 12939 var keyCode = event.keyCode || event.which || event.charCode; 12940 switch (keyCode) { 12941 // Enter 12942 case 13: 12943 if (this.viewer.contains(event.target)) { 12944 this.click(event); 12945 } 12946 break; 12947 } 12948 if (!this.fulled) { 12949 return; 12950 } 12951 switch (keyCode) { 12952 // Escape 12953 case 27: 12954 if (this.played) { 12955 this.stop(); 12956 } else if (options.inline) { 12957 if (this.fulled) { 12958 this.exit(); 12959 } 12960 } else { 12961 this.hide(); 12962 } 12963 break; 12964 // Space 12965 case 32: 12966 if (this.played) { 12967 this.stop(); 12968 } 12969 break; 12970 // ArrowLeft 12971 case 37: 12972 if (this.played && this.playing) { 12973 this.playing.prev(); 12974 } else { 12975 this.prev(options.loop); 12976 } 12977 break; 12978 // ArrowUp 12979 case 38: 12980 event.preventDefault(); 12981 this.zoom(options.zoomRatio, true); 12982 break; 12983 // ArrowRight 12984 case 39: 12985 if (this.played && this.playing) { 12986 this.playing.next(); 12987 } else { 12988 this.next(options.loop); 12989 } 12990 break; 12991 // ArrowDown 12992 case 40: 12993 event.preventDefault(); 12994 this.zoom(-options.zoomRatio, true); 12995 break; 12996 // Ctrl + 0 12997 case 48: 12998 // Fall through 12999 // Ctrl + 1 13000 // eslint-disable-next-line no-fallthrough 13001 case 49: 13002 if (event.ctrlKey) { 13003 event.preventDefault(); 13004 this.toggle(); 13005 } 13006 break; 13007 } 13008 }, 13009 dragstart: function dragstart(event) { 13010 if (event.target.localName === "img") { 13011 event.preventDefault(); 13012 } 13013 }, 13014 pointerdown: function pointerdown(event) { 13015 var options = this.options, pointers = this.pointers; 13016 var buttons = event.buttons, button = event.button; 13017 this.pointerMoved = false; 13018 if (!this.viewed || this.showing || this.viewing || this.hiding || (event.type === "mousedown" || event.type === "pointerdown" && event.pointerType === "mouse") && // No primary button (Usually the left button) 13019 (isNumber(buttons) && buttons !== 1 || isNumber(button) && button !== 0 || event.ctrlKey)) { 13020 return; 13021 } 13022 event.preventDefault(); 13023 if (event.changedTouches) { 13024 forEach(event.changedTouches, function(touch) { 13025 pointers[touch.identifier] = getPointer(touch); 13026 }); 13027 } else { 13028 pointers[event.pointerId || 0] = getPointer(event); 13029 } 13030 var action = options.movable ? ACTION_MOVE : false; 13031 if (options.zoomOnTouch && options.zoomable && Object.keys(pointers).length > 1) { 13032 action = ACTION_ZOOM; 13033 } else if (options.slideOnTouch && (event.pointerType === "touch" || event.type === "touchstart") && this.isSwitchable()) { 13034 action = ACTION_SWITCH; 13035 } 13036 if (options.transition && (action === ACTION_MOVE || action === ACTION_ZOOM)) { 13037 removeClass(this.image, CLASS_TRANSITION); 13038 } 13039 this.action = action; 13040 }, 13041 pointermove: function pointermove(event) { 13042 var pointers = this.pointers, action = this.action; 13043 if (!this.viewed || !action) { 13044 return; 13045 } 13046 event.preventDefault(); 13047 if (event.changedTouches) { 13048 forEach(event.changedTouches, function(touch) { 13049 assign(pointers[touch.identifier] || {}, getPointer(touch, true)); 13050 }); 13051 } else { 13052 assign(pointers[event.pointerId || 0] || {}, getPointer(event, true)); 13053 } 13054 this.change(event); 13055 }, 13056 pointerup: function pointerup(event) { 13057 var _this2 = this; 13058 var options = this.options, action = this.action, pointers = this.pointers; 13059 var pointer; 13060 if (event.changedTouches) { 13061 forEach(event.changedTouches, function(touch) { 13062 pointer = pointers[touch.identifier]; 13063 delete pointers[touch.identifier]; 13064 }); 13065 } else { 13066 pointer = pointers[event.pointerId || 0]; 13067 delete pointers[event.pointerId || 0]; 13068 } 13069 if (!action) { 13070 return; 13071 } 13072 event.preventDefault(); 13073 if (options.transition && (action === ACTION_MOVE || action === ACTION_ZOOM)) { 13074 addClass(this.image, CLASS_TRANSITION); 13075 } 13076 this.action = false; 13077 if (IS_TOUCH_DEVICE && action !== ACTION_ZOOM && pointer && Date.now() - pointer.timeStamp < 500) { 13078 clearTimeout(this.clickCanvasTimeout); 13079 clearTimeout(this.doubleClickImageTimeout); 13080 if (options.toggleOnDblclick && this.viewed && event.target === this.image) { 13081 if (this.pointerMoved) { 13082 this.imageClicked = false; 13083 } else if (this.imageClicked) { 13084 this.imageClicked = false; 13085 this.doubleClickImageTimeout = setTimeout(function() { 13086 dispatchEvent(_this2.image, EVENT_DBLCLICK, { 13087 originalEvent: event 13088 }); 13089 }, 50); 13090 } else { 13091 this.imageClicked = true; 13092 this.doubleClickImageTimeout = setTimeout(function() { 13093 _this2.imageClicked = false; 13094 }, 500); 13095 } 13096 } else { 13097 this.imageClicked = false; 13098 if (options.backdrop && options.backdrop !== "static" && event.target === this.canvas) { 13099 this.clickCanvasTimeout = setTimeout(function() { 13100 dispatchEvent(_this2.canvas, EVENT_CLICK, { 13101 originalEvent: event 13102 }); 13103 }, 50); 13104 } 13105 } 13106 } 13107 }, 13108 resize: function resize() { 13109 var _this3 = this; 13110 if (!this.isShown || this.hiding) { 13111 return; 13112 } 13113 if (this.fulled) { 13114 this.close(); 13115 this.initBody(); 13116 this.open(); 13117 } 13118 this.initContainer(); 13119 this.initViewer(); 13120 this.renderViewer(); 13121 this.renderList(); 13122 if (this.viewed) { 13123 this.initImage(function() { 13124 _this3.renderImage(); 13125 }); 13126 } 13127 if (this.played) { 13128 if (this.options.fullscreen && this.fulled && !(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement)) { 13129 this.stop(); 13130 return; 13131 } 13132 forEach(this.player.getElementsByTagName("img"), function(image) { 13133 addListener(image, EVENT_LOAD, _this3.loadImage.bind(_this3), { 13134 once: true 13135 }); 13136 dispatchEvent(image, EVENT_LOAD); 13137 }); 13138 } 13139 }, 13140 wheel: function wheel(event) { 13141 var _this4 = this; 13142 if (!this.viewed) { 13143 return; 13144 } 13145 event.preventDefault(); 13146 if (this.wheeling) { 13147 return; 13148 } 13149 this.wheeling = true; 13150 setTimeout(function() { 13151 _this4.wheeling = false; 13152 }, 50); 13153 var ratio = Number(this.options.zoomRatio) || 0.1; 13154 var delta = 1; 13155 if (event.deltaY) { 13156 delta = event.deltaY > 0 ? 1 : -1; 13157 } else if (event.wheelDelta) { 13158 delta = -event.wheelDelta / 120; 13159 } else if (event.detail) { 13160 delta = event.detail > 0 ? 1 : -1; 13161 } 13162 this.zoom(-delta * ratio, true, null, event); 13163 } 13164 }; 13165 var methods = { 13166 /** Show the viewer (only available in modal mode) 13167 * @param {boolean} [immediate=false] - Indicates if show the viewer immediately or not. 13168 * @returns {Viewer} this 13169 */ 13170 show: function show() { 13171 var immediate = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; 13172 var element = this.element, options = this.options; 13173 if (options.inline || this.showing || this.isShown || this.showing) { 13174 return this; 13175 } 13176 if (!this.ready) { 13177 this.build(); 13178 if (this.ready) { 13179 this.show(immediate); 13180 } 13181 return this; 13182 } 13183 if (isFunction(options.show)) { 13184 addListener(element, EVENT_SHOW, options.show, { 13185 once: true 13186 }); 13187 } 13188 if (dispatchEvent(element, EVENT_SHOW) === false || !this.ready) { 13189 return this; 13190 } 13191 if (this.hiding) { 13192 this.transitioning.abort(); 13193 } 13194 this.showing = true; 13195 this.open(); 13196 var viewer = this.viewer; 13197 removeClass(viewer, CLASS_HIDE); 13198 viewer.setAttribute("role", "dialog"); 13199 viewer.setAttribute("aria-labelledby", this.title.id); 13200 viewer.setAttribute("aria-modal", true); 13201 viewer.removeAttribute("aria-hidden"); 13202 if (options.transition && !immediate) { 13203 var shown = this.shown.bind(this); 13204 this.transitioning = { 13205 abort: function abort() { 13206 removeListener(viewer, EVENT_TRANSITION_END, shown); 13207 removeClass(viewer, CLASS_IN); 13208 } 13209 }; 13210 addClass(viewer, CLASS_TRANSITION); 13211 viewer.initialOffsetWidth = viewer.offsetWidth; 13212 addListener(viewer, EVENT_TRANSITION_END, shown, { 13213 once: true 13214 }); 13215 addClass(viewer, CLASS_IN); 13216 } else { 13217 addClass(viewer, CLASS_IN); 13218 this.shown(); 13219 } 13220 return this; 13221 }, 13222 /** 13223 * Hide the viewer (only available in modal mode) 13224 * @param {boolean} [immediate=false] - Indicates if hide the viewer immediately or not. 13225 * @returns {Viewer} this 13226 */ 13227 hide: function hide() { 13228 var _this = this; 13229 var immediate = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; 13230 var element = this.element, options = this.options; 13231 if (options.inline || this.hiding || !(this.isShown || this.showing)) { 13232 return this; 13233 } 13234 if (isFunction(options.hide)) { 13235 addListener(element, EVENT_HIDE, options.hide, { 13236 once: true 13237 }); 13238 } 13239 if (dispatchEvent(element, EVENT_HIDE) === false) { 13240 return this; 13241 } 13242 if (this.showing) { 13243 this.transitioning.abort(); 13244 } 13245 this.hiding = true; 13246 if (this.played) { 13247 this.stop(); 13248 } else if (this.viewing) { 13249 this.viewing.abort(); 13250 } 13251 var viewer = this.viewer, image = this.image; 13252 var hideImmediately = function hideImmediately2() { 13253 removeClass(viewer, CLASS_IN); 13254 _this.hidden(); 13255 }; 13256 if (options.transition && !immediate) { 13257 var _onViewerTransitionEnd = function onViewerTransitionEnd(event) { 13258 if (event && event.target === viewer) { 13259 removeListener(viewer, EVENT_TRANSITION_END, _onViewerTransitionEnd); 13260 _this.hidden(); 13261 } 13262 }; 13263 var onImageTransitionEnd = function onImageTransitionEnd2() { 13264 if (hasClass(viewer, CLASS_TRANSITION)) { 13265 addListener(viewer, EVENT_TRANSITION_END, _onViewerTransitionEnd); 13266 removeClass(viewer, CLASS_IN); 13267 } else { 13268 hideImmediately(); 13269 } 13270 }; 13271 this.transitioning = { 13272 abort: function abort() { 13273 if (_this.viewed && hasClass(image, CLASS_TRANSITION)) { 13274 removeListener(image, EVENT_TRANSITION_END, onImageTransitionEnd); 13275 } else if (hasClass(viewer, CLASS_TRANSITION)) { 13276 removeListener(viewer, EVENT_TRANSITION_END, _onViewerTransitionEnd); 13277 } 13278 } 13279 }; 13280 if (this.viewed && hasClass(image, CLASS_TRANSITION)) { 13281 addListener(image, EVENT_TRANSITION_END, onImageTransitionEnd, { 13282 once: true 13283 }); 13284 this.zoomTo(0, false, null, null, true); 13285 } else { 13286 onImageTransitionEnd(); 13287 } 13288 } else { 13289 hideImmediately(); 13290 } 13291 return this; 13292 }, 13293 /** 13294 * View one of the images with image's index 13295 * @param {number} index - The index of the image to view. 13296 * @returns {Viewer} this 13297 */ 13298 view: function view() { 13299 var _this2 = this; 13300 var index = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.initialViewIndex; 13301 index = Number(index) || 0; 13302 if (this.hiding || this.played || index < 0 || index >= this.length || this.viewed && index === this.index) { 13303 return this; 13304 } 13305 if (!this.isShown) { 13306 this.index = index; 13307 return this.show(); 13308 } 13309 if (this.viewing) { 13310 this.viewing.abort(); 13311 } 13312 var element = this.element, options = this.options, title = this.title, canvas = this.canvas; 13313 var item = this.items[index]; 13314 var img = item.querySelector("img"); 13315 var url = getData2(img, "originalUrl"); 13316 var alt = img.getAttribute("alt"); 13317 var image = document.createElement("img"); 13318 forEach(options.inheritedAttributes, function(name) { 13319 var value = img.getAttribute(name); 13320 if (value !== null) { 13321 image.setAttribute(name, value); 13322 } 13323 }); 13324 image.src = url; 13325 image.alt = alt; 13326 if (isFunction(options.view)) { 13327 addListener(element, EVENT_VIEW, options.view, { 13328 once: true 13329 }); 13330 } 13331 if (dispatchEvent(element, EVENT_VIEW, { 13332 originalImage: this.images[index], 13333 index, 13334 image 13335 }) === false || !this.isShown || this.hiding || this.played) { 13336 return this; 13337 } 13338 var activeItem = this.items[this.index]; 13339 if (activeItem) { 13340 removeClass(activeItem, CLASS_ACTIVE); 13341 activeItem.removeAttribute("aria-selected"); 13342 } 13343 addClass(item, CLASS_ACTIVE); 13344 item.setAttribute("aria-selected", true); 13345 if (options.focus) { 13346 item.focus(); 13347 } 13348 this.image = image; 13349 this.viewed = false; 13350 this.index = index; 13351 this.imageData = {}; 13352 addClass(image, CLASS_INVISIBLE); 13353 if (options.loading) { 13354 addClass(canvas, CLASS_LOADING); 13355 } 13356 canvas.innerHTML = ""; 13357 canvas.appendChild(image); 13358 this.renderList(); 13359 title.innerHTML = ""; 13360 var onViewed = function onViewed2() { 13361 var imageData = _this2.imageData; 13362 var render2 = Array.isArray(options.title) ? options.title[1] : options.title; 13363 title.innerHTML = escapeHTMLEntities(isFunction(render2) ? render2.call(_this2, image, imageData) : "".concat(alt, " (").concat(imageData.naturalWidth, " \xD7 ").concat(imageData.naturalHeight, ")")); 13364 }; 13365 var onLoad; 13366 var onError; 13367 addListener(element, EVENT_VIEWED, onViewed, { 13368 once: true 13369 }); 13370 this.viewing = { 13371 abort: function abort() { 13372 removeListener(element, EVENT_VIEWED, onViewed); 13373 if (image.complete) { 13374 if (_this2.imageRendering) { 13375 _this2.imageRendering.abort(); 13376 } else if (_this2.imageInitializing) { 13377 _this2.imageInitializing.abort(); 13378 } 13379 } else { 13380 image.src = ""; 13381 removeListener(image, EVENT_LOAD, onLoad); 13382 if (_this2.timeout) { 13383 clearTimeout(_this2.timeout); 13384 } 13385 } 13386 } 13387 }; 13388 if (image.complete) { 13389 this.load(); 13390 } else { 13391 addListener(image, EVENT_LOAD, onLoad = function onLoad2() { 13392 removeListener(image, EVENT_ERROR, onError); 13393 _this2.load(); 13394 }, { 13395 once: true 13396 }); 13397 addListener(image, EVENT_ERROR, onError = function onError2() { 13398 removeListener(image, EVENT_LOAD, onLoad); 13399 if (_this2.timeout) { 13400 clearTimeout(_this2.timeout); 13401 _this2.timeout = false; 13402 } 13403 removeClass(image, CLASS_INVISIBLE); 13404 if (options.loading) { 13405 removeClass(_this2.canvas, CLASS_LOADING); 13406 } 13407 }, { 13408 once: true 13409 }); 13410 if (this.timeout) { 13411 clearTimeout(this.timeout); 13412 } 13413 this.timeout = setTimeout(function() { 13414 removeClass(image, CLASS_INVISIBLE); 13415 _this2.timeout = false; 13416 }, 1e3); 13417 } 13418 return this; 13419 }, 13420 /** 13421 * View the previous image 13422 * @param {boolean} [loop=false] - Indicate if view the last one 13423 * when it is the first one at present. 13424 * @returns {Viewer} this 13425 */ 13426 prev: function prev() { 13427 var loop = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; 13428 var index = this.index - 1; 13429 if (index < 0) { 13430 index = loop ? this.length - 1 : 0; 13431 } 13432 this.view(index); 13433 return this; 13434 }, 13435 /** 13436 * View the next image 13437 * @param {boolean} [loop=false] - Indicate if view the first one 13438 * when it is the last one at present. 13439 * @returns {Viewer} this 13440 */ 13441 next: function next() { 13442 var loop = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; 13443 var maxIndex = this.length - 1; 13444 var index = this.index + 1; 13445 if (index > maxIndex) { 13446 index = loop ? 0 : maxIndex; 13447 } 13448 this.view(index); 13449 return this; 13450 }, 13451 /** 13452 * Move the image with relative offsets. 13453 * @param {number} x - The moving distance in the horizontal direction. 13454 * @param {number} [y=x] The moving distance in the vertical direction. 13455 * @returns {Viewer} this 13456 */ 13457 move: function move(x) { 13458 var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; 13459 var imageData = this.imageData; 13460 this.moveTo(isUndefined(x) ? x : imageData.x + Number(x), isUndefined(y) ? y : imageData.y + Number(y)); 13461 return this; 13462 }, 13463 /** 13464 * Move the image to an absolute point. 13465 * @param {number} x - The new position in the horizontal direction. 13466 * @param {number} [y=x] - The new position in the vertical direction. 13467 * @param {Event} [_originalEvent=null] - The original event if any. 13468 * @returns {Viewer} this 13469 */ 13470 moveTo: function moveTo(x) { 13471 var _this3 = this; 13472 var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; 13473 var _originalEvent = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null; 13474 var element = this.element, options = this.options, imageData = this.imageData; 13475 x = Number(x); 13476 y = Number(y); 13477 if (this.viewed && !this.played && options.movable) { 13478 var oldX = imageData.x; 13479 var oldY = imageData.y; 13480 var changed = false; 13481 if (isNumber(x)) { 13482 changed = true; 13483 } else { 13484 x = oldX; 13485 } 13486 if (isNumber(y)) { 13487 changed = true; 13488 } else { 13489 y = oldY; 13490 } 13491 if (changed) { 13492 if (isFunction(options.move)) { 13493 addListener(element, EVENT_MOVE, options.move, { 13494 once: true 13495 }); 13496 } 13497 if (dispatchEvent(element, EVENT_MOVE, { 13498 x, 13499 y, 13500 oldX, 13501 oldY, 13502 originalEvent: _originalEvent 13503 }) === false) { 13504 return this; 13505 } 13506 imageData.x = x; 13507 imageData.y = y; 13508 imageData.left = x; 13509 imageData.top = y; 13510 this.moving = true; 13511 this.renderImage(function() { 13512 _this3.moving = false; 13513 if (isFunction(options.moved)) { 13514 addListener(element, EVENT_MOVED, options.moved, { 13515 once: true 13516 }); 13517 } 13518 dispatchEvent(element, EVENT_MOVED, { 13519 x, 13520 y, 13521 oldX, 13522 oldY, 13523 originalEvent: _originalEvent 13524 }, { 13525 cancelable: false 13526 }); 13527 }); 13528 } 13529 } 13530 return this; 13531 }, 13532 /** 13533 * Rotate the image with a relative degree. 13534 * @param {number} degree - The rotate degree. 13535 * @returns {Viewer} this 13536 */ 13537 rotate: function rotate(degree) { 13538 this.rotateTo((this.imageData.rotate || 0) + Number(degree)); 13539 return this; 13540 }, 13541 /** 13542 * Rotate the image to an absolute degree. 13543 * @param {number} degree - The rotate degree. 13544 * @returns {Viewer} this 13545 */ 13546 rotateTo: function rotateTo(degree) { 13547 var _this4 = this; 13548 var element = this.element, options = this.options, imageData = this.imageData; 13549 degree = Number(degree); 13550 if (isNumber(degree) && this.viewed && !this.played && options.rotatable) { 13551 var oldDegree = imageData.rotate; 13552 if (isFunction(options.rotate)) { 13553 addListener(element, EVENT_ROTATE, options.rotate, { 13554 once: true 13555 }); 13556 } 13557 if (dispatchEvent(element, EVENT_ROTATE, { 13558 degree, 13559 oldDegree 13560 }) === false) { 13561 return this; 13562 } 13563 imageData.rotate = degree; 13564 this.rotating = true; 13565 this.renderImage(function() { 13566 _this4.rotating = false; 13567 if (isFunction(options.rotated)) { 13568 addListener(element, EVENT_ROTATED, options.rotated, { 13569 once: true 13570 }); 13571 } 13572 dispatchEvent(element, EVENT_ROTATED, { 13573 degree, 13574 oldDegree 13575 }, { 13576 cancelable: false 13577 }); 13578 }); 13579 } 13580 return this; 13581 }, 13582 /** 13583 * Scale the image on the x-axis. 13584 * @param {number} scaleX - The scale ratio on the x-axis. 13585 * @returns {Viewer} this 13586 */ 13587 scaleX: function scaleX(_scaleX) { 13588 this.scale(_scaleX, this.imageData.scaleY); 13589 return this; 13590 }, 13591 /** 13592 * Scale the image on the y-axis. 13593 * @param {number} scaleY - The scale ratio on the y-axis. 13594 * @returns {Viewer} this 13595 */ 13596 scaleY: function scaleY(_scaleY) { 13597 this.scale(this.imageData.scaleX, _scaleY); 13598 return this; 13599 }, 13600 /** 13601 * Scale the image. 13602 * @param {number} scaleX - The scale ratio on the x-axis. 13603 * @param {number} [scaleY=scaleX] - The scale ratio on the y-axis. 13604 * @returns {Viewer} this 13605 */ 13606 scale: function scale(scaleX) { 13607 var _this5 = this; 13608 var scaleY = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : scaleX; 13609 var element = this.element, options = this.options, imageData = this.imageData; 13610 scaleX = Number(scaleX); 13611 scaleY = Number(scaleY); 13612 if (this.viewed && !this.played && options.scalable) { 13613 var oldScaleX = imageData.scaleX; 13614 var oldScaleY = imageData.scaleY; 13615 var changed = false; 13616 if (isNumber(scaleX)) { 13617 changed = true; 13618 } else { 13619 scaleX = oldScaleX; 13620 } 13621 if (isNumber(scaleY)) { 13622 changed = true; 13623 } else { 13624 scaleY = oldScaleY; 13625 } 13626 if (changed) { 13627 if (isFunction(options.scale)) { 13628 addListener(element, EVENT_SCALE, options.scale, { 13629 once: true 13630 }); 13631 } 13632 if (dispatchEvent(element, EVENT_SCALE, { 13633 scaleX, 13634 scaleY, 13635 oldScaleX, 13636 oldScaleY 13637 }) === false) { 13638 return this; 13639 } 13640 imageData.scaleX = scaleX; 13641 imageData.scaleY = scaleY; 13642 this.scaling = true; 13643 this.renderImage(function() { 13644 _this5.scaling = false; 13645 if (isFunction(options.scaled)) { 13646 addListener(element, EVENT_SCALED, options.scaled, { 13647 once: true 13648 }); 13649 } 13650 dispatchEvent(element, EVENT_SCALED, { 13651 scaleX, 13652 scaleY, 13653 oldScaleX, 13654 oldScaleY 13655 }, { 13656 cancelable: false 13657 }); 13658 }); 13659 } 13660 } 13661 return this; 13662 }, 13663 /** 13664 * Zoom the image with a relative ratio. 13665 * @param {number} ratio - The target ratio. 13666 * @param {boolean} [showTooltip=false] - Indicates whether to show the tooltip. 13667 * @param {Object} [pivot] - The pivot point coordinate for zooming. 13668 * @param {Event} [_originalEvent=null] - The original event if any. 13669 * @returns {Viewer} this 13670 */ 13671 zoom: function zoom(ratio) { 13672 var showTooltip = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; 13673 var pivot = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null; 13674 var _originalEvent = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null; 13675 var imageData = this.imageData; 13676 ratio = Number(ratio); 13677 if (ratio < 0) { 13678 ratio = 1 / (1 - ratio); 13679 } else { 13680 ratio = 1 + ratio; 13681 } 13682 this.zoomTo(imageData.width * ratio / imageData.naturalWidth, showTooltip, pivot, _originalEvent); 13683 return this; 13684 }, 13685 /** 13686 * Zoom the image to an absolute ratio. 13687 * @param {number} ratio - The target ratio. 13688 * @param {boolean} [showTooltip] - Indicates whether to show the tooltip. 13689 * @param {Object} [pivot] - The pivot point coordinate for zooming. 13690 * @param {Event} [_originalEvent=null] - The original event if any. 13691 * @param {Event} [_zoomable=false] - Indicates if the current zoom is available or not. 13692 * @returns {Viewer} this 13693 */ 13694 zoomTo: function zoomTo(ratio) { 13695 var _this6 = this; 13696 var showTooltip = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; 13697 var pivot = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null; 13698 var _originalEvent = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null; 13699 var _zoomable = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false; 13700 var element = this.element, options = this.options, pointers = this.pointers, imageData = this.imageData; 13701 var x = imageData.x, y = imageData.y, width = imageData.width, height = imageData.height, naturalWidth = imageData.naturalWidth, naturalHeight = imageData.naturalHeight; 13702 ratio = Math.max(0, ratio); 13703 if (isNumber(ratio) && this.viewed && !this.played && (_zoomable || options.zoomable)) { 13704 if (!_zoomable) { 13705 var minZoomRatio = Math.max(0.01, options.minZoomRatio); 13706 var maxZoomRatio = Math.min(100, options.maxZoomRatio); 13707 ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio); 13708 } 13709 if (_originalEvent) { 13710 switch (_originalEvent.type) { 13711 case "wheel": 13712 if (options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) { 13713 ratio = 1; 13714 } 13715 break; 13716 case "pointermove": 13717 case "touchmove": 13718 case "mousemove": 13719 if (ratio > 0.99 && ratio < 1.01) { 13720 ratio = 1; 13721 } 13722 break; 13723 } 13724 } 13725 var newWidth = naturalWidth * ratio; 13726 var newHeight = naturalHeight * ratio; 13727 var offsetWidth = newWidth - width; 13728 var offsetHeight = newHeight - height; 13729 var oldRatio = imageData.ratio; 13730 if (isFunction(options.zoom)) { 13731 addListener(element, EVENT_ZOOM, options.zoom, { 13732 once: true 13733 }); 13734 } 13735 if (dispatchEvent(element, EVENT_ZOOM, { 13736 ratio, 13737 oldRatio, 13738 originalEvent: _originalEvent 13739 }) === false) { 13740 return this; 13741 } 13742 this.zooming = true; 13743 if (_originalEvent) { 13744 var offset = getOffset(this.viewer); 13745 var center = pointers && Object.keys(pointers).length > 0 ? getPointersCenter(pointers) : { 13746 pageX: _originalEvent.pageX, 13747 pageY: _originalEvent.pageY 13748 }; 13749 imageData.x -= offsetWidth * ((center.pageX - offset.left - x) / width); 13750 imageData.y -= offsetHeight * ((center.pageY - offset.top - y) / height); 13751 } else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) { 13752 imageData.x -= offsetWidth * ((pivot.x - x) / width); 13753 imageData.y -= offsetHeight * ((pivot.y - y) / height); 13754 } else { 13755 imageData.x -= offsetWidth / 2; 13756 imageData.y -= offsetHeight / 2; 13757 } 13758 imageData.left = imageData.x; 13759 imageData.top = imageData.y; 13760 imageData.width = newWidth; 13761 imageData.height = newHeight; 13762 imageData.oldRatio = oldRatio; 13763 imageData.ratio = ratio; 13764 this.renderImage(function() { 13765 _this6.zooming = false; 13766 if (isFunction(options.zoomed)) { 13767 addListener(element, EVENT_ZOOMED, options.zoomed, { 13768 once: true 13769 }); 13770 } 13771 dispatchEvent(element, EVENT_ZOOMED, { 13772 ratio, 13773 oldRatio, 13774 originalEvent: _originalEvent 13775 }, { 13776 cancelable: false 13777 }); 13778 }); 13779 if (showTooltip) { 13780 this.tooltip(); 13781 } 13782 } 13783 return this; 13784 }, 13785 /** 13786 * Play the images 13787 * @param {boolean|FullscreenOptions} [fullscreen=false] - Indicate if request fullscreen or not. 13788 * @returns {Viewer} this 13789 */ 13790 play: function play() { 13791 var _this7 = this; 13792 var fullscreen = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; 13793 if (!this.isShown || this.played) { 13794 return this; 13795 } 13796 var element = this.element, options = this.options; 13797 if (isFunction(options.play)) { 13798 addListener(element, EVENT_PLAY, options.play, { 13799 once: true 13800 }); 13801 } 13802 if (dispatchEvent(element, EVENT_PLAY) === false) { 13803 return this; 13804 } 13805 var player = this.player; 13806 var onLoad = this.loadImage.bind(this); 13807 var list = []; 13808 var total = 0; 13809 var index = 0; 13810 this.played = true; 13811 this.onLoadWhenPlay = onLoad; 13812 if (fullscreen) { 13813 this.requestFullscreen(fullscreen); 13814 } 13815 addClass(player, CLASS_SHOW); 13816 forEach(this.items, function(item, i) { 13817 var img = item.querySelector("img"); 13818 var image = document.createElement("img"); 13819 image.src = getData2(img, "originalUrl"); 13820 image.alt = img.getAttribute("alt"); 13821 image.referrerPolicy = img.referrerPolicy; 13822 total += 1; 13823 addClass(image, CLASS_FADE); 13824 toggleClass(image, CLASS_TRANSITION, options.transition); 13825 if (hasClass(item, CLASS_ACTIVE)) { 13826 addClass(image, CLASS_IN); 13827 index = i; 13828 } 13829 list.push(image); 13830 addListener(image, EVENT_LOAD, onLoad, { 13831 once: true 13832 }); 13833 player.appendChild(image); 13834 }); 13835 if (isNumber(options.interval) && options.interval > 0) { 13836 var _prev = function prev() { 13837 clearTimeout(_this7.playing.timeout); 13838 removeClass(list[index], CLASS_IN); 13839 index -= 1; 13840 index = index >= 0 ? index : total - 1; 13841 addClass(list[index], CLASS_IN); 13842 _this7.playing.timeout = setTimeout(_prev, options.interval); 13843 }; 13844 var _next = function next() { 13845 clearTimeout(_this7.playing.timeout); 13846 removeClass(list[index], CLASS_IN); 13847 index += 1; 13848 index = index < total ? index : 0; 13849 addClass(list[index], CLASS_IN); 13850 _this7.playing.timeout = setTimeout(_next, options.interval); 13851 }; 13852 if (total > 1) { 13853 this.playing = { 13854 prev: _prev, 13855 next: _next, 13856 timeout: setTimeout(_next, options.interval) 13857 }; 13858 } 13859 } 13860 return this; 13861 }, 13862 // Stop play 13863 stop: function stop() { 13864 var _this8 = this; 13865 if (!this.played) { 13866 return this; 13867 } 13868 var element = this.element, options = this.options; 13869 if (isFunction(options.stop)) { 13870 addListener(element, EVENT_STOP, options.stop, { 13871 once: true 13872 }); 13873 } 13874 if (dispatchEvent(element, EVENT_STOP) === false) { 13875 return this; 13876 } 13877 var player = this.player; 13878 clearTimeout(this.playing.timeout); 13879 this.playing = false; 13880 this.played = false; 13881 forEach(player.getElementsByTagName("img"), function(image) { 13882 removeListener(image, EVENT_LOAD, _this8.onLoadWhenPlay); 13883 }); 13884 removeClass(player, CLASS_SHOW); 13885 player.innerHTML = ""; 13886 this.exitFullscreen(); 13887 return this; 13888 }, 13889 // Enter modal mode (only available in inline mode) 13890 full: function full() { 13891 var _this9 = this; 13892 var options = this.options, viewer = this.viewer, image = this.image, list = this.list; 13893 if (!this.isShown || this.played || this.fulled || !options.inline) { 13894 return this; 13895 } 13896 this.fulled = true; 13897 this.open(); 13898 addClass(this.button, CLASS_FULLSCREEN_EXIT); 13899 if (options.transition) { 13900 removeClass(list, CLASS_TRANSITION); 13901 if (this.viewed) { 13902 removeClass(image, CLASS_TRANSITION); 13903 } 13904 } 13905 addClass(viewer, CLASS_FIXED); 13906 viewer.setAttribute("role", "dialog"); 13907 viewer.setAttribute("aria-labelledby", this.title.id); 13908 viewer.setAttribute("aria-modal", true); 13909 viewer.removeAttribute("style"); 13910 setStyle(viewer, { 13911 zIndex: options.zIndex 13912 }); 13913 if (options.focus) { 13914 this.enforceFocus(); 13915 } 13916 this.initContainer(); 13917 this.viewerData = assign({}, this.containerData); 13918 this.renderList(); 13919 if (this.viewed) { 13920 this.initImage(function() { 13921 _this9.renderImage(function() { 13922 if (options.transition) { 13923 setTimeout(function() { 13924 addClass(image, CLASS_TRANSITION); 13925 addClass(list, CLASS_TRANSITION); 13926 }, 0); 13927 } 13928 }); 13929 }); 13930 } 13931 return this; 13932 }, 13933 // Exit modal mode (only available in inline mode) 13934 exit: function exit() { 13935 var _this0 = this; 13936 var options = this.options, viewer = this.viewer, image = this.image, list = this.list; 13937 if (!this.isShown || this.played || !this.fulled || !options.inline) { 13938 return this; 13939 } 13940 this.fulled = false; 13941 this.close(); 13942 removeClass(this.button, CLASS_FULLSCREEN_EXIT); 13943 if (options.transition) { 13944 removeClass(list, CLASS_TRANSITION); 13945 if (this.viewed) { 13946 removeClass(image, CLASS_TRANSITION); 13947 } 13948 } 13949 if (options.focus) { 13950 this.clearEnforceFocus(); 13951 } 13952 viewer.removeAttribute("role"); 13953 viewer.removeAttribute("aria-labelledby"); 13954 viewer.removeAttribute("aria-modal"); 13955 removeClass(viewer, CLASS_FIXED); 13956 setStyle(viewer, { 13957 zIndex: options.zIndexInline 13958 }); 13959 this.viewerData = assign({}, this.parentData); 13960 this.renderViewer(); 13961 this.renderList(); 13962 if (this.viewed) { 13963 this.initImage(function() { 13964 _this0.renderImage(function() { 13965 if (options.transition) { 13966 setTimeout(function() { 13967 addClass(image, CLASS_TRANSITION); 13968 addClass(list, CLASS_TRANSITION); 13969 }, 0); 13970 } 13971 }); 13972 }); 13973 } 13974 return this; 13975 }, 13976 // Show the current ratio of the image with percentage 13977 tooltip: function tooltip() { 13978 var _this1 = this; 13979 var options = this.options, tooltipBox = this.tooltipBox, imageData = this.imageData; 13980 if (!this.viewed || this.played || !options.tooltip) { 13981 return this; 13982 } 13983 tooltipBox.textContent = "".concat(Math.round(imageData.ratio * 100), "%"); 13984 if (!this.tooltipping) { 13985 if (options.transition) { 13986 if (this.fading) { 13987 dispatchEvent(tooltipBox, EVENT_TRANSITION_END); 13988 } 13989 addClass(tooltipBox, CLASS_SHOW); 13990 addClass(tooltipBox, CLASS_FADE); 13991 addClass(tooltipBox, CLASS_TRANSITION); 13992 tooltipBox.removeAttribute("aria-hidden"); 13993 tooltipBox.initialOffsetWidth = tooltipBox.offsetWidth; 13994 addClass(tooltipBox, CLASS_IN); 13995 } else { 13996 addClass(tooltipBox, CLASS_SHOW); 13997 tooltipBox.removeAttribute("aria-hidden"); 13998 } 13999 } else { 14000 clearTimeout(this.tooltipping); 14001 } 14002 this.tooltipping = setTimeout(function() { 14003 if (options.transition) { 14004 addListener(tooltipBox, EVENT_TRANSITION_END, function() { 14005 removeClass(tooltipBox, CLASS_SHOW); 14006 removeClass(tooltipBox, CLASS_FADE); 14007 removeClass(tooltipBox, CLASS_TRANSITION); 14008 tooltipBox.setAttribute("aria-hidden", true); 14009 _this1.fading = false; 14010 }, { 14011 once: true 14012 }); 14013 removeClass(tooltipBox, CLASS_IN); 14014 _this1.fading = true; 14015 } else { 14016 removeClass(tooltipBox, CLASS_SHOW); 14017 tooltipBox.setAttribute("aria-hidden", true); 14018 } 14019 _this1.tooltipping = false; 14020 }, 1e3); 14021 return this; 14022 }, 14023 /** 14024 * Toggle the image size between its current size and natural size 14025 * @param {Event} [_originalEvent=null] - The original event if any. 14026 * @returns {Viewer} this 14027 */ 14028 toggle: function toggle() { 14029 var _originalEvent = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null; 14030 if (this.imageData.ratio === 1) { 14031 this.zoomTo(this.imageData.oldRatio, true, null, _originalEvent); 14032 } else { 14033 this.zoomTo(1, true, null, _originalEvent); 14034 } 14035 return this; 14036 }, 14037 // Reset the image to its initial state 14038 reset: function reset() { 14039 if (this.viewed && !this.played) { 14040 this.imageData = assign({}, this.initialImageData); 14041 this.renderImage(); 14042 } 14043 return this; 14044 }, 14045 // Update viewer when images changed 14046 update: function update() { 14047 var _this10 = this; 14048 var element = this.element, options = this.options, isImg = this.isImg; 14049 if (isImg && !element.parentNode) { 14050 return this.destroy(); 14051 } 14052 var images = []; 14053 forEach(isImg ? [element] : element.querySelectorAll("img"), function(image) { 14054 if (isFunction(options.filter)) { 14055 if (options.filter.call(_this10, image)) { 14056 images.push(image); 14057 } 14058 } else if (_this10.getImageURL(image)) { 14059 images.push(image); 14060 } 14061 }); 14062 if (!images.length) { 14063 return this; 14064 } 14065 this.images = images; 14066 this.length = images.length; 14067 if (this.ready) { 14068 var changedIndexes = []; 14069 forEach(this.items, function(item, i) { 14070 var img = item.querySelector("img"); 14071 var image = images[i]; 14072 if (image && img) { 14073 if (image.src !== img.src || image.alt !== img.alt) { 14074 changedIndexes.push(i); 14075 } 14076 } else { 14077 changedIndexes.push(i); 14078 } 14079 }); 14080 setStyle(this.list, { 14081 width: "auto" 14082 }); 14083 this.initList(); 14084 if (this.isShown) { 14085 if (this.length) { 14086 if (this.viewed) { 14087 var changedIndex = changedIndexes.indexOf(this.index); 14088 if (changedIndex >= 0) { 14089 this.viewed = false; 14090 this.view(Math.max(Math.min(this.index - changedIndex, this.length - 1), 0)); 14091 } else { 14092 var activeItem = this.items[this.index]; 14093 addClass(activeItem, CLASS_ACTIVE); 14094 activeItem.setAttribute("aria-selected", true); 14095 } 14096 } 14097 } else { 14098 this.image = null; 14099 this.viewed = false; 14100 this.index = 0; 14101 this.imageData = {}; 14102 this.canvas.innerHTML = ""; 14103 this.title.innerHTML = ""; 14104 } 14105 } 14106 } else { 14107 this.build(); 14108 } 14109 return this; 14110 }, 14111 // Destroy the viewer 14112 destroy: function destroy() { 14113 var element = this.element, options = this.options; 14114 if (!element[NAMESPACE]) { 14115 return this; 14116 } 14117 this.destroyed = true; 14118 if (this.ready) { 14119 if (this.played) { 14120 this.stop(); 14121 } 14122 if (options.inline) { 14123 if (this.fulled) { 14124 this.exit(); 14125 } 14126 this.unbind(); 14127 } else if (this.isShown) { 14128 if (this.viewing) { 14129 if (this.imageRendering) { 14130 this.imageRendering.abort(); 14131 } else if (this.imageInitializing) { 14132 this.imageInitializing.abort(); 14133 } 14134 } 14135 if (this.hiding) { 14136 this.transitioning.abort(); 14137 } 14138 this.hidden(); 14139 } else if (this.showing) { 14140 this.transitioning.abort(); 14141 this.hidden(); 14142 } 14143 this.ready = false; 14144 this.viewer.parentNode.removeChild(this.viewer); 14145 } else if (options.inline) { 14146 if (this.delaying) { 14147 this.delaying.abort(); 14148 } else if (this.initializing) { 14149 this.initializing.abort(); 14150 } 14151 } 14152 if (!options.inline) { 14153 removeListener(element, EVENT_CLICK, this.onElementClick); 14154 removeListener(element, EVENT_KEY_DOWN, this.onElementKeyDown); 14155 } 14156 element[NAMESPACE] = void 0; 14157 return this; 14158 } 14159 }; 14160 var others = { 14161 getImageURL: function getImageURL(image) { 14162 var url = this.options.url; 14163 if (isString(url)) { 14164 url = image.getAttribute(url); 14165 } else if (isFunction(url)) { 14166 url = url.call(this, image); 14167 } else { 14168 url = ""; 14169 } 14170 return url; 14171 }, 14172 enforceFocus: function enforceFocus() { 14173 var _this = this; 14174 this.clearEnforceFocus(); 14175 addListener(document, EVENT_FOCUSIN, this.onFocusin = function(event) { 14176 var viewer = _this.viewer; 14177 var target = event.target; 14178 if (target === document || target === viewer || viewer.contains(target)) { 14179 return; 14180 } 14181 while (target) { 14182 if (target.getAttribute("tabindex") !== null || target.getAttribute("aria-modal") === "true") { 14183 return; 14184 } 14185 target = target.parentElement; 14186 } 14187 viewer.focus(); 14188 }); 14189 }, 14190 clearEnforceFocus: function clearEnforceFocus() { 14191 if (this.onFocusin) { 14192 removeListener(document, EVENT_FOCUSIN, this.onFocusin); 14193 this.onFocusin = null; 14194 } 14195 }, 14196 open: function open() { 14197 var body = this.body; 14198 addClass(body, CLASS_OPEN); 14199 if (this.scrollbarWidth > 0) { 14200 body.style.paddingRight = "".concat(this.scrollbarWidth + (parseFloat(this.initialBodyComputedPaddingRight) || 0), "px"); 14201 } 14202 }, 14203 close: function close() { 14204 var body = this.body; 14205 removeClass(body, CLASS_OPEN); 14206 if (this.scrollbarWidth > 0) { 14207 body.style.paddingRight = this.initialBodyPaddingRight; 14208 } 14209 }, 14210 shown: function shown() { 14211 var element = this.element, options = this.options, viewer = this.viewer; 14212 this.fulled = true; 14213 this.isShown = true; 14214 this.render(); 14215 this.bind(); 14216 this.showing = false; 14217 if (options.focus) { 14218 viewer.focus(); 14219 this.enforceFocus(); 14220 } 14221 if (isFunction(options.shown)) { 14222 addListener(element, EVENT_SHOWN, options.shown, { 14223 once: true 14224 }); 14225 } 14226 if (dispatchEvent(element, EVENT_SHOWN) === false) { 14227 return; 14228 } 14229 if (this.ready && this.isShown && !this.hiding) { 14230 this.view(this.index); 14231 } 14232 }, 14233 hidden: function hidden() { 14234 var element = this.element, options = this.options, viewer = this.viewer; 14235 var activeElement = viewer.ownerDocument.activeElement; 14236 if (activeElement && viewer.contains(activeElement) && isFunction(activeElement.blur)) { 14237 activeElement.blur(); 14238 } 14239 if (options.focus) { 14240 this.clearEnforceFocus(); 14241 } 14242 this.close(); 14243 this.unbind(); 14244 addClass(viewer, CLASS_HIDE); 14245 viewer.removeAttribute("role"); 14246 viewer.removeAttribute("aria-labelledby"); 14247 viewer.removeAttribute("aria-modal"); 14248 viewer.setAttribute("aria-hidden", true); 14249 this.resetList(); 14250 this.resetImage(); 14251 this.fulled = false; 14252 this.viewed = false; 14253 this.isShown = false; 14254 this.hiding = false; 14255 if (!this.destroyed) { 14256 if (isFunction(options.hidden)) { 14257 addListener(element, EVENT_HIDDEN, options.hidden, { 14258 once: true 14259 }); 14260 } 14261 dispatchEvent(element, EVENT_HIDDEN, null, { 14262 cancelable: false 14263 }); 14264 } 14265 }, 14266 requestFullscreen: function requestFullscreen(options) { 14267 var document2 = this.element.ownerDocument; 14268 if (this.fulled && !(document2.fullscreenElement || document2.webkitFullscreenElement || document2.mozFullScreenElement || document2.msFullscreenElement)) { 14269 var documentElement = document2.documentElement; 14270 if (documentElement.requestFullscreen) { 14271 if (isPlainObject(options)) { 14272 documentElement.requestFullscreen(options); 14273 } else { 14274 documentElement.requestFullscreen(); 14275 } 14276 } else if (documentElement.webkitRequestFullscreen) { 14277 documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); 14278 } else if (documentElement.mozRequestFullScreen) { 14279 documentElement.mozRequestFullScreen(); 14280 } else if (documentElement.msRequestFullscreen) { 14281 documentElement.msRequestFullscreen(); 14282 } 14283 } 14284 }, 14285 exitFullscreen: function exitFullscreen() { 14286 var document2 = this.element.ownerDocument; 14287 if (this.fulled && (document2.fullscreenElement || document2.webkitFullscreenElement || document2.mozFullScreenElement || document2.msFullscreenElement)) { 14288 if (document2.exitFullscreen) { 14289 document2.exitFullscreen(); 14290 } else if (document2.webkitExitFullscreen) { 14291 document2.webkitExitFullscreen(); 14292 } else if (document2.mozCancelFullScreen) { 14293 document2.mozCancelFullScreen(); 14294 } else if (document2.msExitFullscreen) { 14295 document2.msExitFullscreen(); 14296 } 14297 } 14298 }, 14299 change: function change(event) { 14300 var options = this.options, pointers = this.pointers; 14301 var pointer = pointers[Object.keys(pointers)[0]]; 14302 if (!pointer) { 14303 return; 14304 } 14305 var offsetX = pointer.endX - pointer.startX; 14306 var offsetY = pointer.endY - pointer.startY; 14307 switch (this.action) { 14308 // Move the current image 14309 case ACTION_MOVE: 14310 if (offsetX !== 0 || offsetY !== 0) { 14311 this.pointerMoved = true; 14312 this.move(offsetX, offsetY, event); 14313 } 14314 break; 14315 // Zoom the current image 14316 case ACTION_ZOOM: 14317 this.zoom(getMaxZoomRatio(pointers), false, null, event); 14318 break; 14319 case ACTION_SWITCH: { 14320 this.action = "switched"; 14321 var absoluteOffsetX = Math.abs(offsetX); 14322 if (absoluteOffsetX > 1 && absoluteOffsetX > Math.abs(offsetY)) { 14323 this.pointers = {}; 14324 if (offsetX > 1) { 14325 this.prev(options.loop); 14326 } else if (offsetX < -1) { 14327 this.next(options.loop); 14328 } 14329 } 14330 break; 14331 } 14332 } 14333 forEach(pointers, function(p) { 14334 p.startX = p.endX; 14335 p.startY = p.endY; 14336 }); 14337 }, 14338 isSwitchable: function isSwitchable() { 14339 var imageData = this.imageData, viewerData = this.viewerData; 14340 return this.length > 1 && imageData.x >= 0 && imageData.y >= 0 && imageData.width <= viewerData.width && imageData.height <= viewerData.height; 14341 } 14342 }; 14343 var AnotherViewer = WINDOW.Viewer; 14344 var getUniqueID = /* @__PURE__ */ (function(id) { 14345 return function() { 14346 id += 1; 14347 return id; 14348 }; 14349 })(-1); 14350 var Viewer2 = /* @__PURE__ */ (function() { 14351 function Viewer3(element) { 14352 var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; 14353 _classCallCheck(this, Viewer3); 14354 if (!element || element.nodeType !== 1) { 14355 throw new Error("The first argument is required and must be an element."); 14356 } 14357 this.element = element; 14358 this.options = assign({}, DEFAULTS, isPlainObject(options) && options); 14359 this.action = false; 14360 this.fading = false; 14361 this.fulled = false; 14362 this.hiding = false; 14363 this.imageClicked = false; 14364 this.imageData = {}; 14365 this.index = this.options.initialViewIndex; 14366 this.isImg = false; 14367 this.isShown = false; 14368 this.length = 0; 14369 this.moving = false; 14370 this.played = false; 14371 this.playing = false; 14372 this.pointers = {}; 14373 this.ready = false; 14374 this.rotating = false; 14375 this.scaling = false; 14376 this.showing = false; 14377 this.timeout = false; 14378 this.tooltipping = false; 14379 this.viewed = false; 14380 this.viewing = false; 14381 this.wheeling = false; 14382 this.zooming = false; 14383 this.pointerMoved = false; 14384 this.id = getUniqueID(); 14385 this.init(); 14386 } 14387 return _createClass(Viewer3, [{ 14388 key: "init", 14389 value: function init() { 14390 var _this = this; 14391 var element = this.element, options = this.options; 14392 if (element[NAMESPACE]) { 14393 return; 14394 } 14395 element[NAMESPACE] = this; 14396 if (options.focus && !options.keyboard) { 14397 options.focus = false; 14398 } 14399 var isImg = element.localName === "img"; 14400 var images = []; 14401 forEach(isImg ? [element] : element.querySelectorAll("img"), function(image) { 14402 if (isFunction(options.filter)) { 14403 if (options.filter.call(_this, image)) { 14404 images.push(image); 14405 } 14406 } else if (_this.getImageURL(image)) { 14407 images.push(image); 14408 } 14409 }); 14410 this.isImg = isImg; 14411 this.length = images.length; 14412 this.images = images; 14413 this.initBody(); 14414 if (isUndefined(document.createElement(NAMESPACE).style.transition)) { 14415 options.transition = false; 14416 } 14417 if (options.inline) { 14418 var count = 0; 14419 var progress = function progress2() { 14420 count += 1; 14421 if (count === _this.length) { 14422 var timeout; 14423 _this.initializing = false; 14424 _this.delaying = { 14425 abort: function abort() { 14426 clearTimeout(timeout); 14427 } 14428 }; 14429 timeout = setTimeout(function() { 14430 _this.delaying = false; 14431 _this.build(); 14432 }, 0); 14433 } 14434 }; 14435 this.initializing = { 14436 abort: function abort() { 14437 forEach(images, function(image) { 14438 if (!image.complete) { 14439 removeListener(image, EVENT_LOAD, progress); 14440 removeListener(image, EVENT_ERROR, progress); 14441 } 14442 }); 14443 } 14444 }; 14445 forEach(images, function(image) { 14446 if (image.complete) { 14447 progress(); 14448 } else { 14449 var onLoad; 14450 var onError; 14451 addListener(image, EVENT_LOAD, onLoad = function onLoad2() { 14452 removeListener(image, EVENT_ERROR, onError); 14453 progress(); 14454 }, { 14455 once: true 14456 }); 14457 addListener(image, EVENT_ERROR, onError = function onError2() { 14458 removeListener(image, EVENT_LOAD, onLoad); 14459 progress(); 14460 }, { 14461 once: true 14462 }); 14463 } 14464 }); 14465 } else { 14466 addListener(element, EVENT_CLICK, this.onElementClick = function(_ref) { 14467 var target = _ref.target; 14468 if (target.localName === "img" && (!isFunction(options.filter) || options.filter.call(_this, target))) { 14469 _this.view(_this.images.indexOf(target)); 14470 } 14471 }); 14472 addListener(element, EVENT_KEY_DOWN, this.onElementKeyDown = function(event) { 14473 var target = event.target, key = event.key; 14474 if (target.localName === "img" && (key === "Enter" || key === " ")) { 14475 event.preventDefault(); 14476 if (!isFunction(options.filter) || options.filter.call(_this, target)) { 14477 _this.view(_this.images.indexOf(target)); 14478 } 14479 } 14480 }); 14481 } 14482 } 14483 }, { 14484 key: "build", 14485 value: function build() { 14486 if (this.ready) { 14487 return; 14488 } 14489 var element = this.element, options = this.options; 14490 var parent = element.parentNode; 14491 var template = document.createElement("div"); 14492 template.innerHTML = TEMPLATE; 14493 var viewer = template.querySelector(".".concat(NAMESPACE, "-container")); 14494 var title = viewer.querySelector(".".concat(NAMESPACE, "-title")); 14495 var toolbar = viewer.querySelector(".".concat(NAMESPACE, "-toolbar")); 14496 var navbar = viewer.querySelector(".".concat(NAMESPACE, "-navbar")); 14497 var button = viewer.querySelector(".".concat(NAMESPACE, "-button")); 14498 var canvas = viewer.querySelector(".".concat(NAMESPACE, "-canvas")); 14499 this.parent = parent; 14500 this.viewer = viewer; 14501 this.title = title; 14502 this.toolbar = toolbar; 14503 this.navbar = navbar; 14504 this.button = button; 14505 this.canvas = canvas; 14506 this.footer = viewer.querySelector(".".concat(NAMESPACE, "-footer")); 14507 this.tooltipBox = viewer.querySelector(".".concat(NAMESPACE, "-tooltip")); 14508 this.player = viewer.querySelector(".".concat(NAMESPACE, "-player")); 14509 this.list = viewer.querySelector(".".concat(NAMESPACE, "-list")); 14510 viewer.id = "".concat(NAMESPACE).concat(this.id); 14511 title.id = "".concat(NAMESPACE, "Title").concat(this.id); 14512 addClass(title, !options.title ? CLASS_HIDE : getResponsiveClass(Array.isArray(options.title) ? options.title[0] : options.title)); 14513 addClass(navbar, !options.navbar ? CLASS_HIDE : getResponsiveClass(options.navbar)); 14514 toggleClass(button, CLASS_HIDE, !options.button); 14515 if (options.keyboard) { 14516 button.setAttribute("tabindex", 0); 14517 } 14518 if (options.backdrop) { 14519 addClass(viewer, "".concat(NAMESPACE, "-backdrop")); 14520 if (!options.inline && options.backdrop !== "static") { 14521 setData2(canvas, DATA_ACTION, "hide"); 14522 } 14523 } 14524 if (isString(options.className) && options.className) { 14525 options.className.split(REGEXP_SPACES).forEach(function(className) { 14526 addClass(viewer, className); 14527 }); 14528 } 14529 if (options.toolbar) { 14530 var list = document.createElement("ul"); 14531 var custom = isPlainObject(options.toolbar); 14532 var zoomButtons = BUTTONS.slice(0, 3); 14533 var rotateButtons = BUTTONS.slice(7, 9); 14534 var scaleButtons = BUTTONS.slice(9); 14535 if (!custom) { 14536 addClass(toolbar, getResponsiveClass(options.toolbar)); 14537 } 14538 forEach(custom ? options.toolbar : BUTTONS, function(value, index) { 14539 var deep = custom && isPlainObject(value); 14540 var name = custom ? hyphenate(index) : value; 14541 var show = deep && !isUndefined(value.show) ? value.show : value; 14542 if (!show || !options.zoomable && zoomButtons.indexOf(name) !== -1 || !options.rotatable && rotateButtons.indexOf(name) !== -1 || !options.scalable && scaleButtons.indexOf(name) !== -1) { 14543 return; 14544 } 14545 var size = deep && !isUndefined(value.size) ? value.size : value; 14546 var click = deep && !isUndefined(value.click) ? value.click : value; 14547 var item = document.createElement("li"); 14548 if (options.keyboard) { 14549 item.setAttribute("tabindex", 0); 14550 } 14551 item.setAttribute("role", "button"); 14552 addClass(item, "".concat(NAMESPACE, "-").concat(name)); 14553 if (!isFunction(click)) { 14554 setData2(item, DATA_ACTION, name); 14555 } 14556 if (isNumber(show)) { 14557 addClass(item, getResponsiveClass(show)); 14558 } 14559 if (["small", "large"].indexOf(size) !== -1) { 14560 addClass(item, "".concat(NAMESPACE, "-").concat(size)); 14561 } else if (name === "play") { 14562 addClass(item, "".concat(NAMESPACE, "-large")); 14563 } 14564 if (isFunction(click)) { 14565 addListener(item, EVENT_CLICK, click); 14566 } 14567 list.appendChild(item); 14568 }); 14569 toolbar.appendChild(list); 14570 } else { 14571 addClass(toolbar, CLASS_HIDE); 14572 } 14573 if (!options.rotatable) { 14574 var rotates = toolbar.querySelectorAll('li[class*="rotate"]'); 14575 addClass(rotates, CLASS_INVISIBLE); 14576 forEach(rotates, function(rotate) { 14577 toolbar.appendChild(rotate); 14578 }); 14579 } 14580 if (options.inline) { 14581 addClass(button, CLASS_FULLSCREEN); 14582 setStyle(viewer, { 14583 zIndex: options.zIndexInline 14584 }); 14585 if (window.getComputedStyle(parent).position === "static") { 14586 setStyle(parent, { 14587 position: "relative" 14588 }); 14589 } 14590 parent.insertBefore(viewer, element.nextSibling); 14591 } else { 14592 addClass(button, CLASS_CLOSE); 14593 addClass(viewer, CLASS_FIXED); 14594 addClass(viewer, CLASS_FADE); 14595 addClass(viewer, CLASS_HIDE); 14596 setStyle(viewer, { 14597 zIndex: options.zIndex 14598 }); 14599 var container = options.container; 14600 if (isString(container)) { 14601 container = element.ownerDocument.querySelector(container); 14602 } 14603 if (!container) { 14604 container = this.body; 14605 } 14606 container.appendChild(viewer); 14607 } 14608 if (options.inline) { 14609 this.render(); 14610 this.bind(); 14611 this.isShown = true; 14612 } 14613 this.ready = true; 14614 if (isFunction(options.ready)) { 14615 addListener(element, EVENT_READY, options.ready, { 14616 once: true 14617 }); 14618 } 14619 if (dispatchEvent(element, EVENT_READY) === false) { 14620 this.ready = false; 14621 return; 14622 } 14623 if (this.ready && options.inline) { 14624 this.view(this.index); 14625 } 14626 } 14627 /** 14628 * Get the no conflict viewer class. 14629 * @returns {Viewer} The viewer class. 14630 */ 14631 }], [{ 14632 key: "noConflict", 14633 value: function noConflict() { 14634 window.Viewer = AnotherViewer; 14635 return Viewer3; 14636 } 14637 /** 14638 * Change the default options. 14639 * @param {Object} options - The new default options. 14640 */ 14641 }, { 14642 key: "setDefaults", 14643 value: function setDefaults(options) { 14644 assign(DEFAULTS, isPlainObject(options) && options); 14645 } 14646 }]); 14647 })(); 14648 assign(Viewer2.prototype, render, events, handlers, methods, others); 14649 return Viewer2; 14650 })); 14651 } 14652 }); 14653 14654
vendor: 22,850 bytes, lines 14654-15271
14654// node_modules/@rails/ujs/app/assets/javascripts/rails-ujs.esm.js 14655 var linkClickSelector = "a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]"; 14656 var buttonClickSelector = { 14657 selector: "button[data-remote]:not([form]), button[data-confirm]:not([form])", 14658 exclude: "form button" 14659 }; 14660 var inputChangeSelector = "select[data-remote], input[data-remote], textarea[data-remote]"; 14661 var formSubmitSelector = "form:not([data-turbo=true])"; 14662 var formInputClickSelector = "form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])"; 14663 var formDisableSelector = "input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled"; 14664 var formEnableSelector = "input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled"; 14665 var fileInputSelector = "input[name][type=file]:not([disabled])"; 14666 var linkDisableSelector = "a[data-disable-with], a[data-disable]"; 14667 var buttonDisableSelector = "button[data-remote][data-disable-with], button[data-remote][data-disable]"; 14668 var nonce = null; 14669 var loadCSPNonce = () => { 14670 const metaTag = document.querySelector("meta[name=csp-nonce]"); 14671 return nonce = metaTag && metaTag.content; 14672 }; 14673 var cspNonce = () => nonce || loadCSPNonce(); 14674 var m = Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector; 14675 var matches = function(element, selector) { 14676 if (selector.exclude) { 14677 return m.call(element, selector.selector) && !m.call(element, selector.exclude); 14678 } else { 14679 return m.call(element, selector); 14680 } 14681 }; 14682 var EXPANDO = "_ujsData"; 14683 var getData = (element, key) => element[EXPANDO] ? element[EXPANDO][key] : void 0; 14684 var setData = function(element, key, value) { 14685 if (!element[EXPANDO]) { 14686 element[EXPANDO] = {}; 14687 } 14688 return element[EXPANDO][key] = value; 14689 }; 14690 var $2 = (selector) => Array.prototype.slice.call(document.querySelectorAll(selector)); 14691 var isContentEditable = function(element) { 14692 var isEditable = false; 14693 do { 14694 if (element.isContentEditable) { 14695 isEditable = true; 14696 break; 14697 } 14698 element = element.parentElement; 14699 } while (element); 14700 return isEditable; 14701 }; 14702 var csrfToken = () => { 14703 const meta = document.querySelector("meta[name=csrf-token]"); 14704 return meta && meta.content; 14705 }; 14706 var csrfParam = () => { 14707 const meta = document.querySelector("meta[name=csrf-param]"); 14708 return meta && meta.content; 14709 }; 14710 var CSRFProtection = (xhr) => { 14711 const token = csrfToken(); 14712 if (token) { 14713 return xhr.setRequestHeader("X-CSRF-Token", token); 14714 } 14715 }; 14716 var refreshCSRFTokens = () => { 14717 const token = csrfToken(); 14718 const param = csrfParam(); 14719 if (token && param) { 14720 return $2('form input[name="' + param + '"]').forEach(((input) => input.value = token)); 14721 } 14722 }; 14723 var AcceptHeaders = { 14724 "*": "*/*", 14725 text: "text/plain", 14726 html: "text/html", 14727 xml: "application/xml, text/xml", 14728 json: "application/json, text/javascript", 14729 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" 14730 }; 14731 var ajax = (options) => { 14732 options = prepareOptions(options); 14733 var xhr = createXHR(options, (function() { 14734 const response = processResponse(xhr.response != null ? xhr.response : xhr.responseText, xhr.getResponseHeader("Content-Type")); 14735 if (Math.floor(xhr.status / 100) === 2) { 14736 if (typeof options.success === "function") { 14737 options.success(response, xhr.statusText, xhr); 14738 } 14739 } else { 14740 if (typeof options.error === "function") { 14741 options.error(response, xhr.statusText, xhr); 14742 } 14743 } 14744 return typeof options.complete === "function" ? options.complete(xhr, xhr.statusText) : void 0; 14745 })); 14746 if (options.beforeSend && !options.beforeSend(xhr, options)) { 14747 return false; 14748 } 14749 if (xhr.readyState === XMLHttpRequest.OPENED) { 14750 return xhr.send(options.data); 14751 } 14752 }; 14753 var prepareOptions = function(options) { 14754 options.url = options.url || location.href; 14755 options.type = options.type.toUpperCase(); 14756 if (options.type === "GET" && options.data) { 14757 if (options.url.indexOf("?") < 0) { 14758 options.url += "?" + options.data; 14759 } else { 14760 options.url += "&" + options.data; 14761 } 14762 } 14763 if (!(options.dataType in AcceptHeaders)) { 14764 options.dataType = "*"; 14765 } 14766 options.accept = AcceptHeaders[options.dataType]; 14767 if (options.dataType !== "*") { 14768 options.accept += ", */*; q=0.01"; 14769 } 14770 return options; 14771 }; 14772 var createXHR = function(options, done) { 14773 const xhr = new XMLHttpRequest(); 14774 xhr.open(options.type, options.url, true); 14775 xhr.setRequestHeader("Accept", options.accept); 14776 if (typeof options.data === "string") { 14777 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 14778 } 14779 if (!options.crossDomain) { 14780 xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 14781 CSRFProtection(xhr); 14782 } 14783 xhr.withCredentials = !!options.withCredentials; 14784 xhr.onreadystatechange = function() { 14785 if (xhr.readyState === XMLHttpRequest.DONE) { 14786 return done(xhr); 14787 } 14788 }; 14789 return xhr; 14790 }; 14791 var processResponse = function(response, type) { 14792 if (typeof response === "string" && typeof type === "string") { 14793 if (type.match(/\bjson\b/)) { 14794 try { 14795 response = JSON.parse(response); 14796 } catch (error2) { 14797 } 14798 } else if (type.match(/\b(?:java|ecma)script\b/)) { 14799 const script = document.createElement("script"); 14800 script.setAttribute("nonce", cspNonce()); 14801 script.text = response; 14802 document.head.appendChild(script).parentNode.removeChild(script); 14803 } else if (type.match(/\b(xml|html|svg)\b/)) { 14804 const parser = new DOMParser(); 14805 type = type.replace(/;.+/, ""); 14806 try { 14807 response = parser.parseFromString(response, type); 14808 } catch (error1) { 14809 } 14810 } 14811 } 14812 return response; 14813 }; 14814 var href = (element) => element.href; 14815 var isCrossDomain = function(url) { 14816 const originAnchor = document.createElement("a"); 14817 originAnchor.href = location.href; 14818 const urlAnchor = document.createElement("a"); 14819 try { 14820 urlAnchor.href = url; 14821 return !((!urlAnchor.protocol || urlAnchor.protocol === ":") && !urlAnchor.host || originAnchor.protocol + "//" + originAnchor.host === urlAnchor.protocol + "//" + urlAnchor.host); 14822 } catch (e) { 14823 return true; 14824 } 14825 }; 14826 var preventDefault; 14827 var { CustomEvent: CustomEvent2 } = window; 14828 if (typeof CustomEvent2 !== "function") { 14829 CustomEvent2 = function(event, params) { 14830 const evt = document.createEvent("CustomEvent"); 14831 evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); 14832 return evt; 14833 }; 14834 CustomEvent2.prototype = window.Event.prototype; 14835 ({ preventDefault } = CustomEvent2.prototype); 14836 CustomEvent2.prototype.preventDefault = function() { 14837 const result = preventDefault.call(this); 14838 if (this.cancelable && !this.defaultPrevented) { 14839 Object.defineProperty(this, "defaultPrevented", { 14840 get() { 14841 return true; 14842 } 14843 }); 14844 } 14845 return result; 14846 }; 14847 } 14848 var fire = (obj, name, data) => { 14849 const event = new CustomEvent2(name, { 14850 bubbles: true, 14851 cancelable: true, 14852 detail: data 14853 }); 14854 obj.dispatchEvent(event); 14855 return !event.defaultPrevented; 14856 }; 14857 var stopEverything = (e) => { 14858 fire(e.target, "ujs:everythingStopped"); 14859 e.preventDefault(); 14860 e.stopPropagation(); 14861 e.stopImmediatePropagation(); 14862 }; 14863 var delegate = (element, selector, eventType, handler) => element.addEventListener(eventType, (function(e) { 14864 let { target } = e; 14865 while (!!(target instanceof Element) && !matches(target, selector)) { 14866 target = target.parentNode; 14867 } 14868 if (target instanceof Element && handler.call(target, e) === false) { 14869 e.preventDefault(); 14870 e.stopPropagation(); 14871 } 14872 })); 14873 var toArray = (e) => Array.prototype.slice.call(e); 14874 var serializeElement = (element, additionalParam) => { 14875 let inputs = [element]; 14876 if (matches(element, "form")) { 14877 inputs = toArray(element.elements); 14878 } 14879 const params = []; 14880 inputs.forEach((function(input) { 14881 if (!input.name || input.disabled) { 14882 return; 14883 } 14884 if (matches(input, "fieldset[disabled] *")) { 14885 return; 14886 } 14887 if (matches(input, "select")) { 14888 toArray(input.options).forEach((function(option) { 14889 if (option.selected) { 14890 params.push({ 14891 name: input.name, 14892 value: option.value 14893 }); 14894 } 14895 })); 14896 } else if (input.checked || ["radio", "checkbox", "submit"].indexOf(input.type) === -1) { 14897 params.push({ 14898 name: input.name, 14899 value: input.value 14900 }); 14901 } 14902 })); 14903 if (additionalParam) { 14904 params.push(additionalParam); 14905 } 14906 return params.map((function(param) { 14907 if (param.name) { 14908 return `${encodeURIComponent(param.name)}=${encodeURIComponent(param.value)}`; 14909 } else { 14910 return param; 14911 } 14912 })).join("&"); 14913 }; 14914 var formElements = (form, selector) => { 14915 if (matches(form, "form")) { 14916 return toArray(form.elements).filter(((el) => matches(el, selector))); 14917 } else { 14918 return toArray(form.querySelectorAll(selector)); 14919 } 14920 }; 14921 var handleConfirmWithRails = (rails) => function(e) { 14922 if (!allowAction(this, rails)) { 14923 stopEverything(e); 14924 } 14925 }; 14926 var confirm2 = (message, element) => window.confirm(message); 14927 var allowAction = function(element, rails) { 14928 let callback; 14929 const message = element.getAttribute("data-confirm"); 14930 if (!message) { 14931 return true; 14932 } 14933 let answer = false; 14934 if (fire(element, "confirm")) { 14935 try { 14936 answer = rails.confirm(message, element); 14937 } catch (error2) { 14938 } 14939 callback = fire(element, "confirm:complete", [answer]); 14940 } 14941 return answer && callback; 14942 }; 14943 var handleDisabledElement = function(e) { 14944 const element = this; 14945 if (element.disabled) { 14946 stopEverything(e); 14947 } 14948 }; 14949 var enableElement = (e) => { 14950 let element; 14951 if (e instanceof Event) { 14952 if (isXhrRedirect(e)) { 14953 return; 14954 } 14955 element = e.target; 14956 } else { 14957 element = e; 14958 } 14959 if (isContentEditable(element)) { 14960 return; 14961 } 14962 if (matches(element, linkDisableSelector)) { 14963 return enableLinkElement(element); 14964 } else if (matches(element, buttonDisableSelector) || matches(element, formEnableSelector)) { 14965 return enableFormElement(element); 14966 } else if (matches(element, formSubmitSelector)) { 14967 return enableFormElements(element); 14968 } 14969 }; 14970 var disableElement = (e) => { 14971 const element = e instanceof Event ? e.target : e; 14972 if (isContentEditable(element)) { 14973 return; 14974 } 14975 if (matches(element, linkDisableSelector)) { 14976 return disableLinkElement(element); 14977 } else if (matches(element, buttonDisableSelector) || matches(element, formDisableSelector)) { 14978 return disableFormElement(element); 14979 } else if (matches(element, formSubmitSelector)) { 14980 return disableFormElements(element); 14981 } 14982 }; 14983 var disableLinkElement = function(element) { 14984 if (getData(element, "ujs:disabled")) { 14985 return; 14986 } 14987 const replacement = element.getAttribute("data-disable-with"); 14988 if (replacement != null) { 14989 setData(element, "ujs:enable-with", element.innerHTML); 14990 element.innerHTML = replacement; 14991 } 14992 element.addEventListener("click", stopEverything); 14993 return setData(element, "ujs:disabled", true); 14994 }; 14995 var enableLinkElement = function(element) { 14996 const originalText = getData(element, "ujs:enable-with"); 14997 if (originalText != null) { 14998 element.innerHTML = originalText; 14999 setData(element, "ujs:enable-with", null); 15000 } 15001 element.removeEventListener("click", stopEverything); 15002 return setData(element, "ujs:disabled", null); 15003 }; 15004 var disableFormElements = (form) => formElements(form, formDisableSelector).forEach(disableFormElement); 15005 var disableFormElement = function(element) { 15006 if (getData(element, "ujs:disabled")) { 15007 return; 15008 } 15009 const replacement = element.getAttribute("data-disable-with"); 15010 if (replacement != null) { 15011 if (matches(element, "button")) { 15012 setData(element, "ujs:enable-with", element.innerHTML); 15013 element.innerHTML = replacement; 15014 } else { 15015 setData(element, "ujs:enable-with", element.value); 15016 element.value = replacement; 15017 } 15018 } 15019 element.disabled = true; 15020 return setData(element, "ujs:disabled", true); 15021 }; 15022 var enableFormElements = (form) => formElements(form, formEnableSelector).forEach(((element) => enableFormElement(element))); 15023 var enableFormElement = function(element) { 15024 const originalText = getData(element, "ujs:enable-with"); 15025 if (originalText != null) { 15026 if (matches(element, "button")) { 15027 element.innerHTML = originalText; 15028 } else { 15029 element.value = originalText; 15030 } 15031 setData(element, "ujs:enable-with", null); 15032 } 15033 element.disabled = false; 15034 return setData(element, "ujs:disabled", null); 15035 }; 15036 var isXhrRedirect = function(event) { 15037 const xhr = event.detail ? event.detail[0] : void 0; 15038 return xhr && xhr.getResponseHeader("X-Xhr-Redirect"); 15039 }; 15040 var handleMethodWithRails = (rails) => function(e) { 15041 const link = this; 15042 const method = link.getAttribute("data-method"); 15043 if (!method) { 15044 return; 15045 } 15046 if (isContentEditable(this)) { 15047 return; 15048 } 15049 const href2 = rails.href(link); 15050 const csrfToken$1 = csrfToken(); 15051 const csrfParam$1 = csrfParam(); 15052 const form = document.createElement("form"); 15053 let formContent = `<input name='_method' value='${method}' type='hidden' />`; 15054 if (csrfParam$1 && csrfToken$1 && !isCrossDomain(href2)) { 15055 formContent += `<input name='${csrfParam$1}' value='${csrfToken$1}' type='hidden' />`; 15056 } 15057 formContent += '<input type="submit" />'; 15058 form.method = "post"; 15059 form.action = href2; 15060 form.target = link.target; 15061 form.innerHTML = formContent; 15062 form.style.display = "none"; 15063 document.body.appendChild(form); 15064 form.querySelector('[type="submit"]').click(); 15065 stopEverything(e); 15066 }; 15067 var isRemote = function(element) { 15068 const value = element.getAttribute("data-remote"); 15069 return value != null && value !== "false"; 15070 }; 15071 var handleRemoteWithRails = (rails) => function(e) { 15072 let data, method, url; 15073 const element = this; 15074 if (!isRemote(element)) { 15075 return true; 15076 } 15077 if (!fire(element, "ajax:before")) { 15078 fire(element, "ajax:stopped"); 15079 return false; 15080 } 15081 if (isContentEditable(element)) { 15082 fire(element, "ajax:stopped"); 15083 return false; 15084 } 15085 const withCredentials = element.getAttribute("data-with-credentials"); 15086 const dataType = element.getAttribute("data-type") || "script"; 15087 if (matches(element, formSubmitSelector)) { 15088 const button = getData(element, "ujs:submit-button"); 15089 method = getData(element, "ujs:submit-button-formmethod") || element.getAttribute("method") || "get"; 15090 url = getData(element, "ujs:submit-button-formaction") || element.getAttribute("action") || location.href; 15091 if (method.toUpperCase() === "GET") { 15092 url = url.replace(/\?.*$/, ""); 15093 } 15094 if (element.enctype === "multipart/form-data") { 15095 data = new FormData(element); 15096 if (button != null) { 15097 data.append(button.name, button.value); 15098 } 15099 } else { 15100 data = serializeElement(element, button); 15101 } 15102 setData(element, "ujs:submit-button", null); 15103 setData(element, "ujs:submit-button-formmethod", null); 15104 setData(element, "ujs:submit-button-formaction", null); 15105 } else if (matches(element, buttonClickSelector) || matches(element, inputChangeSelector)) { 15106 method = element.getAttribute("data-method"); 15107 url = element.getAttribute("data-url"); 15108 data = serializeElement(element, element.getAttribute("data-params")); 15109 } else { 15110 method = element.getAttribute("data-method"); 15111 url = rails.href(element); 15112 data = element.getAttribute("data-params"); 15113 } 15114 ajax({ 15115 type: method || "GET", 15116 url, 15117 data, 15118 dataType, 15119 beforeSend(xhr, options) { 15120 if (fire(element, "ajax:beforeSend", [xhr, options])) { 15121 return fire(element, "ajax:send", [xhr]); 15122 } else { 15123 fire(element, "ajax:stopped"); 15124 return false; 15125 } 15126 }, 15127 success(...args) { 15128 return fire(element, "ajax:success", args); 15129 }, 15130 error(...args) { 15131 return fire(element, "ajax:error", args); 15132 }, 15133 complete(...args) { 15134 return fire(element, "ajax:complete", args); 15135 }, 15136 crossDomain: isCrossDomain(url), 15137 withCredentials: withCredentials != null && withCredentials !== "false" 15138 }); 15139 stopEverything(e); 15140 }; 15141 var formSubmitButtonClick = function(e) { 15142 const button = this; 15143 const { form } = button; 15144 if (!form) { 15145 return; 15146 } 15147 if (button.name) { 15148 setData(form, "ujs:submit-button", { 15149 name: button.name, 15150 value: button.value 15151 }); 15152 } 15153 setData(form, "ujs:formnovalidate-button", button.formNoValidate); 15154 setData(form, "ujs:submit-button-formaction", button.getAttribute("formaction")); 15155 return setData(form, "ujs:submit-button-formmethod", button.getAttribute("formmethod")); 15156 }; 15157 var preventInsignificantClick = function(e) { 15158 const link = this; 15159 const method = (link.getAttribute("data-method") || "GET").toUpperCase(); 15160 const data = link.getAttribute("data-params"); 15161 const metaClick = e.metaKey || e.ctrlKey; 15162 const insignificantMetaClick = metaClick && method === "GET" && !data; 15163 const nonPrimaryMouseClick = e.button != null && e.button !== 0; 15164 if (nonPrimaryMouseClick || insignificantMetaClick) { 15165 e.stopImmediatePropagation(); 15166 } 15167 }; 15168 var Rails = { 15169 $: $2, 15170 ajax, 15171 buttonClickSelector, 15172 buttonDisableSelector, 15173 confirm: confirm2, 15174 cspNonce, 15175 csrfToken, 15176 csrfParam, 15177 CSRFProtection, 15178 delegate, 15179 disableElement, 15180 enableElement, 15181 fileInputSelector, 15182 fire, 15183 formElements, 15184 formEnableSelector, 15185 formDisableSelector, 15186 formInputClickSelector, 15187 formSubmitButtonClick, 15188 formSubmitSelector, 15189 getData, 15190 handleDisabledElement, 15191 href, 15192 inputChangeSelector, 15193 isCrossDomain, 15194 linkClickSelector, 15195 linkDisableSelector, 15196 loadCSPNonce, 15197 matches, 15198 preventInsignificantClick, 15199 refreshCSRFTokens, 15200 serializeElement, 15201 setData, 15202 stopEverything 15203 }; 15204 var handleConfirm = handleConfirmWithRails(Rails); 15205 Rails.handleConfirm = handleConfirm; 15206 var handleMethod = handleMethodWithRails(Rails); 15207 Rails.handleMethod = handleMethod; 15208 var handleRemote = handleRemoteWithRails(Rails); 15209 Rails.handleRemote = handleRemote; 15210 var start = function() { 15211 if (window._rails_loaded) { 15212 throw new Error("rails-ujs has already been loaded!"); 15213 } 15214 window.addEventListener("pageshow", (function() { 15215 $2(formEnableSelector).forEach((function(el) { 15216 if (getData(el, "ujs:disabled")) { 15217 enableElement(el); 15218 } 15219 })); 15220 $2(linkDisableSelector).forEach((function(el) { 15221 if (getData(el, "ujs:disabled")) { 15222 enableElement(el); 15223 } 15224 })); 15225 })); 15226 delegate(document, linkDisableSelector, "ajax:complete", enableElement); 15227 delegate(document, linkDisableSelector, "ajax:stopped", enableElement); 15228 delegate(document, buttonDisableSelector, "ajax:complete", enableElement); 15229 delegate(document, buttonDisableSelector, "ajax:stopped", enableElement); 15230 delegate(document, linkClickSelector, "click", preventInsignificantClick); 15231 delegate(document, linkClickSelector, "click", handleDisabledElement); 15232 delegate(document, linkClickSelector, "click", handleConfirm); 15233 delegate(document, linkClickSelector, "click", disableElement); 15234 delegate(document, linkClickSelector, "click", handleRemote); 15235 delegate(document, linkClickSelector, "click", handleMethod); 15236 delegate(document, buttonClickSelector, "click", preventInsignificantClick); 15237 delegate(document, buttonClickSelector, "click", handleDisabledElement); 15238 delegate(document, buttonClickSelector, "click", handleConfirm); 15239 delegate(document, buttonClickSelector, "click", disableElement); 15240 delegate(document, buttonClickSelector, "click", handleRemote); 15241 delegate(document, inputChangeSelector, "change", handleDisabledElement); 15242 delegate(document, inputChangeSelector, "change", handleConfirm); 15243 delegate(document, inputChangeSelector, "change", handleRemote); 15244 delegate(document, formSubmitSelector, "submit", handleDisabledElement); 15245 delegate(document, formSubmitSelector, "submit", handleConfirm); 15246 delegate(document, formSubmitSelector, "submit", handleRemote); 15247 delegate(document, formSubmitSelector, "submit", ((e) => setTimeout((() => disableElement(e)), 13))); 15248 delegate(document, formSubmitSelector, "ajax:send", disableElement); 15249 delegate(document, formSubmitSelector, "ajax:complete", enableElement); 15250 delegate(document, formInputClickSelector, "click", preventInsignificantClick); 15251 delegate(document, formInputClickSelector, "click", handleDisabledElement); 15252 delegate(document, formInputClickSelector, "click", handleConfirm); 15253 delegate(document, formInputClickSelector, "click", formSubmitButtonClick); 15254 document.addEventListener("DOMContentLoaded", refreshCSRFTokens); 15255 document.addEventListener("DOMContentLoaded", loadCSPNonce); 15256 return window._rails_loaded = true; 15257 }; 15258 Rails.start = start; 15259 if (typeof jQuery !== "undefined" && jQuery && jQuery.ajax) { 15260 if (jQuery.rails) { 15261 throw new Error("If you load both jquery_ujs and rails-ujs, use rails-ujs only."); 15262 } 15263 jQuery.rails = Rails; 15264 jQuery.ajaxPrefilter((function(options, originalOptions, xhr) { 15265 if (!options.crossDomain) { 15266 return CSRFProtection(xhr); 15267 } 15268 })); 15269 } 15270 15271
vendor: 185,636 bytes, lines 15271-20704
15271// node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js 15272 var turbo_es2017_esm_exports = {}; 15273 __export(turbo_es2017_esm_exports, { 15274 FetchEnctype: () => FetchEnctype, 15275 FetchMethod: () => FetchMethod, 15276 FetchRequest: () => FetchRequest, 15277 FetchResponse: () => FetchResponse, 15278 FrameElement: () => FrameElement, 15279 FrameLoadingStyle: () => FrameLoadingStyle, 15280 FrameRenderer: () => FrameRenderer, 15281 PageRenderer: () => PageRenderer, 15282 PageSnapshot: () => PageSnapshot, 15283 StreamActions: () => StreamActions, 15284 StreamElement: () => StreamElement, 15285 StreamSourceElement: () => StreamSourceElement, 15286 cache: () => cache, 15287 config: () => config, 15288 connectStreamSource: () => connectStreamSource, 15289 disconnectStreamSource: () => disconnectStreamSource, 15290 fetch: () => fetchWithTurboHeaders, 15291 fetchEnctypeFromString: () => fetchEnctypeFromString, 15292 fetchMethodFromString: () => fetchMethodFromString, 15293 isSafe: () => isSafe, 15294 morphBodyElements: () => morphBodyElements, 15295 morphChildren: () => morphChildren, 15296 morphElements: () => morphElements, 15297 morphTurboFrameElements: () => morphTurboFrameElements, 15298 navigator: () => sessionNavigator, 15299 registerAdapter: () => registerAdapter, 15300 renderStreamMessage: () => renderStreamMessage, 15301 session: () => session, 15302 setConfirmMethod: () => setConfirmMethod, 15303 setFormMode: () => setFormMode, 15304 setProgressBarDelay: () => setProgressBarDelay, 15305 start: () => start2, 15306 visit: () => visit 15307 }); 15308 var FrameLoadingStyle = { 15309 eager: "eager", 15310 lazy: "lazy" 15311 }; 15312 var FrameElement = class _FrameElement extends HTMLElement { 15313 static delegateConstructor = void 0; 15314 loaded = Promise.resolve(); 15315 static get observedAttributes() { 15316 return ["disabled", "loading", "src"]; 15317 } 15318 constructor() { 15319 super(); 15320 this.delegate = new _FrameElement.delegateConstructor(this); 15321 } 15322 connectedCallback() { 15323 this.delegate.connect(); 15324 } 15325 disconnectedCallback() { 15326 this.delegate.disconnect(); 15327 } 15328 reload() { 15329 return this.delegate.sourceURLReloaded(); 15330 } 15331 attributeChangedCallback(name) { 15332 if (name == "loading") { 15333 this.delegate.loadingStyleChanged(); 15334 } else if (name == "src") { 15335 this.delegate.sourceURLChanged(); 15336 } else if (name == "disabled") { 15337 this.delegate.disabledChanged(); 15338 } 15339 } 15340 /** 15341 * Gets the URL to lazily load source HTML from 15342 */ 15343 get src() { 15344 return this.getAttribute("src"); 15345 } 15346 /** 15347 * Sets the URL to lazily load source HTML from 15348 */ 15349 set src(value) { 15350 if (value) { 15351 this.setAttribute("src", value); 15352 } else { 15353 this.removeAttribute("src"); 15354 } 15355 } 15356 /** 15357 * Gets the refresh mode for the frame. 15358 */ 15359 get refresh() { 15360 return this.getAttribute("refresh"); 15361 } 15362 /** 15363 * Sets the refresh mode for the frame. 15364 */ 15365 set refresh(value) { 15366 if (value) { 15367 this.setAttribute("refresh", value); 15368 } else { 15369 this.removeAttribute("refresh"); 15370 } 15371 } 15372 get shouldReloadWithMorph() { 15373 return this.src && this.refresh === "morph"; 15374 } 15375 /** 15376 * Determines if the element is loading 15377 */ 15378 get loading() { 15379 return frameLoadingStyleFromString(this.getAttribute("loading") || ""); 15380 } 15381 /** 15382 * Sets the value of if the element is loading 15383 */ 15384 set loading(value) { 15385 if (value) { 15386 this.setAttribute("loading", value); 15387 } else { 15388 this.removeAttribute("loading"); 15389 } 15390 } 15391 /** 15392 * Gets the disabled state of the frame. 15393 * 15394 * If disabled, no requests will be intercepted by the frame. 15395 */ 15396 get disabled() { 15397 return this.hasAttribute("disabled"); 15398 } 15399 /** 15400 * Sets the disabled state of the frame. 15401 * 15402 * If disabled, no requests will be intercepted by the frame. 15403 */ 15404 set disabled(value) { 15405 if (value) { 15406 this.setAttribute("disabled", ""); 15407 } else { 15408 this.removeAttribute("disabled"); 15409 } 15410 } 15411 /** 15412 * Gets the autoscroll state of the frame. 15413 * 15414 * If true, the frame will be scrolled into view automatically on update. 15415 */ 15416 get autoscroll() { 15417 return this.hasAttribute("autoscroll"); 15418 } 15419 /** 15420 * Sets the autoscroll state of the frame. 15421 * 15422 * If true, the frame will be scrolled into view automatically on update. 15423 */ 15424 set autoscroll(value) { 15425 if (value) { 15426 this.setAttribute("autoscroll", ""); 15427 } else { 15428 this.removeAttribute("autoscroll"); 15429 } 15430 } 15431 /** 15432 * Determines if the element has finished loading 15433 */ 15434 get complete() { 15435 return !this.delegate.isLoading; 15436 } 15437 /** 15438 * Gets the active state of the frame. 15439 * 15440 * If inactive, source changes will not be observed. 15441 */ 15442 get isActive() { 15443 return this.ownerDocument === document && !this.isPreview; 15444 } 15445 /** 15446 * Sets the active state of the frame. 15447 * 15448 * If inactive, source changes will not be observed. 15449 */ 15450 get isPreview() { 15451 return this.ownerDocument?.documentElement?.hasAttribute("data-turbo-preview"); 15452 } 15453 }; 15454 function frameLoadingStyleFromString(style) { 15455 switch (style.toLowerCase()) { 15456 case "lazy": 15457 return FrameLoadingStyle.lazy; 15458 default: 15459 return FrameLoadingStyle.eager; 15460 } 15461 } 15462 var drive = { 15463 enabled: true, 15464 progressBarDelay: 500, 15465 unvisitableExtensions: /* @__PURE__ */ new Set( 15466 [ 15467 ".7z", 15468 ".aac", 15469 ".apk", 15470 ".avi", 15471 ".bmp", 15472 ".bz2", 15473 ".css", 15474 ".csv", 15475 ".deb", 15476 ".dmg", 15477 ".doc", 15478 ".docx", 15479 ".exe", 15480 ".gif", 15481 ".gz", 15482 ".heic", 15483 ".heif", 15484 ".ico", 15485 ".iso", 15486 ".jpeg", 15487 ".jpg", 15488 ".js", 15489 ".json", 15490 ".m4a", 15491 ".mkv", 15492 ".mov", 15493 ".mp3", 15494 ".mp4", 15495 ".mpeg", 15496 ".mpg", 15497 ".msi", 15498 ".ogg", 15499 ".ogv", 15500 ".pdf", 15501 ".pkg", 15502 ".png", 15503 ".ppt", 15504 ".pptx", 15505 ".rar", 15506 ".rtf", 15507 ".svg", 15508 ".tar", 15509 ".tif", 15510 ".tiff", 15511 ".txt", 15512 ".wav", 15513 ".webm", 15514 ".webp", 15515 ".wma", 15516 ".wmv", 15517 ".xls", 15518 ".xlsx", 15519 ".xml", 15520 ".zip" 15521 ] 15522 ) 15523 }; 15524 function activateScriptElement(element) { 15525 if (element.getAttribute("data-turbo-eval") == "false") { 15526 return element; 15527 } else { 15528 const createdScriptElement = document.createElement("script"); 15529 const cspNonce2 = getCspNonce(); 15530 if (cspNonce2) { 15531 createdScriptElement.nonce = cspNonce2; 15532 } 15533 createdScriptElement.textContent = element.textContent; 15534 createdScriptElement.async = false; 15535 copyElementAttributes(createdScriptElement, element); 15536 return createdScriptElement; 15537 } 15538 } 15539 function copyElementAttributes(destinationElement, sourceElement) { 15540 for (const { name, value } of sourceElement.attributes) { 15541 destinationElement.setAttribute(name, value); 15542 } 15543 } 15544 function createDocumentFragment(html) { 15545 const template = document.createElement("template"); 15546 template.innerHTML = html; 15547 return template.content; 15548 } 15549 function dispatch(eventName, { target, cancelable, detail } = {}) { 15550 const event = new CustomEvent(eventName, { 15551 cancelable, 15552 bubbles: true, 15553 composed: true, 15554 detail 15555 }); 15556 if (target && target.isConnected) { 15557 target.dispatchEvent(event); 15558 } else { 15559 document.documentElement.dispatchEvent(event); 15560 } 15561 return event; 15562 } 15563 function cancelEvent(event) { 15564 event.preventDefault(); 15565 event.stopImmediatePropagation(); 15566 } 15567 function nextRepaint() { 15568 if (document.visibilityState === "hidden") { 15569 return nextEventLoopTick(); 15570 } else { 15571 return nextAnimationFrame(); 15572 } 15573 } 15574 function nextAnimationFrame() { 15575 return new Promise((resolve) => requestAnimationFrame(() => resolve())); 15576 } 15577 function nextEventLoopTick() { 15578 return new Promise((resolve) => setTimeout(() => resolve(), 0)); 15579 } 15580 function parseHTMLDocument(html = "") { 15581 return new DOMParser().parseFromString(html, "text/html"); 15582 } 15583 function unindent(strings, ...values) { 15584 const lines = interpolate(strings, values).replace(/^\n/, "").split("\n"); 15585 const match = lines[0].match(/^\s+/); 15586 const indent = match ? match[0].length : 0; 15587 return lines.map((line) => line.slice(indent)).join("\n"); 15588 } 15589 function interpolate(strings, values) { 15590 return strings.reduce((result, string, i) => { 15591 const value = values[i] == void 0 ? "" : values[i]; 15592 return result + string + value; 15593 }, ""); 15594 } 15595 function uuid() { 15596 return Array.from({ length: 36 }).map((_, i) => { 15597 if (i == 8 || i == 13 || i == 18 || i == 23) { 15598 return "-"; 15599 } else if (i == 14) { 15600 return "4"; 15601 } else if (i == 19) { 15602 return (Math.floor(Math.random() * 4) + 8).toString(16); 15603 } else { 15604 return Math.floor(Math.random() * 16).toString(16); 15605 } 15606 }).join(""); 15607 } 15608 function getAttribute(attributeName, ...elements) { 15609 for (const value of elements.map((element) => element?.getAttribute(attributeName))) { 15610 if (typeof value == "string") return value; 15611 } 15612 return null; 15613 } 15614 function hasAttribute(attributeName, ...elements) { 15615 return elements.some((element) => element && element.hasAttribute(attributeName)); 15616 } 15617 function markAsBusy(...elements) { 15618 for (const element of elements) { 15619 if (element.localName == "turbo-frame") { 15620 element.setAttribute("busy", ""); 15621 } 15622 element.setAttribute("aria-busy", "true"); 15623 } 15624 } 15625 function clearBusyState(...elements) { 15626 for (const element of elements) { 15627 if (element.localName == "turbo-frame") { 15628 element.removeAttribute("busy"); 15629 } 15630 element.removeAttribute("aria-busy"); 15631 } 15632 } 15633 function waitForLoad(element, timeoutInMilliseconds = 2e3) { 15634 return new Promise((resolve) => { 15635 const onComplete = () => { 15636 element.removeEventListener("error", onComplete); 15637 element.removeEventListener("load", onComplete); 15638 resolve(); 15639 }; 15640 element.addEventListener("load", onComplete, { once: true }); 15641 element.addEventListener("error", onComplete, { once: true }); 15642 setTimeout(resolve, timeoutInMilliseconds); 15643 }); 15644 } 15645 function getHistoryMethodForAction(action) { 15646 switch (action) { 15647 case "replace": 15648 return history.replaceState; 15649 case "advance": 15650 case "restore": 15651 return history.pushState; 15652 } 15653 } 15654 function isAction(action) { 15655 return action == "advance" || action == "replace" || action == "restore"; 15656 } 15657 function getVisitAction(...elements) { 15658 const action = getAttribute("data-turbo-action", ...elements); 15659 return isAction(action) ? action : null; 15660 } 15661 function getMetaElement(name) { 15662 return document.querySelector(`meta[name="${name}"]`); 15663 } 15664 function getMetaContent(name) { 15665 const element = getMetaElement(name); 15666 return element && element.content; 15667 } 15668 function getCspNonce() { 15669 const element = getMetaElement("csp-nonce"); 15670 if (element) { 15671 const { nonce: nonce2, content } = element; 15672 return nonce2 == "" ? content : nonce2; 15673 } 15674 } 15675 function setMetaContent(name, content) { 15676 let element = getMetaElement(name); 15677 if (!element) { 15678 element = document.createElement("meta"); 15679 element.setAttribute("name", name); 15680 document.head.appendChild(element); 15681 } 15682 element.setAttribute("content", content); 15683 return element; 15684 } 15685 function findClosestRecursively(element, selector) { 15686 if (element instanceof Element) { 15687 return element.closest(selector) || findClosestRecursively(element.assignedSlot || element.getRootNode()?.host, selector); 15688 } 15689 } 15690 function elementIsFocusable(element) { 15691 const inertDisabledOrHidden = "[inert], :disabled, [hidden], details:not([open]), dialog:not([open])"; 15692 return !!element && element.closest(inertDisabledOrHidden) == null && typeof element.focus == "function"; 15693 } 15694 function queryAutofocusableElement(elementOrDocumentFragment) { 15695 return Array.from(elementOrDocumentFragment.querySelectorAll("[autofocus]")).find(elementIsFocusable); 15696 } 15697 async function around(callback, reader) { 15698 const before = reader(); 15699 callback(); 15700 await nextAnimationFrame(); 15701 const after = reader(); 15702 return [before, after]; 15703 } 15704 function doesNotTargetIFrame(name) { 15705 if (name === "_blank") { 15706 return false; 15707 } else if (name) { 15708 for (const element of document.getElementsByName(name)) { 15709 if (element instanceof HTMLIFrameElement) return false; 15710 } 15711 return true; 15712 } else { 15713 return true; 15714 } 15715 } 15716 function findLinkFromClickTarget(target) { 15717 const link = findClosestRecursively(target, "a[href], a[xlink\\:href]"); 15718 if (!link) return null; 15719 if (link.href.startsWith("#")) return null; 15720 if (link.hasAttribute("download")) return null; 15721 const linkTarget = link.getAttribute("target"); 15722 if (linkTarget && linkTarget !== "_self") return null; 15723 return link; 15724 } 15725 function debounce(fn, delay) { 15726 let timeoutId = null; 15727 return (...args) => { 15728 const callback = () => fn.apply(this, args); 15729 clearTimeout(timeoutId); 15730 timeoutId = setTimeout(callback, delay); 15731 }; 15732 } 15733 var submitter = { 15734 "aria-disabled": { 15735 beforeSubmit: (submitter2) => { 15736 submitter2.setAttribute("aria-disabled", "true"); 15737 submitter2.addEventListener("click", cancelEvent); 15738 }, 15739 afterSubmit: (submitter2) => { 15740 submitter2.removeAttribute("aria-disabled"); 15741 submitter2.removeEventListener("click", cancelEvent); 15742 } 15743 }, 15744 "disabled": { 15745 beforeSubmit: (submitter2) => submitter2.disabled = true, 15746 afterSubmit: (submitter2) => submitter2.disabled = false 15747 } 15748 }; 15749 var Config = class { 15750 #submitter = null; 15751 constructor(config2) { 15752 Object.assign(this, config2); 15753 } 15754 get submitter() { 15755 return this.#submitter; 15756 } 15757 set submitter(value) { 15758 this.#submitter = submitter[value] || value; 15759 } 15760 }; 15761 var forms = new Config({ 15762 mode: "on", 15763 submitter: "disabled" 15764 }); 15765 var config = { 15766 drive, 15767 forms 15768 }; 15769 function expandURL(locatable) { 15770 return new URL(locatable.toString(), document.baseURI); 15771 } 15772 function getAnchor(url) { 15773 let anchorMatch; 15774 if (url.hash) { 15775 return url.hash.slice(1); 15776 } else if (anchorMatch = url.href.match(/#(.*)$/)) { 15777 return anchorMatch[1]; 15778 } 15779 } 15780 function getAction$1(form, submitter2) { 15781 const action = submitter2?.getAttribute("formaction") || form.getAttribute("action") || form.action; 15782 return expandURL(action); 15783 } 15784 function getExtension(url) { 15785 return (getLastPathComponent(url).match(/\.[^.]*$/) || [])[0] || ""; 15786 } 15787 function isPrefixedBy(baseURL, url) { 15788 const prefix = addTrailingSlash(url.origin + url.pathname); 15789 return addTrailingSlash(baseURL.href) === prefix || baseURL.href.startsWith(prefix); 15790 } 15791 function locationIsVisitable(location2, rootLocation) { 15792 return isPrefixedBy(location2, rootLocation) && !config.drive.unvisitableExtensions.has(getExtension(location2)); 15793 } 15794 function getLocationForLink(link) { 15795 return expandURL(link.getAttribute("href") || ""); 15796 } 15797 function getRequestURL(url) { 15798 const anchor = getAnchor(url); 15799 return anchor != null ? url.href.slice(0, -(anchor.length + 1)) : url.href; 15800 } 15801 function toCacheKey(url) { 15802 return getRequestURL(url); 15803 } 15804 function urlsAreEqual(left, right) { 15805 return expandURL(left).href == expandURL(right).href; 15806 } 15807 function getPathComponents(url) { 15808 return url.pathname.split("/").slice(1); 15809 } 15810 function getLastPathComponent(url) { 15811 return getPathComponents(url).slice(-1)[0]; 15812 } 15813 function addTrailingSlash(value) { 15814 return value.endsWith("/") ? value : value + "/"; 15815 } 15816 var FetchResponse = class { 15817 constructor(response) { 15818 this.response = response; 15819 } 15820 get succeeded() { 15821 return this.response.ok; 15822 } 15823 get failed() { 15824 return !this.succeeded; 15825 } 15826 get clientError() { 15827 return this.statusCode >= 400 && this.statusCode <= 499; 15828 } 15829 get serverError() { 15830 return this.statusCode >= 500 && this.statusCode <= 599; 15831 } 15832 get redirected() { 15833 return this.response.redirected; 15834 } 15835 get location() { 15836 return expandURL(this.response.url); 15837 } 15838 get isHTML() { 15839 return this.contentType && this.contentType.match(/^(?:text\/([^\s;,]+\b)?html|application\/xhtml\+xml)\b/); 15840 } 15841 get statusCode() { 15842 return this.response.status; 15843 } 15844 get contentType() { 15845 return this.header("Content-Type"); 15846 } 15847 get responseText() { 15848 return this.response.clone().text(); 15849 } 15850 get responseHTML() { 15851 if (this.isHTML) { 15852 return this.response.clone().text(); 15853 } else { 15854 return Promise.resolve(void 0); 15855 } 15856 } 15857 header(name) { 15858 return this.response.headers.get(name); 15859 } 15860 }; 15861 var LimitedSet = class extends Set { 15862 constructor(maxSize) { 15863 super(); 15864 this.maxSize = maxSize; 15865 } 15866 add(value) { 15867 if (this.size >= this.maxSize) { 15868 const iterator = this.values(); 15869 const oldestValue = iterator.next().value; 15870 this.delete(oldestValue); 15871 } 15872 super.add(value); 15873 } 15874 }; 15875 var recentRequests = new LimitedSet(20); 15876 function fetchWithTurboHeaders(url, options = {}) { 15877 const modifiedHeaders = new Headers(options.headers || {}); 15878 const requestUID = uuid(); 15879 recentRequests.add(requestUID); 15880 modifiedHeaders.append("X-Turbo-Request-Id", requestUID); 15881 return window.fetch(url, { 15882 ...options, 15883 headers: modifiedHeaders 15884 }); 15885 } 15886 function fetchMethodFromString(method) { 15887 switch (method.toLowerCase()) { 15888 case "get": 15889 return FetchMethod.get; 15890 case "post": 15891 return FetchMethod.post; 15892 case "put": 15893 return FetchMethod.put; 15894 case "patch": 15895 return FetchMethod.patch; 15896 case "delete": 15897 return FetchMethod.delete; 15898 } 15899 } 15900 var FetchMethod = { 15901 get: "get", 15902 post: "post", 15903 put: "put", 15904 patch: "patch", 15905 delete: "delete" 15906 }; 15907 function fetchEnctypeFromString(encoding) { 15908 switch (encoding.toLowerCase()) { 15909 case FetchEnctype.multipart: 15910 return FetchEnctype.multipart; 15911 case FetchEnctype.plain: 15912 return FetchEnctype.plain; 15913 default: 15914 return FetchEnctype.urlEncoded; 15915 } 15916 } 15917 var FetchEnctype = { 15918 urlEncoded: "application/x-www-form-urlencoded", 15919 multipart: "multipart/form-data", 15920 plain: "text/plain" 15921 }; 15922 var FetchRequest = class { 15923 abortController = new AbortController(); 15924 #resolveRequestPromise = (_value) => { 15925 }; 15926 constructor(delegate2, method, location2, requestBody = new URLSearchParams(), target = null, enctype = FetchEnctype.urlEncoded) { 15927 const [url, body] = buildResourceAndBody(expandURL(location2), method, requestBody, enctype); 15928 this.delegate = delegate2; 15929 this.url = url; 15930 this.target = target; 15931 this.fetchOptions = { 15932 credentials: "same-origin", 15933 redirect: "follow", 15934 method: method.toUpperCase(), 15935 headers: { ...this.defaultHeaders }, 15936 body, 15937 signal: this.abortSignal, 15938 referrer: this.delegate.referrer?.href 15939 }; 15940 this.enctype = enctype; 15941 } 15942 get method() { 15943 return this.fetchOptions.method; 15944 } 15945 set method(value) { 15946 const fetchBody = this.isSafe ? this.url.searchParams : this.fetchOptions.body || new FormData(); 15947 const fetchMethod = fetchMethodFromString(value) || FetchMethod.get; 15948 this.url.search = ""; 15949 const [url, body] = buildResourceAndBody(this.url, fetchMethod, fetchBody, this.enctype); 15950 this.url = url; 15951 this.fetchOptions.body = body; 15952 this.fetchOptions.method = fetchMethod.toUpperCase(); 15953 } 15954 get headers() { 15955 return this.fetchOptions.headers; 15956 } 15957 set headers(value) { 15958 this.fetchOptions.headers = value; 15959 } 15960 get body() { 15961 if (this.isSafe) { 15962 return this.url.searchParams; 15963 } else { 15964 return this.fetchOptions.body; 15965 } 15966 } 15967 set body(value) { 15968 this.fetchOptions.body = value; 15969 } 15970 get location() { 15971 return this.url; 15972 } 15973 get params() { 15974 return this.url.searchParams; 15975 } 15976 get entries() { 15977 return this.body ? Array.from(this.body.entries()) : []; 15978 } 15979 cancel() { 15980 this.abortController.abort(); 15981 } 15982 async perform() { 15983 const { fetchOptions } = this; 15984 this.delegate.prepareRequest(this); 15985 const event = await this.#allowRequestToBeIntercepted(fetchOptions); 15986 try { 15987 this.delegate.requestStarted(this); 15988 if (event.detail.fetchRequest) { 15989 this.response = event.detail.fetchRequest.response; 15990 } else { 15991 this.response = fetchWithTurboHeaders(this.url.href, fetchOptions); 15992 } 15993 const response = await this.response; 15994 return await this.receive(response); 15995 } catch (error2) { 15996 if (error2.name !== "AbortError") { 15997 if (this.#willDelegateErrorHandling(error2)) { 15998 this.delegate.requestErrored(this, error2); 15999 } 16000 throw error2; 16001 } 16002 } finally { 16003 this.delegate.requestFinished(this); 16004 } 16005 } 16006 async receive(response) { 16007 const fetchResponse = new FetchResponse(response); 16008 const event = dispatch("turbo:before-fetch-response", { 16009 cancelable: true, 16010 detail: { fetchResponse }, 16011 target: this.target 16012 }); 16013 if (event.defaultPrevented) { 16014 this.delegate.requestPreventedHandlingResponse(this, fetchResponse); 16015 } else if (fetchResponse.succeeded) { 16016 this.delegate.requestSucceededWithResponse(this, fetchResponse); 16017 } else { 16018 this.delegate.requestFailedWithResponse(this, fetchResponse); 16019 } 16020 return fetchResponse; 16021 } 16022 get defaultHeaders() { 16023 return { 16024 Accept: "text/html, application/xhtml+xml" 16025 }; 16026 } 16027 get isSafe() { 16028 return isSafe(this.method); 16029 } 16030 get abortSignal() { 16031 return this.abortController.signal; 16032 } 16033 acceptResponseType(mimeType) { 16034 this.headers["Accept"] = [mimeType, this.headers["Accept"]].join(", "); 16035 } 16036 async #allowRequestToBeIntercepted(fetchOptions) { 16037 const requestInterception = new Promise((resolve) => this.#resolveRequestPromise = resolve); 16038 const event = dispatch("turbo:before-fetch-request", { 16039 cancelable: true, 16040 detail: { 16041 fetchOptions, 16042 url: this.url, 16043 resume: this.#resolveRequestPromise 16044 }, 16045 target: this.target 16046 }); 16047 this.url = event.detail.url; 16048 if (event.defaultPrevented) await requestInterception; 16049 return event; 16050 } 16051 #willDelegateErrorHandling(error2) { 16052 const event = dispatch("turbo:fetch-request-error", { 16053 target: this.target, 16054 cancelable: true, 16055 detail: { request: this, error: error2 } 16056 }); 16057 return !event.defaultPrevented; 16058 } 16059 }; 16060 function isSafe(fetchMethod) { 16061 return fetchMethodFromString(fetchMethod) == FetchMethod.get; 16062 } 16063 function buildResourceAndBody(resource, method, requestBody, enctype) { 16064 const searchParams = Array.from(requestBody).length > 0 ? new URLSearchParams(entriesExcludingFiles(requestBody)) : resource.searchParams; 16065 if (isSafe(method)) { 16066 return [mergeIntoURLSearchParams(resource, searchParams), null]; 16067 } else if (enctype == FetchEnctype.urlEncoded) { 16068 return [resource, searchParams]; 16069 } else { 16070 return [resource, requestBody]; 16071 } 16072 } 16073 function entriesExcludingFiles(requestBody) { 16074 const entries = []; 16075 for (const [name, value] of requestBody) { 16076 if (value instanceof File) continue; 16077 else entries.push([name, value]); 16078 } 16079 return entries; 16080 } 16081 function mergeIntoURLSearchParams(url, requestBody) { 16082 const searchParams = new URLSearchParams(entriesExcludingFiles(requestBody)); 16083 url.search = searchParams.toString(); 16084 return url; 16085 } 16086 var AppearanceObserver = class { 16087 started = false; 16088 constructor(delegate2, element) { 16089 this.delegate = delegate2; 16090 this.element = element; 16091 this.intersectionObserver = new IntersectionObserver(this.intersect); 16092 } 16093 start() { 16094 if (!this.started) { 16095 this.started = true; 16096 this.intersectionObserver.observe(this.element); 16097 } 16098 } 16099 stop() { 16100 if (this.started) { 16101 this.started = false; 16102 this.intersectionObserver.unobserve(this.element); 16103 } 16104 } 16105 intersect = (entries) => { 16106 const lastEntry = entries.slice(-1)[0]; 16107 if (lastEntry?.isIntersecting) { 16108 this.delegate.elementAppearedInViewport(this.element); 16109 } 16110 }; 16111 }; 16112 var StreamMessage = class { 16113 static contentType = "text/vnd.turbo-stream.html"; 16114 static wrap(message) { 16115 if (typeof message == "string") { 16116 return new this(createDocumentFragment(message)); 16117 } else { 16118 return message; 16119 } 16120 } 16121 constructor(fragment) { 16122 this.fragment = importStreamElements(fragment); 16123 } 16124 }; 16125 function importStreamElements(fragment) { 16126 for (const element of fragment.querySelectorAll("turbo-stream")) { 16127 const streamElement = document.importNode(element, true); 16128 for (const inertScriptElement of streamElement.templateElement.content.querySelectorAll("script")) { 16129 inertScriptElement.replaceWith(activateScriptElement(inertScriptElement)); 16130 } 16131 element.replaceWith(streamElement); 16132 } 16133 return fragment; 16134 } 16135 var identity = (key) => key; 16136 var LRUCache = class { 16137 keys = []; 16138 entries = {}; 16139 #toCacheKey; 16140 constructor(size, toCacheKey2 = identity) { 16141 this.size = size; 16142 this.#toCacheKey = toCacheKey2; 16143 } 16144 has(key) { 16145 return this.#toCacheKey(key) in this.entries; 16146 } 16147 get(key) { 16148 if (this.has(key)) { 16149 const entry = this.read(key); 16150 this.touch(key); 16151 return entry; 16152 } 16153 } 16154 put(key, entry) { 16155 this.write(key, entry); 16156 this.touch(key); 16157 return entry; 16158 } 16159 clear() { 16160 for (const key of Object.keys(this.entries)) { 16161 this.evict(key); 16162 } 16163 } 16164 // Private 16165 read(key) { 16166 return this.entries[this.#toCacheKey(key)]; 16167 } 16168 write(key, entry) { 16169 this.entries[this.#toCacheKey(key)] = entry; 16170 } 16171 touch(key) { 16172 key = this.#toCacheKey(key); 16173 const index = this.keys.indexOf(key); 16174 if (index > -1) this.keys.splice(index, 1); 16175 this.keys.unshift(key); 16176 this.trim(); 16177 } 16178 trim() { 16179 for (const key of this.keys.splice(this.size)) { 16180 this.evict(key); 16181 } 16182 } 16183 evict(key) { 16184 delete this.entries[key]; 16185 } 16186 }; 16187 var PREFETCH_DELAY = 100; 16188 var PrefetchCache = class extends LRUCache { 16189 #prefetchTimeout = null; 16190 #maxAges = {}; 16191 constructor(size = 1, prefetchDelay = PREFETCH_DELAY) { 16192 super(size, toCacheKey); 16193 this.prefetchDelay = prefetchDelay; 16194 } 16195 putLater(url, request, ttl) { 16196 this.#prefetchTimeout = setTimeout(() => { 16197 request.perform(); 16198 this.put(url, request, ttl); 16199 this.#prefetchTimeout = null; 16200 }, this.prefetchDelay); 16201 } 16202 put(url, request, ttl = cacheTtl) { 16203 super.put(url, request); 16204 this.#maxAges[toCacheKey(url)] = new Date((/* @__PURE__ */ new Date()).getTime() + ttl); 16205 } 16206 clear() { 16207 super.clear(); 16208 if (this.#prefetchTimeout) clearTimeout(this.#prefetchTimeout); 16209 } 16210 evict(key) { 16211 super.evict(key); 16212 delete this.#maxAges[key]; 16213 } 16214 has(key) { 16215 if (super.has(key)) { 16216 const maxAge = this.#maxAges[toCacheKey(key)]; 16217 return maxAge && maxAge > Date.now(); 16218 } else { 16219 return false; 16220 } 16221 } 16222 }; 16223 var cacheTtl = 10 * 1e3; 16224 var prefetchCache = new PrefetchCache(); 16225 var FormSubmissionState = { 16226 initialized: "initialized", 16227 requesting: "requesting", 16228 waiting: "waiting", 16229 receiving: "receiving", 16230 stopping: "stopping", 16231 stopped: "stopped" 16232 }; 16233 var FormSubmission = class _FormSubmission { 16234 state = FormSubmissionState.initialized; 16235 static confirmMethod(message) { 16236 return Promise.resolve(confirm(message)); 16237 } 16238 constructor(delegate2, formElement, submitter2, mustRedirect = false) { 16239 const method = getMethod(formElement, submitter2); 16240 const action = getAction(getFormAction(formElement, submitter2), method); 16241 const body = buildFormData(formElement, submitter2); 16242 const enctype = getEnctype(formElement, submitter2); 16243 this.delegate = delegate2; 16244 this.formElement = formElement; 16245 this.submitter = submitter2; 16246 this.fetchRequest = new FetchRequest(this, method, action, body, formElement, enctype); 16247 this.mustRedirect = mustRedirect; 16248 } 16249 get method() { 16250 return this.fetchRequest.method; 16251 } 16252 set method(value) { 16253 this.fetchRequest.method = value; 16254 } 16255 get action() { 16256 return this.fetchRequest.url.toString(); 16257 } 16258 set action(value) { 16259 this.fetchRequest.url = expandURL(value); 16260 } 16261 get body() { 16262 return this.fetchRequest.body; 16263 } 16264 get enctype() { 16265 return this.fetchRequest.enctype; 16266 } 16267 get isSafe() { 16268 return this.fetchRequest.isSafe; 16269 } 16270 get location() { 16271 return this.fetchRequest.url; 16272 } 16273 // The submission process 16274 async start() { 16275 const { initialized, requesting } = FormSubmissionState; 16276 const confirmationMessage = getAttribute("data-turbo-confirm", this.submitter, this.formElement); 16277 if (typeof confirmationMessage === "string") { 16278 const confirmMethod = typeof config.forms.confirm === "function" ? config.forms.confirm : _FormSubmission.confirmMethod; 16279 const answer = await confirmMethod(confirmationMessage, this.formElement, this.submitter); 16280 if (!answer) { 16281 return; 16282 } 16283 } 16284 if (this.state == initialized) { 16285 this.state = requesting; 16286 return this.fetchRequest.perform(); 16287 } 16288 } 16289 stop() { 16290 const { stopping, stopped } = FormSubmissionState; 16291 if (this.state != stopping && this.state != stopped) { 16292 this.state = stopping; 16293 this.fetchRequest.cancel(); 16294 return true; 16295 } 16296 } 16297 // Fetch request delegate 16298 prepareRequest(request) { 16299 if (!request.isSafe) { 16300 const token = getCookieValue(getMetaContent("csrf-param")) || getMetaContent("csrf-token"); 16301 if (token) { 16302 request.headers["X-CSRF-Token"] = token; 16303 } 16304 } 16305 if (this.requestAcceptsTurboStreamResponse(request)) { 16306 request.acceptResponseType(StreamMessage.contentType); 16307 } 16308 } 16309 requestStarted(_request) { 16310 this.state = FormSubmissionState.waiting; 16311 if (this.submitter) config.forms.submitter.beforeSubmit(this.submitter); 16312 this.setSubmitsWith(); 16313 markAsBusy(this.formElement); 16314 dispatch("turbo:submit-start", { 16315 target: this.formElement, 16316 detail: { formSubmission: this } 16317 }); 16318 this.delegate.formSubmissionStarted(this); 16319 } 16320 requestPreventedHandlingResponse(request, response) { 16321 prefetchCache.clear(); 16322 this.result = { success: response.succeeded, fetchResponse: response }; 16323 } 16324 requestSucceededWithResponse(request, response) { 16325 if (response.clientError || response.serverError) { 16326 this.delegate.formSubmissionFailedWithResponse(this, response); 16327 return; 16328 } 16329 prefetchCache.clear(); 16330 if (this.requestMustRedirect(request) && responseSucceededWithoutRedirect(response)) { 16331 const error2 = new Error("Form responses must redirect to another location"); 16332 this.delegate.formSubmissionErrored(this, error2); 16333 } else { 16334 this.state = FormSubmissionState.receiving; 16335 this.result = { success: true, fetchResponse: response }; 16336 this.delegate.formSubmissionSucceededWithResponse(this, response); 16337 } 16338 } 16339 requestFailedWithResponse(request, response) { 16340 this.result = { success: false, fetchResponse: response }; 16341 this.delegate.formSubmissionFailedWithResponse(this, response); 16342 } 16343 requestErrored(request, error2) { 16344 this.result = { success: false, error: error2 }; 16345 this.delegate.formSubmissionErrored(this, error2); 16346 } 16347 requestFinished(_request) { 16348 this.state = FormSubmissionState.stopped; 16349 if (this.submitter) config.forms.submitter.afterSubmit(this.submitter); 16350 this.resetSubmitterText(); 16351 clearBusyState(this.formElement); 16352 dispatch("turbo:submit-end", { 16353 target: this.formElement, 16354 detail: { formSubmission: this, ...this.result } 16355 }); 16356 this.delegate.formSubmissionFinished(this); 16357 } 16358 // Private 16359 setSubmitsWith() { 16360 if (!this.submitter || !this.submitsWith) return; 16361 if (this.submitter.matches("button")) { 16362 this.originalSubmitText = this.submitter.innerHTML; 16363 this.submitter.innerHTML = this.submitsWith; 16364 } else if (this.submitter.matches("input")) { 16365 const input = this.submitter; 16366 this.originalSubmitText = input.value; 16367 input.value = this.submitsWith; 16368 } 16369 } 16370 resetSubmitterText() { 16371 if (!this.submitter || !this.originalSubmitText) return; 16372 if (this.submitter.matches("button")) { 16373 this.submitter.innerHTML = this.originalSubmitText; 16374 } else if (this.submitter.matches("input")) { 16375 const input = this.submitter; 16376 input.value = this.originalSubmitText; 16377 } 16378 } 16379 requestMustRedirect(request) { 16380 return !request.isSafe && this.mustRedirect; 16381 } 16382 requestAcceptsTurboStreamResponse(request) { 16383 return !request.isSafe || hasAttribute("data-turbo-stream", this.submitter, this.formElement); 16384 } 16385 get submitsWith() { 16386 return this.submitter?.getAttribute("data-turbo-submits-with"); 16387 } 16388 }; 16389 function buildFormData(formElement, submitter2) { 16390 const formData = new FormData(formElement); 16391 const name = submitter2?.getAttribute("name"); 16392 const value = submitter2?.getAttribute("value"); 16393 if (name) { 16394 formData.append(name, value || ""); 16395 } 16396 return formData; 16397 } 16398 function getCookieValue(cookieName) { 16399 if (cookieName != null) { 16400 const cookies = document.cookie ? document.cookie.split("; ") : []; 16401 const cookie = cookies.find((cookie2) => cookie2.startsWith(cookieName)); 16402 if (cookie) { 16403 const value = cookie.split("=").slice(1).join("="); 16404 return value ? decodeURIComponent(value) : void 0; 16405 } 16406 } 16407 } 16408 function responseSucceededWithoutRedirect(response) { 16409 return response.statusCode == 200 && !response.redirected; 16410 } 16411 function getFormAction(formElement, submitter2) { 16412 const formElementAction = typeof formElement.action === "string" ? formElement.action : null; 16413 if (submitter2?.hasAttribute("formaction")) { 16414 return submitter2.getAttribute("formaction") || ""; 16415 } else { 16416 return formElement.getAttribute("action") || formElementAction || ""; 16417 } 16418 } 16419 function getAction(formAction, fetchMethod) { 16420 const action = expandURL(formAction); 16421 if (isSafe(fetchMethod)) { 16422 action.search = ""; 16423 } 16424 return action; 16425 } 16426 function getMethod(formElement, submitter2) { 16427 const method = submitter2?.getAttribute("formmethod") || formElement.getAttribute("method") || ""; 16428 return fetchMethodFromString(method.toLowerCase()) || FetchMethod.get; 16429 } 16430 function getEnctype(formElement, submitter2) { 16431 return fetchEnctypeFromString(submitter2?.getAttribute("formenctype") || formElement.enctype); 16432 } 16433 var Snapshot = class { 16434 constructor(element) { 16435 this.element = element; 16436 } 16437 get activeElement() { 16438 return this.element.ownerDocument.activeElement; 16439 } 16440 get children() { 16441 return [...this.element.children]; 16442 } 16443 hasAnchor(anchor) { 16444 return this.getElementForAnchor(anchor) != null; 16445 } 16446 getElementForAnchor(anchor) { 16447 return anchor ? this.element.querySelector(`[id='${anchor}'], a[name='${anchor}']`) : null; 16448 } 16449 get isConnected() { 16450 return this.element.isConnected; 16451 } 16452 get firstAutofocusableElement() { 16453 return queryAutofocusableElement(this.element); 16454 } 16455 get permanentElements() { 16456 return queryPermanentElementsAll(this.element); 16457 } 16458 getPermanentElementById(id) { 16459 return getPermanentElementById(this.element, id); 16460 } 16461 getPermanentElementMapForSnapshot(snapshot) { 16462 const permanentElementMap = {}; 16463 for (const currentPermanentElement of this.permanentElements) { 16464 const { id } = currentPermanentElement; 16465 const newPermanentElement = snapshot.getPermanentElementById(id); 16466 if (newPermanentElement) { 16467 permanentElementMap[id] = [currentPermanentElement, newPermanentElement]; 16468 } 16469 } 16470 return permanentElementMap; 16471 } 16472 }; 16473 function getPermanentElementById(node, id) { 16474 return node.querySelector(`#${id}[data-turbo-permanent]`); 16475 } 16476 function queryPermanentElementsAll(node) { 16477 return node.querySelectorAll("[id][data-turbo-permanent]"); 16478 } 16479 var FormSubmitObserver = class { 16480 started = false; 16481 constructor(delegate2, eventTarget) { 16482 this.delegate = delegate2; 16483 this.eventTarget = eventTarget; 16484 } 16485 start() { 16486 if (!this.started) { 16487 this.eventTarget.addEventListener("submit", this.submitCaptured, true); 16488 this.started = true; 16489 } 16490 } 16491 stop() { 16492 if (this.started) { 16493 this.eventTarget.removeEventListener("submit", this.submitCaptured, true); 16494 this.started = false; 16495 } 16496 } 16497 submitCaptured = () => { 16498 this.eventTarget.removeEventListener("submit", this.submitBubbled, false); 16499 this.eventTarget.addEventListener("submit", this.submitBubbled, false); 16500 }; 16501 submitBubbled = (event) => { 16502 if (!event.defaultPrevented) { 16503 const form = event.target instanceof HTMLFormElement ? event.target : void 0; 16504 const submitter2 = event.submitter || void 0; 16505 if (form && submissionDoesNotDismissDialog(form, submitter2) && submissionDoesNotTargetIFrame(form, submitter2) && this.delegate.willSubmitForm(form, submitter2)) { 16506 event.preventDefault(); 16507 event.stopImmediatePropagation(); 16508 this.delegate.formSubmitted(form, submitter2); 16509 } 16510 } 16511 }; 16512 }; 16513 function submissionDoesNotDismissDialog(form, submitter2) { 16514 const method = submitter2?.getAttribute("formmethod") || form.getAttribute("method"); 16515 return method != "dialog"; 16516 } 16517 function submissionDoesNotTargetIFrame(form, submitter2) { 16518 const target = submitter2?.getAttribute("formtarget") || form.getAttribute("target"); 16519 return doesNotTargetIFrame(target); 16520 } 16521 var View = class { 16522 #resolveRenderPromise = (_value) => { 16523 }; 16524 #resolveInterceptionPromise = (_value) => { 16525 }; 16526 constructor(delegate2, element) { 16527 this.delegate = delegate2; 16528 this.element = element; 16529 } 16530 // Scrolling 16531 scrollToAnchor(anchor) { 16532 const element = this.snapshot.getElementForAnchor(anchor); 16533 if (element) { 16534 this.focusElement(element); 16535 this.scrollToElement(element); 16536 } else { 16537 this.scrollToPosition({ x: 0, y: 0 }); 16538 } 16539 } 16540 scrollToAnchorFromLocation(location2) { 16541 this.scrollToAnchor(getAnchor(location2)); 16542 } 16543 scrollToElement(element) { 16544 element.scrollIntoView(); 16545 } 16546 focusElement(element) { 16547 if (element instanceof HTMLElement) { 16548 if (element.hasAttribute("tabindex")) { 16549 element.focus(); 16550 } else { 16551 element.setAttribute("tabindex", "-1"); 16552 element.focus(); 16553 element.removeAttribute("tabindex"); 16554 } 16555 } 16556 } 16557 scrollToPosition({ x, y }) { 16558 this.scrollRoot.scrollTo(x, y); 16559 } 16560 scrollToTop() { 16561 this.scrollToPosition({ x: 0, y: 0 }); 16562 } 16563 get scrollRoot() { 16564 return window; 16565 } 16566 // Rendering 16567 async render(renderer) { 16568 const { isPreview, shouldRender, willRender, newSnapshot: snapshot } = renderer; 16569 const shouldInvalidate = willRender; 16570 if (shouldRender) { 16571 try { 16572 this.renderPromise = new Promise((resolve) => this.#resolveRenderPromise = resolve); 16573 this.renderer = renderer; 16574 await this.prepareToRenderSnapshot(renderer); 16575 const renderInterception = new Promise((resolve) => this.#resolveInterceptionPromise = resolve); 16576 const options = { resume: this.#resolveInterceptionPromise, render: this.renderer.renderElement, renderMethod: this.renderer.renderMethod }; 16577 const immediateRender = this.delegate.allowsImmediateRender(snapshot, options); 16578 if (!immediateRender) await renderInterception; 16579 await this.renderSnapshot(renderer); 16580 this.delegate.viewRenderedSnapshot(snapshot, isPreview, this.renderer.renderMethod); 16581 this.delegate.preloadOnLoadLinksForView(this.element); 16582 this.finishRenderingSnapshot(renderer); 16583 } finally { 16584 delete this.renderer; 16585 this.#resolveRenderPromise(void 0); 16586 delete this.renderPromise; 16587 } 16588 } else if (shouldInvalidate) { 16589 this.invalidate(renderer.reloadReason); 16590 } 16591 } 16592 invalidate(reason) { 16593 this.delegate.viewInvalidated(reason); 16594 } 16595 async prepareToRenderSnapshot(renderer) { 16596 this.markAsPreview(renderer.isPreview); 16597 await renderer.prepareToRender(); 16598 } 16599 markAsPreview(isPreview) { 16600 if (isPreview) { 16601 this.element.setAttribute("data-turbo-preview", ""); 16602 } else { 16603 this.element.removeAttribute("data-turbo-preview"); 16604 } 16605 } 16606 markVisitDirection(direction) { 16607 this.element.setAttribute("data-turbo-visit-direction", direction); 16608 } 16609 unmarkVisitDirection() { 16610 this.element.removeAttribute("data-turbo-visit-direction"); 16611 } 16612 async renderSnapshot(renderer) { 16613 await renderer.render(); 16614 } 16615 finishRenderingSnapshot(renderer) { 16616 renderer.finishRendering(); 16617 } 16618 }; 16619 var FrameView = class extends View { 16620 missing() { 16621 this.element.innerHTML = `<strong class="turbo-frame-error">Content missing</strong>`; 16622 } 16623 get snapshot() { 16624 return new Snapshot(this.element); 16625 } 16626 }; 16627 var LinkInterceptor = class { 16628 constructor(delegate2, element) { 16629 this.delegate = delegate2; 16630 this.element = element; 16631 } 16632 start() { 16633 this.element.addEventListener("click", this.clickBubbled); 16634 document.addEventListener("turbo:click", this.linkClicked); 16635 document.addEventListener("turbo:before-visit", this.willVisit); 16636 } 16637 stop() { 16638 this.element.removeEventListener("click", this.clickBubbled); 16639 document.removeEventListener("turbo:click", this.linkClicked); 16640 document.removeEventListener("turbo:before-visit", this.willVisit); 16641 } 16642 clickBubbled = (event) => { 16643 if (this.clickEventIsSignificant(event)) { 16644 this.clickEvent = event; 16645 } else { 16646 delete this.clickEvent; 16647 } 16648 }; 16649 linkClicked = (event) => { 16650 if (this.clickEvent && this.clickEventIsSignificant(event)) { 16651 if (this.delegate.shouldInterceptLinkClick(event.target, event.detail.url, event.detail.originalEvent)) { 16652 this.clickEvent.preventDefault(); 16653 event.preventDefault(); 16654 this.delegate.linkClickIntercepted(event.target, event.detail.url, event.detail.originalEvent); 16655 } 16656 } 16657 delete this.clickEvent; 16658 }; 16659 willVisit = (_event) => { 16660 delete this.clickEvent; 16661 }; 16662 clickEventIsSignificant(event) { 16663 const target = event.composed ? event.target?.parentElement : event.target; 16664 const element = findLinkFromClickTarget(target) || target; 16665 return element instanceof Element && element.closest("turbo-frame, html") == this.element; 16666 } 16667 }; 16668 var LinkClickObserver = class { 16669 started = false; 16670 constructor(delegate2, eventTarget) { 16671 this.delegate = delegate2; 16672 this.eventTarget = eventTarget; 16673 } 16674 start() { 16675 if (!this.started) { 16676 this.eventTarget.addEventListener("click", this.clickCaptured, true); 16677 this.started = true; 16678 } 16679 } 16680 stop() { 16681 if (this.started) { 16682 this.eventTarget.removeEventListener("click", this.clickCaptured, true); 16683 this.started = false; 16684 } 16685 } 16686 clickCaptured = () => { 16687 this.eventTarget.removeEventListener("click", this.clickBubbled, false); 16688 this.eventTarget.addEventListener("click", this.clickBubbled, false); 16689 }; 16690 clickBubbled = (event) => { 16691 if (event instanceof MouseEvent && this.clickEventIsSignificant(event)) { 16692 const target = event.composedPath && event.composedPath()[0] || event.target; 16693 const link = findLinkFromClickTarget(target); 16694 if (link && doesNotTargetIFrame(link.target)) { 16695 const location2 = getLocationForLink(link); 16696 if (this.delegate.willFollowLinkToLocation(link, location2, event)) { 16697 event.preventDefault(); 16698 this.delegate.followedLinkToLocation(link, location2); 16699 } 16700 } 16701 } 16702 }; 16703 clickEventIsSignificant(event) { 16704 return !(event.target && event.target.isContentEditable || event.defaultPrevented || event.which > 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey); 16705 } 16706 }; 16707 var FormLinkClickObserver = class { 16708 constructor(delegate2, element) { 16709 this.delegate = delegate2; 16710 this.linkInterceptor = new LinkClickObserver(this, element); 16711 } 16712 start() { 16713 this.linkInterceptor.start(); 16714 } 16715 stop() { 16716 this.linkInterceptor.stop(); 16717 } 16718 // Link hover observer delegate 16719 canPrefetchRequestToLocation(link, location2) { 16720 return false; 16721 } 16722 prefetchAndCacheRequestToLocation(link, location2) { 16723 return; 16724 } 16725 // Link click observer delegate 16726 willFollowLinkToLocation(link, location2, originalEvent) { 16727 return this.delegate.willSubmitFormLinkToLocation(link, location2, originalEvent) && (link.hasAttribute("data-turbo-method") || link.hasAttribute("data-turbo-stream")); 16728 } 16729 followedLinkToLocation(link, location2) { 16730 const form = document.createElement("form"); 16731 const type = "hidden"; 16732 for (const [name, value] of location2.searchParams) { 16733 form.append(Object.assign(document.createElement("input"), { type, name, value })); 16734 } 16735 const action = Object.assign(location2, { search: "" }); 16736 form.setAttribute("data-turbo", "true"); 16737 form.setAttribute("action", action.href); 16738 form.setAttribute("hidden", ""); 16739 const method = link.getAttribute("data-turbo-method"); 16740 if (method) form.setAttribute("method", method); 16741 const turboFrame = link.getAttribute("data-turbo-frame"); 16742 if (turboFrame) form.setAttribute("data-turbo-frame", turboFrame); 16743 const turboAction = getVisitAction(link); 16744 if (turboAction) form.setAttribute("data-turbo-action", turboAction); 16745 const turboConfirm = link.getAttribute("data-turbo-confirm"); 16746 if (turboConfirm) form.setAttribute("data-turbo-confirm", turboConfirm); 16747 const turboStream = link.hasAttribute("data-turbo-stream"); 16748 if (turboStream) form.setAttribute("data-turbo-stream", ""); 16749 this.delegate.submittedFormLinkToLocation(link, location2, form); 16750 document.body.appendChild(form); 16751 form.addEventListener("turbo:submit-end", () => form.remove(), { once: true }); 16752 requestAnimationFrame(() => form.requestSubmit()); 16753 } 16754 }; 16755 var Bardo = class { 16756 static async preservingPermanentElements(delegate2, permanentElementMap, callback) { 16757 const bardo = new this(delegate2, permanentElementMap); 16758 bardo.enter(); 16759 await callback(); 16760 bardo.leave(); 16761 } 16762 constructor(delegate2, permanentElementMap) { 16763 this.delegate = delegate2; 16764 this.permanentElementMap = permanentElementMap; 16765 } 16766 enter() { 16767 for (const id in this.permanentElementMap) { 16768 const [currentPermanentElement, newPermanentElement] = this.permanentElementMap[id]; 16769 this.delegate.enteringBardo(currentPermanentElement, newPermanentElement); 16770 this.replaceNewPermanentElementWithPlaceholder(newPermanentElement); 16771 } 16772 } 16773 leave() { 16774 for (const id in this.permanentElementMap) { 16775 const [currentPermanentElement] = this.permanentElementMap[id]; 16776 this.replaceCurrentPermanentElementWithClone(currentPermanentElement); 16777 this.replacePlaceholderWithPermanentElement(currentPermanentElement); 16778 this.delegate.leavingBardo(currentPermanentElement); 16779 } 16780 } 16781 replaceNewPermanentElementWithPlaceholder(permanentElement) { 16782 const placeholder = createPlaceholderForPermanentElement(permanentElement); 16783 permanentElement.replaceWith(placeholder); 16784 } 16785 replaceCurrentPermanentElementWithClone(permanentElement) { 16786 const clone = permanentElement.cloneNode(true); 16787 permanentElement.replaceWith(clone); 16788 } 16789 replacePlaceholderWithPermanentElement(permanentElement) { 16790 const placeholder = this.getPlaceholderById(permanentElement.id); 16791 placeholder?.replaceWith(permanentElement); 16792 } 16793 getPlaceholderById(id) { 16794 return this.placeholders.find((element) => element.content == id); 16795 } 16796 get placeholders() { 16797 return [...document.querySelectorAll("meta[name=turbo-permanent-placeholder][content]")]; 16798 } 16799 }; 16800 function createPlaceholderForPermanentElement(permanentElement) { 16801 const element = document.createElement("meta"); 16802 element.setAttribute("name", "turbo-permanent-placeholder"); 16803 element.setAttribute("content", permanentElement.id); 16804 return element; 16805 } 16806 var Renderer = class { 16807 #activeElement = null; 16808 static renderElement(currentElement, newElement) { 16809 } 16810 constructor(currentSnapshot, newSnapshot, isPreview, willRender = true) { 16811 this.currentSnapshot = currentSnapshot; 16812 this.newSnapshot = newSnapshot; 16813 this.isPreview = isPreview; 16814 this.willRender = willRender; 16815 this.renderElement = this.constructor.renderElement; 16816 this.promise = new Promise((resolve, reject) => this.resolvingFunctions = { resolve, reject }); 16817 } 16818 get shouldRender() { 16819 return true; 16820 } 16821 get shouldAutofocus() { 16822 return true; 16823 } 16824 get reloadReason() { 16825 return; 16826 } 16827 prepareToRender() { 16828 return; 16829 } 16830 render() { 16831 } 16832 finishRendering() { 16833 if (this.resolvingFunctions) { 16834 this.resolvingFunctions.resolve(); 16835 delete this.resolvingFunctions; 16836 } 16837 } 16838 async preservingPermanentElements(callback) { 16839 await Bardo.preservingPermanentElements(this, this.permanentElementMap, callback); 16840 } 16841 focusFirstAutofocusableElement() { 16842 if (this.shouldAutofocus) { 16843 const element = this.connectedSnapshot.firstAutofocusableElement; 16844 if (element) { 16845 element.focus(); 16846 } 16847 } 16848 } 16849 // Bardo delegate 16850 enteringBardo(currentPermanentElement) { 16851 if (this.#activeElement) return; 16852 if (currentPermanentElement.contains(this.currentSnapshot.activeElement)) { 16853 this.#activeElement = this.currentSnapshot.activeElement; 16854 } 16855 } 16856 leavingBardo(currentPermanentElement) { 16857 if (currentPermanentElement.contains(this.#activeElement) && this.#activeElement instanceof HTMLElement) { 16858 this.#activeElement.focus(); 16859 this.#activeElement = null; 16860 } 16861 } 16862 get connectedSnapshot() { 16863 return this.newSnapshot.isConnected ? this.newSnapshot : this.currentSnapshot; 16864 } 16865 get currentElement() { 16866 return this.currentSnapshot.element; 16867 } 16868 get newElement() { 16869 return this.newSnapshot.element; 16870 } 16871 get permanentElementMap() { 16872 return this.currentSnapshot.getPermanentElementMapForSnapshot(this.newSnapshot); 16873 } 16874 get renderMethod() { 16875 return "replace"; 16876 } 16877 }; 16878 var FrameRenderer = class extends Renderer { 16879 static renderElement(currentElement, newElement) { 16880 const destinationRange = document.createRange(); 16881 destinationRange.selectNodeContents(currentElement); 16882 destinationRange.deleteContents(); 16883 const frameElement = newElement; 16884 const sourceRange = frameElement.ownerDocument?.createRange(); 16885 if (sourceRange) { 16886 sourceRange.selectNodeContents(frameElement); 16887 currentElement.appendChild(sourceRange.extractContents()); 16888 } 16889 } 16890 constructor(delegate2, currentSnapshot, newSnapshot, renderElement, isPreview, willRender = true) { 16891 super(currentSnapshot, newSnapshot, renderElement, isPreview, willRender); 16892 this.delegate = delegate2; 16893 } 16894 get shouldRender() { 16895 return true; 16896 } 16897 async render() { 16898 await nextRepaint(); 16899 this.preservingPermanentElements(() => { 16900 this.loadFrameElement(); 16901 }); 16902 this.scrollFrameIntoView(); 16903 await nextRepaint(); 16904 this.focusFirstAutofocusableElement(); 16905 await nextRepaint(); 16906 this.activateScriptElements(); 16907 } 16908 loadFrameElement() { 16909 this.delegate.willRenderFrame(this.currentElement, this.newElement); 16910 this.renderElement(this.currentElement, this.newElement); 16911 } 16912 scrollFrameIntoView() { 16913 if (this.currentElement.autoscroll || this.newElement.autoscroll) { 16914 const element = this.currentElement.firstElementChild; 16915 const block = readScrollLogicalPosition(this.currentElement.getAttribute("data-autoscroll-block"), "end"); 16916 const behavior = readScrollBehavior(this.currentElement.getAttribute("data-autoscroll-behavior"), "auto"); 16917 if (element) { 16918 element.scrollIntoView({ block, behavior }); 16919 return true; 16920 } 16921 } 16922 return false; 16923 } 16924 activateScriptElements() { 16925 for (const inertScriptElement of this.newScriptElements) { 16926 const activatedScriptElement = activateScriptElement(inertScriptElement); 16927 inertScriptElement.replaceWith(activatedScriptElement); 16928 } 16929 } 16930 get newScriptElements() { 16931 return this.currentElement.querySelectorAll("script"); 16932 } 16933 }; 16934 function readScrollLogicalPosition(value, defaultValue) { 16935 if (value == "end" || value == "start" || value == "center" || value == "nearest") { 16936 return value; 16937 } else { 16938 return defaultValue; 16939 } 16940 } 16941 function readScrollBehavior(value, defaultValue) { 16942 if (value == "auto" || value == "smooth") { 16943 return value; 16944 } else { 16945 return defaultValue; 16946 } 16947 } 16948 var Idiomorph = (function() { 16949 const noOp = () => { 16950 }; 16951 const defaults = { 16952 morphStyle: "outerHTML", 16953 callbacks: { 16954 beforeNodeAdded: noOp, 16955 afterNodeAdded: noOp, 16956 beforeNodeMorphed: noOp, 16957 afterNodeMorphed: noOp, 16958 beforeNodeRemoved: noOp, 16959 afterNodeRemoved: noOp, 16960 beforeAttributeUpdated: noOp 16961 }, 16962 head: { 16963 style: "merge", 16964 shouldPreserve: (elt) => elt.getAttribute("im-preserve") === "true", 16965 shouldReAppend: (elt) => elt.getAttribute("im-re-append") === "true", 16966 shouldRemove: noOp, 16967 afterHeadMorphed: noOp 16968 }, 16969 restoreFocus: true 16970 }; 16971 function morph(oldNode, newContent, config2 = {}) { 16972 oldNode = normalizeElement(oldNode); 16973 const newNode = normalizeParent(newContent); 16974 const ctx = createMorphContext(oldNode, newNode, config2); 16975 const morphedNodes = saveAndRestoreFocus(ctx, () => { 16976 return withHeadBlocking( 16977 ctx, 16978 oldNode, 16979 newNode, 16980 /** @param {MorphContext} ctx */ 16981 (ctx2) => { 16982 if (ctx2.morphStyle === "innerHTML") { 16983 morphChildren2(ctx2, oldNode, newNode); 16984 return Array.from(oldNode.childNodes); 16985 } else { 16986 return morphOuterHTML(ctx2, oldNode, newNode); 16987 } 16988 } 16989 ); 16990 }); 16991 ctx.pantry.remove(); 16992 return morphedNodes; 16993 } 16994 function morphOuterHTML(ctx, oldNode, newNode) { 16995 const oldParent = normalizeParent(oldNode); 16996 morphChildren2( 16997 ctx, 16998 oldParent, 16999 newNode, 17000 // these two optional params are the secret sauce 17001 oldNode, 17002 // start point for iteration 17003 oldNode.nextSibling 17004 // end point for iteration 17005 ); 17006 return Array.from(oldParent.childNodes); 17007 } 17008 function saveAndRestoreFocus(ctx, fn) { 17009 if (!ctx.config.restoreFocus) return fn(); 17010 let activeElement = ( 17011 /** @type {HTMLInputElement|HTMLTextAreaElement|null} */ 17012 document.activeElement 17013 ); 17014 if (!(activeElement instanceof HTMLInputElement || activeElement instanceof HTMLTextAreaElement)) { 17015 return fn(); 17016 } 17017 const { id: activeElementId, selectionStart, selectionEnd } = activeElement; 17018 const results = fn(); 17019 if (activeElementId && activeElementId !== document.activeElement?.getAttribute("id")) { 17020 activeElement = ctx.target.querySelector(`[id="${activeElementId}"]`); 17021 activeElement?.focus(); 17022 } 17023 if (activeElement && !activeElement.selectionEnd && selectionEnd) { 17024 activeElement.setSelectionRange(selectionStart, selectionEnd); 17025 } 17026 return results; 17027 } 17028 const morphChildren2 = /* @__PURE__ */ (function() { 17029 function morphChildren3(ctx, oldParent, newParent, insertionPoint = null, endPoint = null) { 17030 if (oldParent instanceof HTMLTemplateElement && newParent instanceof HTMLTemplateElement) { 17031 oldParent = oldParent.content; 17032 newParent = newParent.content; 17033 } 17034 insertionPoint ||= oldParent.firstChild; 17035 for (const newChild of newParent.childNodes) { 17036 if (insertionPoint && insertionPoint != endPoint) { 17037 const bestMatch = findBestMatch( 17038 ctx, 17039 newChild, 17040 insertionPoint, 17041 endPoint 17042 ); 17043 if (bestMatch) { 17044 if (bestMatch !== insertionPoint) { 17045 removeNodesBetween(ctx, insertionPoint, bestMatch); 17046 } 17047 morphNode(bestMatch, newChild, ctx); 17048 insertionPoint = bestMatch.nextSibling; 17049 continue; 17050 } 17051 } 17052 if (newChild instanceof Element) { 17053 const newChildId = ( 17054 /** @type {String} */ 17055 newChild.getAttribute("id") 17056 ); 17057 if (ctx.persistentIds.has(newChildId)) { 17058 const movedChild = moveBeforeById( 17059 oldParent, 17060 newChildId, 17061 insertionPoint, 17062 ctx 17063 ); 17064 morphNode(movedChild, newChild, ctx); 17065 insertionPoint = movedChild.nextSibling; 17066 continue; 17067 } 17068 } 17069 const insertedNode = createNode( 17070 oldParent, 17071 newChild, 17072 insertionPoint, 17073 ctx 17074 ); 17075 if (insertedNode) { 17076 insertionPoint = insertedNode.nextSibling; 17077 } 17078 } 17079 while (insertionPoint && insertionPoint != endPoint) { 17080 const tempNode = insertionPoint; 17081 insertionPoint = insertionPoint.nextSibling; 17082 removeNode(ctx, tempNode); 17083 } 17084 } 17085 function createNode(oldParent, newChild, insertionPoint, ctx) { 17086 if (ctx.callbacks.beforeNodeAdded(newChild) === false) return null; 17087 if (ctx.idMap.has(newChild)) { 17088 const newEmptyChild = document.createElement( 17089 /** @type {Element} */ 17090 newChild.tagName 17091 ); 17092 oldParent.insertBefore(newEmptyChild, insertionPoint); 17093 morphNode(newEmptyChild, newChild, ctx); 17094 ctx.callbacks.afterNodeAdded(newEmptyChild); 17095 return newEmptyChild; 17096 } else { 17097 const newClonedChild = document.importNode(newChild, true); 17098 oldParent.insertBefore(newClonedChild, insertionPoint); 17099 ctx.callbacks.afterNodeAdded(newClonedChild); 17100 return newClonedChild; 17101 } 17102 } 17103 const findBestMatch = /* @__PURE__ */ (function() { 17104 function findBestMatch2(ctx, node, startPoint, endPoint) { 17105 let softMatch = null; 17106 let nextSibling = node.nextSibling; 17107 let siblingSoftMatchCount = 0; 17108 let cursor = startPoint; 17109 while (cursor && cursor != endPoint) { 17110 if (isSoftMatch(cursor, node)) { 17111 if (isIdSetMatch(ctx, cursor, node)) { 17112 return cursor; 17113 } 17114 if (softMatch === null) { 17115 if (!ctx.idMap.has(cursor)) { 17116 softMatch = cursor; 17117 } 17118 } 17119 } 17120 if (softMatch === null && nextSibling && isSoftMatch(cursor, nextSibling)) { 17121 siblingSoftMatchCount++; 17122 nextSibling = nextSibling.nextSibling; 17123 if (siblingSoftMatchCount >= 2) { 17124 softMatch = void 0; 17125 } 17126 } 17127 if (ctx.activeElementAndParents.includes(cursor)) break; 17128 cursor = cursor.nextSibling; 17129 } 17130 return softMatch || null; 17131 } 17132 function isIdSetMatch(ctx, oldNode, newNode) { 17133 let oldSet = ctx.idMap.get(oldNode); 17134 let newSet = ctx.idMap.get(newNode); 17135 if (!newSet || !oldSet) return false; 17136 for (const id of oldSet) { 17137 if (newSet.has(id)) { 17138 return true; 17139 } 17140 } 17141 return false; 17142 } 17143 function isSoftMatch(oldNode, newNode) { 17144 const oldElt = ( 17145 /** @type {Element} */ 17146 oldNode 17147 ); 17148 const newElt = ( 17149 /** @type {Element} */ 17150 newNode 17151 ); 17152 return oldElt.nodeType === newElt.nodeType && oldElt.tagName === newElt.tagName && // If oldElt has an `id` with possible state and it doesn't match newElt.id then avoid morphing. 17153 // We'll still match an anonymous node with an IDed newElt, though, because if it got this far, 17154 // its not persistent, and new nodes can't have any hidden state. 17155 // We can't use .id because of form input shadowing, and we can't count on .getAttribute's presence because it could be a document-fragment 17156 (!oldElt.getAttribute?.("id") || oldElt.getAttribute?.("id") === newElt.getAttribute?.("id")); 17157 } 17158 return findBestMatch2; 17159 })(); 17160 function removeNode(ctx, node) { 17161 if (ctx.idMap.has(node)) { 17162 moveBefore(ctx.pantry, node, null); 17163 } else { 17164 if (ctx.callbacks.beforeNodeRemoved(node) === false) return; 17165 node.parentNode?.removeChild(node); 17166 ctx.callbacks.afterNodeRemoved(node); 17167 } 17168 } 17169 function removeNodesBetween(ctx, startInclusive, endExclusive) { 17170 let cursor = startInclusive; 17171 while (cursor && cursor !== endExclusive) { 17172 let tempNode = ( 17173 /** @type {Node} */ 17174 cursor 17175 ); 17176 cursor = cursor.nextSibling; 17177 removeNode(ctx, tempNode); 17178 } 17179 return cursor; 17180 } 17181 function moveBeforeById(parentNode, id, after, ctx) { 17182 const target = ( 17183 /** @type {Element} - will always be found */ 17184 // ctx.target.id unsafe because of form input shadowing 17185 // ctx.target could be a document fragment which doesn't have `getAttribute` 17186 ctx.target.getAttribute?.("id") === id && ctx.target || ctx.target.querySelector(`[id="${id}"]`) || ctx.pantry.querySelector(`[id="${id}"]`) 17187 ); 17188 removeElementFromAncestorsIdMaps(target, ctx); 17189 moveBefore(parentNode, target, after); 17190 return target; 17191 } 17192 function removeElementFromAncestorsIdMaps(element, ctx) { 17193 const id = ( 17194 /** @type {String} */ 17195 element.getAttribute("id") 17196 ); 17197 while (element = element.parentNode) { 17198 let idSet = ctx.idMap.get(element); 17199 if (idSet) { 17200 idSet.delete(id); 17201 if (!idSet.size) { 17202 ctx.idMap.delete(element); 17203 } 17204 } 17205 } 17206 } 17207 function moveBefore(parentNode, element, after) { 17208 if (parentNode.moveBefore) { 17209 try { 17210 parentNode.moveBefore(element, after); 17211 } catch (e) { 17212 parentNode.insertBefore(element, after); 17213 } 17214 } else { 17215 parentNode.insertBefore(element, after); 17216 } 17217 } 17218 return morphChildren3; 17219 })(); 17220 const morphNode = /* @__PURE__ */ (function() { 17221 function morphNode2(oldNode, newContent, ctx) { 17222 if (ctx.ignoreActive && oldNode === document.activeElement) { 17223 return null; 17224 } 17225 if (ctx.callbacks.beforeNodeMorphed(oldNode, newContent) === false) { 17226 return oldNode; 17227 } 17228 if (oldNode instanceof HTMLHeadElement && ctx.head.ignore) ; 17229 else if (oldNode instanceof HTMLHeadElement && ctx.head.style !== "morph") { 17230 handleHeadElement( 17231 oldNode, 17232 /** @type {HTMLHeadElement} */ 17233 newContent, 17234 ctx 17235 ); 17236 } else { 17237 morphAttributes(oldNode, newContent, ctx); 17238 if (!ignoreValueOfActiveElement(oldNode, ctx)) { 17239 morphChildren2(ctx, oldNode, newContent); 17240 } 17241 } 17242 ctx.callbacks.afterNodeMorphed(oldNode, newContent); 17243 return oldNode; 17244 } 17245 function morphAttributes(oldNode, newNode, ctx) { 17246 let type = newNode.nodeType; 17247 if (type === 1) { 17248 const oldElt = ( 17249 /** @type {Element} */ 17250 oldNode 17251 ); 17252 const newElt = ( 17253 /** @type {Element} */ 17254 newNode 17255 ); 17256 const oldAttributes = oldElt.attributes; 17257 const newAttributes = newElt.attributes; 17258 for (const newAttribute of newAttributes) { 17259 if (ignoreAttribute(newAttribute.name, oldElt, "update", ctx)) { 17260 continue; 17261 } 17262 if (oldElt.getAttribute(newAttribute.name) !== newAttribute.value) { 17263 oldElt.setAttribute(newAttribute.name, newAttribute.value); 17264 } 17265 } 17266 for (let i = oldAttributes.length - 1; 0 <= i; i--) { 17267 const oldAttribute = oldAttributes[i]; 17268 if (!oldAttribute) continue; 17269 if (!newElt.hasAttribute(oldAttribute.name)) { 17270 if (ignoreAttribute(oldAttribute.name, oldElt, "remove", ctx)) { 17271 continue; 17272 } 17273 oldElt.removeAttribute(oldAttribute.name); 17274 } 17275 } 17276 if (!ignoreValueOfActiveElement(oldElt, ctx)) { 17277 syncInputValue(oldElt, newElt, ctx); 17278 } 17279 } 17280 if (type === 8 || type === 3) { 17281 if (oldNode.nodeValue !== newNode.nodeValue) { 17282 oldNode.nodeValue = newNode.nodeValue; 17283 } 17284 } 17285 } 17286 function syncInputValue(oldElement, newElement, ctx) { 17287 if (oldElement instanceof HTMLInputElement && newElement instanceof HTMLInputElement && newElement.type !== "file") { 17288 let newValue = newElement.value; 17289 let oldValue = oldElement.value; 17290 syncBooleanAttribute(oldElement, newElement, "checked", ctx); 17291 syncBooleanAttribute(oldElement, newElement, "disabled", ctx); 17292 if (!newElement.hasAttribute("value")) { 17293 if (!ignoreAttribute("value", oldElement, "remove", ctx)) { 17294 oldElement.value = ""; 17295 oldElement.removeAttribute("value"); 17296 } 17297 } else if (oldValue !== newValue) { 17298 if (!ignoreAttribute("value", oldElement, "update", ctx)) { 17299 oldElement.setAttribute("value", newValue); 17300 oldElement.value = newValue; 17301 } 17302 } 17303 } else if (oldElement instanceof HTMLOptionElement && newElement instanceof HTMLOptionElement) { 17304 syncBooleanAttribute(oldElement, newElement, "selected", ctx); 17305 } else if (oldElement instanceof HTMLTextAreaElement && newElement instanceof HTMLTextAreaElement) { 17306 let newValue = newElement.value; 17307 let oldValue = oldElement.value; 17308 if (ignoreAttribute("value", oldElement, "update", ctx)) { 17309 return; 17310 } 17311 if (newValue !== oldValue) { 17312 oldElement.value = newValue; 17313 } 17314 if (oldElement.firstChild && oldElement.firstChild.nodeValue !== newValue) { 17315 oldElement.firstChild.nodeValue = newValue; 17316 } 17317 } 17318 } 17319 function syncBooleanAttribute(oldElement, newElement, attributeName, ctx) { 17320 const newLiveValue = newElement[attributeName], oldLiveValue = oldElement[attributeName]; 17321 if (newLiveValue !== oldLiveValue) { 17322 const ignoreUpdate = ignoreAttribute( 17323 attributeName, 17324 oldElement, 17325 "update", 17326 ctx 17327 ); 17328 if (!ignoreUpdate) { 17329 oldElement[attributeName] = newElement[attributeName]; 17330 } 17331 if (newLiveValue) { 17332 if (!ignoreUpdate) { 17333 oldElement.setAttribute(attributeName, ""); 17334 } 17335 } else { 17336 if (!ignoreAttribute(attributeName, oldElement, "remove", ctx)) { 17337 oldElement.removeAttribute(attributeName); 17338 } 17339 } 17340 } 17341 } 17342 function ignoreAttribute(attr, element, updateType, ctx) { 17343 if (attr === "value" && ctx.ignoreActiveValue && element === document.activeElement) { 17344 return true; 17345 } 17346 return ctx.callbacks.beforeAttributeUpdated(attr, element, updateType) === false; 17347 } 17348 function ignoreValueOfActiveElement(possibleActiveElement, ctx) { 17349 return !!ctx.ignoreActiveValue && possibleActiveElement === document.activeElement && possibleActiveElement !== document.body; 17350 } 17351 return morphNode2; 17352 })(); 17353 function withHeadBlocking(ctx, oldNode, newNode, callback) { 17354 if (ctx.head.block) { 17355 const oldHead = oldNode.querySelector("head"); 17356 const newHead = newNode.querySelector("head"); 17357 if (oldHead && newHead) { 17358 const promises = handleHeadElement(oldHead, newHead, ctx); 17359 return Promise.all(promises).then(() => { 17360 const newCtx = Object.assign(ctx, { 17361 head: { 17362 block: false, 17363 ignore: true 17364 } 17365 }); 17366 return callback(newCtx); 17367 }); 17368 } 17369 } 17370 return callback(ctx); 17371 } 17372 function handleHeadElement(oldHead, newHead, ctx) { 17373 let added = []; 17374 let removed = []; 17375 let preserved = []; 17376 let nodesToAppend = []; 17377 let srcToNewHeadNodes = /* @__PURE__ */ new Map(); 17378 for (const newHeadChild of newHead.children) { 17379 srcToNewHeadNodes.set(newHeadChild.outerHTML, newHeadChild); 17380 } 17381 for (const currentHeadElt of oldHead.children) { 17382 let inNewContent = srcToNewHeadNodes.has(currentHeadElt.outerHTML); 17383 let isReAppended = ctx.head.shouldReAppend(currentHeadElt); 17384 let isPreserved = ctx.head.shouldPreserve(currentHeadElt); 17385 if (inNewContent || isPreserved) { 17386 if (isReAppended) { 17387 removed.push(currentHeadElt); 17388 } else { 17389 srcToNewHeadNodes.delete(currentHeadElt.outerHTML); 17390 preserved.push(currentHeadElt); 17391 } 17392 } else { 17393 if (ctx.head.style === "append") { 17394 if (isReAppended) { 17395 removed.push(currentHeadElt); 17396 nodesToAppend.push(currentHeadElt); 17397 } 17398 } else { 17399 if (ctx.head.shouldRemove(currentHeadElt) !== false) { 17400 removed.push(currentHeadElt); 17401 } 17402 } 17403 } 17404 } 17405 nodesToAppend.push(...srcToNewHeadNodes.values()); 17406 let promises = []; 17407 for (const newNode of nodesToAppend) { 17408 let newElt = ( 17409 /** @type {ChildNode} */ 17410 document.createRange().createContextualFragment(newNode.outerHTML).firstChild 17411 ); 17412 if (ctx.callbacks.beforeNodeAdded(newElt) !== false) { 17413 if ("href" in newElt && newElt.href || "src" in newElt && newElt.src) { 17414 let resolve; 17415 let promise = new Promise(function(_resolve) { 17416 resolve = _resolve; 17417 }); 17418 newElt.addEventListener("load", function() { 17419 resolve(); 17420 }); 17421 promises.push(promise); 17422 } 17423 oldHead.appendChild(newElt); 17424 ctx.callbacks.afterNodeAdded(newElt); 17425 added.push(newElt); 17426 } 17427 } 17428 for (const removedElement of removed) { 17429 if (ctx.callbacks.beforeNodeRemoved(removedElement) !== false) { 17430 oldHead.removeChild(removedElement); 17431 ctx.callbacks.afterNodeRemoved(removedElement); 17432 } 17433 } 17434 ctx.head.afterHeadMorphed(oldHead, { 17435 added, 17436 kept: preserved, 17437 removed 17438 }); 17439 return promises; 17440 } 17441 const createMorphContext = /* @__PURE__ */ (function() { 17442 function createMorphContext2(oldNode, newContent, config2) { 17443 const { persistentIds, idMap } = createIdMaps(oldNode, newContent); 17444 const mergedConfig = mergeDefaults(config2); 17445 const morphStyle = mergedConfig.morphStyle || "outerHTML"; 17446 if (!["innerHTML", "outerHTML"].includes(morphStyle)) { 17447 throw `Do not understand how to morph style ${morphStyle}`; 17448 } 17449 return { 17450 target: oldNode, 17451 newContent, 17452 config: mergedConfig, 17453 morphStyle, 17454 ignoreActive: mergedConfig.ignoreActive, 17455 ignoreActiveValue: mergedConfig.ignoreActiveValue, 17456 restoreFocus: mergedConfig.restoreFocus, 17457 idMap, 17458 persistentIds, 17459 pantry: createPantry(), 17460 activeElementAndParents: createActiveElementAndParents(oldNode), 17461 callbacks: mergedConfig.callbacks, 17462 head: mergedConfig.head 17463 }; 17464 } 17465 function mergeDefaults(config2) { 17466 let finalConfig = Object.assign({}, defaults); 17467 Object.assign(finalConfig, config2); 17468 finalConfig.callbacks = Object.assign( 17469 {}, 17470 defaults.callbacks, 17471 config2.callbacks 17472 ); 17473 finalConfig.head = Object.assign({}, defaults.head, config2.head); 17474 return finalConfig; 17475 } 17476 function createPantry() { 17477 const pantry = document.createElement("div"); 17478 pantry.hidden = true; 17479 document.body.insertAdjacentElement("afterend", pantry); 17480 return pantry; 17481 } 17482 function createActiveElementAndParents(oldNode) { 17483 let activeElementAndParents = []; 17484 let elt = document.activeElement; 17485 if (elt?.tagName !== "BODY" && oldNode.contains(elt)) { 17486 while (elt) { 17487 activeElementAndParents.push(elt); 17488 if (elt === oldNode) break; 17489 elt = elt.parentElement; 17490 } 17491 } 17492 return activeElementAndParents; 17493 } 17494 function findIdElements(root) { 17495 let elements = Array.from(root.querySelectorAll("[id]")); 17496 if (root.getAttribute?.("id")) { 17497 elements.push(root); 17498 } 17499 return elements; 17500 } 17501 function populateIdMapWithTree(idMap, persistentIds, root, elements) { 17502 for (const elt of elements) { 17503 const id = ( 17504 /** @type {String} */ 17505 elt.getAttribute("id") 17506 ); 17507 if (persistentIds.has(id)) { 17508 let current = elt; 17509 while (current) { 17510 let idSet = idMap.get(current); 17511 if (idSet == null) { 17512 idSet = /* @__PURE__ */ new Set(); 17513 idMap.set(current, idSet); 17514 } 17515 idSet.add(id); 17516 if (current === root) break; 17517 current = current.parentElement; 17518 } 17519 } 17520 } 17521 } 17522 function createIdMaps(oldContent, newContent) { 17523 const oldIdElements = findIdElements(oldContent); 17524 const newIdElements = findIdElements(newContent); 17525 const persistentIds = createPersistentIds(oldIdElements, newIdElements); 17526 let idMap = /* @__PURE__ */ new Map(); 17527 populateIdMapWithTree(idMap, persistentIds, oldContent, oldIdElements); 17528 const newRoot = newContent.__idiomorphRoot || newContent; 17529 populateIdMapWithTree(idMap, persistentIds, newRoot, newIdElements); 17530 return { persistentIds, idMap }; 17531 } 17532 function createPersistentIds(oldIdElements, newIdElements) { 17533 let duplicateIds = /* @__PURE__ */ new Set(); 17534 let oldIdTagNameMap = /* @__PURE__ */ new Map(); 17535 for (const { id, tagName } of oldIdElements) { 17536 if (oldIdTagNameMap.has(id)) { 17537 duplicateIds.add(id); 17538 } else { 17539 oldIdTagNameMap.set(id, tagName); 17540 } 17541 } 17542 let persistentIds = /* @__PURE__ */ new Set(); 17543 for (const { id, tagName } of newIdElements) { 17544 if (persistentIds.has(id)) { 17545 duplicateIds.add(id); 17546 } else if (oldIdTagNameMap.get(id) === tagName) { 17547 persistentIds.add(id); 17548 } 17549 } 17550 for (const id of duplicateIds) { 17551 persistentIds.delete(id); 17552 } 17553 return persistentIds; 17554 } 17555 return createMorphContext2; 17556 })(); 17557 const { normalizeElement, normalizeParent } = /* @__PURE__ */ (function() { 17558 const generatedByIdiomorph = /* @__PURE__ */ new WeakSet(); 17559 function normalizeElement2(content) { 17560 if (content instanceof Document) { 17561 return content.documentElement; 17562 } else { 17563 return content; 17564 } 17565 } 17566 function normalizeParent2(newContent) { 17567 if (newContent == null) { 17568 return document.createElement("div"); 17569 } else if (typeof newContent === "string") { 17570 return normalizeParent2(parseContent(newContent)); 17571 } else if (generatedByIdiomorph.has( 17572 /** @type {Element} */ 17573 newContent 17574 )) { 17575 return ( 17576 /** @type {Element} */ 17577 newContent 17578 ); 17579 } else if (newContent instanceof Node) { 17580 if (newContent.parentNode) { 17581 return ( 17582 /** @type {any} */ 17583 new SlicedParentNode(newContent) 17584 ); 17585 } else { 17586 const dummyParent = document.createElement("div"); 17587 dummyParent.append(newContent); 17588 return dummyParent; 17589 } 17590 } else { 17591 const dummyParent = document.createElement("div"); 17592 for (const elt of [...newContent]) { 17593 dummyParent.append(elt); 17594 } 17595 return dummyParent; 17596 } 17597 } 17598 class SlicedParentNode { 17599 /** @param {Node} node */ 17600 constructor(node) { 17601 this.originalNode = node; 17602 this.realParentNode = /** @type {Element} */ 17603 node.parentNode; 17604 this.previousSibling = node.previousSibling; 17605 this.nextSibling = node.nextSibling; 17606 } 17607 /** @returns {Node[]} */ 17608 get childNodes() { 17609 const nodes = []; 17610 let cursor = this.previousSibling ? this.previousSibling.nextSibling : this.realParentNode.firstChild; 17611 while (cursor && cursor != this.nextSibling) { 17612 nodes.push(cursor); 17613 cursor = cursor.nextSibling; 17614 } 17615 return nodes; 17616 } 17617 /** 17618 * @param {string} selector 17619 * @returns {Element[]} 17620 */ 17621 querySelectorAll(selector) { 17622 return this.childNodes.reduce( 17623 (results, node) => { 17624 if (node instanceof Element) { 17625 if (node.matches(selector)) results.push(node); 17626 const nodeList = node.querySelectorAll(selector); 17627 for (let i = 0; i < nodeList.length; i++) { 17628 results.push(nodeList[i]); 17629 } 17630 } 17631 return results; 17632 }, 17633 /** @type {Element[]} */ 17634 [] 17635 ); 17636 } 17637 /** 17638 * @param {Node} node 17639 * @param {Node} referenceNode 17640 * @returns {Node} 17641 */ 17642 insertBefore(node, referenceNode) { 17643 return this.realParentNode.insertBefore(node, referenceNode); 17644 } 17645 /** 17646 * @param {Node} node 17647 * @param {Node} referenceNode 17648 * @returns {Node} 17649 */ 17650 moveBefore(node, referenceNode) { 17651 return this.realParentNode.moveBefore(node, referenceNode); 17652 } 17653 /** 17654 * for later use with populateIdMapWithTree to halt upwards iteration 17655 * @returns {Node} 17656 */ 17657 get __idiomorphRoot() { 17658 return this.originalNode; 17659 } 17660 } 17661 function parseContent(newContent) { 17662 let parser = new DOMParser(); 17663 let contentWithSvgsRemoved = newContent.replace( 17664 /<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim, 17665 "" 17666 ); 17667 if (contentWithSvgsRemoved.match(/<\/html>/) || contentWithSvgsRemoved.match(/<\/head>/) || contentWithSvgsRemoved.match(/<\/body>/)) { 17668 let content = parser.parseFromString(newContent, "text/html"); 17669 if (contentWithSvgsRemoved.match(/<\/html>/)) { 17670 generatedByIdiomorph.add(content); 17671 return content; 17672 } else { 17673 let htmlElement = content.firstChild; 17674 if (htmlElement) { 17675 generatedByIdiomorph.add(htmlElement); 17676 } 17677 return htmlElement; 17678 } 17679 } else { 17680 let responseDoc = parser.parseFromString( 17681 "<body><template>" + newContent + "</template></body>", 17682 "text/html" 17683 ); 17684 let content = ( 17685 /** @type {HTMLTemplateElement} */ 17686 responseDoc.body.querySelector("template").content 17687 ); 17688 generatedByIdiomorph.add(content); 17689 return content; 17690 } 17691 } 17692 return { normalizeElement: normalizeElement2, normalizeParent: normalizeParent2 }; 17693 })(); 17694 return { 17695 morph, 17696 defaults 17697 }; 17698 })(); 17699 function morphElements(currentElement, newElement, { callbacks, ...options } = {}) { 17700 Idiomorph.morph(currentElement, newElement, { 17701 ...options, 17702 callbacks: new DefaultIdiomorphCallbacks(callbacks) 17703 }); 17704 } 17705 function morphChildren(currentElement, newElement, options = {}) { 17706 morphElements(currentElement, newElement.childNodes, { 17707 ...options, 17708 morphStyle: "innerHTML" 17709 }); 17710 } 17711 function shouldRefreshFrameWithMorphing(currentFrame, newFrame) { 17712 return currentFrame instanceof FrameElement && currentFrame.shouldReloadWithMorph && (!newFrame || areFramesCompatibleForRefreshing(currentFrame, newFrame)) && !currentFrame.closest("[data-turbo-permanent]"); 17713 } 17714 function areFramesCompatibleForRefreshing(currentFrame, newFrame) { 17715 return newFrame instanceof Element && newFrame.nodeName === "TURBO-FRAME" && currentFrame.id === newFrame.id && (!newFrame.getAttribute("src") || urlsAreEqual(currentFrame.src, newFrame.getAttribute("src"))); 17716 } 17717 function closestFrameReloadableWithMorphing(node) { 17718 return node.parentElement.closest("turbo-frame[src][refresh=morph]"); 17719 } 17720 var DefaultIdiomorphCallbacks = class { 17721 #beforeNodeMorphed; 17722 constructor({ beforeNodeMorphed } = {}) { 17723 this.#beforeNodeMorphed = beforeNodeMorphed || (() => true); 17724 } 17725 beforeNodeAdded = (node) => { 17726 return !(node.id && node.hasAttribute("data-turbo-permanent") && document.getElementById(node.id)); 17727 }; 17728 beforeNodeMorphed = (currentElement, newElement) => { 17729 if (currentElement instanceof Element) { 17730 if (!currentElement.hasAttribute("data-turbo-permanent") && this.#beforeNodeMorphed(currentElement, newElement)) { 17731 const event = dispatch("turbo:before-morph-element", { 17732 cancelable: true, 17733 target: currentElement, 17734 detail: { currentElement, newElement } 17735 }); 17736 return !event.defaultPrevented; 17737 } else { 17738 return false; 17739 } 17740 } 17741 }; 17742 beforeAttributeUpdated = (attributeName, target, mutationType) => { 17743 const event = dispatch("turbo:before-morph-attribute", { 17744 cancelable: true, 17745 target, 17746 detail: { attributeName, mutationType } 17747 }); 17748 return !event.defaultPrevented; 17749 }; 17750 beforeNodeRemoved = (node) => { 17751 return this.beforeNodeMorphed(node); 17752 }; 17753 afterNodeMorphed = (currentElement, newElement) => { 17754 if (currentElement instanceof Element) { 17755 dispatch("turbo:morph-element", { 17756 target: currentElement, 17757 detail: { currentElement, newElement } 17758 }); 17759 } 17760 }; 17761 }; 17762 var MorphingFrameRenderer = class extends FrameRenderer { 17763 static renderElement(currentElement, newElement) { 17764 dispatch("turbo:before-frame-morph", { 17765 target: currentElement, 17766 detail: { currentElement, newElement } 17767 }); 17768 morphChildren(currentElement, newElement, { 17769 callbacks: { 17770 beforeNodeMorphed: (node, newNode) => { 17771 if (shouldRefreshFrameWithMorphing(node, newNode) && closestFrameReloadableWithMorphing(node) === currentElement) { 17772 node.reload(); 17773 return false; 17774 } 17775 return true; 17776 } 17777 } 17778 }); 17779 } 17780 async preservingPermanentElements(callback) { 17781 return await callback(); 17782 } 17783 }; 17784 var ProgressBar = class _ProgressBar { 17785 static animationDuration = 300; 17786 /*ms*/ 17787 static get defaultCSS() { 17788 return unindent` 17789 .turbo-progress-bar { 17790 position: fixed; 17791 display: block; 17792 top: 0; 17793 left: 0; 17794 height: 3px; 17795 background: #0076ff; 17796 z-index: 2147483647; 17797 transition: 17798 width ${_ProgressBar.animationDuration}ms ease-out, 17799 opacity ${_ProgressBar.animationDuration / 2}ms ${_ProgressBar.animationDuration / 2}ms ease-in; 17800 transform: translate3d(0, 0, 0); 17801 } 17802 `; 17803 } 17804 hiding = false; 17805 value = 0; 17806 visible = false; 17807 constructor() { 17808 this.stylesheetElement = this.createStylesheetElement(); 17809 this.progressElement = this.createProgressElement(); 17810 this.installStylesheetElement(); 17811 this.setValue(0); 17812 } 17813 show() { 17814 if (!this.visible) { 17815 this.visible = true; 17816 this.installProgressElement(); 17817 this.startTrickling(); 17818 } 17819 } 17820 hide() { 17821 if (this.visible && !this.hiding) { 17822 this.hiding = true; 17823 this.fadeProgressElement(() => { 17824 this.uninstallProgressElement(); 17825 this.stopTrickling(); 17826 this.visible = false; 17827 this.hiding = false; 17828 }); 17829 } 17830 } 17831 setValue(value) { 17832 this.value = value; 17833 this.refresh(); 17834 } 17835 // Private 17836 installStylesheetElement() { 17837 document.head.insertBefore(this.stylesheetElement, document.head.firstChild); 17838 } 17839 installProgressElement() { 17840 this.progressElement.style.width = "0"; 17841 this.progressElement.style.opacity = "1"; 17842 document.documentElement.insertBefore(this.progressElement, document.body); 17843 this.refresh(); 17844 } 17845 fadeProgressElement(callback) { 17846 this.progressElement.style.opacity = "0"; 17847 setTimeout(callback, _ProgressBar.animationDuration * 1.5); 17848 } 17849 uninstallProgressElement() { 17850 if (this.progressElement.parentNode) { 17851 document.documentElement.removeChild(this.progressElement); 17852 } 17853 } 17854 startTrickling() { 17855 if (!this.trickleInterval) { 17856 this.trickleInterval = window.setInterval(this.trickle, _ProgressBar.animationDuration); 17857 } 17858 } 17859 stopTrickling() { 17860 window.clearInterval(this.trickleInterval); 17861 delete this.trickleInterval; 17862 } 17863 trickle = () => { 17864 this.setValue(this.value + Math.random() / 100); 17865 }; 17866 refresh() { 17867 requestAnimationFrame(() => { 17868 this.progressElement.style.width = `${10 + this.value * 90}%`; 17869 }); 17870 } 17871 createStylesheetElement() { 17872 const element = document.createElement("style"); 17873 element.type = "text/css"; 17874 element.textContent = _ProgressBar.defaultCSS; 17875 const cspNonce2 = getCspNonce(); 17876 if (cspNonce2) { 17877 element.nonce = cspNonce2; 17878 } 17879 return element; 17880 } 17881 createProgressElement() { 17882 const element = document.createElement("div"); 17883 element.className = "turbo-progress-bar"; 17884 return element; 17885 } 17886 }; 17887 var HeadSnapshot = class extends Snapshot { 17888 detailsByOuterHTML = this.children.filter((element) => !elementIsNoscript(element)).map((element) => elementWithoutNonce(element)).reduce((result, element) => { 17889 const { outerHTML } = element; 17890 const details = outerHTML in result ? result[outerHTML] : { 17891 type: elementType(element), 17892 tracked: elementIsTracked(element), 17893 elements: [] 17894 }; 17895 return { 17896 ...result, 17897 [outerHTML]: { 17898 ...details, 17899 elements: [...details.elements, element] 17900 } 17901 }; 17902 }, {}); 17903 get trackedElementSignature() { 17904 return Object.keys(this.detailsByOuterHTML).filter((outerHTML) => this.detailsByOuterHTML[outerHTML].tracked).join(""); 17905 } 17906 getScriptElementsNotInSnapshot(snapshot) { 17907 return this.getElementsMatchingTypeNotInSnapshot("script", snapshot); 17908 } 17909 getStylesheetElementsNotInSnapshot(snapshot) { 17910 return this.getElementsMatchingTypeNotInSnapshot("stylesheet", snapshot); 17911 } 17912 getElementsMatchingTypeNotInSnapshot(matchedType, snapshot) { 17913 return Object.keys(this.detailsByOuterHTML).filter((outerHTML) => !(outerHTML in snapshot.detailsByOuterHTML)).map((outerHTML) => this.detailsByOuterHTML[outerHTML]).filter(({ type }) => type == matchedType).map(({ elements: [element] }) => element); 17914 } 17915 get provisionalElements() { 17916 return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => { 17917 const { type, tracked, elements } = this.detailsByOuterHTML[outerHTML]; 17918 if (type == null && !tracked) { 17919 return [...result, ...elements]; 17920 } else if (elements.length > 1) { 17921 return [...result, ...elements.slice(1)]; 17922 } else { 17923 return result; 17924 } 17925 }, []); 17926 } 17927 getMetaValue(name) { 17928 const element = this.findMetaElementByName(name); 17929 return element ? element.getAttribute("content") : null; 17930 } 17931 findMetaElementByName(name) { 17932 return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => { 17933 const { 17934 elements: [element] 17935 } = this.detailsByOuterHTML[outerHTML]; 17936 return elementIsMetaElementWithName(element, name) ? element : result; 17937 }, void 0 | void 0); 17938 } 17939 }; 17940 function elementType(element) { 17941 if (elementIsScript(element)) { 17942 return "script"; 17943 } else if (elementIsStylesheet(element)) { 17944 return "stylesheet"; 17945 } 17946 } 17947 function elementIsTracked(element) { 17948 return element.getAttribute("data-turbo-track") == "reload"; 17949 } 17950 function elementIsScript(element) { 17951 const tagName = element.localName; 17952 return tagName == "script"; 17953 } 17954 function elementIsNoscript(element) { 17955 const tagName = element.localName; 17956 return tagName == "noscript"; 17957 } 17958 function elementIsStylesheet(element) { 17959 const tagName = element.localName; 17960 return tagName == "style" || tagName == "link" && element.getAttribute("rel") == "stylesheet"; 17961 } 17962 function elementIsMetaElementWithName(element, name) { 17963 const tagName = element.localName; 17964 return tagName == "meta" && element.getAttribute("name") == name; 17965 } 17966 function elementWithoutNonce(element) { 17967 if (element.hasAttribute("nonce")) { 17968 element.setAttribute("nonce", ""); 17969 } 17970 return element; 17971 } 17972 var PageSnapshot = class _PageSnapshot extends Snapshot { 17973 static fromHTMLString(html = "") { 17974 return this.fromDocument(parseHTMLDocument(html)); 17975 } 17976 static fromElement(element) { 17977 return this.fromDocument(element.ownerDocument); 17978 } 17979 static fromDocument({ documentElement, body, head }) { 17980 return new this(documentElement, body, new HeadSnapshot(head)); 17981 } 17982 constructor(documentElement, body, headSnapshot) { 17983 super(body); 17984 this.documentElement = documentElement; 17985 this.headSnapshot = headSnapshot; 17986 } 17987 clone() { 17988 const clonedElement = this.element.cloneNode(true); 17989 const selectElements = this.element.querySelectorAll("select"); 17990 const clonedSelectElements = clonedElement.querySelectorAll("select"); 17991 for (const [index, source] of selectElements.entries()) { 17992 const clone = clonedSelectElements[index]; 17993 for (const option of clone.selectedOptions) option.selected = false; 17994 for (const option of source.selectedOptions) clone.options[option.index].selected = true; 17995 } 17996 for (const clonedPasswordInput of clonedElement.querySelectorAll('input[type="password"]')) { 17997 clonedPasswordInput.value = ""; 17998 } 17999 for (const clonedNoscriptElement of clonedElement.querySelectorAll("noscript")) { 18000 clonedNoscriptElement.remove(); 18001 } 18002 return new _PageSnapshot(this.documentElement, clonedElement, this.headSnapshot); 18003 } 18004 get lang() { 18005 return this.documentElement.getAttribute("lang"); 18006 } 18007 get dir() { 18008 return this.documentElement.getAttribute("dir"); 18009 } 18010 get headElement() { 18011 return this.headSnapshot.element; 18012 } 18013 get rootLocation() { 18014 const root = this.getSetting("root") ?? "/"; 18015 return expandURL(root); 18016 } 18017 get cacheControlValue() { 18018 return this.getSetting("cache-control"); 18019 } 18020 get isPreviewable() { 18021 return this.cacheControlValue != "no-preview"; 18022 } 18023 get isCacheable() { 18024 return this.cacheControlValue != "no-cache"; 18025 } 18026 get isVisitable() { 18027 return this.getSetting("visit-control") != "reload"; 18028 } 18029 get prefersViewTransitions() { 18030 const viewTransitionEnabled = this.getSetting("view-transition") === "true" || this.headSnapshot.getMetaValue("view-transition") === "same-origin"; 18031 return viewTransitionEnabled && !window.matchMedia("(prefers-reduced-motion: reduce)").matches; 18032 } 18033 get refreshMethod() { 18034 return this.getSetting("refresh-method"); 18035 } 18036 get refreshScroll() { 18037 return this.getSetting("refresh-scroll"); 18038 } 18039 // Private 18040 getSetting(name) { 18041 return this.headSnapshot.getMetaValue(`turbo-${name}`); 18042 } 18043 }; 18044 var ViewTransitioner = class { 18045 #viewTransitionStarted = false; 18046 #lastOperation = Promise.resolve(); 18047 renderChange(useViewTransition, render) { 18048 if (useViewTransition && this.viewTransitionsAvailable && !this.#viewTransitionStarted) { 18049 this.#viewTransitionStarted = true; 18050 this.#lastOperation = this.#lastOperation.then(async () => { 18051 await document.startViewTransition(render).finished; 18052 }); 18053 } else { 18054 this.#lastOperation = this.#lastOperation.then(render); 18055 } 18056 return this.#lastOperation; 18057 } 18058 get viewTransitionsAvailable() { 18059 return document.startViewTransition; 18060 } 18061 }; 18062 var defaultOptions = { 18063 action: "advance", 18064 historyChanged: false, 18065 visitCachedSnapshot: () => { 18066 }, 18067 willRender: true, 18068 updateHistory: true, 18069 shouldCacheSnapshot: true, 18070 acceptsStreamResponse: false, 18071 refresh: {} 18072 }; 18073 var TimingMetric = { 18074 visitStart: "visitStart", 18075 requestStart: "requestStart", 18076 requestEnd: "requestEnd", 18077 visitEnd: "visitEnd" 18078 }; 18079 var VisitState = { 18080 initialized: "initialized", 18081 started: "started", 18082 canceled: "canceled", 18083 failed: "failed", 18084 completed: "completed" 18085 }; 18086 var SystemStatusCode = { 18087 networkFailure: 0, 18088 timeoutFailure: -1, 18089 contentTypeMismatch: -2 18090 }; 18091 var Direction = { 18092 advance: "forward", 18093 restore: "back", 18094 replace: "none" 18095 }; 18096 var Visit = class { 18097 identifier = uuid(); 18098 // Required by turbo-ios 18099 timingMetrics = {}; 18100 followedRedirect = false; 18101 historyChanged = false; 18102 scrolled = false; 18103 shouldCacheSnapshot = true; 18104 acceptsStreamResponse = false; 18105 snapshotCached = false; 18106 state = VisitState.initialized; 18107 viewTransitioner = new ViewTransitioner(); 18108 constructor(delegate2, location2, restorationIdentifier, options = {}) { 18109 this.delegate = delegate2; 18110 this.location = location2; 18111 this.restorationIdentifier = restorationIdentifier || uuid(); 18112 const { 18113 action, 18114 historyChanged, 18115 referrer, 18116 snapshot, 18117 snapshotHTML, 18118 response, 18119 visitCachedSnapshot, 18120 willRender, 18121 updateHistory, 18122 shouldCacheSnapshot, 18123 acceptsStreamResponse, 18124 direction, 18125 refresh 18126 } = { 18127 ...defaultOptions, 18128 ...options 18129 }; 18130 this.action = action; 18131 this.historyChanged = historyChanged; 18132 this.referrer = referrer; 18133 this.snapshot = snapshot; 18134 this.snapshotHTML = snapshotHTML; 18135 this.response = response; 18136 this.isPageRefresh = this.view.isPageRefresh(this); 18137 this.visitCachedSnapshot = visitCachedSnapshot; 18138 this.willRender = willRender; 18139 this.updateHistory = updateHistory; 18140 this.scrolled = !willRender; 18141 this.shouldCacheSnapshot = shouldCacheSnapshot; 18142 this.acceptsStreamResponse = acceptsStreamResponse; 18143 this.direction = direction || Direction[action]; 18144 this.refresh = refresh; 18145 } 18146 get adapter() { 18147 return this.delegate.adapter; 18148 } 18149 get view() { 18150 return this.delegate.view; 18151 } 18152 get history() { 18153 return this.delegate.history; 18154 } 18155 get restorationData() { 18156 return this.history.getRestorationDataForIdentifier(this.restorationIdentifier); 18157 } 18158 start() { 18159 if (this.state == VisitState.initialized) { 18160 this.recordTimingMetric(TimingMetric.visitStart); 18161 this.state = VisitState.started; 18162 this.adapter.visitStarted(this); 18163 this.delegate.visitStarted(this); 18164 } 18165 } 18166 cancel() { 18167 if (this.state == VisitState.started) { 18168 if (this.request) { 18169 this.request.cancel(); 18170 } 18171 this.cancelRender(); 18172 this.state = VisitState.canceled; 18173 } 18174 } 18175 complete() { 18176 if (this.state == VisitState.started) { 18177 this.recordTimingMetric(TimingMetric.visitEnd); 18178 this.adapter.visitCompleted(this); 18179 this.state = VisitState.completed; 18180 this.followRedirect(); 18181 if (!this.followedRedirect) { 18182 this.delegate.visitCompleted(this); 18183 } 18184 } 18185 } 18186 fail() { 18187 if (this.state == VisitState.started) { 18188 this.state = VisitState.failed; 18189 this.adapter.visitFailed(this); 18190 this.delegate.visitCompleted(this); 18191 } 18192 } 18193 changeHistory() { 18194 if (!this.historyChanged && this.updateHistory) { 18195 const actionForHistory = this.location.href === this.referrer?.href ? "replace" : this.action; 18196 const method = getHistoryMethodForAction(actionForHistory); 18197 this.history.update(method, this.location, this.restorationIdentifier); 18198 this.historyChanged = true; 18199 } 18200 } 18201 issueRequest() { 18202 if (this.hasPreloadedResponse()) { 18203 this.simulateRequest(); 18204 } else if (this.shouldIssueRequest() && !this.request) { 18205 this.request = new FetchRequest(this, FetchMethod.get, this.location); 18206 this.request.perform(); 18207 } 18208 } 18209 simulateRequest() { 18210 if (this.response) { 18211 this.startRequest(); 18212 this.recordResponse(); 18213 this.finishRequest(); 18214 } 18215 } 18216 startRequest() { 18217 this.recordTimingMetric(TimingMetric.requestStart); 18218 this.adapter.visitRequestStarted(this); 18219 } 18220 recordResponse(response = this.response) { 18221 this.response = response; 18222 if (response) { 18223 const { statusCode } = response; 18224 if (isSuccessful(statusCode)) { 18225 this.adapter.visitRequestCompleted(this); 18226 } else { 18227 this.adapter.visitRequestFailedWithStatusCode(this, statusCode); 18228 } 18229 } 18230 } 18231 finishRequest() { 18232 this.recordTimingMetric(TimingMetric.requestEnd); 18233 this.adapter.visitRequestFinished(this); 18234 } 18235 loadResponse() { 18236 if (this.response) { 18237 const { statusCode, responseHTML } = this.response; 18238 this.render(async () => { 18239 if (this.shouldCacheSnapshot) this.cacheSnapshot(); 18240 if (this.view.renderPromise) await this.view.renderPromise; 18241 if (isSuccessful(statusCode) && responseHTML != null) { 18242 const snapshot = PageSnapshot.fromHTMLString(responseHTML); 18243 await this.renderPageSnapshot(snapshot, false); 18244 this.adapter.visitRendered(this); 18245 this.complete(); 18246 } else { 18247 await this.view.renderError(PageSnapshot.fromHTMLString(responseHTML), this); 18248 this.adapter.visitRendered(this); 18249 this.fail(); 18250 } 18251 }); 18252 } 18253 } 18254 getCachedSnapshot() { 18255 const snapshot = this.view.getCachedSnapshotForLocation(this.location) || this.getPreloadedSnapshot(); 18256 if (snapshot && (!getAnchor(this.location) || snapshot.hasAnchor(getAnchor(this.location)))) { 18257 if (this.action == "restore" || snapshot.isPreviewable) { 18258 return snapshot; 18259 } 18260 } 18261 } 18262 getPreloadedSnapshot() { 18263 if (this.snapshotHTML) { 18264 return PageSnapshot.fromHTMLString(this.snapshotHTML); 18265 } 18266 } 18267 hasCachedSnapshot() { 18268 return this.getCachedSnapshot() != null; 18269 } 18270 loadCachedSnapshot() { 18271 const snapshot = this.getCachedSnapshot(); 18272 if (snapshot) { 18273 const isPreview = this.shouldIssueRequest(); 18274 this.render(async () => { 18275 this.cacheSnapshot(); 18276 if (this.isPageRefresh) { 18277 this.adapter.visitRendered(this); 18278 } else { 18279 if (this.view.renderPromise) await this.view.renderPromise; 18280 await this.renderPageSnapshot(snapshot, isPreview); 18281 this.adapter.visitRendered(this); 18282 if (!isPreview) { 18283 this.complete(); 18284 } 18285 } 18286 }); 18287 } 18288 } 18289 followRedirect() { 18290 if (this.redirectedToLocation && !this.followedRedirect && this.response?.redirected) { 18291 this.adapter.visitProposedToLocation(this.redirectedToLocation, { 18292 action: "replace", 18293 response: this.response, 18294 shouldCacheSnapshot: false, 18295 willRender: false 18296 }); 18297 this.followedRedirect = true; 18298 } 18299 } 18300 // Fetch request delegate 18301 prepareRequest(request) { 18302 if (this.acceptsStreamResponse) { 18303 request.acceptResponseType(StreamMessage.contentType); 18304 } 18305 } 18306 requestStarted() { 18307 this.startRequest(); 18308 } 18309 requestPreventedHandlingResponse(_request, _response) { 18310 } 18311 async requestSucceededWithResponse(request, response) { 18312 const responseHTML = await response.responseHTML; 18313 const { redirected, statusCode } = response; 18314 if (responseHTML == void 0) { 18315 this.recordResponse({ 18316 statusCode: SystemStatusCode.contentTypeMismatch, 18317 redirected 18318 }); 18319 } else { 18320 this.redirectedToLocation = response.redirected ? response.location : void 0; 18321 this.recordResponse({ statusCode, responseHTML, redirected }); 18322 } 18323 } 18324 async requestFailedWithResponse(request, response) { 18325 const responseHTML = await response.responseHTML; 18326 const { redirected, statusCode } = response; 18327 if (responseHTML == void 0) { 18328 this.recordResponse({ 18329 statusCode: SystemStatusCode.contentTypeMismatch, 18330 redirected 18331 }); 18332 } else { 18333 this.recordResponse({ statusCode, responseHTML, redirected }); 18334 } 18335 } 18336 requestErrored(_request, _error) { 18337 this.recordResponse({ 18338 statusCode: SystemStatusCode.networkFailure, 18339 redirected: false 18340 }); 18341 } 18342 requestFinished() { 18343 this.finishRequest(); 18344 } 18345 // Scrolling 18346 performScroll() { 18347 if (!this.scrolled && !this.view.forceReloaded && !this.view.shouldPreserveScrollPosition(this)) { 18348 if (this.action == "restore") { 18349 this.scrollToRestoredPosition() || this.scrollToAnchor() || this.view.scrollToTop(); 18350 } else { 18351 this.scrollToAnchor() || this.view.scrollToTop(); 18352 } 18353 this.scrolled = true; 18354 } 18355 } 18356 scrollToRestoredPosition() { 18357 const { scrollPosition } = this.restorationData; 18358 if (scrollPosition) { 18359 this.view.scrollToPosition(scrollPosition); 18360 return true; 18361 } 18362 } 18363 scrollToAnchor() { 18364 const anchor = getAnchor(this.location); 18365 if (anchor != null) { 18366 this.view.scrollToAnchor(anchor); 18367 return true; 18368 } 18369 } 18370 // Instrumentation 18371 recordTimingMetric(metric) { 18372 this.timingMetrics[metric] = (/* @__PURE__ */ new Date()).getTime(); 18373 } 18374 getTimingMetrics() { 18375 return { ...this.timingMetrics }; 18376 } 18377 // Private 18378 hasPreloadedResponse() { 18379 return typeof this.response == "object"; 18380 } 18381 shouldIssueRequest() { 18382 if (this.action == "restore") { 18383 return !this.hasCachedSnapshot(); 18384 } else { 18385 return this.willRender; 18386 } 18387 } 18388 cacheSnapshot() { 18389 if (!this.snapshotCached) { 18390 this.view.cacheSnapshot(this.snapshot).then((snapshot) => snapshot && this.visitCachedSnapshot(snapshot)); 18391 this.snapshotCached = true; 18392 } 18393 } 18394 async render(callback) { 18395 this.cancelRender(); 18396 await new Promise((resolve) => { 18397 this.frame = document.visibilityState === "hidden" ? setTimeout(() => resolve(), 0) : requestAnimationFrame(() => resolve()); 18398 }); 18399 await callback(); 18400 delete this.frame; 18401 } 18402 async renderPageSnapshot(snapshot, isPreview) { 18403 await this.viewTransitioner.renderChange(this.view.shouldTransitionTo(snapshot), async () => { 18404 await this.view.renderPage(snapshot, isPreview, this.willRender, this); 18405 this.performScroll(); 18406 }); 18407 } 18408 cancelRender() { 18409 if (this.frame) { 18410 cancelAnimationFrame(this.frame); 18411 delete this.frame; 18412 } 18413 } 18414 }; 18415 function isSuccessful(statusCode) { 18416 return statusCode >= 200 && statusCode < 300; 18417 } 18418 var BrowserAdapter = class { 18419 progressBar = new ProgressBar(); 18420 constructor(session2) { 18421 this.session = session2; 18422 } 18423 visitProposedToLocation(location2, options) { 18424 if (locationIsVisitable(location2, this.navigator.rootLocation)) { 18425 this.navigator.startVisit(location2, options?.restorationIdentifier || uuid(), options); 18426 } else { 18427 window.location.href = location2.toString(); 18428 } 18429 } 18430 visitStarted(visit2) { 18431 this.location = visit2.location; 18432 this.redirectedToLocation = null; 18433 visit2.loadCachedSnapshot(); 18434 visit2.issueRequest(); 18435 } 18436 visitRequestStarted(visit2) { 18437 this.progressBar.setValue(0); 18438 if (visit2.hasCachedSnapshot() || visit2.action != "restore") { 18439 this.showVisitProgressBarAfterDelay(); 18440 } else { 18441 this.showProgressBar(); 18442 } 18443 } 18444 visitRequestCompleted(visit2) { 18445 visit2.loadResponse(); 18446 if (visit2.response.redirected) { 18447 this.redirectedToLocation = visit2.redirectedToLocation; 18448 } 18449 } 18450 visitRequestFailedWithStatusCode(visit2, statusCode) { 18451 switch (statusCode) { 18452 case SystemStatusCode.networkFailure: 18453 case SystemStatusCode.timeoutFailure: 18454 case SystemStatusCode.contentTypeMismatch: 18455 return this.reload({ 18456 reason: "request_failed", 18457 context: { 18458 statusCode 18459 } 18460 }); 18461 default: 18462 return visit2.loadResponse(); 18463 } 18464 } 18465 visitRequestFinished(_visit) { 18466 } 18467 visitCompleted(_visit) { 18468 this.progressBar.setValue(1); 18469 this.hideVisitProgressBar(); 18470 } 18471 pageInvalidated(reason) { 18472 this.reload(reason); 18473 } 18474 visitFailed(_visit) { 18475 this.progressBar.setValue(1); 18476 this.hideVisitProgressBar(); 18477 } 18478 visitRendered(_visit) { 18479 } 18480 // Link prefetching 18481 linkPrefetchingIsEnabledForLocation(location2) { 18482 return true; 18483 } 18484 // Form Submission Delegate 18485 formSubmissionStarted(_formSubmission) { 18486 this.progressBar.setValue(0); 18487 this.showFormProgressBarAfterDelay(); 18488 } 18489 formSubmissionFinished(_formSubmission) { 18490 this.progressBar.setValue(1); 18491 this.hideFormProgressBar(); 18492 } 18493 // Private 18494 showVisitProgressBarAfterDelay() { 18495 this.visitProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay); 18496 } 18497 hideVisitProgressBar() { 18498 this.progressBar.hide(); 18499 if (this.visitProgressBarTimeout != null) { 18500 window.clearTimeout(this.visitProgressBarTimeout); 18501 delete this.visitProgressBarTimeout; 18502 } 18503 } 18504 showFormProgressBarAfterDelay() { 18505 if (this.formProgressBarTimeout == null) { 18506 this.formProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay); 18507 } 18508 } 18509 hideFormProgressBar() { 18510 this.progressBar.hide(); 18511 if (this.formProgressBarTimeout != null) { 18512 window.clearTimeout(this.formProgressBarTimeout); 18513 delete this.formProgressBarTimeout; 18514 } 18515 } 18516 showProgressBar = () => { 18517 this.progressBar.show(); 18518 }; 18519 reload(reason) { 18520 dispatch("turbo:reload", { detail: reason }); 18521 window.location.href = (this.redirectedToLocation || this.location)?.toString() || window.location.href; 18522 } 18523 get navigator() { 18524 return this.session.navigator; 18525 } 18526 }; 18527 var CacheObserver = class { 18528 selector = "[data-turbo-temporary]"; 18529 started = false; 18530 start() { 18531 if (!this.started) { 18532 this.started = true; 18533 addEventListener("turbo:before-cache", this.removeTemporaryElements, false); 18534 } 18535 } 18536 stop() { 18537 if (this.started) { 18538 this.started = false; 18539 removeEventListener("turbo:before-cache", this.removeTemporaryElements, false); 18540 } 18541 } 18542 removeTemporaryElements = (_event) => { 18543 for (const element of this.temporaryElements) { 18544 element.remove(); 18545 } 18546 }; 18547 get temporaryElements() { 18548 return [...document.querySelectorAll(this.selector)]; 18549 } 18550 }; 18551 var FrameRedirector = class { 18552 constructor(session2, element) { 18553 this.session = session2; 18554 this.element = element; 18555 this.linkInterceptor = new LinkInterceptor(this, element); 18556 this.formSubmitObserver = new FormSubmitObserver(this, element); 18557 } 18558 start() { 18559 this.linkInterceptor.start(); 18560 this.formSubmitObserver.start(); 18561 } 18562 stop() { 18563 this.linkInterceptor.stop(); 18564 this.formSubmitObserver.stop(); 18565 } 18566 // Link interceptor delegate 18567 shouldInterceptLinkClick(element, _location, _event) { 18568 return this.#shouldRedirect(element); 18569 } 18570 linkClickIntercepted(element, url, event) { 18571 const frame = this.#findFrameElement(element); 18572 if (frame) { 18573 frame.delegate.linkClickIntercepted(element, url, event); 18574 } 18575 } 18576 // Form submit observer delegate 18577 willSubmitForm(element, submitter2) { 18578 return element.closest("turbo-frame") == null && this.#shouldSubmit(element, submitter2) && this.#shouldRedirect(element, submitter2); 18579 } 18580 formSubmitted(element, submitter2) { 18581 const frame = this.#findFrameElement(element, submitter2); 18582 if (frame) { 18583 frame.delegate.formSubmitted(element, submitter2); 18584 } 18585 } 18586 #shouldSubmit(form, submitter2) { 18587 const action = getAction$1(form, submitter2); 18588 const meta = this.element.ownerDocument.querySelector(`meta[name="turbo-root"]`); 18589 const rootLocation = expandURL(meta?.content ?? "/"); 18590 return this.#shouldRedirect(form, submitter2) && locationIsVisitable(action, rootLocation); 18591 } 18592 #shouldRedirect(element, submitter2) { 18593 const isNavigatable = element instanceof HTMLFormElement ? this.session.submissionIsNavigatable(element, submitter2) : this.session.elementIsNavigatable(element); 18594 if (isNavigatable) { 18595 const frame = this.#findFrameElement(element, submitter2); 18596 return frame ? frame != element.closest("turbo-frame") : false; 18597 } else { 18598 return false; 18599 } 18600 } 18601 #findFrameElement(element, submitter2) { 18602 const id = submitter2?.getAttribute("data-turbo-frame") || element.getAttribute("data-turbo-frame"); 18603 if (id && id != "_top") { 18604 const frame = this.element.querySelector(`#${id}:not([disabled])`); 18605 if (frame instanceof FrameElement) { 18606 return frame; 18607 } 18608 } 18609 } 18610 }; 18611 var History = class { 18612 location; 18613 restorationIdentifier = uuid(); 18614 restorationData = {}; 18615 started = false; 18616 currentIndex = 0; 18617 constructor(delegate2) { 18618 this.delegate = delegate2; 18619 } 18620 start() { 18621 if (!this.started) { 18622 addEventListener("popstate", this.onPopState, false); 18623 this.currentIndex = history.state?.turbo?.restorationIndex || 0; 18624 this.started = true; 18625 this.replace(new URL(window.location.href)); 18626 } 18627 } 18628 stop() { 18629 if (this.started) { 18630 removeEventListener("popstate", this.onPopState, false); 18631 this.started = false; 18632 } 18633 } 18634 push(location2, restorationIdentifier) { 18635 this.update(history.pushState, location2, restorationIdentifier); 18636 } 18637 replace(location2, restorationIdentifier) { 18638 this.update(history.replaceState, location2, restorationIdentifier); 18639 } 18640 update(method, location2, restorationIdentifier = uuid()) { 18641 if (method === history.pushState) ++this.currentIndex; 18642 const state = { turbo: { restorationIdentifier, restorationIndex: this.currentIndex } }; 18643 method.call(history, state, "", location2.href); 18644 this.location = location2; 18645 this.restorationIdentifier = restorationIdentifier; 18646 } 18647 // Restoration data 18648 getRestorationDataForIdentifier(restorationIdentifier) { 18649 return this.restorationData[restorationIdentifier] || {}; 18650 } 18651 updateRestorationData(additionalData) { 18652 const { restorationIdentifier } = this; 18653 const restorationData = this.restorationData[restorationIdentifier]; 18654 this.restorationData[restorationIdentifier] = { 18655 ...restorationData, 18656 ...additionalData 18657 }; 18658 } 18659 // Scroll restoration 18660 assumeControlOfScrollRestoration() { 18661 if (!this.previousScrollRestoration) { 18662 this.previousScrollRestoration = history.scrollRestoration ?? "auto"; 18663 history.scrollRestoration = "manual"; 18664 } 18665 } 18666 relinquishControlOfScrollRestoration() { 18667 if (this.previousScrollRestoration) { 18668 history.scrollRestoration = this.previousScrollRestoration; 18669 delete this.previousScrollRestoration; 18670 } 18671 } 18672 // Event handlers 18673 onPopState = (event) => { 18674 const { turbo } = event.state || {}; 18675 this.location = new URL(window.location.href); 18676 if (turbo) { 18677 const { restorationIdentifier, restorationIndex } = turbo; 18678 this.restorationIdentifier = restorationIdentifier; 18679 const direction = restorationIndex > this.currentIndex ? "forward" : "back"; 18680 this.delegate.historyPoppedToLocationWithRestorationIdentifierAndDirection(this.location, restorationIdentifier, direction); 18681 this.currentIndex = restorationIndex; 18682 } else { 18683 this.currentIndex++; 18684 this.delegate.historyPoppedWithEmptyState(this.location); 18685 } 18686 }; 18687 }; 18688 var LinkPrefetchObserver = class { 18689 started = false; 18690 #prefetchedLink = null; 18691 constructor(delegate2, eventTarget) { 18692 this.delegate = delegate2; 18693 this.eventTarget = eventTarget; 18694 } 18695 start() { 18696 if (this.started) return; 18697 if (this.eventTarget.readyState === "loading") { 18698 this.eventTarget.addEventListener("DOMContentLoaded", this.#enable, { once: true }); 18699 } else { 18700 this.#enable(); 18701 } 18702 } 18703 stop() { 18704 if (!this.started) return; 18705 this.eventTarget.removeEventListener("mouseenter", this.#tryToPrefetchRequest, { 18706 capture: true, 18707 passive: true 18708 }); 18709 this.eventTarget.removeEventListener("mouseleave", this.#cancelRequestIfObsolete, { 18710 capture: true, 18711 passive: true 18712 }); 18713 this.eventTarget.removeEventListener("turbo:before-fetch-request", this.#tryToUsePrefetchedRequest, true); 18714 this.started = false; 18715 } 18716 #enable = () => { 18717 this.eventTarget.addEventListener("mouseenter", this.#tryToPrefetchRequest, { 18718 capture: true, 18719 passive: true 18720 }); 18721 this.eventTarget.addEventListener("mouseleave", this.#cancelRequestIfObsolete, { 18722 capture: true, 18723 passive: true 18724 }); 18725 this.eventTarget.addEventListener("turbo:before-fetch-request", this.#tryToUsePrefetchedRequest, true); 18726 this.started = true; 18727 }; 18728 #tryToPrefetchRequest = (event) => { 18729 if (getMetaContent("turbo-prefetch") === "false") return; 18730 const target = event.target; 18731 const isLink = target.matches && target.matches("a[href]:not([target^=_]):not([download])"); 18732 if (isLink && this.#isPrefetchable(target)) { 18733 const link = target; 18734 const location2 = getLocationForLink(link); 18735 if (this.delegate.canPrefetchRequestToLocation(link, location2)) { 18736 this.#prefetchedLink = link; 18737 const fetchRequest = new FetchRequest( 18738 this, 18739 FetchMethod.get, 18740 location2, 18741 new URLSearchParams(), 18742 target 18743 ); 18744 fetchRequest.fetchOptions.priority = "low"; 18745 prefetchCache.putLater(location2, fetchRequest, this.#cacheTtl); 18746 } 18747 } 18748 }; 18749 #cancelRequestIfObsolete = (event) => { 18750 if (event.target === this.#prefetchedLink) this.#cancelPrefetchRequest(); 18751 }; 18752 #cancelPrefetchRequest = () => { 18753 prefetchCache.clear(); 18754 this.#prefetchedLink = null; 18755 }; 18756 #tryToUsePrefetchedRequest = (event) => { 18757 if (event.target.tagName !== "FORM" && event.detail.fetchOptions.method === "GET") { 18758 const cached = prefetchCache.get(event.detail.url); 18759 if (cached) { 18760 event.detail.fetchRequest = cached; 18761 } 18762 prefetchCache.clear(); 18763 } 18764 }; 18765 prepareRequest(request) { 18766 const link = request.target; 18767 request.headers["X-Sec-Purpose"] = "prefetch"; 18768 const turboFrame = link.closest("turbo-frame"); 18769 const turboFrameTarget = link.getAttribute("data-turbo-frame") || turboFrame?.getAttribute("target") || turboFrame?.id; 18770 if (turboFrameTarget && turboFrameTarget !== "_top") { 18771 request.headers["Turbo-Frame"] = turboFrameTarget; 18772 } 18773 } 18774 // Fetch request interface 18775 requestSucceededWithResponse() { 18776 } 18777 requestStarted(fetchRequest) { 18778 } 18779 requestErrored(fetchRequest) { 18780 } 18781 requestFinished(fetchRequest) { 18782 } 18783 requestPreventedHandlingResponse(fetchRequest, fetchResponse) { 18784 } 18785 requestFailedWithResponse(fetchRequest, fetchResponse) { 18786 } 18787 get #cacheTtl() { 18788 return Number(getMetaContent("turbo-prefetch-cache-time")) || cacheTtl; 18789 } 18790 #isPrefetchable(link) { 18791 const href2 = link.getAttribute("href"); 18792 if (!href2) return false; 18793 if (unfetchableLink(link)) return false; 18794 if (linkToTheSamePage(link)) return false; 18795 if (linkOptsOut(link)) return false; 18796 if (nonSafeLink(link)) return false; 18797 if (eventPrevented(link)) return false; 18798 return true; 18799 } 18800 }; 18801 var unfetchableLink = (link) => { 18802 return link.origin !== document.location.origin || !["http:", "https:"].includes(link.protocol) || link.hasAttribute("target"); 18803 }; 18804 var linkToTheSamePage = (link) => { 18805 return link.pathname + link.search === document.location.pathname + document.location.search || link.href.startsWith("#"); 18806 }; 18807 var linkOptsOut = (link) => { 18808 if (link.getAttribute("data-turbo-prefetch") === "false") return true; 18809 if (link.getAttribute("data-turbo") === "false") return true; 18810 const turboPrefetchParent = findClosestRecursively(link, "[data-turbo-prefetch]"); 18811 if (turboPrefetchParent && turboPrefetchParent.getAttribute("data-turbo-prefetch") === "false") return true; 18812 return false; 18813 }; 18814 var nonSafeLink = (link) => { 18815 const turboMethod = link.getAttribute("data-turbo-method"); 18816 if (turboMethod && turboMethod.toLowerCase() !== "get") return true; 18817 if (isUJS(link)) return true; 18818 if (link.hasAttribute("data-turbo-confirm")) return true; 18819 if (link.hasAttribute("data-turbo-stream")) return true; 18820 return false; 18821 }; 18822 var isUJS = (link) => { 18823 return link.hasAttribute("data-remote") || link.hasAttribute("data-behavior") || link.hasAttribute("data-confirm") || link.hasAttribute("data-method"); 18824 }; 18825 var eventPrevented = (link) => { 18826 const event = dispatch("turbo:before-prefetch", { target: link, cancelable: true }); 18827 return event.defaultPrevented; 18828 }; 18829 var Navigator = class { 18830 constructor(delegate2) { 18831 this.delegate = delegate2; 18832 } 18833 proposeVisit(location2, options = {}) { 18834 if (this.delegate.allowsVisitingLocationWithAction(location2, options.action)) { 18835 this.delegate.visitProposedToLocation(location2, options); 18836 } 18837 } 18838 startVisit(locatable, restorationIdentifier, options = {}) { 18839 this.stop(); 18840 this.currentVisit = new Visit(this, expandURL(locatable), restorationIdentifier, { 18841 referrer: this.location, 18842 ...options 18843 }); 18844 this.currentVisit.start(); 18845 } 18846 submitForm(form, submitter2) { 18847 this.stop(); 18848 this.formSubmission = new FormSubmission(this, form, submitter2, true); 18849 this.formSubmission.start(); 18850 } 18851 stop() { 18852 if (this.formSubmission) { 18853 this.formSubmission.stop(); 18854 delete this.formSubmission; 18855 } 18856 if (this.currentVisit) { 18857 this.currentVisit.cancel(); 18858 delete this.currentVisit; 18859 } 18860 } 18861 get adapter() { 18862 return this.delegate.adapter; 18863 } 18864 get view() { 18865 return this.delegate.view; 18866 } 18867 get rootLocation() { 18868 return this.view.snapshot.rootLocation; 18869 } 18870 get history() { 18871 return this.delegate.history; 18872 } 18873 // Form submission delegate 18874 formSubmissionStarted(formSubmission) { 18875 if (typeof this.adapter.formSubmissionStarted === "function") { 18876 this.adapter.formSubmissionStarted(formSubmission); 18877 } 18878 } 18879 async formSubmissionSucceededWithResponse(formSubmission, fetchResponse) { 18880 if (formSubmission == this.formSubmission) { 18881 const responseHTML = await fetchResponse.responseHTML; 18882 if (responseHTML) { 18883 const shouldCacheSnapshot = formSubmission.isSafe; 18884 if (!shouldCacheSnapshot) { 18885 this.view.clearSnapshotCache(); 18886 } 18887 const { statusCode, redirected } = fetchResponse; 18888 const action = this.#getActionForFormSubmission(formSubmission, fetchResponse); 18889 const visitOptions = { 18890 action, 18891 shouldCacheSnapshot, 18892 response: { statusCode, responseHTML, redirected } 18893 }; 18894 this.proposeVisit(fetchResponse.location, visitOptions); 18895 } 18896 } 18897 } 18898 async formSubmissionFailedWithResponse(formSubmission, fetchResponse) { 18899 const responseHTML = await fetchResponse.responseHTML; 18900 if (responseHTML) { 18901 const snapshot = PageSnapshot.fromHTMLString(responseHTML); 18902 if (fetchResponse.serverError) { 18903 await this.view.renderError(snapshot, this.currentVisit); 18904 } else { 18905 await this.view.renderPage(snapshot, false, true, this.currentVisit); 18906 } 18907 if (snapshot.refreshScroll !== "preserve") { 18908 this.view.scrollToTop(); 18909 } 18910 this.view.clearSnapshotCache(); 18911 } 18912 } 18913 formSubmissionErrored(formSubmission, error2) { 18914 console.error(error2); 18915 } 18916 formSubmissionFinished(formSubmission) { 18917 if (typeof this.adapter.formSubmissionFinished === "function") { 18918 this.adapter.formSubmissionFinished(formSubmission); 18919 } 18920 } 18921 // Link prefetching 18922 linkPrefetchingIsEnabledForLocation(location2) { 18923 if (typeof this.adapter.linkPrefetchingIsEnabledForLocation === "function") { 18924 return this.adapter.linkPrefetchingIsEnabledForLocation(location2); 18925 } 18926 return true; 18927 } 18928 // Visit delegate 18929 visitStarted(visit2) { 18930 this.delegate.visitStarted(visit2); 18931 } 18932 visitCompleted(visit2) { 18933 this.delegate.visitCompleted(visit2); 18934 delete this.currentVisit; 18935 } 18936 // Same-page links are no longer handled with a Visit. 18937 // This method is still needed for Turbo Native adapters. 18938 locationWithActionIsSamePage(location2, action) { 18939 return false; 18940 } 18941 // Visits 18942 get location() { 18943 return this.history.location; 18944 } 18945 get restorationIdentifier() { 18946 return this.history.restorationIdentifier; 18947 } 18948 #getActionForFormSubmission(formSubmission, fetchResponse) { 18949 const { submitter: submitter2, formElement } = formSubmission; 18950 return getVisitAction(submitter2, formElement) || this.#getDefaultAction(fetchResponse); 18951 } 18952 #getDefaultAction(fetchResponse) { 18953 const sameLocationRedirect = fetchResponse.redirected && fetchResponse.location.href === this.location?.href; 18954 return sameLocationRedirect ? "replace" : "advance"; 18955 } 18956 }; 18957 var PageStage = { 18958 initial: 0, 18959 loading: 1, 18960 interactive: 2, 18961 complete: 3 18962 }; 18963 var PageObserver = class { 18964 stage = PageStage.initial; 18965 started = false; 18966 constructor(delegate2) { 18967 this.delegate = delegate2; 18968 } 18969 start() { 18970 if (!this.started) { 18971 if (this.stage == PageStage.initial) { 18972 this.stage = PageStage.loading; 18973 } 18974 document.addEventListener("readystatechange", this.interpretReadyState, false); 18975 addEventListener("pagehide", this.pageWillUnload, false); 18976 this.started = true; 18977 } 18978 } 18979 stop() { 18980 if (this.started) { 18981 document.removeEventListener("readystatechange", this.interpretReadyState, false); 18982 removeEventListener("pagehide", this.pageWillUnload, false); 18983 this.started = false; 18984 } 18985 } 18986 interpretReadyState = () => { 18987 const { readyState } = this; 18988 if (readyState == "interactive") { 18989 this.pageIsInteractive(); 18990 } else if (readyState == "complete") { 18991 this.pageIsComplete(); 18992 } 18993 }; 18994 pageIsInteractive() { 18995 if (this.stage == PageStage.loading) { 18996 this.stage = PageStage.interactive; 18997 this.delegate.pageBecameInteractive(); 18998 } 18999 } 19000 pageIsComplete() { 19001 this.pageIsInteractive(); 19002 if (this.stage == PageStage.interactive) { 19003 this.stage = PageStage.complete; 19004 this.delegate.pageLoaded(); 19005 } 19006 } 19007 pageWillUnload = () => { 19008 this.delegate.pageWillUnload(); 19009 }; 19010 get readyState() { 19011 return document.readyState; 19012 } 19013 }; 19014 var ScrollObserver = class { 19015 started = false; 19016 constructor(delegate2) { 19017 this.delegate = delegate2; 19018 } 19019 start() { 19020 if (!this.started) { 19021 addEventListener("scroll", this.onScroll, false); 19022 this.onScroll(); 19023 this.started = true; 19024 } 19025 } 19026 stop() { 19027 if (this.started) { 19028 removeEventListener("scroll", this.onScroll, false); 19029 this.started = false; 19030 } 19031 } 19032 onScroll = () => { 19033 this.updatePosition({ x: window.pageXOffset, y: window.pageYOffset }); 19034 }; 19035 // Private 19036 updatePosition(position) { 19037 this.delegate.scrollPositionChanged(position); 19038 } 19039 }; 19040 var StreamMessageRenderer = class { 19041 render({ fragment }) { 19042 Bardo.preservingPermanentElements(this, getPermanentElementMapForFragment(fragment), () => { 19043 withAutofocusFromFragment(fragment, () => { 19044 withPreservedFocus(() => { 19045 document.documentElement.appendChild(fragment); 19046 }); 19047 }); 19048 }); 19049 } 19050 // Bardo delegate 19051 enteringBardo(currentPermanentElement, newPermanentElement) { 19052 newPermanentElement.replaceWith(currentPermanentElement.cloneNode(true)); 19053 } 19054 leavingBardo() { 19055 } 19056 }; 19057 function getPermanentElementMapForFragment(fragment) { 19058 const permanentElementsInDocument = queryPermanentElementsAll(document.documentElement); 19059 const permanentElementMap = {}; 19060 for (const permanentElementInDocument of permanentElementsInDocument) { 19061 const { id } = permanentElementInDocument; 19062 for (const streamElement of fragment.querySelectorAll("turbo-stream")) { 19063 const elementInStream = getPermanentElementById(streamElement.templateElement.content, id); 19064 if (elementInStream) { 19065 permanentElementMap[id] = [permanentElementInDocument, elementInStream]; 19066 } 19067 } 19068 } 19069 return permanentElementMap; 19070 } 19071 async function withAutofocusFromFragment(fragment, callback) { 19072 const generatedID = `turbo-stream-autofocus-${uuid()}`; 19073 const turboStreams = fragment.querySelectorAll("turbo-stream"); 19074 const elementWithAutofocus = firstAutofocusableElementInStreams(turboStreams); 19075 let willAutofocusId = null; 19076 if (elementWithAutofocus) { 19077 if (elementWithAutofocus.id) { 19078 willAutofocusId = elementWithAutofocus.id; 19079 } else { 19080 willAutofocusId = generatedID; 19081 } 19082 elementWithAutofocus.id = willAutofocusId; 19083 } 19084 callback(); 19085 await nextRepaint(); 19086 const hasNoActiveElement = document.activeElement == null || document.activeElement == document.body; 19087 if (hasNoActiveElement && willAutofocusId) { 19088 const elementToAutofocus = document.getElementById(willAutofocusId); 19089 if (elementIsFocusable(elementToAutofocus)) { 19090 elementToAutofocus.focus(); 19091 } 19092 if (elementToAutofocus && elementToAutofocus.id == generatedID) { 19093 elementToAutofocus.removeAttribute("id"); 19094 } 19095 } 19096 } 19097 async function withPreservedFocus(callback) { 19098 const [activeElementBeforeRender, activeElementAfterRender] = await around(callback, () => document.activeElement); 19099 const restoreFocusTo = activeElementBeforeRender && activeElementBeforeRender.id; 19100 if (restoreFocusTo) { 19101 const elementToFocus = document.getElementById(restoreFocusTo); 19102 if (elementIsFocusable(elementToFocus) && elementToFocus != activeElementAfterRender) { 19103 elementToFocus.focus(); 19104 } 19105 } 19106 } 19107 function firstAutofocusableElementInStreams(nodeListOfStreamElements) { 19108 for (const streamElement of nodeListOfStreamElements) { 19109 const elementWithAutofocus = queryAutofocusableElement(streamElement.templateElement.content); 19110 if (elementWithAutofocus) return elementWithAutofocus; 19111 } 19112 return null; 19113 } 19114 var StreamObserver = class { 19115 sources = /* @__PURE__ */ new Set(); 19116 #started = false; 19117 constructor(delegate2) { 19118 this.delegate = delegate2; 19119 } 19120 start() { 19121 if (!this.#started) { 19122 this.#started = true; 19123 addEventListener("turbo:before-fetch-response", this.inspectFetchResponse, false); 19124 } 19125 } 19126 stop() { 19127 if (this.#started) { 19128 this.#started = false; 19129 removeEventListener("turbo:before-fetch-response", this.inspectFetchResponse, false); 19130 } 19131 } 19132 connectStreamSource(source) { 19133 if (!this.streamSourceIsConnected(source)) { 19134 this.sources.add(source); 19135 source.addEventListener("message", this.receiveMessageEvent, false); 19136 } 19137 } 19138 disconnectStreamSource(source) { 19139 if (this.streamSourceIsConnected(source)) { 19140 this.sources.delete(source); 19141 source.removeEventListener("message", this.receiveMessageEvent, false); 19142 } 19143 } 19144 streamSourceIsConnected(source) { 19145 return this.sources.has(source); 19146 } 19147 inspectFetchResponse = (event) => { 19148 const response = fetchResponseFromEvent(event); 19149 if (response && fetchResponseIsStream(response)) { 19150 event.preventDefault(); 19151 this.receiveMessageResponse(response); 19152 } 19153 }; 19154 receiveMessageEvent = (event) => { 19155 if (this.#started && typeof event.data == "string") { 19156 this.receiveMessageHTML(event.data); 19157 } 19158 }; 19159 async receiveMessageResponse(response) { 19160 const html = await response.responseHTML; 19161 if (html) { 19162 this.receiveMessageHTML(html); 19163 } 19164 } 19165 receiveMessageHTML(html) { 19166 this.delegate.receivedMessageFromStream(StreamMessage.wrap(html)); 19167 } 19168 }; 19169 function fetchResponseFromEvent(event) { 19170 const fetchResponse = event.detail?.fetchResponse; 19171 if (fetchResponse instanceof FetchResponse) { 19172 return fetchResponse; 19173 } 19174 } 19175 function fetchResponseIsStream(response) { 19176 const contentType = response.contentType ?? ""; 19177 return contentType.startsWith(StreamMessage.contentType); 19178 } 19179 var ErrorRenderer = class extends Renderer { 19180 static renderElement(currentElement, newElement) { 19181 const { documentElement, body } = document; 19182 documentElement.replaceChild(newElement, body); 19183 } 19184 async render() { 19185 this.replaceHeadAndBody(); 19186 this.activateScriptElements(); 19187 } 19188 replaceHeadAndBody() { 19189 const { documentElement, head } = document; 19190 documentElement.replaceChild(this.newHead, head); 19191 this.renderElement(this.currentElement, this.newElement); 19192 } 19193 activateScriptElements() { 19194 for (const replaceableElement of this.scriptElements) { 19195 const parentNode = replaceableElement.parentNode; 19196 if (parentNode) { 19197 const element = activateScriptElement(replaceableElement); 19198 parentNode.replaceChild(element, replaceableElement); 19199 } 19200 } 19201 } 19202 get newHead() { 19203 return this.newSnapshot.headSnapshot.element; 19204 } 19205 get scriptElements() { 19206 return document.documentElement.querySelectorAll("script"); 19207 } 19208 }; 19209 var PageRenderer = class extends Renderer { 19210 static renderElement(currentElement, newElement) { 19211 if (document.body && newElement instanceof HTMLBodyElement) { 19212 document.body.replaceWith(newElement); 19213 } else { 19214 document.documentElement.appendChild(newElement); 19215 } 19216 } 19217 get shouldRender() { 19218 return this.newSnapshot.isVisitable && this.trackedElementsAreIdentical; 19219 } 19220 get reloadReason() { 19221 if (!this.newSnapshot.isVisitable) { 19222 return { 19223 reason: "turbo_visit_control_is_reload" 19224 }; 19225 } 19226 if (!this.trackedElementsAreIdentical) { 19227 return { 19228 reason: "tracked_element_mismatch" 19229 }; 19230 } 19231 } 19232 async prepareToRender() { 19233 this.#setLanguage(); 19234 await this.mergeHead(); 19235 } 19236 async render() { 19237 if (this.willRender) { 19238 await this.replaceBody(); 19239 } 19240 } 19241 finishRendering() { 19242 super.finishRendering(); 19243 if (!this.isPreview) { 19244 this.focusFirstAutofocusableElement(); 19245 } 19246 } 19247 get currentHeadSnapshot() { 19248 return this.currentSnapshot.headSnapshot; 19249 } 19250 get newHeadSnapshot() { 19251 return this.newSnapshot.headSnapshot; 19252 } 19253 get newElement() { 19254 return this.newSnapshot.element; 19255 } 19256 #setLanguage() { 19257 const { documentElement } = this.currentSnapshot; 19258 const { dir, lang } = this.newSnapshot; 19259 if (lang) { 19260 documentElement.setAttribute("lang", lang); 19261 } else { 19262 documentElement.removeAttribute("lang"); 19263 } 19264 if (dir) { 19265 documentElement.setAttribute("dir", dir); 19266 } else { 19267 documentElement.removeAttribute("dir"); 19268 } 19269 } 19270 async mergeHead() { 19271 const mergedHeadElements = this.mergeProvisionalElements(); 19272 const newStylesheetElements = this.copyNewHeadStylesheetElements(); 19273 this.copyNewHeadScriptElements(); 19274 await mergedHeadElements; 19275 await newStylesheetElements; 19276 if (this.willRender) { 19277 this.removeUnusedDynamicStylesheetElements(); 19278 } 19279 } 19280 async replaceBody() { 19281 await this.preservingPermanentElements(async () => { 19282 this.activateNewBody(); 19283 await this.assignNewBody(); 19284 }); 19285 } 19286 get trackedElementsAreIdentical() { 19287 return this.currentHeadSnapshot.trackedElementSignature == this.newHeadSnapshot.trackedElementSignature; 19288 } 19289 async copyNewHeadStylesheetElements() { 19290 const loadingElements = []; 19291 for (const element of this.newHeadStylesheetElements) { 19292 loadingElements.push(waitForLoad(element)); 19293 document.head.appendChild(element); 19294 } 19295 await Promise.all(loadingElements); 19296 } 19297 copyNewHeadScriptElements() { 19298 for (const element of this.newHeadScriptElements) { 19299 document.head.appendChild(activateScriptElement(element)); 19300 } 19301 } 19302 removeUnusedDynamicStylesheetElements() { 19303 for (const element of this.unusedDynamicStylesheetElements) { 19304 document.head.removeChild(element); 19305 } 19306 } 19307 async mergeProvisionalElements() { 19308 const newHeadElements = [...this.newHeadProvisionalElements]; 19309 for (const element of this.currentHeadProvisionalElements) { 19310 if (!this.isCurrentElementInElementList(element, newHeadElements)) { 19311 document.head.removeChild(element); 19312 } 19313 } 19314 for (const element of newHeadElements) { 19315 document.head.appendChild(element); 19316 } 19317 } 19318 isCurrentElementInElementList(element, elementList) { 19319 for (const [index, newElement] of elementList.entries()) { 19320 if (element.tagName == "TITLE") { 19321 if (newElement.tagName != "TITLE") { 19322 continue; 19323 } 19324 if (element.innerHTML == newElement.innerHTML) { 19325 elementList.splice(index, 1); 19326 return true; 19327 } 19328 } 19329 if (newElement.isEqualNode(element)) { 19330 elementList.splice(index, 1); 19331 return true; 19332 } 19333 } 19334 return false; 19335 } 19336 removeCurrentHeadProvisionalElements() { 19337 for (const element of this.currentHeadProvisionalElements) { 19338 document.head.removeChild(element); 19339 } 19340 } 19341 copyNewHeadProvisionalElements() { 19342 for (const element of this.newHeadProvisionalElements) { 19343 document.head.appendChild(element); 19344 } 19345 } 19346 activateNewBody() { 19347 document.adoptNode(this.newElement); 19348 this.removeNoscriptElements(); 19349 this.activateNewBodyScriptElements(); 19350 } 19351 removeNoscriptElements() { 19352 for (const noscriptElement of this.newElement.querySelectorAll("noscript")) { 19353 noscriptElement.remove(); 19354 } 19355 } 19356 activateNewBodyScriptElements() { 19357 for (const inertScriptElement of this.newBodyScriptElements) { 19358 const activatedScriptElement = activateScriptElement(inertScriptElement); 19359 inertScriptElement.replaceWith(activatedScriptElement); 19360 } 19361 } 19362 async assignNewBody() { 19363 await this.renderElement(this.currentElement, this.newElement); 19364 } 19365 get unusedDynamicStylesheetElements() { 19366 return this.oldHeadStylesheetElements.filter((element) => { 19367 return element.getAttribute("data-turbo-track") === "dynamic"; 19368 }); 19369 } 19370 get oldHeadStylesheetElements() { 19371 return this.currentHeadSnapshot.getStylesheetElementsNotInSnapshot(this.newHeadSnapshot); 19372 } 19373 get newHeadStylesheetElements() { 19374 return this.newHeadSnapshot.getStylesheetElementsNotInSnapshot(this.currentHeadSnapshot); 19375 } 19376 get newHeadScriptElements() { 19377 return this.newHeadSnapshot.getScriptElementsNotInSnapshot(this.currentHeadSnapshot); 19378 } 19379 get currentHeadProvisionalElements() { 19380 return this.currentHeadSnapshot.provisionalElements; 19381 } 19382 get newHeadProvisionalElements() { 19383 return this.newHeadSnapshot.provisionalElements; 19384 } 19385 get newBodyScriptElements() { 19386 return this.newElement.querySelectorAll("script"); 19387 } 19388 }; 19389 var MorphingPageRenderer = class extends PageRenderer { 19390 static renderElement(currentElement, newElement) { 19391 morphElements(currentElement, newElement, { 19392 callbacks: { 19393 beforeNodeMorphed: (node, newNode) => { 19394 if (shouldRefreshFrameWithMorphing(node, newNode) && !closestFrameReloadableWithMorphing(node)) { 19395 node.reload(); 19396 return false; 19397 } 19398 return true; 19399 } 19400 } 19401 }); 19402 dispatch("turbo:morph", { detail: { currentElement, newElement } }); 19403 } 19404 async preservingPermanentElements(callback) { 19405 return await callback(); 19406 } 19407 get renderMethod() { 19408 return "morph"; 19409 } 19410 get shouldAutofocus() { 19411 return false; 19412 } 19413 }; 19414 var SnapshotCache = class extends LRUCache { 19415 constructor(size) { 19416 super(size, toCacheKey); 19417 } 19418 get snapshots() { 19419 return this.entries; 19420 } 19421 }; 19422 var PageView = class extends View { 19423 snapshotCache = new SnapshotCache(10); 19424 lastRenderedLocation = new URL(location.href); 19425 forceReloaded = false; 19426 shouldTransitionTo(newSnapshot) { 19427 return this.snapshot.prefersViewTransitions && newSnapshot.prefersViewTransitions; 19428 } 19429 renderPage(snapshot, isPreview = false, willRender = true, visit2) { 19430 const shouldMorphPage = this.isPageRefresh(visit2) && (visit2?.refresh?.method || this.snapshot.refreshMethod) === "morph"; 19431 const rendererClass = shouldMorphPage ? MorphingPageRenderer : PageRenderer; 19432 const renderer = new rendererClass(this.snapshot, snapshot, isPreview, willRender); 19433 if (!renderer.shouldRender) { 19434 this.forceReloaded = true; 19435 } else { 19436 visit2?.changeHistory(); 19437 } 19438 return this.render(renderer); 19439 } 19440 renderError(snapshot, visit2) { 19441 visit2?.changeHistory(); 19442 const renderer = new ErrorRenderer(this.snapshot, snapshot, false); 19443 return this.render(renderer); 19444 } 19445 clearSnapshotCache() { 19446 this.snapshotCache.clear(); 19447 } 19448 async cacheSnapshot(snapshot = this.snapshot) { 19449 if (snapshot.isCacheable) { 19450 this.delegate.viewWillCacheSnapshot(); 19451 const { lastRenderedLocation: location2 } = this; 19452 await nextEventLoopTick(); 19453 const cachedSnapshot = snapshot.clone(); 19454 this.snapshotCache.put(location2, cachedSnapshot); 19455 return cachedSnapshot; 19456 } 19457 } 19458 getCachedSnapshotForLocation(location2) { 19459 return this.snapshotCache.get(location2); 19460 } 19461 isPageRefresh(visit2) { 19462 return !visit2 || this.lastRenderedLocation.pathname === visit2.location.pathname && visit2.action === "replace"; 19463 } 19464 shouldPreserveScrollPosition(visit2) { 19465 return this.isPageRefresh(visit2) && (visit2?.refresh?.scroll || this.snapshot.refreshScroll) === "preserve"; 19466 } 19467 get snapshot() { 19468 return PageSnapshot.fromElement(this.element); 19469 } 19470 }; 19471 var Preloader = class { 19472 selector = "a[data-turbo-preload]"; 19473 constructor(delegate2, snapshotCache) { 19474 this.delegate = delegate2; 19475 this.snapshotCache = snapshotCache; 19476 } 19477 start() { 19478 if (document.readyState === "loading") { 19479 document.addEventListener("DOMContentLoaded", this.#preloadAll); 19480 } else { 19481 this.preloadOnLoadLinksForView(document.body); 19482 } 19483 } 19484 stop() { 19485 document.removeEventListener("DOMContentLoaded", this.#preloadAll); 19486 } 19487 preloadOnLoadLinksForView(element) { 19488 for (const link of element.querySelectorAll(this.selector)) { 19489 if (this.delegate.shouldPreloadLink(link)) { 19490 this.preloadURL(link); 19491 } 19492 } 19493 } 19494 async preloadURL(link) { 19495 const location2 = new URL(link.href); 19496 if (this.snapshotCache.has(location2)) { 19497 return; 19498 } 19499 const fetchRequest = new FetchRequest(this, FetchMethod.get, location2, new URLSearchParams(), link); 19500 await fetchRequest.perform(); 19501 } 19502 // Fetch request delegate 19503 prepareRequest(fetchRequest) { 19504 fetchRequest.headers["X-Sec-Purpose"] = "prefetch"; 19505 } 19506 async requestSucceededWithResponse(fetchRequest, fetchResponse) { 19507 try { 19508 const responseHTML = await fetchResponse.responseHTML; 19509 const snapshot = PageSnapshot.fromHTMLString(responseHTML); 19510 this.snapshotCache.put(fetchRequest.url, snapshot); 19511 } catch (_) { 19512 } 19513 } 19514 requestStarted(fetchRequest) { 19515 } 19516 requestErrored(fetchRequest) { 19517 } 19518 requestFinished(fetchRequest) { 19519 } 19520 requestPreventedHandlingResponse(fetchRequest, fetchResponse) { 19521 } 19522 requestFailedWithResponse(fetchRequest, fetchResponse) { 19523 } 19524 #preloadAll = () => { 19525 this.preloadOnLoadLinksForView(document.body); 19526 }; 19527 }; 19528 var Cache = class { 19529 constructor(session2) { 19530 this.session = session2; 19531 } 19532 clear() { 19533 this.session.clearCache(); 19534 } 19535 resetCacheControl() { 19536 this.#setCacheControl(""); 19537 } 19538 exemptPageFromCache() { 19539 this.#setCacheControl("no-cache"); 19540 } 19541 exemptPageFromPreview() { 19542 this.#setCacheControl("no-preview"); 19543 } 19544 #setCacheControl(value) { 19545 setMetaContent("turbo-cache-control", value); 19546 } 19547 }; 19548 var Session = class { 19549 navigator = new Navigator(this); 19550 history = new History(this); 19551 view = new PageView(this, document.documentElement); 19552 adapter = new BrowserAdapter(this); 19553 pageObserver = new PageObserver(this); 19554 cacheObserver = new CacheObserver(); 19555 linkPrefetchObserver = new LinkPrefetchObserver(this, document); 19556 linkClickObserver = new LinkClickObserver(this, window); 19557 formSubmitObserver = new FormSubmitObserver(this, document); 19558 scrollObserver = new ScrollObserver(this); 19559 streamObserver = new StreamObserver(this); 19560 formLinkClickObserver = new FormLinkClickObserver(this, document.documentElement); 19561 frameRedirector = new FrameRedirector(this, document.documentElement); 19562 streamMessageRenderer = new StreamMessageRenderer(); 19563 cache = new Cache(this); 19564 enabled = true; 19565 started = false; 19566 #pageRefreshDebouncePeriod = 150; 19567 constructor(recentRequests2) { 19568 this.recentRequests = recentRequests2; 19569 this.preloader = new Preloader(this, this.view.snapshotCache); 19570 this.debouncedRefresh = this.refresh; 19571 this.pageRefreshDebouncePeriod = this.pageRefreshDebouncePeriod; 19572 } 19573 start() { 19574 if (!this.started) { 19575 this.pageObserver.start(); 19576 this.cacheObserver.start(); 19577 this.linkPrefetchObserver.start(); 19578 this.formLinkClickObserver.start(); 19579 this.linkClickObserver.start(); 19580 this.formSubmitObserver.start(); 19581 this.scrollObserver.start(); 19582 this.streamObserver.start(); 19583 this.frameRedirector.start(); 19584 this.history.start(); 19585 this.preloader.start(); 19586 this.started = true; 19587 this.enabled = true; 19588 } 19589 } 19590 disable() { 19591 this.enabled = false; 19592 } 19593 stop() { 19594 if (this.started) { 19595 this.pageObserver.stop(); 19596 this.cacheObserver.stop(); 19597 this.linkPrefetchObserver.stop(); 19598 this.formLinkClickObserver.stop(); 19599 this.linkClickObserver.stop(); 19600 this.formSubmitObserver.stop(); 19601 this.scrollObserver.stop(); 19602 this.streamObserver.stop(); 19603 this.frameRedirector.stop(); 19604 this.history.stop(); 19605 this.preloader.stop(); 19606 this.started = false; 19607 } 19608 } 19609 registerAdapter(adapter) { 19610 this.adapter = adapter; 19611 } 19612 visit(location2, options = {}) { 19613 const frameElement = options.frame ? document.getElementById(options.frame) : null; 19614 if (frameElement instanceof FrameElement) { 19615 const action = options.action || getVisitAction(frameElement); 19616 frameElement.delegate.proposeVisitIfNavigatedWithAction(frameElement, action); 19617 frameElement.src = location2.toString(); 19618 } else { 19619 this.navigator.proposeVisit(expandURL(location2), options); 19620 } 19621 } 19622 refresh(url, options = {}) { 19623 options = typeof options === "string" ? { requestId: options } : options; 19624 const { method, requestId, scroll } = options; 19625 const isRecentRequest = requestId && this.recentRequests.has(requestId); 19626 const isCurrentUrl = url === document.baseURI; 19627 if (!isRecentRequest && !this.navigator.currentVisit && isCurrentUrl) { 19628 this.visit(url, { action: "replace", shouldCacheSnapshot: false, refresh: { method, scroll } }); 19629 } 19630 } 19631 connectStreamSource(source) { 19632 this.streamObserver.connectStreamSource(source); 19633 } 19634 disconnectStreamSource(source) { 19635 this.streamObserver.disconnectStreamSource(source); 19636 } 19637 renderStreamMessage(message) { 19638 this.streamMessageRenderer.render(StreamMessage.wrap(message)); 19639 } 19640 clearCache() { 19641 this.view.clearSnapshotCache(); 19642 } 19643 setProgressBarDelay(delay) { 19644 console.warn( 19645 "Please replace `session.setProgressBarDelay(delay)` with `session.progressBarDelay = delay`. The function is deprecated and will be removed in a future version of Turbo.`" 19646 ); 19647 this.progressBarDelay = delay; 19648 } 19649 set progressBarDelay(delay) { 19650 config.drive.progressBarDelay = delay; 19651 } 19652 get progressBarDelay() { 19653 return config.drive.progressBarDelay; 19654 } 19655 set drive(value) { 19656 config.drive.enabled = value; 19657 } 19658 get drive() { 19659 return config.drive.enabled; 19660 } 19661 set formMode(value) { 19662 config.forms.mode = value; 19663 } 19664 get formMode() { 19665 return config.forms.mode; 19666 } 19667 get location() { 19668 return this.history.location; 19669 } 19670 get restorationIdentifier() { 19671 return this.history.restorationIdentifier; 19672 } 19673 get pageRefreshDebouncePeriod() { 19674 return this.#pageRefreshDebouncePeriod; 19675 } 19676 set pageRefreshDebouncePeriod(value) { 19677 this.refresh = debounce(this.debouncedRefresh.bind(this), value); 19678 this.#pageRefreshDebouncePeriod = value; 19679 } 19680 // Preloader delegate 19681 shouldPreloadLink(element) { 19682 const isUnsafe = element.hasAttribute("data-turbo-method"); 19683 const isStream = element.hasAttribute("data-turbo-stream"); 19684 const frameTarget = element.getAttribute("data-turbo-frame"); 19685 const frame = frameTarget == "_top" ? null : document.getElementById(frameTarget) || findClosestRecursively(element, "turbo-frame:not([disabled])"); 19686 if (isUnsafe || isStream || frame instanceof FrameElement) { 19687 return false; 19688 } else { 19689 const location2 = new URL(element.href); 19690 return this.elementIsNavigatable(element) && locationIsVisitable(location2, this.snapshot.rootLocation); 19691 } 19692 } 19693 // History delegate 19694 historyPoppedToLocationWithRestorationIdentifierAndDirection(location2, restorationIdentifier, direction) { 19695 if (this.enabled) { 19696 this.navigator.startVisit(location2, restorationIdentifier, { 19697 action: "restore", 19698 historyChanged: true, 19699 direction 19700 }); 19701 } else { 19702 this.adapter.pageInvalidated({ 19703 reason: "turbo_disabled" 19704 }); 19705 } 19706 } 19707 historyPoppedWithEmptyState(location2) { 19708 this.history.replace(location2); 19709 this.view.lastRenderedLocation = location2; 19710 this.view.cacheSnapshot(); 19711 } 19712 // Scroll observer delegate 19713 scrollPositionChanged(position) { 19714 this.history.updateRestorationData({ scrollPosition: position }); 19715 } 19716 // Form click observer delegate 19717 willSubmitFormLinkToLocation(link, location2) { 19718 return this.elementIsNavigatable(link) && locationIsVisitable(location2, this.snapshot.rootLocation); 19719 } 19720 submittedFormLinkToLocation() { 19721 } 19722 // Link hover observer delegate 19723 canPrefetchRequestToLocation(link, location2) { 19724 return this.elementIsNavigatable(link) && locationIsVisitable(location2, this.snapshot.rootLocation) && this.navigator.linkPrefetchingIsEnabledForLocation(location2); 19725 } 19726 // Link click observer delegate 19727 willFollowLinkToLocation(link, location2, event) { 19728 return this.elementIsNavigatable(link) && locationIsVisitable(location2, this.snapshot.rootLocation) && this.applicationAllowsFollowingLinkToLocation(link, location2, event); 19729 } 19730 followedLinkToLocation(link, location2) { 19731 const action = this.getActionForLink(link); 19732 const acceptsStreamResponse = link.hasAttribute("data-turbo-stream"); 19733 this.visit(location2.href, { action, acceptsStreamResponse }); 19734 } 19735 // Navigator delegate 19736 allowsVisitingLocationWithAction(location2, action) { 19737 return this.applicationAllowsVisitingLocation(location2); 19738 } 19739 visitProposedToLocation(location2, options) { 19740 extendURLWithDeprecatedProperties(location2); 19741 this.adapter.visitProposedToLocation(location2, options); 19742 } 19743 // Visit delegate 19744 visitStarted(visit2) { 19745 if (!visit2.acceptsStreamResponse) { 19746 markAsBusy(document.documentElement); 19747 this.view.markVisitDirection(visit2.direction); 19748 } 19749 extendURLWithDeprecatedProperties(visit2.location); 19750 this.notifyApplicationAfterVisitingLocation(visit2.location, visit2.action); 19751 } 19752 visitCompleted(visit2) { 19753 this.view.unmarkVisitDirection(); 19754 clearBusyState(document.documentElement); 19755 this.notifyApplicationAfterPageLoad(visit2.getTimingMetrics()); 19756 } 19757 // Form submit observer delegate 19758 willSubmitForm(form, submitter2) { 19759 const action = getAction$1(form, submitter2); 19760 return this.submissionIsNavigatable(form, submitter2) && locationIsVisitable(expandURL(action), this.snapshot.rootLocation); 19761 } 19762 formSubmitted(form, submitter2) { 19763 this.navigator.submitForm(form, submitter2); 19764 } 19765 // Page observer delegate 19766 pageBecameInteractive() { 19767 this.view.lastRenderedLocation = this.location; 19768 this.notifyApplicationAfterPageLoad(); 19769 } 19770 pageLoaded() { 19771 this.history.assumeControlOfScrollRestoration(); 19772 } 19773 pageWillUnload() { 19774 this.history.relinquishControlOfScrollRestoration(); 19775 } 19776 // Stream observer delegate 19777 receivedMessageFromStream(message) { 19778 this.renderStreamMessage(message); 19779 } 19780 // Page view delegate 19781 viewWillCacheSnapshot() { 19782 this.notifyApplicationBeforeCachingSnapshot(); 19783 } 19784 allowsImmediateRender({ element }, options) { 19785 const event = this.notifyApplicationBeforeRender(element, options); 19786 const { 19787 defaultPrevented, 19788 detail: { render } 19789 } = event; 19790 if (this.view.renderer && render) { 19791 this.view.renderer.renderElement = render; 19792 } 19793 return !defaultPrevented; 19794 } 19795 viewRenderedSnapshot(_snapshot, _isPreview, renderMethod) { 19796 this.view.lastRenderedLocation = this.history.location; 19797 this.notifyApplicationAfterRender(renderMethod); 19798 } 19799 preloadOnLoadLinksForView(element) { 19800 this.preloader.preloadOnLoadLinksForView(element); 19801 } 19802 viewInvalidated(reason) { 19803 this.adapter.pageInvalidated(reason); 19804 } 19805 // Frame element 19806 frameLoaded(frame) { 19807 this.notifyApplicationAfterFrameLoad(frame); 19808 } 19809 frameRendered(fetchResponse, frame) { 19810 this.notifyApplicationAfterFrameRender(fetchResponse, frame); 19811 } 19812 // Application events 19813 applicationAllowsFollowingLinkToLocation(link, location2, ev) { 19814 const event = this.notifyApplicationAfterClickingLinkToLocation(link, location2, ev); 19815 return !event.defaultPrevented; 19816 } 19817 applicationAllowsVisitingLocation(location2) { 19818 const event = this.notifyApplicationBeforeVisitingLocation(location2); 19819 return !event.defaultPrevented; 19820 } 19821 notifyApplicationAfterClickingLinkToLocation(link, location2, event) { 19822 return dispatch("turbo:click", { 19823 target: link, 19824 detail: { url: location2.href, originalEvent: event }, 19825 cancelable: true 19826 }); 19827 } 19828 notifyApplicationBeforeVisitingLocation(location2) { 19829 return dispatch("turbo:before-visit", { 19830 detail: { url: location2.href }, 19831 cancelable: true 19832 }); 19833 } 19834 notifyApplicationAfterVisitingLocation(location2, action) { 19835 return dispatch("turbo:visit", { detail: { url: location2.href, action } }); 19836 } 19837 notifyApplicationBeforeCachingSnapshot() { 19838 return dispatch("turbo:before-cache"); 19839 } 19840 notifyApplicationBeforeRender(newBody, options) { 19841 return dispatch("turbo:before-render", { 19842 detail: { newBody, ...options }, 19843 cancelable: true 19844 }); 19845 } 19846 notifyApplicationAfterRender(renderMethod) { 19847 return dispatch("turbo:render", { detail: { renderMethod } }); 19848 } 19849 notifyApplicationAfterPageLoad(timing = {}) { 19850 return dispatch("turbo:load", { 19851 detail: { url: this.location.href, timing } 19852 }); 19853 } 19854 notifyApplicationAfterFrameLoad(frame) { 19855 return dispatch("turbo:frame-load", { target: frame }); 19856 } 19857 notifyApplicationAfterFrameRender(fetchResponse, frame) { 19858 return dispatch("turbo:frame-render", { 19859 detail: { fetchResponse }, 19860 target: frame, 19861 cancelable: true 19862 }); 19863 } 19864 // Helpers 19865 submissionIsNavigatable(form, submitter2) { 19866 if (config.forms.mode == "off") { 19867 return false; 19868 } else { 19869 const submitterIsNavigatable = submitter2 ? this.elementIsNavigatable(submitter2) : true; 19870 if (config.forms.mode == "optin") { 19871 return submitterIsNavigatable && form.closest('[data-turbo="true"]') != null; 19872 } else { 19873 return submitterIsNavigatable && this.elementIsNavigatable(form); 19874 } 19875 } 19876 } 19877 elementIsNavigatable(element) { 19878 const container = findClosestRecursively(element, "[data-turbo]"); 19879 const withinFrame = findClosestRecursively(element, "turbo-frame"); 19880 if (config.drive.enabled || withinFrame) { 19881 if (container) { 19882 return container.getAttribute("data-turbo") != "false"; 19883 } else { 19884 return true; 19885 } 19886 } else { 19887 if (container) { 19888 return container.getAttribute("data-turbo") == "true"; 19889 } else { 19890 return false; 19891 } 19892 } 19893 } 19894 // Private 19895 getActionForLink(link) { 19896 return getVisitAction(link) || "advance"; 19897 } 19898 get snapshot() { 19899 return this.view.snapshot; 19900 } 19901 }; 19902 function extendURLWithDeprecatedProperties(url) { 19903 Object.defineProperties(url, deprecatedLocationPropertyDescriptors); 19904 } 19905 var deprecatedLocationPropertyDescriptors = { 19906 absoluteURL: { 19907 get() { 19908 return this.toString(); 19909 } 19910 } 19911 }; 19912 var session = new Session(recentRequests); 19913 var { cache, navigator: sessionNavigator } = session; 19914 function start2() { 19915 session.start(); 19916 } 19917 function registerAdapter(adapter) { 19918 session.registerAdapter(adapter); 19919 } 19920 function visit(location2, options) { 19921 session.visit(location2, options); 19922 } 19923 function connectStreamSource(source) { 19924 session.connectStreamSource(source); 19925 } 19926 function disconnectStreamSource(source) { 19927 session.disconnectStreamSource(source); 19928 } 19929 function renderStreamMessage(message) { 19930 session.renderStreamMessage(message); 19931 } 19932 function setProgressBarDelay(delay) { 19933 console.warn( 19934 "Please replace `Turbo.setProgressBarDelay(delay)` with `Turbo.config.drive.progressBarDelay = delay`. The top-level function is deprecated and will be removed in a future version of Turbo.`" 19935 ); 19936 config.drive.progressBarDelay = delay; 19937 } 19938 function setConfirmMethod(confirmMethod) { 19939 console.warn( 19940 "Please replace `Turbo.setConfirmMethod(confirmMethod)` with `Turbo.config.forms.confirm = confirmMethod`. The top-level function is deprecated and will be removed in a future version of Turbo.`" 19941 ); 19942 config.forms.confirm = confirmMethod; 19943 } 19944 function setFormMode(mode) { 19945 console.warn( 19946 "Please replace `Turbo.setFormMode(mode)` with `Turbo.config.forms.mode = mode`. The top-level function is deprecated and will be removed in a future version of Turbo.`" 19947 ); 19948 config.forms.mode = mode; 19949 } 19950 function morphBodyElements(currentBody, newBody) { 19951 MorphingPageRenderer.renderElement(currentBody, newBody); 19952 } 19953 function morphTurboFrameElements(currentFrame, newFrame) { 19954 MorphingFrameRenderer.renderElement(currentFrame, newFrame); 19955 } 19956 var Turbo2 = /* @__PURE__ */ Object.freeze({ 19957 __proto__: null, 19958 PageRenderer, 19959 PageSnapshot, 19960 FrameRenderer, 19961 fetch: fetchWithTurboHeaders, 19962 config, 19963 session, 19964 cache, 19965 navigator: sessionNavigator, 19966 start: start2, 19967 registerAdapter, 19968 visit, 19969 connectStreamSource, 19970 disconnectStreamSource, 19971 renderStreamMessage, 19972 setProgressBarDelay, 19973 setConfirmMethod, 19974 setFormMode, 19975 morphBodyElements, 19976 morphTurboFrameElements, 19977 morphChildren, 19978 morphElements 19979 }); 19980 var TurboFrameMissingError = class extends Error { 19981 }; 19982 var FrameController = class { 19983 fetchResponseLoaded = (_fetchResponse) => Promise.resolve(); 19984 #currentFetchRequest = null; 19985 #resolveVisitPromise = () => { 19986 }; 19987 #connected = false; 19988 #hasBeenLoaded = false; 19989 #ignoredAttributes = /* @__PURE__ */ new Set(); 19990 #shouldMorphFrame = false; 19991 action = null; 19992 constructor(element) { 19993 this.element = element; 19994 this.view = new FrameView(this, this.element); 19995 this.appearanceObserver = new AppearanceObserver(this, this.element); 19996 this.formLinkClickObserver = new FormLinkClickObserver(this, this.element); 19997 this.linkInterceptor = new LinkInterceptor(this, this.element); 19998 this.restorationIdentifier = uuid(); 19999 this.formSubmitObserver = new FormSubmitObserver(this, this.element); 20000 } 20001 // Frame delegate 20002 connect() { 20003 if (!this.#connected) { 20004 this.#connected = true; 20005 if (this.loadingStyle == FrameLoadingStyle.lazy) { 20006 this.appearanceObserver.start(); 20007 } else { 20008 this.#loadSourceURL(); 20009 } 20010 this.formLinkClickObserver.start(); 20011 this.linkInterceptor.start(); 20012 this.formSubmitObserver.start(); 20013 } 20014 } 20015 disconnect() { 20016 if (this.#connected) { 20017 this.#connected = false; 20018 this.appearanceObserver.stop(); 20019 this.formLinkClickObserver.stop(); 20020 this.linkInterceptor.stop(); 20021 this.formSubmitObserver.stop(); 20022 if (!this.element.hasAttribute("recurse")) { 20023 this.#currentFetchRequest?.cancel(); 20024 } 20025 } 20026 } 20027 disabledChanged() { 20028 if (this.disabled) { 20029 this.#currentFetchRequest?.cancel(); 20030 } else if (this.loadingStyle == FrameLoadingStyle.eager) { 20031 this.#loadSourceURL(); 20032 } 20033 } 20034 sourceURLChanged() { 20035 if (this.#isIgnoringChangesTo("src")) return; 20036 if (!this.sourceURL) { 20037 this.#currentFetchRequest?.cancel(); 20038 } 20039 if (this.element.isConnected) { 20040 this.complete = false; 20041 } 20042 if (this.loadingStyle == FrameLoadingStyle.eager || this.#hasBeenLoaded) { 20043 this.#loadSourceURL(); 20044 } 20045 } 20046 sourceURLReloaded() { 20047 const { refresh, src } = this.element; 20048 this.#shouldMorphFrame = src && refresh === "morph"; 20049 this.element.removeAttribute("complete"); 20050 this.element.src = null; 20051 this.element.src = src; 20052 return this.element.loaded; 20053 } 20054 loadingStyleChanged() { 20055 if (this.loadingStyle == FrameLoadingStyle.lazy) { 20056 this.appearanceObserver.start(); 20057 } else { 20058 this.appearanceObserver.stop(); 20059 this.#loadSourceURL(); 20060 } 20061 } 20062 async #loadSourceURL() { 20063 if (this.enabled && this.isActive && !this.complete && this.sourceURL) { 20064 this.element.loaded = this.#visit(expandURL(this.sourceURL)); 20065 this.appearanceObserver.stop(); 20066 await this.element.loaded; 20067 this.#hasBeenLoaded = true; 20068 } 20069 } 20070 async loadResponse(fetchResponse) { 20071 if (fetchResponse.redirected || fetchResponse.succeeded && fetchResponse.isHTML) { 20072 this.sourceURL = fetchResponse.response.url; 20073 } 20074 try { 20075 const html = await fetchResponse.responseHTML; 20076 if (html) { 20077 const document2 = parseHTMLDocument(html); 20078 const pageSnapshot = PageSnapshot.fromDocument(document2); 20079 if (pageSnapshot.isVisitable) { 20080 await this.#loadFrameResponse(fetchResponse, document2); 20081 } else { 20082 await this.#handleUnvisitableFrameResponse(fetchResponse); 20083 } 20084 } 20085 } finally { 20086 this.#shouldMorphFrame = false; 20087 this.fetchResponseLoaded = () => Promise.resolve(); 20088 } 20089 } 20090 // Appearance observer delegate 20091 elementAppearedInViewport(element) { 20092 this.proposeVisitIfNavigatedWithAction(element, getVisitAction(element)); 20093 this.#loadSourceURL(); 20094 } 20095 // Form link click observer delegate 20096 willSubmitFormLinkToLocation(link) { 20097 return this.#shouldInterceptNavigation(link); 20098 } 20099 submittedFormLinkToLocation(link, _location, form) { 20100 const frame = this.#findFrameElement(link); 20101 if (frame) form.setAttribute("data-turbo-frame", frame.id); 20102 } 20103 // Link interceptor delegate 20104 shouldInterceptLinkClick(element, _location, _event) { 20105 return this.#shouldInterceptNavigation(element); 20106 } 20107 linkClickIntercepted(element, location2) { 20108 this.#navigateFrame(element, location2); 20109 } 20110 // Form submit observer delegate 20111 willSubmitForm(element, submitter2) { 20112 return element.closest("turbo-frame") == this.element && this.#shouldInterceptNavigation(element, submitter2); 20113 } 20114 formSubmitted(element, submitter2) { 20115 if (this.formSubmission) { 20116 this.formSubmission.stop(); 20117 } 20118 this.formSubmission = new FormSubmission(this, element, submitter2); 20119 const { fetchRequest } = this.formSubmission; 20120 const frame = this.#findFrameElement(element, submitter2); 20121 this.prepareRequest(fetchRequest, frame); 20122 this.formSubmission.start(); 20123 } 20124 // Fetch request delegate 20125 prepareRequest(request, frame = this) { 20126 request.headers["Turbo-Frame"] = frame.id; 20127 if (this.currentNavigationElement?.hasAttribute("data-turbo-stream")) { 20128 request.acceptResponseType(StreamMessage.contentType); 20129 } 20130 } 20131 requestStarted(_request) { 20132 markAsBusy(this.element); 20133 } 20134 requestPreventedHandlingResponse(_request, _response) { 20135 this.#resolveVisitPromise(); 20136 } 20137 async requestSucceededWithResponse(request, response) { 20138 await this.loadResponse(response); 20139 this.#resolveVisitPromise(); 20140 } 20141 async requestFailedWithResponse(request, response) { 20142 await this.loadResponse(response); 20143 this.#resolveVisitPromise(); 20144 } 20145 requestErrored(request, error2) { 20146 console.error(error2); 20147 this.#resolveVisitPromise(); 20148 } 20149 requestFinished(_request) { 20150 clearBusyState(this.element); 20151 } 20152 // Form submission delegate 20153 formSubmissionStarted({ formElement }) { 20154 markAsBusy(formElement, this.#findFrameElement(formElement)); 20155 } 20156 formSubmissionSucceededWithResponse(formSubmission, response) { 20157 const frame = this.#findFrameElement(formSubmission.formElement, formSubmission.submitter); 20158 frame.delegate.proposeVisitIfNavigatedWithAction(frame, getVisitAction(formSubmission.submitter, formSubmission.formElement, frame)); 20159 frame.delegate.loadResponse(response); 20160 if (!formSubmission.isSafe) { 20161 session.clearCache(); 20162 } 20163 } 20164 formSubmissionFailedWithResponse(formSubmission, fetchResponse) { 20165 this.element.delegate.loadResponse(fetchResponse); 20166 session.clearCache(); 20167 } 20168 formSubmissionErrored(formSubmission, error2) { 20169 console.error(error2); 20170 } 20171 formSubmissionFinished({ formElement }) { 20172 clearBusyState(formElement, this.#findFrameElement(formElement)); 20173 } 20174 // View delegate 20175 allowsImmediateRender({ element: newFrame }, options) { 20176 const event = dispatch("turbo:before-frame-render", { 20177 target: this.element, 20178 detail: { newFrame, ...options }, 20179 cancelable: true 20180 }); 20181 const { 20182 defaultPrevented, 20183 detail: { render } 20184 } = event; 20185 if (this.view.renderer && render) { 20186 this.view.renderer.renderElement = render; 20187 } 20188 return !defaultPrevented; 20189 } 20190 viewRenderedSnapshot(_snapshot, _isPreview, _renderMethod) { 20191 } 20192 preloadOnLoadLinksForView(element) { 20193 session.preloadOnLoadLinksForView(element); 20194 } 20195 viewInvalidated() { 20196 } 20197 // Frame renderer delegate 20198 willRenderFrame(currentElement, _newElement) { 20199 this.previousFrameElement = currentElement.cloneNode(true); 20200 } 20201 visitCachedSnapshot = ({ element }) => { 20202 const frame = element.querySelector("#" + this.element.id); 20203 if (frame && this.previousFrameElement) { 20204 frame.replaceChildren(...this.previousFrameElement.children); 20205 } 20206 delete this.previousFrameElement; 20207 }; 20208 // Private 20209 async #loadFrameResponse(fetchResponse, document2) { 20210 const newFrameElement = await this.extractForeignFrameElement(document2.body); 20211 const rendererClass = this.#shouldMorphFrame ? MorphingFrameRenderer : FrameRenderer; 20212 if (newFrameElement) { 20213 const snapshot = new Snapshot(newFrameElement); 20214 const renderer = new rendererClass(this, this.view.snapshot, snapshot, false, false); 20215 if (this.view.renderPromise) await this.view.renderPromise; 20216 this.changeHistory(); 20217 await this.view.render(renderer); 20218 this.complete = true; 20219 session.frameRendered(fetchResponse, this.element); 20220 session.frameLoaded(this.element); 20221 await this.fetchResponseLoaded(fetchResponse); 20222 } else if (this.#willHandleFrameMissingFromResponse(fetchResponse)) { 20223 this.#handleFrameMissingFromResponse(fetchResponse); 20224 } 20225 } 20226 async #visit(url) { 20227 const request = new FetchRequest(this, FetchMethod.get, url, new URLSearchParams(), this.element); 20228 this.#currentFetchRequest?.cancel(); 20229 this.#currentFetchRequest = request; 20230 return new Promise((resolve) => { 20231 this.#resolveVisitPromise = () => { 20232 this.#resolveVisitPromise = () => { 20233 }; 20234 this.#currentFetchRequest = null; 20235 resolve(); 20236 }; 20237 request.perform(); 20238 }); 20239 } 20240 #navigateFrame(element, url, submitter2) { 20241 const frame = this.#findFrameElement(element, submitter2); 20242 frame.delegate.proposeVisitIfNavigatedWithAction(frame, getVisitAction(submitter2, element, frame)); 20243 this.#withCurrentNavigationElement(element, () => { 20244 frame.src = url; 20245 }); 20246 } 20247 proposeVisitIfNavigatedWithAction(frame, action = null) { 20248 this.action = action; 20249 if (this.action) { 20250 const pageSnapshot = PageSnapshot.fromElement(frame).clone(); 20251 const { visitCachedSnapshot } = frame.delegate; 20252 frame.delegate.fetchResponseLoaded = async (fetchResponse) => { 20253 if (frame.src) { 20254 const { statusCode, redirected } = fetchResponse; 20255 const responseHTML = await fetchResponse.responseHTML; 20256 const response = { statusCode, redirected, responseHTML }; 20257 const options = { 20258 response, 20259 visitCachedSnapshot, 20260 willRender: false, 20261 updateHistory: false, 20262 restorationIdentifier: this.restorationIdentifier, 20263 snapshot: pageSnapshot 20264 }; 20265 if (this.action) options.action = this.action; 20266 session.visit(frame.src, options); 20267 } 20268 }; 20269 } 20270 } 20271 changeHistory() { 20272 if (this.action) { 20273 const method = getHistoryMethodForAction(this.action); 20274 session.history.update(method, expandURL(this.element.src || ""), this.restorationIdentifier); 20275 } 20276 } 20277 async #handleUnvisitableFrameResponse(fetchResponse) { 20278 console.warn( 20279 `The response (${fetchResponse.statusCode}) from <turbo-frame id="${this.element.id}"> is performing a full page visit due to turbo-visit-control.` 20280 ); 20281 await this.#visitResponse(fetchResponse.response); 20282 } 20283 #willHandleFrameMissingFromResponse(fetchResponse) { 20284 this.element.setAttribute("complete", ""); 20285 const response = fetchResponse.response; 20286 const visit2 = async (url, options) => { 20287 if (url instanceof Response) { 20288 this.#visitResponse(url); 20289 } else { 20290 session.visit(url, options); 20291 } 20292 }; 20293 const event = dispatch("turbo:frame-missing", { 20294 target: this.element, 20295 detail: { response, visit: visit2 }, 20296 cancelable: true 20297 }); 20298 return !event.defaultPrevented; 20299 } 20300 #handleFrameMissingFromResponse(fetchResponse) { 20301 this.view.missing(); 20302 this.#throwFrameMissingError(fetchResponse); 20303 } 20304 #throwFrameMissingError(fetchResponse) { 20305 const message = `The response (${fetchResponse.statusCode}) did not contain the expected <turbo-frame id="${this.element.id}"> and will be ignored. To perform a full page visit instead, set turbo-visit-control to reload.`; 20306 throw new TurboFrameMissingError(message); 20307 } 20308 async #visitResponse(response) { 20309 const wrapped = new FetchResponse(response); 20310 const responseHTML = await wrapped.responseHTML; 20311 const { location: location2, redirected, statusCode } = wrapped; 20312 return session.visit(location2, { response: { redirected, statusCode, responseHTML } }); 20313 } 20314 #findFrameElement(element, submitter2) { 20315 const id = getAttribute("data-turbo-frame", submitter2, element) || this.element.getAttribute("target"); 20316 const target = this.#getFrameElementById(id); 20317 return target instanceof FrameElement ? target : this.element; 20318 } 20319 async extractForeignFrameElement(container) { 20320 let element; 20321 const id = CSS.escape(this.id); 20322 try { 20323 element = activateElement(container.querySelector(`turbo-frame#${id}`), this.sourceURL); 20324 if (element) { 20325 return element; 20326 } 20327 element = activateElement(container.querySelector(`turbo-frame[src][recurse~=${id}]`), this.sourceURL); 20328 if (element) { 20329 await element.loaded; 20330 return await this.extractForeignFrameElement(element); 20331 } 20332 } catch (error2) { 20333 console.error(error2); 20334 return new FrameElement(); 20335 } 20336 return null; 20337 } 20338 #formActionIsVisitable(form, submitter2) { 20339 const action = getAction$1(form, submitter2); 20340 return locationIsVisitable(expandURL(action), this.rootLocation); 20341 } 20342 #shouldInterceptNavigation(element, submitter2) { 20343 const id = getAttribute("data-turbo-frame", submitter2, element) || this.element.getAttribute("target"); 20344 if (element instanceof HTMLFormElement && !this.#formActionIsVisitable(element, submitter2)) { 20345 return false; 20346 } 20347 if (!this.enabled || id == "_top") { 20348 return false; 20349 } 20350 if (id) { 20351 const frameElement = this.#getFrameElementById(id); 20352 if (frameElement) { 20353 return !frameElement.disabled; 20354 } else if (id == "_parent") { 20355 return false; 20356 } 20357 } 20358 if (!session.elementIsNavigatable(element)) { 20359 return false; 20360 } 20361 if (submitter2 && !session.elementIsNavigatable(submitter2)) { 20362 return false; 20363 } 20364 return true; 20365 } 20366 // Computed properties 20367 get id() { 20368 return this.element.id; 20369 } 20370 get disabled() { 20371 return this.element.disabled; 20372 } 20373 get enabled() { 20374 return !this.disabled; 20375 } 20376 get sourceURL() { 20377 if (this.element.src) { 20378 return this.element.src; 20379 } 20380 } 20381 set sourceURL(sourceURL) { 20382 this.#ignoringChangesToAttribute("src", () => { 20383 this.element.src = sourceURL ?? null; 20384 }); 20385 } 20386 get loadingStyle() { 20387 return this.element.loading; 20388 } 20389 get isLoading() { 20390 return this.formSubmission !== void 0 || this.#resolveVisitPromise() !== void 0; 20391 } 20392 get complete() { 20393 return this.element.hasAttribute("complete"); 20394 } 20395 set complete(value) { 20396 if (value) { 20397 this.element.setAttribute("complete", ""); 20398 } else { 20399 this.element.removeAttribute("complete"); 20400 } 20401 } 20402 get isActive() { 20403 return this.element.isActive && this.#connected; 20404 } 20405 get rootLocation() { 20406 const meta = this.element.ownerDocument.querySelector(`meta[name="turbo-root"]`); 20407 const root = meta?.content ?? "/"; 20408 return expandURL(root); 20409 } 20410 #isIgnoringChangesTo(attributeName) { 20411 return this.#ignoredAttributes.has(attributeName); 20412 } 20413 #ignoringChangesToAttribute(attributeName, callback) { 20414 this.#ignoredAttributes.add(attributeName); 20415 callback(); 20416 this.#ignoredAttributes.delete(attributeName); 20417 } 20418 #withCurrentNavigationElement(element, callback) { 20419 this.currentNavigationElement = element; 20420 callback(); 20421 delete this.currentNavigationElement; 20422 } 20423 #getFrameElementById(id) { 20424 if (id != null) { 20425 const element = id === "_parent" ? this.element.parentElement.closest("turbo-frame") : document.getElementById(id); 20426 if (element instanceof FrameElement) { 20427 return element; 20428 } 20429 } 20430 } 20431 }; 20432 function activateElement(element, currentURL) { 20433 if (element) { 20434 const src = element.getAttribute("src"); 20435 if (src != null && currentURL != null && urlsAreEqual(src, currentURL)) { 20436 throw new Error(`Matching <turbo-frame id="${element.id}"> element has a source URL which references itself`); 20437 } 20438 if (element.ownerDocument !== document) { 20439 element = document.importNode(element, true); 20440 } 20441 if (element instanceof FrameElement) { 20442 element.connectedCallback(); 20443 element.disconnectedCallback(); 20444 return element; 20445 } 20446 } 20447 } 20448 var StreamActions = { 20449 after() { 20450 this.removeDuplicateTargetSiblings(); 20451 this.targetElements.forEach((e) => e.parentElement?.insertBefore(this.templateContent, e.nextSibling)); 20452 }, 20453 append() { 20454 this.removeDuplicateTargetChildren(); 20455 this.targetElements.forEach((e) => e.append(this.templateContent)); 20456 }, 20457 before() { 20458 this.removeDuplicateTargetSiblings(); 20459 this.targetElements.forEach((e) => e.parentElement?.insertBefore(this.templateContent, e)); 20460 }, 20461 prepend() { 20462 this.removeDuplicateTargetChildren(); 20463 this.targetElements.forEach((e) => e.prepend(this.templateContent)); 20464 }, 20465 remove() { 20466 this.targetElements.forEach((e) => e.remove()); 20467 }, 20468 replace() { 20469 const method = this.getAttribute("method"); 20470 this.targetElements.forEach((targetElement) => { 20471 if (method === "morph") { 20472 morphElements(targetElement, this.templateContent); 20473 } else { 20474 targetElement.replaceWith(this.templateContent); 20475 } 20476 }); 20477 }, 20478 update() { 20479 const method = this.getAttribute("method"); 20480 this.targetElements.forEach((targetElement) => { 20481 if (method === "morph") { 20482 morphChildren(targetElement, this.templateContent); 20483 } else { 20484 targetElement.innerHTML = ""; 20485 targetElement.append(this.templateContent); 20486 } 20487 }); 20488 }, 20489 refresh() { 20490 const method = this.getAttribute("method"); 20491 const requestId = this.requestId; 20492 const scroll = this.getAttribute("scroll"); 20493 session.refresh(this.baseURI, { method, requestId, scroll }); 20494 } 20495 }; 20496 var StreamElement = class _StreamElement extends HTMLElement { 20497 static async renderElement(newElement) { 20498 await newElement.performAction(); 20499 } 20500 async connectedCallback() { 20501 try { 20502 await this.render(); 20503 } catch (error2) { 20504 console.error(error2); 20505 } finally { 20506 this.disconnect(); 20507 } 20508 } 20509 async render() { 20510 return this.renderPromise ??= (async () => { 20511 const event = this.beforeRenderEvent; 20512 if (this.dispatchEvent(event)) { 20513 await nextRepaint(); 20514 await event.detail.render(this); 20515 } 20516 })(); 20517 } 20518 disconnect() { 20519 try { 20520 this.remove(); 20521 } catch { 20522 } 20523 } 20524 /** 20525 * Removes duplicate children (by ID) 20526 */ 20527 removeDuplicateTargetChildren() { 20528 this.duplicateChildren.forEach((c) => c.remove()); 20529 } 20530 /** 20531 * Gets the list of duplicate children (i.e. those with the same ID) 20532 */ 20533 get duplicateChildren() { 20534 const existingChildren = this.targetElements.flatMap((e) => [...e.children]).filter((c) => !!c.getAttribute("id")); 20535 const newChildrenIds = [...this.templateContent?.children || []].filter((c) => !!c.getAttribute("id")).map((c) => c.getAttribute("id")); 20536 return existingChildren.filter((c) => newChildrenIds.includes(c.getAttribute("id"))); 20537 } 20538 /** 20539 * Removes duplicate siblings (by ID) 20540 */ 20541 removeDuplicateTargetSiblings() { 20542 this.duplicateSiblings.forEach((c) => c.remove()); 20543 } 20544 /** 20545 * Gets the list of duplicate siblings (i.e. those with the same ID) 20546 */ 20547 get duplicateSiblings() { 20548 const existingChildren = this.targetElements.flatMap((e) => [...e.parentElement.children]).filter((c) => !!c.id); 20549 const newChildrenIds = [...this.templateContent?.children || []].filter((c) => !!c.id).map((c) => c.id); 20550 return existingChildren.filter((c) => newChildrenIds.includes(c.id)); 20551 } 20552 /** 20553 * Gets the action function to be performed. 20554 */ 20555 get performAction() { 20556 if (this.action) { 20557 const actionFunction = StreamActions[this.action]; 20558 if (actionFunction) { 20559 return actionFunction; 20560 } 20561 this.#raise("unknown action"); 20562 } 20563 this.#raise("action attribute is missing"); 20564 } 20565 /** 20566 * Gets the target elements which the template will be rendered to. 20567 */ 20568 get targetElements() { 20569 if (this.target) { 20570 return this.targetElementsById; 20571 } else if (this.targets) { 20572 return this.targetElementsByQuery; 20573 } else { 20574 this.#raise("target or targets attribute is missing"); 20575 } 20576 } 20577 /** 20578 * Gets the contents of the main `<template>`. 20579 */ 20580 get templateContent() { 20581 return this.templateElement.content.cloneNode(true); 20582 } 20583 /** 20584 * Gets the main `<template>` used for rendering 20585 */ 20586 get templateElement() { 20587 if (this.firstElementChild === null) { 20588 const template = this.ownerDocument.createElement("template"); 20589 this.appendChild(template); 20590 return template; 20591 } else if (this.firstElementChild instanceof HTMLTemplateElement) { 20592 return this.firstElementChild; 20593 } 20594 this.#raise("first child element must be a <template> element"); 20595 } 20596 /** 20597 * Gets the current action. 20598 */ 20599 get action() { 20600 return this.getAttribute("action"); 20601 } 20602 /** 20603 * Gets the current target (an element ID) to which the result will 20604 * be rendered. 20605 */ 20606 get target() { 20607 return this.getAttribute("target"); 20608 } 20609 /** 20610 * Gets the current "targets" selector (a CSS selector) 20611 */ 20612 get targets() { 20613 return this.getAttribute("targets"); 20614 } 20615 /** 20616 * Reads the request-id attribute 20617 */ 20618 get requestId() { 20619 return this.getAttribute("request-id"); 20620 } 20621 #raise(message) { 20622 throw new Error(`${this.description}: ${message}`); 20623 } 20624 get description() { 20625 return (this.outerHTML.match(/<[^>]+>/) ?? [])[0] ?? "<turbo-stream>"; 20626 } 20627 get beforeRenderEvent() { 20628 return new CustomEvent("turbo:before-stream-render", { 20629 bubbles: true, 20630 cancelable: true, 20631 detail: { newStream: this, render: _StreamElement.renderElement } 20632 }); 20633 } 20634 get targetElementsById() { 20635 const element = this.ownerDocument?.getElementById(this.target); 20636 if (element !== null) { 20637 return [element]; 20638 } else { 20639 return []; 20640 } 20641 } 20642 get targetElementsByQuery() { 20643 const elements = this.ownerDocument?.querySelectorAll(this.targets); 20644 if (elements.length !== 0) { 20645 return Array.prototype.slice.call(elements); 20646 } else { 20647 return []; 20648 } 20649 } 20650 }; 20651 var StreamSourceElement = class extends HTMLElement { 20652 streamSource = null; 20653 connectedCallback() { 20654 this.streamSource = this.src.match(/^ws{1,2}:/) ? new WebSocket(this.src) : new EventSource(this.src); 20655 connectStreamSource(this.streamSource); 20656 } 20657 disconnectedCallback() { 20658 if (this.streamSource) { 20659 this.streamSource.close(); 20660 disconnectStreamSource(this.streamSource); 20661 } 20662 } 20663 get src() { 20664 return this.getAttribute("src") || ""; 20665 } 20666 }; 20667 FrameElement.delegateConstructor = FrameController; 20668 if (customElements.get("turbo-frame") === void 0) { 20669 customElements.define("turbo-frame", FrameElement); 20670 } 20671 if (customElements.get("turbo-stream") === void 0) { 20672 customElements.define("turbo-stream", StreamElement); 20673 } 20674 if (customElements.get("turbo-stream-source") === void 0) { 20675 customElements.define("turbo-stream-source", StreamSourceElement); 20676 } 20677 (() => { 20678 const scriptElement = document.currentScript; 20679 if (!scriptElement) return; 20680 if (scriptElement.hasAttribute("data-turbo-suppress-warning")) return; 20681 let element = scriptElement.parentElement; 20682 while (element) { 20683 if (element == document.body) { 20684 return console.warn( 20685 unindent` 20686 You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do! 20687 20688 Load your applicationâs JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change. 20689 20690 For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements 20691 20692 ââ 20693 Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s 20694 `, 20695 scriptElement.outerHTML 20696 ); 20697 } 20698 element = element.parentElement; 20699 } 20700 })(); 20701 window.Turbo = { ...Turbo2, StreamActions }; 20702 start2(); 20703 20704
vendor: 607 bytes, lines 20704-20721
20704// node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable.js 20705 var consumer; 20706 async function getConsumer() { 20707 return consumer || setConsumer(createConsumer2().then(setConsumer)); 20708 } 20709 function setConsumer(newConsumer) { 20710 return consumer = newConsumer; 20711 } 20712 async function createConsumer2() { 20713 const { createConsumer: createConsumer3 } = await Promise.resolve().then(() => (init_src(), src_exports)); 20714 return createConsumer3(); 20715 } 20716 async function subscribeTo(channel, mixin) { 20717 const { subscriptions } = await getConsumer(); 20718 return subscriptions.create(channel, mixin); 20719 } 20720 20721
vendor: 532 bytes, lines 20721-20735
20721// node_modules/@hotwired/turbo-rails/app/javascript/turbo/snakeize.js 20722 function walk(obj) { 20723 if (!obj || typeof obj !== "object") return obj; 20724 if (obj instanceof Date || obj instanceof RegExp) return obj; 20725 if (Array.isArray(obj)) return obj.map(walk); 20726 return Object.keys(obj).reduce(function(acc, key) { 20727 var camel = key[0].toLowerCase() + key.slice(1).replace(/([A-Z]+)/g, function(m2, x) { 20728 return "_" + x.toLowerCase(); 20729 }); 20730 acc[camel] = walk(obj[key]); 20731 return acc; 20732 }, {}); 20733 } 20734 20735
vendor: 1,553 bytes, lines 20735-20777
20735// node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable_stream_source_element.js 20736 var TurboCableStreamSourceElement = class extends HTMLElement { 20737 static observedAttributes = ["channel", "signed-stream-name"]; 20738 async connectedCallback() { 20739 connectStreamSource(this); 20740 this.subscription = await subscribeTo(this.channel, { 20741 received: this.dispatchMessageEvent.bind(this), 20742 connected: this.subscriptionConnected.bind(this), 20743 disconnected: this.subscriptionDisconnected.bind(this) 20744 }); 20745 } 20746 disconnectedCallback() { 20747 disconnectStreamSource(this); 20748 if (this.subscription) this.subscription.unsubscribe(); 20749 this.subscriptionDisconnected(); 20750 } 20751 attributeChangedCallback() { 20752 if (this.subscription) { 20753 this.disconnectedCallback(); 20754 this.connectedCallback(); 20755 } 20756 } 20757 dispatchMessageEvent(data) { 20758 const event = new MessageEvent("message", { data }); 20759 return this.dispatchEvent(event); 20760 } 20761 subscriptionConnected() { 20762 this.setAttribute("connected", ""); 20763 } 20764 subscriptionDisconnected() { 20765 this.removeAttribute("connected"); 20766 } 20767 get channel() { 20768 const channel = this.getAttribute("channel"); 20769 const signed_stream_name = this.getAttribute("signed-stream-name"); 20770 return { channel, signed_stream_name, ...walk({ ...this.dataset }) }; 20771 } 20772 }; 20773 if (customElements.get("turbo-cable-stream-source") === void 0) { 20774 customElements.define("turbo-cable-stream-source", TurboCableStreamSourceElement); 20775 } 20776 20777
vendor: 1,703 bytes, lines 20777-20824
20777// node_modules/@hotwired/turbo-rails/app/javascript/turbo/fetch_requests.js 20778 function encodeMethodIntoRequestBody(event) { 20779 if (event.target instanceof HTMLFormElement) { 20780 const { target: form, detail: { fetchOptions } } = event; 20781 form.addEventListener("turbo:submit-start", ({ detail: { formSubmission: { submitter: submitter2 } } }) => { 20782 const body = isBodyInit(fetchOptions.body) ? fetchOptions.body : new URLSearchParams(); 20783 const method = determineFetchMethod(submitter2, body, form); 20784 if (!/get/i.test(method)) { 20785 if (/post/i.test(method)) { 20786 body.delete("_method"); 20787 } else { 20788 body.set("_method", method); 20789 } 20790 fetchOptions.method = "post"; 20791 } 20792 }, { once: true }); 20793 } 20794 } 20795 function determineFetchMethod(submitter2, body, form) { 20796 const formMethod = determineFormMethod(submitter2); 20797 const overrideMethod = body.get("_method"); 20798 const method = form.getAttribute("method") || "get"; 20799 if (typeof formMethod == "string") { 20800 return formMethod; 20801 } else if (typeof overrideMethod == "string") { 20802 return overrideMethod; 20803 } else { 20804 return method; 20805 } 20806 } 20807 function determineFormMethod(submitter2) { 20808 if (submitter2 instanceof HTMLButtonElement || submitter2 instanceof HTMLInputElement) { 20809 if (submitter2.name === "_method") { 20810 return submitter2.value; 20811 } else if (submitter2.hasAttribute("formmethod")) { 20812 return submitter2.formMethod; 20813 } else { 20814 return null; 20815 } 20816 } else { 20817 return null; 20818 } 20819 } 20820 function isBodyInit(body) { 20821 return body instanceof FormData || body instanceof URLSearchParams; 20822 } 20823 20824
vendor: 193 bytes, lines 20824-20828
20824// node_modules/@hotwired/turbo-rails/app/javascript/turbo/index.js 20825 window.Turbo = turbo_es2017_esm_exports; 20826 addEventListener("turbo:before-fetch-request", encodeMethodIntoRequestBody); 20827 20828
20828// app/javascript/jquery.js 20829 var import_jquery = __toESM(require_jquery()); 20830 window.jQuery = import_jquery.default; 20831 window.$ = import_jquery.default; 20832 20833
20833// app/javascript/application.js 20834 var import_bootstrap = __toESM(require_bootstrap()); 20835 var import_viewer = __toESM(require_viewer()); 20836 20837
vendor: 28,441 bytes, lines 20837-21229
20837// node_modules/cookieconsent/build/cookieconsent.min.js 20838 !(function(e) { 20839 if (!e.hasInitialised) { 20840 var t = { escapeRegExp: function(e2) { 20841 return e2.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 20842 }, hasClass: function(e2, t2) { 20843 var i2 = " "; 20844 return 1 === e2.nodeType && (i2 + e2.className + i2).replace(/[\n\t]/g, i2).indexOf(i2 + t2 + i2) >= 0; 20845 }, addClass: function(e2, t2) { 20846 e2.className += " " + t2; 20847 }, removeClass: function(e2, t2) { 20848 var i2 = new RegExp("\\b" + this.escapeRegExp(t2) + "\\b"); 20849 e2.className = e2.className.replace(i2, ""); 20850 }, interpolateString: function(e2, t2) { 20851 return e2.replace(/{{([a-z][a-z0-9\-_]*)}}/gi, function(e3) { 20852 return t2(arguments[1]) || ""; 20853 }); 20854 }, getCookie: function(e2) { 20855 var t2 = ("; " + document.cookie).split("; " + e2 + "="); 20856 return t2.length < 2 ? void 0 : t2.pop().split(";").shift(); 20857 }, setCookie: function(e2, t2, i2, n, o, s) { 20858 var r = /* @__PURE__ */ new Date(); 20859 r.setHours(r.getHours() + 24 * (i2 || 365)); 20860 var a = [e2 + "=" + t2, "expires=" + r.toUTCString(), "path=" + (o || "/")]; 20861 n && a.push("domain=" + n), s && a.push("secure"), document.cookie = a.join(";"); 20862 }, deepExtend: function(e2, t2) { 20863 for (var i2 in t2) t2.hasOwnProperty(i2) && (i2 in e2 && this.isPlainObject(e2[i2]) && this.isPlainObject(t2[i2]) ? this.deepExtend(e2[i2], t2[i2]) : e2[i2] = t2[i2]); 20864 return e2; 20865 }, throttle: function(e2, t2) { 20866 var i2 = false; 20867 return function() { 20868 i2 || (e2.apply(this, arguments), i2 = true, setTimeout(function() { 20869 i2 = false; 20870 }, t2)); 20871 }; 20872 }, hash: function(e2) { 20873 var t2, i2, n = 0; 20874 if (0 === e2.length) return n; 20875 for (t2 = 0, i2 = e2.length; t2 < i2; ++t2) n = (n << 5) - n + e2.charCodeAt(t2), n |= 0; 20876 return n; 20877 }, normaliseHex: function(e2) { 20878 return "#" == e2[0] && (e2 = e2.substr(1)), 3 == e2.length && (e2 = e2[0] + e2[0] + e2[1] + e2[1] + e2[2] + e2[2]), e2; 20879 }, getContrast: function(e2) { 20880 return e2 = this.normaliseHex(e2), (299 * parseInt(e2.substr(0, 2), 16) + 587 * parseInt(e2.substr(2, 2), 16) + 114 * parseInt(e2.substr(4, 2), 16)) / 1e3 >= 128 ? "#000" : "#fff"; 20881 }, getLuminance: function(e2) { 20882 var t2 = parseInt(this.normaliseHex(e2), 16), i2 = 38 + (t2 >> 16), n = 38 + (t2 >> 8 & 255), o = 38 + (255 & t2); 20883 return "#" + (16777216 + 65536 * (i2 < 255 ? i2 < 1 ? 0 : i2 : 255) + 256 * (n < 255 ? n < 1 ? 0 : n : 255) + (o < 255 ? o < 1 ? 0 : o : 255)).toString(16).slice(1); 20884 }, isMobile: function() { 20885 return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); 20886 }, isPlainObject: function(e2) { 20887 return "object" == typeof e2 && null !== e2 && e2.constructor == Object; 20888 }, traverseDOMPath: function(e2, i2) { 20889 return e2 && e2.parentNode ? t.hasClass(e2, i2) ? e2 : this.traverseDOMPath(e2.parentNode, i2) : null; 20890 } }; 20891 e.status = { deny: "deny", allow: "allow", dismiss: "dismiss" }, e.transitionEnd = (function() { 20892 var e2 = document.createElement("div"), t2 = { t: "transitionend", OT: "oTransitionEnd", msT: "MSTransitionEnd", MozT: "transitionend", WebkitT: "webkitTransitionEnd" }; 20893 for (var i2 in t2) if (t2.hasOwnProperty(i2) && void 0 !== e2.style[i2 + "ransition"]) return t2[i2]; 20894 return ""; 20895 })(), e.hasTransition = !!e.transitionEnd; 20896 var i = Object.keys(e.status).map(t.escapeRegExp); 20897 e.customStyles = {}, e.Popup = (function() { 20898 var n = { enabled: true, container: null, cookie: { name: "cookieconsent_status", path: "/", domain: "", expiryDays: 365, secure: false }, onPopupOpen: function() { 20899 }, onPopupClose: function() { 20900 }, onInitialise: function(e2) { 20901 }, onStatusChange: function(e2, t2) { 20902 }, onRevokeChoice: function() { 20903 }, onNoCookieLaw: function(e2, t2) { 20904 }, content: { header: "Cookies used on the website!", message: "This website uses cookies to ensure you get the best experience on our website.", dismiss: "Got it!", allow: "Allow cookies", deny: "Decline", link: "Learn more", href: "https://www.cookiesandyou.com", close: "❌", target: "_blank", policy: "Cookie Policy" }, elements: { header: '<span class="cc-header">{{header}}</span> ', message: '<span id="cookieconsent:desc" class="cc-message">{{message}}</span>', messagelink: '<span id="cookieconsent:desc" class="cc-message">{{message}} <a aria-label="learn more about cookies" role=button tabindex="0" class="cc-link" href="{{href}}" rel="noopener noreferrer nofollow" target="{{target}}">{{link}}</a></span>', dismiss: '<a aria-label="dismiss cookie message" role=button tabindex="0" class="cc-btn cc-dismiss">{{dismiss}}</a>', allow: '<a aria-label="allow cookies" role=button tabindex="0" class="cc-btn cc-allow">{{allow}}</a>', deny: '<a aria-label="deny cookies" role=button tabindex="0" class="cc-btn cc-deny">{{deny}}</a>', link: '<a aria-label="learn more about cookies" role=button tabindex="0" class="cc-link" href="{{href}}" rel="noopener noreferrer nofollow" target="{{target}}">{{link}}</a>', close: '<span aria-label="dismiss cookie message" role=button tabindex="0" class="cc-close">{{close}}</span>' }, window: '<div role="dialog" aria-live="polite" aria-label="cookieconsent" aria-describedby="cookieconsent:desc" class="cc-window {{classes}}"><!--googleoff: all-->{{children}}<!--googleon: all--></div>', revokeBtn: '<div class="cc-revoke {{classes}}">{{policy}}</div>', compliance: { info: '<div class="cc-compliance">{{dismiss}}</div>', "opt-in": '<div class="cc-compliance cc-highlight">{{deny}}{{allow}}</div>', "opt-out": '<div class="cc-compliance cc-highlight">{{deny}}{{allow}}</div>' }, type: "info", layouts: { basic: "{{messagelink}}{{compliance}}", "basic-close": "{{messagelink}}{{compliance}}{{close}}", "basic-header": "{{header}}{{message}}{{link}}{{compliance}}" }, layout: "basic", position: "bottom", theme: "block", static: false, palette: null, revokable: false, animateRevokable: true, showLink: true, dismissOnScroll: false, dismissOnTimeout: false, dismissOnWindowClick: false, ignoreClicksFrom: ["cc-revoke", "cc-btn"], autoOpen: true, autoAttach: true, whitelistPage: [], blacklistPage: [], overrideHTML: null }; 20905 function o() { 20906 this.initialise.apply(this, arguments); 20907 } 20908 function s(e2) { 20909 this.openingTimeout = null, t.removeClass(e2, "cc-invisible"); 20910 } 20911 function r(t2) { 20912 t2.style.display = "none", t2.removeEventListener(e.transitionEnd, this.afterTransition), this.afterTransition = null; 20913 } 20914 function a() { 20915 var e2 = this.options.position.split("-"), t2 = []; 20916 return e2.forEach(function(e3) { 20917 t2.push("cc-" + e3); 20918 }), t2; 20919 } 20920 function c(n2) { 20921 var o2 = this.options, s2 = document.createElement("div"), r2 = o2.container && 1 === o2.container.nodeType ? o2.container : document.body; 20922 s2.innerHTML = n2; 20923 var a2 = s2.children[0]; 20924 return a2.style.display = "none", t.hasClass(a2, "cc-window") && e.hasTransition && t.addClass(a2, "cc-invisible"), this.onButtonClick = function(n3) { 20925 var o3 = t.traverseDOMPath(n3.target, "cc-btn") || n3.target; 20926 if (t.hasClass(o3, "cc-btn")) { 20927 var s3 = o3.className.match(new RegExp("\\bcc-(" + i.join("|") + ")\\b")), r3 = s3 && s3[1] || false; 20928 r3 && (this.setStatus(r3), this.close(true)); 20929 } 20930 t.hasClass(o3, "cc-close") && (this.setStatus(e.status.dismiss), this.close(true)); 20931 t.hasClass(o3, "cc-revoke") && this.revokeChoice(); 20932 }.bind(this), a2.addEventListener("click", this.onButtonClick), o2.autoAttach && (r2.firstChild ? r2.insertBefore(a2, r2.firstChild) : r2.appendChild(a2)), a2; 20933 } 20934 function l(e2) { 20935 return "000000" == (e2 = t.normaliseHex(e2)) ? "#222" : t.getLuminance(e2); 20936 } 20937 function u(e2, t2) { 20938 for (var i2 = 0, n2 = e2.length; i2 < n2; ++i2) { 20939 var o2 = e2[i2]; 20940 if (o2 instanceof RegExp && o2.test(t2) || "string" == typeof o2 && o2.length && o2 === t2) return true; 20941 } 20942 return false; 20943 } 20944 return o.prototype.initialise = function(i2) { 20945 this.options && this.destroy(), t.deepExtend(this.options = {}, n), t.isPlainObject(i2) && t.deepExtend(this.options, i2), function() { 20946 var t2 = this.options.onInitialise.bind(this); 20947 if (!window.navigator.cookieEnabled) return t2(e.status.deny), true; 20948 if (window.CookiesOK || window.navigator.CookiesOK) return t2(e.status.allow), true; 20949 var i3 = Object.keys(e.status), n2 = this.getStatus(), o3 = i3.indexOf(n2) >= 0; 20950 o3 && t2(n2); 20951 return o3; 20952 }.call(this) && (this.options.enabled = false), u(this.options.blacklistPage, location.pathname) && (this.options.enabled = false), u(this.options.whitelistPage, location.pathname) && (this.options.enabled = true); 20953 var o2 = this.options.window.replace("{{classes}}", function() { 20954 var i3 = this.options, n2 = "top" == i3.position || "bottom" == i3.position ? "banner" : "floating"; 20955 t.isMobile() && (n2 = "floating"); 20956 var o3 = ["cc-" + n2, "cc-type-" + i3.type, "cc-theme-" + i3.theme]; 20957 i3.static && o3.push("cc-static"); 20958 o3.push.apply(o3, a.call(this)); 20959 (function(i4) { 20960 var n3 = t.hash(JSON.stringify(i4)), o4 = "cc-color-override-" + n3, s3 = t.isPlainObject(i4); 20961 this.customStyleSelector = s3 ? o4 : null, s3 && (function(i5, n4, o5) { 20962 if (e.customStyles[i5]) return void ++e.customStyles[i5].references; 20963 var s4 = {}, r3 = n4.popup, a2 = n4.button, c2 = n4.highlight; 20964 r3 && (r3.text = r3.text ? r3.text : t.getContrast(r3.background), r3.link = r3.link ? r3.link : r3.text, s4[o5 + ".cc-window"] = ["color: " + r3.text, "background-color: " + r3.background], s4[o5 + ".cc-revoke"] = ["color: " + r3.text, "background-color: " + r3.background], s4[o5 + " .cc-link," + o5 + " .cc-link:active," + o5 + " .cc-link:visited"] = ["color: " + r3.link], a2 && (a2.text = a2.text ? a2.text : t.getContrast(a2.background), a2.border = a2.border ? a2.border : "transparent", s4[o5 + " .cc-btn"] = ["color: " + a2.text, "border-color: " + a2.border, "background-color: " + a2.background], a2.padding && s4[o5 + " .cc-btn"].push("padding: " + a2.padding), "transparent" != a2.background && (s4[o5 + " .cc-btn:hover, " + o5 + " .cc-btn:focus"] = ["background-color: " + (a2.hover || l(a2.background))]), c2 ? (c2.text = c2.text ? c2.text : t.getContrast(c2.background), c2.border = c2.border ? c2.border : "transparent", s4[o5 + " .cc-highlight .cc-btn:first-child"] = ["color: " + c2.text, "border-color: " + c2.border, "background-color: " + c2.background]) : s4[o5 + " .cc-highlight .cc-btn:first-child"] = ["color: " + r3.text])); 20965 var u2 = document.createElement("style"); 20966 document.head.appendChild(u2), e.customStyles[i5] = { references: 1, element: u2.sheet }; 20967 var h = -1; 20968 for (var p in s4) s4.hasOwnProperty(p) && u2.sheet.insertRule(p + "{" + s4[p].join(";") + "}", ++h); 20969 })(n3, i4, "." + o4); 20970 return s3; 20971 }).call(this, this.options.palette); 20972 this.customStyleSelector && o3.push(this.customStyleSelector); 20973 return o3; 20974 }.call(this).join(" ")).replace("{{children}}", function() { 20975 var e2 = {}, i3 = this.options; 20976 i3.showLink || (i3.elements.link = "", i3.elements.messagelink = i3.elements.message); 20977 Object.keys(i3.elements).forEach(function(n3) { 20978 e2[n3] = t.interpolateString(i3.elements[n3], function(e3) { 20979 var t2 = i3.content[e3]; 20980 return e3 && "string" == typeof t2 && t2.length ? t2 : ""; 20981 }); 20982 }); 20983 var n2 = i3.compliance[i3.type]; 20984 n2 || (n2 = i3.compliance.info); 20985 e2.compliance = t.interpolateString(n2, function(t2) { 20986 return e2[t2]; 20987 }); 20988 var o3 = i3.layouts[i3.layout]; 20989 o3 || (o3 = i3.layouts.basic); 20990 return t.interpolateString(o3, function(t2) { 20991 return e2[t2]; 20992 }); 20993 }.call(this)), s2 = this.options.overrideHTML; 20994 if ("string" == typeof s2 && s2.length && (o2 = s2), this.options.static) { 20995 var r2 = c.call(this, '<div class="cc-grower">' + o2 + "</div>"); 20996 r2.style.display = "", this.element = r2.firstChild, this.element.style.display = "none", t.addClass(this.element, "cc-invisible"); 20997 } else this.element = c.call(this, o2); 20998 (function() { 20999 var i3 = this.setStatus.bind(this), n2 = this.close.bind(this), o3 = this.options.dismissOnTimeout; 21000 "number" == typeof o3 && o3 >= 0 && (this.dismissTimeout = window.setTimeout(function() { 21001 i3(e.status.dismiss), n2(true); 21002 }, Math.floor(o3))); 21003 var s3 = this.options.dismissOnScroll; 21004 if ("number" == typeof s3 && s3 >= 0) { 21005 var r3 = function(t2) { 21006 window.pageYOffset > Math.floor(s3) && (i3(e.status.dismiss), n2(true), window.removeEventListener("scroll", r3), this.onWindowScroll = null); 21007 }; 21008 this.options.enabled && (this.onWindowScroll = r3, window.addEventListener("scroll", r3)); 21009 } 21010 var a2 = this.options.dismissOnWindowClick, c2 = this.options.ignoreClicksFrom; 21011 if (a2) { 21012 var l2 = function(o4) { 21013 for (var s4 = false, r4 = o4.path.length, a3 = c2.length, u2 = 0; u2 < r4; u2++) if (!s4) for (var h = 0; h < a3; h++) s4 || (s4 = t.hasClass(o4.path[u2], c2[h])); 21014 s4 || (i3(e.status.dismiss), n2(true), window.removeEventListener("click", l2), window.removeEventListener("touchend", l2), this.onWindowClick = null); 21015 }.bind(this); 21016 this.options.enabled && (this.onWindowClick = l2, window.addEventListener("click", l2), window.addEventListener("touchend", l2)); 21017 } 21018 }).call(this), function() { 21019 "info" != this.options.type && (this.options.revokable = true); 21020 t.isMobile() && (this.options.animateRevokable = false); 21021 if (this.options.revokable) { 21022 var e2 = a.call(this); 21023 this.options.animateRevokable && e2.push("cc-animate"), this.customStyleSelector && e2.push(this.customStyleSelector); 21024 var i3 = this.options.revokeBtn.replace("{{classes}}", e2.join(" ")).replace("{{policy}}", this.options.content.policy); 21025 this.revokeBtn = c.call(this, i3); 21026 var n2 = this.revokeBtn; 21027 if (this.options.animateRevokable) { 21028 var o3 = t.throttle(function(e3) { 21029 var i4 = false, o4 = window.innerHeight - 20; 21030 t.hasClass(n2, "cc-top") && e3.clientY < 20 && (i4 = true), t.hasClass(n2, "cc-bottom") && e3.clientY > o4 && (i4 = true), i4 ? t.hasClass(n2, "cc-active") || t.addClass(n2, "cc-active") : t.hasClass(n2, "cc-active") && t.removeClass(n2, "cc-active"); 21031 }, 200); 21032 this.onMouseMove = o3, window.addEventListener("mousemove", o3); 21033 } 21034 } 21035 }.call(this), this.options.autoOpen && this.autoOpen(); 21036 }, o.prototype.destroy = function() { 21037 this.onButtonClick && this.element && (this.element.removeEventListener("click", this.onButtonClick), this.onButtonClick = null), this.dismissTimeout && (clearTimeout(this.dismissTimeout), this.dismissTimeout = null), this.onWindowScroll && (window.removeEventListener("scroll", this.onWindowScroll), this.onWindowScroll = null), this.onWindowClick && (window.removeEventListener("click", this.onWindowClick), this.onWindowClick = null), this.onMouseMove && (window.removeEventListener("mousemove", this.onMouseMove), this.onMouseMove = null), this.element && this.element.parentNode && this.element.parentNode.removeChild(this.element), this.element = null, this.revokeBtn && this.revokeBtn.parentNode && this.revokeBtn.parentNode.removeChild(this.revokeBtn), this.revokeBtn = null, (function(i2) { 21038 if (t.isPlainObject(i2)) { 21039 var n2 = t.hash(JSON.stringify(i2)), o2 = e.customStyles[n2]; 21040 if (o2 && !--o2.references) { 21041 var s2 = o2.element.ownerNode; 21042 s2 && s2.parentNode && s2.parentNode.removeChild(s2), e.customStyles[n2] = null; 21043 } 21044 } 21045 })(this.options.palette), this.options = null; 21046 }, o.prototype.open = function(t2) { 21047 if (this.element) return this.isOpen() || (e.hasTransition ? this.fadeIn() : this.element.style.display = "", this.options.revokable && this.toggleRevokeButton(), this.options.onPopupOpen.call(this)), this; 21048 }, o.prototype.close = function(t2) { 21049 if (this.element) return this.isOpen() && (e.hasTransition ? this.fadeOut() : this.element.style.display = "none", t2 && this.options.revokable && this.toggleRevokeButton(true), this.options.onPopupClose.call(this)), this; 21050 }, o.prototype.fadeIn = function() { 21051 var i2 = this.element; 21052 if (e.hasTransition && i2 && (this.afterTransition && r.call(this, i2), t.hasClass(i2, "cc-invisible"))) { 21053 if (i2.style.display = "", this.options.static) { 21054 var n2 = this.element.clientHeight; 21055 this.element.parentNode.style.maxHeight = n2 + "px"; 21056 } 21057 this.openingTimeout = setTimeout(s.bind(this, i2), 20); 21058 } 21059 }, o.prototype.fadeOut = function() { 21060 var i2 = this.element; 21061 e.hasTransition && i2 && (this.openingTimeout && (clearTimeout(this.openingTimeout), s.bind(this, i2)), t.hasClass(i2, "cc-invisible") || (this.options.static && (this.element.parentNode.style.maxHeight = ""), this.afterTransition = r.bind(this, i2), i2.addEventListener(e.transitionEnd, this.afterTransition), t.addClass(i2, "cc-invisible"))); 21062 }, o.prototype.isOpen = function() { 21063 return this.element && "" == this.element.style.display && (!e.hasTransition || !t.hasClass(this.element, "cc-invisible")); 21064 }, o.prototype.toggleRevokeButton = function(e2) { 21065 this.revokeBtn && (this.revokeBtn.style.display = e2 ? "" : "none"); 21066 }, o.prototype.revokeChoice = function(e2) { 21067 this.options.enabled = true, this.clearStatus(), this.options.onRevokeChoice.call(this), e2 || this.autoOpen(); 21068 }, o.prototype.hasAnswered = function(t2) { 21069 return Object.keys(e.status).indexOf(this.getStatus()) >= 0; 21070 }, o.prototype.hasConsented = function(t2) { 21071 var i2 = this.getStatus(); 21072 return i2 == e.status.allow || i2 == e.status.dismiss; 21073 }, o.prototype.autoOpen = function(e2) { 21074 !this.hasAnswered() && this.options.enabled ? this.open() : this.hasAnswered() && this.options.revokable && this.toggleRevokeButton(true); 21075 }, o.prototype.setStatus = function(i2) { 21076 var n2 = this.options.cookie, o2 = t.getCookie(n2.name), s2 = Object.keys(e.status).indexOf(o2) >= 0; 21077 Object.keys(e.status).indexOf(i2) >= 0 ? (t.setCookie(n2.name, i2, n2.expiryDays, n2.domain, n2.path, n2.secure), this.options.onStatusChange.call(this, i2, s2)) : this.clearStatus(); 21078 }, o.prototype.getStatus = function() { 21079 return t.getCookie(this.options.cookie.name); 21080 }, o.prototype.clearStatus = function() { 21081 var e2 = this.options.cookie; 21082 t.setCookie(e2.name, "", -1, e2.domain, e2.path); 21083 }, o; 21084 })(), e.Location = (function() { 21085 var e2 = { timeout: 5e3, services: ["ipinfo"], serviceDefinitions: { ipinfo: function() { 21086 return { url: "//ipinfo.io", headers: ["Accept: application/json"], callback: function(e3, t2) { 21087 try { 21088 var i3 = JSON.parse(t2); 21089 return i3.error ? s(i3) : { code: i3.country }; 21090 } catch (e4) { 21091 return s({ error: "Invalid response (" + e4 + ")" }); 21092 } 21093 } }; 21094 }, ipinfodb: function(e3) { 21095 return { url: "//api.ipinfodb.com/v3/ip-country/?key={api_key}&format=json&callback={callback}", isScript: true, callback: function(e4, t2) { 21096 try { 21097 var i3 = JSON.parse(t2); 21098 return "ERROR" == i3.statusCode ? s({ error: i3.statusMessage }) : { code: i3.countryCode }; 21099 } catch (e5) { 21100 return s({ error: "Invalid response (" + e5 + ")" }); 21101 } 21102 } }; 21103 }, maxmind: function() { 21104 return { url: "//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js", isScript: true, callback: function(e3) { 21105 window.geoip2 ? geoip2.country(function(t2) { 21106 try { 21107 e3({ code: t2.country.iso_code }); 21108 } catch (t3) { 21109 e3(s(t3)); 21110 } 21111 }, function(t2) { 21112 e3(s(t2)); 21113 }) : e3(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope")); 21114 } }; 21115 } } }; 21116 function i2(i3) { 21117 t.deepExtend(this.options = {}, e2), t.isPlainObject(i3) && t.deepExtend(this.options, i3), this.currentServiceIndex = -1; 21118 } 21119 function n(e3, t2, i3) { 21120 var n2, o2 = document.createElement("script"); 21121 o2.type = "text/" + (e3.type || "javascript"), o2.src = e3.src || e3, o2.async = false, o2.onreadystatechange = o2.onload = function() { 21122 var e4 = o2.readyState; 21123 clearTimeout(n2), t2.done || e4 && !/loaded|complete/.test(e4) || (t2.done = true, t2(), o2.onreadystatechange = o2.onload = null); 21124 }, document.body.appendChild(o2), n2 = setTimeout(function() { 21125 t2.done = true, t2(), o2.onreadystatechange = o2.onload = null; 21126 }, i3); 21127 } 21128 function o(e3, t2, i3, n2, o2) { 21129 var s2 = new (window.XMLHttpRequest || window.ActiveXObject)("MSXML2.XMLHTTP.3.0"); 21130 if (s2.open(n2 ? "POST" : "GET", e3, 1), s2.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), Array.isArray(o2)) for (var r = 0, a = o2.length; r < a; ++r) { 21131 var c = o2[r].split(":", 2); 21132 s2.setRequestHeader(c[0].replace(/^\s+|\s+$/g, ""), c[1].replace(/^\s+|\s+$/g, "")); 21133 } 21134 "function" == typeof t2 && (s2.onreadystatechange = function() { 21135 s2.readyState > 3 && t2(s2); 21136 }), s2.send(n2); 21137 } 21138 function s(e3) { 21139 return new Error("Error [" + (e3.code || "UNKNOWN") + "]: " + e3.error); 21140 } 21141 return i2.prototype.getNextService = function() { 21142 var e3; 21143 do { 21144 e3 = this.getServiceByIdx(++this.currentServiceIndex); 21145 } while (this.currentServiceIndex < this.options.services.length && !e3); 21146 return e3; 21147 }, i2.prototype.getServiceByIdx = function(e3) { 21148 var i3 = this.options.services[e3]; 21149 if ("function" == typeof i3) { 21150 var n2 = i3(); 21151 return n2.name && t.deepExtend(n2, this.options.serviceDefinitions[n2.name](n2)), n2; 21152 } 21153 return "string" == typeof i3 ? this.options.serviceDefinitions[i3]() : t.isPlainObject(i3) ? this.options.serviceDefinitions[i3.name](i3) : null; 21154 }, i2.prototype.locate = function(e3, t2) { 21155 var i3 = this.getNextService(); 21156 i3 ? (this.callbackComplete = e3, this.callbackError = t2, this.runService(i3, this.runNextServiceOnError.bind(this))) : t2(new Error("No services to run")); 21157 }, i2.prototype.setupUrl = function(e3) { 21158 var t2 = this.getCurrentServiceOpts(); 21159 return e3.url.replace(/\{(.*?)\}/g, function(i3, n2) { 21160 if ("callback" === n2) { 21161 var o2 = "callback" + Date.now(); 21162 return window[o2] = function(t3) { 21163 e3.__JSONP_DATA = JSON.stringify(t3); 21164 }, o2; 21165 } 21166 if (n2 in t2.interpolateUrl) return t2.interpolateUrl[n2]; 21167 }); 21168 }, i2.prototype.runService = function(e3, t2) { 21169 var i3 = this; 21170 e3 && e3.url && e3.callback && (e3.isScript ? n : o)(this.setupUrl(e3), function(n2) { 21171 var o2 = n2 ? n2.responseText : ""; 21172 e3.__JSONP_DATA && (o2 = e3.__JSONP_DATA, delete e3.__JSONP_DATA), i3.runServiceCallback.call(i3, t2, e3, o2); 21173 }, this.options.timeout, e3.data, e3.headers); 21174 }, i2.prototype.runServiceCallback = function(e3, t2, i3) { 21175 var n2 = this, o2 = t2.callback(function(t3) { 21176 o2 || n2.onServiceResult.call(n2, e3, t3); 21177 }, i3); 21178 o2 && this.onServiceResult.call(this, e3, o2); 21179 }, i2.prototype.onServiceResult = function(e3, t2) { 21180 t2 instanceof Error || t2 && t2.error ? e3.call(this, t2, null) : e3.call(this, null, t2); 21181 }, i2.prototype.runNextServiceOnError = function(e3, t2) { 21182 if (e3) { 21183 this.logError(e3); 21184 var i3 = this.getNextService(); 21185 i3 ? this.runService(i3, this.runNextServiceOnError.bind(this)) : this.completeService.call(this, this.callbackError, new Error("All services failed")); 21186 } else this.completeService.call(this, this.callbackComplete, t2); 21187 }, i2.prototype.getCurrentServiceOpts = function() { 21188 var e3 = this.options.services[this.currentServiceIndex]; 21189 return "string" == typeof e3 ? { name: e3 } : "function" == typeof e3 ? e3() : t.isPlainObject(e3) ? e3 : {}; 21190 }, i2.prototype.completeService = function(e3, t2) { 21191 this.currentServiceIndex = -1, e3 && e3(t2); 21192 }, i2.prototype.logError = function(e3) { 21193 var t2 = this.currentServiceIndex, i3 = this.getServiceByIdx(t2); 21194 console.warn("The service[" + t2 + "] (" + i3.url + ") responded with the following error", e3); 21195 }, i2; 21196 })(), e.Law = (function() { 21197 var e2 = { regionalLaw: true, hasLaw: ["AT", "BE", "BG", "HR", "CZ", "CY", "DK", "EE", "FI", "FR", "DE", "EL", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "SK", "ES", "SE", "GB", "UK", "GR", "EU"], revokable: ["HR", "CY", "DK", "EE", "FR", "DE", "LV", "LT", "NL", "PT", "ES"], explicitAction: ["HR", "IT", "ES"] }; 21198 function i2(e3) { 21199 this.initialise.apply(this, arguments); 21200 } 21201 return i2.prototype.initialise = function(i3) { 21202 t.deepExtend(this.options = {}, e2), t.isPlainObject(i3) && t.deepExtend(this.options, i3); 21203 }, i2.prototype.get = function(e3) { 21204 var t2 = this.options; 21205 return { hasLaw: t2.hasLaw.indexOf(e3) >= 0, revokable: t2.revokable.indexOf(e3) >= 0, explicitAction: t2.explicitAction.indexOf(e3) >= 0 }; 21206 }, i2.prototype.applyLaw = function(e3, t2) { 21207 var i3 = this.get(t2); 21208 return i3.hasLaw || (e3.enabled = false, "function" == typeof e3.onNoCookieLaw && e3.onNoCookieLaw(t2, i3)), this.options.regionalLaw && (i3.revokable && (e3.revokable = true), i3.explicitAction && (e3.dismissOnScroll = false, e3.dismissOnTimeout = false)), e3; 21209 }, i2; 21210 })(), e.initialise = function(i2, n, o) { 21211 var s = new e.Law(i2.law); 21212 n || (n = function() { 21213 }), o || (o = function() { 21214 }); 21215 var r = Object.keys(e.status), a = t.getCookie("cookieconsent_status"); 21216 r.indexOf(a) >= 0 ? n(new e.Popup(i2)) : e.getCountryCode(i2, function(t2) { 21217 delete i2.law, delete i2.location, t2.code && (i2 = s.applyLaw(i2, t2.code)), n(new e.Popup(i2)); 21218 }, function(t2) { 21219 delete i2.law, delete i2.location, o(t2, new e.Popup(i2)); 21220 }); 21221 }, e.getCountryCode = function(t2, i2, n) { 21222 t2.law && t2.law.countryCode ? i2({ code: t2.law.countryCode }) : t2.location ? new e.Location(t2.location).locate(function(e2) { 21223 i2(e2 || {}); 21224 }, n) : i2({}); 21225 }, e.utils = t, e.hasInitialised = true, window.cookieconsent = e; 21226 } 21227 })(window.cookieconsent || {}); 21228 21229
21229// app/javascript/ckeditor/config.js 21230 if (typeof CKEDITOR !== "undefined") { 21231 CKEDITOR.editorConfig = function(config2) { 21232 config2.language = "de"; 21233 config2.uiColor = "#ffffff"; 21234 config2.filebrowserBrowseUrl = "/ckeditor/attachment_files"; 21235 config2.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files"; 21236 config2.filebrowserFlashUploadUrl = "/ckeditor/attachment_files"; 21237 config2.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures"; 21238 config2.filebrowserImageBrowseUrl = "/ckeditor/pictures"; 21239 config2.filebrowserImageUploadUrl = "/ckeditor/pictures?"; 21240 config2.filebrowserUploadUrl = "/ckeditor/attachment_files"; 21241 config2.allowedContent = true; 21242 config2.filebrowserUploadMethod = "form"; 21243 config2.toolbar = [ 21244 { name: "document", groups: ["mode", "document", "doctools"], items: ["Source"] }, 21245 { 21246 name: "clipboard", 21247 groups: ["clipboard", "undo"], 21248 items: ["Cut", "Copy", "Paste", "PasteText", "PasteFromWord", "-", "Undo", "Redo"] 21249 }, 21250 // { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] }, 21251 // { name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] }, 21252 { name: "links", items: ["Link", "Unlink", "Anchor"] }, 21253 { name: "insert", items: ["Image", "Flash", "Table", "HorizontalRule", "SpecialChar"] }, 21254 { 21255 name: "paragraph", 21256 groups: ["list", "indent", "blocks", "align", "bidi"], 21257 items: ["NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "Blockquote", "CreateDiv", "-", "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"] 21258 }, 21259 "/", 21260 { name: "styles", items: ["Styles", "Format", "Font", "FontSize"] }, 21261 { name: "colors", items: ["TextColor", "BGColor"] }, 21262 { 21263 name: "basicstyles", 21264 groups: ["basicstyles", "cleanup"], 21265 items: ["Bold", "Italic", "Underline", "Strike", "Subscript", "Superscript", "-", "RemoveFormat"] 21266 } 21267 ]; 21268 config2.toolbar_mini = [ 21269 { 21270 name: "paragraph", 21271 groups: ["list", "indent", "blocks", "align", "bidi"], 21272 items: ["NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "Blockquote", "CreateDiv", "-", "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"] 21273 }, 21274 { name: "styles", items: ["Font", "FontSize"] }, 21275 { name: "colors", items: ["TextColor", "BGColor"] }, 21276 { 21277 name: "basicstyles", 21278 groups: ["basicstyles", "cleanup"], 21279 items: ["Bold", "Italic", "Underline", "Strike", "Subscript", "Superscript", "-", "RemoveFormat"] 21280 }, 21281 { name: "insert", items: ["Image", "Table", "HorizontalRule", "SpecialChar"] } 21282 ]; 21283 }; 21284 } 21285 21286
21286// app/javascript/cookie_banner.js 21287 $(document).on("turbo:load", function() { 21288 const gtmKey = window.Germann.cookieConsent.googleTagManagerKey; 21289 window.dataLayer = window.dataLayer || []; 21290 function gtag() { 21291 dataLayer.push(arguments); 21292 } 21293 function updateGTMConsent(state, accepted) { 21294 if (gtmKey === "") return; 21295 gtag("consent", state, { 21296 "ad_storage": accepted ? "granted" : "denied", 21297 "ad_user_data": accepted ? "granted" : "denied", 21298 "ad_personalization": accepted ? "granted" : "denied", 21299 "analytics_storage": accepted ? "granted" : "denied", 21300 "personalization_storage": accepted ? "granted" : "denied", 21301 "functional_storage": accepted ? "granted" : "denied", 21302 "security_storage": accepted ? "granted" : "denied", 21303 "wait_for_update": 500 21304 }); 21305 } 21306 if (window.cookieconsent) { 21307 window.cookieconsent.initialise({ 21308 "type": "opt-in", 21309 "cookie": { "name": "cookie_consent_status", "domain": window.location.hostname }, 21310 "cookieconsent": { "status": { "deny": "deny", "allow": "allow", "dismiss": "dismiss" } }, 21311 "position": "bottom-right", 21312 onPopupOpen: function() { 21313 updateGTMConsent("default", false); 21314 }, 21315 onInitialise: function(status) { 21316 updateGTMConsent("default", status === "allow"); 21317 }, 21318 onStatusChange: function(status, chosenBefore) { 21319 updateGTMConsent("update", status === "allow"); 21320 }, 21321 "palette": { 21322 "popup": { 21323 "background": "#ffffff", 21324 "text": "#000000" 21325 }, 21326 "button": { 21327 "background": "#000000", 21328 "text": "#ffffff" 21329 } 21330 }, 21331 "content": window.Germann.cookieConsent.content 21332 }); 21333 } 21334 if (gtmKey !== "") { 21335 (function(w, d, s, l, i) { 21336 w[l] = w[l] || []; 21337 w[l].push({ 21338 "gtm.start": (/* @__PURE__ */ new Date()).getTime(), 21339 event: "gtm.js" 21340 }); 21341 var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != "dataLayer" ? "&l=" + l : ""; 21342 j.async = true; 21343 j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl; 21344 f.parentNode.insertBefore(j, f); 21345 })(window, document, "script", "dataLayer", gtmKey); 21346 } 21347 }); 21348 21349
21349// app/javascript/acceptance_import.js 21350 $(document).on("turbo:load", function() { 21351 $("[data-restyled-file-input]").change(function() { 21352 var submitButton = $("[data-restyled-file-submit]"); 21353 if (!$(this).val()) { 21354 submitButton.prop("disabled", true); 21355 } else { 21356 var filename = $(this).val().replace(/\\/g, "/").replace(/.*\//, ""); 21357 $(this).closest("[data-restyled-file-selection]").find("[data-file-name]").html(filename); 21358 submitButton.prop("disabled", false); 21359 } 21360 }); 21361 }); 21362 21363
21363// app/javascript/artist_overview.js 21364 $(document).on("turbo:load", () => { 21365 const artistOverviewSelector = "[data-artist-overview]"; 21366 const artistOverview = $(artistOverviewSelector); 21367 const navbarHeight = $("nav.fixed-top").height() + 1; 21368 if ($(artistOverviewSelector).length) { 21369 $("body").scrollspy({ 21370 target: artistOverviewSelector, 21371 offset: navbarHeight 21372 }); 21373 if (CSS && CSS.supports && CSS.supports("position", "sticky")) { 21374 artistOverview.css("top", navbarHeight); 21375 } 21376 } 21377 }); 21378 21379
21379// app/javascript/cookie_malfunction_warning.js 21380 window.cookiesEnabled = function() { 21381 if ("cookieEnabled" in navigator) { 21382 return navigator.cookieEnabled; 21383 } 21384 document.cookie = "testing_cookie=12"; 21385 return document.cookie.indexOf("testing_cookie") !== -1; 21386 }; 21387 if (!cookiesEnabled()) { 21388 $(document).on("turbo:load", () => { 21389 $(".cookie-malfunction-warning").css("display", "block"); 21390 $(".btn[data-requires-cookies]").attr("disabled", "disabled").addClass("disabled"); 21391 }); 21392 } 21393 21394
21394// app/javascript/forms.js 21395 function submitCorrespondingForm(event) { 21396 const form = $(event.target.form)[0]; 21397 form.requestSubmit(); 21398 } 21399 $(document).on("turbo:load", () => { 21400 $("[data-submit-on-change]").change((event) => { 21401 submitCorrespondingForm(event); 21402 }); 21403 $("[data-submit-on-enter]").keydown((event) => { 21404 if (event.keyCode !== 13) { 21405 return; 21406 } 21407 submitCorrespondingForm(event); 21408 event.preventDefault(); 21409 }); 21410 $("[data-select-on-focus]").focus(function() { 21411 $(this).select(); 21412 }); 21413 }); 21414 21415
21415// app/javascript/auction_item_image_import.js 21416 $(document).on("turbo:load", function() { 21417 if (!window.Dropzone) { 21418 return; 21419 } 21420 window.Dropzone.options.itemImagesUpload = { 21421 url: "/auction_item_image_imports", 21422 paramName: "auction_item_image_import[files]", 21423 headers: { "X-CSRF-Token": document.querySelector('meta[name="csrf-token"]')?.getAttribute("content") }, 21424 parallelUploads: 5, 21425 uploadMultiple: true, 21426 addRemoveLinks: true, 21427 init: function() { 21428 let errorMessages = /* @__PURE__ */ new Set(); 21429 this.on("sendingmultiple", function(data, xhr, formData) { 21430 const selectedAuctionNumbers = getSelectedAuctionNumbers(); 21431 for (const auctionNumber of selectedAuctionNumbers) { 21432 formData.append("auction_item_image_import[auction_numbers][]", auctionNumber); 21433 } 21434 }); 21435 this.on("errormultiple", function(files, message, _) { 21436 if (getSelectedAuctionNumbers().length === 0 && errorMessages.size > 0) { 21437 return; 21438 } 21439 errorMessages.add(message.error); 21440 displayBanner(Array.from(errorMessages).join("<br>"), "danger"); 21441 }); 21442 this.on("queuecomplete", function() { 21443 if (errorMessages.size > 0) { 21444 return; 21445 } 21446 displayBanner(window.Germann.dropzone.auction_images_upload.success, "success"); 21447 }); 21448 function getSelectedAuctionNumbers() { 21449 const auctionInputs = document.querySelectorAll("[data-auction-numbers]:checked"); 21450 return Array.from(auctionInputs).map((input) => input.value); 21451 } 21452 function displayBanner(message, type) { 21453 const alertDiv = document.querySelector("[data-auction-images-upload-messages]"); 21454 const alertMessage = document.createElement("div"); 21455 alertMessage.classList.add("alert", `alert-${type}`); 21456 alertMessage.innerHTML = message; 21457 alertDiv.innerHTML = ""; 21458 alertDiv.appendChild(alertMessage); 21459 } 21460 } 21461 }; 21462 }); 21463 21464
21464// app/javascript/initialize_dropzone.js 21465 if (window.Dropzone) { 21466 window.Dropzone.autoDiscover = false; 21467 $(document).on("turbo:load", window.Dropzone.discover); 21468 } 21469 21470
21470// app/javascript/infinite_scroll.js 21471 document.addEventListener("turbo:load", () => { 21472 const loadMores = document.querySelectorAll("[data-load-more]"); 21473 const initLoadMore = (more) => { 21474 if (!more) return; 21475 let page = 1; 21476 const maxPages = Number(more.dataset.totalPages); 21477 const itemListReference = more.dataset.loadMore; 21478 if (maxPages <= 1) return; 21479 const io = new IntersectionObserver((entries) => { 21480 entries.forEach((e) => { 21481 if (e.isIntersecting) { 21482 const target = e.target; 21483 io.unobserve(target); 21484 const params = new URLSearchParams(location.search); 21485 params.set("page", ++page); 21486 const itemListSelector = `.item-list[data-item-list-reference='${itemListReference}']`; 21487 fetch(`${location.pathname}?${params.toString()}`).then((r) => r.text()).then((htmlStr) => { 21488 const response = document.createElement("div"); 21489 response.innerHTML = htmlStr; 21490 const children = [...response.querySelector(itemListSelector).childNodes]; 21491 document.querySelector(itemListSelector)?.append(...children); 21492 if (page < maxPages) { 21493 io.observe(children.at(-1)); 21494 } else { 21495 more.remove(); 21496 } 21497 }); 21498 } 21499 ; 21500 }); 21501 }, { rootMargin: "1000px 0px" }); 21502 io.observe(more); 21503 };
21504 loadMores.forEach((more) => initLoadMore(more)); 21505 }); 21506 21507
21507// app/javascript/item_form.js 21508 $(document).on("turbo:load", () => { 21509 const artistSelect = $("[data-item-artist-select]"); 21510 if (artistSelect.length) { 21511 artistSelect.selectize({ 21512 items: $("[data-item-artist-ids]").val().split(" "), 21513 onChange: function(value) { 21514 $("[data-item-artist-ids]").val((value || []).join(" ")); 21515 } 21516 }); 21517 } 21518 $("[data-autoheight]").each((_index, element) => { 21519 const offset = 2; 21520 element.style.height = element.scrollHeight + offset + "px"; 21521 }); 21522 }); 21523 21524
21524// app/javascript/item_image.js 21525 var import_viewerjs = __toESM(require_viewer()); 21526 var viewerOptions = { 21527 title: false, 21528 rotatable: false, 21529 scalable: false, 21530 navbar: false, 21531 minZoomRatio: 0.4, 21532 maxZoomRatio: 4, 21533 tooltip: false, 21534 toolbar: { 21535 prev: { 21536 show: true, 21537 size: "large" 21538 }, 21539 next: { 21540 show: true, 21541 size: "large" 21542 } 21543 } 21544 }; 21545 $(document).on("click", ".item-image", function(event) { 21546 event.preventDefault(); 21547 const clonedImage = $(this).clone(); 21548 clonedImage.removeClass("item-image"); 21549 clonedImage.addClass("main-image"); 21550 $("div[data-main-image]").each((_, wrapper) => { 21551 if (wrapper.offsetParent) $(wrapper).html(clonedImage); 21552 }); 21553 }); 21554 $(document).on("click", "div[data-main-image]", function(event) { 21555 event.preventDefault(); 21556 const imageIdx = $(this).find("img").data("gallery-index") || 0; 21557 const images = document.getElementById("item-images").cloneNode(true); 21558 const gallery = new import_viewerjs.default(images, viewerOptions); 21559 gallery.view(imageIdx); 21560 }); 21561 21562
21562// app/javascript/item_print.js 21563 $(document).on("turbo:load", () => { 21564 $(".print-item").click((e) => { 21565 e.preventDefault(); 21566 window.print(); 21567 }); 21568 }); 21569 21570
21570// app/javascript/messages.js 21571 $(document).on("turbo:load", () => { 21572 let alertElement = $(".alert-dismissable"); 21573 if (alertElement.length) { 21574 setTimeout(() => { 21575 alertElement.alert("close"); 21576 }, 12e3); 21577 } 21578 }); 21579 21580
21580// app/javascript/mobile_toggle.js 21581 $(document).on("turbo:load", () => { 21582 const isMobile = $('[data-toggle="collapse"].navbar-toggler').is(":visible"); 21583 if (isMobile) { 21584 $("[data-mobile-dropdown-toggle]").each((idx, el) => { 21585 $(el).attr("data-toggle", "dropdown"); 21586 }); 21587 } 21588 }); 21589 21590
21590// app/javascript/open_url.js 21591 $(document).on("turbo:load", () => { 21592 $("[data-open-url]").click((event) => { 21593 const path = $(event.currentTarget).data("open-url"); 21594 if (path) { 21595 Turbo.visit(path); 21596 } 21597 }); 21598 }); 21599 21600
21600// app/javascript/pagination_observer.js 21601 document.addEventListener("turbo:load", () => { 21602 const paginations = document.querySelectorAll(".pagination-nav-bottom"); 21603 const initPagination = (pagination) => { 21604 window.addEventListener("scroll", function() { 21605 if (window.scrollY > 0) { 21606 pagination.classList.add("position-sticky"); 21607 } else { 21608 pagination.classList.remove("position-sticky"); 21609 } 21610 }); 21611 }; 21612 paginations.forEach((pagination) => initPagination(pagination)); 21613 }); 21614 21615
21615// app/javascript/recaptcha.js 21616 $(document).on("turbo:load", () => { 21617 if (typeof RecaptchaKey !== "undefined") { 21618 $("[data-recaptcha]").submit(function(event) { 21619 grecaptcha.ready(function() { 21620 grecaptcha.execute(RecaptchaKey, { action: "new_contact_request" }).then(function(token) { 21621 var hiddenTag = $('<input type="hidden" name="recaptcha">'); 21622 hiddenTag.val(token); 21623 $(event.target).append(hiddenTag); 21624 event.target.submit(); 21625 }); 21626 }); 21627 return false; 21628 }); 21629 } 21630 }); 21631 21632
21632// app/javascript/smooth_scroll.js 21633 $(document).on("click", 'a[href*="#"]:not([href="#"])', function(event) { 21634 if (location.pathname.replace(/^\//, "") == this.pathname.replace(/^\//, "") && location.hostname == this.hostname) { 21635 var target = $(this.hash); 21636 target = target.length ? target : $("[name=" + this.hash.slice(1) + "]"); 21637 if (target.length) { 21638 event.preventDefault(); 21639 $("html, body").animate({ 21640 scrollTop: target.offset().top - $("nav.fixed-top").height() 21641 }, 1e3, function() { 21642 var $target = $(target); 21643 $target.focus(); 21644 if ($target.is(":focus")) { 21645 return false; 21646 } else { 21647 $target.attr("tabindex", "-1"); 21648 $target.focus(); 21649 } 21650 ; 21651 }); 21652 } 21653 } 21654 }); 21655 21656
21656// app/javascript/tooltips.js 21657 $(document).on("turbo:load", function() { 21658 $('[data-toggle="tooltip"]').tooltip(); 21659 }); 21660 21661
21661// app/javascript/translation_items_link.js 21662 var TranslationItem = class { 21663 constructor(element) { 21664 this.element = $(element); 21665 this._setupResultContainer(); 21666 this._registerListener(); 21667 } 21668 _setupResultContainer() { 21669 const parent = this.element.parent(); 21670 const existingContainer = parent.find("[data-translation-items-result]"); 21671 if (existingContainer.length) { 21672 this.resultContainer = existingContainer; 21673 this.performed = true; 21674 } else { 21675 this.resultContainer = $('<div data-translation-items-result="1">Loading \u2026</div>'); 21676 this.resultContainer.hide(); 21677 parent.append(this.resultContainer); 21678 } 21679 } 21680 _registerListener() { 21681 this.element.click((event) => { 21682 event.preventDefault(); 21683 this.resultContainer.toggle(); 21684 if (this.performed) { 21685 return; 21686 } 21687 this._fetchItems(); 21688 }); 21689 } 21690 _fetchItems() { 21691 this.performed = true; 21692 $.ajax({ 21693 url: this._path(), 21694 success: (html) => { 21695 this._showResult(html); 21696 }, 21697 error: () => { 21698 this._showResult('<p class="bg-danger text-white p-1">Could not load items for this translation</p>'); 21699 } 21700 }); 21701 } 21702 _showResult(html) { 21703 this.resultContainer.html(html); 21704 } 21705 _path() { 21706 return this.element.data("translation-items-link"); 21707 } 21708 }; 21709 $(document).on("turbo:load", () => { 21710 $("[data-translation-items-link]").map(function() { 21711 new TranslationItem(this); 21712 }); 21713 }); 21714 21715
21715// app/javascript/translations.js 21716 $(document).on("turbo:load", function() { 21717 $("[data-item-translation-form]").submit(function() { 21718 $("[data-reload-hint]").show(); 21719 $("[data-edit-item] :input").prop("disabled", true); 21720 $("[data-edit-item] :input[type=submit]").hide(); 21721 }); 21722 }); 21723 21724
21724// app/javascript/watchlist.js 21725 var Watchlist = class { 21726 constructor() { 21727 this.EXPIRATION = 7; 21728 this._loadItemList(); 21729 if ($('[data-watchlist="form-container"]').length) { 21730 this._initializeItemsForms(); 21731 } 21732 } 21733 addToWatchlist(itemId, { reload = true } = {}) { 21734 const watchlist = this._getWatchlist(); 21735 if (watchlist.indexOf(itemId) === -1) { 21736 this._loadItemList(); 21737 this.itemList.set(itemId, {}); 21738 watchlist.push(itemId); 21739 } 21740 this._saveWatchlist(watchlist); 21741 if (reload) location.reload(); 21742 } 21743 removeFromWatchlist(itemId) { 21744 const watchlist = this._getWatchlist(); 21745 let idx; 21746 if ((idx = watchlist.indexOf(itemId)) !== -1) { 21747 watchlist.splice(idx, 1); 21748 } 21749 this._loadItemList(); 21750 this.itemList.delete(itemId); 21751 this._saveWatchlist(watchlist); 21752 location.reload(); 21753 } 21754 togglePhoneBid(itemId, checked) { 21755 this._toggleBidField(itemId, checked); 21756 this._loadItemList(); 21757 this.itemList.get(itemId).phone_bid = checked; 21758 this._saveWatchlist(); 21759 } 21760 updatePrice(itemId, value) { 21761 this._loadItemList(); 21762 this.itemList.get(itemId).price = value; 21763 this._saveWatchlist(); 21764 } 21765 _loadItemList() { 21766 this.itemList = new Map(localStorage.watchlist ? JSON.parse(localStorage.watchlist) : void 0); 21767 } 21768 _getWatchlist() { 21769 const watchlist = Cookies.get("watchlist"); 21770 return watchlist ? watchlist.split(",") : []; 21771 } 21772 _saveWatchlist(watchlist = this._getWatchlist()) { 21773 Cookies.set("watchlist", watchlist.join(","), { path: "/", expires: this.EXPIRATION }); 21774 localStorage.watchlist = JSON.stringify([...this.itemList]); 21775 } 21776 _initializeItemsForms() { 21777 for (let [itemId, values] of this.itemList) { 21778 $('[data-watchlist="phone-bid"][data-item-id="' + itemId + '"]').prop("checked", values.phone_bid); 21779 $('[data-watchlist="price-field"][data-item-id="' + itemId + '"]').val(values.price); 21780 this._toggleBidField(itemId, values.phone_bid); 21781 } 21782 } 21783 _toggleBidField(itemId, checked) { 21784 const bidField = $('[data-bid-field-id="' + itemId + '"]'); 21785 checked ? bidField.hide() : bidField.show(); 21786 } 21787 }; 21788 $(document).on("turbo:load", function() { 21789 if (cookiesEnabled() && $("[data-watchlist]").length > 0) { 21790 const watchlist = new Watchlist(); 21791 $('[data-watchlist="add"]').click(function(evt) { 21792 evt.preventDefault(); 21793 evt.stopPropagation(); 21794 const itemId = $(evt.currentTarget).data("item-id").toString(); 21795 watchlist.addToWatchlist(itemId); 21796 }); 21797 $('[data-watchlist="add-and-redirect"]').click(function(evt) { 21798 evt.preventDefault(); 21799 evt.stopPropagation(); 21800 const itemId = $(evt.currentTarget).data("item-id").toString(); 21801 watchlist.addToWatchlist(itemId, { reload: false }); 21802 Turbo.visit($(evt.currentTarget).data("redirect-url")); 21803 }); 21804 $('[data-watchlist="remove"]').click(function(evt) { 21805 evt.preventDefault(); 21806 evt.stopPropagation(); 21807 const itemId = $(evt.currentTarget).data("item-id").toString(); 21808 watchlist.removeFromWatchlist(itemId); 21809 }); 21810 $('[data-watchlist="phone-bid"]').click(function(evt) { 21811 const itemId = $(evt.target).data("item-id").toString(); 21812 watchlist.togglePhoneBid(itemId, evt.target.checked); 21813 }); 21814 $('[data-watchlist="price-field"]').keyup(function(evt) { 21815 evt.preventDefault(); 21816 evt.stopPropagation(); 21817 const itemId = $(evt.target).data("item-id").toString(); 21818 watchlist.updatePrice(itemId, evt.target.value); 21819 }); 21820 } 21821 }); 21822 21823
vendor: 84,336 bytes, lines 21823-24271
21823// node_modules/@hotwired/stimulus/dist/stimulus.js 21824 var EventListener = class { 21825 constructor(eventTarget, eventName, eventOptions) { 21826 this.eventTarget = eventTarget; 21827 this.eventName = eventName; 21828 this.eventOptions = eventOptions; 21829 this.unorderedBindings = /* @__PURE__ */ new Set(); 21830 } 21831 connect() { 21832 this.eventTarget.addEventListener(this.eventName, this, this.eventOptions); 21833 } 21834 disconnect() { 21835 this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions); 21836 } 21837 bindingConnected(binding) { 21838 this.unorderedBindings.add(binding); 21839 } 21840 bindingDisconnected(binding) { 21841 this.unorderedBindings.delete(binding); 21842 } 21843 handleEvent(event) { 21844 const extendedEvent = extendEvent(event); 21845 for (const binding of this.bindings) { 21846 if (extendedEvent.immediatePropagationStopped) { 21847 break; 21848 } else { 21849 binding.handleEvent(extendedEvent); 21850 } 21851 } 21852 } 21853 hasBindings() { 21854 return this.unorderedBindings.size > 0; 21855 } 21856 get bindings() { 21857 return Array.from(this.unorderedBindings).sort((left, right) => { 21858 const leftIndex = left.index, rightIndex = right.index; 21859 return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0; 21860 }); 21861 } 21862 }; 21863 function extendEvent(event) { 21864 if ("immediatePropagationStopped" in event) { 21865 return event; 21866 } else { 21867 const { stopImmediatePropagation } = event; 21868 return Object.assign(event, { 21869 immediatePropagationStopped: false, 21870 stopImmediatePropagation() { 21871 this.immediatePropagationStopped = true; 21872 stopImmediatePropagation.call(this); 21873 } 21874 }); 21875 } 21876 } 21877 var Dispatcher = class { 21878 constructor(application2) { 21879 this.application = application2; 21880 this.eventListenerMaps = /* @__PURE__ */ new Map(); 21881 this.started = false; 21882 } 21883 start() { 21884 if (!this.started) { 21885 this.started = true; 21886 this.eventListeners.forEach((eventListener) => eventListener.connect()); 21887 } 21888 } 21889 stop() { 21890 if (this.started) { 21891 this.started = false; 21892 this.eventListeners.forEach((eventListener) => eventListener.disconnect()); 21893 } 21894 } 21895 get eventListeners() { 21896 return Array.from(this.eventListenerMaps.values()).reduce((listeners, map) => listeners.concat(Array.from(map.values())), []); 21897 } 21898 bindingConnected(binding) { 21899 this.fetchEventListenerForBinding(binding).bindingConnected(binding); 21900 } 21901 bindingDisconnected(binding, clearEventListeners = false) { 21902 this.fetchEventListenerForBinding(binding).bindingDisconnected(binding); 21903 if (clearEventListeners) 21904 this.clearEventListenersForBinding(binding); 21905 } 21906 handleError(error2, message, detail = {}) { 21907 this.application.handleError(error2, `Error ${message}`, detail); 21908 } 21909 clearEventListenersForBinding(binding) { 21910 const eventListener = this.fetchEventListenerForBinding(binding); 21911 if (!eventListener.hasBindings()) { 21912 eventListener.disconnect(); 21913 this.removeMappedEventListenerFor(binding); 21914 } 21915 } 21916 removeMappedEventListenerFor(binding) { 21917 const { eventTarget, eventName, eventOptions } = binding; 21918 const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget); 21919 const cacheKey = this.cacheKey(eventName, eventOptions); 21920 eventListenerMap.delete(cacheKey); 21921 if (eventListenerMap.size == 0) 21922 this.eventListenerMaps.delete(eventTarget); 21923 } 21924 fetchEventListenerForBinding(binding) { 21925 const { eventTarget, eventName, eventOptions } = binding; 21926 return this.fetchEventListener(eventTarget, eventName, eventOptions); 21927 } 21928 fetchEventListener(eventTarget, eventName, eventOptions) { 21929 const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget); 21930 const cacheKey = this.cacheKey(eventName, eventOptions); 21931 let eventListener = eventListenerMap.get(cacheKey); 21932 if (!eventListener) { 21933 eventListener = this.createEventListener(eventTarget, eventName, eventOptions); 21934 eventListenerMap.set(cacheKey, eventListener); 21935 } 21936 return eventListener; 21937 } 21938 createEventListener(eventTarget, eventName, eventOptions) { 21939 const eventListener = new EventListener(eventTarget, eventName, eventOptions); 21940 if (this.started) { 21941 eventListener.connect(); 21942 } 21943 return eventListener; 21944 } 21945 fetchEventListenerMapForEventTarget(eventTarget) { 21946 let eventListenerMap = this.eventListenerMaps.get(eventTarget); 21947 if (!eventListenerMap) { 21948 eventListenerMap = /* @__PURE__ */ new Map(); 21949 this.eventListenerMaps.set(eventTarget, eventListenerMap); 21950 } 21951 return eventListenerMap; 21952 } 21953 cacheKey(eventName, eventOptions) { 21954 const parts = [eventName]; 21955 Object.keys(eventOptions).sort().forEach((key) => { 21956 parts.push(`${eventOptions[key] ? "" : "!"}${key}`); 21957 }); 21958 return parts.join(":"); 21959 } 21960 }; 21961 var defaultActionDescriptorFilters = { 21962 stop({ event, value }) { 21963 if (value) 21964 event.stopPropagation(); 21965 return true; 21966 }, 21967 prevent({ event, value }) { 21968 if (value) 21969 event.preventDefault(); 21970 return true; 21971 }, 21972 self({ event, value, element }) { 21973 if (value) { 21974 return element === event.target; 21975 } else { 21976 return true; 21977 } 21978 } 21979 }; 21980 var descriptorPattern = /^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/; 21981 function parseActionDescriptorString(descriptorString) { 21982 const source = descriptorString.trim(); 21983 const matches2 = source.match(descriptorPattern) || []; 21984 let eventName = matches2[2]; 21985 let keyFilter = matches2[3]; 21986 if (keyFilter && !["keydown", "keyup", "keypress"].includes(eventName)) { 21987 eventName += `.${keyFilter}`; 21988 keyFilter = ""; 21989 } 21990 return { 21991 eventTarget: parseEventTarget(matches2[4]), 21992 eventName, 21993 eventOptions: matches2[7] ? parseEventOptions(matches2[7]) : {}, 21994 identifier: matches2[5], 21995 methodName: matches2[6], 21996 keyFilter: matches2[1] || keyFilter 21997 }; 21998 } 21999 function parseEventTarget(eventTargetName) { 22000 if (eventTargetName == "window") { 22001 return window; 22002 } else if (eventTargetName == "document") { 22003 return document; 22004 } 22005 } 22006 function parseEventOptions(eventOptions) { 22007 return eventOptions.split(":").reduce((options, token) => Object.assign(options, { [token.replace(/^!/, "")]: !/^!/.test(token) }), {}); 22008 } 22009 function stringifyEventTarget(eventTarget) { 22010 if (eventTarget == window) { 22011 return "window"; 22012 } else if (eventTarget == document) { 22013 return "document"; 22014 } 22015 } 22016 function camelize(value) { 22017 return value.replace(/(?:[_-])([a-z0-9])/g, (_, char) => char.toUpperCase()); 22018 } 22019 function namespaceCamelize(value) { 22020 return camelize(value.replace(/--/g, "-").replace(/__/g, "_")); 22021 } 22022 function capitalize(value) { 22023 return value.charAt(0).toUpperCase() + value.slice(1); 22024 } 22025 function dasherize(value) { 22026 return value.replace(/([A-Z])/g, (_, char) => `-${char.toLowerCase()}`); 22027 } 22028 function tokenize(value) { 22029 return value.match(/[^\s]+/g) || []; 22030 } 22031 function isSomething(object) { 22032 return object !== null && object !== void 0; 22033 } 22034 function hasProperty(object, property) { 22035 return Object.prototype.hasOwnProperty.call(object, property); 22036 } 22037 var allModifiers = ["meta", "ctrl", "alt", "shift"]; 22038 var Action = class { 22039 constructor(element, index, descriptor, schema) { 22040 this.element = element; 22041 this.index = index; 22042 this.eventTarget = descriptor.eventTarget || element; 22043 this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name"); 22044 this.eventOptions = descriptor.eventOptions || {}; 22045 this.identifier = descriptor.identifier || error("missing identifier"); 22046 this.methodName = descriptor.methodName || error("missing method name"); 22047 this.keyFilter = descriptor.keyFilter || ""; 22048 this.schema = schema; 22049 } 22050 static forToken(token, schema) { 22051 return new this(token.element, token.index, parseActionDescriptorString(token.content), schema); 22052 } 22053 toString() { 22054 const eventFilter = this.keyFilter ? `.${this.keyFilter}` : ""; 22055 const eventTarget = this.eventTargetName ? `@${this.eventTargetName}` : ""; 22056 return `${this.eventName}${eventFilter}${eventTarget}->${this.identifier}#${this.methodName}`; 22057 } 22058 shouldIgnoreKeyboardEvent(event) { 22059 if (!this.keyFilter) { 22060 return false; 22061 } 22062 const filters = this.keyFilter.split("+"); 22063 if (this.keyFilterDissatisfied(event, filters)) { 22064 return true; 22065 } 22066 const standardFilter = filters.filter((key) => !allModifiers.includes(key))[0]; 22067 if (!standardFilter) { 22068 return false; 22069 } 22070 if (!hasProperty(this.keyMappings, standardFilter)) { 22071 error(`contains unknown key filter: ${this.keyFilter}`); 22072 } 22073 return this.keyMappings[standardFilter].toLowerCase() !== event.key.toLowerCase(); 22074 } 22075 shouldIgnoreMouseEvent(event) { 22076 if (!this.keyFilter) { 22077 return false; 22078 } 22079 const filters = [this.keyFilter]; 22080 if (this.keyFilterDissatisfied(event, filters)) { 22081 return true; 22082 } 22083 return false; 22084 } 22085 get params() { 22086 const params = {}; 22087 const pattern = new RegExp(`^data-${this.identifier}-(.+)-param$`, "i"); 22088 for (const { name, value } of Array.from(this.element.attributes)) { 22089 const match = name.match(pattern); 22090 const key = match && match[1]; 22091 if (key) { 22092 params[camelize(key)] = typecast(value); 22093 } 22094 } 22095 return params; 22096 } 22097 get eventTargetName() { 22098 return stringifyEventTarget(this.eventTarget); 22099 } 22100 get keyMappings() { 22101 return this.schema.keyMappings; 22102 } 22103 keyFilterDissatisfied(event, filters) { 22104 const [meta, ctrl, alt, shift] = allModifiers.map((modifier) => filters.includes(modifier)); 22105 return event.metaKey !== meta || event.ctrlKey !== ctrl || event.altKey !== alt || event.shiftKey !== shift; 22106 } 22107 }; 22108 var defaultEventNames = { 22109 a: () => "click", 22110 button: () => "click", 22111 form: () => "submit", 22112 details: () => "toggle", 22113 input: (e) => e.getAttribute("type") == "submit" ? "click" : "input", 22114 select: () => "change", 22115 textarea: () => "input" 22116 }; 22117 function getDefaultEventNameForElement(element) { 22118 const tagName = element.tagName.toLowerCase(); 22119 if (tagName in defaultEventNames) { 22120 return defaultEventNames[tagName](element); 22121 } 22122 } 22123 function error(message) { 22124 throw new Error(message); 22125 } 22126 function typecast(value) { 22127 try { 22128 return JSON.parse(value); 22129 } catch (o_O) { 22130 return value; 22131 } 22132 } 22133 var Binding = class { 22134 constructor(context, action) { 22135 this.context = context; 22136 this.action = action; 22137 } 22138 get index() { 22139 return this.action.index; 22140 } 22141 get eventTarget() { 22142 return this.action.eventTarget; 22143 } 22144 get eventOptions() { 22145 return this.action.eventOptions; 22146 } 22147 get identifier() { 22148 return this.context.identifier; 22149 } 22150 handleEvent(event) { 22151 const actionEvent = this.prepareActionEvent(event); 22152 if (this.willBeInvokedByEvent(event) && this.applyEventModifiers(actionEvent)) { 22153 this.invokeWithEvent(actionEvent); 22154 } 22155 } 22156 get eventName() { 22157 return this.action.eventName; 22158 } 22159 get method() { 22160 const method = this.controller[this.methodName]; 22161 if (typeof method == "function") { 22162 return method; 22163 } 22164 throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`); 22165 } 22166 applyEventModifiers(event) { 22167 const { element } = this.action; 22168 const { actionDescriptorFilters } = this.context.application; 22169 const { controller } = this.context; 22170 let passes = true; 22171 for (const [name, value] of Object.entries(this.eventOptions)) { 22172 if (name in actionDescriptorFilters) { 22173 const filter = actionDescriptorFilters[name]; 22174 passes = passes && filter({ name, value, event, element, controller }); 22175 } else { 22176 continue; 22177 } 22178 } 22179 return passes; 22180 } 22181 prepareActionEvent(event) { 22182 return Object.assign(event, { params: this.action.params }); 22183 } 22184 invokeWithEvent(event) { 22185 const { target, currentTarget } = event; 22186 try { 22187 this.method.call(this.controller, event); 22188 this.context.logDebugActivity(this.methodName, { event, target, currentTarget, action: this.methodName }); 22189 } catch (error2) { 22190 const { identifier, controller, element, index } = this; 22191 const detail = { identifier, controller, element, index, event }; 22192 this.context.handleError(error2, `invoking action "${this.action}"`, detail); 22193 } 22194 } 22195 willBeInvokedByEvent(event) { 22196 const eventTarget = event.target; 22197 if (event instanceof KeyboardEvent && this.action.shouldIgnoreKeyboardEvent(event)) { 22198 return false; 22199 } 22200 if (event instanceof MouseEvent && this.action.shouldIgnoreMouseEvent(event)) { 22201 return false; 22202 } 22203 if (this.element === eventTarget) { 22204 return true; 22205 } else if (eventTarget instanceof Element && this.element.contains(eventTarget)) { 22206 return this.scope.containsElement(eventTarget); 22207 } else { 22208 return this.scope.containsElement(this.action.element); 22209 } 22210 } 22211 get controller() { 22212 return this.context.controller; 22213 } 22214 get methodName() { 22215 return this.action.methodName; 22216 } 22217 get element() { 22218 return this.scope.element; 22219 } 22220 get scope() { 22221 return this.context.scope; 22222 } 22223 }; 22224 var ElementObserver = class { 22225 constructor(element, delegate2) { 22226 this.mutationObserverInit = { attributes: true, childList: true, subtree: true }; 22227 this.element = element; 22228 this.started = false; 22229 this.delegate = delegate2; 22230 this.elements = /* @__PURE__ */ new Set(); 22231 this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations)); 22232 } 22233 start() { 22234 if (!this.started) { 22235 this.started = true; 22236 this.mutationObserver.observe(this.element, this.mutationObserverInit); 22237 this.refresh(); 22238 } 22239 } 22240 pause(callback) { 22241 if (this.started) { 22242 this.mutationObserver.disconnect(); 22243 this.started = false; 22244 } 22245 callback(); 22246 if (!this.started) { 22247 this.mutationObserver.observe(this.element, this.mutationObserverInit); 22248 this.started = true; 22249 } 22250 } 22251 stop() { 22252 if (this.started) { 22253 this.mutationObserver.takeRecords(); 22254 this.mutationObserver.disconnect(); 22255 this.started = false; 22256 } 22257 } 22258 refresh() { 22259 if (this.started) { 22260 const matches2 = new Set(this.matchElementsInTree()); 22261 for (const element of Array.from(this.elements)) { 22262 if (!matches2.has(element)) { 22263 this.removeElement(element); 22264 } 22265 } 22266 for (const element of Array.from(matches2)) { 22267 this.addElement(element); 22268 } 22269 } 22270 } 22271 processMutations(mutations) { 22272 if (this.started) { 22273 for (const mutation of mutations) { 22274 this.processMutation(mutation); 22275 } 22276 } 22277 } 22278 processMutation(mutation) { 22279 if (mutation.type == "attributes") { 22280 this.processAttributeChange(mutation.target, mutation.attributeName); 22281 } else if (mutation.type == "childList") { 22282 this.processRemovedNodes(mutation.removedNodes); 22283 this.processAddedNodes(mutation.addedNodes); 22284 } 22285 } 22286 processAttributeChange(element, attributeName) { 22287 if (this.elements.has(element)) { 22288 if (this.delegate.elementAttributeChanged && this.matchElement(element)) { 22289 this.delegate.elementAttributeChanged(element, attributeName); 22290 } else { 22291 this.removeElement(element); 22292 } 22293 } else if (this.matchElement(element)) { 22294 this.addElement(element); 22295 } 22296 } 22297 processRemovedNodes(nodes) { 22298 for (const node of Array.from(nodes)) { 22299 const element = this.elementFromNode(node); 22300 if (element) { 22301 this.processTree(element, this.removeElement); 22302 } 22303 } 22304 } 22305 processAddedNodes(nodes) { 22306 for (const node of Array.from(nodes)) { 22307 const element = this.elementFromNode(node); 22308 if (element && this.elementIsActive(element)) { 22309 this.processTree(element, this.addElement); 22310 } 22311 } 22312 } 22313 matchElement(element) { 22314 return this.delegate.matchElement(element); 22315 } 22316 matchElementsInTree(tree = this.element) { 22317 return this.delegate.matchElementsInTree(tree); 22318 } 22319 processTree(tree, processor) { 22320 for (const element of this.matchElementsInTree(tree)) { 22321 processor.call(this, element); 22322 } 22323 } 22324 elementFromNode(node) { 22325 if (node.nodeType == Node.ELEMENT_NODE) { 22326 return node; 22327 } 22328 } 22329 elementIsActive(element) { 22330 if (element.isConnected != this.element.isConnected) { 22331 return false; 22332 } else { 22333 return this.element.contains(element); 22334 } 22335 } 22336 addElement(element) { 22337 if (!this.elements.has(element)) { 22338 if (this.elementIsActive(element)) { 22339 this.elements.add(element); 22340 if (this.delegate.elementMatched) { 22341 this.delegate.elementMatched(element); 22342 } 22343 } 22344 } 22345 } 22346 removeElement(element) { 22347 if (this.elements.has(element)) { 22348 this.elements.delete(element); 22349 if (this.delegate.elementUnmatched) { 22350 this.delegate.elementUnmatched(element); 22351 } 22352 } 22353 } 22354 }; 22355 var AttributeObserver = class { 22356 constructor(element, attributeName, delegate2) { 22357 this.attributeName = attributeName; 22358 this.delegate = delegate2; 22359 this.elementObserver = new ElementObserver(element, this); 22360 } 22361 get element() { 22362 return this.elementObserver.element; 22363 } 22364 get selector() { 22365 return `[${this.attributeName}]`; 22366 } 22367 start() { 22368 this.elementObserver.start(); 22369 } 22370 pause(callback) { 22371 this.elementObserver.pause(callback); 22372 } 22373 stop() { 22374 this.elementObserver.stop(); 22375 } 22376 refresh() { 22377 this.elementObserver.refresh(); 22378 } 22379 get started() { 22380 return this.elementObserver.started; 22381 } 22382 matchElement(element) { 22383 return element.hasAttribute(this.attributeName); 22384 } 22385 matchElementsInTree(tree) { 22386 const match = this.matchElement(tree) ? [tree] : []; 22387 const matches2 = Array.from(tree.querySelectorAll(this.selector)); 22388 return match.concat(matches2); 22389 } 22390 elementMatched(element) { 22391 if (this.delegate.elementMatchedAttribute) { 22392 this.delegate.elementMatchedAttribute(element, this.attributeName); 22393 } 22394 } 22395 elementUnmatched(element) { 22396 if (this.delegate.elementUnmatchedAttribute) { 22397 this.delegate.elementUnmatchedAttribute(element, this.attributeName); 22398 } 22399 } 22400 elementAttributeChanged(element, attributeName) { 22401 if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) { 22402 this.delegate.elementAttributeValueChanged(element, attributeName); 22403 } 22404 } 22405 }; 22406 function add(map, key, value) { 22407 fetch2(map, key).add(value); 22408 } 22409 function del(map, key, value) { 22410 fetch2(map, key).delete(value); 22411 prune(map, key); 22412 } 22413 function fetch2(map, key) { 22414 let values = map.get(key); 22415 if (!values) { 22416 values = /* @__PURE__ */ new Set(); 22417 map.set(key, values); 22418 } 22419 return values; 22420 } 22421 function prune(map, key) { 22422 const values = map.get(key); 22423 if (values != null && values.size == 0) { 22424 map.delete(key); 22425 } 22426 } 22427 var Multimap = class { 22428 constructor() { 22429 this.valuesByKey = /* @__PURE__ */ new Map(); 22430 } 22431 get keys() { 22432 return Array.from(this.valuesByKey.keys()); 22433 } 22434 get values() { 22435 const sets = Array.from(this.valuesByKey.values()); 22436 return sets.reduce((values, set) => values.concat(Array.from(set)), []); 22437 } 22438 get size() { 22439 const sets = Array.from(this.valuesByKey.values()); 22440 return sets.reduce((size, set) => size + set.size, 0); 22441 } 22442 add(key, value) { 22443 add(this.valuesByKey, key, value); 22444 } 22445 delete(key, value) { 22446 del(this.valuesByKey, key, value); 22447 } 22448 has(key, value) { 22449 const values = this.valuesByKey.get(key); 22450 return values != null && values.has(value); 22451 } 22452 hasKey(key) { 22453 return this.valuesByKey.has(key); 22454 } 22455 hasValue(value) { 22456 const sets = Array.from(this.valuesByKey.values()); 22457 return sets.some((set) => set.has(value)); 22458 } 22459 getValuesForKey(key) { 22460 const values = this.valuesByKey.get(key); 22461 return values ? Array.from(values) : []; 22462 } 22463 getKeysForValue(value) { 22464 return Array.from(this.valuesByKey).filter(([_key, values]) => values.has(value)).map(([key, _values]) => key); 22465 } 22466 }; 22467 var SelectorObserver = class { 22468 constructor(element, selector, delegate2, details) { 22469 this._selector = selector; 22470 this.details = details; 22471 this.elementObserver = new ElementObserver(element, this); 22472 this.delegate = delegate2; 22473 this.matchesByElement = new Multimap(); 22474 } 22475 get started() { 22476 return this.elementObserver.started; 22477 } 22478 get selector() { 22479 return this._selector; 22480 } 22481 set selector(selector) { 22482 this._selector = selector; 22483 this.refresh(); 22484 } 22485 start() { 22486 this.elementObserver.start(); 22487 } 22488 pause(callback) { 22489 this.elementObserver.pause(callback); 22490 } 22491 stop() { 22492 this.elementObserver.stop(); 22493 } 22494 refresh() { 22495 this.elementObserver.refresh(); 22496 } 22497 get element() { 22498 return this.elementObserver.element; 22499 } 22500 matchElement(element) { 22501 const { selector } = this; 22502 if (selector) { 22503 const matches2 = element.matches(selector); 22504 if (this.delegate.selectorMatchElement) { 22505 return matches2 && this.delegate.selectorMatchElement(element, this.details); 22506 } 22507 return matches2; 22508 } else { 22509 return false; 22510 } 22511 } 22512 matchElementsInTree(tree) { 22513 const { selector } = this; 22514 if (selector) { 22515 const match = this.matchElement(tree) ? [tree] : []; 22516 const matches2 = Array.from(tree.querySelectorAll(selector)).filter((match2) => this.matchElement(match2)); 22517 return match.concat(matches2); 22518 } else { 22519 return []; 22520 } 22521 } 22522 elementMatched(element) { 22523 const { selector } = this; 22524 if (selector) { 22525 this.selectorMatched(element, selector); 22526 } 22527 } 22528 elementUnmatched(element) { 22529 const selectors = this.matchesByElement.getKeysForValue(element); 22530 for (const selector of selectors) { 22531 this.selectorUnmatched(element, selector); 22532 } 22533 } 22534 elementAttributeChanged(element, _attributeName) { 22535 const { selector } = this; 22536 if (selector) { 22537 const matches2 = this.matchElement(element); 22538 const matchedBefore = this.matchesByElement.has(selector, element); 22539 if (matches2 && !matchedBefore) { 22540 this.selectorMatched(element, selector); 22541 } else if (!matches2 && matchedBefore) { 22542 this.selectorUnmatched(element, selector); 22543 } 22544 } 22545 } 22546 selectorMatched(element, selector) { 22547 this.delegate.selectorMatched(element, selector, this.details); 22548 this.matchesByElement.add(selector, element); 22549 } 22550 selectorUnmatched(element, selector) { 22551 this.delegate.selectorUnmatched(element, selector, this.details); 22552 this.matchesByElement.delete(selector, element); 22553 } 22554 }; 22555 var StringMapObserver = class { 22556 constructor(element, delegate2) { 22557 this.element = element; 22558 this.delegate = delegate2; 22559 this.started = false; 22560 this.stringMap = /* @__PURE__ */ new Map(); 22561 this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations)); 22562 } 22563 start() { 22564 if (!this.started) { 22565 this.started = true; 22566 this.mutationObserver.observe(this.element, { attributes: true, attributeOldValue: true }); 22567 this.refresh(); 22568 } 22569 } 22570 stop() { 22571 if (this.started) { 22572 this.mutationObserver.takeRecords(); 22573 this.mutationObserver.disconnect(); 22574 this.started = false; 22575 } 22576 } 22577 refresh() { 22578 if (this.started) { 22579 for (const attributeName of this.knownAttributeNames) { 22580 this.refreshAttribute(attributeName, null); 22581 } 22582 } 22583 } 22584 processMutations(mutations) { 22585 if (this.started) { 22586 for (const mutation of mutations) { 22587 this.processMutation(mutation); 22588 } 22589 } 22590 } 22591 processMutation(mutation) { 22592 const attributeName = mutation.attributeName; 22593 if (attributeName) { 22594 this.refreshAttribute(attributeName, mutation.oldValue); 22595 } 22596 } 22597 refreshAttribute(attributeName, oldValue) { 22598 const key = this.delegate.getStringMapKeyForAttribute(attributeName); 22599 if (key != null) { 22600 if (!this.stringMap.has(attributeName)) { 22601 this.stringMapKeyAdded(key, attributeName); 22602 } 22603 const value = this.element.getAttribute(attributeName); 22604 if (this.stringMap.get(attributeName) != value) { 22605 this.stringMapValueChanged(value, key, oldValue); 22606 } 22607 if (value == null) { 22608 const oldValue2 = this.stringMap.get(attributeName); 22609 this.stringMap.delete(attributeName); 22610 if (oldValue2) 22611 this.stringMapKeyRemoved(key, attributeName, oldValue2); 22612 } else { 22613 this.stringMap.set(attributeName, value); 22614 } 22615 } 22616 } 22617 stringMapKeyAdded(key, attributeName) { 22618 if (this.delegate.stringMapKeyAdded) { 22619 this.delegate.stringMapKeyAdded(key, attributeName); 22620 } 22621 } 22622 stringMapValueChanged(value, key, oldValue) { 22623 if (this.delegate.stringMapValueChanged) { 22624 this.delegate.stringMapValueChanged(value, key, oldValue); 22625 } 22626 } 22627 stringMapKeyRemoved(key, attributeName, oldValue) { 22628 if (this.delegate.stringMapKeyRemoved) { 22629 this.delegate.stringMapKeyRemoved(key, attributeName, oldValue); 22630 } 22631 } 22632 get knownAttributeNames() { 22633 return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames))); 22634 } 22635 get currentAttributeNames() { 22636 return Array.from(this.element.attributes).map((attribute) => attribute.name); 22637 } 22638 get recordedAttributeNames() { 22639 return Array.from(this.stringMap.keys()); 22640 } 22641 }; 22642 var TokenListObserver = class { 22643 constructor(element, attributeName, delegate2) { 22644 this.attributeObserver = new AttributeObserver(element, attributeName, this); 22645 this.delegate = delegate2; 22646 this.tokensByElement = new Multimap(); 22647 } 22648 get started() { 22649 return this.attributeObserver.started; 22650 } 22651 start() { 22652 this.attributeObserver.start(); 22653 } 22654 pause(callback) { 22655 this.attributeObserver.pause(callback); 22656 } 22657 stop() { 22658 this.attributeObserver.stop(); 22659 } 22660 refresh() { 22661 this.attributeObserver.refresh(); 22662 } 22663 get element() { 22664 return this.attributeObserver.element; 22665 } 22666 get attributeName() { 22667 return this.attributeObserver.attributeName; 22668 } 22669 elementMatchedAttribute(element) { 22670 this.tokensMatched(this.readTokensForElement(element)); 22671 } 22672 elementAttributeValueChanged(element) { 22673 const [unmatchedTokens, matchedTokens] = this.refreshTokensForElement(element); 22674 this.tokensUnmatched(unmatchedTokens); 22675 this.tokensMatched(matchedTokens); 22676 } 22677 elementUnmatchedAttribute(element) { 22678 this.tokensUnmatched(this.tokensByElement.getValuesForKey(element)); 22679 } 22680 tokensMatched(tokens) { 22681 tokens.forEach((token) => this.tokenMatched(token)); 22682 } 22683 tokensUnmatched(tokens) { 22684 tokens.forEach((token) => this.tokenUnmatched(token)); 22685 } 22686 tokenMatched(token) { 22687 this.delegate.tokenMatched(token); 22688 this.tokensByElement.add(token.element, token); 22689 } 22690 tokenUnmatched(token) { 22691 this.delegate.tokenUnmatched(token); 22692 this.tokensByElement.delete(token.element, token); 22693 } 22694 refreshTokensForElement(element) { 22695 const previousTokens = this.tokensByElement.getValuesForKey(element); 22696 const currentTokens = this.readTokensForElement(element); 22697 const firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(([previousToken, currentToken]) => !tokensAreEqual(previousToken, currentToken)); 22698 if (firstDifferingIndex == -1) { 22699 return [[], []]; 22700 } else { 22701 return [previousTokens.slice(firstDifferingIndex), currentTokens.slice(firstDifferingIndex)]; 22702 } 22703 } 22704 readTokensForElement(element) { 22705 const attributeName = this.attributeName; 22706 const tokenString = element.getAttribute(attributeName) || ""; 22707 return parseTokenString(tokenString, element, attributeName); 22708 } 22709 }; 22710 function parseTokenString(tokenString, element, attributeName) { 22711 return tokenString.trim().split(/\s+/).filter((content) => content.length).map((content, index) => ({ element, attributeName, content, index })); 22712 } 22713 function zip(left, right) { 22714 const length = Math.max(left.length, right.length); 22715 return Array.from({ length }, (_, index) => [left[index], right[index]]); 22716 } 22717 function tokensAreEqual(left, right) { 22718 return left && right && left.index == right.index && left.content == right.content; 22719 } 22720 var ValueListObserver = class { 22721 constructor(element, attributeName, delegate2) { 22722 this.tokenListObserver = new TokenListObserver(element, attributeName, this); 22723 this.delegate = delegate2; 22724 this.parseResultsByToken = /* @__PURE__ */ new WeakMap(); 22725 this.valuesByTokenByElement = /* @__PURE__ */ new WeakMap(); 22726 } 22727 get started() { 22728 return this.tokenListObserver.started; 22729 } 22730 start() { 22731 this.tokenListObserver.start(); 22732 } 22733 stop() { 22734 this.tokenListObserver.stop(); 22735 } 22736 refresh() { 22737 this.tokenListObserver.refresh(); 22738 } 22739 get element() { 22740 return this.tokenListObserver.element; 22741 } 22742 get attributeName() { 22743 return this.tokenListObserver.attributeName; 22744 } 22745 tokenMatched(token) { 22746 const { element } = token; 22747 const { value } = this.fetchParseResultForToken(token); 22748 if (value) { 22749 this.fetchValuesByTokenForElement(element).set(token, value); 22750 this.delegate.elementMatchedValue(element, value); 22751 } 22752 } 22753 tokenUnmatched(token) { 22754 const { element } = token; 22755 const { value } = this.fetchParseResultForToken(token); 22756 if (value) { 22757 this.fetchValuesByTokenForElement(element).delete(token); 22758 this.delegate.elementUnmatchedValue(element, value); 22759 } 22760 } 22761 fetchParseResultForToken(token) { 22762 let parseResult = this.parseResultsByToken.get(token); 22763 if (!parseResult) { 22764 parseResult = this.parseToken(token); 22765 this.parseResultsByToken.set(token, parseResult); 22766 } 22767 return parseResult; 22768 } 22769 fetchValuesByTokenForElement(element) { 22770 let valuesByToken = this.valuesByTokenByElement.get(element); 22771 if (!valuesByToken) { 22772 valuesByToken = /* @__PURE__ */ new Map(); 22773 this.valuesByTokenByElement.set(element, valuesByToken); 22774 } 22775 return valuesByToken; 22776 } 22777 parseToken(token) { 22778 try { 22779 const value = this.delegate.parseValueForToken(token); 22780 return { value }; 22781 } catch (error2) { 22782 return { error: error2 }; 22783 } 22784 } 22785 }; 22786 var BindingObserver = class { 22787 constructor(context, delegate2) { 22788 this.context = context; 22789 this.delegate = delegate2; 22790 this.bindingsByAction = /* @__PURE__ */ new Map(); 22791 } 22792 start() { 22793 if (!this.valueListObserver) { 22794 this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this); 22795 this.valueListObserver.start(); 22796 } 22797 } 22798 stop() { 22799 if (this.valueListObserver) { 22800 this.valueListObserver.stop(); 22801 delete this.valueListObserver; 22802 this.disconnectAllActions(); 22803 } 22804 } 22805 get element() { 22806 return this.context.element; 22807 } 22808 get identifier() { 22809 return this.context.identifier; 22810 } 22811 get actionAttribute() { 22812 return this.schema.actionAttribute; 22813 } 22814 get schema() { 22815 return this.context.schema; 22816 } 22817 get bindings() { 22818 return Array.from(this.bindingsByAction.values()); 22819 } 22820 connectAction(action) { 22821 const binding = new Binding(this.context, action); 22822 this.bindingsByAction.set(action, binding); 22823 this.delegate.bindingConnected(binding); 22824 } 22825 disconnectAction(action) { 22826 const binding = this.bindingsByAction.get(action); 22827 if (binding) { 22828 this.bindingsByAction.delete(action); 22829 this.delegate.bindingDisconnected(binding); 22830 } 22831 } 22832 disconnectAllActions() { 22833 this.bindings.forEach((binding) => this.delegate.bindingDisconnected(binding, true)); 22834 this.bindingsByAction.clear(); 22835 } 22836 parseValueForToken(token) { 22837 const action = Action.forToken(token, this.schema); 22838 if (action.identifier == this.identifier) { 22839 return action; 22840 } 22841 } 22842 elementMatchedValue(element, action) { 22843 this.connectAction(action); 22844 } 22845 elementUnmatchedValue(element, action) { 22846 this.disconnectAction(action); 22847 } 22848 }; 22849 var ValueObserver = class { 22850 constructor(context, receiver) { 22851 this.context = context; 22852 this.receiver = receiver; 22853 this.stringMapObserver = new StringMapObserver(this.element, this); 22854 this.valueDescriptorMap = this.controller.valueDescriptorMap; 22855 } 22856 start() { 22857 this.stringMapObserver.start(); 22858 this.invokeChangedCallbacksForDefaultValues(); 22859 } 22860 stop() { 22861 this.stringMapObserver.stop(); 22862 } 22863 get element() { 22864 return this.context.element; 22865 } 22866 get controller() { 22867 return this.context.controller; 22868 } 22869 getStringMapKeyForAttribute(attributeName) { 22870 if (attributeName in this.valueDescriptorMap) { 22871 return this.valueDescriptorMap[attributeName].name; 22872 } 22873 } 22874 stringMapKeyAdded(key, attributeName) { 22875 const descriptor = this.valueDescriptorMap[attributeName]; 22876 if (!this.hasValue(key)) { 22877 this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue)); 22878 } 22879 } 22880 stringMapValueChanged(value, name, oldValue) { 22881 const descriptor = this.valueDescriptorNameMap[name]; 22882 if (value === null) 22883 return; 22884 if (oldValue === null) { 22885 oldValue = descriptor.writer(descriptor.defaultValue); 22886 } 22887 this.invokeChangedCallback(name, value, oldValue); 22888 } 22889 stringMapKeyRemoved(key, attributeName, oldValue) { 22890 const descriptor = this.valueDescriptorNameMap[key]; 22891 if (this.hasValue(key)) { 22892 this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue); 22893 } else { 22894 this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue); 22895 } 22896 } 22897 invokeChangedCallbacksForDefaultValues() { 22898 for (const { key, name, defaultValue, writer } of this.valueDescriptors) { 22899 if (defaultValue != void 0 && !this.controller.data.has(key)) { 22900 this.invokeChangedCallback(name, writer(defaultValue), void 0); 22901 } 22902 } 22903 } 22904 invokeChangedCallback(name, rawValue, rawOldValue) { 22905 const changedMethodName = `${name}Changed`; 22906 const changedMethod = this.receiver[changedMethodName]; 22907 if (typeof changedMethod == "function") { 22908 const descriptor = this.valueDescriptorNameMap[name]; 22909 try { 22910 const value = descriptor.reader(rawValue); 22911 let oldValue = rawOldValue; 22912 if (rawOldValue) { 22913 oldValue = descriptor.reader(rawOldValue); 22914 } 22915 changedMethod.call(this.receiver, value, oldValue); 22916 } catch (error2) { 22917 if (error2 instanceof TypeError) { 22918 error2.message = `Stimulus Value "${this.context.identifier}.${descriptor.name}" - ${error2.message}`; 22919 } 22920 throw error2; 22921 } 22922 } 22923 } 22924 get valueDescriptors() { 22925 const { valueDescriptorMap } = this; 22926 return Object.keys(valueDescriptorMap).map((key) => valueDescriptorMap[key]); 22927 } 22928 get valueDescriptorNameMap() { 22929 const descriptors = {}; 22930 Object.keys(this.valueDescriptorMap).forEach((key) => { 22931 const descriptor = this.valueDescriptorMap[key]; 22932 descriptors[descriptor.name] = descriptor; 22933 }); 22934 return descriptors; 22935 } 22936 hasValue(attributeName) { 22937 const descriptor = this.valueDescriptorNameMap[attributeName]; 22938 const hasMethodName = `has${capitalize(descriptor.name)}`; 22939 return this.receiver[hasMethodName]; 22940 } 22941 }; 22942 var TargetObserver = class { 22943 constructor(context, delegate2) { 22944 this.context = context; 22945 this.delegate = delegate2; 22946 this.targetsByName = new Multimap(); 22947 } 22948 start() { 22949 if (!this.tokenListObserver) { 22950 this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this); 22951 this.tokenListObserver.start(); 22952 } 22953 } 22954 stop() { 22955 if (this.tokenListObserver) { 22956 this.disconnectAllTargets(); 22957 this.tokenListObserver.stop(); 22958 delete this.tokenListObserver; 22959 } 22960 } 22961 tokenMatched({ element, content: name }) { 22962 if (this.scope.containsElement(element)) { 22963 this.connectTarget(element, name); 22964 } 22965 } 22966 tokenUnmatched({ element, content: name }) { 22967 this.disconnectTarget(element, name); 22968 } 22969 connectTarget(element, name) { 22970 var _a; 22971 if (!this.targetsByName.has(name, element)) { 22972 this.targetsByName.add(name, element); 22973 (_a = this.tokenListObserver) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.targetConnected(element, name)); 22974 } 22975 } 22976 disconnectTarget(element, name) { 22977 var _a; 22978 if (this.targetsByName.has(name, element)) { 22979 this.targetsByName.delete(name, element); 22980 (_a = this.tokenListObserver) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.targetDisconnected(element, name)); 22981 } 22982 } 22983 disconnectAllTargets() { 22984 for (const name of this.targetsByName.keys) { 22985 for (const element of this.targetsByName.getValuesForKey(name)) { 22986 this.disconnectTarget(element, name); 22987 } 22988 } 22989 } 22990 get attributeName() { 22991 return `data-${this.context.identifier}-target`; 22992 } 22993 get element() { 22994 return this.context.element; 22995 } 22996 get scope() { 22997 return this.context.scope; 22998 } 22999 }; 23000 function readInheritableStaticArrayValues(constructor, propertyName) { 23001 const ancestors = getAncestorsForConstructor(constructor); 23002 return Array.from(ancestors.reduce((values, constructor2) => { 23003 getOwnStaticArrayValues(constructor2, propertyName).forEach((name) => values.add(name)); 23004 return values; 23005 }, /* @__PURE__ */ new Set())); 23006 } 23007 function readInheritableStaticObjectPairs(constructor, propertyName) { 23008 const ancestors = getAncestorsForConstructor(constructor); 23009 return ancestors.reduce((pairs, constructor2) => { 23010 pairs.push(...getOwnStaticObjectPairs(constructor2, propertyName)); 23011 return pairs; 23012 }, []); 23013 } 23014 function getAncestorsForConstructor(constructor) { 23015 const ancestors = []; 23016 while (constructor) { 23017 ancestors.push(constructor); 23018 constructor = Object.getPrototypeOf(constructor); 23019 } 23020 return ancestors.reverse(); 23021 } 23022 function getOwnStaticArrayValues(constructor, propertyName) { 23023 const definition = constructor[propertyName]; 23024 return Array.isArray(definition) ? definition : []; 23025 } 23026 function getOwnStaticObjectPairs(constructor, propertyName) { 23027 const definition = constructor[propertyName]; 23028 return definition ? Object.keys(definition).map((key) => [key, definition[key]]) : []; 23029 } 23030 var OutletObserver = class { 23031 constructor(context, delegate2) { 23032 this.started = false; 23033 this.context = context; 23034 this.delegate = delegate2; 23035 this.outletsByName = new Multimap(); 23036 this.outletElementsByName = new Multimap(); 23037 this.selectorObserverMap = /* @__PURE__ */ new Map(); 23038 this.attributeObserverMap = /* @__PURE__ */ new Map(); 23039 } 23040 start() { 23041 if (!this.started) { 23042 this.outletDefinitions.forEach((outletName) => { 23043 this.setupSelectorObserverForOutlet(outletName); 23044 this.setupAttributeObserverForOutlet(outletName); 23045 }); 23046 this.started = true; 23047 this.dependentContexts.forEach((context) => context.refresh()); 23048 } 23049 } 23050 refresh() { 23051 this.selectorObserverMap.forEach((observer) => observer.refresh()); 23052 this.attributeObserverMap.forEach((observer) => observer.refresh()); 23053 } 23054 stop() { 23055 if (this.started) { 23056 this.started = false; 23057 this.disconnectAllOutlets(); 23058 this.stopSelectorObservers(); 23059 this.stopAttributeObservers(); 23060 } 23061 } 23062 stopSelectorObservers() { 23063 if (this.selectorObserverMap.size > 0) { 23064 this.selectorObserverMap.forEach((observer) => observer.stop()); 23065 this.selectorObserverMap.clear(); 23066 } 23067 } 23068 stopAttributeObservers() { 23069 if (this.attributeObserverMap.size > 0) { 23070 this.attributeObserverMap.forEach((observer) => observer.stop()); 23071 this.attributeObserverMap.clear(); 23072 } 23073 } 23074 selectorMatched(element, _selector, { outletName }) { 23075 const outlet = this.getOutlet(element, outletName); 23076 if (outlet) { 23077 this.connectOutlet(outlet, element, outletName); 23078 } 23079 } 23080 selectorUnmatched(element, _selector, { outletName }) { 23081 const outlet = this.getOutletFromMap(element, outletName); 23082 if (outlet) { 23083 this.disconnectOutlet(outlet, element, outletName); 23084 } 23085 } 23086 selectorMatchElement(element, { outletName }) { 23087 const selector = this.selector(outletName); 23088 const hasOutlet = this.hasOutlet(element, outletName); 23089 const hasOutletController = element.matches(`[${this.schema.controllerAttribute}~=${outletName}]`); 23090 if (selector) { 23091 return hasOutlet && hasOutletController && element.matches(selector); 23092 } else { 23093 return false; 23094 } 23095 } 23096 elementMatchedAttribute(_element, attributeName) { 23097 const outletName = this.getOutletNameFromOutletAttributeName(attributeName); 23098 if (outletName) { 23099 this.updateSelectorObserverForOutlet(outletName); 23100 } 23101 } 23102 elementAttributeValueChanged(_element, attributeName) { 23103 const outletName = this.getOutletNameFromOutletAttributeName(attributeName); 23104 if (outletName) { 23105 this.updateSelectorObserverForOutlet(outletName); 23106 } 23107 } 23108 elementUnmatchedAttribute(_element, attributeName) { 23109 const outletName = this.getOutletNameFromOutletAttributeName(attributeName); 23110 if (outletName) { 23111 this.updateSelectorObserverForOutlet(outletName); 23112 } 23113 } 23114 connectOutlet(outlet, element, outletName) { 23115 var _a; 23116 if (!this.outletElementsByName.has(outletName, element)) { 23117 this.outletsByName.add(outletName, outlet); 23118 this.outletElementsByName.add(outletName, element); 23119 (_a = this.selectorObserverMap.get(outletName)) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.outletConnected(outlet, element, outletName)); 23120 } 23121 } 23122 disconnectOutlet(outlet, element, outletName) { 23123 var _a; 23124 if (this.outletElementsByName.has(outletName, element)) { 23125 this.outletsByName.delete(outletName, outlet); 23126 this.outletElementsByName.delete(outletName, element); 23127 (_a = this.selectorObserverMap.get(outletName)) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.outletDisconnected(outlet, element, outletName)); 23128 } 23129 } 23130 disconnectAllOutlets() { 23131 for (const outletName of this.outletElementsByName.keys) { 23132 for (const element of this.outletElementsByName.getValuesForKey(outletName)) { 23133 for (const outlet of this.outletsByName.getValuesForKey(outletName)) { 23134 this.disconnectOutlet(outlet, element, outletName); 23135 } 23136 } 23137 } 23138 } 23139 updateSelectorObserverForOutlet(outletName) { 23140 const observer = this.selectorObserverMap.get(outletName); 23141 if (observer) { 23142 observer.selector = this.selector(outletName); 23143 } 23144 } 23145 setupSelectorObserverForOutlet(outletName) { 23146 const selector = this.selector(outletName); 23147 const selectorObserver = new SelectorObserver(document.body, selector, this, { outletName }); 23148 this.selectorObserverMap.set(outletName, selectorObserver); 23149 selectorObserver.start(); 23150 } 23151 setupAttributeObserverForOutlet(outletName) { 23152 const attributeName = this.attributeNameForOutletName(outletName); 23153 const attributeObserver = new AttributeObserver(this.scope.element, attributeName, this); 23154 this.attributeObserverMap.set(outletName, attributeObserver); 23155 attributeObserver.start(); 23156 } 23157 selector(outletName) { 23158 return this.scope.outlets.getSelectorForOutletName(outletName); 23159 } 23160 attributeNameForOutletName(outletName) { 23161 return this.scope.schema.outletAttributeForScope(this.identifier, outletName); 23162 } 23163 getOutletNameFromOutletAttributeName(attributeName) { 23164 return this.outletDefinitions.find((outletName) => this.attributeNameForOutletName(outletName) === attributeName); 23165 } 23166 get outletDependencies() { 23167 const dependencies = new Multimap(); 23168 this.router.modules.forEach((module) => { 23169 const constructor = module.definition.controllerConstructor; 23170 const outlets = readInheritableStaticArrayValues(constructor, "outlets"); 23171 outlets.forEach((outlet) => dependencies.add(outlet, module.identifier)); 23172 }); 23173 return dependencies; 23174 } 23175 get outletDefinitions() { 23176 return this.outletDependencies.getKeysForValue(this.identifier); 23177 } 23178 get dependentControllerIdentifiers() { 23179 return this.outletDependencies.getValuesForKey(this.identifier); 23180 } 23181 get dependentContexts() { 23182 const identifiers = this.dependentControllerIdentifiers; 23183 return this.router.contexts.filter((context) => identifiers.includes(context.identifier)); 23184 } 23185 hasOutlet(element, outletName) { 23186 return !!this.getOutlet(element, outletName) || !!this.getOutletFromMap(element, outletName); 23187 } 23188 getOutlet(element, outletName) { 23189 return this.application.getControllerForElementAndIdentifier(element, outletName); 23190 } 23191 getOutletFromMap(element, outletName) { 23192 return this.outletsByName.getValuesForKey(outletName).find((outlet) => outlet.element === element); 23193 } 23194 get scope() { 23195 return this.context.scope; 23196 } 23197 get schema() { 23198 return this.context.schema; 23199 } 23200 get identifier() { 23201 return this.context.identifier; 23202 } 23203 get application() { 23204 return this.context.application; 23205 } 23206 get router() { 23207 return this.application.router; 23208 } 23209 }; 23210 var Context = class { 23211 constructor(module, scope) { 23212 this.logDebugActivity = (functionName, detail = {}) => { 23213 const { identifier, controller, element } = this; 23214 detail = Object.assign({ identifier, controller, element }, detail); 23215 this.application.logDebugActivity(this.identifier, functionName, detail); 23216 }; 23217 this.module = module; 23218 this.scope = scope; 23219 this.controller = new module.controllerConstructor(this); 23220 this.bindingObserver = new BindingObserver(this, this.dispatcher); 23221 this.valueObserver = new ValueObserver(this, this.controller); 23222 this.targetObserver = new TargetObserver(this, this); 23223 this.outletObserver = new OutletObserver(this, this); 23224 try { 23225 this.controller.initialize(); 23226 this.logDebugActivity("initialize"); 23227 } catch (error2) { 23228 this.handleError(error2, "initializing controller"); 23229 } 23230 } 23231 connect() { 23232 this.bindingObserver.start(); 23233 this.valueObserver.start(); 23234 this.targetObserver.start(); 23235 this.outletObserver.start(); 23236 try { 23237 this.controller.connect(); 23238 this.logDebugActivity("connect"); 23239 } catch (error2) { 23240 this.handleError(error2, "connecting controller"); 23241 } 23242 } 23243 refresh() { 23244 this.outletObserver.refresh(); 23245 } 23246 disconnect() { 23247 try { 23248 this.controller.disconnect(); 23249 this.logDebugActivity("disconnect"); 23250 } catch (error2) { 23251 this.handleError(error2, "disconnecting controller"); 23252 } 23253 this.outletObserver.stop(); 23254 this.targetObserver.stop(); 23255 this.valueObserver.stop(); 23256 this.bindingObserver.stop(); 23257 } 23258 get application() { 23259 return this.module.application; 23260 } 23261 get identifier() { 23262 return this.module.identifier; 23263 } 23264 get schema() { 23265 return this.application.schema; 23266 } 23267 get dispatcher() { 23268 return this.application.dispatcher; 23269 } 23270 get element() { 23271 return this.scope.element; 23272 } 23273 get parentElement() { 23274 return this.element.parentElement; 23275 } 23276 handleError(error2, message, detail = {}) { 23277 const { identifier, controller, element } = this; 23278 detail = Object.assign({ identifier, controller, element }, detail); 23279 this.application.handleError(error2, `Error ${message}`, detail); 23280 } 23281 targetConnected(element, name) { 23282 this.invokeControllerMethod(`${name}TargetConnected`, element); 23283 } 23284 targetDisconnected(element, name) { 23285 this.invokeControllerMethod(`${name}TargetDisconnected`, element); 23286 } 23287 outletConnected(outlet, element, name) { 23288 this.invokeControllerMethod(`${namespaceCamelize(name)}OutletConnected`, outlet, element); 23289 } 23290 outletDisconnected(outlet, element, name) { 23291 this.invokeControllerMethod(`${namespaceCamelize(name)}OutletDisconnected`, outlet, element); 23292 } 23293 invokeControllerMethod(methodName, ...args) { 23294 const controller = this.controller; 23295 if (typeof controller[methodName] == "function") { 23296 controller[methodName](...args); 23297 } 23298 } 23299 }; 23300 function bless(constructor) { 23301 return shadow(constructor, getBlessedProperties(constructor)); 23302 } 23303 function shadow(constructor, properties) { 23304 const shadowConstructor = extend2(constructor); 23305 const shadowProperties = getShadowProperties(constructor.prototype, properties); 23306 Object.defineProperties(shadowConstructor.prototype, shadowProperties); 23307 return shadowConstructor; 23308 } 23309 function getBlessedProperties(constructor) { 23310 const blessings = readInheritableStaticArrayValues(constructor, "blessings"); 23311 return blessings.reduce((blessedProperties, blessing) => { 23312 const properties = blessing(constructor); 23313 for (const key in properties) { 23314 const descriptor = blessedProperties[key] || {}; 23315 blessedProperties[key] = Object.assign(descriptor, properties[key]); 23316 } 23317 return blessedProperties; 23318 }, {}); 23319 } 23320 function getShadowProperties(prototype, properties) { 23321 return getOwnKeys(properties).reduce((shadowProperties, key) => { 23322 const descriptor = getShadowedDescriptor(prototype, properties, key); 23323 if (descriptor) { 23324 Object.assign(shadowProperties, { [key]: descriptor }); 23325 } 23326 return shadowProperties; 23327 }, {}); 23328 } 23329 function getShadowedDescriptor(prototype, properties, key) { 23330 const shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key); 23331 const shadowedByValue = shadowingDescriptor && "value" in shadowingDescriptor; 23332 if (!shadowedByValue) { 23333 const descriptor = Object.getOwnPropertyDescriptor(properties, key).value; 23334 if (shadowingDescriptor) { 23335 descriptor.get = shadowingDescriptor.get || descriptor.get; 23336 descriptor.set = shadowingDescriptor.set || descriptor.set; 23337 } 23338 return descriptor; 23339 } 23340 } 23341 var getOwnKeys = (() => { 23342 if (typeof Object.getOwnPropertySymbols == "function") { 23343 return (object) => [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)]; 23344 } else { 23345 return Object.getOwnPropertyNames; 23346 } 23347 })(); 23348 var extend2 = (() => { 23349 function extendWithReflect(constructor) { 23350 function extended() { 23351 return Reflect.construct(constructor, arguments, new.target); 23352 } 23353 extended.prototype = Object.create(constructor.prototype, { 23354 constructor: { value: extended } 23355 }); 23356 Reflect.setPrototypeOf(extended, constructor); 23357 return extended; 23358 } 23359 function testReflectExtension() { 23360 const a = function() { 23361 this.a.call(this); 23362 }; 23363 const b = extendWithReflect(a); 23364 b.prototype.a = function() { 23365 }; 23366 return new b(); 23367 } 23368 try { 23369 testReflectExtension(); 23370 return extendWithReflect; 23371 } catch (error2) { 23372 return (constructor) => class extended extends constructor { 23373 }; 23374 } 23375 })(); 23376 function blessDefinition(definition) { 23377 return { 23378 identifier: definition.identifier, 23379 controllerConstructor: bless(definition.controllerConstructor) 23380 }; 23381 } 23382 var Module = class { 23383 constructor(application2, definition) { 23384 this.application = application2; 23385 this.definition = blessDefinition(definition); 23386 this.contextsByScope = /* @__PURE__ */ new WeakMap(); 23387 this.connectedContexts = /* @__PURE__ */ new Set(); 23388 } 23389 get identifier() { 23390 return this.definition.identifier; 23391 } 23392 get controllerConstructor() { 23393 return this.definition.controllerConstructor; 23394 } 23395 get contexts() { 23396 return Array.from(this.connectedContexts); 23397 } 23398 connectContextForScope(scope) { 23399 const context = this.fetchContextForScope(scope); 23400 this.connectedContexts.add(context); 23401 context.connect(); 23402 } 23403 disconnectContextForScope(scope) { 23404 const context = this.contextsByScope.get(scope); 23405 if (context) { 23406 this.connectedContexts.delete(context); 23407 context.disconnect(); 23408 } 23409 } 23410 fetchContextForScope(scope) { 23411 let context = this.contextsByScope.get(scope); 23412 if (!context) { 23413 context = new Context(this, scope); 23414 this.contextsByScope.set(scope, context); 23415 } 23416 return context; 23417 } 23418 }; 23419 var ClassMap = class { 23420 constructor(scope) { 23421 this.scope = scope; 23422 } 23423 has(name) { 23424 return this.data.has(this.getDataKey(name)); 23425 } 23426 get(name) { 23427 return this.getAll(name)[0]; 23428 } 23429 getAll(name) { 23430 const tokenString = this.data.get(this.getDataKey(name)) || ""; 23431 return tokenize(tokenString); 23432 } 23433 getAttributeName(name) { 23434 return this.data.getAttributeNameForKey(this.getDataKey(name)); 23435 } 23436 getDataKey(name) { 23437 return `${name}-class`; 23438 } 23439 get data() { 23440 return this.scope.data; 23441 } 23442 }; 23443 var DataMap = class { 23444 constructor(scope) { 23445 this.scope = scope; 23446 } 23447 get element() { 23448 return this.scope.element; 23449 } 23450 get identifier() { 23451 return this.scope.identifier; 23452 } 23453 get(key) { 23454 const name = this.getAttributeNameForKey(key); 23455 return this.element.getAttribute(name); 23456 } 23457 set(key, value) { 23458 const name = this.getAttributeNameForKey(key); 23459 this.element.setAttribute(name, value); 23460 return this.get(key); 23461 } 23462 has(key) { 23463 const name = this.getAttributeNameForKey(key); 23464 return this.element.hasAttribute(name); 23465 } 23466 delete(key) { 23467 if (this.has(key)) { 23468 const name = this.getAttributeNameForKey(key); 23469 this.element.removeAttribute(name); 23470 return true; 23471 } else { 23472 return false; 23473 } 23474 } 23475 getAttributeNameForKey(key) { 23476 return `data-${this.identifier}-${dasherize(key)}`; 23477 } 23478 }; 23479 var Guide = class { 23480 constructor(logger) { 23481 this.warnedKeysByObject = /* @__PURE__ */ new WeakMap(); 23482 this.logger = logger; 23483 } 23484 warn(object, key, message) { 23485 let warnedKeys = this.warnedKeysByObject.get(object); 23486 if (!warnedKeys) { 23487 warnedKeys = /* @__PURE__ */ new Set(); 23488 this.warnedKeysByObject.set(object, warnedKeys); 23489 } 23490 if (!warnedKeys.has(key)) { 23491 warnedKeys.add(key); 23492 this.logger.warn(message, object); 23493 } 23494 } 23495 }; 23496 function attributeValueContainsToken(attributeName, token) { 23497 return `[${attributeName}~="${token}"]`; 23498 } 23499 var TargetSet = class { 23500 constructor(scope) { 23501 this.scope = scope; 23502 } 23503 get element() { 23504 return this.scope.element; 23505 } 23506 get identifier() { 23507 return this.scope.identifier; 23508 } 23509 get schema() { 23510 return this.scope.schema; 23511 } 23512 has(targetName) { 23513 return this.find(targetName) != null; 23514 } 23515 find(...targetNames) { 23516 return targetNames.reduce((target, targetName) => target || this.findTarget(targetName) || this.findLegacyTarget(targetName), void 0); 23517 } 23518 findAll(...targetNames) { 23519 return targetNames.reduce((targets, targetName) => [ 23520 ...targets, 23521 ...this.findAllTargets(targetName), 23522 ...this.findAllLegacyTargets(targetName) 23523 ], []); 23524 } 23525 findTarget(targetName) { 23526 const selector = this.getSelectorForTargetName(targetName); 23527 return this.scope.findElement(selector); 23528 } 23529 findAllTargets(targetName) { 23530 const selector = this.getSelectorForTargetName(targetName); 23531 return this.scope.findAllElements(selector); 23532 } 23533 getSelectorForTargetName(targetName) { 23534 const attributeName = this.schema.targetAttributeForScope(this.identifier); 23535 return attributeValueContainsToken(attributeName, targetName); 23536 } 23537 findLegacyTarget(targetName) { 23538 const selector = this.getLegacySelectorForTargetName(targetName); 23539 return this.deprecate(this.scope.findElement(selector), targetName); 23540 } 23541 findAllLegacyTargets(targetName) { 23542 const selector = this.getLegacySelectorForTargetName(targetName); 23543 return this.scope.findAllElements(selector).map((element) => this.deprecate(element, targetName)); 23544 } 23545 getLegacySelectorForTargetName(targetName) { 23546 const targetDescriptor = `${this.identifier}.${targetName}`; 23547 return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor); 23548 } 23549 deprecate(element, targetName) { 23550 if (element) { 23551 const { identifier } = this; 23552 const attributeName = this.schema.targetAttribute; 23553 const revisedAttributeName = this.schema.targetAttributeForScope(identifier); 23554 this.guide.warn(element, `target:${targetName}`, `Please replace ${attributeName}="${identifier}.${targetName}" with ${revisedAttributeName}="${targetName}". The ${attributeName} attribute is deprecated and will be removed in a future version of Stimulus.`); 23555 } 23556 return element; 23557 } 23558 get guide() { 23559 return this.scope.guide; 23560 } 23561 }; 23562 var OutletSet = class { 23563 constructor(scope, controllerElement) { 23564 this.scope = scope; 23565 this.controllerElement = controllerElement; 23566 } 23567 get element() { 23568 return this.scope.element; 23569 } 23570 get identifier() { 23571 return this.scope.identifier; 23572 } 23573 get schema() { 23574 return this.scope.schema; 23575 } 23576 has(outletName) { 23577 return this.find(outletName) != null; 23578 } 23579 find(...outletNames) { 23580 return outletNames.reduce((outlet, outletName) => outlet || this.findOutlet(outletName), void 0); 23581 } 23582 findAll(...outletNames) { 23583 return outletNames.reduce((outlets, outletName) => [...outlets, ...this.findAllOutlets(outletName)], []); 23584 } 23585 getSelectorForOutletName(outletName) { 23586 const attributeName = this.schema.outletAttributeForScope(this.identifier, outletName); 23587 return this.controllerElement.getAttribute(attributeName); 23588 } 23589 findOutlet(outletName) { 23590 const selector = this.getSelectorForOutletName(outletName); 23591 if (selector) 23592 return this.findElement(selector, outletName); 23593 } 23594 findAllOutlets(outletName) { 23595 const selector = this.getSelectorForOutletName(outletName); 23596 return selector ? this.findAllElements(selector, outletName) : []; 23597 } 23598 findElement(selector, outletName) { 23599 const elements = this.scope.queryElements(selector); 23600 return elements.filter((element) => this.matchesElement(element, selector, outletName))[0]; 23601 } 23602 findAllElements(selector, outletName) { 23603 const elements = this.scope.queryElements(selector); 23604 return elements.filter((element) => this.matchesElement(element, selector, outletName)); 23605 } 23606 matchesElement(element, selector, outletName) { 23607 const controllerAttribute = element.getAttribute(this.scope.schema.controllerAttribute) || ""; 23608 return element.matches(selector) && controllerAttribute.split(" ").includes(outletName); 23609 } 23610 }; 23611 var Scope = class _Scope { 23612 constructor(schema, element, identifier, logger) { 23613 this.targets = new TargetSet(this); 23614 this.classes = new ClassMap(this); 23615 this.data = new DataMap(this); 23616 this.containsElement = (element2) => { 23617 return element2.closest(this.controllerSelector) === this.element; 23618 }; 23619 this.schema = schema; 23620 this.element = element; 23621 this.identifier = identifier; 23622 this.guide = new Guide(logger); 23623 this.outlets = new OutletSet(this.documentScope, element); 23624 } 23625 findElement(selector) { 23626 return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement); 23627 } 23628 findAllElements(selector) { 23629 return [ 23630 ...this.element.matches(selector) ? [this.element] : [], 23631 ...this.queryElements(selector).filter(this.containsElement) 23632 ]; 23633 } 23634 queryElements(selector) { 23635 return Array.from(this.element.querySelectorAll(selector)); 23636 } 23637 get controllerSelector() { 23638 return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier); 23639 } 23640 get isDocumentScope() { 23641 return this.element === document.documentElement; 23642 } 23643 get documentScope() { 23644 return this.isDocumentScope ? this : new _Scope(this.schema, document.documentElement, this.identifier, this.guide.logger); 23645 } 23646 }; 23647 var ScopeObserver = class { 23648 constructor(element, schema, delegate2) { 23649 this.element = element; 23650 this.schema = schema; 23651 this.delegate = delegate2; 23652 this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this); 23653 this.scopesByIdentifierByElement = /* @__PURE__ */ new WeakMap(); 23654 this.scopeReferenceCounts = /* @__PURE__ */ new WeakMap(); 23655 } 23656 start() { 23657 this.valueListObserver.start(); 23658 } 23659 stop() { 23660 this.valueListObserver.stop(); 23661 } 23662 get controllerAttribute() { 23663 return this.schema.controllerAttribute; 23664 } 23665 parseValueForToken(token) { 23666 const { element, content: identifier } = token; 23667 return this.parseValueForElementAndIdentifier(element, identifier); 23668 } 23669 parseValueForElementAndIdentifier(element, identifier) { 23670 const scopesByIdentifier = this.fetchScopesByIdentifierForElement(element); 23671 let scope = scopesByIdentifier.get(identifier); 23672 if (!scope) { 23673 scope = this.delegate.createScopeForElementAndIdentifier(element, identifier); 23674 scopesByIdentifier.set(identifier, scope); 23675 } 23676 return scope; 23677 } 23678 elementMatchedValue(element, value) { 23679 const referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1; 23680 this.scopeReferenceCounts.set(value, referenceCount); 23681 if (referenceCount == 1) { 23682 this.delegate.scopeConnected(value); 23683 } 23684 } 23685 elementUnmatchedValue(element, value) { 23686 const referenceCount = this.scopeReferenceCounts.get(value); 23687 if (referenceCount) { 23688 this.scopeReferenceCounts.set(value, referenceCount - 1); 23689 if (referenceCount == 1) { 23690 this.delegate.scopeDisconnected(value); 23691 } 23692 } 23693 } 23694 fetchScopesByIdentifierForElement(element) { 23695 let scopesByIdentifier = this.scopesByIdentifierByElement.get(element); 23696 if (!scopesByIdentifier) { 23697 scopesByIdentifier = /* @__PURE__ */ new Map(); 23698 this.scopesByIdentifierByElement.set(element, scopesByIdentifier); 23699 } 23700 return scopesByIdentifier; 23701 } 23702 }; 23703 var Router = class { 23704 constructor(application2) { 23705 this.application = application2; 23706 this.scopeObserver = new ScopeObserver(this.element, this.schema, this); 23707 this.scopesByIdentifier = new Multimap(); 23708 this.modulesByIdentifier = /* @__PURE__ */ new Map(); 23709 } 23710 get element() { 23711 return this.application.element; 23712 } 23713 get schema() { 23714 return this.application.schema; 23715 } 23716 get logger() { 23717 return this.application.logger; 23718 } 23719 get controllerAttribute() { 23720 return this.schema.controllerAttribute; 23721 } 23722 get modules() { 23723 return Array.from(this.modulesByIdentifier.values()); 23724 } 23725 get contexts() { 23726 return this.modules.reduce((contexts, module) => contexts.concat(module.contexts), []); 23727 } 23728 start() { 23729 this.scopeObserver.start(); 23730 } 23731 stop() { 23732 this.scopeObserver.stop(); 23733 } 23734 loadDefinition(definition) { 23735 this.unloadIdentifier(definition.identifier); 23736 const module = new Module(this.application, definition); 23737 this.connectModule(module); 23738 const afterLoad = definition.controllerConstructor.afterLoad; 23739 if (afterLoad) { 23740 afterLoad.call(definition.controllerConstructor, definition.identifier, this.application); 23741 } 23742 } 23743 unloadIdentifier(identifier) { 23744 const module = this.modulesByIdentifier.get(identifier); 23745 if (module) { 23746 this.disconnectModule(module); 23747 } 23748 } 23749 getContextForElementAndIdentifier(element, identifier) { 23750 const module = this.modulesByIdentifier.get(identifier); 23751 if (module) { 23752 return module.contexts.find((context) => context.element == element); 23753 } 23754 } 23755 proposeToConnectScopeForElementAndIdentifier(element, identifier) { 23756 const scope = this.scopeObserver.parseValueForElementAndIdentifier(element, identifier); 23757 if (scope) { 23758 this.scopeObserver.elementMatchedValue(scope.element, scope); 23759 } else { 23760 console.error(`Couldn't find or create scope for identifier: "${identifier}" and element:`, element); 23761 } 23762 } 23763 handleError(error2, message, detail) { 23764 this.application.handleError(error2, message, detail); 23765 } 23766 createScopeForElementAndIdentifier(element, identifier) { 23767 return new Scope(this.schema, element, identifier, this.logger); 23768 } 23769 scopeConnected(scope) { 23770 this.scopesByIdentifier.add(scope.identifier, scope); 23771 const module = this.modulesByIdentifier.get(scope.identifier); 23772 if (module) { 23773 module.connectContextForScope(scope); 23774 } 23775 } 23776 scopeDisconnected(scope) { 23777 this.scopesByIdentifier.delete(scope.identifier, scope); 23778 const module = this.modulesByIdentifier.get(scope.identifier); 23779 if (module) { 23780 module.disconnectContextForScope(scope); 23781 } 23782 } 23783 connectModule(module) { 23784 this.modulesByIdentifier.set(module.identifier, module); 23785 const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); 23786 scopes.forEach((scope) => module.connectContextForScope(scope)); 23787 } 23788 disconnectModule(module) { 23789 this.modulesByIdentifier.delete(module.identifier); 23790 const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); 23791 scopes.forEach((scope) => module.disconnectContextForScope(scope)); 23792 } 23793 }; 23794 var defaultSchema = { 23795 controllerAttribute: "data-controller", 23796 actionAttribute: "data-action", 23797 targetAttribute: "data-target", 23798 targetAttributeForScope: (identifier) => `data-${identifier}-target`, 23799 outletAttributeForScope: (identifier, outlet) => `data-${identifier}-${outlet}-outlet`, 23800 keyMappings: Object.assign(Object.assign({ enter: "Enter", tab: "Tab", esc: "Escape", space: " ", up: "ArrowUp", down: "ArrowDown", left: "ArrowLeft", right: "ArrowRight", home: "Home", end: "End", page_up: "PageUp", page_down: "PageDown" }, objectFromEntries("abcdefghijklmnopqrstuvwxyz".split("").map((c) => [c, c]))), objectFromEntries("0123456789".split("").map((n) => [n, n]))) 23801 }; 23802 function objectFromEntries(array) { 23803 return array.reduce((memo, [k, v]) => Object.assign(Object.assign({}, memo), { [k]: v }), {}); 23804 } 23805 var Application = class { 23806 constructor(element = document.documentElement, schema = defaultSchema) { 23807 this.logger = console; 23808 this.debug = false; 23809 this.logDebugActivity = (identifier, functionName, detail = {}) => { 23810 if (this.debug) { 23811 this.logFormattedMessage(identifier, functionName, detail); 23812 } 23813 }; 23814 this.element = element; 23815 this.schema = schema; 23816 this.dispatcher = new Dispatcher(this); 23817 this.router = new Router(this); 23818 this.actionDescriptorFilters = Object.assign({}, defaultActionDescriptorFilters); 23819 } 23820 static start(element, schema) { 23821 const application2 = new this(element, schema); 23822 application2.start(); 23823 return application2; 23824 } 23825 async start() { 23826 await domReady(); 23827 this.logDebugActivity("application", "starting"); 23828 this.dispatcher.start(); 23829 this.router.start(); 23830 this.logDebugActivity("application", "start"); 23831 } 23832 stop() { 23833 this.logDebugActivity("application", "stopping"); 23834 this.dispatcher.stop(); 23835 this.router.stop(); 23836 this.logDebugActivity("application", "stop"); 23837 } 23838 register(identifier, controllerConstructor) { 23839 this.load({ identifier, controllerConstructor }); 23840 } 23841 registerActionOption(name, filter) { 23842 this.actionDescriptorFilters[name] = filter; 23843 } 23844 load(head, ...rest) { 23845 const definitions = Array.isArray(head) ? head : [head, ...rest]; 23846 definitions.forEach((definition) => { 23847 if (definition.controllerConstructor.shouldLoad) { 23848 this.router.loadDefinition(definition); 23849 } 23850 }); 23851 } 23852 unload(head, ...rest) { 23853 const identifiers = Array.isArray(head) ? head : [head, ...rest]; 23854 identifiers.forEach((identifier) => this.router.unloadIdentifier(identifier)); 23855 } 23856 get controllers() { 23857 return this.router.contexts.map((context) => context.controller); 23858 } 23859 getControllerForElementAndIdentifier(element, identifier) { 23860 const context = this.router.getContextForElementAndIdentifier(element, identifier); 23861 return context ? context.controller : null; 23862 } 23863 handleError(error2, message, detail) { 23864 var _a; 23865 this.logger.error(`%s 23866 23867%o 23868 23869%o`, message, error2, detail); 23870 (_a = window.onerror) === null || _a === void 0 ? void 0 : _a.call(window, message, "", 0, 0, error2); 23871 } 23872 logFormattedMessage(identifier, functionName, detail = {}) { 23873 detail = Object.assign({ application: this }, detail); 23874 this.logger.groupCollapsed(`${identifier} #${functionName}`); 23875 this.logger.log("details:", Object.assign({}, detail)); 23876 this.logger.groupEnd(); 23877 } 23878 }; 23879 function domReady() { 23880 return new Promise((resolve) => { 23881 if (document.readyState == "loading") { 23882 document.addEventListener("DOMContentLoaded", () => resolve()); 23883 } else { 23884 resolve(); 23885 } 23886 }); 23887 } 23888 function ClassPropertiesBlessing(constructor) { 23889 const classes = readInheritableStaticArrayValues(constructor, "classes"); 23890 return classes.reduce((properties, classDefinition) => { 23891 return Object.assign(properties, propertiesForClassDefinition(classDefinition)); 23892 }, {}); 23893 } 23894 function propertiesForClassDefinition(key) { 23895 return { 23896 [`${key}Class`]: { 23897 get() { 23898 const { classes } = this; 23899 if (classes.has(key)) { 23900 return classes.get(key); 23901 } else { 23902 const attribute = classes.getAttributeName(key); 23903 throw new Error(`Missing attribute "${attribute}"`); 23904 } 23905 } 23906 }, 23907 [`${key}Classes`]: { 23908 get() { 23909 return this.classes.getAll(key); 23910 } 23911 }, 23912 [`has${capitalize(key)}Class`]: { 23913 get() { 23914 return this.classes.has(key); 23915 } 23916 } 23917 }; 23918 } 23919 function OutletPropertiesBlessing(constructor) { 23920 const outlets = readInheritableStaticArrayValues(constructor, "outlets"); 23921 return outlets.reduce((properties, outletDefinition) => { 23922 return Object.assign(properties, propertiesForOutletDefinition(outletDefinition)); 23923 }, {}); 23924 } 23925 function getOutletController(controller, element, identifier) { 23926 return controller.application.getControllerForElementAndIdentifier(element, identifier); 23927 } 23928 function getControllerAndEnsureConnectedScope(controller, element, outletName) { 23929 let outletController = getOutletController(controller, element, outletName); 23930 if (outletController) 23931 return outletController; 23932 controller.application.router.proposeToConnectScopeForElementAndIdentifier(element, outletName); 23933 outletController = getOutletController(controller, element, outletName); 23934 if (outletController) 23935 return outletController; 23936 } 23937 function propertiesForOutletDefinition(name) { 23938 const camelizedName = namespaceCamelize(name); 23939 return { 23940 [`${camelizedName}Outlet`]: { 23941 get() { 23942 const outletElement = this.outlets.find(name); 23943 const selector = this.outlets.getSelectorForOutletName(name); 23944 if (outletElement) { 23945 const outletController = getControllerAndEnsureConnectedScope(this, outletElement, name); 23946 if (outletController) 23947 return outletController; 23948 throw new Error(`The provided outlet element is missing an outlet controller "${name}" instance for host controller "${this.identifier}"`); 23949 } 23950 throw new Error(`Missing outlet element "${name}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${selector}".`); 23951 } 23952 }, 23953 [`${camelizedName}Outlets`]: { 23954 get() { 23955 const outlets = this.outlets.findAll(name); 23956 if (outlets.length > 0) { 23957 return outlets.map((outletElement) => { 23958 const outletController = getControllerAndEnsureConnectedScope(this, outletElement, name); 23959 if (outletController) 23960 return outletController; 23961 console.warn(`The provided outlet element is missing an outlet controller "${name}" instance for host controller "${this.identifier}"`, outletElement); 23962 }).filter((controller) => controller); 23963 } 23964 return []; 23965 } 23966 }, 23967 [`${camelizedName}OutletElement`]: { 23968 get() { 23969 const outletElement = this.outlets.find(name); 23970 const selector = this.outlets.getSelectorForOutletName(name); 23971 if (outletElement) { 23972 return outletElement; 23973 } else { 23974 throw new Error(`Missing outlet element "${name}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${selector}".`); 23975 } 23976 } 23977 }, 23978 [`${camelizedName}OutletElements`]: { 23979 get() { 23980 return this.outlets.findAll(name); 23981 } 23982 }, 23983 [`has${capitalize(camelizedName)}Outlet`]: { 23984 get() { 23985 return this.outlets.has(name); 23986 } 23987 } 23988 }; 23989 } 23990 function TargetPropertiesBlessing(constructor) { 23991 const targets = readInheritableStaticArrayValues(constructor, "targets"); 23992 return targets.reduce((properties, targetDefinition) => { 23993 return Object.assign(properties, propertiesForTargetDefinition(targetDefinition)); 23994 }, {}); 23995 } 23996 function propertiesForTargetDefinition(name) { 23997 return { 23998 [`${name}Target`]: { 23999 get() { 24000 const target = this.targets.find(name); 24001 if (target) { 24002 return target; 24003 } else { 24004 throw new Error(`Missing target element "${name}" for "${this.identifier}" controller`); 24005 } 24006 } 24007 }, 24008 [`${name}Targets`]: { 24009 get() { 24010 return this.targets.findAll(name); 24011 } 24012 }, 24013 [`has${capitalize(name)}Target`]: { 24014 get() { 24015 return this.targets.has(name); 24016 } 24017 } 24018 }; 24019 } 24020 function ValuePropertiesBlessing(constructor) { 24021 const valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, "values"); 24022 const propertyDescriptorMap = { 24023 valueDescriptorMap: { 24024 get() { 24025 return valueDefinitionPairs.reduce((result, valueDefinitionPair) => { 24026 const valueDescriptor = parseValueDefinitionPair(valueDefinitionPair, this.identifier); 24027 const attributeName = this.data.getAttributeNameForKey(valueDescriptor.key); 24028 return Object.assign(result, { [attributeName]: valueDescriptor }); 24029 }, {}); 24030 } 24031 } 24032 }; 24033 return valueDefinitionPairs.reduce((properties, valueDefinitionPair) => { 24034 return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair)); 24035 }, propertyDescriptorMap); 24036 } 24037 function propertiesForValueDefinitionPair(valueDefinitionPair, controller) { 24038 const definition = parseValueDefinitionPair(valueDefinitionPair, controller); 24039 const { key, name, reader: read, writer: write } = definition; 24040 return { 24041 [name]: { 24042 get() { 24043 const value = this.data.get(key); 24044 if (value !== null) { 24045 return read(value); 24046 } else { 24047 return definition.defaultValue; 24048 } 24049 }, 24050 set(value) { 24051 if (value === void 0) { 24052 this.data.delete(key); 24053 } else { 24054 this.data.set(key, write(value)); 24055 } 24056 } 24057 }, 24058 [`has${capitalize(name)}`]: { 24059 get() { 24060 return this.data.has(key) || definition.hasCustomDefaultValue; 24061 } 24062 } 24063 }; 24064 } 24065 function parseValueDefinitionPair([token, typeDefinition], controller) { 24066 return valueDescriptorForTokenAndTypeDefinition({ 24067 controller, 24068 token, 24069 typeDefinition 24070 }); 24071 } 24072 function parseValueTypeConstant(constant) { 24073 switch (constant) { 24074 case Array: 24075 return "array"; 24076 case Boolean: 24077 return "boolean"; 24078 case Number: 24079 return "number"; 24080 case Object: 24081 return "object"; 24082 case String: 24083 return "string"; 24084 } 24085 } 24086 function parseValueTypeDefault(defaultValue) { 24087 switch (typeof defaultValue) { 24088 case "boolean": 24089 return "boolean"; 24090 case "number": 24091 return "number"; 24092 case "string": 24093 return "string"; 24094 } 24095 if (Array.isArray(defaultValue)) 24096 return "array"; 24097 if (Object.prototype.toString.call(defaultValue) === "[object Object]") 24098 return "object"; 24099 } 24100 function parseValueTypeObject(payload) { 24101 const { controller, token, typeObject } = payload; 24102 const hasType = isSomething(typeObject.type); 24103 const hasDefault = isSomething(typeObject.default); 24104 const fullObject = hasType && hasDefault; 24105 const onlyType = hasType && !hasDefault; 24106 const onlyDefault = !hasType && hasDefault; 24107 const typeFromObject = parseValueTypeConstant(typeObject.type); 24108 const typeFromDefaultValue = parseValueTypeDefault(payload.typeObject.default); 24109 if (onlyType) 24110 return typeFromObject; 24111 if (onlyDefault) 24112 return typeFromDefaultValue; 24113 if (typeFromObject !== typeFromDefaultValue) { 24114 const propertyPath = controller ? `${controller}.${token}` : token; 24115 throw new Error(`The specified default value for the Stimulus Value "${propertyPath}" must match the defined type "${typeFromObject}". The provided default value of "${typeObject.default}" is of type "${typeFromDefaultValue}".`); 24116 } 24117 if (fullObject) 24118 return typeFromObject; 24119 } 24120 function parseValueTypeDefinition(payload) { 24121 const { controller, token, typeDefinition } = payload; 24122 const typeObject = { controller, token, typeObject: typeDefinition }; 24123 const typeFromObject = parseValueTypeObject(typeObject); 24124 const typeFromDefaultValue = parseValueTypeDefault(typeDefinition); 24125 const typeFromConstant = parseValueTypeConstant(typeDefinition); 24126 const type = typeFromObject || typeFromDefaultValue || typeFromConstant; 24127 if (type) 24128 return type; 24129 const propertyPath = controller ? `${controller}.${typeDefinition}` : token; 24130 throw new Error(`Unknown value type "${propertyPath}" for "${token}" value`); 24131 } 24132 function defaultValueForDefinition(typeDefinition) { 24133 const constant = parseValueTypeConstant(typeDefinition); 24134 if (constant) 24135 return defaultValuesByType[constant]; 24136 const hasDefault = hasProperty(typeDefinition, "default"); 24137 const hasType = hasProperty(typeDefinition, "type"); 24138 const typeObject = typeDefinition; 24139 if (hasDefault) 24140 return typeObject.default; 24141 if (hasType) { 24142 const { type } = typeObject; 24143 const constantFromType = parseValueTypeConstant(type); 24144 if (constantFromType) 24145 return defaultValuesByType[constantFromType]; 24146 } 24147 return typeDefinition; 24148 } 24149 function valueDescriptorForTokenAndTypeDefinition(payload) { 24150 const { token, typeDefinition } = payload; 24151 const key = `${dasherize(token)}-value`; 24152 const type = parseValueTypeDefinition(payload); 24153 return { 24154 type, 24155 key, 24156 name: camelize(key), 24157 get defaultValue() { 24158 return defaultValueForDefinition(typeDefinition); 24159 }, 24160 get hasCustomDefaultValue() { 24161 return parseValueTypeDefault(typeDefinition) !== void 0; 24162 }, 24163 reader: readers[type], 24164 writer: writers[type] || writers.default 24165 }; 24166 } 24167 var defaultValuesByType = { 24168 get array() { 24169 return []; 24170 }, 24171 boolean: false, 24172 number: 0, 24173 get object() { 24174 return {}; 24175 }, 24176 string: "" 24177 }; 24178 var readers = { 24179 array(value) { 24180 const array = JSON.parse(value); 24181 if (!Array.isArray(array)) { 24182 throw new TypeError(`expected value of type "array" but instead got value "${value}" of type "${parseValueTypeDefault(array)}"`); 24183 } 24184 return array; 24185 }, 24186 boolean(value) { 24187 return !(value == "0" || String(value).toLowerCase() == "false"); 24188 }, 24189 number(value) { 24190 return Number(value.replace(/_/g, "")); 24191 }, 24192 object(value) { 24193 const object = JSON.parse(value); 24194 if (object === null || typeof object != "object" || Array.isArray(object)) { 24195 throw new TypeError(`expected value of type "object" but instead got value "${value}" of type "${parseValueTypeDefault(object)}"`); 24196 } 24197 return object; 24198 }, 24199 string(value) { 24200 return value; 24201 } 24202 }; 24203 var writers = { 24204 default: writeString, 24205 array: writeJSON, 24206 object: writeJSON 24207 }; 24208 function writeJSON(value) { 24209 return JSON.stringify(value); 24210 } 24211 function writeString(value) { 24212 return `${value}`; 24213 } 24214 var Controller = class { 24215 constructor(context) { 24216 this.context = context; 24217 } 24218 static get shouldLoad() { 24219 return true; 24220 } 24221 static afterLoad(_identifier, _application) { 24222 return; 24223 } 24224 get application() { 24225 return this.context.application; 24226 } 24227 get scope() { 24228 return this.context.scope; 24229 } 24230 get element() { 24231 return this.scope.element; 24232 } 24233 get identifier() { 24234 return this.scope.identifier; 24235 } 24236 get targets() { 24237 return this.scope.targets; 24238 } 24239 get outlets() { 24240 return this.scope.outlets; 24241 } 24242 get classes() { 24243 return this.scope.classes; 24244 } 24245 get data() { 24246 return this.scope.data; 24247 } 24248 initialize() { 24249 } 24250 connect() { 24251 } 24252 disconnect() { 24253 } 24254 dispatch(eventName, { target = this.element, detail = {}, prefix = this.identifier, bubbles = true, cancelable = true } = {}) { 24255 const type = prefix ? `${prefix}:${eventName}` : eventName; 24256 const event = new CustomEvent(type, { detail, bubbles, cancelable }); 24257 target.dispatchEvent(event); 24258 return event; 24259 } 24260 }; 24261 Controller.blessings = [ 24262 ClassPropertiesBlessing, 24263 TargetPropertiesBlessing, 24264 ValuePropertiesBlessing, 24265 OutletPropertiesBlessing 24266 ]; 24267 Controller.targets = []; 24268 Controller.outlets = []; 24269 Controller.values = {}; 24270 24271
24271// app/javascript/controllers/application.js 24272 var application = Application.start(); 24273 application.debug = false; 24274 window.Stimulus = application; 24275 24276
24276// app/javascript/controllers/artists_search_controller.js 24277 var artists_search_controller_default = class extends Controller { 24278 static targets = ["searchResultLink", "itemSearchLink", "viewAllLink"]; 24279 static values = { paramName: String, searchText: String }; 24280 search(event) { 24281 clearTimeout(this.timeout); 24282 this.timeout = setTimeout(() => { 24283 this.element.requestSubmit(); 24284 }, 300); 24285 this.searchTextValue = event.target.value; 24286 this.updateSearchParam(event.target.value); 24287 } 24288 updateSearchParam(value) { 24289 const url = new URL(this.itemSearchLinkTarget.href); 24290 const params = new URLSearchParams(url.search); 24291 if (value) { 24292 params.set(this.paramNameValue, value); 24293 } else { 24294 params.delete(this.paramNameValue); 24295 } 24296 url.search = params.toString(); 24297 this.itemSearchLinkTarget.href = url.toString(); 24298 } 24299 viewAllLinkTargetConnected(target) { 24300 target.href = this.itemSearchLinkTarget.href; 24301 this.#highlightSearchResults(this.searchTextValue); 24302 } 24303 navigateToResults(event) { 24304 Turbo.visit(this.itemSearchLinkTarget.href); 24305 } 24306 #highlightSearchResults(search) { 24307 if (!search) return; 24308 const escapedSearch = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"); 24309 const regex = new RegExp(escapedSearch, "gi"); 24310 this.searchResultLinkTargets.forEach((link) => { 24311 const text = link.innerText; 24312 link.innerHTML = text.replace(regex, (match) => `<strong>${match}</strong>`); 24313 }); 24314 } 24315 }; 24316 24317
24317// app/javascript/controllers/index.js 24318 application.register("artists-search", artists_search_controller_default); 24319 24320
24320// app/javascript/sticky_header.js 24321 document.addEventListener("turbo:load", () => { 24322 const stickyHeader = document.querySelector("[data-sticky-header]"); 24323 if (!stickyHeader) return; 24324 const accordions = document.querySelectorAll("[data-parent='#auctionAccordion']"); 24325 const deltaInPx = 10; 24326 let lastScrollY = 0; 24327 let hidden = false; 24328 let accordionsOpen = Array(accordions.length).fill(false); 24329 accordions.forEach((accordion, index) => { 24330 $(accordion).on("show.bs.collapse", () => accordionsOpen[index] = true); 24331 $(accordion).on("hidden.bs.collapse", () => accordionsOpen[index] = false); 24332 }); 24333 window.addEventListener("scroll", () => { 24334 if (accordionsOpen.includes(true)) return; 24335 if (scrollY > lastScrollY) { 24336 if (!hidden && Math.abs(scrollY - lastScrollY) > deltaInPx) { 24337 hidden = true; 24338 stickyHeader.classList.add("auction-header-hidden"); 24339 stickyHeader.classList.remove("auction-header-visible"); 24340 } 24341 } else if (hidden) { 24342 hidden = false; 24343 stickyHeader.classList.remove("auction-header-hidden"); 24344 stickyHeader.classList.add("auction-header-visible"); 24345 } 24346 lastScrollY = scrollY; 24347 }); 24348 }); 24349 24350
24350// app/javascript/application.js 24351 window.Rails = Rails; 24352})(); 24353/*! Bundled license information: 24354 24355jquery/dist/jquery.js: 24356 (*! 24357 * jQuery JavaScript Library v3.7.1 24358 * https://jquery.com/ 24359 * 24360 * Copyright OpenJS Foundation and other contributors 24361 * Released under the MIT license 24362 * https://jquery.org/license 24363 * 24364 * Date: 2023-08-28T13:37Z 24365 *) 24366 24367popper.js/dist/umd/popper.js: 24368 (**! 24369 * @fileOverview Kickass library to create and place poppers near their reference elements. 24370 * @version 1.16.1 24371 * @license 24372 * Copyright (c) 2016 Federico Zivolo and contributors 24373 * 24374 * Permission is hereby granted, free of charge, to any person obtaining a copy 24375 * of this software and associated documentation files (the "Software"), to deal 24376 * in the Software without restriction, including without limitation the rights 24377 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 24378 * copies of the Software, and to permit persons to whom the Software is 24379 * furnished to do so, subject to the following conditions: 24380 * 24381 * The above copyright notice and this permission notice shall be included in all 24382 * copies or substantial portions of the Software. 24383 * 24384 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24385 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24386 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24387 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24388 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24389 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24390 * SOFTWARE. 24391 *) 24392 24393bootstrap/dist/js/bootstrap.js: 24394 (*! 24395 * Bootstrap v4.3.1 (https://getbootstrap.com/) 24396 * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) 24397 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 24398 *) 24399 24400viewerjs/dist/viewer.js: 24401 (*! 24402 * Viewer.js v1.12.0 24403 * https://fengyuanchen.github.io/viewerjs 24404 * 24405 * Copyright 2015-present Chen Fengyuan 24406 * Released under the MIT license 24407 * 24408 * Date: 2026-08-22T13:00:39.652Z 24409 *) 24410 24411@hotwired/turbo/dist/turbo.es2017-esm.js: 24412 (*! 24413 Turbo 8.0.23 24414 Copyright © 2026 37signals LLC 24415 *) 24416*/ 24417;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.