| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 "use strict"; 2 var wp; 3 (wp ||= {}).compose = (() => { 4 var __create = Object.create; 5 var __defProp = Object.defineProperty; 6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 7 var __getOwnPropNames = Object.getOwnPropertyNames; 8 var __getProtoOf = Object.getPrototypeOf; 9 var __hasOwnProp = Object.prototype.hasOwnProperty; 10 var __commonJS = (cb, mod) => function __require() { 11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 12 }; 13 var __export = (target, all) => { 14 for (var name in all) 15 __defProp(target, name, { get: all[name], enumerable: true }); 16 }; 17 var __copyProps = (to, from, except, desc) => { 18 if (from && typeof from === "object" || typeof from === "function") { 19 for (let key of __getOwnPropNames(from)) 20 if (!__hasOwnProp.call(to, key) && key !== except) 21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 22 } 23 return to; 24 }; 25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 26 // If the importer is in node compatibility mode or this is not an ESM 27 // file that has been converted to a CommonJS file using a Babel- 28 // compatible transform (i.e. "__esModule" has not been set), then set 29 // "default" to the CommonJS "module.exports" for node compatibility. 30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 31 mod 32 )); 33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 34 35 // package-external:@wordpress/private-apis 36 var require_private_apis = __commonJS({ 37 "package-external:@wordpress/private-apis"(exports, module) { 38 module.exports = window.wp.privateApis; 39 } 40 }); 41 42 // vendor-external:react/jsx-runtime 43 var require_jsx_runtime = __commonJS({ 44 "vendor-external:react/jsx-runtime"(exports, module) { 45 module.exports = window.ReactJSXRuntime; 46 } 47 }); 48 49 // package-external:@wordpress/is-shallow-equal 50 var require_is_shallow_equal = __commonJS({ 51 "package-external:@wordpress/is-shallow-equal"(exports, module) { 52 module.exports = window.wp.isShallowEqual; 53 } 54 }); 55 56 // package-external:@wordpress/element 57 var require_element = __commonJS({ 58 "package-external:@wordpress/element"(exports, module) { 59 module.exports = window.wp.element; 60 } 61 }); 62 63 // package-external:@wordpress/deprecated 64 var require_deprecated = __commonJS({ 65 "package-external:@wordpress/deprecated"(exports, module) { 66 module.exports = window.wp.deprecated; 67 } 68 }); 69 70 // package-external:@wordpress/dom 71 var require_dom = __commonJS({ 72 "package-external:@wordpress/dom"(exports, module) { 73 module.exports = window.wp.dom; 74 } 75 }); 76 77 // node_modules/mousetrap/mousetrap.js 78 var require_mousetrap = __commonJS({ 79 "node_modules/mousetrap/mousetrap.js"(exports, module) { 80 (function(window2, document2, undefined2) { 81 if (!window2) { 82 return; 83 } 84 var _MAP = { 85 8: "backspace", 86 9: "tab", 87 13: "enter", 88 16: "shift", 89 17: "ctrl", 90 18: "alt", 91 20: "capslock", 92 27: "esc", 93 32: "space", 94 33: "pageup", 95 34: "pagedown", 96 35: "end", 97 36: "home", 98 37: "left", 99 38: "up", 100 39: "right", 101 40: "down", 102 45: "ins", 103 46: "del", 104 91: "meta", 105 93: "meta", 106 224: "meta" 107 }; 108 var _KEYCODE_MAP = { 109 106: "*", 110 107: "+", 111 109: "-", 112 110: ".", 113 111: "/", 114 186: ";", 115 187: "=", 116 188: ",", 117 189: "-", 118 190: ".", 119 191: "/", 120 192: "`", 121 219: "[", 122 220: "\\", 123 221: "]", 124 222: "'" 125 }; 126 var _SHIFT_MAP = { 127 "~": "`", 128 "!": "1", 129 "@": "2", 130 "#": "3", 131 "$": "4", 132 "%": "5", 133 "^": "6", 134 "&": "7", 135 "*": "8", 136 "(": "9", 137 ")": "0", 138 "_": "-", 139 "+": "=", 140 ":": ";", 141 '"': "'", 142 "<": ",", 143 ">": ".", 144 "?": "/", 145 "|": "\\" 146 }; 147 var _SPECIAL_ALIASES = { 148 "option": "alt", 149 "command": "meta", 150 "return": "enter", 151 "escape": "esc", 152 "plus": "+", 153 "mod": /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? "meta" : "ctrl" 154 }; 155 var _REVERSE_MAP; 156 for (var i = 1; i < 20; ++i) { 157 _MAP[111 + i] = "f" + i; 158 } 159 for (i = 0; i <= 9; ++i) { 160 _MAP[i + 96] = i.toString(); 161 } 162 function _addEvent(object, type, callback) { 163 if (object.addEventListener) { 164 object.addEventListener(type, callback, false); 165 return; 166 } 167 object.attachEvent("on" + type, callback); 168 } 169 function _characterFromEvent(e) { 170 if (e.type == "keypress") { 171 var character = String.fromCharCode(e.which); 172 if (!e.shiftKey) { 173 character = character.toLowerCase(); 174 } 175 return character; 176 } 177 if (_MAP[e.which]) { 178 return _MAP[e.which]; 179 } 180 if (_KEYCODE_MAP[e.which]) { 181 return _KEYCODE_MAP[e.which]; 182 } 183 return String.fromCharCode(e.which).toLowerCase(); 184 } 185 function _modifiersMatch(modifiers1, modifiers2) { 186 return modifiers1.sort().join(",") === modifiers2.sort().join(","); 187 } 188 function _eventModifiers(e) { 189 var modifiers = []; 190 if (e.shiftKey) { 191 modifiers.push("shift"); 192 } 193 if (e.altKey) { 194 modifiers.push("alt"); 195 } 196 if (e.ctrlKey) { 197 modifiers.push("ctrl"); 198 } 199 if (e.metaKey) { 200 modifiers.push("meta"); 201 } 202 return modifiers; 203 } 204 function _preventDefault(e) { 205 if (e.preventDefault) { 206 e.preventDefault(); 207 return; 208 } 209 e.returnValue = false; 210 } 211 function _stopPropagation(e) { 212 if (e.stopPropagation) { 213 e.stopPropagation(); 214 return; 215 } 216 e.cancelBubble = true; 217 } 218 function _isModifier(key) { 219 return key == "shift" || key == "ctrl" || key == "alt" || key == "meta"; 220 } 221 function _getReverseMap() { 222 if (!_REVERSE_MAP) { 223 _REVERSE_MAP = {}; 224 for (var key in _MAP) { 225 if (key > 95 && key < 112) { 226 continue; 227 } 228 if (_MAP.hasOwnProperty(key)) { 229 _REVERSE_MAP[_MAP[key]] = key; 230 } 231 } 232 } 233 return _REVERSE_MAP; 234 } 235 function _pickBestAction(key, modifiers, action) { 236 if (!action) { 237 action = _getReverseMap()[key] ? "keydown" : "keypress"; 238 } 239 if (action == "keypress" && modifiers.length) { 240 action = "keydown"; 241 } 242 return action; 243 } 244 function _keysFromString(combination) { 245 if (combination === "+") { 246 return ["+"]; 247 } 248 combination = combination.replace(/\+{2}/g, "+plus"); 249 return combination.split("+"); 250 } 251 function _getKeyInfo(combination, action) { 252 var keys; 253 var key; 254 var i2; 255 var modifiers = []; 256 keys = _keysFromString(combination); 257 for (i2 = 0; i2 < keys.length; ++i2) { 258 key = keys[i2]; 259 if (_SPECIAL_ALIASES[key]) { 260 key = _SPECIAL_ALIASES[key]; 261 } 262 if (action && action != "keypress" && _SHIFT_MAP[key]) { 263 key = _SHIFT_MAP[key]; 264 modifiers.push("shift"); 265 } 266 if (_isModifier(key)) { 267 modifiers.push(key); 268 } 269 } 270 action = _pickBestAction(key, modifiers, action); 271 return { 272 key, 273 modifiers, 274 action 275 }; 276 } 277 function _belongsTo(element, ancestor) { 278 if (element === null || element === document2) { 279 return false; 280 } 281 if (element === ancestor) { 282 return true; 283 } 284 return _belongsTo(element.parentNode, ancestor); 285 } 286 function Mousetrap3(targetElement) { 287 var self = this; 288 targetElement = targetElement || document2; 289 if (!(self instanceof Mousetrap3)) { 290 return new Mousetrap3(targetElement); 291 } 292 self.target = targetElement; 293 self._callbacks = {}; 294 self._directMap = {}; 295 var _sequenceLevels = {}; 296 var _resetTimer; 297 var _ignoreNextKeyup = false; 298 var _ignoreNextKeypress = false; 299 var _nextExpectedAction = false; 300 function _resetSequences(doNotReset) { 301 doNotReset = doNotReset || {}; 302 var activeSequences = false, key; 303 for (key in _sequenceLevels) { 304 if (doNotReset[key]) { 305 activeSequences = true; 306 continue; 307 } 308 _sequenceLevels[key] = 0; 309 } 310 if (!activeSequences) { 311 _nextExpectedAction = false; 312 } 313 } 314 function _getMatches(character, modifiers, e, sequenceName, combination, level) { 315 var i2; 316 var callback; 317 var matches = []; 318 var action = e.type; 319 if (!self._callbacks[character]) { 320 return []; 321 } 322 if (action == "keyup" && _isModifier(character)) { 323 modifiers = [character]; 324 } 325 for (i2 = 0; i2 < self._callbacks[character].length; ++i2) { 326 callback = self._callbacks[character][i2]; 327 if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) { 328 continue; 329 } 330 if (action != callback.action) { 331 continue; 332 } 333 if (action == "keypress" && !e.metaKey && !e.ctrlKey || _modifiersMatch(modifiers, callback.modifiers)) { 334 var deleteCombo = !sequenceName && callback.combo == combination; 335 var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level; 336 if (deleteCombo || deleteSequence) { 337 self._callbacks[character].splice(i2, 1); 338 } 339 matches.push(callback); 340 } 341 } 342 return matches; 343 } 344 function _fireCallback(callback, e, combo, sequence) { 345 if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) { 346 return; 347 } 348 if (callback(e, combo) === false) { 349 _preventDefault(e); 350 _stopPropagation(e); 351 } 352 } 353 self._handleKey = function(character, modifiers, e) { 354 var callbacks = _getMatches(character, modifiers, e); 355 var i2; 356 var doNotReset = {}; 357 var maxLevel = 0; 358 var processedSequenceCallback = false; 359 for (i2 = 0; i2 < callbacks.length; ++i2) { 360 if (callbacks[i2].seq) { 361 maxLevel = Math.max(maxLevel, callbacks[i2].level); 362 } 363 } 364 for (i2 = 0; i2 < callbacks.length; ++i2) { 365 if (callbacks[i2].seq) { 366 if (callbacks[i2].level != maxLevel) { 367 continue; 368 } 369 processedSequenceCallback = true; 370 doNotReset[callbacks[i2].seq] = 1; 371 _fireCallback(callbacks[i2].callback, e, callbacks[i2].combo, callbacks[i2].seq); 372 continue; 373 } 374 if (!processedSequenceCallback) { 375 _fireCallback(callbacks[i2].callback, e, callbacks[i2].combo); 376 } 377 } 378 var ignoreThisKeypress = e.type == "keypress" && _ignoreNextKeypress; 379 if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) { 380 _resetSequences(doNotReset); 381 } 382 _ignoreNextKeypress = processedSequenceCallback && e.type == "keydown"; 383 }; 384 function _handleKeyEvent(e) { 385 if (typeof e.which !== "number") { 386 e.which = e.keyCode; 387 } 388 var character = _characterFromEvent(e); 389 if (!character) { 390 return; 391 } 392 if (e.type == "keyup" && _ignoreNextKeyup === character) { 393 _ignoreNextKeyup = false; 394 return; 395 } 396 self.handleKey(character, _eventModifiers(e), e); 397 } 398 function _resetSequenceTimer() { 399 clearTimeout(_resetTimer); 400 _resetTimer = setTimeout(_resetSequences, 1e3); 401 } 402 function _bindSequence(combo, keys, callback, action) { 403 _sequenceLevels[combo] = 0; 404 function _increaseSequence(nextAction) { 405 return function() { 406 _nextExpectedAction = nextAction; 407 ++_sequenceLevels[combo]; 408 _resetSequenceTimer(); 409 }; 410 } 411 function _callbackAndReset(e) { 412 _fireCallback(callback, e, combo); 413 if (action !== "keyup") { 414 _ignoreNextKeyup = _characterFromEvent(e); 415 } 416 setTimeout(_resetSequences, 10); 417 } 418 for (var i2 = 0; i2 < keys.length; ++i2) { 419 var isFinal = i2 + 1 === keys.length; 420 var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i2 + 1]).action); 421 _bindSingle(keys[i2], wrappedCallback, action, combo, i2); 422 } 423 } 424 function _bindSingle(combination, callback, action, sequenceName, level) { 425 self._directMap[combination + ":" + action] = callback; 426 combination = combination.replace(/\s+/g, " "); 427 var sequence = combination.split(" "); 428 var info; 429 if (sequence.length > 1) { 430 _bindSequence(combination, sequence, callback, action); 431 return; 432 } 433 info = _getKeyInfo(combination, action); 434 self._callbacks[info.key] = self._callbacks[info.key] || []; 435 _getMatches(info.key, info.modifiers, { type: info.action }, sequenceName, combination, level); 436 self._callbacks[info.key][sequenceName ? "unshift" : "push"]({ 437 callback, 438 modifiers: info.modifiers, 439 action: info.action, 440 seq: sequenceName, 441 level, 442 combo: combination 443 }); 444 } 445 self._bindMultiple = function(combinations, callback, action) { 446 for (var i2 = 0; i2 < combinations.length; ++i2) { 447 _bindSingle(combinations[i2], callback, action); 448 } 449 }; 450 _addEvent(targetElement, "keypress", _handleKeyEvent); 451 _addEvent(targetElement, "keydown", _handleKeyEvent); 452 _addEvent(targetElement, "keyup", _handleKeyEvent); 453 } 454 Mousetrap3.prototype.bind = function(keys, callback, action) { 455 var self = this; 456 keys = keys instanceof Array ? keys : [keys]; 457 self._bindMultiple.call(self, keys, callback, action); 458 return self; 459 }; 460 Mousetrap3.prototype.unbind = function(keys, action) { 461 var self = this; 462 return self.bind.call(self, keys, function() { 463 }, action); 464 }; 465 Mousetrap3.prototype.trigger = function(keys, action) { 466 var self = this; 467 if (self._directMap[keys + ":" + action]) { 468 self._directMap[keys + ":" + action]({}, keys); 469 } 470 return self; 471 }; 472 Mousetrap3.prototype.reset = function() { 473 var self = this; 474 self._callbacks = {}; 475 self._directMap = {}; 476 return self; 477 }; 478 Mousetrap3.prototype.stopCallback = function(e, element) { 479 var self = this; 480 if ((" " + element.className + " ").indexOf(" mousetrap ") > -1) { 481 return false; 482 } 483 if (_belongsTo(element, self.target)) { 484 return false; 485 } 486 if ("composedPath" in e && typeof e.composedPath === "function") { 487 var initialEventTarget = e.composedPath()[0]; 488 if (initialEventTarget !== e.target) { 489 element = initialEventTarget; 490 } 491 } 492 return element.tagName == "INPUT" || element.tagName == "SELECT" || element.tagName == "TEXTAREA" || element.isContentEditable; 493 }; 494 Mousetrap3.prototype.handleKey = function() { 495 var self = this; 496 return self._handleKey.apply(self, arguments); 497 }; 498 Mousetrap3.addKeycodes = function(object) { 499 for (var key in object) { 500 if (object.hasOwnProperty(key)) { 501 _MAP[key] = object[key]; 502 } 503 } 504 _REVERSE_MAP = null; 505 }; 506 Mousetrap3.init = function() { 507 var documentMousetrap = Mousetrap3(document2); 508 for (var method in documentMousetrap) { 509 if (method.charAt(0) !== "_") { 510 Mousetrap3[method] = /* @__PURE__ */ (function(method2) { 511 return function() { 512 return documentMousetrap[method2].apply(documentMousetrap, arguments); 513 }; 514 })(method); 515 } 516 } 517 }; 518 Mousetrap3.init(); 519 window2.Mousetrap = Mousetrap3; 520 if (typeof module !== "undefined" && module.exports) { 521 module.exports = Mousetrap3; 522 } 523 if (typeof define === "function" && define.amd) { 524 define(function() { 525 return Mousetrap3; 526 }); 527 } 528 })(typeof window !== "undefined" ? window : null, typeof window !== "undefined" ? document : null); 529 } 530 }); 531 532 // package-external:@wordpress/keycodes 533 var require_keycodes = __commonJS({ 534 "package-external:@wordpress/keycodes"(exports, module) { 535 module.exports = window.wp.keycodes; 536 } 537 }); 538 539 // package-external:@wordpress/undo-manager 540 var require_undo_manager = __commonJS({ 541 "package-external:@wordpress/undo-manager"(exports, module) { 542 module.exports = window.wp.undoManager; 543 } 544 }); 545 546 // package-external:@wordpress/priority-queue 547 var require_priority_queue = __commonJS({ 548 "package-external:@wordpress/priority-queue"(exports, module) { 549 module.exports = window.wp.priorityQueue; 550 } 551 }); 552 553 // vendor-external:react 554 var require_react = __commonJS({ 555 "vendor-external:react"(exports, module) { 556 module.exports = window.React; 557 } 558 }); 559 560 // packages/compose/build-module/index.mjs 561 var index_exports = {}; 562 __export(index_exports, { 563 __experimentalUseDialog: () => use_dialog_default, 564 __experimentalUseDragging: () => useDragging, 565 __experimentalUseDropZone: () => useDropZone, 566 __experimentalUseFixedWindowList: () => useFixedWindowList, 567 __experimentalUseFocusOutside: () => useFocusOutside, 568 compose: () => compose_default, 569 createHigherOrderComponent: () => createHigherOrderComponent, 570 debounce: () => debounce, 571 ifCondition: () => if_condition_default, 572 observableMap: () => observableMap, 573 pipe: () => pipe_default, 574 privateApis: () => privateApis, 575 pure: () => pure_default, 576 throttle: () => throttle, 577 useAsyncList: () => use_async_list_default, 578 useConstrainedTabbing: () => use_constrained_tabbing_default, 579 useCopyOnClick: () => useCopyOnClick, 580 useCopyToClipboard: () => useCopyToClipboard, 581 useDebounce: () => useDebounce, 582 useDebouncedInput: () => useDebouncedInput, 583 useDisabled: () => useDisabled, 584 useEvent: () => useEvent, 585 useFocusOnMount: () => useFocusOnMount, 586 useFocusReturn: () => use_focus_return_default, 587 useFocusableIframe: () => useFocusableIframe, 588 useInstanceId: () => use_instance_id_default, 589 useIsomorphicLayoutEffect: () => use_isomorphic_layout_effect_default, 590 useKeyboardShortcut: () => use_keyboard_shortcut_default, 591 useMediaQuery: () => useMediaQuery, 592 useMergeRefs: () => useMergeRefs, 593 useObservableValue: () => useObservableValue, 594 usePrevious: () => usePrevious, 595 useReducedMotion: () => use_reduced_motion_default, 596 useRefEffect: () => useRefEffect, 597 useResizeObserver: () => useResizeObserver2, 598 useStateWithHistory: () => useStateWithHistory, 599 useThrottle: () => useThrottle, 600 useViewportMatch: () => use_viewport_match_default, 601 useWarnOnChange: () => use_warn_on_change_default, 602 withGlobalEvents: () => withGlobalEvents, 603 withInstanceId: () => with_instance_id_default, 604 withSafeTimeout: () => with_safe_timeout_default, 605 withState: () => withState 606 }); 607 608 // node_modules/tslib/tslib.es6.mjs 609 var __assign = function() { 610 __assign = Object.assign || function __assign2(t) { 611 for (var s, i = 1, n = arguments.length; i < n; i++) { 612 s = arguments[i]; 613 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 614 } 615 return t; 616 }; 617 return __assign.apply(this, arguments); 618 }; 619 620 // node_modules/lower-case/dist.es2015/index.js 621 function lowerCase(str) { 622 return str.toLowerCase(); 623 } 624 625 // node_modules/no-case/dist.es2015/index.js 626 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 627 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 628 function noCase(input, options) { 629 if (options === void 0) { 630 options = {}; 631 } 632 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; 633 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 634 var start = 0; 635 var end = result.length; 636 while (result.charAt(start) === "\0") 637 start++; 638 while (result.charAt(end - 1) === "\0") 639 end--; 640 return result.slice(start, end).split("\0").map(transform).join(delimiter); 641 } 642 function replace(input, re, value) { 643 if (re instanceof RegExp) 644 return input.replace(re, value); 645 return re.reduce(function(input2, re2) { 646 return input2.replace(re2, value); 647 }, input); 648 } 649 650 // node_modules/pascal-case/dist.es2015/index.js 651 function pascalCaseTransform(input, index) { 652 var firstChar = input.charAt(0); 653 var lowerChars = input.substr(1).toLowerCase(); 654 if (index > 0 && firstChar >= "0" && firstChar <= "9") { 655 return "_" + firstChar + lowerChars; 656 } 657 return "" + firstChar.toUpperCase() + lowerChars; 658 } 659 function pascalCase(input, options) { 660 if (options === void 0) { 661 options = {}; 662 } 663 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); 664 } 665 666 // packages/compose/build-module/utils/create-higher-order-component/index.mjs 667 function createHigherOrderComponent(mapComponent, modifierName) { 668 return (Inner) => { 669 const Outer = mapComponent(Inner); 670 Outer.displayName = hocName(modifierName, Inner); 671 return Outer; 672 }; 673 } 674 var hocName = (name, Inner) => { 675 const inner = Inner.displayName || Inner.name || "Component"; 676 const outer = pascalCase(name ?? ""); 677 return `$outer}($inner})`; 678 }; 679 680 // packages/compose/build-module/utils/debounce/index.mjs 681 var debounce = (func, wait, options) => { 682 let lastArgs; 683 let lastThis; 684 let maxWait = 0; 685 let result; 686 let timerId; 687 let lastCallTime; 688 let lastInvokeTime = 0; 689 let leading = false; 690 let maxing = false; 691 let trailing = true; 692 if (options) { 693 leading = !!options.leading; 694 maxing = "maxWait" in options; 695 if (options.maxWait !== void 0) { 696 maxWait = Math.max(options.maxWait, wait); 697 } 698 trailing = "trailing" in options ? !!options.trailing : trailing; 699 } 700 function invokeFunc(time) { 701 const args = lastArgs; 702 const thisArg = lastThis; 703 lastArgs = void 0; 704 lastThis = void 0; 705 lastInvokeTime = time; 706 result = func.apply(thisArg, args); 707 return result; 708 } 709 function startTimer(pendingFunc, waitTime) { 710 timerId = setTimeout(pendingFunc, waitTime); 711 } 712 function cancelTimer() { 713 if (timerId !== void 0) { 714 clearTimeout(timerId); 715 } 716 } 717 function leadingEdge(time) { 718 lastInvokeTime = time; 719 startTimer(timerExpired, wait); 720 return leading ? invokeFunc(time) : result; 721 } 722 function getTimeSinceLastCall(time) { 723 return time - (lastCallTime || 0); 724 } 725 function remainingWait(time) { 726 const timeSinceLastCall = getTimeSinceLastCall(time); 727 const timeSinceLastInvoke = time - lastInvokeTime; 728 const timeWaiting = wait - timeSinceLastCall; 729 return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting; 730 } 731 function shouldInvoke(time) { 732 const timeSinceLastCall = getTimeSinceLastCall(time); 733 const timeSinceLastInvoke = time - lastInvokeTime; 734 return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; 735 } 736 function timerExpired() { 737 const time = Date.now(); 738 if (shouldInvoke(time)) { 739 return trailingEdge(time); 740 } 741 startTimer(timerExpired, remainingWait(time)); 742 return void 0; 743 } 744 function clearTimer() { 745 timerId = void 0; 746 } 747 function trailingEdge(time) { 748 clearTimer(); 749 if (trailing && lastArgs) { 750 return invokeFunc(time); 751 } 752 lastArgs = lastThis = void 0; 753 return result; 754 } 755 function cancel() { 756 cancelTimer(); 757 lastInvokeTime = 0; 758 clearTimer(); 759 lastArgs = lastCallTime = lastThis = void 0; 760 } 761 function flush() { 762 return pending() ? trailingEdge(Date.now()) : result; 763 } 764 function pending() { 765 return timerId !== void 0; 766 } 767 function debounced(...args) { 768 const time = Date.now(); 769 const isInvoking = shouldInvoke(time); 770 lastArgs = args; 771 lastThis = this; 772 lastCallTime = time; 773 if (isInvoking) { 774 if (!pending()) { 775 return leadingEdge(lastCallTime); 776 } 777 if (maxing) { 778 startTimer(timerExpired, wait); 779 return invokeFunc(lastCallTime); 780 } 781 } 782 if (!pending()) { 783 startTimer(timerExpired, wait); 784 } 785 return result; 786 } 787 debounced.cancel = cancel; 788 debounced.flush = flush; 789 debounced.pending = pending; 790 return debounced; 791 }; 792 793 // packages/compose/build-module/utils/throttle/index.mjs 794 var throttle = (func, wait, options) => { 795 let leading = true; 796 let trailing = true; 797 if (options) { 798 leading = "leading" in options ? !!options.leading : leading; 799 trailing = "trailing" in options ? !!options.trailing : trailing; 800 } 801 return debounce(func, wait, { 802 leading, 803 trailing, 804 maxWait: wait 805 }); 806 }; 807 808 // packages/compose/build-module/utils/observable-map/index.mjs 809 function observableMap() { 810 const map = /* @__PURE__ */ new Map(); 811 const listeners = /* @__PURE__ */ new Map(); 812 function callListeners(name) { 813 const list = listeners.get(name); 814 if (!list) { 815 return; 816 } 817 for (const listener2 of list) { 818 listener2(); 819 } 820 } 821 return { 822 get(name) { 823 return map.get(name); 824 }, 825 set(name, value) { 826 map.set(name, value); 827 callListeners(name); 828 }, 829 delete(name) { 830 map.delete(name); 831 callListeners(name); 832 }, 833 subscribe(name, listener2) { 834 let list = listeners.get(name); 835 if (!list) { 836 list = /* @__PURE__ */ new Set(); 837 listeners.set(name, list); 838 } 839 list.add(listener2); 840 return () => { 841 list.delete(listener2); 842 if (list.size === 0) { 843 listeners.delete(name); 844 } 845 }; 846 } 847 }; 848 } 849 850 // packages/compose/build-module/lock-unlock.mjs 851 var import_private_apis = __toESM(require_private_apis(), 1); 852 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 853 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 854 "@wordpress/compose" 855 ); 856 857 // packages/compose/build-module/utils/subscribe-delegated-listener/index.mjs 858 var registries = /* @__PURE__ */ new WeakMap(); 859 function subscribeDelegatedListener(target, eventType, callback, capture = false) { 860 const ownerDoc = target.ownerDocument; 861 const root = ownerDoc ?? target; 862 const isWindow = ownerDoc === void 0; 863 let perRoot = registries.get(root); 864 if (!perRoot) { 865 perRoot = /* @__PURE__ */ new Map(); 866 registries.set(root, perRoot); 867 } 868 const key = capture ? `$eventType}:capture` : eventType; 869 let perEvent = perRoot.get(key); 870 if (!perEvent) { 871 perEvent = /* @__PURE__ */ new WeakMap(); 872 perRoot.set(key, perEvent); 873 const subscribers = perEvent; 874 root.addEventListener( 875 eventType, 876 (event) => { 877 if (isWindow) { 878 const set2 = subscribers.get(root); 879 if (set2) { 880 for (const cb of set2) { 881 cb(event); 882 } 883 } 884 return; 885 } 886 if (capture) { 887 const path = []; 888 let current = event.target; 889 while (current) { 890 path.push(current); 891 if (current === root) { 892 break; 893 } 894 current = current.parentNode; 895 } 896 for (let i = path.length - 1; i >= 0; i--) { 897 const set2 = subscribers.get(path[i]); 898 if (set2) { 899 for (const cb of set2) { 900 cb(event); 901 } 902 } 903 } 904 } else { 905 let current = event.target; 906 while (current) { 907 const set2 = subscribers.get(current); 908 if (set2) { 909 for (const cb of set2) { 910 cb(event); 911 } 912 } 913 if (current === root) { 914 break; 915 } 916 current = current.parentNode; 917 } 918 } 919 }, 920 capture 921 ); 922 } 923 let set = perEvent.get(target); 924 if (!set) { 925 set = /* @__PURE__ */ new Set(); 926 perEvent.set(target, set); 927 } 928 set.add(callback); 929 return () => { 930 set.delete(callback); 931 }; 932 } 933 934 // packages/compose/build-module/private-apis.mjs 935 var privateApis = {}; 936 lock(privateApis, { 937 subscribeDelegatedListener 938 }); 939 940 // packages/compose/build-module/higher-order/pipe.mjs 941 var basePipe = (reverse = false) => (...funcs) => (...args) => { 942 const functions = funcs.flat(); 943 if (reverse) { 944 functions.reverse(); 945 } 946 return functions.reduce( 947 (prev, func) => [func(...prev)], 948 args 949 )[0]; 950 }; 951 var pipe = basePipe(); 952 var pipe_default = pipe; 953 954 // packages/compose/build-module/higher-order/compose.mjs 955 var compose = basePipe(true); 956 var compose_default = compose; 957 958 // packages/compose/build-module/higher-order/if-condition/index.mjs 959 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 960 function ifCondition(predicate) { 961 return createHigherOrderComponent( 962 (WrappedComponent) => (props) => { 963 if (!predicate(props)) { 964 return null; 965 } 966 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WrappedComponent, { ...props }); 967 }, 968 "ifCondition" 969 ); 970 } 971 var if_condition_default = ifCondition; 972 973 // packages/compose/build-module/higher-order/pure/index.mjs 974 var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1); 975 var import_element = __toESM(require_element(), 1); 976 var import_deprecated = __toESM(require_deprecated(), 1); 977 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 978 var pure = createHigherOrderComponent(function(WrappedComponent) { 979 (0, import_deprecated.default)("wp.compose.pure", { 980 since: "7.1", 981 alternative: "Use `memo` or `PureComponent` instead" 982 }); 983 if (WrappedComponent.prototype instanceof import_element.Component) { 984 return class extends WrappedComponent { 985 shouldComponentUpdate(nextProps, nextState) { 986 return !(0, import_is_shallow_equal.isShallowEqual)(nextProps, this.props) || !(0, import_is_shallow_equal.isShallowEqual)(nextState, this.state); 987 } 988 }; 989 } 990 return class extends import_element.Component { 991 shouldComponentUpdate(nextProps) { 992 return !(0, import_is_shallow_equal.isShallowEqual)(nextProps, this.props); 993 } 994 render() { 995 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WrappedComponent, { ...this.props }); 996 } 997 }; 998 }, "pure"); 999 var pure_default = pure; 1000 1001 // packages/compose/build-module/higher-order/with-global-events/index.mjs 1002 var import_element2 = __toESM(require_element(), 1); 1003 var import_deprecated2 = __toESM(require_deprecated(), 1); 1004 1005 // packages/compose/build-module/higher-order/with-global-events/listener.mjs 1006 var Listener = class { 1007 constructor() { 1008 this.listeners = {}; 1009 this.handleEvent = this.handleEvent.bind(this); 1010 } 1011 add(eventType, instance) { 1012 if (!this.listeners[eventType]) { 1013 window.addEventListener(eventType, this.handleEvent); 1014 this.listeners[eventType] = []; 1015 } 1016 this.listeners[eventType].push(instance); 1017 } 1018 remove(eventType, instance) { 1019 if (!this.listeners[eventType]) { 1020 return; 1021 } 1022 this.listeners[eventType] = this.listeners[eventType].filter( 1023 (listener2) => listener2 !== instance 1024 ); 1025 if (!this.listeners[eventType].length) { 1026 window.removeEventListener(eventType, this.handleEvent); 1027 delete this.listeners[eventType]; 1028 } 1029 } 1030 handleEvent(event) { 1031 this.listeners[event.type]?.forEach( 1032 (instance) => { 1033 instance.handleEvent(event); 1034 } 1035 ); 1036 } 1037 }; 1038 var listener_default = Listener; 1039 1040 // packages/compose/build-module/higher-order/with-global-events/index.mjs 1041 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 1042 var listener = new listener_default(); 1043 function withGlobalEvents(eventTypesToHandlers) { 1044 (0, import_deprecated2.default)("wp.compose.withGlobalEvents", { 1045 since: "5.7", 1046 alternative: "useEffect" 1047 }); 1048 return createHigherOrderComponent((WrappedComponent) => { 1049 class Wrapper extends import_element2.Component { 1050 constructor(props) { 1051 super(props); 1052 this.handleEvent = this.handleEvent.bind(this); 1053 this.handleRef = this.handleRef.bind(this); 1054 } 1055 componentDidMount() { 1056 Object.keys(eventTypesToHandlers).forEach((eventType) => { 1057 listener.add(eventType, this); 1058 }); 1059 } 1060 componentWillUnmount() { 1061 Object.keys(eventTypesToHandlers).forEach((eventType) => { 1062 listener.remove(eventType, this); 1063 }); 1064 } 1065 handleEvent(event) { 1066 const handler = eventTypesToHandlers[ 1067 /** @type {keyof GlobalEventHandlersEventMap} */ 1068 event.type 1069 ]; 1070 if (typeof this.wrappedRef[handler] === "function") { 1071 this.wrappedRef[handler](event); 1072 } 1073 } 1074 handleRef(el) { 1075 this.wrappedRef = el; 1076 if (this.props.forwardedRef) { 1077 this.props.forwardedRef(el); 1078 } 1079 } 1080 render() { 1081 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( 1082 WrappedComponent, 1083 { 1084 ...this.props.ownProps, 1085 ref: this.handleRef 1086 } 1087 ); 1088 } 1089 } 1090 return (0, import_element2.forwardRef)((props, ref) => { 1091 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Wrapper, { ownProps: props, forwardedRef: ref }); 1092 }); 1093 }, "withGlobalEvents"); 1094 } 1095 1096 // packages/compose/build-module/hooks/use-instance-id/index.mjs 1097 var import_element3 = __toESM(require_element(), 1); 1098 var instanceMap = /* @__PURE__ */ new WeakMap(); 1099 function createId(object) { 1100 const instances = instanceMap.get(object) || 0; 1101 instanceMap.set(object, instances + 1); 1102 return instances; 1103 } 1104 function useInstanceId(object, prefix, preferredId) { 1105 return (0, import_element3.useMemo)(() => { 1106 if (preferredId) { 1107 return preferredId; 1108 } 1109 const id = createId(object); 1110 return prefix ? `$prefix}-$id}` : id; 1111 }, [object, preferredId, prefix]); 1112 } 1113 var use_instance_id_default = useInstanceId; 1114 1115 // packages/compose/build-module/higher-order/with-instance-id/index.mjs 1116 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 1117 var withInstanceId = createHigherOrderComponent( 1118 (WrappedComponent) => { 1119 return (props) => { 1120 const instanceId = use_instance_id_default(WrappedComponent); 1121 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WrappedComponent, { ...props, instanceId }); 1122 }; 1123 }, 1124 "instanceId" 1125 ); 1126 var with_instance_id_default = withInstanceId; 1127 1128 // packages/compose/build-module/higher-order/with-safe-timeout/index.mjs 1129 var import_element4 = __toESM(require_element(), 1); 1130 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 1131 var withSafeTimeout = createHigherOrderComponent( 1132 (OriginalComponent) => { 1133 return class WrappedComponent extends import_element4.Component { 1134 timeouts; 1135 constructor(props) { 1136 super(props); 1137 this.timeouts = []; 1138 this.setTimeout = this.setTimeout.bind(this); 1139 this.clearTimeout = this.clearTimeout.bind(this); 1140 } 1141 componentWillUnmount() { 1142 this.timeouts.forEach(clearTimeout); 1143 } 1144 setTimeout(fn, delay) { 1145 const id = setTimeout(() => { 1146 fn(); 1147 this.clearTimeout(id); 1148 }, delay); 1149 this.timeouts.push(id); 1150 return id; 1151 } 1152 clearTimeout(id) { 1153 clearTimeout(id); 1154 this.timeouts = this.timeouts.filter( 1155 (timeoutId) => timeoutId !== id 1156 ); 1157 } 1158 render() { 1159 return ( 1160 // @ts-ignore 1161 /* @__PURE__ */ (0, import_jsx_runtime5.jsx)( 1162 OriginalComponent, 1163 { 1164 ...this.props, 1165 setTimeout: this.setTimeout, 1166 clearTimeout: this.clearTimeout 1167 } 1168 ) 1169 ); 1170 } 1171 }; 1172 }, 1173 "withSafeTimeout" 1174 ); 1175 var with_safe_timeout_default = withSafeTimeout; 1176 1177 // packages/compose/build-module/higher-order/with-state/index.mjs 1178 var import_element5 = __toESM(require_element(), 1); 1179 var import_deprecated3 = __toESM(require_deprecated(), 1); 1180 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 1181 function withState(initialState = {}) { 1182 (0, import_deprecated3.default)("wp.compose.withState", { 1183 since: "5.8", 1184 alternative: "wp.element.useState" 1185 }); 1186 return createHigherOrderComponent((OriginalComponent) => { 1187 return class WrappedComponent extends import_element5.Component { 1188 constructor(props) { 1189 super(props); 1190 this.setState = this.setState.bind(this); 1191 this.state = initialState; 1192 } 1193 render() { 1194 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)( 1195 OriginalComponent, 1196 { 1197 ...this.props, 1198 ...this.state, 1199 setState: this.setState 1200 } 1201 ); 1202 } 1203 }; 1204 }, "withState"); 1205 } 1206 1207 // packages/compose/build-module/hooks/use-constrained-tabbing/index.mjs 1208 var import_dom = __toESM(require_dom(), 1); 1209 1210 // packages/compose/build-module/hooks/use-ref-effect/index.mjs 1211 var import_element6 = __toESM(require_element(), 1); 1212 function useRefEffect(callback, dependencies) { 1213 const cleanupRef = (0, import_element6.useRef)(void 0); 1214 return (0, import_element6.useCallback)((node) => { 1215 if (node) { 1216 cleanupRef.current = callback(node); 1217 } else if (cleanupRef.current) { 1218 cleanupRef.current(); 1219 } 1220 }, dependencies); 1221 } 1222 1223 // packages/compose/build-module/hooks/use-constrained-tabbing/index.mjs 1224 function useConstrainedTabbing() { 1225 return useRefEffect((node) => { 1226 function onKeyDown(event) { 1227 const { key, shiftKey, target } = event; 1228 if (key !== "Tab") { 1229 return; 1230 } 1231 const action = shiftKey ? "findPrevious" : "findNext"; 1232 const nextElement = import_dom.focus.tabbable[action]( 1233 /** @type {HTMLElement} */ 1234 target 1235 ) || null; 1236 if ( 1237 /** @type {HTMLElement} */ 1238 target.contains(nextElement) 1239 ) { 1240 event.preventDefault(); 1241 nextElement?.focus(); 1242 return; 1243 } 1244 if (node.contains(nextElement)) { 1245 return; 1246 } 1247 const domAction = shiftKey ? "append" : "prepend"; 1248 const { ownerDocument } = node; 1249 const trap = ownerDocument.createElement("div"); 1250 trap.tabIndex = -1; 1251 node[domAction](trap); 1252 trap.addEventListener("blur", () => node.removeChild(trap)); 1253 trap.focus(); 1254 } 1255 node.addEventListener("keydown", onKeyDown); 1256 return () => { 1257 node.removeEventListener("keydown", onKeyDown); 1258 }; 1259 }, []); 1260 } 1261 var use_constrained_tabbing_default = useConstrainedTabbing; 1262 1263 // packages/compose/build-module/hooks/use-copy-on-click/index.mjs 1264 var import_element8 = __toESM(require_element(), 1); 1265 var import_deprecated4 = __toESM(require_deprecated(), 1); 1266 1267 // packages/compose/build-module/hooks/use-copy-to-clipboard/index.mjs 1268 var import_element7 = __toESM(require_element(), 1); 1269 async function copyToClipboard(text, trigger) { 1270 if (!trigger) { 1271 return false; 1272 } 1273 const { ownerDocument } = trigger; 1274 if (!ownerDocument) { 1275 return false; 1276 } 1277 const { defaultView } = ownerDocument; 1278 try { 1279 if (defaultView?.navigator?.clipboard?.writeText) { 1280 await defaultView.navigator.clipboard.writeText(text); 1281 return true; 1282 } 1283 const textarea = ownerDocument.createElement("textarea"); 1284 textarea.value = text; 1285 textarea.setAttribute("readonly", ""); 1286 textarea.style.position = "fixed"; 1287 textarea.style.left = "-9999px"; 1288 textarea.style.top = "-9999px"; 1289 ownerDocument.body.appendChild(textarea); 1290 textarea.select(); 1291 const success = ownerDocument.execCommand("copy"); 1292 textarea.remove(); 1293 return success; 1294 } catch { 1295 return false; 1296 } 1297 } 1298 function restoreFocus(trigger) { 1299 if ("focus" in trigger && typeof trigger.focus === "function") { 1300 trigger.focus(); 1301 } 1302 } 1303 function useUpdatedRef(value) { 1304 const ref = (0, import_element7.useRef)(value); 1305 (0, import_element7.useLayoutEffect)(() => { 1306 ref.current = value; 1307 }, [value]); 1308 return ref; 1309 } 1310 function useCopyToClipboard(text, onSuccess) { 1311 const textRef = useUpdatedRef(text); 1312 const onSuccessRef = useUpdatedRef(onSuccess); 1313 return useRefEffect((node) => { 1314 let isActive = true; 1315 const handleClick = async () => { 1316 const textToCopy = typeof textRef.current === "function" ? textRef.current() : textRef.current || ""; 1317 const success = await copyToClipboard(textToCopy, node); 1318 if (success) { 1319 if (isActive) { 1320 restoreFocus(node); 1321 } 1322 if (onSuccessRef.current) { 1323 onSuccessRef.current(); 1324 } 1325 } 1326 }; 1327 node.addEventListener("click", handleClick); 1328 return () => { 1329 isActive = false; 1330 node.removeEventListener("click", handleClick); 1331 }; 1332 }, []); 1333 } 1334 1335 // packages/compose/build-module/hooks/use-copy-on-click/index.mjs 1336 function useCopyOnClick(ref, text, timeout = 4e3) { 1337 (0, import_deprecated4.default)("wp.compose.useCopyOnClick", { 1338 since: "5.8", 1339 alternative: "wp.compose.useCopyToClipboard" 1340 }); 1341 const [hasCopied, setHasCopied] = (0, import_element8.useState)(false); 1342 (0, import_element8.useEffect)(() => { 1343 let isActive = true; 1344 let timeoutId; 1345 if (!ref.current) { 1346 return; 1347 } 1348 let targets; 1349 if (typeof ref.current === "string") { 1350 targets = typeof document !== "undefined" ? Array.from(document.querySelectorAll(ref.current)) : []; 1351 } else if ("length" in ref.current && typeof ref.current.length === "number") { 1352 targets = Array.from(ref.current); 1353 } else { 1354 targets = [ref.current]; 1355 } 1356 if (targets.length === 0) { 1357 return; 1358 } 1359 const handleClick = async (event) => { 1360 const trigger = event.currentTarget; 1361 if (!trigger) { 1362 return; 1363 } 1364 const success = await copyToClipboard( 1365 typeof text === "function" ? text() : text || "", 1366 trigger 1367 ); 1368 if (!isActive) { 1369 return; 1370 } 1371 if (success) { 1372 restoreFocus(trigger); 1373 if (timeout) { 1374 setHasCopied(true); 1375 clearTimeout(timeoutId); 1376 timeoutId = setTimeout( 1377 () => setHasCopied(false), 1378 timeout 1379 ); 1380 } 1381 } 1382 }; 1383 for (const target of targets) { 1384 target.addEventListener("click", handleClick); 1385 } 1386 return () => { 1387 isActive = false; 1388 for (const target of targets) { 1389 target.removeEventListener("click", handleClick); 1390 } 1391 clearTimeout(timeoutId); 1392 }; 1393 }, [ref, text, timeout]); 1394 return hasCopied; 1395 } 1396 1397 // packages/compose/build-module/hooks/use-dialog/index.mjs 1398 var import_element13 = __toESM(require_element(), 1); 1399 1400 // packages/compose/build-module/hooks/use-focus-on-mount/index.mjs 1401 var import_dom2 = __toESM(require_dom(), 1); 1402 var import_element9 = __toESM(require_element(), 1); 1403 function useFocusOnMount(focusOnMount = "firstElement") { 1404 const focusOnMountRef = (0, import_element9.useRef)(focusOnMount); 1405 const setFocus = (target) => { 1406 target.focus({ 1407 // When focusing newly mounted dialogs, 1408 // the position of the popover is often not right on the first render 1409 // This prevents the layout shifts when focusing the dialogs. 1410 preventScroll: true 1411 }); 1412 }; 1413 (0, import_element9.useEffect)(() => { 1414 focusOnMountRef.current = focusOnMount; 1415 }, [focusOnMount]); 1416 return useRefEffect((node) => { 1417 if (focusOnMountRef.current === false) { 1418 return; 1419 } 1420 if (node.contains(node.ownerDocument?.activeElement ?? null)) { 1421 return; 1422 } 1423 if (focusOnMountRef.current !== "firstElement" && focusOnMountRef.current !== "firstInputElement") { 1424 setFocus(node); 1425 return; 1426 } 1427 const timerId = setTimeout(() => { 1428 if (focusOnMountRef.current === "firstInputElement") { 1429 const formInput = node.querySelector( 1430 'input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled])' 1431 ); 1432 if (formInput) { 1433 setFocus(formInput); 1434 return; 1435 } 1436 } 1437 const firstTabbable = import_dom2.focus.tabbable.find(node)[0]; 1438 if (firstTabbable) { 1439 setFocus(firstTabbable); 1440 } 1441 }, 0); 1442 return () => { 1443 clearTimeout(timerId); 1444 }; 1445 }, []); 1446 } 1447 1448 // packages/compose/build-module/hooks/use-focus-return/index.mjs 1449 var import_element10 = __toESM(require_element(), 1); 1450 var origin = null; 1451 function useFocusReturn(onFocusReturn) { 1452 const ref = (0, import_element10.useRef)(null); 1453 const focusedBeforeMount = (0, import_element10.useRef)(null); 1454 const onFocusReturnRef = (0, import_element10.useRef)(onFocusReturn); 1455 (0, import_element10.useEffect)(() => { 1456 onFocusReturnRef.current = onFocusReturn; 1457 }, [onFocusReturn]); 1458 return (0, import_element10.useCallback)((node) => { 1459 if (node) { 1460 ref.current = node; 1461 if (focusedBeforeMount.current) { 1462 return; 1463 } 1464 const activeDocument = node.ownerDocument.activeElement instanceof window.HTMLIFrameElement ? node.ownerDocument.activeElement.contentDocument : node.ownerDocument; 1465 focusedBeforeMount.current = activeDocument?.activeElement ?? null; 1466 } else if (focusedBeforeMount.current) { 1467 const isFocused = ref.current?.contains( 1468 ref.current?.ownerDocument.activeElement 1469 ); 1470 if (ref.current?.isConnected && !isFocused) { 1471 origin ??= focusedBeforeMount.current; 1472 return; 1473 } 1474 if (onFocusReturnRef.current) { 1475 onFocusReturnRef.current(); 1476 } else { 1477 (!focusedBeforeMount.current.isConnected ? origin : focusedBeforeMount.current)?.focus(); 1478 } 1479 origin = null; 1480 } 1481 }, []); 1482 } 1483 var use_focus_return_default = useFocusReturn; 1484 1485 // packages/compose/build-module/hooks/use-focus-outside/index.mjs 1486 var import_element11 = __toESM(require_element(), 1); 1487 var INPUT_BUTTON_TYPES = ["button", "submit"]; 1488 function isFocusNormalizedButton(eventTarget) { 1489 if (!(eventTarget instanceof window.HTMLElement)) { 1490 return false; 1491 } 1492 switch (eventTarget.nodeName) { 1493 case "A": 1494 case "BUTTON": 1495 return true; 1496 case "INPUT": 1497 return INPUT_BUTTON_TYPES.includes( 1498 eventTarget.type 1499 ); 1500 } 1501 return false; 1502 } 1503 function useFocusOutside(onFocusOutside) { 1504 const currentOnFocusOutsideRef = (0, import_element11.useRef)(onFocusOutside); 1505 (0, import_element11.useEffect)(() => { 1506 currentOnFocusOutsideRef.current = onFocusOutside; 1507 }, [onFocusOutside]); 1508 const preventBlurCheckRef = (0, import_element11.useRef)(false); 1509 const blurCheckTimeoutIdRef = (0, import_element11.useRef)(void 0); 1510 const cancelBlurCheck = (0, import_element11.useCallback)(() => { 1511 clearTimeout(blurCheckTimeoutIdRef.current); 1512 }, []); 1513 (0, import_element11.useEffect)(() => { 1514 if (!onFocusOutside) { 1515 cancelBlurCheck(); 1516 } 1517 }, [onFocusOutside, cancelBlurCheck]); 1518 const normalizeButtonFocus = (0, import_element11.useCallback)((event) => { 1519 const { type, target } = event; 1520 const isInteractionEnd = ["mouseup", "touchend"].includes(type); 1521 if (isInteractionEnd) { 1522 preventBlurCheckRef.current = false; 1523 } else if (isFocusNormalizedButton(target)) { 1524 preventBlurCheckRef.current = true; 1525 } 1526 }, []); 1527 const queueBlurCheck = (0, import_element11.useCallback)((event) => { 1528 event.persist(); 1529 if (preventBlurCheckRef.current) { 1530 return; 1531 } 1532 const ignoreForRelatedTarget = event.target.getAttribute( 1533 "data-unstable-ignore-focus-outside-for-relatedtarget" 1534 ); 1535 if (ignoreForRelatedTarget && event.relatedTarget?.closest(ignoreForRelatedTarget)) { 1536 return; 1537 } 1538 blurCheckTimeoutIdRef.current = setTimeout(() => { 1539 if (!document.hasFocus()) { 1540 event.preventDefault(); 1541 return; 1542 } 1543 if ("function" === typeof currentOnFocusOutsideRef.current) { 1544 currentOnFocusOutsideRef.current(event); 1545 } 1546 }, 0); 1547 }, []); 1548 return { 1549 onFocus: cancelBlurCheck, 1550 onMouseDown: normalizeButtonFocus, 1551 onMouseUp: normalizeButtonFocus, 1552 onTouchStart: normalizeButtonFocus, 1553 onTouchEnd: normalizeButtonFocus, 1554 onBlur: queueBlurCheck 1555 }; 1556 } 1557 1558 // packages/compose/build-module/hooks/use-merge-refs/index.mjs 1559 var import_element12 = __toESM(require_element(), 1); 1560 function assignRef(ref, value) { 1561 if (typeof ref === "function") { 1562 const returned = ref(value); 1563 return typeof returned === "function" ? returned : void 0; 1564 } else if (ref && ref.hasOwnProperty("current")) { 1565 ref.current = value; 1566 } 1567 return void 0; 1568 } 1569 function detachRef(ref, index, cleanups) { 1570 const cleanup = cleanups[index]; 1571 if (cleanup) { 1572 cleanups[index] = void 0; 1573 cleanup(); 1574 } else { 1575 assignRef(ref, null); 1576 } 1577 } 1578 function useMergeRefs(refs) { 1579 const elementRef = (0, import_element12.useRef)(null); 1580 const isAttachedRef = (0, import_element12.useRef)(false); 1581 const didElementChangeRef = (0, import_element12.useRef)(false); 1582 const previousRefsRef = (0, import_element12.useRef)([]); 1583 const currentRefsRef = (0, import_element12.useRef)(refs); 1584 const cleanupsRef = (0, import_element12.useRef)([]); 1585 currentRefsRef.current = refs; 1586 (0, import_element12.useLayoutEffect)(() => { 1587 if (didElementChangeRef.current === false && isAttachedRef.current === true) { 1588 refs.forEach((ref, index) => { 1589 const previousRef = previousRefsRef.current[index]; 1590 if (ref !== previousRef) { 1591 detachRef(previousRef, index, cleanupsRef.current); 1592 cleanupsRef.current[index] = assignRef( 1593 ref, 1594 elementRef.current 1595 ); 1596 } 1597 }); 1598 } 1599 previousRefsRef.current = refs; 1600 }, refs); 1601 (0, import_element12.useLayoutEffect)(() => { 1602 didElementChangeRef.current = false; 1603 }); 1604 return (0, import_element12.useCallback)((value) => { 1605 elementRef.current = value; 1606 didElementChangeRef.current = true; 1607 isAttachedRef.current = value !== null; 1608 if (value === null) { 1609 previousRefsRef.current.forEach((ref, index) => { 1610 detachRef(ref, index, cleanupsRef.current); 1611 }); 1612 } else { 1613 currentRefsRef.current.forEach((ref, index) => { 1614 cleanupsRef.current[index] = assignRef(ref, value); 1615 }); 1616 } 1617 }, []); 1618 } 1619 1620 // packages/compose/build-module/hooks/use-dialog/index.mjs 1621 function useDialog(options) { 1622 const currentOptions = (0, import_element13.useRef)(void 0); 1623 const { constrainTabbing = options.focusOnMount !== false } = options; 1624 (0, import_element13.useEffect)(() => { 1625 currentOptions.current = options; 1626 }, Object.values(options)); 1627 const constrainedTabbingRef = use_constrained_tabbing_default(); 1628 const focusOnMountRef = useFocusOnMount(options.focusOnMount); 1629 const focusReturnRef = use_focus_return_default(); 1630 const focusOutsideProps = useFocusOutside((event) => { 1631 if (currentOptions.current?.__unstableOnClose) { 1632 currentOptions.current.__unstableOnClose("focus-outside", event); 1633 } else if (currentOptions.current?.onClose) { 1634 currentOptions.current.onClose(); 1635 } 1636 }); 1637 const onKeyDown = (0, import_element13.useCallback)((event) => { 1638 currentOptions.current?.onKeyDown?.(event); 1639 if (event.key === "Escape" && !event.defaultPrevented && currentOptions.current?.onClose) { 1640 event.preventDefault(); 1641 event.stopPropagation(); 1642 currentOptions.current.onClose(); 1643 } 1644 }, []); 1645 return [ 1646 useMergeRefs([ 1647 constrainTabbing ? constrainedTabbingRef : null, 1648 options.focusOnMount !== false ? focusReturnRef : null, 1649 options.focusOnMount !== false ? focusOnMountRef : null 1650 ]), 1651 { 1652 ...focusOutsideProps, 1653 onKeyDown, 1654 tabIndex: -1 1655 } 1656 ]; 1657 } 1658 var use_dialog_default = useDialog; 1659 1660 // packages/compose/build-module/hooks/use-disabled/index.mjs 1661 function useDisabled({ 1662 isDisabled: isDisabledProp = false 1663 } = {}) { 1664 return useRefEffect( 1665 (node) => { 1666 if (isDisabledProp) { 1667 return; 1668 } 1669 const defaultView = node?.ownerDocument?.defaultView; 1670 if (!defaultView) { 1671 return; 1672 } 1673 const updates = []; 1674 const disable = () => { 1675 node.childNodes.forEach((child) => { 1676 if (!(child instanceof defaultView.HTMLElement)) { 1677 return; 1678 } 1679 if (!child.getAttribute("inert")) { 1680 child.setAttribute("inert", "true"); 1681 updates.push(() => { 1682 child.removeAttribute("inert"); 1683 }); 1684 } 1685 }); 1686 }; 1687 const debouncedDisable = debounce(disable, 0, { 1688 leading: true 1689 }); 1690 disable(); 1691 const observer = new window.MutationObserver(debouncedDisable); 1692 observer.observe(node, { 1693 childList: true 1694 }); 1695 return () => { 1696 if (observer) { 1697 observer.disconnect(); 1698 } 1699 debouncedDisable.cancel(); 1700 updates.forEach((update) => update()); 1701 }; 1702 }, 1703 [isDisabledProp] 1704 ); 1705 } 1706 1707 // packages/compose/build-module/hooks/use-event/index.mjs 1708 var import_element14 = __toESM(require_element(), 1); 1709 function useEvent(callback) { 1710 const ref = (0, import_element14.useRef)(() => { 1711 throw new Error( 1712 "Callbacks created with `useEvent` cannot be called during rendering." 1713 ); 1714 }); 1715 (0, import_element14.useInsertionEffect)(() => { 1716 ref.current = callback; 1717 }); 1718 return (0, import_element14.useCallback)( 1719 (...args) => ref.current?.(...args), 1720 [] 1721 ); 1722 } 1723 1724 // packages/compose/build-module/hooks/use-dragging/index.mjs 1725 var import_element16 = __toESM(require_element(), 1); 1726 1727 // packages/compose/build-module/hooks/use-isomorphic-layout-effect/index.mjs 1728 var import_element15 = __toESM(require_element(), 1); 1729 var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_element15.useLayoutEffect : import_element15.useEffect; 1730 var use_isomorphic_layout_effect_default = useIsomorphicLayoutEffect; 1731 1732 // packages/compose/build-module/hooks/use-dragging/index.mjs 1733 function useDragging({ onDragStart, onDragMove, onDragEnd }) { 1734 const [isDragging, setIsDragging] = (0, import_element16.useState)(false); 1735 const eventsRef = (0, import_element16.useRef)({ 1736 onDragStart, 1737 onDragMove, 1738 onDragEnd 1739 }); 1740 use_isomorphic_layout_effect_default(() => { 1741 eventsRef.current.onDragStart = onDragStart; 1742 eventsRef.current.onDragMove = onDragMove; 1743 eventsRef.current.onDragEnd = onDragEnd; 1744 }, [onDragStart, onDragMove, onDragEnd]); 1745 const onMouseMove = (0, import_element16.useCallback)( 1746 (event) => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event), 1747 [] 1748 ); 1749 const endDrag = (0, import_element16.useCallback)((event) => { 1750 if (eventsRef.current.onDragEnd) { 1751 eventsRef.current.onDragEnd(event); 1752 } 1753 document.removeEventListener("mousemove", onMouseMove); 1754 document.removeEventListener("mouseup", endDrag); 1755 setIsDragging(false); 1756 }, []); 1757 const startDrag = (0, import_element16.useCallback)((event) => { 1758 if (eventsRef.current.onDragStart) { 1759 eventsRef.current.onDragStart(event); 1760 } 1761 document.addEventListener("mousemove", onMouseMove); 1762 document.addEventListener("mouseup", endDrag); 1763 setIsDragging(true); 1764 }, []); 1765 (0, import_element16.useEffect)(() => { 1766 return () => { 1767 if (isDragging) { 1768 document.removeEventListener("mousemove", onMouseMove); 1769 document.removeEventListener("mouseup", endDrag); 1770 } 1771 }; 1772 }, [isDragging]); 1773 return { 1774 startDrag, 1775 endDrag, 1776 isDragging 1777 }; 1778 } 1779 1780 // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs 1781 var import_mousetrap = __toESM(require_mousetrap(), 1); 1782 1783 // node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js 1784 (function(Mousetrap3) { 1785 if (!Mousetrap3) { 1786 return; 1787 } 1788 var _globalCallbacks = {}; 1789 var _originalStopCallback = Mousetrap3.prototype.stopCallback; 1790 Mousetrap3.prototype.stopCallback = function(e, element, combo, sequence) { 1791 var self = this; 1792 if (self.paused) { 1793 return true; 1794 } 1795 if (_globalCallbacks[combo] || _globalCallbacks[sequence]) { 1796 return false; 1797 } 1798 return _originalStopCallback.call(self, e, element, combo); 1799 }; 1800 Mousetrap3.prototype.bindGlobal = function(keys, callback, action) { 1801 var self = this; 1802 self.bind(keys, callback, action); 1803 if (keys instanceof Array) { 1804 for (var i = 0; i < keys.length; i++) { 1805 _globalCallbacks[keys[i]] = true; 1806 } 1807 return; 1808 } 1809 _globalCallbacks[keys] = true; 1810 }; 1811 Mousetrap3.init(); 1812 })(typeof Mousetrap !== "undefined" ? Mousetrap : void 0); 1813 1814 // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs 1815 var import_element17 = __toESM(require_element(), 1); 1816 var import_keycodes = __toESM(require_keycodes(), 1); 1817 function useKeyboardShortcut(shortcuts, callback, { 1818 bindGlobal = false, 1819 eventName = "keydown", 1820 isDisabled = false, 1821 // This is important for performance considerations. 1822 target 1823 } = {}) { 1824 const currentCallbackRef = (0, import_element17.useRef)(callback); 1825 (0, import_element17.useEffect)(() => { 1826 currentCallbackRef.current = callback; 1827 }, [callback]); 1828 (0, import_element17.useEffect)(() => { 1829 if (isDisabled) { 1830 return; 1831 } 1832 const mousetrap = new import_mousetrap.default( 1833 target && target.current ? target.current : ( 1834 // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`. 1835 // 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 1836 // necessary to maintain the existing behavior. 1837 /** @type {Element} */ 1838 /** @type {unknown} */ 1839 document 1840 ) 1841 ); 1842 const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts]; 1843 shortcutsArray.forEach((shortcut) => { 1844 const keys = shortcut.split("+"); 1845 const modifiers = new Set( 1846 keys.filter((value) => value.length > 1) 1847 ); 1848 const hasAlt = modifiers.has("alt"); 1849 const hasShift = modifiers.has("shift"); 1850 if ((0, import_keycodes.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) { 1851 throw new Error( 1852 `Cannot bind $shortcut}. Alt and Shift+Alt modifiers are reserved for character input.` 1853 ); 1854 } 1855 const bindFn = bindGlobal ? "bindGlobal" : "bind"; 1856 mousetrap[bindFn]( 1857 shortcut, 1858 (...args) => currentCallbackRef.current(...args), 1859 eventName 1860 ); 1861 }); 1862 return () => { 1863 mousetrap.reset(); 1864 }; 1865 }, [shortcuts, bindGlobal, eventName, target, isDisabled]); 1866 } 1867 var use_keyboard_shortcut_default = useKeyboardShortcut; 1868 1869 // packages/compose/build-module/hooks/use-media-query/index.mjs 1870 var import_element18 = __toESM(require_element(), 1); 1871 var perWindowCache = /* @__PURE__ */ new WeakMap(); 1872 var EMPTY_SUBSCRIBER = { 1873 subscribe: () => () => { 1874 }, 1875 getValue: () => false 1876 }; 1877 function getMQLSubscriber(view, query) { 1878 if (!view || !query || typeof view.matchMedia !== "function") { 1879 return EMPTY_SUBSCRIBER; 1880 } 1881 let queryCache = perWindowCache.get(view); 1882 if (!queryCache) { 1883 queryCache = /* @__PURE__ */ new Map(); 1884 perWindowCache.set(view, queryCache); 1885 } 1886 const cached = queryCache.get(query); 1887 if (cached) { 1888 return cached; 1889 } 1890 const mediaQueryList = view.matchMedia(query); 1891 const listeners = /* @__PURE__ */ new Set(); 1892 const notify = () => { 1893 for (const listener2 of listeners) { 1894 listener2(); 1895 } 1896 }; 1897 const subscriber = { 1898 subscribe(onStoreChange) { 1899 if (listeners.size === 0) { 1900 mediaQueryList.addEventListener?.("change", notify); 1901 } 1902 listeners.add(onStoreChange); 1903 return () => { 1904 listeners.delete(onStoreChange); 1905 if (listeners.size === 0) { 1906 mediaQueryList.removeEventListener?.("change", notify); 1907 } 1908 }; 1909 }, 1910 getValue() { 1911 return mediaQueryList.matches; 1912 } 1913 }; 1914 queryCache.set(query, subscriber); 1915 return subscriber; 1916 } 1917 function useMediaQuery(query, view = typeof window !== "undefined" ? window : void 0) { 1918 const source = getMQLSubscriber(view, query); 1919 return (0, import_element18.useSyncExternalStore)( 1920 source.subscribe, 1921 source.getValue, 1922 () => false 1923 ); 1924 } 1925 1926 // packages/compose/build-module/hooks/use-previous/index.mjs 1927 var import_element19 = __toESM(require_element(), 1); 1928 function usePrevious(value) { 1929 const ref = (0, import_element19.useRef)(void 0); 1930 (0, import_element19.useEffect)(() => { 1931 ref.current = value; 1932 }, [value]); 1933 return ref.current; 1934 } 1935 1936 // packages/compose/build-module/hooks/use-reduced-motion/index.mjs 1937 var useReducedMotion = () => useMediaQuery("(prefers-reduced-motion: reduce)"); 1938 var use_reduced_motion_default = useReducedMotion; 1939 1940 // packages/compose/build-module/hooks/use-state-with-history/index.mjs 1941 var import_undo_manager = __toESM(require_undo_manager(), 1); 1942 var import_element20 = __toESM(require_element(), 1); 1943 function undoRedoReducer(state, action) { 1944 switch (action.type) { 1945 case "UNDO": { 1946 const undoRecord = state.manager.undo(); 1947 if (undoRecord) { 1948 return { 1949 ...state, 1950 value: undoRecord[0].changes.prop.from 1951 }; 1952 } 1953 return state; 1954 } 1955 case "REDO": { 1956 const redoRecord = state.manager.redo(); 1957 if (redoRecord) { 1958 return { 1959 ...state, 1960 value: redoRecord[0].changes.prop.to 1961 }; 1962 } 1963 return state; 1964 } 1965 case "RECORD": { 1966 state.manager.addRecord( 1967 [ 1968 { 1969 id: "object", 1970 changes: { 1971 prop: { from: state.value, to: action.value } 1972 } 1973 } 1974 ], 1975 action.isStaged 1976 ); 1977 return { 1978 ...state, 1979 value: action.value 1980 }; 1981 } 1982 } 1983 return state; 1984 } 1985 function initReducer(value) { 1986 return { 1987 manager: (0, import_undo_manager.createUndoManager)(), 1988 value 1989 }; 1990 } 1991 function useStateWithHistory(initialValue) { 1992 const [state, dispatch] = (0, import_element20.useReducer)( 1993 undoRedoReducer, 1994 initialValue, 1995 initReducer 1996 ); 1997 return { 1998 value: state.value, 1999 setValue: (0, import_element20.useCallback)((newValue, isStaged) => { 2000 dispatch({ 2001 type: "RECORD", 2002 value: newValue, 2003 isStaged 2004 }); 2005 }, []), 2006 hasUndo: state.manager.hasUndo(), 2007 hasRedo: state.manager.hasRedo(), 2008 undo: (0, import_element20.useCallback)(() => { 2009 dispatch({ type: "UNDO" }); 2010 }, []), 2011 redo: (0, import_element20.useCallback)(() => { 2012 dispatch({ type: "REDO" }); 2013 }, []) 2014 }; 2015 } 2016 2017 // packages/compose/build-module/hooks/use-viewport-match/index.mjs 2018 var import_element21 = __toESM(require_element(), 1); 2019 var BREAKPOINTS = { 2020 xhuge: 1920, 2021 huge: 1440, 2022 wide: 1280, 2023 xlarge: 1080, 2024 large: 960, 2025 medium: 782, 2026 small: 600, 2027 mobile: 480 2028 }; 2029 var CONDITIONS = { 2030 ">=": "min-width", 2031 "<": "max-width" 2032 }; 2033 var OPERATOR_EVALUATORS = { 2034 ">=": (breakpointValue, width) => width >= breakpointValue, 2035 "<": (breakpointValue, width) => width < breakpointValue 2036 }; 2037 var ViewportMatchWidthContext = (0, import_element21.createContext)( 2038 /** @type {null | number} */ 2039 null 2040 ); 2041 ViewportMatchWidthContext.displayName = "ViewportMatchWidthContext"; 2042 var useViewportMatch = (breakpoint, operator = ">=", view = typeof window !== "undefined" ? window : void 0) => { 2043 const simulatedWidth = (0, import_element21.useContext)(ViewportMatchWidthContext); 2044 const mediaQuery = !simulatedWidth && `($CONDITIONS[operator]}: $BREAKPOINTS[breakpoint]}px)`; 2045 const mediaQueryResult = useMediaQuery(mediaQuery || void 0, view); 2046 if (simulatedWidth) { 2047 return OPERATOR_EVALUATORS[operator]( 2048 BREAKPOINTS[breakpoint], 2049 simulatedWidth 2050 ); 2051 } 2052 return mediaQueryResult; 2053 }; 2054 useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider; 2055 var use_viewport_match_default = useViewportMatch; 2056 2057 // packages/compose/build-module/hooks/use-resize-observer/use-resize-observer.mjs 2058 var import_element22 = __toESM(require_element(), 1); 2059 function useResizeObserver(callback, resizeObserverOptions = {}) { 2060 const callbackEvent = useEvent(callback); 2061 const observedElementRef = (0, import_element22.useRef)(null); 2062 const resizeObserverRef = (0, import_element22.useRef)(void 0); 2063 return useEvent((element) => { 2064 if (element === observedElementRef.current) { 2065 return; 2066 } 2067 resizeObserverRef.current ??= new ResizeObserver(callbackEvent); 2068 const { current: resizeObserver } = resizeObserverRef; 2069 if (observedElementRef.current) { 2070 resizeObserver.unobserve(observedElementRef.current); 2071 } 2072 observedElementRef.current = element ?? null; 2073 if (element) { 2074 resizeObserver.observe(element, resizeObserverOptions); 2075 } 2076 }); 2077 } 2078 2079 // packages/compose/build-module/hooks/use-resize-observer/legacy/index.mjs 2080 var import_element23 = __toESM(require_element(), 1); 2081 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 2082 var extractSize = (entry) => { 2083 let entrySize; 2084 if (!entry.contentBoxSize) { 2085 entrySize = [entry.contentRect.width, entry.contentRect.height]; 2086 } else if (entry.contentBoxSize[0]) { 2087 const contentBoxSize = entry.contentBoxSize[0]; 2088 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize]; 2089 } else { 2090 const contentBoxSize = entry.contentBoxSize; 2091 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize]; 2092 } 2093 const [width, height] = entrySize.map((d) => Math.round(d)); 2094 return { width, height }; 2095 }; 2096 var RESIZE_ELEMENT_STYLES = { 2097 position: "absolute", 2098 top: 0, 2099 left: 0, 2100 right: 0, 2101 bottom: 0, 2102 pointerEvents: "none", 2103 opacity: 0, 2104 overflow: "hidden", 2105 zIndex: -1 2106 }; 2107 function ResizeElement({ onResize }) { 2108 const resizeElementRef = useResizeObserver((entries) => { 2109 const newSize = extractSize(entries.at(-1)); 2110 onResize(newSize); 2111 }); 2112 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)( 2113 "div", 2114 { 2115 ref: resizeElementRef, 2116 style: RESIZE_ELEMENT_STYLES, 2117 "aria-hidden": "true" 2118 } 2119 ); 2120 } 2121 function sizeEquals(a, b) { 2122 return a.width === b.width && a.height === b.height; 2123 } 2124 var NULL_SIZE = { width: null, height: null }; 2125 function useLegacyResizeObserver() { 2126 const [size, setSize] = (0, import_element23.useState)(NULL_SIZE); 2127 const previousSizeRef = (0, import_element23.useRef)(NULL_SIZE); 2128 const handleResize = (0, import_element23.useCallback)((newSize) => { 2129 if (!sizeEquals(previousSizeRef.current, newSize)) { 2130 previousSizeRef.current = newSize; 2131 setSize(newSize); 2132 } 2133 }, []); 2134 const resizeElement = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ResizeElement, { onResize: handleResize }); 2135 return [resizeElement, size]; 2136 } 2137 2138 // packages/compose/build-module/hooks/use-resize-observer/index.mjs 2139 function useResizeObserver2(callback, options = {}) { 2140 return callback ? useResizeObserver(callback, options) : useLegacyResizeObserver(); 2141 } 2142 2143 // packages/compose/build-module/hooks/use-async-list/index.mjs 2144 var import_element24 = __toESM(require_element(), 1); 2145 var import_priority_queue = __toESM(require_priority_queue(), 1); 2146 function getFirstItemsPresentInState(list, state) { 2147 const firstItems = []; 2148 for (let i = 0; i < list.length; i++) { 2149 const item = list[i]; 2150 if (!state.includes(item)) { 2151 break; 2152 } 2153 firstItems.push(item); 2154 } 2155 return firstItems; 2156 } 2157 function useAsyncList(list, config = { step: 1 }) { 2158 const { step = 1 } = config; 2159 const [current, setCurrent] = (0, import_element24.useState)([]); 2160 (0, import_element24.useEffect)(() => { 2161 let firstItems = getFirstItemsPresentInState(list, current); 2162 if (firstItems.length < step) { 2163 firstItems = firstItems.concat( 2164 list.slice(firstItems.length, step) 2165 ); 2166 } 2167 setCurrent(firstItems); 2168 const asyncQueue = (0, import_priority_queue.createQueue)(); 2169 for (let i = firstItems.length; i < list.length; i += step) { 2170 asyncQueue.add({}, () => { 2171 (0, import_element24.flushSync)(() => { 2172 setCurrent((state) => [ 2173 ...state, 2174 ...list.slice(i, i + step) 2175 ]); 2176 }); 2177 }); 2178 } 2179 return () => asyncQueue.reset(); 2180 }, [list]); 2181 return current; 2182 } 2183 var use_async_list_default = useAsyncList; 2184 2185 // packages/compose/build-module/hooks/use-warn-on-change/index.mjs 2186 function useWarnOnChange(object, prefix = "Change detection") { 2187 const previousValues = usePrevious(object); 2188 Object.entries(previousValues ?? []).forEach(([key, value]) => { 2189 if (value !== object[ 2190 /** @type {keyof typeof object} */ 2191 key 2192 ]) { 2193 console.warn( 2194 `$prefix}: $key} key changed:`, 2195 value, 2196 object[ 2197 /** @type {keyof typeof object} */ 2198 key 2199 ] 2200 /* eslint-enable jsdoc/check-types */ 2201 ); 2202 } 2203 }); 2204 } 2205 var use_warn_on_change_default = useWarnOnChange; 2206 2207 // node_modules/use-memo-one/dist/use-memo-one.esm.js 2208 var import_react = __toESM(require_react()); 2209 function areInputsEqual(newInputs, lastInputs) { 2210 if (newInputs.length !== lastInputs.length) { 2211 return false; 2212 } 2213 for (var i = 0; i < newInputs.length; i++) { 2214 if (newInputs[i] !== lastInputs[i]) { 2215 return false; 2216 } 2217 } 2218 return true; 2219 } 2220 function useMemoOne(getResult, inputs) { 2221 var initial = (0, import_react.useState)(function() { 2222 return { 2223 inputs, 2224 result: getResult() 2225 }; 2226 })[0]; 2227 var committed = (0, import_react.useRef)(initial); 2228 var isInputMatch = Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); 2229 var cache = isInputMatch ? committed.current : { 2230 inputs, 2231 result: getResult() 2232 }; 2233 (0, import_react.useEffect)(function() { 2234 committed.current = cache; 2235 }, [cache]); 2236 return cache.result; 2237 } 2238 2239 // packages/compose/build-module/hooks/use-debounce/index.mjs 2240 var import_element25 = __toESM(require_element(), 1); 2241 function useDebounce(fn, wait, options) { 2242 const debounced = useMemoOne( 2243 () => debounce(fn, wait ?? 0, options), 2244 [fn, wait, options?.leading, options?.trailing, options?.maxWait] 2245 ); 2246 (0, import_element25.useEffect)(() => () => debounced.cancel(), [debounced]); 2247 return debounced; 2248 } 2249 2250 // packages/compose/build-module/hooks/use-debounced-input/index.mjs 2251 var import_element26 = __toESM(require_element(), 1); 2252 function useDebouncedInput(defaultValue = "") { 2253 const [input, setInput] = (0, import_element26.useState)(defaultValue); 2254 const [debouncedInput, setDebouncedState] = (0, import_element26.useState)(defaultValue); 2255 const setDebouncedInput = useDebounce(setDebouncedState, 250); 2256 (0, import_element26.useEffect)(() => { 2257 setDebouncedInput(input); 2258 }, [input, setDebouncedInput]); 2259 return [input, setInput, debouncedInput]; 2260 } 2261 2262 // packages/compose/build-module/hooks/use-throttle/index.mjs 2263 var import_element27 = __toESM(require_element(), 1); 2264 function useThrottle(fn, wait, options) { 2265 const throttled = useMemoOne( 2266 () => throttle(fn, wait ?? 0, options), 2267 [fn, wait, options] 2268 ); 2269 (0, import_element27.useEffect)(() => () => throttled.cancel(), [throttled]); 2270 return throttled; 2271 } 2272 2273 // packages/compose/build-module/hooks/use-drop-zone/index.mjs 2274 function useDropZone({ 2275 dropZoneElement, 2276 isDisabled, 2277 onDrop: _onDrop, 2278 onDragStart: _onDragStart, 2279 onDragEnter: _onDragEnter, 2280 onDragLeave: _onDragLeave, 2281 onDragEnd: _onDragEnd, 2282 onDragOver: _onDragOver 2283 }) { 2284 const onDropEvent = useEvent(_onDrop); 2285 const onDragStartEvent = useEvent(_onDragStart); 2286 const onDragEnterEvent = useEvent(_onDragEnter); 2287 const onDragLeaveEvent = useEvent(_onDragLeave); 2288 const onDragEndEvent = useEvent(_onDragEnd); 2289 const onDragOverEvent = useEvent(_onDragOver); 2290 return useRefEffect( 2291 (elem) => { 2292 if (isDisabled) { 2293 return; 2294 } 2295 const element = dropZoneElement ?? elem; 2296 let isDragging = false; 2297 const { ownerDocument } = element; 2298 function isElementInZone(targetToCheck) { 2299 const { defaultView } = ownerDocument; 2300 if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) { 2301 return false; 2302 } 2303 let elementToCheck = targetToCheck; 2304 do { 2305 if (elementToCheck.dataset.isDropZone) { 2306 return elementToCheck === element; 2307 } 2308 } while (elementToCheck = elementToCheck.parentElement); 2309 return false; 2310 } 2311 function maybeDragStart(event) { 2312 if (isDragging) { 2313 return; 2314 } 2315 isDragging = true; 2316 ownerDocument.addEventListener("dragend", maybeDragEnd); 2317 ownerDocument.addEventListener("mousemove", maybeDragEnd); 2318 if (_onDragStart) { 2319 onDragStartEvent(event); 2320 } 2321 } 2322 function onDragEnter(event) { 2323 event.preventDefault(); 2324 if (element.contains( 2325 /** @type {Node} */ 2326 event.relatedTarget 2327 )) { 2328 return; 2329 } 2330 if (_onDragEnter) { 2331 onDragEnterEvent(event); 2332 } 2333 } 2334 function onDragOver(event) { 2335 if (!event.defaultPrevented && _onDragOver) { 2336 onDragOverEvent(event); 2337 } 2338 event.preventDefault(); 2339 } 2340 function onDragLeave(event) { 2341 if (isElementInZone(event.relatedTarget)) { 2342 return; 2343 } 2344 if (_onDragLeave) { 2345 onDragLeaveEvent(event); 2346 } 2347 } 2348 function onDrop(event) { 2349 if (event.defaultPrevented) { 2350 return; 2351 } 2352 event.preventDefault(); 2353 event.dataTransfer && event.dataTransfer.files.length; 2354 if (_onDrop) { 2355 onDropEvent(event); 2356 } 2357 maybeDragEnd(event); 2358 } 2359 function maybeDragEnd(event) { 2360 if (!isDragging) { 2361 return; 2362 } 2363 isDragging = false; 2364 ownerDocument.removeEventListener("dragend", maybeDragEnd); 2365 ownerDocument.removeEventListener("mousemove", maybeDragEnd); 2366 if (_onDragEnd) { 2367 onDragEndEvent(event); 2368 } 2369 } 2370 element.setAttribute("data-is-drop-zone", "true"); 2371 element.addEventListener("drop", onDrop); 2372 element.addEventListener("dragenter", onDragEnter); 2373 element.addEventListener("dragover", onDragOver); 2374 element.addEventListener("dragleave", onDragLeave); 2375 ownerDocument.addEventListener("dragenter", maybeDragStart); 2376 return () => { 2377 element.removeAttribute("data-is-drop-zone"); 2378 element.removeEventListener("drop", onDrop); 2379 element.removeEventListener("dragenter", onDragEnter); 2380 element.removeEventListener("dragover", onDragOver); 2381 element.removeEventListener("dragleave", onDragLeave); 2382 ownerDocument.removeEventListener("dragend", maybeDragEnd); 2383 ownerDocument.removeEventListener("mousemove", maybeDragEnd); 2384 ownerDocument.removeEventListener( 2385 "dragenter", 2386 maybeDragStart 2387 ); 2388 }; 2389 }, 2390 [isDisabled, dropZoneElement] 2391 // Refresh when the passed in dropZoneElement changes. 2392 ); 2393 } 2394 2395 // packages/compose/build-module/hooks/use-focusable-iframe/index.mjs 2396 function useFocusableIframe() { 2397 return useRefEffect((element) => { 2398 const { ownerDocument } = element; 2399 if (!ownerDocument) { 2400 return; 2401 } 2402 const { defaultView } = ownerDocument; 2403 if (!defaultView) { 2404 return; 2405 } 2406 function checkFocus() { 2407 if (ownerDocument && ownerDocument.activeElement === element) { 2408 element.focus(); 2409 } 2410 } 2411 defaultView.addEventListener("blur", checkFocus); 2412 return () => { 2413 defaultView.removeEventListener("blur", checkFocus); 2414 }; 2415 }, []); 2416 } 2417 2418 // packages/compose/build-module/hooks/use-fixed-window-list/index.mjs 2419 var import_element28 = __toESM(require_element(), 1); 2420 var import_dom3 = __toESM(require_dom(), 1); 2421 var import_keycodes2 = __toESM(require_keycodes(), 1); 2422 var DEFAULT_INIT_WINDOW_SIZE = 30; 2423 function useFixedWindowList(elementRef, itemHeight, totalItems, options) { 2424 const initWindowSize = options?.initWindowSize ?? DEFAULT_INIT_WINDOW_SIZE; 2425 const useWindowing = options?.useWindowing ?? true; 2426 const [fixedListWindow, setFixedListWindow] = (0, import_element28.useState)({ 2427 visibleItems: initWindowSize, 2428 start: 0, 2429 end: initWindowSize, 2430 itemInView: (index) => { 2431 return index >= 0 && index <= initWindowSize; 2432 } 2433 }); 2434 (0, import_element28.useLayoutEffect)(() => { 2435 if (!useWindowing) { 2436 return; 2437 } 2438 const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current); 2439 const measureWindow = (initRender) => { 2440 if (!scrollContainer) { 2441 return; 2442 } 2443 const visibleItems = Math.ceil( 2444 scrollContainer.clientHeight / itemHeight 2445 ); 2446 const windowOverscan = initRender ? visibleItems : options?.windowOverscan ?? visibleItems; 2447 const firstViewableIndex = Math.floor( 2448 scrollContainer.scrollTop / itemHeight 2449 ); 2450 const start = Math.max(0, firstViewableIndex - windowOverscan); 2451 const end = Math.min( 2452 totalItems - 1, 2453 firstViewableIndex + visibleItems + windowOverscan 2454 ); 2455 setFixedListWindow((lastWindow) => { 2456 const nextWindow = { 2457 visibleItems, 2458 start, 2459 end, 2460 itemInView: (index) => { 2461 return start <= index && index <= end; 2462 } 2463 }; 2464 if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) { 2465 return nextWindow; 2466 } 2467 return lastWindow; 2468 }); 2469 }; 2470 measureWindow(true); 2471 const debounceMeasureList = debounce(() => { 2472 measureWindow(); 2473 }, 16); 2474 scrollContainer?.addEventListener("scroll", debounceMeasureList); 2475 scrollContainer?.ownerDocument?.defaultView?.addEventListener( 2476 "resize", 2477 debounceMeasureList 2478 ); 2479 scrollContainer?.ownerDocument?.defaultView?.addEventListener( 2480 "resize", 2481 debounceMeasureList 2482 ); 2483 return () => { 2484 scrollContainer?.removeEventListener( 2485 "scroll", 2486 debounceMeasureList 2487 ); 2488 scrollContainer?.ownerDocument?.defaultView?.removeEventListener( 2489 "resize", 2490 debounceMeasureList 2491 ); 2492 }; 2493 }, [ 2494 itemHeight, 2495 elementRef, 2496 totalItems, 2497 options?.expandedState, 2498 options?.windowOverscan, 2499 useWindowing 2500 ]); 2501 (0, import_element28.useLayoutEffect)(() => { 2502 if (!useWindowing) { 2503 return; 2504 } 2505 const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current); 2506 const handleKeyDown = (event) => { 2507 switch (event.keyCode) { 2508 case import_keycodes2.HOME: { 2509 return scrollContainer?.scrollTo({ top: 0 }); 2510 } 2511 case import_keycodes2.END: { 2512 return scrollContainer?.scrollTo({ 2513 top: totalItems * itemHeight 2514 }); 2515 } 2516 case import_keycodes2.PAGEUP: { 2517 return scrollContainer?.scrollTo({ 2518 top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight 2519 }); 2520 } 2521 case import_keycodes2.PAGEDOWN: { 2522 return scrollContainer?.scrollTo({ 2523 top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight 2524 }); 2525 } 2526 } 2527 }; 2528 scrollContainer?.ownerDocument?.defaultView?.addEventListener( 2529 "keydown", 2530 handleKeyDown 2531 ); 2532 return () => { 2533 scrollContainer?.ownerDocument?.defaultView?.removeEventListener( 2534 "keydown", 2535 handleKeyDown 2536 ); 2537 }; 2538 }, [ 2539 totalItems, 2540 itemHeight, 2541 elementRef, 2542 fixedListWindow.visibleItems, 2543 useWindowing, 2544 options?.expandedState 2545 ]); 2546 return [fixedListWindow, setFixedListWindow]; 2547 } 2548 2549 // packages/compose/build-module/hooks/use-observable-value/index.mjs 2550 var import_element29 = __toESM(require_element(), 1); 2551 function useObservableValue(map, name) { 2552 const [subscribe, getValue] = (0, import_element29.useMemo)( 2553 () => [ 2554 (listener2) => map.subscribe(name, listener2), 2555 () => map.get(name) 2556 ], 2557 [map, name] 2558 ); 2559 return (0, import_element29.useSyncExternalStore)(subscribe, getValue, getValue); 2560 } 2561 return __toCommonJS(index_exports); 2562 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Tue Jul 7 08:20:13 2026 | Cross-referenced by PHPXref |