[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ var __webpack_modules__ = ({ 3 4 /***/ 1933: 5 /***/ ((module, exports, __webpack_require__) => { 6 7 var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */ 8 /** 9 * Copyright 2012-2017 Craig Campbell 10 * 11 * Licensed under the Apache License, Version 2.0 (the "License"); 12 * you may not use this file except in compliance with the License. 13 * You may obtain a copy of the License at 14 * 15 * http://www.apache.org/licenses/LICENSE-2.0 16 * 17 * Unless required by applicable law or agreed to in writing, software 18 * distributed under the License is distributed on an "AS IS" BASIS, 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 * See the License for the specific language governing permissions and 21 * limitations under the License. 22 * 23 * Mousetrap is a simple keyboard shortcut library for Javascript with 24 * no external dependencies 25 * 26 * @version 1.6.5 27 * @url craig.is/killing/mice 28 */ 29 (function(window, document, undefined) { 30 31 // Check if mousetrap is used inside browser, if not, return 32 if (!window) { 33 return; 34 } 35 36 /** 37 * mapping of special keycodes to their corresponding keys 38 * 39 * everything in this dictionary cannot use keypress events 40 * so it has to be here to map to the correct keycodes for 41 * keyup/keydown events 42 * 43 * @type {Object} 44 */ 45 var _MAP = { 46 8: 'backspace', 47 9: 'tab', 48 13: 'enter', 49 16: 'shift', 50 17: 'ctrl', 51 18: 'alt', 52 20: 'capslock', 53 27: 'esc', 54 32: 'space', 55 33: 'pageup', 56 34: 'pagedown', 57 35: 'end', 58 36: 'home', 59 37: 'left', 60 38: 'up', 61 39: 'right', 62 40: 'down', 63 45: 'ins', 64 46: 'del', 65 91: 'meta', 66 93: 'meta', 67 224: 'meta' 68 }; 69 70 /** 71 * mapping for special characters so they can support 72 * 73 * this dictionary is only used incase you want to bind a 74 * keyup or keydown event to one of these keys 75 * 76 * @type {Object} 77 */ 78 var _KEYCODE_MAP = { 79 106: '*', 80 107: '+', 81 109: '-', 82 110: '.', 83 111 : '/', 84 186: ';', 85 187: '=', 86 188: ',', 87 189: '-', 88 190: '.', 89 191: '/', 90 192: '`', 91 219: '[', 92 220: '\\', 93 221: ']', 94 222: '\'' 95 }; 96 97 /** 98 * this is a mapping of keys that require shift on a US keypad 99 * back to the non shift equivelents 100 * 101 * this is so you can use keyup events with these keys 102 * 103 * note that this will only work reliably on US keyboards 104 * 105 * @type {Object} 106 */ 107 var _SHIFT_MAP = { 108 '~': '`', 109 '!': '1', 110 '@': '2', 111 '#': '3', 112 '$': '4', 113 '%': '5', 114 '^': '6', 115 '&': '7', 116 '*': '8', 117 '(': '9', 118 ')': '0', 119 '_': '-', 120 '+': '=', 121 ':': ';', 122 '\"': '\'', 123 '<': ',', 124 '>': '.', 125 '?': '/', 126 '|': '\\' 127 }; 128 129 /** 130 * this is a list of special strings you can use to map 131 * to modifier keys when you specify your keyboard shortcuts 132 * 133 * @type {Object} 134 */ 135 var _SPECIAL_ALIASES = { 136 'option': 'alt', 137 'command': 'meta', 138 'return': 'enter', 139 'escape': 'esc', 140 'plus': '+', 141 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl' 142 }; 143 144 /** 145 * variable to store the flipped version of _MAP from above 146 * needed to check if we should use keypress or not when no action 147 * is specified 148 * 149 * @type {Object|undefined} 150 */ 151 var _REVERSE_MAP; 152 153 /** 154 * loop through the f keys, f1 to f19 and add them to the map 155 * programatically 156 */ 157 for (var i = 1; i < 20; ++i) { 158 _MAP[111 + i] = 'f' + i; 159 } 160 161 /** 162 * loop through to map numbers on the numeric keypad 163 */ 164 for (i = 0; i <= 9; ++i) { 165 166 // This needs to use a string cause otherwise since 0 is falsey 167 // mousetrap will never fire for numpad 0 pressed as part of a keydown 168 // event. 169 // 170 // @see https://github.com/ccampbell/mousetrap/pull/258 171 _MAP[i + 96] = i.toString(); 172 } 173 174 /** 175 * cross browser add event method 176 * 177 * @param {Element|HTMLDocument} object 178 * @param {string} type 179 * @param {Function} callback 180 * @returns void 181 */ 182 function _addEvent(object, type, callback) { 183 if (object.addEventListener) { 184 object.addEventListener(type, callback, false); 185 return; 186 } 187 188 object.attachEvent('on' + type, callback); 189 } 190 191 /** 192 * takes the event and returns the key character 193 * 194 * @param {Event} e 195 * @return {string} 196 */ 197 function _characterFromEvent(e) { 198 199 // for keypress events we should return the character as is 200 if (e.type == 'keypress') { 201 var character = String.fromCharCode(e.which); 202 203 // if the shift key is not pressed then it is safe to assume 204 // that we want the character to be lowercase. this means if 205 // you accidentally have caps lock on then your key bindings 206 // will continue to work 207 // 208 // the only side effect that might not be desired is if you 209 // bind something like 'A' cause you want to trigger an 210 // event when capital A is pressed caps lock will no longer 211 // trigger the event. shift+a will though. 212 if (!e.shiftKey) { 213 character = character.toLowerCase(); 214 } 215 216 return character; 217 } 218 219 // for non keypress events the special maps are needed 220 if (_MAP[e.which]) { 221 return _MAP[e.which]; 222 } 223 224 if (_KEYCODE_MAP[e.which]) { 225 return _KEYCODE_MAP[e.which]; 226 } 227 228 // if it is not in the special map 229 230 // with keydown and keyup events the character seems to always 231 // come in as an uppercase character whether you are pressing shift 232 // or not. we should make sure it is always lowercase for comparisons 233 return String.fromCharCode(e.which).toLowerCase(); 234 } 235 236 /** 237 * checks if two arrays are equal 238 * 239 * @param {Array} modifiers1 240 * @param {Array} modifiers2 241 * @returns {boolean} 242 */ 243 function _modifiersMatch(modifiers1, modifiers2) { 244 return modifiers1.sort().join(',') === modifiers2.sort().join(','); 245 } 246 247 /** 248 * takes a key event and figures out what the modifiers are 249 * 250 * @param {Event} e 251 * @returns {Array} 252 */ 253 function _eventModifiers(e) { 254 var modifiers = []; 255 256 if (e.shiftKey) { 257 modifiers.push('shift'); 258 } 259 260 if (e.altKey) { 261 modifiers.push('alt'); 262 } 263 264 if (e.ctrlKey) { 265 modifiers.push('ctrl'); 266 } 267 268 if (e.metaKey) { 269 modifiers.push('meta'); 270 } 271 272 return modifiers; 273 } 274 275 /** 276 * prevents default for this event 277 * 278 * @param {Event} e 279 * @returns void 280 */ 281 function _preventDefault(e) { 282 if (e.preventDefault) { 283 e.preventDefault(); 284 return; 285 } 286 287 e.returnValue = false; 288 } 289 290 /** 291 * stops propogation for this event 292 * 293 * @param {Event} e 294 * @returns void 295 */ 296 function _stopPropagation(e) { 297 if (e.stopPropagation) { 298 e.stopPropagation(); 299 return; 300 } 301 302 e.cancelBubble = true; 303 } 304 305 /** 306 * determines if the keycode specified is a modifier key or not 307 * 308 * @param {string} key 309 * @returns {boolean} 310 */ 311 function _isModifier(key) { 312 return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta'; 313 } 314 315 /** 316 * reverses the map lookup so that we can look for specific keys 317 * to see what can and can't use keypress 318 * 319 * @return {Object} 320 */ 321 function _getReverseMap() { 322 if (!_REVERSE_MAP) { 323 _REVERSE_MAP = {}; 324 for (var key in _MAP) { 325 326 // pull out the numeric keypad from here cause keypress should 327 // be able to detect the keys from the character 328 if (key > 95 && key < 112) { 329 continue; 330 } 331 332 if (_MAP.hasOwnProperty(key)) { 333 _REVERSE_MAP[_MAP[key]] = key; 334 } 335 } 336 } 337 return _REVERSE_MAP; 338 } 339 340 /** 341 * picks the best action based on the key combination 342 * 343 * @param {string} key - character for key 344 * @param {Array} modifiers 345 * @param {string=} action passed in 346 */ 347 function _pickBestAction(key, modifiers, action) { 348 349 // if no action was picked in we should try to pick the one 350 // that we think would work best for this key 351 if (!action) { 352 action = _getReverseMap()[key] ? 'keydown' : 'keypress'; 353 } 354 355 // modifier keys don't work as expected with keypress, 356 // switch to keydown 357 if (action == 'keypress' && modifiers.length) { 358 action = 'keydown'; 359 } 360 361 return action; 362 } 363 364 /** 365 * Converts from a string key combination to an array 366 * 367 * @param {string} combination like "command+shift+l" 368 * @return {Array} 369 */ 370 function _keysFromString(combination) { 371 if (combination === '+') { 372 return ['+']; 373 } 374 375 combination = combination.replace(/\+{2}/g, '+plus'); 376 return combination.split('+'); 377 } 378 379 /** 380 * Gets info for a specific key combination 381 * 382 * @param {string} combination key combination ("command+s" or "a" or "*") 383 * @param {string=} action 384 * @returns {Object} 385 */ 386 function _getKeyInfo(combination, action) { 387 var keys; 388 var key; 389 var i; 390 var modifiers = []; 391 392 // take the keys from this pattern and figure out what the actual 393 // pattern is all about 394 keys = _keysFromString(combination); 395 396 for (i = 0; i < keys.length; ++i) { 397 key = keys[i]; 398 399 // normalize key names 400 if (_SPECIAL_ALIASES[key]) { 401 key = _SPECIAL_ALIASES[key]; 402 } 403 404 // if this is not a keypress event then we should 405 // be smart about using shift keys 406 // this will only work for US keyboards however 407 if (action && action != 'keypress' && _SHIFT_MAP[key]) { 408 key = _SHIFT_MAP[key]; 409 modifiers.push('shift'); 410 } 411 412 // if this key is a modifier then add it to the list of modifiers 413 if (_isModifier(key)) { 414 modifiers.push(key); 415 } 416 } 417 418 // depending on what the key combination is 419 // we will try to pick the best event for it 420 action = _pickBestAction(key, modifiers, action); 421 422 return { 423 key: key, 424 modifiers: modifiers, 425 action: action 426 }; 427 } 428 429 function _belongsTo(element, ancestor) { 430 if (element === null || element === document) { 431 return false; 432 } 433 434 if (element === ancestor) { 435 return true; 436 } 437 438 return _belongsTo(element.parentNode, ancestor); 439 } 440 441 function Mousetrap(targetElement) { 442 var self = this; 443 444 targetElement = targetElement || document; 445 446 if (!(self instanceof Mousetrap)) { 447 return new Mousetrap(targetElement); 448 } 449 450 /** 451 * element to attach key events to 452 * 453 * @type {Element} 454 */ 455 self.target = targetElement; 456 457 /** 458 * a list of all the callbacks setup via Mousetrap.bind() 459 * 460 * @type {Object} 461 */ 462 self._callbacks = {}; 463 464 /** 465 * direct map of string combinations to callbacks used for trigger() 466 * 467 * @type {Object} 468 */ 469 self._directMap = {}; 470 471 /** 472 * keeps track of what level each sequence is at since multiple 473 * sequences can start out with the same sequence 474 * 475 * @type {Object} 476 */ 477 var _sequenceLevels = {}; 478 479 /** 480 * variable to store the setTimeout call 481 * 482 * @type {null|number} 483 */ 484 var _resetTimer; 485 486 /** 487 * temporary state where we will ignore the next keyup 488 * 489 * @type {boolean|string} 490 */ 491 var _ignoreNextKeyup = false; 492 493 /** 494 * temporary state where we will ignore the next keypress 495 * 496 * @type {boolean} 497 */ 498 var _ignoreNextKeypress = false; 499 500 /** 501 * are we currently inside of a sequence? 502 * type of action ("keyup" or "keydown" or "keypress") or false 503 * 504 * @type {boolean|string} 505 */ 506 var _nextExpectedAction = false; 507 508 /** 509 * resets all sequence counters except for the ones passed in 510 * 511 * @param {Object} doNotReset 512 * @returns void 513 */ 514 function _resetSequences(doNotReset) { 515 doNotReset = doNotReset || {}; 516 517 var activeSequences = false, 518 key; 519 520 for (key in _sequenceLevels) { 521 if (doNotReset[key]) { 522 activeSequences = true; 523 continue; 524 } 525 _sequenceLevels[key] = 0; 526 } 527 528 if (!activeSequences) { 529 _nextExpectedAction = false; 530 } 531 } 532 533 /** 534 * finds all callbacks that match based on the keycode, modifiers, 535 * and action 536 * 537 * @param {string} character 538 * @param {Array} modifiers 539 * @param {Event|Object} e 540 * @param {string=} sequenceName - name of the sequence we are looking for 541 * @param {string=} combination 542 * @param {number=} level 543 * @returns {Array} 544 */ 545 function _getMatches(character, modifiers, e, sequenceName, combination, level) { 546 var i; 547 var callback; 548 var matches = []; 549 var action = e.type; 550 551 // if there are no events related to this keycode 552 if (!self._callbacks[character]) { 553 return []; 554 } 555 556 // if a modifier key is coming up on its own we should allow it 557 if (action == 'keyup' && _isModifier(character)) { 558 modifiers = [character]; 559 } 560 561 // loop through all callbacks for the key that was pressed 562 // and see if any of them match 563 for (i = 0; i < self._callbacks[character].length; ++i) { 564 callback = self._callbacks[character][i]; 565 566 // if a sequence name is not specified, but this is a sequence at 567 // the wrong level then move onto the next match 568 if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) { 569 continue; 570 } 571 572 // if the action we are looking for doesn't match the action we got 573 // then we should keep going 574 if (action != callback.action) { 575 continue; 576 } 577 578 // if this is a keypress event and the meta key and control key 579 // are not pressed that means that we need to only look at the 580 // character, otherwise check the modifiers as well 581 // 582 // chrome will not fire a keypress if meta or control is down 583 // safari will fire a keypress if meta or meta+shift is down 584 // firefox will fire a keypress if meta or control is down 585 if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) { 586 587 // when you bind a combination or sequence a second time it 588 // should overwrite the first one. if a sequenceName or 589 // combination is specified in this call it does just that 590 // 591 // @todo make deleting its own method? 592 var deleteCombo = !sequenceName && callback.combo == combination; 593 var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level; 594 if (deleteCombo || deleteSequence) { 595 self._callbacks[character].splice(i, 1); 596 } 597 598 matches.push(callback); 599 } 600 } 601 602 return matches; 603 } 604 605 /** 606 * actually calls the callback function 607 * 608 * if your callback function returns false this will use the jquery 609 * convention - prevent default and stop propogation on the event 610 * 611 * @param {Function} callback 612 * @param {Event} e 613 * @returns void 614 */ 615 function _fireCallback(callback, e, combo, sequence) { 616 617 // if this event should not happen stop here 618 if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) { 619 return; 620 } 621 622 if (callback(e, combo) === false) { 623 _preventDefault(e); 624 _stopPropagation(e); 625 } 626 } 627 628 /** 629 * handles a character key event 630 * 631 * @param {string} character 632 * @param {Array} modifiers 633 * @param {Event} e 634 * @returns void 635 */ 636 self._handleKey = function(character, modifiers, e) { 637 var callbacks = _getMatches(character, modifiers, e); 638 var i; 639 var doNotReset = {}; 640 var maxLevel = 0; 641 var processedSequenceCallback = false; 642 643 // Calculate the maxLevel for sequences so we can only execute the longest callback sequence 644 for (i = 0; i < callbacks.length; ++i) { 645 if (callbacks[i].seq) { 646 maxLevel = Math.max(maxLevel, callbacks[i].level); 647 } 648 } 649 650 // loop through matching callbacks for this key event 651 for (i = 0; i < callbacks.length; ++i) { 652 653 // fire for all sequence callbacks 654 // this is because if for example you have multiple sequences 655 // bound such as "g i" and "g t" they both need to fire the 656 // callback for matching g cause otherwise you can only ever 657 // match the first one 658 if (callbacks[i].seq) { 659 660 // only fire callbacks for the maxLevel to prevent 661 // subsequences from also firing 662 // 663 // for example 'a option b' should not cause 'option b' to fire 664 // even though 'option b' is part of the other sequence 665 // 666 // any sequences that do not match here will be discarded 667 // below by the _resetSequences call 668 if (callbacks[i].level != maxLevel) { 669 continue; 670 } 671 672 processedSequenceCallback = true; 673 674 // keep a list of which sequences were matches for later 675 doNotReset[callbacks[i].seq] = 1; 676 _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq); 677 continue; 678 } 679 680 // if there were no sequence matches but we are still here 681 // that means this is a regular match so we should fire that 682 if (!processedSequenceCallback) { 683 _fireCallback(callbacks[i].callback, e, callbacks[i].combo); 684 } 685 } 686 687 // if the key you pressed matches the type of sequence without 688 // being a modifier (ie "keyup" or "keypress") then we should 689 // reset all sequences that were not matched by this event 690 // 691 // this is so, for example, if you have the sequence "h a t" and you 692 // type "h e a r t" it does not match. in this case the "e" will 693 // cause the sequence to reset 694 // 695 // modifier keys are ignored because you can have a sequence 696 // that contains modifiers such as "enter ctrl+space" and in most 697 // cases the modifier key will be pressed before the next key 698 // 699 // also if you have a sequence such as "ctrl+b a" then pressing the 700 // "b" key will trigger a "keypress" and a "keydown" 701 // 702 // the "keydown" is expected when there is a modifier, but the 703 // "keypress" ends up matching the _nextExpectedAction since it occurs 704 // after and that causes the sequence to reset 705 // 706 // we ignore keypresses in a sequence that directly follow a keydown 707 // for the same character 708 var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress; 709 if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) { 710 _resetSequences(doNotReset); 711 } 712 713 _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown'; 714 }; 715 716 /** 717 * handles a keydown event 718 * 719 * @param {Event} e 720 * @returns void 721 */ 722 function _handleKeyEvent(e) { 723 724 // normalize e.which for key events 725 // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion 726 if (typeof e.which !== 'number') { 727 e.which = e.keyCode; 728 } 729 730 var character = _characterFromEvent(e); 731 732 // no character found then stop 733 if (!character) { 734 return; 735 } 736 737 // need to use === for the character check because the character can be 0 738 if (e.type == 'keyup' && _ignoreNextKeyup === character) { 739 _ignoreNextKeyup = false; 740 return; 741 } 742 743 self.handleKey(character, _eventModifiers(e), e); 744 } 745 746 /** 747 * called to set a 1 second timeout on the specified sequence 748 * 749 * this is so after each key press in the sequence you have 1 second 750 * to press the next key before you have to start over 751 * 752 * @returns void 753 */ 754 function _resetSequenceTimer() { 755 clearTimeout(_resetTimer); 756 _resetTimer = setTimeout(_resetSequences, 1000); 757 } 758 759 /** 760 * binds a key sequence to an event 761 * 762 * @param {string} combo - combo specified in bind call 763 * @param {Array} keys 764 * @param {Function} callback 765 * @param {string=} action 766 * @returns void 767 */ 768 function _bindSequence(combo, keys, callback, action) { 769 770 // start off by adding a sequence level record for this combination 771 // and setting the level to 0 772 _sequenceLevels[combo] = 0; 773 774 /** 775 * callback to increase the sequence level for this sequence and reset 776 * all other sequences that were active 777 * 778 * @param {string} nextAction 779 * @returns {Function} 780 */ 781 function _increaseSequence(nextAction) { 782 return function() { 783 _nextExpectedAction = nextAction; 784 ++_sequenceLevels[combo]; 785 _resetSequenceTimer(); 786 }; 787 } 788 789 /** 790 * wraps the specified callback inside of another function in order 791 * to reset all sequence counters as soon as this sequence is done 792 * 793 * @param {Event} e 794 * @returns void 795 */ 796 function _callbackAndReset(e) { 797 _fireCallback(callback, e, combo); 798 799 // we should ignore the next key up if the action is key down 800 // or keypress. this is so if you finish a sequence and 801 // release the key the final key will not trigger a keyup 802 if (action !== 'keyup') { 803 _ignoreNextKeyup = _characterFromEvent(e); 804 } 805 806 // weird race condition if a sequence ends with the key 807 // another sequence begins with 808 setTimeout(_resetSequences, 10); 809 } 810 811 // loop through keys one at a time and bind the appropriate callback 812 // function. for any key leading up to the final one it should 813 // increase the sequence. after the final, it should reset all sequences 814 // 815 // if an action is specified in the original bind call then that will 816 // be used throughout. otherwise we will pass the action that the 817 // next key in the sequence should match. this allows a sequence 818 // to mix and match keypress and keydown events depending on which 819 // ones are better suited to the key provided 820 for (var i = 0; i < keys.length; ++i) { 821 var isFinal = i + 1 === keys.length; 822 var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action); 823 _bindSingle(keys[i], wrappedCallback, action, combo, i); 824 } 825 } 826 827 /** 828 * binds a single keyboard combination 829 * 830 * @param {string} combination 831 * @param {Function} callback 832 * @param {string=} action 833 * @param {string=} sequenceName - name of sequence if part of sequence 834 * @param {number=} level - what part of the sequence the command is 835 * @returns void 836 */ 837 function _bindSingle(combination, callback, action, sequenceName, level) { 838 839 // store a direct mapped reference for use with Mousetrap.trigger 840 self._directMap[combination + ':' + action] = callback; 841 842 // make sure multiple spaces in a row become a single space 843 combination = combination.replace(/\s+/g, ' '); 844 845 var sequence = combination.split(' '); 846 var info; 847 848 // if this pattern is a sequence of keys then run through this method 849 // to reprocess each pattern one key at a time 850 if (sequence.length > 1) { 851 _bindSequence(combination, sequence, callback, action); 852 return; 853 } 854 855 info = _getKeyInfo(combination, action); 856 857 // make sure to initialize array if this is the first time 858 // a callback is added for this key 859 self._callbacks[info.key] = self._callbacks[info.key] || []; 860 861 // remove an existing match if there is one 862 _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level); 863 864 // add this call back to the array 865 // if it is a sequence put it at the beginning 866 // if not put it at the end 867 // 868 // this is important because the way these are processed expects 869 // the sequence ones to come first 870 self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({ 871 callback: callback, 872 modifiers: info.modifiers, 873 action: info.action, 874 seq: sequenceName, 875 level: level, 876 combo: combination 877 }); 878 } 879 880 /** 881 * binds multiple combinations to the same callback 882 * 883 * @param {Array} combinations 884 * @param {Function} callback 885 * @param {string|undefined} action 886 * @returns void 887 */ 888 self._bindMultiple = function(combinations, callback, action) { 889 for (var i = 0; i < combinations.length; ++i) { 890 _bindSingle(combinations[i], callback, action); 891 } 892 }; 893 894 // start! 895 _addEvent(targetElement, 'keypress', _handleKeyEvent); 896 _addEvent(targetElement, 'keydown', _handleKeyEvent); 897 _addEvent(targetElement, 'keyup', _handleKeyEvent); 898 } 899 900 /** 901 * binds an event to mousetrap 902 * 903 * can be a single key, a combination of keys separated with +, 904 * an array of keys, or a sequence of keys separated by spaces 905 * 906 * be sure to list the modifier keys first to make sure that the 907 * correct key ends up getting bound (the last key in the pattern) 908 * 909 * @param {string|Array} keys 910 * @param {Function} callback 911 * @param {string=} action - 'keypress', 'keydown', or 'keyup' 912 * @returns void 913 */ 914 Mousetrap.prototype.bind = function(keys, callback, action) { 915 var self = this; 916 keys = keys instanceof Array ? keys : [keys]; 917 self._bindMultiple.call(self, keys, callback, action); 918 return self; 919 }; 920 921 /** 922 * unbinds an event to mousetrap 923 * 924 * the unbinding sets the callback function of the specified key combo 925 * to an empty function and deletes the corresponding key in the 926 * _directMap dict. 927 * 928 * TODO: actually remove this from the _callbacks dictionary instead 929 * of binding an empty function 930 * 931 * the keycombo+action has to be exactly the same as 932 * it was defined in the bind method 933 * 934 * @param {string|Array} keys 935 * @param {string} action 936 * @returns void 937 */ 938 Mousetrap.prototype.unbind = function(keys, action) { 939 var self = this; 940 return self.bind.call(self, keys, function() {}, action); 941 }; 942 943 /** 944 * triggers an event that has already been bound 945 * 946 * @param {string} keys 947 * @param {string=} action 948 * @returns void 949 */ 950 Mousetrap.prototype.trigger = function(keys, action) { 951 var self = this; 952 if (self._directMap[keys + ':' + action]) { 953 self._directMap[keys + ':' + action]({}, keys); 954 } 955 return self; 956 }; 957 958 /** 959 * resets the library back to its initial state. this is useful 960 * if you want to clear out the current keyboard shortcuts and bind 961 * new ones - for example if you switch to another page 962 * 963 * @returns void 964 */ 965 Mousetrap.prototype.reset = function() { 966 var self = this; 967 self._callbacks = {}; 968 self._directMap = {}; 969 return self; 970 }; 971 972 /** 973 * should we stop this event before firing off callbacks 974 * 975 * @param {Event} e 976 * @param {Element} element 977 * @return {boolean} 978 */ 979 Mousetrap.prototype.stopCallback = function(e, element) { 980 var self = this; 981 982 // if the element has the class "mousetrap" then no need to stop 983 if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) { 984 return false; 985 } 986 987 if (_belongsTo(element, self.target)) { 988 return false; 989 } 990 991 // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host, 992 // not the initial event target in the shadow tree. Note that not all events cross the 993 // shadow boundary. 994 // For shadow trees with `mode: 'open'`, the initial event target is the first element in 995 // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event 996 // target cannot be obtained. 997 if ('composedPath' in e && typeof e.composedPath === 'function') { 998 // For open shadow trees, update `element` so that the following check works. 999 var initialEventTarget = e.composedPath()[0]; 1000 if (initialEventTarget !== e.target) { 1001 element = initialEventTarget; 1002 } 1003 } 1004 1005 // stop for input, select, and textarea 1006 return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable; 1007 }; 1008 1009 /** 1010 * exposes _handleKey publicly so it can be overwritten by extensions 1011 */ 1012 Mousetrap.prototype.handleKey = function() { 1013 var self = this; 1014 return self._handleKey.apply(self, arguments); 1015 }; 1016 1017 /** 1018 * allow custom key mappings 1019 */ 1020 Mousetrap.addKeycodes = function(object) { 1021 for (var key in object) { 1022 if (object.hasOwnProperty(key)) { 1023 _MAP[key] = object[key]; 1024 } 1025 } 1026 _REVERSE_MAP = null; 1027 }; 1028 1029 /** 1030 * Init the global mousetrap functions 1031 * 1032 * This method is needed to allow the global mousetrap functions to work 1033 * now that mousetrap is a constructor function. 1034 */ 1035 Mousetrap.init = function() { 1036 var documentMousetrap = Mousetrap(document); 1037 for (var method in documentMousetrap) { 1038 if (method.charAt(0) !== '_') { 1039 Mousetrap[method] = (function(method) { 1040 return function() { 1041 return documentMousetrap[method].apply(documentMousetrap, arguments); 1042 }; 1043 } (method)); 1044 } 1045 } 1046 }; 1047 1048 Mousetrap.init(); 1049 1050 // expose mousetrap to the global object 1051 window.Mousetrap = Mousetrap; 1052 1053 // expose as a common js module 1054 if ( true && module.exports) { 1055 module.exports = Mousetrap; 1056 } 1057 1058 // expose mousetrap as an AMD module 1059 if (true) { 1060 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 1061 return Mousetrap; 1062 }).call(exports, __webpack_require__, exports, module), 1063 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 1064 } 1065 }) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null); 1066 1067 1068 /***/ }), 1069 1070 /***/ 3758: 1071 /***/ (function(module) { 1072 1073 /*! 1074 * clipboard.js v2.0.11 1075 * https://clipboardjs.com/ 1076 * 1077 * Licensed MIT © Zeno Rocha 1078 */ 1079 (function webpackUniversalModuleDefinition(root, factory) { 1080 if(true) 1081 module.exports = factory(); 1082 else {} 1083 })(this, function() { 1084 return /******/ (function() { // webpackBootstrap 1085 /******/ var __webpack_modules__ = ({ 1086 1087 /***/ 686: 1088 /***/ (function(__unused_webpack_module, __nested_webpack_exports__, __nested_webpack_require_623__) { 1089 1090 "use strict"; 1091 1092 // EXPORTS 1093 __nested_webpack_require_623__.d(__nested_webpack_exports__, { 1094 "default": function() { return /* binding */ clipboard; } 1095 }); 1096 1097 // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js 1098 var tiny_emitter = __nested_webpack_require_623__(279); 1099 var tiny_emitter_default = /*#__PURE__*/__nested_webpack_require_623__.n(tiny_emitter); 1100 // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js 1101 var listen = __nested_webpack_require_623__(370); 1102 var listen_default = /*#__PURE__*/__nested_webpack_require_623__.n(listen); 1103 // EXTERNAL MODULE: ./node_modules/select/src/select.js 1104 var src_select = __nested_webpack_require_623__(817); 1105 var select_default = /*#__PURE__*/__nested_webpack_require_623__.n(src_select); 1106 ;// CONCATENATED MODULE: ./src/common/command.js 1107 /** 1108 * Executes a given operation type. 1109 * @param {String} type 1110 * @return {Boolean} 1111 */ 1112 function command(type) { 1113 try { 1114 return document.execCommand(type); 1115 } catch (err) { 1116 return false; 1117 } 1118 } 1119 ;// CONCATENATED MODULE: ./src/actions/cut.js 1120 1121 1122 /** 1123 * Cut action wrapper. 1124 * @param {String|HTMLElement} target 1125 * @return {String} 1126 */ 1127 1128 var ClipboardActionCut = function ClipboardActionCut(target) { 1129 var selectedText = select_default()(target); 1130 command('cut'); 1131 return selectedText; 1132 }; 1133 1134 /* harmony default export */ var actions_cut = (ClipboardActionCut); 1135 ;// CONCATENATED MODULE: ./src/common/create-fake-element.js 1136 /** 1137 * Creates a fake textarea element with a value. 1138 * @param {String} value 1139 * @return {HTMLElement} 1140 */ 1141 function createFakeElement(value) { 1142 var isRTL = document.documentElement.getAttribute('dir') === 'rtl'; 1143 var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS 1144 1145 fakeElement.style.fontSize = '12pt'; // Reset box model 1146 1147 fakeElement.style.border = '0'; 1148 fakeElement.style.padding = '0'; 1149 fakeElement.style.margin = '0'; // Move element out of screen horizontally 1150 1151 fakeElement.style.position = 'absolute'; 1152 fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically 1153 1154 var yPosition = window.pageYOffset || document.documentElement.scrollTop; 1155 fakeElement.style.top = "".concat(yPosition, "px"); 1156 fakeElement.setAttribute('readonly', ''); 1157 fakeElement.value = value; 1158 return fakeElement; 1159 } 1160 ;// CONCATENATED MODULE: ./src/actions/copy.js 1161 1162 1163 1164 /** 1165 * Create fake copy action wrapper using a fake element. 1166 * @param {String} target 1167 * @param {Object} options 1168 * @return {String} 1169 */ 1170 1171 var fakeCopyAction = function fakeCopyAction(value, options) { 1172 var fakeElement = createFakeElement(value); 1173 options.container.appendChild(fakeElement); 1174 var selectedText = select_default()(fakeElement); 1175 command('copy'); 1176 fakeElement.remove(); 1177 return selectedText; 1178 }; 1179 /** 1180 * Copy action wrapper. 1181 * @param {String|HTMLElement} target 1182 * @param {Object} options 1183 * @return {String} 1184 */ 1185 1186 1187 var ClipboardActionCopy = function ClipboardActionCopy(target) { 1188 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 1189 container: document.body 1190 }; 1191 var selectedText = ''; 1192 1193 if (typeof target === 'string') { 1194 selectedText = fakeCopyAction(target, options); 1195 } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) { 1196 // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange 1197 selectedText = fakeCopyAction(target.value, options); 1198 } else { 1199 selectedText = select_default()(target); 1200 command('copy'); 1201 } 1202 1203 return selectedText; 1204 }; 1205 1206 /* harmony default export */ var actions_copy = (ClipboardActionCopy); 1207 ;// CONCATENATED MODULE: ./src/actions/default.js 1208 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 1209 1210 1211 1212 /** 1213 * Inner function which performs selection from either `text` or `target` 1214 * properties and then executes copy or cut operations. 1215 * @param {Object} options 1216 */ 1217 1218 var ClipboardActionDefault = function ClipboardActionDefault() { 1219 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 1220 // Defines base properties passed from constructor. 1221 var _options$action = options.action, 1222 action = _options$action === void 0 ? 'copy' : _options$action, 1223 container = options.container, 1224 target = options.target, 1225 text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'. 1226 1227 if (action !== 'copy' && action !== 'cut') { 1228 throw new Error('Invalid "action" value, use either "copy" or "cut"'); 1229 } // Sets the `target` property using an element that will be have its content copied. 1230 1231 1232 if (target !== undefined) { 1233 if (target && _typeof(target) === 'object' && target.nodeType === 1) { 1234 if (action === 'copy' && target.hasAttribute('disabled')) { 1235 throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); 1236 } 1237 1238 if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { 1239 throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); 1240 } 1241 } else { 1242 throw new Error('Invalid "target" value, use a valid Element'); 1243 } 1244 } // Define selection strategy based on `text` property. 1245 1246 1247 if (text) { 1248 return actions_copy(text, { 1249 container: container 1250 }); 1251 } // Defines which selection strategy based on `target` property. 1252 1253 1254 if (target) { 1255 return action === 'cut' ? actions_cut(target) : actions_copy(target, { 1256 container: container 1257 }); 1258 } 1259 }; 1260 1261 /* harmony default export */ var actions_default = (ClipboardActionDefault); 1262 ;// CONCATENATED MODULE: ./src/clipboard.js 1263 function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); } 1264 1265 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1266 1267 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 1268 1269 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 1270 1271 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 1272 1273 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 1274 1275 function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 1276 1277 function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 1278 1279 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 1280 1281 function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 1282 1283 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 1284 1285 1286 1287 1288 1289 1290 /** 1291 * Helper function to retrieve attribute value. 1292 * @param {String} suffix 1293 * @param {Element} element 1294 */ 1295 1296 function getAttributeValue(suffix, element) { 1297 var attribute = "data-clipboard-".concat(suffix); 1298 1299 if (!element.hasAttribute(attribute)) { 1300 return; 1301 } 1302 1303 return element.getAttribute(attribute); 1304 } 1305 /** 1306 * Base class which takes one or more elements, adds event listeners to them, 1307 * and instantiates a new `ClipboardAction` on each click. 1308 */ 1309 1310 1311 var Clipboard = /*#__PURE__*/function (_Emitter) { 1312 _inherits(Clipboard, _Emitter); 1313 1314 var _super = _createSuper(Clipboard); 1315 1316 /** 1317 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger 1318 * @param {Object} options 1319 */ 1320 function Clipboard(trigger, options) { 1321 var _this; 1322 1323 _classCallCheck(this, Clipboard); 1324 1325 _this = _super.call(this); 1326 1327 _this.resolveOptions(options); 1328 1329 _this.listenClick(trigger); 1330 1331 return _this; 1332 } 1333 /** 1334 * Defines if attributes would be resolved using internal setter functions 1335 * or custom functions that were passed in the constructor. 1336 * @param {Object} options 1337 */ 1338 1339 1340 _createClass(Clipboard, [{ 1341 key: "resolveOptions", 1342 value: function resolveOptions() { 1343 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 1344 this.action = typeof options.action === 'function' ? options.action : this.defaultAction; 1345 this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; 1346 this.text = typeof options.text === 'function' ? options.text : this.defaultText; 1347 this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body; 1348 } 1349 /** 1350 * Adds a click event listener to the passed trigger. 1351 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger 1352 */ 1353 1354 }, { 1355 key: "listenClick", 1356 value: function listenClick(trigger) { 1357 var _this2 = this; 1358 1359 this.listener = listen_default()(trigger, 'click', function (e) { 1360 return _this2.onClick(e); 1361 }); 1362 } 1363 /** 1364 * Defines a new `ClipboardAction` on each click event. 1365 * @param {Event} e 1366 */ 1367 1368 }, { 1369 key: "onClick", 1370 value: function onClick(e) { 1371 var trigger = e.delegateTarget || e.currentTarget; 1372 var action = this.action(trigger) || 'copy'; 1373 var text = actions_default({ 1374 action: action, 1375 container: this.container, 1376 target: this.target(trigger), 1377 text: this.text(trigger) 1378 }); // Fires an event based on the copy operation result. 1379 1380 this.emit(text ? 'success' : 'error', { 1381 action: action, 1382 text: text, 1383 trigger: trigger, 1384 clearSelection: function clearSelection() { 1385 if (trigger) { 1386 trigger.focus(); 1387 } 1388 1389 window.getSelection().removeAllRanges(); 1390 } 1391 }); 1392 } 1393 /** 1394 * Default `action` lookup function. 1395 * @param {Element} trigger 1396 */ 1397 1398 }, { 1399 key: "defaultAction", 1400 value: function defaultAction(trigger) { 1401 return getAttributeValue('action', trigger); 1402 } 1403 /** 1404 * Default `target` lookup function. 1405 * @param {Element} trigger 1406 */ 1407 1408 }, { 1409 key: "defaultTarget", 1410 value: function defaultTarget(trigger) { 1411 var selector = getAttributeValue('target', trigger); 1412 1413 if (selector) { 1414 return document.querySelector(selector); 1415 } 1416 } 1417 /** 1418 * Allow fire programmatically a copy action 1419 * @param {String|HTMLElement} target 1420 * @param {Object} options 1421 * @returns Text copied. 1422 */ 1423 1424 }, { 1425 key: "defaultText", 1426 1427 /** 1428 * Default `text` lookup function. 1429 * @param {Element} trigger 1430 */ 1431 value: function defaultText(trigger) { 1432 return getAttributeValue('text', trigger); 1433 } 1434 /** 1435 * Destroy lifecycle. 1436 */ 1437 1438 }, { 1439 key: "destroy", 1440 value: function destroy() { 1441 this.listener.destroy(); 1442 } 1443 }], [{ 1444 key: "copy", 1445 value: function copy(target) { 1446 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 1447 container: document.body 1448 }; 1449 return actions_copy(target, options); 1450 } 1451 /** 1452 * Allow fire programmatically a cut action 1453 * @param {String|HTMLElement} target 1454 * @returns Text cutted. 1455 */ 1456 1457 }, { 1458 key: "cut", 1459 value: function cut(target) { 1460 return actions_cut(target); 1461 } 1462 /** 1463 * Returns the support of the given action, or all actions if no action is 1464 * given. 1465 * @param {String} [action] 1466 */ 1467 1468 }, { 1469 key: "isSupported", 1470 value: function isSupported() { 1471 var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; 1472 var actions = typeof action === 'string' ? [action] : action; 1473 var support = !!document.queryCommandSupported; 1474 actions.forEach(function (action) { 1475 support = support && !!document.queryCommandSupported(action); 1476 }); 1477 return support; 1478 } 1479 }]); 1480 1481 return Clipboard; 1482 }((tiny_emitter_default())); 1483 1484 /* harmony default export */ var clipboard = (Clipboard); 1485 1486 /***/ }), 1487 1488 /***/ 828: 1489 /***/ (function(module) { 1490 1491 var DOCUMENT_NODE_TYPE = 9; 1492 1493 /** 1494 * A polyfill for Element.matches() 1495 */ 1496 if (typeof Element !== 'undefined' && !Element.prototype.matches) { 1497 var proto = Element.prototype; 1498 1499 proto.matches = proto.matchesSelector || 1500 proto.mozMatchesSelector || 1501 proto.msMatchesSelector || 1502 proto.oMatchesSelector || 1503 proto.webkitMatchesSelector; 1504 } 1505 1506 /** 1507 * Finds the closest parent that matches a selector. 1508 * 1509 * @param {Element} element 1510 * @param {String} selector 1511 * @return {Function} 1512 */ 1513 function closest (element, selector) { 1514 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { 1515 if (typeof element.matches === 'function' && 1516 element.matches(selector)) { 1517 return element; 1518 } 1519 element = element.parentNode; 1520 } 1521 } 1522 1523 module.exports = closest; 1524 1525 1526 /***/ }), 1527 1528 /***/ 438: 1529 /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_15749__) { 1530 1531 var closest = __nested_webpack_require_15749__(828); 1532 1533 /** 1534 * Delegates event to a selector. 1535 * 1536 * @param {Element} element 1537 * @param {String} selector 1538 * @param {String} type 1539 * @param {Function} callback 1540 * @param {Boolean} useCapture 1541 * @return {Object} 1542 */ 1543 function _delegate(element, selector, type, callback, useCapture) { 1544 var listenerFn = listener.apply(this, arguments); 1545 1546 element.addEventListener(type, listenerFn, useCapture); 1547 1548 return { 1549 destroy: function() { 1550 element.removeEventListener(type, listenerFn, useCapture); 1551 } 1552 } 1553 } 1554 1555 /** 1556 * Delegates event to a selector. 1557 * 1558 * @param {Element|String|Array} [elements] 1559 * @param {String} selector 1560 * @param {String} type 1561 * @param {Function} callback 1562 * @param {Boolean} useCapture 1563 * @return {Object} 1564 */ 1565 function delegate(elements, selector, type, callback, useCapture) { 1566 // Handle the regular Element usage 1567 if (typeof elements.addEventListener === 'function') { 1568 return _delegate.apply(null, arguments); 1569 } 1570 1571 // Handle Element-less usage, it defaults to global delegation 1572 if (typeof type === 'function') { 1573 // Use `document` as the first parameter, then apply arguments 1574 // This is a short way to .unshift `arguments` without running into deoptimizations 1575 return _delegate.bind(null, document).apply(null, arguments); 1576 } 1577 1578 // Handle Selector-based usage 1579 if (typeof elements === 'string') { 1580 elements = document.querySelectorAll(elements); 1581 } 1582 1583 // Handle Array-like based usage 1584 return Array.prototype.map.call(elements, function (element) { 1585 return _delegate(element, selector, type, callback, useCapture); 1586 }); 1587 } 1588 1589 /** 1590 * Finds closest match and invokes callback. 1591 * 1592 * @param {Element} element 1593 * @param {String} selector 1594 * @param {String} type 1595 * @param {Function} callback 1596 * @return {Function} 1597 */ 1598 function listener(element, selector, type, callback) { 1599 return function(e) { 1600 e.delegateTarget = closest(e.target, selector); 1601 1602 if (e.delegateTarget) { 1603 callback.call(element, e); 1604 } 1605 } 1606 } 1607 1608 module.exports = delegate; 1609 1610 1611 /***/ }), 1612 1613 /***/ 879: 1614 /***/ (function(__unused_webpack_module, exports) { 1615 1616 /** 1617 * Check if argument is a HTML element. 1618 * 1619 * @param {Object} value 1620 * @return {Boolean} 1621 */ 1622 exports.node = function(value) { 1623 return value !== undefined 1624 && value instanceof HTMLElement 1625 && value.nodeType === 1; 1626 }; 1627 1628 /** 1629 * Check if argument is a list of HTML elements. 1630 * 1631 * @param {Object} value 1632 * @return {Boolean} 1633 */ 1634 exports.nodeList = function(value) { 1635 var type = Object.prototype.toString.call(value); 1636 1637 return value !== undefined 1638 && (type === '[object NodeList]' || type === '[object HTMLCollection]') 1639 && ('length' in value) 1640 && (value.length === 0 || exports.node(value[0])); 1641 }; 1642 1643 /** 1644 * Check if argument is a string. 1645 * 1646 * @param {Object} value 1647 * @return {Boolean} 1648 */ 1649 exports.string = function(value) { 1650 return typeof value === 'string' 1651 || value instanceof String; 1652 }; 1653 1654 /** 1655 * Check if argument is a function. 1656 * 1657 * @param {Object} value 1658 * @return {Boolean} 1659 */ 1660 exports.fn = function(value) { 1661 var type = Object.prototype.toString.call(value); 1662 1663 return type === '[object Function]'; 1664 }; 1665 1666 1667 /***/ }), 1668 1669 /***/ 370: 1670 /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_19113__) { 1671 1672 var is = __nested_webpack_require_19113__(879); 1673 var delegate = __nested_webpack_require_19113__(438); 1674 1675 /** 1676 * Validates all params and calls the right 1677 * listener function based on its target type. 1678 * 1679 * @param {String|HTMLElement|HTMLCollection|NodeList} target 1680 * @param {String} type 1681 * @param {Function} callback 1682 * @return {Object} 1683 */ 1684 function listen(target, type, callback) { 1685 if (!target && !type && !callback) { 1686 throw new Error('Missing required arguments'); 1687 } 1688 1689 if (!is.string(type)) { 1690 throw new TypeError('Second argument must be a String'); 1691 } 1692 1693 if (!is.fn(callback)) { 1694 throw new TypeError('Third argument must be a Function'); 1695 } 1696 1697 if (is.node(target)) { 1698 return listenNode(target, type, callback); 1699 } 1700 else if (is.nodeList(target)) { 1701 return listenNodeList(target, type, callback); 1702 } 1703 else if (is.string(target)) { 1704 return listenSelector(target, type, callback); 1705 } 1706 else { 1707 throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); 1708 } 1709 } 1710 1711 /** 1712 * Adds an event listener to a HTML element 1713 * and returns a remove listener function. 1714 * 1715 * @param {HTMLElement} node 1716 * @param {String} type 1717 * @param {Function} callback 1718 * @return {Object} 1719 */ 1720 function listenNode(node, type, callback) { 1721 node.addEventListener(type, callback); 1722 1723 return { 1724 destroy: function() { 1725 node.removeEventListener(type, callback); 1726 } 1727 } 1728 } 1729 1730 /** 1731 * Add an event listener to a list of HTML elements 1732 * and returns a remove listener function. 1733 * 1734 * @param {NodeList|HTMLCollection} nodeList 1735 * @param {String} type 1736 * @param {Function} callback 1737 * @return {Object} 1738 */ 1739 function listenNodeList(nodeList, type, callback) { 1740 Array.prototype.forEach.call(nodeList, function(node) { 1741 node.addEventListener(type, callback); 1742 }); 1743 1744 return { 1745 destroy: function() { 1746 Array.prototype.forEach.call(nodeList, function(node) { 1747 node.removeEventListener(type, callback); 1748 }); 1749 } 1750 } 1751 } 1752 1753 /** 1754 * Add an event listener to a selector 1755 * and returns a remove listener function. 1756 * 1757 * @param {String} selector 1758 * @param {String} type 1759 * @param {Function} callback 1760 * @return {Object} 1761 */ 1762 function listenSelector(selector, type, callback) { 1763 return delegate(document.body, selector, type, callback); 1764 } 1765 1766 module.exports = listen; 1767 1768 1769 /***/ }), 1770 1771 /***/ 817: 1772 /***/ (function(module) { 1773 1774 function select(element) { 1775 var selectedText; 1776 1777 if (element.nodeName === 'SELECT') { 1778 element.focus(); 1779 1780 selectedText = element.value; 1781 } 1782 else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { 1783 var isReadOnly = element.hasAttribute('readonly'); 1784 1785 if (!isReadOnly) { 1786 element.setAttribute('readonly', ''); 1787 } 1788 1789 element.select(); 1790 element.setSelectionRange(0, element.value.length); 1791 1792 if (!isReadOnly) { 1793 element.removeAttribute('readonly'); 1794 } 1795 1796 selectedText = element.value; 1797 } 1798 else { 1799 if (element.hasAttribute('contenteditable')) { 1800 element.focus(); 1801 } 1802 1803 var selection = window.getSelection(); 1804 var range = document.createRange(); 1805 1806 range.selectNodeContents(element); 1807 selection.removeAllRanges(); 1808 selection.addRange(range); 1809 1810 selectedText = selection.toString(); 1811 } 1812 1813 return selectedText; 1814 } 1815 1816 module.exports = select; 1817 1818 1819 /***/ }), 1820 1821 /***/ 279: 1822 /***/ (function(module) { 1823 1824 function E () { 1825 // Keep this empty so it's easier to inherit from 1826 // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) 1827 } 1828 1829 E.prototype = { 1830 on: function (name, callback, ctx) { 1831 var e = this.e || (this.e = {}); 1832 1833 (e[name] || (e[name] = [])).push({ 1834 fn: callback, 1835 ctx: ctx 1836 }); 1837 1838 return this; 1839 }, 1840 1841 once: function (name, callback, ctx) { 1842 var self = this; 1843 function listener () { 1844 self.off(name, listener); 1845 callback.apply(ctx, arguments); 1846 }; 1847 1848 listener._ = callback 1849 return this.on(name, listener, ctx); 1850 }, 1851 1852 emit: function (name) { 1853 var data = [].slice.call(arguments, 1); 1854 var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); 1855 var i = 0; 1856 var len = evtArr.length; 1857 1858 for (i; i < len; i++) { 1859 evtArr[i].fn.apply(evtArr[i].ctx, data); 1860 } 1861 1862 return this; 1863 }, 1864 1865 off: function (name, callback) { 1866 var e = this.e || (this.e = {}); 1867 var evts = e[name]; 1868 var liveEvents = []; 1869 1870 if (evts && callback) { 1871 for (var i = 0, len = evts.length; i < len; i++) { 1872 if (evts[i].fn !== callback && evts[i].fn._ !== callback) 1873 liveEvents.push(evts[i]); 1874 } 1875 } 1876 1877 // Remove event from queue to prevent memory leak 1878 // Suggested by https://github.com/lazd 1879 // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 1880 1881 (liveEvents.length) 1882 ? e[name] = liveEvents 1883 : delete e[name]; 1884 1885 return this; 1886 } 1887 }; 1888 1889 module.exports = E; 1890 module.exports.TinyEmitter = E; 1891 1892 1893 /***/ }) 1894 1895 /******/ }); 1896 /************************************************************************/ 1897 /******/ // The module cache 1898 /******/ var __webpack_module_cache__ = {}; 1899 /******/ 1900 /******/ // The require function 1901 /******/ function __nested_webpack_require_24495__(moduleId) { 1902 /******/ // Check if module is in cache 1903 /******/ if(__webpack_module_cache__[moduleId]) { 1904 /******/ return __webpack_module_cache__[moduleId].exports; 1905 /******/ } 1906 /******/ // Create a new module (and put it into the cache) 1907 /******/ var module = __webpack_module_cache__[moduleId] = { 1908 /******/ // no module.id needed 1909 /******/ // no module.loaded needed 1910 /******/ exports: {} 1911 /******/ }; 1912 /******/ 1913 /******/ // Execute the module function 1914 /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_24495__); 1915 /******/ 1916 /******/ // Return the exports of the module 1917 /******/ return module.exports; 1918 /******/ } 1919 /******/ 1920 /************************************************************************/ 1921 /******/ /* webpack/runtime/compat get default export */ 1922 /******/ !function() { 1923 /******/ // getDefaultExport function for compatibility with non-harmony modules 1924 /******/ __nested_webpack_require_24495__.n = function(module) { 1925 /******/ var getter = module && module.__esModule ? 1926 /******/ function() { return module['default']; } : 1927 /******/ function() { return module; }; 1928 /******/ __nested_webpack_require_24495__.d(getter, { a: getter }); 1929 /******/ return getter; 1930 /******/ }; 1931 /******/ }(); 1932 /******/ 1933 /******/ /* webpack/runtime/define property getters */ 1934 /******/ !function() { 1935 /******/ // define getter functions for harmony exports 1936 /******/ __nested_webpack_require_24495__.d = function(exports, definition) { 1937 /******/ for(var key in definition) { 1938 /******/ if(__nested_webpack_require_24495__.o(definition, key) && !__nested_webpack_require_24495__.o(exports, key)) { 1939 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 1940 /******/ } 1941 /******/ } 1942 /******/ }; 1943 /******/ }(); 1944 /******/ 1945 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 1946 /******/ !function() { 1947 /******/ __nested_webpack_require_24495__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 1948 /******/ }(); 1949 /******/ 1950 /************************************************************************/ 1951 /******/ // module exports must be returned from runtime so entry inlining is disabled 1952 /******/ // startup 1953 /******/ // Load entry module and return exports 1954 /******/ return __nested_webpack_require_24495__(686); 1955 /******/ })() 1956 .default; 1957 }); 1958 1959 /***/ }), 1960 1961 /***/ 5760: 1962 /***/ (() => { 1963 1964 /** 1965 * adds a bindGlobal method to Mousetrap that allows you to 1966 * bind specific keyboard shortcuts that will still work 1967 * inside a text input field 1968 * 1969 * usage: 1970 * Mousetrap.bindGlobal('ctrl+s', _saveChanges); 1971 */ 1972 /* global Mousetrap:true */ 1973 (function(Mousetrap) { 1974 if (! Mousetrap) { 1975 return; 1976 } 1977 var _globalCallbacks = {}; 1978 var _originalStopCallback = Mousetrap.prototype.stopCallback; 1979 1980 Mousetrap.prototype.stopCallback = function(e, element, combo, sequence) { 1981 var self = this; 1982 1983 if (self.paused) { 1984 return true; 1985 } 1986 1987 if (_globalCallbacks[combo] || _globalCallbacks[sequence]) { 1988 return false; 1989 } 1990 1991 return _originalStopCallback.call(self, e, element, combo); 1992 }; 1993 1994 Mousetrap.prototype.bindGlobal = function(keys, callback, action) { 1995 var self = this; 1996 self.bind(keys, callback, action); 1997 1998 if (keys instanceof Array) { 1999 for (var i = 0; i < keys.length; i++) { 2000 _globalCallbacks[keys[i]] = true; 2001 } 2002 return; 2003 } 2004 2005 _globalCallbacks[keys] = true; 2006 }; 2007 2008 Mousetrap.init(); 2009 }) (typeof Mousetrap !== "undefined" ? Mousetrap : undefined); 2010 2011 2012 /***/ }) 2013 2014 /******/ }); 2015 /************************************************************************/ 2016 /******/ // The module cache 2017 /******/ var __webpack_module_cache__ = {}; 2018 /******/ 2019 /******/ // The require function 2020 /******/ function __webpack_require__(moduleId) { 2021 /******/ // Check if module is in cache 2022 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 2023 /******/ if (cachedModule !== undefined) { 2024 /******/ return cachedModule.exports; 2025 /******/ } 2026 /******/ // Create a new module (and put it into the cache) 2027 /******/ var module = __webpack_module_cache__[moduleId] = { 2028 /******/ // no module.id needed 2029 /******/ // no module.loaded needed 2030 /******/ exports: {} 2031 /******/ }; 2032 /******/ 2033 /******/ // Execute the module function 2034 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 2035 /******/ 2036 /******/ // Return the exports of the module 2037 /******/ return module.exports; 2038 /******/ } 2039 /******/ 2040 /************************************************************************/ 2041 /******/ /* webpack/runtime/compat get default export */ 2042 /******/ (() => { 2043 /******/ // getDefaultExport function for compatibility with non-harmony modules 2044 /******/ __webpack_require__.n = (module) => { 2045 /******/ var getter = module && module.__esModule ? 2046 /******/ () => (module['default']) : 2047 /******/ () => (module); 2048 /******/ __webpack_require__.d(getter, { a: getter }); 2049 /******/ return getter; 2050 /******/ }; 2051 /******/ })(); 2052 /******/ 2053 /******/ /* webpack/runtime/define property getters */ 2054 /******/ (() => { 2055 /******/ // define getter functions for harmony exports 2056 /******/ __webpack_require__.d = (exports, definition) => { 2057 /******/ for(var key in definition) { 2058 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 2059 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 2060 /******/ } 2061 /******/ } 2062 /******/ }; 2063 /******/ })(); 2064 /******/ 2065 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 2066 /******/ (() => { 2067 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 2068 /******/ })(); 2069 /******/ 2070 /******/ /* webpack/runtime/make namespace object */ 2071 /******/ (() => { 2072 /******/ // define __esModule on exports 2073 /******/ __webpack_require__.r = (exports) => { 2074 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 2075 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 2076 /******/ } 2077 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 2078 /******/ }; 2079 /******/ })(); 2080 /******/ 2081 /************************************************************************/ 2082 var __webpack_exports__ = {}; 2083 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode. 2084 (() => { 2085 "use strict"; 2086 // ESM COMPAT FLAG 2087 __webpack_require__.r(__webpack_exports__); 2088 2089 // EXPORTS 2090 __webpack_require__.d(__webpack_exports__, { 2091 __experimentalUseDialog: () => (/* reexport */ use_dialog), 2092 __experimentalUseDragging: () => (/* reexport */ useDragging), 2093 __experimentalUseDropZone: () => (/* reexport */ useDropZone), 2094 __experimentalUseFixedWindowList: () => (/* reexport */ useFixedWindowList), 2095 __experimentalUseFocusOutside: () => (/* reexport */ useFocusOutside), 2096 compose: () => (/* reexport */ higher_order_compose), 2097 createHigherOrderComponent: () => (/* reexport */ createHigherOrderComponent), 2098 debounce: () => (/* reexport */ debounce), 2099 ifCondition: () => (/* reexport */ if_condition), 2100 observableMap: () => (/* reexport */ observableMap), 2101 pipe: () => (/* reexport */ higher_order_pipe), 2102 pure: () => (/* reexport */ higher_order_pure), 2103 throttle: () => (/* reexport */ throttle), 2104 useAsyncList: () => (/* reexport */ use_async_list), 2105 useConstrainedTabbing: () => (/* reexport */ use_constrained_tabbing), 2106 useCopyOnClick: () => (/* reexport */ useCopyOnClick), 2107 useCopyToClipboard: () => (/* reexport */ useCopyToClipboard), 2108 useDebounce: () => (/* reexport */ useDebounce), 2109 useDebouncedInput: () => (/* reexport */ useDebouncedInput), 2110 useDisabled: () => (/* reexport */ useDisabled), 2111 useEvent: () => (/* reexport */ useEvent), 2112 useFocusOnMount: () => (/* reexport */ useFocusOnMount), 2113 useFocusReturn: () => (/* reexport */ use_focus_return), 2114 useFocusableIframe: () => (/* reexport */ useFocusableIframe), 2115 useInstanceId: () => (/* reexport */ use_instance_id), 2116 useIsomorphicLayoutEffect: () => (/* reexport */ use_isomorphic_layout_effect), 2117 useKeyboardShortcut: () => (/* reexport */ use_keyboard_shortcut), 2118 useMediaQuery: () => (/* reexport */ useMediaQuery), 2119 useMergeRefs: () => (/* reexport */ useMergeRefs), 2120 useObservableValue: () => (/* reexport */ useObservableValue), 2121 usePrevious: () => (/* reexport */ usePrevious), 2122 useReducedMotion: () => (/* reexport */ use_reduced_motion), 2123 useRefEffect: () => (/* reexport */ useRefEffect), 2124 useResizeObserver: () => (/* reexport */ use_resize_observer_useResizeObserver), 2125 useStateWithHistory: () => (/* reexport */ useStateWithHistory), 2126 useThrottle: () => (/* reexport */ useThrottle), 2127 useViewportMatch: () => (/* reexport */ use_viewport_match), 2128 useWarnOnChange: () => (/* reexport */ use_warn_on_change), 2129 withGlobalEvents: () => (/* reexport */ withGlobalEvents), 2130 withInstanceId: () => (/* reexport */ with_instance_id), 2131 withSafeTimeout: () => (/* reexport */ with_safe_timeout), 2132 withState: () => (/* reexport */ withState) 2133 }); 2134 2135 ;// ./node_modules/tslib/tslib.es6.mjs 2136 /****************************************************************************** 2137 Copyright (c) Microsoft Corporation. 2138 2139 Permission to use, copy, modify, and/or distribute this software for any 2140 purpose with or without fee is hereby granted. 2141 2142 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 2143 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 2144 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 2145 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 2146 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 2147 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 2148 PERFORMANCE OF THIS SOFTWARE. 2149 ***************************************************************************** */ 2150 /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ 2151 2152 var extendStatics = function(d, b) { 2153 extendStatics = Object.setPrototypeOf || 2154 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 2155 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; 2156 return extendStatics(d, b); 2157 }; 2158 2159 function __extends(d, b) { 2160 if (typeof b !== "function" && b !== null) 2161 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 2162 extendStatics(d, b); 2163 function __() { this.constructor = d; } 2164 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 2165 } 2166 2167 var __assign = function() { 2168 __assign = Object.assign || function __assign(t) { 2169 for (var s, i = 1, n = arguments.length; i < n; i++) { 2170 s = arguments[i]; 2171 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 2172 } 2173 return t; 2174 } 2175 return __assign.apply(this, arguments); 2176 } 2177 2178 function __rest(s, e) { 2179 var t = {}; 2180 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 2181 t[p] = s[p]; 2182 if (s != null && typeof Object.getOwnPropertySymbols === "function") 2183 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 2184 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) 2185 t[p[i]] = s[p[i]]; 2186 } 2187 return t; 2188 } 2189 2190 function __decorate(decorators, target, key, desc) { 2191 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 2192 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 2193 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 2194 return c > 3 && r && Object.defineProperty(target, key, r), r; 2195 } 2196 2197 function __param(paramIndex, decorator) { 2198 return function (target, key) { decorator(target, key, paramIndex); } 2199 } 2200 2201 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { 2202 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } 2203 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; 2204 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; 2205 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); 2206 var _, done = false; 2207 for (var i = decorators.length - 1; i >= 0; i--) { 2208 var context = {}; 2209 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; 2210 for (var p in contextIn.access) context.access[p] = contextIn.access[p]; 2211 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; 2212 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); 2213 if (kind === "accessor") { 2214 if (result === void 0) continue; 2215 if (result === null || typeof result !== "object") throw new TypeError("Object expected"); 2216 if (_ = accept(result.get)) descriptor.get = _; 2217 if (_ = accept(result.set)) descriptor.set = _; 2218 if (_ = accept(result.init)) initializers.unshift(_); 2219 } 2220 else if (_ = accept(result)) { 2221 if (kind === "field") initializers.unshift(_); 2222 else descriptor[key] = _; 2223 } 2224 } 2225 if (target) Object.defineProperty(target, contextIn.name, descriptor); 2226 done = true; 2227 }; 2228 2229 function __runInitializers(thisArg, initializers, value) { 2230 var useValue = arguments.length > 2; 2231 for (var i = 0; i < initializers.length; i++) { 2232 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); 2233 } 2234 return useValue ? value : void 0; 2235 }; 2236 2237 function __propKey(x) { 2238 return typeof x === "symbol" ? x : "".concat(x); 2239 }; 2240 2241 function __setFunctionName(f, name, prefix) { 2242 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; 2243 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); 2244 }; 2245 2246 function __metadata(metadataKey, metadataValue) { 2247 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); 2248 } 2249 2250 function __awaiter(thisArg, _arguments, P, generator) { 2251 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 2252 return new (P || (P = Promise))(function (resolve, reject) { 2253 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 2254 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 2255 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 2256 step((generator = generator.apply(thisArg, _arguments || [])).next()); 2257 }); 2258 } 2259 2260 function __generator(thisArg, body) { 2261 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); 2262 return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 2263 function verb(n) { return function (v) { return step([n, v]); }; } 2264 function step(op) { 2265 if (f) throw new TypeError("Generator is already executing."); 2266 while (g && (g = 0, op[0] && (_ = 0)), _) try { 2267 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 2268 if (y = 0, t) op = [op[0] & 2, t.value]; 2269 switch (op[0]) { 2270 case 0: case 1: t = op; break; 2271 case 4: _.label++; return { value: op[1], done: false }; 2272 case 5: _.label++; y = op[1]; op = [0]; continue; 2273 case 7: op = _.ops.pop(); _.trys.pop(); continue; 2274 default: 2275 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 2276 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 2277 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 2278 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 2279 if (t[2]) _.ops.pop(); 2280 _.trys.pop(); continue; 2281 } 2282 op = body.call(thisArg, _); 2283 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 2284 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 2285 } 2286 } 2287 2288 var __createBinding = Object.create ? (function(o, m, k, k2) { 2289 if (k2 === undefined) k2 = k; 2290 var desc = Object.getOwnPropertyDescriptor(m, k); 2291 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 2292 desc = { enumerable: true, get: function() { return m[k]; } }; 2293 } 2294 Object.defineProperty(o, k2, desc); 2295 }) : (function(o, m, k, k2) { 2296 if (k2 === undefined) k2 = k; 2297 o[k2] = m[k]; 2298 }); 2299 2300 function __exportStar(m, o) { 2301 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); 2302 } 2303 2304 function __values(o) { 2305 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; 2306 if (m) return m.call(o); 2307 if (o && typeof o.length === "number") return { 2308 next: function () { 2309 if (o && i >= o.length) o = void 0; 2310 return { value: o && o[i++], done: !o }; 2311 } 2312 }; 2313 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); 2314 } 2315 2316 function __read(o, n) { 2317 var m = typeof Symbol === "function" && o[Symbol.iterator]; 2318 if (!m) return o; 2319 var i = m.call(o), r, ar = [], e; 2320 try { 2321 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 2322 } 2323 catch (error) { e = { error: error }; } 2324 finally { 2325 try { 2326 if (r && !r.done && (m = i["return"])) m.call(i); 2327 } 2328 finally { if (e) throw e.error; } 2329 } 2330 return ar; 2331 } 2332 2333 /** @deprecated */ 2334 function __spread() { 2335 for (var ar = [], i = 0; i < arguments.length; i++) 2336 ar = ar.concat(__read(arguments[i])); 2337 return ar; 2338 } 2339 2340 /** @deprecated */ 2341 function __spreadArrays() { 2342 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 2343 for (var r = Array(s), k = 0, i = 0; i < il; i++) 2344 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) 2345 r[k] = a[j]; 2346 return r; 2347 } 2348 2349 function __spreadArray(to, from, pack) { 2350 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { 2351 if (ar || !(i in from)) { 2352 if (!ar) ar = Array.prototype.slice.call(from, 0, i); 2353 ar[i] = from[i]; 2354 } 2355 } 2356 return to.concat(ar || Array.prototype.slice.call(from)); 2357 } 2358 2359 function __await(v) { 2360 return this instanceof __await ? (this.v = v, this) : new __await(v); 2361 } 2362 2363 function __asyncGenerator(thisArg, _arguments, generator) { 2364 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 2365 var g = generator.apply(thisArg, _arguments || []), i, q = []; 2366 return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i; 2367 function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; } 2368 function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } } 2369 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } 2370 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } 2371 function fulfill(value) { resume("next", value); } 2372 function reject(value) { resume("throw", value); } 2373 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } 2374 } 2375 2376 function __asyncDelegator(o) { 2377 var i, p; 2378 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; 2379 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } 2380 } 2381 2382 function __asyncValues(o) { 2383 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 2384 var m = o[Symbol.asyncIterator], i; 2385 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); 2386 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } 2387 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } 2388 } 2389 2390 function __makeTemplateObject(cooked, raw) { 2391 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } 2392 return cooked; 2393 }; 2394 2395 var __setModuleDefault = Object.create ? (function(o, v) { 2396 Object.defineProperty(o, "default", { enumerable: true, value: v }); 2397 }) : function(o, v) { 2398 o["default"] = v; 2399 }; 2400 2401 var ownKeys = function(o) { 2402 ownKeys = Object.getOwnPropertyNames || function (o) { 2403 var ar = []; 2404 for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; 2405 return ar; 2406 }; 2407 return ownKeys(o); 2408 }; 2409 2410 function __importStar(mod) { 2411 if (mod && mod.__esModule) return mod; 2412 var result = {}; 2413 if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); 2414 __setModuleDefault(result, mod); 2415 return result; 2416 } 2417 2418 function __importDefault(mod) { 2419 return (mod && mod.__esModule) ? mod : { default: mod }; 2420 } 2421 2422 function __classPrivateFieldGet(receiver, state, kind, f) { 2423 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); 2424 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); 2425 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); 2426 } 2427 2428 function __classPrivateFieldSet(receiver, state, value, kind, f) { 2429 if (kind === "m") throw new TypeError("Private method is not writable"); 2430 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); 2431 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); 2432 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; 2433 } 2434 2435 function __classPrivateFieldIn(state, receiver) { 2436 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); 2437 return typeof state === "function" ? receiver === state : state.has(receiver); 2438 } 2439 2440 function __addDisposableResource(env, value, async) { 2441 if (value !== null && value !== void 0) { 2442 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); 2443 var dispose, inner; 2444 if (async) { 2445 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); 2446 dispose = value[Symbol.asyncDispose]; 2447 } 2448 if (dispose === void 0) { 2449 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); 2450 dispose = value[Symbol.dispose]; 2451 if (async) inner = dispose; 2452 } 2453 if (typeof dispose !== "function") throw new TypeError("Object not disposable."); 2454 if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } }; 2455 env.stack.push({ value: value, dispose: dispose, async: async }); 2456 } 2457 else if (async) { 2458 env.stack.push({ async: true }); 2459 } 2460 return value; 2461 } 2462 2463 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { 2464 var e = new Error(message); 2465 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; 2466 }; 2467 2468 function __disposeResources(env) { 2469 function fail(e) { 2470 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; 2471 env.hasError = true; 2472 } 2473 var r, s = 0; 2474 function next() { 2475 while (r = env.stack.pop()) { 2476 try { 2477 if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); 2478 if (r.dispose) { 2479 var result = r.dispose.call(r.value); 2480 if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); 2481 } 2482 else s |= 1; 2483 } 2484 catch (e) { 2485 fail(e); 2486 } 2487 } 2488 if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); 2489 if (env.hasError) throw env.error; 2490 } 2491 return next(); 2492 } 2493 2494 function __rewriteRelativeImportExtension(path, preserveJsx) { 2495 if (typeof path === "string" && /^\.\.?\//.test(path)) { 2496 return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) { 2497 return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js"); 2498 }); 2499 } 2500 return path; 2501 } 2502 2503 /* harmony default export */ const tslib_es6 = ({ 2504 __extends, 2505 __assign, 2506 __rest, 2507 __decorate, 2508 __param, 2509 __esDecorate, 2510 __runInitializers, 2511 __propKey, 2512 __setFunctionName, 2513 __metadata, 2514 __awaiter, 2515 __generator, 2516 __createBinding, 2517 __exportStar, 2518 __values, 2519 __read, 2520 __spread, 2521 __spreadArrays, 2522 __spreadArray, 2523 __await, 2524 __asyncGenerator, 2525 __asyncDelegator, 2526 __asyncValues, 2527 __makeTemplateObject, 2528 __importStar, 2529 __importDefault, 2530 __classPrivateFieldGet, 2531 __classPrivateFieldSet, 2532 __classPrivateFieldIn, 2533 __addDisposableResource, 2534 __disposeResources, 2535 __rewriteRelativeImportExtension, 2536 }); 2537 2538 ;// ./node_modules/lower-case/dist.es2015/index.js 2539 /** 2540 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt 2541 */ 2542 var SUPPORTED_LOCALE = { 2543 tr: { 2544 regexp: /\u0130|\u0049|\u0049\u0307/g, 2545 map: { 2546 İ: "\u0069", 2547 I: "\u0131", 2548 İ: "\u0069", 2549 }, 2550 }, 2551 az: { 2552 regexp: /\u0130/g, 2553 map: { 2554 İ: "\u0069", 2555 I: "\u0131", 2556 İ: "\u0069", 2557 }, 2558 }, 2559 lt: { 2560 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, 2561 map: { 2562 I: "\u0069\u0307", 2563 J: "\u006A\u0307", 2564 Į: "\u012F\u0307", 2565 Ì: "\u0069\u0307\u0300", 2566 Í: "\u0069\u0307\u0301", 2567 Ĩ: "\u0069\u0307\u0303", 2568 }, 2569 }, 2570 }; 2571 /** 2572 * Localized lower case. 2573 */ 2574 function localeLowerCase(str, locale) { 2575 var lang = SUPPORTED_LOCALE[locale.toLowerCase()]; 2576 if (lang) 2577 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; })); 2578 return lowerCase(str); 2579 } 2580 /** 2581 * Lower case as a function. 2582 */ 2583 function lowerCase(str) { 2584 return str.toLowerCase(); 2585 } 2586 2587 ;// ./node_modules/no-case/dist.es2015/index.js 2588 2589 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). 2590 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 2591 // Remove all non-word characters. 2592 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 2593 /** 2594 * Normalize the string into something other libraries can manipulate easier. 2595 */ 2596 function noCase(input, options) { 2597 if (options === void 0) { options = {}; } 2598 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; 2599 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 2600 var start = 0; 2601 var end = result.length; 2602 // Trim the delimiter from around the output string. 2603 while (result.charAt(start) === "\0") 2604 start++; 2605 while (result.charAt(end - 1) === "\0") 2606 end--; 2607 // Transform each token independently. 2608 return result.slice(start, end).split("\0").map(transform).join(delimiter); 2609 } 2610 /** 2611 * Replace `re` in the input string with the replacement value. 2612 */ 2613 function replace(input, re, value) { 2614 if (re instanceof RegExp) 2615 return input.replace(re, value); 2616 return re.reduce(function (input, re) { return input.replace(re, value); }, input); 2617 } 2618 2619 ;// ./node_modules/pascal-case/dist.es2015/index.js 2620 2621 2622 function pascalCaseTransform(input, index) { 2623 var firstChar = input.charAt(0); 2624 var lowerChars = input.substr(1).toLowerCase(); 2625 if (index > 0 && firstChar >= "0" && firstChar <= "9") { 2626 return "_" + firstChar + lowerChars; 2627 } 2628 return "" + firstChar.toUpperCase() + lowerChars; 2629 } 2630 function pascalCaseTransformMerge(input) { 2631 return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); 2632 } 2633 function pascalCase(input, options) { 2634 if (options === void 0) { options = {}; } 2635 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); 2636 } 2637 2638 ;// ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js 2639 /** 2640 * External dependencies 2641 */ 2642 2643 /** 2644 * Given a function mapping a component to an enhanced component and modifier 2645 * name, returns the enhanced component augmented with a generated displayName. 2646 * 2647 * @param mapComponent Function mapping component to enhanced component. 2648 * @param modifierName Seed name from which to generated display name. 2649 * 2650 * @return Component class with generated display name assigned. 2651 */ 2652 function createHigherOrderComponent(mapComponent, modifierName) { 2653 return Inner => { 2654 const Outer = mapComponent(Inner); 2655 Outer.displayName = hocName(modifierName, Inner); 2656 return Outer; 2657 }; 2658 } 2659 2660 /** 2661 * Returns a displayName for a higher-order component, given a wrapper name. 2662 * 2663 * @example 2664 * hocName( 'MyMemo', Widget ) === 'MyMemo(Widget)'; 2665 * hocName( 'MyMemo', <div /> ) === 'MyMemo(Component)'; 2666 * 2667 * @param name Name assigned to higher-order component's wrapper component. 2668 * @param Inner Wrapped component inside higher-order component. 2669 * @return Wrapped name of higher-order component. 2670 */ 2671 const hocName = (name, Inner) => { 2672 const inner = Inner.displayName || Inner.name || 'Component'; 2673 const outer = pascalCase(name !== null && name !== void 0 ? name : ''); 2674 return `$outer}($inner})`; 2675 }; 2676 2677 ;// ./node_modules/@wordpress/compose/build-module/utils/debounce/index.js 2678 /** 2679 * Parts of this source were derived and modified from lodash, 2680 * released under the MIT license. 2681 * 2682 * https://github.com/lodash/lodash 2683 * 2684 * Copyright JS Foundation and other contributors <https://js.foundation/> 2685 * 2686 * Based on Underscore.js, copyright Jeremy Ashkenas, 2687 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> 2688 * 2689 * This software consists of voluntary contributions made by many 2690 * individuals. For exact contribution history, see the revision history 2691 * available at https://github.com/lodash/lodash 2692 * 2693 * The following license applies to all parts of this software except as 2694 * documented below: 2695 * 2696 * ==== 2697 * 2698 * Permission is hereby granted, free of charge, to any person obtaining 2699 * a copy of this software and associated documentation files (the 2700 * "Software"), to deal in the Software without restriction, including 2701 * without limitation the rights to use, copy, modify, merge, publish, 2702 * distribute, sublicense, and/or sell copies of the Software, and to 2703 * permit persons to whom the Software is furnished to do so, subject to 2704 * the following conditions: 2705 * 2706 * The above copyright notice and this permission notice shall be 2707 * included in all copies or substantial portions of the Software. 2708 * 2709 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2710 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2711 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2712 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 2713 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 2714 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 2715 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2716 */ 2717 2718 /** 2719 * A simplified and properly typed version of lodash's `debounce`, that 2720 * always uses timers instead of sometimes using rAF. 2721 * 2722 * Creates a debounced function that delays invoking `func` until after `wait` 2723 * milliseconds have elapsed since the last time the debounced function was 2724 * invoked. The debounced function comes with a `cancel` method to cancel delayed 2725 * `func` invocations and a `flush` method to immediately invoke them. Provide 2726 * `options` to indicate whether `func` should be invoked on the leading and/or 2727 * trailing edge of the `wait` timeout. The `func` is invoked with the last 2728 * arguments provided to the debounced function. Subsequent calls to the debounced 2729 * function return the result of the last `func` invocation. 2730 * 2731 * **Note:** If `leading` and `trailing` options are `true`, `func` is 2732 * invoked on the trailing edge of the timeout only if the debounced function 2733 * is invoked more than once during the `wait` timeout. 2734 * 2735 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 2736 * until the next tick, similar to `setTimeout` with a timeout of `0`. 2737 * 2738 * @param {Function} func The function to debounce. 2739 * @param {number} wait The number of milliseconds to delay. 2740 * @param {Partial< DebounceOptions >} options The options object. 2741 * @param {boolean} options.leading Specify invoking on the leading edge of the timeout. 2742 * @param {number} options.maxWait The maximum time `func` is allowed to be delayed before it's invoked. 2743 * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout. 2744 * 2745 * @return Returns the new debounced function. 2746 */ 2747 const debounce = (func, wait, options) => { 2748 let lastArgs; 2749 let lastThis; 2750 let maxWait = 0; 2751 let result; 2752 let timerId; 2753 let lastCallTime; 2754 let lastInvokeTime = 0; 2755 let leading = false; 2756 let maxing = false; 2757 let trailing = true; 2758 if (options) { 2759 leading = !!options.leading; 2760 maxing = 'maxWait' in options; 2761 if (options.maxWait !== undefined) { 2762 maxWait = Math.max(options.maxWait, wait); 2763 } 2764 trailing = 'trailing' in options ? !!options.trailing : trailing; 2765 } 2766 function invokeFunc(time) { 2767 const args = lastArgs; 2768 const thisArg = lastThis; 2769 lastArgs = undefined; 2770 lastThis = undefined; 2771 lastInvokeTime = time; 2772 result = func.apply(thisArg, args); 2773 return result; 2774 } 2775 function startTimer(pendingFunc, waitTime) { 2776 timerId = setTimeout(pendingFunc, waitTime); 2777 } 2778 function cancelTimer() { 2779 if (timerId !== undefined) { 2780 clearTimeout(timerId); 2781 } 2782 } 2783 function leadingEdge(time) { 2784 // Reset any `maxWait` timer. 2785 lastInvokeTime = time; 2786 // Start the timer for the trailing edge. 2787 startTimer(timerExpired, wait); 2788 // Invoke the leading edge. 2789 return leading ? invokeFunc(time) : result; 2790 } 2791 function getTimeSinceLastCall(time) { 2792 return time - (lastCallTime || 0); 2793 } 2794 function remainingWait(time) { 2795 const timeSinceLastCall = getTimeSinceLastCall(time); 2796 const timeSinceLastInvoke = time - lastInvokeTime; 2797 const timeWaiting = wait - timeSinceLastCall; 2798 return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting; 2799 } 2800 function shouldInvoke(time) { 2801 const timeSinceLastCall = getTimeSinceLastCall(time); 2802 const timeSinceLastInvoke = time - lastInvokeTime; 2803 2804 // Either this is the first call, activity has stopped and we're at the 2805 // trailing edge, the system time has gone backwards and we're treating 2806 // it as the trailing edge, or we've hit the `maxWait` limit. 2807 return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; 2808 } 2809 function timerExpired() { 2810 const time = Date.now(); 2811 if (shouldInvoke(time)) { 2812 return trailingEdge(time); 2813 } 2814 // Restart the timer. 2815 startTimer(timerExpired, remainingWait(time)); 2816 return undefined; 2817 } 2818 function clearTimer() { 2819 timerId = undefined; 2820 } 2821 function trailingEdge(time) { 2822 clearTimer(); 2823 2824 // Only invoke if we have `lastArgs` which means `func` has been 2825 // debounced at least once. 2826 if (trailing && lastArgs) { 2827 return invokeFunc(time); 2828 } 2829 lastArgs = lastThis = undefined; 2830 return result; 2831 } 2832 function cancel() { 2833 cancelTimer(); 2834 lastInvokeTime = 0; 2835 clearTimer(); 2836 lastArgs = lastCallTime = lastThis = undefined; 2837 } 2838 function flush() { 2839 return pending() ? trailingEdge(Date.now()) : result; 2840 } 2841 function pending() { 2842 return timerId !== undefined; 2843 } 2844 function debounced(...args) { 2845 const time = Date.now(); 2846 const isInvoking = shouldInvoke(time); 2847 lastArgs = args; 2848 lastThis = this; 2849 lastCallTime = time; 2850 if (isInvoking) { 2851 if (!pending()) { 2852 return leadingEdge(lastCallTime); 2853 } 2854 if (maxing) { 2855 // Handle invocations in a tight loop. 2856 startTimer(timerExpired, wait); 2857 return invokeFunc(lastCallTime); 2858 } 2859 } 2860 if (!pending()) { 2861 startTimer(timerExpired, wait); 2862 } 2863 return result; 2864 } 2865 debounced.cancel = cancel; 2866 debounced.flush = flush; 2867 debounced.pending = pending; 2868 return debounced; 2869 }; 2870 2871 ;// ./node_modules/@wordpress/compose/build-module/utils/throttle/index.js 2872 /** 2873 * Parts of this source were derived and modified from lodash, 2874 * released under the MIT license. 2875 * 2876 * https://github.com/lodash/lodash 2877 * 2878 * Copyright JS Foundation and other contributors <https://js.foundation/> 2879 * 2880 * Based on Underscore.js, copyright Jeremy Ashkenas, 2881 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> 2882 * 2883 * This software consists of voluntary contributions made by many 2884 * individuals. For exact contribution history, see the revision history 2885 * available at https://github.com/lodash/lodash 2886 * 2887 * The following license applies to all parts of this software except as 2888 * documented below: 2889 * 2890 * ==== 2891 * 2892 * Permission is hereby granted, free of charge, to any person obtaining 2893 * a copy of this software and associated documentation files (the 2894 * "Software"), to deal in the Software without restriction, including 2895 * without limitation the rights to use, copy, modify, merge, publish, 2896 * distribute, sublicense, and/or sell copies of the Software, and to 2897 * permit persons to whom the Software is furnished to do so, subject to 2898 * the following conditions: 2899 * 2900 * The above copyright notice and this permission notice shall be 2901 * included in all copies or substantial portions of the Software. 2902 * 2903 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2904 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2905 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2906 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 2907 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 2908 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 2909 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2910 */ 2911 2912 /** 2913 * Internal dependencies 2914 */ 2915 2916 /** 2917 * A simplified and properly typed version of lodash's `throttle`, that 2918 * always uses timers instead of sometimes using rAF. 2919 * 2920 * Creates a throttled function that only invokes `func` at most once per 2921 * every `wait` milliseconds. The throttled function comes with a `cancel` 2922 * method to cancel delayed `func` invocations and a `flush` method to 2923 * immediately invoke them. Provide `options` to indicate whether `func` 2924 * should be invoked on the leading and/or trailing edge of the `wait` 2925 * timeout. The `func` is invoked with the last arguments provided to the 2926 * throttled function. Subsequent calls to the throttled function return 2927 * the result of the last `func` invocation. 2928 * 2929 * **Note:** If `leading` and `trailing` options are `true`, `func` is 2930 * invoked on the trailing edge of the timeout only if the throttled function 2931 * is invoked more than once during the `wait` timeout. 2932 * 2933 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 2934 * until the next tick, similar to `setTimeout` with a timeout of `0`. 2935 * 2936 * @param {Function} func The function to throttle. 2937 * @param {number} wait The number of milliseconds to throttle invocations to. 2938 * @param {Partial< ThrottleOptions >} options The options object. 2939 * @param {boolean} options.leading Specify invoking on the leading edge of the timeout. 2940 * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout. 2941 * @return Returns the new throttled function. 2942 */ 2943 const throttle = (func, wait, options) => { 2944 let leading = true; 2945 let trailing = true; 2946 if (options) { 2947 leading = 'leading' in options ? !!options.leading : leading; 2948 trailing = 'trailing' in options ? !!options.trailing : trailing; 2949 } 2950 return debounce(func, wait, { 2951 leading, 2952 trailing, 2953 maxWait: wait 2954 }); 2955 }; 2956 2957 ;// ./node_modules/@wordpress/compose/build-module/utils/observable-map/index.js 2958 /** 2959 * A constructor (factory) for `ObservableMap`, a map-like key/value data structure 2960 * where the individual entries are observable: using the `subscribe` method, you can 2961 * subscribe to updates for a particular keys. Each subscriber always observes one 2962 * specific key and is not notified about any unrelated changes (for different keys) 2963 * in the `ObservableMap`. 2964 * 2965 * @template K The type of the keys in the map. 2966 * @template V The type of the values in the map. 2967 * @return A new instance of the `ObservableMap` type. 2968 */ 2969 function observableMap() { 2970 const map = new Map(); 2971 const listeners = new Map(); 2972 function callListeners(name) { 2973 const list = listeners.get(name); 2974 if (!list) { 2975 return; 2976 } 2977 for (const listener of list) { 2978 listener(); 2979 } 2980 } 2981 return { 2982 get(name) { 2983 return map.get(name); 2984 }, 2985 set(name, value) { 2986 map.set(name, value); 2987 callListeners(name); 2988 }, 2989 delete(name) { 2990 map.delete(name); 2991 callListeners(name); 2992 }, 2993 subscribe(name, listener) { 2994 let list = listeners.get(name); 2995 if (!list) { 2996 list = new Set(); 2997 listeners.set(name, list); 2998 } 2999 list.add(listener); 3000 return () => { 3001 list.delete(listener); 3002 if (list.size === 0) { 3003 listeners.delete(name); 3004 } 3005 }; 3006 } 3007 }; 3008 } 3009 3010 ;// ./node_modules/@wordpress/compose/build-module/higher-order/pipe.js 3011 /** 3012 * Parts of this source were derived and modified from lodash, 3013 * released under the MIT license. 3014 * 3015 * https://github.com/lodash/lodash 3016 * 3017 * Copyright JS Foundation and other contributors <https://js.foundation/> 3018 * 3019 * Based on Underscore.js, copyright Jeremy Ashkenas, 3020 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> 3021 * 3022 * This software consists of voluntary contributions made by many 3023 * individuals. For exact contribution history, see the revision history 3024 * available at https://github.com/lodash/lodash 3025 * 3026 * The following license applies to all parts of this software except as 3027 * documented below: 3028 * 3029 * ==== 3030 * 3031 * Permission is hereby granted, free of charge, to any person obtaining 3032 * a copy of this software and associated documentation files (the 3033 * "Software"), to deal in the Software without restriction, including 3034 * without limitation the rights to use, copy, modify, merge, publish, 3035 * distribute, sublicense, and/or sell copies of the Software, and to 3036 * permit persons to whom the Software is furnished to do so, subject to 3037 * the following conditions: 3038 * 3039 * The above copyright notice and this permission notice shall be 3040 * included in all copies or substantial portions of the Software. 3041 * 3042 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3043 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3044 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3045 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 3046 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 3047 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 3048 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 3049 */ 3050 3051 /** 3052 * Creates a pipe function. 3053 * 3054 * Allows to choose whether to perform left-to-right or right-to-left composition. 3055 * 3056 * @see https://lodash.com/docs/4#flow 3057 * 3058 * @param {boolean} reverse True if right-to-left, false for left-to-right composition. 3059 */ 3060 const basePipe = (reverse = false) => (...funcs) => (...args) => { 3061 const functions = funcs.flat(); 3062 if (reverse) { 3063 functions.reverse(); 3064 } 3065 return functions.reduce((prev, func) => [func(...prev)], args)[0]; 3066 }; 3067 3068 /** 3069 * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function 3070 * composition, where each successive invocation is supplied the return value of the previous. 3071 * 3072 * This is inspired by `lodash`'s `flow` function. 3073 * 3074 * @see https://lodash.com/docs/4#flow 3075 */ 3076 const pipe = basePipe(); 3077 3078 /* harmony default export */ const higher_order_pipe = (pipe); 3079 3080 ;// ./node_modules/@wordpress/compose/build-module/higher-order/compose.js 3081 /** 3082 * Internal dependencies 3083 */ 3084 3085 3086 /** 3087 * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function 3088 * composition, where each successive invocation is supplied the return value of the previous. 3089 * 3090 * This is inspired by `lodash`'s `flowRight` function. 3091 * 3092 * @see https://lodash.com/docs/4#flow-right 3093 */ 3094 const compose = basePipe(true); 3095 /* harmony default export */ const higher_order_compose = (compose); 3096 3097 ;// external "ReactJSXRuntime" 3098 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; 3099 ;// ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js 3100 /** 3101 * External dependencies 3102 */ 3103 3104 /** 3105 * Internal dependencies 3106 */ 3107 3108 3109 /** 3110 * Higher-order component creator, creating a new component which renders if 3111 * the given condition is satisfied or with the given optional prop name. 3112 * 3113 * @example 3114 * ```ts 3115 * type Props = { foo: string }; 3116 * const Component = ( props: Props ) => <div>{ props.foo }</div>; 3117 * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component ); 3118 * <ConditionalComponent foo="" />; // => null 3119 * <ConditionalComponent foo="bar" />; // => <div>bar</div>; 3120 * ``` 3121 * 3122 * @param predicate Function to test condition. 3123 * 3124 * @return Higher-order component. 3125 */ 3126 3127 function ifCondition(predicate) { 3128 return createHigherOrderComponent(WrappedComponent => props => { 3129 if (!predicate(props)) { 3130 return null; 3131 } 3132 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 3133 ...props 3134 }); 3135 }, 'ifCondition'); 3136 } 3137 /* harmony default export */ const if_condition = (ifCondition); 3138 3139 ;// external ["wp","isShallowEqual"] 3140 const external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; 3141 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); 3142 ;// external ["wp","element"] 3143 const external_wp_element_namespaceObject = window["wp"]["element"]; 3144 ;// ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js 3145 /** 3146 * External dependencies 3147 */ 3148 3149 /** 3150 * WordPress dependencies 3151 */ 3152 3153 3154 3155 /** 3156 * Internal dependencies 3157 */ 3158 3159 3160 /** 3161 * Given a component returns the enhanced component augmented with a component 3162 * only re-rendering when its props/state change 3163 * 3164 * @deprecated Use `memo` or `PureComponent` instead. 3165 */ 3166 3167 const pure = createHigherOrderComponent(function (WrappedComponent) { 3168 if (WrappedComponent.prototype instanceof external_wp_element_namespaceObject.Component) { 3169 return class extends WrappedComponent { 3170 shouldComponentUpdate(nextProps, nextState) { 3171 return !external_wp_isShallowEqual_default()(nextProps, this.props) || !external_wp_isShallowEqual_default()(nextState, this.state); 3172 } 3173 }; 3174 } 3175 return class extends external_wp_element_namespaceObject.Component { 3176 shouldComponentUpdate(nextProps) { 3177 return !external_wp_isShallowEqual_default()(nextProps, this.props); 3178 } 3179 render() { 3180 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 3181 ...this.props 3182 }); 3183 } 3184 }; 3185 }, 'pure'); 3186 /* harmony default export */ const higher_order_pure = (pure); 3187 3188 ;// external ["wp","deprecated"] 3189 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; 3190 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); 3191 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js 3192 /** 3193 * Class responsible for orchestrating event handling on the global window, 3194 * binding a single event to be shared across all handling instances, and 3195 * removing the handler when no instances are listening for the event. 3196 */ 3197 class Listener { 3198 constructor() { 3199 /** @type {any} */ 3200 this.listeners = {}; 3201 this.handleEvent = this.handleEvent.bind(this); 3202 } 3203 add(/** @type {any} */eventType, /** @type {any} */instance) { 3204 if (!this.listeners[eventType]) { 3205 // Adding first listener for this type, so bind event. 3206 window.addEventListener(eventType, this.handleEvent); 3207 this.listeners[eventType] = []; 3208 } 3209 this.listeners[eventType].push(instance); 3210 } 3211 remove(/** @type {any} */eventType, /** @type {any} */instance) { 3212 if (!this.listeners[eventType]) { 3213 return; 3214 } 3215 this.listeners[eventType] = this.listeners[eventType].filter((/** @type {any} */listener) => listener !== instance); 3216 if (!this.listeners[eventType].length) { 3217 // Removing last listener for this type, so unbind event. 3218 window.removeEventListener(eventType, this.handleEvent); 3219 delete this.listeners[eventType]; 3220 } 3221 } 3222 handleEvent(/** @type {any} */event) { 3223 this.listeners[event.type]?.forEach((/** @type {any} */instance) => { 3224 instance.handleEvent(event); 3225 }); 3226 } 3227 } 3228 /* harmony default export */ const listener = (Listener); 3229 3230 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js 3231 /** 3232 * WordPress dependencies 3233 */ 3234 3235 3236 3237 /** 3238 * Internal dependencies 3239 */ 3240 3241 3242 3243 /** 3244 * Listener instance responsible for managing document event handling. 3245 */ 3246 3247 const with_global_events_listener = new listener(); 3248 3249 /* eslint-disable jsdoc/no-undefined-types */ 3250 /** 3251 * Higher-order component creator which, given an object of DOM event types and 3252 * values corresponding to a callback function name on the component, will 3253 * create or update a window event handler to invoke the callback when an event 3254 * occurs. On behalf of the consuming developer, the higher-order component 3255 * manages unbinding when the component unmounts, and binding at most a single 3256 * event handler for the entire application. 3257 * 3258 * @deprecated 3259 * 3260 * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM 3261 * event type, the value a 3262 * name of the function on 3263 * the original component's 3264 * instance which handles 3265 * the event. 3266 * 3267 * @return {any} Higher-order component. 3268 */ 3269 function withGlobalEvents(eventTypesToHandlers) { 3270 external_wp_deprecated_default()('wp.compose.withGlobalEvents', { 3271 since: '5.7', 3272 alternative: 'useEffect' 3273 }); 3274 3275 // @ts-ignore We don't need to fix the type-related issues because this is deprecated. 3276 return createHigherOrderComponent(WrappedComponent => { 3277 class Wrapper extends external_wp_element_namespaceObject.Component { 3278 constructor(/** @type {any} */props) { 3279 super(props); 3280 this.handleEvent = this.handleEvent.bind(this); 3281 this.handleRef = this.handleRef.bind(this); 3282 } 3283 componentDidMount() { 3284 Object.keys(eventTypesToHandlers).forEach(eventType => { 3285 with_global_events_listener.add(eventType, this); 3286 }); 3287 } 3288 componentWillUnmount() { 3289 Object.keys(eventTypesToHandlers).forEach(eventType => { 3290 with_global_events_listener.remove(eventType, this); 3291 }); 3292 } 3293 handleEvent(/** @type {any} */event) { 3294 const handler = eventTypesToHandlers[(/** @type {keyof GlobalEventHandlersEventMap} */ 3295 event.type 3296 3297 /* eslint-enable jsdoc/no-undefined-types */)]; 3298 if (typeof this.wrappedRef[handler] === 'function') { 3299 this.wrappedRef[handler](event); 3300 } 3301 } 3302 handleRef(/** @type {any} */el) { 3303 this.wrappedRef = el; 3304 // Any component using `withGlobalEvents` that is not setting a `ref` 3305 // will cause `this.props.forwardedRef` to be `null`, so we need this 3306 // check. 3307 if (this.props.forwardedRef) { 3308 this.props.forwardedRef(el); 3309 } 3310 } 3311 render() { 3312 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 3313 ...this.props.ownProps, 3314 ref: this.handleRef 3315 }); 3316 } 3317 } 3318 return (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => { 3319 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Wrapper, { 3320 ownProps: props, 3321 forwardedRef: ref 3322 }); 3323 }); 3324 }, 'withGlobalEvents'); 3325 } 3326 3327 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js 3328 /** 3329 * WordPress dependencies 3330 */ 3331 3332 const instanceMap = new WeakMap(); 3333 3334 /** 3335 * Creates a new id for a given object. 3336 * 3337 * @param object Object reference to create an id for. 3338 * @return The instance id (index). 3339 */ 3340 function createId(object) { 3341 const instances = instanceMap.get(object) || 0; 3342 instanceMap.set(object, instances + 1); 3343 return instances; 3344 } 3345 3346 /** 3347 * Specify the useInstanceId *function* signatures. 3348 * 3349 * More accurately, useInstanceId distinguishes between three different 3350 * signatures: 3351 * 3352 * 1. When only object is given, the returned value is a number 3353 * 2. When object and prefix is given, the returned value is a string 3354 * 3. When preferredId is given, the returned value is the type of preferredId 3355 * 3356 * @param object Object reference to create an id for. 3357 */ 3358 3359 /** 3360 * Provides a unique instance ID. 3361 * 3362 * @param object Object reference to create an id for. 3363 * @param [prefix] Prefix for the unique id. 3364 * @param [preferredId] Default ID to use. 3365 * @return The unique instance id. 3366 */ 3367 function useInstanceId(object, prefix, preferredId) { 3368 return (0,external_wp_element_namespaceObject.useMemo)(() => { 3369 if (preferredId) { 3370 return preferredId; 3371 } 3372 const id = createId(object); 3373 return prefix ? `$prefix}-$id}` : id; 3374 }, [object, preferredId, prefix]); 3375 } 3376 /* harmony default export */ const use_instance_id = (useInstanceId); 3377 3378 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js 3379 /** 3380 * Internal dependencies 3381 */ 3382 3383 3384 3385 3386 /** 3387 * A Higher Order Component used to provide a unique instance ID by component. 3388 */ 3389 const withInstanceId = createHigherOrderComponent(WrappedComponent => { 3390 return props => { 3391 const instanceId = use_instance_id(WrappedComponent); 3392 // @ts-ignore 3393 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 3394 ...props, 3395 instanceId: instanceId 3396 }); 3397 }; 3398 }, 'instanceId'); 3399 /* harmony default export */ const with_instance_id = (withInstanceId); 3400 3401 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js 3402 /** 3403 * WordPress dependencies 3404 */ 3405 3406 3407 /** 3408 * Internal dependencies 3409 */ 3410 3411 3412 3413 /** 3414 * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']` 3415 * types here because those functions include functionality that is not handled 3416 * by this component, like the ability to pass extra arguments. 3417 * 3418 * In the case of this component, we only handle the simplest case where 3419 * `setTimeout` only accepts a function (not a string) and an optional delay. 3420 */ 3421 3422 /** 3423 * A higher-order component used to provide and manage delayed function calls 3424 * that ought to be bound to a component's lifecycle. 3425 */ 3426 const withSafeTimeout = createHigherOrderComponent(OriginalComponent => { 3427 return class WrappedComponent extends external_wp_element_namespaceObject.Component { 3428 constructor(props) { 3429 super(props); 3430 this.timeouts = []; 3431 this.setTimeout = this.setTimeout.bind(this); 3432 this.clearTimeout = this.clearTimeout.bind(this); 3433 } 3434 componentWillUnmount() { 3435 this.timeouts.forEach(clearTimeout); 3436 } 3437 setTimeout(fn, delay) { 3438 const id = setTimeout(() => { 3439 fn(); 3440 this.clearTimeout(id); 3441 }, delay); 3442 this.timeouts.push(id); 3443 return id; 3444 } 3445 clearTimeout(id) { 3446 clearTimeout(id); 3447 this.timeouts = this.timeouts.filter(timeoutId => timeoutId !== id); 3448 } 3449 render() { 3450 return ( 3451 /*#__PURE__*/ 3452 // @ts-ignore 3453 (0,external_ReactJSXRuntime_namespaceObject.jsx)(OriginalComponent, { 3454 ...this.props, 3455 setTimeout: this.setTimeout, 3456 clearTimeout: this.clearTimeout 3457 }) 3458 ); 3459 } 3460 }; 3461 }, 'withSafeTimeout'); 3462 /* harmony default export */ const with_safe_timeout = (withSafeTimeout); 3463 3464 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js 3465 /** 3466 * WordPress dependencies 3467 */ 3468 3469 3470 3471 /** 3472 * Internal dependencies 3473 */ 3474 3475 3476 /** 3477 * A Higher Order Component used to provide and manage internal component state 3478 * via props. 3479 * 3480 * @deprecated Use `useState` instead. 3481 * 3482 * @param {any} initialState Optional initial state of the component. 3483 * 3484 * @return {any} A higher order component wrapper accepting a component that takes the state props + its own props + `setState` and returning a component that only accepts the own props. 3485 */ 3486 3487 function withState(initialState = {}) { 3488 external_wp_deprecated_default()('wp.compose.withState', { 3489 since: '5.8', 3490 alternative: 'wp.element.useState' 3491 }); 3492 return createHigherOrderComponent(OriginalComponent => { 3493 return class WrappedComponent extends external_wp_element_namespaceObject.Component { 3494 constructor(/** @type {any} */props) { 3495 super(props); 3496 this.setState = this.setState.bind(this); 3497 this.state = initialState; 3498 } 3499 render() { 3500 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OriginalComponent, { 3501 ...this.props, 3502 ...this.state, 3503 setState: this.setState 3504 }); 3505 } 3506 }; 3507 }, 'withState'); 3508 } 3509 3510 ;// external ["wp","dom"] 3511 const external_wp_dom_namespaceObject = window["wp"]["dom"]; 3512 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-ref-effect/index.js 3513 /** 3514 * External dependencies 3515 */ 3516 3517 /** 3518 * WordPress dependencies 3519 */ 3520 3521 3522 /** 3523 * Effect-like ref callback. Just like with `useEffect`, this allows you to 3524 * return a cleanup function to be run if the ref changes or one of the 3525 * dependencies changes. The ref is provided as an argument to the callback 3526 * functions. The main difference between this and `useEffect` is that 3527 * the `useEffect` callback is not called when the ref changes, but this is. 3528 * Pass the returned ref callback as the component's ref and merge multiple refs 3529 * with `useMergeRefs`. 3530 * 3531 * It's worth noting that if the dependencies array is empty, there's not 3532 * strictly a need to clean up event handlers for example, because the node is 3533 * to be removed. It *is* necessary if you add dependencies because the ref 3534 * callback will be called multiple times for the same node. 3535 * 3536 * @param callback Callback with ref as argument. 3537 * @param dependencies Dependencies of the callback. 3538 * 3539 * @return Ref callback. 3540 */ 3541 function useRefEffect(callback, dependencies) { 3542 const cleanupRef = (0,external_wp_element_namespaceObject.useRef)(); 3543 return (0,external_wp_element_namespaceObject.useCallback)(node => { 3544 if (node) { 3545 cleanupRef.current = callback(node); 3546 } else if (cleanupRef.current) { 3547 cleanupRef.current(); 3548 } 3549 }, dependencies); 3550 } 3551 3552 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-constrained-tabbing/index.js 3553 /** 3554 * WordPress dependencies 3555 */ 3556 3557 3558 /** 3559 * Internal dependencies 3560 */ 3561 3562 3563 /** 3564 * In Dialogs/modals, the tabbing must be constrained to the content of 3565 * the wrapper element. This hook adds the behavior to the returned ref. 3566 * 3567 * @return {import('react').RefCallback<Element>} Element Ref. 3568 * 3569 * @example 3570 * ```js 3571 * import { useConstrainedTabbing } from '@wordpress/compose'; 3572 * 3573 * const ConstrainedTabbingExample = () => { 3574 * const constrainedTabbingRef = useConstrainedTabbing() 3575 * return ( 3576 * <div ref={ constrainedTabbingRef }> 3577 * <Button /> 3578 * <Button /> 3579 * </div> 3580 * ); 3581 * } 3582 * ``` 3583 */ 3584 function useConstrainedTabbing() { 3585 return useRefEffect((/** @type {HTMLElement} */node) => { 3586 function onKeyDown(/** @type {KeyboardEvent} */event) { 3587 const { 3588 key, 3589 shiftKey, 3590 target 3591 } = event; 3592 if (key !== 'Tab') { 3593 return; 3594 } 3595 const action = shiftKey ? 'findPrevious' : 'findNext'; 3596 const nextElement = external_wp_dom_namespaceObject.focus.tabbable[action](/** @type {HTMLElement} */target) || null; 3597 3598 // When the target element contains the element that is about to 3599 // receive focus, for example when the target is a tabbable 3600 // container, browsers may disagree on where to move focus next. 3601 // In this case we can't rely on native browsers behavior. We need 3602 // to manage focus instead. 3603 // See https://github.com/WordPress/gutenberg/issues/46041. 3604 if (/** @type {HTMLElement} */target.contains(nextElement)) { 3605 event.preventDefault(); 3606 nextElement?.focus(); 3607 return; 3608 } 3609 3610 // If the element that is about to receive focus is inside the 3611 // area, rely on native browsers behavior and let tabbing follow 3612 // the native tab sequence. 3613 if (node.contains(nextElement)) { 3614 return; 3615 } 3616 3617 // If the element that is about to receive focus is outside the 3618 // area, move focus to a div and insert it at the start or end of 3619 // the area, depending on the direction. Without preventing default 3620 // behaviour, the browser will then move focus to the next element. 3621 const domAction = shiftKey ? 'append' : 'prepend'; 3622 const { 3623 ownerDocument 3624 } = node; 3625 const trap = ownerDocument.createElement('div'); 3626 trap.tabIndex = -1; 3627 node[domAction](trap); 3628 3629 // Remove itself when the trap loses focus. 3630 trap.addEventListener('blur', () => node.removeChild(trap)); 3631 trap.focus(); 3632 } 3633 node.addEventListener('keydown', onKeyDown); 3634 return () => { 3635 node.removeEventListener('keydown', onKeyDown); 3636 }; 3637 }, []); 3638 } 3639 /* harmony default export */ const use_constrained_tabbing = (useConstrainedTabbing); 3640 3641 // EXTERNAL MODULE: ./node_modules/clipboard/dist/clipboard.js 3642 var dist_clipboard = __webpack_require__(3758); 3643 var clipboard_default = /*#__PURE__*/__webpack_require__.n(dist_clipboard); 3644 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-copy-on-click/index.js 3645 /** 3646 * External dependencies 3647 */ 3648 3649 3650 /** 3651 * WordPress dependencies 3652 */ 3653 3654 3655 3656 /* eslint-disable jsdoc/no-undefined-types */ 3657 /** 3658 * Copies the text to the clipboard when the element is clicked. 3659 * 3660 * @deprecated 3661 * 3662 * @param {import('react').RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element. 3663 * @param {string|Function} text The text to copy. 3664 * @param {number} [timeout] Optional timeout to reset the returned 3665 * state. 4 seconds by default. 3666 * 3667 * @return {boolean} Whether or not the text has been copied. Resets after the 3668 * timeout. 3669 */ 3670 function useCopyOnClick(ref, text, timeout = 4000) { 3671 /* eslint-enable jsdoc/no-undefined-types */ 3672 external_wp_deprecated_default()('wp.compose.useCopyOnClick', { 3673 since: '5.8', 3674 alternative: 'wp.compose.useCopyToClipboard' 3675 }); 3676 3677 /** @type {import('react').MutableRefObject<Clipboard | undefined>} */ 3678 const clipboardRef = (0,external_wp_element_namespaceObject.useRef)(); 3679 const [hasCopied, setHasCopied] = (0,external_wp_element_namespaceObject.useState)(false); 3680 (0,external_wp_element_namespaceObject.useEffect)(() => { 3681 /** @type {number | undefined} */ 3682 let timeoutId; 3683 if (!ref.current) { 3684 return; 3685 } 3686 3687 // Clipboard listens to click events. 3688 clipboardRef.current = new (clipboard_default())(ref.current, { 3689 text: () => typeof text === 'function' ? text() : text 3690 }); 3691 clipboardRef.current.on('success', ({ 3692 clearSelection, 3693 trigger 3694 }) => { 3695 // Clearing selection will move focus back to the triggering button, 3696 // ensuring that it is not reset to the body, and further that it is 3697 // kept within the rendered node. 3698 clearSelection(); 3699 3700 // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 3701 if (trigger) { 3702 /** @type {HTMLElement} */trigger.focus(); 3703 } 3704 if (timeout) { 3705 setHasCopied(true); 3706 clearTimeout(timeoutId); 3707 timeoutId = setTimeout(() => setHasCopied(false), timeout); 3708 } 3709 }); 3710 return () => { 3711 if (clipboardRef.current) { 3712 clipboardRef.current.destroy(); 3713 } 3714 clearTimeout(timeoutId); 3715 }; 3716 }, [text, timeout, setHasCopied]); 3717 return hasCopied; 3718 } 3719 3720 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-copy-to-clipboard/index.js 3721 /** 3722 * External dependencies 3723 */ 3724 3725 3726 /** 3727 * WordPress dependencies 3728 */ 3729 3730 3731 /** 3732 * Internal dependencies 3733 */ 3734 3735 3736 /** 3737 * @template T 3738 * @param {T} value 3739 * @return {import('react').RefObject<T>} The updated ref 3740 */ 3741 function useUpdatedRef(value) { 3742 const ref = (0,external_wp_element_namespaceObject.useRef)(value); 3743 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 3744 ref.current = value; 3745 }, [value]); 3746 return ref; 3747 } 3748 3749 /** 3750 * Copies the given text to the clipboard when the element is clicked. 3751 * 3752 * @template {HTMLElement} TElementType 3753 * @param {string | (() => string)} text The text to copy. Use a function if not 3754 * already available and expensive to compute. 3755 * @param {Function} onSuccess Called when to text is copied. 3756 * 3757 * @return {import('react').Ref<TElementType>} A ref to assign to the target element. 3758 */ 3759 function useCopyToClipboard(text, onSuccess) { 3760 // Store the dependencies as refs and continuously update them so they're 3761 // fresh when the callback is called. 3762 const textRef = useUpdatedRef(text); 3763 const onSuccessRef = useUpdatedRef(onSuccess); 3764 return useRefEffect(node => { 3765 // Clipboard listens to click events. 3766 const clipboard = new (clipboard_default())(node, { 3767 text() { 3768 return typeof textRef.current === 'function' ? textRef.current() : textRef.current || ''; 3769 } 3770 }); 3771 clipboard.on('success', ({ 3772 clearSelection 3773 }) => { 3774 // Clearing selection will move focus back to the triggering 3775 // button, ensuring that it is not reset to the body, and 3776 // further that it is kept within the rendered node. 3777 clearSelection(); 3778 if (onSuccessRef.current) { 3779 onSuccessRef.current(); 3780 } 3781 }); 3782 return () => { 3783 clipboard.destroy(); 3784 }; 3785 }, []); 3786 } 3787 3788 ;// external ["wp","keycodes"] 3789 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; 3790 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-focus-on-mount/index.js 3791 /** 3792 * WordPress dependencies 3793 */ 3794 3795 3796 3797 /** 3798 * Internal dependencies 3799 */ 3800 3801 3802 /** 3803 * Hook used to focus the first tabbable element on mount. 3804 * 3805 * @param {boolean | 'firstElement'} focusOnMount Focus on mount mode. 3806 * @return {import('react').RefCallback<HTMLElement>} Ref callback. 3807 * 3808 * @example 3809 * ```js 3810 * import { useFocusOnMount } from '@wordpress/compose'; 3811 * 3812 * const WithFocusOnMount = () => { 3813 * const ref = useFocusOnMount() 3814 * return ( 3815 * <div ref={ ref }> 3816 * <Button /> 3817 * <Button /> 3818 * </div> 3819 * ); 3820 * } 3821 * ``` 3822 */ 3823 function useFocusOnMount(focusOnMount = 'firstElement') { 3824 const focusOnMountRef = (0,external_wp_element_namespaceObject.useRef)(focusOnMount); 3825 3826 /** 3827 * Sets focus on a DOM element. 3828 * 3829 * @param {HTMLElement} target The DOM element to set focus to. 3830 * @return {void} 3831 */ 3832 const setFocus = target => { 3833 target.focus({ 3834 // When focusing newly mounted dialogs, 3835 // the position of the popover is often not right on the first render 3836 // This prevents the layout shifts when focusing the dialogs. 3837 preventScroll: true 3838 }); 3839 }; 3840 3841 /** @type {import('react').MutableRefObject<ReturnType<setTimeout> | undefined>} */ 3842 const timerIdRef = (0,external_wp_element_namespaceObject.useRef)(); 3843 (0,external_wp_element_namespaceObject.useEffect)(() => { 3844 focusOnMountRef.current = focusOnMount; 3845 }, [focusOnMount]); 3846 return useRefEffect(node => { 3847 var _node$ownerDocument$a; 3848 if (!node || focusOnMountRef.current === false) { 3849 return; 3850 } 3851 if (node.contains((_node$ownerDocument$a = node.ownerDocument?.activeElement) !== null && _node$ownerDocument$a !== void 0 ? _node$ownerDocument$a : null)) { 3852 return; 3853 } 3854 if (focusOnMountRef.current !== 'firstElement') { 3855 setFocus(node); 3856 return; 3857 } 3858 timerIdRef.current = setTimeout(() => { 3859 const firstTabbable = external_wp_dom_namespaceObject.focus.tabbable.find(node)[0]; 3860 if (firstTabbable) { 3861 setFocus(firstTabbable); 3862 } 3863 }, 0); 3864 return () => { 3865 if (timerIdRef.current) { 3866 clearTimeout(timerIdRef.current); 3867 } 3868 }; 3869 }, []); 3870 } 3871 3872 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-focus-return/index.js 3873 /** 3874 * WordPress dependencies 3875 */ 3876 3877 3878 /** @type {Element|null} */ 3879 let origin = null; 3880 3881 /** 3882 * Adds the unmount behavior of returning focus to the element which had it 3883 * previously as is expected for roles like menus or dialogs. 3884 * 3885 * @param {() => void} [onFocusReturn] Overrides the default return behavior. 3886 * @return {import('react').RefCallback<HTMLElement>} Element Ref. 3887 * 3888 * @example 3889 * ```js 3890 * import { useFocusReturn } from '@wordpress/compose'; 3891 * 3892 * const WithFocusReturn = () => { 3893 * const ref = useFocusReturn() 3894 * return ( 3895 * <div ref={ ref }> 3896 * <Button /> 3897 * <Button /> 3898 * </div> 3899 * ); 3900 * } 3901 * ``` 3902 */ 3903 function useFocusReturn(onFocusReturn) { 3904 /** @type {import('react').MutableRefObject<null | HTMLElement>} */ 3905 const ref = (0,external_wp_element_namespaceObject.useRef)(null); 3906 /** @type {import('react').MutableRefObject<null | Element>} */ 3907 const focusedBeforeMount = (0,external_wp_element_namespaceObject.useRef)(null); 3908 const onFocusReturnRef = (0,external_wp_element_namespaceObject.useRef)(onFocusReturn); 3909 (0,external_wp_element_namespaceObject.useEffect)(() => { 3910 onFocusReturnRef.current = onFocusReturn; 3911 }, [onFocusReturn]); 3912 return (0,external_wp_element_namespaceObject.useCallback)(node => { 3913 if (node) { 3914 var _activeDocument$activ; 3915 // Set ref to be used when unmounting. 3916 ref.current = node; 3917 3918 // Only set when the node mounts. 3919 if (focusedBeforeMount.current) { 3920 return; 3921 } 3922 const activeDocument = node.ownerDocument.activeElement instanceof window.HTMLIFrameElement ? node.ownerDocument.activeElement.contentDocument : node.ownerDocument; 3923 focusedBeforeMount.current = (_activeDocument$activ = activeDocument?.activeElement) !== null && _activeDocument$activ !== void 0 ? _activeDocument$activ : null; 3924 } else if (focusedBeforeMount.current) { 3925 const isFocused = ref.current?.contains(ref.current?.ownerDocument.activeElement); 3926 if (ref.current?.isConnected && !isFocused) { 3927 var _origin; 3928 (_origin = origin) !== null && _origin !== void 0 ? _origin : origin = focusedBeforeMount.current; 3929 return; 3930 } 3931 3932 // Defer to the component's own explicit focus return behavior, if 3933 // specified. This allows for support that the `onFocusReturn` 3934 // decides to allow the default behavior to occur under some 3935 // conditions. 3936 if (onFocusReturnRef.current) { 3937 onFocusReturnRef.current(); 3938 } else { 3939 /** @type {null|HTMLElement} */(!focusedBeforeMount.current.isConnected ? origin : focusedBeforeMount.current)?.focus(); 3940 } 3941 origin = null; 3942 } 3943 }, []); 3944 } 3945 /* harmony default export */ const use_focus_return = (useFocusReturn); 3946 3947 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js 3948 /** 3949 * WordPress dependencies 3950 */ 3951 3952 3953 /** 3954 * Input types which are classified as button types, for use in considering 3955 * whether element is a (focus-normalized) button. 3956 */ 3957 const INPUT_BUTTON_TYPES = ['button', 'submit']; 3958 3959 /** 3960 * List of HTML button elements subject to focus normalization 3961 * 3962 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 3963 */ 3964 3965 /** 3966 * Returns true if the given element is a button element subject to focus 3967 * normalization, or false otherwise. 3968 * 3969 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 3970 * 3971 * @param eventTarget The target from a mouse or touch event. 3972 * 3973 * @return Whether the element is a button element subject to focus normalization. 3974 */ 3975 function isFocusNormalizedButton(eventTarget) { 3976 if (!(eventTarget instanceof window.HTMLElement)) { 3977 return false; 3978 } 3979 switch (eventTarget.nodeName) { 3980 case 'A': 3981 case 'BUTTON': 3982 return true; 3983 case 'INPUT': 3984 return INPUT_BUTTON_TYPES.includes(eventTarget.type); 3985 } 3986 return false; 3987 } 3988 /** 3989 * A react hook that can be used to check whether focus has moved outside the 3990 * element the event handlers are bound to. 3991 * 3992 * @param onFocusOutside A callback triggered when focus moves outside 3993 * the element the event handlers are bound to. 3994 * 3995 * @return An object containing event handlers. Bind the event handlers to a 3996 * wrapping element element to capture when focus moves outside that element. 3997 */ 3998 function useFocusOutside(onFocusOutside) { 3999 const currentOnFocusOutsideRef = (0,external_wp_element_namespaceObject.useRef)(onFocusOutside); 4000 (0,external_wp_element_namespaceObject.useEffect)(() => { 4001 currentOnFocusOutsideRef.current = onFocusOutside; 4002 }, [onFocusOutside]); 4003 const preventBlurCheckRef = (0,external_wp_element_namespaceObject.useRef)(false); 4004 const blurCheckTimeoutIdRef = (0,external_wp_element_namespaceObject.useRef)(); 4005 4006 /** 4007 * Cancel a blur check timeout. 4008 */ 4009 const cancelBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(() => { 4010 clearTimeout(blurCheckTimeoutIdRef.current); 4011 }, []); 4012 4013 // Cancel blur checks on unmount. 4014 (0,external_wp_element_namespaceObject.useEffect)(() => { 4015 return () => cancelBlurCheck(); 4016 }, []); 4017 4018 // Cancel a blur check if the callback or ref is no longer provided. 4019 (0,external_wp_element_namespaceObject.useEffect)(() => { 4020 if (!onFocusOutside) { 4021 cancelBlurCheck(); 4022 } 4023 }, [onFocusOutside, cancelBlurCheck]); 4024 4025 /** 4026 * Handles a mousedown or mouseup event to respectively assign and 4027 * unassign a flag for preventing blur check on button elements. Some 4028 * browsers, namely Firefox and Safari, do not emit a focus event on 4029 * button elements when clicked, while others do. The logic here 4030 * intends to normalize this as treating click on buttons as focus. 4031 * 4032 * @param event 4033 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 4034 */ 4035 const normalizeButtonFocus = (0,external_wp_element_namespaceObject.useCallback)(event => { 4036 const { 4037 type, 4038 target 4039 } = event; 4040 const isInteractionEnd = ['mouseup', 'touchend'].includes(type); 4041 if (isInteractionEnd) { 4042 preventBlurCheckRef.current = false; 4043 } else if (isFocusNormalizedButton(target)) { 4044 preventBlurCheckRef.current = true; 4045 } 4046 }, []); 4047 4048 /** 4049 * A callback triggered when a blur event occurs on the element the handler 4050 * is bound to. 4051 * 4052 * Calls the `onFocusOutside` callback in an immediate timeout if focus has 4053 * move outside the bound element and is still within the document. 4054 */ 4055 const queueBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(event => { 4056 // React does not allow using an event reference asynchronously 4057 // due to recycling behavior, except when explicitly persisted. 4058 event.persist(); 4059 4060 // Skip blur check if clicking button. See `normalizeButtonFocus`. 4061 if (preventBlurCheckRef.current) { 4062 return; 4063 } 4064 4065 // The usage of this attribute should be avoided. The only use case 4066 // would be when we load modals that are not React components and 4067 // therefore don't exist in the React tree. An example is opening 4068 // the Media Library modal from another dialog. 4069 // This attribute should contain a selector of the related target 4070 // we want to ignore, because we still need to trigger the blur event 4071 // on all other cases. 4072 const ignoreForRelatedTarget = event.target.getAttribute('data-unstable-ignore-focus-outside-for-relatedtarget'); 4073 if (ignoreForRelatedTarget && event.relatedTarget?.closest(ignoreForRelatedTarget)) { 4074 return; 4075 } 4076 blurCheckTimeoutIdRef.current = setTimeout(() => { 4077 // If document is not focused then focus should remain 4078 // inside the wrapped component and therefore we cancel 4079 // this blur event thereby leaving focus in place. 4080 // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus. 4081 if (!document.hasFocus()) { 4082 event.preventDefault(); 4083 return; 4084 } 4085 if ('function' === typeof currentOnFocusOutsideRef.current) { 4086 currentOnFocusOutsideRef.current(event); 4087 } 4088 }, 0); 4089 }, []); 4090 return { 4091 onFocus: cancelBlurCheck, 4092 onMouseDown: normalizeButtonFocus, 4093 onMouseUp: normalizeButtonFocus, 4094 onTouchStart: normalizeButtonFocus, 4095 onTouchEnd: normalizeButtonFocus, 4096 onBlur: queueBlurCheck 4097 }; 4098 } 4099 4100 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-merge-refs/index.js 4101 /** 4102 * WordPress dependencies 4103 */ 4104 4105 4106 /* eslint-disable jsdoc/valid-types */ 4107 /** 4108 * @template T 4109 * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef 4110 */ 4111 /* eslint-enable jsdoc/valid-types */ 4112 4113 /** 4114 * @template T 4115 * @param {import('react').Ref<T>} ref 4116 * @param {T} value 4117 */ 4118 function assignRef(ref, value) { 4119 if (typeof ref === 'function') { 4120 ref(value); 4121 } else if (ref && ref.hasOwnProperty('current')) { 4122 /* eslint-disable jsdoc/no-undefined-types */ 4123 /** @type {import('react').MutableRefObject<T>} */ref.current = value; 4124 /* eslint-enable jsdoc/no-undefined-types */ 4125 } 4126 } 4127 4128 /** 4129 * Merges refs into one ref callback. 4130 * 4131 * It also ensures that the merged ref callbacks are only called when they 4132 * change (as a result of a `useCallback` dependency update) OR when the ref 4133 * value changes, just as React does when passing a single ref callback to the 4134 * component. 4135 * 4136 * As expected, if you pass a new function on every render, the ref callback 4137 * will be called after every render. 4138 * 4139 * If you don't wish a ref callback to be called after every render, wrap it 4140 * with `useCallback( callback, dependencies )`. When a dependency changes, the 4141 * old ref callback will be called with `null` and the new ref callback will be 4142 * called with the same value. 4143 * 4144 * To make ref callbacks easier to use, you can also pass the result of 4145 * `useRefEffect`, which makes cleanup easier by allowing you to return a 4146 * cleanup function instead of handling `null`. 4147 * 4148 * It's also possible to _disable_ a ref (and its behaviour) by simply not 4149 * passing the ref. 4150 * 4151 * ```jsx 4152 * const ref = useRefEffect( ( node ) => { 4153 * node.addEventListener( ... ); 4154 * return () => { 4155 * node.removeEventListener( ... ); 4156 * }; 4157 * }, [ ...dependencies ] ); 4158 * const otherRef = useRef(); 4159 * const mergedRefs useMergeRefs( [ 4160 * enabled && ref, 4161 * otherRef, 4162 * ] ); 4163 * return <div ref={ mergedRefs } />; 4164 * ``` 4165 * 4166 * @template {import('react').Ref<any>} TRef 4167 * @param {Array<TRef>} refs The refs to be merged. 4168 * 4169 * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback. 4170 */ 4171 function useMergeRefs(refs) { 4172 const element = (0,external_wp_element_namespaceObject.useRef)(); 4173 const isAttachedRef = (0,external_wp_element_namespaceObject.useRef)(false); 4174 const didElementChangeRef = (0,external_wp_element_namespaceObject.useRef)(false); 4175 /* eslint-disable jsdoc/no-undefined-types */ 4176 /** @type {import('react').MutableRefObject<TRef[]>} */ 4177 /* eslint-enable jsdoc/no-undefined-types */ 4178 const previousRefsRef = (0,external_wp_element_namespaceObject.useRef)([]); 4179 const currentRefsRef = (0,external_wp_element_namespaceObject.useRef)(refs); 4180 4181 // Update on render before the ref callback is called, so the ref callback 4182 // always has access to the current refs. 4183 currentRefsRef.current = refs; 4184 4185 // If any of the refs change, call the previous ref with `null` and the new 4186 // ref with the node, except when the element changes in the same cycle, in 4187 // which case the ref callbacks will already have been called. 4188 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 4189 if (didElementChangeRef.current === false && isAttachedRef.current === true) { 4190 refs.forEach((ref, index) => { 4191 const previousRef = previousRefsRef.current[index]; 4192 if (ref !== previousRef) { 4193 assignRef(previousRef, null); 4194 assignRef(ref, element.current); 4195 } 4196 }); 4197 } 4198 previousRefsRef.current = refs; 4199 }, refs); 4200 4201 // No dependencies, must be reset after every render so ref callbacks are 4202 // correctly called after a ref change. 4203 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 4204 didElementChangeRef.current = false; 4205 }); 4206 4207 // There should be no dependencies so that `callback` is only called when 4208 // the node changes. 4209 return (0,external_wp_element_namespaceObject.useCallback)(value => { 4210 // Update the element so it can be used when calling ref callbacks on a 4211 // dependency change. 4212 assignRef(element, value); 4213 didElementChangeRef.current = true; 4214 isAttachedRef.current = value !== null; 4215 4216 // When an element changes, the current ref callback should be called 4217 // with the new element and the previous one with `null`. 4218 const refsToAssign = value ? currentRefsRef.current : previousRefsRef.current; 4219 4220 // Update the latest refs. 4221 for (const ref of refsToAssign) { 4222 assignRef(ref, value); 4223 } 4224 }, []); 4225 } 4226 4227 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js 4228 /** 4229 * External dependencies 4230 */ 4231 4232 /** 4233 * WordPress dependencies 4234 */ 4235 4236 4237 4238 /** 4239 * Internal dependencies 4240 */ 4241 4242 4243 4244 4245 4246 /** 4247 * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors: 4248 * - constrained tabbing. 4249 * - focus on mount. 4250 * - return focus on unmount. 4251 * - focus outside. 4252 * 4253 * @param options Dialog Options. 4254 */ 4255 function useDialog(options) { 4256 const currentOptions = (0,external_wp_element_namespaceObject.useRef)(); 4257 const { 4258 constrainTabbing = options.focusOnMount !== false 4259 } = options; 4260 (0,external_wp_element_namespaceObject.useEffect)(() => { 4261 currentOptions.current = options; 4262 }, Object.values(options)); 4263 const constrainedTabbingRef = use_constrained_tabbing(); 4264 const focusOnMountRef = useFocusOnMount(options.focusOnMount); 4265 const focusReturnRef = use_focus_return(); 4266 const focusOutsideProps = useFocusOutside(event => { 4267 // This unstable prop is here only to manage backward compatibility 4268 // for the Popover component otherwise, the onClose should be enough. 4269 if (currentOptions.current?.__unstableOnClose) { 4270 currentOptions.current.__unstableOnClose('focus-outside', event); 4271 } else if (currentOptions.current?.onClose) { 4272 currentOptions.current.onClose(); 4273 } 4274 }); 4275 const closeOnEscapeRef = (0,external_wp_element_namespaceObject.useCallback)(node => { 4276 if (!node) { 4277 return; 4278 } 4279 node.addEventListener('keydown', event => { 4280 // Close on escape. 4281 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) { 4282 event.preventDefault(); 4283 currentOptions.current.onClose(); 4284 } 4285 }); 4286 }, []); 4287 return [useMergeRefs([constrainTabbing ? constrainedTabbingRef : null, options.focusOnMount !== false ? focusReturnRef : null, options.focusOnMount !== false ? focusOnMountRef : null, closeOnEscapeRef]), { 4288 ...focusOutsideProps, 4289 tabIndex: -1 4290 }]; 4291 } 4292 /* harmony default export */ const use_dialog = (useDialog); 4293 4294 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-disabled/index.js 4295 /** 4296 * Internal dependencies 4297 */ 4298 4299 4300 4301 /** 4302 * In some circumstances, such as block previews, all focusable DOM elements 4303 * (input fields, links, buttons, etc.) need to be disabled. This hook adds the 4304 * behavior to disable nested DOM elements to the returned ref. 4305 * 4306 * If you can, prefer the use of the inert HTML attribute. 4307 * 4308 * @param {Object} config Configuration object. 4309 * @param {boolean=} config.isDisabled Whether the element should be disabled. 4310 * @return {import('react').RefCallback<HTMLElement>} Element Ref. 4311 * 4312 * @example 4313 * ```js 4314 * import { useDisabled } from '@wordpress/compose'; 4315 * 4316 * const DisabledExample = () => { 4317 * const disabledRef = useDisabled(); 4318 * return ( 4319 * <div ref={ disabledRef }> 4320 * <a href="#">This link will have tabindex set to -1</a> 4321 * <input placeholder="This input will have the disabled attribute added to it." type="text" /> 4322 * </div> 4323 * ); 4324 * }; 4325 * ``` 4326 */ 4327 function useDisabled({ 4328 isDisabled: isDisabledProp = false 4329 } = {}) { 4330 return useRefEffect(node => { 4331 if (isDisabledProp) { 4332 return; 4333 } 4334 const defaultView = node?.ownerDocument?.defaultView; 4335 if (!defaultView) { 4336 return; 4337 } 4338 4339 /** A variable keeping track of the previous updates in order to restore them. */ 4340 const updates = []; 4341 const disable = () => { 4342 node.childNodes.forEach(child => { 4343 if (!(child instanceof defaultView.HTMLElement)) { 4344 return; 4345 } 4346 if (!child.getAttribute('inert')) { 4347 child.setAttribute('inert', 'true'); 4348 updates.push(() => { 4349 child.removeAttribute('inert'); 4350 }); 4351 } 4352 }); 4353 }; 4354 4355 // Debounce re-disable since disabling process itself will incur 4356 // additional mutations which should be ignored. 4357 const debouncedDisable = debounce(disable, 0, { 4358 leading: true 4359 }); 4360 disable(); 4361 4362 /** @type {MutationObserver | undefined} */ 4363 const observer = new window.MutationObserver(debouncedDisable); 4364 observer.observe(node, { 4365 childList: true 4366 }); 4367 return () => { 4368 if (observer) { 4369 observer.disconnect(); 4370 } 4371 debouncedDisable.cancel(); 4372 updates.forEach(update => update()); 4373 }; 4374 }, [isDisabledProp]); 4375 } 4376 4377 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-event/index.js 4378 /** 4379 * WordPress dependencies 4380 */ 4381 4382 4383 /** 4384 * Any function. 4385 */ 4386 4387 /** 4388 * Creates a stable callback function that has access to the latest state and 4389 * can be used within event handlers and effect callbacks. Throws when used in 4390 * the render phase. 4391 * 4392 * @param callback The callback function to wrap. 4393 * 4394 * @example 4395 * 4396 * ```tsx 4397 * function Component( props ) { 4398 * const onClick = useEvent( props.onClick ); 4399 * useEffect( () => { 4400 * onClick(); 4401 * // Won't trigger the effect again when props.onClick is updated. 4402 * }, [ onClick ] ); 4403 * // Won't re-render Button when props.onClick is updated (if `Button` is 4404 * // wrapped in `React.memo`). 4405 * return <Button onClick={ onClick } />; 4406 * } 4407 * ``` 4408 */ 4409 function useEvent( 4410 /** 4411 * The callback function to wrap. 4412 */ 4413 callback) { 4414 const ref = (0,external_wp_element_namespaceObject.useRef)(() => { 4415 throw new Error('Callbacks created with `useEvent` cannot be called during rendering.'); 4416 }); 4417 (0,external_wp_element_namespaceObject.useInsertionEffect)(() => { 4418 ref.current = callback; 4419 }); 4420 return (0,external_wp_element_namespaceObject.useCallback)((...args) => ref.current?.(...args), []); 4421 } 4422 4423 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-isomorphic-layout-effect/index.js 4424 /** 4425 * WordPress dependencies 4426 */ 4427 4428 4429 /** 4430 * Preferred over direct usage of `useLayoutEffect` when supporting 4431 * server rendered components (SSR) because currently React 4432 * throws a warning when using useLayoutEffect in that environment. 4433 */ 4434 const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_wp_element_namespaceObject.useLayoutEffect : external_wp_element_namespaceObject.useEffect; 4435 /* harmony default export */ const use_isomorphic_layout_effect = (useIsomorphicLayoutEffect); 4436 4437 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js 4438 /** 4439 * WordPress dependencies 4440 */ 4441 4442 4443 /** 4444 * Internal dependencies 4445 */ 4446 4447 4448 // Event handlers that are triggered from `document` listeners accept a MouseEvent, 4449 // while those triggered from React listeners accept a React.MouseEvent. 4450 /** 4451 * @param {Object} props 4452 * @param {(e: import('react').MouseEvent) => void} props.onDragStart 4453 * @param {(e: MouseEvent) => void} props.onDragMove 4454 * @param {(e?: MouseEvent) => void} props.onDragEnd 4455 */ 4456 function useDragging({ 4457 onDragStart, 4458 onDragMove, 4459 onDragEnd 4460 }) { 4461 const [isDragging, setIsDragging] = (0,external_wp_element_namespaceObject.useState)(false); 4462 const eventsRef = (0,external_wp_element_namespaceObject.useRef)({ 4463 onDragStart, 4464 onDragMove, 4465 onDragEnd 4466 }); 4467 use_isomorphic_layout_effect(() => { 4468 eventsRef.current.onDragStart = onDragStart; 4469 eventsRef.current.onDragMove = onDragMove; 4470 eventsRef.current.onDragEnd = onDragEnd; 4471 }, [onDragStart, onDragMove, onDragEnd]); 4472 4473 /** @type {(e: MouseEvent) => void} */ 4474 const onMouseMove = (0,external_wp_element_namespaceObject.useCallback)(event => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event), []); 4475 /** @type {(e?: MouseEvent) => void} */ 4476 const endDrag = (0,external_wp_element_namespaceObject.useCallback)(event => { 4477 if (eventsRef.current.onDragEnd) { 4478 eventsRef.current.onDragEnd(event); 4479 } 4480 document.removeEventListener('mousemove', onMouseMove); 4481 document.removeEventListener('mouseup', endDrag); 4482 setIsDragging(false); 4483 }, []); 4484 /** @type {(e: import('react').MouseEvent) => void} */ 4485 const startDrag = (0,external_wp_element_namespaceObject.useCallback)(event => { 4486 if (eventsRef.current.onDragStart) { 4487 eventsRef.current.onDragStart(event); 4488 } 4489 document.addEventListener('mousemove', onMouseMove); 4490 document.addEventListener('mouseup', endDrag); 4491 setIsDragging(true); 4492 }, []); 4493 4494 // Remove the global events when unmounting if needed. 4495 (0,external_wp_element_namespaceObject.useEffect)(() => { 4496 return () => { 4497 if (isDragging) { 4498 document.removeEventListener('mousemove', onMouseMove); 4499 document.removeEventListener('mouseup', endDrag); 4500 } 4501 }; 4502 }, [isDragging]); 4503 return { 4504 startDrag, 4505 endDrag, 4506 isDragging 4507 }; 4508 } 4509 4510 // EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js 4511 var mousetrap_mousetrap = __webpack_require__(1933); 4512 var mousetrap_default = /*#__PURE__*/__webpack_require__.n(mousetrap_mousetrap); 4513 // EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js 4514 var mousetrap_global_bind = __webpack_require__(5760); 4515 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js 4516 /** 4517 * External dependencies 4518 */ 4519 4520 4521 4522 /** 4523 * WordPress dependencies 4524 */ 4525 4526 4527 4528 /** 4529 * A block selection object. 4530 * 4531 * @typedef {Object} WPKeyboardShortcutConfig 4532 * 4533 * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields. 4534 * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown. 4535 * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true. 4536 * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event. 4537 */ 4538 4539 /* eslint-disable jsdoc/valid-types */ 4540 /** 4541 * Attach a keyboard shortcut handler. 4542 * 4543 * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter. 4544 * 4545 * @param {string[]|string} shortcuts Keyboard Shortcuts. 4546 * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback. 4547 * @param {WPKeyboardShortcutConfig} options Shortcut options. 4548 */ 4549 function useKeyboardShortcut(/* eslint-enable jsdoc/valid-types */ 4550 shortcuts, callback, { 4551 bindGlobal = false, 4552 eventName = 'keydown', 4553 isDisabled = false, 4554 // This is important for performance considerations. 4555 target 4556 } = {}) { 4557 const currentCallbackRef = (0,external_wp_element_namespaceObject.useRef)(callback); 4558 (0,external_wp_element_namespaceObject.useEffect)(() => { 4559 currentCallbackRef.current = callback; 4560 }, [callback]); 4561 (0,external_wp_element_namespaceObject.useEffect)(() => { 4562 if (isDisabled) { 4563 return; 4564 } 4565 const mousetrap = new (mousetrap_default())(target && target.current ? target.current : 4566 // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`. 4567 // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's 4568 // necessary to maintain the existing behavior. 4569 /** @type {Element} */ /** @type {unknown} */ 4570 document); 4571 const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts]; 4572 shortcutsArray.forEach(shortcut => { 4573 const keys = shortcut.split('+'); 4574 // Determines whether a key is a modifier by the length of the string. 4575 // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that 4576 // the modifiers are Shift and Cmd because they're not a single character. 4577 const modifiers = new Set(keys.filter(value => value.length > 1)); 4578 const hasAlt = modifiers.has('alt'); 4579 const hasShift = modifiers.has('shift'); 4580 4581 // This should be better moved to the shortcut registration instead. 4582 if ((0,external_wp_keycodes_namespaceObject.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) { 4583 throw new Error(`Cannot bind $shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`); 4584 } 4585 const bindFn = bindGlobal ? 'bindGlobal' : 'bind'; 4586 // @ts-ignore `bindGlobal` is an undocumented property 4587 mousetrap[bindFn](shortcut, (/* eslint-disable jsdoc/valid-types */ 4588 /** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */...args) => /* eslint-enable jsdoc/valid-types */ 4589 currentCallbackRef.current(...args), eventName); 4590 }); 4591 return () => { 4592 mousetrap.reset(); 4593 }; 4594 }, [shortcuts, bindGlobal, eventName, target, isDisabled]); 4595 } 4596 /* harmony default export */ const use_keyboard_shortcut = (useKeyboardShortcut); 4597 4598 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js 4599 /** 4600 * WordPress dependencies 4601 */ 4602 4603 const matchMediaCache = new Map(); 4604 4605 /** 4606 * A new MediaQueryList object for the media query 4607 * 4608 * @param {string} [query] Media Query. 4609 * @return {MediaQueryList|null} A new object for the media query 4610 */ 4611 function getMediaQueryList(query) { 4612 if (!query) { 4613 return null; 4614 } 4615 let match = matchMediaCache.get(query); 4616 if (match) { 4617 return match; 4618 } 4619 if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') { 4620 match = window.matchMedia(query); 4621 matchMediaCache.set(query, match); 4622 return match; 4623 } 4624 return null; 4625 } 4626 4627 /** 4628 * Runs a media query and returns its value when it changes. 4629 * 4630 * @param {string} [query] Media Query. 4631 * @return {boolean} return value of the media query. 4632 */ 4633 function useMediaQuery(query) { 4634 const source = (0,external_wp_element_namespaceObject.useMemo)(() => { 4635 const mediaQueryList = getMediaQueryList(query); 4636 return { 4637 /** @type {(onStoreChange: () => void) => () => void} */ 4638 subscribe(onStoreChange) { 4639 if (!mediaQueryList) { 4640 return () => {}; 4641 } 4642 4643 // Avoid a fatal error when browsers don't support `addEventListener` on MediaQueryList. 4644 mediaQueryList.addEventListener?.('change', onStoreChange); 4645 return () => { 4646 mediaQueryList.removeEventListener?.('change', onStoreChange); 4647 }; 4648 }, 4649 getValue() { 4650 var _mediaQueryList$match; 4651 return (_mediaQueryList$match = mediaQueryList?.matches) !== null && _mediaQueryList$match !== void 0 ? _mediaQueryList$match : false; 4652 } 4653 }; 4654 }, [query]); 4655 return (0,external_wp_element_namespaceObject.useSyncExternalStore)(source.subscribe, source.getValue, () => false); 4656 } 4657 4658 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js 4659 /** 4660 * WordPress dependencies 4661 */ 4662 4663 4664 /** 4665 * Use something's value from the previous render. 4666 * Based on https://usehooks.com/usePrevious/. 4667 * 4668 * @param value The value to track. 4669 * 4670 * @return The value from the previous render. 4671 */ 4672 function usePrevious(value) { 4673 const ref = (0,external_wp_element_namespaceObject.useRef)(); 4674 4675 // Store current value in ref. 4676 (0,external_wp_element_namespaceObject.useEffect)(() => { 4677 ref.current = value; 4678 }, [value]); // Re-run when value changes. 4679 4680 // Return previous value (happens before update in useEffect above). 4681 return ref.current; 4682 } 4683 4684 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js 4685 /** 4686 * Internal dependencies 4687 */ 4688 4689 4690 /** 4691 * Hook returning whether the user has a preference for reduced motion. 4692 * 4693 * @return {boolean} Reduced motion preference value. 4694 */ 4695 const useReducedMotion = () => useMediaQuery('(prefers-reduced-motion: reduce)'); 4696 /* harmony default export */ const use_reduced_motion = (useReducedMotion); 4697 4698 ;// ./node_modules/@wordpress/undo-manager/build-module/index.js 4699 /** 4700 * WordPress dependencies 4701 */ 4702 4703 4704 /** @typedef {import('./types').HistoryRecord} HistoryRecord */ 4705 /** @typedef {import('./types').HistoryChange} HistoryChange */ 4706 /** @typedef {import('./types').HistoryChanges} HistoryChanges */ 4707 /** @typedef {import('./types').UndoManager} UndoManager */ 4708 4709 /** 4710 * Merge changes for a single item into a record of changes. 4711 * 4712 * @param {Record< string, HistoryChange >} changes1 Previous changes 4713 * @param {Record< string, HistoryChange >} changes2 NextChanges 4714 * 4715 * @return {Record< string, HistoryChange >} Merged changes 4716 */ 4717 function mergeHistoryChanges(changes1, changes2) { 4718 /** 4719 * @type {Record< string, HistoryChange >} 4720 */ 4721 const newChanges = { 4722 ...changes1 4723 }; 4724 Object.entries(changes2).forEach(([key, value]) => { 4725 if (newChanges[key]) { 4726 newChanges[key] = { 4727 ...newChanges[key], 4728 to: value.to 4729 }; 4730 } else { 4731 newChanges[key] = value; 4732 } 4733 }); 4734 return newChanges; 4735 } 4736 4737 /** 4738 * Adds history changes for a single item into a record of changes. 4739 * 4740 * @param {HistoryRecord} record The record to merge into. 4741 * @param {HistoryChanges} changes The changes to merge. 4742 */ 4743 const addHistoryChangesIntoRecord = (record, changes) => { 4744 const existingChangesIndex = record?.findIndex(({ 4745 id: recordIdentifier 4746 }) => { 4747 return typeof recordIdentifier === 'string' ? recordIdentifier === changes.id : external_wp_isShallowEqual_default()(recordIdentifier, changes.id); 4748 }); 4749 const nextRecord = [...record]; 4750 if (existingChangesIndex !== -1) { 4751 // If the edit is already in the stack leave the initial "from" value. 4752 nextRecord[existingChangesIndex] = { 4753 id: changes.id, 4754 changes: mergeHistoryChanges(nextRecord[existingChangesIndex].changes, changes.changes) 4755 }; 4756 } else { 4757 nextRecord.push(changes); 4758 } 4759 return nextRecord; 4760 }; 4761 4762 /** 4763 * Creates an undo manager. 4764 * 4765 * @return {UndoManager} Undo manager. 4766 */ 4767 function createUndoManager() { 4768 /** 4769 * @type {HistoryRecord[]} 4770 */ 4771 let history = []; 4772 /** 4773 * @type {HistoryRecord} 4774 */ 4775 let stagedRecord = []; 4776 /** 4777 * @type {number} 4778 */ 4779 let offset = 0; 4780 const dropPendingRedos = () => { 4781 history = history.slice(0, offset || undefined); 4782 offset = 0; 4783 }; 4784 const appendStagedRecordToLatestHistoryRecord = () => { 4785 var _history$index; 4786 const index = history.length === 0 ? 0 : history.length - 1; 4787 let latestRecord = (_history$index = history[index]) !== null && _history$index !== void 0 ? _history$index : []; 4788 stagedRecord.forEach(changes => { 4789 latestRecord = addHistoryChangesIntoRecord(latestRecord, changes); 4790 }); 4791 stagedRecord = []; 4792 history[index] = latestRecord; 4793 }; 4794 4795 /** 4796 * Checks whether a record is empty. 4797 * A record is considered empty if it the changes keep the same values. 4798 * Also updates to function values are ignored. 4799 * 4800 * @param {HistoryRecord} record 4801 * @return {boolean} Whether the record is empty. 4802 */ 4803 const isRecordEmpty = record => { 4804 const filteredRecord = record.filter(({ 4805 changes 4806 }) => { 4807 return Object.values(changes).some(({ 4808 from, 4809 to 4810 }) => typeof from !== 'function' && typeof to !== 'function' && !external_wp_isShallowEqual_default()(from, to)); 4811 }); 4812 return !filteredRecord.length; 4813 }; 4814 return { 4815 /** 4816 * Record changes into the history. 4817 * 4818 * @param {HistoryRecord=} record A record of changes to record. 4819 * @param {boolean} isStaged Whether to immediately create an undo point or not. 4820 */ 4821 addRecord(record, isStaged = false) { 4822 const isEmpty = !record || isRecordEmpty(record); 4823 if (isStaged) { 4824 if (isEmpty) { 4825 return; 4826 } 4827 record.forEach(changes => { 4828 stagedRecord = addHistoryChangesIntoRecord(stagedRecord, changes); 4829 }); 4830 } else { 4831 dropPendingRedos(); 4832 if (stagedRecord.length) { 4833 appendStagedRecordToLatestHistoryRecord(); 4834 } 4835 if (isEmpty) { 4836 return; 4837 } 4838 history.push(record); 4839 } 4840 }, 4841 undo() { 4842 if (stagedRecord.length) { 4843 dropPendingRedos(); 4844 appendStagedRecordToLatestHistoryRecord(); 4845 } 4846 const undoRecord = history[history.length - 1 + offset]; 4847 if (!undoRecord) { 4848 return; 4849 } 4850 offset -= 1; 4851 return undoRecord; 4852 }, 4853 redo() { 4854 const redoRecord = history[history.length + offset]; 4855 if (!redoRecord) { 4856 return; 4857 } 4858 offset += 1; 4859 return redoRecord; 4860 }, 4861 hasUndo() { 4862 return !!history[history.length - 1 + offset]; 4863 }, 4864 hasRedo() { 4865 return !!history[history.length + offset]; 4866 } 4867 }; 4868 } 4869 4870 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-state-with-history/index.js 4871 /** 4872 * WordPress dependencies 4873 */ 4874 4875 4876 function undoRedoReducer(state, action) { 4877 switch (action.type) { 4878 case 'UNDO': 4879 { 4880 const undoRecord = state.manager.undo(); 4881 if (undoRecord) { 4882 return { 4883 ...state, 4884 value: undoRecord[0].changes.prop.from 4885 }; 4886 } 4887 return state; 4888 } 4889 case 'REDO': 4890 { 4891 const redoRecord = state.manager.redo(); 4892 if (redoRecord) { 4893 return { 4894 ...state, 4895 value: redoRecord[0].changes.prop.to 4896 }; 4897 } 4898 return state; 4899 } 4900 case 'RECORD': 4901 { 4902 state.manager.addRecord([{ 4903 id: 'object', 4904 changes: { 4905 prop: { 4906 from: state.value, 4907 to: action.value 4908 } 4909 } 4910 }], action.isStaged); 4911 return { 4912 ...state, 4913 value: action.value 4914 }; 4915 } 4916 } 4917 return state; 4918 } 4919 function initReducer(value) { 4920 return { 4921 manager: createUndoManager(), 4922 value 4923 }; 4924 } 4925 4926 /** 4927 * useState with undo/redo history. 4928 * 4929 * @param initialValue Initial value. 4930 * @return Value, setValue, hasUndo, hasRedo, undo, redo. 4931 */ 4932 function useStateWithHistory(initialValue) { 4933 const [state, dispatch] = (0,external_wp_element_namespaceObject.useReducer)(undoRedoReducer, initialValue, initReducer); 4934 return { 4935 value: state.value, 4936 setValue: (0,external_wp_element_namespaceObject.useCallback)((newValue, isStaged) => { 4937 dispatch({ 4938 type: 'RECORD', 4939 value: newValue, 4940 isStaged 4941 }); 4942 }, []), 4943 hasUndo: state.manager.hasUndo(), 4944 hasRedo: state.manager.hasRedo(), 4945 undo: (0,external_wp_element_namespaceObject.useCallback)(() => { 4946 dispatch({ 4947 type: 'UNDO' 4948 }); 4949 }, []), 4950 redo: (0,external_wp_element_namespaceObject.useCallback)(() => { 4951 dispatch({ 4952 type: 'REDO' 4953 }); 4954 }, []) 4955 }; 4956 } 4957 4958 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js 4959 /** 4960 * WordPress dependencies 4961 */ 4962 4963 4964 /** 4965 * Internal dependencies 4966 */ 4967 4968 4969 /** 4970 * @typedef {"xhuge" | "huge" | "wide" | "xlarge" | "large" | "medium" | "small" | "mobile"} WPBreakpoint 4971 */ 4972 4973 /** 4974 * Hash of breakpoint names with pixel width at which it becomes effective. 4975 * 4976 * @see _breakpoints.scss 4977 * 4978 * @type {Record<WPBreakpoint, number>} 4979 */ 4980 const BREAKPOINTS = { 4981 xhuge: 1920, 4982 huge: 1440, 4983 wide: 1280, 4984 xlarge: 1080, 4985 large: 960, 4986 medium: 782, 4987 small: 600, 4988 mobile: 480 4989 }; 4990 4991 /** 4992 * @typedef {">=" | "<"} WPViewportOperator 4993 */ 4994 4995 /** 4996 * Object mapping media query operators to the condition to be used. 4997 * 4998 * @type {Record<WPViewportOperator, string>} 4999 */ 5000 const CONDITIONS = { 5001 '>=': 'min-width', 5002 '<': 'max-width' 5003 }; 5004 5005 /** 5006 * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values. 5007 * 5008 * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>} 5009 */ 5010 const OPERATOR_EVALUATORS = { 5011 '>=': (breakpointValue, width) => width >= breakpointValue, 5012 '<': (breakpointValue, width) => width < breakpointValue 5013 }; 5014 const ViewportMatchWidthContext = (0,external_wp_element_namespaceObject.createContext)(/** @type {null | number} */null); 5015 5016 /** 5017 * Returns true if the viewport matches the given query, or false otherwise. 5018 * 5019 * @param {WPBreakpoint} breakpoint Breakpoint size name. 5020 * @param {WPViewportOperator} [operator=">="] Viewport operator. 5021 * 5022 * @example 5023 * 5024 * ```js 5025 * useViewportMatch( 'huge', '<' ); 5026 * useViewportMatch( 'medium' ); 5027 * ``` 5028 * 5029 * @return {boolean} Whether viewport matches query. 5030 */ 5031 const useViewportMatch = (breakpoint, operator = '>=') => { 5032 const simulatedWidth = (0,external_wp_element_namespaceObject.useContext)(ViewportMatchWidthContext); 5033 const mediaQuery = !simulatedWidth && `($CONDITIONS[operator]}: $BREAKPOINTS[breakpoint]}px)`; 5034 const mediaQueryResult = useMediaQuery(mediaQuery || undefined); 5035 if (simulatedWidth) { 5036 return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth); 5037 } 5038 return mediaQueryResult; 5039 }; 5040 useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider; 5041 /* harmony default export */ const use_viewport_match = (useViewportMatch); 5042 5043 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/use-resize-observer.js 5044 /** 5045 * WordPress dependencies 5046 */ 5047 5048 /** 5049 * Internal dependencies 5050 */ 5051 5052 5053 // This is the current implementation of `useResizeObserver`. 5054 // 5055 // The legacy implementation is still supported for backwards compatibility. 5056 // This is achieved by overloading the exported function with both signatures, 5057 // and detecting which API is being used at runtime. 5058 function useResizeObserver(callback, resizeObserverOptions = {}) { 5059 const callbackEvent = useEvent(callback); 5060 const observedElementRef = (0,external_wp_element_namespaceObject.useRef)(); 5061 const resizeObserverRef = (0,external_wp_element_namespaceObject.useRef)(); 5062 return useEvent(element => { 5063 var _resizeObserverRef$cu; 5064 if (element === observedElementRef.current) { 5065 return; 5066 } 5067 5068 // Set up `ResizeObserver`. 5069 (_resizeObserverRef$cu = resizeObserverRef.current) !== null && _resizeObserverRef$cu !== void 0 ? _resizeObserverRef$cu : resizeObserverRef.current = new ResizeObserver(callbackEvent); 5070 const { 5071 current: resizeObserver 5072 } = resizeObserverRef; 5073 5074 // Unobserve previous element. 5075 if (observedElementRef.current) { 5076 resizeObserver.unobserve(observedElementRef.current); 5077 } 5078 5079 // Observe new element. 5080 observedElementRef.current = element; 5081 if (element) { 5082 resizeObserver.observe(element, resizeObserverOptions); 5083 } 5084 }); 5085 } 5086 5087 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/legacy/index.js 5088 /** 5089 * External dependencies 5090 */ 5091 5092 /** 5093 * WordPress dependencies 5094 */ 5095 5096 /** 5097 * Internal dependencies 5098 */ 5099 5100 5101 // We're only using the first element of the size sequences, until future versions of the spec solidify on how 5102 // exactly it'll be used for fragments in multi-column scenarios: 5103 // From the spec: 5104 // > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments, 5105 // > which occur in multi-column scenarios. However the current definitions of content rect and border box do not 5106 // > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single 5107 // > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column. 5108 // > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information. 5109 // (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface) 5110 // 5111 // Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback, 5112 // regardless of the "box" option. 5113 // The spec states the following on this: 5114 // > This does not have any impact on which box dimensions are returned to the defined callback when the event 5115 // > is fired, it solely defines which box the author wishes to observe layout changes on. 5116 // (https://drafts.csswg.org/resize-observer/#resize-observer-interface) 5117 // I'm not exactly clear on what this means, especially when you consider a later section stating the following: 5118 // > This section is non-normative. An author may desire to observe more than one CSS box. 5119 // > In this case, author will need to use multiple ResizeObservers. 5120 // (https://drafts.csswg.org/resize-observer/#resize-observer-interface) 5121 // Which is clearly not how current browser implementations behave, and seems to contradict the previous quote. 5122 // For this reason I decided to only return the requested size, 5123 // even though it seems we have access to results for all box types. 5124 // This also means that we get to keep the current api, being able to return a simple { width, height } pair, 5125 // regardless of box option. 5126 const extractSize = entry => { 5127 let entrySize; 5128 if (!entry.contentBoxSize) { 5129 // The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec. 5130 // See the 6th step in the description for the RO algorithm: 5131 // https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h 5132 // > Set this.contentRect to logical this.contentBoxSize given target and observedBox of "content-box". 5133 // In real browser implementations of course these objects differ, but the width/height values should be equivalent. 5134 entrySize = [entry.contentRect.width, entry.contentRect.height]; 5135 } else if (entry.contentBoxSize[0]) { 5136 const contentBoxSize = entry.contentBoxSize[0]; 5137 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize]; 5138 } else { 5139 // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's buggy 5140 // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`. 5141 const contentBoxSize = entry.contentBoxSize; 5142 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize]; 5143 } 5144 const [width, height] = entrySize.map(d => Math.round(d)); 5145 return { 5146 width, 5147 height 5148 }; 5149 }; 5150 const RESIZE_ELEMENT_STYLES = { 5151 position: 'absolute', 5152 top: 0, 5153 left: 0, 5154 right: 0, 5155 bottom: 0, 5156 pointerEvents: 'none', 5157 opacity: 0, 5158 overflow: 'hidden', 5159 zIndex: -1 5160 }; 5161 function ResizeElement({ 5162 onResize 5163 }) { 5164 const resizeElementRef = useResizeObserver(entries => { 5165 const newSize = extractSize(entries.at(-1)); // Entries are never empty. 5166 onResize(newSize); 5167 }); 5168 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 5169 ref: resizeElementRef, 5170 style: RESIZE_ELEMENT_STYLES, 5171 "aria-hidden": "true" 5172 }); 5173 } 5174 function sizeEquals(a, b) { 5175 return a.width === b.width && a.height === b.height; 5176 } 5177 const NULL_SIZE = { 5178 width: null, 5179 height: null 5180 }; 5181 5182 /** 5183 * Hook which allows to listen to the resize event of any target element when it changes size. 5184 * _Note: `useResizeObserver` will report `null` sizes until after first render. 5185 * 5186 * @example 5187 * 5188 * ```js 5189 * const App = () => { 5190 * const [ resizeListener, sizes ] = useResizeObserver(); 5191 * 5192 * return ( 5193 * <div> 5194 * { resizeListener } 5195 * Your content here 5196 * </div> 5197 * ); 5198 * }; 5199 * ``` 5200 */ 5201 function useLegacyResizeObserver() { 5202 const [size, setSize] = (0,external_wp_element_namespaceObject.useState)(NULL_SIZE); 5203 5204 // Using a ref to track the previous width / height to avoid unnecessary renders. 5205 const previousSizeRef = (0,external_wp_element_namespaceObject.useRef)(NULL_SIZE); 5206 const handleResize = (0,external_wp_element_namespaceObject.useCallback)(newSize => { 5207 if (!sizeEquals(previousSizeRef.current, newSize)) { 5208 previousSizeRef.current = newSize; 5209 setSize(newSize); 5210 } 5211 }, []); 5212 const resizeElement = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeElement, { 5213 onResize: handleResize 5214 }); 5215 return [resizeElement, size]; 5216 } 5217 5218 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js 5219 /** 5220 * Internal dependencies 5221 */ 5222 5223 5224 /** 5225 * External dependencies 5226 */ 5227 5228 /** 5229 * Sets up a [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Resize_Observer_API) 5230 * for an HTML or SVG element. 5231 * 5232 * Pass the returned setter as a callback ref to the React element you want 5233 * to observe, or use it in layout effects for advanced use cases. 5234 * 5235 * @example 5236 * 5237 * ```tsx 5238 * const setElement = useResizeObserver( 5239 * ( resizeObserverEntries ) => console.log( resizeObserverEntries ), 5240 * { box: 'border-box' } 5241 * ); 5242 * <div ref={ setElement } />; 5243 * 5244 * // The setter can be used in other ways, for example: 5245 * useLayoutEffect( () => { 5246 * setElement( document.querySelector( `data-element-id="${ elementId }"` ) ); 5247 * }, [ elementId ] ); 5248 * ``` 5249 * 5250 * @param callback The `ResizeObserver` callback - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#callback). 5251 * @param options Options passed to `ResizeObserver.observe` when called - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/observe#options). Changes will be ignored. 5252 */ 5253 5254 /** 5255 * **This is a legacy API and should not be used.** 5256 * 5257 * @deprecated Use the other `useResizeObserver` API instead: `const ref = useResizeObserver( ( entries ) => { ... } )`. 5258 * 5259 * Hook which allows to listen to the resize event of any target element when it changes size. 5260 * _Note: `useResizeObserver` will report `null` sizes until after first render. 5261 * 5262 * @example 5263 * 5264 * ```js 5265 * const App = () => { 5266 * const [ resizeListener, sizes ] = useResizeObserver(); 5267 * 5268 * return ( 5269 * <div> 5270 * { resizeListener } 5271 * Your content here 5272 * </div> 5273 * ); 5274 * }; 5275 * ``` 5276 */ 5277 5278 function use_resize_observer_useResizeObserver(callback, options = {}) { 5279 return callback ? useResizeObserver(callback, options) : useLegacyResizeObserver(); 5280 } 5281 5282 ;// external ["wp","priorityQueue"] 5283 const external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"]; 5284 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-async-list/index.js 5285 /** 5286 * WordPress dependencies 5287 */ 5288 5289 5290 /** 5291 * Returns the first items from list that are present on state. 5292 * 5293 * @param list New array. 5294 * @param state Current state. 5295 * @return First items present in state. 5296 */ 5297 function getFirstItemsPresentInState(list, state) { 5298 const firstItems = []; 5299 for (let i = 0; i < list.length; i++) { 5300 const item = list[i]; 5301 if (!state.includes(item)) { 5302 break; 5303 } 5304 firstItems.push(item); 5305 } 5306 return firstItems; 5307 } 5308 5309 /** 5310 * React hook returns an array which items get asynchronously appended from a source array. 5311 * This behavior is useful if we want to render a list of items asynchronously for performance reasons. 5312 * 5313 * @param list Source array. 5314 * @param config Configuration object. 5315 * 5316 * @return Async array. 5317 */ 5318 function useAsyncList(list, config = { 5319 step: 1 5320 }) { 5321 const { 5322 step = 1 5323 } = config; 5324 const [current, setCurrent] = (0,external_wp_element_namespaceObject.useState)([]); 5325 (0,external_wp_element_namespaceObject.useEffect)(() => { 5326 // On reset, we keep the first items that were previously rendered. 5327 let firstItems = getFirstItemsPresentInState(list, current); 5328 if (firstItems.length < step) { 5329 firstItems = firstItems.concat(list.slice(firstItems.length, step)); 5330 } 5331 setCurrent(firstItems); 5332 const asyncQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)(); 5333 for (let i = firstItems.length; i < list.length; i += step) { 5334 asyncQueue.add({}, () => { 5335 (0,external_wp_element_namespaceObject.flushSync)(() => { 5336 setCurrent(state => [...state, ...list.slice(i, i + step)]); 5337 }); 5338 }); 5339 } 5340 return () => asyncQueue.reset(); 5341 }, [list]); 5342 return current; 5343 } 5344 /* harmony default export */ const use_async_list = (useAsyncList); 5345 5346 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-warn-on-change/index.js 5347 /** 5348 * Internal dependencies 5349 */ 5350 5351 5352 // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in this case 5353 // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript 5354 /* eslint-disable jsdoc/check-types */ 5355 /** 5356 * Hook that performs a shallow comparison between the preview value of an object 5357 * and the new one, if there's a difference, it prints it to the console. 5358 * this is useful in performance related work, to check why a component re-renders. 5359 * 5360 * @example 5361 * 5362 * ```jsx 5363 * function MyComponent(props) { 5364 * useWarnOnChange(props); 5365 * 5366 * return "Something"; 5367 * } 5368 * ``` 5369 * 5370 * @param {object} object Object which changes to compare. 5371 * @param {string} prefix Just a prefix to show when console logging. 5372 */ 5373 function useWarnOnChange(object, prefix = 'Change detection') { 5374 const previousValues = usePrevious(object); 5375 Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(([key, value]) => { 5376 if (value !== object[(/** @type {keyof typeof object} */key)]) { 5377 // eslint-disable-next-line no-console 5378 console.warn(`$prefix}: $key} key changed:`, value, object[(/** @type {keyof typeof object} */key)] 5379 /* eslint-enable jsdoc/check-types */); 5380 } 5381 }); 5382 } 5383 /* harmony default export */ const use_warn_on_change = (useWarnOnChange); 5384 5385 ;// external "React" 5386 const external_React_namespaceObject = window["React"]; 5387 ;// ./node_modules/use-memo-one/dist/use-memo-one.esm.js 5388 5389 5390 function areInputsEqual(newInputs, lastInputs) { 5391 if (newInputs.length !== lastInputs.length) { 5392 return false; 5393 } 5394 5395 for (var i = 0; i < newInputs.length; i++) { 5396 if (newInputs[i] !== lastInputs[i]) { 5397 return false; 5398 } 5399 } 5400 5401 return true; 5402 } 5403 5404 function useMemoOne(getResult, inputs) { 5405 var initial = (0,external_React_namespaceObject.useState)(function () { 5406 return { 5407 inputs: inputs, 5408 result: getResult() 5409 }; 5410 })[0]; 5411 var isFirstRun = (0,external_React_namespaceObject.useRef)(true); 5412 var committed = (0,external_React_namespaceObject.useRef)(initial); 5413 var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); 5414 var cache = useCache ? committed.current : { 5415 inputs: inputs, 5416 result: getResult() 5417 }; 5418 (0,external_React_namespaceObject.useEffect)(function () { 5419 isFirstRun.current = false; 5420 committed.current = cache; 5421 }, [cache]); 5422 return cache.result; 5423 } 5424 function useCallbackOne(callback, inputs) { 5425 return useMemoOne(function () { 5426 return callback; 5427 }, inputs); 5428 } 5429 var useMemo = (/* unused pure expression or super */ null && (useMemoOne)); 5430 var useCallback = (/* unused pure expression or super */ null && (useCallbackOne)); 5431 5432 5433 5434 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-debounce/index.js 5435 /** 5436 * External dependencies 5437 */ 5438 5439 5440 /** 5441 * WordPress dependencies 5442 */ 5443 5444 5445 /** 5446 * Internal dependencies 5447 */ 5448 5449 5450 /** 5451 * Debounces a function similar to Lodash's `debounce`. A new debounced function will 5452 * be returned and any scheduled calls cancelled if any of the arguments change, 5453 * including the function to debounce, so please wrap functions created on 5454 * render in components in `useCallback`. 5455 * 5456 * @see https://lodash.com/docs/4#debounce 5457 * 5458 * @template {(...args: any[]) => void} TFunc 5459 * 5460 * @param {TFunc} fn The function to debounce. 5461 * @param {number} [wait] The number of milliseconds to delay. 5462 * @param {import('../../utils/debounce').DebounceOptions} [options] The options object. 5463 * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Debounced function. 5464 */ 5465 function useDebounce(fn, wait, options) { 5466 const debounced = useMemoOne(() => debounce(fn, wait !== null && wait !== void 0 ? wait : 0, options), [fn, wait, options]); 5467 (0,external_wp_element_namespaceObject.useEffect)(() => () => debounced.cancel(), [debounced]); 5468 return debounced; 5469 } 5470 5471 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-debounced-input/index.js 5472 /** 5473 * WordPress dependencies 5474 */ 5475 5476 5477 /** 5478 * Internal dependencies 5479 */ 5480 5481 5482 /** 5483 * Helper hook for input fields that need to debounce the value before using it. 5484 * 5485 * @param defaultValue The default value to use. 5486 * @return The input value, the setter and the debounced input value. 5487 */ 5488 function useDebouncedInput(defaultValue = '') { 5489 const [input, setInput] = (0,external_wp_element_namespaceObject.useState)(defaultValue); 5490 const [debouncedInput, setDebouncedState] = (0,external_wp_element_namespaceObject.useState)(defaultValue); 5491 const setDebouncedInput = useDebounce(setDebouncedState, 250); 5492 (0,external_wp_element_namespaceObject.useEffect)(() => { 5493 setDebouncedInput(input); 5494 }, [input, setDebouncedInput]); 5495 return [input, setInput, debouncedInput]; 5496 } 5497 5498 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-throttle/index.js 5499 /** 5500 * External dependencies 5501 */ 5502 5503 5504 /** 5505 * WordPress dependencies 5506 */ 5507 5508 5509 /** 5510 * Internal dependencies 5511 */ 5512 5513 5514 /** 5515 * Throttles a function similar to Lodash's `throttle`. A new throttled function will 5516 * be returned and any scheduled calls cancelled if any of the arguments change, 5517 * including the function to throttle, so please wrap functions created on 5518 * render in components in `useCallback`. 5519 * 5520 * @see https://lodash.com/docs/4#throttle 5521 * 5522 * @template {(...args: any[]) => void} TFunc 5523 * 5524 * @param {TFunc} fn The function to throttle. 5525 * @param {number} [wait] The number of milliseconds to throttle invocations to. 5526 * @param {import('../../utils/throttle').ThrottleOptions} [options] The options object. See linked documentation for details. 5527 * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Throttled function. 5528 */ 5529 function useThrottle(fn, wait, options) { 5530 const throttled = useMemoOne(() => throttle(fn, wait !== null && wait !== void 0 ? wait : 0, options), [fn, wait, options]); 5531 (0,external_wp_element_namespaceObject.useEffect)(() => () => throttled.cancel(), [throttled]); 5532 return throttled; 5533 } 5534 5535 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-drop-zone/index.js 5536 /** 5537 * Internal dependencies 5538 */ 5539 5540 5541 5542 /** 5543 * A hook to facilitate drag and drop handling. 5544 * 5545 * @param {Object} props Named parameters. 5546 * @param {?HTMLElement} [props.dropZoneElement] Optional element to be used as the drop zone. 5547 * @param {boolean} [props.isDisabled] Whether or not to disable the drop zone. 5548 * @param {(e: DragEvent) => void} [props.onDragStart] Called when dragging has started. 5549 * @param {(e: DragEvent) => void} [props.onDragEnter] Called when the zone is entered. 5550 * @param {(e: DragEvent) => void} [props.onDragOver] Called when the zone is moved within. 5551 * @param {(e: DragEvent) => void} [props.onDragLeave] Called when the zone is left. 5552 * @param {(e: MouseEvent) => void} [props.onDragEnd] Called when dragging has ended. 5553 * @param {(e: DragEvent) => void} [props.onDrop] Called when dropping in the zone. 5554 * 5555 * @return {import('react').RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element. 5556 */ 5557 function useDropZone({ 5558 dropZoneElement, 5559 isDisabled, 5560 onDrop: _onDrop, 5561 onDragStart: _onDragStart, 5562 onDragEnter: _onDragEnter, 5563 onDragLeave: _onDragLeave, 5564 onDragEnd: _onDragEnd, 5565 onDragOver: _onDragOver 5566 }) { 5567 const onDropEvent = useEvent(_onDrop); 5568 const onDragStartEvent = useEvent(_onDragStart); 5569 const onDragEnterEvent = useEvent(_onDragEnter); 5570 const onDragLeaveEvent = useEvent(_onDragLeave); 5571 const onDragEndEvent = useEvent(_onDragEnd); 5572 const onDragOverEvent = useEvent(_onDragOver); 5573 return useRefEffect(elem => { 5574 if (isDisabled) { 5575 return; 5576 } 5577 5578 // If a custom dropZoneRef is passed, use that instead of the element. 5579 // This allows the dropzone to cover an expanded area, rather than 5580 // be restricted to the area of the ref returned by this hook. 5581 const element = dropZoneElement !== null && dropZoneElement !== void 0 ? dropZoneElement : elem; 5582 let isDragging = false; 5583 const { 5584 ownerDocument 5585 } = element; 5586 5587 /** 5588 * Checks if an element is in the drop zone. 5589 * 5590 * @param {EventTarget|null} targetToCheck 5591 * 5592 * @return {boolean} True if in drop zone, false if not. 5593 */ 5594 function isElementInZone(targetToCheck) { 5595 const { 5596 defaultView 5597 } = ownerDocument; 5598 if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) { 5599 return false; 5600 } 5601 5602 /** @type {HTMLElement|null} */ 5603 let elementToCheck = targetToCheck; 5604 do { 5605 if (elementToCheck.dataset.isDropZone) { 5606 return elementToCheck === element; 5607 } 5608 } while (elementToCheck = elementToCheck.parentElement); 5609 return false; 5610 } 5611 function maybeDragStart(/** @type {DragEvent} */event) { 5612 if (isDragging) { 5613 return; 5614 } 5615 isDragging = true; 5616 5617 // Note that `dragend` doesn't fire consistently for file and 5618 // HTML drag events where the drag origin is outside the browser 5619 // window. In Firefox it may also not fire if the originating 5620 // node is removed. 5621 ownerDocument.addEventListener('dragend', maybeDragEnd); 5622 ownerDocument.addEventListener('mousemove', maybeDragEnd); 5623 if (_onDragStart) { 5624 onDragStartEvent(event); 5625 } 5626 } 5627 function onDragEnter(/** @type {DragEvent} */event) { 5628 event.preventDefault(); 5629 5630 // The `dragenter` event will also fire when entering child 5631 // elements, but we only want to call `onDragEnter` when 5632 // entering the drop zone, which means the `relatedTarget` 5633 // (element that has been left) should be outside the drop zone. 5634 if (element.contains(/** @type {Node} */event.relatedTarget)) { 5635 return; 5636 } 5637 if (_onDragEnter) { 5638 onDragEnterEvent(event); 5639 } 5640 } 5641 function onDragOver(/** @type {DragEvent} */event) { 5642 // Only call onDragOver for the innermost hovered drop zones. 5643 if (!event.defaultPrevented && _onDragOver) { 5644 onDragOverEvent(event); 5645 } 5646 5647 // Prevent the browser default while also signalling to parent 5648 // drop zones that `onDragOver` is already handled. 5649 event.preventDefault(); 5650 } 5651 function onDragLeave(/** @type {DragEvent} */event) { 5652 // The `dragleave` event will also fire when leaving child 5653 // elements, but we only want to call `onDragLeave` when 5654 // leaving the drop zone, which means the `relatedTarget` 5655 // (element that has been entered) should be outside the drop 5656 // zone. 5657 // Note: This is not entirely reliable in Safari due to this bug 5658 // https://bugs.webkit.org/show_bug.cgi?id=66547 5659 5660 if (isElementInZone(event.relatedTarget)) { 5661 return; 5662 } 5663 if (_onDragLeave) { 5664 onDragLeaveEvent(event); 5665 } 5666 } 5667 function onDrop(/** @type {DragEvent} */event) { 5668 // Don't handle drop if an inner drop zone already handled it. 5669 if (event.defaultPrevented) { 5670 return; 5671 } 5672 5673 // Prevent the browser default while also signalling to parent 5674 // drop zones that `onDrop` is already handled. 5675 event.preventDefault(); 5676 5677 // This seemingly useless line has been shown to resolve a 5678 // Safari issue where files dragged directly from the dock are 5679 // not recognized. 5680 // eslint-disable-next-line no-unused-expressions 5681 event.dataTransfer && event.dataTransfer.files.length; 5682 if (_onDrop) { 5683 onDropEvent(event); 5684 } 5685 maybeDragEnd(event); 5686 } 5687 function maybeDragEnd(/** @type {MouseEvent} */event) { 5688 if (!isDragging) { 5689 return; 5690 } 5691 isDragging = false; 5692 ownerDocument.removeEventListener('dragend', maybeDragEnd); 5693 ownerDocument.removeEventListener('mousemove', maybeDragEnd); 5694 if (_onDragEnd) { 5695 onDragEndEvent(event); 5696 } 5697 } 5698 element.setAttribute('data-is-drop-zone', 'true'); 5699 element.addEventListener('drop', onDrop); 5700 element.addEventListener('dragenter', onDragEnter); 5701 element.addEventListener('dragover', onDragOver); 5702 element.addEventListener('dragleave', onDragLeave); 5703 // The `dragstart` event doesn't fire if the drag started outside 5704 // the document. 5705 ownerDocument.addEventListener('dragenter', maybeDragStart); 5706 return () => { 5707 element.removeAttribute('data-is-drop-zone'); 5708 element.removeEventListener('drop', onDrop); 5709 element.removeEventListener('dragenter', onDragEnter); 5710 element.removeEventListener('dragover', onDragOver); 5711 element.removeEventListener('dragleave', onDragLeave); 5712 ownerDocument.removeEventListener('dragend', maybeDragEnd); 5713 ownerDocument.removeEventListener('mousemove', maybeDragEnd); 5714 ownerDocument.removeEventListener('dragenter', maybeDragStart); 5715 }; 5716 }, [isDisabled, dropZoneElement] // Refresh when the passed in dropZoneElement changes. 5717 ); 5718 } 5719 5720 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-focusable-iframe/index.js 5721 /** 5722 * External dependencies 5723 */ 5724 5725 /** 5726 * Internal dependencies 5727 */ 5728 5729 5730 /** 5731 * Dispatches a bubbling focus event when the iframe receives focus. Use 5732 * `onFocus` as usual on the iframe or a parent element. 5733 * 5734 * @return Ref to pass to the iframe. 5735 */ 5736 function useFocusableIframe() { 5737 return useRefEffect(element => { 5738 const { 5739 ownerDocument 5740 } = element; 5741 if (!ownerDocument) { 5742 return; 5743 } 5744 const { 5745 defaultView 5746 } = ownerDocument; 5747 if (!defaultView) { 5748 return; 5749 } 5750 5751 /** 5752 * Checks whether the iframe is the activeElement, inferring that it has 5753 * then received focus, and dispatches a focus event. 5754 */ 5755 function checkFocus() { 5756 if (ownerDocument && ownerDocument.activeElement === element) { 5757 element.focus(); 5758 } 5759 } 5760 defaultView.addEventListener('blur', checkFocus); 5761 return () => { 5762 defaultView.removeEventListener('blur', checkFocus); 5763 }; 5764 }, []); 5765 } 5766 5767 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-fixed-window-list/index.js 5768 /** 5769 * WordPress dependencies 5770 */ 5771 5772 5773 5774 5775 /** 5776 * Internal dependencies 5777 */ 5778 5779 const DEFAULT_INIT_WINDOW_SIZE = 30; 5780 5781 /** 5782 * @typedef {Object} WPFixedWindowList 5783 * 5784 * @property {number} visibleItems Items visible in the current viewport 5785 * @property {number} start Start index of the window 5786 * @property {number} end End index of the window 5787 * @property {(index:number)=>boolean} itemInView Returns true if item is in the window 5788 */ 5789 5790 /** 5791 * @typedef {Object} WPFixedWindowListOptions 5792 * 5793 * @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window. 5794 * @property {boolean} [useWindowing] When false avoids calculating the window size 5795 * @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size. 5796 * @property {any} [expandedState] Used to recalculate the window size when the expanded state of a list changes. 5797 */ 5798 5799 /** 5800 * 5801 * @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element. 5802 * @param { number } itemHeight Fixed item height in pixels 5803 * @param { number } totalItems Total items in list 5804 * @param { WPFixedWindowListOptions } [options] Options object 5805 * @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter 5806 */ 5807 function useFixedWindowList(elementRef, itemHeight, totalItems, options) { 5808 var _options$initWindowSi, _options$useWindowing; 5809 const initWindowSize = (_options$initWindowSi = options?.initWindowSize) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT_INIT_WINDOW_SIZE; 5810 const useWindowing = (_options$useWindowing = options?.useWindowing) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true; 5811 const [fixedListWindow, setFixedListWindow] = (0,external_wp_element_namespaceObject.useState)({ 5812 visibleItems: initWindowSize, 5813 start: 0, 5814 end: initWindowSize, 5815 itemInView: (/** @type {number} */index) => { 5816 return index >= 0 && index <= initWindowSize; 5817 } 5818 }); 5819 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 5820 if (!useWindowing) { 5821 return; 5822 } 5823 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); 5824 const measureWindow = (/** @type {boolean | undefined} */initRender) => { 5825 var _options$windowOversc; 5826 if (!scrollContainer) { 5827 return; 5828 } 5829 const visibleItems = Math.ceil(scrollContainer.clientHeight / itemHeight); 5830 // Aim to keep opening list view fast, afterward we can optimize for scrolling. 5831 const windowOverscan = initRender ? visibleItems : (_options$windowOversc = options?.windowOverscan) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems; 5832 const firstViewableIndex = Math.floor(scrollContainer.scrollTop / itemHeight); 5833 const start = Math.max(0, firstViewableIndex - windowOverscan); 5834 const end = Math.min(totalItems - 1, firstViewableIndex + visibleItems + windowOverscan); 5835 setFixedListWindow(lastWindow => { 5836 const nextWindow = { 5837 visibleItems, 5838 start, 5839 end, 5840 itemInView: (/** @type {number} */index) => { 5841 return start <= index && index <= end; 5842 } 5843 }; 5844 if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) { 5845 return nextWindow; 5846 } 5847 return lastWindow; 5848 }); 5849 }; 5850 measureWindow(true); 5851 const debounceMeasureList = debounce(() => { 5852 measureWindow(); 5853 }, 16); 5854 scrollContainer?.addEventListener('scroll', debounceMeasureList); 5855 scrollContainer?.ownerDocument?.defaultView?.addEventListener('resize', debounceMeasureList); 5856 scrollContainer?.ownerDocument?.defaultView?.addEventListener('resize', debounceMeasureList); 5857 return () => { 5858 scrollContainer?.removeEventListener('scroll', debounceMeasureList); 5859 scrollContainer?.ownerDocument?.defaultView?.removeEventListener('resize', debounceMeasureList); 5860 }; 5861 }, [itemHeight, elementRef, totalItems, options?.expandedState, options?.windowOverscan, useWindowing]); 5862 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 5863 if (!useWindowing) { 5864 return; 5865 } 5866 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); 5867 const handleKeyDown = (/** @type {KeyboardEvent} */event) => { 5868 switch (event.keyCode) { 5869 case external_wp_keycodes_namespaceObject.HOME: 5870 { 5871 return scrollContainer?.scrollTo({ 5872 top: 0 5873 }); 5874 } 5875 case external_wp_keycodes_namespaceObject.END: 5876 { 5877 return scrollContainer?.scrollTo({ 5878 top: totalItems * itemHeight 5879 }); 5880 } 5881 case external_wp_keycodes_namespaceObject.PAGEUP: 5882 { 5883 return scrollContainer?.scrollTo({ 5884 top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight 5885 }); 5886 } 5887 case external_wp_keycodes_namespaceObject.PAGEDOWN: 5888 { 5889 return scrollContainer?.scrollTo({ 5890 top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight 5891 }); 5892 } 5893 } 5894 }; 5895 scrollContainer?.ownerDocument?.defaultView?.addEventListener('keydown', handleKeyDown); 5896 return () => { 5897 scrollContainer?.ownerDocument?.defaultView?.removeEventListener('keydown', handleKeyDown); 5898 }; 5899 }, [totalItems, itemHeight, elementRef, fixedListWindow.visibleItems, useWindowing, options?.expandedState]); 5900 return [fixedListWindow, setFixedListWindow]; 5901 } 5902 5903 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-observable-value/index.js 5904 /** 5905 * WordPress dependencies 5906 */ 5907 5908 5909 /** 5910 * Internal dependencies 5911 */ 5912 5913 /** 5914 * React hook that lets you observe an entry in an `ObservableMap`. The hook returns the 5915 * current value corresponding to the key, or `undefined` when there is no value stored. 5916 * It also observes changes to the value and triggers an update of the calling component 5917 * in case the value changes. 5918 * 5919 * @template K The type of the keys in the map. 5920 * @template V The type of the values in the map. 5921 * @param map The `ObservableMap` to observe. 5922 * @param name The map key to observe. 5923 * @return The value corresponding to the map key requested. 5924 */ 5925 function useObservableValue(map, name) { 5926 const [subscribe, getValue] = (0,external_wp_element_namespaceObject.useMemo)(() => [listener => map.subscribe(name, listener), () => map.get(name)], [map, name]); 5927 return (0,external_wp_element_namespaceObject.useSyncExternalStore)(subscribe, getValue, getValue); 5928 } 5929 5930 ;// ./node_modules/@wordpress/compose/build-module/index.js 5931 // The `createHigherOrderComponent` helper and helper types. 5932 5933 // The `debounce` helper and its types. 5934 5935 // The `throttle` helper and its types. 5936 5937 // The `ObservableMap` data structure 5938 5939 5940 // The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash). 5941 5942 5943 5944 // Higher-order components. 5945 5946 5947 5948 5949 5950 5951 5952 // Hooks. 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 })(); 5985 5986 (window.wp = window.wp || {}).compose = __webpack_exports__; 5987 /******/ })() 5988 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sun Mar 9 08:20:01 2025 | Cross-referenced by PHPXref |